Netdot
Netdot copied to clipboard
Can not download MIBs with non English locale
Hello,
installing netdot by make apt-install
results in error when running on English locale
# make apt-install
.
.
.
We will install the MIB files now. Continue? [y/n] y
Downloading necessary SNMP MIB files. This may take a few minutes.
Downloaded ok, please now run netdisco-mibs-install.
Installing SNMP MIB files
/usr/sbin/netdisco-mibs-install: error: Should be writable only by root: /tmp/netdisco-mibs
There was a problem running /usr/sbin/netdisco-mibs-install
Makefile:81: návod pro cíl „apt-install“ selhal
make: *** [apt-install] Chyba 25
Do you have the right permissions on /tmp
?
# ls -ld /tmp
drwxrwxrwt 12 root root 12288 Feb 9 12:53 /tmp
(note the 't'; this is mode 1777). If that's correct, try rm -rf /tmp/netdisco-mibs
in case this directory was already created, and then retry.
Permission are OK, netdisco-mibs-install
needs only write permissions
# ls -ld /tmp/netdisco-mibs
drwxr-xr-x 2 root root 60 úno 9 13:20 /tmp/netdisco-mibs
The problem is stat
application used by netdisco-mibs-install
They do this
if ! stat $BASEDIR|grep '^Access:.*drwx.-..-.'>/dev/null; then
echo >&2 "$0: error: Should be writable only by root: $BASEDIR"
exit 3
fi
This is output of stat
with LANG=cs_CZ.UTF-8
# LANG=cs_CZ.UTF-8 stat /tmp/netdisco-mibs
Soubor: '/tmp/netdisco-mibs'
Velikost: 60 Bloků: 0 I/O blok: 4096 adresář
Zařízení: 26h/38d I-uzel: 19 Odkazů: 2
Práva: (0755/drwxr-xr-x) UID: ( 0/ root) GID: ( 0/ root)
Přístup: 2018-02-09 13:41:28.665381394 +0100
Změna obsahu: 2018-02-09 13:41:37.997381616 +0100
Změna i-uzlu: 2018-02-09 13:41:37.997381616 +0100
Vznik: -
as you can see there is nohing to be found by grep '^Access:.*drwx.-..-.
Output with LANG=C
is another case
# LANG=C stat /tmp/netdisco-mibs
File: '/tmp/netdisco-mibs'
Size: 60 Blocks: 0 IO Block: 4096 directory
Device: 26h/38d Inode: 19 Links: 2
Access: (0755/drwxr-xr-x) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2018-02-09 13:41:28.665381394 +0100
Modify: 2018-02-09 13:41:37.997381616 +0100
Change: 2018-02-09 13:41:37.997381616 +0100
Birth: -
This is parsable by grep '^Access:.*drwx.-..-.'
and works for netdisco-mibs-install
The problem is stat application used by netdisco-mibs-install
They do this...
Oh, yukkety yuk! They could at least have used stat --format %A /tmp/netdisco-mibs
Anyway, now I understand why your workaround is needed. Thanks.
Yes, more common bash
construct works the same way
cd /tmp
mkdir qqq bbb
chmod 555 qqq
chmod 755 bbb
for i in qqq bbb
do
echo -n "Directory $i "
if [ -d "$i" -a -w "$i" ]
then
echo "- writable"
else
echo "- non writable"
fi
done
The trouble with test -w ...
(or bash [ -w ... ]
) is that it just says if it's writeable by you. The netdisco code was trying to check if it was writeable by anyone else.
IMHO I read this from netdisco-mibs-install
stat $BASEDIR|grep '^Access:.*drwx.-..-.'>/dev/null
And it looks for me like they do not care about group or others permissions
That line checks that the "group write" and "other write" flags are both "-" (dash), i.e. disabled. The dots match any character in the other positions, meaning they don't care about group/other read/execute.
In long-hand:
"Access:" <zero-or-more-any> "drwx" <any-single-char> "-" <any-single-char> <any-single-char> "-" <any-single-char>