summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
Diffstat (limited to 'source3')
-rw-r--r--source3/registry/reg_printing.c45
-rw-r--r--source3/rpc_server/srv_spoolss_nt.c7
2 files changed, 44 insertions, 8 deletions
diff --git a/source3/registry/reg_printing.c b/source3/registry/reg_printing.c
index c689882d53..b1fdcea09c 100644
--- a/source3/registry/reg_printing.c
+++ b/source3/registry/reg_printing.c
@@ -225,6 +225,7 @@ static int key_printers_fetch_keys( const char *key, REGSUBKEY_CTR *subkeys )
char *printername, *printerdatakey;
NT_PRINTER_INFO_LEVEL *printer = NULL;
fstring *subkey_names = NULL;
+ fstring sharename;
DEBUG(10,("key_printers_fetch_keys: key=>[%s]\n", key ? key : "NULL" ));
@@ -255,8 +256,13 @@ static int key_printers_fetch_keys( const char *key, REGSUBKEY_CTR *subkeys )
reg_split_path( printers_key, &printername, &printerdatakey );
- if ( !W_ERROR_IS_OK( get_a_printer(NULL, &printer, 2, printername) ) )
- goto done;
+ alpha_strcpy( sharename, printername, "", sizeof(sharename)-1);
+
+ if ( find_service(sharename) == -1
+ || !W_ERROR_IS_OK( get_a_printer(NULL, &printer, 2, sharename) ) )
+ {
+ return -1;
+ }
num_subkeys = get_printer_subkeys( &printer->info_2->data, printerdatakey?printerdatakey:"", &subkey_names );
@@ -274,12 +280,41 @@ done:
}
/**********************************************************************
- Take a printer name and call add_printer_hook() if necessary
+ Take a list of names and call add_printer_hook() if necessary
+ Note that we do this a little differently from Windows since the
+ keyname is the sharename and not the printer name.
*********************************************************************/
static BOOL add_printers_by_registry( REGSUBKEY_CTR *subkeys )
{
- return False;
+ int i, num_keys, snum;
+ char *printername;
+ NT_PRINTER_INFO_LEVEL_2 info2;
+ NT_PRINTER_INFO_LEVEL printer;
+
+ ZERO_STRUCT( info2 );
+ printer.info_2 = &info2;
+
+ num_keys = regsubkey_ctr_numkeys( subkeys );
+
+ become_root();
+ for ( i=0; i<num_keys; i++ ) {
+ printername = regsubkey_ctr_specific_key( subkeys, i );
+ snum = find_service( printername );
+
+ /* just verify a valied snum for now */
+ if ( snum == -1 ) {
+ fstrcpy( info2.printername, printername );
+ alpha_strcpy( info2.sharename, printername, "", sizeof(info2.sharename)-1);
+ if ( !add_printer_hook( NULL, &printer ) ) {
+ DEBUG(0,("add_printers_by_registry: Failed to add printer [%s]\n",
+ printername));
+ }
+ }
+ }
+ unbecome_root();
+
+ return True;
}
/**********************************************************************
@@ -533,7 +568,7 @@ struct {
{ "UntilTime", REG_IDX_UNTILTIME },
{ "Name", REG_IDX_NAME },
{ "Location", REG_IDX_LOCATION },
- { "Description", REG_IDX_DESCRIPTION },
+ { "Descrioption", REG_IDX_DESCRIPTION },
{ "Parameters", REG_IDX_PARAMETERS },
{ "Port", REG_IDX_PORT },
{ "Share Name", REG_IDX_SHARENAME },
diff --git a/source3/rpc_server/srv_spoolss_nt.c b/source3/rpc_server/srv_spoolss_nt.c
index 0329471d49..b5dd459462 100644
--- a/source3/rpc_server/srv_spoolss_nt.c
+++ b/source3/rpc_server/srv_spoolss_nt.c
@@ -6033,7 +6033,7 @@ static BOOL check_printer_ok(NT_PRINTER_INFO_LEVEL_2 *info, int snum)
/****************************************************************************
****************************************************************************/
-static BOOL add_printer_hook(NT_USER_TOKEN *token, NT_PRINTER_INFO_LEVEL *printer)
+BOOL add_printer_hook(NT_USER_TOKEN *token, NT_PRINTER_INFO_LEVEL *printer)
{
char *cmd = lp_addprinter_cmd();
char **qlines;
@@ -6043,7 +6043,7 @@ static BOOL add_printer_hook(NT_USER_TOKEN *token, NT_PRINTER_INFO_LEVEL *printe
int fd;
fstring remote_machine = "%m";
SE_PRIV se_printop = SE_PRINT_OPERATOR;
- BOOL is_print_op;
+ BOOL is_print_op = False;
standard_sub_basic(current_user_info.smb_name, remote_machine,sizeof(remote_machine));
@@ -6052,7 +6052,8 @@ static BOOL add_printer_hook(NT_USER_TOKEN *token, NT_PRINTER_INFO_LEVEL *printe
printer->info_2->portname, printer->info_2->drivername,
printer->info_2->location, printer->info_2->comment, remote_machine);
- is_print_op = user_has_privileges( token, &se_printop );
+ if ( token )
+ is_print_op = user_has_privileges( token, &se_printop );
DEBUG(10,("Running [%s]\n", command));