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 C6B26139695 for ; Wed, 7 Jun 2017 16:34:41 +0000 (UTC) Received: from pigeon.gentoo.org (localhost [127.0.0.1]) by pigeon.gentoo.org (Postfix) with SMTP id E4CBD21C07F; Wed, 7 Jun 2017 16:34:40 +0000 (UTC) Received: from smtp.gentoo.org (smtp.gentoo.org [140.211.166.183]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by pigeon.gentoo.org (Postfix) with ESMTPS id BFAF721C07F for ; Wed, 7 Jun 2017 16:34:40 +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 52F96341843 for ; Wed, 7 Jun 2017 16:34:39 +0000 (UTC) Received: from localhost.localdomain (localhost [IPv6:::1]) by oystercatcher.gentoo.org (Postfix) with ESMTP id 8E6687452 for ; Wed, 7 Jun 2017 16:34:37 +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: <1496695762.ee886c44824b1dd892eaff2c6da666286e61bc73.williamh@OpenRC> Subject: [gentoo-commits] proj/openrc:master commit in: src/rc/ X-VCS-Repository: proj/openrc X-VCS-Files: src/rc/openrc-shutdown.c X-VCS-Directories: src/rc/ X-VCS-Committer: williamh X-VCS-Committer-Name: William Hubbs X-VCS-Revision: ee886c44824b1dd892eaff2c6da666286e61bc73 X-VCS-Branch: master Date: Wed, 7 Jun 2017 16:34:37 +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: 9715a8bb-46da-45ed-bc04-69593f09119a X-Archives-Hash: 3d36f1a8a25e7076257fe280f70c1cfa commit: ee886c44824b1dd892eaff2c6da666286e61bc73 Author: William Hubbs gmail com> AuthorDate: Mon Jun 5 20:49:22 2017 +0000 Commit: William Hubbs gentoo org> CommitDate: Mon Jun 5 20:49:22 2017 +0000 URL: https://gitweb.gentoo.org/proj/openrc.git/commit/?id=ee886c44 openrc-shutdown: add --single option and clean up option processing src/rc/openrc-shutdown.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/rc/openrc-shutdown.c b/src/rc/openrc-shutdown.c index 4ba619c5..b17a63d8 100644 --- a/src/rc/openrc-shutdown.c +++ b/src/rc/openrc-shutdown.c @@ -37,7 +37,7 @@ const char *applet = NULL; const char *extraopts = NULL; -const char *getoptstring = "dDHKpRrw" getoptstring_COMMON; +const char *getoptstring = "dDHKpRrsw" getoptstring_COMMON; const struct option longopts[] = { { "no-write", no_argument, NULL, 'd'}, { "dry-run", no_argument, NULL, 'D'}, @@ -46,6 +46,7 @@ const struct option longopts[] = { { "poweroff", no_argument, NULL, 'p'}, { "reexec", no_argument, NULL, 'R'}, { "reboot", no_argument, NULL, 'r'}, + { "single", no_argument, NULL, 's'}, { "write-only", no_argument, NULL, 'w'}, longopts_COMMON }; @@ -57,12 +58,13 @@ const char * const longopts_help[] = { "power off the system", "re-execute init (use after upgrading)", "reboot the system", + "single user mode", "write wtmp boot record and exit", longopts_help_COMMON }; const char *usagestring = NULL; const char *exclusive = "Select one of " -"--halt, --kexec, --poweroff, --reexec or --reboot"; +"--halt, --kexec, --poweroff, --reexec, --reboot, --single or --write-only"; static bool do_dryrun = false; static bool do_halt = false; @@ -70,6 +72,7 @@ static bool do_kexec = false; static bool do_poweroff = false; static bool do_reboot = false; static bool do_reexec = false; +static bool do_single = false; static bool do_wtmp = true; static bool do_wtmp_only = false; @@ -132,15 +135,20 @@ int main(int argc, char **argv) do_reboot = true; cmd_count++; break; + case 's': + do_single = true; + cmd_count++; + break; case 'w': do_wtmp_only = true; + cmd_count++; break; case_RC_COMMON_GETOPT } } if (geteuid() != 0 && ! do_dryrun) eerrorx("%s: you must be root\n", applet); - if (cmd_count > 1) { + if (cmd_count != 1) { eerror("%s: %s\n", applet, exclusive); usage(EXIT_FAILURE); } @@ -156,7 +164,7 @@ int main(int argc, char **argv) send_cmd("reexec"); else if (do_wtmp_only) log_wtmp("shutdown", "~~", 0, RUN_LVL, "~~"); - else + else if (do_single) send_cmd("single"); return 0; }