[SOLVED] Failed miserably to execute bash script via PATH variable after FS migration.
Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
My thought was that you might have /home mounted with options/flags not allowing you to execute.
But then, it shouldn't work with "bash scriptfile" either?
I have never used this possibility myself, but maybe it's worth digging into?
It could be that different filesystems have different default options.
After copying ~/ back to the new sda2, all files/dirs had root ownership. I changed that recursively using chown.
I only assumed that the 'user' option in fstab would let me execute scripts, and, as you say I *can* execute them, but only by calling bash explicitly for that particular script.
I forgot to mention, my default shell is indeed bash:
After copying ~/ back to the new sda2, all files/dirs had root ownership. I changed that recursively using chown.
I only assumed that the 'user' option in fstab would let me execute scripts, and, as you say I *can* execute them, but only by calling bash explicitly for that particular script.
Beware about the difference between "user" and "users". A lot of people get confused by that. Double check the mount man page.
He should check the output from "mount" without arguments and make sure that neither of "noexec" and "users" are between the mount options ("users" implies "noexec" by default).
When you open a script doing "bash <filename>" there's virtually no difference between that and doing "oowrite my_file.doc". Bash will launch a new session and start parsing the file. You can quickly check by setting -x on any random script and then launching it with bash or sh.
Code:
[user@computer /]$ mount
proc on /proc type proc (rw,relatime)
sys on /sys type sysfs (rw,relatime)
udev on /dev type devtmpfs (rw,nosuid,relatime,size=10240k,nr_inodes=239727,mode=755)
/dev/disk/by-uuid/d39a9c41-fece-4837-9f5e-b32bdbe5131e on / type ext4 (rw,noatime,discard,commit=0)
none on /dev/pts type devpts (rw)
none on /dev/shm type tmpfs (rw)
tmpfs0 on /tmp type tmpfs (rw,noatime,mode=1777)
tmpfs1 on /var/cache/pacman type tmpfs (rw,noatime,mode=1777)
/dev/sda2 on /mnt/0 type xfs (rw,noexec,nosuid,nodev,noatime)
fusectl on /sys/fs/fuse/connections type fusectl (rw)
/dev/loop0 on /mnt/2 type udf (ro)
gvfs-fuse-daemon on /mnt/0/STATIC/DIR/.gvfs type fuse.gvfs-fuse-daemon (rw,nosuid,nodev,user=user)
[user@computer /]$
Oh... my... holy penguin! How could I have been so stupid?? x(
sda2 is indeed flagged with noexec. Can I fix this easily?
When you open a script doing "bash <filename>" there's virtually no difference between that and doing "oowrite my_file.doc". Bash will launch a new session and start parsing the file. You can quickly check by setting -x on any random script and then launching it with bash or sh.
Exactly. But what happens is that with noexec on the filesystem, he can execute the script if he types "bash scriptfile"! Suddenly the "noexec" has no effect, is this really the case?? A bit too easy to bypass security settings I'd say!
Exactly. But what happens is that with noexec on the filesystem, he can execute the script if he types "bash scriptfile"! Suddenly the "noexec" has no effect, is this really the case?? A bit too easy to bypass security settings I'd say!
As I said above, in that case he's not running a file. In which regards the shell, he is just opening a plain text document with a parser that happens to be named "bash" instead of "oowriter" or "gimp". There's no real difference between "oowrite file.doc", "gimp file.jpg" or "bash file.sh".
It would seem that root (sudo) doesn't execute the file but only reads it as text and gives it to bash. (?)
Although that sounds like nonsense. [EDIT: Actually it makes sense] I suppose root can always read the text file?
Code:
[user@computer /]$ ls -l ~/bin | grep wifil
-rwxr-xr-x 1 user users 1340 Aug 18 08:12 wifil
[user@computer /]$
[EDIT]OK.. you beat me to it. All seems clear now.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.