Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 13 Nov 2008 13:09:25 -0600
From:      Dan Nelson <dnelson@allantgroup.com>
To:        Charles Darwin <darwinskernel@gmail.com>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: Is chflags' "nodump + sunlnk" = "uchg"
Message-ID:  <20081113190925.GA22629@dan.emsphone.com>
In-Reply-To: <318554EF-A7A4-41B6-8B81-6C3B9AFF4013@gmail.com>
References:  <99926641-6491-4F76-B2D2-73B1C6D52033@gmail.com> <20081112234345.GL85407@dan.emsphone.com> <318554EF-A7A4-41B6-8B81-6C3B9AFF4013@gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
In the last episode (Nov 13), Charles Darwin said:
> On 12-Nov-08, at 6:43 PM, Dan Nelson wrote:
> > In the last episode (Nov 12), Charles Darwin said:
> >> Hi all,
> >>
> >> Title is the question actually:  Is chflags' "nodump + sunlnk" =
> >> "uchg"
> >
> > No; why would it be?
>
> I mean as far as their effect on a directory; doesn't "Don't change"
> for a directory mean "Don't add + Don't remove"?

Ok, that's sort of a different question.  "nodump" is only checked by
/sbin/dump, so we'll skip that.  "sunlnk" is a root-only flag, while
"uchg" can be set or reset by the file's owner as well.  So let's look
at "uunlnk" and "uchg":

$ mkdir lnk chg
$ touch lnk/file1 chg/file1
$ chflags uunlnk lnk ; chflags uchg chg
$ ls -lo
total 8
drwxr-xr-x   4 dan   wheel  -       512 Nov 13 12:59 ./
drwxrwxrwt  24 root  wheel  -      1024 Nov 13 12:59 ../
drwxr-xr-x   2 dan   wheel  uchg    512 Nov 13 12:59 chg/
drwxr-xr-x   2 dan   wheel  uunlnk  512 Nov 13 12:59 lnk/
$ rm chg/file1
rm: chg/file1: Operation not permitted
$ rm lnk/file1
$ touch chg/file2
touch: chg/file2: Operation not permitted
$ touch lnk/file2
$ rm lnk/file2
$ mv chg chg1
mv: rename chg to chg1: Operation not permitted
$ mv lnk lnk1
mv: rename lnk to lnk1: Operation not permitted
$ rmdir chg
rmdir: chg: Operation not permitted
$ rmdir lnk
rmdir: lnk: Operation not permitted

So as far as directories are concerned, the only difference between
uchg and uunlnk is that uchg prohibits creation and deletion of files
inside it, and uunlnk allows it.

You can also look at /sys/ufs/ufs/ufs_vnops.c and see what code looks
at which flags.

-- 
	Dan Nelson
	dnelson@allantgroup.com



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20081113190925.GA22629>