From owner-svn-src-head@freebsd.org Sun Nov 29 11:30:18 2015 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6D2C0A3C8F6; Sun, 29 Nov 2015 11:30:18 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 38F67144D; Sun, 29 Nov 2015 11:30:18 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id tATBUHWm058291; Sun, 29 Nov 2015 11:30:17 GMT (envelope-from trasz@FreeBSD.org) Received: (from trasz@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id tATBUHFN058290; Sun, 29 Nov 2015 11:30:17 GMT (envelope-from trasz@FreeBSD.org) Message-Id: <201511291130.tATBUHFN058290@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: trasz set sender to trasz@FreeBSD.org using -f From: Edward Tomasz Napierala Date: Sun, 29 Nov 2015 11:30:17 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r291445 - head/usr.bin/rctl 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.20 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: Sun, 29 Nov 2015 11:30:18 -0000 Author: trasz Date: Sun Nov 29 11:30:17 2015 New Revision: 291445 URL: https://svnweb.freebsd.org/changeset/base/291445 Log: User and group identifiers the rctl(8) utility receives from the kernel are always in numeric form; don't try to resolve them by names. This speeds up rule listing with large rulesets by about 50%. MFC after: 1 month Sponsored by: The FreeBSD Foundation Modified: head/usr.bin/rctl/rctl.c Modified: head/usr.bin/rctl/rctl.c ============================================================================== --- head/usr.bin/rctl/rctl.c Sun Nov 29 11:28:04 2015 (r291444) +++ head/usr.bin/rctl/rctl.c Sun Nov 29 11:30:17 2015 (r291445) @@ -193,7 +193,7 @@ humanize_ids(char *rule) struct passwd *pwd; struct group *grp; const char *subject, *textid, *rest; - char *humanized; + char *end, *humanized; subject = strsep(&rule, ":"); textid = strsep(&rule, ":"); @@ -206,12 +206,16 @@ humanize_ids(char *rule) /* Replace numerical user and group ids with names. */ if (strcasecmp(subject, "user") == 0) { - id = parse_user(textid); + id = strtod(textid, &end); + if ((size_t)(end - textid) != strlen(textid)) + errx(1, "malformed uid '%s'", textid); pwd = getpwuid(id); if (pwd != NULL) textid = pwd->pw_name; } else if (strcasecmp(subject, "group") == 0) { - id = parse_group(textid); + id = strtod(textid, &end); + if ((size_t)(end - textid) != strlen(textid)) + errx(1, "malformed gid '%s'", textid); grp = getgrgid(id); if (grp != NULL) textid = grp->gr_name;