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