diff options
author | Niklas Hallqvist <niklas@cvs.openbsd.org> | 1999-08-26 22:29:58 +0000 |
---|---|---|
committer | Niklas Hallqvist <niklas@cvs.openbsd.org> | 1999-08-26 22:29:58 +0000 |
commit | bf8d1ed4926ea7bf4d3a5a78ea0f5b89d4e4ac8a (patch) | |
tree | d659a13988569f42873f0f4b088681a7c59c053f /sbin | |
parent | 38f382cc637a14bf7430291d69d442485bfefe81 (diff) |
Merge with EOM 1.36
author: ho
style
author: ho
Don't accidentally overwrite files with the FIFO.
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/isakmpd/ui.c | 15 |
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) |