Browse Source

Use bcrypt

Bob Mottram 8 years ago
parent
commit
ef4dd4fa38
1 changed files with 9 additions and 6 deletions
  1. 9
    6
      src/freedombone-app-radicale

+ 9
- 6
src/freedombone-app-radicale View File

@@ -49,7 +49,7 @@ radicale_variables=(ONION_ONLY
49 49
 function remove_user_radicale {
50 50
     remove_username="$1"
51 51
     if grep "$remove_username:" ${RADICALE_DIRECTORY}/users; then
52
-        sed -i "/$remove_username/d" ${RADICALE_DIRECTORY}/users
52
+        sed -i "/$remove_username:/d" ${RADICALE_DIRECTORY}/users
53 53
         systemctl reload radicale
54 54
     fi
55 55
 }
@@ -57,10 +57,13 @@ function remove_user_radicale {
57 57
 function add_user_radicale {
58 58
     new_username="$1"
59 59
     new_user_password="$2"
60
-    new_user_hash=$(echo -n "$new_user_password" | sha1sum | awk -F ' ' '{print $1}')
61 60
 
62
-    if ! grep "$new_username:$new_user_hash" ${RADICALE_DIRECTORY}/users; then
63
-        printf "$new_username:$new_user_hash\n" >> ${RADICALE_DIRECTORY}/users
61
+    if [ ! -f ${RADICALE_DIRECTORY}/users ]; then
62
+        touch ${RADICALE_DIRECTORY}/users
63
+    fi
64
+
65
+    if ! grep "$new_username:" ${RADICALE_DIRECTORY}/users; then
66
+        htpasswd -Bb ${RADICALE_DIRECTORY}/users "$new_username" "$new_user_password"
64 67
         systemctl reload radicale
65 68
     fi
66 69
     echo '0'
@@ -207,7 +210,7 @@ function install_radicale {
207 210
     fi
208 211
     chown -R www-data:www-data /var/log/radicale
209 212
 
210
-    apt-get -yq install python-radicale uwsgi uwsgi-plugin-python radicale
213
+    apt-get -yq install python-radicale uwsgi uwsgi-plugin-python radicale apache2-utils
211 214
 
212 215
     if [ ! -d ${RADICALE_DIRECTORY} ]; then
213 216
         echo $"ERROR: radicale does not appear to have installed"
@@ -226,7 +229,7 @@ function install_radicale {
226 229
     echo '[auth]' >  ${RADICALE_DIRECTORY}/config
227 230
     echo 'type = htpasswd' >> ${RADICALE_DIRECTORY}/config
228 231
     echo "htpasswd_filename = ${RADICALE_DIRECTORY}/users" >> ${RADICALE_DIRECTORY}/config
229
-    echo 'htpasswd_encryption = sha1' >> ${RADICALE_DIRECTORY}/config
232
+    echo 'htpasswd_encryption = bcrypt' >> ${RADICALE_DIRECTORY}/config
230 233
     echo '' >> ${RADICALE_DIRECTORY}/config
231 234
     echo '[rights]' >> ${RADICALE_DIRECTORY}/config
232 235
     echo 'type = owner_only' >> ${RADICALE_DIRECTORY}/config