diff options
Diffstat (limited to 'src/hook_fusefs/hookfs.c')
-rw-r--r-- | src/hook_fusefs/hookfs.c | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/src/hook_fusefs/hookfs.c b/src/hook_fusefs/hookfs.c index 00a27a8..d6371dd 100644 --- a/src/hook_fusefs/hookfs.c +++ b/src/hook_fusefs/hookfs.c @@ -42,7 +42,7 @@ #define MIN(a, b) (((a) < (b)) ? (a) : (b)) -#define MAXPATHLEN 256 +#define MAXPATHLEN PATH_MAX #define MAXSOCKETPATHLEN 108 #define MAXFILEBUFFLEN 2048 @@ -454,7 +454,11 @@ static int hookfs_readdir(const char *path, void *buf, fuse_fill_dir_t filler, { struct hookfs_dirp *d = get_dirp(fi); - (void) path; + struct fuse_context * context = fuse_get_context(); + char *stage=getstagebypid(context->pid); + + + //(void) path; if (offset != d->offset) { seekdir(d->dp, offset); d->entry = NULL; @@ -466,17 +470,31 @@ static int hookfs_readdir(const char *path, void *buf, fuse_fill_dir_t filler, if (!d->entry) { d->entry = readdir(d->dp); + if (!d->entry) break; } + //log_event("debug",d->entry->d_name,"DENIED",0,stage); memset(&st, 0, sizeof(st)); st.st_ino = d->entry->d_ino; st.st_mode = d->entry->d_type << 12; nextoff = telldir(d->dp); - if (filler(buf, d->entry->d_name, &st, nextoff)) + + // we must ask registrar about should we show the file + char fullpath[MAXPATHLEN]; + snprintf(fullpath,MAXPATHLEN,"%s/%s",path,d->entry->d_name); + + char abspath[MAXPATHLEN]; + realpath(fullpath,abspath); + + if(! is_event_allowed("stat",abspath,context->pid,stage)) { + errno=2; + log_event("stat",abspath,"DENIED",errno,stage); + } else if (filler(buf, d->entry->d_name, &st, nextoff)) { break; - + } + d->entry = NULL; d->offset = nextoff; } |