From owner-freebsd-bugs@FreeBSD.ORG Mon Apr 14 08:50:03 2003 Return-Path: Delivered-To: freebsd-bugs@hub.freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id D335237B401 for ; Mon, 14 Apr 2003 08:50:03 -0700 (PDT) Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by mx1.FreeBSD.org (Postfix) with ESMTP id E584D43FBF for ; Mon, 14 Apr 2003 08:50:01 -0700 (PDT) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.12.9/8.12.9) with ESMTP id h3EFo1Up005228 for ; Mon, 14 Apr 2003 08:50:01 -0700 (PDT) (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.12.9/8.12.9/Submit) id h3EFo1oj005227; Mon, 14 Apr 2003 08:50:01 -0700 (PDT) Resent-Date: Mon, 14 Apr 2003 08:50:01 -0700 (PDT) Resent-Message-Id: <200304141550.h3EFo1oj005227@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Rene de Vries Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 8999737B401; Mon, 14 Apr 2003 08:42:39 -0700 (PDT) Received: from bastix.tunix.nl (bastix.tunix.nl [193.79.201.39]) by mx1.FreeBSD.org (Postfix) with ESMTP id E8F0643FAF; Mon, 14 Apr 2003 08:42:37 -0700 (PDT) (envelope-from rene@tunix.nl) Received: (from root@localhost) by bastix.tunix.nl (8.9.3c/8.6.12) id RAA39673; Mon, 14 Apr 2003 17:42:49 +0200 (CEST) Received: by bastix.tunix.nl (TUNIX txp2/smap) id sma039354; Mon, 14 Apr 03 17:41:42 +0200 Received: from upsilix.tunix.nl (upsilix.tunix.nl [172.16.2.22]) by fix.tunix.nl (8.10.2+Sun/8.10.2) with ESMTP id h3EFfT910241; Mon, 14 Apr 2003 17:41:29 +0200 (MEST) Received: from upsilix.tunix.nl (localhost.tunix.nl [127.0.0.1]) by upsilix.tunix.nl (8.12.6/8.12.6) with ESMTP id h3EFfQc5072932; Mon, 14 Apr 2003 17:41:26 +0200 (CEST) (envelope-from rene@upsilix.tunix.nl) Received: (from rene@localhost) by upsilix.tunix.nl (8.12.6/8.12.6/Submit) id h3EFfQQZ072931; Mon, 14 Apr 2003 17:41:26 +0200 (CEST) (envelope-from rene) Message-Id: <200304141541.h3EFfQQZ072931@upsilix.tunix.nl> Date: Mon, 14 Apr 2003 17:41:26 +0200 (CEST) From: Rene de Vries To: FreeBSD-gnats-submit@FreeBSD.org X-Send-Pr-Version: 3.113 cc: robert@FreeBSD.org Subject: bin/50949: BUG: mtree doesn't honor the -P when checking/changing ownership X-BeenThere: freebsd-bugs@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list Reply-To: Rene de Vries List-Id: Bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 14 Apr 2003 15:50:04 -0000 >Number: 50949 >Category: bin >Synopsis: BUG: mtree doesn't honor the -P when checking/changing ownership >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Mon Apr 14 08:50:01 PDT 2003 >Closed-Date: >Last-Modified: >Originator: Rene de Vries >Release: FreeBSD 4.7-RELEASE-p3 i386/FreeBSD 5.0-20030401 i386 >Organization: Tunix Internet Security & Training >Environment: >Description: Symlinks are not always taken into account when -P is used. >How-To-Repeat: >Fix: Files: usr.sbin/mtree/compare.c usr.sbin/mtree/verify.c Diff against FreeBSD 5 (current as of 01 Apr 2003): Index: usr.sbin/mtree/compare.c =================================================================== RCS file: /home/fbsd-cvsrepo/src/usr.sbin/mtree/compare.c,v retrieving revision 1.25 diff -u -r1.25 compare.c --- usr.sbin/mtree/compare.c 13 Mar 2003 23:35:30 -0000 1.25 +++ usr.sbin/mtree/compare.c 1 Apr 2003 14:34:12 -0000 @@ -63,6 +63,7 @@ extern int uflag; extern int lineno; +extern int ftsoptions; static const char *ftype(u_int); @@ -127,11 +128,19 @@ (void)printf("%suser expected %lu found %lu", tab, (u_long)s->st_uid, (u_long)p->fts_statp->st_uid); if (uflag) - if (chown(p->fts_accpath, s->st_uid, -1)) - (void)printf(" not modified: %s\n", - strerror(errno)); - else - (void)printf(" modified\n"); + if (ftsoptions & FTS_PHYSICAL) { + if (lchown(p->fts_accpath, s->st_uid, -1)) + (void)printf(" not modified: %s\n", + strerror(errno)); + else + (void)printf(" modified\n"); + } else { + if (chown(p->fts_accpath, s->st_uid, -1)) + (void)printf(" not modified: %s\n", + strerror(errno)); + else + (void)printf(" modified\n"); + } else (void)printf("\n"); tab = "\t"; @@ -141,11 +150,19 @@ (void)printf("%sgid expected %lu found %lu", tab, (u_long)s->st_gid, (u_long)p->fts_statp->st_gid); if (uflag) - if (chown(p->fts_accpath, -1, s->st_gid)) - (void)printf(" not modified: %s\n", - strerror(errno)); - else - (void)printf(" modified\n"); + if (ftsoptions & FTS_PHYSICAL) { + if (lchown(p->fts_accpath, -1, s->st_gid)) + (void)printf(" not modified: %s\n", + strerror(errno)); + else + (void)printf(" modified\n"); + } else { + if (chown(p->fts_accpath, -1, s->st_gid)) + (void)printf(" not modified: %s\n", + strerror(errno)); + else + (void)printf(" modified\n"); + } else (void)printf("\n"); tab = "\t"; @@ -157,11 +174,19 @@ (void)printf("%spermissions expected %#o found %#o", tab, s->st_mode, p->fts_statp->st_mode & MBITS); if (uflag) - if (chmod(p->fts_accpath, s->st_mode)) - (void)printf(" not modified: %s\n", - strerror(errno)); - else - (void)printf(" modified\n"); + if (ftsoptions & FTS_PHYSICAL) { + if (lchmod(p->fts_accpath, s->st_mode)) + (void)printf(" not modified: %s\n", + strerror(errno)); + else + (void)printf(" modified\n"); + } else { + if (chmod(p->fts_accpath, s->st_mode)) + (void)printf(" not modified: %s\n", + strerror(errno)); + else + (void)printf(" modified\n"); + } else (void)printf("\n"); tab = "\t"; Index: usr.sbin/mtree/verify.c =================================================================== RCS file: /home/fbsd-cvsrepo/src/usr.sbin/mtree/verify.c,v retrieving revision 1.18 diff -u -r1.18 verify.c --- usr.sbin/mtree/verify.c 13 Mar 2003 23:35:30 -0000 1.18 +++ usr.sbin/mtree/verify.c 1 Apr 2003 14:34:12 -0000 @@ -226,19 +226,36 @@ 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 (ftsoptions & FTS_PHYSICAL) { + if (lchown(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 (lchmod(path, p->st_mode)) + (void)printf("%s: permissions not set: %s\n", + path, strerror(errno)); + if ((p->flags & F_FLAGS) && p->st_flags && + chflags(path, p->st_flags)) + (void)printf("%s: file flags not set: %s\n", + path, strerror(errno)); + } else { + 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 (chmod(path, p->st_mode)) + (void)printf("%s: permissions not set: %s\n", + path, strerror(errno)); + if ((p->flags & F_FLAGS) && p->st_flags && + chflags(path, p->st_flags)) + (void)printf("%s: file flags not set: %s\n", + path, strerror(errno)); } - if (chmod(path, p->st_mode)) - (void)printf("%s: permissions not set: %s\n", - path, strerror(errno)); - if ((p->flags & F_FLAGS) && p->st_flags && - chflags(path, p->st_flags)) - (void)printf("%s: file flags not set: %s\n", - path, strerror(errno)); } } >Release-Note: >Audit-Trail: >Unformatted: