The branch, master has been updated
       via  4f9cffb BUG 9378: Add extra attributes for AD printer publishing.
       via  12a08d8 printing: Remove invalid free from error path.
      from  f0852a3 Remove locking across the lifetime of the copychunk call.

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit 4f9cffbae6a60268140eba5e457ac7e86cac6246
Author: David Disseldorp <dd...@samba.org>
Date:   Thu Jan 17 13:21:25 2013 +0100

    BUG 9378: Add extra attributes for AD printer publishing.
    
    Currently attempting to publish a printer in AD fails with "Object class
    violation", due to a number of missing attributes in the LDAP request.
    
    Reviewed-by: Andreas Schneider <a...@samba.org>
    
    Autobuild-User(master): Andreas Schneider <a...@cryptomilk.org>
    Autobuild-Date(master): Fri Jan 18 17:27:35 CET 2013 on sn-devel-104

commit 12a08d8ae254d5cb0651cb6016ab7e1859f47d82
Author: David Disseldorp <dd...@samba.org>
Date:   Fri Jan 18 11:48:20 2013 +0100

    printing: Remove invalid free from error path.
    
    Reviewed-by: Andreas Schneider <a...@samba.org>

-----------------------------------------------------------------------

Summary of changes:
 source3/printing/nt_printing_ads.c |   87 +++++++++++++++++++++++++++++++++++-
 1 files changed, 85 insertions(+), 2 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/printing/nt_printing_ads.c 
b/source3/printing/nt_printing_ads.c
index 87cab63..b99a972 100644
--- a/source3/printing/nt_printing_ads.c
+++ b/source3/printing/nt_printing_ads.c
@@ -87,6 +87,86 @@ done:
        talloc_free(tmp_ctx);
 }
 
+static WERROR nt_printer_info_to_mods(TALLOC_CTX *ctx,
+                                     struct spoolss_PrinterInfo2 *info2,
+                                     ADS_MODLIST *mods)
+{
+       char *info_str;
+
+       ads_mod_str(ctx, mods, SPOOL_REG_PRINTERNAME, info2->sharename);
+       ads_mod_str(ctx, mods, SPOOL_REG_SHORTSERVERNAME, lp_netbios_name());
+       ads_mod_str(ctx, mods, SPOOL_REG_SERVERNAME, get_mydnsfullname());
+
+       info_str = talloc_asprintf(ctx, "\\\\%s\\%s",
+                                  get_mydnsfullname(), info2->sharename);
+       if (info_str == NULL) {
+               return WERR_NOMEM;
+       }
+       ads_mod_str(ctx, mods, SPOOL_REG_UNCNAME, info_str);
+
+       info_str = talloc_asprintf(ctx, "%d", 4);
+       if (info_str == NULL) {
+               return WERR_NOMEM;
+       }
+       ads_mod_str(ctx, mods, SPOOL_REG_VERSIONNUMBER, info_str);
+
+       /* empty strings in the mods list result in an attrubute error */
+       if (strlen(info2->drivername) != 0)
+               ads_mod_str(ctx, mods, SPOOL_REG_DRIVERNAME, info2->drivername);
+       if (strlen(info2->location) != 0)
+               ads_mod_str(ctx, mods, SPOOL_REG_LOCATION, info2->location);
+       if (strlen(info2->comment) != 0)
+               ads_mod_str(ctx, mods, SPOOL_REG_DESCRIPTION, info2->comment);
+       if (strlen(info2->portname) != 0)
+               ads_mod_str(ctx, mods, SPOOL_REG_PORTNAME, info2->portname);
+       if (strlen(info2->sepfile) != 0)
+               ads_mod_str(ctx, mods, SPOOL_REG_PRINTSEPARATORFILE, 
info2->sepfile);
+
+       info_str = talloc_asprintf(ctx, "%u", info2->starttime);
+       if (info_str == NULL) {
+               return WERR_NOMEM;
+       }
+       ads_mod_str(ctx, mods, SPOOL_REG_PRINTSTARTTIME, info_str);
+
+       info_str = talloc_asprintf(ctx, "%u", info2->untiltime);
+       if (info_str == NULL) {
+               return WERR_NOMEM;
+       }
+       ads_mod_str(ctx, mods, SPOOL_REG_PRINTENDTIME, info_str);
+
+       info_str = talloc_asprintf(ctx, "%u", info2->priority);
+       if (info_str == NULL) {
+               return WERR_NOMEM;
+       }
+       ads_mod_str(ctx, mods, SPOOL_REG_PRIORITY, info_str);
+
+       if (info2->attributes & PRINTER_ATTRIBUTE_KEEPPRINTEDJOBS) {
+               ads_mod_str(ctx, mods, SPOOL_REG_PRINTKEEPPRINTEDJOBS, "TRUE");
+       } else {
+               ads_mod_str(ctx, mods, SPOOL_REG_PRINTKEEPPRINTEDJOBS, "FALSE");
+       }
+
+       switch (info2->attributes & 0x3) {
+       case 0:
+               ads_mod_str(ctx, mods, SPOOL_REG_PRINTSPOOLING,
+                           SPOOL_REGVAL_PRINTWHILESPOOLING);
+               break;
+       case 1:
+               ads_mod_str(ctx, mods, SPOOL_REG_PRINTSPOOLING,
+                           SPOOL_REGVAL_PRINTAFTERSPOOLED);
+               break;
+       case 2:
+               ads_mod_str(ctx, mods, SPOOL_REG_PRINTSPOOLING,
+                           SPOOL_REGVAL_PRINTDIRECT);
+               break;
+       default:
+               DEBUG(3, ("unsupported printer attributes %x\n",
+                         info2->attributes));
+       }
+
+       return WERR_OK;
+}
+
 static WERROR nt_printer_publish_ads(struct messaging_context *msg_ctx,
                                     ADS_STRUCT *ads,
                                     struct spoolss_PrinterInfo2 *pinfo2)
@@ -167,12 +247,15 @@ static WERROR nt_printer_publish_ads(struct 
messaging_context *msg_ctx,
        mods = ads_init_mods(ctx);
 
        if (mods == NULL) {
-               SAFE_FREE(prt_dn);
                TALLOC_FREE(ctx);
                return WERR_NOMEM;
        }
 
-       ads_mod_str(ctx, &mods, SPOOL_REG_PRINTERNAME, printer);
+       win_rc = nt_printer_info_to_mods(ctx, pinfo2, &mods);
+       if (!W_ERROR_IS_OK(win_rc)) {
+               TALLOC_FREE(ctx);
+               return win_rc;
+       }
 
        /* publish it */
        ads_rc = ads_mod_printer_entry(ads, prt_dn, ctx, &mods);


-- 
Samba Shared Repository

Reply via email to