Changeset 745 for trunk/server/source3/libads/ldap_printer.c
- Timestamp:
- Nov 27, 2012, 4:43:17 PM (13 years ago)
- Location:
- trunk/server
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/server
- Property svn:mergeinfo changed
/vendor/current merged: 581,587,591,594,597,600,615,618,740
- Property svn:mergeinfo changed
-
trunk/server/source3/libads/ldap_printer.c
r429 r745 19 19 20 20 #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" 22 26 23 27 #ifdef HAVE_ADS … … 43 47 } 44 48 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; 49 51 return ADS_ERROR(LDAP_NO_SUCH_OBJECT); 50 52 } 51 53 srv_dn = ldap_get_dn(ads->ldap.ld, *res); 52 54 if (srv_dn == NULL) { 53 if (res) { 54 ads_msgfree(ads, *res); 55 *res = NULL; 56 } 55 ads_msgfree(ads, *res); 56 *res = NULL; 57 57 return ADS_ERROR(LDAP_NO_MEMORY); 58 58 } … … 60 60 if (srv_cn == NULL) { 61 61 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) {69 62 ads_msgfree(ads, *res); 70 63 *res = NULL; 71 } 64 return ADS_ERROR(LDAP_INVALID_DN_SYNTAX); 65 } 66 ads_msgfree(ads, *res); 67 *res = NULL; 72 68 73 69 if (asprintf(&s, "(cn=%s-%s)", srv_cn[0], printer) == -1) { … … 120 116 */ 121 117 static bool map_sz(TALLOC_CTX *ctx, ADS_MODLIST *mods, 122 conststruct regval_blob *value)118 struct regval_blob *value) 123 119 { 124 120 char *str_value = NULL; … … 126 122 ADS_STATUS status; 127 123 128 if ( value->type!= REG_SZ)124 if (regval_type(value) != REG_SZ) 129 125 return false; 130 126 131 if ( value->size && *((smb_ucs2_t *) value->data_p)) {127 if (regval_size(value) && *((smb_ucs2_t *) regval_data_p(value))) { 132 128 if (!pull_ucs2_talloc(ctx, &str_value, 133 (const smb_ucs2_t *) value->data_p,129 (const smb_ucs2_t *) regval_data_p(value), 134 130 &converted_size)) 135 131 { 136 132 return false; 137 133 } 138 status = ads_mod_str(ctx, mods, value->valuename, str_value);134 status = ads_mod_str(ctx, mods, regval_name(value), str_value); 139 135 return ADS_ERR_OK(status); 140 136 } … … 147 143 */ 148 144 static bool map_dword(TALLOC_CTX *ctx, ADS_MODLIST *mods, 149 conststruct regval_blob *value)145 struct regval_blob *value) 150 146 { 151 147 char *str_value = NULL; 152 148 ADS_STATUS status; 153 149 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))); 157 153 if (!str_value) { 158 154 return False; 159 155 } 160 status = ads_mod_str(ctx, mods, value->valuename, str_value);156 status = ads_mod_str(ctx, mods, regval_name(value), str_value); 161 157 return ADS_ERR_OK(status); 162 158 } … … 166 162 */ 167 163 static bool map_bool(TALLOC_CTX *ctx, ADS_MODLIST *mods, 168 conststruct regval_blob *value)164 struct regval_blob *value) 169 165 { 170 166 char *str_value; 171 167 ADS_STATUS status; 172 168 173 if (( value->type != REG_BINARY) || (value->size!= 1))169 if ((regval_type(value) != REG_BINARY) || (regval_size(value) != 1)) 174 170 return False; 175 171 str_value = talloc_asprintf(ctx, "%s", 176 *( value->data_p) ? "TRUE" : "FALSE");172 *(regval_data_p(value)) ? "TRUE" : "FALSE"); 177 173 if (!str_value) { 178 174 return False; 179 175 } 180 status = ads_mod_str(ctx, mods, value->valuename, str_value);176 status = ads_mod_str(ctx, mods, regval_name(value), str_value); 181 177 return ADS_ERR_OK(status); 182 178 } … … 186 182 */ 187 183 static bool map_multi_sz(TALLOC_CTX *ctx, ADS_MODLIST *mods, 188 conststruct regval_blob *value)184 struct regval_blob *value) 189 185 { 190 186 char **str_values = NULL; 191 187 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); 193 189 uint32 size = 0, num_vals = 0, i=0; 194 190 ADS_STATUS status; 195 191 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))) { 200 196 size += 2 * (strlen_w(cur_str) + 1); 201 197 cur_str += strlen_w(cur_str) + 1; … … 211 207 (num_vals + 1) * sizeof(char *)); 212 208 213 cur_str = (smb_ucs2_t *) value->data_p;209 cur_str = (smb_ucs2_t *) regval_data_p(value); 214 210 for (i=0; i < num_vals; i++) { 215 211 cur_str += pull_ucs2_talloc(ctx, &str_values[i], … … 218 214 } 219 215 220 status = ads_mod_strlist(ctx, mods, value->valuename,216 status = ads_mod_strlist(ctx, mods, regval_name(value), 221 217 (const char **) str_values); 222 218 return ADS_ERR_OK(status); … … 227 223 struct valmap_to_ads { 228 224 const char *valname; 229 bool (*fn)(TALLOC_CTX *, ADS_MODLIST *, conststruct regval_blob *);225 bool (*fn)(TALLOC_CTX *, ADS_MODLIST *, struct regval_blob *); 230 226 }; 231 227 … … 294 290 295 291 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) { 297 293 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))); 299 295 } else { 300 DEBUG(7, ("Mapped value %s\n", value->valuename));296 DEBUG(7, ("Mapped value %s\n", regval_name(value))); 301 297 } 302 298 … … 311 307 const char *printer) 312 308 { 309 struct dcerpc_binding_handle *b = cli->binding_handle; 313 310 WERROR result; 314 311 char *printername; … … 317 314 uint32 i; 318 315 struct policy_handle pol; 316 WERROR werr; 319 317 320 318 if ((asprintf(&printername, "%s\\%s", cli->srv_name_slash, printer) == -1)) { … … 346 344 /* Have the data we need now, so start building */ 347 345 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); 356 358 } 357 359 } … … 367 369 } else { 368 370 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); 377 383 } 378 384 } … … 380 386 ads_mod_str(mem_ctx, mods, SPOOL_REG_PRINTERNAME, printer); 381 387 382 rpccli_spoolss_ClosePrinter(cli, mem_ctx, &pol, NULL);388 dcerpc_spoolss_ClosePrinter(b, mem_ctx, &pol, &werr); 383 389 SAFE_FREE(printername); 384 390 … … 386 392 } 387 393 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 402 394 #endif
Note:
See TracChangeset
for help on using the changeset viewer.