#! /bin/sh /usr/share/dpatch/dpatch-run
## 11-fix_syslog_prefix.dpatch by Sven Mueller <debian@incase.de>
##
## All lines beginning with `## DP:' are a description of the patch.
## DP: Make sure all programs log (to syslog) with "cyrus/<program>" as the
## DP: log prefix.

@DPATCH@
--- a/imap/global.c
+++ b/imap/global.c
@@ -110,6 +110,9 @@ int session_id_count = 0;
 
 strarray_t *suppressed_capabilities = NULL;
 
+/* syslog prefix tag */
+static char syslog_prefix[20];
+
 /* Called before a cyrus application starts (but after command line parameters
  * are read) */
 int cyrus_init(const char *alt_config, const char *ident, unsigned flags)
@@ -137,7 +140,9 @@ int cyrus_init(const char *alt_config, c
     
     /* xxx we lose here since we can't have the prefix until we load the
      * config file */
-    openlog(config_ident, LOG_PID, SYSLOG_FACILITY);
+    strncpy(syslog_prefix, "cyrus/", sizeof(syslog_prefix));
+    strncat(syslog_prefix, ident, sizeof(syslog_prefix) - 7);
+    openlog(syslog_prefix, LOG_PID, SYSLOG_FACILITY);
 
     /* Load configuration file.  This will set config_dir when it finds it */
     config_read(alt_config);
--- a/ptclient/ptexpire.c
+++ b/ptclient/ptexpire.c
@@ -118,7 +118,7 @@ int main(int argc, char *argv[])
 	fatal("must run as the Cyrus user", EC_USAGE);
     }
     
-    openlog("ptexpire", LOG_PID, SYSLOG_FACILITY);
+    openlog("cyrus/ptexpire", LOG_PID, SYSLOG_FACILITY);
 
     while ((opt = getopt(argc, argv, "C:E:")) != EOF) {
 	switch (opt) {
--- a/ptclient/test.c
+++ b/ptclient/test.c
@@ -57,7 +57,7 @@ int main(int argc, char **argv) {
     cacheid=cache;
   } else
     cacheid=NULL;
-  openlog("pttest", LOG_PID, SYSLOG_FACILITY);  
+  openlog("cyrus/pttest", LOG_PID, SYSLOG_FACILITY);  
   
   if (!auth_setid(argv[1],cacheid))
     printf ("Auth_memberof(%s,%s) is %d\n", argv[1], argv[2],
--- a/ptclient/test2.c
+++ b/ptclient/test2.c
@@ -46,7 +46,7 @@
 
 int main(void) {
   char cacheid[16]="4224423";
-  openlog("testr", LOG_PID, SYSLOG_FACILITY);
+  openlog("cyrus/testr", LOG_PID, SYSLOG_FACILITY);
   
   if (!auth_setid("cg2v@club.cc.cmu.edu",cacheid))
     printf ("Auth_memberof(cg2v,cg2v:me) is %d\n",
