From: Michael Stapelberg Date: Wed, 9 Jun 2010 22:18:50 +0000 (+0200) Subject: use getpwuid() to resolve ~ in socket paths instead of glob() X-Git-Tag: AnyEvent-0.05~1 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=72928beb2fd509dbcd9b7195d3af192142812d50;p=i3%2Fi3 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). --- diff --git a/lib/AnyEvent/I3.pm b/lib/AnyEvent/I3.pm index d9a55b2b..944d5f02 100644 --- a/lib/AnyEvent/I3.pm +++ b/lib/AnyEvent/I3.pm @@ -96,7 +96,16 @@ sub new { $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