Ignore:
Timestamp:
Nov 27, 2012, 4:43:17 PM (13 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: updated trunk to 3.6.0

Location:
trunk/server
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/server

  • trunk/server/source3/libads/ldap_printer.c

    r429 r745  
    1919
    2020#include "includes.h"
    21 #include "../librpc/gen_ndr/cli_spoolss.h"
     21#include "ads.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 "registry/reg_objects.h"
    2226
    2327#ifdef HAVE_ADS
     
    4347        }
    4448        if (ads_count_replies(ads, *res) != 1) {
    45                 if (res) {
    46                         ads_msgfree(ads, *res);
    47                         *res = NULL;
    48                 }
     49                ads_msgfree(ads, *res);
     50                *res = NULL;
    4951                return ADS_ERROR(LDAP_NO_SUCH_OBJECT);
    5052        }
    5153        srv_dn = ldap_get_dn(ads->ldap.ld, *res);
    5254        if (srv_dn == NULL) {
    53                 if (res) {
    54                         ads_msgfree(ads, *res);
    55                         *res = NULL;
    56                 }
     55                ads_msgfree(ads, *res);
     56                *res = NULL;
    5757                return ADS_ERROR(LDAP_NO_MEMORY);
    5858        }
     
    6060        if (srv_cn == NULL) {
    6161                ldap_memfree(srv_dn);
    62                 if (res) {
    63                         ads_msgfree(ads, *res);
    64                         *res = NULL;
    65                 }
    66                 return ADS_ERROR(LDAP_INVALID_DN_SYNTAX);
    67         }
    68         if (res) {
    6962                ads_msgfree(ads, *res);
    7063                *res = NULL;
    71         }
     64                return ADS_ERROR(LDAP_INVALID_DN_SYNTAX);
     65        }
     66        ads_msgfree(ads, *res);
     67        *res = NULL;
    7268
    7369        if (asprintf(&s, "(cn=%s-%s)", srv_cn[0], printer) == -1) {
     
    120116*/
    121117static bool map_sz(TALLOC_CTX *ctx, ADS_MODLIST *mods,
    122                    const struct regval_blob *value)
     118                   struct regval_blob *value)
    123119{
    124120        char *str_value = NULL;
     
    126122        ADS_STATUS status;
    127123
    128         if (value->type != REG_SZ)
     124        if (regval_type(value) != REG_SZ)
    129125                return false;
    130126
    131         if (value->size && *((smb_ucs2_t *) value->data_p)) {
     127        if (regval_size(value) && *((smb_ucs2_t *) regval_data_p(value))) {
    132128                if (!pull_ucs2_talloc(ctx, &str_value,
    133                                       (const smb_ucs2_t *) value->data_p,
     129                                      (const smb_ucs2_t *) regval_data_p(value),
    134130                                      &converted_size))
    135131                {
    136132                        return false;
    137133                }
    138                 status = ads_mod_str(ctx, mods, value->valuename, str_value);
     134                status = ads_mod_str(ctx, mods, regval_name(value), str_value);
    139135                return ADS_ERR_OK(status);
    140136        }
     
    147143*/
    148144static bool map_dword(TALLOC_CTX *ctx, ADS_MODLIST *mods,
    149                       const struct regval_blob *value)
     145                      struct regval_blob *value)
    150146{
    151147        char *str_value = NULL;
    152148        ADS_STATUS status;
    153149
    154         if (value->type != REG_DWORD)
    155                 return False;
    156         str_value = talloc_asprintf(ctx, "%d", *((uint32 *) value->data_p));
     150        if (regval_type(value) != REG_DWORD)
     151                return False;
     152        str_value = talloc_asprintf(ctx, "%d", *((uint32 *) regval_data_p(value)));
    157153        if (!str_value) {
    158154                return False;
    159155        }
    160         status = ads_mod_str(ctx, mods, value->valuename, str_value);
     156        status = ads_mod_str(ctx, mods, regval_name(value), str_value);
    161157        return ADS_ERR_OK(status);
    162158}
     
    166162*/
    167163static bool map_bool(TALLOC_CTX *ctx, ADS_MODLIST *mods,
    168                      const struct regval_blob *value)
     164                     struct regval_blob *value)
    169165{
    170166        char *str_value;
    171167        ADS_STATUS status;
    172168
    173         if ((value->type != REG_BINARY) || (value->size != 1))
     169        if ((regval_type(value) != REG_BINARY) || (regval_size(value) != 1))
    174170                return False;
    175171        str_value =  talloc_asprintf(ctx, "%s",
    176                                      *(value->data_p) ? "TRUE" : "FALSE");
     172                                     *(regval_data_p(value)) ? "TRUE" : "FALSE");
    177173        if (!str_value) {
    178174                return False;
    179175        }
    180         status = ads_mod_str(ctx, mods, value->valuename, str_value);
     176        status = ads_mod_str(ctx, mods, regval_name(value), str_value);
    181177        return ADS_ERR_OK(status);
    182178}
     
    186182*/
    187183static bool map_multi_sz(TALLOC_CTX *ctx, ADS_MODLIST *mods,
    188                          const struct regval_blob *value)
     184                         struct regval_blob *value)
    189185{
    190186        char **str_values = NULL;
    191187        size_t converted_size;
    192         smb_ucs2_t *cur_str = (smb_ucs2_t *) value->data_p;
     188        smb_ucs2_t *cur_str = (smb_ucs2_t *) regval_data_p(value);
    193189        uint32 size = 0, num_vals = 0, i=0;
    194190        ADS_STATUS status;
    195191
    196         if (value->type != REG_MULTI_SZ)
    197                 return False;
    198 
    199         while(cur_str && *cur_str && (size < value->size)) {           
     192        if (regval_type(value) != REG_MULTI_SZ)
     193                return False;
     194
     195        while(cur_str && *cur_str && (size < regval_size(value))) {
    200196                size += 2 * (strlen_w(cur_str) + 1);
    201197                cur_str += strlen_w(cur_str) + 1;
     
    211207                       (num_vals + 1) * sizeof(char *));
    212208
    213                 cur_str = (smb_ucs2_t *) value->data_p;
     209                cur_str = (smb_ucs2_t *) regval_data_p(value);
    214210                for (i=0; i < num_vals; i++) {
    215211                        cur_str += pull_ucs2_talloc(ctx, &str_values[i],
     
    218214                }
    219215
    220                 status = ads_mod_strlist(ctx, mods, value->valuename,
     216                status = ads_mod_strlist(ctx, mods, regval_name(value),
    221217                                         (const char **) str_values);
    222218                return ADS_ERR_OK(status);
     
    227223struct valmap_to_ads {
    228224        const char *valname;
    229         bool (*fn)(TALLOC_CTX *, ADS_MODLIST *, const struct regval_blob *);
     225        bool (*fn)(TALLOC_CTX *, ADS_MODLIST *, struct regval_blob *);
    230226};
    231227
     
    294290
    295291        for (i=0; map[i].valname; i++) {
    296                 if (StrCaseCmp(map[i].valname, value->valuename) == 0) {
     292                if (StrCaseCmp(map[i].valname, regval_name(value)) == 0) {
    297293                        if (!map[i].fn(ctx, mods, value)) {
    298                                 DEBUG(5, ("Add of value %s to modlist failed\n", value->valuename));
     294                                DEBUG(5, ("Add of value %s to modlist failed\n", regval_name(value)));
    299295                        } else {
    300                                 DEBUG(7, ("Mapped value %s\n", value->valuename));
     296                                DEBUG(7, ("Mapped value %s\n", regval_name(value)));
    301297                        }
    302298                       
     
    311307                                          const char *printer)
    312308{
     309        struct dcerpc_binding_handle *b = cli->binding_handle;
    313310        WERROR result;
    314311        char *printername;
     
    317314        uint32 i;
    318315        struct policy_handle pol;
     316        WERROR werr;
    319317
    320318        if ((asprintf(&printername, "%s\\%s", cli->srv_name_slash, printer) == -1)) {
     
    346344                /* Have the data we need now, so start building */
    347345                for (i=0; i < count; i++) {
    348                         struct regval_blob v;
    349 
    350                         fstrcpy(v.valuename, info[i].value_name);
    351                         v.type = info[i].type;
    352                         v.data_p = info[i].data->data;
    353                         v.size = info[i].data->length;
    354 
    355                         map_regval_to_ads(mem_ctx, mods, &v);
     346                        struct regval_blob *v;
     347
     348                        v = regval_compose(mem_ctx, info[i].value_name,
     349                                           info[i].type,
     350                                           info[i].data->data,
     351                                           info[i].data->length);
     352                        if (v == NULL) {
     353                                return WERR_NOMEM;
     354                        }
     355
     356                        map_regval_to_ads(mem_ctx, mods, v);
     357                        talloc_free(v);
    356358                }
    357359        }
     
    367369        } else {
    368370                for (i=0; i < count; i++) {
    369                         struct regval_blob v;
    370 
    371                         fstrcpy(v.valuename, info[i].value_name);
    372                         v.type = info[i].type;
    373                         v.data_p = info[i].data->data;
    374                         v.size = info[i].data->length;
    375 
    376                         map_regval_to_ads(mem_ctx, mods, &v);
     371                        struct regval_blob *v;
     372
     373                        v = regval_compose(mem_ctx, info[i].value_name,
     374                                           info[i].type,
     375                                           info[i].data->data,
     376                                           info[i].data->length);
     377                        if (v == NULL) {
     378                                return WERR_NOMEM;
     379                        }
     380
     381                        map_regval_to_ads(mem_ctx, mods, v);
     382                        talloc_free(v);
    377383                }
    378384        }
     
    380386        ads_mod_str(mem_ctx, mods, SPOOL_REG_PRINTERNAME, printer);
    381387
    382         rpccli_spoolss_ClosePrinter(cli, mem_ctx, &pol, NULL);
     388        dcerpc_spoolss_ClosePrinter(b, mem_ctx, &pol, &werr);
    383389        SAFE_FREE(printername);
    384390
     
    386392}
    387393
    388 bool get_local_printer_publishing_data(TALLOC_CTX *mem_ctx,
    389                                        ADS_MODLIST *mods,
    390                                        NT_PRINTER_DATA *data)
    391 {
    392         uint32 key,val;
    393 
    394         for (key=0; key < data->num_keys; key++) {
    395                 struct regval_ctr *ctr = data->keys[key].values;
    396                 for (val=0; val < ctr->num_values; val++)
    397                         map_regval_to_ads(mem_ctx, mods, ctr->values[val]);
    398         }
    399         return True;
    400 }
    401 
    402394#endif
Note: See TracChangeset for help on using the changeset viewer.