- method handle_dir_event dirname evlist fname =
- let fqp = String.concat "/" [dirname;fname] in
- if (Str.string_match !file_regexp fname 0) then
- begin
- let is_event = list_check evlist in
- if (is_event Create) then
- begin
- if (is_event Isdir) then
- begin
- this#new_dir fqp this#handle_dir_event
- end
- else
- (* It's a new script *)
- begin
- (*
- if (Str.string_match dir_regexp fname 0) then
- let fqp = String.concat "/" [dirname;String.sub fname 4 ((String.length fname)-4+1)] in
- let real_fqp = String.concat "/" [dirname;fname] in
- this#new_dir fqp this#handle_spool_event;
- Hashtbl.add spools fqp real_fqp
- else*)
- this#new_script fqp
- end
- end
- else if (is_event Delete) then
- begin
- if (is_event Isdir) then
- begin
- (*this#rm_watch fqp;*)
- List.iter (fun frontend->
- frontend#rmdir (mk_rel_path fqp)) frontend_lst
- end
- else List.iter (fun frontend ->
- frontend#unlink (mk_rel_path fqp)) frontend_lst
- end
- end
- else (* regex not matched *)
- ()
+ method is_acl fname = Str.string_match acl_file_regexp fname 0
+
+ (** Gets called every time there's an inotify event at the backend
+ @param dirname Name of the backend directory
+ @param evlist Description of what happened
+ @param fname Name of the file that the event applies to
+ *)
+ method handle_dir_event _ dirname evlist fname =
+ let fqp = String.concat "/" [dirname;fname] in
+ if ((Str.string_match file_regexp fname 0) && not (Str.string_match acl_file_regexp fname 0)) then
+ begin
+ (* Filter frontend list based on acl *)
+ let acl_fqp = String.concat "." [fqp;"acl"] in
+ let acl_filter = this#make_filter acl_fqp in
+ let slice_list =
+ match acl_filter with
+ | None -> [] (* No ACL *)
+ | Some(filter) -> List.filter
+ (fun fe->Hashtbl.mem filter (fe#get_slice_name ()))
+ frontend_lst
+ in
+ let is_event = list_check evlist in
+ if (is_event Create) then
+ begin
+ if (is_event Isdir) then
+ begin
+ this#new_dir slice_list fqp this#handle_dir_event
+ end
+ else
+ (* It's a new script *)
+ begin
+ this#new_script slice_list fqp
+ end
+ end
+ else if (is_event Delete) then
+ begin
+ if (is_event Isdir) then
+ begin
+ (*this#rm_watch fqp;*)
+ List.iter (fun frontend->
+ frontend#rmdir (mk_rel_path fqp)) slice_list
+ end
+ else List.iter (fun frontend ->
+ frontend#unlink (mk_rel_path fqp)) slice_list
+ end
+ end
+ else (* regex not matched *)
+ fprintf logfd "Rejected weird entry %s\n" fname