From owner-svn-src-all@FreeBSD.ORG Thu Aug 5 17:08:24 2010 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2775F1065672; Thu, 5 Aug 2010 17:08:24 +0000 (UTC) (envelope-from trasz@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 14C478FC14; Thu, 5 Aug 2010 17:08:24 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o75H8NID051446; Thu, 5 Aug 2010 17:08:23 GMT (envelope-from trasz@svn.freebsd.org) Received: (from trasz@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o75H8NBj051442; Thu, 5 Aug 2010 17:08:23 GMT (envelope-from trasz@svn.freebsd.org) Message-Id: <201008051708.o75H8NBj051442@svn.freebsd.org> From: Edward Tomasz Napierala Date: Thu, 5 Aug 2010 17:08:23 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r210867 - stable/8/lib/libc/posix1e X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 05 Aug 2010 17:08:24 -0000 Author: trasz Date: Thu Aug 5 17:08:23 2010 New Revision: 210867 URL: http://svn.freebsd.org/changeset/base/210867 Log: MFC r209736: Fix acl_from_text(3) - and, therefore, setfacl(1) - for user and group names names starting with a digit. Modified: stable/8/lib/libc/posix1e/acl_from_text.c stable/8/lib/libc/posix1e/acl_from_text_nfs4.c stable/8/lib/libc/posix1e/acl_support.h Directory Properties: stable/8/lib/libc/ (props changed) stable/8/lib/libc/locale/ (props changed) stable/8/lib/libc/stdtime/ (props changed) stable/8/lib/libc/sys/ (props changed) Modified: stable/8/lib/libc/posix1e/acl_from_text.c ============================================================================== --- stable/8/lib/libc/posix1e/acl_from_text.c Thu Aug 5 16:52:13 2010 (r210866) +++ stable/8/lib/libc/posix1e/acl_from_text.c Thu Aug 5 17:08:23 2010 (r210867) @@ -44,7 +44,6 @@ __FBSDID("$FreeBSD$"); #include "acl_support.h" -static int _posix1e_acl_name_to_id(acl_tag_t tag, char *name, uid_t *id); static acl_tag_t acl_string_to_tag(char *tag, char *qualifier); int _nfs4_acl_entry_from_text(acl_t aclp, char *entry); @@ -148,8 +147,7 @@ _posix1e_acl_entry_from_text(acl_t aclp, case ACL_USER: case ACL_GROUP: - error = _posix1e_acl_name_to_id(t, qualifier, - &id); + error = _acl_name_to_id(t, qualifier, &id); if (error == -1) return (-1); break; @@ -275,8 +273,8 @@ error_label: * XXX currently doesn't deal correctly with a numeric uid being passed * instead of a username. What is correct behavior here? Check chown. */ -static int -_posix1e_acl_name_to_id(acl_tag_t tag, char *name, uid_t *id) +int +_acl_name_to_id(acl_tag_t tag, char *name, uid_t *id) { struct group *g; struct passwd *p; Modified: stable/8/lib/libc/posix1e/acl_from_text_nfs4.c ============================================================================== --- stable/8/lib/libc/posix1e/acl_from_text_nfs4.c Thu Aug 5 16:52:13 2010 (r210866) +++ stable/8/lib/libc/posix1e/acl_from_text_nfs4.c Thu Aug 5 17:08:23 2010 (r210867) @@ -79,16 +79,14 @@ parse_tag(const char *str, acl_entry_t e /* * Parse the qualifier field of ACL entry passed as "str". * If user or group name cannot be resolved, then the variable - * referenced by "need_qualifier" is set to 1. + * referenced by "need_qualifier" is set to 1; it will be checked + * later to figure out whether the appended_id is required. */ static int parse_qualifier(char *str, acl_entry_t entry, int *need_qualifier) { int qualifier_length, error; - id_t id; - char *end; - struct passwd *pwd; - struct group *grp; + uid_t id; acl_tag_t tag; assert(need_qualifier != NULL); @@ -101,44 +99,17 @@ parse_qualifier(char *str, acl_entry_t e return (-1); } - /* XXX: Can we assume that valid username never begins with a digit? */ - if (isdigit(str[0])) { - id = strtod(str, &end); - - if (end - str != qualifier_length) { - warnx("malformed ACL: trailing characters " - "after numerical id"); - return (-1); - } - - return (acl_set_qualifier(entry, &id)); - } - error = acl_get_tag_type(entry, &tag); if (error) return (error); - assert(tag == ACL_USER || tag == ACL_GROUP); - - if (tag == ACL_USER) { - /* XXX: Thread-unsafe. */ - pwd = getpwnam(str); - if (pwd == NULL) { - *need_qualifier = 1; - return (0); - } - - return (acl_set_qualifier(entry, &(pwd->pw_uid))); - } - - /* XXX: Thread-unsafe. */ - grp = getgrnam(str); - if (grp == NULL) { + error = _acl_name_to_id(tag, str, &id); + if (error) { *need_qualifier = 1; return (0); } - return (acl_set_qualifier(entry, &(grp->gr_gid))); + return (acl_set_qualifier(entry, &id)); } static int Modified: stable/8/lib/libc/posix1e/acl_support.h ============================================================================== --- stable/8/lib/libc/posix1e/acl_support.h Thu Aug 5 16:52:13 2010 (r210866) +++ stable/8/lib/libc/posix1e/acl_support.h Thu Aug 5 17:08:23 2010 (r210867) @@ -61,5 +61,6 @@ int _posix1e_acl_add_entry(acl_t acl, ac acl_perm_t perm); char *string_skip_whitespace(char *string); void string_trim_trailing_whitespace(char *string); +int _acl_name_to_id(acl_tag_t tag, char *name, uid_t *id); #endif