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>
37 #include <sys/types.h>
41 #include <afs/afsutil.h>
45 extern afs_int32 verbose_track;
53 OpenLog(AFSDIR_SERVER_KALOGDB_FILEPATH); /* set up logging */
56 dbm_open(AFSDIR_SERVER_KALOG_FILEPATH, O_WRONLY | O_CREAT,
59 ViceLog(0, ("Cannot open dbm database - no DB logging possible\n"));
62 /* log a ticket usage */
63 kalog_log(principal, instance, sprincipal, sinstance, realm, hostaddr, type)
64 char *principal, *instance, *sprincipal, *sinstance, *realm;
67 char keybuf[512]; /* not random! 63 . 63 , 63 . 63 max key */
74 strcpy(keybuf, principal);
77 strcat(keybuf, realm);
81 strcat(keybuf, instance);
84 /* unlike the name/instance, the services can come down as NULL */
85 if (sprincipal && *sprincipal) {
87 strcat(keybuf, sprincipal);
88 if (sinstance && *sinstance) {
90 strcat(keybuf, sinstance);
95 strcat(keybuf, ":cruser");
98 strcat(keybuf, ":chp");
100 case LOG_AUTHENTICATE:
101 strcat(keybuf, ":auth");
104 strcat(keybuf, ":authnot");
107 strcat(keybuf, ":setf");
110 strcat(keybuf, ":delu");
113 strcat(keybuf, ":unlok");
116 strcat(keybuf, ":gtck");
123 key.dsize = strlen(keybuf) + 1; /* store the key in a string w/ null */
124 rdata.last_use = time((time_t *) 0);
125 rdata.host = hostaddr;
126 data.dptr = (char *)&rdata;
127 data.dsize = sizeof(kalog_elt);
129 dbm_store(kalog_db, key, data, DBM_REPLACE);
131 ViceLog(verbose_track, ("%s from %x\n", keybuf, hostaddr));
135 #endif /* AUTH_DBM_LOG */
138 /* log a ticket usage to the text log */
140 ka_log(char *principal, char *instance, char *sprincipal, char *sinstance,
141 char *realm, int hostaddr, int type)
143 char logbuf[512]; /* not random! 63 . 63 , 63 . 63 max key */
146 strcpy(logbuf, principal);
149 strcat(logbuf, realm);
153 strcat(logbuf, instance);
156 /* unlike the name/instance, the services can come down as NULL */
157 if (sprincipal && *sprincipal) {
159 strcat(logbuf, sprincipal);
160 if (sinstance && *sinstance) {
162 strcat(logbuf, sinstance);
167 strcat(logbuf, ":cruser");
170 strcat(logbuf, ":chp");
172 case LOG_AUTHENTICATE:
173 strcat(logbuf, ":auth");
176 strcat(logbuf, ":authnot");
179 strcat(logbuf, ":setf");
182 strcat(logbuf, ":delu");
185 strcat(logbuf, ":unlok");
188 strcat(logbuf, ":gtck");
194 ViceLog(verbose_track, ("%s from %x\n", logbuf, hostaddr));