summaryrefslogtreecommitdiff
path: root/source3/printing/nt_printing.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2003-09-10 22:33:06 +0000
committerJeremy Allison <jra@samba.org>2003-09-10 22:33:06 +0000
commitca1c6ebb11361dabaca22015736f3876d51833a2 (patch)
tree462e0afef069859619591cbf0e83742c94457fb4 /source3/printing/nt_printing.c
parentb5f07b9ca802747816c407e9c79bcfb4009d605f (diff)
downloadsamba-ca1c6ebb11361dabaca22015736f3876d51833a2.tar.gz
samba-ca1c6ebb11361dabaca22015736f3876d51833a2.tar.bz2
samba-ca1c6ebb11361dabaca22015736f3876d51833a2.zip
Fix a nasty mess, and also bug #296. passdb/pdb_ldap.c was not converting
to/from utf8 for some calls. The libads code gets this right. Wonder why the passdb code doesn't use it ? Jeremy. (This used to be commit 910d21d3164c2c64773031fddaad35ea88e72a04)
Diffstat (limited to 'source3/printing/nt_printing.c')
-rw-r--r--source3/printing/nt_printing.c44
1 files changed, 39 insertions, 5 deletions
diff --git a/source3/printing/nt_printing.c b/source3/printing/nt_printing.c
index 4859d785be..868f68c079 100644
--- a/source3/printing/nt_printing.c
+++ b/source3/printing/nt_printing.c
@@ -2587,7 +2587,8 @@ static WERROR publish_it(NT_PRINTER_INFO_LEVEL *printer)
ADS_STATUS ads_rc;
TALLOC_CTX *ctx = talloc_init("publish_it");
ADS_MODLIST mods = ads_init_mods(ctx);
- char *prt_dn = NULL, *srv_dn, **srv_cn;
+ char *prt_dn = NULL, *srv_dn, *srv_cn_0;
+ char *srv_dn_utf8, **srv_cn_utf8;
void *res = NULL;
ADS_STRUCT *ads;
const char *attrs[] = {"objectGUID", NULL};
@@ -2634,12 +2635,45 @@ static WERROR publish_it(NT_PRINTER_INFO_LEVEL *printer)
/* figure out where to publish */
ads_find_machine_acct(ads, &res, global_myname());
- srv_dn = ldap_get_dn(ads->ld, res);
+
+ /* We use ldap_get_dn here as we need the answer
+ * in utf8 to call ldap_explode_dn(). JRA. */
+
+ srv_dn_utf8 = ldap_get_dn(ads->ld, res);
+ if (!srv_dn_utf8) {
+ ads_destroy(&ads);
+ return WERR_SERVER_UNAVAILABLE;
+ }
ads_msgfree(ads, res);
- srv_cn = ldap_explode_dn(srv_dn, 1);
- asprintf(&prt_dn, "cn=%s-%s,%s", srv_cn[0],
+ srv_cn_utf8 = ldap_explode_dn(srv_dn_utf8, 1);
+ if (!srv_cn_utf8) {
+ ldap_memfree(srv_dn_utf8);
+ ads_destroy(&ads);
+ return WERR_SERVER_UNAVAILABLE;
+ }
+ /* Now convert to CH_UNIX. */
+ if (pull_utf8_allocate((void **) &srv_dn, srv_dn_utf8) == (size_t)-1) {
+ ldap_memfree(srv_dn_utf8);
+ ldap_memfree(srv_cn_utf8);
+ ads_destroy(&ads);
+ return WERR_SERVER_UNAVAILABLE;
+ }
+ if (pull_utf8_allocate((void **) &srv_cn_0, srv_cn_utf8[0]) == (size_t)-1) {
+ ldap_memfree(srv_dn_utf8);
+ ldap_memfree(srv_cn_utf8);
+ ads_destroy(&ads);
+ SAFE_FREE(srv_dn);
+ return WERR_SERVER_UNAVAILABLE;
+ }
+
+ ldap_memfree(srv_dn_utf8);
+ ldap_memfree(srv_cn_utf8);
+
+ asprintf(&prt_dn, "cn=%s-%s,%s", srv_cn_0,
printer->info_2->sharename, srv_dn);
- ads_memfree(ads, srv_dn);
+
+ SAFE_FREE(srv_dn);
+ SAFE_FREE(srv_cn_0);
/* publish it */
ads_rc = ads_add_printer_entry(ads, prt_dn, ctx, &mods);