소스 검색

Move passwords to security settings

Bob Mottram 7 년 전
부모
커밋
a97c7d8dcf
3개의 변경된 파일201개의 추가작업 그리고 197개의 파일을 삭제
  1. 36
    166
      src/freedombone-controlpanel
  2. 124
    31
      src/freedombone-sec
  3. 41
    0
      src/freedombone-utils-passwords

+ 36
- 166
src/freedombone-controlpanel 파일 보기

@@ -185,73 +185,6 @@ function get_app_icann_address {
185 185
     echo "${DEFAULT_DOMAIN_NAME}"
186 186
 }
187 187
 
188
-function passwords_select_user {
189
-    SELECTED_USERNAME=
190
-
191
-    # shellcheck disable=SC2207
192
-    users_array=($(ls /home))
193
-
194
-    delete=(git)
195
-    # shellcheck disable=SC2068
196
-    for del in ${delete[@]}
197
-    do
198
-        # shellcheck disable=SC2206
199
-        users_array=(${users_array[@]/$del})
200
-    done
201
-
202
-    i=0
203
-    W=()
204
-    name=()
205
-    # shellcheck disable=SC2068
206
-    for u in ${users_array[@]}
207
-    do
208
-        if [[ $(is_valid_user "$u") == "1" ]]; then
209
-            i=$((i+1))
210
-            W+=("$i" "$u")
211
-            name+=("$u")
212
-        fi
213
-    done
214
-
215
-    if [ $i -eq 1 ]; then
216
-        SELECTED_USERNAME="${name[0]}"
217
-    else
218
-        # shellcheck disable=SC2068
219
-        user_index=$(dialog --backtitle $"Freedombone Control Panel" --title $"Select User" --menu $"Select one of the following:" 24 40 17 ${W[@]} 3>&2 2>&1 1>&3)
220
-
221
-        # shellcheck disable=SC2181
222
-        if [ $? -eq 0 ]; then
223
-            SELECTED_USERNAME="${name[$((user_index-1))]}"
224
-        fi
225
-    fi
226
-}
227
-
228
-function passwords_show_apps {
229
-    SELECTED_APP=
230
-    i=0
231
-    W=()
232
-    name=()
233
-    # shellcheck disable=SC2068
234
-    for a in ${APPS_AVAILABLE[@]}
235
-    do
236
-        if [[ $(function_exists "change_password_${a}") == "1" ]]; then
237
-            i=$((i+1))
238
-            W+=("$i" "$a")
239
-            name+=("$a")
240
-        fi
241
-    done
242
-    i=$((i+1))
243
-    W+=("$i" "mariadb")
244
-    name+=("mariadb")
245
-
246
-    # shellcheck disable=SC2068
247
-    selected_app_index=$(dialog --backtitle $"Freedombone Control Panel" --title $"Select App" --menu $"Select one of the following:" 24 40 17 ${W[@]} 3>&2 2>&1 1>&3)
248
-
249
-    # shellcheck disable=SC2181
250
-    if [ $? -eq 0 ]; then
251
-        SELECTED_APP="${name[$((selected_app_index-1))]}"
252
-    fi
253
-}
254
-
255 188
 function reset_password_tries {
256 189
     passwords_select_user
257 190
     if [ ! "$SELECTED_USERNAME" ]; then
@@ -262,67 +195,6 @@ function reset_password_tries {
262 195
            --msgbox $"Password tries have been reset for $SELECTED_USERNAME" 6 60
263 196
 }
264 197
 
265
-function view_or_change_passwords {
266
-    passwords_select_user
267
-    if [ ! "$SELECTED_USERNAME" ]; then
268
-        return
269
-    fi
270
-    detect_installed_apps
271
-    passwords_show_apps
272
-    if [ ! "$SELECTED_APP" ]; then
273
-        return
274
-    fi
275
-
276
-    CURR_PASSWORD=$("${PROJECT_NAME}-pass" -u "${SELECTED_USERNAME}" -a "${SELECTED_APP}")
277
-
278
-    icann_address=$(get_app_icann_address "${SELECTED_APP}")
279
-    onion_address=$(get_app_onion_address "${SELECTED_APP}")
280
-
281
-    titlestr=$"View or Change Password"
282
-    if [ ${#onion_address} -gt 0 ]; then
283
-        viewstr=$"${SELECTED_APP} password for ${SELECTED_USERNAME} on $icann_address or $onion_address\\n\\nCopy or change it if you wish."
284
-    else
285
-        viewstr=$"${SELECTED_APP} password for ${SELECTED_USERNAME} on $icann_address\\n\\nCopy or change it if you wish."
286
-    fi
287
-
288
-    if [ -f /root/.nostore ]; then
289
-        titlestr=$"Change Password"
290
-        if [ ${#onion_address} -gt 0 ]; then
291
-            viewstr=$"Change the ${SELECTED_APP} password for ${SELECTED_USERNAME} on $icann_address or $onion_address."
292
-        else
293
-            viewstr=$"Change the ${SELECTED_APP} password for ${SELECTED_USERNAME} on $icann_address."
294
-        fi
295
-    fi
296
-
297
-    if [[ "${SELECTED_APP}" == 'mariadb' ]]; then
298
-        CURR_PASSWORD=$("${PROJECT_NAME}-pass" -u root -a mariadb)
299
-        dialog --title $"MariaDB database password" \
300
-               --msgbox "\\n            ${CURR_PASSWORD}" 7 40
301
-        return
302
-    fi
303
-
304
-    data=$(mktemp 2>/dev/null)
305
-    dialog --title "$titlestr" \
306
-           --backtitle $"Freedombone Control Panel" \
307
-           --inputbox "$viewstr" 12 75 "$CURR_PASSWORD" 2>"$data"
308
-    sel=$?
309
-    case $sel in
310
-        0)
311
-            CURR_PASSWORD=$(<"$data")
312
-            if [ ${#CURR_PASSWORD} -gt 8 ]; then
313
-                "${PROJECT_NAME}-pass" -u "${SELECTED_USERNAME}" -a "${SELECTED_APP}" -p "${CURR_PASSWORD}"
314
-                "change_password_${SELECTED_APP}" "${SELECTED_USERNAME}" "${CURR_PASSWORD}"
315
-                dialog --title $"Change password" \
316
-                       --msgbox $"The password was changed" 6 40
317
-            else
318
-                dialog --title $"Change password" \
319
-                       --msgbox $"The password given must be at least 8 characters" 6 40
320
-            fi
321
-            ;;
322
-    esac
323
-    rm -f "$data"
324
-}
325
-
326 198
 function check_for_updates {
327 199
     if [ ! -f "/etc/cron.weekly/$UPGRADE_SCRIPT_NAME" ]; then
328 200
         dialog --title $"Check for updates" \
@@ -2227,25 +2099,24 @@ function menu_top_level {
2227 2099
     while true
2228 2100
     do
2229 2101
         W=(1 $"About this system"
2230
-           2 $"Passwords"
2231
-           3 $"Backup and Restore"
2232
-           4 $"Verify Tripwire Code"
2233
-           5 $"Reset Tripwire"
2234
-           6 $"App Settings"
2235
-           7 $"Add/Remove Apps"
2236
-           8 $"Logging on/off"
2237
-           9 $"Ping enable/disable"
2238
-           10 $"Manage Users"
2239
-           11 $"Email Menu"
2240
-           12 $"Domain or User Blocking"
2241
-           13 $"Security Settings"
2242
-           14 $"Change the name of this system"
2243
-           15 $"Set a static local IP address"
2244
-           16 $"Wifi menu"
2245
-           17 $"Add Clacks"
2246
-           18 $"Check for updates"
2247
-           19 $"Power off the system"
2248
-           20 $"Restart the system")
2102
+           2 $"Backup and Restore"
2103
+           3 $"Verify Tripwire Code"
2104
+           4 $"Reset Tripwire"
2105
+           5 $"App Settings"
2106
+           6 $"Add/Remove Apps"
2107
+           7 $"Logging on/off"
2108
+           8 $"Ping enable/disable"
2109
+           9 $"Manage Users"
2110
+           10 $"Email Menu"
2111
+           11 $"Domain or User Blocking"
2112
+           12 $"Security Settings"
2113
+           13 $"Change the name of this system"
2114
+           14 $"Set a static local IP address"
2115
+           15 $"Wifi menu"
2116
+           16 $"Add Clacks"
2117
+           17 $"Check for updates"
2118
+           18 $"Power off the system"
2119
+           19 $"Restart the system")
2249 2120
 
2250 2121
         # shellcheck disable=SC2068
2251 2122
         selection=$(dialog --backtitle $"Freedombone Administrator Control Panel" --title $"Administrator Control Panel" --menu $"Choose an operation, or ESC to exit:" 27 60 27 "${W[@]}" 3>&2 2>&1 1>&3)
@@ -2258,29 +2129,28 @@ function menu_top_level {
2258 2129
 
2259 2130
         case $selection in
2260 2131
             1) show_about;;
2261
-            2) view_or_change_passwords;;
2262
-            3) menu_backup_restore;;
2263
-            4) show_tripwire_verification_code
2132
+            2) menu_backup_restore;;
2133
+            3) show_tripwire_verification_code
2264 2134
                any_key_verify;;
2265
-            5) reset_tripwire;;
2266
-            6) menu_app_settings;;
2267
-            7) if ! /usr/local/bin/addremove; then
2135
+            4) reset_tripwire;;
2136
+            5) menu_app_settings;;
2137
+            6) if ! /usr/local/bin/addremove; then
2268 2138
                    any_key
2269 2139
                fi
2270 2140
                ;;
2271
-            8) logging_on_off;;
2272
-            9) ping_enable_disable;;
2273
-            10) menu_users;;
2274
-            11) menu_email;;
2275
-            12) domain_blocking;;
2276
-            13) security_settings;;
2277
-            14) change_system_name;;
2278
-            15) set_static_IP;;
2279
-            16) menu_wifi;;
2280
-            17) add_clacks;;
2281
-            18) check_for_updates;;
2282
-            19) shut_down_system;;
2283
-            20) restart_system;;
2141
+            7) logging_on_off;;
2142
+            8) ping_enable_disable;;
2143
+            9) menu_users;;
2144
+            10) menu_email;;
2145
+            11) domain_blocking;;
2146
+            12) security_settings;;
2147
+            13) change_system_name;;
2148
+            14) set_static_IP;;
2149
+            15) menu_wifi;;
2150
+            16) add_clacks;;
2151
+            17) check_for_updates;;
2152
+            18) shut_down_system;;
2153
+            19) restart_system;;
2284 2154
         esac
2285 2155
     done
2286 2156
 }

+ 124
- 31
src/freedombone-sec 파일 보기

@@ -69,6 +69,94 @@ LETSENCRYPT_SERVER='https://acme-v01.api.letsencrypt.org/directory'
69 69
 
70 70
 MY_USERNAME=
71 71
 
72
+function passwords_show_apps {
73
+    SELECTED_APP=
74
+    i=0
75
+    W=()
76
+    name=()
77
+    # shellcheck disable=SC2068
78
+    for a in ${APPS_AVAILABLE[@]}
79
+    do
80
+        if [[ $(function_exists "change_password_${a}") == "1" ]]; then
81
+            i=$((i+1))
82
+            W+=("$i" "$a")
83
+            name+=("$a")
84
+        fi
85
+    done
86
+    i=$((i+1))
87
+    W+=("$i" "mariadb")
88
+    name+=("mariadb")
89
+
90
+    # shellcheck disable=SC2068
91
+    selected_app_index=$(dialog --backtitle $"Freedombone Control Panel" --title $"Select App" --menu $"Select one of the following:" 24 40 17 ${W[@]} 3>&2 2>&1 1>&3)
92
+
93
+    # shellcheck disable=SC2181
94
+    if [ $? -eq 0 ]; then
95
+        SELECTED_APP="${name[$((selected_app_index-1))]}"
96
+    fi
97
+}
98
+
99
+function view_or_change_passwords {
100
+    passwords_select_user
101
+    if [ ! "$SELECTED_USERNAME" ]; then
102
+        return
103
+    fi
104
+    detect_installed_apps
105
+    passwords_show_apps
106
+    if [ ! "$SELECTED_APP" ]; then
107
+        return
108
+    fi
109
+
110
+    CURR_PASSWORD=$("${PROJECT_NAME}-pass" -u "${SELECTED_USERNAME}" -a "${SELECTED_APP}")
111
+
112
+    icann_address=$(get_app_icann_address "${SELECTED_APP}")
113
+    onion_address=$(get_app_onion_address "${SELECTED_APP}")
114
+
115
+    titlestr=$"View or Change Password"
116
+    if [ ${#onion_address} -gt 0 ]; then
117
+        viewstr=$"${SELECTED_APP} password for ${SELECTED_USERNAME} on $icann_address or $onion_address\\n\\nCopy or change it if you wish."
118
+    else
119
+        viewstr=$"${SELECTED_APP} password for ${SELECTED_USERNAME} on $icann_address\\n\\nCopy or change it if you wish."
120
+    fi
121
+
122
+    if [ -f /root/.nostore ]; then
123
+        titlestr=$"Change Password"
124
+        if [ ${#onion_address} -gt 0 ]; then
125
+            viewstr=$"Change the ${SELECTED_APP} password for ${SELECTED_USERNAME} on $icann_address or $onion_address."
126
+        else
127
+            viewstr=$"Change the ${SELECTED_APP} password for ${SELECTED_USERNAME} on $icann_address."
128
+        fi
129
+    fi
130
+
131
+    if [[ "${SELECTED_APP}" == 'mariadb' ]]; then
132
+        CURR_PASSWORD=$("${PROJECT_NAME}-pass" -u root -a mariadb)
133
+        dialog --title $"MariaDB database password" \
134
+               --msgbox "\\n            ${CURR_PASSWORD}" 7 40
135
+        return
136
+    fi
137
+
138
+    data=$(mktemp 2>/dev/null)
139
+    dialog --title "$titlestr" \
140
+           --backtitle $"Freedombone Control Panel" \
141
+           --inputbox "$viewstr" 12 75 "$CURR_PASSWORD" 2>"$data"
142
+    sel=$?
143
+    case $sel in
144
+        0)
145
+            CURR_PASSWORD=$(<"$data")
146
+            if [ ${#CURR_PASSWORD} -gt 8 ]; then
147
+                "${PROJECT_NAME}-pass" -u "${SELECTED_USERNAME}" -a "${SELECTED_APP}" -p "${CURR_PASSWORD}"
148
+                "change_password_${SELECTED_APP}" "${SELECTED_USERNAME}" "${CURR_PASSWORD}"
149
+                dialog --title $"Change password" \
150
+                       --msgbox $"The password was changed" 6 40
151
+            else
152
+                dialog --title $"Change password" \
153
+                       --msgbox $"The password given must be at least 8 characters" 6 40
154
+            fi
155
+            ;;
156
+    esac
157
+    rm -f "$data"
158
+}
159
+
72 160
 function show_firewall {
73 161
     W=()
74 162
     while read -r line; do
@@ -974,22 +1062,23 @@ function menu_tor_bridges {
974 1062
 }
975 1063
 
976 1064
 function menu_security_settings {
977
-    W=(1 $"Run STIG tests"
978
-       2 $"Fix STIG test failures"
979
-       3 $"Show ssh host public key"
980
-       4 $"Tor bridges"
981
-       5 $"Password storage"
982
-       6 $"Export passwords"
983
-       7 $"Regenerate ssh host keys"
984
-       8 $"Regenerate Diffie-Hellman keys"
985
-       9 $"Update cipersuite"
986
-       10 $"Create a new Let's Encrypt certificate"
987
-       11 $"Renew Let's Encrypt certificate"
988
-       12 $"Delete a Let's Encrypt certificate"
989
-       13 $"Enable GPG based authentication (monkeysphere)"
990
-       14 $"Register a website with monkeysphere"
991
-       15 $"Allow ssh login with passwords"
992
-       16 $"Show firewall")
1065
+    W=(1 $"Passwords"
1066
+       2 $"Run STIG tests"
1067
+       3 $"Fix STIG test failures"
1068
+       4 $"Show ssh host public key"
1069
+       5 $"Tor bridges"
1070
+       6 $"Password storage"
1071
+       7 $"Export passwords"
1072
+       8 $"Regenerate ssh host keys"
1073
+       9 $"Regenerate Diffie-Hellman keys"
1074
+       10 $"Update cipersuite"
1075
+       11 $"Create a new Let's Encrypt certificate"
1076
+       12 $"Renew Let's Encrypt certificate"
1077
+       13 $"Delete a Let's Encrypt certificate"
1078
+       14 $"Enable GPG based authentication (monkeysphere)"
1079
+       15 $"Register a website with monkeysphere"
1080
+       16 $"Allow ssh login with passwords"
1081
+       17 $"Show firewall")
993 1082
 
994 1083
     # shellcheck disable=SC2068
995 1084
     selection=$(dialog --backtitle $"Freedombone Administrator Control Panel" --title $"Security Settings" --menu $"Choose an operation, or ESC to exit:" 24 76 24 "${W[@]}" 3>&2 2>&1 1>&3)
@@ -1014,13 +1103,17 @@ function menu_security_settings {
1014 1103
 
1015 1104
     case $selection in
1016 1105
         1)
1106
+            view_or_change_passwords
1107
+            exit 0;
1108
+            ;;
1109
+        2)
1017 1110
             clear
1018 1111
             echo $'Running STIG tests...'
1019 1112
             echo ''
1020 1113
             ${PROJECT_NAME}-tests --stig showall
1021 1114
             exit 0
1022 1115
             ;;
1023
-        2)
1116
+        3)
1024 1117
             clear
1025 1118
             echo $'Fixing any STIG failures...'
1026 1119
             echo ''
@@ -1028,54 +1121,54 @@ function menu_security_settings {
1028 1121
             echo $'Fixes applied. You will need to run the STIG tests again to be sure that they were all fixed.'
1029 1122
             exit 0
1030 1123
             ;;
1031
-        3)
1124
+        4)
1032 1125
             dialog --title $"SSH host public keys" \
1033 1126
                    --msgbox "\\n$(get_ssh_server_key)" 12 60
1034 1127
             exit 0
1035 1128
             ;;
1036
-        4)
1129
+        5)
1037 1130
             menu_tor_bridges
1038 1131
             exit 0
1039 1132
             ;;
1040
-        5)
1133
+        6)
1041 1134
             store_passwords
1042 1135
             exit 0
1043 1136
             ;;
1044
-        6)
1137
+        7)
1045 1138
             export_passwords
1046 1139
             exit 0
1047 1140
             ;;
1048
-        7)
1141
+        8)
1049 1142
             regenerate_ssh_host_keys
1050 1143
             ;;
1051
-        8)
1144
+        9)
1052 1145
             regenerate_dh_keys
1053 1146
             ;;
1054
-        9)
1147
+        10)
1055 1148
             interactive_setup
1056 1149
             update_ciphersuite
1057 1150
             ;;
1058
-        10)
1151
+        11)
1059 1152
             create_letsencrypt
1060 1153
             ;;
1061
-        11)
1154
+        12)
1062 1155
             renew_letsencrypt
1063 1156
             ;;
1064
-        12)
1157
+        13)
1065 1158
             delete_letsencrypt
1066 1159
             ;;
1067
-        13)
1160
+        14)
1068 1161
             enable_monkeysphere
1069 1162
             ;;
1070
-        14)
1163
+        15)
1071 1164
             register_website
1072 1165
             ;;
1073
-        15)
1166
+        16)
1074 1167
             allow_ssh_passwords
1075 1168
             change_ssh_settings
1076 1169
             exit 0
1077 1170
             ;;
1078
-        16)
1171
+        17)
1079 1172
             show_firewall
1080 1173
             exit 0
1081 1174
             ;;

+ 41
- 0
src/freedombone-utils-passwords 파일 보기

@@ -39,6 +39,47 @@ MINIMUM_PASSWORD_LENGTH=10
39 39
 # The default password length used in images
40 40
 DEFAULT_PASSWORD_LENGTH=20
41 41
 
42
+function passwords_select_user {
43
+    SELECTED_USERNAME=
44
+
45
+    # shellcheck disable=SC2207
46
+    users_array=($(ls /home))
47
+
48
+    delete=(git)
49
+    # shellcheck disable=SC2068
50
+    for del in ${delete[@]}
51
+    do
52
+        # shellcheck disable=SC2206
53
+        users_array=(${users_array[@]/$del})
54
+    done
55
+
56
+    i=0
57
+    W=()
58
+    name=()
59
+    # shellcheck disable=SC2068
60
+    for u in ${users_array[@]}
61
+    do
62
+        if [[ $(is_valid_user "$u") == "1" ]]; then
63
+            i=$((i+1))
64
+            W+=("$i" "$u")
65
+            name+=("$u")
66
+        fi
67
+    done
68
+
69
+    if [ $i -eq 1 ]; then
70
+        SELECTED_USERNAME="${name[0]}"
71
+    else
72
+        # shellcheck disable=SC2068
73
+        user_index=$(dialog --backtitle $"Freedombone Control Panel" --title $"Select User" --menu $"Select one of the following:" 24 40 17 ${W[@]} 3>&2 2>&1 1>&3)
74
+
75
+        # shellcheck disable=SC2181
76
+        if [ $? -eq 0 ]; then
77
+            # shellcheck disable=SC2034
78
+            SELECTED_USERNAME="${name[$((user_index-1))]}"
79
+        fi
80
+    fi
81
+}
82
+
42 83
 function enforce_good_passwords {
43 84
     # because humans are generally bad at choosing passwords
44 85
     if [[ $(is_completed "${FUNCNAME[0]}") == "1" ]]; then