Ignore:
Timestamp:
Nov 14, 2012, 12:59:34 PM (13 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: update vendor to 3.6.0

File:
1 edited

Legend:

Unmodified
Added
Removed
  • vendor/current/source3/utils/net_rpc_printer.c

    r597 r740  
    1818*/
    1919#include "includes.h"
     20
    2021#include "utils/net.h"
    21 #include "../librpc/gen_ndr/cli_spoolss.h"
     22#include "rpc_client/rpc_client.h"
     23#include "../librpc/gen_ndr/ndr_spoolss_c.h"
     24#include "rpc_client/cli_spoolss.h"
     25#include "rpc_client/init_spoolss.h"
     26#include "nt_printing.h"
     27#include "registry/reg_objects.h"
     28#include "../libcli/security/security.h"
     29#include "../libcli/registry/util_reg.h"
     30#include "libsmb/libsmb.h"
    2231
    2332/* support itanium as well */
     
    6271        printf(_("\tHelpfile: [%s]\n\n"), r->help_file);
    6372
    64         for (i=0; r->dependent_files[i] != NULL; i++) {
     73        for (i=0; r->dependent_files[i] != NULL; i++) {
    6574                printf(_("\tDependentfiles: [%s]\n"), r->dependent_files[i]);
    6675        }
     
    7281}
    7382
    74 static void display_reg_value(const char *subkey, struct regval_blob value)
     83static void display_reg_value(const char *subkey, struct regval_blob value)
    7584{
    7685        const char *text;
    7786        DATA_BLOB blob;
    7887
    79         switch(value.type) {
     88        switch() {
    8089        case REG_DWORD:
    8190                d_printf(_("\t[%s:%s]: REG_DWORD: 0x%08x\n"), subkey,
    82                         value.valuename, *((uint32_t *) value.data_p));
     91                        ));
    8392                break;
    8493
    8594        case REG_SZ:
    86                 blob = data_blob_const(value.data_p, value.size);
     95                blob = data_blob_const();
    8796                pull_reg_sz(talloc_tos(), &blob, &text);
    8897                if (!text) {
    8998                        break;
    9099                }
    91                 d_printf(_("\t[%s:%s]: REG_SZ: %s\n"), subkey, value.valuename,
     100                d_printf(_("\t[%s:%s]: REG_SZ: %s\n"), subkey, ,
    92101                         text);
    93102                break;
     
    96105                d_printf(_("\t[%s:%s]: REG_BINARY: unknown length value not "
    97106                           "displayed\n"),
    98                          subkey, value.valuename);
     107                         subkey, );
    99108                break;
    100109
     
    102111                uint32_t i;
    103112                const char **values;
    104                 blob = data_blob_const(value.data_p, value.size);
     113                blob = data_blob_const();
    105114
    106115                if (!pull_reg_multi_sz(NULL, &blob, &values)) {
     
    109118                }
    110119
    111                 printf("%s: REG_MULTI_SZ: \n", value.valuename);
     120                printf("%s: REG_MULTI_SZ: \n", );
    112121                for (i=0; values[i] != NULL; i++) {
    113122                        d_printf("%s\n", values[i]);
     
    118127
    119128        default:
    120                 d_printf(_("\t%s: unknown type %d\n"), value.valuename,
    121                          value.type);
     129                d_printf(_("\t%s: unknown type %d\n"), ,
     130                         );
    122131        }
    123132
     
    153162        uint16_t fnum_src = 0;
    154163        uint16_t fnum_dst = 0;
    155         SEC_DESC *sd = NULL;
     164        *sd = NULL;
    156165        uint16_t attr;
    157166        time_t f_atime, f_ctime, f_mtime;
     
    226235
    227236        if (copy_acls) {
     237
    228238
    229239                /* 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);
     240                status = cli_set_secdesc(cli_share_dst, fnum_dst, sd);
     241                if (!NT_STATUS_IS_OK(status)) {
     242                        DEBUG(0, ("could not set secdesc on %s: %s\n",
     243                                  dst_name, nt_errstr(status)));
     244                        nt_status = status;
    234245                        goto out;
    235246                }
     
    377388
    378389                /* copying file */
    379                 int n, ret;
     390                int n;
    380391                n = cli_read(cli_share_src, fnum_src, data, nread,
    381392                                read_size);
     
    384395                        break;
    385396
    386                 ret = cli_write(cli_share_dst, fnum_dst, 0, data,
    387                         nread, n);
    388 
    389                 if (n != ret) {
     397                ,
     398                        );
     399
     400                if () {
    390401                        d_fprintf(stderr, _("Error writing file: %s\n"),
    391                                 cli_errstr(cli_share_dst));
    392                         nt_status = cli_nt_error(cli_share_dst);
     402                                  nt_errstr(nt_status));
    393403                        goto out;
    394404                }
     
    487497                                    const char *file, const char *short_archi) {
    488498
    489         NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
    490499        const char *p;
    491500        char *src_name;
    492501        char *dst_name;
    493         char *version;
    494         char *filename;
     502        char *version;
     503        char *filename;
    495504        char *tok;
    496505
     
    509518        }
    510519
     520
     521
     522
     523
    511524        /* build source file name */
    512         if (asprintf(&src_name, "\\%s\\%s\\%s", short_archi, version, filename) < 0 )
     525        src_name = talloc_asprintf(mem_ctx, "\\%s\\%s\\%s",
     526                                   short_archi, version, filename);
     527        if (src_name == NULL) {
    513528                return NT_STATUS_NO_MEMORY;
    514 
     529        }
    515530
    516531        /* create destination file name */
    517         if (asprintf(&dst_name, "\\%s\\%s", short_archi, filename) < 0 )
    518                 return NT_STATUS_NO_MEMORY;
     532        dst_name = talloc_asprintf(mem_ctx, "\\%s\\%s", short_archi, filename);
     533        if (dst_name == NULL) {
     534                return NT_STATUS_NO_MEMORY;
     535        }
    519536
    520537
    521538        /* 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;
     539        return net_copy_file(c, mem_ctx, cli_share_src, cli_share_dst,
     540                             src_name, dst_name, false, false, false, true);
    534541}
    535542
     
    752759                                union spoolss_PrinterInfo *info)
    753760{
     761
    754762        WERROR result;
    755763        NTSTATUS status;
     
    812820        }
    813821
    814         status = rpccli_spoolss_SetPrinter(pipe_hnd, mem_ctx,
     822        status = , mem_ctx,
    815823                                           hnd,
    816824                                           &info_ctr,
     
    819827                                           0, /* command */
    820828                                           &result);
    821 
     829        if (!NT_STATUS_IS_OK(status)) {
     830                printf(_("cannot set printer-info: %s\n"), nt_errstr(status));
     831                return false;
     832        }
    822833        if (!W_ERROR_IS_OK(result)) {
    823834                printf(_("cannot set printer-info: %s\n"), win_errstr(result));
     
    837848                                       uint32_t offered)
    838849{
     850
    839851        WERROR result;
    840852        NTSTATUS status;
    841853
    842854        /* setprinterdata call */
    843         status = rpccli_spoolss_SetPrinterData(pipe_hnd, mem_ctx,
     855        status = , mem_ctx,
    844856                                               hnd,
    845857                                               value_name,
     
    848860                                               offered,
    849861                                               &result);
    850 
     862        if (!NT_STATUS_IS_OK(status)) {
     863                printf (_("unable to set printerdata: %s\n"),
     864                        nt_errstr(status));
     865                return false;
     866        }
    851867        if (!W_ERROR_IS_OK(result)) {
    852868                printf (_("unable to set printerdata: %s\n"),
     
    911927                                        struct regval_blob *value)
    912928{
     929
    913930        WERROR result;
    914931        NTSTATUS status;
    915932
    916933        /* setprinterdataex call */
    917         status = rpccli_spoolss_SetPrinterDataEx(pipe_hnd, mem_ctx,
     934        status = , mem_ctx,
    918935                                                 hnd,
    919936                                                 keyname,
    920                                                  value->valuename,
    921                                                  value->type,
    922                                                  value->data_p,
    923                                                  value->size,
     937                                                 ,
     938                                                 ,
     939                                                 ,
     940                                                 ,
    924941                                                 &result);
    925 
     942        if (!NT_STATUS_IS_OK(status)) {
     943                printf(_("could not set printerdataex: %s\n"),
     944                       nt_errstr(status));
     945                return false;
     946        }
    926947        if (!W_ERROR_IS_OK(result)) {
    927948                printf(_("could not set printerdataex: %s\n"),
     
    974995                                                   info);
    975996        if (!W_ERROR_IS_OK(result)) {
    976                 printf(_("cannot enum drivers: %s\n"), win_errstr(result));
    977                 return false;
     997                if (W_ERROR_V(result) != W_ERROR_V(WERR_INVALID_ENVIRONMENT)) {
     998                        printf(_("cannot enum drivers for environment %s: %s\n"), env,
     999                                win_errstr(result));
     1000                        return false;
     1001                } else {
     1002                        printf(_("Server does not support environment [%s]\n"),
     1003                                env);
     1004                }
    9781005        }
    9791006
     
    10211048                             union spoolss_DriverInfo *info)
    10221049{
     1050
    10231051        WERROR result;
    10241052        NTSTATUS status;
     
    10421070
    10431071        /* addprinterdriver call */
    1044         status = rpccli_spoolss_AddPrinterDriver(pipe_hnd, mem_ctx,
     1072        status = , mem_ctx,
    10451073                                                 pipe_hnd->srv_name_slash,
    10461074                                                 &info_ctr,
    10471075                                                 &result);
     1076
     1077
     1078
     1079
    10481080        /* be more verbose */
    10491081        if (W_ERROR_V(result) == W_ERROR_V(WERR_ACCESS_DENIED)) {
     
    10721104                        union spoolss_PrinterInfo **info_p)
    10731105{
     1106
    10741107        struct policy_handle hnd;
     1108
    10751109
    10761110        /* no arguments given, enumerate all printers */
     
    10981132
    10991133        if (!net_spoolss_getprinter(pipe_hnd, mem_ctx, &hnd, level, *info_p)) {
    1100                 rpccli_spoolss_ClosePrinter(pipe_hnd, mem_ctx, &hnd, NULL);
     1134                );
    11011135                return false;
    11021136        }
    11031137
    1104         rpccli_spoolss_ClosePrinter(pipe_hnd, mem_ctx, &hnd, NULL);
     1138        );
    11051139
    11061140        *num_printers = 1;
     
    11311165
    11321166NTSTATUS rpc_printer_list_internals(struct net_context *c,
    1133                                         const DOM_SID *domain_sid,
     1167                                        const *domain_sid,
    11341168                                        const char *domain_name,
    11351169                                        struct cli_state *cli,
     
    11831217
    11841218NTSTATUS rpc_printer_driver_list_internals(struct net_context *c,
    1185                                                 const DOM_SID *domain_sid,
     1219                                                const *domain_sid,
    11861220                                                const char *domain_name,
    11871221                                                struct cli_state *cli,
     
    12541288                                        uint32_t action)
    12551289{
     1290
    12561291        NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
    12571292        uint32_t i, num_printers;
     
    13011336                default:
    13021337                        action_str = N_("unknown action");
    1303                         printf(_("unkown action: %d\n"), action);
     1338                        printf(_("unkown action: %d\n"), action);
    13041339                        break;
    13051340                }
     
    13131348                ZERO_STRUCT(secdesc_ctr);
    13141349
    1315                 nt_status = rpccli_spoolss_SetPrinter(pipe_hnd, mem_ctx,
     1350                nt_status = , mem_ctx,
    13161351                                                      &hnd,
    13171352                                                      &info_ctr,
     
    13201355                                                      0, /* command */
    13211356                                                      &result);
    1322 
    1323                 if (!W_ERROR_IS_OK(result) && (W_ERROR_V(result) != W_ERROR_V(WERR_IO_PENDING))) {
     1357                if (!NT_STATUS_IS_OK(nt_status)) {
    13241358                        printf(_("cannot set printer-info: %s\n"),
    1325                                win_errstr(result));
     1359                               nt_errstr(nt_status));
     1360                        goto done;
     1361                }
     1362                if (!W_ERROR_IS_OK(result) && !W_ERROR_EQUAL(result, WERR_IO_PENDING)) {
     1363                        if ((action == DSPRINT_UPDATE) && W_ERROR_EQUAL(result, W_ERROR(0x80070002))) {
     1364                                printf(_("printer not published yet\n"));
     1365                        } else {
     1366                                printf(_("cannot set printer-info: %s\n"),
     1367                                       win_errstr(result));
     1368                        }
     1369                        nt_status = werror_to_ntstatus(result);
    13261370                        goto done;
    13271371                }
     
    13341378
    13351379done:
    1336         if (is_valid_policy_hnd(&hnd))
    1337                 rpccli_spoolss_ClosePrinter(pipe_hnd, mem_ctx, &hnd, NULL);
     1380        if (is_valid_policy_hnd(&hnd)) {
     1381                dcerpc_spoolss_ClosePrinter(b, mem_ctx, &hnd, &result);
     1382        }
    13381383
    13391384        return nt_status;
     
    13411386
    13421387NTSTATUS rpc_printer_publish_publish_internals(struct net_context *c,
    1343                                                 const DOM_SID *domain_sid,
     1388                                                const *domain_sid,
    13441389                                                const char *domain_name,
    13451390                                                struct cli_state *cli,
     
    13531398
    13541399NTSTATUS rpc_printer_publish_unpublish_internals(struct net_context *c,
    1355                                                 const DOM_SID *domain_sid,
     1400                                                const *domain_sid,
    13561401                                                const char *domain_name,
    13571402                                                struct cli_state *cli,
     
    13651410
    13661411NTSTATUS rpc_printer_publish_update_internals(struct net_context *c,
    1367                                                 const DOM_SID *domain_sid,
     1412                                                const *domain_sid,
    13681413                                                const char *domain_name,
    13691414                                                struct cli_state *cli,
     
    13941439
    13951440NTSTATUS rpc_printer_publish_list_internals(struct net_context *c,
    1396                                                 const DOM_SID *domain_sid,
     1441                                                const *domain_sid,
    13971442                                                const char *domain_name,
    13981443                                                struct cli_state *cli,
     
    14021447                                                const char **argv)
    14031448{
     1449
    14041450        NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
    14051451        uint32_t i, num_printers;
     
    14101456        struct policy_handle hnd;
    14111457        int state;
     1458
    14121459
    14131460        if (!get_printer_info(pipe_hnd, mem_ctx, 2, argc, argv, &num_printers, &info_enum))
     
    14541501                                break;
    14551502                        default:
    1456                                 printf(_("unkown state: %d\n"), state);
     1503                                printf(_("unkown state: %d\n"), state);
    14571504                                break;
    14581505                }
     
    14621509
    14631510done:
    1464         if (is_valid_policy_hnd(&hnd))
    1465                 rpccli_spoolss_ClosePrinter(pipe_hnd, mem_ctx, &hnd, NULL);
     1511        if (is_valid_policy_hnd(&hnd)) {
     1512                dcerpc_spoolss_ClosePrinter(b, mem_ctx, &hnd, &werr);
     1513        }
    14661514
    14671515        return nt_status;
     
    14861534
    14871535NTSTATUS rpc_printer_migrate_security_internals(struct net_context *c,
    1488                                                 const DOM_SID *domain_sid,
     1536                                                const *domain_sid,
    14891537                                                const char *domain_name,
    14901538                                                struct cli_state *cli,
     
    14941542                                                const char **argv)
    14951543{
     1544
    14961545        /* TODO: what now, info2 or info3 ?
    14971546           convince jerry that we should add clientside setacls level 3 at least
     
    15031552        const char *printername, *sharename;
    15041553        struct rpc_pipe_client *pipe_hnd_dst = NULL;
     1554
    15051555        struct policy_handle hnd_src, hnd_dst;
    15061556        union spoolss_PrinterInfo *info_enum;
    15071557        struct cli_state *cli_dst = NULL;
    15081558        union spoolss_PrinterInfo info_src, info_dst;
     1559
    15091560
    15101561        DEBUG(3,("copying printer ACLs\n"));
     
    15131564        nt_status = connect_dst_pipe(c, &cli_dst, &pipe_hnd_dst,
    15141565                                     &ndr_table_spoolss.syntax_id);
    1515         if (!NT_STATUS_IS_OK(nt_status))
     1566        if (!NT_STATUS_IS_OK(nt_status))
    15161567                return nt_status;
    1517 
     1568        }
     1569        b_dst = pipe_hnd_dst->binding_handle;
    15181570
    15191571        /* enum source printers */
     
    15891641                /* close printer handles here */
    15901642                if (is_valid_policy_hnd(&hnd_src)) {
    1591                         rpccli_spoolss_ClosePrinter(pipe_hnd, mem_ctx, &hnd_src, NULL);
     1643                        );
    15921644                }
    15931645
    15941646                if (is_valid_policy_hnd(&hnd_dst)) {
    1595                         rpccli_spoolss_ClosePrinter(pipe_hnd_dst, mem_ctx, &hnd_dst, NULL);
     1647                        );
    15961648                }
    15971649
     
    16031655
    16041656        if (is_valid_policy_hnd(&hnd_src)) {
    1605                 rpccli_spoolss_ClosePrinter(pipe_hnd, mem_ctx, &hnd_src, NULL);
     1657                );
    16061658        }
    16071659
    16081660        if (is_valid_policy_hnd(&hnd_dst)) {
    1609                 rpccli_spoolss_ClosePrinter(pipe_hnd_dst, mem_ctx, &hnd_dst, NULL);
     1661                );
    16101662        }
    16111663
     
    16341686
    16351687NTSTATUS rpc_printer_migrate_forms_internals(struct net_context *c,
    1636                                                 const DOM_SID *domain_sid,
     1688                                                const *domain_sid,
    16371689                                                const char *domain_name,
    16381690                                                struct cli_state *cli,
     
    16421694                                                const char **argv)
    16431695{
     1696
    16441697        NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
    16451698        WERROR result;
     
    16491702        const char *printername, *sharename;
    16501703        struct rpc_pipe_client *pipe_hnd_dst = NULL;
     1704
    16511705        struct policy_handle hnd_src, hnd_dst;
    16521706        union spoolss_PrinterInfo *info_enum;
     
    16611715        nt_status = connect_dst_pipe(c, &cli_dst, &pipe_hnd_dst,
    16621716                                     &ndr_table_spoolss.syntax_id);
    1663         if (!NT_STATUS_IS_OK(nt_status))
     1717        if (!NT_STATUS_IS_OK(nt_status))
    16641718                return nt_status;
     1719
     1720
    16651721
    16661722        /* enum src printers */
     
    17371793                        /* FIXME: there might be something wrong with samba's
    17381794                           builtin-forms */
    1739                         status = rpccli_spoolss_AddForm(pipe_hnd_dst, mem_ctx,
     1795                        status = _dst, mem_ctx,
    17401796                                                        &hnd_dst,
    17411797                                                        1,
    17421798                                                        info,
    17431799                                                        &result);
     1800
     1801
     1802
     1803
     1804
    17441805                        if (!W_ERROR_IS_OK(result)) {
    17451806                                d_printf(_("\tAddForm form %d: [%s] refused.\n"),
     
    17551816                /* close printer handles here */
    17561817                if (is_valid_policy_hnd(&hnd_src)) {
    1757                         rpccli_spoolss_ClosePrinter(pipe_hnd, mem_ctx, &hnd_src, NULL);
     1818                        );
    17581819                }
    17591820
    17601821                if (is_valid_policy_hnd(&hnd_dst)) {
    1761                         rpccli_spoolss_ClosePrinter(pipe_hnd_dst, mem_ctx, &hnd_dst, NULL);
     1822                        );
    17621823                }
    17631824        }
     
    17671828done:
    17681829
    1769         if (is_valid_policy_hnd(&hnd_src))
    1770                 rpccli_spoolss_ClosePrinter(pipe_hnd, mem_ctx, &hnd_src, NULL);
    1771 
    1772         if (is_valid_policy_hnd(&hnd_dst))
    1773                 rpccli_spoolss_ClosePrinter(pipe_hnd_dst, mem_ctx, &hnd_dst, NULL);
     1830        if (is_valid_policy_hnd(&hnd_src)) {
     1831                dcerpc_spoolss_ClosePrinter(b_src, mem_ctx, &hnd_src, &result);
     1832        }
     1833
     1834        if (is_valid_policy_hnd(&hnd_dst)) {
     1835                dcerpc_spoolss_ClosePrinter(b_dst, mem_ctx, &hnd_dst, &result);
     1836        }
    17741837
    17751838        if (cli_dst) {
     
    17971860
    17981861NTSTATUS rpc_printer_migrate_drivers_internals(struct net_context *c,
    1799                                                 const DOM_SID *domain_sid,
     1862                                                const *domain_sid,
    18001863                                                const char *domain_name,
    18011864                                                struct cli_state *cli,
     
    18051868                                                const char **argv)
    18061869{
     1870
    18071871        NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
    18081872        uint32_t i, p;
     
    18131877        bool got_dst_driver_share = false;
    18141878        struct rpc_pipe_client *pipe_hnd_dst = NULL;
     1879
    18151880        struct policy_handle hnd_src, hnd_dst;
    18161881        union spoolss_DriverInfo drv_info_src;
     
    18211886        struct cli_state *cli_share_dst = NULL;
    18221887        const char *drivername = NULL;
     1888
    18231889
    18241890        DEBUG(3,("copying printer-drivers\n"));
     
    18261892        nt_status = connect_dst_pipe(c, &cli_dst, &pipe_hnd_dst,
    18271893                                     &ndr_table_spoolss.syntax_id);
    1828         if (!NT_STATUS_IS_OK(nt_status))
     1894        if (!NT_STATUS_IS_OK(nt_status))
    18291895                return nt_status;
     1896
     1897
    18301898
    18311899        /* open print$-share on the src server */
     
    19562024                /* close dst */
    19572025                if (is_valid_policy_hnd(&hnd_dst)) {
    1958                         rpccli_spoolss_ClosePrinter(pipe_hnd_dst, mem_ctx, &hnd_dst, NULL);
     2026                        );
    19592027                }
    19602028
    19612029                /* close src */
    19622030                if (is_valid_policy_hnd(&hnd_src)) {
    1963                         rpccli_spoolss_ClosePrinter(pipe_hnd, mem_ctx, &hnd_src, NULL);
     2031                        );
    19642032                }
    19652033        }
     
    19692037done:
    19702038
    1971         if (is_valid_policy_hnd(&hnd_src))
    1972                 rpccli_spoolss_ClosePrinter(pipe_hnd, mem_ctx, &hnd_src, NULL);
    1973 
    1974         if (is_valid_policy_hnd(&hnd_dst))
    1975                 rpccli_spoolss_ClosePrinter(pipe_hnd_dst, mem_ctx, &hnd_dst, NULL);
     2039        if (is_valid_policy_hnd(&hnd_dst)) {
     2040                dcerpc_spoolss_ClosePrinter(b_dst, mem_ctx, &hnd_dst, &werr);
     2041        }
     2042
     2043        /* close src */
     2044        if (is_valid_policy_hnd(&hnd_src)) {
     2045                dcerpc_spoolss_ClosePrinter(b_src, mem_ctx, &hnd_src, &werr);
     2046        }
    19762047
    19772048        if (cli_dst) {
     
    20082079
    20092080NTSTATUS rpc_printer_migrate_printers_internals(struct net_context *c,
    2010                                                 const DOM_SID *domain_sid,
     2081                                                const *domain_sid,
    20112082                                                const char *domain_name,
    20122083                                                struct cli_state *cli,
     
    20162087                                                const char **argv)
    20172088{
     2089
    20182090        WERROR result;
    20192091        NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
     
    20262098        const char *printername, *sharename;
    20272099        struct rpc_pipe_client *pipe_hnd_dst = NULL;
     2100
    20282101        struct spoolss_SetPrinterInfoCtr info_ctr;
    20292102
     
    20332106        nt_status = connect_dst_pipe(c, &cli_dst, &pipe_hnd_dst,
    20342107                                     &ndr_table_spoolss.syntax_id);
    2035         if (!NT_STATUS_IS_OK(nt_status))
     2108        if (!NT_STATUS_IS_OK(nt_status))
    20362109                return nt_status;
     2110
     2111
    20372112
    20382113        /* enum printers */
     
    20822157                        /* close printer handle here - dst only, not got src yet. */
    20832158                        if (is_valid_policy_hnd(&hnd_dst)) {
    2084                                 rpccli_spoolss_ClosePrinter(pipe_hnd_dst, mem_ctx, &hnd_dst, NULL);
     2159                                );
    20852160                        }
    20862161                        continue;
     
    21252200                /* close printer handles here */
    21262201                if (is_valid_policy_hnd(&hnd_src)) {
    2127                         rpccli_spoolss_ClosePrinter(pipe_hnd, mem_ctx, &hnd_src, NULL);
     2202                        );
    21282203                }
    21292204
    21302205                if (is_valid_policy_hnd(&hnd_dst)) {
    2131                         rpccli_spoolss_ClosePrinter(pipe_hnd_dst, mem_ctx, &hnd_dst, NULL);
     2206                        );
    21322207                }
    21332208        }
     
    21362211
    21372212done:
    2138         if (is_valid_policy_hnd(&hnd_src))
    2139                 rpccli_spoolss_ClosePrinter(pipe_hnd, mem_ctx, &hnd_src, NULL);
    2140 
    2141         if (is_valid_policy_hnd(&hnd_dst))
    2142                 rpccli_spoolss_ClosePrinter(pipe_hnd_dst, mem_ctx, &hnd_dst, NULL);
     2213        if (is_valid_policy_hnd(&hnd_src)) {
     2214                dcerpc_spoolss_ClosePrinter(b_src, mem_ctx, &hnd_src, &result);
     2215        }
     2216
     2217        if (is_valid_policy_hnd(&hnd_dst)) {
     2218                dcerpc_spoolss_ClosePrinter(b_dst, mem_ctx, &hnd_dst, &result);
     2219        }
    21432220
    21442221        if (cli_dst) {
     
    21672244
    21682245NTSTATUS rpc_printer_migrate_settings_internals(struct net_context *c,
    2169                                                 const DOM_SID *domain_sid,
     2246                                                const *domain_sid,
    21702247                                                const char *domain_name,
    21712248                                                struct cli_state *cli,
     
    21752252                                                const char **argv)
    21762253{
     2254
    21772255
    21782256        /* FIXME: Here the nightmare begins */
     
    21802258        WERROR result;
    21812259        NTSTATUS nt_status = NT_STATUS_UNSUCCESSFUL;
    2182         uint32_t i = 0, p = 0, j = 0;
     2260        uint32_t i = 0, j = 0;
    21832261        uint32_t num_printers;
    21842262        uint32_t level = 2;
    21852263        const char *printername, *sharename;
    21862264        struct rpc_pipe_client *pipe_hnd_dst = NULL;
     2265
    21872266        struct policy_handle hnd_src, hnd_dst;
    21882267        union spoolss_PrinterInfo *info_enum;
     
    22022281        nt_status = connect_dst_pipe(c, &cli_dst, &pipe_hnd_dst,
    22032282                                     &ndr_table_spoolss.syntax_id);
    2204         if (!NT_STATUS_IS_OK(nt_status))
     2283        if (!NT_STATUS_IS_OK(nt_status))
    22052284                return nt_status;
     2285
     2286
    22062287
    22072288        /* enum src printers */
     
    22282309        for (i = 0; i < num_printers; i++) {
    22292310
    2230                 uint32_t value_offered = 0, value_needed;
    2231                 uint32_t data_offered = 0, data_needed;
     2311                uint32_t value_needed;
     2312                uint32_t data_needed;
    22322313                enum winreg_Type type;
    2233                 uint8_t *buffer = NULL;
    2234                 const char *value_name = NULL;
     2314                struct spoolss_EnumPrinterData r;
    22352315
    22362316                /* do some initialization */
     
    23242404                */
    23252405
     2406
     2407
     2408
     2409
     2410
     2411
     2412
     2413
     2414
     2415
    23262416                /* enumerate data on src handle */
    2327                 nt_status = rpccli_spoolss_EnumPrinterData(pipe_hnd, mem_ctx,
    2328                                                            &hnd_src,
    2329                                                            p,
    2330                                                            value_name,
    2331                                                            value_offered,
    2332                                                            &value_needed,
    2333                                                            &type,
    2334                                                            buffer,
    2335                                                            data_offered,
    2336                                                            &data_needed,
    2337                                                            &result);
    2338 
    2339                 data_offered    = data_needed;
    2340                 value_offered   = value_needed;
    2341                 buffer          = talloc_zero_array(mem_ctx, uint8_t, data_needed);
    2342                 value_name      = talloc_zero_array(mem_ctx, char, value_needed);
     2417                nt_status = dcerpc_spoolss_EnumPrinterData_r(b_src, mem_ctx, &r);
     2418
     2419                r.in.data_offered       = *r.out.data_needed;
     2420                r.in.value_offered      = *r.out.value_needed;
     2421                r.out.data              = talloc_zero_array(mem_ctx, uint8_t, r.in.data_offered);
     2422                r.out.value_name        = talloc_zero_array(mem_ctx, char, r.in.value_offered);
    23432423
    23442424                /* loop for all printerdata of "PrinterDriverData" */
    2345                 while (NT_STATUS_IS_OK(nt_status) && W_ERROR_IS_OK(result)) {
    2346 
    2347                         nt_status = rpccli_spoolss_EnumPrinterData(pipe_hnd, mem_ctx,
    2348                                                                    &hnd_src,
    2349                                                                    p++,
    2350                                                                    value_name,
    2351                                                                    value_offered,
    2352                                                                    &value_needed,
    2353                                                                    &type,
    2354                                                                    buffer,
    2355                                                                    data_offered,
    2356                                                                    &data_needed,
    2357                                                                    &result);
     2425                while (NT_STATUS_IS_OK(nt_status) && W_ERROR_IS_OK(r.out.result)) {
     2426
     2427                        r.in.enum_index++;
     2428
     2429                        nt_status = dcerpc_spoolss_EnumPrinterData_r(b_src, mem_ctx, &r);
     2430
    23582431                        /* loop for all reg_keys */
    2359                         if (NT_STATUS_IS_OK(nt_status) && W_ERROR_IS_OK(result)) {
    2360 
    2361                                 struct regval_blob v;
     2432                        if (NT_STATUS_IS_OK(nt_status) && W_ERROR_IS_OK(r.out.result)) {
    23622433
    23632434                                /* display_value */
    23642435                                if (c->opt_verbose) {
    2365                                         fstrcpy(v.valuename, value_name);
    2366                                         v.type = type;
    2367                                         v.size = data_offered;
    2368                                         v.data_p = buffer;
     2436                                        struct regval_blob *v;
     2437
     2438                                        v = regval_compose(talloc_tos(),
     2439                                                           r.out.value_name,
     2440                                                           *r.out.type,
     2441                                                           r.out.data,
     2442                                                           r.in.data_offered);
     2443                                        if (v == NULL) {
     2444                                                nt_status = NT_STATUS_NO_MEMORY;
     2445                                                goto done;
     2446                                        }
     2447
    23692448                                        display_reg_value(SPOOL_PRINTERDATA_KEY, v);
     2449
    23702450                                }
    23712451
    23722452                                /* set_value */
    23732453                                if (!net_spoolss_setprinterdata(pipe_hnd_dst, mem_ctx,
    2374                                                                 &hnd_dst, value_name,
    2375                                                                 type, buffer, data_offered))
     2454                                                                &hnd_dst, value_name,
     2455                                                                data_offered))
    23762456                                        goto done;
    23772457
    23782458                                DEBUGADD(1,("\tSetPrinterData of [%s] succeeded\n",
    2379                                         v.valuename));
     2459                                        name));
    23802460                        }
    23812461                }
     
    24162496                        for (j=0; j < count; j++) {
    24172497
    2418                                 struct regval_blob value;
     2498                                struct regval_blob value;
    24192499                                DATA_BLOB blob;
     2500
     2501
    24202502
    24212503                                /* although samba replies with sane data in most cases we
     
    24322514                                                /* although windows uses a multi-sz, we use a sz */
    24332515                                                push_reg_sz(mem_ctx, &blob, SAMBA_PRINTER_PORT_NAME);
    2434                                                 fstrcpy(value.valuename, SPOOL_REG_PORTNAME);
    24352516                                        }
    24362517
     
    24422523                                                }
    24432524                                                push_reg_sz(mem_ctx, &blob, unc_name);
    2444                                                 fstrcpy(value.valuename, SPOOL_REG_UNCNAME);
    24452525                                        }
    24462526
     
    24552535                                                        goto done;
    24562536                                                }
    2457                                                 push_reg_sz(mem_ctx, &blob, url);
     2537                                                push_reg_sz(mem_ctx, &blob, url);
    24582538                                                fstrcpy(value.valuename, SPOOL_REG_URL);
    24592539#endif
     
    24632543
    24642544                                                push_reg_sz(mem_ctx, &blob, longname);
    2465                                                 fstrcpy(value.valuename, SPOOL_REG_SERVERNAME);
    24662545                                        }
    24672546
     
    24692548
    24702549                                                push_reg_sz(mem_ctx, &blob, global_myname());
    2471                                                 fstrcpy(value.valuename, SPOOL_REG_SHORTSERVERNAME);
    24722550                                        }
    24732551
    2474                                         value.type = REG_SZ;
    2475                                         value.size = blob.length;
    2476                                         if (value.size) {
    2477                                                 value.data_p = blob.data;
    2478                                         } else {
    2479                                                 value.data_p = NULL;
     2552                                        value = regval_compose(talloc_tos(),
     2553                                                               info[j].value_name,
     2554                                                               REG_SZ,
     2555                                                               blob.length == 0 ? NULL : blob.data,
     2556                                                               blob.length);
     2557                                        if (value == NULL) {
     2558                                                nt_status = NT_STATUS_NO_MEMORY;
     2559                                                goto done;
    24802560                                        }
    24812561
     
    24852565                                        /* here we have to set all subkeys on the dst server */
    24862566                                        if (!net_spoolss_setprinterdataex(pipe_hnd_dst, mem_ctx, &hnd_dst,
    2487                                                         subkey, &value))
     2567                                                        subkey, value))
     2568                                        {
     2569                                                talloc_free(value);
    24882570                                                goto done;
    2489 
     2571                                        }
     2572
     2573                                        talloc_free(value);
    24902574                                } else {
    24912575
    2492                                         struct regval_blob v;
    2493 
    2494                                         fstrcpy(v.valuename, info[j].value_name);
    2495                                         v.type = info[j].type;
    2496                                         v.data_p = info[j].data->data;
    2497                                         v.size = info[j].data->length;
     2576                                        struct regval_blob *v;
     2577
     2578                                        v = regval_compose(talloc_tos(),
     2579                                                           info[j].value_name,
     2580                                                           info[j].type,
     2581                                                           info[j].data->data,
     2582                                                           info[j].data->length);
     2583                                        if (v == NULL) {
     2584                                                nt_status = NT_STATUS_NO_MEMORY;
     2585                                                goto done;
     2586                                        }
    24982587
    24992588                                        if (c->opt_verbose) {
     
    25032592                                        /* here we have to set all subkeys on the dst server */
    25042593                                        if (!net_spoolss_setprinterdataex(pipe_hnd_dst, mem_ctx, &hnd_dst,
    2505                                                         subkey, &v)) {
     2594                                                        subkey, v)) {
    25062595                                                goto done;
    25072596                                        }
    25082597
     2598
    25092599                                }
    25102600
     
    25192609                /* close printer handles here */
    25202610                if (is_valid_policy_hnd(&hnd_src)) {
    2521                         rpccli_spoolss_ClosePrinter(pipe_hnd, mem_ctx, &hnd_src, NULL);
     2611                        );
    25222612                }
    25232613
    25242614                if (is_valid_policy_hnd(&hnd_dst)) {
    2525                         rpccli_spoolss_ClosePrinter(pipe_hnd_dst, mem_ctx, &hnd_dst, NULL);
    2526                 }
    2527 
     2615                        dcerpc_spoolss_ClosePrinter(b_dst, mem_ctx, &hnd_dst, &result);
     2616                }
    25282617        }
    25292618
     
    25352624        SAFE_FREE(unc_name);
    25362625
    2537         if (is_valid_policy_hnd(&hnd_src))
    2538                 rpccli_spoolss_ClosePrinter(pipe_hnd, mem_ctx, &hnd_src, NULL);
    2539 
    2540         if (is_valid_policy_hnd(&hnd_dst))
    2541                 rpccli_spoolss_ClosePrinter(pipe_hnd_dst, mem_ctx, &hnd_dst, NULL);
     2626        if (is_valid_policy_hnd(&hnd_src)) {
     2627                dcerpc_spoolss_ClosePrinter(b_src, mem_ctx, &hnd_src, &result);
     2628        }
     2629
     2630        if (is_valid_policy_hnd(&hnd_dst)) {
     2631                dcerpc_spoolss_ClosePrinter(b_dst, mem_ctx, &hnd_dst, &result);
     2632        }
    25422633
    25432634        if (cli_dst) {
Note: See TracChangeset for help on using the changeset viewer.