1 | /*
|
---|
2 | * Unix SMB/CIFS implementation.
|
---|
3 | * Virtual Windows Registry Layer
|
---|
4 | * Copyright (C) Gerald Carter 2005
|
---|
5 | *
|
---|
6 | * This program is free software; you can redistribute it and/or modify
|
---|
7 | * it under the terms of the GNU General Public License as published by
|
---|
8 | * the Free Software Foundation; either version 3 of the License, or
|
---|
9 | * (at your option) any later version.
|
---|
10 | *
|
---|
11 | * This program is distributed in the hope that it will be useful,
|
---|
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
14 | * GNU General Public License for more details.
|
---|
15 | *
|
---|
16 | * You should have received a copy of the GNU General Public License
|
---|
17 | * along with this program; if not, see <http://www.gnu.org/licenses/>.
|
---|
18 | */
|
---|
19 |
|
---|
20 | /* Implementation of registry virtual views for printing information */
|
---|
21 |
|
---|
22 | #include "includes.h"
|
---|
23 |
|
---|
24 | #undef DBGC_CLASS
|
---|
25 | #define DBGC_CLASS DBGC_REGISTRY
|
---|
26 |
|
---|
27 | /**********************************************************************
|
---|
28 | It is safe to assume that every registry path passed into on of
|
---|
29 | the exported functions here begins with KEY_PRINTING else
|
---|
30 | these functions would have never been called. This is a small utility
|
---|
31 | function to strip the beginning of the path and make a copy that the
|
---|
32 | caller can modify. Note that the caller is responsible for releasing
|
---|
33 | the memory allocated here.
|
---|
34 | **********************************************************************/
|
---|
35 |
|
---|
36 | static char* trim_reg_path( const char *path )
|
---|
37 | {
|
---|
38 | const char *p;
|
---|
39 | uint16 key_len = strlen(KEY_SHARES);
|
---|
40 |
|
---|
41 | /*
|
---|
42 | * sanity check...this really should never be True.
|
---|
43 | * It is only here to prevent us from accessing outside
|
---|
44 | * the path buffer in the extreme case.
|
---|
45 | */
|
---|
46 |
|
---|
47 | if ( strlen(path) < key_len ) {
|
---|
48 | DEBUG(0,("trim_reg_path: Registry path too short! [%s]\n", path));
|
---|
49 | return NULL;
|
---|
50 | }
|
---|
51 |
|
---|
52 |
|
---|
53 | p = path + strlen( KEY_SHARES );
|
---|
54 |
|
---|
55 | if ( *p == '\\' )
|
---|
56 | p++;
|
---|
57 |
|
---|
58 | if ( *p )
|
---|
59 | return SMB_STRDUP(p);
|
---|
60 | else
|
---|
61 | return NULL;
|
---|
62 | }
|
---|
63 |
|
---|
64 | /**********************************************************************
|
---|
65 | Enumerate registry subkey names given a registry path.
|
---|
66 | Caller is responsible for freeing memory to **subkeys
|
---|
67 | *********************************************************************/
|
---|
68 |
|
---|
69 | static int shares_subkey_info( const char *key, struct regsubkey_ctr *subkey_ctr )
|
---|
70 | {
|
---|
71 | char *path;
|
---|
72 | bool top_level = False;
|
---|
73 | int num_subkeys = 0;
|
---|
74 |
|
---|
75 | DEBUG(10,("printing_subkey_info: key=>[%s]\n", key));
|
---|
76 |
|
---|
77 | path = trim_reg_path( key );
|
---|
78 |
|
---|
79 | /* check to see if we are dealing with the top level key */
|
---|
80 |
|
---|
81 | if ( !path )
|
---|
82 | top_level = True;
|
---|
83 |
|
---|
84 | if ( top_level ) {
|
---|
85 | num_subkeys = 1;
|
---|
86 | regsubkey_ctr_addkey( subkey_ctr, "Security" );
|
---|
87 | }
|
---|
88 | #if 0
|
---|
89 | else
|
---|
90 | num_subkeys = handle_share_subpath( path, subkey_ctr, NULL );
|
---|
91 | #endif
|
---|
92 |
|
---|
93 | SAFE_FREE( path );
|
---|
94 |
|
---|
95 | return num_subkeys;
|
---|
96 | }
|
---|
97 |
|
---|
98 | /**********************************************************************
|
---|
99 | Enumerate registry values given a registry path.
|
---|
100 | Caller is responsible for freeing memory
|
---|
101 | *********************************************************************/
|
---|
102 |
|
---|
103 | static int shares_value_info(const char *key, struct regval_ctr *val)
|
---|
104 | {
|
---|
105 | char *path;
|
---|
106 | bool top_level = False;
|
---|
107 | int num_values = 0;
|
---|
108 |
|
---|
109 | DEBUG(10,("printing_value_info: key=>[%s]\n", key));
|
---|
110 |
|
---|
111 | path = trim_reg_path( key );
|
---|
112 |
|
---|
113 | /* check to see if we are dealing with the top level key */
|
---|
114 |
|
---|
115 | if ( !path )
|
---|
116 | top_level = True;
|
---|
117 |
|
---|
118 | /* fill in values from the getprinterdata_printer_server() */
|
---|
119 | if ( top_level )
|
---|
120 | num_values = 0;
|
---|
121 | #if 0
|
---|
122 | else
|
---|
123 | num_values = handle_printing_subpath( path, NULL, val );
|
---|
124 | #endif
|
---|
125 |
|
---|
126 | SAFE_FREE(path);
|
---|
127 |
|
---|
128 | return num_values;
|
---|
129 | }
|
---|
130 |
|
---|
131 | /**********************************************************************
|
---|
132 | Stub function which always returns failure since we don't want
|
---|
133 | people storing printing information directly via regostry calls
|
---|
134 | (for now at least)
|
---|
135 | *********************************************************************/
|
---|
136 |
|
---|
137 | static bool shares_store_subkey( const char *key, struct regsubkey_ctr *subkeys )
|
---|
138 | {
|
---|
139 | return False;
|
---|
140 | }
|
---|
141 |
|
---|
142 | /**********************************************************************
|
---|
143 | Stub function which always returns failure since we don't want
|
---|
144 | people storing printing information directly via regostry calls
|
---|
145 | (for now at least)
|
---|
146 | *********************************************************************/
|
---|
147 |
|
---|
148 | static bool shares_store_value(const char *key, struct regval_ctr *val)
|
---|
149 | {
|
---|
150 | return False;
|
---|
151 | }
|
---|
152 |
|
---|
153 | /*
|
---|
154 | * Table of function pointers for accessing printing data
|
---|
155 | */
|
---|
156 |
|
---|
157 | struct registry_ops shares_reg_ops = {
|
---|
158 | .fetch_subkeys = shares_subkey_info,
|
---|
159 | .fetch_values = shares_value_info,
|
---|
160 | .store_subkeys = shares_store_subkey,
|
---|
161 | .store_values = shares_store_value,
|
---|
162 | };
|
---|
163 |
|
---|
164 |
|
---|