From bece9417d2e232e5b13ea340c79430bb9680eb8a Mon Sep 17 00:00:00 2001 From: Simo Sorce Date: Wed, 23 Mar 2005 20:57:03 +0000 Subject: r6004: Let's make server manager able to kill a user session. This will send a shutdown command to the right process by pid read from the sessions list. (This used to be commit 5d3d025db757f7d48f241142a60a93214f2b47ea) --- source3/rpc_server/srv_srvsvc.c | 29 +++++++++++++++++++++++++ source3/rpc_server/srv_srvsvc_nt.c | 43 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 72 insertions(+) (limited to 'source3/rpc_server') diff --git a/source3/rpc_server/srv_srvsvc.c b/source3/rpc_server/srv_srvsvc.c index 9d85088e56..0b4eac5cc7 100644 --- a/source3/rpc_server/srv_srvsvc.c +++ b/source3/rpc_server/srv_srvsvc.c @@ -165,6 +165,34 @@ static BOOL api_srv_net_sess_enum(pipes_struct *p) return True; } +/******************************************************************* + Delete session. +********************************************************************/ + +static BOOL api_srv_net_sess_del(pipes_struct *p) +{ + SRV_Q_NET_SESS_DEL q_u; + SRV_R_NET_SESS_DEL r_u; + prs_struct *data = &p->in_data.data; + prs_struct *rdata = &p->out_data.rdata; + + ZERO_STRUCT(q_u); + ZERO_STRUCT(r_u); + + /* grab the net server get enum */ + if (!srv_io_q_net_sess_del("", &q_u, data, 0)) + return False; + + /* construct reply. always indicate success */ + r_u.status = _srv_net_sess_del(p, &q_u, &r_u); + + /* store the response in the SMB stream */ + if (!srv_io_r_net_sess_del("", &r_u, rdata, 0)) + return False; + + return True; +} + /******************************************************************* RPC to enumerate shares. ********************************************************************/ @@ -530,6 +558,7 @@ static struct api_struct api_srv_cmds[] = { { "SRV_NET_CONN_ENUM" , SRV_NET_CONN_ENUM , api_srv_net_conn_enum }, { "SRV_NET_SESS_ENUM" , SRV_NET_SESS_ENUM , api_srv_net_sess_enum }, + { "SRV_NET_SESS_DEL" , SRV_NET_SESS_DEL , api_srv_net_sess_del }, { "SRV_NET_SHARE_ENUM_ALL" , SRV_NET_SHARE_ENUM_ALL , api_srv_net_share_enum_all }, { "SRV_NET_SHARE_ENUM" , SRV_NET_SHARE_ENUM , api_srv_net_share_enum }, { "SRV_NET_SHARE_ADD" , SRV_NET_SHARE_ADD , api_srv_net_share_add }, diff --git a/source3/rpc_server/srv_srvsvc_nt.c b/source3/rpc_server/srv_srvsvc_nt.c index 13e1971925..8bcb5c82ac 100644 --- a/source3/rpc_server/srv_srvsvc_nt.c +++ b/source3/rpc_server/srv_srvsvc_nt.c @@ -1348,6 +1348,49 @@ WERROR _srv_net_sess_enum(pipes_struct *p, SRV_Q_NET_SESS_ENUM *q_u, SRV_R_NET_S return r_u->status; } +/******************************************************************* +net sess del +********************************************************************/ + +WERROR _srv_net_sess_del(pipes_struct *p, SRV_Q_NET_SESS_DEL *q_u, SRV_R_NET_SESS_DEL *r_u) +{ + struct sessionid *session_list; + int num_sessions, snum, ret; + fstring username; + fstring machine; + + rpcstr_pull_unistr2_fstring(username, &q_u->uni_user_name); + rpcstr_pull_unistr2_fstring(machine, &q_u->uni_cli_name); + + /* strip leading backslashes if any */ + while (machine[0] == '\\') { + memmove(machine, &machine[1], strlen(machine)); + } + + num_sessions = list_sessions(&session_list); + + DEBUG(5,("_srv_net_sess_del: %d\n", __LINE__)); + + r_u->status = WERR_ACCESS_DENIED; + + for (snum = 0; snum < num_sessions; snum++) { + + if ((StrCaseCmp(session_list[snum].username, username) == 0 || username[0] == '\0' ) && + StrCaseCmp(session_list[snum].remote_machine, machine) == 0) { + + if ((ret = message_send_pid(session_list[snum].pid, MSG_SHUTDOWN, NULL, 0, False))) { + r_u->status = WERR_OK; + } else { + r_u->status = WERR_ACCESS_DENIED; + } + } + } + + DEBUG(5,("_srv_net_sess_del: %d\n", __LINE__)); + + return r_u->status; +} + /******************************************************************* Net share enum all. ********************************************************************/ -- cgit