Permission denied to execute script that is world executable

2011-06-18 Thread John Williams
I find that I cannot execute world-executable scripts when they are in
a directory which is mounted on a drive on an HBA (host bus adapter
card) in pass-thru mode, but the exact same scripts are executable
when they are in a directory on my boot drive (connected to
motherboard SATA).

Is this a bash bug, or intentional behavior?

The drives connected through the HBA work well for all other purposes
I have tried, except executing scripts. The only oddity I have noticed
is that the identification info stored by the kernel driver
(megaraid_sas) during boot cannot be read by hdparm, although hdparm
has no problem reading the info directly. Apparently, the megaraid_sas
kernel driver is not perfect, but why should this affect bash?

In the output below, the behavior is identical if the first line calls
bash, sh (symlink to bash), or zsh. I left it at zsh (below) to
eliminate ambiguity between the active shell (bash) and the script
shell.

What causes this behavior?

***

cmd$ pwd
/tmp

cmd$ ls -al
total 16
drwxrwxrwt  3 rootroot  4096 Jun 18 13:13 .
drwxr-xr-x 25 rootroot  4096 May  1 21:26 ..
-rwxr-xr-x  1 joe users   23 Jun 18 13:12 okay
drwx--  3 joe users 4096 Jun 17 19:13 spool_joe

cmd$ cat okay
#!/bin/zsh
echo "okay"

cmd$ ./okay
okay

cmd$ /tmp/okay
okay

cmd$ cp okay /mnt/r6c4/

cmd$ /mnt/r6c4/okay
bash: /mnt/r6c4/okay: Permission denied

cmd$ cd /mnt/r6c4

cmd$ ls -al
total 8
drwxr-xr-x  2 joe users8 Jun 18 13:15 .
drwxr-xr-x 26 joe users 4096 Jun 16 22:44 ..
-rwxr-xr-x  1 joe users   23 Jun 18 13:15 okay

cmd$ ./okay
bash: ./okay: Permission denied

cmd$ /bin/bash okay
okay

cmd$ . okay
okay

cmd$ df /mnt/r6c4
Filesystem  Size  Used Avail Use% Mounted on
/dev/sdh1   2.8T  350M  2.8T   1% /mnt/r6c4

$ sudo hdparm -i /dev/sdh

/dev/sdh:
 HDIO_GET_IDENTITY failed: Invalid argument

$ sudo hdparm -I /dev/sdh

/dev/sdh:

ATA device, with non-removable media
Model Number:   Hitachi HDS5C3030ALA630
Serial Number:  MJ1321YNG1ABJA
Firmware Revision:  MEAOA580
Transport:  Serial, ATA8-AST, SATA 1.0a, SATA II Extensions,
SATA Rev 2.5, SATA Rev 2.6; Revision: ATA8-AST T13 Project D1697
Revision 0b
Standards:
Used: unknown (minor revision code 0x0029)
Supported: 8 7 6 5
Likely used: 8
Configuration:
Logical max current
cylinders   16383   16383
heads   16  16
sectors/track   63  63
--
CHS current addressable sectors:   16514064
LBAuser addressable sectors:  268435455
LBA48  user addressable sectors: 5860533168
Logical  Sector size:   512 bytes
Physical Sector size:   512 bytes
device size with M = 1024*1024: 2861588 MBytes
device size with M = 1000*1000: 3000592 MBytes (3000 GB)
cache/buffer size  = 26129 KBytes (type=DualPortCache)
Form Factor: 3.5 inch
Nominal Media Rotation Rate: 5700
Capabilities:
LBA, IORDY(can be disabled)
Queue depth: 32
Standby timer values: spec'd by Standard, no device specific minimum
R/W multiple sector transfer: Max = 16  Current = 0
Advanced power management level: disabled
DMA: mdma0 mdma1 mdma2 udma0 udma1 udma2 udma3 udma4 udma5 *udma6
 Cycle time: min=120ns recommended=120ns
PIO: pio0 pio1 pio2 pio3 pio4
 Cycle time: no flow control=120ns  IORDY flow control=120ns
Commands/features:
Enabled Supported:
   *SMART feature set
Security Mode feature set
   *Power Management feature set
   *Write cache
   *Look-ahead
   *Host Protected Area feature set
   *WRITE_BUFFER command
   *READ_BUFFER command
   *NOP cmd
   *DOWNLOAD_MICROCODE
Advanced Power Management feature set
Power-Up In Standby feature set
   *SET_FEATURES required to spinup after power up
SET_MAX security extension
   *48-bit Address feature set
   *Device Configuration Overlay feature set
   *Mandatory FLUSH_CACHE
   *FLUSH_CACHE_EXT
   *SMART error logging
   *SMART self-test
Media Card Pass-Through
   *General Purpose Logging feature set
   *WRITE_{DMA|MULTIPLE}_FUA_EXT
   *64-bit World wide name
   *URG for READ_STREAM[_DMA]_EXT
   *URG for WRITE_STREAM[_DMA]_EXT
   *WRITE_UNCORRECTABLE_EXT command
   *{READ,WRITE}_DMA_EXT_GPL commands
   *Segmented DOWNLOAD_MICROCODE
unknown 119[7]
   *Gen1 signaling speed (1.5Gb/s)
   *Gen2 signaling speed (3.0Gb/s)
   *Gen3 signaling speed (6.0Gb/s)
   *Native Command Queueing (NCQ)
 

Re: Permission denied to execute script that is world executable

2011-06-18 Thread Jan Schampera

John Williams wrote:

I find that I cannot execute world-executable scripts when they are in
a directory which is mounted on a drive on an HBA (host bus adapter


Can you show the mount options of the filesystem?


--
Be conservative in what you do, be liberal in what you accept from others.
- jbp, master of the net, in RFC793




Re: Permission denied to execute script that is world executable

2011-06-18 Thread Mike Frysinger
On Saturday, June 18, 2011 16:37:18 John Williams wrote:
> Is this a bash bug, or intentional behavior?

it's coming from the kernel, not bash

post the output of `mount` and make sure that it doesnt have the "noexec" flag
-mike


signature.asc
Description: This is a digitally signed message part.


Re: Permission denied to execute script that is world executable

2011-06-18 Thread John Williams
On Sat, Jun 18, 2011 at 1:51 PM, Jan Schampera  wrote:

> Can you show the mount options of the filesystem?

Good call, I should have though of that. I had all the filesystems on
the non-boot drives mounted with the "user" option, which I just
learned from the mount man page also activate "noexec". I changed the
mount option to "user,exec" and now all is fine. Sorry for the false
alarm!

***

cmd$ mount -l
/dev/sdh1 on /mnt/r6c4 type jfs (rw,noexec,nosuid,nodev,noatime) [R6C4]