summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorTim Potter <tpot@samba.org>2003-09-15 05:35:02 +0000
committerTim Potter <tpot@samba.org>2003-09-15 05:35:02 +0000
commit240d5944e3b8e5b748465f9e974b2fab309703be (patch)
treebd8dad509383b6cce6a6bdcdac8f9a4fd6aadc1e /source3
parentca3d5310ce1ae62a8d169b68416096fca67a5f62 (diff)
downloadsamba-240d5944e3b8e5b748465f9e974b2fab309703be.tar.gz
samba-240d5944e3b8e5b748465f9e974b2fab309703be.tar.bz2
samba-240d5944e3b8e5b748465f9e974b2fab309703be.zip
Merge from Samba 3.0:
>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 9b6328bcfd5b53a05926eb5a97c74275842d086b)
Diffstat (limited to 'source3')
-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);