aboutsummaryrefslogtreecommitdiff
path: root/src/librc/librc.c
diff options
context:
space:
mode:
authorWilliam Hubbs <w.d.hubbs@gmail.com>2017-10-26 12:54:37 -0500
committerWilliam Hubbs <w.d.hubbs@gmail.com>2017-10-26 12:54:37 -0500
commitcf429ee359356d736c818e8b35db8fca887e7332 (patch)
tree5851e65891253e3cefe9849474887fed8967353e /src/librc/librc.c
parent6f3e2e2d7de61ab28cf03937ccf2e5f80b62190a (diff)
rc_service_value_set: remove the option if NULL is the value
This allows the equivalent of "unsetting" a value for a service.
Diffstat (limited to 'src/librc/librc.c')
-rw-r--r--src/librc/librc.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/librc/librc.c b/src/librc/librc.c
index 84c76b5a..ee65b00a 100644
--- a/src/librc/librc.c
+++ b/src/librc/librc.c
@@ -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)