aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorBill Nottingham <notting@redhat.com>2004-11-16 06:19:13 +0000
committerBill Nottingham <notting@redhat.com>2004-11-16 06:19:13 +0000
commitddef4757714ccc9d566b0fba4494528c32bcaa9d (patch)
tree5b290e86c415cd0d5d6731a77626e7b940eb8d9c /src
parent7a97a0567f5a3d489e9383a99ee2416f400acaa1 (diff)
downloadinitscripts-ddef4757714ccc9d566b0fba4494528c32bcaa9d.tar
initscripts-ddef4757714ccc9d566b0fba4494528c32bcaa9d.tar.gz
initscripts-ddef4757714ccc9d566b0fba4494528c32bcaa9d.tar.bz2
initscripts-ddef4757714ccc9d566b0fba4494528c32bcaa9d.tar.xz
initscripts-ddef4757714ccc9d566b0fba4494528c32bcaa9d.zip
fix various minilogd bogosities (uninitialized variable, handling of wrong-protocol connections, don't check atime) (#106338)
Diffstat (limited to 'src')
-rw-r--r--src/initlog.c2
-rw-r--r--src/minilogd.c10
2 files changed, 8 insertions, 4 deletions
diff --git a/src/initlog.c b/src/initlog.c
index 13a376ec..3b1cded6 100644
--- a/src/initlog.c
+++ b/src/initlog.c
@@ -213,7 +213,7 @@ int trySocket() {
strncpy(addr.sun_path,_PATH_LOG,sizeof(addr.sun_path)-1);
if (connect(s,(struct sockaddr *) &addr,sizeof(addr))<0) {
- if (errno == EPROTOTYPE) {
+ if (errno == EPROTOTYPE || errno == ECONNREFUSED) {
DDEBUG("connect failed (EPROTOTYPE), trying stream\n");
close(s);
s = socket(AF_LOCAL, SOCK_STREAM, 0);
diff --git a/src/minilogd.c b/src/minilogd.c
index b7cbc8c0..85430978 100644
--- a/src/minilogd.c
+++ b/src/minilogd.c
@@ -77,7 +77,8 @@ void cleanup(int exitcode) {
void runDaemon(int sock) {
struct sockaddr_un addr;
- int x,len,addrlen,done=0;
+ int x,len,done=0;
+ int addrlen = sizeof(struct sockaddr_un);
char *message;
struct stat s1,s2;
struct pollfd pfds;
@@ -109,10 +110,13 @@ void runDaemon(int sock) {
}
if ( (x>0) && pfds.revents & (POLLIN | POLLPRI)) {
message = calloc(8192,sizeof(char));
+ addrlen = sizeof(struct sockaddr_un);
recvsock = accept(sock,(struct sockaddr *) &addr, &addrlen);
+ if (recvsock == -1)
+ continue;
alarm(2);
signal(SIGALRM, alarm_handler);
- len = read(recvsock,message,8192);
+ len = recv(recvsock,message,8192,0);
alarm(0);
close(recvsock);
if (len>0) {
@@ -135,7 +139,7 @@ void runDaemon(int sock) {
/* Check to see if syslogd's yanked our socket out from under us */
if ( (stat(_PATH_LOG,&s2)!=0) ||
(s1.st_ino != s2.st_ino ) || (s1.st_ctime != s2.st_ctime) ||
- (s1.st_mtime != s2.st_mtime) || (s1.st_atime != s2.st_atime) ) {
+ (s1.st_mtime != s2.st_mtime) ) {
done = 1;
we_own_log = 0;
}