From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from lists.gentoo.org (pigeon.gentoo.org [208.92.234.80]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by finch.gentoo.org (Postfix) with ESMTPS id 3B4321396DA for ; Thu, 26 Oct 2017 18:58:29 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id 5BB57E0C2F; Thu, 26 Oct 2017 18:58:28 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id 2FDD1E0C2F for ; Thu, 26 Oct 2017 18:58:28 +0000 (UTC) Received: from oystercatcher.gentoo.org (unknown [IPv6:2a01:4f8:202:4333:225:90ff:fed9:fc84]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.gentoo.org (Postfix) with ESMTPS id 6C72B33FE49 for ; Thu, 26 Oct 2017 18:58:27 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 2F029831 for ; Thu, 26 Oct 2017 18:58:26 +0000 (UTC) From: "William Hubbs" To: gentoo-commits@lists.gentoo.org Content-Transfer-Encoding: 8bit Content-type: text/plain; charset=UTF-8 Reply-To: gentoo-dev@lists.gentoo.org, "William Hubbs" Message-ID: <1509040477.cf429ee359356d736c818e8b35db8fca887e7332.williamh@OpenRC> Subject: [gentoo-commits] proj/openrc:master commit in: src/librc/ X-VCS-Repository: proj/openrc X-VCS-Files: src/librc/librc.c X-VCS-Directories: src/librc/ X-VCS-Committer: williamh X-VCS-Committer-Name: William Hubbs X-VCS-Revision: cf429ee359356d736c818e8b35db8fca887e7332 X-VCS-Branch: master Date: Thu, 26 Oct 2017 18:58:26 +0000 (UTC) Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-Id: Gentoo Linux mail X-BeenThere: gentoo-commits@lists.gentoo.org X-Archives-Salt: aee8a830-c54c-4f19-afc8-408b1ab48759 X-Archives-Hash: ad1f8a74df03ba89ba4866bf567243f6 commit: cf429ee359356d736c818e8b35db8fca887e7332 Author: William Hubbs gmail com> AuthorDate: Thu Oct 26 17:54:37 2017 +0000 Commit: William Hubbs gentoo 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)