summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorniklas <niklas@openbsd.org>1999-08-26 22:29:57 +0000
committerniklas <niklas@openbsd.org>1999-08-26 22:29:57 +0000
commit31747f340e44dd70a4e45b97344598bb4f4bf69e (patch)
treefb1c0220a01eb81919a18918fad521a9ab80a4af
parentMerge with EOM 1.8 (diff)
downloadwireguard-openbsd-31747f340e44dd70a4e45b97344598bb4f4bf69e.tar.xz
wireguard-openbsd-31747f340e44dd70a4e45b97344598bb4f4bf69e.zip
Merge with EOM 1.36
author: ho style author: ho Don't accidentally overwrite files with the FIFO.
-rw-r--r--sbin/isakmpd/ui.c15
1 files changed, 13 insertions, 2 deletions
diff --git a/sbin/isakmpd/ui.c b/sbin/isakmpd/ui.c
index 08b9cbfb24d..4578493754e 100644
--- a/sbin/isakmpd/ui.c
+++ b/sbin/isakmpd/ui.c
@@ -1,5 +1,5 @@
-/* $OpenBSD: ui.c,v 1.10 1999/08/05 22:41:08 niklas Exp $ */
-/* $EOM: ui.c,v 1.34 1999/08/05 14:58:00 niklas Exp $ */
+/* $OpenBSD: ui.c,v 1.11 1999/08/26 22:29:57 niklas Exp $ */
+/* $EOM: ui.c,v 1.36 1999/08/20 12:54:51 ho Exp $ */
/*
* Copyright (c) 1998, 1999 Niklas Hallqvist. All rights reserved.
@@ -40,6 +40,7 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <errno.h>
#include "sysdep.h"
@@ -64,11 +65,21 @@ int ui_socket;
void
ui_init ()
{
+ struct stat st;
+
/* -f- means control messages comes in via stdin. */
if (strcmp (ui_fifo, "-") == 0)
ui_socket = 0;
else
{
+ /* Don't overwrite a file, i.e '-f /etc/isakmpd/isakmpd.conf'. */
+ if (lstat (ui_fifo, &st) == 0)
+ if ((st.st_mode & S_IFMT) == S_IFREG)
+ {
+ errno = EEXIST;
+ log_fatal ("could not create FIFO \"%s\"", ui_fifo);
+ }
+
/* No need to know about errors. */
unlink (ui_fifo);
if (mkfifo (ui_fifo, 0600) == -1)