tazbug diff old/tazbug @ rev 151
Fix in users plugin (from tinycm)
author | Christophe Lincoln <pankso@slitaz.org> |
---|---|
date | Tue Feb 28 22:59:52 2017 +0100 (2017-02-28) |
parents | 3acb15d87d6e |
children |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/old/tazbug Tue Feb 28 22:59:52 2017 +0100 1.3 @@ -0,0 +1,174 @@ 1.4 +#!/bin/sh 1.5 +# 1.6 +# TazBug Command line tool. Help to encrypt password, key and post on the 1.7 +# the server side. 1.8 +# 1.9 +# Copyright (C) 2012-2014 SliTaz GNU/Linux - BSD License 1.10 +# 1.11 +. /usr/lib/slitaz/httphelper 1.12 +[ -f "/etc/slitaz/tazbug.conf" ] && . /etc/slitaz/tazbug.conf 1.13 +[ -f "tazbug.conf" ] && . tazbug.conf 1.14 + 1.15 +# Use same key for SliTaz sites. 1.16 +conf=$HOME/.config/slitaz/account.conf 1.17 + 1.18 +# Internationalization: $(gettext "") 1.19 +. /usr/bin/gettext.sh 1.20 +TEXTDOMAIN='tazbug' 1.21 +export TEXTDOMAIN 1.22 + 1.23 +# Parse cmdline options. 1.24 +for opt in "$@" 1.25 +do 1.26 + case "$opt" in 1.27 + --bug=*) 1.28 + bug="${opt#--bug=}" ;; 1.29 + --desc=*) 1.30 + desc="${opt#--desc=}" ;; 1.31 + --msg=*) 1.32 + msg="${opt#--msg=}" ;; 1.33 + --priority=*) 1.34 + priority=${opt#--priority=} ;; 1.35 + --pkgs=*) 1.36 + pkgs="${opt#--pkgs=}" ;; 1.37 + --name=*) 1.38 + name="${opt#--name=}" ;; 1.39 + --user=*) 1.40 + user=${opt#--user=} ;; 1.41 + --mail=*) 1.42 + mail=${opt#--mail=} ;; 1.43 + --pass=*) 1.44 + pass=${opt#--pass=} ;; 1.45 + esac 1.46 +done 1.47 + 1.48 +# 1.49 +# Functions 1.50 +# 1.51 + 1.52 +# --> in /usr/lib/slitaz/httphelper 1.53 +# httpd -e dont work with GET URL requests 1.54 +http_urlencode() { 1.55 + #space: + or %20 1.56 + sed -e 's/ /+/g; s/!/%21/g; s/"/%22/g; s/#/%23/g; s/%/%25/g; s/&/%26/g' 1.57 +} 1.58 + 1.59 +# Usage. 1.60 +usage() { 1.61 + cat << EOT 1.62 + 1.63 +$(gettext 'Usage:') $(basename $0) $(gettext '[command] [args]') 1.64 + 1.65 +$(gettext 'Commands:') 1.66 + gen-key $(gettext "Recreate the SliTaz secure key.") 1.67 + gen-config $(gettext "Create a new SliTaz account configuration.") 1.68 + signup $(gettext "Create a new account on SliTaz Bugs.") 1.69 + new-msg $(gettext "Send a new message to an open bug.") 1.70 + new-bug $(gettext "Send a new bug report.") 1.71 + 1.72 +$(gettext 'Examples:') 1.73 + $(basename $0) signup --name="Real Name" --user=login \\ 1.74 + --mail=mail@domain --pass=password 1.75 + $(basename $0) new-msg --bug=0 --msg="Message for bug with ID 0" 1.76 + 1.77 +EOT 1.78 +} 1.79 + 1.80 +# Check cmdline user info args 1.81 +check_info_args() { 1.82 + [ ! "$name" ] && gettext "Missing real name" && echo && exit 0 1.83 + [ ! "$user" ] && gettext "Missing login name" && echo && exit 0 1.84 + [ ! "$mail" ] && gettext "Missing email" && echo && exit 0 1.85 + [ ! "$pass" ] && gettext "Missing password" && echo && exit 0 1.86 +} 1.87 + 1.88 +# Crypt pass when login 1.89 +crypt_pass() { 1.90 + echo -n "$1" | md5sum | awk '{print $1}' 1.91 +} 1.92 + 1.93 +# Gen a config file 1.94 +gen_config() { 1.95 + gettext "Creating SliTaz account configuration..."; echo 1.96 + mkdir -p $HOME/.config/slitaz 1.97 + cat > $conf << EOT 1.98 +# SliTaz account configuration 1.99 + 1.100 +NAME="$name" 1.101 +USER="$user" 1.102 +MAIL="$mail" 1.103 +KEY="" 1.104 +EOT 1.105 + chmod 0600 $conf 1.106 +} 1.107 + 1.108 +# Gen the secure key: gen_key login mail passwd 1.109 +gen_key() { 1.110 + gettext "Creating SliTaz secure key..."; echo 1.111 + key=$(echo -n "$user:$mail:$pass" | md5sum | awk '{print $1}') 1.112 + sed -i s"/KEY=.*/KEY=\"$key\"/" $conf 1.113 + chmod 0600 $conf 1.114 +} 1.115 + 1.116 +# 1.117 +# Commands 1.118 +# 1.119 + 1.120 +case "$1" in 1.121 + gen-key) 1.122 + # MD5 key 1.123 + [ ! "$pass" ] && gettext "Missing password" && echo && exit 0 1.124 + . $conf || exit 1 1.125 + gen_key $USER $MAIL $pass ;; 1.126 + gen-config) 1.127 + # Recreate a config file if values have changed sites must be updated 1.128 + check_info_args 1.129 + gen_config 1.130 + gen_key ;; 1.131 + signup) 1.132 + # Create an account on the server 1.133 + check_info_args 1.134 + echo "" 1.135 + echo "Sending account request for: $name ($user)" 1.136 + # 'gen_key user:mail:passwd' locally but don't send it. It will be 1.137 + # generated on server from the user login, mail and encrypted password 1.138 + # so it is not transmited in GET urls. 1.139 + gen_config 1.140 + pass=$(crypt_pass $pass) 1.141 + name="$(echo $name | http_urlencode)" 1.142 + gen_key 1.143 + . $conf 1.144 + echo "Secure key: $KEY" 1.145 + # Wget GET url 1.146 + busybox wget "${WEB_URL}?signup=$user&name=$name&mail=$mail&pass=$pass" \ 1.147 + -O /tmp/bug.msg 1.148 + cat /tmp/bug.msg && rm -f /tmp/bug.msg && echo "" ;; 1.149 + new-msg) 1.150 + # Post a new message: ID message 1.151 + . $conf || exit 1 1.152 + [ ! "$bug" ] && gettext "Missing bug ID" && echo && exit 0 1.153 + [ ! "$msg" ] && gettext "Missing message" && echo && exit 0 1.154 + msg="$(echo $msg | http_urlencode)" 1.155 + # Wget GET url 1.156 + busybox wget \ 1.157 + "${WEB_URL}?key=$KEY&bug=$bug&msg=$msg" -O /tmp/bug.msg 1.158 + cat /tmp/bug.msg && rm -f /tmp/bug.msg && echo "" ;; 1.159 + new-bug) 1.160 + # Post a new bug: bug desc priority pkgs 1.161 + . $conf || exit 1 1.162 + [ ! "$bug" ] && gettext "Missing bug title" && echo && exit 0 1.163 + [ ! "$desc" ] && gettext "Missing description" && echo && exit 0 1.164 + [ ! "$priority" ] && gettext "Missing bug priority" && echo && exit 0 1.165 + bug="$(echo $bug | http_urlencode)" 1.166 + desc="$(echo $desc | http_urlencode)" 1.167 + releases="$(basename $(cat /var/lib/tazpkg/mirror))" 1.168 + # Wget GET url 1.169 + busybox wget \ 1.170 + "${WEB_URL}?key=$KEY&bug=$bug&desc=$desc&priority=$priority&pkgs=$pkgs&releases=$releases" \ 1.171 + -O /tmp/bug.msg 1.172 + cat /tmp/bug.msg && rm -f /tmp/bug.msg && echo "" ;; 1.173 + *) 1.174 + usage ;; 1.175 +esac 1.176 + 1.177 +exit 0