Преглед изворни кода

Include optional mailsync address when adding other keyserver

Bob Mottram пре 7 година
родитељ
комит
d81cea2fe9
1 измењених фајлова са 23 додато и 3 уклоњено
  1. 23
    3
      src/freedombone-app-keyserver

+ 23
- 3
src/freedombone-app-keyserver Прегледај датотеку

@@ -160,6 +160,7 @@ function restore_local_keyserver {
160 160
     cp -r $temp_restore_dir/etc/sks/* /etc/sks/
161 161
     rm -rf $temp_restore_dir
162 162
     chown -Rc debian-sks: /etc/sks/sksconf
163
+    chown -Rc debian-sks: /etc/sks/mailsync
163 164
 
164 165
     temp_restore_dir=/root/tempkeyserver
165 166
     function_check restore_directory_from_usb
@@ -223,6 +224,7 @@ function restore_remote_keyserver {
223 224
     cp -r $temp_restore_dir/etc/sks/* /etc/sks/
224 225
     rm -rf $temp_restore_dir
225 226
     chown -Rc debian-sks: /etc/sks/sksconf
227
+    chown -Rc debian-sks: /etc/sks/mailsync
226 228
 
227 229
     temp_restore_dir=/root/tempkeyserver
228 230
     function_check restore_directory_from_friend
@@ -297,6 +299,12 @@ function install_interactive_keyserver {
297 299
     APP_INSTALLED=1
298 300
 }
299 301
 
302
+function keyserver_create_mailsync {
303
+    echo $"# List of email addresses which submitted keys will be forwarded to" > /etc/sks/mailsync
304
+    echo '' >> /etc/sks/mailsync
305
+    chown -Rc debian-sks: /etc/sks/mailsync
306
+}
307
+
300 308
 function keyserver_create_membership {
301 309
     if [ -f /etc/sks/membership ]; then
302 310
         return
@@ -343,9 +351,10 @@ function keyserver_sync {
343 351
     trap "rm -f $data" 0 1 2 5 15
344 352
     dialog --backtitle $"Freedombone Control Panel" \
345 353
            --title $"Sync with other keyserver" \
346
-           --form $"\nEnter details for the other server. Please be aware that it's not a good idea to sync with major keyservers which have exceptionally large databases. This is intended to sync with other $PROJECT_NAME systems each having a small database for a particular community." 15 60 2 \
347
-           $"Domain:" 1 1 "" 1 18 32 32 \
348
-           $"Port:" 2 1 "11370" 2 18 8 8 \
354
+           --form $"\nEnter details for the other server. Please be aware that it's not a good idea to sync with major keyservers which have exceptionally large databases. This is intended to sync with other $PROJECT_NAME systems each having a small database for a particular community." 16 60 3 \
355
+           $"Domain:" 1 1 "" 1 25 32 64 \
356
+           $"Port:" 2 1 "11370" 2 25 6 6 \
357
+           $"Sync Email (optional):" 3 1 "pgp-public-keys@" 3 25 32 64 \
349 358
            2> $data
350 359
     sel=$?
351 360
     case $sel in
@@ -354,6 +363,7 @@ function keyserver_sync {
354 363
     esac
355 364
     other_keyserver_domain=$(cat $data | sed -n 1p)
356 365
     other_keyserver_port=$(cat $data | sed -n 2p)
366
+    other_keyserver_email=$(cat $data | sed -n 3p)
357 367
     if [[ "$other_keyserver_domain" != *'.'* ]]; then
358 368
         return
359 369
     fi
@@ -372,6 +382,15 @@ function keyserver_sync {
372 382
     if [ ${#other_keyserver_port} -lt 4 ]; then
373 383
         return
374 384
     fi
385
+    if [[ "$other_keyserver_email" != "pgp-public-keys@" ]]; then
386
+        if [[ "$other_keyserver_email" == *"@"* ]]; then
387
+            keyserver_create_mailsync
388
+            if ! grep -q "$other_keyserver_email" /etc/sks/mailsync; then
389
+                echo "$other_keyserver_email" >> /etc/sks/mailsync
390
+                chown -Rc debian-sks: /etc/sks/mailsync
391
+            fi
392
+        fi
393
+    fi
375 394
     keyserver_create_membership
376 395
     if grep -q "$other_keyserver_domain $other_keyserver_port" /etc/sks/membership; then
377 396
         return
@@ -686,6 +705,7 @@ function install_keyserver {
686 705
     if ! grep -q "pgp-public-keys" /etc/aliases; then
687 706
         echo 'pgp-public-keys:      "|/usr/lib/sks/sks_add_mail /etc/sks"' >> /etc/aliases
688 707
     fi
708
+    chown -Rc debian-sks: /etc/sks/mailsync
689 709
 
690 710
     systemctl enable sks
691 711
     systemctl restart sks