Bladeren bron

Use a known set of prosody modules

Helps to ensure stability and reduce chances of security problems
Bob Mottram 7 jaren geleden
bovenliggende
commit
b3825d1602
2 gewijzigde bestanden met toevoegingen van 40 en 20 verwijderingen
  1. BIN
      image_build/prosody-modules-20170514.tar.gz
  2. 40
    20
      src/freedombone-app-xmpp

BIN
image_build/prosody-modules-20170514.tar.gz Bestand weergeven


+ 40
- 20
src/freedombone-app-xmpp Bestand weergeven

@@ -13,7 +13,7 @@
13 13
 # License
14 14
 # =======
15 15
 #
16
-# Copyright (C) 2014-2016 Bob Mottram <bob@freedombone.net>
16
+# Copyright (C) 2014-2017 Bob Mottram <bob@freedombone.net>
17 17
 #
18 18
 # This program is free software: you can redistribute it and/or modify
19 19
 # it under the terms of the GNU Affero General Public License as published by
@@ -45,7 +45,10 @@ prosody_nightly=382
45 45
 prosody_nightly_hash='770f1a0466f2361184eebffac9f50c102ad842cd855190db6c7f42f2f09884f5'
46 46
 prosody_filename=prosody-${prosody_latest_version}-1nightly${prosody_nightly}
47 47
 prosody_nightly_url="https://prosody.im/nightly/${prosody_latest_version}/latest/${prosody_filename}.tar.gz"
48
-prosody_modules_repo='https://hg.prosody.im/prosody-modules/'
48
+
49
+# From https://hg.prosody.im/prosody-modules
50
+prosody_modules_filename='prosody-modules-20170514.tar.gz'
51
+prosody_modules_hash='ef404c203317cc0de6da7aaec4f21765a57f630adfbf082cf2dd92b881c15f86'
49 52
 
50 53
 LIBMESODE_REPO="https://github.com/boothj5/libmesode"
51 54
 LIBMESODE_COMMIT='e3db0e9bfba61b2d82193874343a94a88f910800'
@@ -283,18 +286,44 @@ function reconfigure_xmpp {
283 286
 }
284 287
 
285 288
 function update_prosody_modules {
286
-    if [ ! -d /var/lib/prosody/prosody-modules ]; then
287
-        return
289
+    if [ ! $1 ]; then
290
+        if [ ! -d /var/lib/prosody/prosody-modules ]; then
291
+            return
292
+        fi
288 293
     fi
289 294
     if [ ! -d /usr/lib/prosody ]; then
290 295
         return
291 296
     fi
292 297
 
293
-    hg clone $prosody_modules_repo /var/lib/prosody/prosody-modules-new
294
-    if [ -d /var/lib/prosody/prosody-modules-new ]; then
295
-        rm -rf /var/lib/prosody/prosody-modules
296
-        mv /var/lib/prosody/prosody-modules-new /var/lib/prosody/prosody-modules
297
-        chown -R prosody:prosody /var/lib/prosody/prosody-modules
298
+    if [ ! -f $INSTALL_DIR/$prosody_modules_filename ]; then
299
+        # Obtain the modules
300
+        if [ -f ~/freedombone/image_build/$prosody_modules_filename ]; then
301
+            cp ~/freedombone/image_build/$prosody_modules_filename $INSTALL_DIR
302
+        else
303
+            if [ -f /home/$MY_USERNAME/freedombone/image_build/$prosody_modules_filename ]; then
304
+                cp /home/$MY_USERNAME/freedombone/image_build/$prosody_modules_filename $INSTALL_DIR
305
+            fi
306
+        fi
307
+
308
+        if [ -f $INSTALL_DIR/$prosody_modules_filename ]; then
309
+            cd $INSTALL_DIR
310
+
311
+            # Check the hash
312
+            curr_hash=$(sha256sum $INSTALL_DIR/$prosody_modules_filename | awk -F ' ' '{print $1}')
313
+            if [[ "$curr_hash" != "$prosody_modules_hash" ]]; then
314
+                echo $'Prosody modules hash does not match'
315
+            else
316
+                # Extract the modules
317
+                if [ -d prosody-modules ]; then
318
+                    rm -rf prosody-modules
319
+                fi
320
+                tar -xzvf $prosody_modules_filename
321
+                if [ -d prosody-modules ]; then
322
+                    cp -r prosody-modules/* /var/lib/prosody/prosody-modules
323
+                    chown -R prosody:prosody /var/lib/prosody/prosody-modules
324
+                fi
325
+            fi
326
+        fi
298 327
     fi
299 328
 
300 329
     # change to using pep rather than profile modules
@@ -835,21 +864,12 @@ function install_xmpp_main {
835 864
         mkdir /etc/prosody/conf.d
836 865
     fi
837 866
 
838
-    # obtain the prosody modules
839
-    if [ ! -d /var/lib/prosody/prosody-modules ]; then
840
-        hg clone $prosody_modules_repo /var/lib/prosody/prosody-modules
841
-    fi
842
-    if [ ! -d /var/lib/prosody/prosody-modules/mod_onions ]; then
843
-        echo $'mod_onions prosody module could not be found'
844
-        exit 73254
845
-    fi
846
-
847 867
     chmod -R 700 /etc/prosody/conf.d
848 868
     chown -R prosody /var/lib/prosody
849 869
     chown -R prosody /etc/prosody/conf.d
850 870
 
851
-    # install the onions module
852
-    update_prosody_modules
871
+    # install modules
872
+    update_prosody_modules initial
853 873
 
854 874
     # create a certificate
855 875
     if [[ "$(cert_exists ${DEFAULT_DOMAIN_NAME} pem)" == "0" ]]; then