Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F97319884
D23744.id68508.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
D23744.id68508.diff
View Options
Index: usr.bin/logger/logger.c
===================================================================
--- usr.bin/logger/logger.c
+++ usr.bin/logger/logger.c
@@ -44,6 +44,7 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
+#include <sys/capsicum.h>
#include <sys/param.h>
#include <sys/socket.h>
#include <netinet/in.h>
@@ -57,6 +58,9 @@
#include <time.h>
#include <unistd.h>
+#include <libcasper.h>
+#include <casper/cap_syslog.h>
+
#define SYSLOG_NAMES
#include <syslog.h>
@@ -76,6 +80,7 @@
struct socks *, ssize_t, const char *);
static void usage(void);
+static cap_channel_t *capcas, *capsyslog;
#ifdef INET6
static int family = PF_UNSPEC; /* protocol family (IPv4, IPv6 or both) */
#else
@@ -97,7 +102,7 @@
time_t now;
int ch, logflags, pri;
char *tag, *host, buf[1024], *timestamp, tbuf[26],
- *hostname, hbuf[MAXHOSTNAMELEN];
+ *hostname, hbuf[MAXHOSTNAMELEN], *pristr;
const char *svcname, *src;
tag = NULL;
@@ -107,6 +112,7 @@
src = NULL;
socks = NULL;
pri = LOG_USER | LOG_NOTICE;
+ pristr = NULL;
logflags = 0;
unsetenv("TZ");
while ((ch = getopt(argc, argv, "46Af:H:h:iP:p:S:st:")) != -1)
@@ -140,7 +146,7 @@
svcname = optarg;
break;
case 'p': /* priority */
- pri = pencode(optarg);
+ pristr = optarg;
break;
case 's': /* log to standard error */
logflags |= LOG_PERROR;
@@ -168,12 +174,23 @@
nsock = 0;
}
+ capcas = cap_init();
+ if (capcas == NULL)
+ err(1, "Unable to contact Casper");
+ if (cap_enter() < 0)
+ err(1, "Unable to enter capability mode");
+ capsyslog = cap_service_open(capcas, "system.syslog");
+ if (capsyslog == NULL)
+ err(1, "Unable to open system.syslog service");
+ cap_close(capcas);
+
+ if (pristr != NULL)
+ pri = pencode(pristr);
if (tag == NULL)
tag = getlogin();
/* setup for logging */
if (host == NULL)
- openlog(tag, logflags, 0);
- (void) fclose(stdout);
+ cap_openlog(capsyslog, tag, logflags, 0);
(void )time(&now);
(void )ctime_r(&now, tbuf);
@@ -349,7 +366,7 @@
int len, i, lsent;
if (nsock == 0) {
- syslog(pri, "%s", buf);
+ cap_syslog(capsyslog, pri, "%s", buf);
return;
}
if ((len = asprintf(&line, "<%d>%s %s %s: %s", pri, timestamp,
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Sep 29, 3:41 PM (7 h, 16 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
13138660
Default Alt Text
D23744.id68508.diff (2 KB)
Attached To
Mode
D23744: Added casper service to logger
Attached
Detach File
Event Timeline
Log In to Comment