[ssh-agent.c]
use log interface and remove perror() in child. use
fatal_add_cleanup() vs. atexit(). ok mouring@ markus@
-/* $OpenBSD: ssh-agent.c,v 1.80 2002/02/04 00:53:39 stevesk Exp $ */
+/* $OpenBSD: ssh-agent.c,v 1.81 2002/02/05 15:50:12 stevesk Exp $ */
/*
* Author: Tatu Ylonen <ylo@cs.hut.fi>
/*
* Author: Tatu Ylonen <ylo@cs.hut.fi>
-RCSID("$OpenBSD: ssh-agent.c,v 1.80 2002/02/04 00:53:39 stevesk Exp $");
+RCSID("$OpenBSD: ssh-agent.c,v 1.81 2002/02/05 15:50:12 stevesk Exp $");
#if defined(HAVE_SYS_QUEUE_H) && !defined(HAVE_BOGUS_SYS_QUEUE_H)
#include <sys/queue.h>
#if defined(HAVE_SYS_QUEUE_H) && !defined(HAVE_BOGUS_SYS_QUEUE_H)
#include <sys/queue.h>
sock = accept(sockets[i].fd,
(struct sockaddr *) &sunaddr, &slen);
if (sock < 0) {
sock = accept(sockets[i].fd,
(struct sockaddr *) &sunaddr, &slen);
if (sock < 0) {
- perror("accept from AUTH_SOCKET");
+ error("accept from AUTH_SOCKET: %s",
+ strerror(errno));
break;
}
new_socket(AUTH_CONNECTION, sock);
break;
}
new_socket(AUTH_CONNECTION, sock);
{
if (socket_name[0])
unlink(socket_name);
{
if (socket_name[0])
unlink(socket_name);
static void
cleanup_exit(int i)
{
static void
cleanup_exit(int i)
{
exit(i);
}
static void
cleanup_handler(int sig)
{
exit(i);
}
static void
cleanup_handler(int sig)
{
pid = fork();
if (pid == -1) {
perror("fork");
pid = fork();
if (pid == -1) {
perror("fork");
}
if (pid != 0) { /* Parent - execute the given command. */
close(sock);
}
if (pid != 0) { /* Parent - execute the given command. */
close(sock);
perror(av[0]);
exit(1);
}
perror(av[0]);
exit(1);
}
+ /* child */
+ log_init(__progname, SYSLOG_LEVEL_INFO, SYSLOG_FACILITY_AUTH, 0);
+ error("setsid: %s", strerror(errno));
/* deny core dumps, since memory contains unencrypted private keys */
rlim.rlim_cur = rlim.rlim_max = 0;
if (setrlimit(RLIMIT_CORE, &rlim) < 0) {
/* deny core dumps, since memory contains unencrypted private keys */
rlim.rlim_cur = rlim.rlim_max = 0;
if (setrlimit(RLIMIT_CORE, &rlim) < 0) {
- perror("setrlimit rlimit_core failed");
+ error("setrlimit RLIMIT_CORE: %s", strerror(errno));
cleanup_exit(1);
}
#endif
skip:
cleanup_exit(1);
}
#endif
skip:
- if (atexit(cleanup_socket) < 0) {
- perror("atexit");
- cleanup_exit(1);
- }
+ fatal_add_cleanup(cleanup_socket, NULL);
new_socket(AUTH_SOCKET, sock);
if (ac > 0) {
signal(SIGALRM, check_parent_exists);
new_socket(AUTH_SOCKET, sock);
if (ac > 0) {
signal(SIGALRM, check_parent_exists);
if (select(max_fd + 1, readsetp, writesetp, NULL, NULL) < 0) {
if (errno == EINTR)
continue;
if (select(max_fd + 1, readsetp, writesetp, NULL, NULL) < 0) {
if (errno == EINTR)
continue;
+ fatal("select: %s", strerror(errno));
}
after_select(readsetp, writesetp);
}
}
after_select(readsetp, writesetp);
}