Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!

Bug 387001

Summary: net-proxy/tsocks segfaults if /etc/tsocks/tsocks.conf does not exist
Product: Gentoo Linux Reporter: Longpoke <longpoke>
Component: Current packagesAssignee: Andrew Savchenko <bircoph>
Status: RESOLVED FIXED    
Severity: normal CC: bircoph, mjo
Priority: Normal Keywords: NeedPatch
Version: unspecified   
Hardware: All   
OS: Linux   
Whiteboard:
Package list:
Runtime testing required: ---

Description Longpoke 2011-10-13 01:22:56 UTC
$ tsocks poo
/usr/bin/tsocks: line 84: exec: poo: not found
$ tsocks id
13:33:37 (4413): Could not open socks configuration file (/etc/socks/tsocks.conf), assuming all networks local
Segmentation fault


Reproducible: Always
Comment 1 Longpoke 2011-10-13 01:24:27 UTC
forgot version:
net-proxy/tsocks-1.8_beta5-r5:0

also, tordns useflag is set
Comment 2 Michael Orlitzky gentoo-dev 2011-10-13 01:32:37 UTC
Confirmed:

  $ TSOCKS_CONFFILE="~/aint-here.conf" tsocks true
21:29:35 (15133): Could not open socks configuration file (/etc/socks/tsocks.conf), assuming all networks local
  Segmentation fault

If we touch the default conf file,

  $ sudo touch /etc/socks/tsocks.conf

the warning goes away but the segfault stays:

  $ TSOCKS_CONFFILE="~/aint-here.conf" tsocks true
  Segmentation fault
Comment 3 Diego Augusto Molina 2011-10-16 15:05:02 UTC
Have you tried talking upstream?
Comment 4 Jeroen Roovers (RETIRED) gentoo-dev 2011-10-18 16:36:02 UTC
We could just install tsocks.conf.simple.example or indeed an empty file, but it also looks like it segfaults /after/ that, not because of it, so I would assume that instead, it segfaults because a certain runtime configuration variable is not set.
Comment 5 Andrew Savchenko gentoo-dev 2015-01-09 04:56:26 UTC
Strage, tsocks segfault without config file is not reproducible on all setups, only on some of them...
Comment 6 Andrew Savchenko gentoo-dev 2015-01-09 05:02:16 UTC
(In reply to Andrew Savchenko from comment #5)
> Strage, tsocks segfault without config file is not reproducible on all
> setups, only on some of them...

Oh, this happens only with USE="-tordns".
Comment 7 Andrew Savchenko gentoo-dev 2015-01-09 05:07:40 UTC
(In reply to Andrew Savchenko from comment #6)
> (In reply to Andrew Savchenko from comment #5)
> > Strage, tsocks segfault without config file is not reproducible on all
> > setups, only on some of them...
> 
> Oh, this happens only with USE="-tordns".

And even in this case it works here:
libtsocks(32341): Could not open socks configuration file (/etc/socks/tsocks.conf), assuming all networks local
Comment 8 Andrew Savchenko gentoo-dev 2015-01-09 06:06:08 UTC
Yup, this is tordns patch flow:
it requires server data to setup pool early (at _init stage):

Program terminated with signal SIGSEGV, Segmentation fault.
#0  0xb69c43c8 in inet_aton () from /lib/libc.so.6
(gdb) bt
#0  0xb69c43c8 in inet_aton () from /lib/libc.so.6
#1  0xb7760339 in init_pool (pool_size=pool_size@entry=256, deadrange_base=..., deadrange_mask=..., sockshost=0x0, socksport=0) at dead_pool.c:84
#2  0xb775d763 in deadpool_init () at tsocks.c:1309
#3  _init () at tsocks.c:165
#4  0xb77c30b2 in call_init.part () from /lib/ld-linux.so.2
#5  0xb77c31e2 in _dl_init_internal () from /lib/ld-linux.so.2
#6  0xb77b501f in _dl_start_user () from /lib/ld-linux.so.2

The only thing I can do here is to bail out before init_pool call if serever data is wrong.

Though with torsocks in tree does anyone needs this patch anyway?
Comment 9 Andrew Savchenko gentoo-dev 2015-01-09 06:53:37 UTC
Fix is ready, will be in -r7 (other changes are pending revbump now).
Comment 10 Andrew Savchenko gentoo-dev 2015-01-09 17:05:20 UTC
Fixed in tsocks-1.8_beta5-r7.

Now if SOCKS server is not properly configured, tordns is being disabled with the following message:

20:04:37 (2319): Could not open socks configuration file (/etc/socks tsocks.conf), assuming all networks local
20:04:37 (2319): SOCKS server or port is not provided, edit your config file to fix
20:04:37 (2319): failed to initialize deadpool: tordns disabled