On Sat, Feb 4, 2012 at 4:56 AM, Martin Grigorov <[email protected]>wrote:

> On Fri, Feb 3, 2012 at 5:53 AM, abhisheks <[email protected]> wrote:
> > i am developing a web application using apache wickets. I need to call a
> > shell script residing on my local disk from java code.
> >
> > this is the section of code under concern :
> >
> > ProcessBuilder builder = new
> >
> ProcessBuilder("sh","/media/drive_/MtechDocuments/ProgramingNOTES/RunShellfromJAVA/test.sh");
> >                                 builder.redirectErrorStream(true);
> >                                    final Process process =
> builder.start();
> >                        }
> >                                 process.waitFor();
> >
> > ------
> >
> > This is piece of code successfully runs fine and execute a shell when
> this
> > code is a part of java prgram residing anywhere on my laal disk. However,
> > when i make a jar file of a progeam , put in webapps folder , and start
> the
> > web application , it reports permission denied error on test.sh script.
> >
> > I then modify the line as :
> >
> > ProcessBuilder builder = new ProcessBuilder("sudo", "-A",
> >
> "sh","/media/drive_/MtechDocuments/ProgramingNOTES/RunShellfromJAVA/test.sh");
> > and set the SUDO_ASKPASS env variable to script returning my sudo
> password ,
> > then it reports the following error :
> > sudo: 3 incorrect password attempts and script calling is failed. Again
> this
> > works correctly when i run the program outside the web development
> > environment , it is able to read my sudo password correctly at run time
> with
> > -A option. Why is it failing when running the same program from web
> > application ?  please help !!
>
> Maybe your web server runs with a user which has no permissions to
> become different user (via sudo).
> When you run it as a normal Java program you run it with your user
> which has this permission.
>
> In any case it has nothing to do with Wicket.
>

And if your webapp *is* running as a user with sudo access you're just
asking for trouble.

-- 
Jeremy Thomerson
http://wickettraining.com
*Need a CMS for Wicket?  Use Brix! http://brixcms.org*

Reply via email to