No interpereters for files on a specific partition?

  • Follow


When I run scripts that require a shebang to run, where the scripts are
on a specific partition, bash says something analogous to:

-bash: ./error.sh: /home/shortcircuit/sh: bad interpreter: Permission
denied

(contrived example using a friends system; I don't have access to my
machine from work/school.  /home/shortcircuit/sh is a "chmod -x"'d copy
of /bin/sh)

First, my system specs:
* Duron 750MHz, 768MB RAM
* Debian sarge, last updated with packages from jigdo CDs made in early
December.
* / is mounted from /dev/hda1
* /home is mounted from /dev/hdb1
* /home/shortcircuit/data/external is mounted from /dev/sda2
* /home/shortcircuit/data/fat32 is mounted from /dev/sda1
* / and /home are ext3 filesystems.  They work fine.
* /dev/hda is an internal IDE/ATA 20GB drive
* /dev/hdb is an internal IDE/ATA 40GB drive
* /dev/sda is an external 250GB drive connected to a PCI USB2 (EHCI)
add-on card
* /dev/sda1 is an 80GB FAT32 partition
* /dev/sda2 is a 170GB ext3 partition
* I have approx. 11GB free on /dev/hda1, 21GB free on /dev/hdb1, and
significantly more free on /dev/sda2.

When I run interpereted scripts from any folder under
/home/shortcircuit/data/external, I get an error similar to the error
given above (albeit with a proper path to the interpereter.).  I've
confirmed this for scripts needing /bin/sh, /bin/bash, and
/usr/bin/perl.

When I copy any of the scripts to /home/shortcircuit/data,
/home/shortcircuit, or even /usr/src, they work fine.

running "mount" doesn't show any flags I don't recognize, nor does
running lsattr on the scripts relevant.

"fsck.ext3 -f -v /dev/sda2" doesn't show anything unusual. "fsck.ext3
-cc -f /dev/sda2" was still running as I left for work this morning,
but hadn't yet shown any errors after running for four and a half
hours.

Finally, dmesg didn't turn up any errors.

Am I missing something?  Are there any other tests I can run? (Be
warned I won't get a chance to respond with results until Wednesday;
I'm not going to see that machine until tomorrow night.)

0
Reply mikemol (370) 2/28/2005 12:30:15 PM

On 28 Feb 2005 04:30:15 -0800, "Mike Mol" <mikemol@gmail.com> wrote:

>When I run scripts that require a shebang to run, where the scripts are
>on a specific partition, bash says something analogous to:
>
>-bash: ./error.sh: /home/shortcircuit/sh: bad interpreter: Permission
>denied

>When I run interpereted scripts from any folder under
>/home/shortcircuit/data/external, I get an error similar to the error
>given above (albeit with a proper path to the interpereter.).  I've
>confirmed this for scripts needing /bin/sh, /bin/bash, and
>/usr/bin/perl.
>
>When I copy any of the scripts to /home/shortcircuit/data,
>/home/shortcircuit, or even /usr/src, they work fine.

>Am I missing something?  Are there any other tests I can run? (Be
>warned I won't get a chance to respond with results until Wednesday;
>I'm not going to see that machine until tomorrow night.)

Try running the script thru strace, like: "strace somescript", and
see where it fails. 

When I've seen problems like you describe,
it is sometimes a permissions problem, where some higher top
level directory, has it's permissions set, so that the user can't
read it. 
I got burned a few times by setting /usr to 700, by stupidly copying
over it, and would get odd "permission denied" errors.

See what happens when you try the scripts as root.



-- 
I'm not really a human, but I play one on earth.
http://zentara.net/japh.html
0
Reply zentara (292) 2/28/2005 4:32:46 PM


On Mon, 28 Feb 2005 at 12:30 GMT, Mike Mol wrote:
> When I run scripts that require a shebang to run, where the scripts are
> on a specific partition, bash says something analogous to:
> 
> -bash: ./error.sh: /home/shortcircuit/sh: bad interpreter: Permission
> denied

   A common cause of this error is a DOS file with CRLF line endings;
   remove them with dos2unix or recode or tr ot sed or ....

> (contrived example using a friends system; I don't have access to my
> machine from work/school.  /home/shortcircuit/sh is a "chmod -x"'d copy
> of /bin/sh)

  If you have removed -x permissions, how do you expect to execute it?

-- 
    Chris F.A. Johnson                  http://cfaj.freeshell.org/shell
    ===================================================================
    My code (if any) in this post is copyright 2005, Chris F.A. Johnson
    and may be copied under the terms of the GNU General Public License
0
Reply cfajohnson (1783) 2/28/2005 4:54:23 PM

Chris F.A. Johnson wrote:
> On Mon, 28 Feb 2005 at 12:30 GMT, Mike Mol wrote:
> > When I run scripts that require a shebang to run, where the scripts
are
> > on a specific partition, bash says something analogous to:
> >
> > -bash: ./error.sh: /home/shortcircuit/sh: bad interpreter:
Permission
> > denied
>
>    A common cause of this error is a DOS file with CRLF line endings;
>    remove them with dos2unix or recode or tr ot sed or ....

That would make sense, except I first encountered the problem trying to
run bochs's configure script.  I then confirmed the issue with a Perl
app I'd been successfully developing on on another machine.

>
> > (contrived example using a friends system; I don't have access to
my
> > machine from work/school.  /home/shortcircuit/sh is a "chmod -x"'d
copy
> > of /bin/sh)
>
>   If you have removed -x permissions, how do you expect to execute
it?

That was for the error.sh script, and was intentional.  I needed the
error message, or something enough like it, without having the actual
system in front of me.  That's why it's "contrieved." :)

0
Reply mikemol (370) 2/28/2005 5:17:09 PM

Mike Mol wrote:

> When I run scripts that require a shebang to run, where the scripts
> are on a specific partition, bash says something analogous to:
> 
> -bash: ./error.sh: /home/shortcircuit/sh: bad interpreter: Permission
> denied
> 
> (contrived example using a friends system; I don't have access to my
> machine from work/school.  /home/shortcircuit/sh is a "chmod -x"'d
> copy of /bin/sh)
Probably the partition is mounted with the (default) "noexec" option.
Use the "exec" when mounting the partition to change that.  
0
Reply markus.kossmann (64) 2/28/2005 5:21:27 PM

zentara@highstream.net wrote:

> On 28 Feb 2005 04:30:15 -0800, "Mike Mol" <mikemol@gmail.com> wrote:
> >Am I missing something?  Are there any other tests I can run? (Be
> >warned I won't get a chance to respond with results until Wednesday;
> >I'm not going to see that machine until tomorrow night.)
>
> Try running the script thru strace, like: "strace somescript", and
> see where it fails.

I'll try that.

>
> When I've seen problems like you describe,
> it is sometimes a permissions problem, where some higher top
> level directory, has it's permissions set, so that the user can't
> read it.

So, for example, the permissions of
/home/shortcircuit/data/external/citygen-dev might affect attempts to
run the script citygen.pl from within that directory?

> I got burned a few times by setting /usr to 700, by stupidly copying
> over it, and would get odd "permission denied" errors.

It would have to be a problem with both /bin and /usr/bin, because both
sh and perl are affected.

>
> See what happens when you try the scripts as root.

I did try them as root, and they still didn't work. (I should have
mentioned that.)

I also tried moving /home/shortcircuit/data/external/citygen-dev to
/home/shortcircuit/data, and it worked.  Using mv should retain
permissions, shouldn't it?

0
Reply mikemol (370) 2/28/2005 6:01:01 PM

Markus Kossmann wrote:
> Mike Mol wrote:
>
> Probably the partition is mounted with the (default) "noexec" option.
> Use the "exec" when mounting the partition to change that.

Nearly everything in my /etc/fstab is hand-crafted.  I don't think I
have "exec" explicitly set for /home, but I'll check.  And I'll try
adding "exec" to the entry for /home/shortcircuit/data/external ...

Thanks.  This sounds the most likely of all the options yet suggested.

0
Reply mikemol (370) 2/28/2005 10:52:49 PM

On 28 Feb 2005 10:01:01 -0800, "Mike Mol" <mikemol@gmail.com> wrote:


>So, for example, the permissions of
>/home/shortcircuit/data/external/citygen-dev might affect attempts to
>run the script citygen.pl from within that directory?
>
>> I got burned a few times by setting /usr to 700, by stupidly copying
>> over it, and would get odd "permission denied" errors.
>
>It would have to be a problem with both /bin and /usr/bin, because both
>sh and perl are affected.
>

What I was getting at, is that if the interpreter can't load it's
library dependencies, it will fail with permission denied.
If /usr/lib gets accidently set to 700, then a normal user
can't get to the libraries in /usr/lib and/or /usr/local/lib.

strace should tell you exactly where the problem is.

Another thing, do you have any "extra security patches"
in your kernel? You may have something like set like
"no executable symlinks".



-- 
I'm not really a human, but I play one on earth.
http://zentara.net/japh.html
0
Reply zentara (292) 3/1/2005 1:07:40 PM

Markus Kossmann wrote:
> Mike Mol wrote:
>
> Probably the partition is mounted with the (default) "noexec" option.
> Use the "exec" when mounting the partition to change that.

Solved. This turned out to be the problem.

I replaced the line:

/dev/sda2 /home/shortcircuit/data/external ext3 user,noauto 0 0

with

/dev/sda2 /home/shortcircuit/data/external ext3 user,noauto,exec 0 0

And it worked.

However, I'd still like clarification on something.  "noexec" clearly
isn't the default for / and /home, yet the options filed for those
mounts don't include the "exec" option.

Is "noexec" default for USB mass-storage drives, or is it default for
SCSI drives? (Since the drive in question is showing up as a SCSI disk.)

0
Reply mikemol (370) 3/2/2005 4:57:35 PM

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Mike Mol wrote:
> Markus Kossmann wrote:
> 
>>Mike Mol wrote:
>>
>>Probably the partition is mounted with the (default) "noexec" option.
>>Use the "exec" when mounting the partition to change that.
> 
> 
> Solved. This turned out to be the problem.
> 
> I replaced the line:
> 
> /dev/sda2 /home/shortcircuit/data/external ext3 user,noauto 0 0
> 
> with
> 
> /dev/sda2 /home/shortcircuit/data/external ext3 user,noauto,exec 0 0
> 
> And it worked.
> 
> However, I'd still like clarification on something.  "noexec" clearly
> isn't the default for / and /home, yet the options filed for those
> mounts don't include the "exec" option.

According to the mount(8) manpage, "user" implies "noexec", "nosuid" and
"nodev" unless explicitly overridden by subsequent options. You
originally mounted /dev/sda2 with "user,noauto", so you got noexec for
free, courtesy of "user".




- --

Lew Pitcher, IT Specialist, Enterprise Data Systems
Enterprise Technology Solutions, TD Bank Financial Group

(Opinions expressed here are my own, not my employer's)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.4 (MingW32)

iD8DBQFCJfRHagVFX4UWr64RApG9AJ9hnpXUZ5BXKWdaLyrH7zEuDVZlkgCfdV/h
+YJCfaKlh/Fxw8zKCjJMSD8=
=K3zw
-----END PGP SIGNATURE-----
0
Reply Lew.Pitcher (530) 3/2/2005 5:13:43 PM

Lew Pitcher wrote:

> According to the mount(8) manpage, "user" implies "noexec", "nosuid"
and
> "nodev" unless explicitly overridden by subsequent options. You
> originally mounted /dev/sda2 with "user,noauto", so you got noexec
for
> free, courtesy of "user".

Shoulda checked the docs, then, I guess. :)

Thanks.

0
Reply mikemol (370) 3/2/2005 8:55:56 PM

10 Replies
29 Views

(page loaded in 0.135 seconds)


Reply: