| 1 | /*
|
|---|
| 2 | Samba Unix/Linux SMB client library
|
|---|
| 3 | Distributed SMB/CIFS Server Management Utility
|
|---|
| 4 | Copyright (C) 2004,2009 Guenther Deschner ([email protected])
|
|---|
| 5 |
|
|---|
| 6 | This program is free software; you can redistribute it and/or modify
|
|---|
| 7 | it under the terms of the GNU General Public License as published by
|
|---|
| 8 | the Free Software Foundation; either version 3 of the License, or
|
|---|
| 9 | (at your option) any later version.
|
|---|
| 10 |
|
|---|
| 11 | This program is distributed in the hope that it will be useful,
|
|---|
| 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|---|
| 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|---|
| 14 | GNU General Public License for more details.
|
|---|
| 15 |
|
|---|
| 16 | You should have received a copy of the GNU General Public License
|
|---|
| 17 | along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|---|
| 18 | */
|
|---|
| 19 | #include "includes.h"
|
|---|
| 20 | #include "utils/net.h"
|
|---|
| 21 | #include "../librpc/gen_ndr/cli_spoolss.h"
|
|---|
| 22 |
|
|---|
| 23 | /* support itanium as well */
|
|---|
| 24 | static const struct print_architecture_table_node archi_table[]= {
|
|---|
| 25 |
|
|---|
| 26 | {"Windows 4.0", "WIN40", 0 },
|
|---|
| 27 | {"Windows NT x86", "W32X86", 2 },
|
|---|
| 28 | {"Windows NT x86", "W32X86", 3 },
|
|---|
| 29 | {"Windows NT R4000", "W32MIPS", 2 },
|
|---|
| 30 | {"Windows NT Alpha_AXP", "W32ALPHA", 2 },
|
|---|
| 31 | {"Windows NT PowerPC", "W32PPC", 2 },
|
|---|
| 32 | {"Windows IA64", "IA64", 3 },
|
|---|
| 33 | {"Windows x64", "x64", 3 },
|
|---|
| 34 | {NULL, "", -1 }
|
|---|
| 35 | };
|
|---|
| 36 |
|
|---|
| 37 |
|
|---|
| 38 | /**
|
|---|
| 39 | * This display-printdriver-functions was borrowed from rpcclient/cmd_spoolss.c.
|
|---|
| 40 | * It is here for debugging purpose and should be removed later on.
|
|---|
| 41 | **/
|
|---|
| 42 |
|
|---|
| 43 | /****************************************************************************
|
|---|
| 44 | Printer info level 3 display function.
|
|---|
| 45 | ****************************************************************************/
|
|---|
| 46 |
|
|---|
| 47 | static void display_print_driver3(struct spoolss_DriverInfo3 *r)
|
|---|
| 48 | {
|
|---|
| 49 | int i;
|
|---|
| 50 |
|
|---|
| 51 | if (!r) {
|
|---|
| 52 | return;
|
|---|
| 53 | }
|
|---|
| 54 |
|
|---|
| 55 | printf(_("Printer Driver Info 3:\n"));
|
|---|
| 56 | printf(_("\tVersion: [%x]\n"), r->version);
|
|---|
| 57 | printf(_("\tDriver Name: [%s]\n"), r->driver_name);
|
|---|
| 58 | printf(_("\tArchitecture: [%s]\n"), r->architecture);
|
|---|
| 59 | printf(_("\tDriver Path: [%s]\n"), r->driver_path);
|
|---|
| 60 | printf(_("\tDatafile: [%s]\n"), r->data_file);
|
|---|
| 61 | printf(_("\tConfigfile: [%s]\n\n"), r->config_file);
|
|---|
| 62 | printf(_("\tHelpfile: [%s]\n\n"), r->help_file);
|
|---|
| 63 |
|
|---|
| 64 | for (i=0; r->dependent_files[i] != NULL; i++) {
|
|---|
| 65 | printf(_("\tDependentfiles: [%s]\n"), r->dependent_files[i]);
|
|---|
| 66 | }
|
|---|
| 67 |
|
|---|
| 68 | printf("\n");
|
|---|
| 69 |
|
|---|
| 70 | printf(_("\tMonitorname: [%s]\n"), r->monitor_name);
|
|---|
| 71 | printf(_("\tDefaultdatatype: [%s]\n\n"), r->default_datatype);
|
|---|
| 72 | }
|
|---|
| 73 |
|
|---|
| 74 | static void display_reg_value(const char *subkey, struct regval_blob value)
|
|---|
| 75 | {
|
|---|
| 76 | const char *text;
|
|---|
| 77 | DATA_BLOB blob;
|
|---|
| 78 |
|
|---|
| 79 | switch(value.type) {
|
|---|
| 80 | case REG_DWORD:
|
|---|
| 81 | d_printf(_("\t[%s:%s]: REG_DWORD: 0x%08x\n"), subkey,
|
|---|
| 82 | value.valuename, *((uint32_t *) value.data_p));
|
|---|
| 83 | break;
|
|---|
| 84 |
|
|---|
| 85 | case REG_SZ:
|
|---|
| 86 | blob = data_blob_const(value.data_p, value.size);
|
|---|
| 87 | pull_reg_sz(talloc_tos(), &blob, &text);
|
|---|
| 88 | if (!text) {
|
|---|
| 89 | break;
|
|---|
| 90 | }
|
|---|
| 91 | d_printf(_("\t[%s:%s]: REG_SZ: %s\n"), subkey, value.valuename,
|
|---|
| 92 | text);
|
|---|
| 93 | break;
|
|---|
| 94 |
|
|---|
| 95 | case REG_BINARY:
|
|---|
| 96 | d_printf(_("\t[%s:%s]: REG_BINARY: unknown length value not "
|
|---|
| 97 | "displayed\n"),
|
|---|
| 98 | subkey, value.valuename);
|
|---|
| 99 | break;
|
|---|
| 100 |
|
|---|
| 101 | case REG_MULTI_SZ: {
|
|---|
| 102 | uint32_t i;
|
|---|
| 103 | const char **values;
|
|---|
| 104 | blob = data_blob_const(value.data_p, value.size);
|
|---|
| 105 |
|
|---|
| 106 | if (!pull_reg_multi_sz(NULL, &blob, &values)) {
|
|---|
| 107 | d_printf("pull_reg_multi_sz failed\n");
|
|---|
| 108 | break;
|
|---|
| 109 | }
|
|---|
| 110 |
|
|---|
| 111 | printf("%s: REG_MULTI_SZ: \n", value.valuename);
|
|---|
| 112 | for (i=0; values[i] != NULL; i++) {
|
|---|
| 113 | d_printf("%s\n", values[i]);
|
|---|
| 114 | }
|
|---|
| 115 | TALLOC_FREE(values);
|
|---|
| 116 | break;
|
|---|
| 117 | }
|
|---|
| 118 |
|
|---|
| 119 | default:
|
|---|
| 120 | d_printf(_("\t%s: unknown type %d\n"), value.valuename,
|
|---|
| 121 | value.type);
|
|---|
| 122 | }
|
|---|
| 123 |
|
|---|
| 124 | }
|
|---|
| 125 |
|
|---|
| 126 | /**
|
|---|
| 127 | * Copies ACLs, DOS-attributes and timestamps from one
|
|---|
| 128 | * file or directory from one connected share to another connected share
|
|---|
| 129 | *
|
|---|
| 130 | * @param c A net_context structure
|
|---|
| 131 | * @param mem_ctx A talloc-context
|
|---|
| 132 | * @param cli_share_src A connected cli_state
|
|---|
| 133 | * @param cli_share_dst A connected cli_state
|
|---|
| 134 | * @param src_file The source file-name
|
|---|
| 135 | * @param dst_file The destination file-name
|
|---|
| 136 | * @param copy_acls Whether to copy acls
|
|---|
| 137 | * @param copy_attrs Whether to copy DOS attributes
|
|---|
| 138 | * @param copy_timestamps Whether to preserve timestamps
|
|---|
| 139 | * @param is_file Whether this file is a file or a dir
|
|---|
| 140 | *
|
|---|
| 141 | * @return Normal NTSTATUS return.
|
|---|
| 142 | **/
|
|---|
| 143 |
|
|---|
| 144 | NTSTATUS net_copy_fileattr(struct net_context *c,
|
|---|
| 145 | TALLOC_CTX *mem_ctx,
|
|---|
| 146 | struct cli_state *cli_share_src,
|
|---|
| 147 | struct cli_state *cli_share_dst,
|
|---|
| 148 | const char *src_name, const char *dst_name,
|
|---|
| 149 | bool copy_acls, bool copy_attrs,
|
|---|
| 150 | bool copy_timestamps, bool is_file)
|
|---|
| 151 | {
|
|---|
| 152 | NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
|
|---|
| 153 | uint16_t fnum_src = 0;
|
|---|
| 154 | uint16_t fnum_dst = 0;
|
|---|
| 155 | SEC_DESC *sd = NULL;
|
|---|
| 156 | uint16_t attr;
|
|---|
| 157 | time_t f_atime, f_ctime, f_mtime;
|
|---|
| 158 |
|
|---|
| 159 |
|
|---|
| 160 | if (!copy_timestamps && !copy_acls && !copy_attrs)
|
|---|
| 161 | return NT_STATUS_OK;
|
|---|
| 162 |
|
|---|
| 163 | /* open file/dir on the originating server */
|
|---|
| 164 |
|
|---|
| 165 | DEBUGADD(3,("opening %s %s on originating server\n",
|
|---|
| 166 | is_file?"file":"dir", src_name));
|
|---|
| 167 |
|
|---|
| 168 | if (!NT_STATUS_IS_OK(cli_ntcreate(cli_share_src, src_name, 0, READ_CONTROL_ACCESS, 0,
|
|---|
| 169 | FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_OPEN, 0x0, 0x0, &fnum_src))) {
|
|---|
| 170 | DEBUGADD(0,("cannot open %s %s on originating server %s\n",
|
|---|
| 171 | is_file?"file":"dir", src_name, cli_errstr(cli_share_src)));
|
|---|
| 172 | nt_status = cli_nt_error(cli_share_src);
|
|---|
| 173 | goto out;
|
|---|
| 174 | }
|
|---|
| 175 |
|
|---|
| 176 |
|
|---|
| 177 | if (copy_acls) {
|
|---|
| 178 |
|
|---|
| 179 | /* get the security descriptor */
|
|---|
| 180 | sd = cli_query_secdesc(cli_share_src, fnum_src, mem_ctx);
|
|---|
| 181 | if (!sd) {
|
|---|
| 182 | DEBUG(0,("failed to get security descriptor: %s\n",
|
|---|
| 183 | cli_errstr(cli_share_src)));
|
|---|
| 184 | nt_status = cli_nt_error(cli_share_src);
|
|---|
| 185 | goto out;
|
|---|
| 186 | }
|
|---|
| 187 |
|
|---|
| 188 | if (c->opt_verbose && DEBUGLEVEL >= 3)
|
|---|
| 189 | display_sec_desc(sd);
|
|---|
| 190 | }
|
|---|
| 191 |
|
|---|
| 192 |
|
|---|
| 193 | if (copy_attrs || copy_timestamps) {
|
|---|
| 194 |
|
|---|
| 195 | /* get file attributes */
|
|---|
| 196 | if (!NT_STATUS_IS_OK(cli_getattrE(cli_share_src, fnum_src, &attr, NULL,
|
|---|
| 197 | &f_ctime, &f_atime, &f_mtime))) {
|
|---|
| 198 | DEBUG(0,("failed to get file-attrs: %s\n",
|
|---|
| 199 | cli_errstr(cli_share_src)));
|
|---|
| 200 | nt_status = cli_nt_error(cli_share_src);
|
|---|
| 201 | goto out;
|
|---|
| 202 | }
|
|---|
| 203 | }
|
|---|
| 204 |
|
|---|
| 205 |
|
|---|
| 206 | /* open the file/dir on the destination server */
|
|---|
| 207 |
|
|---|
| 208 | if (!NT_STATUS_IS_OK(cli_ntcreate(cli_share_dst, dst_name, 0, WRITE_DAC_ACCESS | WRITE_OWNER_ACCESS, 0,
|
|---|
| 209 | FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_OPEN, 0x0, 0x0, &fnum_dst))) {
|
|---|
| 210 | DEBUG(0,("failed to open %s on the destination server: %s: %s\n",
|
|---|
| 211 | is_file?"file":"dir", dst_name, cli_errstr(cli_share_dst)));
|
|---|
| 212 | nt_status = cli_nt_error(cli_share_dst);
|
|---|
| 213 | goto out;
|
|---|
| 214 | }
|
|---|
| 215 |
|
|---|
| 216 | if (copy_timestamps) {
|
|---|
| 217 |
|
|---|
| 218 | /* set timestamps */
|
|---|
| 219 | if (!NT_STATUS_IS_OK(cli_setattrE(cli_share_dst, fnum_dst, f_ctime, f_atime, f_mtime))) {
|
|---|
| 220 | DEBUG(0,("failed to set file-attrs (timestamps): %s\n",
|
|---|
| 221 | cli_errstr(cli_share_dst)));
|
|---|
| 222 | nt_status = cli_nt_error(cli_share_dst);
|
|---|
| 223 | goto out;
|
|---|
| 224 | }
|
|---|
| 225 | }
|
|---|
| 226 |
|
|---|
| 227 | if (copy_acls) {
|
|---|
| 228 |
|
|---|
| 229 | /* set acls */
|
|---|
| 230 | if (!cli_set_secdesc(cli_share_dst, fnum_dst, sd)) {
|
|---|
| 231 | DEBUG(0,("could not set secdesc on %s: %s\n",
|
|---|
| 232 | dst_name, cli_errstr(cli_share_dst)));
|
|---|
| 233 | nt_status = cli_nt_error(cli_share_dst);
|
|---|
| 234 | goto out;
|
|---|
| 235 | }
|
|---|
| 236 | }
|
|---|
| 237 |
|
|---|
| 238 | if (copy_attrs) {
|
|---|
| 239 |
|
|---|
| 240 | /* set attrs */
|
|---|
| 241 | if (!NT_STATUS_IS_OK(cli_setatr(cli_share_dst, dst_name, attr, 0))) {
|
|---|
| 242 | DEBUG(0,("failed to set file-attrs: %s\n",
|
|---|
| 243 | cli_errstr(cli_share_dst)));
|
|---|
| 244 | nt_status = cli_nt_error(cli_share_dst);
|
|---|
| 245 | goto out;
|
|---|
| 246 | }
|
|---|
| 247 | }
|
|---|
| 248 |
|
|---|
| 249 |
|
|---|
| 250 | /* closing files */
|
|---|
| 251 |
|
|---|
| 252 | if (!NT_STATUS_IS_OK(cli_close(cli_share_src, fnum_src))) {
|
|---|
| 253 | d_fprintf(stderr,
|
|---|
| 254 | _("could not close %s on originating server: %s\n"),
|
|---|
| 255 | is_file?"file":"dir", cli_errstr(cli_share_src));
|
|---|
| 256 | nt_status = cli_nt_error(cli_share_src);
|
|---|
| 257 | goto out;
|
|---|
| 258 | }
|
|---|
| 259 |
|
|---|
| 260 | if (!NT_STATUS_IS_OK(cli_close(cli_share_dst, fnum_dst))) {
|
|---|
| 261 | d_fprintf(stderr,
|
|---|
| 262 | _("could not close %s on destination server: %s\n"),
|
|---|
| 263 | is_file?"file":"dir", cli_errstr(cli_share_dst));
|
|---|
| 264 | nt_status = cli_nt_error(cli_share_dst);
|
|---|
| 265 | goto out;
|
|---|
| 266 | }
|
|---|
| 267 |
|
|---|
| 268 |
|
|---|
| 269 | nt_status = NT_STATUS_OK;
|
|---|
| 270 |
|
|---|
| 271 | out:
|
|---|
| 272 |
|
|---|
| 273 | /* cleaning up */
|
|---|
| 274 | if (fnum_src)
|
|---|
| 275 | cli_close(cli_share_src, fnum_src);
|
|---|
| 276 |
|
|---|
| 277 | if (fnum_dst)
|
|---|
| 278 | cli_close(cli_share_dst, fnum_dst);
|
|---|
| 279 |
|
|---|
| 280 | return nt_status;
|
|---|
| 281 | }
|
|---|
| 282 |
|
|---|
| 283 | /**
|
|---|
| 284 | * Copy a file or directory from a connected share to another connected share
|
|---|
| 285 | *
|
|---|
| 286 | * @param c A net_context structure
|
|---|
| 287 | * @param mem_ctx A talloc-context
|
|---|
| 288 | * @param cli_share_src A connected cli_state
|
|---|
| 289 | * @param cli_share_dst A connected cli_state
|
|---|
| 290 | * @param src_file The source file-name
|
|---|
| 291 | * @param dst_file The destination file-name
|
|---|
| 292 | * @param copy_acls Whether to copy acls
|
|---|
| 293 | * @param copy_attrs Whether to copy DOS attributes
|
|---|
| 294 | * @param copy_timestamps Whether to preserve timestamps
|
|---|
| 295 | * @param is_file Whether this file is a file or a dir
|
|---|
| 296 | *
|
|---|
| 297 | * @return Normal NTSTATUS return.
|
|---|
| 298 | **/
|
|---|
| 299 |
|
|---|
| 300 | NTSTATUS net_copy_file(struct net_context *c,
|
|---|
| 301 | TALLOC_CTX *mem_ctx,
|
|---|
| 302 | struct cli_state *cli_share_src,
|
|---|
| 303 | struct cli_state *cli_share_dst,
|
|---|
| 304 | const char *src_name, const char *dst_name,
|
|---|
| 305 | bool copy_acls, bool copy_attrs,
|
|---|
| 306 | bool copy_timestamps, bool is_file)
|
|---|
| 307 | {
|
|---|
| 308 | NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
|
|---|
| 309 | uint16_t fnum_src = 0;
|
|---|
| 310 | uint16_t fnum_dst = 0;
|
|---|
| 311 | static int io_bufsize = 64512;
|
|---|
| 312 | int read_size = io_bufsize;
|
|---|
| 313 | char *data = NULL;
|
|---|
| 314 | off_t nread = 0;
|
|---|
| 315 |
|
|---|
| 316 |
|
|---|
| 317 | if (!src_name || !dst_name)
|
|---|
| 318 | goto out;
|
|---|
| 319 |
|
|---|
| 320 | if (cli_share_src == NULL || cli_share_dst == NULL)
|
|---|
| 321 | goto out;
|
|---|
| 322 |
|
|---|
| 323 | /* open on the originating server */
|
|---|
| 324 | DEBUGADD(3,("opening %s %s on originating server\n",
|
|---|
| 325 | is_file ? "file":"dir", src_name));
|
|---|
| 326 | if (is_file)
|
|---|
| 327 | nt_status = cli_open(cli_share_src, src_name, O_RDONLY, DENY_NONE, &fnum_src);
|
|---|
| 328 | else
|
|---|
| 329 | nt_status = cli_ntcreate(cli_share_src, src_name, 0, READ_CONTROL_ACCESS, 0,
|
|---|
| 330 | FILE_SHARE_READ|FILE_SHARE_WRITE, FILE_OPEN, 0x0, 0x0, &fnum_src);
|
|---|
| 331 |
|
|---|
| 332 | if (!NT_STATUS_IS_OK(nt_status)) {
|
|---|
| 333 | DEBUGADD(0,("cannot open %s %s on originating server %s\n",
|
|---|
| 334 | is_file ? "file":"dir",
|
|---|
| 335 | src_name, cli_errstr(cli_share_src)));
|
|---|
| 336 | goto out;
|
|---|
| 337 | }
|
|---|
| 338 |
|
|---|
| 339 |
|
|---|
| 340 | if (is_file) {
|
|---|
| 341 |
|
|---|
| 342 | /* open file on the destination server */
|
|---|
| 343 | DEBUGADD(3,("opening file %s on destination server\n", dst_name));
|
|---|
| 344 | nt_status = cli_open(cli_share_dst, dst_name,
|
|---|
| 345 | O_RDWR|O_CREAT|O_TRUNC, DENY_NONE, &fnum_dst);
|
|---|
| 346 |
|
|---|
| 347 | if (!NT_STATUS_IS_OK(nt_status)) {
|
|---|
| 348 | DEBUGADD(1,("cannot create file %s on destination server: %s\n",
|
|---|
| 349 | dst_name, cli_errstr(cli_share_dst)));
|
|---|
| 350 | goto out;
|
|---|
| 351 | }
|
|---|
| 352 |
|
|---|
| 353 | /* allocate memory */
|
|---|
| 354 | if (!(data = (char *)SMB_MALLOC(read_size))) {
|
|---|
| 355 | d_fprintf(stderr, _("malloc fail for size %d\n"),
|
|---|
| 356 | read_size);
|
|---|
| 357 | nt_status = NT_STATUS_NO_MEMORY;
|
|---|
| 358 | goto out;
|
|---|
| 359 | }
|
|---|
| 360 |
|
|---|
| 361 | }
|
|---|
| 362 |
|
|---|
| 363 |
|
|---|
| 364 | if (c->opt_verbose) {
|
|---|
| 365 |
|
|---|
| 366 | d_printf(_("copying [\\\\%s\\%s%s] => [\\\\%s\\%s%s] "
|
|---|
| 367 | "%s ACLs and %s DOS Attributes %s\n"),
|
|---|
| 368 | cli_share_src->desthost, cli_share_src->share, src_name,
|
|---|
| 369 | cli_share_dst->desthost, cli_share_dst->share, dst_name,
|
|---|
| 370 | copy_acls ? _("with") : _("without"),
|
|---|
| 371 | copy_attrs ? _("with") : _("without"),
|
|---|
| 372 | copy_timestamps ? _("(preserving timestamps)") : "" );
|
|---|
| 373 | }
|
|---|
| 374 |
|
|---|
| 375 |
|
|---|
| 376 | while (is_file) {
|
|---|
| 377 |
|
|---|
| 378 | /* copying file */
|
|---|
| 379 | int n, ret;
|
|---|
| 380 | n = cli_read(cli_share_src, fnum_src, data, nread,
|
|---|
| 381 | read_size);
|
|---|
| 382 |
|
|---|
| 383 | if (n <= 0)
|
|---|
| 384 | break;
|
|---|
| 385 |
|
|---|
| 386 | ret = cli_write(cli_share_dst, fnum_dst, 0, data,
|
|---|
| 387 | nread, n);
|
|---|
| 388 |
|
|---|
| 389 | if (n != ret) {
|
|---|
| 390 | d_fprintf(stderr, _("Error writing file: %s\n"),
|
|---|
| 391 | cli_errstr(cli_share_dst));
|
|---|
| 392 | nt_status = cli_nt_error(cli_share_dst);
|
|---|
| 393 | goto out;
|
|---|
| 394 | }
|
|---|
| 395 |
|
|---|
| 396 | nread += n;
|
|---|
| 397 | }
|
|---|
| 398 |
|
|---|
| 399 |
|
|---|
| 400 | if (!is_file && !NT_STATUS_IS_OK(cli_chkpath(cli_share_dst, dst_name))) {
|
|---|
| 401 |
|
|---|
| 402 | /* creating dir */
|
|---|
| 403 | DEBUGADD(3,("creating dir %s on the destination server\n",
|
|---|
| 404 | dst_name));
|
|---|
| 405 |
|
|---|
| 406 | if (!NT_STATUS_IS_OK(cli_mkdir(cli_share_dst, dst_name))) {
|
|---|
| 407 | DEBUG(0,("cannot create directory %s: %s\n",
|
|---|
| 408 | dst_name, cli_errstr(cli_share_dst)));
|
|---|
| 409 | nt_status = NT_STATUS_NO_SUCH_FILE;
|
|---|
| 410 | }
|
|---|
| 411 |
|
|---|
| 412 | if (!NT_STATUS_IS_OK(cli_chkpath(cli_share_dst, dst_name))) {
|
|---|
| 413 | d_fprintf(stderr,
|
|---|
| 414 | _("cannot check for directory %s: %s\n"),
|
|---|
| 415 | dst_name, cli_errstr(cli_share_dst));
|
|---|
| 416 | goto out;
|
|---|
| 417 | }
|
|---|
| 418 | }
|
|---|
| 419 |
|
|---|
| 420 |
|
|---|
| 421 | /* closing files */
|
|---|
| 422 | if (!NT_STATUS_IS_OK(cli_close(cli_share_src, fnum_src))) {
|
|---|
| 423 | d_fprintf(stderr,
|
|---|
| 424 | _("could not close file on originating server: %s\n"),
|
|---|
| 425 | cli_errstr(cli_share_src));
|
|---|
| 426 | nt_status = cli_nt_error(cli_share_src);
|
|---|
| 427 | goto out;
|
|---|
| 428 | }
|
|---|
| 429 |
|
|---|
| 430 | if (is_file && !NT_STATUS_IS_OK(cli_close(cli_share_dst, fnum_dst))) {
|
|---|
| 431 | d_fprintf(stderr,
|
|---|
| 432 | _("could not close file on destination server: %s\n"),
|
|---|
| 433 | cli_errstr(cli_share_dst));
|
|---|
| 434 | nt_status = cli_nt_error(cli_share_dst);
|
|---|
| 435 | goto out;
|
|---|
| 436 | }
|
|---|
| 437 |
|
|---|
| 438 | /* possibly we have to copy some file-attributes / acls / sd */
|
|---|
| 439 | nt_status = net_copy_fileattr(c, mem_ctx, cli_share_src, cli_share_dst,
|
|---|
| 440 | src_name, dst_name, copy_acls,
|
|---|
| 441 | copy_attrs, copy_timestamps, is_file);
|
|---|
| 442 | if (!NT_STATUS_IS_OK(nt_status))
|
|---|
| 443 | goto out;
|
|---|
| 444 |
|
|---|
| 445 |
|
|---|
| 446 | nt_status = NT_STATUS_OK;
|
|---|
| 447 |
|
|---|
| 448 | out:
|
|---|
| 449 |
|
|---|
| 450 | /* cleaning up */
|
|---|
| 451 | if (fnum_src)
|
|---|
| 452 | cli_close(cli_share_src, fnum_src);
|
|---|
| 453 |
|
|---|
| 454 | if (fnum_dst)
|
|---|
| 455 | cli_close(cli_share_dst, fnum_dst);
|
|---|
| 456 |
|
|---|
| 457 | SAFE_FREE(data);
|
|---|
| 458 |
|
|---|
| 459 | return nt_status;
|
|---|
| 460 | }
|
|---|
| 461 |
|
|---|
| 462 | /**
|
|---|
| 463 | * Copy a driverfile from on connected share to another connected share
|
|---|
| 464 | * This silently assumes that a driver-file is picked up from
|
|---|
| 465 | *
|
|---|
| 466 | * \\src_server\print$\{arch}\{version}\file
|
|---|
| 467 | *
|
|---|
| 468 | * and copied to
|
|---|
| 469 | *
|
|---|
| 470 | * \\dst_server\print$\{arch}\file
|
|---|
| 471 | *
|
|---|
| 472 | * to be added via setdriver-calls later.
|
|---|
| 473 | * @param c A net_context structure
|
|---|
| 474 | * @param mem_ctx A talloc-context
|
|---|
| 475 | * @param cli_share_src A cli_state connected to source print$-share
|
|---|
| 476 | * @param cli_share_dst A cli_state connected to destination print$-share
|
|---|
| 477 | * @param file The file-name to be copied
|
|---|
| 478 | * @param short_archi The name of the driver-architecture (short form)
|
|---|
| 479 | *
|
|---|
| 480 | * @return Normal NTSTATUS return.
|
|---|
| 481 | **/
|
|---|
| 482 |
|
|---|
| 483 | static NTSTATUS net_copy_driverfile(struct net_context *c,
|
|---|
| 484 | TALLOC_CTX *mem_ctx,
|
|---|
| 485 | struct cli_state *cli_share_src,
|
|---|
| 486 | struct cli_state *cli_share_dst,
|
|---|
| 487 | const char *file, const char *short_archi) {
|
|---|
| 488 |
|
|---|
| 489 | NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
|
|---|
| 490 | const char *p;
|
|---|
| 491 | char *src_name;
|
|---|
| 492 | char *dst_name;
|
|---|
| 493 | char *version;
|
|---|
| 494 | char *filename;
|
|---|
| 495 | char *tok;
|
|---|
| 496 |
|
|---|
| 497 | if (!file) {
|
|---|
| 498 | return NT_STATUS_OK;
|
|---|
| 499 | }
|
|---|
| 500 |
|
|---|
| 501 | /* scroll through the file until we have the part
|
|---|
| 502 | beyond archi_table.short_archi */
|
|---|
| 503 | p = file;
|
|---|
| 504 | while (next_token_talloc(mem_ctx, &p, &tok, "\\")) {
|
|---|
| 505 | if (strequal(tok, short_archi)) {
|
|---|
| 506 | next_token_talloc(mem_ctx, &p, &version, "\\");
|
|---|
| 507 | next_token_talloc(mem_ctx, &p, &filename, "\\");
|
|---|
| 508 | }
|
|---|
| 509 | }
|
|---|
| 510 |
|
|---|
| 511 | /* build source file name */
|
|---|
| 512 | if (asprintf(&src_name, "\\%s\\%s\\%s", short_archi, version, filename) < 0 )
|
|---|
| 513 | return NT_STATUS_NO_MEMORY;
|
|---|
| 514 |
|
|---|
| 515 |
|
|---|
| 516 | /* create destination file name */
|
|---|
| 517 | if (asprintf(&dst_name, "\\%s\\%s", short_archi, filename) < 0 )
|
|---|
| 518 | return NT_STATUS_NO_MEMORY;
|
|---|
| 519 |
|
|---|
| 520 |
|
|---|
| 521 | /* finally copy the file */
|
|---|
| 522 | nt_status = net_copy_file(c, mem_ctx, cli_share_src, cli_share_dst,
|
|---|
| 523 | src_name, dst_name, false, false, false, true);
|
|---|
| 524 | if (!NT_STATUS_IS_OK(nt_status))
|
|---|
| 525 | goto out;
|
|---|
| 526 |
|
|---|
| 527 | nt_status = NT_STATUS_OK;
|
|---|
| 528 |
|
|---|
| 529 | out:
|
|---|
| 530 | SAFE_FREE(src_name);
|
|---|
| 531 | SAFE_FREE(dst_name);
|
|---|
| 532 |
|
|---|
| 533 | return nt_status;
|
|---|
| 534 | }
|
|---|
| 535 |
|
|---|
| 536 | /**
|
|---|
| 537 | * Check for existing Architecture directory on a given server
|
|---|
| 538 | *
|
|---|
| 539 | * @param cli_share A cli_state connected to a print$-share
|
|---|
| 540 | * @param short_archi The Architecture for the print-driver
|
|---|
| 541 | *
|
|---|
| 542 | * @return Normal NTSTATUS return.
|
|---|
| 543 | **/
|
|---|
| 544 |
|
|---|
| 545 | static NTSTATUS check_arch_dir(struct cli_state *cli_share, const char *short_archi)
|
|---|
| 546 | {
|
|---|
| 547 |
|
|---|
| 548 | NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
|
|---|
| 549 | char *dir;
|
|---|
| 550 |
|
|---|
| 551 | if (asprintf(&dir, "\\%s", short_archi) < 0) {
|
|---|
| 552 | return NT_STATUS_NO_MEMORY;
|
|---|
| 553 | }
|
|---|
| 554 |
|
|---|
| 555 | DEBUG(10,("creating print-driver dir for architecture: %s\n",
|
|---|
| 556 | short_archi));
|
|---|
| 557 |
|
|---|
| 558 | if (!NT_STATUS_IS_OK(cli_mkdir(cli_share, dir))) {
|
|---|
| 559 | DEBUG(1,("cannot create directory %s: %s\n",
|
|---|
| 560 | dir, cli_errstr(cli_share)));
|
|---|
| 561 | nt_status = NT_STATUS_NO_SUCH_FILE;
|
|---|
| 562 | }
|
|---|
| 563 |
|
|---|
| 564 | if (!NT_STATUS_IS_OK(cli_chkpath(cli_share, dir))) {
|
|---|
| 565 | d_fprintf(stderr, _("cannot check %s: %s\n"),
|
|---|
| 566 | dir, cli_errstr(cli_share));
|
|---|
| 567 | goto out;
|
|---|
| 568 | }
|
|---|
| 569 |
|
|---|
| 570 | nt_status = NT_STATUS_OK;
|
|---|
| 571 |
|
|---|
| 572 | out:
|
|---|
| 573 | SAFE_FREE(dir);
|
|---|
| 574 | return nt_status;
|
|---|
| 575 | }
|
|---|
| 576 |
|
|---|
| 577 | /**
|
|---|
| 578 | * Copy a print-driver (level 3) from one connected print$-share to another
|
|---|
| 579 | * connected print$-share
|
|---|
| 580 | *
|
|---|
| 581 | * @param c A net_context structure
|
|---|
| 582 | * @param mem_ctx A talloc-context
|
|---|
| 583 | * @param cli_share_src A cli_state connected to a print$-share
|
|---|
| 584 | * @param cli_share_dst A cli_state connected to a print$-share
|
|---|
| 585 | * @param short_archi The Architecture for the print-driver
|
|---|
| 586 | * @param i1 The DRIVER_INFO_3-struct
|
|---|
| 587 | *
|
|---|
| 588 | * @return Normal NTSTATUS return.
|
|---|
| 589 | **/
|
|---|
| 590 |
|
|---|
| 591 | static NTSTATUS copy_print_driver_3(struct net_context *c,
|
|---|
| 592 | TALLOC_CTX *mem_ctx,
|
|---|
| 593 | struct cli_state *cli_share_src,
|
|---|
| 594 | struct cli_state *cli_share_dst,
|
|---|
| 595 | const char *short_archi,
|
|---|
| 596 | struct spoolss_DriverInfo3 *r)
|
|---|
| 597 | {
|
|---|
| 598 | NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
|
|---|
| 599 | int i;
|
|---|
| 600 |
|
|---|
| 601 | if (r == NULL) {
|
|---|
| 602 | return nt_status;
|
|---|
| 603 | }
|
|---|
| 604 |
|
|---|
| 605 | if (c->opt_verbose)
|
|---|
| 606 | d_printf(_("copying driver: [%s], for architecture: [%s], "
|
|---|
| 607 | "version: [%d]\n"),
|
|---|
| 608 | r->driver_name, short_archi, r->version);
|
|---|
| 609 |
|
|---|
| 610 | nt_status = net_copy_driverfile(c, mem_ctx, cli_share_src, cli_share_dst,
|
|---|
| 611 | r->driver_path, short_archi);
|
|---|
| 612 | if (!NT_STATUS_IS_OK(nt_status))
|
|---|
| 613 | return nt_status;
|
|---|
| 614 |
|
|---|
| 615 | nt_status = net_copy_driverfile(c, mem_ctx, cli_share_src, cli_share_dst,
|
|---|
| 616 | r->data_file, short_archi);
|
|---|
| 617 | if (!NT_STATUS_IS_OK(nt_status))
|
|---|
| 618 | return nt_status;
|
|---|
| 619 |
|
|---|
| 620 | nt_status = net_copy_driverfile(c, mem_ctx, cli_share_src, cli_share_dst,
|
|---|
| 621 | r->config_file, short_archi);
|
|---|
| 622 | if (!NT_STATUS_IS_OK(nt_status))
|
|---|
| 623 | return nt_status;
|
|---|
| 624 |
|
|---|
| 625 | nt_status = net_copy_driverfile(c, mem_ctx, cli_share_src, cli_share_dst,
|
|---|
| 626 | r->help_file, short_archi);
|
|---|
| 627 | if (!NT_STATUS_IS_OK(nt_status))
|
|---|
| 628 | return nt_status;
|
|---|
| 629 |
|
|---|
| 630 | for (i=0; r->dependent_files[i] != NULL; i++) {
|
|---|
| 631 |
|
|---|
| 632 | nt_status = net_copy_driverfile(c, mem_ctx,
|
|---|
| 633 | cli_share_src, cli_share_dst,
|
|---|
| 634 | r->dependent_files[i], short_archi);
|
|---|
| 635 | if (!NT_STATUS_IS_OK(nt_status)) {
|
|---|
| 636 | return nt_status;
|
|---|
| 637 | }
|
|---|
| 638 | }
|
|---|
| 639 |
|
|---|
| 640 | return NT_STATUS_OK;
|
|---|
| 641 | }
|
|---|
| 642 |
|
|---|
| 643 | /**
|
|---|
| 644 | * net_spoolss-functions
|
|---|
| 645 | * =====================
|
|---|
| 646 | *
|
|---|
| 647 | * the net_spoolss-functions aim to simplify spoolss-client-functions
|
|---|
| 648 | * required during the migration-process wrt buffer-sizes, returned
|
|---|
| 649 | * error-codes, etc.
|
|---|
| 650 | *
|
|---|
| 651 | * this greatly reduces the complexitiy of the migrate-functions.
|
|---|
| 652 | *
|
|---|
| 653 | **/
|
|---|
| 654 |
|
|---|
| 655 | static bool net_spoolss_enum_printers(struct rpc_pipe_client *pipe_hnd,
|
|---|
| 656 | TALLOC_CTX *mem_ctx,
|
|---|
| 657 | char *name,
|
|---|
| 658 | uint32_t flags,
|
|---|
| 659 | uint32_t level,
|
|---|
| 660 | uint32_t *num_printers,
|
|---|
| 661 | union spoolss_PrinterInfo **info)
|
|---|
| 662 | {
|
|---|
| 663 | WERROR result;
|
|---|
| 664 |
|
|---|
| 665 | /* enum printers */
|
|---|
| 666 |
|
|---|
| 667 | result = rpccli_spoolss_enumprinters(pipe_hnd, mem_ctx,
|
|---|
| 668 | flags,
|
|---|
| 669 | name,
|
|---|
| 670 | level,
|
|---|
| 671 | 0,
|
|---|
| 672 | num_printers,
|
|---|
| 673 | info);
|
|---|
| 674 | if (!W_ERROR_IS_OK(result)) {
|
|---|
| 675 | printf(_("cannot enum printers: %s\n"), win_errstr(result));
|
|---|
| 676 | return false;
|
|---|
| 677 | }
|
|---|
| 678 |
|
|---|
| 679 | return true;
|
|---|
| 680 | }
|
|---|
| 681 |
|
|---|
| 682 | static bool net_spoolss_open_printer_ex(struct rpc_pipe_client *pipe_hnd,
|
|---|
| 683 | TALLOC_CTX *mem_ctx,
|
|---|
| 684 | const char *printername,
|
|---|
| 685 | uint32_t access_required,
|
|---|
| 686 | const char *username,
|
|---|
| 687 | struct policy_handle *hnd)
|
|---|
| 688 | {
|
|---|
| 689 | WERROR result;
|
|---|
| 690 | fstring printername2;
|
|---|
| 691 |
|
|---|
| 692 | fstrcpy(printername2, pipe_hnd->srv_name_slash);
|
|---|
| 693 | fstrcat(printername2, "\\");
|
|---|
| 694 | fstrcat(printername2, printername);
|
|---|
| 695 |
|
|---|
| 696 | DEBUG(10,("connecting to: %s as %s for %s and access: %x\n",
|
|---|
| 697 | pipe_hnd->srv_name_slash, username, printername2, access_required));
|
|---|
| 698 |
|
|---|
| 699 | /* open printer */
|
|---|
| 700 | result = rpccli_spoolss_openprinter_ex(pipe_hnd, mem_ctx,
|
|---|
| 701 | printername2,
|
|---|
| 702 | access_required,
|
|---|
| 703 | hnd);
|
|---|
| 704 |
|
|---|
| 705 | /* be more verbose */
|
|---|
| 706 | if (W_ERROR_V(result) == W_ERROR_V(WERR_ACCESS_DENIED)) {
|
|---|
| 707 | d_fprintf(stderr,
|
|---|
| 708 | _("no access to printer [%s] on [%s] for user [%s] "
|
|---|
| 709 | "granted\n"),
|
|---|
| 710 | printername2, pipe_hnd->srv_name_slash, username);
|
|---|
| 711 | return false;
|
|---|
| 712 | }
|
|---|
| 713 |
|
|---|
| 714 | if (!W_ERROR_IS_OK(result)) {
|
|---|
| 715 | d_fprintf(stderr,_("cannot open printer %s on server %s: %s\n"),
|
|---|
| 716 | printername2, pipe_hnd->srv_name_slash, win_errstr(result));
|
|---|
| 717 | return false;
|
|---|
| 718 | }
|
|---|
| 719 |
|
|---|
| 720 | DEBUG(2,("got printer handle for printer: %s, server: %s\n",
|
|---|
| 721 | printername2, pipe_hnd->srv_name_slash));
|
|---|
| 722 |
|
|---|
| 723 | return true;
|
|---|
| 724 | }
|
|---|
| 725 |
|
|---|
| 726 | static bool net_spoolss_getprinter(struct rpc_pipe_client *pipe_hnd,
|
|---|
| 727 | TALLOC_CTX *mem_ctx,
|
|---|
| 728 | struct policy_handle *hnd,
|
|---|
| 729 | uint32_t level,
|
|---|
| 730 | union spoolss_PrinterInfo *info)
|
|---|
| 731 | {
|
|---|
| 732 | WERROR result;
|
|---|
| 733 |
|
|---|
| 734 | /* getprinter call */
|
|---|
| 735 | result = rpccli_spoolss_getprinter(pipe_hnd, mem_ctx,
|
|---|
| 736 | hnd,
|
|---|
| 737 | level,
|
|---|
| 738 | 0, /* offered */
|
|---|
| 739 | info);
|
|---|
| 740 | if (!W_ERROR_IS_OK(result)) {
|
|---|
| 741 | printf(_("cannot get printer-info: %s\n"), win_errstr(result));
|
|---|
| 742 | return false;
|
|---|
| 743 | }
|
|---|
| 744 |
|
|---|
| 745 | return true;
|
|---|
| 746 | }
|
|---|
| 747 |
|
|---|
| 748 | static bool net_spoolss_setprinter(struct rpc_pipe_client *pipe_hnd,
|
|---|
| 749 | TALLOC_CTX *mem_ctx,
|
|---|
| 750 | struct policy_handle *hnd,
|
|---|
| 751 | uint32_t level,
|
|---|
| 752 | union spoolss_PrinterInfo *info)
|
|---|
| 753 | {
|
|---|
| 754 | WERROR result;
|
|---|
| 755 | NTSTATUS status;
|
|---|
| 756 | struct spoolss_SetPrinterInfoCtr info_ctr;
|
|---|
| 757 | struct spoolss_SetPrinterInfo2 info2;
|
|---|
| 758 | struct spoolss_DevmodeContainer devmode_ctr;
|
|---|
| 759 | struct sec_desc_buf secdesc_ctr;
|
|---|
| 760 |
|
|---|
| 761 | ZERO_STRUCT(devmode_ctr);
|
|---|
| 762 | ZERO_STRUCT(secdesc_ctr);
|
|---|
| 763 |
|
|---|
| 764 | /* setprinter call */
|
|---|
| 765 |
|
|---|
| 766 | info_ctr.level = level;
|
|---|
| 767 | switch (level) {
|
|---|
| 768 | case 0:
|
|---|
| 769 | info_ctr.info.info0 = (struct spoolss_SetPrinterInfo0 *)
|
|---|
| 770 | (void *)&info->info0;
|
|---|
| 771 | break;
|
|---|
| 772 | case 1:
|
|---|
| 773 | info_ctr.info.info1 = (struct spoolss_SetPrinterInfo1 *)
|
|---|
| 774 | (void *)&info->info1;
|
|---|
| 775 | break;
|
|---|
| 776 | case 2:
|
|---|
| 777 | spoolss_printerinfo2_to_setprinterinfo2(&info->info2, &info2);
|
|---|
| 778 | info_ctr.info.info2 = &info2;
|
|---|
| 779 | break;
|
|---|
| 780 | case 3:
|
|---|
| 781 | info_ctr.info.info3 = (struct spoolss_SetPrinterInfo3 *)
|
|---|
| 782 | (void *)&info->info3;
|
|---|
| 783 | break;
|
|---|
| 784 | case 4:
|
|---|
| 785 | info_ctr.info.info4 = (struct spoolss_SetPrinterInfo4 *)
|
|---|
| 786 | (void *)&info->info4;
|
|---|
| 787 | break;
|
|---|
| 788 | case 5:
|
|---|
| 789 | info_ctr.info.info5 = (struct spoolss_SetPrinterInfo5 *)
|
|---|
| 790 | (void *)&info->info5;
|
|---|
| 791 | break;
|
|---|
| 792 | case 6:
|
|---|
| 793 | info_ctr.info.info6 = (struct spoolss_SetPrinterInfo6 *)
|
|---|
| 794 | (void *)&info->info6;
|
|---|
| 795 | break;
|
|---|
| 796 | case 7:
|
|---|
| 797 | info_ctr.info.info7 = (struct spoolss_SetPrinterInfo7 *)
|
|---|
| 798 | (void *)&info->info7;
|
|---|
| 799 | break;
|
|---|
| 800 | #if 0 /* FIXME GD */
|
|---|
| 801 | case 8:
|
|---|
| 802 | info_ctr.info.info8 = (struct spoolss_SetPrinterInfo8 *)
|
|---|
| 803 | (void *)&info->info8;
|
|---|
| 804 | break;
|
|---|
| 805 | case 9:
|
|---|
| 806 | info_ctr.info.info9 = (struct spoolss_SetPrinterInfo9 *)
|
|---|
| 807 | (void *)&info->info9;
|
|---|
| 808 | break;
|
|---|
| 809 | #endif
|
|---|
| 810 | default:
|
|---|
| 811 | break; /* FIXME */
|
|---|
| 812 | }
|
|---|
| 813 |
|
|---|
| 814 | status = rpccli_spoolss_SetPrinter(pipe_hnd, mem_ctx,
|
|---|
| 815 | hnd,
|
|---|
| 816 | &info_ctr,
|
|---|
| 817 | &devmode_ctr,
|
|---|
| 818 | &secdesc_ctr,
|
|---|
| 819 | 0, /* command */
|
|---|
| 820 | &result);
|
|---|
| 821 |
|
|---|
| 822 | if (!W_ERROR_IS_OK(result)) {
|
|---|
| 823 | printf(_("cannot set printer-info: %s\n"), win_errstr(result));
|
|---|
| 824 | return false;
|
|---|
| 825 | }
|
|---|
| 826 |
|
|---|
| 827 | return true;
|
|---|
| 828 | }
|
|---|
| 829 |
|
|---|
| 830 |
|
|---|
| 831 | static bool net_spoolss_setprinterdata(struct rpc_pipe_client *pipe_hnd,
|
|---|
| 832 | TALLOC_CTX *mem_ctx,
|
|---|
| 833 | struct policy_handle *hnd,
|
|---|
| 834 | const char *value_name,
|
|---|
| 835 | enum winreg_Type type,
|
|---|
| 836 | uint8_t *data,
|
|---|
| 837 | uint32_t offered)
|
|---|
| 838 | {
|
|---|
| 839 | WERROR result;
|
|---|
| 840 | NTSTATUS status;
|
|---|
| 841 |
|
|---|
| 842 | /* setprinterdata call */
|
|---|
| 843 | status = rpccli_spoolss_SetPrinterData(pipe_hnd, mem_ctx,
|
|---|
| 844 | hnd,
|
|---|
| 845 | value_name,
|
|---|
| 846 | type,
|
|---|
| 847 | data,
|
|---|
| 848 | offered,
|
|---|
| 849 | &result);
|
|---|
| 850 |
|
|---|
| 851 | if (!W_ERROR_IS_OK(result)) {
|
|---|
| 852 | printf (_("unable to set printerdata: %s\n"),
|
|---|
| 853 | win_errstr(result));
|
|---|
| 854 | return false;
|
|---|
| 855 | }
|
|---|
| 856 |
|
|---|
| 857 | return true;
|
|---|
| 858 | }
|
|---|
| 859 |
|
|---|
| 860 |
|
|---|
| 861 | static bool net_spoolss_enumprinterkey(struct rpc_pipe_client *pipe_hnd,
|
|---|
| 862 | TALLOC_CTX *mem_ctx,
|
|---|
| 863 | struct policy_handle *hnd,
|
|---|
| 864 | const char *keyname,
|
|---|
| 865 | const char ***keylist)
|
|---|
| 866 | {
|
|---|
| 867 | WERROR result;
|
|---|
| 868 |
|
|---|
| 869 | /* enumprinterkey call */
|
|---|
| 870 | result = rpccli_spoolss_enumprinterkey(pipe_hnd, mem_ctx, hnd, keyname, keylist, 0);
|
|---|
| 871 |
|
|---|
| 872 | if (!W_ERROR_IS_OK(result)) {
|
|---|
| 873 | printf(_("enumprinterkey failed: %s\n"), win_errstr(result));
|
|---|
| 874 | return false;
|
|---|
| 875 | }
|
|---|
| 876 |
|
|---|
| 877 | return true;
|
|---|
| 878 | }
|
|---|
| 879 |
|
|---|
| 880 | static bool net_spoolss_enumprinterdataex(struct rpc_pipe_client *pipe_hnd,
|
|---|
| 881 | TALLOC_CTX *mem_ctx,
|
|---|
| 882 | uint32_t offered,
|
|---|
| 883 | struct policy_handle *hnd,
|
|---|
| 884 | const char *keyname,
|
|---|
| 885 | uint32_t *count,
|
|---|
| 886 | struct spoolss_PrinterEnumValues **info)
|
|---|
| 887 | {
|
|---|
| 888 | WERROR result;
|
|---|
| 889 |
|
|---|
| 890 | /* enumprinterdataex call */
|
|---|
| 891 | result = rpccli_spoolss_enumprinterdataex(pipe_hnd, mem_ctx,
|
|---|
| 892 | hnd,
|
|---|
| 893 | keyname,
|
|---|
| 894 | 0, /* offered */
|
|---|
| 895 | count,
|
|---|
| 896 | info);
|
|---|
| 897 |
|
|---|
| 898 | if (!W_ERROR_IS_OK(result)) {
|
|---|
| 899 | printf(_("enumprinterdataex failed: %s\n"), win_errstr(result));
|
|---|
| 900 | return false;
|
|---|
| 901 | }
|
|---|
| 902 |
|
|---|
| 903 | return true;
|
|---|
| 904 | }
|
|---|
| 905 |
|
|---|
| 906 |
|
|---|
| 907 | static bool net_spoolss_setprinterdataex(struct rpc_pipe_client *pipe_hnd,
|
|---|
| 908 | TALLOC_CTX *mem_ctx,
|
|---|
| 909 | struct policy_handle *hnd,
|
|---|
| 910 | const char *keyname,
|
|---|
| 911 | struct regval_blob *value)
|
|---|
| 912 | {
|
|---|
| 913 | WERROR result;
|
|---|
| 914 | NTSTATUS status;
|
|---|
| 915 |
|
|---|
| 916 | /* setprinterdataex call */
|
|---|
| 917 | status = rpccli_spoolss_SetPrinterDataEx(pipe_hnd, mem_ctx,
|
|---|
| 918 | hnd,
|
|---|
| 919 | keyname,
|
|---|
| 920 | value->valuename,
|
|---|
| 921 | value->type,
|
|---|
| 922 | value->data_p,
|
|---|
| 923 | value->size,
|
|---|
| 924 | &result);
|
|---|
| 925 |
|
|---|
| 926 | if (!W_ERROR_IS_OK(result)) {
|
|---|
| 927 | printf(_("could not set printerdataex: %s\n"),
|
|---|
| 928 | win_errstr(result));
|
|---|
| 929 | return false;
|
|---|
| 930 | }
|
|---|
| 931 |
|
|---|
| 932 | return true;
|
|---|
| 933 | }
|
|---|
| 934 |
|
|---|
| 935 | static bool net_spoolss_enumforms(struct rpc_pipe_client *pipe_hnd,
|
|---|
| 936 | TALLOC_CTX *mem_ctx,
|
|---|
| 937 | struct policy_handle *hnd,
|
|---|
| 938 | int level,
|
|---|
| 939 | uint32_t *num_forms,
|
|---|
| 940 | union spoolss_FormInfo **forms)
|
|---|
| 941 | {
|
|---|
| 942 | WERROR result;
|
|---|
| 943 |
|
|---|
| 944 | /* enumforms call */
|
|---|
| 945 | result = rpccli_spoolss_enumforms(pipe_hnd, mem_ctx,
|
|---|
| 946 | hnd,
|
|---|
| 947 | level,
|
|---|
| 948 | 0,
|
|---|
| 949 | num_forms,
|
|---|
| 950 | forms);
|
|---|
| 951 | if (!W_ERROR_IS_OK(result)) {
|
|---|
| 952 | printf(_("could not enum forms: %s\n"), win_errstr(result));
|
|---|
| 953 | return false;
|
|---|
| 954 | }
|
|---|
| 955 |
|
|---|
| 956 | return true;
|
|---|
| 957 | }
|
|---|
| 958 |
|
|---|
| 959 | static bool net_spoolss_enumprinterdrivers (struct rpc_pipe_client *pipe_hnd,
|
|---|
| 960 | TALLOC_CTX *mem_ctx,
|
|---|
| 961 | uint32_t level, const char *env,
|
|---|
| 962 | uint32_t *count,
|
|---|
| 963 | union spoolss_DriverInfo **info)
|
|---|
| 964 | {
|
|---|
| 965 | WERROR result;
|
|---|
| 966 |
|
|---|
| 967 | /* enumprinterdrivers call */
|
|---|
| 968 | result = rpccli_spoolss_enumprinterdrivers(pipe_hnd, mem_ctx,
|
|---|
| 969 | pipe_hnd->srv_name_slash,
|
|---|
| 970 | env,
|
|---|
| 971 | level,
|
|---|
| 972 | 0,
|
|---|
| 973 | count,
|
|---|
| 974 | info);
|
|---|
| 975 | if (!W_ERROR_IS_OK(result)) {
|
|---|
| 976 | printf(_("cannot enum drivers: %s\n"), win_errstr(result));
|
|---|
| 977 | return false;
|
|---|
| 978 | }
|
|---|
| 979 |
|
|---|
| 980 | return true;
|
|---|
| 981 | }
|
|---|
| 982 |
|
|---|
| 983 | static bool net_spoolss_getprinterdriver(struct rpc_pipe_client *pipe_hnd,
|
|---|
| 984 | TALLOC_CTX *mem_ctx,
|
|---|
| 985 | struct policy_handle *hnd, uint32_t level,
|
|---|
| 986 | const char *env, int version,
|
|---|
| 987 | union spoolss_DriverInfo *info)
|
|---|
| 988 | {
|
|---|
| 989 | WERROR result;
|
|---|
| 990 | uint32_t server_major_version;
|
|---|
| 991 | uint32_t server_minor_version;
|
|---|
| 992 |
|
|---|
| 993 | /* getprinterdriver call */
|
|---|
| 994 | result = rpccli_spoolss_getprinterdriver2(pipe_hnd, mem_ctx,
|
|---|
| 995 | hnd,
|
|---|
| 996 | env,
|
|---|
| 997 | level,
|
|---|
| 998 | 0,
|
|---|
| 999 | version,
|
|---|
| 1000 | 2,
|
|---|
| 1001 | info,
|
|---|
| 1002 | &server_major_version,
|
|---|
| 1003 | &server_minor_version);
|
|---|
| 1004 | if (!W_ERROR_IS_OK(result)) {
|
|---|
| 1005 | DEBUG(1,("cannot get driver (for architecture: %s): %s\n",
|
|---|
| 1006 | env, win_errstr(result)));
|
|---|
| 1007 | if (W_ERROR_V(result) != W_ERROR_V(WERR_UNKNOWN_PRINTER_DRIVER) &&
|
|---|
| 1008 | W_ERROR_V(result) != W_ERROR_V(WERR_INVALID_ENVIRONMENT)) {
|
|---|
| 1009 | printf(_("cannot get driver: %s\n"),
|
|---|
| 1010 | win_errstr(result));
|
|---|
| 1011 | }
|
|---|
| 1012 | return false;
|
|---|
| 1013 | }
|
|---|
| 1014 |
|
|---|
| 1015 | return true;
|
|---|
| 1016 | }
|
|---|
| 1017 |
|
|---|
| 1018 |
|
|---|
| 1019 | static bool net_spoolss_addprinterdriver(struct rpc_pipe_client *pipe_hnd,
|
|---|
| 1020 | TALLOC_CTX *mem_ctx, uint32_t level,
|
|---|
| 1021 | union spoolss_DriverInfo *info)
|
|---|
| 1022 | {
|
|---|
| 1023 | WERROR result;
|
|---|
| 1024 | NTSTATUS status;
|
|---|
| 1025 | struct spoolss_AddDriverInfoCtr info_ctr;
|
|---|
| 1026 |
|
|---|
| 1027 | info_ctr.level = level;
|
|---|
| 1028 |
|
|---|
| 1029 | switch (level) {
|
|---|
| 1030 | case 2:
|
|---|
| 1031 | info_ctr.info.info2 = (struct spoolss_AddDriverInfo2 *)
|
|---|
| 1032 | (void *)&info->info2;
|
|---|
| 1033 | break;
|
|---|
| 1034 | case 3:
|
|---|
| 1035 | info_ctr.info.info3 = (struct spoolss_AddDriverInfo3 *)
|
|---|
| 1036 | (void *)&info->info3;
|
|---|
| 1037 | break;
|
|---|
| 1038 | default:
|
|---|
| 1039 | printf(_("unsupported info level: %d\n"), level);
|
|---|
| 1040 | return false;
|
|---|
| 1041 | }
|
|---|
| 1042 |
|
|---|
| 1043 | /* addprinterdriver call */
|
|---|
| 1044 | status = rpccli_spoolss_AddPrinterDriver(pipe_hnd, mem_ctx,
|
|---|
| 1045 | pipe_hnd->srv_name_slash,
|
|---|
| 1046 | &info_ctr,
|
|---|
| 1047 | &result);
|
|---|
| 1048 | /* be more verbose */
|
|---|
| 1049 | if (W_ERROR_V(result) == W_ERROR_V(WERR_ACCESS_DENIED)) {
|
|---|
| 1050 | printf(_("You are not allowed to add drivers\n"));
|
|---|
| 1051 | return false;
|
|---|
| 1052 | }
|
|---|
| 1053 | if (!W_ERROR_IS_OK(result)) {
|
|---|
| 1054 | printf(_("cannot add driver: %s\n"), win_errstr(result));
|
|---|
| 1055 | return false;
|
|---|
| 1056 | }
|
|---|
| 1057 |
|
|---|
| 1058 | return true;
|
|---|
| 1059 | }
|
|---|
| 1060 |
|
|---|
| 1061 | /**
|
|---|
| 1062 | * abstraction function to get uint32_t num_printers and PRINTER_INFO_CTR ctr
|
|---|
| 1063 | * for a single printer or for all printers depending on argc/argv
|
|---|
| 1064 | **/
|
|---|
| 1065 |
|
|---|
| 1066 | static bool get_printer_info(struct rpc_pipe_client *pipe_hnd,
|
|---|
| 1067 | TALLOC_CTX *mem_ctx,
|
|---|
| 1068 | int level,
|
|---|
| 1069 | int argc,
|
|---|
| 1070 | const char **argv,
|
|---|
| 1071 | uint32_t *num_printers,
|
|---|
| 1072 | union spoolss_PrinterInfo **info_p)
|
|---|
| 1073 | {
|
|---|
| 1074 | struct policy_handle hnd;
|
|---|
| 1075 |
|
|---|
| 1076 | /* no arguments given, enumerate all printers */
|
|---|
| 1077 | if (argc == 0) {
|
|---|
| 1078 |
|
|---|
| 1079 | if (!net_spoolss_enum_printers(pipe_hnd, mem_ctx, NULL,
|
|---|
| 1080 | PRINTER_ENUM_LOCAL|PRINTER_ENUM_SHARED,
|
|---|
| 1081 | level, num_printers, info_p))
|
|---|
| 1082 | return false;
|
|---|
| 1083 |
|
|---|
| 1084 | goto out;
|
|---|
| 1085 | }
|
|---|
| 1086 |
|
|---|
| 1087 | /* argument given, get a single printer by name */
|
|---|
| 1088 | if (!net_spoolss_open_printer_ex(pipe_hnd, mem_ctx, argv[0],
|
|---|
| 1089 | MAXIMUM_ALLOWED_ACCESS,
|
|---|
| 1090 | pipe_hnd->auth->user_name,
|
|---|
| 1091 | &hnd))
|
|---|
| 1092 | return false;
|
|---|
| 1093 |
|
|---|
| 1094 | if (!net_spoolss_getprinter(pipe_hnd, mem_ctx, &hnd, level, *info_p)) {
|
|---|
| 1095 | rpccli_spoolss_ClosePrinter(pipe_hnd, mem_ctx, &hnd, NULL);
|
|---|
| 1096 | return false;
|
|---|
| 1097 | }
|
|---|
| 1098 |
|
|---|
| 1099 | rpccli_spoolss_ClosePrinter(pipe_hnd, mem_ctx, &hnd, NULL);
|
|---|
| 1100 |
|
|---|
| 1101 | *num_printers = 1;
|
|---|
| 1102 |
|
|---|
| 1103 | out:
|
|---|
| 1104 | DEBUG(3,("got %d printers\n", *num_printers));
|
|---|
| 1105 |
|
|---|
| 1106 | return true;
|
|---|
| 1107 |
|
|---|
| 1108 | }
|
|---|
| 1109 |
|
|---|
| 1110 | /**
|
|---|
| 1111 | * List print-queues (including local printers that are not shared)
|
|---|
| 1112 | *
|
|---|
| 1113 | * All parameters are provided by the run_rpc_command function, except for
|
|---|
| 1114 | * argc, argv which are passed through.
|
|---|
| 1115 | *
|
|---|
| 1116 | * @param c A net_context structure
|
|---|
| 1117 | * @param domain_sid The domain sid aquired from the remote server
|
|---|
| 1118 | * @param cli A cli_state connected to the server.
|
|---|
| 1119 | * @param mem_ctx Talloc context, destoyed on compleation of the function.
|
|---|
| 1120 | * @param argc Standard main() style argc
|
|---|
| 1121 | * @param argv Standard main() style argv. Initial components are already
|
|---|
| 1122 | * stripped
|
|---|
| 1123 | *
|
|---|
| 1124 | * @return Normal NTSTATUS return.
|
|---|
| 1125 | **/
|
|---|
| 1126 |
|
|---|
| 1127 | NTSTATUS rpc_printer_list_internals(struct net_context *c,
|
|---|
| 1128 | const DOM_SID *domain_sid,
|
|---|
| 1129 | const char *domain_name,
|
|---|
| 1130 | struct cli_state *cli,
|
|---|
| 1131 | struct rpc_pipe_client *pipe_hnd,
|
|---|
| 1132 | TALLOC_CTX *mem_ctx,
|
|---|
| 1133 | int argc,
|
|---|
| 1134 | const char **argv)
|
|---|
| 1135 | {
|
|---|
| 1136 | NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
|
|---|
| 1137 | uint32_t i, num_printers;
|
|---|
| 1138 | uint32_t level = 2;
|
|---|
| 1139 | const char *printername, *sharename;
|
|---|
| 1140 | union spoolss_PrinterInfo *info;
|
|---|
| 1141 |
|
|---|
| 1142 | printf("listing printers\n");
|
|---|
| 1143 |
|
|---|
| 1144 | if (!get_printer_info(pipe_hnd, mem_ctx, level, argc, argv, &num_printers, &info))
|
|---|
| 1145 | return nt_status;
|
|---|
| 1146 |
|
|---|
| 1147 | for (i = 0; i < num_printers; i++) {
|
|---|
| 1148 |
|
|---|
| 1149 | /* do some initialization */
|
|---|
| 1150 | printername = info[i].info2.printername;
|
|---|
| 1151 | sharename = info[i].info2.sharename;
|
|---|
| 1152 |
|
|---|
| 1153 | if (printername && sharename) {
|
|---|
| 1154 | d_printf(_("printer %d: %s, shared as: %s\n"),
|
|---|
| 1155 | i+1, printername, sharename);
|
|---|
| 1156 | }
|
|---|
| 1157 | }
|
|---|
| 1158 |
|
|---|
| 1159 | return NT_STATUS_OK;
|
|---|
| 1160 | }
|
|---|
| 1161 |
|
|---|
| 1162 | /**
|
|---|
| 1163 | * List printer-drivers from a server
|
|---|
| 1164 | *
|
|---|
| 1165 | * All parameters are provided by the run_rpc_command function, except for
|
|---|
| 1166 | * argc, argv which are passed through.
|
|---|
| 1167 | *
|
|---|
| 1168 | * @param c A net_context structure
|
|---|
| 1169 | * @param domain_sid The domain sid aquired from the remote server
|
|---|
| 1170 | * @param cli A cli_state connected to the server.
|
|---|
| 1171 | * @param mem_ctx Talloc context, destoyed on compleation of the function.
|
|---|
| 1172 | * @param argc Standard main() style argc
|
|---|
| 1173 | * @param argv Standard main() style argv. Initial components are already
|
|---|
| 1174 | * stripped
|
|---|
| 1175 | *
|
|---|
| 1176 | * @return Normal NTSTATUS return.
|
|---|
| 1177 | **/
|
|---|
| 1178 |
|
|---|
| 1179 | NTSTATUS rpc_printer_driver_list_internals(struct net_context *c,
|
|---|
| 1180 | const DOM_SID *domain_sid,
|
|---|
| 1181 | const char *domain_name,
|
|---|
| 1182 | struct cli_state *cli,
|
|---|
| 1183 | struct rpc_pipe_client *pipe_hnd,
|
|---|
| 1184 | TALLOC_CTX *mem_ctx,
|
|---|
| 1185 | int argc,
|
|---|
| 1186 | const char **argv)
|
|---|
| 1187 | {
|
|---|
| 1188 | NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
|
|---|
| 1189 | uint32_t i;
|
|---|
| 1190 | uint32_t level = 3;
|
|---|
| 1191 | union spoolss_DriverInfo *info;
|
|---|
| 1192 | int d;
|
|---|
| 1193 |
|
|---|
| 1194 | printf(_("listing printer-drivers\n"));
|
|---|
| 1195 |
|
|---|
| 1196 | for (i=0; archi_table[i].long_archi!=NULL; i++) {
|
|---|
| 1197 |
|
|---|
| 1198 | uint32_t num_drivers;
|
|---|
| 1199 |
|
|---|
| 1200 | /* enum remote drivers */
|
|---|
| 1201 | if (!net_spoolss_enumprinterdrivers(pipe_hnd, mem_ctx, level,
|
|---|
| 1202 | archi_table[i].long_archi,
|
|---|
| 1203 | &num_drivers, &info)) {
|
|---|
| 1204 | nt_status = NT_STATUS_UNSUCCESSFUL;
|
|---|
| 1205 | goto done;
|
|---|
| 1206 | }
|
|---|
| 1207 |
|
|---|
| 1208 | if (num_drivers == 0) {
|
|---|
| 1209 | d_printf(_("no drivers found on server for "
|
|---|
| 1210 | "architecture: [%s].\n"),
|
|---|
| 1211 | archi_table[i].long_archi);
|
|---|
| 1212 | continue;
|
|---|
| 1213 | }
|
|---|
| 1214 |
|
|---|
| 1215 | d_printf(_("got %d printer-drivers for architecture: [%s]\n"),
|
|---|
| 1216 | num_drivers, archi_table[i].long_archi);
|
|---|
| 1217 |
|
|---|
| 1218 |
|
|---|
| 1219 | /* do something for all drivers for architecture */
|
|---|
| 1220 | for (d = 0; d < num_drivers; d++) {
|
|---|
| 1221 | display_print_driver3(&info[d].info3);
|
|---|
| 1222 | }
|
|---|
| 1223 | }
|
|---|
| 1224 |
|
|---|
| 1225 | nt_status = NT_STATUS_OK;
|
|---|
| 1226 |
|
|---|
| 1227 | done:
|
|---|
| 1228 | return nt_status;
|
|---|
| 1229 |
|
|---|
| 1230 | }
|
|---|
| 1231 |
|
|---|
| 1232 | /**
|
|---|
| 1233 | * Publish print-queues with args-wrapper
|
|---|
| 1234 | *
|
|---|
| 1235 | * @param cli A cli_state connected to the server.
|
|---|
| 1236 | * @param mem_ctx Talloc context, destoyed on compleation of the function.
|
|---|
| 1237 | * @param argc Standard main() style argc
|
|---|
| 1238 | * @param argv Standard main() style argv. Initial components are already
|
|---|
| 1239 | * stripped
|
|---|
| 1240 | * @param action
|
|---|
| 1241 | *
|
|---|
| 1242 | * @return Normal NTSTATUS return.
|
|---|
| 1243 | **/
|
|---|
| 1244 |
|
|---|
| 1245 | static NTSTATUS rpc_printer_publish_internals_args(struct rpc_pipe_client *pipe_hnd,
|
|---|
| 1246 | TALLOC_CTX *mem_ctx,
|
|---|
| 1247 | int argc,
|
|---|
| 1248 | const char **argv,
|
|---|
| 1249 | uint32_t action)
|
|---|
| 1250 | {
|
|---|
| 1251 | NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
|
|---|
| 1252 | uint32_t i, num_printers;
|
|---|
| 1253 | uint32_t level = 7;
|
|---|
| 1254 | const char *printername, *sharename;
|
|---|
| 1255 | union spoolss_PrinterInfo *info_enum;
|
|---|
| 1256 | union spoolss_PrinterInfo info;
|
|---|
| 1257 | struct spoolss_SetPrinterInfoCtr info_ctr;
|
|---|
| 1258 | struct spoolss_DevmodeContainer devmode_ctr;
|
|---|
| 1259 | struct sec_desc_buf secdesc_ctr;
|
|---|
| 1260 | struct policy_handle hnd;
|
|---|
| 1261 | WERROR result;
|
|---|
| 1262 | const char *action_str;
|
|---|
| 1263 |
|
|---|
| 1264 | if (!get_printer_info(pipe_hnd, mem_ctx, 2, argc, argv, &num_printers, &info_enum))
|
|---|
| 1265 | return nt_status;
|
|---|
| 1266 |
|
|---|
| 1267 | for (i = 0; i < num_printers; i++) {
|
|---|
| 1268 |
|
|---|
| 1269 | /* do some initialization */
|
|---|
| 1270 | printername = info_enum[i].info2.printername;
|
|---|
| 1271 | sharename = info_enum[i].info2.sharename;
|
|---|
| 1272 | if (!printername || !sharename) {
|
|---|
| 1273 | goto done;
|
|---|
| 1274 | }
|
|---|
| 1275 |
|
|---|
| 1276 | /* open printer handle */
|
|---|
| 1277 | if (!net_spoolss_open_printer_ex(pipe_hnd, mem_ctx, sharename,
|
|---|
| 1278 | PRINTER_ALL_ACCESS, pipe_hnd->auth->user_name, &hnd))
|
|---|
| 1279 | goto done;
|
|---|
| 1280 |
|
|---|
| 1281 | /* check for existing dst printer */
|
|---|
| 1282 | if (!net_spoolss_getprinter(pipe_hnd, mem_ctx, &hnd, level, &info))
|
|---|
| 1283 | goto done;
|
|---|
| 1284 |
|
|---|
| 1285 | /* check action and set string */
|
|---|
| 1286 | switch (action) {
|
|---|
| 1287 | case DSPRINT_PUBLISH:
|
|---|
| 1288 | action_str = N_("published");
|
|---|
| 1289 | break;
|
|---|
| 1290 | case DSPRINT_UPDATE:
|
|---|
| 1291 | action_str = N_("updated");
|
|---|
| 1292 | break;
|
|---|
| 1293 | case DSPRINT_UNPUBLISH:
|
|---|
| 1294 | action_str = N_("unpublished");
|
|---|
| 1295 | break;
|
|---|
| 1296 | default:
|
|---|
| 1297 | action_str = N_("unknown action");
|
|---|
| 1298 | printf(_("unkown action: %d\n"), action);
|
|---|
| 1299 | break;
|
|---|
| 1300 | }
|
|---|
| 1301 |
|
|---|
| 1302 | info.info7.action = action;
|
|---|
| 1303 | info_ctr.level = 7;
|
|---|
| 1304 | info_ctr.info.info7 = (struct spoolss_SetPrinterInfo7 *)
|
|---|
| 1305 | (void *)&info.info7;
|
|---|
| 1306 |
|
|---|
| 1307 | ZERO_STRUCT(devmode_ctr);
|
|---|
| 1308 | ZERO_STRUCT(secdesc_ctr);
|
|---|
| 1309 |
|
|---|
| 1310 | nt_status = rpccli_spoolss_SetPrinter(pipe_hnd, mem_ctx,
|
|---|
| 1311 | &hnd,
|
|---|
| 1312 | &info_ctr,
|
|---|
| 1313 | &devmode_ctr,
|
|---|
| 1314 | &secdesc_ctr,
|
|---|
| 1315 | 0, /* command */
|
|---|
| 1316 | &result);
|
|---|
| 1317 |
|
|---|
| 1318 | if (!W_ERROR_IS_OK(result) && (W_ERROR_V(result) != W_ERROR_V(WERR_IO_PENDING))) {
|
|---|
| 1319 | printf(_("cannot set printer-info: %s\n"),
|
|---|
| 1320 | win_errstr(result));
|
|---|
| 1321 | goto done;
|
|---|
| 1322 | }
|
|---|
| 1323 |
|
|---|
| 1324 | printf(_("successfully %s printer %s in Active Directory\n"),
|
|---|
| 1325 | action_str, sharename);
|
|---|
| 1326 | }
|
|---|
| 1327 |
|
|---|
| 1328 | nt_status = NT_STATUS_OK;
|
|---|
| 1329 |
|
|---|
| 1330 | done:
|
|---|
| 1331 | if (is_valid_policy_hnd(&hnd))
|
|---|
| 1332 | rpccli_spoolss_ClosePrinter(pipe_hnd, mem_ctx, &hnd, NULL);
|
|---|
| 1333 |
|
|---|
| 1334 | return nt_status;
|
|---|
| 1335 | }
|
|---|
| 1336 |
|
|---|
| 1337 | NTSTATUS rpc_printer_publish_publish_internals(struct net_context *c,
|
|---|
| 1338 | const DOM_SID *domain_sid,
|
|---|
| 1339 | const char *domain_name,
|
|---|
| 1340 | struct cli_state *cli,
|
|---|
| 1341 | struct rpc_pipe_client *pipe_hnd,
|
|---|
| 1342 | TALLOC_CTX *mem_ctx,
|
|---|
| 1343 | int argc,
|
|---|
| 1344 | const char **argv)
|
|---|
| 1345 | {
|
|---|
| 1346 | return rpc_printer_publish_internals_args(pipe_hnd, mem_ctx, argc, argv, DSPRINT_PUBLISH);
|
|---|
| 1347 | }
|
|---|
| 1348 |
|
|---|
| 1349 | NTSTATUS rpc_printer_publish_unpublish_internals(struct net_context *c,
|
|---|
| 1350 | const DOM_SID *domain_sid,
|
|---|
| 1351 | const char *domain_name,
|
|---|
| 1352 | struct cli_state *cli,
|
|---|
| 1353 | struct rpc_pipe_client *pipe_hnd,
|
|---|
| 1354 | TALLOC_CTX *mem_ctx,
|
|---|
| 1355 | int argc,
|
|---|
| 1356 | const char **argv)
|
|---|
| 1357 | {
|
|---|
| 1358 | return rpc_printer_publish_internals_args(pipe_hnd, mem_ctx, argc, argv, DSPRINT_UNPUBLISH);
|
|---|
| 1359 | }
|
|---|
| 1360 |
|
|---|
| 1361 | NTSTATUS rpc_printer_publish_update_internals(struct net_context *c,
|
|---|
| 1362 | const DOM_SID *domain_sid,
|
|---|
| 1363 | const char *domain_name,
|
|---|
| 1364 | struct cli_state *cli,
|
|---|
| 1365 | struct rpc_pipe_client *pipe_hnd,
|
|---|
| 1366 | TALLOC_CTX *mem_ctx,
|
|---|
| 1367 | int argc,
|
|---|
| 1368 | const char **argv)
|
|---|
| 1369 | {
|
|---|
| 1370 | return rpc_printer_publish_internals_args(pipe_hnd, mem_ctx, argc, argv, DSPRINT_UPDATE);
|
|---|
| 1371 | }
|
|---|
| 1372 |
|
|---|
| 1373 | /**
|
|---|
| 1374 | * List print-queues w.r.t. their publishing state
|
|---|
| 1375 | *
|
|---|
| 1376 | * All parameters are provided by the run_rpc_command function, except for
|
|---|
| 1377 | * argc, argv which are passed through.
|
|---|
| 1378 | *
|
|---|
| 1379 | * @param c A net_context structure
|
|---|
| 1380 | * @param domain_sid The domain sid aquired from the remote server
|
|---|
| 1381 | * @param cli A cli_state connected to the server.
|
|---|
| 1382 | * @param mem_ctx Talloc context, destoyed on compleation of the function.
|
|---|
| 1383 | * @param argc Standard main() style argc
|
|---|
| 1384 | * @param argv Standard main() style argv. Initial components are already
|
|---|
| 1385 | * stripped
|
|---|
| 1386 | *
|
|---|
| 1387 | * @return Normal NTSTATUS return.
|
|---|
| 1388 | **/
|
|---|
| 1389 |
|
|---|
| 1390 | NTSTATUS rpc_printer_publish_list_internals(struct net_context *c,
|
|---|
| 1391 | const DOM_SID *domain_sid,
|
|---|
| 1392 | const char *domain_name,
|
|---|
| 1393 | struct cli_state *cli,
|
|---|
| 1394 | struct rpc_pipe_client *pipe_hnd,
|
|---|
| 1395 | TALLOC_CTX *mem_ctx,
|
|---|
| 1396 | int argc,
|
|---|
| 1397 | const char **argv)
|
|---|
| 1398 | {
|
|---|
| 1399 | NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
|
|---|
| 1400 | uint32_t i, num_printers;
|
|---|
| 1401 | uint32_t level = 7;
|
|---|
| 1402 | const char *printername, *sharename;
|
|---|
| 1403 | union spoolss_PrinterInfo *info_enum;
|
|---|
| 1404 | union spoolss_PrinterInfo info;
|
|---|
| 1405 | struct policy_handle hnd;
|
|---|
| 1406 | int state;
|
|---|
| 1407 |
|
|---|
| 1408 | if (!get_printer_info(pipe_hnd, mem_ctx, 2, argc, argv, &num_printers, &info_enum))
|
|---|
| 1409 | return nt_status;
|
|---|
| 1410 |
|
|---|
| 1411 | for (i = 0; i < num_printers; i++) {
|
|---|
| 1412 |
|
|---|
| 1413 | /* do some initialization */
|
|---|
| 1414 | printername = info_enum[i].info2.printername;
|
|---|
| 1415 | sharename = info_enum[i].info2.sharename;
|
|---|
| 1416 |
|
|---|
| 1417 | if (!printername || !sharename) {
|
|---|
| 1418 | goto done;
|
|---|
| 1419 | }
|
|---|
| 1420 |
|
|---|
| 1421 | /* open printer handle */
|
|---|
| 1422 | if (!net_spoolss_open_printer_ex(pipe_hnd, mem_ctx, sharename,
|
|---|
| 1423 | PRINTER_ALL_ACCESS, cli->user_name, &hnd))
|
|---|
| 1424 | goto done;
|
|---|
| 1425 |
|
|---|
| 1426 | /* check for existing dst printer */
|
|---|
| 1427 | if (!net_spoolss_getprinter(pipe_hnd, mem_ctx, &hnd, level, &info))
|
|---|
| 1428 | goto done;
|
|---|
| 1429 |
|
|---|
| 1430 | if (!info.info7.guid) {
|
|---|
| 1431 | goto done;
|
|---|
| 1432 | }
|
|---|
| 1433 | state = info.info7.action;
|
|---|
| 1434 | switch (state) {
|
|---|
| 1435 | case DSPRINT_PUBLISH:
|
|---|
| 1436 | printf(_("printer [%s] is published"),
|
|---|
| 1437 | sharename);
|
|---|
| 1438 | if (c->opt_verbose)
|
|---|
| 1439 | printf(_(", guid: %s"),info.info7.guid);
|
|---|
| 1440 | printf("\n");
|
|---|
| 1441 | break;
|
|---|
| 1442 | case DSPRINT_UNPUBLISH:
|
|---|
| 1443 | printf(_("printer [%s] is unpublished\n"),
|
|---|
| 1444 | sharename);
|
|---|
| 1445 | break;
|
|---|
| 1446 | case DSPRINT_UPDATE:
|
|---|
| 1447 | printf(_("printer [%s] is currently updating\n"),
|
|---|
| 1448 | sharename);
|
|---|
| 1449 | break;
|
|---|
| 1450 | default:
|
|---|
| 1451 | printf(_("unkown state: %d\n"), state);
|
|---|
| 1452 | break;
|
|---|
| 1453 | }
|
|---|
| 1454 | }
|
|---|
| 1455 |
|
|---|
| 1456 | nt_status = NT_STATUS_OK;
|
|---|
| 1457 |
|
|---|
| 1458 | done:
|
|---|
| 1459 | if (is_valid_policy_hnd(&hnd))
|
|---|
| 1460 | rpccli_spoolss_ClosePrinter(pipe_hnd, mem_ctx, &hnd, NULL);
|
|---|
| 1461 |
|
|---|
| 1462 | return nt_status;
|
|---|
| 1463 | }
|
|---|
| 1464 |
|
|---|
| 1465 | /**
|
|---|
| 1466 | * Migrate Printer-ACLs from a source server to the destination server
|
|---|
| 1467 | *
|
|---|
| 1468 | * All parameters are provided by the run_rpc_command function, except for
|
|---|
| 1469 | * argc, argv which are passed through.
|
|---|
| 1470 | *
|
|---|
| 1471 | * @param c A net_context structure
|
|---|
| 1472 | * @param domain_sid The domain sid aquired from the remote server
|
|---|
| 1473 | * @param cli A cli_state connected to the server.
|
|---|
| 1474 | * @param mem_ctx Talloc context, destoyed on compleation of the function.
|
|---|
| 1475 | * @param argc Standard main() style argc
|
|---|
| 1476 | * @param argv Standard main() style argv. Initial components are already
|
|---|
| 1477 | * stripped
|
|---|
| 1478 | *
|
|---|
| 1479 | * @return Normal NTSTATUS return.
|
|---|
| 1480 | **/
|
|---|
| 1481 |
|
|---|
| 1482 | NTSTATUS rpc_printer_migrate_security_internals(struct net_context *c,
|
|---|
| 1483 | const DOM_SID *domain_sid,
|
|---|
| 1484 | const char *domain_name,
|
|---|
| 1485 | struct cli_state *cli,
|
|---|
| 1486 | struct rpc_pipe_client *pipe_hnd,
|
|---|
| 1487 | TALLOC_CTX *mem_ctx,
|
|---|
| 1488 | int argc,
|
|---|
| 1489 | const char **argv)
|
|---|
| 1490 | {
|
|---|
| 1491 | /* TODO: what now, info2 or info3 ?
|
|---|
| 1492 | convince jerry that we should add clientside setacls level 3 at least
|
|---|
| 1493 | */
|
|---|
| 1494 | NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
|
|---|
| 1495 | uint32_t i = 0;
|
|---|
| 1496 | uint32_t num_printers;
|
|---|
| 1497 | uint32_t level = 2;
|
|---|
| 1498 | const char *printername, *sharename;
|
|---|
| 1499 | struct rpc_pipe_client *pipe_hnd_dst = NULL;
|
|---|
| 1500 | struct policy_handle hnd_src, hnd_dst;
|
|---|
| 1501 | union spoolss_PrinterInfo *info_enum;
|
|---|
| 1502 | struct cli_state *cli_dst = NULL;
|
|---|
| 1503 | union spoolss_PrinterInfo info_src, info_dst;
|
|---|
| 1504 |
|
|---|
| 1505 | DEBUG(3,("copying printer ACLs\n"));
|
|---|
| 1506 |
|
|---|
| 1507 | /* connect destination PI_SPOOLSS */
|
|---|
| 1508 | nt_status = connect_dst_pipe(c, &cli_dst, &pipe_hnd_dst,
|
|---|
| 1509 | &ndr_table_spoolss.syntax_id);
|
|---|
| 1510 | if (!NT_STATUS_IS_OK(nt_status))
|
|---|
| 1511 | return nt_status;
|
|---|
| 1512 |
|
|---|
| 1513 |
|
|---|
| 1514 | /* enum source printers */
|
|---|
| 1515 | if (!get_printer_info(pipe_hnd, mem_ctx, level, argc, argv, &num_printers, &info_enum)) {
|
|---|
| 1516 | nt_status = NT_STATUS_UNSUCCESSFUL;
|
|---|
| 1517 | goto done;
|
|---|
| 1518 | }
|
|---|
| 1519 |
|
|---|
| 1520 | if (!num_printers) {
|
|---|
| 1521 | printf (_("no printers found on server.\n"));
|
|---|
| 1522 | nt_status = NT_STATUS_OK;
|
|---|
| 1523 | goto done;
|
|---|
| 1524 | }
|
|---|
| 1525 |
|
|---|
| 1526 | /* do something for all printers */
|
|---|
| 1527 | for (i = 0; i < num_printers; i++) {
|
|---|
| 1528 |
|
|---|
| 1529 | /* do some initialization */
|
|---|
| 1530 | printername = info_enum[i].info2.printername;
|
|---|
| 1531 | sharename = info_enum[i].info2.sharename;
|
|---|
| 1532 |
|
|---|
| 1533 | if (!printername || !sharename) {
|
|---|
| 1534 | nt_status = NT_STATUS_UNSUCCESSFUL;
|
|---|
| 1535 | goto done;
|
|---|
| 1536 | }
|
|---|
| 1537 |
|
|---|
| 1538 | /* we can reset NT_STATUS here because we do not
|
|---|
| 1539 | get any real NT_STATUS-codes anymore from now on */
|
|---|
| 1540 | nt_status = NT_STATUS_UNSUCCESSFUL;
|
|---|
| 1541 |
|
|---|
| 1542 | d_printf(_("migrating printer ACLs for: [%s] / [%s]\n"),
|
|---|
| 1543 | printername, sharename);
|
|---|
| 1544 |
|
|---|
| 1545 | /* according to msdn you have specify these access-rights
|
|---|
| 1546 | to see the security descriptor
|
|---|
| 1547 | - READ_CONTROL (DACL)
|
|---|
| 1548 | - ACCESS_SYSTEM_SECURITY (SACL)
|
|---|
| 1549 | */
|
|---|
| 1550 |
|
|---|
| 1551 | /* open src printer handle */
|
|---|
| 1552 | if (!net_spoolss_open_printer_ex(pipe_hnd, mem_ctx, sharename,
|
|---|
| 1553 | MAXIMUM_ALLOWED_ACCESS, cli->user_name, &hnd_src))
|
|---|
| 1554 | goto done;
|
|---|
| 1555 |
|
|---|
| 1556 | /* open dst printer handle */
|
|---|
| 1557 | if (!net_spoolss_open_printer_ex(pipe_hnd_dst, mem_ctx, sharename,
|
|---|
| 1558 | PRINTER_ALL_ACCESS, cli_dst->user_name, &hnd_dst))
|
|---|
| 1559 | goto done;
|
|---|
| 1560 |
|
|---|
| 1561 | /* check for existing dst printer */
|
|---|
| 1562 | if (!net_spoolss_getprinter(pipe_hnd_dst, mem_ctx, &hnd_dst, level, &info_dst))
|
|---|
| 1563 | goto done;
|
|---|
| 1564 |
|
|---|
| 1565 | /* check for existing src printer */
|
|---|
| 1566 | if (!net_spoolss_getprinter(pipe_hnd, mem_ctx, &hnd_src, 3, &info_src))
|
|---|
| 1567 | goto done;
|
|---|
| 1568 |
|
|---|
| 1569 | /* Copy Security Descriptor */
|
|---|
| 1570 |
|
|---|
| 1571 | /* copy secdesc (info level 2) */
|
|---|
| 1572 | info_dst.info2.devmode = NULL;
|
|---|
| 1573 | info_dst.info2.secdesc = dup_sec_desc(mem_ctx, info_src.info3.secdesc);
|
|---|
| 1574 |
|
|---|
| 1575 | if (c->opt_verbose)
|
|---|
| 1576 | display_sec_desc(info_dst.info2.secdesc);
|
|---|
| 1577 |
|
|---|
| 1578 | if (!net_spoolss_setprinter(pipe_hnd_dst, mem_ctx, &hnd_dst, 2, &info_dst))
|
|---|
| 1579 | goto done;
|
|---|
| 1580 |
|
|---|
| 1581 | DEBUGADD(1,("\tSetPrinter of SECDESC succeeded\n"));
|
|---|
| 1582 |
|
|---|
| 1583 |
|
|---|
| 1584 | /* close printer handles here */
|
|---|
| 1585 | if (is_valid_policy_hnd(&hnd_src)) {
|
|---|
| 1586 | rpccli_spoolss_ClosePrinter(pipe_hnd, mem_ctx, &hnd_src, NULL);
|
|---|
| 1587 | }
|
|---|
| 1588 |
|
|---|
| 1589 | if (is_valid_policy_hnd(&hnd_dst)) {
|
|---|
| 1590 | rpccli_spoolss_ClosePrinter(pipe_hnd_dst, mem_ctx, &hnd_dst, NULL);
|
|---|
| 1591 | }
|
|---|
| 1592 |
|
|---|
| 1593 | }
|
|---|
| 1594 |
|
|---|
| 1595 | nt_status = NT_STATUS_OK;
|
|---|
| 1596 |
|
|---|
| 1597 | done:
|
|---|
| 1598 |
|
|---|
| 1599 | if (is_valid_policy_hnd(&hnd_src)) {
|
|---|
| 1600 | rpccli_spoolss_ClosePrinter(pipe_hnd, mem_ctx, &hnd_src, NULL);
|
|---|
| 1601 | }
|
|---|
| 1602 |
|
|---|
| 1603 | if (is_valid_policy_hnd(&hnd_dst)) {
|
|---|
| 1604 | rpccli_spoolss_ClosePrinter(pipe_hnd_dst, mem_ctx, &hnd_dst, NULL);
|
|---|
| 1605 | }
|
|---|
| 1606 |
|
|---|
| 1607 | if (cli_dst) {
|
|---|
| 1608 | cli_shutdown(cli_dst);
|
|---|
| 1609 | }
|
|---|
| 1610 | return nt_status;
|
|---|
| 1611 | }
|
|---|
| 1612 |
|
|---|
| 1613 | /**
|
|---|
| 1614 | * Migrate printer-forms from a src server to the dst server
|
|---|
| 1615 | *
|
|---|
| 1616 | * All parameters are provided by the run_rpc_command function, except for
|
|---|
| 1617 | * argc, argv which are passed through.
|
|---|
| 1618 | *
|
|---|
| 1619 | * @param c A net_context structure
|
|---|
| 1620 | * @param domain_sid The domain sid aquired from the remote server
|
|---|
| 1621 | * @param cli A cli_state connected to the server.
|
|---|
| 1622 | * @param mem_ctx Talloc context, destoyed on compleation of the function.
|
|---|
| 1623 | * @param argc Standard main() style argc
|
|---|
| 1624 | * @param argv Standard main() style argv. Initial components are already
|
|---|
| 1625 | * stripped
|
|---|
| 1626 | *
|
|---|
| 1627 | * @return Normal NTSTATUS return.
|
|---|
| 1628 | **/
|
|---|
| 1629 |
|
|---|
| 1630 | NTSTATUS rpc_printer_migrate_forms_internals(struct net_context *c,
|
|---|
| 1631 | const DOM_SID *domain_sid,
|
|---|
| 1632 | const char *domain_name,
|
|---|
| 1633 | struct cli_state *cli,
|
|---|
| 1634 | struct rpc_pipe_client *pipe_hnd,
|
|---|
| 1635 | TALLOC_CTX *mem_ctx,
|
|---|
| 1636 | int argc,
|
|---|
| 1637 | const char **argv)
|
|---|
| 1638 | {
|
|---|
| 1639 | NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
|
|---|
| 1640 | WERROR result;
|
|---|
| 1641 | uint32_t i, f;
|
|---|
| 1642 | uint32_t num_printers;
|
|---|
| 1643 | uint32_t level = 1;
|
|---|
| 1644 | const char *printername, *sharename;
|
|---|
| 1645 | struct rpc_pipe_client *pipe_hnd_dst = NULL;
|
|---|
| 1646 | struct policy_handle hnd_src, hnd_dst;
|
|---|
| 1647 | union spoolss_PrinterInfo *info_enum;
|
|---|
| 1648 | union spoolss_PrinterInfo info_dst;
|
|---|
| 1649 | uint32_t num_forms;
|
|---|
| 1650 | union spoolss_FormInfo *forms;
|
|---|
| 1651 | struct cli_state *cli_dst = NULL;
|
|---|
| 1652 |
|
|---|
| 1653 | DEBUG(3,("copying forms\n"));
|
|---|
| 1654 |
|
|---|
| 1655 | /* connect destination PI_SPOOLSS */
|
|---|
| 1656 | nt_status = connect_dst_pipe(c, &cli_dst, &pipe_hnd_dst,
|
|---|
| 1657 | &ndr_table_spoolss.syntax_id);
|
|---|
| 1658 | if (!NT_STATUS_IS_OK(nt_status))
|
|---|
| 1659 | return nt_status;
|
|---|
| 1660 |
|
|---|
| 1661 | /* enum src printers */
|
|---|
| 1662 | if (!get_printer_info(pipe_hnd, mem_ctx, 2, argc, argv, &num_printers, &info_enum)) {
|
|---|
| 1663 | nt_status = NT_STATUS_UNSUCCESSFUL;
|
|---|
| 1664 | goto done;
|
|---|
| 1665 | }
|
|---|
| 1666 |
|
|---|
| 1667 | if (!num_printers) {
|
|---|
| 1668 | printf (_("no printers found on server.\n"));
|
|---|
| 1669 | nt_status = NT_STATUS_OK;
|
|---|
| 1670 | goto done;
|
|---|
| 1671 | }
|
|---|
| 1672 |
|
|---|
| 1673 | /* do something for all printers */
|
|---|
| 1674 | for (i = 0; i < num_printers; i++) {
|
|---|
| 1675 |
|
|---|
| 1676 | /* do some initialization */
|
|---|
| 1677 | printername = info_enum[i].info2.printername;
|
|---|
| 1678 | sharename = info_enum[i].info2.sharename;
|
|---|
| 1679 |
|
|---|
| 1680 | if (!printername || !sharename) {
|
|---|
| 1681 | nt_status = NT_STATUS_UNSUCCESSFUL;
|
|---|
| 1682 | goto done;
|
|---|
| 1683 | }
|
|---|
| 1684 | /* we can reset NT_STATUS here because we do not
|
|---|
| 1685 | get any real NT_STATUS-codes anymore from now on */
|
|---|
| 1686 | nt_status = NT_STATUS_UNSUCCESSFUL;
|
|---|
| 1687 |
|
|---|
| 1688 | d_printf(_("migrating printer forms for: [%s] / [%s]\n"),
|
|---|
| 1689 | printername, sharename);
|
|---|
| 1690 |
|
|---|
| 1691 |
|
|---|
| 1692 | /* open src printer handle */
|
|---|
| 1693 | if (!net_spoolss_open_printer_ex(pipe_hnd, mem_ctx, sharename,
|
|---|
| 1694 | MAXIMUM_ALLOWED_ACCESS, cli->user_name, &hnd_src))
|
|---|
| 1695 | goto done;
|
|---|
| 1696 |
|
|---|
| 1697 | /* open dst printer handle */
|
|---|
| 1698 | if (!net_spoolss_open_printer_ex(pipe_hnd_dst, mem_ctx, sharename,
|
|---|
| 1699 | PRINTER_ALL_ACCESS, cli->user_name, &hnd_dst))
|
|---|
| 1700 | goto done;
|
|---|
| 1701 |
|
|---|
| 1702 | /* check for existing dst printer */
|
|---|
| 1703 | if (!net_spoolss_getprinter(pipe_hnd_dst, mem_ctx, &hnd_dst, level, &info_dst))
|
|---|
| 1704 | goto done;
|
|---|
| 1705 |
|
|---|
| 1706 | /* finally migrate forms */
|
|---|
| 1707 | if (!net_spoolss_enumforms(pipe_hnd, mem_ctx, &hnd_src, level, &num_forms, &forms))
|
|---|
| 1708 | goto done;
|
|---|
| 1709 |
|
|---|
| 1710 | DEBUG(1,("got %d forms for printer\n", num_forms));
|
|---|
| 1711 |
|
|---|
| 1712 |
|
|---|
| 1713 | for (f = 0; f < num_forms; f++) {
|
|---|
| 1714 |
|
|---|
| 1715 | union spoolss_AddFormInfo info;
|
|---|
| 1716 | NTSTATUS status;
|
|---|
| 1717 |
|
|---|
| 1718 | /* only migrate FORM_PRINTER types, according to jerry
|
|---|
| 1719 | FORM_BUILTIN-types are hard-coded in samba */
|
|---|
| 1720 | if (forms[f].info1.flags != SPOOLSS_FORM_PRINTER)
|
|---|
| 1721 | continue;
|
|---|
| 1722 |
|
|---|
| 1723 | if (c->opt_verbose)
|
|---|
| 1724 | d_printf(_("\tmigrating form # %d [%s] of type "
|
|---|
| 1725 | "[%d]\n"),
|
|---|
| 1726 | f, forms[f].info1.form_name,
|
|---|
| 1727 | forms[f].info1.flags);
|
|---|
| 1728 |
|
|---|
| 1729 | info.info1 = (struct spoolss_AddFormInfo1 *)
|
|---|
| 1730 | (void *)&forms[f].info1;
|
|---|
| 1731 |
|
|---|
| 1732 | /* FIXME: there might be something wrong with samba's
|
|---|
| 1733 | builtin-forms */
|
|---|
| 1734 | status = rpccli_spoolss_AddForm(pipe_hnd_dst, mem_ctx,
|
|---|
| 1735 | &hnd_dst,
|
|---|
| 1736 | 1,
|
|---|
| 1737 | info,
|
|---|
| 1738 | &result);
|
|---|
| 1739 | if (!W_ERROR_IS_OK(result)) {
|
|---|
| 1740 | d_printf(_("\tAddForm form %d: [%s] refused.\n"),
|
|---|
| 1741 | f, forms[f].info1.form_name);
|
|---|
| 1742 | continue;
|
|---|
| 1743 | }
|
|---|
| 1744 |
|
|---|
| 1745 | DEBUGADD(1,("\tAddForm of [%s] succeeded\n",
|
|---|
| 1746 | forms[f].info1.form_name));
|
|---|
| 1747 | }
|
|---|
| 1748 |
|
|---|
| 1749 |
|
|---|
| 1750 | /* close printer handles here */
|
|---|
| 1751 | if (is_valid_policy_hnd(&hnd_src)) {
|
|---|
| 1752 | rpccli_spoolss_ClosePrinter(pipe_hnd, mem_ctx, &hnd_src, NULL);
|
|---|
| 1753 | }
|
|---|
| 1754 |
|
|---|
| 1755 | if (is_valid_policy_hnd(&hnd_dst)) {
|
|---|
| 1756 | rpccli_spoolss_ClosePrinter(pipe_hnd_dst, mem_ctx, &hnd_dst, NULL);
|
|---|
| 1757 | }
|
|---|
| 1758 | }
|
|---|
| 1759 |
|
|---|
| 1760 | nt_status = NT_STATUS_OK;
|
|---|
| 1761 |
|
|---|
| 1762 | done:
|
|---|
| 1763 |
|
|---|
| 1764 | if (is_valid_policy_hnd(&hnd_src))
|
|---|
| 1765 | rpccli_spoolss_ClosePrinter(pipe_hnd, mem_ctx, &hnd_src, NULL);
|
|---|
| 1766 |
|
|---|
| 1767 | if (is_valid_policy_hnd(&hnd_dst))
|
|---|
| 1768 | rpccli_spoolss_ClosePrinter(pipe_hnd_dst, mem_ctx, &hnd_dst, NULL);
|
|---|
| 1769 |
|
|---|
| 1770 | if (cli_dst) {
|
|---|
| 1771 | cli_shutdown(cli_dst);
|
|---|
| 1772 | }
|
|---|
| 1773 | return nt_status;
|
|---|
| 1774 | }
|
|---|
| 1775 |
|
|---|
| 1776 | /**
|
|---|
| 1777 | * Migrate printer-drivers from a src server to the dst server
|
|---|
| 1778 | *
|
|---|
| 1779 | * All parameters are provided by the run_rpc_command function, except for
|
|---|
| 1780 | * argc, argv which are passed through.
|
|---|
| 1781 | *
|
|---|
| 1782 | * @param c A net_context structure
|
|---|
| 1783 | * @param domain_sid The domain sid aquired from the remote server
|
|---|
| 1784 | * @param cli A cli_state connected to the server.
|
|---|
| 1785 | * @param mem_ctx Talloc context, destoyed on compleation of the function.
|
|---|
| 1786 | * @param argc Standard main() style argc
|
|---|
| 1787 | * @param argv Standard main() style argv. Initial components are already
|
|---|
| 1788 | * stripped
|
|---|
| 1789 | *
|
|---|
| 1790 | * @return Normal NTSTATUS return.
|
|---|
| 1791 | **/
|
|---|
| 1792 |
|
|---|
| 1793 | NTSTATUS rpc_printer_migrate_drivers_internals(struct net_context *c,
|
|---|
| 1794 | const DOM_SID *domain_sid,
|
|---|
| 1795 | const char *domain_name,
|
|---|
| 1796 | struct cli_state *cli,
|
|---|
| 1797 | struct rpc_pipe_client *pipe_hnd,
|
|---|
| 1798 | TALLOC_CTX *mem_ctx,
|
|---|
| 1799 | int argc,
|
|---|
| 1800 | const char **argv)
|
|---|
| 1801 | {
|
|---|
| 1802 | NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
|
|---|
| 1803 | uint32_t i, p;
|
|---|
| 1804 | uint32_t num_printers;
|
|---|
| 1805 | uint32_t level = 3;
|
|---|
| 1806 | const char *printername, *sharename;
|
|---|
| 1807 | bool got_src_driver_share = false;
|
|---|
| 1808 | bool got_dst_driver_share = false;
|
|---|
| 1809 | struct rpc_pipe_client *pipe_hnd_dst = NULL;
|
|---|
| 1810 | struct policy_handle hnd_src, hnd_dst;
|
|---|
| 1811 | union spoolss_DriverInfo drv_info_src;
|
|---|
| 1812 | union spoolss_PrinterInfo *info_enum;
|
|---|
| 1813 | union spoolss_PrinterInfo info_dst;
|
|---|
| 1814 | struct cli_state *cli_dst = NULL;
|
|---|
| 1815 | struct cli_state *cli_share_src = NULL;
|
|---|
| 1816 | struct cli_state *cli_share_dst = NULL;
|
|---|
| 1817 | const char *drivername = NULL;
|
|---|
| 1818 |
|
|---|
| 1819 | DEBUG(3,("copying printer-drivers\n"));
|
|---|
| 1820 |
|
|---|
| 1821 | nt_status = connect_dst_pipe(c, &cli_dst, &pipe_hnd_dst,
|
|---|
| 1822 | &ndr_table_spoolss.syntax_id);
|
|---|
| 1823 | if (!NT_STATUS_IS_OK(nt_status))
|
|---|
| 1824 | return nt_status;
|
|---|
| 1825 |
|
|---|
| 1826 | /* open print$-share on the src server */
|
|---|
| 1827 | nt_status = connect_to_service(c, &cli_share_src, &cli->dest_ss,
|
|---|
| 1828 | cli->desthost, "print$", "A:");
|
|---|
| 1829 | if (!NT_STATUS_IS_OK(nt_status))
|
|---|
| 1830 | goto done;
|
|---|
| 1831 |
|
|---|
| 1832 | got_src_driver_share = true;
|
|---|
| 1833 |
|
|---|
| 1834 |
|
|---|
| 1835 | /* open print$-share on the dst server */
|
|---|
| 1836 | nt_status = connect_to_service(c, &cli_share_dst, &cli_dst->dest_ss,
|
|---|
| 1837 | cli_dst->desthost, "print$", "A:");
|
|---|
| 1838 | if (!NT_STATUS_IS_OK(nt_status))
|
|---|
| 1839 | return nt_status;
|
|---|
| 1840 |
|
|---|
| 1841 | got_dst_driver_share = true;
|
|---|
| 1842 |
|
|---|
| 1843 |
|
|---|
| 1844 | /* enum src printers */
|
|---|
| 1845 | if (!get_printer_info(pipe_hnd, mem_ctx, 2, argc, argv, &num_printers, &info_enum)) {
|
|---|
| 1846 | nt_status = NT_STATUS_UNSUCCESSFUL;
|
|---|
| 1847 | goto done;
|
|---|
| 1848 | }
|
|---|
| 1849 |
|
|---|
| 1850 | if (num_printers == 0) {
|
|---|
| 1851 | printf (_("no printers found on server.\n"));
|
|---|
| 1852 | nt_status = NT_STATUS_OK;
|
|---|
| 1853 | goto done;
|
|---|
| 1854 | }
|
|---|
| 1855 |
|
|---|
| 1856 |
|
|---|
| 1857 | /* do something for all printers */
|
|---|
| 1858 | for (p = 0; p < num_printers; p++) {
|
|---|
| 1859 |
|
|---|
| 1860 | /* do some initialization */
|
|---|
| 1861 | printername = info_enum[p].info2.printername;
|
|---|
| 1862 | sharename = info_enum[p].info2.sharename;
|
|---|
| 1863 |
|
|---|
| 1864 | if (!printername || !sharename) {
|
|---|
| 1865 | nt_status = NT_STATUS_UNSUCCESSFUL;
|
|---|
| 1866 | goto done;
|
|---|
| 1867 | }
|
|---|
| 1868 |
|
|---|
| 1869 | /* we can reset NT_STATUS here because we do not
|
|---|
| 1870 | get any real NT_STATUS-codes anymore from now on */
|
|---|
| 1871 | nt_status = NT_STATUS_UNSUCCESSFUL;
|
|---|
| 1872 |
|
|---|
| 1873 | d_printf(_("migrating printer driver for: [%s] / [%s]\n"),
|
|---|
| 1874 | printername, sharename);
|
|---|
| 1875 |
|
|---|
| 1876 | /* open dst printer handle */
|
|---|
| 1877 | if (!net_spoolss_open_printer_ex(pipe_hnd_dst, mem_ctx, sharename,
|
|---|
| 1878 | PRINTER_ALL_ACCESS, cli->user_name, &hnd_dst))
|
|---|
| 1879 | goto done;
|
|---|
| 1880 |
|
|---|
| 1881 | /* check for existing dst printer */
|
|---|
| 1882 | if (!net_spoolss_getprinter(pipe_hnd_dst, mem_ctx, &hnd_dst, 2, &info_dst))
|
|---|
| 1883 | goto done;
|
|---|
| 1884 |
|
|---|
| 1885 |
|
|---|
| 1886 | /* open src printer handle */
|
|---|
| 1887 | if (!net_spoolss_open_printer_ex(pipe_hnd, mem_ctx, sharename,
|
|---|
| 1888 | MAXIMUM_ALLOWED_ACCESS,
|
|---|
| 1889 | pipe_hnd->auth->user_name,
|
|---|
| 1890 | &hnd_src))
|
|---|
| 1891 | goto done;
|
|---|
| 1892 |
|
|---|
| 1893 | /* in a first step call getdriver for each shared printer (per arch)
|
|---|
| 1894 | to get a list of all files that have to be copied */
|
|---|
| 1895 |
|
|---|
| 1896 | for (i=0; archi_table[i].long_archi!=NULL; i++) {
|
|---|
| 1897 |
|
|---|
| 1898 | /* getdriver src */
|
|---|
| 1899 | if (!net_spoolss_getprinterdriver(pipe_hnd, mem_ctx, &hnd_src,
|
|---|
| 1900 | level, archi_table[i].long_archi,
|
|---|
| 1901 | archi_table[i].version, &drv_info_src))
|
|---|
| 1902 | continue;
|
|---|
| 1903 |
|
|---|
| 1904 | drivername = drv_info_src.info3.driver_name;
|
|---|
| 1905 |
|
|---|
| 1906 | if (c->opt_verbose)
|
|---|
| 1907 | display_print_driver3(&drv_info_src.info3);
|
|---|
| 1908 |
|
|---|
| 1909 | /* check arch dir */
|
|---|
| 1910 | nt_status = check_arch_dir(cli_share_dst, archi_table[i].short_archi);
|
|---|
| 1911 | if (!NT_STATUS_IS_OK(nt_status))
|
|---|
| 1912 | goto done;
|
|---|
| 1913 |
|
|---|
| 1914 |
|
|---|
| 1915 | /* copy driver-files */
|
|---|
| 1916 | nt_status = copy_print_driver_3(c, mem_ctx, cli_share_src, cli_share_dst,
|
|---|
| 1917 | archi_table[i].short_archi,
|
|---|
| 1918 | &drv_info_src.info3);
|
|---|
| 1919 | if (!NT_STATUS_IS_OK(nt_status))
|
|---|
| 1920 | goto done;
|
|---|
| 1921 |
|
|---|
| 1922 |
|
|---|
| 1923 | /* adddriver dst */
|
|---|
| 1924 | if (!net_spoolss_addprinterdriver(pipe_hnd_dst, mem_ctx, level, &drv_info_src)) {
|
|---|
| 1925 | nt_status = NT_STATUS_UNSUCCESSFUL;
|
|---|
| 1926 | goto done;
|
|---|
| 1927 | }
|
|---|
| 1928 |
|
|---|
| 1929 | DEBUGADD(1,("Sucessfully added driver [%s] for printer [%s]\n",
|
|---|
| 1930 | drivername, printername));
|
|---|
| 1931 |
|
|---|
| 1932 | }
|
|---|
| 1933 |
|
|---|
| 1934 | if (!drivername || strlen(drivername) == 0) {
|
|---|
| 1935 | DEBUGADD(1,("Did not get driver for printer %s\n",
|
|---|
| 1936 | printername));
|
|---|
| 1937 | goto done;
|
|---|
| 1938 | }
|
|---|
| 1939 |
|
|---|
| 1940 | /* setdriver dst */
|
|---|
| 1941 | info_dst.info2.drivername = drivername;
|
|---|
| 1942 |
|
|---|
| 1943 | if (!net_spoolss_setprinter(pipe_hnd_dst, mem_ctx, &hnd_dst, 2, &info_dst)) {
|
|---|
| 1944 | nt_status = NT_STATUS_UNSUCCESSFUL;
|
|---|
| 1945 | goto done;
|
|---|
| 1946 | }
|
|---|
| 1947 |
|
|---|
| 1948 | DEBUGADD(1,("Sucessfully set driver %s for printer %s\n",
|
|---|
| 1949 | drivername, printername));
|
|---|
| 1950 |
|
|---|
| 1951 | /* close dst */
|
|---|
| 1952 | if (is_valid_policy_hnd(&hnd_dst)) {
|
|---|
| 1953 | rpccli_spoolss_ClosePrinter(pipe_hnd_dst, mem_ctx, &hnd_dst, NULL);
|
|---|
| 1954 | }
|
|---|
| 1955 |
|
|---|
| 1956 | /* close src */
|
|---|
| 1957 | if (is_valid_policy_hnd(&hnd_src)) {
|
|---|
| 1958 | rpccli_spoolss_ClosePrinter(pipe_hnd, mem_ctx, &hnd_src, NULL);
|
|---|
| 1959 | }
|
|---|
| 1960 | }
|
|---|
| 1961 |
|
|---|
| 1962 | nt_status = NT_STATUS_OK;
|
|---|
| 1963 |
|
|---|
| 1964 | done:
|
|---|
| 1965 |
|
|---|
| 1966 | if (is_valid_policy_hnd(&hnd_src))
|
|---|
| 1967 | rpccli_spoolss_ClosePrinter(pipe_hnd, mem_ctx, &hnd_src, NULL);
|
|---|
| 1968 |
|
|---|
| 1969 | if (is_valid_policy_hnd(&hnd_dst))
|
|---|
| 1970 | rpccli_spoolss_ClosePrinter(pipe_hnd_dst, mem_ctx, &hnd_dst, NULL);
|
|---|
| 1971 |
|
|---|
| 1972 | if (cli_dst) {
|
|---|
| 1973 | cli_shutdown(cli_dst);
|
|---|
| 1974 | }
|
|---|
| 1975 |
|
|---|
| 1976 | if (got_src_driver_share)
|
|---|
| 1977 | cli_shutdown(cli_share_src);
|
|---|
| 1978 |
|
|---|
| 1979 | if (got_dst_driver_share)
|
|---|
| 1980 | cli_shutdown(cli_share_dst);
|
|---|
| 1981 |
|
|---|
| 1982 | return nt_status;
|
|---|
| 1983 |
|
|---|
| 1984 | }
|
|---|
| 1985 |
|
|---|
| 1986 | /**
|
|---|
| 1987 | * Migrate printer-queues from a src to the dst server
|
|---|
| 1988 | * (requires a working "addprinter command" to be installed for the local smbd)
|
|---|
| 1989 | *
|
|---|
| 1990 | * All parameters are provided by the run_rpc_command function, except for
|
|---|
| 1991 | * argc, argv which are passed through.
|
|---|
| 1992 | *
|
|---|
| 1993 | * @param c A net_context structure
|
|---|
| 1994 | * @param domain_sid The domain sid aquired from the remote server
|
|---|
| 1995 | * @param cli A cli_state connected to the server.
|
|---|
| 1996 | * @param mem_ctx Talloc context, destoyed on compleation of the function.
|
|---|
| 1997 | * @param argc Standard main() style argc
|
|---|
| 1998 | * @param argv Standard main() style argv. Initial components are already
|
|---|
| 1999 | * stripped
|
|---|
| 2000 | *
|
|---|
| 2001 | * @return Normal NTSTATUS return.
|
|---|
| 2002 | **/
|
|---|
| 2003 |
|
|---|
| 2004 | NTSTATUS rpc_printer_migrate_printers_internals(struct net_context *c,
|
|---|
| 2005 | const DOM_SID *domain_sid,
|
|---|
| 2006 | const char *domain_name,
|
|---|
| 2007 | struct cli_state *cli,
|
|---|
| 2008 | struct rpc_pipe_client *pipe_hnd,
|
|---|
| 2009 | TALLOC_CTX *mem_ctx,
|
|---|
| 2010 | int argc,
|
|---|
| 2011 | const char **argv)
|
|---|
| 2012 | {
|
|---|
| 2013 | WERROR result;
|
|---|
| 2014 | NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
|
|---|
| 2015 | uint32_t i = 0, num_printers;
|
|---|
| 2016 | uint32_t level = 2;
|
|---|
| 2017 | union spoolss_PrinterInfo info_dst, info_src;
|
|---|
| 2018 | union spoolss_PrinterInfo *info_enum;
|
|---|
| 2019 | struct cli_state *cli_dst = NULL;
|
|---|
| 2020 | struct policy_handle hnd_dst, hnd_src;
|
|---|
| 2021 | const char *printername, *sharename;
|
|---|
| 2022 | struct rpc_pipe_client *pipe_hnd_dst = NULL;
|
|---|
| 2023 | struct spoolss_SetPrinterInfoCtr info_ctr;
|
|---|
| 2024 |
|
|---|
| 2025 | DEBUG(3,("copying printers\n"));
|
|---|
| 2026 |
|
|---|
| 2027 | /* connect destination PI_SPOOLSS */
|
|---|
| 2028 | nt_status = connect_dst_pipe(c, &cli_dst, &pipe_hnd_dst,
|
|---|
| 2029 | &ndr_table_spoolss.syntax_id);
|
|---|
| 2030 | if (!NT_STATUS_IS_OK(nt_status))
|
|---|
| 2031 | return nt_status;
|
|---|
| 2032 |
|
|---|
| 2033 | /* enum printers */
|
|---|
| 2034 | if (!get_printer_info(pipe_hnd, mem_ctx, level, argc, argv, &num_printers, &info_enum)) {
|
|---|
| 2035 | nt_status = NT_STATUS_UNSUCCESSFUL;
|
|---|
| 2036 | goto done;
|
|---|
| 2037 | }
|
|---|
| 2038 |
|
|---|
| 2039 | if (!num_printers) {
|
|---|
| 2040 | printf (_("no printers found on server.\n"));
|
|---|
| 2041 | nt_status = NT_STATUS_OK;
|
|---|
| 2042 | goto done;
|
|---|
| 2043 | }
|
|---|
| 2044 |
|
|---|
| 2045 | /* do something for all printers */
|
|---|
| 2046 | for (i = 0; i < num_printers; i++) {
|
|---|
| 2047 |
|
|---|
| 2048 | struct spoolss_SetPrinterInfo2 info2;
|
|---|
| 2049 |
|
|---|
| 2050 | /* do some initialization */
|
|---|
| 2051 | printername = info_enum[i].info2.printername;
|
|---|
| 2052 | sharename = info_enum[i].info2.sharename;
|
|---|
| 2053 |
|
|---|
| 2054 | if (!printername || !sharename) {
|
|---|
| 2055 | nt_status = NT_STATUS_UNSUCCESSFUL;
|
|---|
| 2056 | goto done;
|
|---|
| 2057 | }
|
|---|
| 2058 | /* we can reset NT_STATUS here because we do not
|
|---|
| 2059 | get any real NT_STATUS-codes anymore from now on */
|
|---|
| 2060 | nt_status = NT_STATUS_UNSUCCESSFUL;
|
|---|
| 2061 |
|
|---|
| 2062 | d_printf(_("migrating printer queue for: [%s] / [%s]\n"),
|
|---|
| 2063 | printername, sharename);
|
|---|
| 2064 |
|
|---|
| 2065 | /* open dst printer handle */
|
|---|
| 2066 | if (!net_spoolss_open_printer_ex(pipe_hnd_dst, mem_ctx, sharename,
|
|---|
| 2067 | PRINTER_ALL_ACCESS, cli->user_name, &hnd_dst)) {
|
|---|
| 2068 |
|
|---|
| 2069 | DEBUG(1,("could not open printer: %s\n", sharename));
|
|---|
| 2070 | }
|
|---|
| 2071 |
|
|---|
| 2072 | /* check for existing dst printer */
|
|---|
| 2073 | if (!net_spoolss_getprinter(pipe_hnd_dst, mem_ctx, &hnd_dst, level, &info_dst)) {
|
|---|
| 2074 | printf (_("could not get printer, creating printer.\n"));
|
|---|
| 2075 | } else {
|
|---|
| 2076 | DEBUG(1,("printer already exists: %s\n", sharename));
|
|---|
| 2077 | /* close printer handle here - dst only, not got src yet. */
|
|---|
| 2078 | if (is_valid_policy_hnd(&hnd_dst)) {
|
|---|
| 2079 | rpccli_spoolss_ClosePrinter(pipe_hnd_dst, mem_ctx, &hnd_dst, NULL);
|
|---|
| 2080 | }
|
|---|
| 2081 | continue;
|
|---|
| 2082 | }
|
|---|
| 2083 |
|
|---|
| 2084 | /* now get again src printer ctr via getprinter,
|
|---|
| 2085 | we first need a handle for that */
|
|---|
| 2086 |
|
|---|
| 2087 | /* open src printer handle */
|
|---|
| 2088 | if (!net_spoolss_open_printer_ex(pipe_hnd, mem_ctx, sharename,
|
|---|
| 2089 | MAXIMUM_ALLOWED_ACCESS, cli->user_name, &hnd_src))
|
|---|
| 2090 | goto done;
|
|---|
| 2091 |
|
|---|
| 2092 | /* getprinter on the src server */
|
|---|
| 2093 | if (!net_spoolss_getprinter(pipe_hnd, mem_ctx, &hnd_src, level, &info_src))
|
|---|
| 2094 | goto done;
|
|---|
| 2095 |
|
|---|
| 2096 | /* copy each src printer to a dst printer 1:1,
|
|---|
| 2097 | maybe some values have to be changed though */
|
|---|
| 2098 | d_printf(_("creating printer: %s\n"), printername);
|
|---|
| 2099 |
|
|---|
| 2100 | info_ctr.level = level;
|
|---|
| 2101 | spoolss_printerinfo2_to_setprinterinfo2(&info_src.info2, &info2);
|
|---|
| 2102 | info_ctr.info.info2 = &info2;
|
|---|
| 2103 |
|
|---|
| 2104 | result = rpccli_spoolss_addprinterex(pipe_hnd_dst,
|
|---|
| 2105 | mem_ctx,
|
|---|
| 2106 | &info_ctr);
|
|---|
| 2107 |
|
|---|
| 2108 | if (W_ERROR_IS_OK(result))
|
|---|
| 2109 | d_printf (_("printer [%s] successfully added.\n"),
|
|---|
| 2110 | printername);
|
|---|
| 2111 | else if (W_ERROR_V(result) == W_ERROR_V(WERR_PRINTER_ALREADY_EXISTS))
|
|---|
| 2112 | d_fprintf (stderr, _("printer [%s] already exists.\n"),
|
|---|
| 2113 | printername);
|
|---|
| 2114 | else {
|
|---|
| 2115 | d_fprintf (stderr, _("could not create printer [%s]\n"),
|
|---|
| 2116 | printername);
|
|---|
| 2117 | goto done;
|
|---|
| 2118 | }
|
|---|
| 2119 |
|
|---|
| 2120 | /* close printer handles here */
|
|---|
| 2121 | if (is_valid_policy_hnd(&hnd_src)) {
|
|---|
| 2122 | rpccli_spoolss_ClosePrinter(pipe_hnd, mem_ctx, &hnd_src, NULL);
|
|---|
| 2123 | }
|
|---|
| 2124 |
|
|---|
| 2125 | if (is_valid_policy_hnd(&hnd_dst)) {
|
|---|
| 2126 | rpccli_spoolss_ClosePrinter(pipe_hnd_dst, mem_ctx, &hnd_dst, NULL);
|
|---|
| 2127 | }
|
|---|
| 2128 | }
|
|---|
| 2129 |
|
|---|
| 2130 | nt_status = NT_STATUS_OK;
|
|---|
| 2131 |
|
|---|
| 2132 | done:
|
|---|
| 2133 | if (is_valid_policy_hnd(&hnd_src))
|
|---|
| 2134 | rpccli_spoolss_ClosePrinter(pipe_hnd, mem_ctx, &hnd_src, NULL);
|
|---|
| 2135 |
|
|---|
| 2136 | if (is_valid_policy_hnd(&hnd_dst))
|
|---|
| 2137 | rpccli_spoolss_ClosePrinter(pipe_hnd_dst, mem_ctx, &hnd_dst, NULL);
|
|---|
| 2138 |
|
|---|
| 2139 | if (cli_dst) {
|
|---|
| 2140 | cli_shutdown(cli_dst);
|
|---|
| 2141 | }
|
|---|
| 2142 | return nt_status;
|
|---|
| 2143 | }
|
|---|
| 2144 |
|
|---|
| 2145 | /**
|
|---|
| 2146 | * Migrate Printer-Settings from a src server to the dst server
|
|---|
| 2147 | * (for this to work, printers and drivers already have to be migrated earlier)
|
|---|
| 2148 | *
|
|---|
| 2149 | * All parameters are provided by the run_rpc_command function, except for
|
|---|
| 2150 | * argc, argv which are passed through.
|
|---|
| 2151 | *
|
|---|
| 2152 | * @param c A net_context structure
|
|---|
| 2153 | * @param domain_sid The domain sid aquired from the remote server
|
|---|
| 2154 | * @param cli A cli_state connected to the server.
|
|---|
| 2155 | * @param mem_ctx Talloc context, destoyed on compleation of the function.
|
|---|
| 2156 | * @param argc Standard main() style argc
|
|---|
| 2157 | * @param argv Standard main() style argv. Initial components are already
|
|---|
| 2158 | * stripped
|
|---|
| 2159 | *
|
|---|
| 2160 | * @return Normal NTSTATUS return.
|
|---|
| 2161 | **/
|
|---|
| 2162 |
|
|---|
| 2163 | NTSTATUS rpc_printer_migrate_settings_internals(struct net_context *c,
|
|---|
| 2164 | const DOM_SID *domain_sid,
|
|---|
| 2165 | const char *domain_name,
|
|---|
| 2166 | struct cli_state *cli,
|
|---|
| 2167 | struct rpc_pipe_client *pipe_hnd,
|
|---|
| 2168 | TALLOC_CTX *mem_ctx,
|
|---|
| 2169 | int argc,
|
|---|
| 2170 | const char **argv)
|
|---|
| 2171 | {
|
|---|
| 2172 |
|
|---|
| 2173 | /* FIXME: Here the nightmare begins */
|
|---|
| 2174 |
|
|---|
| 2175 | WERROR result;
|
|---|
| 2176 | NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
|
|---|
| 2177 | uint32_t i = 0, p = 0, j = 0;
|
|---|
| 2178 | uint32_t num_printers;
|
|---|
| 2179 | uint32_t level = 2;
|
|---|
| 2180 | const char *printername, *sharename;
|
|---|
| 2181 | struct rpc_pipe_client *pipe_hnd_dst = NULL;
|
|---|
| 2182 | struct policy_handle hnd_src, hnd_dst;
|
|---|
| 2183 | union spoolss_PrinterInfo *info_enum;
|
|---|
| 2184 | union spoolss_PrinterInfo info_dst_publish;
|
|---|
| 2185 | union spoolss_PrinterInfo info_dst;
|
|---|
| 2186 | struct cli_state *cli_dst = NULL;
|
|---|
| 2187 | char *devicename = NULL, *unc_name = NULL, *url = NULL;
|
|---|
| 2188 | const char *longname;
|
|---|
| 2189 | const char **keylist = NULL;
|
|---|
| 2190 |
|
|---|
| 2191 | /* FIXME GD */
|
|---|
| 2192 | ZERO_STRUCT(info_dst_publish);
|
|---|
| 2193 |
|
|---|
| 2194 | DEBUG(3,("copying printer settings\n"));
|
|---|
| 2195 |
|
|---|
| 2196 | /* connect destination PI_SPOOLSS */
|
|---|
| 2197 | nt_status = connect_dst_pipe(c, &cli_dst, &pipe_hnd_dst,
|
|---|
| 2198 | &ndr_table_spoolss.syntax_id);
|
|---|
| 2199 | if (!NT_STATUS_IS_OK(nt_status))
|
|---|
| 2200 | return nt_status;
|
|---|
| 2201 |
|
|---|
| 2202 | /* enum src printers */
|
|---|
| 2203 | if (!get_printer_info(pipe_hnd, mem_ctx, level, argc, argv, &num_printers, &info_enum)) {
|
|---|
| 2204 | nt_status = NT_STATUS_UNSUCCESSFUL;
|
|---|
| 2205 | goto done;
|
|---|
| 2206 | }
|
|---|
| 2207 |
|
|---|
| 2208 | if (!num_printers) {
|
|---|
| 2209 | printf (_("no printers found on server.\n"));
|
|---|
| 2210 | nt_status = NT_STATUS_OK;
|
|---|
| 2211 | goto done;
|
|---|
| 2212 | }
|
|---|
| 2213 |
|
|---|
| 2214 |
|
|---|
| 2215 | /* needed for dns-strings in regkeys */
|
|---|
| 2216 | longname = get_mydnsfullname();
|
|---|
| 2217 | if (!longname) {
|
|---|
| 2218 | nt_status = NT_STATUS_UNSUCCESSFUL;
|
|---|
| 2219 | goto done;
|
|---|
| 2220 | }
|
|---|
| 2221 |
|
|---|
| 2222 | /* do something for all printers */
|
|---|
| 2223 | for (i = 0; i < num_printers; i++) {
|
|---|
| 2224 |
|
|---|
| 2225 | uint32_t value_offered = 0, value_needed;
|
|---|
| 2226 | uint32_t data_offered = 0, data_needed;
|
|---|
| 2227 | enum winreg_Type type;
|
|---|
| 2228 | uint8_t *buffer = NULL;
|
|---|
| 2229 | const char *value_name = NULL;
|
|---|
| 2230 |
|
|---|
| 2231 | /* do some initialization */
|
|---|
| 2232 | printername = info_enum[i].info2.printername;
|
|---|
| 2233 | sharename = info_enum[i].info2.sharename;
|
|---|
| 2234 |
|
|---|
| 2235 | if (!printername || !sharename) {
|
|---|
| 2236 | nt_status = NT_STATUS_UNSUCCESSFUL;
|
|---|
| 2237 | goto done;
|
|---|
| 2238 | }
|
|---|
| 2239 | /* we can reset NT_STATUS here because we do not
|
|---|
| 2240 | get any real NT_STATUS-codes anymore from now on */
|
|---|
| 2241 | nt_status = NT_STATUS_UNSUCCESSFUL;
|
|---|
| 2242 |
|
|---|
| 2243 | d_printf(_("migrating printer settings for: [%s] / [%s]\n"),
|
|---|
| 2244 | printername, sharename);
|
|---|
| 2245 |
|
|---|
| 2246 |
|
|---|
| 2247 | /* open src printer handle */
|
|---|
| 2248 | if (!net_spoolss_open_printer_ex(pipe_hnd, mem_ctx, sharename,
|
|---|
| 2249 | MAXIMUM_ALLOWED_ACCESS, cli->user_name, &hnd_src))
|
|---|
| 2250 | goto done;
|
|---|
| 2251 |
|
|---|
| 2252 | /* open dst printer handle */
|
|---|
| 2253 | if (!net_spoolss_open_printer_ex(pipe_hnd_dst, mem_ctx, sharename,
|
|---|
| 2254 | PRINTER_ALL_ACCESS, cli_dst->user_name, &hnd_dst))
|
|---|
| 2255 | goto done;
|
|---|
| 2256 |
|
|---|
| 2257 | /* check for existing dst printer */
|
|---|
| 2258 | if (!net_spoolss_getprinter(pipe_hnd_dst, mem_ctx, &hnd_dst,
|
|---|
| 2259 | level, &info_dst))
|
|---|
| 2260 | goto done;
|
|---|
| 2261 |
|
|---|
| 2262 |
|
|---|
| 2263 | /* STEP 1: COPY DEVICE-MODE and other
|
|---|
| 2264 | PRINTER_INFO_2-attributes
|
|---|
| 2265 | */
|
|---|
| 2266 |
|
|---|
| 2267 | info_dst.info2 = info_enum[i].info2;
|
|---|
| 2268 |
|
|---|
| 2269 | /* why is the port always disconnected when the printer
|
|---|
| 2270 | is correctly installed (incl. driver ???) */
|
|---|
| 2271 | info_dst.info2.portname = SAMBA_PRINTER_PORT_NAME;
|
|---|
| 2272 |
|
|---|
| 2273 | /* check if printer is published */
|
|---|
| 2274 | if (info_enum[i].info2.attributes & PRINTER_ATTRIBUTE_PUBLISHED) {
|
|---|
| 2275 |
|
|---|
| 2276 | /* check for existing dst printer */
|
|---|
| 2277 | if (!net_spoolss_getprinter(pipe_hnd_dst, mem_ctx, &hnd_dst, 7, &info_dst_publish))
|
|---|
| 2278 | goto done;
|
|---|
| 2279 |
|
|---|
| 2280 | info_dst_publish.info7.action = DSPRINT_PUBLISH;
|
|---|
| 2281 |
|
|---|
| 2282 | /* ignore false from setprinter due to WERR_IO_PENDING */
|
|---|
| 2283 | net_spoolss_setprinter(pipe_hnd_dst, mem_ctx, &hnd_dst, 7, &info_dst_publish);
|
|---|
| 2284 |
|
|---|
| 2285 | DEBUG(3,("republished printer\n"));
|
|---|
| 2286 | }
|
|---|
| 2287 |
|
|---|
| 2288 | if (info_enum[i].info2.devmode != NULL) {
|
|---|
| 2289 |
|
|---|
| 2290 | /* copy devmode (info level 2) */
|
|---|
| 2291 | info_dst.info2.devmode = info_enum[i].info2.devmode;
|
|---|
| 2292 |
|
|---|
| 2293 | /* do not copy security descriptor (we have another
|
|---|
| 2294 | * command for that) */
|
|---|
| 2295 | info_dst.info2.secdesc = NULL;
|
|---|
| 2296 |
|
|---|
| 2297 | #if 0
|
|---|
| 2298 | info_dst.info2.devmode.devicename =
|
|---|
| 2299 | talloc_asprintf(mem_ctx, "\\\\%s\\%s",
|
|---|
| 2300 | longname, printername);
|
|---|
| 2301 | if (!info_dst.info2.devmode.devicename) {
|
|---|
| 2302 | nt_status = NT_STATUS_NO_MEMORY;
|
|---|
| 2303 | goto done;
|
|---|
| 2304 | }
|
|---|
| 2305 | #endif
|
|---|
| 2306 | if (!net_spoolss_setprinter(pipe_hnd_dst, mem_ctx, &hnd_dst,
|
|---|
| 2307 | level, &info_dst))
|
|---|
| 2308 | goto done;
|
|---|
| 2309 |
|
|---|
| 2310 | DEBUGADD(1,("\tSetPrinter of DEVICEMODE succeeded\n"));
|
|---|
| 2311 | }
|
|---|
| 2312 |
|
|---|
| 2313 | /* STEP 2: COPY REGISTRY VALUES */
|
|---|
| 2314 |
|
|---|
| 2315 | /* please keep in mind that samba parse_spools gives horribly
|
|---|
| 2316 | crippled results when used to rpccli_spoolss_enumprinterdataex
|
|---|
| 2317 | a win2k3-server. (Bugzilla #1851)
|
|---|
| 2318 | FIXME: IIRC I've seen it too on a win2k-server
|
|---|
| 2319 | */
|
|---|
| 2320 |
|
|---|
| 2321 | /* enumerate data on src handle */
|
|---|
| 2322 | nt_status = rpccli_spoolss_EnumPrinterData(pipe_hnd, mem_ctx,
|
|---|
| 2323 | &hnd_src,
|
|---|
| 2324 | p,
|
|---|
| 2325 | value_name,
|
|---|
| 2326 | value_offered,
|
|---|
| 2327 | &value_needed,
|
|---|
| 2328 | &type,
|
|---|
| 2329 | buffer,
|
|---|
| 2330 | data_offered,
|
|---|
| 2331 | &data_needed,
|
|---|
| 2332 | &result);
|
|---|
| 2333 |
|
|---|
| 2334 | data_offered = data_needed;
|
|---|
| 2335 | value_offered = value_needed;
|
|---|
| 2336 | buffer = talloc_zero_array(mem_ctx, uint8_t, data_needed);
|
|---|
| 2337 | value_name = talloc_zero_array(mem_ctx, char, value_needed);
|
|---|
| 2338 |
|
|---|
| 2339 | /* loop for all printerdata of "PrinterDriverData" */
|
|---|
| 2340 | while (NT_STATUS_IS_OK(nt_status) && W_ERROR_IS_OK(result)) {
|
|---|
| 2341 |
|
|---|
| 2342 | nt_status = rpccli_spoolss_EnumPrinterData(pipe_hnd, mem_ctx,
|
|---|
| 2343 | &hnd_src,
|
|---|
| 2344 | p++,
|
|---|
| 2345 | value_name,
|
|---|
| 2346 | value_offered,
|
|---|
| 2347 | &value_needed,
|
|---|
| 2348 | &type,
|
|---|
| 2349 | buffer,
|
|---|
| 2350 | data_offered,
|
|---|
| 2351 | &data_needed,
|
|---|
| 2352 | &result);
|
|---|
| 2353 | /* loop for all reg_keys */
|
|---|
| 2354 | if (NT_STATUS_IS_OK(nt_status) && W_ERROR_IS_OK(result)) {
|
|---|
| 2355 |
|
|---|
| 2356 | struct regval_blob v;
|
|---|
| 2357 |
|
|---|
| 2358 | /* display_value */
|
|---|
| 2359 | if (c->opt_verbose) {
|
|---|
| 2360 | fstrcpy(v.valuename, value_name);
|
|---|
| 2361 | v.type = type;
|
|---|
| 2362 | v.size = data_offered;
|
|---|
| 2363 | v.data_p = buffer;
|
|---|
| 2364 | display_reg_value(SPOOL_PRINTERDATA_KEY, v);
|
|---|
| 2365 | }
|
|---|
| 2366 |
|
|---|
| 2367 | /* set_value */
|
|---|
| 2368 | if (!net_spoolss_setprinterdata(pipe_hnd_dst, mem_ctx,
|
|---|
| 2369 | &hnd_dst, value_name,
|
|---|
| 2370 | type, buffer, data_offered))
|
|---|
| 2371 | goto done;
|
|---|
| 2372 |
|
|---|
| 2373 | DEBUGADD(1,("\tSetPrinterData of [%s] succeeded\n",
|
|---|
| 2374 | v.valuename));
|
|---|
| 2375 | }
|
|---|
| 2376 | }
|
|---|
| 2377 |
|
|---|
| 2378 | /* STEP 3: COPY SUBKEY VALUES */
|
|---|
| 2379 |
|
|---|
| 2380 | /* here we need to enum all printer_keys and then work
|
|---|
| 2381 | on the result with enum_printer_key_ex. nt4 does not
|
|---|
| 2382 | respond to enumprinterkey, win2k does, so continue
|
|---|
| 2383 | in case of an error */
|
|---|
| 2384 |
|
|---|
| 2385 | if (!net_spoolss_enumprinterkey(pipe_hnd, mem_ctx, &hnd_src, "", &keylist)) {
|
|---|
| 2386 | printf(_("got no key-data\n"));
|
|---|
| 2387 | continue;
|
|---|
| 2388 | }
|
|---|
| 2389 |
|
|---|
| 2390 |
|
|---|
| 2391 | /* work on a list of printer keys
|
|---|
| 2392 | each key has to be enumerated to get all required
|
|---|
| 2393 | information. information is then set via setprinterdataex-calls */
|
|---|
| 2394 |
|
|---|
| 2395 | if (keylist == NULL)
|
|---|
| 2396 | continue;
|
|---|
| 2397 |
|
|---|
| 2398 | for (i=0; keylist && keylist[i] != NULL; i++) {
|
|---|
| 2399 |
|
|---|
| 2400 | const char *subkey = keylist[i];
|
|---|
| 2401 | uint32_t count;
|
|---|
| 2402 | struct spoolss_PrinterEnumValues *info;
|
|---|
| 2403 |
|
|---|
| 2404 | /* enumerate all src subkeys */
|
|---|
| 2405 | if (!net_spoolss_enumprinterdataex(pipe_hnd, mem_ctx, 0,
|
|---|
| 2406 | &hnd_src, subkey,
|
|---|
| 2407 | &count, &info)) {
|
|---|
| 2408 | goto done;
|
|---|
| 2409 | }
|
|---|
| 2410 |
|
|---|
| 2411 | for (j=0; j < count; j++) {
|
|---|
| 2412 |
|
|---|
| 2413 | struct regval_blob value;
|
|---|
| 2414 | DATA_BLOB blob;
|
|---|
| 2415 |
|
|---|
| 2416 | /* although samba replies with sane data in most cases we
|
|---|
| 2417 | should try to avoid writing wrong registry data */
|
|---|
| 2418 |
|
|---|
| 2419 | if (strequal(info[j].value_name, SPOOL_REG_PORTNAME) ||
|
|---|
| 2420 | strequal(info[j].value_name, SPOOL_REG_UNCNAME) ||
|
|---|
| 2421 | strequal(info[j].value_name, SPOOL_REG_URL) ||
|
|---|
| 2422 | strequal(info[j].value_name, SPOOL_REG_SHORTSERVERNAME) ||
|
|---|
| 2423 | strequal(info[j].value_name, SPOOL_REG_SERVERNAME)) {
|
|---|
| 2424 |
|
|---|
| 2425 | if (strequal(info[j].value_name, SPOOL_REG_PORTNAME)) {
|
|---|
| 2426 |
|
|---|
| 2427 | /* although windows uses a multi-sz, we use a sz */
|
|---|
| 2428 | push_reg_sz(mem_ctx, &blob, SAMBA_PRINTER_PORT_NAME);
|
|---|
| 2429 | fstrcpy(value.valuename, SPOOL_REG_PORTNAME);
|
|---|
| 2430 | }
|
|---|
| 2431 |
|
|---|
| 2432 | if (strequal(info[j].value_name, SPOOL_REG_UNCNAME)) {
|
|---|
| 2433 |
|
|---|
| 2434 | if (asprintf(&unc_name, "\\\\%s\\%s", longname, sharename) < 0) {
|
|---|
| 2435 | nt_status = NT_STATUS_NO_MEMORY;
|
|---|
| 2436 | goto done;
|
|---|
| 2437 | }
|
|---|
| 2438 | push_reg_sz(mem_ctx, &blob, unc_name);
|
|---|
| 2439 | fstrcpy(value.valuename, SPOOL_REG_UNCNAME);
|
|---|
| 2440 | }
|
|---|
| 2441 |
|
|---|
| 2442 | if (strequal(info[j].value_name, SPOOL_REG_URL)) {
|
|---|
| 2443 |
|
|---|
| 2444 | continue;
|
|---|
| 2445 |
|
|---|
| 2446 | #if 0
|
|---|
| 2447 | /* FIXME: should we really do that ??? */
|
|---|
| 2448 | if (asprintf(&url, "http://%s:631/printers/%s", longname, sharename) < 0) {
|
|---|
| 2449 | nt_status = NT_STATUS_NO_MEMORY;
|
|---|
| 2450 | goto done;
|
|---|
| 2451 | }
|
|---|
| 2452 | push_reg_sz(mem_ctx, &blob, url);
|
|---|
| 2453 | fstrcpy(value.valuename, SPOOL_REG_URL);
|
|---|
| 2454 | #endif
|
|---|
| 2455 | }
|
|---|
| 2456 |
|
|---|
| 2457 | if (strequal(info[j].value_name, SPOOL_REG_SERVERNAME)) {
|
|---|
| 2458 |
|
|---|
| 2459 | push_reg_sz(mem_ctx, &blob, longname);
|
|---|
| 2460 | fstrcpy(value.valuename, SPOOL_REG_SERVERNAME);
|
|---|
| 2461 | }
|
|---|
| 2462 |
|
|---|
| 2463 | if (strequal(info[j].value_name, SPOOL_REG_SHORTSERVERNAME)) {
|
|---|
| 2464 |
|
|---|
| 2465 | push_reg_sz(mem_ctx, &blob, global_myname());
|
|---|
| 2466 | fstrcpy(value.valuename, SPOOL_REG_SHORTSERVERNAME);
|
|---|
| 2467 | }
|
|---|
| 2468 |
|
|---|
| 2469 | value.type = REG_SZ;
|
|---|
| 2470 | value.size = blob.length;
|
|---|
| 2471 | if (value.size) {
|
|---|
| 2472 | value.data_p = blob.data;
|
|---|
| 2473 | } else {
|
|---|
| 2474 | value.data_p = NULL;
|
|---|
| 2475 | }
|
|---|
| 2476 |
|
|---|
| 2477 | if (c->opt_verbose)
|
|---|
| 2478 | display_reg_value(subkey, value);
|
|---|
| 2479 |
|
|---|
| 2480 | /* here we have to set all subkeys on the dst server */
|
|---|
| 2481 | if (!net_spoolss_setprinterdataex(pipe_hnd_dst, mem_ctx, &hnd_dst,
|
|---|
| 2482 | subkey, &value))
|
|---|
| 2483 | goto done;
|
|---|
| 2484 |
|
|---|
| 2485 | } else {
|
|---|
| 2486 |
|
|---|
| 2487 | struct regval_blob v;
|
|---|
| 2488 |
|
|---|
| 2489 | fstrcpy(v.valuename, info[j].value_name);
|
|---|
| 2490 | v.type = info[j].type;
|
|---|
| 2491 | v.data_p = info[j].data->data;
|
|---|
| 2492 | v.size = info[j].data->length;
|
|---|
| 2493 |
|
|---|
| 2494 | if (c->opt_verbose) {
|
|---|
| 2495 | display_reg_value(subkey, v);
|
|---|
| 2496 | }
|
|---|
| 2497 |
|
|---|
| 2498 | /* here we have to set all subkeys on the dst server */
|
|---|
| 2499 | if (!net_spoolss_setprinterdataex(pipe_hnd_dst, mem_ctx, &hnd_dst,
|
|---|
| 2500 | subkey, &v)) {
|
|---|
| 2501 | goto done;
|
|---|
| 2502 | }
|
|---|
| 2503 |
|
|---|
| 2504 | }
|
|---|
| 2505 |
|
|---|
| 2506 | DEBUGADD(1,("\tSetPrinterDataEx of key [%s\\%s] succeeded\n",
|
|---|
| 2507 | subkey, info[j].value_name));
|
|---|
| 2508 |
|
|---|
| 2509 | }
|
|---|
| 2510 | }
|
|---|
| 2511 |
|
|---|
| 2512 | TALLOC_FREE(keylist);
|
|---|
| 2513 |
|
|---|
| 2514 | /* close printer handles here */
|
|---|
| 2515 | if (is_valid_policy_hnd(&hnd_src)) {
|
|---|
| 2516 | rpccli_spoolss_ClosePrinter(pipe_hnd, mem_ctx, &hnd_src, NULL);
|
|---|
| 2517 | }
|
|---|
| 2518 |
|
|---|
| 2519 | if (is_valid_policy_hnd(&hnd_dst)) {
|
|---|
| 2520 | rpccli_spoolss_ClosePrinter(pipe_hnd_dst, mem_ctx, &hnd_dst, NULL);
|
|---|
| 2521 | }
|
|---|
| 2522 |
|
|---|
| 2523 | }
|
|---|
| 2524 |
|
|---|
| 2525 | nt_status = NT_STATUS_OK;
|
|---|
| 2526 |
|
|---|
| 2527 | done:
|
|---|
| 2528 | SAFE_FREE(devicename);
|
|---|
| 2529 | SAFE_FREE(url);
|
|---|
| 2530 | SAFE_FREE(unc_name);
|
|---|
| 2531 |
|
|---|
| 2532 | if (is_valid_policy_hnd(&hnd_src))
|
|---|
| 2533 | rpccli_spoolss_ClosePrinter(pipe_hnd, mem_ctx, &hnd_src, NULL);
|
|---|
| 2534 |
|
|---|
| 2535 | if (is_valid_policy_hnd(&hnd_dst))
|
|---|
| 2536 | rpccli_spoolss_ClosePrinter(pipe_hnd_dst, mem_ctx, &hnd_dst, NULL);
|
|---|
| 2537 |
|
|---|
| 2538 | if (cli_dst) {
|
|---|
| 2539 | cli_shutdown(cli_dst);
|
|---|
| 2540 | }
|
|---|
| 2541 | return nt_status;
|
|---|
| 2542 | }
|
|---|