I already tried that, but for some reasonm, it just doesn't run. it
doesn't give any errors, it just returns to the prompt. I tried another
approach, I hard-coded the root password in the script, ran su, and then
tried to do all this. Then, it changed back to the user I was running as.
I interspersed all commands with a spawn id to see who was the user at
each time, and after the first time, it was my user again, not root.
I am new to EXPECT so I might be making a fundamental mistake. I have
attached a copy of my script. Please help me out.
-Prashant
#!/usr/local/bin/expect
set arg1 [lindex $argv 0]
set arg2 [lindex $argv 1]
spawn su root
expect "assword:"
send "<root password here>\r"
expect "#"
spawn /usr/sbin/useradd -g 110 -d /home/popuser -s /sbin/nologin $arg1
expect "#"
puts "user added"
spawn id
spawn passwd $arg1
expect "New password:"
send "$arg2\r"
expect "Re-enter new password:"
send "$arg2\r"
expect "#"
I also tried a variation
spawn su root -c /usr/sbin/useradd -g 110 -d /home/popuser -s /sbin/nologin $arg1
but that gave me an error saying invalid syntax with useradd!
Please help me.
On Tue, 6 Jul 1999, Carric Dooley wrote:
> suid is dangerous but:
>
> change onwnership of the file to root then do a:
>
> chmod 4755 [filename]
>
> THis causes the process to run as root:
>
> 4000 = suid
> 2000 = sgid
> 1000 = sticky bit
>
> What was that IP again? >;)
>
> Carric Dooley
> COM2:Interactive Media
> http://www.com2usa.com
>
> On Tue, 6 Jul 1999, Prashant Vijay wrote:
>
> > THis isn't related to firewalls, but its security related.
> > I have an expect script that takes in a username and a password, and adds
> > and account. This scripts runs useradd and passwd. It has to be run as
> > root, but I will be calling this script from a cgi script, which will be
> > running as nobody. How do I make just this script run as root. I don't
> > want to put the root passwd in the script and run su. Isn't there
> > something like set suid? PLease help me out. ANy help would be greatly
> > appreciated.
> > -Prashant
> >
> > -
> > [To unsubscribe, send mail to [EMAIL PROTECTED] with
> > "unsubscribe firewalls" in the body of the message.]
> >
>
> -
> [To unsubscribe, send mail to [EMAIL PROTECTED] with
> "unsubscribe firewalls" in the body of the message.]
>
-
[To unsubscribe, send mail to [EMAIL PROTECTED] with
"unsubscribe firewalls" in the body of the message.]