From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/12593 Path: news.gmane.org!.POSTED!not-for-mail From: "Siebenborn, Axel" Newsgroups: gmane.linux.lib.musl.general Subject: No fallback to /bin/sh in execvp Date: Fri, 9 Mar 2018 12:23:06 +0000 Message-ID: <3a04ed7d2f8748a79941a3676658fc25@sap.com> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-Trace: blaine.gmane.org 1520598082 815 195.159.176.226 (9 Mar 2018 12:21:22 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Fri, 9 Mar 2018 12:21:22 +0000 (UTC) To: "musl@lists.openwall.com" Original-X-From: musl-return-12607-gllmg-musl=m.gmane.org@lists.openwall.com Fri Mar 09 13:21:18 2018 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.84_2) (envelope-from ) id 1euH1R-00007M-Tg for gllmg-musl@m.gmane.org; Fri, 09 Mar 2018 13:21:18 +0100 Original-Received: (qmail 24152 invoked by uid 550); 9 Mar 2018 12:23:20 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 24103 invoked from network); 9 Mar 2018 12:23:19 -0000 Thread-Topic: No fallback to /bin/sh in execvp Thread-Index: AdO3nwXUH97g8DoOQUWtYADufxl2wA== Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.21.23.236] Xref: news.gmane.org gmane.linux.lib.musl.general:12593 Archived-At: Hi, I encountered a problem with execvp with musl. Trying to execute shell scripts without #! fails with ENOEXEC. However, according to the standard, execvp should fallback to execute the f= ile using /bin/sh. A simple test: Create a script file 'prog' without '!#' with the following content and m= ake it executable: /bin/echo "$@"=20 Compile and run the following c-program: #include #include #include #include int main (){ int ret; char *cmd[] =3D { "./prog","Hello", "World", (char *)0 }; ret =3D execvp ("./prog", cmd); int errorNumber =3D errno; printf("Error code: %d. Error message: %s\n", errorNumber, strerror(error= Number)); } With musl the execution results in the following error: Error code: 8. Error message: Exec format error With glibs 'Hello world' is printed. Is this a bug, that will be fixed someday or intended behavior for security= reasons. I think it's a quiet a strange way to execute shell commands. However, some= ancient code might rely on this=20 and compatibility wins over sanity, Kind regards, Axel