bash file direct execution

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



Since /home/user is probably not on your path (for good security reasons),
I would not expect this to run anyway.

Try moving it to /home/user/bin or a directory that is in your path.

On my CentOS4.1 system, putting it in /root does not make it work - I
still have to do ./test.sh.  /root is not in the path.  QED.

What are the directory permissions as well?  ls -ld /home/user and compare
with ls -ld /root or wherever it runs OK.  You only need execute access on
a directory to be able to use it but you need read access if you want to
find a file in it.

Have you tried strace?

strace ./test.sh 2>&1 > test.trace (or whatever)

will put a lot of stuff in test.trace.  Usually it is some permission
issue as you can execute it from root but not from your home directory.

Look for permission denied and other strings in the output.

Most of the obvious possibilities have already been discussed -
reinstalling coreutils or binutils or whatever, filesystem mounted noexec
(that's caught me out a few times - now I have a great big README in the
root directory of any noexec filesystem).

HTH

John

John Logsdon                               "Try to make things as simple
Quantex Research Ltd, Manchester UK         as possible but not simpler"
j.logsdon@xxxxxxxxxxxxxxxxxxxx              a.einstein@xxxxxxxxxxxxxx
+44(0)161 445 4951/G:+44(0)7717758675       www.quantex-research.com


On Tue, 2 Aug 2005, dan1 wrote:

> Hello, Will. Inline answers are below..
> 
> >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?
> 
> Yes, exactly the same.
> 
> >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 kernel 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@xxxxxxxxxxxxx
> >0       string/b        #!\ /bin/ksh            Korn shell script text
> >executable
> 
> Yes, exactly the same lines of code. At least, now I know a bit more how the 
> shell is run when directly running the command. :-)
> 
> >What happens if you just type in "ldd" without quotes, that's a shell
> >script and it's in your PATH.
> 
> This is something interesting. If I run 'ldd', it works.
> Now I copied this script to the / directory and run it again with /ldd. That 
> works too.
> Now I have transformed that file into my little echo script:
> #!/bin/sh
> echo testing
> 
> And that works too. So I have now two files (/ldd and /ldd2) which are 
> scripts and which contains exactly the same content and which behaves 
> differently, from the same directory. One is done from scratch and the other 
> is modified from another working script.
> 
> Again each file's contents:
> #! /bin/sh
> echo testing
> 
> The result is the following when executed:
> [root@box /]# ./ldd
> testing
> [root@box /]# ./ldd2
> [root@box /]#
> 
> Here is the file's permissions:
> -rwxr-xr-x    1 root root    25 Aug  2 14:07 ldd
> -rwxr-xr-x    1 root root    25 Aug  2 14:07 ldd2
> 
> Strange, isn't it ? Is there something else as suid bits or so which could 
> be mixed up ?
> 
> 
> >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 ?
> 
> Here are the results:
> [root@box /]# set
> BASH=/bin/bash
> BASH_ARGC=()
> BASH_ARGV=()
> BASH_LINENO=()
> BASH_SOURCE=()
> BASH_VERSINFO=([0]="3" [1]="00" [2]="15" [3]="1" [4]="release" 
> [5]="i686-redhat-linux-gnu")
> BASH_VERSION='3.00.15(1)-release'
> COLORS=/etc/DIR_COLORS.xterm
> COLUMNS=157
> DIRSTACK=()
> EUID=0
> GROUPS=()
> G_BROKEN_FILENAMES=1
> HISTFILE=/root/.bash_history
> HISTFILESIZE=1000
> HISTSIZE=1000
> HOME=/root
> HOSTNAME=box.mydomain.com
> HOSTTYPE=i686
> IFS=$' \t\n'
> INPUTRC=/etc/inputrc
> JAVA_HOME=/usr/java/j2sdk
> KDEDIR=/usr
> LANG=en_US.UTF-8
> LESSOPEN='|/usr/bin/lesspipe.sh %s'
> LINES=60
> LOGNAME=root
> LS_COLORS='no=00:fi=00:di=00;34:ln=00;36:pi=40;33:so=00;35:bd=40;33;01:cd=40;33;01:or=01;05;37;41:mi=01;05;37;41:ex=00;32:*.cmd=00;32:*.exe=00;32:*.com=00;32:*.btm=00;32:*.bat=00;32:*.sh=00;32:*.csh=00;32:*.tar=00;31:*.tgz=00;31:*.arj=00;31:*.taz=00;31:*.lzh=00;31:*.zip=00;31:*.z=00;31:*.Z=00;31:*.gz=00;31:*.bz2=00;31:*.bz=00;31:*.tz=00;31:*.rpm=00;31:*.cpio=00;31:*.jpg=00;35:*.gif=00;35:*.bmp=00;35:*.xbm=00;35:*.xpm=00;35:*.png=00;35:*.tif=00;35:'
> MACHTYPE=i686-redhat-linux-gnu
> MAIL=/var/spool/mail/root
> MAILCHECK=60
> OLDPWD=/root
> OPTERR=1
> OPTIND=1
> OSTYPE=linux-gnu
> PATH=/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/sbin:/usr/sbin:/root/bin
> PIPESTATUS=([0]="0")
> PPID=3077
> PROMPT_COMMAND='echo -ne 
> "\033]0;${USER}@${HOSTNAME%%.*}:${PWD/#$HOME/~}\007"'
> PS1='[\u@\h \W]\$ '
> PS2='> '
> PS4='+ '
> PWD=/
> QTDIR=/usr/lib/qt-3.3
> SHELL=/bin/bash
> SHELLOPTS=braceexpand:emacs:hashall:histexpand:history:interactive-comments:monitor
> SHLVL=1
> SSH_ASKPASS=/usr/libexec/openssh/gnome-ssh-askpass
> SSH_CLIENT='::ffff:89.214.2.219 2074 22'
> SSH_CONNECTION='::ffff:89.214.2.219 2074 ::ffff:151.35.1.234 22'
> SSH_TTY=/dev/pts/1
> SUPPORTED=en_US.UTF-8:en_US:en
> TERM=xterm
> UID=0
> USER=root
> _=./testing1
> 
> 
> [root@anoigo /]# env
> HOSTNAME=box.mydomain.com
> TERM=xterm
> SHELL=/bin/bash
> HISTSIZE=1000
> SSH_CLIENT=::ffff:89.214.2.219 2074 22
> QTDIR=/usr/lib/qt-3.3
> OLDPWD=/root
> SSH_TTY=/dev/pts/1
> USER=root
> LS_COLORS=no=00:fi=00:di=00;34:ln=00;36:pi=40;33:so=00;35:bd=40;33;01:cd=40;33;01:or=01;05;37;41:mi=01;05;37;41:ex=00;32:*.cmd=00;32:*.exe=00;32:*.com=00;32:*.btm=00;32:*.bat=00;32:*.sh=00;32:*.csh=00;32:*.tar=00;31:*.tgz=00;31:*.arj=00;31:*.taz=00;31:*.lzh=00;31:*.zip=00;31:*.z=00;31:*.Z=00;31:*.gz=00;31:*.bz2=00;31:*.bz=00;31:*.tz=00;31:*.rpm=00;31:*.cpio=00;31:*.jpg=00;35:*.gif=00;35:*.bmp=00;35:*.xbm=00;35:*.xpm=00;35:*.png=00;35:*.tif=00;35:
> KDEDIR=/usr
> MAIL=/var/spool/mail/root
> PATH=/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/X11R6/bin:/sbin:/usr/sbin:/root/bin
> INPUTRC=/etc/inputrc
> PWD=/
> JAVA_HOME=/usr/java/j2sdk
> LANG=en_US.UTF-8
> SSH_ASKPASS=/usr/libexec/openssh/gnome-ssh-askpass
> SHLVL=1
> HOME=/root
> LOGNAME=root
> SSH_CONNECTION=::ffff:89.214.2.219 2074 ::ffff:151.35.1.234 22
> LESSOPEN=|/usr/bin/lesspipe.sh %s
> G_BROKEN_FILENAMES=1
> _=/bin/env
> 
> 
> Kind regards,
> Daniel
> 
> 
> _______________________________________________
> CentOS mailing list
> CentOS@xxxxxxxxxx
> http://lists.centos.org/mailman/listinfo/centos
> 



[Index of Archives]     [CentOS]     [CentOS Announce]     [CentOS Development]     [CentOS ARM Devel]     [CentOS Docs]     [CentOS Virtualization]     [Carrier Grade Linux]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Linux USB]
  Powered by Linux