2 * Copyright 2000, International Business Machines Corporation and others.
5 * This software has been released under the terms of the IBM Public
6 * License. For details, see the LICENSE file in the top-level source
7 * directory or online at http://www.openafs.org/dl/license10.html
15 * Routines to log kaserver activity
19 #include <afsconfig.h>
20 #include <afs/param.h>
26 #include <afs/afsutil.h>
31 #include <sys/types.h>
35 #include <afs/afsutil.h>
39 extern afs_int32 verbose_track;
47 OpenLog(AFSDIR_SERVER_KALOGDB_FILEPATH); /* set up logging */
50 dbm_open(AFSDIR_SERVER_KALOG_FILEPATH, O_WRONLY | O_CREAT,
53 ViceLog(0, ("Cannot open dbm database - no DB logging possible\n"));
56 /* log a ticket usage */
57 kalog_log(principal, instance, sprincipal, sinstance, realm, hostaddr, type)
58 char *principal, *instance, *sprincipal, *sinstance, *realm;
61 char keybuf[512]; /* not random! 63 . 63 , 63 . 63 max key */
68 strcpy(keybuf, principal);
71 strcat(keybuf, realm);
75 strcat(keybuf, instance);
78 /* unlike the name/instance, the services can come down as NULL */
79 if (sprincipal && *sprincipal) {
81 strcat(keybuf, sprincipal);
82 if (sinstance && *sinstance) {
84 strcat(keybuf, sinstance);
89 strcat(keybuf, ":cruser");
92 strcat(keybuf, ":chp");
94 case LOG_AUTHENTICATE:
95 strcat(keybuf, ":auth");
98 strcat(keybuf, ":authnot");
101 strcat(keybuf, ":setf");
104 strcat(keybuf, ":delu");
107 strcat(keybuf, ":unlok");
110 strcat(keybuf, ":gtck");
117 key.dsize = strlen(keybuf) + 1; /* store the key in a string w/ null */
118 rdata.last_use = time((time_t *) 0);
119 rdata.host = hostaddr;
120 data.dptr = (char *)&rdata;
121 data.dsize = sizeof(kalog_elt);
123 dbm_store(kalog_db, key, data, DBM_REPLACE);
125 ViceLog(verbose_track, ("%s from %x\n", keybuf, hostaddr));
129 #endif /* AUTH_DBM_LOG */
132 /* log a ticket usage to the text log */
134 ka_log(char *principal, char *instance, char *sprincipal, char *sinstance,
135 char *realm, int hostaddr, int type)
137 char logbuf[512]; /* not random! 63 . 63 , 63 . 63 max key */
140 strcpy(logbuf, principal);
143 strcat(logbuf, realm);
147 strcat(logbuf, instance);
150 /* unlike the name/instance, the services can come down as NULL */
151 if (sprincipal && *sprincipal) {
153 strcat(logbuf, sprincipal);
154 if (sinstance && *sinstance) {
156 strcat(logbuf, sinstance);
161 strcat(logbuf, ":cruser");
164 strcat(logbuf, ":chp");
166 case LOG_AUTHENTICATE:
167 strcat(logbuf, ":auth");
170 strcat(logbuf, ":authnot");
173 strcat(logbuf, ":setf");
176 strcat(logbuf, ":delu");
179 strcat(logbuf, ":unlok");
182 strcat(logbuf, ":gtck");
188 ViceLog(verbose_track, ("%s from %x\n", logbuf, hostaddr));