On 2010-May-02 01:44:51 +0800, Edward Ned Harvey <solar...@nedharvey.com> wrote:
>Obviously, the kernel has the facility to open an inode by number.  However,
>for security reasons (enforcing permissions of parent directories before the
>parent directories have been identified), the ability to open an arbitrary
>inode by number is not normally made available to user level applications,
>except perhaps when run by root.

There is no provision in normal Unix to open a file by inode from
userland.  Some filesystems (eg HP Tru64) may expose a special
pseudo-directoy that exposes all the inodes.  Note that opening a
file by inode number is a completely different issue to mapping an
inode number to a pathname.

>because:  (a) every directory contains an entry ".." which refers to its
>parent by number, and (b) every directory has precisely one parent, and no
>more.  There is no such thing as a hardlink copy of a directory.  Therefore,
>there is exactly one absolute path to any directory in any ZFS filesystem.

s/is/should be/ - I haven't checked with ZFS but it may be possible to
trick/corrupt the filesystem into allowing a second real name (though
the filesystem is then inconsistent).

>If the kernel (or root) can open an arbitrary directory by inode number,
>then the kernel (or root) can find the inode number of its parent by looking
>at the '..' entry, which the kernel (or root) can then open, and identify
>both:  the name of the child subdir whose inode number is already known, and
>(b) yet another '..' entry.  The kernel (or root) can repeat this process
>recursively, up to the root of the filesystem tree.  At that time, the
>kernel (or root) has completely identified the absolute path of the inode
>that it started with.

Any user can do this (subject to permissions) and this is how 'pwd'
was traditionally implemented.  Note that you need to check device and
inode, not just inode, to correctly handle mountpoints.

-- 
Peter Jeremy

Attachment: pgpsc9geRSx95.pgp
Description: PGP signature

_______________________________________________
zfs-discuss mailing list
zfs-discuss@opensolaris.org
http://mail.opensolaris.org/mailman/listinfo/zfs-discuss

Reply via email to