pkgsrc-WIP-changes archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

torsocks: More adjustments/backporting for bin/torsocks.in



Module Name:	pkgsrc-wip
Committed By:	Leonardo Taccari <leot%NetBSD.org@localhost>
Pushed By:	leot
Date:		Tue Jan 30 21:09:19 2018 +0100
Changeset:	32eebb209803adf10f07cf57f7d256c5514c098e

Modified Files:
	torsocks/TODO
	torsocks/distinfo
	torsocks/patches/patch-src_bin_torsocks.in

Log Message:
torsocks: More adjustments/backporting for bin/torsocks.in

- Add a reference to upstream commit regarding getcap(1) usage and delete the
  TODO entry regarding it (yes, on some platforms the getcap(1) usage in such
  ways is not correct).
- Backport a patch from upstream to properly quote variables

To see a diff of this commit:
https://wip.pkgsrc.org/cgi-bin/gitweb.cgi?p=pkgsrc-wip.git;a=commitdiff;h=32eebb209803adf10f07cf57f7d256c5514c098e

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

diffstat:
 torsocks/TODO                              |   2 -
 torsocks/distinfo                          |   2 +-
 torsocks/patches/patch-src_bin_torsocks.in | 129 +++++++++++++++++++++++++++--
 3 files changed, 123 insertions(+), 10 deletions(-)

diffs:
diff --git a/torsocks/TODO b/torsocks/TODO
index fba0110ad1..2234beb1c7 100644
--- a/torsocks/TODO
+++ b/torsocks/TODO
@@ -1,5 +1,3 @@
-- Figure out getcap(1) usage in src/bin/torsocks.in, at least on NetBSD isn't
-  kosher to call `getcap /usr/bin/foo'
 - Is LIBC_PATH usage via CONFIGURE_ARGS correct, needed and portable?
 - Adjust any possible hardcoded path in man pages
 - Test it via net/tor torify(1)
diff --git a/torsocks/distinfo b/torsocks/distinfo
index d7280f35a8..8d4d3691a6 100644
--- a/torsocks/distinfo
+++ b/torsocks/distinfo
@@ -4,4 +4,4 @@ SHA1 (torsocks_2.2.0.orig.tar.xz) = 53d8cb45b487571d39ab226e25cb538976a195a1
 RMD160 (torsocks_2.2.0.orig.tar.xz) = a16adc2120da9c846d4801ece60a43758a25f2e6
 SHA512 (torsocks_2.2.0.orig.tar.xz) = 89eb1263bfb0079ca5cb7fcc3a6fa1ecde1327df9ea98de48babfff1f8947b1e9db8407ead747fef0190671e7fff502025dcfcd9b6cba97abbaf25b5a575c62a
 Size (torsocks_2.2.0.orig.tar.xz) = 309916 bytes
-SHA1 (patch-src_bin_torsocks.in) = bee6e0266b7ff1bedccb5ecb3879915b48acb7c1
+SHA1 (patch-src_bin_torsocks.in) = c4129716ee6cf0d5b31e9dd66a8fc67b9bb15168
diff --git a/torsocks/patches/patch-src_bin_torsocks.in b/torsocks/patches/patch-src_bin_torsocks.in
index 0dd323c9c8..a0288c83aa 100644
--- a/torsocks/patches/patch-src_bin_torsocks.in
+++ b/torsocks/patches/patch-src_bin_torsocks.in
@@ -1,18 +1,133 @@
 $NetBSD$
 
-Discard stderr when invoking getcap(1).
+- Add missing quotes to variable in torsocks.in.
+  From upstream commit 5a5b72fa0aef2315c369cedc5f448ee473be5e4f.
+- Discard stderr when invoking getcap(1).
+  Not all platforms support it.
+  Also present in upstream commit 6228eabd72eda576403bf6f199881a6d39c1148e.
 
-XXX: At least on NetBSD `getcap' should be invoked against databases, not
-XXX: arbitrary paths.
-
---- src/bin/torsocks.in.orig	2016-10-16 21:11:33.000000000 +0000
+--- src/bin/torsocks.in.orig	2018-01-30 12:14:16.600824876 +0000
 +++ src/bin/torsocks.in
-@@ -144,7 +144,7 @@ torify_app ()
+@@ -73,7 +73,7 @@ set_ld_preload ()
+ 	if [ -z "$@LDPRELOAD@" ]; then
+ 		export @LDPRELOAD@="${SHLIB}"
+ 	else
+-		echo $@LDPRELOAD@ | grep -q "${SHLIB}" || \
++		echo "$@LDPRELOAD@" | grep -q "${SHLIB}" || \
+ 			export @LDPRELOAD@="${SHLIB} $@LDPRELOAD@"
+ 	fi
+ 
+@@ -130,13 +130,13 @@ tor_shell ()
+ 
+ torify_app ()
+ {
+-	local app_path=`which $1`
+-	local getcap=`PATH="$PATH:/usr/sbin:/sbin" which getcap`
++	local app_path="`which $1`"
++	local getcap="`PATH="$PATH:/usr/sbin:/sbin" which getcap`"
+ 	local caps=
+ 
+-	if [ -z $1 ]; then
++	if [ -z "$1" ]; then
+ 		echo "Please provide an application to torify." >&2
+-	elif [ -z $app_path ]; then
++	elif [ -z "$app_path" ]; then
+ 		echo "ERROR: $1 cannot be found." >&2
+ 		exit 1
+ 	fi
+@@ -144,20 +144,20 @@ torify_app ()
  	# This must be before torifying because getcap uses cap_get_file(3)
  	# via syscall(2) which breaks torsocks.
  	if [ -n "$getcap" ]; then
 -		caps=`$getcap $app_path`
-+		caps=`$getcap $app_path 2>/dev/null`
++		caps="`$getcap $app_path 2>/dev/null`"
  	fi
  
  	# Check if Apple's System Integrity Protection is enabled if the user is
+ 	# running on macOS.
+-	macos_sip_check $app_path
++	macos_sip_check "$app_path"
+ 
+ 	# NEVER remove that line or else nothing it torified.
+ 	set_ld_preload
+ 
+-	if [ -u $app_path ]; then
++	if [ -u "$app_path" ]; then
+ 		echo "ERROR: $1 is setuid. torsocks will not work on a setuid executable." >&2
+ 		exit 1
+-	elif [ -g $app_path ]; then
++	elif [ -g "$app_path" ]; then
+ 		echo "ERROR: $1 is setgid. torsocks will not work on a setgid executable." >&2
+ 		exit 1
+ 	elif [ -n "$caps" ]; then
+@@ -219,7 +219,7 @@ if [ $# -eq 0 ] ; then
+ fi
+ 
+ # Ensure libtorsocks exists,
+-if [ ! -f $SHLIB ]; then
++if [ ! -f "$SHLIB" ]; then
+    echo "$0: $SHLIB does not exist! Try re-installing torsocks."
+    exit
+ fi
+@@ -228,14 +228,14 @@ while true;
+ do
+ 	case "$1" in
+ 		on)
+-			check_script_sourced $1
++			check_script_sourced "$1"
+ 			set_ld_preload
+ 			echo "Tor mode activated. Every command will be torified for this shell."
+ 			break
+ 			;;
+ 		off)
+-			check_script_sourced $1
+-			export @LDPRELOAD@=`echo -n $@LDPRELOAD@ | sed "s#$SHLIB *##"`
++			check_script_sourced "$1"
++			export @LDPRELOAD@="`echo -n $@LDPRELOAD@ | sed "s#$SHLIB *##"`"
+ 			if [ -z "$@LDPRELOAD@" ]; then
+ 				unset @LDPRELOAD@
+ 				case "$OSTYPE" in
+@@ -256,35 +256,35 @@ do
+ 			break
+ 			;;
+ 		-u|--user)
+-			if [ -z $2 ]; then
++			if [ -z "$2" ]; then
+ 				echo "Missing username to -u" >&2
+ 				exit 1
+ 			fi
+-			export TORSOCKS_USERNAME=$2
++			export TORSOCKS_USERNAME="$2"
+ 			shift
+ 			;;
+ 		-p|--pass)
+-			if [ -z $2 ]; then
++			if [ -z "$2" ]; then
+ 				echo "Missing password to -p" >&2
+ 				exit 1
+ 			fi
+-			export TORSOCKS_PASSWORD=$2
++			export TORSOCKS_PASSWORD="$2"
+ 			shift
+ 			;;
+ 		-a|--address)
+-			if [ -z $2 ]; then
++			if [ -z "$2" ]; then
+ 				echo "Missing address to -a" >&2
+ 				exit 1
+ 			fi
+-			export TORSOCKS_TOR_ADDRESS=$2
++			export TORSOCKS_TOR_ADDRESS="$2"
+ 			shift
+ 			;;
+ 		-P|--port)
+-			if [ -z $2 ]; then
++			if [ -z "$2" ]; then
+ 				echo "Missing port to -P" >&2
+ 				exit 1
+ 			fi
+-			export TORSOCKS_TOR_PORT=$2
++			export TORSOCKS_TOR_PORT="$2"
+ 			shift
+ 			;;
+ 		-i|--isolate)


Home | Main Index | Thread Index | Old Index