1 #!/usr/sbin/dtrace -q -s
7 typedef uint32_t DTPort;
8 typedef uint64_t DTHandle;
10 DTHandle portmap[DTPort]; /* map client reply ports to connections */
13 DTPort replyport; /* reply port for client thread */
14 uint32_t client; /* client object for this connection */
16 struct connection connection[DTHandle]; /* indexed by connection handle */
18 /* should be a single self struct, but that doesn't work right... */
19 self string reqName; /* request name */
20 self DTHandle reqConnection; /* associated connection */
21 self DTHandle reqClient; /* associated client */
24 pid_t pid; /* original client pid */
25 DTHandle session; /* session handle */
26 string name; /* abbreviated name */
27 string path; /* path to client process (regardless of guests) */
28 DTPort taskport; /* process task port */
30 struct client client[DTHandle]; /* indexed by client handle */
33 string name; /* keychain path */
35 struct keychain keychain[DTHandle]; /* indexed by DbCommon handle */
43 /* fake data for unknown processes */
45 client[0].session = 0;
46 client[0].name = "*UNKNOWN*";
47 client[0].path = "*UNKNOWN*";
56 uint32_t threads[DTHandle]; /* map tids to simple thread numbers */
57 uint32_t nextThread; /* next unused thread number */
58 self uint32_t mytid; /* translated tid */
60 securityd*::: /!threads[tid]/ { threads[tid] = ++nextThread; }
61 security_debug*::: /!threads[tid]/ { threads[tid] = ++nextThread; }
63 securityd*::: { self->mytid = threads[tid]; }
64 security_debug*::: { self->mytid = threads[tid]; }
70 securityd*:::installmode
72 printf("%u SYSTEM INSTALLATION MODE SELECTED\n", timestamp);
75 securityd*:::initialized
77 printf("%u COMMENCING SERVICE as %s\n", timestamp, copyinstr(arg0));
84 securityd*:::client-connection-new
86 replymap[arg1] = arg0;
87 self->reqClient = arg2;
88 connection[arg0].client = self->reqClient;
89 self->reqConnection = arg0;
90 @total["Connections"] = count();
91 printf("%u T%d:connection-new(<%x>,port=%d,client=<%x>/%s(%d))\n",
92 timestamp, self->mytid, arg0, arg1,
93 arg2, client[arg2].name, client[arg2].pid);
96 securityd*:::client-connection-release
97 /connection[arg0].client/
99 printf("%u T%d:connection-release(<%x>,client=<%x>/%s(%d))\n",
100 timestamp, self->mytid, arg0,
101 connection[arg0].client,
102 client[connection[arg0].client].name,
103 client[connection[arg0].client].pid);
104 replymap[connection[arg0].replyport] = 0; /* clear from port map */
105 connection[arg0].replyport = 0;
106 connection[arg0].client = 0;
109 securityd*:::client-new
111 client[arg0].pid = arg1;
112 client[arg0].session = arg2;
113 client[arg0].path = copyinstr(arg3);
114 client[arg0].name = basename(client[arg0].path);
115 client[arg0].taskport = arg4;
116 self->reqClient = arg0;
117 @total["Processes"] = count();
118 printf("%u T%d:client-new(<%x>,%s(%d),session=<%x>,task=%d)\n",
119 timestamp, self->mytid, arg0,
120 client[arg0].path, client[arg0].pid,
121 client[arg0].session, client[arg0].taskport);
124 securityd*:::client-release
126 printf("%u T%d:client-release(<%x>,%s(%d))\n",
127 timestamp, self->mytid, arg0, client[arg0].path, arg1);
128 client[arg0].pid = 0;
131 securityd*:::client-change_session
133 printf("%u T%d:client-change_session(<%x>,new session=<%x>)\n",
134 timestamp, self->mytid, arg0, arg1);
135 client[arg0].pid = 0;
142 uint32_t connections[DTHandle];
143 uint32_t nextConnection;
144 self uint32_t myConnection;
146 securityd*:::request-entry
148 { connections[arg1] = ++nextConnection; }
150 securityd*:::request-entry
152 self->reqName = copyinstr(arg0);
153 self->reqConnection = arg1;
154 self->myConnection = connections[arg1];
155 self->reqClient = arg2;
156 this->client = client[self->reqClient];
159 securityd*:::request-entry
162 printf("%u T%d:C%d:%s(%d)%s\n",
163 timestamp, self->mytid, self->myConnection, this->client.name, this->client.pid, self->reqName);
164 @request[client[self->reqClient].name, self->reqName] = count();
167 securityd*:::request-entry
170 printf("%u T%d:C%d:%s\n",
171 timestamp, self->mytid, self->myConnection, self->reqName);
174 securityd*:::request-entry
176 @requests[self->reqName] = count();
177 @total["Requests"] = count();
180 securityd*:::request-return
181 /self->reqConnection && arg0 == 0/
183 printf("%u T%d:C%d:return\n",
184 timestamp, self->mytid, self->myConnection);
187 securityd*:::request-return
188 /self->reqConnection && arg0 != 0/
190 printf("%u T%d:C%d:FAIL(%d)\n",
191 timestamp, self->mytid, self->myConnection, arg0);
194 securityd*:::request-return
196 self->reqConnection = 0;
204 securityd*:::session-*
206 printf("%u T%d:%s(<%x>,0x%x)\n", timestamp, self->mytid, probename, arg0, arg1);
213 securityd*:::keychain-*
215 this->path = copyinstr(arg1);
216 printf("%u T%d:%s(<%x>,%s)\n", timestamp, self->mytid, probename, arg0, this->path);
217 @keychain[this->path, probename] = count();
222 * Low-level port events
226 printf("%u T%d:%s(%d)\n", timestamp, self->mytid, probename, arg0);
233 securityd*:::guest-create
235 printf("%u T%d:guest-create(<%x>,host=<%x>,guest=<%x>,status=0x%x,flags=0x%x,path=%s)\n",
236 timestamp, self->mytid, arg0, arg1, arg2, arg3, arg4, copyinstr(arg5));
237 @total["Guests"] = count();
240 securityd*:::guest-change
242 printf("%u T%d:guest-change(<%x>,<%x>,status=0x%x)\n", timestamp, self->mytid, arg0, arg1, arg2);
245 securityd*:::guest-destroy
247 printf("%u T%d:guest-destroy(<%x>,<%x>)\n", timestamp, self->mytid, arg0, arg1);
250 securityd*:::host-register,
251 securityd*:::host-proxy
253 printf("%u T%d:%s(<%x>,port=%d)\n", timestamp, self->mytid, probename, arg0, arg1);
254 @total["Hosts"] = count();
257 securityd*:::host-unregister
259 printf("%u T%d:host-unregister(<%x>)\n", timestamp, self->mytid, arg0);
268 printf("%u T%d:%s(%d,%d)\n", timestamp, self->mytid, probename, arg0, arg1);
277 printf("%u T%d:POWER(%s)\n", timestamp, self->mytid, probename);
284 securityd*:::auth-create
286 printf("%u T%d:%s ref(%#x) session(%#x)\n", timestamp, self->mytid, probename, arg1, arg0);
289 securityd*:::auth-allow,
290 securityd*:::auth-deny,
291 securityd*:::auth-user,
292 securityd*:::auth-rules,
293 securityd*:::auth-kofn,
294 securityd*:::auth-mechrule
296 printf("%u T%d:%s ref(%#x) rule(%s)\n", timestamp, self->mytid, probename, arg0, copyinstr(arg1));
299 securityd*:::auth-mech
301 printf("%u T%d:%s ref(%#x) (%s)\n", timestamp, self->mytid, probename, arg0, copyinstr(arg1));
304 securityd*:::auth-user-allowroot,
305 securityd*:::auth-user-allowsessionowner
307 printf("%u T%d:%s ref(%#x)\n", timestamp, self->mytid, probename, arg0);
310 securityd*:::auth-evalright
312 printf("%u T%d:%s ref(%#x) %s (%d)\n", timestamp, self->mytid, probename, arg0, copyinstr(arg1), arg2);
319 securityd*:::entropy-collect
321 printf("%u T%d:entropy-collect()\n", timestamp, tid);
324 securityd*:::entropy-seed
326 printf("%u T%d:entropy-seed(%d)\n", timestamp, self->mytid, arg0);
329 securityd*:::entropy-save
331 printf("%u T%d:entropy-save(%s)\n", timestamp, self->mytid, copyinstr(arg0));
334 securityd*:::signal-*
336 printf("%u T%d:%s(%d)\n", timestamp, self->mytid, probename, arg0);
341 * Integrate secdebug logs
343 security_debug*:::log
344 /execname == "securityd"/
346 printf("%u T%d:[%s]%s\n", timestamp, threads[tid],
347 copyinstr(arg0), copyinstr(arg1));
350 security_exception*:::throw-*
351 /execname == "securityd"/
353 printf("%u T%d:EXCEPTION(%p) THROWN %s(%d)\n", timestamp, threads[tid],
354 arg0, probename, arg1);
363 printa("%@8u %s\n", @total);
364 printf("\n Requests:\n");
365 printa("%@8u %s\n", @requests);
366 printf("\n Requests by client:\n");
367 printa("%@8u %s:%s\n", @request);
368 printf("\n Keychains by path and operation:\n");
369 printa("%@8u %s(%s)\n", @keychain);