summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorKevin Steves <stevesk@cvs.openbsd.org>2002-02-05 15:50:13 +0000
committerKevin Steves <stevesk@cvs.openbsd.org>2002-02-05 15:50:13 +0000
commit88aba8a3432b32e750331cbeae4e915673df2073 (patch)
treef5a2246e9d082f2a8ab2a2a227faaf32cb8977e4 /usr.bin
parent469d1b1aae9e146e9c3f00d1633a4446768b7c91 (diff)
use log interface and remove perror() in child. use
fatal_add_cleanup() vs. atexit(). ok mouring@ markus@
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/ssh/ssh-agent.c28
1 files changed, 14 insertions, 14 deletions
diff --git a/usr.bin/ssh/ssh-agent.c b/usr.bin/ssh/ssh-agent.c
index 1ad62f578b6..d01cf90dc96 100644
--- a/usr.bin/ssh/ssh-agent.c
+++ b/usr.bin/ssh/ssh-agent.c
@@ -1,4 +1,4 @@
-/* $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>
@@ -37,7 +37,7 @@
#include "includes.h"
#include <sys/queue.h>
-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 $");
#include <openssl/evp.h>
#include <openssl/md5.h>
@@ -712,7 +712,8 @@ after_select(fd_set *readset, fd_set *writeset)
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);
@@ -766,7 +767,7 @@ after_select(fd_set *readset, fd_set *writeset)
}
static void
-cleanup_socket(void)
+cleanup_socket(void *p)
{
if (socket_name[0])
unlink(socket_name);
@@ -777,14 +778,14 @@ cleanup_socket(void)
static void
cleanup_exit(int i)
{
- cleanup_socket();
+ cleanup_socket(NULL);
exit(i);
}
static void
cleanup_handler(int sig)
{
- cleanup_socket();
+ cleanup_socket(NULL);
_exit(2);
}
@@ -933,7 +934,7 @@ main(int ac, char **av)
pid = fork();
if (pid == -1) {
perror("fork");
- exit(1);
+ cleanup_exit(1);
}
if (pid != 0) { /* Parent - execute the given command. */
close(sock);
@@ -956,9 +957,11 @@ main(int ac, char **av)
perror(av[0]);
exit(1);
}
+ /* child */
+ log_init(__progname, SYSLOG_LEVEL_INFO, SYSLOG_FACILITY_AUTH, 0);
if (setsid() == -1) {
- perror("setsid");
+ error("setsid: %s", strerror(errno));
cleanup_exit(1);
}
@@ -970,15 +973,12 @@ main(int ac, char **av)
/* 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);
}
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);
@@ -997,7 +997,7 @@ skip:
if (select(max_fd + 1, readsetp, writesetp, NULL, NULL) < 0) {
if (errno == EINTR)
continue;
- exit(1);
+ fatal("select: %s", strerror(errno));
}
after_select(readsetp, writesetp);
}