From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <96078694111287.tru64-unix-managers.marc@archive.invalid> From: George Guethlein Date: Thu, 12 Feb 1998 13:43:17 +0000 To: tru64-unix-managers Subject: Trusted(?) Password Maint With EXPECT X-MARC-Message: https://marc.info/?l=tru64-unix-managers&m=96078694111287 MIME-Version: 1 Content-Type: multipart/mixed; boundary="--=_C2971980.E584E80F" This is a MIME message. If you are reading this text, you may want to consider changing to a mail reader or gateway that understands how to properly handle MIME multipart messages. --=_C2971980.E584E80F Content-Type: text/plain Content-Disposition: inline I need to allow "trusted" users to perform password maintenance on my AlphaServers (running DUnix 3.2C,F & 4.0,B,D). It's a 24x7 application and I would like to sleep at some point in my life ! Any thoughts or ideas on my following strategy would be GREATLY appreciated, AS WELL AS ANY ALTERNATIVES. I will summarize. I am trying to use Expect in this scenario, as follows : 1.) Trusted users ".profile" executes a kornshell menu script. 2.) Option 1 of menu allows password maintenance. User provides USERID for password change; NEW PASSWORD; NEW PASSWORD AGAIN for verification. 3.) Expect script "TMSpassmnt" (basically the "autopasswd" example) is executed. I have set the permissions/ownership on "TMSpassmnt" to 7755/root:system. My thinking is that the expect script will run as root and allow the password to be changed without being asked for the OLD password (the reason this process is needed - forgetful users don't remember their password). I encounter two errors : 1.) I am being asked for "Old password:", so it appears that the setUID isn't working. 2.) I get error "send: invalid spawn id (4)" on the second send of password. I have attached the three files that represent the scenario steps above, as well as the output from the execution of the process. You can see in "exec3.doc" that I have tried many code features in the Expect script. I have also posted the question to newsgroup "comp.lang.tcl", but haven't had any takers on assistance. Based on previous experience, I think I'll get a better response with this posting. I Look forward to your replies. --=_C2971980.E584E80F Content-Type: text/plain Content-Disposition: attachment; filename="EXEC1.DOC" Content-Description: WordPerfect 4.2 trap " " 1 2 3 4 5 6 15 16 18 TERM=vt100; export TERM /d/bin/TMSmenu.s exit --=_C2971980.E584E80F Content-Type: text/plain Content-Disposition: attachment; filename="EXEC2.DOC" #!/bin/ksh # #************************************************************************** # Function to display main menu selection * #************************************************************************** displaymenu() { clear echo "TMS Password Maintenance & Application Menu" echo "===========================================" echo echo " 1) Password Maintenance" echo echo " 2) TMS STORE Application" echo echo " 3) TMS YARD Application" echo echo "q|Q) quit" echo echo "Select Option[(1-3)|(q)]: \c" read OPTION echo } #************************************************************************** # Main Processing Control Section * #************************************************************************** /usr/bin/clear displaymenu # display main menu while [ "$OPTION" != "q" ] || [ "$OPTION" != "Q" ] do case $OPTION in 1) /usr/bin/clear badpass=0 while ((badpass < 1)) do print " " print " " print -n " Enter Userid For Password Maintenance : " read USRMNT print " " print " " print -n " Enter New Password : " read newpass1 print " " print " " print -n " Enter New Password Again For Verification : " read newpass2 npass_len=${#newpass1} if [[ $newpass1 = $USRMNT ]] # Password Matches Userid then print " Password Can Not Match Userid, Try Again" continue elif [[ $newpass1 != $newpass2 ]] # Passwords Don't Match then print " Passwords Do Not Match, Try Again" continue elif [[ $newpass1 = +([a-z]) ]] # Password ALL Lowercase then print " Password Can Not Be All Lowercase, Try Again" continue elif ((npass_len != 6)) # Password 6 Characters then print " Password Must Be 6 Characters Long, Try Again" continue else ((badpass = badpass + 1)) # Terminate Loop Control exec /usr/local/bin/TMSpassmnt $USRMNT $newpass1 # Expect Script fi done ;; 2) cd /dir run tmsstore ;; 3) cd /dir run tmsyard ;; Q|q) exit ;; *) echo "**** Invalid selection ****" ;; esac echo displaymenu done --=_C2971980.E584E80F Content-Type: text/plain Content-Disposition: attachment; filename="EXEC3.DOC" Content-Description: WordPerfect 4.2 #!/usr/local/bin/expect -f #********** #* FILE = /usr/local/bin/TMSpassmnt #********** # wrapper to make passwd(1) be non-interactive # username is passed as 1st arg, passwd as 2nd #set username [lindex $argv 0] set password [lindex $argv 1] #************************************ #spawn passwd [lindex $argv 0] #spawn passwd $username #* Start Of Added Code * #************************************ #set cntr 0 #while {$cntr < 1 } { # if {[fork] != 0} { # set cntr [expr $cntr + 1] # send_user " Working ......\n" # send_user " \n" # send_user " Passed username = [lindex $argv 0]\n" # send_user " \n" # send_user " Passed password = [lindex $argv 1]\n" # send_user " \n" # send_user " Assigned username = $username\n" # send_user " \n" # send_user " Assigned password = $password\n" # send_user " \n" # send_user " \n" # send_user " \n" # continue # } #disconnect spawn passwd [lindex $argv 0] expect_after { eof { sleep 02 } exit } expect "password:" send "$password\r" expect "password:" send "$password\r" sleep 02 } #expect eof --=_C2971980.E584E80F Content-Type: text/plain Content-Disposition: attachment; filename="EXECOUT.DOC" Content-Description: WordPerfect 4.2 TMS Password Maintenance & Application Menu =========================================== 1) Password Maintenance 2) TMS STORE Application 3) TMS YARD Application q|Q) quit Select Option[(1-3)|(q)]: Changing password for lmhTST. Old password: Sorry. send: invalid spawn id (4) while executing "send "$password\r"" (file "/usr/local/bin/TMSpassmnt" line 47) q --=_C2971980.E584E80F--