Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F151257926
D4270.id10494.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D4270.id10494.diff
View Options
Index: syslogd.c
===================================================================
--- syslogd.c
+++ syslogd.c
@@ -341,6 +341,7 @@
static int p_open(const char *, pid_t *);
static void readklog(void);
static void reapchild(int);
+static const char *ttymsg_check(struct iovec *, int, char *, int);
static void usage(void);
static int validate(struct sockaddr *, const char *);
static void unmapped(struct sockaddr *);
@@ -1425,7 +1426,7 @@
if (!f->f_un.f_uname[i][0])
break;
if (!strcmp(f->f_un.f_uname[i], ut->ut_user)) {
- if ((p = ttymsg(iov, iovlen, ut->ut_line,
+ if ((p = ttymsg_check(iov, iovlen, ut->ut_line,
TTYMSGTIME)) != NULL) {
errno = 0; /* already in msg */
logerror(p);
@@ -1438,6 +1439,29 @@
reenter = 0;
}
+/*
+ * Wrapper routine for ttymsg() that checks the terminal for messages enabled.
+ */
+static const char *
+ttymsg_check(struct iovec *iov, int iovcnt, char *line, int tmout)
+{
+ static char device[1024];
+ static char errbuf[1024];
+ struct stat sb;
+
+ (void) snprintf(device, sizeof(device), "%s%s", _PATH_DEV, line);
+
+ if (stat(device, &sb) < 0) {
+ (void) snprintf(errbuf, sizeof(errbuf),
+ "%s: %s", device, strerror(errno));
+ return (errbuf);
+ }
+ if ((sb.st_mode & S_IWGRP) == 0)
+ /* Messages disabled. */
+ return (NULL);
+ return ttymsg(iov, iovcnt, line, tmout);
+}
+
static void
reapchild(int signo __unused)
{
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Apr 8, 4:06 AM (2 h, 5 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
31074283
Default Alt Text
D4270.id10494.diff (1 KB)
Attached To
Mode
D4270: Have syslogd honor 'mesg' status when logging to users.
Attached
Detach File
Event Timeline
Log In to Comment