<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">
do 'mailboxes-lib.pl';

# useradmin_create_user(&amp;details)
# Create a new empty mail file
sub useradmin_create_user
{
if ($config{'sync_create'} &amp;&amp; !&amp;test_mail_system()) {
	local ($dir, $style, $mailbox, $maildir) = &amp;get_mail_style();
	if ($dir &amp;&amp; -d $dir) {
		# Create mail file like /var/mail/USERNAME
		local $mf = &amp;mail_file_style($_[0]-&gt;{'user'}, $dir, $style);
		if (!-e $mf) {
			&amp;create_mail_file($_[0], $mf);
			}
		}
	if ($mailbox &amp;&amp; !-e "$_[0]-&gt;{'home'}/$mailbox") {
		# Create mail file ~USERNAME/Mailbox
		&amp;create_mail_file($_[0], "$_[0]-&gt;{'home'}/$mailbox");
		}
	if ($maildir &amp;&amp; !-e "$_[0]-&gt;{'home'}/$maildir") {
		# Create mail directory like ~USERNAME/Maildir
		&amp;create_mail_dir($_[0], "$_[0]-&gt;{'home'}/$maildir");
		}
	}
}

# create_mail_file(&amp;user, file)
sub create_mail_file
{
open(TOUCH, "&gt;$_[1]");
close(TOUCH);
if ($config{'sync_perms'}) {
	system("chmod ".
	       quotemeta($config{'sync_perms'})." ".
	       quotemeta($_[1]));
	}
chown($_[0]-&gt;{'uid'}, $_[0]-&gt;{'gid'}, $_[1]);
}

# create_mail_dir(&amp;user, dir)
sub create_mail_dir
{
local $d;
foreach $d ($_[1], "$_[0]/cur", "$_[1]/tmp", "$_[1]/new") {
	&amp;make_dir($d, 0700);
	if ($config{'sync_perms'}) {
		system("chmod ".
		       quotemeta($config{'sync_perms'})." ".
		       quotemeta($d));
		}
	chown($_[0]-&gt;{'uid'}, $_[0]-&gt;{'gid'}, $d);
	}
}



# useradmin_delete_user(&amp;details)
# Delete the user's mail file
sub useradmin_delete_user
{
if ($config{'sync_delete'} &amp;&amp; !&amp;test_mail_system()) {
	local ($dir, $style, $mailbox, $maildir) = &amp;get_mail_style();
	if ($dir &amp;&amp; -d $dir) {
		local $mf = &amp;mail_file_style($_[0]-&gt;{'user'}, $dir, $style);
		unlink($mf);
		unlink($mf.".pop");
		}
	&amp;delete_user_index_files($_[0]-&gt;{'user'});
	}
}

# useradmin_modify_user(&amp;details, &amp;old)
# Rename the user's mail file if necessary, and change it's UID
sub useradmin_modify_user
{
if ($config{'sync_modify'} &amp;&amp; !&amp;test_mail_system() &amp;&amp;
    ($_[0]-&gt;{'user'} ne $_[1]-&gt;{'user'} || $_[0]-&gt;{'uid'} != $_[1]-&gt;{'uid'})) {
	local ($dir, $style, $mailbox, $maildir) = &amp;get_mail_style();
	if ($dir &amp;&amp; -d $dir) {
		local $omf = &amp;mail_file_style($_[0]-&gt;{'olduser'}, $dir, $style);
		local $nmf = &amp;mail_file_style($_[0]-&gt;{'user'}, $dir, $style);
		local @st = stat($omf);
		if ($st[4] != $_[0]-&gt;{'uid'}) {
			chown($_[0]-&gt;{'uid'}, $st[5], $omf);
			}
		if ($omf ne $nmf &amp;&amp; -e $omf) {
			&amp;rename_logged($omf, $nmf);
			}
		}
	}
}

1;

</pre></body></html>