r23271: merge service control pidl change for CloseServiceHandle() from SAMBA_3_0_26
[obnox/samba/samba-obnox.git] / source / rpc_server / srv_svcctl.c
index 74ae3aaa16fde92f237270f3b1bb1419fb837079..e36df7ac93b9e96fa49f4ced4c408ce5d2305d75 100644 (file)
@@ -1,7 +1,7 @@
 /* 
  *  Unix SMB/CIFS implementation.
  *  RPC Pipe client / server routines
- *  Copyright (C) Gerald Carter                   2005.
+ *  Copyright (C) Gerald Carter                   2005 - 2007
  *  
  *  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
 #undef DBGC_CLASS
 #define DBGC_CLASS DBGC_RPC_SRV
 
-/*******************************************************************
- ********************************************************************/
-
-static BOOL api_svcctl_close_service(pipes_struct *p)
+static BOOL proxy_svcctl_call(pipes_struct *p, uint8 opnum)
 {
-       SVCCTL_Q_CLOSE_SERVICE q_u;
-       SVCCTL_R_CLOSE_SERVICE r_u;
-       prs_struct *data = &p->in_data.data;
-       prs_struct *rdata = &p->out_data.rdata;
+       struct api_struct *fns;
+       int n_fns;
 
-       ZERO_STRUCT(q_u);
-       ZERO_STRUCT(r_u);
+       svcctl_get_pipe_fns(&fns, &n_fns);
 
-       if(!svcctl_io_q_close_service("", &q_u, data, 0))
+       if (opnum >= n_fns)
                return False;
 
-       r_u.status = _svcctl_close_service(p, &q_u, &r_u);
+       if (fns[opnum].opnum != opnum) {
+               smb_panic("SVCCTL function table not sorted\n");
+       }
 
-       if(!svcctl_io_r_close_service("", &r_u, rdata, 0))
-               return False;
+       return fns[opnum].fn(p);
+}
 
-       return True;
+
+/*******************************************************************
+ ********************************************************************/
+
+static BOOL api_svcctl_close_service(pipes_struct *p)
+{
+       return proxy_svcctl_call( p, DCERPC_SVCCTL_CLOSESERVICEHANDLE );
 }
 
 /*******************************************************************
@@ -432,14 +434,15 @@ static struct api_struct api_svcctl_cmds[] =
 };
 
 
-void svcctl_get_pipe_fns( struct api_struct **fns, int *n_fns )
+void svcctl2_get_pipe_fns( struct api_struct **fns, int *n_fns )
 {
-       *fns = api_svcctl_cmds;
+        *fns = api_svcctl_cmds;
        *n_fns = sizeof(api_svcctl_cmds) / sizeof(struct api_struct);
 }
 
-NTSTATUS rpc_svcctl_init(void)
+NTSTATUS rpc_svcctl2_init(void)
 {
-  return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION, "svcctl", "ntsvcs", api_svcctl_cmds,
-                                   sizeof(api_svcctl_cmds) / sizeof(struct api_struct));
+       return rpc_pipe_register_commands(SMB_RPC_INTERFACE_VERSION,
+                                         "svcctl", "ntsvcs", api_svcctl_cmds,
+                                         sizeof(api_svcctl_cmds) / sizeof(struct api_struct));
 }