update for stretch
[hcoop/debian/libapache-mod-waklog.git] / mod_waklog.c
index 0a7b693..614cf33 100644 (file)
@@ -55,11 +55,6 @@ module waklog_module;
 #define MK_POOL apr_pool_t
 #define MK_TABLE_GET apr_table_get
 #define MK_TABLE_SET apr_table_set
-#include "unixd.h"
-extern unixd_config_rec unixd_config;
-#define ap_user_id        unixd_config.user_id
-#define ap_group_id       unixd_config.group_id
-#define ap_user_name      unixd_config.user_name
 #define command(name, func, var, type, usage)           \
   AP_INIT_ ## type (name, (void*) func,                 \
         NULL,     \
@@ -68,6 +63,11 @@ module AP_MODULE_DECLARE_DATA waklog_module;
 typedef struct { int dummy; } child_info;
 const char *userdata_key = "waklog_init"; 
 
+/* Apache 2.4 */
+#ifdef APLOG_USE_MODULE
+APLOG_USE_MODULE(waklog);
+#endif
+
 #endif /* APACHE2 */
 /**************************************************************************************************/
 
@@ -80,6 +80,7 @@ const char *userdata_key = "waklog_init";
 #include <afs/auth.h>
 #include <afs/dirpath.h>
 #include <afs/ptuser.h>
+#include <afs/com_err.h>
 #include <rx/rxkad.h>
 
 #define TKT_LIFE  ( 12 * 60 * 60 )
@@ -166,9 +167,15 @@ int renewcount = 0;
 #define getModConfig(P, X) P = (waklog_config *) ap_get_module_config( (X)->module_config, &waklog_module );
 
 
+#ifdef APLOG_USE_MODULE
+static void
+log_error (const char *file, int line, int module_index, int level, int status,
+           const server_rec * s, const char *fmt, ...)
+#else
 static void
 log_error (const char *file, int line, int level, int status,
            const server_rec * s, const char *fmt, ...)
+#endif
 {
   char errstr[4096];
   va_list ap;
@@ -178,7 +185,12 @@ log_error (const char *file, int line, int level, int status,
   va_end (ap);
 
 #ifdef APACHE2
+ #ifdef APLOG_USE_MODULE
+  /* Apache 2.4 */
+  ap_log_error (file, line, module_index, level | APLOG_NOERRNO, status, s, "%s", errstr);
+ #else
   ap_log_error (file, line, level | APLOG_NOERRNO, status, s, "(%d) %s", getpid(), errstr);
+ #endif
 #else
   ap_log_error (file, line, level | APLOG_NOERRNO, s, "(%d) %s", getpid(), errstr);
 #endif
@@ -454,11 +466,11 @@ set_auth ( server_rec *s, request_rec *r, int self, char *principal, char *keyta
                 log_error(APLOG_MARK, APLOG_ERR, 0, s, "mod_waklog: krb5_get_init_creds_password %s",
                   afs_error_message(kerror) );
                   /* nuke the password so it doesn't end up in core files */
-                  memset(k5secret, 0, sizeof(k5secret));               
+                  memset(k5secret, 0, strlen(k5secret));
                 goto cleanup;
         }
       
-        memset(k5secret, 0, sizeof(k5secret));      
+        memset(k5secret, 0, strlen(k5secret));
       }
 
       /* initialize the credentials cache and store the stuff we just got */
@@ -1259,7 +1271,6 @@ waklog_init_handler (apr_pool_t * p, apr_pool_t * plog,
                      apr_pool_t * ptemp, server_rec * s)
 {
   int rv;
-  extern char *version;
   apr_proc_t *proc;
   waklog_config *cfg;
   void *data;
@@ -1296,7 +1307,7 @@ waklog_init_handler (apr_pool_t * p, apr_pool_t * plog,
   else
     {
       log_error (APLOG_MARK, APLOG_INFO, 0, s,
-                 "mod_waklog: version %s initialized for cell %s", version, cfg->afs_cell);
+                 "mod_waklog: version %s initialized for cell %s", VERSION, cfg->afs_cell);
 
       if ( sharedspace ) {
         log_error(APLOG_MARK, APLOG_ERR, 0, s, "mod_waklog: shared memory already allocated." );
@@ -1407,7 +1418,6 @@ waklog_init_handler (apr_pool_t * p, apr_pool_t * plog,
 static void
 waklog_init (server_rec * s, MK_POOL * p)
 {
-  extern char *version;
   int pid;
   waklog_config *cfg;
   int fd = -1;
@@ -1419,7 +1429,7 @@ waklog_init (server_rec * s, MK_POOL * p)
 #endif
 
   log_error (APLOG_MARK, APLOG_DEBUG, 0, s,
-             "mod_waklog: version %s initialized.", version);
+             "mod_waklog: version %s initialized.", VERSION);
 
   if ( sharedspace ) {
     log_error(APLOG_MARK, APLOG_ERR, 0, s, "mod_waklog: shared memory already allocated." );