Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I do not have sudo installed on my machine, but I have a third party program which runs as different user other than root and tries to execute sudo command. Is there a way to enable this program to run sudo ?

I have logged in as root and created sudo bash script in /usr/bin with following contents, since I know root password is there a way I can modify the script to run the command with root privileges. Or is there any other way ? Yes this is foolish, but I need this only for testing.

#!/bin/sh
$@
share|improve this question
1  
You can write a wrapper script that runs ssh root@localhost and run whatever you want. –  dawud May 9 '13 at 6:28
    
@dawud how can I add password to the above command, since sudo script is run by other program which runs in background. –  Sirish Kumar May 9 '13 at 6:35
    
I have tried copying the public key to roots authorized keys file and run the command ssh root@localhost command, it worked fine –  Sirish Kumar May 9 '13 at 8:42
1  
Nice to hear. Keep in mind this is not optimal, nor auditable in the way sudo is. –  dawud May 9 '13 at 9:29
add comment

1 Answer

You seem to be asking about the SUID bit; if you do chown root:root /usr/local/bin/foo; chmod 4755 /usr/local/bin/foo then, in theory, whoever runs /usr/local/bin/foo will run it as root. But the concept is so security-problematic that somes OSes don't honour the SUID bit at all, and others don't honour it on some executables (eg, shell scripts).

Since you have the root password, why not just install sudo? It has a good security track-record, and you can restrict the ability to run as root not just to a certain executable, but to a certain user also.

If you absolutely must use the suid bit, do not grant suid-root status to the script above, or you will have given anyone the power to do anything as root.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.