diff options
author | Volker Lendecke <vlendec@samba.org> | 2006-11-30 07:38:40 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 12:16:16 -0500 |
commit | 575845ccbeb2acc5dcb5133b80fd19b1d80169f2 (patch) | |
tree | 0ec427819a9f6e9e417a1e34b9bbcfd23badc1b7 /source3/smbd | |
parent | 3fda843ac16d3d8c66a398a93b5de81f7d74276d (diff) | |
download | samba-575845ccbeb2acc5dcb5133b80fd19b1d80169f2.tar.gz samba-575845ccbeb2acc5dcb5133b80fd19b1d80169f2.tar.bz2 samba-575845ccbeb2acc5dcb5133b80fd19b1d80169f2.zip |
r19963: Add 'registry shares = yes' and registry key security descriptors.
(This used to be commit 6cab254c49e07b11c170511ec613f0f33914c3e6)
Diffstat (limited to 'source3/smbd')
-rw-r--r-- | source3/smbd/lanman.c | 1 | ||||
-rw-r--r-- | source3/smbd/msdfs.c | 1 | ||||
-rw-r--r-- | source3/smbd/service.c | 113 |
3 files changed, 115 insertions, 0 deletions
diff --git a/source3/smbd/lanman.c b/source3/smbd/lanman.c index 8ecc965c0d..e42d96b11e 100644 --- a/source3/smbd/lanman.c +++ b/source3/smbd/lanman.c @@ -1671,6 +1671,7 @@ static BOOL api_RNetShareEnum( connection_struct *conn, /* Ensure all the usershares are loaded. */ become_root(); + load_registry_shares(); count = load_usershare_shares(); unbecome_root(); diff --git a/source3/smbd/msdfs.c b/source3/smbd/msdfs.c index 1f04356b4f..12fd333efe 100644 --- a/source3/smbd/msdfs.c +++ b/source3/smbd/msdfs.c @@ -1114,6 +1114,7 @@ int enum_msdfs_links(TALLOC_CTX *ctx, struct junction_map *jucn, int jn_max) /* Ensure all the usershares are loaded. */ become_root(); + load_registry_shares(); sharecount = load_usershare_shares(); unbecome_root(); diff --git a/source3/smbd/service.c b/source3/smbd/service.c index 60ba85ab65..e63bc01a7d 100644 --- a/source3/smbd/service.c +++ b/source3/smbd/service.c @@ -229,6 +229,115 @@ int add_home_service(const char *service, const char *username, const char *home } +static int load_registry_service(const char *servicename) +{ + REGISTRY_KEY *key; + char *path; + WERROR err; + NTSTATUS status; + + uint32 i, num_values; + char **value_names; + struct registry_value **values = NULL; + + int res; + + if (!lp_registry_shares()) { + return -1; + } + + if (asprintf(&path, "%s\\%s", KEY_SMBCONF, servicename) == -1) { + return -1; + } + + err = regkey_open_internal(NULL, NULL, &key, path, get_root_nt_token(), + REG_KEY_READ); + SAFE_FREE(path); + + if (!W_ERROR_IS_OK(err)) { + return -1; + } + + status = registry_fetch_values(NULL, key, &num_values, &value_names, + &values); + + TALLOC_FREE(key); + + if (!NT_STATUS_IS_OK(status)) { + goto error; + } + + res = lp_add_service(servicename, -1); + if (res == -1) { + goto error; + } + + for (i=0; i<num_values; i++) { + switch (values[i]->type) { + case REG_DWORD: { + char *val; + if (asprintf(&val, "%d", values[i]->v.dword) == -1) { + continue; + } + lp_do_parameter(res, value_names[i], val); + SAFE_FREE(val); + break; + } + case REG_SZ: { + lp_do_parameter(res, value_names[i], + values[i]->v.sz.str); + break; + } + default: + /* Ignore all the rest */ + break; + } + } + + TALLOC_FREE(value_names); + TALLOC_FREE(values); + return res; + + error: + + TALLOC_FREE(value_names); + TALLOC_FREE(values); + return -1; +} + +void load_registry_shares(void) +{ + REGISTRY_KEY *key; + REGSUBKEY_CTR *keys; + WERROR err; + int i; + + if (!lp_registry_shares()) { + return; + } + + if (!(keys = TALLOC_ZERO_P(NULL, REGSUBKEY_CTR))) { + goto done; + } + + err = regkey_open_internal(keys, NULL, &key, KEY_SMBCONF, + get_root_nt_token(), REG_KEY_READ); + if (!(W_ERROR_IS_OK(err))) { + goto done; + } + + if (fetch_reg_keys(key, keys) == -1) { + goto done; + } + + for (i=0; i<keys->num_subkeys; i++) { + load_registry_service(keys->subkeys[i]); + } + + done: + TALLOC_FREE(keys); + return; +} /** * Find a service entry. @@ -307,6 +416,10 @@ int find_service(fstring service) } } + if (iService < 0) { + iService = load_registry_service(service); + } + /* Is it a usershare service ? */ if (iService < 0 && *lp_usershare_path()) { /* Ensure the name is canonicalized. */ |