From e9a03238b07457697468a52a46c6f31b178a71bc Mon Sep 17 00:00:00 2001 From: Brooks Davis Date: Wed, 20 Feb 2013 15:25:40 +0000 Subject: [PATCH] Fix the -N option in manifest mode by using pwcache(3). This also speeds up image creation appreciably. Reviewed by: marcel Sponsored by: DARPA, AFRL --- usr.sbin/makefs/mtree.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/usr.sbin/makefs/mtree.c b/usr.sbin/makefs/mtree.c index f5eb5fc8cf85..12893df26cec 100644 --- a/usr.sbin/makefs/mtree.c +++ b/usr.sbin/makefs/mtree.c @@ -508,8 +508,8 @@ read_mtree_keywords(FILE *fp, fsnode *node) { char keyword[PATH_MAX]; char *name, *p, *value; - struct group *grent; - struct passwd *pwent; + gid_t gid; + uid_t uid; struct stat *st, sb; intmax_t num; u_long flset, flclr; @@ -585,11 +585,10 @@ read_mtree_keywords(FILE *fp, fsnode *node) error = ENOATTR; break; } - grent = getgrnam(value); - if (grent != NULL) - st->st_gid = grent->gr_gid; + if (gid_from_group(value, &gid) == 0) + st->st_gid = gid; else - error = errno; + error = EINVAL; } else error = ENOSYS; break; @@ -698,11 +697,10 @@ read_mtree_keywords(FILE *fp, fsnode *node) error = ENOATTR; break; } - pwent = getpwnam(value); - if (pwent != NULL) - st->st_uid = pwent->pw_uid; + if (uid_from_user(value, &uid) == 0) + st->st_uid = uid; else - error = errno; + error = EINVAL; } else error = ENOSYS; break;