Lines 88-94
Link Here
|
88 |
#define POP_OLDPASS 0 |
88 |
#define POP_OLDPASS 0 |
89 |
#define POP_NEWPASS 1 |
89 |
#define POP_NEWPASS 1 |
90 |
#define POP_SKIPASS 2 |
90 |
#define POP_SKIPASS 2 |
91 |
short int pop_state = POP_OLDPASS; |
|
|
92 |
|
91 |
|
93 |
void WriteToClient (char *fmt, ...) |
92 |
void WriteToClient (char *fmt, ...) |
94 |
{ |
93 |
{ |
Lines 116-121
Link Here
|
116 |
line[BUFSIZE-1] = '\0'; |
115 |
line[BUFSIZE-1] = '\0'; |
117 |
} |
116 |
} |
118 |
|
117 |
|
|
|
118 |
static inline int getstate(const char *msg) |
119 |
{ |
120 |
/* Interpret possible PAM messages (not including errors) */ |
121 |
if(!strcmp(msg, "Password: ")) |
122 |
return POP_OLDPASS; |
123 |
if(!strcmp(msg, "Enter login(LDAP) password: ")) |
124 |
return POP_OLDPASS; |
125 |
|
126 |
if(!strcmp(msg, "New password: ")) |
127 |
return POP_NEWPASS; |
128 |
if(!strcmp(msg, "Re-enter new password: ")) |
129 |
return POP_NEWPASS; |
130 |
if(!strcmp(msg, "Enter new UNIX password: ")) |
131 |
return POP_NEWPASS; |
132 |
if(!strcmp(msg, "Retype new UNIX password: ")) |
133 |
return POP_NEWPASS; |
134 |
if(!strcmp(msg, "New UNIX password: ")) |
135 |
return POP_NEWPASS; |
136 |
|
137 |
WriteToClient("Unknown PAM Message: %s", msg); // We should not ever reach here. |
138 |
|
139 |
return POP_SKIPASS; |
140 |
} |
141 |
|
119 |
int poppassd_conv(num_msg, msg, resp, appdata_ptr) |
142 |
int poppassd_conv(num_msg, msg, resp, appdata_ptr) |
120 |
int num_msg; |
143 |
int num_msg; |
121 |
const struct pam_message **msg; |
144 |
const struct pam_message **msg; |
Lines 147-153
Link Here
|
147 |
if(msg[i]->msg_style == PAM_PROMPT_ECHO_OFF || |
170 |
if(msg[i]->msg_style == PAM_PROMPT_ECHO_OFF || |
148 |
msg[i]->msg_style == PAM_PROMPT_ECHO_ON) |
171 |
msg[i]->msg_style == PAM_PROMPT_ECHO_ON) |
149 |
{ |
172 |
{ |
150 |
switch(pop_state) { |
173 |
switch(getstate(msg[i]->msg)) { |
151 |
case POP_OLDPASS: |
174 |
case POP_OLDPASS: |
152 |
r[i].resp = strdup(oldpass); |
175 |
r[i].resp = strdup(oldpass); |
153 |
break; |
176 |
break; |
Lines 158-164
Link Here
|
158 |
r[i].resp = NULL; |
181 |
r[i].resp = NULL; |
159 |
break; |
182 |
break; |
160 |
default: |
183 |
default: |
161 |
syslog(LOG_ERR, "PAM error: too many switches (state=%d)", pop_state); |
184 |
syslog(LOG_ERR, "PAM error: too many switches"); |
162 |
} |
185 |
} |
163 |
} else |
186 |
} else |
164 |
{ |
187 |
{ |
Lines 235-242
Link Here
|
235 |
exit(1); |
258 |
exit(1); |
236 |
} |
259 |
} |
237 |
|
260 |
|
238 |
pop_state = POP_NEWPASS; |
|
|
239 |
|
240 |
WriteToClient ("200 Your new password please."); |
261 |
WriteToClient ("200 Your new password please."); |
241 |
ReadFromClient (line); |
262 |
ReadFromClient (line); |
242 |
sscanf (line, "newpass %" MAX_LEN_PASS "c", newpass); |
263 |
sscanf (line, "newpass %" MAX_LEN_PASS "c", newpass); |