Changeset 745 for trunk/server/source3/utils/net_status.c
- Timestamp:
- Nov 27, 2012, 4:43:17 PM (13 years ago)
- Location:
- trunk/server
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/server
- Property svn:mergeinfo changed
/vendor/current merged: 581,587,591,594,597,600,615,618,740
- Property svn:mergeinfo changed
-
trunk/server/source3/utils/net_status.c
r414 r745 19 19 #include "includes.h" 20 20 #include "utils/net.h" 21 #include "session.h" 22 #include "messages.h" 21 23 22 24 int net_status_usage(struct net_context *c, int argc, const char **argv) … … 29 31 } 30 32 31 static int show_session(struct db_record *rec, void *private_data) 33 static int show_session(const char *key, struct sessionid *session, 34 void *private_data) 32 35 { 33 36 bool *parseable = (bool *)private_data; 34 struct sessionid sessionid; 35 36 if (rec->value.dsize != sizeof(sessionid)) 37 return 0; 38 39 memcpy(&sessionid, rec->value.dptr, sizeof(sessionid)); 40 41 if (!process_exists(sessionid.pid)) { 37 38 if (!process_exists(session->pid)) { 42 39 return 0; 43 40 } … … 45 42 if (*parseable) { 46 43 d_printf("%s\\%s\\%s\\%s\\%s\n", 47 procid_str_static(&sessionid.pid), uidtoname(sessionid.uid), 48 gidtoname(sessionid.gid), 49 sessionid.remote_machine, sessionid.hostname); 44 procid_str_static(&session->pid), 45 uidtoname(session->uid), 46 gidtoname(session->gid), 47 session->remote_machine, session->hostname); 50 48 } else { 51 49 d_printf("%7s %-12s %-12s %-12s (%s)\n", 52 procid_str_static(&sessionid.pid), uidtoname(sessionid.uid), 53 gidtoname(sessionid.gid), 54 sessionid.remote_machine, sessionid.hostname); 50 procid_str_static(&session->pid), 51 uidtoname(session->uid), 52 gidtoname(session->gid), 53 session->remote_machine, session->hostname); 55 54 } 56 55 … … 60 59 static int net_status_sessions(struct net_context *c, int argc, const char **argv) 61 60 { 62 struct db_context *db;63 61 bool parseable; 64 62 … … 89 87 } 90 88 91 db = db_open(NULL, lock_path("sessionid.tdb"), 0, 92 TDB_CLEAR_IF_FIRST, O_RDONLY, 0644); 93 if (db == NULL) { 94 d_fprintf(stderr, _("%s not initialised\n"), 95 lock_path("sessionid.tdb")); 96 return -1; 97 } 98 99 db->traverse_read(db, show_session, &parseable); 100 TALLOC_FREE(db); 101 89 sessionid_traverse_read(show_session, &parseable); 102 90 return 0; 103 91 } … … 128 116 }; 129 117 130 static int collect_pid(struct db_record *rec, void *private_data) 118 static int collect_pids(const char *key, struct sessionid *session, 119 void *private_data) 131 120 { 132 121 struct sessionids *ids = (struct sessionids *)private_data; 133 struct sessionid sessionid; 134 135 if (rec->value.dsize != sizeof(sessionid)) 136 return 0; 137 138 memcpy(&sessionid, rec->value.dptr, sizeof(sessionid)); 139 140 if (!process_exists(sessionid.pid)) 122 123 if (!process_exists(session->pid)) 141 124 return 0; 142 125 … … 147 130 return 0; 148 131 } 149 ids->entries[ids->num_entries-1] = sessionid; 150 151 return 0; 152 } 153 154 static int show_share_parseable(struct db_record *rec, 155 const struct connections_key *key, 132 ids->entries[ids->num_entries-1] = *session; 133 134 return 0; 135 } 136 137 static int show_share_parseable(const struct connections_key *key, 156 138 const struct connections_data *crec, 157 139 void *state) … … 190 172 { 191 173 struct sessionids ids; 192 struct db_context *db;193 174 194 175 ids.num_entries = 0; 195 176 ids.entries = NULL; 196 177 197 db = db_open(NULL, lock_path("sessionid.tdb"), 0, 198 TDB_CLEAR_IF_FIRST, O_RDONLY, 0644); 199 if (db == NULL) { 200 d_fprintf(stderr, _("%s not initialised\n"), 201 lock_path("sessionid.tdb")); 202 return -1; 203 } 204 205 db->traverse_read(db, collect_pid, &ids); 206 TALLOC_FREE(db); 207 208 connections_forall(show_share_parseable, &ids); 178 sessionid_traverse_read(collect_pids, &ids); 179 180 connections_forall_read(show_share_parseable, &ids); 209 181 210 182 SAFE_FREE(ids.entries);
Note:
See TracChangeset
for help on using the changeset viewer.