From owner-freebsd-ports Sat Dec 9 22:10:10 2000 From owner-freebsd-ports@FreeBSD.ORG Sat Dec 9 22:10:01 2000 Return-Path: Delivered-To: freebsd-ports@hub.freebsd.org Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id F037F37B401 for ; Sat, 9 Dec 2000 22:10:00 -0800 (PST) Received: (from gnats@localhost) by freefall.freebsd.org (8.11.1/8.11.1) id eBA6A0353572; Sat, 9 Dec 2000 22:10:00 -0800 (PST) (envelope-from gnats) Resent-Date: Sat, 9 Dec 2000 22:10:00 -0800 (PST) Resent-Message-Id: <200012100610.eBA6A0353572@freefall.freebsd.org> Resent-From: gnats-admin@FreeBSD.org (GNATS Management) Resent-To: freebsd-ports@FreeBSD.org Resent-Reply-To: gnats-admin@FreeBSD.org, mwm@mired.org Received: from guru.mired.org (okc-65-26-235-186.mmcable.com [65.26.235.186]) by hub.freebsd.org (Postfix) with SMTP id 261F237B400 for ; Sat, 9 Dec 2000 22:09:13 -0800 (PST) Received: (qmail 3813 invoked by uid 100); 10 Dec 2000 06:09:12 -0000 Message-Id: <20001210060912.3812.qmail@guru.mired.org> Date: 10 Dec 2000 06:09:12 -0000 From: mwm@mired.org Reply-To: mwm@mired.org To: FreeBSD-gnats-submit@freebsd.org X-Send-Pr-Version: 3.113 Subject: ports/23410: [PATCH] FreeBSD throws away information on failed #! execs; this recreates it Resent-Sender: gnats@FreeBSD.org Sender: owner-freebsd-ports@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.org >Number: 23410 >Category: ports >Synopsis: [PATCH] FreeBSD throws away information on failed #! execs; this recreates it >Confidential: no >Severity: non-critical >Priority: high >Responsible: freebsd-ports >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Sat Dec 09 22:10:00 PST 2000 >Closed-Date: >Last-Modified: >Originator: Mike Meyer >Release: FreeBSD 5.0-CURRENT i386 >Organization: Meyer Consulting >Environment: System: FreeBSD guru.mired.org 5.0-CURRENT FreeBSD 5.0-CURRENT #0: Sun Dec 3 05:30:23 CST 2000 mwm@guru.mired.org:/usr/obj/sharetmp/src/sys/GURU i386 >Description: See http://www.freebsd.org/cgi/query-pr.cgi?pr=22755 for a detailed description of the problem, and why this is being fixed in ports. >How-To-Repeat: See http://www.freebsd.org/cgi/query-pr.cgi?pr=22755 for a detailed description of the problem, and why this is being fixed in ports. >Fix: Add the following patch to the patches for the shell/bash2 port. That at least fixes the problem for bash2. I'm assuming alfred won't mind helping users of others shells fix theirs, as he advocates this solution. --- execute_cmd.c.orig Tue Jan 25 10:29:11 2000 +++ execute_cmd.c Sat Dec 9 23:59:00 2000 @@ -3311,11 +3311,30 @@ { struct stat finfo; int larray, i, fd; + unsigned char sample[80]; + int sample_len; SETOSTYPE (0); /* Some systems use for USG/POSIX semantics */ execve (command, args, env); SETOSTYPE (1); + fd = open (command, O_RDONLY); + if (fd >= 0) + { + sample_len = read (fd, (char *)sample, 80); + close (fd); + } + else + sample_len = 0; + +#if defined(HAVE_HASH_BANG_EXEC) + if (sample_len > 2 && sample[0] == '#' && sample[1] == '!' + && !access(command, X_OK | R_OK)) { + internal_error("%s: bad interpreter", command); + return EX_NOEXEC; + } +#endif + /* If we get to this point, then start checking out the file. Maybe it is something we can hack ourselves. */ if (errno != ENOEXEC) @@ -3336,38 +3355,30 @@ systems. Otherwise, check to see if it is a binary file by seeing if the first line (or up to 80 characters) are in the ASCII set. Execute the contents as shell commands. */ - fd = open (command, O_RDONLY); - if (fd >= 0) - { - unsigned char sample[80]; - int sample_len; - sample_len = read (fd, (char *)sample, 80); - close (fd); - - if (sample_len == 0) - return (EXECUTION_SUCCESS); + if (sample_len == 0) + return (EXECUTION_SUCCESS); - /* Is this supposed to be an executable script? - If so, the format of the line is "#! interpreter [argument]". - A single argument is allowed. The BSD kernel restricts - the length of the entire line to 32 characters (32 bytes - being the size of the BSD exec header), but we allow 80 - characters. */ - if (sample_len > 0) - { + /* Is this supposed to be an executable script? + If so, the format of the line is "#! interpreter [argument]". + A single argument is allowed. The BSD kernel restricts + the length of the entire line to 32 characters (32 bytes + being the size of the BSD exec header), but we allow 80 + characters. */ + if (sample_len > 0) + { #if !defined (HAVE_HASH_BANG_EXEC) - if (sample[0] == '#' && sample[1] == '!') - return (execute_shell_script (sample, sample_len, command, args, env)); - else + if (sample[0] == '#' && sample[1] == '!') + return (execute_shell_script (sample, sample_len, command, args, env)); + else #endif - if (check_binary_file (sample, sample_len)) - { - internal_error ("%s: cannot execute binary file", command); - return (EX_BINARY_FILE); - } - } - } + if (check_binary_file (sample, sample_len)) + { + internal_error ("%s: cannot execute binary file", command); + return (EX_BINARY_FILE); + } + } + initialize_subshell (); >Release-Note: >Audit-Trail: >Unformatted: To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-ports" in the body of the message