#define ap_user_name unixd_config.user_name
#define command(name, func, var, type, usage) \
AP_INIT_ ## type (name, (void*) func, \
- (void*)APR_OFFSETOF(waklog_config, var), \
+ (void*)APR_OFFSETOF(waklog_commands, var), \
OR_AUTHCFG | RSRC_CONF, usage)
typedef struct {
int dummy;
-} child_info;
+}
+child_info;
const char *userdata_key = "waklog_init";
#else
#include "ap_config.h"
+#define MK_POOL pool
+#define MK_TABLE_GET ap_table_get
+#define MK_TABLE_SET ap_table_set
+
+
+
+
+#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>
+
+#define TKT_LIFE ( 12 * 60 * 60 )
+#define SLEEP_TIME ( TKT_LIFE - 5*60 )
+
+#define WAKLOG_ON 1
+#define WAKLOG_OFF 2
+#define WAKLOG_UNSET 0
+
+#ifdef WAKLOG_DEBUG
+#undef APLOG_DEBUG
+#define APLOG_DEBUG APLOG_ERR
+#endif
+
+#ifndef CELL_IN_PRINCIPAL
+int cell_in_principal = 1;
+#else
+int cell_in_principal = 0;
+#endif
+
+/* this is used to turn off pag generation for the backround worker child during startup */
+int pag_for_children = 1;
+
+typedef struct
+{
+ int forked;
+ int configured;
+ int protect;
+ int usertokens;
+ char *keytab;
+ char *principal;
+ char *default_principal;
+ char *default_keytab;
+ char *afs_cell;
+ char *path;
+ MK_POOL *p;
+}
+waklog_config;
+
+typedef struct
+{
+ struct ktc_token token;
+ char clientprincipal[MAXNAMELEN];
+ krb5_context kcontext;
+ krb5_ccache ccache;
+ struct ktc_principal server;
+ struct ktc_principal client;
+ int pr_init;
+} waklog_child_config;
+
+waklog_child_config child;
+
+struct tokencache_ent {
+ char clientprincipal[MAXNAMELEN];
+ struct ktc_token token;
+ struct ktc_principal client;
+ struct ktc_principal server;
+ time_t lastused;
+ int persist;
+};
+
+#define SHARED_TABLE_SIZE 512
+
+struct sharedspace_s {
+ int renewcount;
+ struct tokencache_ent sharedtokens[SHARED_TABLE_SIZE];
+};
+
+struct sharedspace_s *sharedspace = NULL;
+
+struct renew_ent {
+ char *keytab;
+ char *principal;
+ int lastrenewed;
+};
+
+#ifdef use_pthreads
+pthread_rwlock_t *sharedlock = NULL;
+#else
+rwlock_t *sharedlock = NULL;
+#endif
+
+struct renew_ent renewtable[SHARED_TABLE_SIZE];
+
+int renewcount = 0;
+
module waklog_module;
#define MK_POOL pool
#define MK_TABLE_GET ap_table_get
#define command(name, func, var, type, usage) \
{ name, func, \
- (void*)XtOffsetOf(waklog_config, var), \
+ (void*)XtOffsetOf(waklog_commands, var), \
OR_AUTHCFG | RSRC_CONF, type, usage }
#endif /* STANDARD20_MODULE_STUFF */
-#define getModConfig(P, X) P = (waklog_host_config *) ap_get_module_config( (X)->module_config, &waklog_module );
+#define getModConfig(P, X) P = (waklog_config *) ap_get_module_config( (X)->module_config, &waklog_module );
#include <krb5.h>
#define PRINCIPAL "someplacewwwserver"
#define AFS_CELL "someplace.edu"
-#define TKT_LIFE 10*60*60
-#define SLEEP_TIME TKT_LIFE - 5*60
/* If there's an error, retry more aggressively */
#define ERR_SLEEP_TIME 5*60
#define K5PATH "FILE:/tmp/waklog.creds.k5"
-typedef struct
-{
- int forked;
- int configured;
- int protect;
- char *keytab;
- char *principal;
- char *afs_cell;
- MK_POOL *p;
-}
-waklog_host_config;
-
-typedef struct {
- struct ktc_token token;
-} waklog_child_config;
-waklog_child_config child;
-
static void
log_error(const char *file, int line, int level, int status,
const server_rec *s, const char *fmt, ...)
static void *
waklog_create_server_config( MK_POOL *p, server_rec *s )
{
- waklog_host_config *cfg;
+ waklog_config *cfg;
- cfg = (waklog_host_config *)ap_pcalloc( p, sizeof( waklog_host_config ));
+ cfg = (waklog_config *)ap_pcalloc( p, sizeof( waklog_config ));
cfg->p = p;
cfg->forked = 0;
cfg->configured = 0;
static const char *
set_waklog_protect( cmd_parms *params, void *mconfig, int flag )
{
- waklog_host_config *cfg;
+ waklog_config *cfg;
getModConfig(cfg, params->server );
static const char *
set_waklog_keytab( cmd_parms *params, void *mconfig, char *file )
{
- waklog_host_config *cfg;
+ waklog_config *cfg;
getModConfig(cfg, params->server );
static const char *
set_waklog_use_principal( cmd_parms *params, void *mconfig, char *file )
{
- waklog_host_config *cfg;
+ waklog_config *cfg;
getModConfig(cfg, params->server );
static const char *
set_waklog_use_afs_cell( cmd_parms *params, void *mconfig, char *file )
{
- waklog_host_config *cfg;
+ waklog_config *cfg;
getModConfig(cfg, params->server );
char *wak_keytab;
char *wak_ktprinc;
char *wak_afscell;
-} waklog_config;
+} waklog_commands;
command_rec waklog_cmds[ ] =
{
krb5_keytab keytab = NULL;
char ktbuf[ MAX_KEYTAB_NAME_LEN + 1 ];
int i;
- waklog_host_config *cfg;
+ waklog_config *cfg;
log_error( APLOG_MARK, APLOG_DEBUG, 0, s,
"mod_waklog: waklog_kinit called: pid: %d", getpid() );
struct ktc_principal server = { "afs", "", "" };
struct ktc_principal client;
struct ktc_token token;
- waklog_host_config *cfg;
+ waklog_config *cfg;
int buflen;
k5path = MK_TABLE_GET( r->subprocess_env, "KRB5CCNAME" );
int rv;
extern char *version;
apr_proc_t *proc;
- waklog_host_config *cfg;
+ waklog_config *cfg;
void *data;
getModConfig(cfg, s);
static int
waklog_phase0( request_rec *r )
{
- waklog_host_config *cfg;
+ waklog_config *cfg;
log_error( APLOG_MARK, APLOG_DEBUG, 0, r->server,
"mod_waklog: phase0 called" );
static int
waklog_phase7( request_rec *r )
{
- waklog_host_config *cfg;
+ waklog_config *cfg;
log_error( APLOG_MARK, APLOG_DEBUG, 0, r->server,
"mod_waklog: phase7 called" );
)
{
- waklog_config *cfg;
+ waklog_commands *cfg;
log_error (APLOG_MARK, APLOG_DEBUG, 0, c->base_server,
"mod_waklog: new_connection called: pid: %d", getpid ());