summaryrefslogtreecommitdiff
path: root/source3/smbd
diff options
context:
space:
mode:
authorDavid Disseldorp <ddiss@samba.org>2014-08-01 16:25:59 +0200
committerKarolin Seeger <kseeger@samba.org>2014-09-01 21:34:11 +0200
commit00a0c2d04839e628e1e557648862161a796208a0 (patch)
tree1347d2ec2df94d23b1474fdbaa3f63592b905440 /source3/smbd
parent44a3d3fa33fdc213fd38bc502cd29fe966d315e6 (diff)
downloadsamba-00a0c2d04839e628e1e557648862161a796208a0.tar.gz
smbd: split printer reload processing
All printer inventory updates are currently done via delete_and_reload_printers(), which handles registry.tdb updates for added or removed printers, AD printer unpublishing on removal, as well as share service creation and deletion. This change splits this functionality into two functions such that per-client smbd processes do not perform registry.tdb updates or printer unpublishing. This is now only performed by the process that performs the printcap cache update. This change is similar to ac6604868d1325dd4c872dc0f6ab056d10ebaecf from the 3.6 branch. Bug: https://bugzilla.samba.org/show_bug.cgi?id=10652 Signed-off-by: David Disseldorp <ddiss@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org> (cherry picked from commit 2706af4d78fc9a47a4ac45b373edf276e3a9b354)
Diffstat (limited to 'source3/smbd')
-rw-r--r--source3/smbd/server_reload.c51
1 files changed, 7 insertions, 44 deletions
diff --git a/source3/smbd/server_reload.c b/source3/smbd/server_reload.c
index feb8415e82..971c8b86ef 100644
--- a/source3/smbd/server_reload.c
+++ b/source3/smbd/server_reload.c
@@ -44,14 +44,10 @@ bool snum_is_shared_printer(int snum)
}
/**
- * @brief Purge stale printers and reload from pre-populated pcap cache.
+ * @brief Purge stale printer shares and reload from pre-populated pcap cache.
*
* This function should normally only be called as a callback on a successful
- * pcap_cache_reload() or after a MSG_PRINTER_CAP message is received.
- *
- * This function can cause DELETION of printers and drivers from our registry,
- * so calling it on a failed pcap reload may REMOVE permanently all printers
- * and drivers.
+ * pcap_cache_reload(), or on client enumeration.
*
* @param[in] ev The event context.
*
@@ -60,25 +56,24 @@ bool snum_is_shared_printer(int snum)
void delete_and_reload_printers(struct tevent_context *ev,
struct messaging_context *msg_ctx)
{
- struct auth_session_info *session_info = NULL;
- struct spoolss_PrinterInfo2 *pinfo2 = NULL;
int n_services;
int pnum;
int snum;
const char *pname;
- const char *sname;
- NTSTATUS status;
bool ok;
time_t pcap_last_update;
+ TALLOC_CTX *frame = talloc_stackframe();
ok = pcap_cache_loaded(&pcap_last_update);
if (!ok) {
DEBUG(1, ("pcap cache not loaded\n"));
+ talloc_free(frame);
return;
}
if (reload_last_pcap_time == pcap_last_update) {
DEBUG(5, ("skipping printer reload, already up to date.\n"));
+ talloc_free(frame);
return;
}
reload_last_pcap_time = pcap_last_update;
@@ -91,15 +86,6 @@ void delete_and_reload_printers(struct tevent_context *ev,
DEBUG(10, ("reloading printer services from pcap cache\n"));
- status = make_session_info_system(talloc_tos(), &session_info);
- if (!NT_STATUS_IS_OK(status)) {
- DEBUG(3, ("reload_printers: "
- "Could not create system session_info\n"));
- /* can't remove stale printers before we
- * are fully initilized */
- return;
- }
-
/*
* Add default config for printers added to smb.conf file and remove
* stale printers
@@ -115,41 +101,18 @@ void delete_and_reload_printers(struct tevent_context *ev,
continue;
}
- sname = lp_const_servicename(snum);
- pname = lp_printername(session_info, snum);
+ pname = lp_printername(frame, snum);
/* check printer, but avoid removing non-autoloaded printers */
if (lp_autoloaded(snum) && !pcap_printername_ok(pname)) {
- DEBUG(3, ("removing stale printer %s\n", pname));
-
- if (is_printer_published(session_info, session_info,
- msg_ctx,
- NULL,
- lp_servicename(session_info,
- snum),
- &pinfo2)) {
- nt_printer_publish(session_info,
- session_info,
- msg_ctx,
- pinfo2,
- DSPRINT_UNPUBLISH);
- TALLOC_FREE(pinfo2);
- }
- nt_printer_remove(session_info, session_info, msg_ctx,
- pname);
lp_killservice(snum);
- } else {
- DEBUG(8, ("Adding default registry entry for printer "
- "[%s], if it doesn't exist.\n", sname));
- nt_printer_add(session_info, session_info, msg_ctx,
- sname);
}
}
/* Make sure deleted printers are gone */
load_printers(ev, msg_ctx);
- TALLOC_FREE(session_info);
+ talloc_free(frame);
}
/****************************************************************************