[arch-projects] [PATCH 7/7] minilogd: kill
Tom Gundersen
teg at jklm.no
Wed Oct 26 19:38:33 EDT 2011
This is not very useful, is not maintained, has open serious bugs. Better
to admit that it does not work and just remove it. Someone could easily
make an AUR package with a hook, if they want it and can make it work
as expected.
The only case where this would be useful is in case lvm monitoring is in use
and dmeventd sends out a message to syslog before syslog-ng is started
(there is a very small window). However, not even this works atm (as far
as I know) due to bugs in minilogd.
Signed-off-by: Tom Gundersen <teg at jklm.no>
---
Makefile | 10 +--
PKGBUILD | 2 +-
minilogd.c | 202 ------------------------------------------------------------
rc.sysinit | 3 +-
4 files changed, 6 insertions(+), 211 deletions(-)
delete mode 100644 minilogd.c
diff --git a/Makefile b/Makefile
index c7eaa5f..7da89e3 100644
--- a/Makefile
+++ b/Makefile
@@ -15,21 +15,19 @@ DIRS := \
/usr/share/zsh/site-functions \
/usr/share/man/man8
-all: minilogd doc
-
-minilogd: minilogd.o
+all: doc
installdirs:
install -dm755 $(foreach DIR, $(DIRS), $(DESTDIR)$(DIR))
-install: minilogd installdirs doc
+install: installdirs doc
install -m644 -t $(DESTDIR)/etc inittab rc.conf
install -m755 -t $(DESTDIR)/etc rc.local rc.local.shutdown rc.multi rc.shutdown rc.single rc.sysinit
install -m644 -t $(DESTDIR)/etc/logrotate.d bootlog
install -m644 -t $(DESTDIR)/etc/rc.d functions
install -m755 -t $(DESTDIR)/etc/rc.d hwclock network netfs
install -m755 -t $(DESTDIR)/etc/profile.d locale.sh
- install -m755 -t $(DESTDIR)/usr/sbin minilogd rc.d
+ install -m755 -t $(DESTDIR)/usr/sbin rc.d
install -m644 -t ${DESTDIR}/usr/share/man/man8 rc.d.8
install -m755 -t $(DESTDIR)/usr/lib/initscripts arch-tmpfiles arch-sysctl
install -m644 tmpfiles.conf $(DESTDIR)/usr/lib/tmpfiles.d/arch.conf
@@ -42,7 +40,7 @@ rc.d.8: rc.d.8.txt
doc: rc.d.8
clean:
- rm -f minilogd minilogd.o rc.d.8
+ rm -f rc.d.8
release:
git archive HEAD --prefix=initscripts-$(VER)/ | xz > initscripts-$(VER).tar.xz
diff --git a/PKGBUILD b/PKGBUILD
index 0c5b71d..deddbd5 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -2,7 +2,7 @@ pkgname=initscripts-git
pkgver=$(date +%s)
pkgrel=$(git log -1 --pretty=format:%h)
pkgdesc="System initialization/bootup scripts"
-arch=('i686' 'x86_64')
+arch=('any')
url="http://www.archlinux.org"
license=('GPL')
groups=('base')
diff --git a/minilogd.c b/minilogd.c
deleted file mode 100644
index c86ab23..0000000
--- a/minilogd.c
+++ /dev/null
@@ -1,202 +0,0 @@
-/* minilogd.c
- *
- * A pale imitation of syslogd. Most notably, doesn't write anything
- * anywhere except possibly back to syslogd.
- *
- */
-
-#include <errno.h>
-#include <fcntl.h>
-#include <signal.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <strings.h>
-#include <stdarg.h>
-#include <syslog.h>
-#ifndef __USE_BSD
-# define __USE_BSD
-#endif
-#include <unistd.h>
-
-#include <sys/poll.h>
-#include <sys/socket.h>
-#include <sys/stat.h>
-#include <sys/un.h>
-
-#define MAX_BUF_LINES 10000
-#define BUF_LINE_SIZE 8192
-
-static int we_own_log=0;
-static char **buffer=NULL;
-static int buflines=0;
-
-int debug;
-
-int recvsock;
-
-void alarm_handler(int x) {
- alarm(0);
- close(recvsock);
- recvsock = -1;
-}
-
-void freeBuffer() {
- struct sockaddr_un addr;
- int sock;
- int x=0,conn;
-
- memset(&addr, 0, sizeof(addr));
- addr.sun_family = AF_LOCAL;
- strncpy(addr.sun_path,_PATH_LOG,sizeof(addr.sun_path)-1);
- /* wait for klogd to hit syslog */
- sleep(2);
- sock = socket(AF_LOCAL, SOCK_STREAM,0);
- conn=connect(sock,(struct sockaddr *) &addr,(socklen_t)sizeof(addr));
- while (x<buflines) {
- if (!conn) {
- /*printf("to syslog: %s\n", buffer[x]);*/
- write(sock,buffer[x],strlen(buffer[x])+1);
- }
- free(buffer[x]);
- x++;
- }
- free(buffer);
-}
-
-void cleanup(int exitcode) {
- /* If we own the log, unlink it before trying to free our buffer.
- * Otherwise, sending the buffer to /dev/log doesn't make much sense.... */
- if (we_own_log) {
- perror("wol");
- unlink(_PATH_LOG);
- }
- /* Don't try to free buffer if we were called from a signal handler */
- if (exitcode<=0) {
- if (buffer)
- freeBuffer();
- exit(exitcode);
- } else
- exit(exitcode+128);
-}
-
-void runDaemon(int sock) {
- struct sockaddr_un addr;
- int x,done=0;
- ssize_t len;
- socklen_t addrlen = (socklen_t)sizeof(struct sockaddr_un);
- char *message = NULL;
- struct stat s1,s2;
- struct pollfd pfds;
-
- daemon(0,-1);
- /* try not to leave stale sockets lying around */
- /* Hopefully, we won't actually get any of these */
- signal(SIGHUP,cleanup);
- signal(SIGINT,cleanup);
- signal(SIGQUIT,cleanup);
- signal(SIGILL,cleanup);
- signal(SIGABRT,cleanup);
- signal(SIGFPE,cleanup);
- signal(SIGSEGV,cleanup);
- signal(SIGPIPE,cleanup);
- signal(SIGBUS,cleanup);
- signal(SIGTERM,cleanup);
- done = 0;
- /* Get stat info on /dev/log so we can later check to make sure we
- * still own it... */
- if (stat(_PATH_LOG,&s1) != 0)
- memset(&s1, 0, sizeof(struct stat));
- while (!done) {
- pfds.fd = sock;
- pfds.events = POLLIN|POLLPRI;
- pfds.revents = 0;
- if ( ( (x=poll(&pfds,1,500))==-1) && errno !=EINTR) {
- perror("poll");
- cleanup(-1);
- }
- if ( (x>0) && (pfds.revents & (POLLIN | POLLPRI))) {
- if (message == NULL) {
- message = calloc(BUF_LINE_SIZE,sizeof(char));
- }
- recvsock = accept(sock,(struct sockaddr *) &addr, &addrlen);
- alarm(2);
- signal(SIGALRM, alarm_handler);
- len = read(recvsock,message,BUF_LINE_SIZE);
- alarm(0);
- close(recvsock);
- if (len>0) {
- /*printf("line recv'd: %s\n", message);*/
- if (buflines < MAX_BUF_LINES) {
- if (buffer)
- buffer = realloc(buffer,(buflines+1)*sizeof(char *));
- else
- buffer = malloc(sizeof(char *));
- message[strlen(message)]='\n';
- buffer[buflines]=message;
- message = NULL;
- buflines++;
- }
- }
- else {
- recvsock=-1;
- }
- }
- if ( (x>0) && ( pfds.revents & (POLLHUP | POLLNVAL)) )
- done = 1;
- /* 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) ) {*/
- done = 1;
- we_own_log = 0;
- /*printf("someone stole our %s\n", _PATH_LOG);
- printf("st_ino: %d %d\n", s1.st_ino, s2.st_ino);
- printf("st_ctime: %d %d\n", s1.st_ctime, s2.st_ctime);
- printf("st_atime: %d %d\n", s1.st_atime, s2.st_atime);
- printf("st_mtime: %d %d\n", s1.st_mtime, s2.st_mtime);*/
- }
- }
- free(message);
- cleanup(0);
-}
-
-int main(int argc, char **argv) {
- struct sockaddr_un addr;
- int sock;
- int pid;
-
- /* option processing made simple... */
- if (argc>1) debug=1;
- /* just in case */
- sock = open("/dev/null",O_RDWR);
- dup2(sock,0);
- dup2(sock,1);
- dup2(sock,2);
-
- memset(&addr, 0, sizeof(addr));
- addr.sun_family = AF_LOCAL;
- strncpy(addr.sun_path,_PATH_LOG,sizeof(addr.sun_path)-1);
- sock = socket(AF_LOCAL, SOCK_STREAM,0);
- unlink(_PATH_LOG);
- /* Bind socket before forking, so we know if the server started */
- if (!bind(sock,(struct sockaddr *) &addr, (socklen_t)sizeof(addr))) {
- we_own_log = 1;
- listen(sock,5);
- if ((pid=fork())==-1) {
- perror("fork");
- exit(3);
- }
- if (pid) {
- exit(0);
- } else {
- /*printf("starting daemon...\n");*/
- runDaemon(sock);
- /* shouldn't get back here... */
- exit(4);
- }
- } else {
- exit(5);
- }
-}
-/* vim: set ts=2 noet: */
diff --git a/rc.sysinit b/rc.sysinit
index f82368a..d802f3f 100755
--- a/rc.sysinit
+++ b/rc.sysinit
@@ -31,8 +31,7 @@ findmnt / --options ro &>/dev/null ||
run_hook sysinit_start
-# start up our mini logger until syslog takes over
-minilogd
+# log all console messages
bootlogd -p /run/bootlogd.pid
if [[ ! -a /usr/lib ]] ; then
--
1.7.7.1
More information about the arch-projects
mailing list