svn commit: samba r8324 - in branches/SAMBA_3_0/source: registry rpc_server

jerry at samba.org jerry at samba.org
Mon Jul 11 18:27:23 GMT 2005


Author: jerry
Date: 2005-07-11 18:27:22 +0000 (Mon, 11 Jul 2005)
New Revision: 8324

WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=8324

Log:
* initial cut at creating printers via the registry API
  Need to add delete_key support


Modified:
   branches/SAMBA_3_0/source/registry/reg_printing.c
   branches/SAMBA_3_0/source/rpc_server/srv_spoolss_nt.c


Changeset:
Modified: branches/SAMBA_3_0/source/registry/reg_printing.c
===================================================================
--- branches/SAMBA_3_0/source/registry/reg_printing.c	2005-07-11 17:17:50 UTC (rev 8323)
+++ branches/SAMBA_3_0/source/registry/reg_printing.c	2005-07-11 18:27:22 UTC (rev 8324)
@@ -225,6 +225,7 @@
 	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,9 +256,14 @@
 	
 	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 );
 	
 	for ( i=0; i<num_subkeys; i++ )
@@ -274,12 +280,41 @@
 }
 
 /**********************************************************************
- 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 @@
 	{ "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 },

Modified: branches/SAMBA_3_0/source/rpc_server/srv_spoolss_nt.c
===================================================================
--- branches/SAMBA_3_0/source/rpc_server/srv_spoolss_nt.c	2005-07-11 17:17:50 UTC (rev 8323)
+++ branches/SAMBA_3_0/source/rpc_server/srv_spoolss_nt.c	2005-07-11 18:27:22 UTC (rev 8324)
@@ -6033,7 +6033,7 @@
 /****************************************************************************
 ****************************************************************************/
 
-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 @@
 	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 @@
 			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));
 



More information about the samba-cvs mailing list