diff options
| author | Brian Somers <brian@FreeBSD.org> | 2005-08-11 15:43:55 +0000 |
|---|---|---|
| committer | Brian Somers <brian@FreeBSD.org> | 2005-08-11 15:43:55 +0000 |
| commit | 6e03259288a5136e88aa4fb27232a8fbf7a40485 (patch) | |
| tree | 039837d987097567dddb325e601f7421c20ad58d /usr.sbin | |
| parent | c948b4bc6480e72fbbc2cbed626bef5c83a96f2a (diff) | |
Notes
Diffstat (limited to 'usr.sbin')
| -rw-r--r-- | usr.sbin/mtree/verify.c | 38 |
1 files changed, 28 insertions, 10 deletions
diff --git a/usr.sbin/mtree/verify.c b/usr.sbin/mtree/verify.c index 7f2cf8dbe846e..cc31ea4e3323f 100644 --- a/usr.sbin/mtree/verify.c +++ b/usr.sbin/mtree/verify.c @@ -154,7 +154,8 @@ miss(NODE *p, char *tail) { int create; char *tp; - const char *type; + const char *type, *what; + int serr; for (; p; p = p->next) { if (p->type != F_DIR && (dflag || p->flags & F_VISIT)) @@ -191,9 +192,20 @@ miss(NODE *p, char *tail) strerror(errno)); else (void)printf(" (created)\n"); - if (lchown(path, p->st_uid, p->st_gid)) - (void)printf("%s: user/group not modified: %s\n", - path, strerror(errno)); + if (lchown(path, p->st_uid, p->st_gid) == -1) { + serr = errno; + if (p->st_uid == (uid_t)-1) + what = "group"; + else if (lchown(path, (uid_t)-1, + p->st_gid) == -1) + what = "user & group"; + else { + what = "user"; + errno = serr; + } + (void)printf("%s: %s not modified: %s" + "\n", path, what, strerror(errno)); + } continue; } else if (!(p->flags & F_MODE)) (void)printf(" (directory not created: mode not specified)"); @@ -215,12 +227,18 @@ miss(NODE *p, char *tail) if (!create) continue; - if (chown(path, p->st_uid, p->st_gid)) { - (void)printf("%s: user/group/mode not modified: %s\n", - path, strerror(errno)); - (void)printf("%s: warning: file mode %snot set\n", path, - (p->flags & F_FLAGS) ? "and file flags " : ""); - continue; + if (chown(path, p->st_uid, p->st_gid) == -1) { + serr = errno; + if (p->st_uid == (uid_t)-1) + what = "group"; + else if (chown(path, (uid_t)-1, p->st_gid) == -1) + what = "user & group"; + else { + what = "user"; + errno = serr; + } + (void)printf("%s: %s not modified: %s\n", + path, what, strerror(errno)); } if (chmod(path, p->st_mode)) (void)printf("%s: permissions not set: %s\n", |
