Linux permission denied after chmod a=rwx
Asked Answered
A

6

9

So I have a little Linux problem, geez that will teach me to spend so many years on Windows. Anyway I did a little java app, wrapped nicely with the Java Service Wrapper script, but when I run that script:

sh ./wrapper.sh console

I get permission denied right away. The permission denied message is like that:

eval: 1: /home/user1/MyApp/bin/wrapper: Permission denied

My little wrapper.sh lives in the MyApp/bin folder. The directory MyApp/bin/wrapper contains 2 files:

  • wrapper-linux-x86-32
  • wrapper-linux-x86-64

As a test I ran the following chmod command:

chmod a=rwx MyApp -R

I verified that everything was rwx, even in the sub-folders and tried to run the script again, with the exact same result... permission denied.

Anyone has any idea of what I could try next to make that baby run?

Thanks, Lancelot

Axletree answered 7/4, 2009 at 23:12 Comment(2)
What are the contents of the wrapper? Could it be that it calls a command called eval? My man tells me there is a command eval - construct command by concatenating arguments. Maybe there is a problem in the wrapper script.Armagh
I trust that you have removed the public write permission on the files and on the directories. It is seldom defensible to leave files or directories with public write permission - /tmp is a special case and requires the sticky-bit set to be remotely safe.Ramage
M
8

I just noticed the error message references the name of the directory hosting your file:

eval: 1: /home/user1/MyApp/bin/wrapper: Permission denied

We know it's a directory since you mentioned "The directory MyApp/bin/wrapper contains 2 files".

Could you check your script for instance where you're using the name of the directory as a command? Such as using wrapper (which is the directory name) instead of wrapper/wrapper-linux-x86-32 (which would be a file name), or similar errors?

Similar errors often appear when using spaces in filenames and forgetting to quote said filenames (probably not the case here, though.)

Failing that, could you edit your question to include the contents of the wrapper script you're calling?

(New answer since it's completely unrelated to the previous noexec idea, and that one can stay for reference.)

Moulden answered 7/4, 2009 at 23:37 Comment(2)
You da man. That's exactly what was happening. The system was confused and tried to execute a folder instead of a file. Note that if my structure had been bullet proof in the first place the system wouldn't be confused. Machines do only what we tell them to do! Thanks a million times moocha.Axletree
Don't mention it, glad to be able to help.Nitro
M
9

The file system hosting your script might be mounted with the noexec flag. Check your /etc/fstab entry for that file system and if there's a noexec there try removing it then remounting that file system via mount /path/to/mountpoint -o remount

On second thought, check the output of the mount command for noexec instances instead of /etc/fstab (the file system might have been mounted dynamically.)

Moulden answered 7/4, 2009 at 23:19 Comment(2)
no there is no "noexec" option on any of the file systems. But thanks for pointing out that file, it's useful to know where that info is.Axletree
This is a very straight forward install of Ubuntu. Nothing is mounted after startup. The disk drives and the cdrom are mounted automatically when the system boots up.Axletree
M
8

I just noticed the error message references the name of the directory hosting your file:

eval: 1: /home/user1/MyApp/bin/wrapper: Permission denied

We know it's a directory since you mentioned "The directory MyApp/bin/wrapper contains 2 files".

Could you check your script for instance where you're using the name of the directory as a command? Such as using wrapper (which is the directory name) instead of wrapper/wrapper-linux-x86-32 (which would be a file name), or similar errors?

Similar errors often appear when using spaces in filenames and forgetting to quote said filenames (probably not the case here, though.)

Failing that, could you edit your question to include the contents of the wrapper script you're calling?

(New answer since it's completely unrelated to the previous noexec idea, and that one can stay for reference.)

Moulden answered 7/4, 2009 at 23:37 Comment(2)
You da man. That's exactly what was happening. The system was confused and tried to execute a folder instead of a file. Note that if my structure had been bullet proof in the first place the system wouldn't be confused. Machines do only what we tell them to do! Thanks a million times moocha.Axletree
Don't mention it, glad to be able to help.Nitro
S
1

You may try to execute the file that was there in other user's home directory, you can give permission to the user "user"

chmod -R a+x /home/user1 or chmod -R o+x /home/user1 chmod -R g+x /home/user1

Sack answered 22/4, 2009 at 4:39 Comment(0)
E
0

you may have to also grant execution script to your wrapper

chmod +x wrapper.sh

EDIT: i just noticed that your wrapper.sh is located in your MyApp folder /EDIT

also, if u make sure you have

#!/bin/sh

at the top of your .sh file, you can execute it like this:

.wrapper.sh

Emf answered 7/4, 2009 at 23:17 Comment(2)
Hi Roy, when I do ls -Al here is what it prints for my wrapper.sh: -rwxrwxrwx 1 user1 user1 19035 2009-04-07 15:32 wrapper.shAxletree
chmod with = is quite acceptable, it's already set execute bit.Sturrock
H
0

First, try opening it in a text editor, to make sure you have read access. If so, do

chmod +x wrapper.sh

And make sure you have #!/bin/sh at the beginning of the script

Hackle answered 7/4, 2009 at 23:18 Comment(1)
Hi Zifre, the #!/bin/sh is there I just checked.Axletree
F
0

Although my problem was a bit different this question appeared in my search few times while searching for similar problem so I'll post my findings here.

My problem was that I couldn't access storage/ folder after chmod command.

After executing command:

sudo chmod -755 storage -R    //notice -755 is wrong, it should be 755

I couldn't access storage/ folder any more.

I've tried ls -l:

storage permissions d---------

Also after git status:

storage/.gitignore: Permission denied

After executing the right command:

sudo chmod 755 storage -R // without -

everything returned back to normal.

Funicular answered 4/4, 2017 at 9:57 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.