diff options
-rw-r--r-- | usr.sbin/mtree/mtree.8 | 2 | ||||
-rw-r--r-- | usr.sbin/mtree/verify.c | 23 |
2 files changed, 20 insertions, 5 deletions
diff --git a/usr.sbin/mtree/mtree.8 b/usr.sbin/mtree/mtree.8 index 6f4d16d..d5a59f5 100644 --- a/usr.sbin/mtree/mtree.8 +++ b/usr.sbin/mtree/mtree.8 @@ -109,7 +109,7 @@ was specified. The checksum is seeded with the specified value. .It Fl U Modify the owner, group, and permissions of existing files to match -the specification and create any missing directories. +the specification and create any missing directories or symbolic links. User, group, and permissions must all be specified for missing directories to be created. Exit with a status of 0 on success, 1 if any error occurred; diff --git a/usr.sbin/mtree/verify.c b/usr.sbin/mtree/verify.c index 25b33aa..d25797b 100644 --- a/usr.sbin/mtree/verify.c +++ b/usr.sbin/mtree/verify.c @@ -165,6 +165,7 @@ miss(p, tail) { register int create; register char *tp; + const char *type; for (; p; p = p->next) { if (p->type != F_DIR && (dflag || p->flags & F_VISIT)) @@ -172,18 +173,32 @@ miss(p, tail) (void)strcpy(tail, p->name); if (!(p->flags & F_VISIT)) (void)printf("missing: %s", path); - if (p->type != F_DIR) { + if (p->type != F_DIR && p->type != F_LINK) { putchar('\n'); continue; } create = 0; + if (p->type == F_LINK) + type = "symlink"; + else + type = "directory"; if (!(p->flags & F_VISIT) && uflag) { if (!(p->flags & (F_UID | F_UNAME))) - (void)printf(" (directory not created: user not specified)"); + (void)printf(" (%s not created: user not specified)", type); else if (!(p->flags & (F_GID | F_GNAME))) - (void)printf(" (directory not created: group not specified)"); - else if (!(p->flags & F_MODE)) + (void)printf(" (%s not created: group not specified)", type); + else if (p->type == F_LINK) { + if (symlink(p->slink, path)) + (void)printf(" (symlink not created: %s)\n", + 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)); + continue; + } else if (!(p->flags & F_MODE)) (void)printf(" (directory not created: mode not specified)"); else if (mkdir(path, S_IRWXU)) (void)printf(" (directory not created: %s)", |