the-djmaze/snappymail

Admin panel is broken.

Smiley-McSmiles opened this issue · 3 comments

Describe the bug
After launching the admin panel, grabbing the admin_password.txt content. I can log in, but after I change the password (Which is explicitly recommended) I can no longer log into the admin panel with my new password. Instead I'm given the error authentication failed I've restarted httpd as well and still no go. I tried clearing my browsers history and cookies, even installed a new browser just to test, and it will not accept the new password.

To Reproduce

#!/bin/bash

# Define variables
WEBSITE_URL="mail.example.com"
INSTALL_DIR="/var/www/html/webmail/"
APACHE_CONF="/etc/httpd/conf.d/snappymail.conf"
CADDY_CONF="/etc/caddy/Caddyfile"
NGINX_CONF="/etc/nginx/conf.d/mail.example.com.conf"
PACKAGES_NEEDED="php-mbstring php-zlib php-json php-libxml php-dom"

# Install needed packages
dnf install $PACKAGES_NEEDED

# Create the installation directory
mkdir -p $INSTALL_DIR

# Download the latest release of SnappyMail
cd /tmp
wget https://snappymail.eu/repository/latest.tar.gz
tar -xzf latest.tar.gz -C $INSTALL_DIR
rm latest.tar.gz
cd -

# Set correct permissions for the files and directories
find $INSTALL_DIR -type d -exec chmod 755 {} \;
find $INSTALL_DIR -type f -exec chmod 644 {} \;
chown -R apache:apache $INSTALL_DIR

# Configure Apache to serve SnappyMail
sed -i.bak '/^#Listen.*/a Listen 8060' /etc/httpd/conf/httpd.conf
echo '<VirtualHost *:8060>
    DocumentRoot /var/www/html/webmail/

    <Directory /var/www/html/webmail/>
        Require all granted
        AllowOverride All
        Options FollowSymLinks MultiViews
    </Directory>

    <IfModule mod_headers.c>
        Header always set Strict-Transport-Security "max-age=15552000; includeSubDomains"
    </IfModule>
</VirtualHost>' | sudo tee $APACHE_CONF

# Configure Caddy reverse proxy
echo '
mail.familytime.lol {
  	reverse_proxy localhost:8060
}' | sudo tee -a $CADDY_CONF

# Configure NGINX reverse proxy as a backup to Caddy
echo 'server {
    server_name mail.example.com;
    
    # HTTP configuration
    listen 80;
        
    location / {
        proxy_pass http://127.0.0.1:8060;
        proxy_redirect off;
        proxy_set_header Host $http_host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_read_timeout 900;
    }
}' | sudo tee $NGINX_CONF

# Firewall Rules
firewall-cmd --permanent --add-port=8060/tcp
firewall-cmd --reload

# SELinux Rules
semanage port -a -t http_port_t -p tcp 8060
semanage fcontext -a -t httpd_sys_rw_content_t '/var/www/html/webmail(/.*)?'
semanage fcontext -a -t httpd_sys_rw_content_t '/var/www/html/webmail/snappymail(/.*)?'
semanage fcontext -a -t httpd_sys_rw_content_t '/var/www/html/webmail/data(/.*)?'
semanage fcontext -a -t httpd_sys_rw_content_t '/var/www/html/webmail/.htaccess'
semanage fcontext -m -t httpd_sys_rw_content_t  "/var/www/html/webmail(/.*)?"
restorecon -R '/var/www/html/webmail/'
setsebool -P httpd_can_network_connect on
chcon -Rt httpd_sys_rw_content_t /var/www/html/webmail

# Restart Apache and Caddy to apply the changes
systemctl restart php-fpm httpd caddy

# Inform the user about the next steps
echo "SnappyMail has been installed successfully."
echo "You can access it at https://$WEBSITE_URL"
echo "Please configure your mail server settings in the admin UI:"
echo "https://$WEBSITE_URL/?admin"

Expected behavior
To login with username "admin" and password "myNewPassword"

Please complete the following information:

  • Browser: Firefox 131.0.2 (64-bit)
  • SnappyMail Version: 2.38.2
  • Mode: bare-metal
  • OS: Fedora Server

And you changed the password through www.yourdomain.com/webmail?admin and not the txt file?

And you changed the password through www.yourdomain.com/webmail?admin and not the txt file?

Yep

Tested and everything works as expected.
Please try again by removing the application.ini and follow the steps from the documentation.
https://github.com/the-djmaze/snappymail/wiki/Installation-instructions#now-access-the-admin-page