Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 29869 - mirrorselect 0.82 will truncate config files
Summary: mirrorselect 0.82 will truncate config files
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: High major (vote)
Assignee: John Mylchreest (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2003-09-28 22:14 UTC by evanm
Modified: 2003-09-30 08:31 UTC (History)
0 users

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description evanm 2003-09-28 22:14:15 UTC
When running mirrorselect and redirecting stdout, mirrorselect will truncate the file that it's directed to. The error is in using /dev/std* for io redirection, as the symlinks to /proc/self/fd/* symlink directly to the file that i/o hasbeen redirected to, and mirrorselect will echo with a >, which will always clobber the file. 

When used as per the install instructions, mirrorselect will destroy /etc/make.conf!

A patch for this (untested) is located here: http://frap.net/stuff/mirrorselect.patch

A log detailing the problem in action follows:

scale root # echo what >test
scale root # cat test
what
scale root # mirrorselect -a -s1 -o >> test
Downloading a list of mirrors...
Removing IPV6 Only Servers...
Running netselect to determine mirrors, this might take a moment...
netselect: unknown host mirror.iawnet.sandia.gov
netselect: unknown host mirrors.sec.informatik.tu-darmstadt.de
scale root # cat test
GENTOO_MIRRORS="ftp://gentoo.ccccom.com"
scale root # echo what >test
scale root # cat test
what
scale root # ./mirrorselect.fixed -a -s1 -o >> test
Downloading a list of mirrors...
Removing IPV6 Only Servers...
Running netselect to determine mirrors, this might take a moment...
netselect: unknown host mirror.iawnet.sandia.gov
scale root # cat test
what
GENTOO_MIRRORS="http://mirrors.tds.net/gentoo"
scale root # diff `which mirrorselect` mirrorselect.fixed
296c296
<               echo "${PATTERN}=\"${MIRRORS}\"" > /dev/stdout
---
>               echo "${PATTERN}=\"${MIRRORS}\"" # > /dev/stdout


/dev/std* must not be used in this manner!
Comment 1 John Mylchreest (RETIRED) gentoo-dev 2003-09-29 00:24:41 UTC
I have not modified mirrorselect for this test but...

# echo what > test
# mirrorselect -a -s15 -o >> test
Downloading a list of mirrors...
Removing IPV6 Only Servers...
Running netselect to determine mirrors, this might take a moment...
VHOST entries have been removed. This list might be shorter than expected
root@johnm johnm # cat test
what
GENTOO_MIRRORS="http://www.mirror.ac.uk/sites/www.ibiblio.org/gentoo/ ftp://ftp.easynet.nl/mirror/gentoo/"

Do you results differ from this then?
Comment 2 evanm 2003-09-29 00:40:29 UTC
Yes, my results differ, and I've tested this on several machines. Are you
using version 0.82?
Comment 3 John Mylchreest (RETIRED) gentoo-dev 2003-09-29 08:55:58 UTC
yes i am.
# mirrorselect -v
Mirrorselect version: 0.82

Could you please remove the file from distfiles and try again.
Comment 4 evanm 2003-09-29 11:56:04 UTC
I removed /usr/sbin/mirrorselect, /var/tmp/portage/mirrorselect-0.82/ and
/usr/portage/distfiles/mirrorselect-0.82.tbz2, and then emerged it again.
I'm still having the same problem.

48e84253f50bdf970e889a0c7f398f32  /usr/sbin/mirrorselect

It's evident what the bug is. It can be re-created with this simple shell
script:

#!/bin/bash
ls -l /proc/self/fd/1 >&2
echo truncate > /dev/stdout

Ran like so:

scale root # echo data>test; ./iobug.sh >>test; cat test
lrwx------    1 root     root           64 Sep 29 11:57 /proc/self/fd/1 ->
/dev/pts/7
truncated

Any usage of /dev/std* symlinks will create this behavior.
Comment 5 John Mylchreest (RETIRED) gentoo-dev 2003-09-29 12:59:47 UTC
mirrorselect-0.82-r1 was just commited, with the new tarball propogating
shortly.
I have ammended it to redirect the same way you did in your patch, and i
have tested here.

The results i got with both versions are identical, however hopefully you
now should get the same results as myself.

Please test and report back, and then i shall close this bug.
Comment 6 evanm 2003-09-29 17:31:40 UTC
Works as expected now, thanks!

Comment 7 John Mylchreest (RETIRED) gentoo-dev 2003-09-30 08:31:20 UTC
fixed