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 <afs/param.h>
21 #include <afs/afsutil.h>
26 #include <sys/types.h>
30 #include <afs/afsutil.h>
34 extern afs_int32 verbose_track;
42 OpenLog(AFSDIR_SERVER_KALOGDB_FILEPATH); /* set up logging */
44 kalog_db = dbm_open(AFSDIR_SERVER_KALOG_FILEPATH, O_WRONLY | O_CREAT, KALOG_DB_MODE);
46 ViceLog(0, ("Cannot open dbm database - no DB logging possible\n"));
49 /* log a ticket usage */
50 kalog_log(principal, instance, sprincipal, sinstance, realm, hostaddr, type)
51 char *principal, *instance, *sprincipal, *sinstance, *realm;
54 char keybuf[512]; /* not random! 63 . 63 , 63 . 63 max key */
58 if (!kalog_db) return;
60 strcpy(keybuf, principal);
63 strcat(keybuf, realm);
67 strcat(keybuf, instance);
70 /* unlike the name/instance, the services can come down as NULL */
71 if (sprincipal && *sprincipal) {
73 strcat(keybuf, sprincipal);
74 if (sinstance && *sinstance) {
76 strcat(keybuf, sinstance);
81 strcat(keybuf, ":cruser");
84 strcat(keybuf, ":chp");
86 case LOG_AUTHENTICATE:
87 strcat(keybuf, ":auth");
90 strcat(keybuf, ":authnot");
93 strcat(keybuf, ":setf");
96 strcat(keybuf, ":delu");
99 strcat(keybuf, ":unlok");
102 strcat(keybuf, ":gtck");
109 key.dsize = strlen(keybuf) + 1; /* store the key in a string w/ null */
110 rdata.last_use = time((time_t *) 0);
111 rdata.host = hostaddr;
112 data.dptr = (char *) &rdata;
113 data.dsize = sizeof(kalog_elt);
115 dbm_store(kalog_db, key, data, DBM_REPLACE);
117 ViceLog(verbose_track, ("%s from %x\n", keybuf, hostaddr));
121 #endif /* AUTH_DBM_LOG */
124 /* log a ticket usage to the text log */
125 void ka_log(char *principal, char *instance, char *sprincipal, char *sinstance,
126 char *realm, int hostaddr, int type)
128 char logbuf[512]; /* not random! 63 . 63 , 63 . 63 max key */
131 strcpy(logbuf, principal);
134 strcat(logbuf, realm);
138 strcat(logbuf, instance);
141 /* unlike the name/instance, the services can come down as NULL */
142 if (sprincipal && *sprincipal) {
144 strcat(logbuf, sprincipal);
145 if (sinstance && *sinstance) {
147 strcat(logbuf, sinstance);
152 strcat(logbuf, ":cruser");
155 strcat(logbuf, ":chp");
157 case LOG_AUTHENTICATE:
158 strcat(logbuf, ":auth");
161 strcat(logbuf, ":authnot");
164 strcat(logbuf, ":setf");
167 strcat(logbuf, ":delu");
170 strcat(logbuf, ":unlok");
173 strcat(logbuf, ":gtck");
179 ViceLog(verbose_track, ("%s from %x\n", logbuf, hostaddr));