version 1.111.2.2, 2004/08/19 22:37:32 |
version 1.112, 2003/09/18 08:49:45 |
|
|
#include "authfd.h" |
#include "authfd.h" |
#include "compat.h" |
#include "compat.h" |
#include "log.h" |
#include "log.h" |
|
#include "readpass.h" |
#include "misc.h" |
#include "misc.h" |
|
|
#ifdef SMARTCARD |
#ifdef SMARTCARD |
|
|
p = read_passphrase(prompt, RP_ALLOW_EOF); |
p = read_passphrase(prompt, RP_ALLOW_EOF); |
if (p != NULL) { |
if (p != NULL) { |
/* |
/* |
* Accept empty responses and responses consisting |
* Accept empty responses and responses consisting |
* of the word "yes" as affirmative. |
* of the word "yes" as affirmative. |
*/ |
*/ |
if (*p == '\0' || *p == '\n' || strcasecmp(p, "yes") == 0) |
if (*p == '\0' || *p == '\n' || strcasecmp(p, "yes") == 0) |
|
|
{ |
{ |
u_int i, old_alloc, new_alloc; |
u_int i, old_alloc, new_alloc; |
|
|
set_nonblock(fd); |
if (fcntl(fd, F_SETFL, O_NONBLOCK) < 0) |
|
error("fcntl O_NONBLOCK: %s", strerror(errno)); |
|
|
if (fd > max_fd) |
if (fd > max_fd) |
max_fd = fd; |
max_fd = fd; |
|
|
} |
} |
|
|
static int |
static int |
prepare_select(fd_set **fdrp, fd_set **fdwp, int *fdl, u_int *nallocp) |
prepare_select(fd_set **fdrp, fd_set **fdwp, int *fdl, int *nallocp) |
{ |
{ |
u_int i, sz; |
u_int i, sz; |
int n = 0; |
int n = 0; |
|
|
} |
} |
|
|
static void |
static void |
cleanup_socket(void) |
cleanup_socket(void *p) |
{ |
{ |
if (socket_name[0]) |
if (socket_name[0]) |
unlink(socket_name); |
unlink(socket_name); |
|
|
rmdir(socket_dir); |
rmdir(socket_dir); |
} |
} |
|
|
void |
static void |
cleanup_exit(int i) |
cleanup_exit(int i) |
{ |
{ |
cleanup_socket(); |
cleanup_socket(NULL); |
_exit(i); |
exit(i); |
} |
} |
|
|
static void |
static void |
cleanup_handler(int sig) |
cleanup_handler(int sig) |
{ |
{ |
cleanup_socket(); |
cleanup_socket(NULL); |
_exit(2); |
_exit(2); |
} |
} |
|
|
|
|
main(int ac, char **av) |
main(int ac, char **av) |
{ |
{ |
int c_flag = 0, d_flag = 0, k_flag = 0, s_flag = 0; |
int c_flag = 0, d_flag = 0, k_flag = 0, s_flag = 0; |
int sock, fd, ch; |
int sock, fd, ch, nalloc; |
u_int nalloc; |
|
char *shell, *format, *pidstr, *agentsocket = NULL; |
char *shell, *format, *pidstr, *agentsocket = NULL; |
fd_set *readsetp = NULL, *writesetp = NULL; |
fd_set *readsetp = NULL, *writesetp = NULL; |
struct sockaddr_un sunaddr; |
struct sockaddr_un sunaddr; |
|
|
|
|
if (agentsocket == NULL) { |
if (agentsocket == NULL) { |
/* Create private directory for agent socket */ |
/* Create private directory for agent socket */ |
strlcpy(socket_dir, "/tmp/ssh-XXXXXXXXXX", sizeof socket_dir); |
strlcpy(socket_dir, "/tmp/ssh-XXXXXXXX", sizeof socket_dir); |
if (mkdtemp(socket_dir) == NULL) { |
if (mkdtemp(socket_dir) == NULL) { |
perror("mkdtemp: private socket dir"); |
perror("mkdtemp: private socket dir"); |
exit(1); |
exit(1); |
|
|
perror("bind"); |
perror("bind"); |
cleanup_exit(1); |
cleanup_exit(1); |
} |
} |
if (listen(sock, SSH_LISTEN_BACKLOG) < 0) { |
if (listen(sock, 128) < 0) { |
perror("listen"); |
perror("listen"); |
cleanup_exit(1); |
cleanup_exit(1); |
} |
} |
|
|
} |
} |
|
|
skip: |
skip: |
|
fatal_add_cleanup(cleanup_socket, NULL); |
new_socket(AUTH_SOCKET, sock); |
new_socket(AUTH_SOCKET, sock); |
if (ac > 0) { |
if (ac > 0) { |
signal(SIGALRM, check_parent_exists); |
signal(SIGALRM, check_parent_exists); |