aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorRob Landley <rob@landley.net>2019-03-09 00:14:13 -0600
committerRob Landley <rob@landley.net>2019-03-09 00:14:13 -0600
commitcd358823399a700e476f4ddc1192f2fea7c09235 (patch)
tree9d7abe2c4315890c79949da9f71d39e9f3b213b4 /lib
parente191597e6bbf03e920e1b42f44ac65faaddedf51 (diff)
downloadtoybox-cd358823399a700e476f4ddc1192f2fea7c09235.tar.gz
Half-finished su change checked in, sorry.
Diffstat (limited to 'lib')
-rw-r--r--lib/lib.c15
-rw-r--r--lib/lib.h1
2 files changed, 16 insertions, 0 deletions
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();
+}
diff --git a/lib/lib.h b/lib/lib.h
index 87f4150e..9de18413 100644
--- a/lib/lib.h
+++ b/lib/lib.h
@@ -260,6 +260,7 @@ long environ_bytes();
long long millitime(void);
char *format_iso_time(char *buf, size_t len, struct timespec *ts);
void reset_env(struct passwd *p, int clear);
+void loggit(int priority, char *format, ...);
#define HR_SPACE 1 // Space between number and units
#define HR_B 2 // Use "B" for single byte units