1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-23 17:34:34 +03:00
samba-mirror/source3/lib/sessionid_tdb.c
Ralph Wuerthner e139f19327 s3: add suport for SMB3_10 and SMB3_11 protocols in smbstatus
BUG: https://bugzilla.samba.org/show_bug.cgi?id=11472

Signed-off-by: Ralph Wuerthner <ralph.wuerthner@de.ibm.com>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>

Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Sat Aug 29 07:05:10 CEST 2015 on sn-devel-104
2015-08-29 07:05:10 +02:00

123 lines
3.5 KiB
C

/*
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"
#include "system/filesys.h"
#include "dbwrap/dbwrap.h"
#include "dbwrap/dbwrap_open.h"
#include "session.h"
#include "util_tdb.h"
#include "smbd/globals.h"
struct sessionid_traverse_read_state {
int (*fn)(const char *key, struct sessionid *session,
void *private_data);
void *private_data;
};
static int sessionid_traverse_read_fn(struct smbXsrv_session_global0 *global,
void *private_data)
{
struct sessionid_traverse_read_state *state =
(struct sessionid_traverse_read_state *)private_data;
struct auth_session_info *session_info = global->auth_session_info;
struct sessionid session = {
.uid = -1,
.gid = -1,
.id_num = global->session_global_id,
.connect_start = nt_time_to_unix(global->creation_time),
.pid = global->channels[0].server_id,
};
switch(global->connection_dialect){
case SMB2_DIALECT_REVISION_000:
fstrcpy(session.protocol_ver, "NT1");
break;
case SMB2_DIALECT_REVISION_202:
fstrcpy(session.protocol_ver, "SMB2_02");
break;
case SMB2_DIALECT_REVISION_210:
fstrcpy(session.protocol_ver, "SMB2_10");
break;
case SMB2_DIALECT_REVISION_222:
fstrcpy(session.protocol_ver, "SMB2_22");
break;
case SMB2_DIALECT_REVISION_224:
fstrcpy(session.protocol_ver, "SMB2_24");
break;
case SMB3_DIALECT_REVISION_300:
fstrcpy(session.protocol_ver, "SMB3_00");
break;
case SMB3_DIALECT_REVISION_302:
fstrcpy(session.protocol_ver, "SMB3_02");
break;
case SMB3_DIALECT_REVISION_310:
fstrcpy(session.protocol_ver, "SMB3_10");
break;
case SMB3_DIALECT_REVISION_311:
fstrcpy(session.protocol_ver, "SMB3_11");
break;
default:
fstr_sprintf(session.protocol_ver, "Unknown (0x%04x)",
global->connection_dialect);
break;
}
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);
}
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,
struct sessionid *session,
void *private_data),
void *private_data)
{
struct sessionid_traverse_read_state state;
NTSTATUS status;
state.fn = fn;
state.private_data = private_data;
status = smbXsrv_session_global_traverse(sessionid_traverse_read_fn,
&state);
return status;
}