struct smbd_server_connection *msg_ctx_to_sconn(struct messaging_context *msg_ctx) { struct server_id my_id, msg_id; my_id = messaging_server_id(smbd_server_conn->msg_ctx); msg_id = messaging_server_id(msg_ctx); if (!procid_equal(&my_id, &msg_id)) { return NULL; } return smbd_server_conn; }
/* lookup PID <-> Machine name mapping */ static char *mapPid2Machine (struct server_id pid) { static char pidbuf [64]; PIDMAP *map; /* show machine name rather PID on table "Open Files"? */ if (PID_or_Machine) { for (map = pidmap; map != NULL; map = map->next) { if (procid_equal(&pid, &map->pid)) { if (map->machine == NULL) /* no machine name */ break; /* show PID */ return map->machine; } } } /* PID not in list or machine name NULL? return pid as string */ snprintf (pidbuf, sizeof (pidbuf) - 1, "%s", procid_str_static(&pid)); return pidbuf; }
/* traversal fn for showing machine connections */ static int traverse_fn2(const struct connections_key *key, const struct connections_data *crec, void *private_data) { if (crec->cnum == -1 || !process_exists(crec->pid) || procid_equal(&crec->pid, &smbd_pid)) return 0; addPid2Machine (crec->pid, crec->machine); printf("<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td>\n", procid_str_static(&crec->pid), crec->machine, crec->addr, tstring(talloc_tos(),crec->start)); if (geteuid() == 0) { printf("<td><input type=submit value=\"X\" name=\"kill_%s\"></td>\n", procid_str_static(&crec->pid)); } printf("</tr>\n"); return 0; }