A NOTE has been added to this issue. ====================================================================== https://austingroupbugs.net/view.php?id=1645 ====================================================================== Reported By: eblake Assigned To: ====================================================================== Project: 1003.1(2016/18)/Issue7+TC2 Issue ID: 1645 Category: System Interfaces Type: Clarification Requested Severity: Objection Priority: normal Status: New Name: Eric Blake Organization: Red Hat User Reference: ebb.execvp Section: XSH exec Page Number: 784 Line Number: 26548 Interp Status: --- Final Accepted Text: ====================================================================== Date Submitted: 2023-03-22 19:47 UTC Last Modified: 2023-05-11 16:05 UTC ====================================================================== Summary: execvp( ) requirements on arg0 are too strict ====================================================================== Relationships ID Summary ---------------------------------------------------------------------- related to 0000953 Alias expansion is under-specified related to 0001674 may posix_spawnp() fail with ENOEXEC? ======================================================================
---------------------------------------------------------------------- (0006281) geoffclare (manager) - 2023-05-11 16:05 https://austingroupbugs.net/view.php?id=1645#c6281 ---------------------------------------------------------------------- Interpretation response ------------------------ The standard states the value of arg0 to be passed to the sh utility, and conforming implementations must conform to this. However, concerns have been raised about this which are being referred to the sponsor. Rationale: ------------- The standard does not match some existing practice, and a different arg0 value is not observable by applications (without using extensions). Notes to the Editor (not part of this interpretation): ------------------------------------------------------- At page 784 lines 26552-26557 (XSH exec DESCRIPTION), change:<blockquote>...the executed command shall be as if the process invoked the <i>sh</i> utility using <i>execl</i>( ) as follows: <tt>execl(<shell path>, arg0, file, arg1, ..., (char *)0);</tt> where <<i>shell path</i>> is an unspecified pathname for the <i>sh</i> utility, <i>file</i> is the process image file, and for <i>execvp</i>( ), where <i>arg0</i>, <i>arg1</i>, and so on correspond to the values passed to <i>execvp</i>( ) in <i>argv</i>[0], <i>argv</i>[1], and so on.</blockquote>to:<blockquote>...the executed command shall be as if the process invoked the <i>sh</i> utility using <i>execl</i>( ) as follows: <tt>execl(<shell path>, <name>, file, <args>, (char *)0);</tt> where <<i>shell path</i>> is an unspecified pathname for the <i>sh</i> utility, <<i>name</i>> is an unspecified string, <i>file</i> is the process image file, and where <<i>args</i>> is zero or more parameters corresponding to any initial non-null arguments passed after <i>arg0</i> for <i>execlp</i>( ) or to any initial non-null members of <i>argv</i> starting at <i>argv</i>[1] for <i>execvp</i>( ).</blockquote> After page 794 line 26981 (XSH exec RATIONALE), add a new paragraph:<blockquote>When <i>execlp</i>( ) or <i>execvp</i>( ) fall back to invoking <i>sh</i> because of an ENOEXEC condition, the standard leaves the process name (what becomes <i>argv</i>[0] in the resulting sh process) unspecified. Existing implementations vary on whether they pass a variation of "sh", or preserve the original <i>arg0</i>. There are existing implementations of <i>sh</i> that behave differently depending on the contents of <i>argv</i>[0], such that blindly passing the original <i>arg0</i> on to the fallback execution can fail to invoke a compliant shell environment. Because of the requirements on how <i>sh</i> handles its command line arguments, the shell script will see $0 containing the pathname of the script being executed, regardless of the value of <i>argv</i>[0].</blockquote> Issue History Date Modified Username Field Change ====================================================================== 2023-03-22 19:47 eblake New Issue 2023-03-22 19:47 eblake Name => Eric Blake 2023-03-22 19:47 eblake Organization => Red Hat 2023-03-22 19:47 eblake User Reference => ebb.execvp 2023-03-22 19:47 eblake Section => XSH exec 2023-03-22 19:47 eblake Page Number => 784 2023-03-22 19:47 eblake Line Number => 26548 2023-03-22 19:47 eblake Interp Status => --- 2023-03-22 19:55 eblake Description Updated 2023-03-22 20:05 eblake Relationship added related to 0000953 2023-03-22 20:35 eblake Note Added: 0006226 2023-03-22 21:19 eblake Description Updated 2023-03-23 08:11 lacos Note Added: 0006228 2023-03-23 10:53 bastien Issue Monitored: bastien 2023-03-23 10:53 bastien Note Added: 0006231 2023-03-23 11:11 lacos Issue Monitored: lacos 2023-04-19 17:26 eblake Relationship added related to 0001674 2023-05-11 16:05 geoffclare Note Added: 0006281 ======================================================================