瀏覽代碼

Merge branch 'stretch' of https://github.com/bashrc/freedombone

Bob Mottram 6 年之前
父節點
當前提交
2d45c34f22

+ 2
- 0
doc/EN/mobile.org 查看文件

@@ -96,6 +96,8 @@ Now edit the hosts file which was pulled and append:
96 96
 127.0.0.1       www.google-analytics.com
97 97
 127.0.0.1       google-analytics.com
98 98
 127.0.0.1       ssl.google-analytics.com
99
+127.0.0.1       telemetry.mozilla.org
100
+127.0.0.1       incoming.telemetry.mozilla.org
99 101
 #+end_src
100 102
 
101 103
 Then upload the hosts file back again with:

二進制
man/freedombone-image.1.gz 查看文件


+ 25
- 5
src/freedombone-app-pleroma 查看文件

@@ -36,7 +36,7 @@ PLEROMA_CODE=
36 36
 PLEROMA_PORT=4000
37 37
 PLEROMA_ONION_PORT=8011
38 38
 PLEROMA_REPO="https://git.pleroma.social/pleroma/pleroma.git"
39
-PLEROMA_COMMIT='5b6d6d7f2d9363c494642bfda4d6e4d12daa53c7'
39
+PLEROMA_COMMIT='762f6edc29a7a48e3a663e9bedec58e0036ff363'
40 40
 PLEROMA_ADMIN_PASSWORD=
41 41
 PLEROMA_DIR=/etc/pleroma
42 42
 PLEROMA_SECRET_KEY=""
@@ -733,15 +733,21 @@ function configure_interactive_pleroma {
733 733
             enablechatstr=$'Disable chat system'
734 734
         fi
735 735
 
736
+        pleromatorstr=$'Enable routing through Tor for onion addresses'
737
+        if grep -q '9050' $pleroma_secret; then
738
+            pleromatorstr=$'Disable routing through Tor'
739
+        fi
740
+
736 741
         W=(1 $"Set a background image"
737 742
            2 $"Set the title"
738 743
            3 $"Disable new account registrations"
739 744
            4 $"Add a custom emoji"
740 745
            5 $"Set post expiry period (currently $PLEROMA_EXPIRE_MONTHS months)"
741
-           6 "$enablechatstr")
746
+           6 "$enablechatstr"
747
+           7 "$pleromatorstr")
742 748
 
743 749
         # shellcheck disable=SC2068
744
-        selection=$(dialog --backtitle $"Freedombone Administrator Control Panel" --title $"Pleroma" --menu $"Choose an operation, or ESC to exit:" 13 60 6 "${W[@]}" 3>&2 2>&1 1>&3)
750
+        selection=$(dialog --backtitle $"Freedombone Administrator Control Panel" --title $"Pleroma" --menu $"Choose an operation, or ESC to exit:" 14 60 7 "${W[@]}" 3>&2 2>&1 1>&3)
745 751
 
746 752
         if [ ! "$selection" ]; then
747 753
             break
@@ -759,11 +765,25 @@ function configure_interactive_pleroma {
759 765
                    pleroma_enable_chat true
760 766
                fi
761 767
                ;;
768
+            7) if grep -q '9050' $pleroma_secret; then
769
+                   pleroma_disable_tor
770
+               else
771
+                   pleroma_enable_tor
772
+               fi
773
+               ;;
762 774
         esac
763 775
     done
764 776
 }
765 777
 
766
-function pleroma_upgrade_tor {
778
+function pleroma_disable_tor {
779
+    if grep -q '9050' $pleroma_secret; then
780
+        sed -i '/9050/d' $pleroma_secret
781
+        sed -i 's|# config :pleroma, :http, proxy_url:|config :pleroma, :http, proxy_url:|g' $PLEROMA_DIR/config/config.exs
782
+        pleroma_recompile
783
+    fi
784
+}
785
+
786
+function pleroma_enable_tor {
767 787
     pleroma_tor_update=
768 788
 
769 789
     if ! grep -q '{:socks5, :localhost, 9050}' $pleroma_secret; then
@@ -806,7 +826,7 @@ function upgrade_pleroma {
806 826
         create_pleroma_blocklist
807 827
     fi
808 828
 
809
-    pleroma_upgrade_tor
829
+    #pleroma_enable_tor
810 830
 
811 831
     CURR_PLEROMA_COMMIT=$(get_completion_param "pleroma commit")
812 832
     if [[ "$CURR_PLEROMA_COMMIT" == "$PLEROMA_COMMIT" ]]; then

+ 125
- 86
src/freedombone-controlpanel 查看文件

@@ -224,114 +224,153 @@ function show_tor_bridges {
224 224
 function show_domains {
225 225
     read_config_param "DEFAULT_DOMAIN_NAME"
226 226
 
227
-    W=()
227
+    while true
228
+    do
229
+        W=()
228 230
 
229
-    W+=("IPv4" "$(get_ipv4_address) / $(get_external_ipv4_address)")
230
-    ipv6_address="$(get_ipv6_address)"
231
-    if [ ${#ipv6_address} -gt 0 ]; then
232
-        W+=("IPv6" "${ipv6_address}")
233
-    fi
231
+        W+=("IPv4" "$(get_ipv4_address) / $(get_external_ipv4_address)")
232
+        ipv6_address="$(get_ipv6_address)"
233
+        if [ ${#ipv6_address} -gt 0 ]; then
234
+            W+=("IPv6" "${ipv6_address}")
235
+        fi
234 236
 
235
-    if [ -f /etc/ssh/ssh_host_rsa_key.pub ]; then
236
-        W+=("ssh rsa sha256" "$(awk '{print $2}' /etc/ssh/ssh_host_rsa_key.pub | base64 -d | sha256sum -b | awk '{print $1}' | xxd -r -p | base64 | sed 's|=||g')")
237
-    fi
238
-    if [ -f /etc/ssh/ssh_host_ed25519_key.pub ]; then
239
-        W+=("ssh ed25519 sha256" "$(awk '{print $2}' /etc/ssh/ssh_host_ed25519_key.pub | base64 -d | sha256sum -b | awk '{print $1}' | xxd -r -p | base64 | sed 's|=||g')")
240
-    fi
237
+        if [ -f /etc/ssh/ssh_host_rsa_key.pub ]; then
238
+            W+=("ssh rsa sha256" "$(awk '{print $2}' /etc/ssh/ssh_host_rsa_key.pub | base64 -d | sha256sum -b | awk '{print $1}' | xxd -r -p | base64 | sed 's|=||g')")
239
+        fi
240
+        if [ -f /etc/ssh/ssh_host_ed25519_key.pub ]; then
241
+            W+=("ssh ed25519 sha256" "$(awk '{print $2}' /etc/ssh/ssh_host_ed25519_key.pub | base64 -d | sha256sum -b | awk '{print $1}' | xxd -r -p | base64 | sed 's|=||g')")
242
+        fi
241 243
 
242
-    if grep -q "ssh onion domain" "$COMPLETION_FILE"; then
243
-        domain_onion=$(grep 'ssh onion domain' "${COMPLETION_FILE}" | awk -F ':' '{print $2}')
244
-        W+=("ssh" "${DEFAULT_DOMAIN_NAME} / ${domain_onion}")
245
-    fi
246
-    if grep -q "email onion domain" "$COMPLETION_FILE"; then
247
-        domain_onion=$(grep 'email onion domain' "${COMPLETION_FILE}" | awk -F ':' '{print $2}')
248
-        W+=("Email" "${DEFAULT_DOMAIN_NAME} / ${domain_onion}")
249
-    fi
250
-    if grep -q "sks onion domain" "$COMPLETION_FILE"; then
251
-        read_config_param "KEYSERVER_DOMAIN_NAME"
252
-        domain_onion=$(grep 'sks onion domain' "${COMPLETION_FILE}" | awk -F ':' '{print $2}')
253
-        W+=("SKS" "${KEYSERVER_DOMAIN_NAME} / ${domain_onion}")
254
-    fi
244
+        if grep -q "ssh onion domain" "$COMPLETION_FILE"; then
245
+            domain_onion=$(grep 'ssh onion domain' "${COMPLETION_FILE}" | awk -F ':' '{print $2}')
246
+            W+=("ssh" "${DEFAULT_DOMAIN_NAME} / ${domain_onion}")
247
+        fi
248
+        if grep -q "email onion domain" "$COMPLETION_FILE"; then
249
+            domain_onion=$(grep 'email onion domain' "${COMPLETION_FILE}" | awk -F ':' '{print $2}')
250
+            W+=("Email" "${DEFAULT_DOMAIN_NAME} / ${domain_onion}")
251
+        fi
252
+        if grep -q "sks onion domain" "$COMPLETION_FILE"; then
253
+            read_config_param "KEYSERVER_DOMAIN_NAME"
254
+            domain_onion=$(grep 'sks onion domain' "${COMPLETION_FILE}" | awk -F ':' '{print $2}')
255
+            W+=("SKS" "${KEYSERVER_DOMAIN_NAME} / ${domain_onion}")
256
+        fi
255 257
 
256
-    INTRODUCER_FILENAME=/home/tahoelafs/data/private/introducer.furl
257
-    if [ -f $INTRODUCER_FILENAME ]; then
258
-        W+=("Tahoe-LAFS" "$(cat $INTRODUCER_FILENAME)")
259
-    fi
258
+        INTRODUCER_FILENAME=/home/tahoelafs/data/private/introducer.furl
259
+        if [ -f $INTRODUCER_FILENAME ]; then
260
+            W+=("Tahoe-LAFS" "$(cat $INTRODUCER_FILENAME)")
261
+        fi
260 262
 
261
-    show_tor_bridges
263
+        show_tor_bridges
262 264
 
263
-    # shellcheck disable=SC2068
264
-    for app_name in ${APPS_INSTALLED_NAMES[@]}
265
-    do
266
-        if ! grep -q "SHOW_ON_ABOUT=1" "/usr/share/${PROJECT_NAME}/apps/${PROJECT_NAME}-app-${app_name}"; then
267
-            continue
268
-        fi
265
+        # shellcheck disable=SC2068
266
+        for app_name in ${APPS_INSTALLED_NAMES[@]}
267
+        do
268
+            if ! grep -q "SHOW_ON_ABOUT=1" "/usr/share/${PROJECT_NAME}/apps/${PROJECT_NAME}-app-${app_name}"; then
269
+                continue
270
+            fi
269 271
 
270
-        # handle the foibles of capitalisation
271
-        if ! grep -q "${app_name} domain" "$COMPLETION_FILE"; then
272
-            app_name_upper=$(echo "${app_name}" | awk '{print toupper($0)}')
273
-            if grep -q "${app_name_upper} domain" "$COMPLETION_FILE"; then
274
-                app_name=${app_name_upper}
275
-            else
276
-                app_name_first_upper="$(tr '[:lower:]' '[:upper:]' <<< "${app_name:0:1}")${app_name:1}"
277
-                if grep -q "${app_name_first_upper} domain" "$COMPLETION_FILE"; then
278
-                    app_name=${app_name_first_upper}
272
+            # handle the foibles of capitalisation
273
+            if ! grep -q "${app_name} domain" "$COMPLETION_FILE"; then
274
+                app_name_upper=$(echo "${app_name}" | awk '{print toupper($0)}')
275
+                if grep -q "${app_name_upper} domain" "$COMPLETION_FILE"; then
276
+                    app_name=${app_name_upper}
277
+                else
278
+                    app_name_first_upper="$(tr '[:lower:]' '[:upper:]' <<< "${app_name:0:1}")${app_name:1}"
279
+                    if grep -q "${app_name_first_upper} domain" "$COMPLETION_FILE"; then
280
+                        app_name=${app_name_first_upper}
281
+                    fi
279 282
                 fi
280 283
             fi
281
-        fi
282 284
 
283
-        if [ ${#app_name} -gt 0 ]; then
284
-            icann_address=$(get_app_icann_address "$app_name")
285
-            if grep -q "SHOW_ICANN_ADDRESS_ON_ABOUT=0" "/usr/share/${PROJECT_NAME}/apps/${PROJECT_NAME}-app-${app_name}"; then
286
-                icann_address='-'
287
-            fi
288
-            if [[ "$ONION_ONLY" != 'no' ]]; then
289
-                if [[ "${icann_address}" != "${LOCAL_NAME}.local" ]]; then
285
+            if [ ${#app_name} -gt 0 ]; then
286
+                icann_address=$(get_app_icann_address "$app_name")
287
+                if grep -q "SHOW_ICANN_ADDRESS_ON_ABOUT=0" "/usr/share/${PROJECT_NAME}/apps/${PROJECT_NAME}-app-${app_name}"; then
290 288
                     icann_address='-'
291 289
                 fi
292
-            fi
293
-            onion_address=$(get_app_onion_address "$app_name")
294
-            if [ ${#onion_address} -eq 0 ]; then
295
-                onion_address="-"
296
-            fi
297
-
298
-            if [[ "${icann_address}" != '-' ]]; then
299
-                if [[ "${onion_address}" != '-' ]]; then
300
-                    W+=("${app_name}" "${icann_address} / ${onion_address}")
301
-                else
302
-                    W+=("${app_name}" "${icann_address}")
290
+                if [[ "$ONION_ONLY" != 'no' ]]; then
291
+                    if [[ "${icann_address}" != "${LOCAL_NAME}.local" ]]; then
292
+                        icann_address='-'
293
+                    fi
294
+                fi
295
+                onion_address=$(get_app_onion_address "$app_name")
296
+                if [ ${#onion_address} -eq 0 ]; then
297
+                    onion_address="-"
303 298
                 fi
304
-            else
305
-                W+=("${app_name}" "${onion_address}")
306
-            fi
307 299
 
308
-            if grep -q "mobile${app_name} onion domain" "$COMPLETION_FILE"; then
309
-                onion_address=$(get_app_onion_address "${app_name}" "mobile")
310 300
                 if [[ "${icann_address}" != '-' ]]; then
311
-                    W+=("${app_name} (mobile)" "${icann_address} / ${onion_address}")
301
+                    if [[ "${onion_address}" != '-' ]]; then
302
+                        W+=("${app_name}" "${icann_address} / ${onion_address}")
303
+                    else
304
+                        W+=("${app_name}" "${icann_address}")
305
+                    fi
312 306
                 else
313
-                    W+=("${app_name} (mobile)" "${onion_address}")
307
+                    W+=("${app_name}" "${onion_address}")
308
+                fi
309
+
310
+                if grep -q "mobile${app_name} onion domain" "$COMPLETION_FILE"; then
311
+                    onion_address=$(get_app_onion_address "${app_name}" "mobile")
312
+                    if [[ "${icann_address}" != '-' ]]; then
313
+                        W+=("${app_name} (mobile)" "${icann_address} / ${onion_address}")
314
+                    else
315
+                        W+=("${app_name} (mobile)" "${onion_address}")
316
+                    fi
314 317
                 fi
315 318
             fi
316
-        fi
317
-    done
319
+        done
318 320
 
319
-    if grep -q "rss reader domain" "$COMPLETION_FILE"; then
320
-        if [ -d /var/lib/tor/hidden_service_ttrss ]; then
321
-            domain_onion=$(cat /var/lib/tor/hidden_service_ttrss/hostname)
322
-            W+=("RSS Reader" "${domain_onion}")
323
-        fi
324
-        if [ -d /var/lib/tor/hidden_service_mobilerss ]; then
325
-            domain_onion=$(cat /var/lib/tor/hidden_service_mobilerss/hostname)
326
-            W+=("RSS mobile" "${domain_onion}")
321
+        if grep -q "rss reader domain" "$COMPLETION_FILE"; then
322
+            if [ -d /var/lib/tor/hidden_service_ttrss ]; then
323
+                domain_onion=$(cat /var/lib/tor/hidden_service_ttrss/hostname)
324
+                W+=("RSS Reader" "${domain_onion}")
325
+            fi
326
+            if [ -d /var/lib/tor/hidden_service_mobilerss ]; then
327
+                domain_onion=$(cat /var/lib/tor/hidden_service_mobilerss/hostname)
328
+                W+=("RSS mobile" "${domain_onion}")
329
+            fi
327 330
         fi
328
-    fi
329 331
 
330
-    width=$(tput cols)
331
-    height=$(tput lines)
332
+        width=$(tput cols)
333
+        height=$(tput lines)
332 334
 
333
-    # shellcheck disable=SC2068
334
-    dialog --backtitle $"Freedombone Control Panel" --title $"Domains" --menu $"Use Shift+cursors to select and copy onion addresses" $((height-4)) $((width-4)) $((height-4)) "${W[@]}" 3>&2 2>&1 1>&3
335
+        # shellcheck disable=SC2068
336
+        selected=$(dialog --backtitle $"Freedombone Control Panel" --title $"Domains" --menu $"Use Shift+cursors to select and copy onion addresses" $((height-4)) $((width-4)) $((height-4)) "${W[@]}" 3>&2 2>&1 1>&3)
337
+        if [ ! "$selected" ]; then
338
+            break
339
+        fi
340
+        # obtain the addresses from the key by itterating through
341
+        # the array. This is quite crude and maybe there's a better way
342
+        key_found=
343
+        selected_addresses=
344
+        for key in "${W[@]}";
345
+        do
346
+            if [ $key_found ]; then
347
+                selected_addresses="$key"
348
+                break
349
+            fi
350
+            if [[ "$key" == "$selected" ]]; then
351
+                key_found=1
352
+            fi
353
+        done
354
+        # Was the key matched?
355
+        if [ ! "$selected_addresses" ]; then
356
+            break
357
+        fi
358
+        # addresses were found - is this an onion?
359
+        if [[ "$selected_addresses" != *".onion"* ]]; then
360
+            continue
361
+        fi
362
+        # There are two forms of addresses: "x / y.onion" and "x.onion"
363
+        if [[ "$selected_addresses" == *'/'* ]]; then
364
+            onion_addr=$(echo "$selected_addresses" | awk -F '/' '{print $2}' | awk -F ' ' '{print $1}')
365
+        else
366
+            onion_addr="$selected_addresses"
367
+        fi
368
+        # show the onion address as a QR code
369
+        clear
370
+        echo "${selected}: ${onion_addr}"
371
+        echo -n "$onion_addr" | qrencode -t UTF8
372
+        any_key
373
+    done
335 374
 }
336 375
 
337 376
 function show_users {

+ 4
- 0
src/freedombone-controlpanel-user 查看文件

@@ -434,6 +434,10 @@ function show_gpg_key {
434 434
     dialog --title $"My PGP/GPG Key" \
435 435
            --backtitle $"Freedombone User Control Panel" \
436 436
            --msgbox $"Email Address: $MY_EMAIL_ADDRESS\\n\\nKey ID: $GPG_ID\\n\\nFingerprint: $GPG_FINGERPRINT\\n\\nCreated: $GPG_DATE" 12 70
437
+    clear
438
+    echo $"Your GPG/PGP public key:"
439
+    gpg --armor --export "$GPG_ID" | qrencode -t UTF8
440
+    any_key
437 441
 }
438 442
 
439 443
 function show_full_gpg_key {

+ 9
- 2
src/freedombone-image 查看文件

@@ -74,6 +74,8 @@ IMAGE_NAME='full'
74 74
 USERNAME="$USER"
75 75
 PASSWORD=
76 76
 
77
+CONTINUOUS_INTEGRATION=
78
+
77 79
 # IP address of the router (gateway)
78 80
 ROUTER_IP_ADDRESS="192.168.1.254"
79 81
 
@@ -378,6 +380,10 @@ do
378 380
             shift
379 381
             INTERACTIVE="$1"
380 382
             ;;
383
+        --ci)
384
+            shift
385
+            CONTINUOUS_INTEGRATION="$1"
386
+            ;;
381 387
         -g|--generic)
382 388
             shift
383 389
             GENERIC_IMAGE="$1"
@@ -614,6 +620,7 @@ make "$IMAGE_TYPE" \
614 620
      AMNESIC="$AMNESIC" \
615 621
      SOCIALINSTANCE="$SOCIALINSTANCE" \
616 622
      EXTERNAL_DRIVE="$EXTERNAL_DRIVE" \
623
+     CONTINUOUS_INTEGRATION="$CONTINUOUS_INTEGRATION" \
617 624
      LOCAL_NAME="$LOCAL_NAME"
618 625
 
619 626
 # shellcheck disable=SC2181
@@ -641,8 +648,8 @@ fi
641 648
 for im in ${image_types[@]}
642 649
 do
643 650
     # shellcheck disable=SC2012,SC2086
644
-    no_of_files=$(ls -afq build/${PROJECT_NAME}*.${im} | wc -l)
645
-    if (( no_of_files > 0 )); then
651
+    no_of_files=$(ls -l build/${PROJECT_NAME}*.${im} | wc -l)
652
+    if [ "$no_of_files" -gt 0 ]; then
646 653
         # shellcheck disable=SC2086
647 654
         mv build/${PROJECT_NAME}*.${im} ${CURR_DIR}/
648 655
         # shellcheck disable=SC2086

+ 4
- 2
src/freedombone-image-customise 查看文件

@@ -139,6 +139,8 @@ BMX6_COMMIT='39dd1f2d99ac5a3fa28e92f8173c15039132e181'
139 139
 BMX7_REPO="https://github.com/bmx-routing/bmx7"
140 140
 BMX7_COMMIT='0a82c7c10fef44b259b35e77ab33632aa132d219'
141 141
 
142
+CONTINUOUS_INTEGRATION=
143
+
142 144
 PATH=/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin:/bin:/sbin
143 145
 
144 146
 # Whether to use a SATA drive and if so what its device/partition name is
@@ -1766,8 +1768,8 @@ image_setup_utils() {
1766 1768
     chroot "$rootdir" apt-get -yq -t stretch-backports install tor
1767 1769
     chroot "$rootdir" apt-get -yq install connect-proxy
1768 1770
     chroot "$rootdir" connect-proxy
1769
-    sed -i 's|#Log notice file.*|Log notice file /dev/null|g' "$rootdir/etc/tor/torrc"
1770
-    sed -i 's|Log notice file.*|Log notice file /dev/null|g' "$rootdir/etc/tor/torrc"
1771
+    sed -i 's|#Log notice file.*|Log notice file /var/log/tor/notices.log|g' "$rootdir/etc/tor/torrc"
1772
+    sed -i 's|Log notice file.*|Log notice file /var/log/tor/notices.log|g' "$rootdir/etc/tor/torrc"
1771 1773
     sed -i "s|#AccountingMax.*|AccountingMax $TOR_MAX_TRAFFIC_PER_MONTH_GB GBytes|g" "$rootdir/etc/tor/torrc"
1772 1774
     sed -i "s|AccountingMax.*|AccountingMax $TOR_MAX_TRAFFIC_PER_MONTH_GB GBytes|g" "$rootdir/etc/tor/torrc"
1773 1775
     if ! grep -q 'Host *.onion' "$rootdir/root/.ssh/config"; then

+ 2
- 0
src/freedombone-image-make 查看文件

@@ -78,6 +78,7 @@ export AMNESIC
78 78
 export SOCIALINSTANCE
79 79
 export LOCAL_NAME
80 80
 export EXTERNAL_DRIVE
81
+export CONTINUOUS_INTEGRATION
81 82
 
82 83
 # Locate vmdebootstrap program fetched in Makefile
83 84
 basedir=`pwd`
@@ -228,6 +229,7 @@ sed -i "s|SOCIALINSTANCE=.*|SOCIALINSTANCE=\"${SOCIALINSTANCE}\"|g" "$TEMP_CUSTO
228 229
 sed -i "s|LOCAL_NAME=.*|LOCAL_NAME=\"${LOCAL_NAME}\"|g" "$TEMP_CUSTOMISE3"
229 230
 sed -i "s|EXTERNAL_DRIVE=.*|EXTERNAL_DRIVE=\"${EXTERNAL_DRIVE}\"|g" "$TEMP_CUSTOMISE3"
230 231
 sed -i 's|#!/bin/bash||g' "$TEMP_CUSTOMISE3"
232
+sed -i "s|CONTINUOUS_INTEGRATION=.*|CONTINUOUS_INTEGRATION=${CONTINUOUS_INTEGRATION}|g" "$TEMP_CUSTOMISE3"
231 233
 
232 234
 cat $TEMP_CUSTOMISE2 $TEMP_CUSTOMISE3 > $TEMP_CUSTOMISE4
233 235
 if [ -f $TEMP_CUSTOMISE ]; then

+ 20
- 15
src/freedombone-image-makefile 查看文件

@@ -41,8 +41,13 @@ IMAGE = $(NAME).img
41 41
 ARCHIVE = $(IMAGE).xz
42 42
 SIGNATURE = $(ARCHIVE).sig
43 43
 OWNER = 1000
44
-XZ = xz --no-warn --verbose --keep --threads=0 -3
45
-SIGN = -gpg --output $(SIGNATURE) --detach-sig $(ARCHIVE)
44
+ifeq ("$CONTINUOUS_INTEGRATION", "")
45
+    XZ = xz --no-warn --verbose --keep --threads=0 -3 $(IMAGE)
46
+    SIGN = -gpg --output $(SIGNATURE) --detach-sig $(ARCHIVE)
47
+else
48
+	XZ =
49
+	SIGN =
50
+endif
46 51
 
47 52
 # settings for `make test`
48 53
 TEST_SSH_PORT = 2222
@@ -90,7 +95,7 @@ beaglebone: prep
90 95
 	$(eval MACHINE = beaglebone)
91 96
 	$(MAKE_IMAGE)
92 97
 	@rm -f $(ARCHIVE)
93
-	$(XZ) $(IMAGE)
98
+	$(XZ)
94 99
 	@echo ""
95 100
 	$(SIGN)
96 101
 	@echo "Build complete."
@@ -101,7 +106,7 @@ cubieboard2: prep
101 106
 	$(eval MACHINE = cubieboard2)
102 107
 	$(MAKE_IMAGE)
103 108
 	@rm -f $(ARCHIVE)
104
-	$(XZ) $(IMAGE)
109
+	$(XZ)
105 110
 	@echo ""
106 111
 	$(SIGN)
107 112
 	@echo "Build complete."
@@ -112,7 +117,7 @@ pcduino3: prep
112 117
 	$(eval MACHINE = pcduino3)
113 118
 	$(MAKE_IMAGE)
114 119
 	@rm -f $(ARCHIVE)
115
-	$(XZ) $(IMAGE)
120
+	$(XZ)
116 121
 	@echo ""
117 122
 	$(SIGN)
118 123
 	@echo "Build complete."
@@ -123,7 +128,7 @@ cubietruck: prep
123 128
 	$(eval MACHINE = cubietruck)
124 129
 	$(MAKE_IMAGE)
125 130
 	@rm -f $(ARCHIVE)
126
-	$(XZ) $(IMAGE)
131
+	$(XZ)
127 132
 	@echo ""
128 133
 	$(SIGN)
129 134
 	@echo "Build complete."
@@ -135,7 +140,7 @@ a20-olinuxino-lime: prep
135 140
 	$(eval IMAGE = $(NAME).img)
136 141
 	$(MAKE_IMAGE)
137 142
 	rm -f $(ARCHIVE)
138
-	$(XZ) $(IMAGE)
143
+	$(XZ)
139 144
 	@echo ""
140 145
 	$(SIGN)
141 146
 
@@ -145,7 +150,7 @@ a20-olinuxino-lime2: prep
145 150
 	$(eval MACHINE = a20-olinuxino-lime2)
146 151
 	$(MAKE_IMAGE)
147 152
 	@rm -f $(ARCHIVE)
148
-	$(XZ) $(IMAGE)
153
+	$(XZ)
149 154
 	@echo ""
150 155
 	$(SIGN)
151 156
 	@echo "Build complete."
@@ -156,7 +161,7 @@ a20-olinuxino-micro: prep
156 161
 	$(eval MACHINE = a20-olinuxino-micro)
157 162
 	$(MAKE_IMAGE)
158 163
 	@rm -f $(ARCHIVE)
159
-	$(XZ) $(IMAGE)
164
+	$(XZ)
160 165
 	@echo ""
161 166
 	$(SIGN)
162 167
 	@echo "Build complete."
@@ -167,7 +172,7 @@ i386: prep
167 172
 	$(eval MACHINE = all)
168 173
 	$(MAKE_IMAGE)
169 174
 	@rm -f $(ARCHIVE)
170
-	$(XZ) $(IMAGE)
175
+	$(XZ)
171 176
 	@echo ""
172 177
 	$(SIGN)
173 178
 	@echo "Build complete."
@@ -178,7 +183,7 @@ i686: prep
178 183
 	$(eval MACHINE = all)
179 184
 	$(MAKE_IMAGE)
180 185
 	@rm -f $(ARCHIVE)
181
-	$(XZ) $(IMAGE)
186
+	$(XZ)
182 187
 	@echo ""
183 188
 	$(SIGN)
184 189
 	@echo "Build complete."
@@ -189,7 +194,7 @@ amd64: prep
189 194
 	$(eval MACHINE = all)
190 195
 	$(MAKE_IMAGE)
191 196
 	@rm -f $(ARCHIVE)
192
-	$(XZ) $(IMAGE)
197
+	$(XZ)
193 198
 	@echo ""
194 199
 	$(SIGN)
195 200
 	@echo "Build complete."
@@ -200,7 +205,7 @@ apu: prep
200 205
 	$(eval MACHINE = all)
201 206
 	$(MAKE_IMAGE)
202 207
 	@rm -f $(ARCHIVE)
203
-	$(XZ) $(IMAGE)
208
+	$(XZ)
204 209
 	@echo ""
205 210
 	$(SIGN)
206 211
 	@echo "Build complete."
@@ -215,7 +220,7 @@ qemu-i386: prep
215 220
 	# Convert image to qemu format
216 221
 	qemu-img convert -O qcow2 $(NAME).img $(NAME).qcow2
217 222
 	@rm -f $(ARCHIVE)
218
-	$(XZ) $(IMAGE)
223
+	$(XZ)
219 224
 	@echo ""
220 225
 	$(SIGN)
221 226
 	@echo "Build complete."
@@ -227,7 +232,7 @@ qemu-x86_64: prep
227 232
 	# Convert image to qemu format
228 233
 	qemu-img convert -O qcow2 $(NAME).img $(NAME).qcow2
229 234
 	@rm -f $(ARCHIVE)
230
-	$(XZ) $(IMAGE)
235
+	$(XZ)
231 236
 	@echo ""
232 237
 	$(SIGN)
233 238
 	@echo "Build complete."

+ 2
- 3
src/freedombone-logging 查看文件

@@ -179,9 +179,8 @@ if [[ "$1" == "on" || "$1" == "On" || "$1" == "ON" ]]; then
179 179
 else
180 180
     turn_logging_off
181 181
 
182
-    if [ -d /etc/tor ]; then
183
-        echo 'Log notice file /dev/null' > /etc/torrc.d/logging
184
-        rm /var/log/tor/*
182
+    if [ -d /etc/torrc.d ]; then
183
+        echo 'Log notice file /var/log/tor/notices.log' > /etc/torrc.d/logging
185 184
     fi
186 185
     if [ -d /var/log/radicale ]; then
187 186
         $REMOVE_FILES_COMMAND /var/log/radicale/*

+ 6
- 0
src/freedombone-tests 查看文件

@@ -759,6 +759,12 @@ function test_stig {
759 759
     output "V-38605" $? ${SETLANG}
760 760
     ################
761 761
 
762
+    ##Check that openssh client and server are installed
763
+    bash $STIG_TESTS_DIR/check-ssh.sh installed >/dev/null 2>&1 &
764
+    stig_spinner $!
765
+    output "SV-86857r1_rule" $? ${SETLANG}
766
+    ################
767
+    
762 768
     ##RHEL-06-000227
763 769
     ##The SSH daemon must be configured to use only the SSHv2 protocol.
764 770
 

+ 62
- 0
src/freedombone-tor-health 查看文件

@@ -0,0 +1,62 @@
1
+#!/bin/bash
2
+#  _____               _           _
3
+# |   __|___ ___ ___ _| |___ _____| |_ ___ ___ ___
4
+# |   __|  _| -_| -_| . | . |     | . | . |   | -_|
5
+# |__|  |_| |___|___|___|___|_|_|_|___|___|_|_|___|
6
+#
7
+#                              Freedom in the Cloud
8
+#
9
+# Returns a health status for Tor
10
+#
11
+# License
12
+# =======
13
+#
14
+# Copyright (C) 2018 Bob Mottram <bob@freedombone.net>
15
+#
16
+# This program is free software: you can redistribute it and/or modify
17
+# it under the terms of the GNU Affero General Public License as published by
18
+# the Free Software Foundation, either version 3 of the License, or
19
+# (at your option) any later version.
20
+#
21
+# This program is distributed in the hope that it will be useful,
22
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
23
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
24
+# GNU Affero General Public License for more details.
25
+#
26
+# You should have received a copy of the GNU Affero General Public License
27
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
28
+
29
+PROJECT_NAME='freedombone'
30
+
31
+export TEXTDOMAIN=${PROJECT_NAME}-tor-health
32
+export TEXTDOMAINDIR="/usr/share/locale"
33
+
34
+d1=$(date --date="-10 min" "+%b %d %H:%M"):00
35
+d2=$(date "+%b %d %H:%M"):00
36
+ctr=0
37
+echo -n '' > /var/log/tor/notices_new.log
38
+while read -r line; do
39
+    datestr=$(echo "$line" | awk -F '.' '{print $1}')
40
+    if [[ "$datestr" > "$d1" && "$datestr" < "$d2" || "$datestr" =~ $d2 ]]; then
41
+        if [[ "$line" == *'Retrying'* ]]; then
42
+            ctr=$((ctr+1))
43
+        fi
44
+        echo "$line" >> /var/log/tor/notices_new.log
45
+    fi
46
+done < /var/log/tor/notices.log
47
+
48
+mv /var/log/tor/notices_new.log /var/log/tor/notices.log
49
+chown -R debian-tor:adm /var/log/tor
50
+
51
+if [ $ctr -gt 5 ]; then
52
+    echo $'Failed'
53
+    exit 0
54
+fi
55
+
56
+if [ $ctr -gt 0 ]; then
57
+    echo $'Poor'
58
+    exit 0
59
+fi
60
+
61
+echo $'Good'
62
+exit 0

+ 49
- 1
src/freedombone-utils-firewall 查看文件

@@ -32,6 +32,7 @@ FIREWALL_CONFIG=$HOME/${PROJECT_NAME}-firewall.cfg
32 32
 FIREWALL_DOMAINS=$HOME/${PROJECT_NAME}-firewall-domains.cfg
33 33
 FIREWALL_EIFACE=eth0
34 34
 EXTERNAL_IPV4_ADDRESS=
35
+FIREFOX_TELEMETRY_IP='52.88.27.118'
35 36
 
36 37
 function save_firewall_settings {
37 38
     iptables-save > /etc/firewall.conf
@@ -47,6 +48,25 @@ function save_firewall_settings {
47 48
     fi
48 49
 }
49 50
 
51
+function block_firefox_telemetry {
52
+    # This shouldn't be needed on a server, but we'll do it anyway
53
+    # to be on the safe side
54
+    # Within firefox source code see submit_telemetry_data.py
55
+
56
+    if ! grep -q 'telemetry.mozilla' /etc/hosts; then
57
+	echo '127.0.0.1  telemetry.mozilla.org' >> /etc/hosts
58
+	echo '127.0.0.1  incoming.telemetry.mozilla.org' >> /etc/hosts
59
+    fi
60
+        
61
+    if grep -q "$FIREFOX_TELEMETRY_IP" /etc/firewall.conf; then
62
+        return
63
+    fi
64
+
65
+    iptables -A INPUT -s $FIREFOX_TELEMETRY_IP -j DROP
66
+    iptables -A OUTPUT -s $FIREFOX_TELEMETRY_IP -j DROP
67
+    save_firewall_settings
68
+}
69
+
50 70
 function firewall_block_bad_ip_ranges {
51 71
     if [ "$INSTALLING_MESH" ]; then
52 72
         return
@@ -340,6 +360,32 @@ function mesh_firewall {
340 360
     FIREWALL_FILENAME="${rootdir}/etc/systemd/system/meshfirewall.service"
341 361
     MESH_FIREWALL_SCRIPT=${rootdir}/usr/bin/mesh-firewall
342 362
 
363
+    if ! grep -q 'telemetry.mozilla' ${rootdir}/etc/hosts; then
364
+	echo '127.0.0.1       telemetry.mozilla.org' >> ${rootdir}/etc/hosts
365
+	echo '127.0.0.1       incoming.telemetry.mozilla.org' >> ${rootdir}/etc/hosts
366
+    fi
367
+
368
+    if ! grep -q 'facebook' ${rootdir}/etc/hosts; then
369
+	{ echo '127.0.0.1       www.facebook.com';
370
+	  echo '127.0.0.1       facebook.com';
371
+	  echo '127.0.0.1       static.ak.fbcdn.net';
372
+	  echo '127.0.0.1       www.static.ak.fbcdn.net';
373
+	  echo '127.0.0.1       login.facebook.com';
374
+	  echo '127.0.0.1       www.login.facebook.com';
375
+	  echo '127.0.0.1       fbcdn.net';
376
+	  echo '127.0.0.1       www.fbcdn.net';
377
+	  echo '127.0.0.1       fbcdn.com';
378
+	  echo '127.0.0.1       www.fbcdn.com';
379
+	  echo '127.0.0.1       static.ak.connect.facebook.com';
380
+	  echo '127.0.0.1       www.static.ak.connect.facebook.com'; } >> ${rootdir}/etc/hosts	
381
+    fi
382
+    
383
+    if ! grep -q 'google' ${rootdir}/etc/hosts; then
384
+	{ echo '127.0.0.1       www.google-analytics.com';
385
+	  echo '127.0.0.1       google-analytics.com';
386
+	  echo '127.0.0.1       ssl.google-analytics.com'; } >> ${rootdir}/etc/hosts
387
+    fi    
388
+    
343 389
     { echo '#!/bin/bash';
344 390
       echo 'iptables -P INPUT ACCEPT';
345 391
       echo 'ip6tables -P INPUT ACCEPT';
@@ -387,7 +433,9 @@ function mesh_firewall {
387 433
       echo "iptables -A INPUT -p tcp --dport $TRACKER_PORT -j ACCEPT";
388 434
       echo "ip6tables -A INPUT -p tcp --dport $TRACKER_PORT -j ACCEPT";
389 435
       echo "iptables -A INPUT -p udp --dport 1900 -j ACCEPT";
390
-      echo "ip6tables -A INPUT -p udp --dport 1900 -j ACCEPT"; } > "$MESH_FIREWALL_SCRIPT"
436
+      echo "ip6tables -A INPUT -p udp --dport 1900 -j ACCEPT";
437
+      echo "iptables -A INPUT -s $FIREFOX_TELEMETRY_IP -j DROP";
438
+      echo "iptables -A OUTPUT -s $FIREFOX_TELEMETRY_IP -j DROP"; } > "$MESH_FIREWALL_SCRIPT"
391 439
     chmod +x "$MESH_FIREWALL_SCRIPT"
392 440
 
393 441
     { echo '[Unit]';

+ 29
- 1
src/freedombone-utils-onion 查看文件

@@ -311,6 +311,34 @@ function configure_ssh_onion {
311 311
     mark_completed "${FUNCNAME[0]}"
312 312
 }
313 313
 
314
+function check_tor_health {
315
+    { echo '#!/bin/bash';
316
+      echo "status=\$(${PROJECT_NAME}-tor-health)";
317
+      echo "ADMIN_USER=\$(grep \"MY_USERNAME=\" ~/${PROJECT_NAME}.cfg | awk -F '=' '{print \$2}')";
318
+      echo "if [[ \"\$status\" == 'G'* ]]; then";
319
+      echo '    if [ -f /tmp/.torfailed ]; then';
320
+      echo '        rm /tmp/.torfailed';
321
+      echo "        tail -n 3 /var/log/tor/notices.log | mail -s \"[${PROJECT_NAME}] Tor status is now \$status\" \$ADMIN_USER@\$HOSTNAME";
322
+      echo '    fi';
323
+      echo '    exit 0';
324
+      echo 'fi';
325
+      echo 'if [ ! -f /tmp/.torfailed ]; then';
326
+      echo "    tail -n 3 /var/log/tor/notices.log | mail -s \"[${PROJECT_NAME}] Tor status is \$status\" \$ADMIN_USER@\$HOSTNAME";
327
+      echo "    echo \"\$status\" > /tmp/.torfailed";
328
+      echo 'else';
329
+      echo "    prev_status=\$(cat /tmp/.torfailed)";
330
+      echo "    if [[ \"\$prev_status\" != \"\$status\" ]]; then";
331
+      echo "        tail -n 3 /var/log/tor/notices.log | mail -s \"[${PROJECT_NAME}] Tor status is \$status\" \$ADMIN_USER@\$HOSTNAME";
332
+      echo "        echo \"\$status\" > /tmp/.torfailed";
333
+      echo '    fi';
334
+      echo 'fi'; } > /usr/bin/check_tor_health
335
+    chmod +x /usr/bin/check_tor_health
336
+
337
+    if ! grep -q 'check_tor_health' /etc/crontab; then
338
+        cron_add_mins 10 "/usr/bin/check_tor_health"
339
+    fi
340
+}
341
+
314 342
 function install_tor {
315 343
     if [[ $SYSTEM_TYPE == "mesh*" ]]; then
316 344
         return
@@ -336,7 +364,7 @@ function install_tor {
336 364
         echo '%include /etc/torrc.d' >> /etc/tor/torrc
337 365
     fi
338 366
 
339
-    echo 'Log notice file /dev/null' > /etc/torrc.d/logging
367
+    echo 'Log notice file /var/log/tor/notices.log' > /etc/torrc.d/logging
340 368
     echo "AccountingMax $TOR_MAX_TRAFFIC_PER_MONTH_GB GBytes" > /etc/torrc.d/maxtraffic
341 369
 
342 370
     mark_completed "${FUNCNAME[0]}"

+ 6
- 0
src/freedombone-utils-setup 查看文件

@@ -720,6 +720,9 @@ function setup_firewall {
720 720
     function_check configure_firewall
721 721
     configure_firewall
722 722
 
723
+    function_check block_firefox_telemetry
724
+    block_firefox_telemetry
725
+
723 726
     function_check configure_firewall_ping
724 727
     configure_firewall_ping
725 728
 
@@ -971,6 +974,9 @@ function setup_utils {
971 974
     function_check install_tor
972 975
     install_tor
973 976
 
977
+    function_check check_tor_health
978
+    check_tor_health
979
+
974 980
     function_check install_command_line_browser
975 981
     install_command_line_browser
976 982
 

+ 13
- 0
tests/check-ssh.sh 查看文件

@@ -44,6 +44,19 @@ case $1 in
44 44
             exit 1
45 45
         fi
46 46
         ;;
47
+    installed)
48
+	OPENSSH_SERVER=$(dpkg -s openssh-server | grep -i "Status:.*install.*ok.*installed" | wc -l)
49
+	OPENSSH_CLIENT=$(dpkg -s openssh-client | grep -i "Status:.*install.*ok.*installed" | wc -l)
50
+	if [ ${OPENSSH_SERVER} -eq 1 ]; then
51
+	    if [ ${OPENSSH_CLIENT} -eq 1 ]; then
52
+		:
53
+	    else
54
+		exit 1
55
+	    fi
56
+	else
57
+	    exit 1
58
+	fi	
59
+	;;    
47 60
     sshd_status)
48 61
         if systemctl status sshd | grep "Active:.*(running)";then
49 62
             :

+ 9
- 0
tests/output.sh 查看文件

@@ -1399,6 +1399,15 @@ disabled. The "nis" service can be disabled with the following commands:\n\n#upd
1399 1399
                   printf '\n######################\n\nSTIG-ID:RHEL-06-000224\n\nVulnerability Discussion: Due to its usage for maintenance and security-supporting tasks, enabling the cron daemon is essential.\n\nFix text: The "crond" service is used to execute commands at preconfigured times. It is required by almost all systems to perform necessary maintenance tasks, such as notifying root of system activity. The "crond" service can be enabled with the following commands:\n\n#update-rc.d cron defaults\nservice cron start\n\n######################\n\n' >> $LOG
1400 1400
               fi
1401 1401
               ;;
1402
+    SV-86857r1_rule) if [ "$3" = "en" ]; then
1403
+			 log_msg $2 'OpenSSH server and client must be installed.'
1404
+		     else
1405
+			 log_msg $2 '必须安装OpenSSH服务器和客户端'
1406
+		     fi		     
1407
+		     if [ $2 -ne 0 ];then
1408
+			 printf '\n######################\n\nWithout protection of the transmitted information, confidentiality and integrity may be compromised because unprotected communications can be intercepted and either read or altered. \n\nThis requirement applies to both internal and external networks and all types of information system components from which information can be transmitted (e.g., servers, mobile devices, notebook computers, printers, copiers, scanners, and facsimile machines). Communication paths outside the physical protection of a controlled boundary are exposed to the possibility of interception and modification. \n\nProtecting the confidentiality and integrity of organizational information can be accomplished by physical means (e.g., employing physical distribution systems) or by logical means (e.g., employing cryptographic techniques). If physical means of protection are employed, logical means (cryptography) do not have to be employed, and vice versa.\n\n######################\n\n' >> $LOG
1409
+		     fi
1410
+		     ;;
1402 1411
     V-38607)  if [ "$3" = "en" ]; then
1403 1412
                   log_msg $2 'The SSH daemon must be configured to use only the SSHv2 protocol.'
1404 1413
               else