1 #!/usr/sbin/dtrace -q -s
8 typedef uint32_t DTPort;
9 typedef uint64_t DTHandle;
11 DTHandle portmap[DTPort]; /* map client reply ports to connections */
14 DTPort replyport; /* reply port for client thread */
15 uint32_t client; /* client object for this connection */
17 struct connection connection[DTHandle]; /* indexed by connection handle */
19 /* should be a single self struct, but that doesn't work right... */
20 self string reqName; /* request name */
21 self DTHandle reqConnection; /* associated connection */
22 self DTHandle reqClient; /* associated client */
25 pid_t pid; /* original client pid */
26 DTHandle session; /* session handle */
27 string name; /* abbreviated name */
28 string path; /* path to client process (regardless of guests) */
29 DTPort taskport; /* process task port */
31 struct client client[DTHandle]; /* indexed by client handle */
34 string name; /* keychain path */
36 struct keychain keychain[DTHandle]; /* indexed by DbCommon handle */
44 /* fake data for unknown processes */
46 client[0].session = 0;
47 client[0].name = "*UNKNOWN*";
48 client[0].path = "*UNKNOWN*";
57 uint32_t threads[DTHandle]; /* map tids to simple thread numbers */
58 uint32_t nextThread; /* next unused thread number */
59 self uint32_t mytid; /* translated tid */
61 securityd*::: /!threads[tid]/ { threads[tid] = ++nextThread; }
62 security_debug*::: /!threads[tid]/ { threads[tid] = ++nextThread; }
64 securityd*::: { self->mytid = threads[tid]; }
65 security_debug*::: { self->mytid = threads[tid]; }
71 securityd*:::installmode
73 printf("%u SYSTEM INSTALLATION MODE SELECTED\n", timestamp);
76 securityd*:::initialized
78 printf("%u COMMENCING SERVICE as %s\n", timestamp, copyinstr(arg0));
85 securityd*:::client-connection-new
87 replymap[arg1] = arg0;
88 self->reqClient = arg2;
89 connection[arg0].client = self->reqClient;
90 self->reqConnection = arg0;
91 @total["Connections"] = count();
92 printf("%u T%d:connection-new(<%x>,port=%d,client=<%x>/%s(%d))\n",
93 timestamp, self->mytid, arg0, arg1,
94 arg2, client[arg2].name, client[arg2].pid);
97 securityd*:::client-connection-release
98 /connection[arg0].client/
100 printf("%u T%d:connection-release(<%x>,client=<%x>/%s(%d))\n",
101 timestamp, self->mytid, arg0,
102 connection[arg0].client,
103 client[connection[arg0].client].name,
104 client[connection[arg0].client].pid);
105 replymap[connection[arg0].replyport] = 0; /* clear from port map */
106 connection[arg0].replyport = 0;
107 connection[arg0].client = 0;
110 securityd*:::client-new
112 client[arg0].pid = arg1;
113 client[arg0].session = arg2;
114 client[arg0].path = copyinstr(arg3);
115 client[arg0].name = basename(client[arg0].path);
116 client[arg0].taskport = arg4;
117 self->reqClient = arg0;
118 @total["Processes"] = count();
119 printf("%u T%d:client-new(<%x>,%s(%d),session=<%x>,task=%d)\n",
120 timestamp, self->mytid, arg0,
121 client[arg0].path, client[arg0].pid,
122 client[arg0].session, client[arg0].taskport);
125 securityd*:::client-release
127 printf("%u T%d:client-release(<%x>,%s(%d))\n",
128 timestamp, self->mytid, arg0, client[arg0].path, arg1);
129 client[arg0].pid = 0;
132 securityd*:::client-change_session
134 printf("%u T%d:client-change_session(<%x>,new session=<%x>)\n",
135 timestamp, self->mytid, arg0, arg1);
136 client[arg0].pid = 0;
143 uint32_t connections[DTHandle];
144 uint32_t nextConnection;
145 self uint32_t myConnection;
147 securityd*:::request-entry
149 { connections[arg1] = ++nextConnection; }
151 securityd*:::request-entry
153 self->reqName = copyinstr(arg0);
154 self->reqConnection = arg1;
155 self->myConnection = connections[arg1];
156 self->reqClient = arg2;
157 this->client = client[self->reqClient];
160 securityd*:::request-entry
163 printf("%u T%d:C%d:%s(%d)%s\n",
164 timestamp, self->mytid, self->myConnection, this->client.name, this->client.pid, self->reqName);
165 @request[client[self->reqClient].name, self->reqName] = count();
168 securityd*:::request-entry
171 printf("%u T%d:C%d:%s\n",
172 timestamp, self->mytid, self->myConnection, self->reqName);
175 securityd*:::request-entry
177 @requests[self->reqName] = count();
178 @total["Requests"] = count();
181 securityd*:::request-return
182 /self->reqConnection && arg0 == 0/
184 printf("%u T%d:C%d:return\n",
185 timestamp, self->mytid, self->myConnection);
188 securityd*:::request-return
189 /self->reqConnection && arg0 != 0/
191 printf("%u T%d:C%d:FAIL(%d)\n",
192 timestamp, self->mytid, self->myConnection, arg0);
195 securityd*:::request-return
197 self->reqConnection = 0;
205 typedef uint32_t SessionId;
211 struct Session session[SessionId];
214 uint32_t ai_auid; /* audit user id */
224 au_asid_t ai_asid; /* audit session id */
225 au_asflgs_t ai_flags; /* audit session flags */
227 self struct xauditinfo *ai;
229 securityd*:::session-create
231 session[arg1].handle = arg0;
232 session[arg1].sessionid = arg1;
233 self->ai = copyin(arg2, sizeof(struct xauditinfo));
234 printf("%u T%d:%s(<%x>,id=%d,uid=%d,flags=%#x)\n", timestamp, self->mytid, probename,
235 arg0, arg1, self->ai->ai_auid, self->ai->ai_flags);
238 securityd*:::session-kill
240 printf("%u T%d:%s(<%x>,id=%d)\n", timestamp, self->mytid, probename, arg0, arg1);
243 securityd*:::session-destroy
245 printf("%u T%d:%s(<%x>,id=%d)\n", timestamp, self->mytid, probename, arg0, arg1);
248 securityd*:::session-notify
250 printf("%u T%d:%s(<%x>,id=%d,events=0x%x,uid=%d)\n", timestamp, self->mytid, probename,
251 session[arg0].handle, arg0, arg1, arg2);
258 securityd*:::keychain-*
260 this->path = copyinstr(arg1);
261 printf("%u T%d:%s(<%x>,%s)\n", timestamp, self->mytid, probename, arg0, this->path);
262 @keychain[this->path, probename] = count();
267 * Low-level port events
271 printf("%u T%d:%s(%d)\n", timestamp, self->mytid, probename, arg0);
278 securityd*:::guest-create
280 printf("%u T%d:guest-create(<%x>,host=<%x>,guest=<%x>,status=0x%x,flags=0x%x,path=%s)\n",
281 timestamp, self->mytid, arg0, arg1, arg2, arg3, arg4, copyinstr(arg5));
282 @total["Guests"] = count();
285 securityd*:::guest-change
287 printf("%u T%d:guest-change(<%x>,<%x>,status=0x%x)\n", timestamp, self->mytid, arg0, arg1, arg2);
290 securityd*:::guest-destroy
292 printf("%u T%d:guest-destroy(<%x>,<%x>)\n", timestamp, self->mytid, arg0, arg1);
295 securityd*:::host-register,
296 securityd*:::host-proxy
298 printf("%u T%d:%s(<%x>,port=%d)\n", timestamp, self->mytid, probename, arg0, arg1);
299 @total["Hosts"] = count();
302 securityd*:::host-unregister
304 printf("%u T%d:host-unregister(<%x>)\n", timestamp, self->mytid, arg0);
313 printf("%u T%d:%s(%d,%d)\n", timestamp, self->mytid, probename, arg0, arg1);
322 printf("%u T%d:POWER(%s)\n", timestamp, self->mytid, probename);
329 securityd*:::auth-create
331 printf("%u T%d:%s ref(%#x) session(%#x)\n", timestamp, self->mytid, probename, arg1, arg0);
334 securityd*:::auth-allow,
335 securityd*:::auth-deny,
336 securityd*:::auth-user,
337 securityd*:::auth-rules,
338 securityd*:::auth-kofn,
339 securityd*:::auth-mechrule
341 printf("%u T%d:%s ref(%#x) rule(%s)\n", timestamp, self->mytid, probename, arg0, copyinstr(arg1));
344 securityd*:::auth-mech
346 printf("%u T%d:%s ref(%#x) (%s)\n", timestamp, self->mytid, probename, arg0, copyinstr(arg1));
349 securityd*:::auth-user-allowroot,
350 securityd*:::auth-user-allowsessionowner
352 printf("%u T%d:%s ref(%#x)\n", timestamp, self->mytid, probename, arg0);
355 securityd*:::auth-evalright
357 printf("%u T%d:%s ref(%#x) %s (%d)\n", timestamp, self->mytid, probename, arg0, copyinstr(arg1), arg2);
364 securityd*:::entropy-collect
366 printf("%u T%d:entropy-collect()\n", timestamp, tid);
369 securityd*:::entropy-seed
371 printf("%u T%d:entropy-seed(%d)\n", timestamp, self->mytid, arg0);
374 securityd*:::entropy-save
376 printf("%u T%d:entropy-save(%s)\n", timestamp, self->mytid, copyinstr(arg0));
379 securityd*:::signal-*
381 printf("%u T%d:%s(%d)\n", timestamp, self->mytid, probename, arg0);
386 * Integrate secdebug logs
388 security_debug*:::log
389 /execname == "securityd"/
391 printf("%u T%d:[%s]%s\n", timestamp, threads[tid],
392 copyinstr(arg0), copyinstr(arg1));
395 security_exception*:::throw-*
396 /execname == "securityd"/
398 printf("%u T%d:EXCEPTION(%p) THROWN %s(%d)\n", timestamp, threads[tid],
399 arg0, probename, arg1);
408 printa("%@8u %s\n", @total);
409 printf("\n Requests:\n");
410 printa("%@8u %s\n", @requests);
411 printf("\n Requests by client:\n");
412 printa("%@8u %s:%s\n", @request);
413 printf("\n Keychains by path and operation:\n");
414 printa("%@8u %s(%s)\n", @keychain);