0

I have a java app that writes to a very important table I have. This is sudo protected, but this app takes a parameters for where the output should go. The default is the REAL DEAL but the "output" parameter takes priority over the default, so if a user provides a path that they have write permission for, say: /home/username/mystuff then I would like for users to be allowed to write to these directories.

The app is launched in a shell script, so I am wondering if I can check that the string does not equal /path/to/real/deal and not empty (since /path/to/real/deal is the default) and allow users to write to places they have permissions for.

My impression of linux permissions is that it is tied to the application itself and cannot be conditionally approved, but I wonder if there is some bash fu or alternative method I can perform to get me my desired result.

Using Ubuntu 10.04.4 LTS

0

Linux permissions are tied to the user (not to the application). You might get the result you want by starting the script as a normal user:

OUTFILE="/home/username/mystuff"
DEFAULT="/path/to/real/deal"
touch "$OUTFILE" || OUTFILE="$DEFAULT"
sudo java_app "$OUTFILE"

Touch will not work in a directory where the user has no write permission so in that case the touch will fail and the outputfile will get the default path/filename.
Sudo is invoked AFTER this test.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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