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>
29 #include <sys/types.h>
33 #include <afs/afsutil.h>
37 extern afs_int32 verbose_track;
45 OpenLog(AFSDIR_SERVER_KALOGDB_FILEPATH); /* set up logging */
48 dbm_open(AFSDIR_SERVER_KALOG_FILEPATH, O_WRONLY | O_CREAT,
51 ViceLog(0, ("Cannot open dbm database - no DB logging possible\n"));
54 /* log a ticket usage */
55 kalog_log(principal, instance, sprincipal, sinstance, realm, hostaddr, type)
56 char *principal, *instance, *sprincipal, *sinstance, *realm;
59 char keybuf[512]; /* not random! 63 . 63 , 63 . 63 max key */
66 strcpy(keybuf, principal);
69 strcat(keybuf, realm);
73 strcat(keybuf, instance);
76 /* unlike the name/instance, the services can come down as NULL */
77 if (sprincipal && *sprincipal) {
79 strcat(keybuf, sprincipal);
80 if (sinstance && *sinstance) {
82 strcat(keybuf, sinstance);
87 strcat(keybuf, ":cruser");
90 strcat(keybuf, ":chp");
92 case LOG_AUTHENTICATE:
93 strcat(keybuf, ":auth");
96 strcat(keybuf, ":authnot");
99 strcat(keybuf, ":setf");
102 strcat(keybuf, ":delu");
105 strcat(keybuf, ":unlok");
108 strcat(keybuf, ":gtck");
111 strcat(keybuf, ":tgtreq");
118 key.dsize = strlen(keybuf) + 1; /* store the key in a string w/ null */
119 rdata.last_use = time((time_t *) 0);
120 rdata.host = hostaddr;
121 data.dptr = (char *)&rdata;
122 data.dsize = sizeof(kalog_elt);
124 dbm_store(kalog_db, key, data, DBM_REPLACE);
126 ViceLog(verbose_track, ("%s from %x\n", keybuf, hostaddr));
130 #endif /* AUTH_DBM_LOG */
133 /* log a ticket usage to the text log */
135 ka_log(char *principal, char *instance, char *sprincipal, char *sinstance,
136 char *realm, int hostaddr, int type)
138 char logbuf[512]; /* not random! 63 . 63 , 63 . 63 max key */
141 strcpy(logbuf, principal);
144 strcat(logbuf, realm);
148 strcat(logbuf, instance);
151 /* unlike the name/instance, the services can come down as NULL */
152 if (sprincipal && *sprincipal) {
154 strcat(logbuf, sprincipal);
155 if (sinstance && *sinstance) {
157 strcat(logbuf, sinstance);
162 strcat(logbuf, ":cruser");
165 strcat(logbuf, ":chp");
167 case LOG_AUTHENTICATE:
168 strcat(logbuf, ":auth");
171 strcat(logbuf, ":authnot");
174 strcat(logbuf, ":setf");
177 strcat(logbuf, ":delu");
180 strcat(logbuf, ":unlok");
183 strcat(logbuf, ":gtck");
186 strcat(logbuf, ":tgtreq");
192 ViceLog(verbose_track, ("%s from %x\n", logbuf, hostaddr));