diff options
author | Jakub Jankowski <shasta@toxcorp.com> | 2017-11-21 03:57:16 +0100 |
---|---|---|
committer | Robby Workman <rworkman@slackware.com> | 2017-11-21 00:07:59 -0600 |
commit | d0c9d92192a208a4f76ffd7a9e2a580a48698c50 (patch) | |
tree | cc2219a183a2374da1c5910cde6e31a4e88cef57 /.gitignore | |
parent | 96cba49d10f8cd7c50bd20b21203fd6277ea3257 (diff) | |
download | slacknetsetup-d0c9d92192a208a4f76ffd7a9e2a580a48698c50.tar.xz |
rc.inet1: Check for iface in /sys/class/net, not /proc/net/dev
There is a slight problem with things like
grep lo: /proc/net/dev
especially with tun/tap devices with can have arbitrary names.
Consider a scenario where you name your tap iface "trololo":
$ grep -c lo: /proc/net/dev
2
$
To fix this (quite hypothetical, but still) problem, instead
of simple grepping in /proc/net/dev, check of sysfs path
existence (/sys/class/net/<interface>).
Same fix in if_up() and if_down() for non-loopback interfaces.
While there, also strip colon-whatever from interface name
(what I think was the original idea behind a construct like
grep $(echo ${1}: | cut -f 1 -d :): /proc/net/dev) by using
parameter expansion: ${1%%:*} will remove the longest suffix
matching ":*", ie. colon-and-everything-after.
This is supported by POSIX:
http://pubs.opengroup.org/onlinepubs/009695399/utilities/xcu_chap02.html
Alternative solution would be to change the grep pattern to
grep '^ *lo:' /proc/net/dev
Signed-off-by: Robby Workman <rworkman@slackware.com>
Diffstat (limited to '.gitignore')
0 files changed, 0 insertions, 0 deletions