[CentOS] bash file direct execution

Will McDonald wmcdonald at gmail.com
Tue Aug 2 11:23:00 UTC 2005


On 02/08/05, dan1 <dan1 at edenpics.com> wrote:
> >On 02/08/05, dan1 <dan1 at edenpics.com> wrote:
> >> So the question is: does anybody know what program is in charge of
> >> parsing
> >> that '#!/bin/sh' information, which apparently makes an error in the
> >> parsing
> >
> >http://en.wikipedia.org/wiki/Shebang answers that.
> >
> >The "file" package will certainly be needed for this to function
> >correctly but I imagine your system would be really badly broken
> >without.
> >
> ># rpm -qf magic
> >file-4.12-1.FC3.1
> ># rpm -qi file
> >
> >Peter mentioned the possibility of your partitions being mounted
> >noexec, what's the output of a "mount" command?
> >
> >Will.
> Thanks for this explanation of the magic invocation.

No problem.

> I have tried the command you have stated above but had no results:
> [root at box /]# rpm -qf magic
> error: file magic: No such file or directory

Ah, I was sat in /usr/share/file at the time. Does...

$ ls -l /usr/share/file/magic /usr/share/magic
-rw-r--r--  1 root root 356854 Apr 28 06:08 /usr/share/file/magic
lrwxrwxrwx  1 root root     10 May 31 11:15 /usr/share/magic -> file/magic

Look OK on your system? If you actually less the file do its contents
look OK? You should have a bunch of enties along the lines of...

#------------------------------------------------------------------------------
# commands:  file(1) magic for various shells and interpreters
#
0       string          :                       shell archive or
script for antique ker
nel text
0       string/b        #!\ /bin/sh             Bourne shell script
text executable
0       string/b        #!\ /bin/csh            C shell script text executable
# korn shell magic, sent by George Wu, gwu at clyde.att.com
0       string/b        #!\ /bin/ksh            Korn shell script text
executable


> But that is the same with the working box.
> However, here is the result of the second command:
> [root at anoigo /]# rpm -qi file
> Name        : file                         Relocations: (not relocatable)
> Version     : 4.10                              Vendor: CentOS
> Release     : 2                             Build Date: Mon 21 Feb 2005
> 07:58:50
>  PM EST
> Install Date: Tue 02 Aug 2005 12:31:41 PM EDT      Build Host:
> guru.build.karan.
> org
> Group       : Applications/File             Source RPM: file-4.10-2.src.rpm
> Size        : 1330107                          License: distributable
> Signature   : DSA/SHA1, Sat 26 Feb 2005 03:37:03 PM EST, Key ID
> a53d0bab443e1821
> Packager    : Karanbir Singh <kbsingh at centos.org>
> Summary     : A utility for determining file types.
> Description :
> The file command is used to identify a particular file according to the
> type of data contained by the file.  File can identify many different
> file types, including ELF binaries, system libraries, RPM packages, and
> different graphics formats.

That shows the file package is installed.

> Here is also the output of the 'mount' command:
> 
> [root at box /]# mount
> /dev/md0 on / type ext3 (rw)
> none on /proc type proc (rw)
> none on /sys type sysfs (rw)
> none on /dev/pts type devpts (rw,gid=5,mode=620)
> usbfs on /proc/bus/usb type usbfs (rw)
> /dev/md1 on /boot type ext3 (rw)
> none on /dev/shm type tmpfs (rw)
> none on /proc/sys/fs/binfmt_misc type binfmt_misc (rw)
> sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw)

And that confirms that nothing's mounted noexec. :o\ I can't
specifically think of anything else that'd be causing this problem.

What happens if you just type in "ldd" without quotes, that's a shell
script and it's in your PATH.

What about aliases and the rest of your shell environment, is there
anything out of the ordinary in there? What's the output of set and
env ?



More information about the CentOS mailing list