Move dcerpc_init() to svcinstall.c
authorThomas Hood <jdthood@gmail.com>
Tue, 6 Sep 2011 14:00:00 +0000 (16:00 +0200)
committerThomas Hood <jdthood@gmail.com>
Tue, 6 Sep 2011 14:00:00 +0000 (16:00 +0200)
source/svcinstall.c
source/winexe.c

index d04b3f04d9761c6470bbde26aef968676107183f..18fbc007c7ea40df38dcd66e4e37ef74980a1f94 100644 (file)
 #define NT_ERR(status, lvl, args...) if (!NT_STATUS_IS_OK(status)) { DEBUG(lvl,("ERROR: " args)); DEBUG(lvl,(". %s.\n", nt_errstr(status))); return status; }
 #define NT_RES(status, werr) (NT_STATUS_IS_OK(status) ? werror_to_ntstatus(werr) : status)
 
+static void svc_dcerpc_init_once()
+{
+       static int initialized = 0;
+
+       if (!initialized) {
+               dcerpc_init();
+               initialized = 1;
+       }
+}
+
 static NTSTATUS svc_pipe_connect(struct tevent_context *ev_ctx, 
                           struct dcerpc_pipe **psvc_pipe,
                          const char *hostname,
@@ -43,6 +53,7 @@ static NTSTATUS svc_pipe_connect(struct tevent_context *ev_ctx,
        char *binding;
 
        asprintf(&binding, "ncacn_np:%s%s", hostname, DEBUGLVL(9)?"[print]":"");
+       svc_dcerpc_init_once();
        status =
            dcerpc_pipe_connect(NULL, psvc_pipe, binding,
                                &ndr_table_svcctl, credentials, ev_ctx, cmdline_lp_ctx);
index ba6298f11e2025af88b0a867d63e9101fa8d5cd9..8b9f10e8078544585b74aa8af58239178e387a68 100644 (file)
@@ -389,8 +389,6 @@ int main(int argc, char *argv[])
        DEBUG(1, (version_string, VERSION_MAJOR, VERSION_MINOR));
        ev_ctx = s4_event_context_init(talloc_autofree_context());
 
-       dcerpc_init();
-
        if (options.flags & SVC_FORCE_UPLOAD)
                svc_uninstall(ev_ctx, options.hostname, SERVICE_NAME, SERVICE_FILENAME, cmdline_credentials);