summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--source3/param/loadparm.c3
-rw-r--r--source3/rpc_server/srv_reg.c28
-rw-r--r--source3/rpc_server/srv_reg_nt.c35
3 files changed, 56 insertions, 10 deletions
diff --git a/source3/param/loadparm.c b/source3/param/loadparm.c
index 682ac7054c..a8365af0eb 100644
--- a/source3/param/loadparm.c
+++ b/source3/param/loadparm.c
@@ -146,6 +146,7 @@ typedef struct
char *szDelUserToGroupScript;
char *szAddMachineScript;
char *szShutdownScript;
+ char *szAbortShutdownScript;
char *szWINSHook;
#ifdef WITH_UTMP
char *szUtmpDir;
@@ -889,6 +890,7 @@ static struct parm_struct parm_table[] = {
{"delete user from group script", P_STRING, P_GLOBAL, &Globals.szDelUserToGroupScript, NULL, NULL, 0},
{"add machine script", P_STRING, P_GLOBAL, &Globals.szAddMachineScript, NULL, NULL, 0},
{"shutdown script", P_STRING, P_GLOBAL, &Globals.szShutdownScript, NULL, NULL, 0},
+ {"abort shutdown script", P_STRING, P_GLOBAL, &Globals.szAbortShutdownScript, NULL, NULL, 0},
{"logon script", P_STRING, P_GLOBAL, &Globals.szLogonScript, NULL, NULL, 0},
{"logon path", P_STRING, P_GLOBAL, &Globals.szLogonPath, NULL, NULL, 0},
@@ -1473,6 +1475,7 @@ FN_GLOBAL_STRING(lp_deluserfromgroup_script, &Globals.szDelUserToGroupScript)
FN_GLOBAL_STRING(lp_addmachine_script, &Globals.szAddMachineScript)
FN_GLOBAL_STRING(lp_shutdown_script, &Globals.szShutdownScript)
+FN_GLOBAL_STRING(lp_abort_shutdown_script, &Globals.szAbortShutdownScript)
FN_GLOBAL_STRING(lp_wins_hook, &Globals.szWINSHook)
FN_GLOBAL_LIST(lp_domain_admin_group, &Globals.szDomainAdminGroup)
diff --git a/source3/rpc_server/srv_reg.c b/source3/rpc_server/srv_reg.c
index 105230a22f..8aa5c4bddf 100644
--- a/source3/rpc_server/srv_reg.c
+++ b/source3/rpc_server/srv_reg.c
@@ -160,6 +160,32 @@ static BOOL api_reg_shutdown(pipes_struct *p)
return True;
}
+/*******************************************************************
+ api_reg_abort_shutdown
+ ********************************************************************/
+
+static BOOL api_reg_abort_shutdown(pipes_struct *p)
+{
+ REG_Q_ABORT_SHUTDOWN q_u;
+ REG_R_ABORT_SHUTDOWN 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 reg shutdown */
+ if(!reg_io_q_abort_shutdown("", &q_u, data, 0))
+ return False;
+
+ r_u.status = _reg_abort_shutdown(p, &q_u, &r_u);
+
+ if(!reg_io_r_abort_shutdown("", &r_u, rdata, 0))
+ return False;
+
+ return True;
+}
+
/*******************************************************************
array of \PIPE\reg operations
@@ -171,7 +197,7 @@ static struct api_struct api_reg_cmds[] =
{ "REG_OPEN" , REG_OPEN_HKLM , api_reg_open },
{ "REG_INFO" , REG_INFO , api_reg_info },
{ "REG_SHUTDOWN" , REG_SHUTDOWN , api_reg_shutdown },
-/* { "REG_ABORT_SHUTDOWN", REG_ABORT_SHUTDOWN, api_reg_abrot_shutdown }, */
+ { "REG_ABORT_SHUTDOWN", REG_ABORT_SHUTDOWN, api_reg_abort_shutdown },
{ NULL, 0 , NULL }
};
diff --git a/source3/rpc_server/srv_reg_nt.c b/source3/rpc_server/srv_reg_nt.c
index a467e529cb..a77f329d4a 100644
--- a/source3/rpc_server/srv_reg_nt.c
+++ b/source3/rpc_server/srv_reg_nt.c
@@ -192,26 +192,27 @@ uint32 _reg_shutdown(pipes_struct *p, REG_Q_SHUTDOWN *q_u, REG_R_SHUTDOWN *r_u)
pstring shutdown_script;
UNISTR2 unimsg = q_u->uni_msg;
pstring message;
+ pstring chkmsg;
fstring timeout;
fstring r;
fstring f;
+ /* message */
rpcstr_pull (message, unimsg.buffer, sizeof(message), unimsg.uni_str_len*2,0);
+ /* security check */
+ alpha_strcpy (chkmsg, message, NULL, sizeof(message);
+ /* timeout */
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);
+ /* reboot */
+ snprintf(r, sizeof(r), (q_u->flags & 0x100)?SHUTDOWN_R_STRING:"");
+ /* force */
+ snprintf(f, sizeof(f), (q_u->flags & 0x001)?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, "%m", chkmsg, 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));
@@ -221,3 +222,19 @@ uint32 _reg_shutdown(pipes_struct *p, REG_Q_SHUTDOWN *q_u, REG_R_SHUTDOWN *r_u)
return status;
}
+
+uint32 _reg_abort_shutdown(pipes_struct *p, REG_Q_ABORT_SHUTDOWN *q_u, REG_R_ABORT_SHUTDOWN *r_u)
+{
+ uint32 status = NT_STATUS_NOPROBLEMO;
+ pstring abort_shutdown_script;
+
+ pstrcpy(abort_shutdown_script, lp_abort_shutdown_script());
+
+ if(*abort_shutdown_script) {
+ int abort_shutdown_ret;
+ abort_shutdown_ret = smbrun(abort_shutdown_script,NULL);
+ DEBUG(3,("_reg_abort_shutdown: Running the command `%s' gave %d\n",abort_shutdown_script,abort_shutdown_ret));
+ }
+
+ return status;
+}