dot

packages and services management
Log | Files | Refs | README

commit a1621628d8c675b232ffb9e21a07e5be8fbfeb74
parent fb2032d991dc6f4b884699a60ca271ae49befad0
Author: Josuah Demangeon <josuah.demangeon@gandi.net>
Date:   Sat,  5 Aug 2017 16:51:10 +0200

shell/bin/*: sanitize scripts

Diffstat:
Mpkg/bin/pkg-tar | 2+-
Mshell/bin/dns-used-tld | 21+++++++++++++--------
Mshell/bin/screen-brightness | 2+-
3 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/pkg/bin/pkg-tar b/pkg/bin/pkg-tar @@ -1,4 +1,4 @@ -read tar < "$PKG/$1/tar" +read tar < "$PKG/$1/tar" || exit 1 [ -e "$SRC/$1" ] && exit 1 diff --git a/shell/bin/dns-used-tld b/shell/bin/dns-used-tld @@ -1,12 +1,13 @@ -# Usage: used-tld.sh name -# # list all used TLD for a given SLD +: ${1:?Usage: ${0##*/} segond-level-domain} + + # get the list of the domains -[ -f /tmp/tlds.txt ] || +[ -f /tmp/tlds-alpha-by-domain.txt ] || wget -O- http://data.iana.org/TLD/tlds-alpha-by-domain.txt 2> /dev/null | -sed 1d > /tmp/tlds.txt +sed 1d > /tmp/tlds-alpha-by-domain.txt # remove the false positive by checking a long random domain name @@ -26,11 +27,15 @@ fi i=0 while read tld do - i=$((i + 1)) - dig -t NS "$1.$tld" | grep -q 'ANSWER: 0' || echo "$tld" & - [ "$i" = 5 ] && wait + i=$((i + 1)) + dig -t NS "$1.$tld" | awk '/^[^;]/ && $3 == "IN" { + gsub("[^.]", "", $1) + if (length($1) <= 1) exit 0 + exit 1 + }' || echo "$tld" & + [ "$i" = 5 ] && wait done << EOF -$(grep -vFf /tmp/tlds-false-positive.txt /tmp/tlds.txt) +$(grep -vFf /tmp/tlds-false-positive.txt /tmp/tlds-alpha-by-domain.txt) EOF wait diff --git a/shell/bin/screen-brightness b/shell/bin/screen-brightness @@ -1 +1 @@ -printf %s "$1" | sudo tee -a /sys/class/backlight/*/brightness +printf '%s\n' "$1" | sudo tee -a /sys/class/backlight/*/brightness