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>
24 #include <afs/afsutil.h>
28 extern afs_int32 verbose_track;
37 OpenLog(AFSDIR_SERVER_KALOGDB_FILEPATH); /* set up logging */
40 dbm_open(AFSDIR_SERVER_KALOG_FILEPATH, O_WRONLY | O_CREAT,
43 ViceLog(0, ("Cannot open dbm database - no DB logging possible\n"));
46 /* log a ticket usage */
48 kalog_log(char *principal, char *instance, char *sprincipal,
49 char *sinstance, char *realm, int hostaddr, int type)
51 char keybuf[512]; /* not random! 63 . 63 , 63 . 63 max key */
58 strcpy(keybuf, principal);
61 strcat(keybuf, realm);
65 strcat(keybuf, instance);
68 /* unlike the name/instance, the services can come down as NULL */
69 if (sprincipal && *sprincipal) {
71 strcat(keybuf, sprincipal);
72 if (sinstance && *sinstance) {
74 strcat(keybuf, sinstance);
79 strcat(keybuf, ":cruser");
82 strcat(keybuf, ":chp");
84 case LOG_AUTHENTICATE:
85 strcat(keybuf, ":auth");
88 strcat(keybuf, ":authnot");
91 strcat(keybuf, ":setf");
94 strcat(keybuf, ":delu");
97 strcat(keybuf, ":unlok");
100 strcat(keybuf, ":gtck");
103 strcat(keybuf, ":tgtreq");
110 key.dsize = strlen(keybuf) + 1; /* store the key in a string w/ null */
111 rdata.last_use = time((time_t *) 0);
112 rdata.host = hostaddr;
113 data.dptr = (char *)&rdata;
114 data.dsize = sizeof(kalog_elt);
116 dbm_store(kalog_db, key, data, DBM_REPLACE);
118 ViceLog(verbose_track, ("%s from %x\n", keybuf, hostaddr));
122 #endif /* AUTH_DBM_LOG */
125 /* log a ticket usage to the text log */
127 ka_log(char *principal, char *instance, char *sprincipal, char *sinstance,
128 char *realm, int hostaddr, int type)
130 char logbuf[512]; /* not random! 63 . 63 , 63 . 63 max key */
133 strcpy(logbuf, principal);
136 strcat(logbuf, realm);
140 strcat(logbuf, instance);
143 /* unlike the name/instance, the services can come down as NULL */
144 if (sprincipal && *sprincipal) {
146 strcat(logbuf, sprincipal);
147 if (sinstance && *sinstance) {
149 strcat(logbuf, sinstance);
154 strcat(logbuf, ":cruser");
157 strcat(logbuf, ":chp");
159 case LOG_AUTHENTICATE:
160 strcat(logbuf, ":auth");
163 strcat(logbuf, ":authnot");
166 strcat(logbuf, ":setf");
169 strcat(logbuf, ":delu");
172 strcat(logbuf, ":unlok");
175 strcat(logbuf, ":gtck");
178 strcat(logbuf, ":tgtreq");
184 ViceLog(verbose_track, ("%s from %x\n", logbuf, hostaddr));