diff options
author | Simo Sorce <idra@samba.org> | 2001-08-23 23:25:34 +0000 |
---|---|---|
committer | Simo Sorce <idra@samba.org> | 2001-08-23 23:25:34 +0000 |
commit | 8ef7ddba65f326df69d3ff247491a0df1fa89578 (patch) | |
tree | db8d4a3598f771de03ce2a56e14bc04e8f350858 /source3/rpc_server/srv_reg_nt.c | |
parent | c50da047a1a7c64d3017f9d4b12391f384205072 (diff) | |
download | samba-8ef7ddba65f326df69d3ff247491a0df1fa89578.tar.gz samba-8ef7ddba65f326df69d3ff247491a0df1fa89578.tar.xz samba-8ef7ddba65f326df69d3ff247491a0df1fa89578.zip |
so let admins shutdown their samba servers remotely if they want :-)
(This used to be commit 6391fd7bdab07c83e9eed02e761db09918e60302)
Diffstat (limited to 'source3/rpc_server/srv_reg_nt.c')
-rw-r--r-- | source3/rpc_server/srv_reg_nt.c | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/source3/rpc_server/srv_reg_nt.c b/source3/rpc_server/srv_reg_nt.c index 3ed673c68a0..a467e529cbb 100644 --- a/source3/rpc_server/srv_reg_nt.c +++ b/source3/rpc_server/srv_reg_nt.c @@ -177,3 +177,47 @@ uint32 _reg_info(pipes_struct *p, REG_Q_INFO *q_u, REG_R_INFO *r_u) return status; } + +/******************************************************************* + reg_shutdwon + ********************************************************************/ + +#define SHUTDOWN_R_STRING "-r" +#define SHUTDOWN_F_STRING "-f" + + +uint32 _reg_shutdown(pipes_struct *p, REG_Q_SHUTDOWN *q_u, REG_R_SHUTDOWN *r_u) +{ + uint32 status = NT_STATUS_NOPROBLEMO; + pstring shutdown_script; + UNISTR2 unimsg = q_u->uni_msg; + pstring message; + fstring timeout; + fstring r; + fstring f; + + rpcstr_pull (message, unimsg.buffer, sizeof(message), unimsg.uni_str_len*2,0); + snprintf(timeout, sizeof(timeout), "%d", q_u->timeout); + if ((q_u->flags) & 0x100) /* reboot */ + snprintf(r, sizeof(r), SHUTDOWN_R_STRING); + if ((q_u->flags) & 0x001) /* force */ + snprintf(f, sizeof(f), SHUTDOWN_F_STRING); + + pstrcpy(shutdown_script, lp_shutdown_script()); + + if (!*shutdown_script) { + pstrcpy(shutdown_script, lp_shutdown_script()); + } + + if(*shutdown_script) { + int shutdown_ret; + all_string_sub(shutdown_script, "%m", message, sizeof(shutdown_script)); + all_string_sub(shutdown_script, "%t", timeout, sizeof(shutdown_script)); + all_string_sub(shutdown_script, "%r", r, sizeof(shutdown_script)); + all_string_sub(shutdown_script, "%f", f, sizeof(shutdown_script)); + shutdown_ret = smbrun(shutdown_script,NULL); + DEBUG(3,("_reg_shutdown: Running the command `%s' gave %d\n",shutdown_script,shutdown_ret)); + } + + return status; +} |