Ignore:
Timestamp:
May 13, 2014, 11:39:04 AM (11 years ago)
Author:
Silvan Scherrer
Message:

Samba Server: update trunk to 3.6.23

Location:
trunk/server
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/server

  • trunk/server/source3/smbd/server_reload.c

    r751 r862  
    3737                     struct messaging_context *msg_ctx)
    3838{
     39        int n_services;
     40        int pnum;
     41        int snum;
     42        const char *pname;
     43
     44        n_services = lp_numservices();
     45        pnum = lp_servicenumber(PRINTERS_NAME);
     46
     47        DEBUG(10, ("reloading printer services from pcap cache\n"));
     48
     49        /*
     50         * Add default config for printers added to smb.conf file and remove
     51         * stale printers
     52         */
     53        for (snum = 0; snum < n_services; snum++) {
     54                /* avoid removing PRINTERS_NAME */
     55                if (snum == pnum) {
     56                        continue;
     57                }
     58
     59                /* skip no-printer services */
     60                if (!(lp_snum_ok(snum) && lp_print_ok(snum))) {
     61                        continue;
     62                }
     63
     64                pname = lp_printername(snum);
     65
     66                /* check printer, but avoid removing non-autoloaded printers */
     67                if (lp_autoloaded(snum) && !pcap_printername_ok(pname)) {
     68                        DEBUG(3, ("removing stale printer %s\n", pname));
     69                        lp_killservice(snum);
     70                }
     71        }
     72
     73        /* Make sure deleted printers are gone */
     74        load_printers(ev, msg_ctx);
     75}
     76
     77/****************************************************************************
     78 purge stale printers and reload from pre-populated pcap cache
     79**************************************************************************/
     80void reload_printers_full(struct tevent_context *ev,
     81                          struct messaging_context *msg_ctx)
     82{
    3983        struct auth_serversupplied_info *session_info = NULL;
    40         struct spoolss_PrinterInfo2 *pinfo2 = NULL;
    4184        int n_services;
    4285        int pnum;
     
    4689        NTSTATUS status;
    4790
    48         load_printers(ev, msg_ctx);
    49 
    5091        n_services = lp_numservices();
    5192        pnum = lp_servicenumber(PRINTERS_NAME);
    5293
    53         DEBUG(10, ("reloading printer services from pcap cache\n"));
    54 
    55         status = make_session_info_system(talloc_tos(), &session_info);
     94        status = make_session_info_system(talloc_new(NULL), &session_info);
    5695        if (!NT_STATUS_IS_OK(status)) {
    57                 DEBUG(3, ("reload_printers: "
    58                           "Could not create system session_info\n"));
     96                DEBUG(3, ("Could not create system session_info\n"));
    5997                /* can't remove stale printers before we
    6098                 * are fully initilized */
     
    82120                /* check printer, but avoid removing non-autoloaded printers */
    83121                if (lp_autoloaded(snum) && !pcap_printername_ok(pname)) {
    84                         DEBUG(3, ("removing stale printer %s\n", pname));
    85 
     122                        struct spoolss_PrinterInfo2 *pinfo2 = NULL;
    86123                        if (is_printer_published(session_info, session_info,
    87124                                                 msg_ctx,
    88                                                  NULL, lp_servicename(snum),
    89                                                  NULL, &pinfo2)) {
     125                                                 NULL,
     126                                                 lp_servicename(snum),
     127                                                 &pinfo2)) {
    90128                                nt_printer_publish(session_info,
    91129                                                   session_info,
     
    97135                        nt_printer_remove(session_info, session_info, msg_ctx,
    98136                                          pname);
    99                         lp_killservice(snum);
    100137                } else {
    101138                        DEBUG(8, ("Adding default registry entry for printer "
     
    106143        }
    107144
    108         /* Make sure deleted printers are gone */
    109         load_printers(ev, msg_ctx);
     145        /* finally, purge old snums */
     146        reload_printers(ev, msg_ctx);
    110147
    111148        TALLOC_FREE(session_info);
     
    161198        return(ret);
    162199}
    163 
    164 /****************************************************************************
    165  Notify smbds of new printcap data
    166 **************************************************************************/
    167 void reload_pcap_change_notify(struct tevent_context *ev,
    168                                struct messaging_context *msg_ctx)
    169 {
    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 
    179         message_send_all(msg_ctx, MSG_PRINTER_PCAP, NULL, 0, NULL);
    180 }
Note: See TracChangeset for help on using the changeset viewer.