diff --git a/src/lib/Sympa/Aliases/Template.pm b/src/lib/Sympa/Aliases/Template.pm index bf6ad06ae..eeab7527a 100644 --- a/src/lib/Sympa/Aliases/Template.pm +++ b/src/lib/Sympa/Aliases/Template.pm @@ -5,8 +5,8 @@ # Sympa - SYsteme de Multi-Postage Automatique # -# Copyright 2017, 2018 The Sympa Community. See the AUTHORS.md file at the -# top-level directory of this distribution and at +# Copyright 2017, 2018, 2024 The Sympa Community. See the +# AUTHORS.md file at the top-level directory of this distribution and at # . # # This program is free software; you can redistribute it and/or modify @@ -101,7 +101,8 @@ sub add { # Create a lock my $lock_fh; unless ($lock_fh = Sympa::LockedFile->new($alias_file, 20, '+>>')) { - $log->syslog('err', 'Can\'t lock %s', $alias_file); + $log->syslog('err', 'Can\'t lock %s: %s', + $alias_file, Sympa::LockedFile->last_error); return undef; } @@ -168,7 +169,8 @@ sub del { # Create a lock my $lock_fh; unless ($lock_fh = Sympa::LockedFile->new($alias_file, 20, '+<')) { - $log->syslog('err', 'Can\'t lock %s', $alias_file); + $log->syslog('err', 'Can\'t lock %s: %s', + $alias_file, Sympa::LockedFile->last_error); return undef; } diff --git a/src/lib/Sympa/List.pm b/src/lib/Sympa/List.pm index b137bb3e3..c9928553d 100644 --- a/src/lib/Sympa/List.pm +++ b/src/lib/Sympa/List.pm @@ -7,9 +7,9 @@ # Copyright (c) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, # 2006, 2007, 2008, 2009, 2010, 2011 Comite Reseau des Universites # Copyright (c) 2011, 2012, 2013, 2014, 2015, 2016, 2017 GIP RENATER -# Copyright 2017, 2018, 2019, 2020, 2021, 2022 The Sympa Community. See the -# AUTHORS.md file at the top-level directory of this distribution and at -# . +# Copyright 2017, 2018, 2019, 2020, 2021, 2022, 2024 The Sympa Community. +# See the AUTHORS.md file at the top-level directory of this distribution +# and at . # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -364,7 +364,11 @@ sub update_stats { my $lock_fh = Sympa::LockedFile->new($self->{'dir'} . '/stats', 2, '+>>'); unless ($lock_fh) { - $log->syslog('err', 'Could not create new lock'); + $log->syslog( + 'err', + 'Could not create new lock: %s', + Sympa::LockedFile->last_error + ); return; } @@ -552,7 +556,11 @@ sub save_config { ## Lock file my $lock_fh = Sympa::LockedFile->new($config_file_name, 5, '+<'); unless ($lock_fh) { - $log->syslog('err', 'Could not create new lock'); + $log->syslog( + 'err', + 'Could not create new lock: %s', + Sympa::LockedFile->last_error + ); return undef; } @@ -675,7 +683,11 @@ sub load { my $lock_fh = Sympa::LockedFile->new($self->{'dir'} . '/config', 5, '<'); unless ($lock_fh) { - $log->syslog('err', 'Could not create new lock'); + $log->syslog( + 'err', + 'Could not create new lock: %s', + Sympa::LockedFile->last_error + ); return undef; } @@ -704,7 +716,11 @@ sub load { my $lock_fh = Sympa::LockedFile->new($self->{'dir'} . '/config', 5, '+<'); unless ($lock_fh) { - $log->syslog('err', 'Could not create new lock'); + $log->syslog( + 'err', + 'Could not create new lock: %s', + Sympa::LockedFile->last_error + ); return undef; } @@ -5033,7 +5049,10 @@ sub _load_list_config_file { ## Lock file my $lock_fh = Sympa::LockedFile->new($config_file, 5, '<'); unless ($lock_fh) { - $log->syslog('err', 'Could not create new lock on %s', $config_file); + $log->syslog( + 'err', 'Could not create new lock on %s: %s', + $config_file, Sympa::LockedFile->last_error + ); return undef; } diff --git a/src/lib/Sympa/Process.pm b/src/lib/Sympa/Process.pm index bcdfd6944..d5f1122ec 100644 --- a/src/lib/Sympa/Process.pm +++ b/src/lib/Sympa/Process.pm @@ -1,6 +1,5 @@ # -*- indent-tabs-mode: nil; -*- # vim:ft=perl:et:sw=4 -# $Id$ # Sympa - SYsteme de Multi-Postage Automatique # @@ -8,6 +7,9 @@ # Copyright (c) 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, # 2006, 2007, 2008, 2009, 2010, 2011 Comite Reseau des Universites # Copyright (c) 2011, 2012, 2013, 2014, 2015, 2016, 2017 GIP RENATER +# Copyright 2024 The Sympa Community. See the +# AUTHORS.md file at the top-level directory of this distribution and at +# . # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -237,8 +239,8 @@ sub remove_pid { # Lock pid file my $lock_fh = Sympa::LockedFile->new($pidfile, 5, '+<'); unless ($lock_fh) { - $log->syslog('err', 'Could not open %s to remove PID %s', - $pidfile, $pid); + $log->syslog('err', 'Could not open %s to remove PID %s: %s', + $pidfile, $pid, Sympa::LockedFile->last_error); return undef; } @@ -306,7 +308,7 @@ sub write_pid { group => Sympa::Constants::GROUP, ) ) { - die sprintf 'Unable to set rights on %s. Exiting.', $piddir; + die sprintf 'Unable to set rights on %s: %s', $piddir, $ERRNO; ## No return } @@ -315,8 +317,8 @@ sub write_pid { # Lock pid file my $lock_fh = Sympa::LockedFile->new($pidfile, 5, '+>>'); unless ($lock_fh) { - die sprintf 'Unable to lock %s file in write mode. Exiting.', - $pidfile; + die sprintf 'Unable to lock %s file in write mode: %s', + $pidfile, Sympa::LockedFile->last_error; } ## If pidfile exists, read the PIDs if (-s $pidfile) { @@ -348,9 +350,10 @@ sub write_pid { seek $lock_fh, 0, 0; unless (truncate $lock_fh, 0) { - ## Unlock pid file + my $errno = $ERRNO; + # Unlock pid file $lock_fh->close(); - die sprintf 'Could not truncate %s, exiting.', $pidfile; + die sprintf 'Could not truncate %s: %s', $pidfile, $errno; } print $lock_fh $pid . "\n"; @@ -363,9 +366,10 @@ sub write_pid { group => Sympa::Constants::GROUP, ) ) { - ## Unlock pid file + my $errno = $ERRNO; + # Unlock pid file $lock_fh->close(); - die sprintf 'Unable to set rights on %s', $pidfile; + die sprintf 'Unable to set rights on %s: %s', $pidfile, $errno; } ## Unlock pid file $lock_fh->close(); @@ -445,7 +449,10 @@ sub _get_pids_in_pid_file { my $lock_fh = Sympa::LockedFile->new($pidfile, 5, '<'); unless ($lock_fh) { - $log->syslog('err', 'Unable to open PID file %s: %m', $pidfile); + $log->syslog( + 'err', 'Unable to open PID file %s: %s', + $pidfile, Sympa::LockedFile->last_error + ); return; } my $l = <$lock_fh>; diff --git a/src/lib/Sympa/Request/Handler/update_automatic_list.pm b/src/lib/Sympa/Request/Handler/update_automatic_list.pm index 8c3404168..07eb230a4 100644 --- a/src/lib/Sympa/Request/Handler/update_automatic_list.pm +++ b/src/lib/Sympa/Request/Handler/update_automatic_list.pm @@ -4,8 +4,8 @@ # Sympa - SYsteme de Multi-Postage Automatique # -# Copyright 2018, 2019, 2020 The Sympa Community. See the AUTHORS.md -# file at the top-level directory of this distribution and at +# Copyright 2018, 2019, 2020, 2024 The Sympa Community. See the +# AUTHORS.md file at the top-level directory of this distribution and at # . # # This program is free software; you can redistribute it and/or modify @@ -148,8 +148,10 @@ sub _twist { ## Lock config before openning the config file my $lock_fh = Sympa::LockedFile->new($list->{'dir'} . '/config', 5, '>'); unless ($lock_fh) { - $log->syslog('err', 'Impossible to create %s/config: %s', - $list->{'dir'}, $ERRNO); + $log->syslog( + 'err', 'Impossible to create %s/config: %s', + $list->{'dir'}, Sympa::LockedFile->last_error + ); $self->add_stash($request, 'intern'); return undef; }