#!/usr/bin/perl -w package esmith; use File::Path qw(mkpath rmtree); use esmith::AccountsDB; my $a = esmith::AccountsDB->open_ro(); $ENV{'PATH'} = "/bin"; my $setfacl = "/usr/bin/setfacl"; my $event = $ARGV [0]; my $name = $ARGV [1]; die "Event name missing\n" unless (defined $event); if ($event eq 'user-create'){ mkpath "/home/e-smith/files/scan/$name"; system ("$setfacl", '-m', "u:scanner:w,u:$name:rwX,d:u:$name:rw", '--', "/home/e-smith/files/scan/$name"); } elsif ($event eq 'user-delete'){ rmtree "/home/e-smith/files/scan/$name"; } else { system ("$setfacl", '-R', '--remove-all', '--remove-default', '--', "/home/e-smith/files/scan/"); foreach ($a->users,$a->get('admin')){ $name = $_->key; if (-d "/home/e-smith/files/scan/$name"){ chmod 0700, "/home/e-smith/files/scan/$name"; } else { mkdir "/home/e-smith/files/scan/$name", 0700; } system ("$setfacl", '-R', '-m', "u:scanner:w,u:$name:rwX,d:u:$name:rwX", '--', "/home/e-smith/files/scan/$name"); } } exit (0);