2010-03-01 18:18:23 +03:00
/*
Unix SMB / CIFS implementation .
Low - level sessionid . tdb access functions
Copyright ( C ) Volker Lendecke 2010
This program is free software ; you can redistribute it and / or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation ; either version 3 of the License , or
( at your option ) any later version .
This program is distributed in the hope that it will be useful ,
but WITHOUT ANY WARRANTY ; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE . See the
GNU General Public License for more details .
You should have received a copy of the GNU General Public License
along with this program . If not , see < http : //www.gnu.org/licenses/>.
*/
# include "includes.h"
2011-02-26 01:20:06 +03:00
# include "system/filesys.h"
2011-07-07 19:42:08 +04:00
# include "dbwrap/dbwrap.h"
2011-07-06 18:40:21 +04:00
# include "dbwrap/dbwrap_open.h"
2011-02-25 01:14:15 +03:00
# include "session.h"
2011-05-05 13:25:29 +04:00
# include "util_tdb.h"
2012-08-23 12:36:59 +04:00
# include "smbd/globals.h"
2010-03-01 18:18:23 +03:00
struct sessionid_traverse_read_state {
int ( * fn ) ( const char * key , struct sessionid * session ,
void * private_data ) ;
void * private_data ;
} ;
2012-08-23 12:36:59 +04:00
static int sessionid_traverse_read_fn ( struct smbXsrv_session_global0 * global ,
2010-03-01 18:18:23 +03:00
void * private_data )
{
struct sessionid_traverse_read_state * state =
( struct sessionid_traverse_read_state * ) private_data ;
2012-08-23 12:36:59 +04:00
struct auth_session_info * session_info = global - > auth_session_info ;
struct sessionid session = {
2013-07-05 15:19:59 +04:00
. uid = - 1 ,
. gid = - 1 ,
2012-08-23 12:36:59 +04:00
. id_num = global - > session_global_id ,
. connect_start = nt_time_to_unix ( global - > creation_time ) ,
. pid = global - > channels [ 0 ] . server_id ,
2015-11-30 12:48:12 +03:00
. connection_dialect = global - > connection_dialect ,
2012-08-23 12:36:59 +04:00
} ;
2013-07-05 15:19:59 +04:00
if ( session_info ! = NULL ) {
session . uid = session_info - > unix_token - > uid ;
session . gid = session_info - > unix_token - > gid ;
strncpy ( session . username ,
session_info - > unix_info - > unix_name ,
sizeof ( fstring ) - 1 ) ;
}
2012-08-23 12:36:59 +04:00
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 ) ;
2015-11-09 19:17:17 +03:00
session . encryption_flags = global - > encryption_flags ;
session . cipher = global - > channels [ 0 ] . encryption_cipher ;
2015-11-30 13:20:43 +03:00
session . signing_flags = global - > signing_flags ;
2015-11-09 19:17:17 +03:00
2012-08-23 12:36:59 +04:00
return state - > fn ( NULL , & session , state - > private_data ) ;
2010-03-01 18:18:23 +03:00
}
2011-08-17 12:33:58 +04:00
NTSTATUS sessionid_traverse_read ( int ( * fn ) ( const char * key ,
struct sessionid * session ,
void * private_data ) ,
void * private_data )
2010-03-01 18:18:23 +03:00
{
struct sessionid_traverse_read_state state ;
2011-08-17 12:33:58 +04:00
NTSTATUS status ;
2010-03-01 18:18:23 +03:00
state . fn = fn ;
state . private_data = private_data ;
2012-08-23 12:36:59 +04:00
status = smbXsrv_session_global_traverse ( sessionid_traverse_read_fn ,
& state ) ;
2011-08-17 12:33:58 +04:00
return status ;
2010-03-01 18:18:23 +03:00
}