* Re-Applied patch provided vom Topi Miettinen with regard to the people
from OpenBSD. This provides the additional '-a' argument used for specifying additional UNIX domain sockets to listen to. This is been used with chroot()'ed named's for example. An example is described at http://www.psionic.com/papers/dns.html. This time the patch doesn't stall syslogd. Thanks to Topi Miettinen <tom@medialab.sonera.net> (closes: Bug#24893)
This commit is contained in:
parent
3acc6c3a40
commit
2b70a699f1
32
sysklogd.8
32
sysklogd.8
@ -7,10 +7,9 @@
|
|||||||
sysklogd \- Linux system logging utilities.
|
sysklogd \- Linux system logging utilities.
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
.B syslogd
|
.B syslogd
|
||||||
.\" Bug#24893 --> uncomment the following
|
.RB [ " \-a "
|
||||||
.\" .RB [ " \-a "
|
.I socket
|
||||||
.\" .I socket
|
]
|
||||||
.\" ]
|
|
||||||
.RB [ " \-d " ]
|
.RB [ " \-d " ]
|
||||||
.RB [ " \-f "
|
.RB [ " \-f "
|
||||||
.I config file
|
.I config file
|
||||||
@ -74,19 +73,18 @@ the whole line is ignored.
|
|||||||
|
|
||||||
.LP
|
.LP
|
||||||
.SH OPTIONS
|
.SH OPTIONS
|
||||||
.\" Bug#24893 --> uncomment the following
|
.TP
|
||||||
.\" .TP
|
.BI "\-a " "socket"
|
||||||
.\" .BI "\-a " "socket"
|
Using this argument you can specify additional sockets from that
|
||||||
.\" Using this argument you can specify additional sockets from that
|
.B syslogd
|
||||||
.\" .B syslogd
|
has to listen to. This is needed if you're going to let some daemon
|
||||||
.\" has to listen to. This is needed if you're going to let some daemon
|
run within a chroot() environment. You can use up to 19 additional
|
||||||
.\" run within a chroot() environment. You can use up to 19 additional
|
sockets. If your environment needs even more, you have to increase
|
||||||
.\" sockets. If your environment needs even more, you have to increase
|
the symbol
|
||||||
.\" the symbol
|
.B MAXFUNIX
|
||||||
.\" .B MAXFUNIX
|
within the syslogd.c source file. An example for a chroot() daemon is
|
||||||
.\" within the syslogd.c source file. An example for a chroot() daemon is
|
described by the people from OpenBSD at
|
||||||
.\" described by the people from OpenBSD at
|
http://www.psionic.com/papers/dns.html.
|
||||||
.\" http://www.psionic.com/papers/dns.html.
|
|
||||||
.TP
|
.TP
|
||||||
.B "\-d"
|
.B "\-d"
|
||||||
Turns on debug mode. Using this the daemon will not proceed a
|
Turns on debug mode. Using this the daemon will not proceed a
|
||||||
|
64
syslogd.c
64
syslogd.c
@ -512,27 +512,22 @@ static char sccsid[] = "@(#)syslogd.c 5.27 (Berkeley) 10/10/88";
|
|||||||
#define _PATH_LOG "/dev/log"
|
#define _PATH_LOG "/dev/log"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Bug#24893: --> remove LogName */
|
|
||||||
char *LogName = _PATH_LOG;
|
|
||||||
char *ConfFile = _PATH_LOGCONF;
|
char *ConfFile = _PATH_LOGCONF;
|
||||||
char *PidFile = _PATH_LOGPID;
|
char *PidFile = _PATH_LOGPID;
|
||||||
char ctty[] = _PATH_CONSOLE;
|
char ctty[] = _PATH_CONSOLE;
|
||||||
|
|
||||||
char **parts;
|
char **parts;
|
||||||
|
|
||||||
/* Bug#24893 --> remove funix */
|
int inetm = 0;
|
||||||
int inetm = 0, funix = -1;
|
|
||||||
static int debugging_on = 0;
|
static int debugging_on = 0;
|
||||||
static int nlogs = -1;
|
static int nlogs = -1;
|
||||||
static int restart = 0;
|
static int restart = 0;
|
||||||
|
|
||||||
/* Bug#24893: --> insert
|
|
||||||
#define MAXFUNIX 20
|
#define MAXFUNIX 20
|
||||||
|
|
||||||
int nfunix = 1;
|
int nfunix = 1;
|
||||||
char *funixn[MAXFUNIX] = { _PATH_LOG };
|
char *funixn[MAXFUNIX] = { _PATH_LOG };
|
||||||
int funix[MAXFUNIX] = { -1, };
|
int funix[MAXFUNIX] = { -1, };
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef UT_NAMESIZE
|
#ifdef UT_NAMESIZE
|
||||||
# define UNAMESZ UT_NAMESIZE /* length of a login name */
|
# define UNAMESZ UT_NAMESIZE /* length of a login name */
|
||||||
@ -789,22 +784,18 @@ int main(argc, argv)
|
|||||||
#ifndef TESTING
|
#ifndef TESTING
|
||||||
chdir ("/");
|
chdir ("/");
|
||||||
#endif
|
#endif
|
||||||
/* Bug#24893 --> add
|
|
||||||
for (i = 1; i < nfunix; i++) {
|
for (i = 1; i < nfunix; i++) {
|
||||||
funixn[i] = "";
|
funixn[i] = "";
|
||||||
funix[i] = -1;
|
funix[i] = -1;
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
|
|
||||||
while ((ch = getopt(argc, argv, "a:dhf:l:m:np:rs:v")) != EOF)
|
while ((ch = getopt(argc, argv, "a:dhf:l:m:np:rs:v")) != EOF)
|
||||||
switch((char)ch) {
|
switch((char)ch) {
|
||||||
case 'a':
|
case 'a':
|
||||||
/* Bug#24893 --> add
|
|
||||||
if (nfunix < MAXFUNIX)
|
if (nfunix < MAXFUNIX)
|
||||||
funixn[nfunix++] = optarg;
|
funixn[nfunix++] = optarg;
|
||||||
else
|
else
|
||||||
fprintf(stderr, "Out of descriptors, ignoring %s\n", optarg);
|
fprintf(stderr, "Out of descriptors, ignoring %s\n", optarg);
|
||||||
*/
|
|
||||||
break;
|
break;
|
||||||
case 'd': /* debug */
|
case 'd': /* debug */
|
||||||
Debug = 1;
|
Debug = 1;
|
||||||
@ -830,10 +821,7 @@ int main(argc, argv)
|
|||||||
NoFork = 1;
|
NoFork = 1;
|
||||||
break;
|
break;
|
||||||
case 'p': /* path to regular log socket */
|
case 'p': /* path to regular log socket */
|
||||||
/* Bug#24893 --> exchange
|
|
||||||
funixn[0] = optarg;
|
funixn[0] = optarg;
|
||||||
*/
|
|
||||||
LogName = optarg;
|
|
||||||
break;
|
break;
|
||||||
case 'r': /* accept remote messages */
|
case 'r': /* accept remote messages */
|
||||||
AcceptRemote = 1;
|
AcceptRemote = 1;
|
||||||
@ -995,26 +983,29 @@ int main(argc, argv)
|
|||||||
|
|
||||||
/* Main loop begins here. */
|
/* Main loop begins here. */
|
||||||
FD_ZERO(&unixm);
|
FD_ZERO(&unixm);
|
||||||
FD_ZERO(&readfds);
|
|
||||||
for (;;) {
|
for (;;) {
|
||||||
int nfds;
|
int nfds;
|
||||||
errno = 0;
|
errno = 0;
|
||||||
#ifdef SYSLOG_UNIXAF
|
#ifdef SYSLOG_UNIXAF
|
||||||
|
FD_ZERO(&readfds);
|
||||||
#ifndef TESTING
|
#ifndef TESTING
|
||||||
/*
|
/*
|
||||||
* Add the Unix Domain Sockets to the list of read
|
* Add the Unix Domain Sockets to the list of read
|
||||||
* descriptors.
|
* descriptors.
|
||||||
*/
|
*/
|
||||||
if (funix >= 0) {
|
len = 0;
|
||||||
FD_SET(funix, &readfds);
|
/* Copy master connections */
|
||||||
for (nfds= 0; nfds < FD_SETSIZE; ++nfds)
|
|
||||||
if ( FD_ISSET(nfds, &unixm) )
|
|
||||||
FD_SET(nfds, &readfds);
|
|
||||||
/* Bug#24893 --> remove above if(), add the following
|
|
||||||
for (i = 0; i < nfunix; i++) {
|
for (i = 0; i < nfunix; i++) {
|
||||||
if (funix[i] != -1)
|
if (funix[i] != -1) {
|
||||||
FD_SET(funix[i], &readfds);
|
FD_SET(funix[i], &readfds);
|
||||||
*/
|
if (i>len) len=i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/* Copy accepted connections */
|
||||||
|
for (nfds= 0; nfds < FD_SETSIZE; ++nfds)
|
||||||
|
if (FD_ISSET(nfds, &unixm)) {
|
||||||
|
FD_SET(nfds, &readfds);
|
||||||
|
if (i>nfds) len=nfds;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
@ -1043,7 +1034,7 @@ int main(argc, argv)
|
|||||||
dprintf("%d ", nfds);
|
dprintf("%d ", nfds);
|
||||||
dprintf("\n");
|
dprintf("\n");
|
||||||
}
|
}
|
||||||
nfds = select(FD_SETSIZE, (fd_set *) &readfds, (fd_set *) NULL,
|
nfds = select(len, (fd_set *) &readfds, (fd_set *) NULL,
|
||||||
(fd_set *) NULL, (struct timeval *) NULL);
|
(fd_set *) NULL, (struct timeval *) NULL);
|
||||||
if ( restart )
|
if ( restart )
|
||||||
{
|
{
|
||||||
@ -1110,22 +1101,6 @@ int main(argc, argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* Accept a new unix connection */
|
/* Accept a new unix connection */
|
||||||
|
|
||||||
if (FD_ISSET(funix, &readfds)) {
|
|
||||||
len = sizeof(fromunix);
|
|
||||||
if ((fd = accept(funix, (struct sockaddr *) &fromunix,\
|
|
||||||
&len)) >= 0) {
|
|
||||||
FD_SET(fd, &unixm);
|
|
||||||
dprintf("New UNIX connect assigned to fd: " \
|
|
||||||
"%d.\n", fd);
|
|
||||||
FD_SET(fd, &readfds);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
dprintf("Error accepting UNIX connection: " \
|
|
||||||
"%d = %s.\n", errno, strerror(errno));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/* Bug#24893 --> remove above if(), add the following
|
|
||||||
for (i = 0; i < nfunix; i++)
|
for (i = 0; i < nfunix; i++)
|
||||||
if (funix[i] != -1 && FD_ISSET(funix[i], &readfds)) {
|
if (funix[i] != -1 && FD_ISSET(funix[i], &readfds)) {
|
||||||
len = sizeof(fromunix);
|
len = sizeof(fromunix);
|
||||||
@ -1140,7 +1115,6 @@ int main(argc, argv)
|
|||||||
"%d = %s.\n", errno, strerror(errno));
|
"%d = %s.\n", errno, strerror(errno));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef SYSLOG_INET
|
#ifdef SYSLOG_INET
|
||||||
@ -2159,22 +2133,16 @@ void die(sig)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Close the UNIX sockets. */
|
/* Close the UNIX sockets. */
|
||||||
close(funix);
|
|
||||||
/* Bug#24893 --> remove above close(), add the following
|
|
||||||
for (i = 0; i < nfunix; i++)
|
for (i = 0; i < nfunix; i++)
|
||||||
if (funix[i] != -1)
|
if (funix[i] != -1)
|
||||||
close(funix[i]);
|
close(funix[i]);
|
||||||
*/
|
|
||||||
/* Close the inet socket. */
|
/* Close the inet socket. */
|
||||||
if (InetInuse) close(inetm);
|
if (InetInuse) close(inetm);
|
||||||
|
|
||||||
/* Clean-up files. */
|
/* Clean-up files. */
|
||||||
(void) unlink(LogName);
|
|
||||||
/* Bug#24893 --> remove above unlink(), add the following
|
|
||||||
for (i = 0; i < nfunix; i++)
|
for (i = 0; i < nfunix; i++)
|
||||||
if (funixn[i] && funix[i] != -1)
|
if (funixn[i] && funix[i] != -1)
|
||||||
(void)unlink(funixn[i]);
|
(void)unlink(funixn[i]);
|
||||||
*/
|
|
||||||
#ifndef TESTING
|
#ifndef TESTING
|
||||||
(void) remove_pid(PidFile);
|
(void) remove_pid(PidFile);
|
||||||
#endif
|
#endif
|
||||||
@ -2344,13 +2312,9 @@ void init()
|
|||||||
(void) fclose(cf);
|
(void) fclose(cf);
|
||||||
|
|
||||||
#ifdef SYSLOG_UNIXAF
|
#ifdef SYSLOG_UNIXAF
|
||||||
if (funix < 0)
|
|
||||||
funix = create_unix_socket(LogName);
|
|
||||||
/* Bug#24893 --> remove above if(), add the following
|
|
||||||
for (i = 0; i < nfunix; i++)
|
for (i = 0; i < nfunix; i++)
|
||||||
if ((funix[i] = create_unix_socket(funixn[i])) != -1)
|
if ((funix[i] = create_unix_socket(funixn[i])) != -1)
|
||||||
dprintf("Opened UNIX socket `%s'.\n", funixn[i]);
|
dprintf("Opened UNIX socket `%s'.\n", funixn[i]);
|
||||||
*/
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef SYSLOG_INET
|
#ifdef SYSLOG_INET
|
||||||
|
Loading…
x
Reference in New Issue
Block a user