From owner-svn-src-stable-9@FreeBSD.ORG Wed May 23 14:48:15 2012 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 21567106564A; Wed, 23 May 2012 14:48:15 +0000 (UTC) (envelope-from jamie@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 0B4918FC0A; Wed, 23 May 2012 14:48:15 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id q4NEmEeC078645; Wed, 23 May 2012 14:48:14 GMT (envelope-from jamie@svn.freebsd.org) Received: (from jamie@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q4NEmEVg078643; Wed, 23 May 2012 14:48:14 GMT (envelope-from jamie@svn.freebsd.org) Message-Id: <201205231448.q4NEmEVg078643@svn.freebsd.org> From: Jamie Gritton Date: Wed, 23 May 2012 14:48:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r235836 - stable/9/lib/libjail X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 23 May 2012 14:48:15 -0000 Author: jamie Date: Wed May 23 14:48:14 2012 New Revision: 235836 URL: http://svn.freebsd.org/changeset/base/235836 Log: MFC r235799: The fix in r235291 (r235624) re-broke the "allow.nomount" case. Re-fix it by testing for the right parameter name. PR: bin/168250 Modified: stable/9/lib/libjail/jail.c Directory Properties: stable/9/lib/libjail/ (props changed) Modified: stable/9/lib/libjail/jail.c ============================================================================== --- stable/9/lib/libjail/jail.c Wed May 23 14:44:57 2012 (r235835) +++ stable/9/lib/libjail/jail.c Wed May 23 14:48:14 2012 (r235836) @@ -853,7 +853,7 @@ jailparam_free(struct jailparam *jp, uns static int jailparam_type(struct jailparam *jp) { - char *p, *nname; + char *p, *name, *nname; size_t miblen, desclen; int i, isarray; struct { @@ -863,7 +863,8 @@ jailparam_type(struct jailparam *jp) int mib[CTL_MAXNAME]; /* The "lastjid" parameter isn't real. */ - if (!strcmp(jp->jp_name, "lastjid")) { + name = jp->jp_name; + if (!strcmp(name, "lastjid")) { jp->jp_valuelen = sizeof(int); jp->jp_ctltype = CTLTYPE_INT | CTLFLAG_WR; return (0); @@ -872,19 +873,19 @@ jailparam_type(struct jailparam *jp) /* Find the sysctl that describes the parameter. */ mib[0] = 0; mib[1] = 3; - snprintf(desc.s, sizeof(desc.s), SJPARAM ".%s", jp->jp_name); + snprintf(desc.s, sizeof(desc.s), SJPARAM ".%s", name); miblen = sizeof(mib) - 2 * sizeof(int); if (sysctl(mib, 2, mib + 2, &miblen, desc.s, strlen(desc.s)) < 0) { if (errno != ENOENT) { snprintf(jail_errmsg, JAIL_ERRMSGLEN, - "sysctl(0.3.%s): %s", jp->jp_name, strerror(errno)); + "sysctl(0.3.%s): %s", name, strerror(errno)); return (-1); } /* * The parameter probably doesn't exist. But it might be * the "no" counterpart to a boolean. */ - nname = nononame(jp->jp_name); + nname = nononame(name); if (nname == NULL) { unknown_parameter: snprintf(jail_errmsg, JAIL_ERRMSGLEN, @@ -892,8 +893,10 @@ jailparam_type(struct jailparam *jp) errno = ENOENT; return (-1); } - snprintf(desc.s, sizeof(desc.s), SJPARAM ".%s", nname); + name = alloca(strlen(nname) + 1); + strcpy(name, nname); free(nname); + snprintf(desc.s, sizeof(desc.s), SJPARAM ".%s", name); miblen = sizeof(mib) - 2 * sizeof(int); if (sysctl(mib, 2, mib + 2, &miblen, desc.s, strlen(desc.s)) < 0) @@ -906,7 +909,7 @@ jailparam_type(struct jailparam *jp) if (sysctl(mib, (miblen / sizeof(int)) + 2, &desc, &desclen, NULL, 0) < 0) { snprintf(jail_errmsg, JAIL_ERRMSGLEN, - "sysctl(0.4.%s): %s", jp->jp_name, strerror(errno)); + "sysctl(0.4.%s): %s", name, strerror(errno)); return (-1); } jp->jp_ctltype = desc.i; @@ -952,7 +955,7 @@ jailparam_type(struct jailparam *jp) if (sysctl(mib + 2, miblen / sizeof(int), desc.s, &desclen, NULL, 0) < 0) { snprintf(jail_errmsg, JAIL_ERRMSGLEN, - "sysctl(" SJPARAM ".%s): %s", jp->jp_name, + "sysctl(" SJPARAM ".%s): %s", name, strerror(errno)); return (-1); } @@ -970,7 +973,7 @@ jailparam_type(struct jailparam *jp) if (sysctl(mib + 2, miblen / sizeof(int), NULL, &jp->jp_valuelen, NULL, 0) < 0) { snprintf(jail_errmsg, JAIL_ERRMSGLEN, - "sysctl(" SJPARAM ".%s): %s", jp->jp_name, + "sysctl(" SJPARAM ".%s): %s", name, strerror(errno)); return (-1); } @@ -995,10 +998,9 @@ jailparam_type(struct jailparam *jp) "sysctl(0.1): %s", strerror(errno)); return (-1); } - if (desclen == - sizeof(SJPARAM) + strlen(jp->jp_name) + 2 && + if (desclen == sizeof(SJPARAM) + strlen(name) + 2 && memcmp(SJPARAM ".", desc.s, sizeof(SJPARAM)) == 0 && - memcmp(jp->jp_name, desc.s + sizeof(SJPARAM), + memcmp(name, desc.s + sizeof(SJPARAM), desclen - sizeof(SJPARAM) - 2) == 0 && desc.s[desclen - 2] == '.') goto mib_desc;