s3:auth Remove NT_USER_TOKEN
[metze/samba/wip.git] / source3 / include / registry.h
1 /*
2  *  Unix SMB/CIFS implementation.
3  *  Virtual Windows Registry Layer
4  *
5  *  Copyright (C) Gerald Carter              2002-2005
6  *  Copyright (C) Volker Lendecke            2006
7  *  Copyright (C) Michael Adam               2006-2010
8  *
9  *  This program is free software; you can redistribute it and/or modify
10  *  it under the terms of the GNU General Public License as published by
11  *  the Free Software Foundation; either version 3 of the License, or
12  *  (at your option) any later version.
13  *
14  *  This program is distributed in the hope that it will be useful,
15  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
16  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  *  GNU General Public License for more details.
18  *
19  *  You should have received a copy of the GNU General Public License
20  *  along with this program; if not, see <http://www.gnu.org/licenses/>.
21  */
22
23 #ifndef _REGISTRY_H
24 #define _REGISTRY_H
25
26 #include "../librpc/gen_ndr/winreg.h"
27
28 struct registry_value {
29         enum winreg_Type type;
30         DATA_BLOB data;
31 };
32
33 /* forward declarations. definitions in reg_objects.c */
34 struct regval_ctr;
35 struct regsubkey_ctr;
36
37 /*
38  * container for function pointers to enumeration routines
39  * for virtual registry view
40  */
41
42 struct registry_ops {
43         /* functions for enumerating subkeys and values */
44         int     (*fetch_subkeys)( const char *key, struct regsubkey_ctr *subkeys);
45         int     (*fetch_values) ( const char *key, struct regval_ctr *val );
46         bool    (*store_subkeys)( const char *key, struct regsubkey_ctr *subkeys );
47         WERROR  (*create_subkey)(const char *key, const char *subkey);
48         WERROR  (*delete_subkey)(const char *key, const char *subkey);
49         bool    (*store_values)( const char *key, struct regval_ctr *val );
50         bool    (*reg_access_check)( const char *keyname, uint32 requested,
51                                      uint32 *granted,
52                                      const struct security_token *token );
53         WERROR (*get_secdesc)(TALLOC_CTX *mem_ctx, const char *key,
54                               struct security_descriptor **psecdesc);
55         WERROR (*set_secdesc)(const char *key,
56                               struct security_descriptor *sec_desc);
57         bool    (*subkeys_need_update)(struct regsubkey_ctr *subkeys);
58         bool    (*values_need_update)(struct regval_ctr *values);
59 };
60
61 /* structure to store the registry handles */
62
63 struct registry_key_handle {
64         uint32          type;
65         char            *name;          /* full name of registry key */
66         uint32          access_granted;
67         struct registry_ops     *ops;
68 };
69
70 struct registry_key {
71         struct registry_key_handle *key;
72         struct regsubkey_ctr *subkeys;
73         struct regval_ctr *values;
74         struct security_token *token;
75 };
76
77
78 /*
79  *
80  * Macros that used to reside in rpc_reg.h
81  *
82  */
83
84 #define HKEY_CLASSES_ROOT       0x80000000
85 #define HKEY_CURRENT_USER       0x80000001
86 #define HKEY_LOCAL_MACHINE      0x80000002
87 #define HKEY_USERS              0x80000003
88 #define HKEY_PERFORMANCE_DATA   0x80000004
89
90 #define KEY_HKLM                "HKLM"
91 #define KEY_HKU                 "HKU"
92 #define KEY_HKCC                "HKCC"
93 #define KEY_HKCR                "HKCR"
94 #define KEY_HKPD                "HKPD"
95 #define KEY_HKPT                "HKPT"
96 #define KEY_HKPN                "HKPN"
97 #define KEY_HKCU                "HKCU"
98 #define KEY_HKDD                "HKDD"
99 #define KEY_SERVICES            "HKLM\\SYSTEM\\CurrentControlSet\\Services"
100 #define KEY_EVENTLOG            "HKLM\\SYSTEM\\CurrentControlSet\\Services\\Eventlog"
101 #define KEY_SHARES              "HKLM\\SYSTEM\\CurrentControlSet\\Services\\LanmanServer\\Shares"
102 #define KEY_NETLOGON_PARAMS     "HKLM\\SYSTEM\\CurrentControlSet\\Services\\Netlogon\\Parameters"
103 #define KEY_TCPIP_PARAMS        "HKLM\\SYSTEM\\CurrentControlSet\\Services\\Tcpip\\Parameters"
104 #define KEY_PROD_OPTIONS        "HKLM\\SYSTEM\\CurrentControlSet\\Control\\ProductOptions"
105 #define KEY_PRINTING            "HKLM\\SYSTEM\\CurrentControlSet\\Control\\Print"
106 #define KEY_PRINTING_2K         "HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Print\\Printers"
107 #define KEY_PRINTING_PORTS      "HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Ports"
108 #define KEY_CURRENT_VERSION     "HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion"
109 #define KEY_PERFLIB             "HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Perflib"
110 #define KEY_PERFLIB_009         "HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Perflib\\009"
111 #define KEY_GROUP_POLICY        "HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Group Policy"
112 #define KEY_WINLOGON            "HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Winlogon"
113 #define KEY_SMBCONF             "HKLM\\SOFTWARE\\Samba\\smbconf"
114 #define KEY_SAMBA_GROUP_POLICY  "HKLM\\SOFTWARE\\Samba\\Group Policy"
115 #define KEY_TREE_ROOT           ""
116
117 #define KEY_GP_MACHINE_POLICY           "HKLM\\Software\\Policies"
118 #define KEY_GP_MACHINE_WIN_POLICY       "HKLM\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies"
119 #define KEY_GP_USER_POLICY              "HKCU\\Software\\Policies"
120 #define KEY_GP_USER_WIN_POLICY          "HKCU\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies"
121
122 /*
123  * Registry key types
124  *      Most keys are going to be GENERIC -- may need a better name?
125  *      HKPD and HKPT are used by reg_perfcount.c
126  *              they are special keys that contain performance data
127  */
128 #define REG_KEY_GENERIC         0
129 #define REG_KEY_HKPD            1
130 #define REG_KEY_HKPT            2
131
132
133 /* The following definitions come from registry/reg_api.c  */
134
135 WERROR reg_openhive(TALLOC_CTX *mem_ctx, const char *hive,
136                     uint32 desired_access,
137                     const struct security_token *token,
138                     struct registry_key **pkey);
139 WERROR reg_openkey(TALLOC_CTX *mem_ctx, struct registry_key *parent,
140                    const char *name, uint32 desired_access,
141                    struct registry_key **pkey);
142 WERROR reg_enumkey(TALLOC_CTX *mem_ctx, struct registry_key *key,
143                    uint32 idx, char **name, NTTIME *last_write_time);
144 WERROR reg_enumvalue(TALLOC_CTX *mem_ctx, struct registry_key *key,
145                      uint32 idx, char **pname, struct registry_value **pval);
146 WERROR reg_queryvalue(TALLOC_CTX *mem_ctx, struct registry_key *key,
147                       const char *name, struct registry_value **pval);
148 WERROR reg_querymultiplevalues(TALLOC_CTX *mem_ctx,
149                                struct registry_key *key,
150                                uint32_t num_names,
151                                const char **names,
152                                uint32_t *pnum_vals,
153                                struct registry_value **pvals);
154 WERROR reg_queryinfokey(struct registry_key *key, uint32_t *num_subkeys,
155                         uint32_t *max_subkeylen, uint32_t *max_subkeysize,
156                         uint32_t *num_values, uint32_t *max_valnamelen,
157                         uint32_t *max_valbufsize, uint32_t *secdescsize,
158                         NTTIME *last_changed_time);
159 WERROR reg_createkey(TALLOC_CTX *ctx, struct registry_key *parent,
160                      const char *subkeypath, uint32 desired_access,
161                      struct registry_key **pkey,
162                      enum winreg_CreateAction *paction);
163 WERROR reg_deletekey(struct registry_key *parent, const char *path);
164 WERROR reg_setvalue(struct registry_key *key, const char *name,
165                     const struct registry_value *val);
166 WERROR reg_deletevalue(struct registry_key *key, const char *name);
167 WERROR reg_getkeysecurity(TALLOC_CTX *mem_ctx, struct registry_key *key,
168                           struct security_descriptor **psecdesc);
169 WERROR reg_setkeysecurity(struct registry_key *key,
170                           struct security_descriptor *psecdesc);
171 WERROR reg_getversion(uint32_t *version);
172 WERROR reg_restorekey(struct registry_key *key, const char *fname);
173 WERROR reg_savekey(struct registry_key *key, const char *fname);
174 WERROR reg_deleteallvalues(struct registry_key *key);
175 WERROR reg_open_path(TALLOC_CTX *mem_ctx, const char *orig_path,
176                      uint32 desired_access, const struct security_token *token,
177                      struct registry_key **pkey);
178 WERROR reg_deletekey_recursive(TALLOC_CTX *ctx,
179                                struct registry_key *parent,
180                                const char *path);
181 WERROR reg_deletesubkeys_recursive(TALLOC_CTX *ctx,
182                                    struct registry_key *parent,
183                                    const char *path);
184 WERROR reg_create_path(TALLOC_CTX *mem_ctx, const char *orig_path,
185                        uint32 desired_access,
186                        const struct security_token *token,
187                        enum winreg_CreateAction *paction,
188                        struct registry_key **pkey);
189 WERROR reg_delete_path(const struct security_token *token,
190                        const char *orig_path);
191
192 /* The following definitions come from registry/reg_init_basic.c  */
193
194 WERROR registry_init_common(void);
195 WERROR registry_init_basic(void);
196
197 /* The following definitions come from registry/reg_init_full.c  */
198
199 WERROR registry_init_full(void);
200
201 /* The following definitions come from registry/reg_init_smbconf.c  */
202
203 WERROR registry_init_smbconf(const char *keyname);
204
205 #endif /* _REGISTRY_H */