From owner-freebsd-bugs Sun Feb 11 14:50:46 2001 Delivered-To: freebsd-bugs@hub.freebsd.org Received: from freefall.freebsd.org (freefall.freebsd.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id 0B3C037B699 for ; Sun, 11 Feb 2001 14:50:03 -0800 (PST) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.1/8.11.1) id f1BMo2g56777; Sun, 11 Feb 2001 14:50:02 -0800 (PST) (envelope-from gnats) Received: from ns1.tu-graz.ac.at (ns1.tu-graz.ac.at [129.27.2.3]) by hub.freebsd.org (Postfix) with ESMTP id 8853437B401 for ; Sun, 11 Feb 2001 14:43:52 -0800 (PST) Received: from homebox.kammerhofer.org (isdn091.tu-graz.ac.at [129.27.240.91]) by ns1.tu-graz.ac.at (8.9.3/8.9.3) with ESMTP id XAA07824 for ; Sun, 11 Feb 2001 23:43:47 +0100 (MET) Received: (from mkamm@localhost) by homebox.kammerhofer.org (8.11.2/8.11.2) id f1AIisA11912; Sat, 10 Feb 2001 19:44:54 +0100 (CET) (envelope-from mkamm) Message-Id: <200102101844.f1AIisA11912@homebox.kammerhofer.org> Date: Sat, 10 Feb 2001 19:44:54 +0100 (CET) From: mkamm@gmx.net Reply-To: mkamm@gmx.net To: FreeBSD-gnats-submit@freebsd.org X-Send-Pr-Version: 3.2 Subject: kern/25018: lstat(2) returns bogus permissions on symlinks Sender: owner-freebsd-bugs@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org >Number: 25018 >Category: kern >Synopsis: lstat(2) returns bogus permissions on symlinks >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Sun Feb 11 14:50:02 PST 2001 >Closed-Date: >Last-Modified: >Originator: Martin Kammerhofer >Release: FreeBSD 4.2-STABLE i386 >Organization: Universität Graz >Environment: >Description: I quote a commitlog message here: ##peter 97/03/31 04:03:04 ## ## Treat symlinks as first class citizens with their own uid/gid rather than ## as shadows of their containing directory. This should solve the problem ## of users not being able to delete their symlinks from /tmp once and for ## all. ## ## Symlinks do not have modes though, they are accessable to everything that ## can read the directory (as before). They are made to show this fact at ## lstat time (they appear as mode 0777 always, since that's how the the ## lookup routines in the kernel treat them). ## ## More commits will follow, eg: add a real lchown() syscall and man pages. ## ## Revision Changes Path ## 1.62 +19 -70 src/sys/kern/vfs_syscalls.c However the mentioned feature "appear as mode 0777" was broken later when mount option "nosymfollow" was introduced because the mode was written to the wrong variable. For easy reference I quote a part of this second commit log too: ##wosch 1998/04/08 11:32:00 PDT ## New mount option nosymfollow. If enabled, the kernel lookup() ## function will not follow symbolic links on the mounted ## file system and return EACCES (Permission denied). ## ## Revision Changes Path ## 1.97 +3 -5 src/sys/kern/vfs_syscalls.c ## 1.55 +6 -1 src/sys/kern/vfs_vnops.c >How-To-Repeat: (umask 321 && ln -s "have strange but nontheless nonexistant perms" symlinks) ls -l symlinks The permissions shown reflect the umask value at the time of the symlink(2) call rather than the more intuitive "lrwxrwxrwx" or in case of mount -onosymfollow "l---------". >Fix: Don't set a variable that will be overwritten shortly after the break... Index: vfs_vnops.c =================================================================== RCS file: /home/ncvs/src/sys/kern/vfs_vnops.c,v retrieving revision 1.107 diff -u -11 -r1.107 vfs_vnops.c --- vfs_vnops.c 2001/01/24 12:35:50 1.107 +++ vfs_vnops.c 2001/02/10 12:57:00 @@ -479,25 +479,25 @@ break; case VBLK: mode |= S_IFBLK; break; case VCHR: mode |= S_IFCHR; break; case VLNK: mode |= S_IFLNK; /* This is a cosmetic change, symlinks do not have a mode. */ if (vp->v_mount->mnt_flag & MNT_NOSYMFOLLOW) - sb->st_mode &= ~ACCESSPERMS; /* 0000 */ + mode &= ~ACCESSPERMS; /* 0000 */ else - sb->st_mode |= ACCESSPERMS; /* 0777 */ + mode |= ACCESSPERMS; /* 0777 */ break; case VSOCK: mode |= S_IFSOCK; break; case VFIFO: mode |= S_IFIFO; break; default: return (EBADF); }; sb->st_mode = mode; >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-bugs" in the body of the message