From cf429ee359356d736c818e8b35db8fca887e7332 Mon Sep 17 00:00:00 2001 From: William Hubbs Date: Thu, 26 Oct 2017 12:54:37 -0500 Subject: 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(-) (limited to 'src') 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) -- cgit v1.2.3