--- ../4/poppassd.c 2007-01-17 18:46:12.000000000 +0530 +++ poppassd.c 2007-01-17 11:17:41.000000000 +0530 @@ -92,6 +92,16 @@ char **pamstrings[2]; // 0 - oldpass, 1 - newpass +// The default PAM strings for old and new passwords +char *oldstr[] = { "Password: ", + "Enter login(LDAP) password: " }; + +char *newstr[] = { "New password: ", + "Re-enter new password: ", + "Enter new UNIX password: ", + "Retype new UNIX password: ", + "New UNIX password: " }; + void WriteToClient (char *fmt, ...) { va_list ap; @@ -136,9 +146,12 @@ void setstrings(int argc, char **argv) { - int old=0, new=0, c; + int old, new, c; extern int opterr; + old = sizeof(oldstr) / sizeof(oldstr[0]); + new = sizeof(newstr) / sizeof(newstr[0]); + opterr = 0; while(1) { @@ -162,6 +175,14 @@ } optind = 1; + // add the default PAM strings present in oldstr and newstr to the end of pamstrings + for(c = 0 ; c < (sizeof(oldstr) / sizeof(oldstr[0])) ; c++) + pamstrings[POP_OLDPASS][--old] = oldstr[c]; + + for(c = 0 ; c < (sizeof(newstr) / sizeof(newstr[0])) ; c++) + pamstrings[POP_NEWPASS][--new] = newstr[c]; + + // add the cli PAM arguments infront of the default ones (added above) while(1) { c = getopt(argc, argv, "n:o:"); @@ -175,31 +196,16 @@ { char **pammsg; - /* Interpret possible PAM messages (not including errors) */ + // check if PAM is asking for old password for(pammsg = pamstrings[POP_OLDPASS] ; *pammsg ; pammsg++) if(!strcmp(msg, *pammsg)) return POP_OLDPASS; - if(!strcmp(msg, "Password: ")) - return POP_OLDPASS; - if(!strcmp(msg, "Enter login(LDAP) password: ")) - return POP_OLDPASS; - + // check if PAM is asking for new password for(pammsg = pamstrings[POP_NEWPASS] ; *pammsg ; pammsg++) if(!strcmp(msg, *pammsg)) return POP_NEWPASS; - if(!strcmp(msg, "New password: ")) - return POP_NEWPASS; - if(!strcmp(msg, "Re-enter new password: ")) - return POP_NEWPASS; - if(!strcmp(msg, "Enter new UNIX password: ")) - return POP_NEWPASS; - if(!strcmp(msg, "Retype new UNIX password: ")) - return POP_NEWPASS; - if(!strcmp(msg, "New UNIX password: ")) - return POP_NEWPASS; - WriteToClient("Unknown PAM Message: %s", msg); // We should not ever reach here. return POP_SKIPASS;