Better random generation

This commit is contained in:
southerntofu 2020-04-28 12:56:35 +02:00
parent db720258ac
commit cca442aa2a
1 changed files with 17 additions and 1 deletions

View File

@ -25,6 +25,22 @@ help_cmd() {
}
list_cmd() {
# If we receive a repo argument, we print the subscribers to it
if [ $# -gt 0 ]; then
r="$1"
rhex="$(from_url "$r")"
if [ ! -f $db/."$rhex".secret ]; then
# Repository not found
exit 1
fi
for u in "$db"/"$rhex".*; do
# For each subscriber, print the username
u="$(basename "$u")"
u="${u#$rhex.}"
echo "$u"
done
exit 0
fi
for f in "$db"/*."$user"; do
rhex="$(basename "$f" ".$user")"
r="$(from_hex "$rhex")"
@ -90,7 +106,7 @@ add_cmd() {
fi
touch $db/owned-by/"$user"/"$rhex"
if [ -z ${2+NULL} ]; then
secret="$(hexdump -n 32 -e ' /1 "%02x"' /dev/urandom)"
secret="$(tr -dc _A-Z-a-z-0-9 < /dev/urandom | head -c32)"
else
secret="$2"
fi