Commit Diff
Diff:
8f114ba73b0d676fcccf561a65b2ab3d0437f44a
b3cb5043dae10698e5812efbe314ee5b39cdc726
Commit:
b3cb5043dae10698e5812efbe314ee5b39cdc726
Tree:
7fd3e0134de218a80d5a53d9f9361b25a2011c61
Author:
jrmu <jrmu@ircnow.org>
Committer:
jrmu <jrmu@ircnow.org>
Date:
Mon Mar 6 21:21:52 2023 UTC
Message:
Fixes for Mail.pm
blob - 998a9f356779d0206a285511fd55fc2242c09c77
blob + e2a2e49708d7f2cbe3208ffc1d3a564681825043
--- Mail.pm
+++ Mail.pm
@@ -28,8 +28,7 @@ my $virtualspath = "/etc/mail/virtuals";
my $senderspath = "/etc/mail/users";
my @users;
-### TODO: Turn this back on once stable ###
-#main::cbind("msg", "-", "mail", \&mmail);
+main::cbind("msg", "-", "mail", \&mmail);
sub init {
#dependencies for encrypt
@@ -75,9 +74,13 @@ sub mmail {
$line =~ s/^#(${username}\@${hostname}.*)/$1/;
}
# trailing newline necessary
- main::writefile("$passwdpath.bak", join("\n", @passwd)."\n");
- copy "${passwdpath}.bak", $passwdpath;
+ my $passwdfile = join("\n", @passwd)."\n" ;
+ `doas sh -c 'echo "$passwdfile" > $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");
}
@@ -119,8 +122,11 @@ sub mmail {
$line =~ s/^(${username}\@${hostname}.*)/#$1/;
}
# trailing newline necessary
- main::writefile("$passwdpath.bak", join("\n", @passwd)."\n");
- copy "${passwdpath}.bak", $passwdpath;
+ 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::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) {
@@ -269,12 +275,20 @@ sub deletemail {
@senders = grep !/^${username}\@${hostname}/, @virtuals;
# trailing newline necessary
- 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;
+ 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;
`doas rcctl restart smtpd`;
`doas rcctl reload dovecot`;
IRCNow