# Copyright 2001-2003, 2009 Roland Mas <lolando@debian.org>
# Copyright 2003, 2004, Christian Bayle <bayle@debian.org>
# Copyright 2005, INRIA (David Margery and Soraya Arias)
+# Copyright 2012, Franck Villaume - TrivialDev
use DBI ;
use strict ;
$dbh->commit () ;
}
+ $query = "SELECT mail_group_list.group_list_id,
+ mail_group_list.list_name,
+ users.user_name,
+ mail_group_list.password,
+ mail_group_list.description,
+ mail_group_list.is_public
+ FROM mail_group_list, users
+ WHERE mail_group_list.status = 5
+ AND mail_group_list.list_admin = users.user_id" ; # Status = 5: configuration change requested
+ $sth = $dbh->prepare ($query) ;
+ $sth->execute () ;
+ @lines = () ;
+ while (my @myarray = $sth->fetchrow_array ()) {
+ push @lines, \@myarray ;
+ }
+ $sth->finish () ;
+ foreach $line (@lines) {
+ @array = @{$line} ;
+ my ($group_list_id, $listname, $user_name, $password, $description, $is_public) ;
+ my ($tmp) ;
+ $tmp = mktemp ("/tmp/XXXXXX") ;
+ $cmd = "/usr/lib/mailman/bin/config_list -o $tmp $listname" ;
+ #print "cmd = <$cmd>\n" ;
+# Commented out on Matt Hope <dopey@debian.org> advice
+# To be revised by Roland Mas
+# system ($cmd) ;
+ open CONFIG, ">>$tmp" ;
+ print CONFIG "description = \"$description\"\n" ;
+ print CONFIG "host_name = '$sys_lists_host'\n" ;
+ if (!$is_public) {
+ print CONFIG "archive_private = True\n" ;
+ print CONFIG "advertised = False\n" ;
+ print CONFIG "subscribe_policy = 3\n" ;
+ ## Reject mails sent by non-members
+ print CONFIG "generic_nonmember_action = 2\n";
+ ## Do not forward auto discard message
+ print CONFIG "forward_auto_discards = 0\n";
+ } else {
+ print CONFIG "archive_private = False\n" ;
+ print CONFIG "advertised = True\n" ;
+ print CONFIG "subscribe_policy = 1\n" ;
+ }
+ close CONFIG ;
+ $cmd = "/usr/lib/mailman/bin/config_list -i $tmp $listname" ;
+ #print "cmd = <$cmd>\n" ;
+ system ($cmd) ;
+ unlink $tmp ;
+
+ $query = "UPDATE mail_group_list SET status = 3 where group_list_id = group_list_id" ; # Status = 3: list configured on Mailman
+ $sth = $dbh->prepare ($query) ;
+ $sth->execute () ;
+ $sth->finish () ;
+
+ #debug "Committing." ;
+ $dbh->commit () ;
+ }
+
# There should be a commit at the end of every block above.
# If there is not, then it might be symptomatic of a problem.
# For safety, we roll back.
# Begin functions
###############################################
+#############################
+# Helper Function
+#############################
+sub run_verbose {
+ my $thecmd = shift(@_);
+
+ if ($verbose) {
+ print "$thecmd\n";
+ }
+ return system($thecmd);
+}
+
#############################
# User Add Function
#############################
my $username = shift(@_);
my $alreadydone=(-f "/var/lib/gforge/tmp/$username.tar.gz");
- if (!$alreadydone){
- if($verbose){print("Deleting User : $username\n")};
- if($verbose){print("/bin/mv /var/lib/gforge/chroot/home/users/$username /var/lib/gforge/chroot/home/users/deleted_$username\n")};
- system("/bin/mv /var/lib/gforge/chroot/home/users/$username /var/lib/gforge/chroot/home/users/deleted_$username");
- if($verbose){print("/bin/tar -czf /var/lib/gforge/tmp/$username.tar.gz /var/lib/gforge/chroot/home/users/deleted_$username && /bin/rm -rf /var/lib/gforge/chroot/home/users/deleted_$username\n")};
- system("/bin/tar -czf /var/lib/gforge/tmp/$username.tar.gz /var/lib/gforge/chroot/home/users/deleted_$username && /bin/rm -rf /var/lib/gforge/chroot/home/users/deleted_$username");
+ if (!$alreadydone) {
+ my $oldmask = umask(077);
+ if ($verbose) {
+ print("Deleting User : $username\n");
+ }
+ run_verbose("/bin/mv /var/lib/gforge/chroot/home/users/$username /var/lib/gforge/chroot/home/users/deleted_$username");
+ run_verbose("cd / && /bin/tar -cf - /var/lib/gforge/chroot/home/users/deleted_$username | /bin/gzip -n9 >/var/lib/gforge/tmp/$username.tar.gz && /bin/rm -rf /var/lib/gforge/chroot/home/users/deleted_$username");
+ umask($oldmask);
}
}