summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2002-05-09 19:54:47 +0000
committerJeremy Allison <jra@samba.org>2002-05-09 19:54:47 +0000
commit059da8fb3b7197bd6a9bfe57940a96a2546e63a5 (patch)
tree2a9321487a1e4dd0903e40216df90c0a82a387ca
parent909bb7a0551b54a18540b50c5e5159738c76b3c9 (diff)
downloadsamba-059da8fb3b7197bd6a9bfe57940a96a2546e63a5.tar.gz
samba-059da8fb3b7197bd6a9bfe57940a96a2546e63a5.tar.bz2
samba-059da8fb3b7197bd6a9bfe57940a96a2546e63a5.zip
Merged in printing fixes... There were many missing !
Jeremy (This used to be commit 32fa089adead6ff3279172fd36560f4f9e2aeef0)
-rwxr-xr-xsource3/configure18
-rw-r--r--source3/include/config.h.in2
-rw-r--r--source3/include/messages.h4
-rw-r--r--source3/printing/nt_printing.c29
-rw-r--r--source3/rpc_server/srv_spoolss_nt.c112
5 files changed, 152 insertions, 13 deletions
diff --git a/source3/configure b/source3/configure
index 1671ffc7ef..0e95fa91d4 100755
--- a/source3/configure
+++ b/source3/configure
@@ -2880,12 +2880,12 @@ else
#line 2881 "configure"
#include "confdefs.h"
#include <stdio.h>
-main()
+int main()
{
FILE *f=fopen("conftestval", "w");
- if (!f) exit(1);
+ if (!f) return(1);
fprintf(f, "%d\n", sizeof(int));
- exit(0);
+ return(0);
}
EOF
if { (eval echo configure:2892: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
@@ -2919,12 +2919,12 @@ else
#line 2920 "configure"
#include "confdefs.h"
#include <stdio.h>
-main()
+int main()
{
FILE *f=fopen("conftestval", "w");
- if (!f) exit(1);
+ if (!f) return(1);
fprintf(f, "%d\n", sizeof(long));
- exit(0);
+ return(0);
}
EOF
if { (eval echo configure:2931: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
@@ -2958,12 +2958,12 @@ else
#line 2959 "configure"
#include "confdefs.h"
#include <stdio.h>
-main()
+int main()
{
FILE *f=fopen("conftestval", "w");
- if (!f) exit(1);
+ if (!f) return(1);
fprintf(f, "%d\n", sizeof(short));
- exit(0);
+ return(0);
}
EOF
if { (eval echo configure:2970: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
diff --git a/source3/include/config.h.in b/source3/include/config.h.in
index 0f82546e33..3691e38747 100644
--- a/source3/include/config.h.in
+++ b/source3/include/config.h.in
@@ -1,4 +1,4 @@
-/* include/config.h.in. Generated automatically from configure.in by autoheader 2.13. */
+/* include/config.h.in. Generated automatically from configure.in by autoheader. */
/* Define if on AIX 3.
System headers sometimes define this.
diff --git a/source3/include/messages.h b/source3/include/messages.h
index 9868b5de09..d500a21dcf 100644
--- a/source3/include/messages.h
+++ b/source3/include/messages.h
@@ -48,8 +48,8 @@
#define MSG_WINS_NEW_ENTRY 1002
/* rpc messages */
-#define MSG_PRINTER_NOTIFY 2001
-#define MSG_PRINTER_UPDATE 2002
+#define MSG_PRINTER_NOTIFY 2001
+#define MSG_PRINTER_DRVUPGRADE 2002
/* smbd messages */
#define MSG_SMB_CONF_UPDATED 3001
diff --git a/source3/printing/nt_printing.c b/source3/printing/nt_printing.c
index 29bc185a6d..9b79eac3e0 100644
--- a/source3/printing/nt_printing.c
+++ b/source3/printing/nt_printing.c
@@ -314,6 +314,11 @@ BOOL nt_printing_init(void)
update_c_setprinter(True);
+ /*
+ * register callback to handle updating printers as new
+ * drivers are installed
+ */
+ message_register(MSG_PRINTER_DRVUPGRADE, do_drv_upgrade_printer);
return True;
}
@@ -2960,6 +2965,30 @@ uint32 set_driver_init(NT_PRINTER_INFO_LEVEL *printer, uint32 level)
}
/****************************************************************************
+ Delete driver init data stored for a specified driver
+****************************************************************************/
+
+BOOL del_driver_init(char *drivername)
+{
+ pstring key;
+ TDB_DATA kbuf;
+
+ if (!drivername || !*drivername) {
+ DEBUG(3,("del_driver_init: No drivername specified!\n"));
+ return False;
+ }
+
+ slprintf(key, sizeof(key)-1, "%s%s", DRIVER_INIT_PREFIX, drivername);
+
+ kbuf.dptr = key;
+ kbuf.dsize = strlen(key)+1;
+
+ DEBUG(6,("del_driver_init: Removing driver init data for [%s]\n", drivername));
+
+ return (tdb_delete(tdb_drivers, kbuf) == 0);
+}
+
+/****************************************************************************
Pack up the DEVMODE and specifics for a printer into a 'driver init' entry
in the tdb. Note: this is different from the driver entry and the printer
entry. There should be a single driver init entry for each driver regardless
diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c
index d6ce065548..8419152cf2 100644
--- a/source3/rpc_server/srv_spoolss_nt.c
+++ b/source3/rpc_server/srv_spoolss_nt.c
@@ -37,6 +37,15 @@
#define PRINTER_HANDLE_IS_PRINTER 0
#define PRINTER_HANDLE_IS_PRINTSERVER 1
+/* Table to map the driver version */
+/* to OS */
+char * drv_ver_to_os[] = {
+ "WIN9X", /* driver version/cversion 0 */
+ "", /* unused ? */
+ "WINNT", /* driver version/cversion 2 */
+ "WIN2K", /* driver version/cversion 3 */
+};
+
struct table_node {
char *long_archi;
char *short_archi;
@@ -760,6 +769,69 @@ static BOOL srv_spoolss_sendnotify(char* printer_name, uint32 high, uint32 low,
}
/********************************************************************
+ Send a message to ourself about new driver being installed
+ so we can upgrade the information for each printer bound to this
+ driver
+********************************************************************/
+
+static BOOL srv_spoolss_drv_upgrade_printer(char* drivername)
+{
+ int len = strlen(drivername);
+
+ if (!len)
+ return False;
+
+ DEBUG(10,("srv_spoolss_drv_upgrade_printer: Sending message about driver upgrade [%s]\n",
+ drivername));
+
+ message_send_pid(sys_getpid(), MSG_PRINTER_DRVUPGRADE, drivername, len+1, False);
+ return True;
+}
+
+/**********************************************************************
+ callback to receive a MSG_PRINTER_DRVUPGRADE message and interate
+ over all printers, upgrading ones as neessary
+**********************************************************************/
+
+void do_drv_upgrade_printer(int msg_type, pid_t src, void *buf, size_t len)
+{
+ fstring drivername;
+ int snum;
+ int n_services = lp_numservices();
+
+ len = MIN(len,sizeof(drivername)-1);
+ strncpy(drivername, buf, len);
+
+ DEBUG(10,("do_drv_upgrade_printer: Got message for new driver [%s]\n", drivername ));
+
+ /* Iterate the printer list */
+
+ for (snum=0; snum<n_services; snum++) {
+ if (lp_snum_ok(snum) && lp_print_ok(snum) ) {
+ WERROR result;
+ NT_PRINTER_INFO_LEVEL *printer = NULL;
+
+ result = get_a_printer(&printer, 2, lp_servicename(snum));
+ if (!W_ERROR_IS_OK(result))
+ continue;
+
+ if (printer && printer->info_2 && !strcmp(drivername, printer->info_2->drivername)) {
+ DEBUG(6,("Updating printer [%s]\n", printer->info_2->printername));
+ /* all we care about currently is the change_id */
+ result = mod_a_printer(*printer, 2);
+ if (!W_ERROR_IS_OK(result)) {
+ DEBUG(3,("do_drv_upgrade_printer: mod_a_printer() failed with status [%s]\n",
+ dos_errstr(result)));
+ }
+ }
+ free_a_printer(&printer, 2);
+ }
+ }
+
+ /* all done */
+}
+
+/********************************************************************
Copy routines used by convert_to_openprinterex()
*******************************************************************/
@@ -6462,7 +6534,8 @@ WERROR _spoolss_addprinterdriver(pipes_struct *p, SPOOL_Q_ADDPRINTERDRIVER *q_u,
WERROR err = WERR_OK;
NT_PRINTER_DRIVER_INFO_LEVEL driver;
struct current_user user;
-
+ fstring driver_name;
+
ZERO_STRUCT(driver);
get_current_user(&user, p);
@@ -6489,6 +6562,43 @@ WERROR _spoolss_addprinterdriver(pipes_struct *p, SPOOL_Q_ADDPRINTERDRIVER *q_u,
goto done;
}
+ /* BEGIN_ADMIN_LOG */
+ switch(level) {
+ case 3:
+ sys_adminlog(LOG_INFO,"Added printer driver. Print driver name: %s. Print driver OS: %s. Administrator name: %s.",
+ driver.info_3->name,drv_ver_to_os[driver.info_3->cversion],uidtoname(user.uid));
+ fstrcpy(driver_name, driver.info_3->name);
+ break;
+ case 6:
+ sys_adminlog(LOG_INFO,"Added printer driver. Print driver name: %s. Print driver OS: %s. Administrator name: %s.",
+ driver.info_6->name,drv_ver_to_os[driver.info_6->version],uidtoname(user.uid));
+ fstrcpy(driver_name, driver.info_6->name);
+ break;
+ }
+ /* END_ADMIN_LOG */
+
+ /*
+ * I think this is where he DrvUpgradePrinter() hook would be
+ * be called in a driver's interface DLL on a Windows NT 4.0/2k
+ * server. Right now, we just need to send ourselves a message
+ * to update each printer bound to this driver. --jerry
+ */
+
+ if (!srv_spoolss_drv_upgrade_printer(driver_name)) {
+ DEBUG(0,("_spoolss_addprinterdriver: Failed to send message about upgrading driver [%s]!\n",
+ driver_name));
+ }
+
+ /* if driver is not 9x, delete existing driver init data */
+
+ if ((level == 3 && driver.info_3->cversion != 0) ||
+ (level == 6 && driver.info_6->version != 0)) {
+ if (!del_driver_init(driver_name))
+ DEBUG(3,("_spoolss_addprinterdriver: del_driver_init(%s) failed!\n", driver_name));
+ } else {
+ DEBUG(10,("_spoolss_addprinterdriver: init data not deleted for 9x driver [%s]\n", driver_name));
+ }
+
done:
free_a_printer_driver(driver, level);
return err;