diff options
author | Gregor Beck <gbeck@sernet.de> | 2012-08-23 10:36:59 +0200 |
---|---|---|
committer | Michael Adam <obnox@samba.org> | 2012-10-19 12:15:00 +0200 |
commit | f2714318ae7358abd328e264dc80821c2749bcc6 (patch) | |
tree | 6e068a9626bea1ed5953cdc91fea928c1b316680 /source3/lib/sessionid_tdb.c | |
parent | d9ea786c86d6bc42df60881ff703213ef3bd9319 (diff) | |
download | samba-f2714318ae7358abd328e264dc80821c2749bcc6.tar.gz |
s3:lib: implement sessionid_traverse_read with smb2srv_session_traverse_read
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Signed-off-by: Michael Adam <obnox@samba.org>
Diffstat (limited to 'source3/lib/sessionid_tdb.c')
-rw-r--r-- | source3/lib/sessionid_tdb.c | 58 |
1 files changed, 33 insertions, 25 deletions
diff --git a/source3/lib/sessionid_tdb.c b/source3/lib/sessionid_tdb.c index 5782c9a5443..fafdb9a8751 100644 --- a/source3/lib/sessionid_tdb.c +++ b/source3/lib/sessionid_tdb.c @@ -23,6 +23,7 @@ #include "dbwrap/dbwrap_open.h" #include "session.h" #include "util_tdb.h" +#include "smbd/globals.h" static struct db_context *session_db_ctx(void) { @@ -113,28 +114,39 @@ struct sessionid_traverse_read_state { void *private_data; }; -static int sessionid_traverse_read_fn(struct db_record *rec, +static int sessionid_traverse_read_fn(struct smbXsrv_session_global0 *global, void *private_data) { - TDB_DATA key; - TDB_DATA value; struct sessionid_traverse_read_state *state = (struct sessionid_traverse_read_state *)private_data; - struct sessionid session; - - key = dbwrap_record_get_key(rec); - value = dbwrap_record_get_value(rec); - - if ((key.dptr[key.dsize-1] != '\0') - || (value.dsize != sizeof(struct sessionid))) { - DEBUG(1, ("Found invalid record in sessionid.tdb\n")); - return 0; - } - - memcpy(&session, value.dptr, sizeof(session)); - - return state->fn((char *)key.dptr, &session, - state->private_data); + struct auth_session_info *session_info = global->auth_session_info; + struct sessionid session = { + .uid = session_info->unix_token->uid, + .gid = session_info->unix_token->gid, + .id_num = global->session_global_id, + .connect_start = nt_time_to_unix(global->creation_time), + .pid = global->channels[0].server_id, + }; + + strncpy(session.username, + session_info->unix_info->unix_name, + sizeof(fstring)-1); + strncpy(session.remote_machine, + global->channels[0].remote_name, + sizeof(fstring)-1); + strncpy(session.hostname, + global->channels[0].remote_address, + sizeof(fstring)-1); + strncpy(session.netbios_name, + global->channels[0].remote_name, + sizeof(fstring)-1); + snprintf(session.id_str, sizeof(fstring)-1, + "smb/%u", global->session_global_id); + strncpy(session.ip_addr_str, + global->channels[0].remote_address, + sizeof(fstring)-1); + + return state->fn(NULL, &session, state->private_data); } NTSTATUS sessionid_traverse_read(int (*fn)(const char *key, @@ -142,17 +154,13 @@ NTSTATUS sessionid_traverse_read(int (*fn)(const char *key, void *private_data), void *private_data) { - struct db_context *db; struct sessionid_traverse_read_state state; NTSTATUS status; - db = session_db_ctx(); - if (db == NULL) { - return NT_STATUS_UNSUCCESSFUL; - } state.fn = fn; state.private_data = private_data; - status = dbwrap_traverse_read(db, sessionid_traverse_read_fn, &state, - NULL); + status = smbXsrv_session_global_traverse(sessionid_traverse_read_fn, + &state); + return status; } |