Package: socklog
Version: 2.0.2-2
Severity: wishlist
Tags: patch

  * Added option '-t' (time stamp); socklog.c modified.
  * killed some compilation warnings in socklog.c, chkshsgr.c, seek_set.c;
    some more left in pathexec_run.c, pathexec.h, prot.c.
  * debian/rules applies patches.
  * debian/rules builds with debug too.
  * debian/rules 'make check' commented out, as syslog checking now fails :(

Please take a look att the attached patches.


Cheers,
Cristian

-- System Information:
Debian Release: testing/unstable
  APT prefers unstable
  APT policy: (500, 'unstable'), (500, 'stable')
Architecture: i386 (i686)
Shell:  /bin/sh linked to /bin/bash
Kernel: Linux 2.4.27
Locale: LANG=C, LC_CTYPE= (charmap=ANSI_X3.4-1968)

Versions of packages socklog depends on:
ii  adduser                       3.77       Add and remove users and groups
ii  libc6                         2.3.5-7    GNU C Library: Shared libraries an

Versions of packages socklog recommends:
ii  ipsvd                         0.11.1-1   Internet protocol service daemons
pn  runit                         <none>     (no description available)
pn  socklog-run                   <none>     (no description available)

-- no debconf information
--- admin/socklog/src/socklog.c.~1~     2005-04-10 09:24:19.000000000 +0200
+++ admin/socklog/src/socklog.c 2005-10-30 01:13:24.000000000 +0200
@@ -1,3 +1,4 @@
+#include <stdio.h>
 #include <sys/types.h>
 #include <netinet/in.h>
 #include <arpa/inet.h>
@@ -7,6 +8,8 @@
 #include <unistd.h>
 #include <string.h>
 #include <errno.h>
+#include <sys/time.h>
+#include <time.h>
 #include "byte.h"
 #include "buffer.h"
 #include "error.h"
@@ -36,9 +39,9 @@
 #define FATAL "socklog: fatal: "
 
 #ifdef SOLARIS
-#define USAGE " [-rRU] [unix|inet|ucspi|sun_stream] [args]"
+#define USAGE " [-rtRU] [unix|inet|ucspi|sun_stream] [args]"
 #else
-#define USAGE " [-rRU] [unix|inet|ucspi] [args]"
+#define USAGE " [-rtRU] [unix|inet|ucspi] [args]"
 #endif
 
 #define VERSION "$Id: socklog.c,v 1.18 2004/06/26 09:36:25 pape Exp $"
@@ -62,6 +65,7 @@
 char *uid, *gid;
 unsigned int lograw =0;
 unsigned int noumask =0;
+static unsigned int tdet = 0;
 
 int flag_exitasap = 0;
 void sig_term_catch(void) {
@@ -82,6 +86,30 @@
   if (s3) buffer_puts(buffer_2, s3);
 }
 
+void timestamp(void) {
+  if (tdet > 0) {
+    struct timeval tv;
+    char tbuf[24];
+
+    gettimeofday(&tv, NULL);
+    if (strftime(tbuf,
+                sizeof(tbuf),
+                "%b %d %H:%M:%S",
+                localtime((const time_t *)&tv.tv_sec)) <= 0) {
+      snprintf(tbuf, sizeof(tbuf), "%u", (int)tv.tv_sec);
+    }
+    err(tbuf, 0, 0);
+
+    if (tdet > 1)
+      snprintf(tbuf, sizeof(tbuf), ".%6u", (unsigned int)tv.tv_usec);
+    else
+      tbuf[0] = 0;
+    err(tbuf, 0, 0);
+
+    buffer_putsflush(buffer_2, " ");
+  }
+}
+
 void setuidgid() {
   /* drop permissions */
   if ((gid = env_get("GID")) != NULL) {
@@ -106,6 +134,7 @@
   int fp =LOG_FAC(fpr) <<3;
   CODE *p;
   int rc =1;
+
   for (p =facilitynames; p->c_name; p++) {
     if (p->c_val == fp) {
       buffer_puts(buf, p->c_name);
@@ -163,7 +192,7 @@
 int socket_unix (const char* f) {
   int s;
   struct sockaddr_un sa;
-  
+
   if ((s =socket(AF_UNIX, SOCK_DGRAM, 0)) == -1)
     strerr_die2sys(111, FATAL, "socket(): ");
   byte_zero(&sa, sizeof(sa));
@@ -182,7 +211,7 @@
   int s;
   unsigned long p;
   struct sockaddr_in sa;
-  
+
   byte_zero(&sa, sizeof(sa));
   if (ip[0] == '0') {
     sa.sin_addr.s_addr =INADDR_ANY;
@@ -220,10 +249,10 @@
 
   for(;;) {
     struct sockaddr_in saf;
-    int dummy =sizeof saf;
+    socklen_t dummy =sizeof saf;
     int linec;
     int os;
-    
+
     linec =recvfrom(s, line, LINEC, 0, (struct sockaddr *) &saf, &dummy);
     if (linec == -1) {
       if (errno != error_intr)
@@ -233,6 +262,8 @@
     }
     if (flag_exitasap) break;
 
+    timestamp();
+
     while (linec && (line[linec -1] == 0)) linec--;
     if (linec == 0) continue;
 
@@ -265,17 +296,17 @@
   char *envs[9];
   int flageol =1;
   int i;
-  
+
   for (i =0; *vars && (i < 8); vars++) {
     if ((envs[i] =env_get(*vars)) != NULL)
       i++;
   }
   envs[i] =NULL;
-  
+
   for(;;) {
     int linec;
     char *l, *p;
-    
+
     linec =buffer_get(buffer_0, line, LINEC);
     if (linec == -1)
       strerr_die2sys(111, FATAL, "read(): ");
@@ -285,7 +316,7 @@
       buffer_flush(buffer_2);
       return(0);
     }
-    
+
     for (l =p =line; l -line < linec; l++) {
       if (flageol) {
        if (! *l || (*l == '\n')) continue;
@@ -331,7 +362,7 @@
     if (di.di_target != -1)
       strerr_die4x(100, FATAL, "door ", door, " allready in use.");
   }
-  
+
   close(dfd);
   fdetach(door); /* highjack the door file */
 
@@ -352,7 +383,7 @@
 
   if ((sfd = open(address, O_RDONLY | O_NOCTTY)) == -1)
     strerr_die2sys(111, FATAL, "open(): ");
-  
+
   memset(&sc, 0, sizeof(sc));
   sc.ic_cmd =I_CONSLOG;
   if (ioctl(sfd, I_STR, &sc) < 0)
@@ -366,19 +397,19 @@
   struct strbuf ctl, data;
   struct log_ctl logctl;
   int flags;
-  
+
   ctl.maxlen =ctl.len =sizeof(logctl);
   ctl.buf =(char *) &logctl;
   data.maxlen =LINEC;
   data.len =0;
   data.buf =line;
   flags =0;
-  
+
   sig_catch(sig_term, sig_term_catch);
   sig_catch(sig_int, sig_term_catch);
   setuidgid();
   buffer_putsflush(buffer_2, "starting.\n");
-  
+
   /* read the messages */
   for (;;) {
 
@@ -391,9 +422,9 @@
     if (data.len) {
       int shorten =data.len;
       if (!line[shorten-1])
-        shorten--;
+       shorten--;
       while (line[shorten-1] == '\n')
-        shorten--;
+       shorten--;
 
       (void) print_syslog_names(logctl.pri, buffer_1);
 
@@ -411,12 +442,13 @@
 int main(int argc, const char **argv, const char *const *envp) {
   int opt;
   int s =0;
-  
+
   progname =*argv;
 
-  while ((opt =getopt(argc, argv, "rRUV")) != opteof) {
+  while ((opt =getopt(argc, argv, "rtRUV")) != opteof) {
     switch(opt) {
     case 'r': lograw =1; break;
+    case 't': tdet +=1; break;
     case 'R': lograw =2; break;
     case 'U': noumask =1; break;
     case 'V':
--- admin/socklog/src/chkshsgr.c.~1~    2005-04-10 09:24:19.000000000 +0200
+++ admin/socklog/src/chkshsgr.c        2005-10-30 01:21:02.000000000 +0200
@@ -1,10 +1,12 @@
 /* Public domain. */
 
 #include <unistd.h>
+#include <sys/types.h>
+#include <grp.h>
 
 int main()
 {
-  short x[4];
+  gid_t x[4];
 
   x[0] = x[1] = 0;
   if (getgroups(1,x) == 0) if (setgroups(1,x) == -1) _exit(1);
--- admin/socklog/src/seek_set.c.~1~    2005-04-10 09:24:19.000000000 +0200
+++ admin/socklog/src/seek_set.c        2005-10-30 02:20:29.000000000 +0200
@@ -1,5 +1,6 @@
 /* Public domain. */
 
+#include <unistd.h>
 #include <sys/types.h>
 #include "seek.h"
 
--- debian/rules.~1~    2005-10-29 16:10:25.000000000 +0200
+++ debian/rules        2005-10-30 02:40:04.000000000 +0200
@@ -5,7 +5,14 @@
   STRIP =: nostrip
 endif
 
-CFLAGS =-g -O2 -Wall
+CFLAGS =-g -Wall
+ifneq (,$(findstring debug,$(DEB_BUILD_OPTIONS)))
+  CFLAGS +=-O0
+  STRIP =: nostrip
+else
+  CFLAGS +=-O2
+endif
+
 LDFLAGS =
 CC =gcc
 ifneq (,$(findstring diet,$(DEB_BUILD_OPTIONS)))
@@ -25,12 +32,21 @@
        rm -f admin/socklog && ln -s socklog-2.0.2 admin/socklog
        echo '$(CC) $(CFLAGS)' >admin/socklog/src/conf-cc
        echo '$(CC) $(LDFLAGS)' >admin/socklog/src/conf-ld
+
+       patch -p0 --verbose < socklog.c.patch
+       patch -p0 --verbose < chkshsgr.c.patch
+       patch -p0 --verbose < seek_set.c.patch
+
        $(MAKE) -Cadmin/socklog/src
-       $(MAKE) -Cadmin/socklog/src check
+       #$(MAKE) -Cadmin/socklog/src check
        touch build-arch-stamp
 
 build-indep: deb-checkdir build-indep-stamp
-build-indep-stamp: 
+build-indep-stamp:
        touch build-indep-stamp
 
 clean: deb-checkdir deb-checkuid
@@ -99,7 +115,7 @@
 binary-arch: deb-checkdir deb-checkuid install-arch socklog.deb
        test '$(CC)' != 'gcc' || \
          dpkg-shlibdeps '$(DIR)'/usr/bin/* '$(DIR)'/usr/sbin/*
-       dpkg-gencontrol -isp -psocklog -P'$(DIR)' 
+       dpkg-gencontrol -isp -psocklog -P'$(DIR)'
        dpkg -b '$(DIR)' ..
 
 binary-indep: deb-checkdir deb-checkuid install-indep socklog-run.deb

Reply via email to