2007-05-26 12:43:48 +00:00
|
|
|
.\" Copyright (C) 2003 Andries Brouwer (aeb@cwi.nl)
|
|
|
|
.\"
|
|
|
|
.\" Permission is granted to make and distribute verbatim copies of this
|
|
|
|
.\" manual provided the copyright notice and this permission notice are
|
|
|
|
.\" preserved on all copies.
|
|
|
|
.\"
|
|
|
|
.\" Permission is granted to copy and distribute modified versions of this
|
|
|
|
.\" manual under the conditions for verbatim copying, provided that the
|
|
|
|
.\" entire resulting derived work is distributed under the terms of a
|
|
|
|
.\" permission notice identical to this one.
|
|
|
|
.\"
|
|
|
|
.\" Since the Linux kernel and libraries are constantly changing, this
|
|
|
|
.\" manual page may be incorrect or out-of-date. The author(s) assume no
|
|
|
|
.\" responsibility for errors or omissions, or for damages resulting from
|
|
|
|
.\" the use of the information contained herein. The author(s) may not
|
|
|
|
.\" have taken the same level of care in the production of this manual,
|
|
|
|
.\" which is licensed free of charge, as they might when working
|
|
|
|
.\" professionally.
|
|
|
|
.\"
|
|
|
|
.\" Formatted or processed versions of this manual, if unaccompanied by
|
|
|
|
.\" the source, must acknowledge the copyright and authors of this work.
|
|
|
|
.\"
|
2009-12-05 06:01:02 +00:00
|
|
|
.TH PATH_RESOLUTION 7 2009-12-05 "Linux" "Linux Programmer's Manual"
|
2007-05-26 12:43:48 +00:00
|
|
|
.SH NAME
|
2009-12-05 06:26:44 +00:00
|
|
|
path_resolution \- how a pathname is resolved to a file
|
2007-05-26 12:43:48 +00:00
|
|
|
.SH DESCRIPTION
|
intro.1, time.1, accept.2, bind.2, connect.2, execve.2, flock.2, getdents.2, getpriority.2, getuid.2, intro.2, ioctl.2, mincore.2, mknod.2, personality.2, ptrace.2, read.2, recv.2, select_tut.2, send.2, sendfile.2, shmctl.2, sigaction.2, signal.2, stat.2, times.2, truncate.2, umask.2, wait.2, MB_CUR_MAX.3, MB_LEN_MAX.3, argz_add.3, btowc.3, clearenv.3, clock.3, cmsg.3, end.3, endian.3, errno.3, exit.3, fgetwc.3, fgetws.3, fopen.3, fputwc.3, fputws.3, fseek.3, fwide.3, getfsent.3, getgrnam.3, gethostid.3, getipnodebyname.3, getmntent.3, getpwnam.3, getwchar.3, grantpt.3, iconv.3, iconv_close.3, iconv_open.3, insque.3, intro.3, iswalnum.3, iswalpha.3, iswblank.3, iswcntrl.3, iswctype.3, iswdigit.3, iswgraph.3, iswlower.3, iswprint.3, iswpunct.3, iswspace.3, iswupper.3, iswxdigit.3, malloc.3, mblen.3, mbrlen.3, mbrtowc.3, mbsinit.3, mbsnrtowcs.3, mbsrtowcs.3, mbstowcs.3, mbtowc.3, mkstemp.3, mktemp.3, nl_langinfo.3, openpty.3, posix_openpt.3, printf.3, ptsname.3, putwchar.3, qecvt.3, rcmd.3, readdir.3, rexec.3, rpc.3, setnetgrent.3, shm_open.3, sigpause.3, stdin.3, stpcpy.3, strftime.3, strptime.3, syslog.3, towctrans.3, towlower.3, towupper.3, ttyslot.3, ungetwc.3, unlocked_stdio.3, wcpcpy.3, wcpncpy.3, wcrtomb.3, wcscasecmp.3, wcscat.3, wcschr.3, wcscmp.3, wcscpy.3, wcscspn.3, wcsdup.3, wcslen.3, wcsncasecmp.3, wcsncat.3, wcsncmp.3, wcsncpy.3, wcsnlen.3, wcsnrtombs.3, wcspbrk.3, wcsrchr.3, wcsrtombs.3, wcsspn.3, wcsstr.3, wcstok.3, wcstombs.3, wcswidth.3, wctob.3, wctomb.3, wctrans.3, wctype.3, wcwidth.3, wmemchr.3, wmemcmp.3, wmemcpy.3, wmemmove.3, wmemset.3, wprintf.3, console_ioctl.4, pts.4, elf.5, filesystems.5, hosts.5, proc.5, ttytype.5, boot.7, capabilities.7, credentials.7, epoll.7, glob.7, koi8-r.7, path_resolution.7, pty.7, signal.7, suffixes.7, time.7, unicode.7, unix.7, uri.7, utf-8.7: global fix: s/Unix/UNIX/
The man pages were rather inconsistent in the use of "Unix"
versus "UNIX". Let's go with the trademark usage.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2010-10-12 04:45:38 +00:00
|
|
|
Some UNIX/Linux system calls have as parameter one or more filenames.
|
2007-05-26 12:43:48 +00:00
|
|
|
A filename (or pathname) is resolved as follows.
|
intro.1, time.1, _syscall.2, accept.2, brk.2, capget.2, faccessat.2, futimesat.2, gethostname.2, intro.2, ioprio_set.2, kill.2, madvise.2, mlock.2, mount.2, msgget.2, perf_event_open.2, poll.2, readv.2, sched_rr_get_interval.2, sched_setscheduler.2, select.2, select_tut.2, shmget.2, stat.2, timer_create.2, ustat.2, vfork.2, wait.2, alloca.3, atexit.3, catopen.3, crypt.3, dbopen.3, fenv.3, fopen.3, getaddrinfo_a.3, gethostbyname.3, getutent.3, intro.3, login.3, mallopt.3, queue.3, regex.3, sigpause.3, sigsetops.3, stdio.3, strftime.3, strptime.3, sysconf.3, ttyslot.3, undocumented.3, cciss.4, console_codes.4, hpsa.4, initrd.4, intro.4, rtc.4, st.4, tty_ioctl.4, wavelan.4, acct.5, charmap.5, dir_colors.5, hosts.5, intro.5, termcap.5, utmp.5, intro.6, armscii-8.7, boot.7, bootparam.7, capabilities.7, cpuset.7, credentials.7, ddp.7, epoll.7, glob.7, intro.7, ip.7, ipv6.7, iso_8859-1.7, iso_8859-10.7, iso_8859-11.7, iso_8859-13.7, iso_8859-14.7, iso_8859-15.7, iso_8859-16.7, iso_8859-2.7, iso_8859-3.7, iso_8859-4.7, iso_8859-5.7, iso_8859-6.7, iso_8859-7.7, iso_8859-8.7, iso_8859-9.7, koi8-r.7, koi8-u.7, man-pages.7, man.7, math_error.7, netlink.7, numa.7, packet.7, path_resolution.7, pipe.7, pthreads.7, raw.7, rtnetlink.7, signal.7, socket.7, spufs.7, svipc.7, tcp.7, time.7, udp.7, udplite.7, unicode.7, unix.7, uri.7, utf-8.7, x25.7, intro.8: Global fix: use consistent capitalization in .SS headings
Capitalization in .SS sections across pages (and sometimes even
within a single page) is wildly inconsistent. Make it consistent.
Capitalize first word in heading, but otherwise use lower case,
except where English usage (e.g., proper nouns) or programming
language requirements (e.g., identifier names) dictate otherwise.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2013-02-24 14:08:38 +00:00
|
|
|
.SS "Step 1: start of the resolution process"
|
2008-06-09 15:49:35 +00:00
|
|
|
If the pathname starts with the \(aq/\(aq character,
|
|
|
|
the starting lookup directory
|
2007-12-27 16:06:35 +00:00
|
|
|
is the root directory of the calling process.
|
2007-05-26 12:43:48 +00:00
|
|
|
(A process inherits its
|
|
|
|
root directory from its parent.
|
|
|
|
Usually this will be the root directory
|
|
|
|
of the file hierarchy.
|
|
|
|
A process may get a different root directory
|
|
|
|
by use of the
|
|
|
|
.BR chroot (2)
|
|
|
|
system call.
|
2008-11-20 16:04:07 +00:00
|
|
|
A process may get an entirely private mount namespace in case
|
intro.1, fork.2, futex.2, open.2, rename.2, select_tut.2, semop.2, spu_create.2, stat.2, netlink.3, random.3, scanf.3, shm_open.3, strftime.3, console.4, console_codes.4, sk98lin.4, st.4, bootparam.7, cpuset.7, credentials.7, man-pages.7, path_resolution.7, uri.7: Global fix: remove spaces around em-dash
Normal English typographical convention is not to have
spaces around em dashes.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2011-10-03 06:47:35 +00:00
|
|
|
it\(emor one of its ancestors\(emwas started by an invocation of the
|
2007-05-26 12:43:48 +00:00
|
|
|
.BR clone (2)
|
2007-06-22 20:40:07 +00:00
|
|
|
system call that had the
|
2007-09-20 16:26:31 +00:00
|
|
|
.B CLONE_NEWNS
|
2007-06-22 20:40:07 +00:00
|
|
|
flag set.)
|
2008-06-09 15:49:35 +00:00
|
|
|
This handles the \(aq/\(aq part of the pathname.
|
2007-05-26 12:43:48 +00:00
|
|
|
|
2008-06-09 15:49:35 +00:00
|
|
|
If the pathname does not start with the \(aq/\(aq character, the
|
2007-05-26 12:43:48 +00:00
|
|
|
starting lookup directory of the resolution process is the current working
|
|
|
|
directory of the process.
|
|
|
|
(This is also inherited from the parent.
|
|
|
|
It can be changed by use of the
|
|
|
|
.BR chdir (2)
|
|
|
|
system call.)
|
|
|
|
|
2008-06-09 15:49:35 +00:00
|
|
|
Pathnames starting with a \(aq/\(aq character are called absolute pathnames.
|
|
|
|
Pathnames not starting with a \(aq/\(aq are called relative pathnames.
|
intro.1, time.1, _syscall.2, accept.2, brk.2, capget.2, faccessat.2, futimesat.2, gethostname.2, intro.2, ioprio_set.2, kill.2, madvise.2, mlock.2, mount.2, msgget.2, perf_event_open.2, poll.2, readv.2, sched_rr_get_interval.2, sched_setscheduler.2, select.2, select_tut.2, shmget.2, stat.2, timer_create.2, ustat.2, vfork.2, wait.2, alloca.3, atexit.3, catopen.3, crypt.3, dbopen.3, fenv.3, fopen.3, getaddrinfo_a.3, gethostbyname.3, getutent.3, intro.3, login.3, mallopt.3, queue.3, regex.3, sigpause.3, sigsetops.3, stdio.3, strftime.3, strptime.3, sysconf.3, ttyslot.3, undocumented.3, cciss.4, console_codes.4, hpsa.4, initrd.4, intro.4, rtc.4, st.4, tty_ioctl.4, wavelan.4, acct.5, charmap.5, dir_colors.5, hosts.5, intro.5, termcap.5, utmp.5, intro.6, armscii-8.7, boot.7, bootparam.7, capabilities.7, cpuset.7, credentials.7, ddp.7, epoll.7, glob.7, intro.7, ip.7, ipv6.7, iso_8859-1.7, iso_8859-10.7, iso_8859-11.7, iso_8859-13.7, iso_8859-14.7, iso_8859-15.7, iso_8859-16.7, iso_8859-2.7, iso_8859-3.7, iso_8859-4.7, iso_8859-5.7, iso_8859-6.7, iso_8859-7.7, iso_8859-8.7, iso_8859-9.7, koi8-r.7, koi8-u.7, man-pages.7, man.7, math_error.7, netlink.7, numa.7, packet.7, path_resolution.7, pipe.7, pthreads.7, raw.7, rtnetlink.7, signal.7, socket.7, spufs.7, svipc.7, tcp.7, time.7, udp.7, udplite.7, unicode.7, unix.7, uri.7, utf-8.7, x25.7, intro.8: Global fix: use consistent capitalization in .SS headings
Capitalization in .SS sections across pages (and sometimes even
within a single page) is wildly inconsistent. Make it consistent.
Capitalize first word in heading, but otherwise use lower case,
except where English usage (e.g., proper nouns) or programming
language requirements (e.g., identifier names) dictate otherwise.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2013-02-24 14:08:38 +00:00
|
|
|
.SS "Step 2: walk along the path"
|
2007-05-26 12:43:48 +00:00
|
|
|
Set the current lookup directory to the starting lookup directory.
|
accept.2, access.2, acct.2, clock_nanosleep.2, mbind.2, mincore.2, remap_file_pages.2, sched_setscheduler.2, set_mempolicy.2, splice.2, stat.2, syslog.2, timer_create.2, timerfd_create.2, truncate.2, fenv.3, ferror.3, fflush.3, fgetwc.3, fgetws.3, flockfile.3, fputwc.3, fputws.3, fread.3, getopt.3, gets.3, getwchar.3, glob.3, iconv.3, longjmp.3, pow.3, printf.3, puts.3, putwchar.3, regex.3, rpc.3, scanf.3, setjmp.3, termios.3, unlocked_stdio.3, wcswidth.3, hd.4, rtc.4, st.4, core.5, dir_colors.5, elf.5, proc.5, arp.7, ascii.7, boot.7, bootparam.7, charsets.7, futex.7, ip.7, iso_8859-11.7, man-pages.7, man.7, mdoc.samples.7, path_resolution.7, pipe.7, posixoptions.7, unicode.7, unix.7, uri.7, utf-8.7, ld.so.8: s/non-/non/
The tendency in English, as prescribed in style guides like
Chicago MoS, is towards removing hyphens after prefixes
like "non-" etc.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2010-01-16 17:20:12 +00:00
|
|
|
Now, for each nonfinal component of the pathname, where a component
|
2008-06-09 15:49:35 +00:00
|
|
|
is a substring delimited by \(aq/\(aq characters, this component is looked up
|
2007-05-26 12:43:48 +00:00
|
|
|
in the current lookup directory.
|
|
|
|
|
|
|
|
If the process does not have search permission on
|
|
|
|
the current lookup directory,
|
2007-06-22 18:25:23 +00:00
|
|
|
an
|
|
|
|
.B EACCES
|
|
|
|
error is returned ("Permission denied").
|
2007-05-26 12:43:48 +00:00
|
|
|
|
2007-06-22 20:40:07 +00:00
|
|
|
If the component is not found, an
|
|
|
|
.B ENOENT
|
|
|
|
error is returned
|
2007-05-26 12:43:48 +00:00
|
|
|
("No such file or directory").
|
|
|
|
|
|
|
|
If the component is found, but is neither a directory nor a symbolic link,
|
2007-06-22 18:25:23 +00:00
|
|
|
an
|
|
|
|
.B ENOTDIR
|
|
|
|
error is returned ("Not a directory").
|
2007-05-26 12:43:48 +00:00
|
|
|
|
|
|
|
If the component is found and is a directory, we set the
|
|
|
|
current lookup directory to that directory, and go to the
|
|
|
|
next component.
|
|
|
|
|
|
|
|
If the component is found and is a symbolic link (symlink), we first
|
|
|
|
resolve this symbolic link (with the current lookup directory
|
|
|
|
as starting lookup directory).
|
|
|
|
Upon error, that error is returned.
|
2007-06-22 18:25:23 +00:00
|
|
|
If the result is not a directory, an
|
|
|
|
.B ENOTDIR
|
|
|
|
error is returned.
|
2007-05-26 12:43:48 +00:00
|
|
|
If the resolution of the symlink is successful and returns a directory,
|
|
|
|
we set the current lookup directory to that directory, and go to
|
|
|
|
the next component.
|
|
|
|
Note that the resolution process here involves recursion.
|
|
|
|
In order to protect the kernel against stack overflow, and also
|
|
|
|
to protect against denial of service, there are limits on the
|
2007-06-08 10:58:53 +00:00
|
|
|
maximum recursion depth, and on the maximum number of symbolic links
|
2007-05-26 12:43:48 +00:00
|
|
|
followed.
|
2007-06-22 20:40:07 +00:00
|
|
|
An
|
|
|
|
.B ELOOP
|
|
|
|
error is returned when the maximum is
|
2007-05-26 12:43:48 +00:00
|
|
|
exceeded ("Too many levels of symbolic links").
|
|
|
|
.\"
|
|
|
|
.\" presently: max recursion depth during symlink resolution: 5
|
2007-06-08 10:58:53 +00:00
|
|
|
.\" max total number of symbolic links followed: 40
|
2007-05-26 12:43:48 +00:00
|
|
|
.\" _POSIX_SYMLOOP_MAX is 8
|
intro.1, time.1, _syscall.2, accept.2, brk.2, capget.2, faccessat.2, futimesat.2, gethostname.2, intro.2, ioprio_set.2, kill.2, madvise.2, mlock.2, mount.2, msgget.2, perf_event_open.2, poll.2, readv.2, sched_rr_get_interval.2, sched_setscheduler.2, select.2, select_tut.2, shmget.2, stat.2, timer_create.2, ustat.2, vfork.2, wait.2, alloca.3, atexit.3, catopen.3, crypt.3, dbopen.3, fenv.3, fopen.3, getaddrinfo_a.3, gethostbyname.3, getutent.3, intro.3, login.3, mallopt.3, queue.3, regex.3, sigpause.3, sigsetops.3, stdio.3, strftime.3, strptime.3, sysconf.3, ttyslot.3, undocumented.3, cciss.4, console_codes.4, hpsa.4, initrd.4, intro.4, rtc.4, st.4, tty_ioctl.4, wavelan.4, acct.5, charmap.5, dir_colors.5, hosts.5, intro.5, termcap.5, utmp.5, intro.6, armscii-8.7, boot.7, bootparam.7, capabilities.7, cpuset.7, credentials.7, ddp.7, epoll.7, glob.7, intro.7, ip.7, ipv6.7, iso_8859-1.7, iso_8859-10.7, iso_8859-11.7, iso_8859-13.7, iso_8859-14.7, iso_8859-15.7, iso_8859-16.7, iso_8859-2.7, iso_8859-3.7, iso_8859-4.7, iso_8859-5.7, iso_8859-6.7, iso_8859-7.7, iso_8859-8.7, iso_8859-9.7, koi8-r.7, koi8-u.7, man-pages.7, man.7, math_error.7, netlink.7, numa.7, packet.7, path_resolution.7, pipe.7, pthreads.7, raw.7, rtnetlink.7, signal.7, socket.7, spufs.7, svipc.7, tcp.7, time.7, udp.7, udplite.7, unicode.7, unix.7, uri.7, utf-8.7, x25.7, intro.8: Global fix: use consistent capitalization in .SS headings
Capitalization in .SS sections across pages (and sometimes even
within a single page) is wildly inconsistent. Make it consistent.
Capitalize first word in heading, but otherwise use lower case,
except where English usage (e.g., proper nouns) or programming
language requirements (e.g., identifier names) dictate otherwise.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2013-02-24 14:08:38 +00:00
|
|
|
.SS "Step 3: find the final entry"
|
2007-05-26 12:43:48 +00:00
|
|
|
The lookup of the final component of the pathname goes just like
|
|
|
|
that of all other components, as described in the previous step,
|
|
|
|
with two differences: (i) the final component need not be a
|
intro.1, fork.2, futex.2, open.2, rename.2, select_tut.2, semop.2, spu_create.2, stat.2, netlink.3, random.3, scanf.3, shm_open.3, strftime.3, console.4, console_codes.4, sk98lin.4, st.4, bootparam.7, cpuset.7, credentials.7, man-pages.7, path_resolution.7, uri.7: Global fix: remove spaces around em-dash
Normal English typographical convention is not to have
spaces around em dashes.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2011-10-03 06:47:35 +00:00
|
|
|
directory (at least as far as the path resolution process is
|
|
|
|
concerned\(emit may have to be a directory, or a nondirectory, because of
|
2007-05-26 12:43:48 +00:00
|
|
|
the requirements of the specific system call), and (ii) it
|
intro.1, fork.2, futex.2, open.2, rename.2, select_tut.2, semop.2, spu_create.2, stat.2, netlink.3, random.3, scanf.3, shm_open.3, strftime.3, console.4, console_codes.4, sk98lin.4, st.4, bootparam.7, cpuset.7, credentials.7, man-pages.7, path_resolution.7, uri.7: Global fix: remove spaces around em-dash
Normal English typographical convention is not to have
spaces around em dashes.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2011-10-03 06:47:35 +00:00
|
|
|
is not necessarily an error if the component is not found\(emmaybe
|
|
|
|
we are just creating it.
|
2007-05-26 12:43:48 +00:00
|
|
|
The details on the treatment
|
|
|
|
of the final entry are described in the manual pages of the specific
|
|
|
|
system calls.
|
|
|
|
.SS ". and .."
|
|
|
|
By convention, every directory has the entries "." and "..",
|
|
|
|
which refer to the directory itself and to its parent directory,
|
|
|
|
respectively.
|
|
|
|
|
|
|
|
The path resolution process will assume that these entries have
|
|
|
|
their conventional meanings, regardless of whether they are
|
2008-03-19 07:26:08 +00:00
|
|
|
actually present in the physical file system.
|
2007-05-26 12:43:48 +00:00
|
|
|
|
|
|
|
One cannot walk down past the root: "/.." is the same as "/".
|
|
|
|
.SS "Mount points"
|
|
|
|
After a "mount dev path" command, the pathname "path" refers to
|
2008-03-19 07:26:08 +00:00
|
|
|
the root of the file system hierarchy on the device "dev", and no
|
2007-05-26 12:43:48 +00:00
|
|
|
longer to whatever it referred to earlier.
|
|
|
|
|
2008-03-19 07:26:08 +00:00
|
|
|
One can walk out of a mounted file system: "path/.." refers to
|
2007-05-26 12:43:48 +00:00
|
|
|
the parent directory of "path",
|
2008-03-19 07:26:08 +00:00
|
|
|
outside of the file system hierarchy on "dev".
|
2007-05-26 12:43:48 +00:00
|
|
|
.SS "Trailing slashes"
|
2008-06-09 15:49:35 +00:00
|
|
|
If a pathname ends in a \(aq/\(aq, that forces resolution of the preceding
|
2007-05-26 12:43:48 +00:00
|
|
|
component as in Step 2: it has to exist and resolve to a directory.
|
2008-06-09 15:49:35 +00:00
|
|
|
Otherwise a trailing \(aq/\(aq is ignored.
|
|
|
|
(Or, equivalently, a pathname with a trailing \(aq/\(aq is equivalent to
|
|
|
|
the pathname obtained by appending \(aq.\(aq to it.)
|
2007-05-26 12:43:48 +00:00
|
|
|
.SS "Final symlink"
|
|
|
|
If the last component of a pathname is a symbolic link, then it
|
|
|
|
depends on the system call whether the file referred to will be
|
|
|
|
the symbolic link or the result of path resolution on its contents.
|
|
|
|
For example, the system call
|
|
|
|
.BR lstat (2)
|
|
|
|
will operate on the symlink, while
|
|
|
|
.BR stat (2)
|
|
|
|
operates on the file pointed to by the symlink.
|
|
|
|
.SS "Length limit"
|
|
|
|
There is a maximum length for pathnames.
|
|
|
|
If the pathname (or some
|
|
|
|
intermediate pathname obtained while resolving symbolic links)
|
2007-06-22 20:40:07 +00:00
|
|
|
is too long, an
|
|
|
|
.B ENAMETOOLONG
|
2011-09-09 13:37:15 +00:00
|
|
|
error is returned ("Filename too long").
|
2007-05-26 12:43:48 +00:00
|
|
|
.SS "Empty pathname"
|
intro.1, time.1, accept.2, bind.2, connect.2, execve.2, flock.2, getdents.2, getpriority.2, getuid.2, intro.2, ioctl.2, mincore.2, mknod.2, personality.2, ptrace.2, read.2, recv.2, select_tut.2, send.2, sendfile.2, shmctl.2, sigaction.2, signal.2, stat.2, times.2, truncate.2, umask.2, wait.2, MB_CUR_MAX.3, MB_LEN_MAX.3, argz_add.3, btowc.3, clearenv.3, clock.3, cmsg.3, end.3, endian.3, errno.3, exit.3, fgetwc.3, fgetws.3, fopen.3, fputwc.3, fputws.3, fseek.3, fwide.3, getfsent.3, getgrnam.3, gethostid.3, getipnodebyname.3, getmntent.3, getpwnam.3, getwchar.3, grantpt.3, iconv.3, iconv_close.3, iconv_open.3, insque.3, intro.3, iswalnum.3, iswalpha.3, iswblank.3, iswcntrl.3, iswctype.3, iswdigit.3, iswgraph.3, iswlower.3, iswprint.3, iswpunct.3, iswspace.3, iswupper.3, iswxdigit.3, malloc.3, mblen.3, mbrlen.3, mbrtowc.3, mbsinit.3, mbsnrtowcs.3, mbsrtowcs.3, mbstowcs.3, mbtowc.3, mkstemp.3, mktemp.3, nl_langinfo.3, openpty.3, posix_openpt.3, printf.3, ptsname.3, putwchar.3, qecvt.3, rcmd.3, readdir.3, rexec.3, rpc.3, setnetgrent.3, shm_open.3, sigpause.3, stdin.3, stpcpy.3, strftime.3, strptime.3, syslog.3, towctrans.3, towlower.3, towupper.3, ttyslot.3, ungetwc.3, unlocked_stdio.3, wcpcpy.3, wcpncpy.3, wcrtomb.3, wcscasecmp.3, wcscat.3, wcschr.3, wcscmp.3, wcscpy.3, wcscspn.3, wcsdup.3, wcslen.3, wcsncasecmp.3, wcsncat.3, wcsncmp.3, wcsncpy.3, wcsnlen.3, wcsnrtombs.3, wcspbrk.3, wcsrchr.3, wcsrtombs.3, wcsspn.3, wcsstr.3, wcstok.3, wcstombs.3, wcswidth.3, wctob.3, wctomb.3, wctrans.3, wctype.3, wcwidth.3, wmemchr.3, wmemcmp.3, wmemcpy.3, wmemmove.3, wmemset.3, wprintf.3, console_ioctl.4, pts.4, elf.5, filesystems.5, hosts.5, proc.5, ttytype.5, boot.7, capabilities.7, credentials.7, epoll.7, glob.7, koi8-r.7, path_resolution.7, pty.7, signal.7, suffixes.7, time.7, unicode.7, unix.7, uri.7, utf-8.7: global fix: s/Unix/UNIX/
The man pages were rather inconsistent in the use of "Unix"
versus "UNIX". Let's go with the trademark usage.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2010-10-12 04:45:38 +00:00
|
|
|
In the original UNIX, the empty pathname referred to the current directory.
|
2007-05-26 12:43:48 +00:00
|
|
|
Nowadays POSIX decrees that an empty pathname must not be resolved
|
|
|
|
successfully.
|
2007-06-22 20:40:07 +00:00
|
|
|
Linux returns
|
|
|
|
.B ENOENT
|
|
|
|
in this case.
|
2007-05-26 12:43:48 +00:00
|
|
|
.SS "Permissions"
|
|
|
|
The permission bits of a file consist of three groups of three bits, cf.\&
|
|
|
|
.BR chmod (1)
|
|
|
|
and
|
|
|
|
.BR stat (2).
|
|
|
|
The first group of three is used when the effective user ID of
|
2007-12-27 16:06:35 +00:00
|
|
|
the calling process equals the owner ID of the file.
|
2007-05-26 12:43:48 +00:00
|
|
|
The second group
|
|
|
|
of three is used when the group ID of the file either equals the
|
2007-12-27 16:06:35 +00:00
|
|
|
effective group ID of the calling process, or is one of the
|
|
|
|
supplementary group IDs of the calling process (as set by
|
2007-05-26 12:43:48 +00:00
|
|
|
.BR setgroups (2)).
|
|
|
|
When neither holds, the third group is used.
|
|
|
|
|
|
|
|
Of the three bits used, the first bit determines read permission,
|
|
|
|
the second write permission, and the last execute permission
|
|
|
|
in case of ordinary files, or search permission in case of directories.
|
|
|
|
|
|
|
|
Linux uses the fsuid instead of the effective user ID in permission checks.
|
|
|
|
Ordinarily the fsuid will equal the effective user ID, but the fsuid can be
|
|
|
|
changed by the system call
|
|
|
|
.BR setfsuid (2).
|
|
|
|
|
|
|
|
(Here "fsuid" stands for something like "file system user ID".
|
|
|
|
The concept was required for the implementation of a user space
|
|
|
|
NFS server at a time when processes could send a signal to a process
|
|
|
|
with the same effective user ID.
|
|
|
|
It is obsolete now.
|
|
|
|
Nobody should use
|
|
|
|
.BR setfsuid (2).)
|
|
|
|
|
|
|
|
Similarly, Linux uses the fsgid ("file system group ID")
|
|
|
|
instead of the effective group ID.
|
|
|
|
See
|
|
|
|
.BR setfsgid (2).
|
2008-03-19 07:26:08 +00:00
|
|
|
.\" FIXME say something about file system mounted read-only ?
|
2007-05-26 12:43:48 +00:00
|
|
|
.SS "Bypassing permission checks: superuser and capabilities"
|
intro.1, time.1, accept.2, bind.2, connect.2, execve.2, flock.2, getdents.2, getpriority.2, getuid.2, intro.2, ioctl.2, mincore.2, mknod.2, personality.2, ptrace.2, read.2, recv.2, select_tut.2, send.2, sendfile.2, shmctl.2, sigaction.2, signal.2, stat.2, times.2, truncate.2, umask.2, wait.2, MB_CUR_MAX.3, MB_LEN_MAX.3, argz_add.3, btowc.3, clearenv.3, clock.3, cmsg.3, end.3, endian.3, errno.3, exit.3, fgetwc.3, fgetws.3, fopen.3, fputwc.3, fputws.3, fseek.3, fwide.3, getfsent.3, getgrnam.3, gethostid.3, getipnodebyname.3, getmntent.3, getpwnam.3, getwchar.3, grantpt.3, iconv.3, iconv_close.3, iconv_open.3, insque.3, intro.3, iswalnum.3, iswalpha.3, iswblank.3, iswcntrl.3, iswctype.3, iswdigit.3, iswgraph.3, iswlower.3, iswprint.3, iswpunct.3, iswspace.3, iswupper.3, iswxdigit.3, malloc.3, mblen.3, mbrlen.3, mbrtowc.3, mbsinit.3, mbsnrtowcs.3, mbsrtowcs.3, mbstowcs.3, mbtowc.3, mkstemp.3, mktemp.3, nl_langinfo.3, openpty.3, posix_openpt.3, printf.3, ptsname.3, putwchar.3, qecvt.3, rcmd.3, readdir.3, rexec.3, rpc.3, setnetgrent.3, shm_open.3, sigpause.3, stdin.3, stpcpy.3, strftime.3, strptime.3, syslog.3, towctrans.3, towlower.3, towupper.3, ttyslot.3, ungetwc.3, unlocked_stdio.3, wcpcpy.3, wcpncpy.3, wcrtomb.3, wcscasecmp.3, wcscat.3, wcschr.3, wcscmp.3, wcscpy.3, wcscspn.3, wcsdup.3, wcslen.3, wcsncasecmp.3, wcsncat.3, wcsncmp.3, wcsncpy.3, wcsnlen.3, wcsnrtombs.3, wcspbrk.3, wcsrchr.3, wcsrtombs.3, wcsspn.3, wcsstr.3, wcstok.3, wcstombs.3, wcswidth.3, wctob.3, wctomb.3, wctrans.3, wctype.3, wcwidth.3, wmemchr.3, wmemcmp.3, wmemcpy.3, wmemmove.3, wmemset.3, wprintf.3, console_ioctl.4, pts.4, elf.5, filesystems.5, hosts.5, proc.5, ttytype.5, boot.7, capabilities.7, credentials.7, epoll.7, glob.7, koi8-r.7, path_resolution.7, pty.7, signal.7, suffixes.7, time.7, unicode.7, unix.7, uri.7, utf-8.7: global fix: s/Unix/UNIX/
The man pages were rather inconsistent in the use of "Unix"
versus "UNIX". Let's go with the trademark usage.
Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
2010-10-12 04:45:38 +00:00
|
|
|
On a traditional UNIX system, the superuser
|
2007-05-26 12:43:48 +00:00
|
|
|
.RI ( root ,
|
|
|
|
user ID 0) is all-powerful, and bypasses all permissions restrictions
|
|
|
|
when accessing files.
|
|
|
|
.\" (but for exec at least one x bit must be set) -- AEB
|
|
|
|
.\" but there is variation across systems on this point: for
|
|
|
|
.\" example, HP-UX and Tru64 are as described by AEB. However,
|
|
|
|
.\" on some implementations (e.g., Solaris, FreeBSD),
|
|
|
|
.\" access(X_OK) by superuser will report success, regardless
|
|
|
|
.\" of the file's execute permission bits. -- MTK (Oct 05)
|
|
|
|
|
|
|
|
On Linux, superuser privileges are divided into capabilities (see
|
|
|
|
.BR capabilities (7)).
|
|
|
|
Two capabilities are relevant for file permissions checks:
|
2007-06-20 22:15:34 +00:00
|
|
|
\fBCAP_DAC_OVERRIDE\fP and \fBCAP_DAC_READ_SEARCH\fP.
|
2007-05-26 12:43:48 +00:00
|
|
|
(A process has these capabilities if its fsuid is 0.)
|
|
|
|
|
2007-06-20 22:15:34 +00:00
|
|
|
The \fBCAP_DAC_OVERRIDE\fP capability overrides all permission checking,
|
2007-05-26 12:43:48 +00:00
|
|
|
but only grants execute permission when at least one
|
|
|
|
of the file's three execute permission bits is set.
|
|
|
|
|
2007-06-20 22:15:34 +00:00
|
|
|
The \fBCAP_DAC_READ_SEARCH\fP capability grants read and search permission
|
2007-05-26 12:43:48 +00:00
|
|
|
on directories, and read permission on ordinary files.
|
|
|
|
.\" FIXME say something about immutable files
|
|
|
|
.\" FIXME say something about ACLs
|
|
|
|
.SH "SEE ALSO"
|
2009-12-05 06:01:02 +00:00
|
|
|
.BR readlink (2),
|
2007-06-08 07:57:18 +00:00
|
|
|
.BR capabilities (7),
|
2008-06-11 21:50:53 +00:00
|
|
|
.BR credentials (7),
|
2008-06-11 22:19:03 +00:00
|
|
|
.BR symlink (7)
|