Ver código fonte

Changing the irc server password

Bob Mottram 8 anos atrás
pai
commit
645959f0fa
1 arquivos alterados com 23 adições e 0 exclusões
  1. 23
    0
      src/freedombone-app-irc

+ 23
- 0
src/freedombone-app-irc Ver arquivo

@@ -293,8 +293,31 @@ function irc_set_global_password {
293 293
                 fi
294 294
             done
295 295
 
296
+            read_config_param DEFAULT_DOMAIN_NAME
297
+            read_config_param IRC_PORT
298
+            read_config_param MY_USERNAME
299
+
300
+            stop_irc_bouncer
301
+            sleep 2
302
+
303
+            # change the hashes. There are multiple users, but since we're using a global
304
+            # password this doesn't matter
305
+            ZNC_SALT="$(dd if=/dev/urandom bs=16c count=1 | md5sum | awk -F ' ' '{print $1}' | cut -c1-20)"
306
+            new_user_hash=$(echo -n "${NEW_IRC_PASSWORD}${ZNC_SALT}" | sha256sum | awk -F ' ' '{print $1}')
307
+            sed -i "s|Hash = .*|Hash = ${new_user_hash}|g" /home/znc/.znc/configs/znc.conf
308
+            sed -i "s|Salt = .*|Salt = ${ZNC_SALT}|g" /home/znc/.znc/configs/znc.conf
309
+
310
+            # change the server password
311
+            sed -i "s|Server     = ${DEFAULT_DOMAIN_NAME}.*|Server     = ${DEFAULT_DOMAIN_NAME} ${IRC_PORT} ${NEW_IRC_PASSWORD}|g" /home/znc/.znc/configs/znc.conf
312
+
313
+            # Update the password in the readme
314
+            sed -i "s|IRC login password.*|IRC login password: $NEW_IRC_PASSWORD|g" /home/$MY_USERNAME/README
315
+
316
+            write_config_param "IRC_PASSWORD" "$NEW_IRC_PASSWORD"
317
+
296 318
             # restart the daemon for the new password to take effect
297 319
             systemctl restart ngircd
320
+            start_irc_bouncer
298 321
 
299 322
             dialog --title $"IRC Password" \
300 323
                    --msgbox $"The IRC password was changed" 6 40