File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Linux / UNIX and the fly likes Using SUDO Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "Using SUDO" Watch "Using SUDO" New topic
Author

Using SUDO

Manish Hatwalne
Ranch Hand

Joined: Sep 22, 2001
Posts: 2578

I am not much of a Unix guy, but need to run one of my scripts as ROOT.
I believe I cn do it with SUDO (SUID being a risk), can someone help me how do I use SUDO stepwise.

TIA,
- Manish
Vijay Chinnasamy
Greenhorn

Joined: Aug 08, 2004
Posts: 4
Here is one of the great links that talks about setting up sudo files for permissions:

http://www.linuxhomenetworking.com/linux-hn/addusers.htm
http://www.courtesan.com/sudo/man/sudoers.html

Once you are setup with sudo, you need to run the script using the following syntax:

sudo sh - user -c command_or_script

Thanks
Vijay


SCSA SCNA CSA-HP-UX SCESODE(LDAP) SCDME
M Beck
Ranch Hand

Joined: Jan 14, 2005
Posts: 323
Originally posted by Vijay Chinnasamy:
sudo sh - user -c command_or_script


um, that looks terribly insecure to me... i believe for that to work, you'd have to add /bin/sh to /etc/sudoers as a sudo-able command, wouldn't you? but that surely wouldn't be right, there's no end of ways the security of the shell could be breached.

i believe the "right" way to do this is to put the "command_or_script" into /usr/local/bin with root.root ownership, non-world-writable, and add that command_or_script only to /etc/sudoers. that way, you can run it as user with:

<pre>sudo -u user command_or_script</pre>

and let the system worry about the interpreter and its command line options.
[ January 14, 2005: Message edited by: M Beck ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Using SUDO
 
Similar Threads
How to provide password to the prompt through Java
Using JAAS UnixLoginModule to login as root on Linux
system users login and login shell
RPM files in Suse
Tomcat shortcuts / aliases on OS X desktop