aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Stapelberg <stapelberg@users.noreply.github.com>2024-04-19 08:45:34 +0200
committerGitHub <noreply@github.com>2024-04-19 08:45:34 +0200
commit91ce3bdbd544497c4b6bb805e7a852b00b60d4a5 (patch)
tree9d05c52cac6e14fa1a41124e13af8e8bc436a9cc
parentffbbbf347703a50c452d766a8bf7e4b12e7c1d72 (diff)
downloadi3-91ce3bdbd544497c4b6bb805e7a852b00b60d4a5.tar.gz
i3-91ce3bdbd544497c4b6bb805e7a852b00b60d4a5.zip
AnyEvent::I3: rip out taint mode compatibility (#5999)
I suspect nobody actually uses Perl’s taint mode with AnyEvent::I3. See https://github.com/i3/i3/pull/5987 for discussion.
-rw-r--r--AnyEvent-I3/lib/AnyEvent/I3.pm34
-rw-r--r--AnyEvent-I3/t/00-load.t2
-rw-r--r--AnyEvent-I3/t/01-workspaces.t2
-rw-r--r--AnyEvent-I3/t/02-sugar.t2
-rw-r--r--AnyEvent-I3/t/boilerplate.t2
-rw-r--r--AnyEvent-I3/t/manifest.t2
-rw-r--r--AnyEvent-I3/t/pod.t2
7 files changed, 7 insertions, 39 deletions
diff --git a/AnyEvent-I3/lib/AnyEvent/I3.pm b/AnyEvent-I3/lib/AnyEvent/I3.pm
index 14618430..c7735c51 100644
--- a/AnyEvent-I3/lib/AnyEvent/I3.pm
+++ b/AnyEvent-I3/lib/AnyEvent/I3.pm
@@ -8,7 +8,6 @@ use AnyEvent::Handle;
use AnyEvent::Socket;
use AnyEvent;
use Encode;
-use Scalar::Util qw(tainted);
use Carp;
=head1 NAME
@@ -132,35 +131,10 @@ sub i3 {
AnyEvent::I3->new(@_)
}
-# Calls i3, even when running in taint mode.
sub _call_i3 {
my ($args) = @_;
- my $path_tainted = tainted($ENV{PATH});
- # This effectively circumvents taint mode checking for $ENV{PATH}. We
- # do this because users might specify PATH explicitly to call i3 in a
- # custom location (think ~/.bin/).
- (local $ENV{PATH}) = ($ENV{PATH} =~ /(.*)/);
-
- # In taint mode, we also need to remove all relative directories from
- # PATH (like . or ../bin). We only do this in taint mode and warn the
- # user, since this might break a real-world use case for some people.
- if ($path_tainted) {
- my @dirs = split /:/, $ENV{PATH};
- my @filtered = grep !/^\./, @dirs;
- if (scalar @dirs != scalar @filtered) {
- $ENV{PATH} = join ':', @filtered;
- warn qq|Removed relative directories from PATH because you | .
- qq|are running Perl with taint mode enabled. Remove -T | .
- qq|to be able to use relative directories in PATH. | .
- qq|New PATH is "$ENV{PATH}"|;
- }
- }
- # Otherwise the qx() operator wont work:
- delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'};
chomp(my $result = qx(i3 $args));
- # Circumventing taint mode again: the socket can be anywhere on the
- # system and that’s okay.
if ($result =~ /^([^\0]+)$/) {
return $1;
}
@@ -184,15 +158,9 @@ sub new {
$path = _call_i3('--get-socketpath') unless $path;
- # This is the old default path (v3.*). This fallback line can be removed in
- # a year from now. -- Michael, 2012-07-09
- $path ||= '~/.i3/ipc.sock';
-
# 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];
+ my $home = $ENV{HOME};
confess "Could not get home directory" unless $home and -d $home;
$path =~ s/~/$home/g;
}
diff --git a/AnyEvent-I3/t/00-load.t b/AnyEvent-I3/t/00-load.t
index 4bf6151e..210ab153 100644
--- a/AnyEvent-I3/t/00-load.t
+++ b/AnyEvent-I3/t/00-load.t
@@ -1,4 +1,4 @@
-#!perl -T
+#!perl
use Test::More tests => 1;
diff --git a/AnyEvent-I3/t/01-workspaces.t b/AnyEvent-I3/t/01-workspaces.t
index f3206d89..8b12f111 100644
--- a/AnyEvent-I3/t/01-workspaces.t
+++ b/AnyEvent-I3/t/01-workspaces.t
@@ -1,4 +1,4 @@
-#!perl -T
+#!perl
# vim:ts=4:sw=4:expandtab
use Test::More tests => 3;
diff --git a/AnyEvent-I3/t/02-sugar.t b/AnyEvent-I3/t/02-sugar.t
index a3e2cc79..4811be44 100644
--- a/AnyEvent-I3/t/02-sugar.t
+++ b/AnyEvent-I3/t/02-sugar.t
@@ -1,4 +1,4 @@
-#!perl -T
+#!perl
# vim:ts=4:sw=4:expandtab
use Test::More tests => 3;
diff --git a/AnyEvent-I3/t/boilerplate.t b/AnyEvent-I3/t/boilerplate.t
index effb65b6..f4024158 100644
--- a/AnyEvent-I3/t/boilerplate.t
+++ b/AnyEvent-I3/t/boilerplate.t
@@ -1,4 +1,4 @@
-#!perl -T
+#!perl
use strict;
use warnings;
diff --git a/AnyEvent-I3/t/manifest.t b/AnyEvent-I3/t/manifest.t
index 45eb83fd..2dcbd43c 100644
--- a/AnyEvent-I3/t/manifest.t
+++ b/AnyEvent-I3/t/manifest.t
@@ -1,4 +1,4 @@
-#!perl -T
+#!perl
use strict;
use warnings;
diff --git a/AnyEvent-I3/t/pod.t b/AnyEvent-I3/t/pod.t
index ee8b18ad..b4791d4e 100644
--- a/AnyEvent-I3/t/pod.t
+++ b/AnyEvent-I3/t/pod.t
@@ -1,4 +1,4 @@
-#!perl -T
+#!perl
use strict;
use warnings;