diff options
author | Gerald Carter <jerry@samba.org> | 2005-07-11 18:27:22 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 10:58:19 -0500 |
commit | e574081ad93ec5f5eb121436a889f64294fa290d (patch) | |
tree | c7fcbe6331688da9496f3cdd3da3d824857619f2 /source3/registry | |
parent | 279a2b48b488ecb8f0e460c5b230bb57e9aef52d (diff) | |
download | samba-e574081ad93ec5f5eb121436a889f64294fa290d.tar.gz samba-e574081ad93ec5f5eb121436a889f64294fa290d.tar.bz2 samba-e574081ad93ec5f5eb121436a889f64294fa290d.zip |
r8324: * initial cut at creating printers via the registry API
Need to add delete_key support
(This used to be commit 9a27f7181adca10f60c47d342a51dec34321e12b)
Diffstat (limited to 'source3/registry')
-rw-r--r-- | source3/registry/reg_printing.c | 45 |
1 files changed, 40 insertions, 5 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 }, |