This patch appends the environment to each syslog entry, replacing
any carrige returns or linebreaks with spaces.

It can be downloaded from:

  http://devsec.org/patch/snoopy/snoopy-1.3.ds2.patch

-Thor Kooda
 2006-12-05


diff -Naru snoopy-1.3.orig/debian/changelog snoopy-1.3/debian/changelog
--- snoopy-1.3.orig/debian/changelog	2006-12-05 16:38:37.000000000 -0600
+++ snoopy-1.3/debian/changelog	2006-12-05 16:59:43.000000000 -0600
@@ -1,3 +1,10 @@
+snoopy (1.3-12.ds2) unstable; urgency=low
+
+  * patched to also log environment:  http://devsec.org/patch/snoopy/snoopy-1.3.ds2.patch
+
+ -- Debian Packager <debian-package-snoopy@devsec.org>  Tue, 05 Dec 2006 16:59:32 -0600
+
+
 snoopy (1.3-12) unstable; urgency=low
 
   * New translation: sv (Swedish) by Daniel Nylander. Closes: #331592
diff -Naru snoopy-1.3.orig/snoopy.c snoopy-1.3/snoopy.c
--- snoopy-1.3.orig/snoopy.c	2000-12-21 01:02:43.000000000 -0600
+++ snoopy-1.3/snoopy.c	2006-12-05 16:58:52.000000000 -0600
@@ -37,6 +37,8 @@
 
 #define FN(ptr,type,name,args)  ptr = (type (*)args)dlsym (REAL_LIBC, name)
 
+extern char **environ;
+
 inline void log(const char *filename, char **argv) {
 	static char *logstring=NULL; 
 	static int argc, size=0;
@@ -80,11 +82,20 @@
 	#else
 	for(i=0; i<argc; i++)
 	    size += sizeof(char)*strlen(*(argv+i))+1;
+	size+=2; /* add "| " separator */
+	for(i=0; environ[i]; i++)
+	    size += sizeof(char)*strlen(*(environ+i))+1;
 	size++; /*make space for that \0*/
 	logstring = (char*)malloc(sizeof(char)*size);
 
 	for(i=0; i<argc; i++)
 	   spos += sprintf(logstring+spos, "%s ", *(argv+i));
+	spos += sprintf(logstring+spos, "| ");
+	for(i=0; environ[i]; i++)
+	   spos += sprintf(logstring+spos, "%s ", *(environ+i));
+	for(i=0; i<=size; i++)
+	   if(logstring[i] == '\n' || logstring[i] == '\r')
+	      logstring[i] = ' '; /* replace linebreaks */
 	#endif
 
 	#if INTEGRITY_CHECK
diff -Naru snoopy-1.3.orig/snoopy.h snoopy-1.3/snoopy.h
--- snoopy-1.3.orig/snoopy.h	2000-12-21 00:53:16.000000000 -0600
+++ snoopy-1.3/snoopy.h	2006-12-05 16:20:44.000000000 -0600
@@ -13,7 +13,7 @@
  * maximum size of any argument.  if set to 0, snoopy will ensure that all
  * arguments get logged to its full lenght; this is also a slower process
  */
-#define MAX 32
+#define MAX 0
 
 /* INTEGRITY_CHECK
  * adds an integrity check to snoopy, should be unnecessary, but is here as an
