Ignore:
Timestamp:
Nov 29, 2012, 1:59:04 PM (13 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: updated trunk to 3.6.9

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/server/source3/smbd/server_reload.c

    r745 r751  
    3939        struct auth_serversupplied_info *session_info = NULL;
    4040        struct spoolss_PrinterInfo2 *pinfo2 = NULL;
     41        int n_services;
     42        int pnum;
    4143        int snum;
    42         int n_services = lp_numservices();
    43         int pnum = lp_servicenumber(PRINTERS_NAME);
    4444        const char *pname;
     45        const char *sname;
    4546        NTSTATUS status;
    46         bool skip = false;
    4747
    48         SMB_ASSERT(pcap_cache_loaded());
     48        load_printers(ev, msg_ctx);
     49
     50        n_services = lp_numservices();
     51        pnum = lp_servicenumber(PRINTERS_NAME);
     52
    4953        DEBUG(10, ("reloading printer services from pcap cache\n"));
    5054
     
    5559                /* can't remove stale printers before we
    5660                 * are fully initilized */
    57                 skip = true;
     61                return;
    5862        }
    5963
    60         /* remove stale printers */
    61         for (snum = 0; skip == false && snum < n_services; snum++) {
    62                 /* avoid removing PRINTERS_NAME or non-autoloaded printers */
    63                 if (snum == pnum || !(lp_snum_ok(snum) && lp_print_ok(snum) &&
    64                                       lp_autoloaded(snum)))
     64        /*
     65         * Add default config for printers added to smb.conf file and remove
     66         * stale printers
     67         */
     68        for (snum = 0; snum < n_services; snum++) {
     69                /* avoid removing PRINTERS_NAME */
     70                if (snum == pnum) {
    6571                        continue;
     72                }
    6673
     74                /* skip no-printer services */
     75                if (!(lp_snum_ok(snum) && lp_print_ok(snum))) {
     76                        continue;
     77                }
     78
     79                sname = lp_const_servicename(snum);
    6780                pname = lp_printername(snum);
    68                 if (!pcap_printername_ok(pname)) {
     81
     82                /* check printer, but avoid removing non-autoloaded printers */
     83                if (lp_autoloaded(snum) && !pcap_printername_ok(pname)) {
    6984                        DEBUG(3, ("removing stale printer %s\n", pname));
    7085
     
    8398                                          pname);
    8499                        lp_killservice(snum);
     100                } else {
     101                        DEBUG(8, ("Adding default registry entry for printer "
     102                                  "[%s], if it doesn't exist.\n", sname));
     103                        nt_printer_add(session_info, session_info, msg_ctx,
     104                                       sname);
    85105                }
    86106        }
    87107
     108        /* Make sure deleted printers are gone */
    88109        load_printers(ev, msg_ctx);
    89110
     
    107128                        test = False;
    108129                }
     130                TALLOC_FREE(fname);
    109131        }
    110132
     
    146168                               struct messaging_context *msg_ctx)
    147169{
     170        /*
     171         * Reload the printers first in the background process so that
     172         * newly added printers get default values created in the registry.
     173         *
     174         * This will block the process for some time (~1 sec per printer), but
     175         * it doesn't block smbd's servering clients.
     176         */
     177        reload_printers(ev, msg_ctx);
     178
    148179        message_send_all(msg_ctx, MSG_PRINTER_PCAP, NULL, 0, NULL);
    149180}
Note: See TracChangeset for help on using the changeset viewer.