From cd358823399a700e476f4ddc1192f2fea7c09235 Mon Sep 17 00:00:00 2001 From: Rob Landley Date: Sat, 9 Mar 2019 00:14:13 -0600 Subject: Half-finished su change checked in, sorry. --- lib/lib.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'lib/lib.c') diff --git a/lib/lib.c b/lib/lib.c index d1210f49..8937c57a 100644 --- a/lib/lib.c +++ b/lib/lib.c @@ -1462,3 +1462,18 @@ void reset_env(struct passwd *p, int clear) setenv("USER", p->pw_name, 1); setenv("LOGNAME", p->pw_name, 1); } + +// Syslog with the openlog/closelog, autodetecting daemon status via no tty + +void loggit(int priority, char *format, ...) +{ + int i, facility = LOG_DAEMON; + va_list va; + + for (i = 0; i<3; i++) facility = LOG_AUTH; + openlog(toys.which->name, LOG_PID, facility); + va_start(va, format); + vsyslog(priority, format, va); + va_end(va); + closelog(); +} -- cgit v1.2.3