summaryrefslogtreecommitdiff
path: root/source/utils/net.c
diff options
context:
space:
mode:
Diffstat (limited to 'source/utils/net.c')
-rw-r--r--source/utils/net.c68
1 files changed, 63 insertions, 5 deletions
diff --git a/source/utils/net.c b/source/utils/net.c
index 67b138a43be..da1339aed10 100644
--- a/source/utils/net.c
+++ b/source/utils/net.c
@@ -78,6 +78,11 @@ BOOL opt_localgroup = False;
BOOL opt_domaingroup = False;
const char *opt_newntname = "";
int opt_rid = 0;
+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;
@@ -126,12 +131,13 @@ int net_run_function(int argc, const char **argv, struct functable *table,
return usage_fn(argc, argv);
}
-
/****************************************************************************
-connect to \\server\ipc$
+connect to \\server\service
****************************************************************************/
-NTSTATUS connect_to_ipc(struct cli_state **c, struct in_addr *server_ip,
- const char *server_name)
+NTSTATUS connect_to_service(struct cli_state **c, struct in_addr *server_ip,
+ const char *server_name,
+ const char *service_name,
+ const char *service_type)
{
NTSTATUS nt_status;
@@ -144,7 +150,7 @@ NTSTATUS connect_to_ipc(struct cli_state **c, struct in_addr *server_ip,
nt_status = cli_full_connection(c, NULL, server_name,
server_ip, opt_port,
- "IPC$", "IPC",
+ service_name, service_type,
opt_user_name, opt_workgroup,
opt_password, 0, Undefined, NULL);
@@ -171,6 +177,16 @@ NTSTATUS connect_to_ipc(struct cli_state **c, struct in_addr *server_ip,
}
}
+
+/****************************************************************************
+connect to \\server\ipc$
+****************************************************************************/
+NTSTATUS connect_to_ipc(struct cli_state **c, struct in_addr *server_ip,
+ const char *server_name)
+{
+ return connect_to_service(c, server_ip, server_name, "IPC$", "IPC");
+}
+
/****************************************************************************
connect to \\server\ipc$ anonymously
****************************************************************************/
@@ -193,6 +209,42 @@ NTSTATUS connect_to_ipc_anonymous(struct cli_state **c,
}
}
+/**
+ * Connect a server and open a given pipe
+ *
+ * @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_pipe(struct cli_state **cli_dst, int pipe_num, BOOL *got_pipe)
+{
+ NTSTATUS nt_status;
+ char *server_name = strdup("127.0.0.1");
+ struct cli_state *cli_tmp = NULL;
+
+ 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;
+
+ if (!cli_nt_session_open(cli_tmp, pipe_num)) {
+ DEBUG(0, ("couldn't not initialize pipe\n"));
+ cli_shutdown(cli_tmp);
+ return NT_STATUS_UNSUCCESSFUL;
+ }
+
+ *cli_dst = cli_tmp;
+ *got_pipe = True;
+
+ return nt_status;
+}
+
+
/****************************************************************************
Use the local machine's password for this session
****************************************************************************/
@@ -690,6 +742,12 @@ static struct functable net_func[] = {
{"domain", 'D', POPT_ARG_NONE, &opt_domaingroup},
{"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},
+ {"exclude", 'e', POPT_ARG_STRING, &opt_exclude},
+ {"destination", 0, POPT_ARG_STRING, &opt_destination},
POPT_COMMON_SAMBA
{ 0, 0, 0, 0}