commit: cf429ee359356d736c818e8b35db8fca887e7332
Author: William Hubbs <w.d.hubbs <AT> gmail <DOT> com>
AuthorDate: Thu Oct 26 17:54:37 2017 +0000
Commit: William Hubbs <williamh <AT> gentoo <DOT> org>
CommitDate: Thu Oct 26 17:54:37 2017 +0000
URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=cf429ee3
rc_service_value_set: remove the option if NULL is the value
This allows the equivalent of "unsetting" a value for a service.
src/librc/librc.c | 13 ++++++++-----
1 file 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)