r2080: Remove last traces of static migration to localhost. Needed to allow a
authorGünther Deschner <gd@samba.org>
Thu, 26 Aug 2004 21:37:20 +0000 (21:37 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 15:52:30 +0000 (10:52 -0500)
local netbios-alias bound to non-loopback interface as a migration target.

It's now possible to migrate printers|shares|files from Server A to
Server B while running the net-command on client C.

Guenther
(This used to be commit 0cfd2866dfe5e959ede169a77c39480790300de3)

source3/utils/net.c
source3/utils/net.h
source3/utils/net_rpc.c
source3/utils/net_rpc_printer.c

index 2c7ee7a224c999a30480465932a92acd982d2491..da1339aed10c132cdc2cd472d9c63b02592bf0d9 100644 (file)
@@ -82,6 +82,7 @@ int opt_acls = 0;
 int opt_attrs = 0;
 int opt_timestamps = 0;
 const char *opt_exclude = NULL;
+const char *opt_destination = NULL;
 
 BOOL opt_have_ip = False;
 struct in_addr opt_dest_ip;
@@ -209,23 +210,25 @@ NTSTATUS connect_to_ipc_anonymous(struct cli_state **c,
 }
 
 /**
- * Connect the local server and open a given pipe
+ * Connect a server and open a given pipe
  *
- * @param cli_local            A cli_state 
+ * @param cli_dst              A cli_state 
  * @param pipe                 The pipe to open
  * @param got_pipe             boolean that stores if we got a pipe
  *
  * @return Normal NTSTATUS return.
  **/
-NTSTATUS connect_local_pipe(struct cli_state **cli_local, int pipe_num, BOOL *got_pipe)
+NTSTATUS connect_pipe(struct cli_state **cli_dst, int pipe_num, BOOL *got_pipe)
 {
        NTSTATUS nt_status;
-       extern struct in_addr loopback_ip;
        char *server_name = strdup("127.0.0.1");
        struct cli_state *cli_tmp = NULL;
 
-       /* make a connection to local named pipe via loopback */
-       nt_status = connect_to_ipc(&cli_tmp, &loopback_ip, server_name);
+       if (opt_destination)
+               server_name = strdup(opt_destination);
+
+       /* make a connection to a named pipe */
+       nt_status = connect_to_ipc(&cli_tmp, NULL, server_name);
        if (!NT_STATUS_IS_OK(nt_status)) 
                return nt_status;
 
@@ -235,7 +238,7 @@ NTSTATUS connect_local_pipe(struct cli_state **cli_local, int pipe_num, BOOL *go
                return NT_STATUS_UNSUCCESSFUL;
        }
 
-       *cli_local = cli_tmp;
+       *cli_dst = cli_tmp;
        *got_pipe = True;
 
        return nt_status;
@@ -740,10 +743,11 @@ static struct functable net_func[] = {
                {"ntname",      'N', POPT_ARG_STRING, &opt_newntname},
                {"rid",         'R', POPT_ARG_INT,    &opt_rid},
                /* Options for 'net rpc share migrate' */
-               {"acls",        0, POPT_ARG_NONE,   &opt_acls},
-               {"attrs",       0, POPT_ARG_NONE,   &opt_attrs},
-               {"timestamps",  0, POPT_ARG_NONE,   &opt_timestamps},
+               {"acls",        0, POPT_ARG_NONE,     &opt_acls},
+               {"attrs",       0, POPT_ARG_NONE,     &opt_attrs},
+               {"timestamps",  0, POPT_ARG_NONE,     &opt_timestamps},
                {"exclude",     'e', POPT_ARG_STRING, &opt_exclude},
+               {"destination", 0, POPT_ARG_STRING,   &opt_destination},
 
                POPT_COMMON_SAMBA
                { 0, 0, 0, 0}
index 29498b9108514f5b8ca180698aa60c7b858cc26e..d75a19e498ee19eb603cca8ae634c5f865457ca5 100644 (file)
@@ -66,6 +66,7 @@ extern int opt_acls;
 extern int opt_attrs;
 extern int opt_timestamps;
 extern const char *opt_exclude;
+extern const char *opt_destination;
 
 extern BOOL opt_have_ip;
 extern struct in_addr opt_dest_ip;
index 26bcb51fa5ee008ccd5643139b7d6adb365f16c7..1a1d76b09a0042059dce79cf9168debd060fc440 100644 (file)
@@ -2534,7 +2534,7 @@ rpc_share_migrate_shares_internals(const DOM_SID *domain_sid, const char *domain
                goto done;
 
        /* connect local PI_SRVSVC */
-        nt_status = connect_local_pipe(&cli_dst, PI_SRVSVC, &got_dst_srvsvc_pipe);
+        nt_status = connect_pipe(&cli_dst, PI_SRVSVC, &got_dst_srvsvc_pipe);
         if (!NT_STATUS_IS_OK(nt_status))
                 return nt_status;
 
@@ -2802,7 +2802,9 @@ rpc_share_migrate_files_internals(const DOM_SID *domain_sid, const char *domain_
        BOOL got_src_share = False;
        BOOL got_dst_share = False;
        pstring mask;
-       extern struct in_addr loopback_ip;
+       char *dst = NULL;
+
+       dst = strdup(opt_destination?opt_destination:"127.0.0.1");
 
        init_enum_hnd(&hnd, 0);
 
@@ -2872,8 +2874,8 @@ rpc_share_migrate_files_internals(const DOM_SID *domain_sid, const char *domain_
 
 
                /* open share destination */
-               nt_status = connect_to_service(&cli_share_dst, &loopback_ip
-                                              "127.0.0.1", netname, "A:");
+               nt_status = connect_to_service(&cli_share_dst, NULL
+                                              dst, netname, "A:");
                if (!NT_STATUS_IS_OK(nt_status))
                        goto done;
 
index b414b38a79d6837bda264e4cf3c624d9cf04d9e2..11f9c0ba2f3e95e3e3e7b8a4005a3d0784a4ac41 100644 (file)
@@ -1324,13 +1324,13 @@ NTSTATUS rpc_printer_migrate_security_internals(const DOM_SID *domain_sid, const
 
        DEBUG(3,("copying printer ACLs\n"));
 
-       /* connect local PI_SPOOLSS */
-       nt_status = connect_local_pipe(&cli_dst, PI_SPOOLSS, &got_dst_spoolss_pipe);
+       /* connect destination PI_SPOOLSS */
+       nt_status = connect_pipe(&cli_dst, PI_SPOOLSS, &got_dst_spoolss_pipe);
        if (!NT_STATUS_IS_OK(nt_status))
                return nt_status;
 
 
-       /* enum remote printers */
+       /* enum source printers */
        if (!get_printer_info(cli, mem_ctx, level, argc, argv, &num_printers, &ctr_enum)) {
                nt_status = NT_STATUS_UNSUCCESSFUL;
                goto done;
@@ -1474,8 +1474,8 @@ NTSTATUS rpc_printer_migrate_forms_internals(const DOM_SID *domain_sid, const ch
 
        DEBUG(3,("copying forms\n"));
        
-       /* connect local PI_SPOOLSS */
-       nt_status = connect_local_pipe(&cli_dst, PI_SPOOLSS, &got_dst_spoolss_pipe);
+       /* connect destination PI_SPOOLSS */
+       nt_status = connect_pipe(&cli_dst, PI_SPOOLSS, &got_dst_spoolss_pipe);
        if (!NT_STATUS_IS_OK(nt_status))
                return nt_status;
        
@@ -1656,7 +1656,7 @@ NTSTATUS rpc_printer_migrate_drivers_internals(const DOM_SID *domain_sid, const
 
        DEBUG(3,("copying printer-drivers\n"));
 
-       nt_status = connect_local_pipe(&cli_dst, PI_SPOOLSS, &got_dst_spoolss_pipe);
+       nt_status = connect_pipe(&cli_dst, PI_SPOOLSS, &got_dst_spoolss_pipe);
        if (!NT_STATUS_IS_OK(nt_status))
                return nt_status;
        
@@ -1855,8 +1855,8 @@ NTSTATUS rpc_printer_migrate_printers_internals(const DOM_SID *domain_sid, const
 
        DEBUG(3,("copying printers\n"));
 
-       /* connect local PI_SPOOLSS */
-       nt_status = connect_local_pipe(&cli_dst, PI_SPOOLSS, &got_dst_spoolss_pipe);
+       /* connect destination PI_SPOOLSS */
+       nt_status = connect_pipe(&cli_dst, PI_SPOOLSS, &got_dst_spoolss_pipe);
        if (!NT_STATUS_IS_OK(nt_status))
                return nt_status;
 
@@ -2024,8 +2024,8 @@ NTSTATUS rpc_printer_migrate_settings_internals(const DOM_SID *domain_sid, const
 
        DEBUG(3,("copying printer settings\n"));
 
-       /* connect local PI_SPOOLSS */
-       nt_status = connect_local_pipe(&cli_dst, PI_SPOOLSS, &got_dst_spoolss_pipe);
+       /* connect destination PI_SPOOLSS */
+       nt_status = connect_pipe(&cli_dst, PI_SPOOLSS, &got_dst_spoolss_pipe);
        if (!NT_STATUS_IS_OK(nt_status))
                return nt_status;