};
-/**
- * The display-functions for Security-Descriptors were taken from rpcclient
- *
- * They reside here for debugging purpose and should
- * possibly be removed later on
- *
- **/
-/****************************************************************************
-convert a security permissions into a string
-****************************************************************************/
-char *get_sec_mask_str(uint32 type)
-{
- static fstring typestr="";
-
- typestr[0] = 0;
-
- if (type & GENERIC_ALL_ACCESS)
- fstrcat(typestr, "Generic all access ");
- if (type & GENERIC_EXECUTE_ACCESS)
- fstrcat(typestr, "Generic execute access ");
- if (type & GENERIC_WRITE_ACCESS)
- fstrcat(typestr, "Generic write access ");
- if (type & GENERIC_READ_ACCESS)
- fstrcat(typestr, "Generic read access ");
- if (type & MAXIMUM_ALLOWED_ACCESS)
- fstrcat(typestr, "MAXIMUM_ALLOWED_ACCESS ");
- if (type & SYSTEM_SECURITY_ACCESS)
- fstrcat(typestr, "SYSTEM_SECURITY_ACCESS ");
- if (type & SYNCHRONIZE_ACCESS)
- fstrcat(typestr, "SYNCHRONIZE_ACCESS ");
- if (type & WRITE_OWNER_ACCESS)
- fstrcat(typestr, "WRITE_OWNER_ACCESS ");
- if (type & WRITE_DAC_ACCESS)
- fstrcat(typestr, "WRITE_DAC_ACCESS ");
- if (type & READ_CONTROL_ACCESS)
- fstrcat(typestr, "READ_CONTROL_ACCESS ");
- if (type & DELETE_ACCESS)
- fstrcat(typestr, "DELETE_ACCESS ");
-
- printf("\t\tSpecific bits: 0x%lx\n", (unsigned long)type&SPECIFIC_RIGHTS_MASK);
-
- return typestr;
-}
-
-
-/****************************************************************************
- display sec_ace structure
- ****************************************************************************/
-void display_sec_ace(SEC_ACE *ace)
-{
- fstring sid_str;
-
- printf("\tACE\n\t\ttype: ");
- switch (ace->type) {
- case SEC_ACE_TYPE_ACCESS_ALLOWED:
- printf("ACCESS ALLOWED");
- break;
- case SEC_ACE_TYPE_ACCESS_DENIED:
- printf("ACCESS DENIED");
- break;
- case SEC_ACE_TYPE_SYSTEM_AUDIT:
- printf("SYSTEM AUDIT");
- break;
- case SEC_ACE_TYPE_SYSTEM_ALARM:
- printf("SYSTEM ALARM");
- break;
- default:
- printf("????");
- break;
- }
- printf(" (%d) flags: %d\n", ace->type, ace->flags);
- printf("\t\tPermissions: 0x%x: %s\n", ace->info.mask, get_sec_mask_str(ace->info.mask));
-
- sid_to_string(sid_str, &ace->trustee);
- printf("\t\tSID: %s\n\n", sid_str);
-}
-
-
-/****************************************************************************
- display sec_acl structure
- ****************************************************************************/
-void display_sec_acl(SEC_ACL *sec_acl)
-{
- int i;
-
- printf("\tACL\tNum ACEs:\t%d\trevision:\t%x\n",
- sec_acl->num_aces, sec_acl->revision);
- printf("\t---\n");
-
- if (sec_acl->size != 0 && sec_acl->num_aces != 0)
- for (i = 0; i < sec_acl->num_aces; i++)
- display_sec_ace(&sec_acl->ace[i]);
-
-}
-
-/****************************************************************************
- display sec_desc structure
- ****************************************************************************/
-void display_sec_desc(SEC_DESC *sec)
-{
- fstring sid_str;
-
- if (sec == NULL)
- return;
-
- if (sec->sacl) {
- printf("SACL\n");
- display_sec_acl(sec->sacl);
- }
-
- if (sec->dacl) {
- printf("DACL\n");
- display_sec_acl(sec->dacl);
- }
-
- if (sec->owner_sid) {
- sid_to_string(sid_str, sec->owner_sid);
- printf("\tOwner SID:\t%s\n", sid_str);
- }
-
- if (sec->grp_sid) {
- sid_to_string(sid_str, sec->grp_sid);
- printf("\tParent SID:\t%s\n", sid_str);
- }
-}
-
-
/**
* This display-printdriver-functions was borrowed from rpcclient/cmd_spoolss.c.
* It is here for debugging purpose and should be removed later on.
**/
/****************************************************************************
-printer info level 3 display function
+ Printer info level 3 display function.
****************************************************************************/
+
static void display_print_driver_3(DRIVER_INFO_3 *i1)
{
fstring name = "";
return;
}
-
static void display_reg_value(const char *subkey, REGISTRY_VALUE value)
{
pstring text;
}
-
/**
* Copies ACLs, DOS-attributes and timestamps from one
* file or directory from one connected share to another connected share
*
* @return Normal NTSTATUS return.
**/
+
NTSTATUS net_copy_fileattr(TALLOC_CTX *mem_ctx,
struct cli_state *cli_share_src,
struct cli_state *cli_share_dst,
if (!copy_timestamps && !copy_acls && !copy_attrs)
return NT_STATUS_OK;
-
/* open file/dir on the originating server */
DEBUGADD(3,("opening %s %s on originating server\n",
/* closing files */
if (!cli_close(cli_share_src, fnum_src)) {
- d_printf("could not close %s on originating server: %s\n",
+ d_fprintf(stderr, "could not close %s on originating server: %s\n",
is_file?"file":"dir", cli_errstr(cli_share_src));
nt_status = cli_nt_error(cli_share_src);
goto out;
}
if (!cli_close(cli_share_dst, fnum_dst)) {
- d_printf("could not close %s on destination server: %s\n",
+ d_fprintf(stderr, "could not close %s on destination server: %s\n",
is_file?"file":"dir", cli_errstr(cli_share_dst));
nt_status = cli_nt_error(cli_share_dst);
goto out;
return nt_status;
}
-
/**
* Copy a file or directory from a connected share to another connected share
*
*
* @return Normal NTSTATUS return.
**/
+
NTSTATUS net_copy_file(TALLOC_CTX *mem_ctx,
struct cli_state *cli_share_src,
struct cli_state *cli_share_dst,
/* allocate memory */
if (!(data = (char *)SMB_MALLOC(read_size))) {
- d_printf("malloc fail for size %d\n", read_size);
+ d_fprintf(stderr, "malloc fail for size %d\n", read_size);
nt_status = NT_STATUS_NO_MEMORY;
goto out;
}
nread + start, n);
if (n != ret) {
- d_printf("Error writing file: %s\n",
+ d_fprintf(stderr, "Error writing file: %s\n",
cli_errstr(cli_share_dst));
nt_status = cli_nt_error(cli_share_dst);
goto out;
}
if (!cli_chkpath(cli_share_dst, dst_name)) {
- d_printf("cannot check for directory %s: %s\n",
+ d_fprintf(stderr, "cannot check for directory %s: %s\n",
dst_name, cli_errstr(cli_share_dst));
goto out;
}
/* closing files */
if (!cli_close(cli_share_src, fnum_src)) {
- d_printf("could not close file on originating server: %s\n",
+ d_fprintf(stderr, "could not close file on originating server: %s\n",
cli_errstr(cli_share_src));
nt_status = cli_nt_error(cli_share_src);
goto out;
}
if (is_file && !cli_close(cli_share_dst, fnum_dst)) {
- d_printf("could not close file on destination server: %s\n",
+ d_fprintf(stderr, "could not close file on destination server: %s\n",
cli_errstr(cli_share_dst));
nt_status = cli_nt_error(cli_share_dst);
goto out;
return nt_status;
}
-
/**
* Copy a driverfile from on connected share to another connected share
* This silently assumes that a driver-file is picked up from
*
* @return Normal NTSTATUS return.
**/
+
static NTSTATUS net_copy_driverfile(TALLOC_CTX *mem_ctx,
struct cli_state *cli_share_src,
struct cli_state *cli_share_dst,
return nt_status;
}
-
/**
* Check for existing Architecture directory on a given server
*
*
* @return Normal NTSTATUS return.
**/
-static NTSTATUS
-check_arch_dir(struct cli_state *cli_share, const char *short_archi)
+
+static NTSTATUS check_arch_dir(struct cli_state *cli_share, const char *short_archi)
{
NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
}
if (!cli_chkpath(cli_share, dir)) {
- d_printf("cannot check %s: %s\n",
+ d_fprintf(stderr, "cannot check %s: %s\n",
dir, cli_errstr(cli_share));
goto out;
}
return nt_status;
}
-
/**
* Copy a print-driver (level 3) from one connected print$-share to another
* connected print$-share
*
* @return Normal NTSTATUS return.
**/
-static NTSTATUS
-copy_print_driver_3(TALLOC_CTX *mem_ctx,
+
+static NTSTATUS copy_print_driver_3(TALLOC_CTX *mem_ctx,
struct cli_state *cli_share_src,
struct cli_state *cli_share_dst,
const char *short_archi, DRIVER_INFO_3 *i1)
return NT_STATUS_OK;
}
-
/**
* net_spoolss-functions
* =====================
*
**/
-static BOOL
-net_spoolss_enum_printers(struct cli_state *cli, TALLOC_CTX *mem_ctx,
- char *name, uint32 flags, uint32 level,
- uint32 *num_printers, PRINTER_INFO_CTR *ctr)
+static BOOL net_spoolss_enum_printers(struct rpc_pipe_client *pipe_hnd,
+ TALLOC_CTX *mem_ctx,
+ char *name,
+ uint32 flags,
+ uint32 level,
+ uint32 *num_printers,
+ PRINTER_INFO_CTR *ctr)
{
-
WERROR result;
/* enum printers */
- result = cli_spoolss_enum_printers(cli, mem_ctx, name, flags,
+ result = rpccli_spoolss_enum_printers(pipe_hnd, mem_ctx, name, flags,
level, num_printers, ctr);
if (!W_ERROR_IS_OK(result)) {
return True;
}
-
-static BOOL
-net_spoolss_open_printer_ex(struct cli_state *cli, TALLOC_CTX *mem_ctx,
- const char *printername, uint32 access_required,
- const char *username, POLICY_HND *hnd)
+static BOOL net_spoolss_open_printer_ex(struct rpc_pipe_client *pipe_hnd,
+ TALLOC_CTX *mem_ctx,
+ const char *printername,
+ uint32 access_required,
+ const char *username,
+ POLICY_HND *hnd)
{
WERROR result;
fstring servername, printername2;
- slprintf(servername, sizeof(servername)-1, "\\\\%s", cli->desthost);
+ slprintf(servername, sizeof(servername)-1, "\\\\%s", pipe_hnd->cli->desthost);
fstrcpy(printername2, servername);
fstrcat(printername2, "\\");
servername, username, printername2, access_required));
/* open printer */
- result = cli_spoolss_open_printer_ex(cli, mem_ctx, printername2,
+ result = rpccli_spoolss_open_printer_ex(pipe_hnd, mem_ctx, printername2,
"", access_required,
servername, username, hnd);
/* be more verbose */
if (W_ERROR_V(result) == W_ERROR_V(WERR_ACCESS_DENIED)) {
- d_printf("no access to printer [%s] on [%s] for user [%s] granted\n",
+ d_fprintf(stderr, "no access to printer [%s] on [%s] for user [%s] granted\n",
printername2, servername, username);
return False;
}
if (!W_ERROR_IS_OK(result)) {
- d_printf("cannot open printer %s on server %s: %s\n",
+ d_fprintf(stderr, "cannot open printer %s on server %s: %s\n",
printername2, servername, dos_errstr(result));
return False;
}
return True;
}
-
-static BOOL
-net_spoolss_getprinter(struct cli_state *cli, TALLOC_CTX *mem_ctx,
- POLICY_HND *hnd, uint32 level,
- PRINTER_INFO_CTR *ctr)
+static BOOL net_spoolss_getprinter(struct rpc_pipe_client *pipe_hnd,
+ TALLOC_CTX *mem_ctx,
+ POLICY_HND *hnd,
+ uint32 level,
+ PRINTER_INFO_CTR *ctr)
{
WERROR result;
/* getprinter call */
- result = cli_spoolss_getprinter(cli, mem_ctx, hnd, level, ctr);
+ result = rpccli_spoolss_getprinter(pipe_hnd, mem_ctx, hnd, level, ctr);
if (!W_ERROR_IS_OK(result)) {
printf("cannot get printer-info: %s\n", dos_errstr(result));
return True;
}
-
-static BOOL
-net_spoolss_setprinter(struct cli_state *cli, TALLOC_CTX *mem_ctx,
- POLICY_HND *hnd, uint32 level,
- PRINTER_INFO_CTR *ctr)
+static BOOL net_spoolss_setprinter(struct rpc_pipe_client *pipe_hnd,
+ TALLOC_CTX *mem_ctx,
+ POLICY_HND *hnd,
+ uint32 level,
+ PRINTER_INFO_CTR *ctr)
{
WERROR result;
/* setprinter call */
- result = cli_spoolss_setprinter(cli, mem_ctx, hnd, level, ctr, 0);
+ result = rpccli_spoolss_setprinter(pipe_hnd, mem_ctx, hnd, level, ctr, 0);
if (!W_ERROR_IS_OK(result)) {
printf("cannot set printer-info: %s\n", dos_errstr(result));
}
-static BOOL
-net_spoolss_setprinterdata(struct cli_state *cli, TALLOC_CTX *mem_ctx,
- POLICY_HND *hnd, REGISTRY_VALUE *value)
+static BOOL net_spoolss_setprinterdata(struct rpc_pipe_client *pipe_hnd,
+ TALLOC_CTX *mem_ctx,
+ POLICY_HND *hnd,
+ REGISTRY_VALUE *value)
{
WERROR result;
/* setprinterdata call */
- result = cli_spoolss_setprinterdata(cli, mem_ctx, hnd, value);
+ result = rpccli_spoolss_setprinterdata(pipe_hnd, mem_ctx, hnd, value);
if (!W_ERROR_IS_OK(result)) {
printf ("unable to set printerdata: %s\n", dos_errstr(result));
}
-static BOOL
-net_spoolss_enumprinterkey(struct cli_state *cli, TALLOC_CTX *mem_ctx,
- POLICY_HND *hnd, const char *keyname,
- uint16 **keylist)
+static BOOL net_spoolss_enumprinterkey(struct rpc_pipe_client *pipe_hnd,
+ TALLOC_CTX *mem_ctx,
+ POLICY_HND *hnd,
+ const char *keyname,
+ uint16 **keylist)
{
WERROR result;
/* enumprinterkey call */
- result = cli_spoolss_enumprinterkey(cli, mem_ctx, hnd, keyname, keylist, NULL);
+ result = rpccli_spoolss_enumprinterkey(pipe_hnd, mem_ctx, hnd, keyname, keylist, NULL);
if (!W_ERROR_IS_OK(result)) {
printf("enumprinterkey failed: %s\n", dos_errstr(result));
return True;
}
-
-static BOOL
-net_spoolss_enumprinterdataex(struct cli_state *cli, TALLOC_CTX *mem_ctx,
- uint32 offered,
- POLICY_HND *hnd, const char *keyname,
- REGVAL_CTR *ctr)
+static BOOL net_spoolss_enumprinterdataex(struct rpc_pipe_client *pipe_hnd,
+ TALLOC_CTX *mem_ctx,
+ uint32 offered,
+ POLICY_HND *hnd,
+ const char *keyname,
+ REGVAL_CTR *ctr)
{
WERROR result;
/* enumprinterdataex call */
- result = cli_spoolss_enumprinterdataex(cli, mem_ctx, hnd, keyname, ctr);
+ result = rpccli_spoolss_enumprinterdataex(pipe_hnd, mem_ctx, hnd, keyname, ctr);
if (!W_ERROR_IS_OK(result)) {
printf("enumprinterdataex failed: %s\n", dos_errstr(result));
}
-static BOOL
-net_spoolss_setprinterdataex(struct cli_state *cli, TALLOC_CTX *mem_ctx,
- POLICY_HND *hnd, char *keyname,
- REGISTRY_VALUE *value)
+static BOOL net_spoolss_setprinterdataex(struct rpc_pipe_client *pipe_hnd,
+ TALLOC_CTX *mem_ctx,
+ POLICY_HND *hnd,
+ char *keyname,
+ REGISTRY_VALUE *value)
{
WERROR result;
/* setprinterdataex call */
- result = cli_spoolss_setprinterdataex(cli, mem_ctx, hnd,
+ result = rpccli_spoolss_setprinterdataex(pipe_hnd, mem_ctx, hnd,
keyname, value);
if (!W_ERROR_IS_OK(result)) {
return True;
}
-
-static BOOL
-net_spoolss_enumforms(struct cli_state *cli, TALLOC_CTX *mem_ctx,
- POLICY_HND *hnd, int level, uint32 *num_forms,
- FORM_1 **forms)
+static BOOL net_spoolss_enumforms(struct rpc_pipe_client *pipe_hnd,
+ TALLOC_CTX *mem_ctx,
+ POLICY_HND *hnd,
+ int level,
+ uint32 *num_forms,
+ FORM_1 **forms)
{
WERROR result;
/* enumforms call */
- result = cli_spoolss_enumforms(cli, mem_ctx, hnd, level, num_forms, forms);
+ result = rpccli_spoolss_enumforms(pipe_hnd, mem_ctx, hnd, level, num_forms, forms);
if (!W_ERROR_IS_OK(result)) {
printf("could not enum forms: %s\n", dos_errstr(result));
return True;
}
-
-static BOOL
-net_spoolss_enumprinterdrivers (struct cli_state *cli, TALLOC_CTX *mem_ctx,
- uint32 level, const char *env,
- uint32 *num_drivers,
- PRINTER_DRIVER_CTR *ctr)
+static BOOL net_spoolss_enumprinterdrivers (struct rpc_pipe_client *pipe_hnd,
+ TALLOC_CTX *mem_ctx,
+ uint32 level, const char *env,
+ uint32 *num_drivers,
+ PRINTER_DRIVER_CTR *ctr)
{
WERROR result;
/* enumprinterdrivers call */
- result = cli_spoolss_enumprinterdrivers(
- cli, mem_ctx, level,
+ result = rpccli_spoolss_enumprinterdrivers(
+ pipe_hnd, mem_ctx, level,
env, num_drivers, ctr);
if (!W_ERROR_IS_OK(result)) {
return True;
}
-
-static BOOL
-net_spoolss_getprinterdriver(struct cli_state *cli,
+static BOOL net_spoolss_getprinterdriver(struct rpc_pipe_client *pipe_hnd,
TALLOC_CTX *mem_ctx,
POLICY_HND *hnd, uint32 level,
const char *env, int version,
WERROR result;
/* getprinterdriver call */
- result = cli_spoolss_getprinterdriver(
- cli, mem_ctx, hnd, level,
+ result = rpccli_spoolss_getprinterdriver(
+ pipe_hnd, mem_ctx, hnd, level,
env, version, ctr);
if (!W_ERROR_IS_OK(result)) {
}
-static BOOL
-net_spoolss_addprinterdriver(struct cli_state *cli,
+static BOOL net_spoolss_addprinterdriver(struct rpc_pipe_client *pipe_hnd,
TALLOC_CTX *mem_ctx, uint32 level,
PRINTER_DRIVER_CTR *ctr)
{
WERROR result;
/* addprinterdriver call */
- result = cli_spoolss_addprinterdriver(cli, mem_ctx, level, ctr);
+ result = rpccli_spoolss_addprinterdriver(pipe_hnd, mem_ctx, level, ctr);
/* be more verbose */
if (W_ERROR_V(result) == W_ERROR_V(WERR_ACCESS_DENIED)) {
* abstraction function to get uint32 num_printers and PRINTER_INFO_CTR ctr
* for a single printer or for all printers depending on argc/argv
**/
-static BOOL
-get_printer_info(struct cli_state *cli, TALLOC_CTX *mem_ctx,
- int level, int argc, const char **argv,
- uint32 *num_printers, PRINTER_INFO_CTR *ctr)
+
+static BOOL get_printer_info(struct rpc_pipe_client *pipe_hnd,
+ TALLOC_CTX *mem_ctx,
+ int level,
+ int argc,
+ const char **argv,
+ uint32 *num_printers,
+ PRINTER_INFO_CTR *ctr)
{
POLICY_HND hnd;
/* no arguments given, enumerate all printers */
if (argc == 0) {
- if (!net_spoolss_enum_printers(cli, mem_ctx, NULL,
+ if (!net_spoolss_enum_printers(pipe_hnd, mem_ctx, NULL,
PRINTER_ENUM_LOCAL|PRINTER_ENUM_SHARED,
level, num_printers, ctr))
return False;
/* argument given, get a single printer by name */
- if (!net_spoolss_open_printer_ex(cli, mem_ctx, argv[0],
- MAXIMUM_ALLOWED_ACCESS, cli->user_name, &hnd))
+ if (!net_spoolss_open_printer_ex(pipe_hnd, mem_ctx, argv[0],
+ MAXIMUM_ALLOWED_ACCESS, pipe_hnd->cli->user_name, &hnd))
return False;
- if (!net_spoolss_getprinter(cli, mem_ctx, &hnd, level, ctr)) {
- cli_spoolss_close_printer(cli, mem_ctx, &hnd);
+ if (!net_spoolss_getprinter(pipe_hnd, mem_ctx, &hnd, level, ctr)) {
+ rpccli_spoolss_close_printer(pipe_hnd, mem_ctx, &hnd);
return False;
}
- cli_spoolss_close_printer(cli, mem_ctx, &hnd);
+ rpccli_spoolss_close_printer(pipe_hnd, mem_ctx, &hnd);
*num_printers = 1;
}
-
/**
* List print-queues (including local printers that are not shared)
*
*
* @return Normal NTSTATUS return.
**/
-NTSTATUS rpc_printer_list_internals(const DOM_SID *domain_sid, const char *domain_name,
- struct cli_state *cli, TALLOC_CTX *mem_ctx,
- int argc, const char **argv)
+
+NTSTATUS rpc_printer_list_internals(const DOM_SID *domain_sid,
+ const char *domain_name,
+ struct cli_state *cli,
+ struct rpc_pipe_client *pipe_hnd,
+ TALLOC_CTX *mem_ctx,
+ int argc,
+ const char **argv)
{
NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
uint32 i, num_printers;
printf("listing printers\n");
- if (!get_printer_info(cli, mem_ctx, level, argc, argv, &num_printers, &ctr))
+ if (!get_printer_info(pipe_hnd, mem_ctx, level, argc, argv, &num_printers, &ctr))
return nt_status;
for (i = 0; i < num_printers; i++) {
return NT_STATUS_OK;
}
-
/**
* List printer-drivers from a server
*
*
* @return Normal NTSTATUS return.
**/
-NTSTATUS rpc_printer_driver_list_internals(const DOM_SID *domain_sid, const char *domain_name,
- struct cli_state *cli, TALLOC_CTX *mem_ctx,
- int argc, const char **argv)
+
+NTSTATUS rpc_printer_driver_list_internals(const DOM_SID *domain_sid,
+ const char *domain_name,
+ struct cli_state *cli,
+ struct rpc_pipe_client *pipe_hnd,
+ TALLOC_CTX *mem_ctx,
+ int argc,
+ const char **argv)
{
NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
uint32 i;
ZERO_STRUCT(drv_ctr_enum);
-
printf("listing printer-drivers\n");
for (i=0; archi_table[i].long_archi!=NULL; i++) {
uint32 num_drivers;
/* enum remote drivers */
- if (!net_spoolss_enumprinterdrivers(cli, mem_ctx, level,
+ if (!net_spoolss_enumprinterdrivers(pipe_hnd, mem_ctx, level,
archi_table[i].long_archi,
&num_drivers, &drv_ctr_enum)) {
* @return Normal NTSTATUS return.
**/
-static NTSTATUS rpc_printer_publish_internals_args(struct cli_state *cli, TALLOC_CTX *mem_ctx,
- int argc, const char **argv, uint32 action)
+static NTSTATUS rpc_printer_publish_internals_args(struct rpc_pipe_client *pipe_hnd,
+ TALLOC_CTX *mem_ctx,
+ int argc,
+ const char **argv,
+ uint32 action)
{
NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
uint32 i, num_printers;
WERROR result;
const char *action_str;
- if (!get_printer_info(cli, mem_ctx, 2, argc, argv, &num_printers, &ctr))
+ if (!get_printer_info(pipe_hnd, mem_ctx, 2, argc, argv, &num_printers, &ctr))
return nt_status;
for (i = 0; i < num_printers; i++) {
sizeof(sharename), -1, STR_TERMINATE);
/* open printer handle */
- if (!net_spoolss_open_printer_ex(cli, mem_ctx, sharename,
- PRINTER_ALL_ACCESS, cli->user_name, &hnd))
+ if (!net_spoolss_open_printer_ex(pipe_hnd, mem_ctx, sharename,
+ PRINTER_ALL_ACCESS, pipe_hnd->cli->user_name, &hnd))
goto done;
got_hnd = True;
/* check for existing dst printer */
- if (!net_spoolss_getprinter(cli, mem_ctx, &hnd, level, &ctr_pub))
+ if (!net_spoolss_getprinter(pipe_hnd, mem_ctx, &hnd, level, &ctr_pub))
goto done;
/* check action and set string */
ctr_pub.printers_7->action = action;
- result = cli_spoolss_setprinter(cli, mem_ctx, &hnd, level, &ctr_pub, 0);
+ result = rpccli_spoolss_setprinter(pipe_hnd, mem_ctx, &hnd, level, &ctr_pub, 0);
if (!W_ERROR_IS_OK(result) && (W_ERROR_V(result) != W_ERROR_V(WERR_IO_PENDING))) {
printf("cannot set printer-info: %s\n", dos_errstr(result));
goto done;
done:
if (got_hnd)
- cli_spoolss_close_printer(cli, mem_ctx, &hnd);
+ rpccli_spoolss_close_printer(pipe_hnd, mem_ctx, &hnd);
return nt_status;
}
-NTSTATUS rpc_printer_publish_publish_internals(const DOM_SID *domain_sid, const char *domain_name,
- struct cli_state *cli, TALLOC_CTX *mem_ctx,
- int argc, const char **argv)
+NTSTATUS rpc_printer_publish_publish_internals(const DOM_SID *domain_sid,
+ const char *domain_name,
+ struct cli_state *cli,
+ struct rpc_pipe_client *pipe_hnd,
+ TALLOC_CTX *mem_ctx,
+ int argc,
+ const char **argv)
{
- return rpc_printer_publish_internals_args(cli, mem_ctx, argc, argv, SPOOL_DS_PUBLISH);
+ return rpc_printer_publish_internals_args(pipe_hnd, mem_ctx, argc, argv, SPOOL_DS_PUBLISH);
}
-NTSTATUS rpc_printer_publish_unpublish_internals(const DOM_SID *domain_sid, const char *domain_name,
- struct cli_state *cli, TALLOC_CTX *mem_ctx,
- int argc, const char **argv)
+NTSTATUS rpc_printer_publish_unpublish_internals(const DOM_SID *domain_sid,
+ const char *domain_name,
+ struct cli_state *cli,
+ struct rpc_pipe_client *pipe_hnd,
+ TALLOC_CTX *mem_ctx,
+ int argc,
+ const char **argv)
{
- return rpc_printer_publish_internals_args(cli, mem_ctx, argc, argv, SPOOL_DS_UNPUBLISH);
+ return rpc_printer_publish_internals_args(pipe_hnd, mem_ctx, argc, argv, SPOOL_DS_UNPUBLISH);
}
-NTSTATUS rpc_printer_publish_update_internals(const DOM_SID *domain_sid, const char *domain_name,
- struct cli_state *cli, TALLOC_CTX *mem_ctx,
- int argc, const char **argv)
+NTSTATUS rpc_printer_publish_update_internals(const DOM_SID *domain_sid,
+ const char *domain_name,
+ struct cli_state *cli,
+ struct rpc_pipe_client *pipe_hnd,
+ TALLOC_CTX *mem_ctx,
+ int argc,
+ const char **argv)
{
- return rpc_printer_publish_internals_args(cli, mem_ctx, argc, argv, SPOOL_DS_UPDATE);
+ return rpc_printer_publish_internals_args(pipe_hnd, mem_ctx, argc, argv, SPOOL_DS_UPDATE);
}
/**
*
* @return Normal NTSTATUS return.
**/
-NTSTATUS rpc_printer_publish_list_internals(const DOM_SID *domain_sid, const char *domain_name,
- struct cli_state *cli, TALLOC_CTX *mem_ctx,
- int argc, const char **argv)
+
+NTSTATUS rpc_printer_publish_list_internals(const DOM_SID *domain_sid,
+ const char *domain_name,
+ struct cli_state *cli,
+ struct rpc_pipe_client *pipe_hnd,
+ TALLOC_CTX *mem_ctx,
+ int argc,
+ const char **argv)
{
NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
uint32 i, num_printers;
BOOL got_hnd = False;
int state;
- if (!get_printer_info(cli, mem_ctx, 2, argc, argv, &num_printers, &ctr))
+ if (!get_printer_info(pipe_hnd, mem_ctx, 2, argc, argv, &num_printers, &ctr))
return nt_status;
for (i = 0; i < num_printers; i++) {
sizeof(sharename), -1, STR_TERMINATE);
/* open printer handle */
- if (!net_spoolss_open_printer_ex(cli, mem_ctx, sharename,
+ if (!net_spoolss_open_printer_ex(pipe_hnd, mem_ctx, sharename,
PRINTER_ALL_ACCESS, cli->user_name, &hnd))
goto done;
got_hnd = True;
/* check for existing dst printer */
- if (!net_spoolss_getprinter(cli, mem_ctx, &hnd, level, &ctr_pub))
+ if (!net_spoolss_getprinter(pipe_hnd, mem_ctx, &hnd, level, &ctr_pub))
goto done;
rpcstr_pull(guid, ctr_pub.printers_7->guid.buffer, sizeof(guid), -1, STR_TERMINATE);
done:
if (got_hnd)
- cli_spoolss_close_printer(cli, mem_ctx, &hnd);
+ rpccli_spoolss_close_printer(pipe_hnd, mem_ctx, &hnd);
return nt_status;
}
*
* @return Normal NTSTATUS return.
**/
-NTSTATUS rpc_printer_migrate_security_internals(const DOM_SID *domain_sid, const char *domain_name,
- struct cli_state *cli, TALLOC_CTX *mem_ctx,
- int argc, const char **argv)
+
+NTSTATUS rpc_printer_migrate_security_internals(const DOM_SID *domain_sid,
+ const char *domain_name,
+ struct cli_state *cli,
+ struct rpc_pipe_client *pipe_hnd,
+ TALLOC_CTX *mem_ctx,
+ int argc,
+ const char **argv)
{
/* TODO: what now, info2 or info3 ?
convince jerry that we should add clientside setacls level 3 at least
pstring printername = "", sharename = "";
BOOL got_hnd_src = False;
BOOL got_hnd_dst = False;
- BOOL got_dst_spoolss_pipe = False;
+ struct rpc_pipe_client *pipe_hnd_dst = NULL;
POLICY_HND hnd_src, hnd_dst;
PRINTER_INFO_CTR ctr_src, ctr_dst, ctr_enum;
struct cli_state *cli_dst = NULL;
DEBUG(3,("copying printer ACLs\n"));
/* connect destination PI_SPOOLSS */
- nt_status = connect_dst_pipe(&cli_dst, PI_SPOOLSS, &got_dst_spoolss_pipe);
+ nt_status = connect_dst_pipe(&cli_dst, &pipe_hnd_dst, PI_SPOOLSS);
if (!NT_STATUS_IS_OK(nt_status))
return nt_status;
/* enum source printers */
- if (!get_printer_info(cli, mem_ctx, level, argc, argv, &num_printers, &ctr_enum)) {
+ if (!get_printer_info(pipe_hnd, mem_ctx, level, argc, argv, &num_printers, &ctr_enum)) {
nt_status = NT_STATUS_UNSUCCESSFUL;
goto done;
}
goto done;
}
-
/* do something for all printers */
for (i = 0; i < num_printers; i++) {
*/
/* open src printer handle */
- if (!net_spoolss_open_printer_ex(cli, mem_ctx, sharename,
+ if (!net_spoolss_open_printer_ex(pipe_hnd, mem_ctx, sharename,
MAXIMUM_ALLOWED_ACCESS, cli->user_name, &hnd_src))
goto done;
got_hnd_src = True;
-
/* open dst printer handle */
- if (!net_spoolss_open_printer_ex(cli_dst, mem_ctx, sharename,
+ if (!net_spoolss_open_printer_ex(pipe_hnd_dst, mem_ctx, sharename,
PRINTER_ALL_ACCESS, cli_dst->user_name, &hnd_dst))
goto done;
got_hnd_dst = True;
-
/* check for existing dst printer */
- if (!net_spoolss_getprinter(cli_dst, mem_ctx, &hnd_dst, level, &ctr_dst))
+ if (!net_spoolss_getprinter(pipe_hnd_dst, mem_ctx, &hnd_dst, level, &ctr_dst))
goto done;
/* check for existing src printer */
- if (!net_spoolss_getprinter(cli, mem_ctx, &hnd_src, 3, &ctr_src))
+ if (!net_spoolss_getprinter(pipe_hnd, mem_ctx, &hnd_src, 3, &ctr_src))
goto done;
-
/* Copy Security Descriptor */
/* copy secdesc (info level 2) */
if (opt_verbose)
display_sec_desc(ctr_dst.printers_2->secdesc);
- if (!net_spoolss_setprinter(cli_dst, mem_ctx, &hnd_dst, 2, &ctr_dst))
+ if (!net_spoolss_setprinter(pipe_hnd_dst, mem_ctx, &hnd_dst, 2, &ctr_dst))
goto done;
DEBUGADD(1,("\tSetPrinter of SECDESC succeeded\n"));
/* close printer handles here */
if (got_hnd_src) {
- cli_spoolss_close_printer(cli, mem_ctx, &hnd_src);
+ rpccli_spoolss_close_printer(pipe_hnd, mem_ctx, &hnd_src);
got_hnd_src = False;
}
if (got_hnd_dst) {
- cli_spoolss_close_printer(cli_dst, mem_ctx, &hnd_dst);
+ rpccli_spoolss_close_printer(pipe_hnd_dst, mem_ctx, &hnd_dst);
got_hnd_dst = False;
}
done:
- if (got_hnd_src)
- cli_spoolss_close_printer(cli, mem_ctx, &hnd_src);
+ if (got_hnd_src) {
+ rpccli_spoolss_close_printer(pipe_hnd, mem_ctx, &hnd_src);
+ }
- if (got_hnd_dst)
- cli_spoolss_close_printer(cli_dst, mem_ctx, &hnd_dst);
+ if (got_hnd_dst) {
+ rpccli_spoolss_close_printer(pipe_hnd_dst, mem_ctx, &hnd_dst);
+ }
- if (got_dst_spoolss_pipe) {
- cli_nt_session_close(cli_dst);
+ if (cli_dst) {
cli_shutdown(cli_dst);
}
return nt_status;
}
-
/**
* Migrate printer-forms from a src server to the dst server
*
*
* @return Normal NTSTATUS return.
**/
-NTSTATUS rpc_printer_migrate_forms_internals(const DOM_SID *domain_sid, const char *domain_name,
- struct cli_state *cli, TALLOC_CTX *mem_ctx,
- int argc, const char **argv)
+
+NTSTATUS rpc_printer_migrate_forms_internals(const DOM_SID *domain_sid,
+ const char *domain_name,
+ struct cli_state *cli,
+ struct rpc_pipe_client *pipe_hnd,
+ TALLOC_CTX *mem_ctx,
+ int argc,
+ const char **argv)
{
NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
WERROR result;
pstring printername = "", sharename = "";
BOOL got_hnd_src = False;
BOOL got_hnd_dst = False;
- BOOL got_dst_spoolss_pipe = False;
+ struct rpc_pipe_client *pipe_hnd_dst = NULL;
POLICY_HND hnd_src, hnd_dst;
PRINTER_INFO_CTR ctr_enum, ctr_dst;
uint32 num_forms;
DEBUG(3,("copying forms\n"));
/* connect destination PI_SPOOLSS */
- nt_status = connect_dst_pipe(&cli_dst, PI_SPOOLSS, &got_dst_spoolss_pipe);
+ nt_status = connect_dst_pipe(&cli_dst, &pipe_hnd_dst, PI_SPOOLSS);
if (!NT_STATUS_IS_OK(nt_status))
return nt_status;
/* enum src printers */
- if (!get_printer_info(cli, mem_ctx, 2, argc, argv, &num_printers, &ctr_enum)) {
+ if (!get_printer_info(pipe_hnd, mem_ctx, 2, argc, argv, &num_printers, &ctr_enum)) {
nt_status = NT_STATUS_UNSUCCESSFUL;
goto done;
}
/* open src printer handle */
- if (!net_spoolss_open_printer_ex(cli, mem_ctx, sharename,
+ if (!net_spoolss_open_printer_ex(pipe_hnd, mem_ctx, sharename,
MAXIMUM_ALLOWED_ACCESS, cli->user_name, &hnd_src))
goto done;
/* open dst printer handle */
- if (!net_spoolss_open_printer_ex(cli_dst, mem_ctx, sharename,
+ if (!net_spoolss_open_printer_ex(pipe_hnd_dst, mem_ctx, sharename,
PRINTER_ALL_ACCESS, cli->user_name, &hnd_dst))
goto done;
/* check for existing dst printer */
- if (!net_spoolss_getprinter(cli_dst, mem_ctx, &hnd_dst, level, &ctr_dst))
+ if (!net_spoolss_getprinter(pipe_hnd_dst, mem_ctx, &hnd_dst, level, &ctr_dst))
goto done;
/* finally migrate forms */
- if (!net_spoolss_enumforms(cli, mem_ctx, &hnd_src, level, &num_forms, &forms))
+ if (!net_spoolss_enumforms(pipe_hnd, mem_ctx, &hnd_src, level, &num_forms, &forms))
goto done;
DEBUG(1,("got %d forms for printer\n", num_forms));
/* FIXME: there might be something wrong with samba's
builtin-forms */
- result = cli_spoolss_addform(cli_dst, mem_ctx,
+ result = rpccli_spoolss_addform(pipe_hnd_dst, mem_ctx,
&hnd_dst, 1, &form);
if (!W_ERROR_IS_OK(result)) {
d_printf("\tAddForm form %d: [%s] refused.\n",
/* close printer handles here */
if (got_hnd_src) {
- cli_spoolss_close_printer(cli, mem_ctx, &hnd_src);
+ rpccli_spoolss_close_printer(pipe_hnd, mem_ctx, &hnd_src);
got_hnd_src = False;
}
if (got_hnd_dst) {
- cli_spoolss_close_printer(cli_dst, mem_ctx, &hnd_dst);
+ rpccli_spoolss_close_printer(pipe_hnd_dst, mem_ctx, &hnd_dst);
got_hnd_dst = False;
}
}
done:
if (got_hnd_src)
- cli_spoolss_close_printer(cli, mem_ctx, &hnd_src);
+ rpccli_spoolss_close_printer(pipe_hnd, mem_ctx, &hnd_src);
if (got_hnd_dst)
- cli_spoolss_close_printer(cli_dst, mem_ctx, &hnd_dst);
+ rpccli_spoolss_close_printer(pipe_hnd_dst, mem_ctx, &hnd_dst);
- if (got_dst_spoolss_pipe) {
- cli_nt_session_close(cli_dst);
+ if (cli_dst) {
cli_shutdown(cli_dst);
}
return nt_status;
-
}
-
/**
* Migrate printer-drivers from a src server to the dst server
*
*
* @return Normal NTSTATUS return.
**/
-NTSTATUS rpc_printer_migrate_drivers_internals(const DOM_SID *domain_sid, const char *domain_name,
- struct cli_state *cli, TALLOC_CTX *mem_ctx,
- int argc, const char **argv)
+
+NTSTATUS rpc_printer_migrate_drivers_internals(const DOM_SID *domain_sid,
+ const char *domain_name,
+ struct cli_state *cli,
+ struct rpc_pipe_client *pipe_hnd,
+ TALLOC_CTX *mem_ctx,
+ int argc,
+ const char **argv)
{
NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
uint32 i, p;
pstring printername = "", sharename = "";
BOOL got_hnd_src = False;
BOOL got_hnd_dst = False;
- BOOL got_dst_spoolss_pipe = False;
BOOL got_src_driver_share = False;
BOOL got_dst_driver_share = False;
+ struct rpc_pipe_client *pipe_hnd_dst = NULL;
POLICY_HND hnd_src, hnd_dst;
PRINTER_DRIVER_CTR drv_ctr_src, drv_ctr_dst;
PRINTER_INFO_CTR info_ctr_enum, info_ctr_dst;
DEBUG(3,("copying printer-drivers\n"));
- nt_status = connect_dst_pipe(&cli_dst, PI_SPOOLSS, &got_dst_spoolss_pipe);
+ nt_status = connect_dst_pipe(&cli_dst, &pipe_hnd_dst, PI_SPOOLSS);
if (!NT_STATUS_IS_OK(nt_status))
return nt_status;
/* enum src printers */
- if (!get_printer_info(cli, mem_ctx, 2, argc, argv, &num_printers, &info_ctr_enum)) {
+ if (!get_printer_info(pipe_hnd, mem_ctx, 2, argc, argv, &num_printers, &info_ctr_enum)) {
nt_status = NT_STATUS_UNSUCCESSFUL;
goto done;
}
printername, sharename);
/* open dst printer handle */
- if (!net_spoolss_open_printer_ex(cli_dst, mem_ctx, sharename,
+ if (!net_spoolss_open_printer_ex(pipe_hnd_dst, mem_ctx, sharename,
PRINTER_ALL_ACCESS, cli->user_name, &hnd_dst))
goto done;
got_hnd_dst = True;
/* check for existing dst printer */
- if (!net_spoolss_getprinter(cli_dst, mem_ctx, &hnd_dst, 2, &info_ctr_dst))
+ if (!net_spoolss_getprinter(pipe_hnd_dst, mem_ctx, &hnd_dst, 2, &info_ctr_dst))
goto done;
/* open src printer handle */
- if (!net_spoolss_open_printer_ex(cli, mem_ctx, sharename,
- MAXIMUM_ALLOWED_ACCESS, cli->user_name, &hnd_src))
+ if (!net_spoolss_open_printer_ex(pipe_hnd, mem_ctx, sharename,
+ MAXIMUM_ALLOWED_ACCESS, pipe_hnd->cli->user_name, &hnd_src))
goto done;
got_hnd_src = True;
for (i=0; archi_table[i].long_archi!=NULL; i++) {
/* getdriver src */
- if (!net_spoolss_getprinterdriver(cli, mem_ctx, &hnd_src,
+ if (!net_spoolss_getprinterdriver(pipe_hnd, mem_ctx, &hnd_src,
level, archi_table[i].long_archi,
archi_table[i].version, &drv_ctr_src))
continue;
/* adddriver dst */
- if (!net_spoolss_addprinterdriver(cli_dst, mem_ctx, level, &drv_ctr_src)) {
+ if (!net_spoolss_addprinterdriver(pipe_hnd_dst, mem_ctx, level, &drv_ctr_src)) {
nt_status = NT_STATUS_UNSUCCESSFUL;
goto done;
}
/* setdriver dst */
init_unistr(&info_ctr_dst.printers_2->drivername, drivername);
- if (!net_spoolss_setprinter(cli_dst, mem_ctx, &hnd_dst, 2, &info_ctr_dst)) {
+ if (!net_spoolss_setprinter(pipe_hnd_dst, mem_ctx, &hnd_dst, 2, &info_ctr_dst)) {
nt_status = NT_STATUS_UNSUCCESSFUL;
goto done;
}
/* close dst */
if (got_hnd_dst) {
- cli_spoolss_close_printer(cli_dst, mem_ctx, &hnd_dst);
+ rpccli_spoolss_close_printer(pipe_hnd_dst, mem_ctx, &hnd_dst);
got_hnd_dst = False;
}
/* close src */
if (got_hnd_src) {
- cli_spoolss_close_printer(cli, mem_ctx, &hnd_src);
+ rpccli_spoolss_close_printer(pipe_hnd, mem_ctx, &hnd_src);
got_hnd_src = False;
}
}
done:
if (got_hnd_src)
- cli_spoolss_close_printer(cli, mem_ctx, &hnd_src);
+ rpccli_spoolss_close_printer(pipe_hnd, mem_ctx, &hnd_src);
if (got_hnd_dst)
- cli_spoolss_close_printer(cli_dst, mem_ctx, &hnd_dst);
+ rpccli_spoolss_close_printer(pipe_hnd_dst, mem_ctx, &hnd_dst);
- if (got_dst_spoolss_pipe) {
- cli_nt_session_close(cli_dst);
+ if (cli_dst) {
cli_shutdown(cli_dst);
}
}
-
/**
* Migrate printer-queues from a src to the dst server
* (requires a working "addprinter command" to be installed for the local smbd)
*
* @return Normal NTSTATUS return.
**/
-NTSTATUS rpc_printer_migrate_printers_internals(const DOM_SID *domain_sid, const char *domain_name,
- struct cli_state *cli, TALLOC_CTX *mem_ctx,
- int argc, const char **argv)
+
+NTSTATUS rpc_printer_migrate_printers_internals(const DOM_SID *domain_sid,
+ const char *domain_name,
+ struct cli_state *cli,
+ struct rpc_pipe_client *pipe_hnd,
+ TALLOC_CTX *mem_ctx,
+ int argc,
+ const char **argv)
{
WERROR result;
NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
pstring printername, sharename;
BOOL got_hnd_src = False;
BOOL got_hnd_dst = False;
- BOOL got_dst_spoolss_pipe = False;
+ struct rpc_pipe_client *pipe_hnd_dst = NULL;
DEBUG(3,("copying printers\n"));
/* connect destination PI_SPOOLSS */
- nt_status = connect_dst_pipe(&cli_dst, PI_SPOOLSS, &got_dst_spoolss_pipe);
+ nt_status = connect_dst_pipe(&cli_dst, &pipe_hnd_dst, PI_SPOOLSS);
if (!NT_STATUS_IS_OK(nt_status))
return nt_status;
/* enum printers */
- if (!get_printer_info(cli, mem_ctx, level, argc, argv, &num_printers, &ctr_enum)) {
+ if (!get_printer_info(pipe_hnd, mem_ctx, level, argc, argv, &num_printers, &ctr_enum)) {
nt_status = NT_STATUS_UNSUCCESSFUL;
goto done;
}
/* open dst printer handle */
- if (!net_spoolss_open_printer_ex(cli_dst, mem_ctx, sharename,
+ if (!net_spoolss_open_printer_ex(pipe_hnd_dst, mem_ctx, sharename,
PRINTER_ALL_ACCESS, cli->user_name, &hnd_dst)) {
DEBUG(1,("could not open printer: %s\n", sharename));
/* check for existing dst printer */
- if (!net_spoolss_getprinter(cli_dst, mem_ctx, &hnd_dst, level, &ctr_dst)) {
+ if (!net_spoolss_getprinter(pipe_hnd_dst, mem_ctx, &hnd_dst, level, &ctr_dst)) {
printf ("could not get printer, creating printer.\n");
} else {
DEBUG(1,("printer already exists: %s\n", sharename));
/* close printer handles here */
if (got_hnd_src) {
- cli_spoolss_close_printer(cli, mem_ctx, &hnd_src);
+ rpccli_spoolss_close_printer(pipe_hnd, mem_ctx, &hnd_src);
got_hnd_src = False;
}
if (got_hnd_dst) {
- cli_spoolss_close_printer(cli_dst, mem_ctx, &hnd_dst);
+ rpccli_spoolss_close_printer(pipe_hnd_dst, mem_ctx, &hnd_dst);
got_hnd_dst = False;
}
continue;
we first need a handle for that */
/* open src printer handle */
- if (!net_spoolss_open_printer_ex(cli, mem_ctx, sharename,
+ if (!net_spoolss_open_printer_ex(pipe_hnd, mem_ctx, sharename,
MAXIMUM_ALLOWED_ACCESS, cli->user_name, &hnd_src))
goto done;
got_hnd_src = True;
/* getprinter on the src server */
- if (!net_spoolss_getprinter(cli, mem_ctx, &hnd_src, level, &ctr_src))
+ if (!net_spoolss_getprinter(pipe_hnd, mem_ctx, &hnd_src, level, &ctr_src))
goto done;
/* copy each src printer to a dst printer 1:1,
maybe some values have to be changed though */
d_printf("creating printer: %s\n", printername);
- result = cli_spoolss_addprinterex (cli_dst, mem_ctx, level, &ctr_src);
+ result = rpccli_spoolss_addprinterex (pipe_hnd_dst, mem_ctx, level, &ctr_src);
if (W_ERROR_IS_OK(result))
d_printf ("printer [%s] successfully added.\n", printername);
else if (W_ERROR_V(result) == W_ERROR_V(WERR_PRINTER_ALREADY_EXISTS))
- d_printf ("printer [%s] already exists.\n", printername);
+ d_fprintf (stderr, "printer [%s] already exists.\n", printername);
else {
- printf ("could not create printer\n");
+ d_fprintf (stderr, "could not create printer [%s]\n", printername);
goto done;
}
/* close printer handles here */
if (got_hnd_src) {
- cli_spoolss_close_printer(cli, mem_ctx, &hnd_src);
+ rpccli_spoolss_close_printer(pipe_hnd, mem_ctx, &hnd_src);
got_hnd_src = False;
}
if (got_hnd_dst) {
- cli_spoolss_close_printer(cli_dst, mem_ctx, &hnd_dst);
+ rpccli_spoolss_close_printer(pipe_hnd_dst, mem_ctx, &hnd_dst);
got_hnd_dst = False;
}
}
done:
if (got_hnd_src)
- cli_spoolss_close_printer(cli, mem_ctx, &hnd_src);
+ rpccli_spoolss_close_printer(pipe_hnd, mem_ctx, &hnd_src);
if (got_hnd_dst)
- cli_spoolss_close_printer(cli_dst, mem_ctx, &hnd_dst);
+ rpccli_spoolss_close_printer(pipe_hnd_dst, mem_ctx, &hnd_dst);
- if (got_dst_spoolss_pipe) {
- cli_nt_session_close(cli_dst);
+ if (cli_dst) {
cli_shutdown(cli_dst);
}
return nt_status;
}
-
/**
* Migrate Printer-Settings from a src server to the dst server
* (for this to work, printers and drivers already have to be migrated earlier)
*
* @return Normal NTSTATUS return.
**/
-NTSTATUS rpc_printer_migrate_settings_internals(const DOM_SID *domain_sid, const char *domain_name,
- struct cli_state *cli, TALLOC_CTX *mem_ctx,
- int argc, const char **argv)
+
+NTSTATUS rpc_printer_migrate_settings_internals(const DOM_SID *domain_sid,
+ const char *domain_name,
+ struct cli_state *cli,
+ struct rpc_pipe_client *pipe_hnd,
+ TALLOC_CTX *mem_ctx,
+ int argc,
+ const char **argv)
{
/* FIXME: Here the nightmare begins */
pstring printername = "", sharename = "";
BOOL got_hnd_src = False;
BOOL got_hnd_dst = False;
- BOOL got_dst_spoolss_pipe = False;
+ struct rpc_pipe_client *pipe_hnd_dst = NULL;
POLICY_HND hnd_src, hnd_dst;
PRINTER_INFO_CTR ctr_enum, ctr_dst, ctr_dst_publish;
- REGVAL_CTR reg_ctr;
+ REGVAL_CTR *reg_ctr;
struct cli_state *cli_dst = NULL;
char *devicename = NULL, *unc_name = NULL, *url = NULL;
fstring longname;
DEBUG(3,("copying printer settings\n"));
/* connect destination PI_SPOOLSS */
- nt_status = connect_dst_pipe(&cli_dst, PI_SPOOLSS, &got_dst_spoolss_pipe);
+ nt_status = connect_dst_pipe(&cli_dst, &pipe_hnd_dst, PI_SPOOLSS);
if (!NT_STATUS_IS_OK(nt_status))
return nt_status;
/* enum src printers */
- if (!get_printer_info(cli, mem_ctx, level, argc, argv, &num_printers, &ctr_enum)) {
+ if (!get_printer_info(pipe_hnd, mem_ctx, level, argc, argv, &num_printers, &ctr_enum)) {
nt_status = NT_STATUS_UNSUCCESSFUL;
goto done;
}
/* open src printer handle */
- if (!net_spoolss_open_printer_ex(cli, mem_ctx, sharename,
+ if (!net_spoolss_open_printer_ex(pipe_hnd, mem_ctx, sharename,
MAXIMUM_ALLOWED_ACCESS, cli->user_name, &hnd_src))
goto done;
/* open dst printer handle */
- if (!net_spoolss_open_printer_ex(cli_dst, mem_ctx, sharename,
+ if (!net_spoolss_open_printer_ex(pipe_hnd_dst, mem_ctx, sharename,
PRINTER_ALL_ACCESS, cli_dst->user_name, &hnd_dst))
goto done;
/* check for existing dst printer */
- if (!net_spoolss_getprinter(cli_dst, mem_ctx, &hnd_dst,
+ if (!net_spoolss_getprinter(pipe_hnd_dst, mem_ctx, &hnd_dst,
level, &ctr_dst))
goto done;
if (ctr_enum.printers_2[i].attributes & PRINTER_ATTRIBUTE_PUBLISHED) {
/* check for existing dst printer */
- if (!net_spoolss_getprinter(cli_dst, mem_ctx, &hnd_dst, 7, &ctr_dst_publish))
+ if (!net_spoolss_getprinter(pipe_hnd_dst, mem_ctx, &hnd_dst, 7, &ctr_dst_publish))
goto done;
ctr_dst_publish.printers_7->action = SPOOL_DS_PUBLISH;
/* ignore False from setprinter due to WERR_IO_PENDING */
- net_spoolss_setprinter(cli_dst, mem_ctx, &hnd_dst, 7, &ctr_dst_publish);
+ net_spoolss_setprinter(pipe_hnd_dst, mem_ctx, &hnd_dst, 7, &ctr_dst_publish);
DEBUG(3,("republished printer\n"));
}
init_unistr(&ctr_dst.printers_2->devmode->devicename,
devicename);
#endif
- if (!net_spoolss_setprinter(cli_dst, mem_ctx, &hnd_dst,
+ if (!net_spoolss_setprinter(pipe_hnd_dst, mem_ctx, &hnd_dst,
level, &ctr_dst))
goto done;
/* STEP 2: COPY REGISTRY VALUES */
/* please keep in mind that samba parse_spools gives horribly
- crippled results when used to cli_spoolss_enumprinterdataex
+ crippled results when used to rpccli_spoolss_enumprinterdataex
a win2k3-server. (Bugzilla #1851)
FIXME: IIRC I've seen it too on a win2k-server
*/
/* enumerate data on src handle */
- result = cli_spoolss_enumprinterdata(cli, mem_ctx, &hnd_src, p, 0, 0,
+ result = rpccli_spoolss_enumprinterdata(pipe_hnd, mem_ctx, &hnd_src, p, 0, 0,
&val_needed, &data_needed, NULL);
/* loop for all printerdata of "PrinterDriverData" */
REGISTRY_VALUE value;
- result = cli_spoolss_enumprinterdata(
- cli, mem_ctx, &hnd_src, p++, val_needed,
+ result = rpccli_spoolss_enumprinterdata(
+ pipe_hnd, mem_ctx, &hnd_src, p++, val_needed,
data_needed, 0, 0, &value);
/* loop for all reg_keys */
display_reg_value(SPOOL_PRINTERDATA_KEY, value);
/* set_value */
- if (!net_spoolss_setprinterdata(cli_dst, mem_ctx,
+ if (!net_spoolss_setprinterdata(pipe_hnd_dst, mem_ctx,
&hnd_dst, &value))
goto done;
respond to enumprinterkey, win2k does, so continue
in case of an error */
- if (!net_spoolss_enumprinterkey(cli, mem_ctx, &hnd_src, "", &keylist)) {
+ if (!net_spoolss_enumprinterkey(pipe_hnd, mem_ctx, &hnd_src, "", &keylist)) {
printf("got no key-data\n");
continue;
}
curkey += strlen(subkey) + 1;
+ if ( !(reg_ctr = TALLOC_ZERO_P( mem_ctx, REGVAL_CTR )) )
+ return NT_STATUS_NO_MEMORY;
+
/* enumerate all src subkeys */
- if (!net_spoolss_enumprinterdataex(cli, mem_ctx, 0,
+ if (!net_spoolss_enumprinterdataex(pipe_hnd, mem_ctx, 0,
&hnd_src, subkey,
- ®_ctr))
+ reg_ctr))
goto done;
- for (j=0; j < reg_ctr.num_values; j++) {
+ for (j=0; j < reg_ctr->num_values; j++) {
REGISTRY_VALUE value;
UNISTR2 data;
/* although samba replies with sane data in most cases we
should try to avoid writing wrong registry data */
- if (strequal(reg_ctr.values[j]->valuename, SPOOL_REG_PORTNAME) ||
- strequal(reg_ctr.values[j]->valuename, SPOOL_REG_UNCNAME) ||
- strequal(reg_ctr.values[j]->valuename, SPOOL_REG_URL) ||
- strequal(reg_ctr.values[j]->valuename, SPOOL_REG_SHORTSERVERNAME) ||
- strequal(reg_ctr.values[j]->valuename, SPOOL_REG_SERVERNAME)) {
+ if (strequal(reg_ctr->values[j]->valuename, SPOOL_REG_PORTNAME) ||
+ strequal(reg_ctr->values[j]->valuename, SPOOL_REG_UNCNAME) ||
+ strequal(reg_ctr->values[j]->valuename, SPOOL_REG_URL) ||
+ strequal(reg_ctr->values[j]->valuename, SPOOL_REG_SHORTSERVERNAME) ||
+ strequal(reg_ctr->values[j]->valuename, SPOOL_REG_SERVERNAME)) {
- if (strequal(reg_ctr.values[j]->valuename, SPOOL_REG_PORTNAME)) {
+ if (strequal(reg_ctr->values[j]->valuename, SPOOL_REG_PORTNAME)) {
/* although windows uses a multi-sz, we use a sz */
init_unistr2(&data, SAMBA_PRINTER_PORT_NAME, UNI_STR_TERMINATE);
fstrcpy(value.valuename, SPOOL_REG_PORTNAME);
}
- if (strequal(reg_ctr.values[j]->valuename, SPOOL_REG_UNCNAME)) {
+ if (strequal(reg_ctr->values[j]->valuename, SPOOL_REG_UNCNAME)) {
if (asprintf(&unc_name, "\\\\%s\\%s", longname, sharename) < 0) {
nt_status = NT_STATUS_NO_MEMORY;
fstrcpy(value.valuename, SPOOL_REG_UNCNAME);
}
- if (strequal(reg_ctr.values[j]->valuename, SPOOL_REG_URL)) {
+ if (strequal(reg_ctr->values[j]->valuename, SPOOL_REG_URL)) {
continue;
#endif
}
- if (strequal(reg_ctr.values[j]->valuename, SPOOL_REG_SERVERNAME)) {
+ if (strequal(reg_ctr->values[j]->valuename, SPOOL_REG_SERVERNAME)) {
init_unistr2(&data, longname, UNI_STR_TERMINATE);
fstrcpy(value.valuename, SPOOL_REG_SERVERNAME);
}
- if (strequal(reg_ctr.values[j]->valuename, SPOOL_REG_SHORTSERVERNAME)) {
+ if (strequal(reg_ctr->values[j]->valuename, SPOOL_REG_SHORTSERVERNAME)) {
init_unistr2(&data, global_myname(), UNI_STR_TERMINATE);
fstrcpy(value.valuename, SPOOL_REG_SHORTSERVERNAME);
display_reg_value(subkey, value);
/* here we have to set all subkeys on the dst server */
- if (!net_spoolss_setprinterdataex(cli_dst, mem_ctx, &hnd_dst,
+ if (!net_spoolss_setprinterdataex(pipe_hnd_dst, mem_ctx, &hnd_dst,
subkey, &value))
goto done;
} else {
if (opt_verbose)
- display_reg_value(subkey, *(reg_ctr.values[j]));
+ display_reg_value(subkey, *(reg_ctr->values[j]));
/* here we have to set all subkeys on the dst server */
- if (!net_spoolss_setprinterdataex(cli_dst, mem_ctx, &hnd_dst,
- subkey, reg_ctr.values[j]))
+ if (!net_spoolss_setprinterdataex(pipe_hnd_dst, mem_ctx, &hnd_dst,
+ subkey, reg_ctr->values[j]))
goto done;
}
DEBUGADD(1,("\tSetPrinterDataEx of key [%s\\%s] succeeded\n",
- subkey, reg_ctr.values[j]->valuename));
+ subkey, reg_ctr->values[j]->valuename));
}
-
- regval_ctr_destroy(®_ctr);
+
+ TALLOC_FREE( reg_ctr );
}
safe_free(keylist);
/* close printer handles here */
if (got_hnd_src) {
- cli_spoolss_close_printer(cli, mem_ctx, &hnd_src);
+ rpccli_spoolss_close_printer(pipe_hnd, mem_ctx, &hnd_src);
got_hnd_src = False;
}
if (got_hnd_dst) {
- cli_spoolss_close_printer(cli_dst, mem_ctx, &hnd_dst);
+ rpccli_spoolss_close_printer(pipe_hnd_dst, mem_ctx, &hnd_dst);
got_hnd_dst = False;
}
SAFE_FREE(unc_name);
if (got_hnd_src)
- cli_spoolss_close_printer(cli, mem_ctx, &hnd_src);
+ rpccli_spoolss_close_printer(pipe_hnd, mem_ctx, &hnd_src);
if (got_hnd_dst)
- cli_spoolss_close_printer(cli_dst, mem_ctx, &hnd_dst);
+ rpccli_spoolss_close_printer(pipe_hnd_dst, mem_ctx, &hnd_dst);
- if (got_dst_spoolss_pipe) {
- cli_nt_session_close(cli_dst);
+ if (cli_dst) {
cli_shutdown(cli_dst);
}
return nt_status;