I have a program that runs a command that is something like this:
/home/myuser/bin>> /usr/bin/sudo -u otheruser script.py /home/otheruser/file.txt
This works, but now I need this to work when the program runs from different locations, so I changed it to use the full path:
/home/myuser/bin>> /usr/bin/sudo -u otheruser /home/myuser/bin/script.py /home/otheruser/file.txt
That results in:
can't open file '/home/myuser/bin/runmacroscript.py': [Errno 13] Permission denied
It's the same file, so why does a full path make a difference?
Best Answer
Your
otheruser
cannot access/home/myuser/bin/runmacroscript.py
. The directory permissions on either or both of/home/myuser
or/home/myuser/bin
are too restrictive.The reason it works when you are already in the
/home/myuser/bin
directory is thatotheruser
doesn't have to traverse the directory tree to get there.