aboutsummaryrefslogtreecommitdiffstats
path: root/lacme-accountd
diff options
context:
space:
mode:
authorGuilhem Moulin <guilhem@fripost.org>2021-02-19 00:06:49 +0100
committerGuilhem Moulin <guilhem@fripost.org>2021-02-20 18:18:48 +0100
commitbaa7c25db322a9472c9155422057ec56aa93f439 (patch)
tree9d6218b9fa85ae177e7c7a4593181ee21ff953f5 /lacme-accountd
parent42a8f9813716ed3495b6f49edea429b127eef0f0 (diff)
Use File::Basename::dirname().
To correctly extract the parent directory of the socket path. The previous returned an empty string when the socket path didn't contain ‘/’.
Diffstat (limited to 'lacme-accountd')
-rwxr-xr-xlacme-accountd5
1 files changed, 3 insertions, 2 deletions
diff --git a/lacme-accountd b/lacme-accountd
index 7b9b1ff..1dc5f03 100755
--- a/lacme-accountd
+++ b/lacme-accountd
@@ -28,6 +28,7 @@ my $PROTOCOL_VERSION = 1;
my $NAME = 'lacme-accountd';
use Errno 'EINTR';
+use File::Basename 'dirname';
use Getopt::Long qw/:config posix_default no_ignore_case gnu_getopt auto_version/;
use List::Util 'first';
use MIME::Base64 'encode_base64url';
@@ -143,8 +144,8 @@ unless (defined $OPTS{stdio}) {
$sockname = $sockname =~ /\A(\p{Print}+)\z/ ? $1 : die "Invalid socket name\n"; # untaint $sockname
# ensure we're the only user with write access to the parent dir
- my $dirname = $sockname =~ s/[^\/]+$//r;
- my @stat = stat($dirname) or die "stat($dirname): $!";
+ my $dirname = dirname($sockname);
+ my @stat = stat($dirname) or die "stat($dirname): $!\n";
die "Error: insecure permissions on $dirname\n" if ($stat[2] & 0022) != 0;
my $umask = umask(0177) // die "umask: $!";