julsford has asked for the wisdom of the Perl Monks concerning the following question:

Help!! I've got a really, REALLY Beta off the shelf application that I'm administering that requires three servers to be synchronized at the startup. Two are windows servers and third is a Unix server. The primary server is Win and it will kick off the synchronization calls to the other two.

We thought we could use port 80, apache and perl to do this, and all would be well and good except (don't cha hate those) the process needs to be started by a different user than the one who owns the Apache server. Of course this is a system call, and the normal rc file syntax for this is:

su - userid "/etc/start-process.sh"

this, of course, asks for the userid's password and won't kick off the process without it.

How can I get the password fed into this and/or kick off the process as the necessary user?

Any help is greatly appreciated.
Juls

Replies are listed 'Best First'.
Re: starting a process as a different user
by iburrell (Chaplain) on Apr 14, 2004 at 18:50 UTC
    Use the appropriate tool for running commands remotely. Use ssh. Don't hack something together with apache. There are good security reasons why apache runs as an unprivledge user.
    ssh user@remote "/etc/start-process.sh"
Re: starting a process as a different user
by Plankton (Vicar) on Apr 14, 2004 at 19:17 UTC
    You could do as iburrell suggest. Secure Shell with public key authenication ( or some form of authenication that does not require the user to type in a password). Or you could look into using expect.

    Plankton: 1% Evil, 99% Hot Gas.
Re: starting a process as a different user
by ambrus (Abbot) on Apr 14, 2004 at 20:13 UTC

    Create a setuid C program that runs the perl script as approperiate user. (Use a setuid-root program and call setuid from it if you need to change the real id too.)

      Better to use sudo than try to write this securely yourself.
Re: starting a process as a different user
by TomDLux (Vicar) on Apr 15, 2004 at 04:50 UTC

    Since it's let's nominate an odd mechanism night, why don't you try expect?

    --
    TTTATCGGTCGTTATATAGATGTTTGCA