summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJelmer Vernooij <jelmer@samba.org>2004-04-18 21:39:03 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:51:18 -0500
commit6de32ddc2dbfe0685f361ed1a0dc11dff8ca19e5 (patch)
tree3fc6206225500a449d039f43333d6f526b0ab327
parentbfa370671bfce8fb9672fc4401232057b73f58ad (diff)
downloadsamba-6de32ddc2dbfe0685f361ed1a0dc11dff8ca19e5.tar.gz
samba-6de32ddc2dbfe0685f361ed1a0dc11dff8ca19e5.tar.bz2
samba-6de32ddc2dbfe0685f361ed1a0dc11dff8ca19e5.zip
r274: Be somewhat more POSIX compatible
(This used to be commit c98a234d02d6190cf99ab1c9ff7b029f929e292a)
-rw-r--r--source4/lib/registry/reg_backend_dir/reg_backend_dir.c28
1 files changed, 19 insertions, 9 deletions
diff --git a/source4/lib/registry/reg_backend_dir/reg_backend_dir.c b/source4/lib/registry/reg_backend_dir/reg_backend_dir.c
index 375daa319b..960d5f3e04 100644
--- a/source4/lib/registry/reg_backend_dir/reg_backend_dir.c
+++ b/source4/lib/registry/reg_backend_dir/reg_backend_dir.c
@@ -80,22 +80,32 @@ static WERROR reg_dir_fetch_subkeys(REG_KEY *k, int *count, REG_KEY ***r)
if(!d) return WERR_INVALID_PARAM;
while((e = readdir(d))) {
- if(e->d_type == DT_DIR &&
- strcmp(e->d_name, ".") &&
+ if( strcmp(e->d_name, ".") &&
strcmp(e->d_name, "..")) {
- ar[(*count)] = reg_key_new_rel(e->d_name, k, NULL);
- ar[(*count)]->backend_data = talloc_asprintf(ar[*count]->mem_ctx, "%s/%s", fullpath, e->d_name);
- if(ar[(*count)])(*count)++;
+ struct stat stbuf;
+ char *thispath;
+
+ /* Check if file is a directory */
+ asprintf(&thispath, "%s/%s", fullpath, e->d_name);
+ stat(thispath, &stbuf);
- if((*count) == max) {
- max+=200;
- ar = realloc(ar, sizeof(REG_KEY *) * max);
+ if(S_ISDIR(stbuf.st_mode)) {
+ ar[(*count)] = reg_key_new_rel(e->d_name, k, NULL);
+ ar[(*count)]->backend_data = talloc_strdup(ar[*count]->mem_ctx, thispath);
+ if(ar[(*count)])(*count)++;
+
+ if((*count) == max) {
+ max+=200;
+ ar = realloc(ar, sizeof(REG_KEY *) * max);
+ }
}
+
+ SAFE_FREE(thispath);
}
}
closedir(d);
-
+
*r = ar;
return WERR_OK;
}