Lines 140-146
struct pam_ctxt {
Link Here
|
140 |
static void sshpam_free_ctx(void *); |
140 |
static void sshpam_free_ctx(void *); |
141 |
static struct pam_ctxt *cleanup_ctxt; |
141 |
static struct pam_ctxt *cleanup_ctxt; |
142 |
|
142 |
|
143 |
#ifndef UNSUPPORTED_POSIX_THREADS_HACK |
143 |
#ifdef UNSUPPORTED_POSIX_THREADS_HACK |
|
|
144 |
/* |
145 |
* Avoid namespace clash when *not* using pthreads for systems *with* |
146 |
* pthreads, where OpenSSL includes <pthread.h> in openssl/crypto.h |
147 |
*/ |
148 |
# define _pthread_exit pthead_exit |
149 |
# define _pthread_create pthread_create |
150 |
# define _pthread_cancel pthread_cancel |
151 |
# define _pthread_join pthread_join |
152 |
#else |
144 |
/* |
153 |
/* |
145 |
* Simulate threads with processes. |
154 |
* Simulate threads with processes. |
146 |
*/ |
155 |
*/ |
Lines 167-173
sshpam_sigchld_handler(int sig)
Link Here
|
167 |
} |
176 |
} |
168 |
if (WIFSIGNALED(sshpam_thread_status) && |
177 |
if (WIFSIGNALED(sshpam_thread_status) && |
169 |
WTERMSIG(sshpam_thread_status) == SIGTERM) |
178 |
WTERMSIG(sshpam_thread_status) == SIGTERM) |
170 |
return; /* terminated by pthread_cancel */ |
179 |
return; /* terminated by _pthread_cancel */ |
171 |
if (!WIFEXITED(sshpam_thread_status)) |
180 |
if (!WIFEXITED(sshpam_thread_status)) |
172 |
sigdie("PAM: authentication thread exited unexpectedly"); |
181 |
sigdie("PAM: authentication thread exited unexpectedly"); |
173 |
if (WEXITSTATUS(sshpam_thread_status) != 0) |
182 |
if (WEXITSTATUS(sshpam_thread_status) != 0) |
Lines 176-189
sshpam_sigchld_handler(int sig)
Link Here
|
176 |
|
185 |
|
177 |
/* ARGSUSED */ |
186 |
/* ARGSUSED */ |
178 |
static void |
187 |
static void |
179 |
pthread_exit(void *value) |
188 |
_pthread_exit(void *value) |
180 |
{ |
189 |
{ |
181 |
_exit(0); |
190 |
_exit(0); |
182 |
} |
191 |
} |
183 |
|
192 |
|
184 |
/* ARGSUSED */ |
193 |
/* ARGSUSED */ |
185 |
static int |
194 |
static int |
186 |
pthread_create(sp_pthread_t *thread, const void *attr, |
195 |
_pthread_create(sp_pthread_t *thread, const void *attr, |
187 |
void *(*thread_start)(void *), void *arg) |
196 |
void *(*thread_start)(void *), void *arg) |
188 |
{ |
197 |
{ |
189 |
pid_t pid; |
198 |
pid_t pid; |
Lines 209-215
pthread_create(sp_pthread_t *thread, const void *attr,
Link Here
|
209 |
} |
218 |
} |
210 |
|
219 |
|
211 |
static int |
220 |
static int |
212 |
pthread_cancel(sp_pthread_t thread) |
221 |
_pthread_cancel(sp_pthread_t thread) |
213 |
{ |
222 |
{ |
214 |
signal(SIGCHLD, sshpam_oldsig); |
223 |
signal(SIGCHLD, sshpam_oldsig); |
215 |
return (kill(thread, SIGTERM)); |
224 |
return (kill(thread, SIGTERM)); |
Lines 217-223
pthread_cancel(sp_pthread_t thread)
Link Here
|
217 |
|
226 |
|
218 |
/* ARGSUSED */ |
227 |
/* ARGSUSED */ |
219 |
static int |
228 |
static int |
220 |
pthread_join(sp_pthread_t thread, void **value) |
229 |
_pthread_join(sp_pthread_t thread, void **value) |
221 |
{ |
230 |
{ |
222 |
int status; |
231 |
int status; |
223 |
|
232 |
|
Lines 505-511
sshpam_thread(void *ctxtp)
Link Here
|
505 |
/* XXX - can't do much about an error here */ |
514 |
/* XXX - can't do much about an error here */ |
506 |
ssh_msg_send(ctxt->pam_csock, sshpam_err, &buffer); |
515 |
ssh_msg_send(ctxt->pam_csock, sshpam_err, &buffer); |
507 |
buffer_free(&buffer); |
516 |
buffer_free(&buffer); |
508 |
pthread_exit(NULL); |
517 |
_pthread_exit(NULL); |
509 |
|
518 |
|
510 |
auth_fail: |
519 |
auth_fail: |
511 |
buffer_put_cstring(&buffer, |
520 |
buffer_put_cstring(&buffer, |
Lines 518-524
sshpam_thread(void *ctxtp)
Link Here
|
518 |
else |
527 |
else |
519 |
ssh_msg_send(ctxt->pam_csock, PAM_AUTH_ERR, &buffer); |
528 |
ssh_msg_send(ctxt->pam_csock, PAM_AUTH_ERR, &buffer); |
520 |
buffer_free(&buffer); |
529 |
buffer_free(&buffer); |
521 |
pthread_exit(NULL); |
530 |
_pthread_exit(NULL); |
522 |
|
531 |
|
523 |
return (NULL); /* Avoid warning for non-pthread case */ |
532 |
return (NULL); /* Avoid warning for non-pthread case */ |
524 |
} |
533 |
} |
Lines 530-537
sshpam_thread_cleanup(void)
Link Here
|
530 |
|
539 |
|
531 |
debug3("PAM: %s entering", __func__); |
540 |
debug3("PAM: %s entering", __func__); |
532 |
if (ctxt != NULL && ctxt->pam_thread != 0) { |
541 |
if (ctxt != NULL && ctxt->pam_thread != 0) { |
533 |
pthread_cancel(ctxt->pam_thread); |
542 |
_pthread_cancel(ctxt->pam_thread); |
534 |
pthread_join(ctxt->pam_thread, NULL); |
543 |
_pthread_join(ctxt->pam_thread, NULL); |
535 |
close(ctxt->pam_psock); |
544 |
close(ctxt->pam_psock); |
536 |
close(ctxt->pam_csock); |
545 |
close(ctxt->pam_csock); |
537 |
memset(ctxt, 0, sizeof(*ctxt)); |
546 |
memset(ctxt, 0, sizeof(*ctxt)); |
Lines 695-701
sshpam_init_ctx(Authctxt *authctxt)
Link Here
|
695 |
} |
704 |
} |
696 |
ctxt->pam_psock = socks[0]; |
705 |
ctxt->pam_psock = socks[0]; |
697 |
ctxt->pam_csock = socks[1]; |
706 |
ctxt->pam_csock = socks[1]; |
698 |
if (pthread_create(&ctxt->pam_thread, NULL, sshpam_thread, ctxt) == -1) { |
707 |
if (_pthread_create(&ctxt->pam_thread, NULL, sshpam_thread, ctxt) == -1) { |
699 |
error("PAM: failed to start authentication thread: %s", |
708 |
error("PAM: failed to start authentication thread: %s", |
700 |
strerror(errno)); |
709 |
strerror(errno)); |
701 |
close(socks[0]); |
710 |
close(socks[0]); |