From owner-svn-src-stable@FreeBSD.ORG Mon Mar 4 23:15:26 2013 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id AB8385E2; Mon, 4 Mar 2013 23:15:26 +0000 (UTC) (envelope-from ian@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 9DBF21E2; Mon, 4 Mar 2013 23:15:26 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r24NFQdN030849; Mon, 4 Mar 2013 23:15:26 GMT (envelope-from ian@svn.freebsd.org) Received: (from ian@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r24NFQDI030847; Mon, 4 Mar 2013 23:15:26 GMT (envelope-from ian@svn.freebsd.org) Message-Id: <201303042315.r24NFQDI030847@svn.freebsd.org> From: Ian Lepore Date: Mon, 4 Mar 2013 23:15:26 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org Subject: svn commit: r247824 - stable/8/sbin/devd X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 Mar 2013 23:15:26 -0000 Author: ian Date: Mon Mar 4 23:15:25 2013 New Revision: 247824 URL: http://svnweb.freebsd.org/changeset/base/247824 Log: MFC ... r210609 - remove unused string r210610 - avoid copy ctors by using prefix operators r213646 - allow spacey things (liberal whitespace parsing) r236388 - libc++ compatibility (add :: prefix to bind() call) r240823 - use O_CLOEXEC for open instead of separate fcntl(2) call r243932 - prefer init expression to assignment in ctor r209583 ... Expand system into my_system, and add the necessary tidyness that we need. Close the pidfile. Then close all descriptors >= 3 to avoid information leakage to children. This solves the problem of not being able to restart devd when you have, for example, a dhclient forked to configure your network... Modified: stable/8/sbin/devd/devd.cc stable/8/sbin/devd/devd.hh Directory Properties: stable/8/sbin/devd/ (props changed) Modified: stable/8/sbin/devd/devd.cc ============================================================================== --- stable/8/sbin/devd/devd.cc Mon Mar 4 23:15:07 2013 (r247823) +++ stable/8/sbin/devd/devd.cc Mon Mar 4 23:15:25 2013 (r247824) @@ -249,10 +249,8 @@ action::do_action(config &c) } match::match(config &c, const char *var, const char *re) - : _var(var) + : _var(var), _re("^") { - string pattern = re; - _re = "^"; if (!c.expand_string(string(re)).empty() && c.expand_string(string(re)).at(0) == '!') { _re.append(c.expand_string(string(re)).substr(1)); @@ -273,7 +271,7 @@ match::~match() bool match::do_match(config &c) { - string value = c.get_variable(_var); + const string &value = c.get_variable(_var); bool retval; if (Dflag) @@ -590,7 +588,7 @@ void config::expand_one(const char *&src, string &dst) { int count; - string buffer, varstr; + string buffer; src++; // $$ -> $ @@ -628,8 +626,7 @@ config::expand_one(const char *&src, str buffer.append(src++, 1); } while (is_id_char(*src)); buffer.append("", 1); - varstr = get_variable(buffer.c_str()); - dst.append(varstr); + dst.append(get_variable(buffer.c_str())); } const string @@ -763,9 +760,13 @@ process_event(char *buffer) if (sp == NULL) return; /* Can't happen? */ *sp++ = '\0'; + while (isspace(*sp)) + sp++; if (strncmp(sp, "at ", 3) == 0) sp += 3; sp = cfg.set_vars(sp); + while (isspace(*sp)) + sp++; if (strncmp(sp, "on ", 3) == 0) cfg.set_variable("bus", sp + 3); break; @@ -776,9 +777,13 @@ process_event(char *buffer) return; /* Can't happen? */ *sp++ = '\0'; cfg.set_variable("device-name", buffer); + while (isspace(*sp)) + sp++; if (strncmp(sp, "at ", 3) == 0) sp += 3; sp = cfg.set_vars(sp); + while (isspace(*sp)) + sp++; if (strncmp(sp, "on ", 3) == 0) cfg.set_variable("bus", sp + 3); break; @@ -803,7 +808,7 @@ create_socket(const char *name) unlink(name); if (fcntl(fd, F_SETFL, O_NONBLOCK) < 0) err(1, "fcntl"); - if (bind(fd, (struct sockaddr *) & sun, slen) < 0) + if (::bind(fd, (struct sockaddr *) & sun, slen) < 0) err(1, "bind"); listen(fd, 4); chown(name, 0, 0); /* XXX - root.wheel */ Modified: stable/8/sbin/devd/devd.hh ============================================================================== --- stable/8/sbin/devd/devd.hh Mon Mar 4 23:15:07 2013 (r247823) +++ stable/8/sbin/devd/devd.hh Mon Mar 4 23:15:25 2013 (r247824) @@ -144,7 +144,7 @@ private: class config { public: - config() { _pidfile = ""; push_var_table(); } + config() : _pidfile("") { push_var_table(); } virtual ~config() { reset(); } void add_attach(int, event_proc *); void add_detach(int, event_proc *);