From 5c5e67d83f6be45507a76cb75af552ccc3576daf Mon Sep 17 00:00:00 2001 From: Baptiste Daroussin Date: Thu, 5 Jan 2012 10:40:24 +0000 Subject: 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) --- libutil/pw_util.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) (limited to 'libutil/pw_util.c') diff --git a/libutil/pw_util.c b/libutil/pw_util.c index 1068eff..5cd27b1 100644 --- a/libutil/pw_util.c +++ b/libutil/pw_util.c @@ -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); } /* -- cgit v1.2.3