|
|
|
@ -1,7 +1,7 @@ |
|
|
|
|
#!/usr/bin/perl -w |
|
|
|
|
|
|
|
|
|
#---------------------------------------------------------------------- |
|
|
|
|
# copyright (C) 2011 Firewall-Services |
|
|
|
|
# copyright (C) 2011-2012 Firewall-Services |
|
|
|
|
# daniel@firewall-services.com |
|
|
|
|
# |
|
|
|
|
# This program is free software; you can redistribute it and/or modify |
|
|
|
@ -26,8 +26,8 @@ use strict; |
|
|
|
|
use Errno; |
|
|
|
|
use esmith::ConfigDB; |
|
|
|
|
use esmith::AccountsDB; |
|
|
|
|
use esmith::templates; |
|
|
|
|
use User::pwent; |
|
|
|
|
use File::Copy qw(mv); |
|
|
|
|
use File::Path qw(mkpath); |
|
|
|
|
|
|
|
|
|
my $configdb = esmith::ConfigDB->open_ro or |
|
|
|
@ -48,30 +48,37 @@ my $event = shift; |
|
|
|
|
my $userName = shift; |
|
|
|
|
my @users; |
|
|
|
|
|
|
|
|
|
if (defined $userName) |
|
|
|
|
{ |
|
|
|
|
if (defined $userName){ |
|
|
|
|
my $rec = $accountsdb->get($userName); |
|
|
|
|
die |
|
|
|
|
"Account $userName is not a user account; signature generation failed.\n" |
|
|
|
|
unless $userName eq 'admin' || ($rec && $rec->prop('type') eq "user"); |
|
|
|
|
@users = ($rec); |
|
|
|
|
} |
|
|
|
|
else |
|
|
|
|
{ |
|
|
|
|
else{ |
|
|
|
|
@users = ( $accountsdb->users, $accountsdb->get('admin') ); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
foreach my $user (@users) |
|
|
|
|
{ |
|
|
|
|
if (-d "/home/e-smith/files/shares/tools/files/templates_signatures"){ |
|
|
|
|
mv ("/home/e-smith/files/shares/tools/files/templates_signatures/", |
|
|
|
|
"/home/e-smith/files/shares/tools/files/signatures/templates/"); |
|
|
|
|
rmdir "/home/e-smith/files/shares/tools/files/templates_signatures"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
foreach my $user (@users){ |
|
|
|
|
$userName = $user->key; |
|
|
|
|
|
|
|
|
|
setpwent(); |
|
|
|
|
my $home = getpwnam($userName)->dir; |
|
|
|
|
my $uid = getpwnam($userName)->uid; |
|
|
|
|
my $gid = getpwnam($userName)->gid; |
|
|
|
|
my $dir = $home . '/home/signature'; |
|
|
|
|
mkpath "$dir"; |
|
|
|
|
chown $uid, $gid, $dir; |
|
|
|
|
my $dir = '/home/e-smith/files/shares/tools/files/signatures/' . $userName; |
|
|
|
|
|
|
|
|
|
# Migrate frmo previous path |
|
|
|
|
if ( -d "$home/home/signature" && !-d $dir ){ |
|
|
|
|
mv ("$home/home/signature", $dir); |
|
|
|
|
} |
|
|
|
|
if (!-d "$dir"){ |
|
|
|
|
mkpath "$dir"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
my $first = $user->prop('FirstName') || ''; |
|
|
|
|
my $last = $user->prop('LastName') || ''; |
|
|
|
@ -99,7 +106,7 @@ foreach my $user (@users) |
|
|
|
|
$url = ($url eq '') ? '':"Web: $url"; |
|
|
|
|
|
|
|
|
|
foreach my $ext (qw/txt html/){ |
|
|
|
|
open(R, '<', "/home/e-smith/files/shares/tools/files/templates_signatures/$template.$ext") || |
|
|
|
|
open(R, '<', "/home/e-smith/files/shares/tools/files/signatures/templates/$template.$ext") || |
|
|
|
|
next; |
|
|
|
|
open(W, '>', "$dir/email.$ext") || die "Error opening output file $dir/email.$ext\n"; |
|
|
|
|
|
|
|
|
@ -125,5 +132,8 @@ foreach my $user (@users) |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
die "Failed to reset permissions on tools share" |
|
|
|
|
unless ( system("/sbin/e-smith/signal-event", "share-modify-files", "tools") == 0 ); |
|
|
|
|
|
|
|
|
|
exit (0); |
|
|
|
|
|
|
|
|
|