Browse Source

Show onion email address on user control panel

Bob Mottram 7 years ago
parent
commit
a9c16b9986
5 changed files with 41 additions and 6 deletions
  1. 1
    0
      Makefile
  2. 7
    3
      src/freedombone-base-email
  3. 18
    3
      src/freedombone-controlpanel-user
  4. 1
    0
      src/freedombone-upgrade
  5. 14
    0
      src/freedombone-utils-web

+ 1
- 0
Makefile View File

@@ -50,6 +50,7 @@ install:
50 50
 	chmod -R +r /usr/share/${APP}
51 51
 #	bash -c "./translate install"
52 52
 	/usr/local/bin/${APP}-prepare-scripts
53
+	# copy email onion domain to somewhere where it's accessible to users
53 54
 uninstall:
54 55
 	rm -f ${PREFIX}/share/${APP}_*.png
55 56
 	rm -f ${PREFIX}/share/man/man1/backup.1.gz

+ 7
- 3
src/freedombone-base-email View File

@@ -225,6 +225,7 @@ function email_create_template {
225 225
 }
226 226
 
227 227
 function create_email_onion_address {
228
+    email_hostname='/var/lib/tor/hidden_service_email/hostname'
228 229
     if ! grep -q "hidden_service_email" /etc/tor/torrc; then
229 230
         { echo 'HiddenServiceDir /var/lib/tor/hidden_service_email/';
230 231
           echo 'HiddenServiceVersion 3';
@@ -238,18 +239,21 @@ function create_email_onion_address {
238 239
         function_check wait_for_onion_service
239 240
         wait_for_onion_service email
240 241
 
241
-        if [ ! -f /var/lib/tor/hidden_service_email/hostname ]; then
242
+        if [ ! -f $email_hostname ]; then
242 243
             echo $"email onion site hostname not found"
243 244
             systemctl restart tor
244 245
             exit 782352
245 246
         fi
246 247
 
247
-        onion_address=$(cat /var/lib/tor/hidden_service_email/hostname)
248
+        onion_address=$(cat $email_hostname)
248 249
         set_completion_param "email onion domain" "${onion_address}"
249 250
         add_email_hostname "$onion_address"
250 251
     else
251
-        onion_address=$(cat /var/lib/tor/hidden_service_email/hostname)
252
+        onion_address=$(cat $email_hostname)
252 253
     fi
254
+    cp $email_hostname /etc/skel/.email_onion_domain
255
+    cp $email_hostname "/home/$MY_USERNAME/.email_onion_domain"
256
+    chown "$MY_USERNAME":"$MY_USERNAME" "/home/$MY_USERNAME/.email_onion_domain"
253 257
 }
254 258
 
255 259
 function configure_email_onion {

+ 18
- 3
src/freedombone-controlpanel-user View File

@@ -852,10 +852,25 @@ function menu_run_client_app {
852 852
 function show_your_email_address {
853 853
     GPG_FINGERPRINT=$(gpg --fingerprint "$GPG_ID" | sed -n '2p' | sed 's/^[ \t]*//')
854 854
     GPG_DATE=$(gpg --fingerprint "$GPG_ID" | grep -i "pub" | head -n 1 | awk -F ' ' '{print $3}')
855
+    onion_domain=
856
+    if [ -f "$HOME/.email_onion_domain" ]; then
857
+        onion_domain=$(cat "$HOME/.email_onion_domain")
858
+    fi
859
+    if [[ "$HOSTNAME" != *'.onion' && "$onion_domain" ]]; then
860
+        msgstr=$"Email Address: $MY_EMAIL_ADDRESS\\n\\nOnion Email: ${USER}@${onion_domain}\\n\\nKey ID: $GPG_ID\\n\\nFingerprint: $GPG_FINGERPRINT\\n\\nCreated: $GPG_DATE"
861
+    else
862
+        msgstr=$"Email Address: $MY_EMAIL_ADDRESS\\n\\nKey ID: $GPG_ID\\n\\nFingerprint: $GPG_FINGERPRINT\\n\\nCreated: $GPG_DATE"
863
+    fi
855 864
     if [ ! -f ~/.mutt/bdsmail ]; then
856
-        dialog --title $"Show your Email Address" \
857
-               --backtitle $"Freedombone User Control Panel" \
858
-               --msgbox $"Email Address: $MY_EMAIL_ADDRESS\\n\\nKey ID: $GPG_ID\\n\\nFingerprint: $GPG_FINGERPRINT\\n\\nCreated: $GPG_DATE" 12 100
865
+        if [[ "$HOSTNAME" != *'.onion' ]]; then
866
+            dialog --title $"Show your Email Address" \
867
+                   --backtitle $"Freedombone User Control Panel" \
868
+                   --msgbox "$msgstr" 14 100
869
+        else
870
+            dialog --title $"Show your Email Address" \
871
+                   --backtitle $"Freedombone User Control Panel" \
872
+                   --msgbox "$msgstr" 12 100
873
+        fi
859 874
     else
860 875
         bdsmail_address=$(grep 'set from=' ~/.mutt/bdsmail | awk -F '=' '{print $2}')
861 876
         dialog --title $"Show your Email Address" \

+ 1
- 0
src/freedombone-upgrade View File

@@ -102,6 +102,7 @@ if [ -d "$PROJECT_DIR" ]; then
102 102
         email_install_tls
103 103
         email_disable_chunking
104 104
         rm /etc/exim4/exim4.conf.template.bak*
105
+        email_update_onion_domain
105 106
         #defrag_filesystem
106 107
 
107 108
         # reinstall tor from backports

+ 14
- 0
src/freedombone-utils-web View File

@@ -1006,6 +1006,20 @@ function email_disable_chunking {
1006 1006
     systemctl restart exim4
1007 1007
 }
1008 1008
 
1009
+function email_update_onion_domain {
1010
+    email_hostname='/var/lib/tor/hidden_service_email/hostname'
1011
+
1012
+    cp $email_hostname /etc/skel/.email_onion_domain
1013
+
1014
+    for d in /home/*/ ; do
1015
+        USERNAME=$(echo "$d" | awk -F '/' '{print $3}')
1016
+        if [[ $(is_valid_user "$USERNAME") == "1" ]]; then
1017
+            cp $email_hostname "/home/$USERNAME/.email_onion_domain"
1018
+            chown "$USERNAME":"$USERNAME" "/home/$USERNAME/.email_onion_domain"
1019
+        fi
1020
+    done
1021
+}
1022
+
1009 1023
 function email_install_tls {
1010 1024
     tls_config_file=/etc/exim4/conf.d/main/03_exim4-config_tlsoptions
1011 1025
     tls_auth_config_file=/etc/exim4/conf.d/auth/30_exim4-config_examples