version 1.85.2.1, 2002/06/26 15:30:39 |
version 1.85.2.2, 2002/10/11 14:51:53 |
|
|
extern char *__progname; |
extern char *__progname; |
|
|
static void |
static void |
|
close_socket(SocketEntry *e) |
|
{ |
|
close(e->fd); |
|
e->fd = -1; |
|
e->type = AUTH_UNUSED; |
|
buffer_free(&e->input); |
|
buffer_free(&e->output); |
|
buffer_free(&e->request); |
|
} |
|
|
|
static void |
idtab_init(void) |
idtab_init(void) |
{ |
{ |
int i; |
int i; |
|
|
cp = buffer_ptr(&e->input); |
cp = buffer_ptr(&e->input); |
msg_len = GET_32BIT(cp); |
msg_len = GET_32BIT(cp); |
if (msg_len > 256 * 1024) { |
if (msg_len > 256 * 1024) { |
shutdown(e->fd, SHUT_RDWR); |
close_socket(e); |
close(e->fd); |
|
e->fd = -1; |
|
e->type = AUTH_UNUSED; |
|
buffer_free(&e->input); |
|
buffer_free(&e->output); |
|
buffer_free(&e->request); |
|
return; |
return; |
} |
} |
if (buffer_len(&e->input) < msg_len + 4) |
if (buffer_len(&e->input) < msg_len + 4) |
|
|
char buf[1024]; |
char buf[1024]; |
int len, sock; |
int len, sock; |
u_int i; |
u_int i; |
|
uid_t euid; |
|
gid_t egid; |
|
|
for (i = 0; i < sockets_alloc; i++) |
for (i = 0; i < sockets_alloc; i++) |
switch (sockets[i].type) { |
switch (sockets[i].type) { |
|
|
strerror(errno)); |
strerror(errno)); |
break; |
break; |
} |
} |
|
if (getpeereid(sock, &euid, &egid) < 0) { |
|
error("getpeereid %d failed: %s", |
|
sock, strerror(errno)); |
|
close(sock); |
|
break; |
|
} |
|
if ((euid != 0) && (getuid() != euid)) { |
|
error("uid mismatch: " |
|
"peer euid %u != uid %u", |
|
(u_int) euid, (u_int) getuid()); |
|
close(sock); |
|
break; |
|
} |
new_socket(AUTH_CONNECTION, sock); |
new_socket(AUTH_CONNECTION, sock); |
} |
} |
break; |
break; |
|
|
break; |
break; |
} while (1); |
} while (1); |
if (len <= 0) { |
if (len <= 0) { |
shutdown(sockets[i].fd, SHUT_RDWR); |
close_socket(&sockets[i]); |
close(sockets[i].fd); |
|
sockets[i].fd = -1; |
|
sockets[i].type = AUTH_UNUSED; |
|
buffer_free(&sockets[i].input); |
|
buffer_free(&sockets[i].output); |
|
buffer_free(&sockets[i].request); |
|
break; |
break; |
} |
} |
buffer_consume(&sockets[i].output, len); |
buffer_consume(&sockets[i].output, len); |
|
|
break; |
break; |
} while (1); |
} while (1); |
if (len <= 0) { |
if (len <= 0) { |
shutdown(sockets[i].fd, SHUT_RDWR); |
close_socket(&sockets[i]); |
close(sockets[i].fd); |
|
sockets[i].fd = -1; |
|
sockets[i].type = AUTH_UNUSED; |
|
buffer_free(&sockets[i].input); |
|
buffer_free(&sockets[i].output); |
|
buffer_free(&sockets[i].request); |
|
break; |
break; |
} |
} |
buffer_append(&sockets[i].input, buf, len); |
buffer_append(&sockets[i].input, buf, len); |
|
|
struct sockaddr_un sunaddr; |
struct sockaddr_un sunaddr; |
struct rlimit rlim; |
struct rlimit rlim; |
extern int optind; |
extern int optind; |
|
extern char *optarg; |
pid_t pid; |
pid_t pid; |
char pidstrbuf[1 + 3 * sizeof pid]; |
char pidstrbuf[1 + 3 * sizeof pid]; |
|
|
|
/* drop */ |
|
setegid(getgid()); |
|
setgid(getgid()); |
|
|
SSLeay_add_all_algorithms(); |
SSLeay_add_all_algorithms(); |
|
|
while ((ch = getopt(ac, av, "cdksa:")) != -1) { |
while ((ch = getopt(ac, av, "cdksa:")) != -1) { |
|
|
perror("bind"); |
perror("bind"); |
cleanup_exit(1); |
cleanup_exit(1); |
} |
} |
if (listen(sock, 5) < 0) { |
if (listen(sock, 128) < 0) { |
perror("listen"); |
perror("listen"); |
cleanup_exit(1); |
cleanup_exit(1); |
} |
} |