From owner-svn-src-head@FreeBSD.ORG Sat Aug 10 01:48:16 2013 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 503FF804; Sat, 10 Aug 2013 01:48:16 +0000 (UTC) (envelope-from alfred@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 23D222FD0; Sat, 10 Aug 2013 01:48:16 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id r7A1mFwI034248; Sat, 10 Aug 2013 01:48:15 GMT (envelope-from alfred@svn.freebsd.org) Received: (from alfred@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id r7A1mFW1034247; Sat, 10 Aug 2013 01:48:15 GMT (envelope-from alfred@svn.freebsd.org) Message-Id: <201308100148.r7A1mFW1034247@svn.freebsd.org> From: Alfred Perlstein Date: Sat, 10 Aug 2013 01:48:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r254173 - head/usr.sbin/watchdogd X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 10 Aug 2013 01:48:16 -0000 Author: alfred Date: Sat Aug 10 01:48:15 2013 New Revision: 254173 URL: http://svnweb.freebsd.org/changeset/base/254173 Log: Fix bug in r253719: fix command line watchdog disable. r253719 disallowed watchdog(8) from disabling the watchdog by breaking the ability to pass 0 as a timeout arg. Fix this. Modified: head/usr.sbin/watchdogd/watchdogd.c Modified: head/usr.sbin/watchdogd/watchdogd.c ============================================================================== --- head/usr.sbin/watchdogd/watchdogd.c Sat Aug 10 00:53:22 2013 (r254172) +++ head/usr.sbin/watchdogd/watchdogd.c Sat Aug 10 01:48:15 2013 (r254173) @@ -60,7 +60,8 @@ __FBSDID("$FreeBSD$"); #include -static long fetchtimeout(int opt, const char *longopt, const char *myoptarg); +static long fetchtimeout(int opt, + const char *longopt, const char *myoptarg, int zero_ok); static void parseargs(int, char *[]); static int seconds_to_pow2ns(int); static void sighandler(int); @@ -219,7 +220,7 @@ parse_timeout_to_pow2ns(char opt, const if (!longopt) shortopt[1] = opt; - a = fetchtimeout(opt, longopt, myoptarg); + a = fetchtimeout(opt, longopt, myoptarg, 1); if (a == 0) rv = WD_TO_NEVER; @@ -487,7 +488,7 @@ usage(void) } static long -fetchtimeout(int opt, const char *longopt, const char *myoptarg) +fetchtimeout(int opt, const char *longopt, const char *myoptarg, int zero_ok) { const char *errstr; char *p; @@ -499,7 +500,7 @@ fetchtimeout(int opt, const char *longop rv = strtol(myoptarg, &p, 0); if ((p != NULL && *p != '\0') || errno != 0) errstr = "is not a number"; - if (rv <= 0) + if (rv < 0 || (!zero_ok && rv == 0)) errstr = "must be greater than zero"; if (errstr) { if (longopt) @@ -721,7 +722,7 @@ parseargs(int argc, char *argv[]) break; #endif case 's': - nap = fetchtimeout(c, NULL, optarg); + nap = fetchtimeout(c, NULL, optarg, 0); break; case 'S': do_syslog = 0; @@ -734,7 +735,8 @@ parseargs(int argc, char *argv[]) timeout); break; case 'T': - carp_thresh_seconds = fetchtimeout(c, "NULL", optarg); + carp_thresh_seconds = + fetchtimeout(c, "NULL", optarg, 0); break; case 'w': do_timedog = 1; @@ -742,7 +744,7 @@ parseargs(int argc, char *argv[]) case 0: lopt = longopts[longindex].name; if (!strcmp(lopt, "pretimeout")) { - pretimeout = fetchtimeout(0, lopt, optarg); + pretimeout = fetchtimeout(0, lopt, optarg, 0); } else if (!strcmp(lopt, "pretimeout-action")) { pretimeout_act = timeout_act_str2int(lopt, optarg);