use getpwuid() to resolve ~ in socket paths instead of glob()
This fixes a warning about using a tainted variable (broke the tests with newer perl versions).
This commit is contained in:
parent
e656864838
commit
192ef6a827
|
@ -96,7 +96,16 @@ sub new {
|
||||||
|
|
||||||
$path ||= '~/.i3/ipc.sock';
|
$path ||= '~/.i3/ipc.sock';
|
||||||
|
|
||||||
bless { path => glob($path) } => $class;
|
# Check if we need to resolve ~
|
||||||
|
if ($path =~ /~/) {
|
||||||
|
# We use getpwuid() instead of $ENV{HOME} because the latter is tainted
|
||||||
|
# and thus produces warnings when running tests with perl -T
|
||||||
|
my $home = (getpwuid($<))[7];
|
||||||
|
die "Could not get home directory" unless $home and -d $home;
|
||||||
|
$path =~ s/~/$home/g;
|
||||||
|
}
|
||||||
|
|
||||||
|
bless { path => $path } => $class;
|
||||||
}
|
}
|
||||||
|
|
||||||
=head2 $i3->connect
|
=head2 $i3->connect
|
||||||
|
|
Loading…
Reference in New Issue