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; return false;
snprintf(p, sizeof(file) - (p - file), "/%s", option); snprintf(p, sizeof(file) - (p - file), "/%s", option);
if (!(fp = fopen(file, "w"))) if (value) {
return false; if (!(fp = fopen(file, "w")))
if (value) return false;
fprintf(fp, "%s", value); fprintf(fp, "%s", value);
fclose(fp); fclose(fp);
return true; } else {
unlink(file);
}
return true;
} }
librc_hidden_def(rc_service_value_set) librc_hidden_def(rc_service_value_set)