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 struct logOptions logopts
;
39 memset(&logopts
, 0, sizeof(logopts
));
40 logopts
.lopt_dest
= logDest_file
;
41 logopts
.lopt_filename
= AFSDIR_SERVER_KALOGDB_FILEPATH
;
42 logopts
.lopt_rotateOnOpen
= 1;
43 logopts
.lopt_rotateStyle
= logRotate_old
;
47 dbm_open(AFSDIR_SERVER_KALOG_FILEPATH
, O_WRONLY
| O_CREAT
,
50 ViceLog(0, ("Cannot open dbm database - no DB logging possible\n"));
53 /* log a ticket usage */
55 kalog_log(char *principal
, char *instance
, char *sprincipal
,
56 char *sinstance
, char *realm
, int hostaddr
, int type
)
58 char keybuf
[512]; /* not random! 63 . 63 , 63 . 63 max key */
65 strcpy(keybuf
, principal
);
68 strcat(keybuf
, realm
);
72 strcat(keybuf
, instance
);
75 /* unlike the name/instance, the services can come down as NULL */
76 if (sprincipal
&& *sprincipal
) {
78 strcat(keybuf
, sprincipal
);
79 if (sinstance
&& *sinstance
) {
81 strcat(keybuf
, sinstance
);
86 strcat(keybuf
, ":cruser");
89 strcat(keybuf
, ":chp");
91 case LOG_AUTHENTICATE
:
92 strcat(keybuf
, ":auth");
95 strcat(keybuf
, ":authnot");
98 strcat(keybuf
, ":setf");
101 strcat(keybuf
, ":delu");
104 strcat(keybuf
, ":unlok");
107 strcat(keybuf
, ":gtck");
110 strcat(keybuf
, ":tgtreq");
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 */
139 logbuf
[0] = '\0'; /* Empty string */
142 strlcpy(logbuf
, principal
, sizeof(logbuf
));
144 strlcat(logbuf
, "@", sizeof(logbuf
));
145 strlcat(logbuf
, realm
, sizeof(logbuf
));
148 strlcat(logbuf
, ".", sizeof(logbuf
));
149 strlcat(logbuf
, instance
, sizeof(logbuf
));
152 /* unlike the name/instance, the services can come down as NULL */
153 if (sprincipal
&& *sprincipal
) {
154 strlcat(logbuf
, ",", sizeof(logbuf
));
155 strlcat(logbuf
, sprincipal
, sizeof(logbuf
));
156 if (sinstance
&& *sinstance
) {
157 strlcat(logbuf
, ".", sizeof(logbuf
));
158 strlcat(logbuf
, sinstance
, sizeof(logbuf
));
163 strlcat(logbuf
, ":cruser", sizeof(logbuf
));
166 strlcat(logbuf
, ":chp", sizeof(logbuf
));
168 case LOG_AUTHENTICATE
:
169 strlcat(logbuf
, ":auth", sizeof(logbuf
));
172 strlcat(logbuf
, ":authnot", sizeof(logbuf
));
175 strlcat(logbuf
, ":setf", sizeof(logbuf
));
178 strlcat(logbuf
, ":delu", sizeof(logbuf
));
181 strlcat(logbuf
, ":unlok", sizeof(logbuf
));
184 strlcat(logbuf
, ":gtck", sizeof(logbuf
));
187 strlcat(logbuf
, ":tgtreq", sizeof(logbuf
));
193 ViceLog(verbose_track
, ("%s from %x\n", logbuf
, hostaddr
));