rc_service_value_set: remove the option if NULL is the value

This allows the equivalent of "unsetting" a value for a service.
This commit is contained in:
William Hubbs 2017-10-26 12:54:37 -05:00
parent 6f3e2e2d7d
commit cf429ee359

View File

@ -894,12 +894,15 @@ rc_service_value_set(const char *service, const char *option,
return false;
snprintf(p, sizeof(file) - (p - file), "/%s", option);
if (!(fp = fopen(file, "w")))
return false;
if (value)
if (value) {
if (!(fp = fopen(file, "w")))
return false;
fprintf(fp, "%s", value);
fclose(fp);
return true;
fclose(fp);
} else {
unlink(file);
}
return true;
}
librc_hidden_def(rc_service_value_set)