sirmarlo
sirmarlo

Reputation: 217

Java Wrapper Script w/ sudo not working

I have a Java executable that takes in command line arguments to launch root protected applications on my Linux box. We have separate user accounts that are given sudo access to launch the single Java executable, which the user can then use to launch the root protected apps. My understanding of sudo is that the user assumes the root 'role' during the single call and any subsequent calls thereafter (i.e. the calls the Java exec makes to the apps). It works for most of my applications, but only partially works for others. In particular the external applications being launched sometime don't operate correctly and seem to output errors that they can't open files (that are read accessible by all). If I run the executable as root, the executable and subsequent apps all run fine, so I know it has something to do w/ sudo.

I can provide more details if necessary but looking if anybody knows if sudo changes environment or runtime issues that I'm not aware of.

UPDATE:

The config files are in readable directories. To test for sure I made the binaries that the Java exec are trying to launch read accessible by all. From my tester account, I then launch the Java exec (w/o sudo) and the app runs fine. I then make just the binaries root protected, and run the Java exec with sudo and the application launch fails and gives me an error like:

"recorder: Fail to open edtrecorder.cfg"

That file and the directory its in are both read accessible by all.

Upvotes: 0

Views: 710

Answers (1)

Dipstick
Dipstick

Reputation: 10129

On some distributions (e.g. ubuntu) sudo runs programs using a restricted environment (with different search path) to the user shell running the command. This is a security feature; for example a program may have changed the PATH so that so that a rogue program is run instead of the real one when the user types a command - this would be catastrophic under sudo. See sudo changes PATH - why?

Upvotes: 1

Related Questions