Solved Compiled but cannot run due to: Permission denied

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.
 
It's seriously bad form to make a SUID root executable world-writable.
 
I suggest you start by using proper permissions: chmod 755 prog

Setting a file world-writable is rarely, if ever, a solution.
 
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
 
./prog is not the same as /home/dik09/prog. So try sudo /home/dik09/prog.
 
./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?
 
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!
 
/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.
 
I've used -save-temps option in cc command but several unwanted files have been created in the current directory.
 
Back
Top