diff -u libanyevent-i3-perl-0.08/debian/changelog libanyevent-i3-perl-0.08/debian/changelog --- libanyevent-i3-perl-0.08/debian/changelog +++ libanyevent-i3-perl-0.08/debian/changelog @@ -1,3 +1,11 @@ +libanyevent-i3-perl (0.08-2) testing-proposed-updates; urgency=low + + * Backport using i3 --get-socketpath by default so that scripts do not have + to figure out the socket path on their own. That formerly required + knowledge of X11 and an X11 library dependency. + + -- Michael Stapelberg Sat, 08 Dec 2012 22:07:07 +0100 + libanyevent-i3-perl (0.08-1) unstable; urgency=low * New upstream version only in patch2: unchanged: --- libanyevent-i3-perl-0.08.orig/debian/patches/taint-mode-2.patch +++ libanyevent-i3-perl-0.08/debian/patches/taint-mode-2.patch @@ -0,0 +1,51 @@ +From a122bde5d5d3b6d61701d8286e4b21b4f047193b Mon Sep 17 00:00:00 2001 +From: Michael Stapelberg +Date: Wed, 11 Jul 2012 06:58:59 +0000 +Subject: remove relative directories from $ENV{PATH} (for taint mode) + +Otherwise, the module will die when you use it with PATH=$PATH:. (as is +the case on the OpenBSD cpan testers). +--- +diff --git a/lib/AnyEvent/I3.pm b/lib/AnyEvent/I3.pm +index 4128870..2170b26 100644 +--- a/lib/AnyEvent/I3.pm ++++ b/lib/AnyEvent/I3.pm +@@ -8,6 +8,7 @@ use AnyEvent::Handle; + use AnyEvent::Socket; + use AnyEvent; + use Encode; ++use Scalar::Util qw(tainted); + + =head1 NAME + +@@ -107,12 +108,25 @@ sub new { + my ($class, $path) = @_; + + if (!$path) { ++ 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/). +- my $paths = $ENV{PATH}; +- if ($paths =~ /^(.*)$/) { +- $ENV{PATH} = $1; ++ (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'}; +-- +cgit v0.9.0.2 only in patch2: unchanged: --- libanyevent-i3-perl-0.08.orig/debian/patches/taint-mode.patch +++ libanyevent-i3-perl-0.08/debian/patches/taint-mode.patch @@ -0,0 +1,21 @@ +From d082a57d47eb15d257c0c14de8ace10db72a5050 Mon Sep 17 00:00:00 2001 +From: Michael Stapelberg +Date: Tue, 10 Jul 2012 16:55:05 +0000 +Subject: taint mode fix for FreeBSD + +--- +diff --git a/lib/AnyEvent/I3.pm b/lib/AnyEvent/I3.pm +index 831f350..b08fdf6 100644 +--- a/lib/AnyEvent/I3.pm ++++ b/lib/AnyEvent/I3.pm +@@ -114,6 +114,8 @@ sub new { + if ($paths =~ /^(.*)$/) { + $ENV{PATH} = $1; + } ++ # Otherwise the qx() operator wont work: ++ delete @ENV{'IFS', 'CDPATH', 'ENV', 'BASH_ENV'}; + chomp($path = qx(i3 --get-socketpath)); + # Circumventing taint mode again: the socket can be anywhere on the + # system and that’s okay. +-- +cgit v0.9.0.2 only in patch2: unchanged: --- libanyevent-i3-perl-0.08.orig/debian/patches/socketpath-1.patch +++ libanyevent-i3-perl-0.08/debian/patches/socketpath-1.patch @@ -0,0 +1,87 @@ +From 79798dc40cc25379507355b67d7f88802668a75b Mon Sep 17 00:00:00 2001 +From: Michael Stapelberg +Date: Mon, 09 Jul 2012 13:49:16 +0000 +Subject: use i3 --get-socketpath by default for determining the socket path + +This was introduced in i3 v4.1 (released 2011-11-11, so should be +widespread enough by now). +--- +diff --git a/lib/AnyEvent/I3.pm b/lib/AnyEvent/I3.pm +index 398040c..3334763 100644 +--- a/lib/AnyEvent/I3.pm ++++ b/lib/AnyEvent/I3.pm +@@ -29,7 +29,7 @@ then subscribe to events or send messages and receive their replies. + + use AnyEvent::I3 qw(:all); + +- my $i3 = i3("~/.i3/ipc.sock"); ++ my $i3 = i3(); + + $i3->connect->recv or die "Error connecting"; + say "Connected to i3"; +@@ -48,8 +48,12 @@ then subscribe to events or send messages and receive their replies. + + =head2 $i3 = i3([ $path ]); + +-Creates a new C object and returns it. C is the path of +-the UNIX socket to connect to. ++Creates a new C object and returns it. ++ ++C is an optional path of the UNIX socket to connect to. It is strongly ++advised to NOT specify this unless you're absolutely sure you need it. ++C will automatically figure it out by querying the running i3 ++instance on the current DISPLAY which is almost always what you want. + + =head1 SUBROUTINES/METHODS + +@@ -91,13 +95,37 @@ sub i3 { + + =head2 $i3 = AnyEvent::I3->new([ $path ]) + +-Creates a new C object and returns it. C is the path of +-the UNIX socket to connect to. ++Creates a new C object and returns it. ++ ++C is an optional path of the UNIX socket to connect to. It is strongly ++advised to NOT specify this unless you're absolutely sure you need it. ++C will automatically figure it out by querying the running i3 ++instance on the current DISPLAY which is almost always what you want. + + =cut + sub new { + my ($class, $path) = @_; + ++ if (!$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/). ++ my $paths = $ENV{PATH}; ++ if ($paths =~ /^(.*)$/) { ++ $ENV{PATH} = $1; ++ } ++ chomp($path = qx(i3 --get-socketpath)); ++ # Circumventing taint mode again: the socket can be anywhere on the ++ # system and that’s okay. ++ if ($path =~ /^([^\0]+)$/) { ++ $path = $1; ++ } else { ++ warn "Asking i3 for the socket path failed. Is DISPLAY set and is i3 in your 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 ~ +@@ -292,7 +320,7 @@ sub _ensure_connection { + + return if defined($self->{ipchdl}); + +- $self->connect->recv or die "Unable to connect to i3" ++ $self->connect->recv or die "Unable to connect to i3 (socket path " . $self->{path} . ")"; + } + + =head2 get_workspaces +-- +cgit v0.9.0.2 only in patch2: unchanged: --- libanyevent-i3-perl-0.08.orig/lib/AnyEvent/I3.pm +++ libanyevent-i3-perl-0.08/lib/AnyEvent/I3.pm @@ -8,6 +8,7 @@ use AnyEvent::Socket; use AnyEvent; use Encode; +use Scalar::Util qw(tainted); =head1 NAME @@ -29,7 +30,7 @@ use AnyEvent::I3 qw(:all); - my $i3 = i3("~/.i3/ipc.sock"); + my $i3 = i3(); $i3->connect->recv or die "Error connecting"; say "Connected to i3"; @@ -48,8 +49,12 @@ =head2 $i3 = i3([ $path ]); -Creates a new C object and returns it. C is the path of -the UNIX socket to connect to. +Creates a new C object and returns it. + +C is an optional path of the UNIX socket to connect to. It is strongly +advised to NOT specify this unless you're absolutely sure you need it. +C will automatically figure it out by querying the running i3 +instance on the current DISPLAY which is almost always what you want. =head1 SUBROUTINES/METHODS @@ -89,13 +94,52 @@ =head2 $i3 = AnyEvent::I3->new([ $path ]) -Creates a new C object and returns it. C is the path of -the UNIX socket to connect to. +Creates a new C object and returns it. + +C is an optional path of the UNIX socket to connect to. It is strongly +advised to NOT specify this unless you're absolutely sure you need it. +C will automatically figure it out by querying the running i3 +instance on the current DISPLAY which is almost always what you want. =cut sub new { my ($class, $path) = @_; + if (!$path) { + 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($path = qx(i3 --get-socketpath)); + # Circumventing taint mode again: the socket can be anywhere on the + # system and that’s okay. + if ($path =~ /^([^\0]+)$/) { + $path = $1; + } else { + warn "Asking i3 for the socket path failed. Is DISPLAY set and is i3 in your 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 ~ @@ -289,7 +333,7 @@ return if defined($self->{ipchdl}); - $self->connect->recv or die "Unable to connect to i3" + $self->connect->recv or die "Unable to connect to i3 (socket path " . $self->{path} . ")"; } =head2 get_workspaces