summaryrefslogtreecommitdiff
path: root/source3/utils/net.c
diff options
context:
space:
mode:
authorGünther Deschner <gd@samba.org>2004-08-10 14:27:17 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 10:52:19 -0500
commit60727acc3b33cb90309a43c10813fadcb94142eb (patch)
treeaeb0de9b905f2b7368912481f8ec3e06f0870f92 /source3/utils/net.c
parent16de9d9711d5de8b2877b367e1d86ad3844d5d09 (diff)
downloadsamba-60727acc3b33cb90309a43c10813fadcb94142eb.tar.gz
samba-60727acc3b33cb90309a43c10813fadcb94142eb.tar.bz2
samba-60727acc3b33cb90309a43c10813fadcb94142eb.zip
r1692: first commit :)
* add IA64 to the architecture table of printer-drivers * add new "net"-subcommands: net rpc printer migrate {drivers|printers|forms|security|settings|all} [printer] net rpc share migrate {shares|files|all} [share] this is the first part of the migration suite. this will will (once feature-complete) allow to do 1:1 server-cloning in the best possible way by making heavy use of samba's rpc_client-functions. all migration-steps are implemented as rpc/smb-client-calls; net communicates via rpc/smb with two servers at the same time (a remote, source server and a destination server that currently defaults to the local smbd). this allows e. g. printer-driver migration including driverfiles, recursive mirroring of file-shares including file-acls, etc. almost any migration step can be called with a migrate-subcommand to provide more flexibility during a migration process (at the cost of quite some redundancy :) ). "net rpc printer migrate settings" is still in a bad condition (many open questions that hopefully can be adressed soon). "net rpc share migrate security" as an isolated call to just migrate share-ACLs will be added later. Before playing with it, make sure to use a test-server. Migration is a serious business and this tool-set can perfectly overwrite your existing file/print-shares. * along with the migration functions had to make I the following changes: - implement setprinter level 3 client-side - implement net_add_share level 502 client-side - allow security descriptor to be set in setprinterdata level 2 serverside guenther (This used to be commit 8f1716a29b7e85baf738bc14df7dabf03762f723)
Diffstat (limited to 'source3/utils/net.c')
-rw-r--r--source3/utils/net.c60
1 files changed, 55 insertions, 5 deletions
diff --git a/source3/utils/net.c b/source3/utils/net.c
index 67b138a43b..30e94ac8a1 100644
--- a/source3/utils/net.c
+++ b/source3/utils/net.c
@@ -78,6 +78,8 @@ BOOL opt_localgroup = False;
BOOL opt_domaingroup = False;
const char *opt_newntname = "";
int opt_rid = 0;
+int opt_acls = 0;
+const char *opt_exclude = NULL;
BOOL opt_have_ip = False;
struct in_addr opt_dest_ip;
@@ -126,12 +128,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 +147,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 +174,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 +206,40 @@ NTSTATUS connect_to_ipc_anonymous(struct cli_state **c,
}
}
+/**
+ * Connect the local server and open a given pipe
+ *
+ * @param cli_local A cli_state to the local spoolss-server
+ * @param pipe The pipe to open
+ * @param got_pipe boolean to that stores if got a pipe
+ *
+ * @return Normal NTSTATUS return.
+ **/
+NTSTATUS connect_local_pipe(struct cli_state **cli_local, int pipe, 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 smbd via loopback */
+ nt_status = connect_to_ipc(&cli_tmp, &loopback_ip, server_name);
+ if (!NT_STATUS_IS_OK(nt_status))
+ return nt_status;
+
+ if (!cli_nt_session_open(cli_tmp, pipe)) {
+ DEBUG(0, ("couldn't not initialise spoolss pipe\n"));
+ cli_shutdown(cli_tmp);
+ return NT_STATUS_UNSUCCESSFUL;
+ }
+
+ *cli_local = cli_tmp;
+ *got_pipe = True;
+
+ return nt_status;
+}
+
+
/****************************************************************************
Use the local machine's password for this session
****************************************************************************/
@@ -690,6 +737,9 @@ 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", 'a', POPT_ARG_NONE, &opt_acls},
+ {"exclude", 'e', POPT_ARG_STRING, &opt_exclude},
POPT_COMMON_SAMBA
{ 0, 0, 0, 0}