From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-2.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL autolearn=ham autolearn_force=no version=3.4.2 Received: from mother.openwall.net (mother.openwall.net [195.42.179.200]) by inbox.vuxu.org (OpenSMTPD) with SMTP id e86fab5c for ; Wed, 12 Feb 2020 13:55:42 +0000 (UTC) Received: (qmail 12168 invoked by uid 550); 12 Feb 2020 13:55:41 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Reply-To: musl@lists.openwall.com Received: (qmail 12132 invoked from network); 12 Feb 2020 13:55:40 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bell-sw-com.20150623.gappssmtp.com; s=20150623; h=from:subject:to:message-id:date:user-agent:mime-version :content-transfer-encoding:content-language; bh=9t8YXuX/ZZ8DTpmWudnRyfAHhvrMirXQcrGEG5sV0ko=; b=yHuznioHxIM0dFg5JgvZ5uFjgG4D84SzUZzGWwdcacNibTzmis2/VaT8fvnVqysOFR K7ojxFCrhPldWS9RcvaZfZSCtelJsjYiyWHhLKo2xFvMnTfg0/LNuPf+pIL7NA9Lt+1x AbzlE+0XiB5Vqf0pQipB2KI5WogSCWGDSBFKoddjfXjb5mNcfKPzua54bwlWG1DkZ7Q8 LclkotPHYw/QnedwOKBEhTfYqL3+zs4Jia2qj+WIAdU47EWR2R9S/BtsiwQ8S4wr+Lll u48DXGUMkGm1mjrV/u951q4IlbUu6eIWCuHxpjIsixaOfleAoHd7QzZY52+pNMfFwRDy UVNA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:subject:to:message-id:date:user-agent :mime-version:content-transfer-encoding:content-language; bh=9t8YXuX/ZZ8DTpmWudnRyfAHhvrMirXQcrGEG5sV0ko=; b=Z4XTl+7XBzlqQ03lsH/m0XejbXxOfWfrLYr3QbN1+BvLs3eIAk4j0KpycYomodfmCh EdWbwUq/4u/mGFdP9QBuelffuf0S7jVvd550XpTRpLKnYCfEdabWOoJ59v+xSZ2L6dOK KhTXESmeMQ5kU+tqrxDBUFhmQ/yxuykan9FvsvPII13yl73zajdcRESUQAIxbl9tW/eo rZcNKWQ1TroHqWC4mcYqMQxwKOV60njwCIBJt8E0ouyHf9CZOvHtiU0Gd6SXTfWfxCiT foB0Z5AeeBjiKLLvZjPlQXfyU9f3NkIaubZLg1aa38G1nK9f+cgRF4Kj/mvHoSI/wI16 n2mQ== X-Gm-Message-State: APjAAAW4w0e977oVDELhs+5raa7ms7eeKVvlxCBDBo6hONuVPOe6Y4fB qfvcw+qpqOFXp0PHGrjzQRsfWVaS5tE= X-Google-Smtp-Source: APXvYqznOXn5w1rTR9lny8m/ZKQdL2oikHVy+zC9oyxsx6XFGUTCrT7SDQKyqmnw7R3M9+uLahA5XA== X-Received: by 2002:a19:c7d8:: with SMTP id x207mr6819949lff.142.1581515728862; Wed, 12 Feb 2020 05:55:28 -0800 (PST) From: Alexander Scherbatiy To: musl@lists.openwall.com Message-ID: <6ead5f7b-d645-5df0-cb06-a99178471a96@bell-sw.com> Date: Wed, 12 Feb 2020 16:54:37 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US Subject: [musl] execvp() behaviour with unrecognized file header Hello, execvp() works differently on Linux Alpine and Ubuntu if it is called with a file which does not contain a proper shebang line. The file is executed on Ubuntu. It results to  ENOEXEC error on Linux Alpine. man execvp on Ubuntu has description: "If the header of a file isn't recognized (the attempted execve(2) failed with the error ENOEXEC), these functions will execute the shell (/bin/sh) with the path of the file as its first argument." Does execvp() from musl behaves differently by purpose in this case? The sample code: ---- execvp_sample.c  ---- #include #include #include #include int main(int argc, char* argv[]) {     char *file = argv[1];     char *execvp_argv[1] = {NULL};     execvp(file, execvp_argv);     exit(errno); } -------------------------------------- gcc -o execvp_sample execvp_sample.c ---- script_1.sh --- #!/bin/bash echo Hello, World! ---------------------- Ubuntu: > ./execvp_sample ./script_1.sh Hello, World! ---- script_2.sh --- #!/bin/ash echo Hello, World! ---------------------- Alpine Linux: > ./execvp_sample ./script_2.sh Hello, World! ---- script_3.sh --- echo Hello, World! ---------------------- Ubuntu: > ./execvp_sample ./script_3.sh Hello, World! Alpine Linux: > ./execvp_sample ./script_3.sh error code: ENOEXEC Thanks, Alexander.