I'm probably overlooking something very simple. :)  My apologies for the
long email, I needed to include the script and the debug output.

We have a slightly non-standard passwd program.  As such, I am modifying the
expect script libexec/authlib/changepwd/authsystem.passwd.

Our password program does the following on a successful change:

bash-2.05$ passwd
passwd: Changing password for testuser
Enter your old password:
Enter your new password:
Enter your new password again:
<Delay of about 30 seconds here due to a lot of things needing to be done
for password change>
Password change successful.

On a non-successful change:

bash-2.05$ passwd
passwd: Changing password for testuser
Enter your old password:
Enter your new password:
Enter your new password again:
Old password is incorrect.  Password not changed.

I have modified the expect script to be as follows:
---------------
#!/usr/local/bin/expect -d -f
set timeout 60

expect {
        -re "(.*)\n(.*)\n" { set oldpass "$expect_out(1,string)" ; set
newpass "$expect_out(2,string)" }
        eof { exit 1 }
        timeout { exit 1 }
}

spawn "/usr/bin/passwd"

expect {
        -re "word:" { send "$oldpass\n" }
        eof { exit 1 }
        timeout { exit 1 }
}

expect {
        -re "nvalid" { exit 1 }
        -re "word:" { send "$newpass\n" }
        eof { exit 1 }
        timeout { exit 1 }
}

expect {
        -re "nvalid" { exit 1 }
        -re "NVALID" { exit 1 }
        -re "bad pass" { exit 1 }
        -re "BAD PASS" { exit 1 }
        -re "dictionary" { exit 1 }
        -re "common" { exit 1 }
        -re "short" { exit 1 }
        -re "gain:" { send "$newpass\n" }
        eof { exit 1 }
        timeout { exit 1 }
}

expect {
        -re "nvalid" { exit 1 }
        -re "nchange" { exit 1 }
        -re "same" { exit 1 }
        -re "ful." { exit 0 }
        eof { exit 0 }
        timeout { exit 1 }
}

exit 1
---------------

Now, if I change to testuser, and run the expect script (in debug mode with
the -d at the top of the file) I get:

---------------
expect version 5.32.1
argv[0] = /usr/local/bin/expect  argv[1] = -d  argv[2] =
/usr/lib/courier/libexec/authlib/changepwd/authsystem.passwd
set argc 0
set argv0 "/usr/lib/courier/libexec/authlib/changepwd/authsystem.passwd"
set argv ""
executing commands from command file
/usr/lib/courier/libexec/authlib/changepwd/authsystem.passwd

expect: does "" (spawn_id exp0) match regular expression "(.*)\n(.*)\n"? no
2345

expect: does "2345\n" (spawn_id exp0) match regular expression
"(.*)\n(.*)\n"? no
1234

expect: does "2345\n1234\n" (spawn_id exp0) match regular expression
"(.*)\n(.*)\n"? yes
expect: set expect_out(0,string) "2345\n1234\n"
expect: set expect_out(1,string) "2345"
expect: set expect_out(2,string) "1234"
expect: set expect_out(spawn_id) "exp0"
expect: set expect_out(buffer) "2345\n1234\n"
spawn /usr/bin/unlv-passwd
parent: waiting for sync byte
parent: telling child to go ahead
parent: now unsynchronized from child
spawn: returns {8564}

expect: does "" (spawn_id exp6) match regular expression "word:"? no
passwd: Changing password for testuser
Enter your old password:
expect: does "passwd: Changing password for testuser\r\nEnter your old
password: " (spawn_id exp6) match regular expression "word:"? yes
expect: set expect_out(0,string) "word:"
expect: set expect_out(spawn_id) "exp6"
expect: set expect_out(buffer) "passwd: Changing password for
testuser\r\nEnter your old password:"
send: sending "2345\n" to { exp6 }

expect: does " " (spawn_id exp6) match regular expression "nvalid"? no
"word:"? no

Enter your new password:
expect: does " \r\nEnter your new password: " (spawn_id exp6) match regular
expression "nvalid"? no
"word:"? yes
expect: set expect_out(0,string) "word:"
expect: set expect_out(spawn_id) "exp6"
expect: set expect_out(buffer) " \r\nEnter your new password:"
send: sending "1234\n" to { exp6 }

expect: does " " (spawn_id exp6) match regular expression "nvalid"? no
"NVALID"? no
"bad pass"? no
"BAD PASS"? no
"dictionary"? no
"common"? no
"short"? no
"gain:"? no

Enter your new password again:
expect: does " \r\nEnter your new password again: " (spawn_id exp6) match
regular expression "nvalid"? no
"NVALID"? no
"bad pass"? no
"BAD PASS"? no
"dictionary"? no
"common"? no
"short"? no
"gain:"? yes
expect: set expect_out(0,string) "gain:"
expect: set expect_out(spawn_id) "exp6"
expect: set expect_out(buffer) " \r\nEnter your new password again:"
send: sending "1234\n" to { exp6 }

expect: does " " (spawn_id exp6) match regular expression "nvalid"? no
"nchange"? no
"same"? no
"ful."? no


expect: does " \r\n" (spawn_id exp6) match regular expression "nvalid"? no
"nchange"? no
"same"? no
"ful."? no
Password change successful.

expect: does " \r\nPassword change successful.\r\n" (spawn_id exp6) match
regular expression "nvalid"? no
"nchange"? no
"same"? no
"ful."? yes
expect: set expect_out(0,string) "ful."
expect: set expect_out(spawn_id) "exp6"
expect: set expect_out(buffer) " \r\nPassword change successful."
bash-2.05$ echo $?
0
----

So it is matching, and it is returning 0.  Yet webmail reports the password
wasn't changed successful (with the large red text saying so), when in fact
it was.

Am I missing something obvious?

---
Andrew Gray
Systems Administrator
University of Nevada, Las Vegas
College of Engineering




-------------------------------------------------------
This sf.net email is sponsored by: To learn the basics of securing 
your web site with SSL, click here to get a FREE TRIAL of a Thawte 
Server Certificate: http://www.gothawte.com/rd524.html
_______________________________________________
courier-users mailing list
[EMAIL PROTECTED]
Unsubscribe: https://lists.sourceforge.net/lists/listinfo/courier-users

Reply via email to