Commit Diff
Diff:
e33dee5851263cb9db277815cf84c10248c3ac8b
717afa50377a0eb642dc71831db47fa4975da252
Commit:
717afa50377a0eb642dc71831db47fa4975da252
Tree:
4536fabf34809a1efca55ff5dad2478fa54cfd9d
Author:
jrmu <jrmu@ircnow.org>
Committer:
jrmu <jrmu@ircnow.org>
Date:
Sun Mar 5 19:34:27 2023 UTC
Message:
Make it easier to activate accounts
blob - f839c18b2355c81cab92af16f974f2a0a4187477
blob + 243d58f4a7ab7feb4e7f5d37b07ba638c8fdb131
--- BNC.pm
+++ BNC.pm
@@ -118,6 +118,12 @@ sub mbnc {
}
}
return;
+ } elsif (main::isstaff($bot, $nick) && $text =~ /^activate\s+([[:ascii:]]+)/) {
+ my $username = $1;
+ main::putserv($bot, "PRIVMSG *blockuser :unblock $username");
+ foreach my $chan (@teamchans) {
+ main::putserv($bot, "PRIVMSG $chan :$username bnc activated");
+ }
} elsif ($staff =~ /$nick/ && $text =~ /^cloneuser$/i) {
main::putserv($bot, "PRIVMSG *controlpanel :deluser cloneuser");
sleep 3;
blob - 923d9533237e710b37e4258afedb9550a920e854
blob + 56d1345f5b4e4a48a21820d5005396962373f045
--- Shell.pm
+++ Shell.pm
@@ -24,6 +24,7 @@ my $terms = $conf{terms};
my $expires = $conf{expires};
my $mailfrom = $conf{mailfrom};
my $mailname = $conf{mailname};
+my $approval = $conf{approval};
my $passpath = "/etc/passwd";
my $httpdconfpath = "/etc/httpd.conf";
my $acmeconfpath = "/etc/acme-client.conf";
@@ -34,6 +35,12 @@ my $endPort;
main::cbind("pub", "-", "shell", \&mshell);
main::cbind("msg", "-", "shell", \&mshell);
+# Returns yesterday's date in MMDDYYYY format
+sub yesterday {
+ my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime();
+ my $localtime = sprintf("%02d%02d%04d", $mon+1, $mday-1, $year+1900);
+ return $localtime;
+}
sub init {
#dependencies for figlet
unveil("/usr/local/bin/figlet", "rx") or die "Unable to unveil $!";
@@ -49,6 +56,7 @@ sub init {
unveil("/bin/chmod", "rx") or die "Unable to unveil $!";
unveil("/usr/sbin/groupadd", "rx") or die "Unable to unveil $!";
unveil("/usr/sbin/useradd", "rx") or die "Unable to unveil $!";
+ unveil("/usr/sbin/usermod", "rx") or die "Unable to unveil $!";
unveil("/usr/sbin/groupdel", "rx") or die "Unable to unveil $!";
unveil("/usr/sbin/userdel", "rx") or die "Unable to unveil $!";
unveil("/bin/mkdir", "rx") or die "Unable to unveil $!";
@@ -87,6 +95,12 @@ sub mshell {
}
}
return;
+ } elsif (main::isstaff($bot, $nick) && $text =~ /^activate\s+([[:ascii:]]+)/) {
+ my $username = $1;
+ system "doas usermod -e 0 -s /bin/ksh $username";
+ foreach my $chan (@teamchans) {
+ main::putserv($bot, "PRIVMSG $chan :$username activated");
+ }
}
### TODO: Check duplicate emails ###
my @rows = SQLite::selectrows("irc", "nick", $nick);
@@ -120,7 +134,19 @@ sub mshell {
createshell($username, $pass, $bindhost);
mailshell($username, $email, $pass, "shell", $version);
main::putserv($bot, "PRIVMSG $nick :Check your email!");
+ if ($approval eq "true") {
+ my $yesterday = yesterday();
+ system "doas usermod -e $yesterday -s /sbin/nologin $username";
+ 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) {
+ main::putservlocalnet($bot, "PRIVMSG $chan :$staff: $nick\'s account $username must be manually unblocked before it can be used.");
+ }
+ }
+ foreach my $chan (@teamchans) {
+ main::putservlocalnet($bot, "PRIVMSG $chan :$nick\'s shell registration of $username on $bot->{name} was successful, please help him connect");
+ }
+
#www($newnick, $reply, $password, "bouncer");
} else {
foreach my $chan (@teamchans) {
IRCNow