Solved Compiled but cannot run due to: Permission denied

IPTRACE

Well-Known Member

Reaction score: 22
Messages: 316

I cannot run the file after compiling.
I run as a standard user, as root everything works fine.

Code:
481557 -rwsrwxrwx  1 root    users   7.2K Apr 10 15:23:31 2017 prog
481553 -rw-r--r--  1 dik09  users    78B Apr 10 15:23:08 2017 prog.c
dik09@domain:~ % ./prog
./prog: Permission denied.
 

SirDice

Administrator
Staff member
Administrator
Moderator

Reaction score: 8,075
Messages: 31,686

It's seriously bad form to make a SUID root executable world-writable.
 

SirDice

Administrator
Staff member
Administrator
Moderator

Reaction score: 8,075
Messages: 31,686

I suggest you start by using proper permissions: chmod 755 prog

Setting a file world-writable is rarely, if ever, a solution.
 
OP
OP
IPTRACE

IPTRACE

Well-Known Member

Reaction score: 22
Messages: 316

Sorry for a small piece of information but I did chmod 777 etc.
I set sudo to run prog and the following info occurs.

Code:
dik09@domain:~ % sudo ./prog
Password:
Sorry, user dik09 is not allowed to execute './prog' as root on domain.
Code:
dik09 ALL=(root) NOPASSWD: /home/dik09/prog
 

SirDice

Administrator
Staff member
Administrator
Moderator

Reaction score: 8,075
Messages: 31,686

./prog is not the same as /home/dik09/prog. So try sudo /home/dik09/prog.
 
OP
OP
IPTRACE

IPTRACE

Well-Known Member

Reaction score: 22
Messages: 316

./prog is not the same as /home/dik09/prog. So try sudo /home/dik09/prog.
The same problem.

Code:
dik09@domain:~ % sudo /home/dik09/prog
Password:
Sorry, user dik09 is not allowed to execute '/home/dik09/prog' as root on domain.
Why does sudo ask for the password if I set NOPASSWD in visudo?
 

SirDice

Administrator
Staff member
Administrator
Moderator

Reaction score: 8,075
Messages: 31,686

What does mount | grep home show?
 
OP
OP
IPTRACE

IPTRACE

Well-Known Member

Reaction score: 22
Messages: 316

I cannot run as root if file is this path.
Code:
481557 -rwxr-xr-x  1 root    users   7.2K Apr 10 15:23:31 2017 prog
481553 -rw-r--r--  1 dik09  users    78B Apr 10 15:23:08 2017 prog.c
root@domain:/home/dik09 # ./prog
./prog: Permission denied
But...
From /usr/sbin it's possible.
Code:
root@hpv:/home/dik09 # /usr/sbin/prog
Hello World!
 

SirDice

Administrator
Staff member
Administrator
Moderator

Reaction score: 8,075
Messages: 31,686

I'm betting /home is mounted with noexec and nosuid set.
 
OP
OP
IPTRACE

IPTRACE

Well-Known Member

Reaction score: 22
Messages: 316

/tmp is mounted with noexec and nosuid as well so I cannot compile the file using cc but gcc works.
Is there any workaround without touching the mount options?
Code:
dik09@domain: % cc -Wall test_2.c -o test_cc
error: unable to open output file '/tmp/test_2-8c100f.o': 'Permission denied'
1 error generated.
 
OP
OP
IPTRACE

IPTRACE

Well-Known Member

Reaction score: 22
Messages: 316

I've used -save-temps option in cc command but several unwanted files have been created in the current directory.
 
Top