r23801: The FSF has moved around a lot. This fixes their Mass Ave address.
[kai/samba-autobuild/.git] / source / registry / reg_smbconf.c
1 /* 
2  *  Unix SMB/CIFS implementation.
3  *  Virtual Windows Registry Layer
4  *  Copyright (C) Volker Lendecke 2006
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 #include "includes.h"
21
22 #undef DBGC_CLASS
23 #define DBGC_CLASS DBGC_RPC_SRV
24
25 extern REGISTRY_OPS regdb_ops;          /* these are the default */
26
27 static int smbconf_fetch_keys( const char *key, REGSUBKEY_CTR *subkey_ctr )
28 {
29         return regdb_ops.fetch_subkeys(key, subkey_ctr);
30 }
31
32 static BOOL smbconf_store_keys( const char *key, REGSUBKEY_CTR *subkeys )
33 {
34         return regdb_ops.store_subkeys(key, subkeys);
35 }
36
37 static int smbconf_fetch_values( const char *key, REGVAL_CTR *val )
38 {
39         return regdb_ops.fetch_values(key, val);
40 }
41
42 static BOOL smbconf_store_values( const char *key, REGVAL_CTR *val )
43 {
44         int i;
45         int num_values = regval_ctr_numvals(val);
46
47         for (i=0; i < num_values; i++) {
48                 REGISTRY_VALUE *theval = regval_ctr_specific_value(val, i);
49                 const char *valname = regval_name(theval);
50
51                 if (registry_smbconf_valname_forbidden(valname)) {
52                         DEBUG(0, ("smbconf_store_values: value '%s' forbidden "
53                               "in registry.\n", valname));
54                         return False;
55                 }
56         }
57         return regdb_ops.store_values(key, val);
58 }
59
60 static BOOL smbconf_reg_access_check(const char *keyname, uint32 requested,
61                                      uint32 *granted,
62                                      const struct nt_user_token *token)
63 {
64         if (!(user_has_privileges(token, &se_disk_operators))) {
65                 return False;
66         }
67
68         *granted = REG_KEY_ALL;
69         return True;
70 }
71
72 static WERROR smbconf_get_secdesc(TALLOC_CTX *mem_ctx, const char *key,
73                                   struct security_descriptor **psecdesc)
74 {
75         return regdb_ops.get_secdesc(mem_ctx, key, psecdesc);
76 }
77
78 static WERROR smbconf_set_secdesc(const char *key,
79                                   struct security_descriptor *secdesc)
80 {
81         return regdb_ops.set_secdesc(key, secdesc);
82 }
83
84
85 /* 
86  * Table of function pointers for accessing smb.conf data
87  */
88  
89 REGISTRY_OPS smbconf_reg_ops = {
90         smbconf_fetch_keys,
91         smbconf_fetch_values,
92         smbconf_store_keys,
93         smbconf_store_values,
94         smbconf_reg_access_check,
95         smbconf_get_secdesc,
96         smbconf_set_secdesc
97 };