Bug#981171: [PATCH 04/13] Document PATH resolution
Yes, you are right. Le jeu. 28 janv. 2021 à 09:25, Michael Kerrisk (man-pages) a écrit : > > Hello Bastien, > > On 1/27/21 4:48 PM, roucaries.bast...@gmail.com wrote: > > From: Bastien Roucariès > > > > Document PATH resolution, particularly null sequence and empty PATH > > > > Signed-off-by: Bastien Roucariès > > --- > > man7/environ.7 | 42 ++ > > 1 file changed, 34 insertions(+), 8 deletions(-) > > > > diff --git a/man7/environ.7 b/man7/environ.7 > > index 8fc26bb92..11f30c332 100644 > > --- a/man7/environ.7 > > +++ b/man7/environ.7 > > @@ -68,7 +68,8 @@ The name of the logged-in user (used by some BSD-derived > > programs). > > Set at login time, see section NOTES below. > > .TP > > .B LOGNAME > > -The name of the logged-in user (used by some System-V derived programs). > > +The name of the logged-in user (used by some System-V derived programs > > +and POSIX.1-2017). > > Please don't include unrelated changes in the same patch. > > > Set at login time, see section NOTES below. > > .TP > > .B HOME > > @@ -94,19 +95,27 @@ for further details of the > > environment variables). > > .TP > > .B PATH > > -The sequence of directory prefixes that > > -.BR sh (1) > > -and many other > > -programs apply in searching for a file known by an incomplete pathname. > > -The prefixes are separated by \(aq\fB:\fP\(aq. > > -(Similarly one has > > +The list of places that shells and other programs look in to find > > +a command when given an incomplete pathname. Elements on this > > +colon-separated (\(aq\fB:\fP\(aq) list may be absolute or relative > > directory > > +names or the zero-length string (interpreted as meaning the > > +current directory, see section BUGS below). > > +.B PATH > > +is checked element by element (left to right), applying that directory > > +name as a prefix to the pathname (if it does not already > > +end in a slash, the expansion will insert one between > > +the prefix and the filename), > > +until a file is found with the appropriate name and execution > > +permissions. > > +.IP > > +Similarly one has > > .B CDPATH > > used by some shells to find the target > > of a change directory command, > > .B MANPATH > > used by > > .BR man (1) > > -to find manual pages, and so on) > > +to find manual pages, and so on. > > .TP > > .B PWD > > The current working directory. > > @@ -254,6 +263,9 @@ and > > are specified by > > POSIX.1-1996 > > and should be reasonably portable. > > +.PP > > +.B PATH > > +behavior is specified by POSIX.1-2017. > > When you write this, it implies that the behavior was not specified > in earlier in earlier versions of POSIX. Is that true? > > > .SH NOTES > > The > > .BR prctl (2) > > @@ -292,6 +304,12 @@ preserves all the variables from the existing shell, > > and > > or > > .I su -l > > is the recommended way of getting a full root environment. > > +.PP > > +The default search path (used when the environment > > +does not contain the variable \fBPATH\fR) > > +shows some variation across systems. See > > +.B execlp (3) > > +for documentation of the exact behavior. > > .SH BUGS > > Clearly there is a security risk here. > > Many a system command has been > > @@ -330,6 +348,13 @@ The authors of > > .I gzip > > should consider renaming their option to > > .BR GZIP_OPT . > > +.PP > > +A zero-length element in > > +.B PATH, > > +which appears as two adjacent colons \(aq\fB::\fP\(aq or as a leading > > +or trailing colon on the list, is replaced by implicit \(aq\fB.\fP\(aq. > > +In order to be portable and strictly conformant to POSIX.1-2017, a user > > +should use instead an explicit \(aq\fB.\fP\(aq. > > .SH SEE ALSO > > .BR bash (1), > > .BR csh (1), > > @@ -343,6 +368,7 @@ should consider renaming their option to > > .BR execve (2), > > .BR clearenv (3), > > .BR exec (3), > > +.BR execlp (3), > > I think this line isn't needed. You mention execlp(3) already above. > > > .BR getenv (3), > > .BR putenv (3), > > .BR setenv (3), > > I generally like the idea of this patch, but I can't apply it > because of > (a) My first comment above > (b) It depends on earlier patches that I havne't applied. > > Thanks, > > Michael > > > -- > Michael Kerrisk > Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/ > Linux/UNIX System Programming Training: http://man7.org/training/
Bug#981171: [PATCH 04/13] Document PATH resolution
Hello Bastien, On 1/27/21 4:48 PM, roucaries.bast...@gmail.com wrote: > From: Bastien Roucariès > > Document PATH resolution, particularly null sequence and empty PATH > > Signed-off-by: Bastien Roucariès > --- > man7/environ.7 | 42 ++ > 1 file changed, 34 insertions(+), 8 deletions(-) > > diff --git a/man7/environ.7 b/man7/environ.7 > index 8fc26bb92..11f30c332 100644 > --- a/man7/environ.7 > +++ b/man7/environ.7 > @@ -68,7 +68,8 @@ The name of the logged-in user (used by some BSD-derived > programs). > Set at login time, see section NOTES below. > .TP > .B LOGNAME > -The name of the logged-in user (used by some System-V derived programs). > +The name of the logged-in user (used by some System-V derived programs > +and POSIX.1-2017). Please don't include unrelated changes in the same patch. > Set at login time, see section NOTES below. > .TP > .B HOME > @@ -94,19 +95,27 @@ for further details of the > environment variables). > .TP > .B PATH > -The sequence of directory prefixes that > -.BR sh (1) > -and many other > -programs apply in searching for a file known by an incomplete pathname. > -The prefixes are separated by \(aq\fB:\fP\(aq. > -(Similarly one has > +The list of places that shells and other programs look in to find > +a command when given an incomplete pathname. Elements on this > +colon-separated (\(aq\fB:\fP\(aq) list may be absolute or relative directory > +names or the zero-length string (interpreted as meaning the > +current directory, see section BUGS below). > +.B PATH > +is checked element by element (left to right), applying that directory > +name as a prefix to the pathname (if it does not already > +end in a slash, the expansion will insert one between > +the prefix and the filename), > +until a file is found with the appropriate name and execution > +permissions. > +.IP > +Similarly one has > .B CDPATH > used by some shells to find the target > of a change directory command, > .B MANPATH > used by > .BR man (1) > -to find manual pages, and so on) > +to find manual pages, and so on. > .TP > .B PWD > The current working directory. > @@ -254,6 +263,9 @@ and > are specified by > POSIX.1-1996 > and should be reasonably portable. > +.PP > +.B PATH > +behavior is specified by POSIX.1-2017. When you write this, it implies that the behavior was not specified in earlier in earlier versions of POSIX. Is that true? > .SH NOTES > The > .BR prctl (2) > @@ -292,6 +304,12 @@ preserves all the variables from the existing shell, and > or > .I su -l > is the recommended way of getting a full root environment. > +.PP > +The default search path (used when the environment > +does not contain the variable \fBPATH\fR) > +shows some variation across systems. See > +.B execlp (3) > +for documentation of the exact behavior. > .SH BUGS > Clearly there is a security risk here. > Many a system command has been > @@ -330,6 +348,13 @@ The authors of > .I gzip > should consider renaming their option to > .BR GZIP_OPT . > +.PP > +A zero-length element in > +.B PATH, > +which appears as two adjacent colons \(aq\fB::\fP\(aq or as a leading > +or trailing colon on the list, is replaced by implicit \(aq\fB.\fP\(aq. > +In order to be portable and strictly conformant to POSIX.1-2017, a user > +should use instead an explicit \(aq\fB.\fP\(aq. > .SH SEE ALSO > .BR bash (1), > .BR csh (1), > @@ -343,6 +368,7 @@ should consider renaming their option to > .BR execve (2), > .BR clearenv (3), > .BR exec (3), > +.BR execlp (3), I think this line isn't needed. You mention execlp(3) already above. > .BR getenv (3), > .BR putenv (3), > .BR setenv (3), I generally like the idea of this patch, but I can't apply it because of (a) My first comment above (b) It depends on earlier patches that I havne't applied. Thanks, Michael -- Michael Kerrisk Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/ Linux/UNIX System Programming Training: http://man7.org/training/
Bug#981171: [PATCH 04/13] Document PATH resolution
From: Bastien Roucariès Document PATH resolution, particularly null sequence and empty PATH Signed-off-by: Bastien Roucariès --- man7/environ.7 | 42 ++ 1 file changed, 34 insertions(+), 8 deletions(-) diff --git a/man7/environ.7 b/man7/environ.7 index 8fc26bb92..11f30c332 100644 --- a/man7/environ.7 +++ b/man7/environ.7 @@ -68,7 +68,8 @@ The name of the logged-in user (used by some BSD-derived programs). Set at login time, see section NOTES below. .TP .B LOGNAME -The name of the logged-in user (used by some System-V derived programs). +The name of the logged-in user (used by some System-V derived programs +and POSIX.1-2017). Set at login time, see section NOTES below. .TP .B HOME @@ -94,19 +95,27 @@ for further details of the environment variables). .TP .B PATH -The sequence of directory prefixes that -.BR sh (1) -and many other -programs apply in searching for a file known by an incomplete pathname. -The prefixes are separated by \(aq\fB:\fP\(aq. -(Similarly one has +The list of places that shells and other programs look in to find +a command when given an incomplete pathname. Elements on this +colon-separated (\(aq\fB:\fP\(aq) list may be absolute or relative directory +names or the zero-length string (interpreted as meaning the +current directory, see section BUGS below). +.B PATH +is checked element by element (left to right), applying that directory +name as a prefix to the pathname (if it does not already +end in a slash, the expansion will insert one between +the prefix and the filename), +until a file is found with the appropriate name and execution +permissions. +.IP +Similarly one has .B CDPATH used by some shells to find the target of a change directory command, .B MANPATH used by .BR man (1) -to find manual pages, and so on) +to find manual pages, and so on. .TP .B PWD The current working directory. @@ -254,6 +263,9 @@ and are specified by POSIX.1-1996 and should be reasonably portable. +.PP +.B PATH +behavior is specified by POSIX.1-2017. .SH NOTES The .BR prctl (2) @@ -292,6 +304,12 @@ preserves all the variables from the existing shell, and or .I su -l is the recommended way of getting a full root environment. +.PP +The default search path (used when the environment +does not contain the variable \fBPATH\fR) +shows some variation across systems. See +.B execlp (3) +for documentation of the exact behavior. .SH BUGS Clearly there is a security risk here. Many a system command has been @@ -330,6 +348,13 @@ The authors of .I gzip should consider renaming their option to .BR GZIP_OPT . +.PP +A zero-length element in +.B PATH, +which appears as two adjacent colons \(aq\fB::\fP\(aq or as a leading +or trailing colon on the list, is replaced by implicit \(aq\fB.\fP\(aq. +In order to be portable and strictly conformant to POSIX.1-2017, a user +should use instead an explicit \(aq\fB.\fP\(aq. .SH SEE ALSO .BR bash (1), .BR csh (1), @@ -343,6 +368,7 @@ should consider renaming their option to .BR execve (2), .BR clearenv (3), .BR exec (3), +.BR execlp (3), .BR getenv (3), .BR putenv (3), .BR setenv (3), -- 2.29.2