From: Eric Bollengier Date: Wed, 4 May 2022 08:11:50 +0000 (+0200) Subject: regress: Add get_perm function to functions.pm module X-Git-Tag: Release-13.0.0~40 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1feb16ceabda25affc416b1bec3b6f2f911a6fcf;p=thirdparty%2Fbacula.git regress: Add get_perm function to functions.pm module Some tests are using "stat -c %a" to get file permission in a way that is suitable to compare later on. Unfortunately, it is not portable. --- diff --git a/regress/scripts/functions.pm b/regress/scripts/functions.pm index 9cc540ef9..2154a985c 100644 --- a/regress/scripts/functions.pm +++ b/regress/scripts/functions.pm @@ -52,7 +52,7 @@ our @EXPORT = qw(update_some_files create_many_files check_multiple_copies check_openfile check_cloud_hash check_bscan add_log_message compare_backup_content check_tls_traces println add_virtual_changer check_events check_events_json create_many_hardlinks check_dot_status parse_fuse_trace generate_random_seek - check_storage_selection check_json + check_storage_selection check_json get_perm ); @@ -2575,4 +2575,12 @@ sub check_json } exit 0; } + +# Get the permission in octal for a file, equivalent to stat -c %a +sub get_perm +{ + my ($file) = @_; + my $mode = (stat($file))[2]; + printf "%04o\n", $mode & 07777; +} 1;