Merge upstream git://git.code.sf.net/p/modwaklog/code
authorClinton Ebadi <clinton@unknownlamer.org>
Wed, 5 Mar 2014 06:39:50 +0000 (01:39 -0500)
committerClinton Ebadi <clinton@unknownlamer.org>
Wed, 5 Mar 2014 06:39:50 +0000 (01:39 -0500)
1  2 
mod_waklog.c

diff --combined mod_waklog.c
@@@ -10,6 -10,8 +10,8 @@@
  
  #ifdef sun
  #include <synch.h>
+ #include <stropts.h>
+ #include <sys/ioccom.h>
  #elif linux
  #define use_pthreads
  #include <features.h>
@@@ -31,9 -33,6 +33,6 @@@
  /********************* APACHE1 ******************************************************************************/
  #ifndef APACHE2
  #include "ap_config.h"
- #if defined(sun)
- #include <sys/ioccom.h>
- #endif /* sun */
  #include <http_conf_globals.h>
  #define MK_POOL pool
  #define MK_TABLE_GET ap_table_get
@@@ -46,6 -45,7 +45,7 @@@ module waklog_module
  
  /********************* APACHE2 ******************************************************************************/
  #else
+ #include "http_connection.h"
  #include <apr_strings.h>
  #include <apr_base64.h>
  #define ap_pcalloc apr_pcalloc
@@@ -71,7 -71,7 +71,7 @@@ const char *userdata_key = "waklog_init
  /**************************************************************************************************/
  
  #include <krb5.h>
- #include <stropts.h>
+ #include <kopenafs.h>
  
  #include <afs/param.h>
  
@@@ -164,18 -164,6 +164,6 @@@ int renewcount = 0
  
  #define getModConfig(P, X) P = (waklog_config *) ap_get_module_config( (X)->module_config, &waklog_module );
  
- #include <krb5.h>
- #if defined(sun)
- #include <sys/ioccom.h>
- #endif /* sun */
- #include <stropts.h>
- #include <afs/venus.h>
- #include <afs/auth.h>
- #include <afs/dirpath.h>
- #include <afs/ptuser.h>
- #include <rx/rxkad.h>
  
  static void
  log_error (const char *file, int line, int level, int status,
@@@ -311,7 -299,7 +299,7 @@@ set_auth ( server_rec *s, request_rec *
  #ifdef APACHE2       
         if ( ! ( r && r->connection && r->user )) {
           log_error(APLOG_MARK, APLOG_ERR, 0, s, "mod_waklog: self authentication selected, but no data available");
-          log_error(APLOG_MARK, APLOG_ERR, 0, s, "mod_waklog: r->user=%s", (r->user==NULL ? "null" : r->user==NULL));
+          log_error(APLOG_MARK, APLOG_ERR, 0, s, "mod_waklog: r->user=%s", (r->user==NULL ? "null" : r->user));
           return -1;
         }
         
    }
  #endif
    
-   log_error(APLOG_MARK, APLOG_DEBUG, 0, s, "mod_waklog: set_auth: k5user=%s", k5user ? k5user : "NULL");
+   log_error(APLOG_MARK, APLOG_DEBUG, 0, s, "mod_waklog: set_auth: k5user=%s", k5user);
    mytime = time(0);
    
    /* see if we should just go ahead and ignore this call, since we already should be set to these
    }
  
    /* if 'usecached' isn't set, we've got to get our tokens from somewhere... */
-   if (( ! usecached ) && ( k5user )) {
+   if ( ! usecached ) {
  
      /* clear out the creds structure */
      memset((void *) &v5creds, 0, sizeof(v5creds));
        log_error(APLOG_MARK, APLOG_DEBUG, 0, s, "mod_waklog: retrieved data from ccache for %s", k5user);
        
        increds.times.endtime = 0;
 -      
 +
 +      /* Since we're fetching a key for AFS, we have to use single DES
 +       and explicitely enable weak crypto using the secret API
 +       call */
        increds.keyblock.enctype = ENCTYPE_DES_CBC_CRC;
 +      krb5_allow_weak_crypto (child.kcontext, 1);
        
        if ( ( kerror = krb5_get_credentials (child.kcontext, 0, clientccache, &increds, &v5credsp ) ) ) {
          /* only complain once we've tried both afs@REALM and afs/cell@REALM */
@@@ -1116,7 -1100,7 +1104,7 @@@ waklog_child_init (server_rec * s, MK_P
    }
    
    if ( pag_for_children ) {
-     setpag ();
+     k_setpag ();
    }
  
    getModConfig (cfg, s);
@@@ -1186,7 -1170,15 +1174,15 @@@ token_cleanup (void *data
    return 0;
  }
  
+ /* This function doesn't return anything but is passed to ap_bspawn_child on
+  * Apache 1 which expects it to return a pid as an int. For want of better
+  * understanding, err on the side of not changing Apache 1 code while fixing
+  * the compile warning on Apache 2. */
+ #ifdef APACHE2
+ static void
+ #else
  static int
+ #endif
  waklog_child_routine (void *data, child_info * pinfo)
  {
    int i;
@@@ -1327,7 -1319,10 +1323,10 @@@ waklog_init_handler (apr_pool_t * p, ap
            struct sharedspace_s bob;
            log_error(APLOG_MARK, APLOG_ERR, 0, s, "mod_waklog: sizing our cache file %d to %d", fd, sizeof(struct sharedspace_s) );
            memset( &bob, 0, sizeof(struct sharedspace_s));
-           write(fd, &bob, sizeof(struct sharedspace_s));
+           if ( write(fd, &bob, sizeof(struct sharedspace_s)) != sizeof(struct sharedspace_s) ) {
+             log_error(APLOG_MARK, APLOG_ERR, 0, s, "mod_waklog: failed to write to our cache file %s (%d)", cache_file, errno );
+             exit(errno);
+           }
            log_error(APLOG_MARK, APLOG_ERR, 0, s, "mod_waklog: done sizing our cache file to %d", sizeof(struct sharedspace_s) );
          }
  
  #define locktype rwlock_t
  #endif
  
-       if ( sharedlock = ( locktype * ) mmap ( NULL, sizeof(locktype), PROT_READ|PROT_WRITE, MAP_SHARED|MAP_ANON, -1, 0 ) ) {
+       if ( ( sharedlock = ( locktype * ) mmap ( NULL, sizeof(locktype), PROT_READ|PROT_WRITE, MAP_SHARED|MAP_ANON, -1, 0 ) ) != NULL ) {
  #ifndef use_pthreads
          rwlock_init(sharedlock, USYNC_PROCESS, NULL );
  #else