commit a03f914c51349e9583d4f6dc23fcf7e10eef2ab4 from: jrmu date: Mon Mar 06 21:56:20 2023 UTC Cleaned up Mail.pm writes to files commit - 3ed8dff61e72f3f14714b13044041803666ecdc7 commit + a03f914c51349e9583d4f6dc23fcf7e10eef2ab4 blob - e2a2e49708d7f2cbe3208ffc1d3a564681825043 blob + d41998e5bf507817e9f1f30711ae7881ff6a06d8 --- Mail.pm +++ Mail.pm @@ -74,13 +74,9 @@ sub mmail { $line =~ s/^#(${username}\@${hostname}.*)/$1/; } # trailing newline necessary - my $passwdfile = join("\n", @passwd)."\n" ; - `doas sh -c 'echo "$passwdfile" > $passwdpath'`; + main::writefile("$passwdpath.bak", join("\n", @passwd)."\n"); + copy "${passwdpath}.bak", $passwdpath; - # below code won't work due to file permissions - #main::writefile("$passwdpath.bak", join("\n", @passwd)."\n"); - #copy "${passwdpath}.bak", $passwdpath; - foreach my $chan (@teamchans) { main::putserv($bot, "PRIVMSG $chan :$username mail approved"); } @@ -122,11 +118,8 @@ sub mmail { $line =~ s/^(${username}\@${hostname}.*)/#$1/; } # trailing newline necessary - my $passwdfile = join("\n", @passwd)."\n" ; - `doas sh -c 'echo "$passwdfile" > $passwdpath'`; - #below won't work due to permissions errors - #main::writefile("$passwdpath.bak", join("\n", @passwd)."\n"); - #copy "${passwdpath}.bak", $passwdpath; + main::writefile("$passwdpath.bak", join("\n", @passwd)."\n"); + copy "${passwdpath}.bak", $passwdpath; main::putserv($bot, "PRIVMSG $nick :Your account has been created but must be manually approved by your admins ($staff) before it can be used."); foreach my $chan (@teamchans) { @@ -275,20 +268,12 @@ sub deletemail { @senders = grep !/^${username}\@${hostname}/, @virtuals; # trailing newline necessary - my $passwdfile = join("\n", @passwd)."\n" ; - `doas sh -c 'echo "$passwdfile" > $passwdpath'`; - my $virtualsfile = join("\n", @virtuals)."\n" ; - `doas sh -c 'echo "$virtualsfile" > $virtualspath'`; - my $sendersfile = join("\n", @senders)."\n" ; - `doas sh -c 'echo "$sendersfile" > $senderspath'`; - - # below won't work due to permissions errors - #main::writefile("$passwdpath.bak", join("\n", @passwd)."\n"); - #copy "${passwdpath}.bak", $passwdpath; - #main::writefile("$virtualspath", join("\n", @virtuals)."\n"); - #copy "${virtualspath}.bak", $virtualspath; - #main::writefile("$senderspath", join("\n", @senders)."\n"); - #copy "${senderspath}.bak", $senderspath; + main::writefile("$passwdpath.bak", join("\n", @passwd)."\n"); + copy "${passwdpath}.bak", $passwdpath; + main::writefile("$virtualspath", join("\n", @virtuals)."\n"); + copy "${virtualspath}.bak", $virtualspath; + main::writefile("$senderspath", join("\n", @senders)."\n"); + copy "${senderspath}.bak", $senderspath; `doas rcctl restart smtpd`; `doas rcctl reload dovecot`;