Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Bash scripts not executing... bad interpreter?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
danthehat
Tux's lil' helper
Tux's lil' helper


Joined: 20 Feb 2005
Posts: 82
Location: Ontario, Canada

PostPosted: Mon Mar 26, 2007 6:37 pm    Post subject: Bash scripts not executing... bad interpreter? Reply with quote

Any bash script or sh script on normal users on my machine fails execution with this error message:
Code:
-bash: ./test.sh: /bin/bash: bad interpreter: Permission denied


Of course, if I run this as root, it works perfectly.

Code:
compaq dcowsill # ./test.sh
Hello world!


Now, the permissions of both /bin/bash and /bin/sh look fine...
Code:
ls -la /bin/*sh
-rwxr-xr-x 1 root root 648400 Feb 28 18:45 /bin/bash
lrwxrwxrwx 1 root root      4 Feb 28 18:45 /bin/rbash -> bash
lrwxrwxrwx 1 root root      4 Feb 28 18:45 /bin/sh -> bash


So what's up?

I had a rather disappointing experience with Grsecurity a little while ago, but I disabled it. Could the RBAC still be coming after me?

Thanks for any help you can offer.
Back to top
View user's profile Send private message
platojones
Veteran
Veteran


Joined: 23 Oct 2002
Posts: 1602
Location: Just over the horizon

PostPosted: Mon Mar 26, 2007 6:43 pm    Post subject: Reply with quote

[removed for stupidity of that response] :roll:
Back to top
View user's profile Send private message
sdfischer
n00b
n00b


Joined: 18 Feb 2007
Posts: 3

PostPosted: Mon Mar 26, 2007 7:01 pm    Post subject: Reply with quote

Perhaps you are trying to run an executable on a filesystem that you have no executable permissions on (noexec) -- but that doesn't explain root being able to run it -- I would investigate filesystem permissions.

Good Luck :)
Back to top
View user's profile Send private message
danthehat
Tux's lil' helper
Tux's lil' helper


Joined: 20 Feb 2005
Posts: 82
Location: Ontario, Canada

PostPosted: Tue Mar 27, 2007 1:09 pm    Post subject: Reply with quote

If my filesystem permissions were somehow altered, then that would mean I would not be able to execute anything else in my $PATH, which is not the case. I can evoke both of the shells and I use Bash as my default shell (as do most people, I imagine).

Having exhausted all of my resources, I haven't a clue how to deal with this situation. I would appreciate any further input.

Thanks.
Back to top
View user's profile Send private message
Jim6
Tux's lil' helper
Tux's lil' helper


Joined: 08 Apr 2005
Posts: 102

PostPosted: Sat Apr 07, 2007 10:05 am    Post subject: Reply with quote

Just posting to say - you're not on your own!


I've the same problem here -
"sh" on it's own works fine
"sh <script>" works fine
"./<script>" fails


I'll let you know if I come across a solution


Edit: solved!
It's almost certain that you don't have the "exec" flag set on whatever filesystem you're running the scripts.

cat /etc/mtab to find out, then change the relevant /etc/fstab line and remount. Happy hunting!


Edit2: Oh, and remember that the "user" flag implies "noexec".
Back to top
View user's profile Send private message
danthehat
Tux's lil' helper
Tux's lil' helper


Joined: 20 Feb 2005
Posts: 82
Location: Ontario, Canada

PostPosted: Sun Apr 08, 2007 6:30 pm    Post subject: Reply with quote

The problem is localized to the /home filesystem (/dev/hdb1). For some reason, I cannot execute binaries or bash files there. I am almost positive this has something to do with whatever grSecurity did to my system, as I had a similar problem when I didn't mount my iPod with the exec flag on my other system.

Are there configuration files that dictate which folders can have executables in them?

Contents of mtab:
Code:
/dev/hda3 / ext3 rw,noatime 0 0
proc /proc proc rw 0 0
sysfs /sys sysfs rw,nosuid,nodev,noexec 0 0
udev /dev tmpfs rw,nosuid 0 0
devpts /dev/pts devpts rw,nosuid,noexec 0 0
shm /dev/shm tmpfs rw,noexec,nosuid,nodev 0 0
usbfs /proc/bus/usb usbfs rw,noexec,nosuid,devmode=0664,devgid=85 0 0
/dev/hdb1 /home ext3 rw 0 0

Contents of fstab:
Code:

/dev/hda1               /boot           ext2            noauto,noatime  1 2
/dev/hda3               /               ext3            noatime         0 1
/dev/hda2               none            swap            sw              0 0
/dev/hdb1               /home           ext3            defaults        0 1


I have tried using the exec keyword in fstab, with no success. I have umounted and re mounted the filesystem with the exec flag, also to no positive end.

I thank you for any input you can give me.
Back to top
View user's profile Send private message
danthehat
Tux's lil' helper
Tux's lil' helper


Joined: 20 Feb 2005
Posts: 82
Location: Ontario, Canada

PostPosted: Sun Apr 08, 2007 7:23 pm    Post subject: Reply with quote

Solved!

GrSecurity was screwing me up, but in a way I didn't consider. After considering and reconsidering the filesystem permissions as the source of the problem, I determined that if the root filesystem was exec and the /home filesystem had identical permissions, then some outside variables were influencing the situation. After confirming that I had removed userland rsbac controls from my system, I turned to the kernel configuration. I discovered that Trusted Path Execution was on and restricting accounts in the users group... which my non-root user was in. I used sysctl to change the untrusted group to a new group that I could manage, logged out and logged back in, and what do you know... My little test bash script said helloes.

Just goes to show... Before enabling any kernel module, you should read the documentation. It's a bit of hefty reading, but worth the headache in the end.

Thanks for your input, guys.
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum