From 08a59f3f0862084061a41b16b72df7cb71d6276c Mon Sep 17 00:00:00 2001 From: Daniel Berteaud Date: Sun, 24 Jun 2012 14:11:44 +0200 Subject: [PATCH] =?UTF-8?q?D=C3=A9placement=20des=20signatures=20dans=20to?= =?UTF-8?q?ols?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../etc/e-smith/events/actions/generate-email-sign | 40 ++++++++++++++-------- 1 file changed, 25 insertions(+), 15 deletions(-) diff --git a/root/etc/e-smith/events/actions/generate-email-sign b/root/etc/e-smith/events/actions/generate-email-sign index 7ee37c9..00f077b 100644 --- a/root/etc/e-smith/events/actions/generate-email-sign +++ b/root/etc/e-smith/events/actions/generate-email-sign @@ -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,9 +26,9 @@ use strict; use Errno; use esmith::ConfigDB; use esmith::AccountsDB; -use esmith::templates; use User::pwent; -use File::Path qw(mkpath); +use File::Copy; +use File::Path qw(mkpath rmtree); my $configdb = esmith::ConfigDB->open_ro or die "Could not open configuration db\n"; @@ -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") + move ("/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 ){ + move("$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);