summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNiels Provos <provos@cvs.openbsd.org>2001-11-30 20:31:50 +0000
committerNiels Provos <provos@cvs.openbsd.org>2001-11-30 20:31:50 +0000
commit2248ef8cd3acc2cae765062db59010ba7843f027 (patch)
treed6a46db90df748928eca86f31e9eda6dbfaa2b98
parent9053583f4f385c0429c7a0385e1b5867cc8387bd (diff)
remove pipe based interface; only support PF_KEY; okay deraadt@
-rw-r--r--sbin/photurisd/api.c60
-rw-r--r--sbin/photurisd/photuris.h3
-rw-r--r--sbin/photurisd/server.c73
3 files changed, 24 insertions, 112 deletions
diff --git a/sbin/photurisd/api.c b/sbin/photurisd/api.c
index 6537543cae2..b4fbab9adbd 100644
--- a/sbin/photurisd/api.c
+++ b/sbin/photurisd/api.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: api.c,v 1.5 2001/01/28 22:45:06 niklas Exp $ */
+/* $OpenBSD: api.c,v 1.6 2001/11/30 20:31:49 provos Exp $ */
/*
* Copyright 1997-2000 Niels Provos <provos@citi.umich.edu>
@@ -39,7 +39,7 @@
*/
#ifndef lint
-static char rcsid[] = "$OpenBSD: api.c,v 1.5 2001/01/28 22:45:06 niklas Exp $";
+static char rcsid[] = "$OpenBSD: api.c,v 1.6 2001/11/30 20:31:49 provos Exp $";
#endif
#define _API_C_
@@ -63,62 +63,6 @@ static char rcsid[] = "$OpenBSD: api.c,v 1.5 2001/01/28 22:45:06 niklas Exp $";
#include "server.h"
#include "packet.h"
-
-/*
- * process_api:
- * process requests from user processes or kernel notify
- */
-
-void
-process_api(int fd, int sendsock)
-{
- struct stateob *st;
- int sz, i;
-
-#ifdef DEBUG
- printf("Entering API.\n");
-#endif
-
- bzero(buffer, BUFFER_SIZE);
-
- if ((sz = read(fd, buffer, BUFFER_SIZE)) == -1)
- log_fatal("read() in process_api()");
-
- buffer[sz >= BUFFER_SIZE ? BUFFER_SIZE -1 : sz] = 0;
-
- if (!sz)
- return;
-
- /* Set up a new state object */
- if ((st = state_new()) == NULL) {
- log_error("state_new() in process_api()");
- return;
- }
-
- startup_parse(st, buffer);
-
-#ifndef DEBUG
- if (addresses != (char **) NULL && strlen(st->address))
- for (i = 0; i < num_ifs; i++) {
- if (addresses[i] == (char *)NULL)
- continue;
- if (!strcmp(addresses[i], st->address)) {
- /* XXX Code to notify kernel of failure here */
- log_print("discarded request to initiate KES with localhost");
- state_value_reset(st);
- free(st);
- return;
- }
- }
-#endif
-
- startup_end(st);
-
-#ifdef DEBUG
- printf("API finished.\n");
-#endif
-}
-
int
start_exchange(int sd, struct stateob *st, char *address, int port)
{
diff --git a/sbin/photurisd/photuris.h b/sbin/photurisd/photuris.h
index 22b1aad4035..38bada09584 100644
--- a/sbin/photurisd/photuris.h
+++ b/sbin/photurisd/photuris.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: photuris.h,v 1.3 2001/01/28 22:45:13 niklas Exp $ */
+/* $OpenBSD: photuris.h,v 1.4 2001/11/30 20:31:49 provos Exp $ */
/*
* Copyright 1997-2000 Niels Provos <provos@citi.umich.edu>
* All rights reserved.
@@ -46,7 +46,6 @@
#endif
#define PHOTURIS_DIR "/etc/photuris"
-#define PHOTURIS_FIFO "photuris.pipe"
#define PHOTURIS_STARTUP "photuris.startup"
#define PHOTURIS_CONFIG "photuris.conf"
#define PHOTURIS_SECRET "secrets.conf"
diff --git a/sbin/photurisd/server.c b/sbin/photurisd/server.c
index 0c8c8dad523..44e9a767d52 100644
--- a/sbin/photurisd/server.c
+++ b/sbin/photurisd/server.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: server.c,v 1.10 2001/11/17 19:54:57 deraadt Exp $ */
+/* $OpenBSD: server.c,v 1.11 2001/11/30 20:31:49 provos Exp $ */
/*
* Copyright 1997-2000 Niels Provos <provos@citi.umich.edu>
@@ -37,7 +37,7 @@
*/
#ifndef lint
-static char rcsid[] = "$OpenBSD: server.c,v 1.10 2001/11/17 19:54:57 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: server.c,v 1.11 2001/11/30 20:31:49 provos Exp $";
#endif
#define _SERVER_C_
@@ -128,36 +128,13 @@ init_server(void)
log_fatal("bind() in init_server()");
/* Save interfaces addresses here */
- addresses = (char **) calloc(1+1, sizeof(char *));
- if (addresses == (char **) NULL)
- log_fatal("calloc() in init_server()");
- addresses[1] = (char *) NULL;
-
- sockets = (int *) calloc(1+1, sizeof(int));
- if (sockets == (int *) NULL)
- log_fatal("calloc() in init_server()");
- sockets[1] = -1;
-
- if (lstat(PHOTURIS_FIFO, &sb) == -1) {
- if (errno != ENOENT)
- log_fatal("stat() in init_server()");
- if (mkfifo(PHOTURIS_FIFO, 0660) == -1)
- log_fatal("mkfifo() in init_server()");
- } else if (!(sb.st_mode & S_IFIFO))
- log_print("%s is not a FIFO in init_server()", PHOTURIS_FIFO);
-
- /* We listen on a named pipe */
-#if defined(linux) || defined(_AIX)
- if ((sockets[0] = open(PHOTURIS_FIFO, O_RDWR| O_NONBLOCK, 0)) == -1)
-#else
- if ((sockets[0] = open(PHOTURIS_FIFO, O_RDONLY | O_NONBLOCK, 0)) == -1)
-#endif
- log_fatal("open() in init_server()");
- i = 1; /* One interface already */
+ addresses = NULL;
+ sockets = NULL;
+ i = 0;
#ifdef IPSEC
/* We also listen on pfkeyv2 for notify messages */
- newbuf = realloc(addresses, (i + 2) * sizeof(char *));
+ newbuf = realloc(addresses, (i + 1) * sizeof(char *));
if (newbuf == NULL) {
if (addresses != NULL)
free (addresses);
@@ -167,7 +144,7 @@ init_server(void)
addresses[i + 1] = (char *) NULL;
- newbuf = realloc(sockets, (i + 2)* sizeof(int));
+ newbuf = realloc(sockets, (i + 1) * sizeof(int));
if (newbuf == NULL) {
if (sockets != NULL)
free (sockets);
@@ -176,7 +153,6 @@ init_server(void)
sockets = (int *) newbuf;
sockets[i] = kernel_get_socket();
- sockets[i+1] = -1;
i++; /* Next interface */
#endif
@@ -195,7 +171,7 @@ init_server(void)
continue;
}
- newbuf = realloc(addresses, (i + 2) * sizeof(char *));
+ newbuf = realloc(addresses, (i + 1) * sizeof(char *));
if (newbuf == NULL) {
if (addresses != NULL)
free (addresses);
@@ -206,9 +182,8 @@ init_server(void)
addresses[i] = strdup(inet_ntoa(sin2->sin_addr));
if (addresses[i] == (char *) NULL)
log_fatal("strdup() in init_server()");
- addresses[i + 1] = (char *) NULL;
- newbuf = realloc(sockets, (i + 2)* sizeof(int));
+ newbuf = realloc(sockets, (i + 1)* sizeof(int));
if (newbuf == NULL) {
if (sockets != NULL)
free (sockets);
@@ -216,8 +191,6 @@ init_server(void)
}
sockets = (int *) newbuf;
- sockets[i+1] = -1;
-
if ((sock = socket(PF_INET, SOCK_DGRAM, proto->p_proto)) < 0)
log_fatal("socket() in init_server()");
setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (void *)&on,
@@ -306,27 +279,23 @@ server(void)
#ifdef IPSEC
if (i == 1) /* PF_ENCAP NOTIFIES */
kernel_handle_notify(sockets[i]);
- else
+ else {
#endif
- if (addresses[i] == NULL)
- process_api(sockets[i], global_socket);
- else {
- d = sizeof(struct sockaddr_in);
- if (recvfrom(sockets[i],
+ d = sizeof(struct sockaddr_in);
+ if (recvfrom(sockets[i],
#ifdef BROKEN_RECVFROM
- (char *) buffer, 1,
+ (char *) buffer, 1,
#else
- (char *) NULL, 0,
+ (char *) NULL, 0,
#endif
- MSG_PEEK,
- (struct sockaddr *)&sin,
- &d) == -1) {
- log_error("recvfrom() in server()");
- return -1;
- }
- handle_packet(sockets[i], addresses[i]);
+ MSG_PEEK,
+ (struct sockaddr *)&sin, &d) == -1) {
+ log_error("recvfrom() in server()");
+ return -1;
+ }
+ handle_packet(sockets[i], addresses[i]);
}
- }
+ }
}
#ifdef IPSEC