aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBill Nottingham <notting@redhat.com>2000-08-11 15:53:47 +0000
committerBill Nottingham <notting@redhat.com>2000-08-11 15:53:47 +0000
commit8cd935021c5d6ef02cacd87f7b9fe60e08eea5ca (patch)
tree6291201bde6a6fb667c3a3728204187f4b4b9860
parent494b4a8e903e099150486c5ba9bd22f0968ec7db (diff)
downloadinitscripts-8cd935021c5d6ef02cacd87f7b9fe60e08eea5ca.tar
initscripts-8cd935021c5d6ef02cacd87f7b9fe60e08eea5ca.tar.gz
initscripts-8cd935021c5d6ef02cacd87f7b9fe60e08eea5ca.tar.bz2
initscripts-8cd935021c5d6ef02cacd87f7b9fe60e08eea5ca.tar.xz
initscripts-8cd935021c5d6ef02cacd87f7b9fe60e08eea5ca.zip
don't do silly access checks on the root partition; instead, just try connecting to the syslog socket if it's there...
-rw-r--r--src/initlog.c39
1 files changed, 38 insertions, 1 deletions
diff --git a/src/initlog.c b/src/initlog.c
index 03782c32..32863591 100644
--- a/src/initlog.c
+++ b/src/initlog.c
@@ -11,7 +11,9 @@
#define SYSLOG_NAMES
#include <syslog.h>
+#include <sys/socket.h>
#include <sys/stat.h>
+#include <sys/un.h>
#include <sys/wait.h>
#define _(String) gettext((String))
@@ -184,6 +186,40 @@ int startDaemon() {
}
}
+int trySocket() {
+ int s;
+ struct sockaddr_un addr;
+
+ s = socket(AF_LOCAL, SOCK_DGRAM, 0);
+ if (s<0)
+ return 1;
+
+ bzero(&addr,sizeof(addr));
+ addr.sun_family = AF_LOCAL;
+ strncpy(addr.sun_path,_PATH_LOG,sizeof(addr.sun_path)-1);
+
+ if (connect(s,(struct sockaddr *) &addr,sizeof(addr))<0) {
+ if (errno == EPROTOTYPE) {
+ DDEBUG("connect failed (EPROTOTYPE), trying stream\n");
+ close(s);
+ s = socket(AF_LOCAL, SOCK_STREAM, 0);
+ if (connect(s,(struct sockaddr *) &addr, sizeof(addr)) < 0) {
+ DDEBUG("connect failed: %s\n",strerror(errno));
+ close(s);
+ return 1;
+ }
+ close(s);
+ return 0;
+ }
+ close(s);
+ DDEBUG("connect failed: %s\n",strerror(errno));
+ return 1;
+ } else {
+ close(s);
+ return 0;
+ }
+}
+
int logLine(struct logInfo *logEnt) {
/* Logs a line... somewhere. */
int x;
@@ -192,7 +228,8 @@ int logLine(struct logInfo *logEnt) {
/* Don't log empty or null lines */
if (!logEnt->line || !strcmp(logEnt->line,"\n")) return 0;
- if ( ((stat(_PATH_LOG,&statbuf)==-1) ||(access("/",W_OK)==-1))
+
+ if ( ((stat(_PATH_LOG,&statbuf)==-1) || trySocket())
&& startDaemon()
) {
DDEBUG("starting daemon failed, pooling entry %d\n",logEntries);