[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[cobalt-developers] Adding more admin scripts?



Hello,

I'm trying to add more admin scripts to the cobalt already existing
scripts in /usr/admserv/cgi-bin/.cobalt/ . I have a programming
background but I'm new to Perl. So...
This is the problem: I need to run a perl script, which should
executemy JAVA program which should modify the files in /etc . In order
to
do that I need uid 0 (root) running the Java program, which memas (I
think) that the Apache has to run as root?
My Cobalt is all stock + kaffe java suite, and Apache is run by the
httpd user. I read a post on this user group about a suExec program
(module?) for Perl. Do I need this? I mean, Cobalt scripts modify
stuff in /etc, does anyone know how do they do it?
Here's my script, should be pretty basic:

#!/usr/bin/perl
# dhcpEdit script....
use CGI qw/:standard/;
print header, start_html("dhcpEdit"), h1("dhcpEdit");
if (param()) { # the form has already been filled out
    $oldPATH = $ENV{"PATH"}; # save previous path
    $ENV{"PATH"} = "/bin:/usr/bin:/usr/local/jdk1.2.2/bin"; # force
known path
    $host=param('host');
    $mac=param('mac');
    $ipaddr=param('ipaddr');
    $file=param('file');
    $user=$ENV{"USER"};
    print ("User is $user");
    ##########################
    #run my custom java program...
    ##########################
    system("java dhcpEdit $host $mac $ipaddr $file");
    $ENV{"PATH"} = $oldPATH; # restore previous path
} else { # first time through, so present clean form
    print hr();
    print start_form();
    print p("Hostname: ", textfield("host"));
    print p("MAC Address: ", textfield("mac"));
    print p("IP Address: ", textfield("ipaddr"));
    print p("File: ", textfield("file"));
    print p(submit("order"), reset("clear"));
    print end_form(), hr();
}
print end_html;

It's interesting that  $user=$ENV{"USER"}; print ("User is $user");
prints "User is" on screen. I belive this means that the user "nobody"
is running the script? Is this true, and why is this when Apache runs as
httpd?

Regards,
Marko