From owner-svn-src-head@FreeBSD.ORG Thu Jan 5 10:40:25 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6ABB3106566B; Thu, 5 Jan 2012 10:40:25 +0000 (UTC) (envelope-from bapt@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 5514A8FC08; Thu, 5 Jan 2012 10:40:25 +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 q05AePGB027830; Thu, 5 Jan 2012 10:40:25 GMT (envelope-from bapt@svn.freebsd.org) Received: (from bapt@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id q05AePQI027827; Thu, 5 Jan 2012 10:40:25 GMT (envelope-from bapt@svn.freebsd.org) Message-Id: <201201051040.q05AePQI027827@svn.freebsd.org> From: Baptiste Daroussin Date: Thu, 5 Jan 2012 10:40:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r229572 - head/lib/libutil X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 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: Thu, 05 Jan 2012 10:40:25 -0000 Author: bapt Date: Thu Jan 5 10:40:24 2012 New Revision: 229572 URL: http://svn.freebsd.org/changeset/base/229572 Log: Add new pw_make_v7 to make a passwd line (in v7 format) out of a struct passwd while here, fix missing parentheses of the return statement of pw_make. Approved by: des (mentor) Modified: head/lib/libutil/libutil.h head/lib/libutil/pw_util.c Modified: head/lib/libutil/libutil.h ============================================================================== --- head/lib/libutil/libutil.h Thu Jan 5 10:32:53 2012 (r229571) +++ head/lib/libutil/libutil.h Thu Jan 5 10:40:24 2012 (r229572) @@ -144,6 +144,7 @@ int pw_equal(const struct passwd *_pw1, void pw_fini(void); int pw_init(const char *_dir, const char *_master); char *pw_make(const struct passwd *_pw); +char *pw_make_v7(const struct passwd *_pw); int pw_mkdb(const char *_user); int pw_lock(void); struct passwd *pw_scan(const char *_line, int _flags); Modified: head/lib/libutil/pw_util.c ============================================================================== --- head/lib/libutil/pw_util.c Thu Jan 5 10:32:53 2012 (r229571) +++ head/lib/libutil/pw_util.c Thu Jan 5 10:40:24 2012 (r229572) @@ -406,7 +406,21 @@ pw_make(const struct passwd *pw) pw->pw_passwd, (uintmax_t)pw->pw_uid, (uintmax_t)pw->pw_gid, pw->pw_class, (uintmax_t)pw->pw_change, (uintmax_t)pw->pw_expire, pw->pw_gecos, pw->pw_dir, pw->pw_shell); - return line; + return (line); +} + +/* + * Make a passwd line (in v7 format) out of a struct passwd + */ +char * +pw_make_v7(const struct passwd *pw) +{ + char *line; + + asprintf(&line, "%s:*:%ju:%ju:%s:%s:%s", pw->pw_name, + (uintmax_t)pw->pw_uid, (uintmax_t)pw->pw_gid, + pw->pw_gecos, pw->pw_dir, pw->pw_shell); + return (line); } /*