2 Unix SMB/CIFS implementation.
3 Low-level sessionid.tdb access functions
4 Copyright (C) Volker Lendecke 2010
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 3 of the License, or
9 (at your option) any later version.
11 This program is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this program. If not, see <http://www.gnu.org/licenses/>.
21 #include "system/filesys.h"
22 #include "dbwrap/dbwrap.h"
23 #include "dbwrap/dbwrap_open.h"
26 #include "smbd/globals.h"
28 struct sessionid_traverse_read_state
{
29 int (*fn
)(const char *key
, struct sessionid
*session
,
34 static int sessionid_traverse_read_fn(struct smbXsrv_session_global0
*global
,
37 struct sessionid_traverse_read_state
*state
=
38 (struct sessionid_traverse_read_state
*)private_data
;
39 struct auth_session_info
*session_info
= global
->auth_session_info
;
40 struct sessionid session
= {
43 .id_num
= global
->session_global_id
,
44 .connect_start
= nt_time_to_unix(global
->creation_time
),
45 .pid
= global
->channels
[0].server_id
,
46 .connection_dialect
= global
->connection_dialect
,
49 if (session_info
!= NULL
) {
50 session
.uid
= session_info
->unix_token
->uid
;
51 session
.gid
= session_info
->unix_token
->gid
;
52 strncpy(session
.username
,
53 session_info
->unix_info
->unix_name
,
57 strncpy(session
.remote_machine
,
58 global
->channels
[0].remote_name
,
60 strncpy(session
.hostname
,
61 global
->channels
[0].remote_address
,
63 strncpy(session
.netbios_name
,
64 global
->channels
[0].remote_name
,
66 snprintf(session
.id_str
, sizeof(fstring
)-1,
67 "smb/%u", global
->session_global_id
);
68 strncpy(session
.ip_addr_str
,
69 global
->channels
[0].remote_address
,
72 session
.encryption_flags
= global
->encryption_flags
;
73 session
.cipher
= global
->channels
[0].encryption_cipher
;
74 session
.signing_flags
= global
->signing_flags
;
76 return state
->fn(NULL
, &session
, state
->private_data
);
79 NTSTATUS
sessionid_traverse_read(int (*fn
)(const char *key
,
80 struct sessionid
*session
,
84 struct sessionid_traverse_read_state state
;
88 state
.private_data
= private_data
;
89 status
= smbXsrv_session_global_traverse(sessionid_traverse_read_fn
,