Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 7f59124

Browse files
committed
Clarified documentation for os.access().
Patch contributed by Sean Reifschneider. Closes SF patch #570618.
1 parent ae39ddd commit 7f59124

2 files changed

Lines changed: 12 additions & 6 deletions

File tree

Doc/lib/libos.tex

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -568,11 +568,13 @@ \subsection{File Descriptor Operations \label{os-fd-ops}}
568568
\subsection{Files and Directories \label{os-file-dir}}
569569

570570
\begin{funcdesc}{access}{path, mode}
571-
Check read/write/execute permissions for this process or existence of
572-
file \var{path}. \var{mode} should be \constant{F_OK} to test the
573-
existence of \var{path}, or it can be the inclusive OR of one or more
574-
of \constant{R_OK}, \constant{W_OK}, and \constant{X_OK} to test
575-
permissions. Return \code{1} if access is allowed, \code{0} if not.
571+
Use the real uid/gid to test for access to \var{path}. Note that most
572+
operations will use the effective uid/gid, therefore this routine can
573+
be used in a suid/sgid environment to test if the invoking user has the
574+
specified access to \var{path}. \var{mode} should be \constant{F_OK}
575+
to test the existence of \var{path}, or it can be the inclusive OR of
576+
one or more of \constant{R_OK}, \constant{W_OK}, and \constant{X_OK} to
577+
test permissions. Return \code{1} if access is allowed, \code{0} if not.
576578
See the \UNIX{} man page \manpage{access}{2} for more information.
577579
Availability: \UNIX, Windows.
578580
\end{funcdesc}

Modules/posixmodule.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -736,7 +736,11 @@ posix_do_stat(PyObject *self, PyObject *args, char *format,
736736

737737
PyDoc_STRVAR(posix_access__doc__,
738738
"access(path, mode) -> 1 if granted, 0 otherwise\n\
739-
Test for access to a file.");
739+
Use the real uid/gid to test for access to a path. Note that most
740+
operations will use the effective uid/gid, therefore this routine can
741+
be used in a suid/sgid environment to test if the invoking user has the
742+
specified access to the path. The mode argument can be F_OK to test
743+
existance, or the inclusive-OR of R_OK, W_OK, and X_OK.");
740744

741745
static PyObject *
742746
posix_access(PyObject *self, PyObject *args)

0 commit comments

Comments
 (0)