Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 533888 - net-misc/minissdpd-1.3 - /etc/init.dminissdpd expects old ifconfig output style
Summary: net-misc/minissdpd-1.3 - /etc/init.dminissdpd expects old ifconfig output style
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Anthony Basile
URL:
Whiteboard:
Keywords: PATCH
Depends on:
Blocks:
 
Reported: 2014-12-29 05:22 UTC by Christohper Harrington
Modified: 2015-01-04 16:10 UTC (History)
0 users

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


Attachments
Update minissdpd init script to detect interfaces correctly (file_533888.txt,2.64 KB, patch)
2014-12-29 05:43 UTC, Christohper Harrington
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Christohper Harrington 2014-12-29 05:22:38 UTC
The init script for minissdpd depends on the output formatting of ifconfig. As a result, minissdpd will not start unless the user has sys-apps/net-tools merged with old-output enabled.

The script also assumes that (unless configured otherwise) you want the interface with a default router attached, which is simply wrong in the general case.

Patch forthcoming.

Reproducible: Always

Steps to Reproduce:
1. USE="-old-output" emerge net-tools minissdpd
2. /etc/init.d/minissdpd start
Comment 1 Christohper Harrington 2014-12-29 05:43:09 UTC
Created attachment 392614 [details, diff]
Update minissdpd init script to detect interfaces correctly

1. The minissdpd -i argument accepts either an interface OR an IP address, so it isn't neccessary for us to divine the IP before adding it to ARGS; we already have the interface. Pass the interface instead.
2. The invocation of ifconfig | grep | awk is counting on deprecated output formatting from ifconfig, and further that output isn't designed to be machine-parsable. The script is already breaking on output from ifconfig if not merged with the USE flag old-output. Instead, read /sys/class/net/[interface]/flags to determine the state of the interface.
3. The script again counts on the output format of route, which isn't designed to be machine-parsable. It also invokes route without the -n parameter, which may involve a reverse-DNS hit. Instead, parse /proc/net/route.
4. By default, the script will only configure one interface unless configured otherwise. The user may have two or more interfaces attached to their computer, especially possible in gateway scenarios. Instead, scan the local interface routes for local subnets, and match them against private subnet prefixes.
Comment 2 Anthony Basile gentoo-dev 2014-12-29 14:42:09 UTC
I thought I'd fixed this in bug #522562.  See http://sources.gentoo.org/cgi-bin/viewvc.cgi/gentoo-x86/net-misc/minissdpd/files/minissdpd.initd-r1?r1=1.3&r2=1.4

Anyhow, your solution avoids ifconfig and route so I like it.  Why not just remove checkconfig() rather than nop it?
Comment 3 Christohper Harrington 2014-12-29 14:46:36 UTC
(In reply to Anthony Basile from comment #2)
> Anyhow, your solution avoids ifconfig and route so I like it.
Thanks!

> Why not just remove checkconfig() rather than nop it?
It seems convention to have a checkconfig() function, and there should likely be a way to enable ipv6 to the configuration file (passing -6 to minissdpd) down the road, which might need some sanity check from the init script, like whether ipv6 functionality is enabled in the kernel.

checkconfig() may also be a good place to actually make sure /proc and /sys are really mounted.

That said, of course, I'm not married to it.
Comment 4 Anthony Basile gentoo-dev 2014-12-30 13:24:05 UTC
(In reply to Christohper Harrington from comment #3)
> (In reply to Anthony Basile from comment #2)
> > Anyhow, your solution avoids ifconfig and route so I like it.
> Thanks!
> 
> > Why not just remove checkconfig() rather than nop it?
> It seems convention to have a checkconfig() function, and there should
> likely be a way to enable ipv6 to the configuration file (passing -6 to
> minissdpd) down the road, which might need some sanity check from the init
> script, like whether ipv6 functionality is enabled in the kernel.
> 
> checkconfig() may also be a good place to actually make sure /proc and /sys
> are really mounted.
> 
> That said, of course, I'm not married to it.

I dropped checkconfig() in the commit.  I see your point about a stub but its not necessary.

Please test minissdpd-1.3-r1.ebuild.  If it works for you I'll drop the older versions.  Thanks for taking the time to think about this.  You might want to pass a note upstream since it avoids ifconfig/route.  Upstream uses that approach and my init script just mimicked it.  The irony is, how do you think ifconfig/route work anyhow :)
Comment 5 Christohper Harrington 2015-01-04 16:10:59 UTC
Tested. Thank you!