diff options
author | Simo Sorce <idra@samba.org> | 2005-03-23 20:57:03 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 10:56:15 -0500 |
commit | bece9417d2e232e5b13ea340c79430bb9680eb8a (patch) | |
tree | 37b9c30816909d8c4706744b3017fe67dfe30ffc | |
parent | 8b6a50cf3ecad43fbb70b778983231d7ec5adbbc (diff) | |
download | samba-bece9417d2e232e5b13ea340c79430bb9680eb8a.tar.gz samba-bece9417d2e232e5b13ea340c79430bb9680eb8a.tar.bz2 samba-bece9417d2e232e5b13ea340c79430bb9680eb8a.zip |
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)
-rw-r--r-- | source3/include/rpc_srvsvc.h | 22 | ||||
-rw-r--r-- | source3/rpc_parse/parse_srv.c | 73 | ||||
-rw-r--r-- | source3/rpc_server/srv_srvsvc.c | 29 | ||||
-rw-r--r-- | source3/rpc_server/srv_srvsvc_nt.c | 43 |
4 files changed, 167 insertions, 0 deletions
diff --git a/source3/include/rpc_srvsvc.h b/source3/include/rpc_srvsvc.h index 5ebb77a8c2..f84054b878 100644 --- a/source3/include/rpc_srvsvc.h +++ b/source3/include/rpc_srvsvc.h @@ -29,6 +29,7 @@ #define SRV_NET_FILE_ENUM 0x09 #define SRV_NET_FILE_CLOSE 0x0b #define SRV_NET_SESS_ENUM 0x0c +#define SRV_NET_SESS_DEL 0x0d #define SRV_NET_SHARE_ADD 0x0e #define SRV_NET_SHARE_ENUM_ALL 0x0f #define SRV_NET_SHARE_GET_INFO 0x10 @@ -193,6 +194,27 @@ typedef struct r_net_sess_enum_info } SRV_R_NET_SESS_ENUM; +/* SRV_Q_NET_SESS_DEL */ +typedef struct q_net_sess_del +{ + uint32 ptr_srv_name; /* pointer (to server name?) */ + UNISTR2 uni_srv_name; /* server name */ + + uint32 ptr_cli_name; /* pointer (to qualifier name) */ + UNISTR2 uni_cli_name; /* qualifier name "\\qualifier" */ + + uint32 ptr_user_name; /* pointer (to user name */ + UNISTR2 uni_user_name; /* user name */ + +} SRV_Q_NET_SESS_DEL; + +/* SRV_R_NET_SESS_DEL */ +typedef struct r_net_sess_del +{ + WERROR status; /* return status */ + +} SRV_R_NET_SESS_DEL; + /* CONN_INFO_0 (pointers to level 0 connection info strings) */ typedef struct ptr_conn_info0 { diff --git a/source3/rpc_parse/parse_srv.c b/source3/rpc_parse/parse_srv.c index 84c45b5901..7d15eda630 100644 --- a/source3/rpc_parse/parse_srv.c +++ b/source3/rpc_parse/parse_srv.c @@ -1996,6 +1996,79 @@ BOOL srv_io_r_net_sess_enum(const char *desc, SRV_R_NET_SESS_ENUM *r_n, prs_stru } /******************************************************************* + Inits a SRV_Q_NET_SESS_DEL structure. +********************************************************************/ + +void init_srv_q_net_sess_del(SRV_Q_NET_SESS_DEL *q_n, const char *srv_name, + const char *cli_name, const char *user_name) +{ + DEBUG(5,("init_q_net_sess_enum\n")); + + init_buf_unistr2(&q_n->uni_srv_name, &q_n->ptr_srv_name, srv_name); + init_buf_unistr2(&q_n->uni_cli_name, &q_n->ptr_cli_name, cli_name); + init_buf_unistr2(&q_n->uni_user_name, &q_n->ptr_user_name, user_name); +} + +/******************************************************************* + Reads or writes a structure. +********************************************************************/ + +BOOL srv_io_q_net_sess_del(const char *desc, SRV_Q_NET_SESS_DEL *q_n, prs_struct *ps, int depth) +{ + if (q_n == NULL) + return False; + + prs_debug(ps, depth, desc, "srv_io_q_net_sess_del"); + depth++; + + if(!prs_align(ps)) + return False; + + if(!prs_uint32("ptr_srv_name", ps, depth, &q_n->ptr_srv_name)) + return False; + if(!smb_io_unistr2("", &q_n->uni_srv_name, True, ps, depth)) + return False; + + if(!prs_align(ps)) + return False; + + if(!prs_uint32("ptr_cli_name", ps, depth, &q_n->ptr_cli_name)) + return False; + if(!smb_io_unistr2("", &q_n->uni_cli_name, q_n->ptr_cli_name, ps, depth)) + return False; + + if(!prs_align(ps)) + return False; + if(!prs_uint32("ptr_user_name", ps, depth, &q_n->ptr_user_name)) + return False; + if(!smb_io_unistr2("", &q_n->uni_user_name, q_n->ptr_user_name, ps, depth)) + return False; + + return True; +} + +/******************************************************************* + Reads or writes a structure. +********************************************************************/ + +BOOL srv_io_r_net_sess_del(const char *desc, SRV_R_NET_SESS_DEL *r_n, prs_struct *ps, int depth) +{ + if (r_n == NULL) + return False; + + prs_debug(ps, depth, desc, "srv_io_r_net_sess_del"); + depth++; + + if(!prs_align(ps)) + return False; + + if(!prs_werror("status", ps, depth, &r_n->status)) + return False; + + return True; +} + +/******************************************************************* Inits a CONN_INFO_0 structure ********************************************************************/ 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 @@ -166,6 +166,34 @@ static BOOL api_srv_net_sess_enum(pipes_struct *p) } /******************************************************************* + 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 @@ -1349,6 +1349,49 @@ WERROR _srv_net_sess_enum(pipes_struct *p, SRV_Q_NET_SESS_ENUM *q_u, SRV_R_NET_S } /******************************************************************* +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. ********************************************************************/ |