A certain caution needs to be exercised however.  I have a security 
fettish and I find the nonchalance of passwords in scripts a bit 
alarming (unless, of course, they are readable/executable only by 
root).

A simple solution is to have the script prompt the user for the IMAP 
admin password instead of supplying it in the script.  This is actually 
better than root only read/execute since the email adminstrator need 
not have root access to create email accounts.  (Sudo is a wonderful 
tool, but even better when no root access is required.)

-- Rob


--On Thursday, August 23, 2001 11:57:03 AM -0300 Patrick Boutilier 
<[EMAIL PROTECTED]> wrote:

> I use the following perl script to create users: (Put in valid
> userid/passwd for $user and $pass)
>
>
>
>
>
> #!/usr/bin/perl -w
> # adduser.pl
> # Usage: adduser.pl newuser
> #
>     use File::Basename;
>     use Net::IMAP;
>  $newuser = "user.$ARGV[0]";
> $user = "user";
> $pass = "password";
>      # Set this to the hostname of your IMAP server
> #    $IMAPSERVER = "142.227.51.106";
>     $IMAPSERVER = "localhost";
>     #
>     # Main Code
>     #
>     # Login to IMAP server
>     $imap = new Net::IMAP($IMAPSERVER, Synchronous => 1) || die "no
> go $! !";     $response = $imap->login($user, $pass);
>     print "Login: ", $response->status, "-", $response->status_text,
> "\n";      # Create the new mailbox
>     $response = $imap->create($newuser);
>     print "Create: ", $response->status, "-", $response->status_text,
> "\n";      # Disconnect from IMAP server
>     $response = $imap->logout();
>     print "Logout: ", $response->status, "-", $response->status_text,
> "\n";
>
>
> Sandra Regina wrote:
>
>> I have been searching the archive messages for a script to create
>> mailbox,  but I have found it only in TCL. I have read on man pages
>> that  cyradm in tcl is not supported any more.
>> Does anyone has the following script  in Perl ?
>>
>> Thanks a lot
>>
>> Sandra
>>
>> su first
>> cyradm -file adduser.tcl
>>
>> if {$argc != 1} {
>>   puts "usage: No user list specifiled."
>>   exit 1
>> }
>>
>> set infile [lindex $argv 0 ]
>> set quota 512
>>
>> eval cyradm connect cyr_conn host
>> eval cyr_conn authenticate -pwcommand {{
>>   set hostname "myhost"
>>   set adminid "cyrus"
>>   set adminpw "the password"
>>   list $adminid $adminpw
>>   }
>> }
>>
>> if [catch {open $infile} IN] {
>>   puts stderr "Can not open file $infile: $IN"
>>   exit 1
>> }
>>
>> while {[gets $IN mailbox] >= 0} {
>>   exec /usr/sbin/adduser -batch $mailbox email $mailbox $mailbox
>>   cyr_conn createmailbox user.$mailbox
>>   cyr_conn setquota user.$mailbox storage $quota
>>   cyr_conn createmailbox user.$mailbox.sentmail
>> }
>> close $IN
>>
>>
>>
>
>
>




       _ _ _ _           _    _ _ _ _ _
      /\_\_\_\_\        /\_\ /\_\_\_\_\_\
     /\/_/_/_/_/       /\/_/ \/_/_/_/_/_/  QUIDQUID LATINE DICTUM SIT,
    /\/_/__\/_/ __    /\/_/    /\/_/          PROFUNDUM VIDITUR
   /\/_/_/_/_/ /\_\  /\/_/    /\/_/
  /\/_/ \/_/  /\/_/_/\/_/    /\/_/         (Whatever is said in Latin
  \/_/  \/_/  \/_/_/_/_/     \/_/              appears profound)

  Rob Tanner
  UNIX and Networks Manager
  Linfield College, McMinnville OR
  (503) 434-2558 <[EMAIL PROTECTED]>


Reply via email to