[Pkg-privacy-commits] [onioncat] 92/340: log file and daemonize option improved
Ximin Luo
infinity0 at moszumanska.debian.org
Sat Aug 22 13:04:28 UTC 2015
This is an automated email from the git hooks/post-receive script.
infinity0 pushed a commit to branch debian
in repository onioncat.
commit 322e38c0bdf75d98740ce6799828981de45f7596
Author: eagle <eagle at 58e1ccc2-750e-0410-8d0d-f93ca75ab447>
Date: Wed Dec 10 10:43:47 2008 +0000
log file and daemonize option improved
git-svn-id: http://www.cypherpunk.at/svn/onioncat/trunk@383 58e1ccc2-750e-0410-8d0d-f93ca75ab447
---
ChangeLog | 2 ++
src/ocat.c | 20 +++++++++++++++++---
2 files changed, 19 insertions(+), 3 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index f43dbe4..10a6178 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,6 @@
* version
+ - connecting logfile to /dev/null if background option given
+ - staying in foreground if failed to open message logfile
- bugfixes
- IPv6 routes are aware of prefix lengths
- IPv6 routing table can be manipulated through controller or config file
diff --git a/src/ocat.c b/src/ocat.c
index 2bac31d..b936edf 100644
--- a/src/ocat.c
+++ b/src/ocat.c
@@ -76,7 +76,11 @@ void usage(const char *s)
}
-void open_logfile(void)
+/*! Open the message log. It's set by command line option -L.
+ * @return 0 if file was successfully opened, -1 if stderr is
+ * used instead.
+ */
+int open_logfile(void)
{
if (CNF(logfn))
{
@@ -86,11 +90,12 @@ void open_logfile(void)
if (setvbuf(CNF(logf), NULL, _IOLBF, 0))
log_msg(LOG_ERR, "could not setup line buffering: %s", strerror(errno));
fflush(CNF(logf));
- return;
+ return 0;
}
CNF(logf) = stderr;
log_msg(LOG_ERR, "could not open logfile %s: %s. Defaulting to stderr", CNF(logfn), strerror(errno));
}
+ return -1;
}
@@ -329,7 +334,16 @@ int main(int argc, char *argv[])
log_debug("uid/gid = %d/%d", getuid(), getgid());
// opening logfile
- open_logfile();
+ if (CNF(daemon) && !CNF(logfn))
+ {
+ log_debug("connecting logfile to /dev/null because of daemon option");
+ CNF(logfn) = "/dev/null";
+ }
+ if ((open_logfile() == -1) && CNF(daemon))
+ {
+ log_msg(LOG_NOTICE, "staying in foreground");
+ CNF(daemon) = 0;
+ }
if (CNF(create_clog))
open_connect_log(pwd->pw_dir);
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/onioncat.git
More information about the Pkg-privacy-commits
mailing list