diff options
author | Yves-Alexis Perez <corsac@corsac.net> | 2017-11-21 10:22:31 +0100 |
---|---|---|
committer | Yves-Alexis Perez <corsac@corsac.net> | 2017-11-21 10:22:31 +0100 |
commit | 6eb3bec5bee061bbb6a5c10f01d9737fb4597265 (patch) | |
tree | c1d58904577a286f7788ab5d2a4f116b07163698 /src/charon | |
parent | 745cb3e75fbcd8bc70e8b5f55a91ae2c8a274688 (diff) | |
parent | e1d78dc2faaa06e7c3f71ef674a71e4de2f0758e (diff) | |
download | vyos-strongswan-6eb3bec5bee061bbb6a5c10f01d9737fb4597265.tar.gz vyos-strongswan-6eb3bec5bee061bbb6a5c10f01d9737fb4597265.zip |
Update upstream source from tag 'upstream/5.6.1'
Update to upstream version '5.6.1'
with Debian dir 3996fc7d7b19a96b252a7fcbac12c94452d1e7d7
Diffstat (limited to 'src/charon')
-rw-r--r-- | src/charon/Makefile.in | 2 | ||||
-rw-r--r-- | src/charon/charon.c | 30 |
2 files changed, 22 insertions, 10 deletions
diff --git a/src/charon/Makefile.in b/src/charon/Makefile.in index 9c5283cd7..14bde277c 100644 --- a/src/charon/Makefile.in +++ b/src/charon/Makefile.in @@ -217,9 +217,11 @@ ECHO_T = @ECHO_T@ EGREP = @EGREP@ EXEEXT = @EXEEXT@ FGREP = @FGREP@ +FUZZING_LDFLAGS = @FUZZING_LDFLAGS@ GEM = @GEM@ GENHTML = @GENHTML@ GPERF = @GPERF@ +GPERF_LEN_TYPE = @GPERF_LEN_TYPE@ GPRBUILD = @GPRBUILD@ GREP = @GREP@ INSTALL = @INSTALL@ diff --git a/src/charon/charon.c b/src/charon/charon.c index 520cb3c74..f23717034 100644 --- a/src/charon/charon.c +++ b/src/charon/charon.c @@ -1,9 +1,9 @@ /* - * Copyright (C) 2006-2012 Tobias Brunner + * Copyright (C) 2006-2017 Tobias Brunner * Copyright (C) 2005-2009 Martin Willi * Copyright (C) 2006 Daniel Roethlisberger * Copyright (C) 2005 Jan Hutter - * Hochschule fuer Technik Rapperswil + * HSR Hochschule fuer Technik Rapperswil * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the @@ -203,8 +203,10 @@ static bool check_pidfile() pid = atoi(buf); } fclose(pidfile); + pidfile = NULL; if (pid && kill(pid, 0) == 0) - { /* such a process is running */ + { + DBG1(DBG_DMN, "charon already running ('"PID_FILE"' exists)"); return TRUE; } } @@ -219,18 +221,28 @@ static bool check_pidfile() int fd; fd = fileno(pidfile); - if (fd == -1 || fcntl(fd, F_SETFD, FD_CLOEXEC) == -1) + if (fd == -1) + { + DBG1(DBG_DMN, "unable to determine fd for '"PID_FILE"'"); + return TRUE; + } + if (fcntl(fd, F_SETFD, FD_CLOEXEC) == -1) { DBG1(DBG_LIB, "setting FD_CLOEXEC for '"PID_FILE"' failed: %s", strerror(errno)); } - ignore_result(fchown(fileno(pidfile), + ignore_result(fchown(fd, lib->caps->get_uid(lib->caps), lib->caps->get_gid(lib->caps))); fprintf(pidfile, "%d\n", getpid()); fflush(pidfile); + return FALSE; + } + else + { + DBG1(DBG_DMN, "unable to create pidfile '"PID_FILE"'"); + return TRUE; } - return FALSE; } /** @@ -246,8 +258,8 @@ static void unlink_pidfile() { ignore_result(ftruncate(fileno(pidfile), 0)); fclose(pidfile); + unlink(PID_FILE); } - unlink(PID_FILE); } /** @@ -402,7 +414,6 @@ int main(int argc, char *argv[]) if (check_pidfile()) { - DBG1(DBG_DMN, "charon already running (\""PID_FILE"\" exists)"); goto deinit; } @@ -434,12 +445,11 @@ int main(int argc, char *argv[]) /* main thread goes to run loop */ run(); - /* normal termination, cleanup and exit */ - unlink_pidfile(); status = 0; deinit: libcharon_deinit(); + unlink_pidfile(); library_deinit(); return status; } |