ispconfig email login with user@domain How to

Discussion in 'Tips/Tricks/Mods' started by desmondk, Nov 2, 2006.

  1. advinser

    advinser New Member

    Yes, thath's all right

    I had an error in the script: now I write /etc/courier/userdb at the end of the line and it create finally the file (I have ubuntu 6.06 like you so the file is in the same place) but I've not the file userdb.db...

    Now the new problem: the test return "Authentication Failed!"

    Why?

    Thx for all!
     
  2. rojozak

    rojozak New Member

    Look in /etc/courier/ for userdb.db, It should be in there.

    Either way, check the final part of your script. It must have the make command to make the userdb.db file from userdb.

    Code:
    /usr/lib/courier/makeuserdb
    Also, if you can't get that part working in your script, you can run makeuserdb from the commandline, to be sure you can create that userdb.db
     
  3. advinser

    advinser New Member

    I have only userdb userdb.dat userdb.lock

    Into the makeuserdb there is no line for creating userdb.db but only this 3 files.

    Why?
     
  4. kassie

    kassie New Member

    Hi All,

    I have ubuntu 7.04 perfect install + ISPConfig 2.2.13.

    I would like to apply this patch. Will it work?

    Is there anybody that can take me through it step by step?? I am very new to linux. I see there is code in the post but i don't know what to do with this code....

    Please help!!!!!
     
  5. soho

    soho New Member



    In the case of multiples domain as to configure the DOMAIN in the ISPConfig?
     
  6. kassie

    kassie New Member

    Running this script now, It doesn't put any data to /etc/courier/userdb. No details in this file, means i have to access mail via domain_user.

    Please help again

    Here are my files
    /usr/sbin/usernames
    #!/bin/bash

    delim="_"

    OIFS=$IFS
    IFS="
    "
    rm -rf /etc/courier/userdb
    touch /etc/courier/userdb
    chmod 600 /etc/courier/userdb

    for line in `/usr/sbin/pw2userdb | grep -ir user`
    do
    full=$( echo $line )
    domain=$( echo $line | cut -d"$delim" -f1 )
    remain=$( echo $line | cut -d"$delim" -f2,3,4 )
    username=$( echo $remain | cut -d' ' -f1 )
    remain2=$( echo $remain | cut -d' ' -f2 )
    uid=$( echo $remain2 | cut -d'|' -f1 )
    gid=$( echo $remain2 | cut -d'|' -f2 )
    home=$( echo $remain2 | cut -d'|' -f3 )
    shell=$( echo $remain2 | cut -d'|' -f4 )
    password=$( echo $remain2 | cut -d'|' -f5)
    echo "$username@$domain $uid|$gid|$home|$shell|$password|/var/www/www.$domain/user/${domain}_$username/Maildir" >> /etc/courier/userdb
    done
    /usr/sbin/makeuserdb

    IFS=$OIFS


    /usr/sbin/pw2userdb

    #! /usr/bin/perl
    #
    # Convert /etc/passwd and /etc/shadow to userdb format.
    #
    # $Id: pw2userdb.in,v 1.5 2000/07/19 11:55:15 mrsam Exp $
    #
    # Copyright 1998 - 1999 Double Precision, Inc. See COPYING for
    # distribution information.

    use Getopt::Long;

    #
    # Some undocumented options here (for vchkpw2userdb)
    #

    die "Invalid options.\n" unless
    GetOptions("passwd=s" => \$passwd, "shadow=s" => \$shadow,
    "noshadow" => \$noshadow, "nouid" => \$nouid,
    "domain=s" => \$domain, "vpopuid" => \$vpopuid );

    ($dummy, $dummy, $fixed_uid, $fixed_gid)=getpwnam("vpopmail")
    if $vpopuid;

    $passwd="/etc/passwd" unless $passwd =~ /./;
    $shadow="/etc/shadow" unless $shadow =~ /./;

    $domain="" unless $domain =~ /./;
    $domain="\@$domain" if $domain =~ /./;

    open(PASSWD, $passwd) || die "$!\n";

    while (<PASSWD>)
    {
    chop if /\n$/;
    next if /^#/;
    ($acct,$passwd,$uid,$gid,$name,$home,$shell)=split ( /:/ );

    ($uid,$gid)=($fixed_uid,$fixed_gid) if $vpopuid;

    $PASSWORD{$acct}=$passwd if $passwd ne "x";
    $UID{$acct}=$uid;
    $GID{$acct}=$gid;
    $HOME{$acct}=$home;
    $SHELL{$acct}=$shell;

    $name =~ s/\|/./g; # Just in case
    $GECOS{$acct}=$name;
    }
    close (PASSWD);

    if ( -f $shadow && ! $noshadow)
    {
    open (SHADOW, $shadow) || die "$!\n";
    while (<SHADOW>)
    {
    next if /^#/;
    ($acct,$passwd,$dummy)=split(/:/);
    $PASSWORD{$acct}=$passwd;
    }
    close (SHADOW);
    }

    while ( defined ($key=each %UID))
    {
    print "$key$domain\tuid=$UID{$key}|gid=$GID{$key}|home=$ HOME{$key}" .
    ( $SHELL{$key} =~ /./ ? "|shell=$SHELL{$key}":"") .
    ( $PASSWORD{$key} =~ /./ ? "|systempw=$PASSWORD{$key}":"") .
    ( $GECOS{$key} =~ /./ ? "|gecos=$GECOS{$key}":"") .
    "\n";
    print "$UID{$key}=\t$key\n" unless $nouid;
    }
     
  7. erebus

    erebus New Member

    Hello,

    I have a "perfect setup" with Centos 4.5 and the latest stable ISPConfig.

    I have upgraded my dovecot to 1.0x so as to be able to use

    auth_username_format = %Ld_%Ln

    I have also set the [DOMAIN]_ in ISPConfig settings. However when I try to login from Uebimiau, I get the following error:

    Sep 25 22:15:48 nemesis dovecot: pop3-login: Disconnected: user=<_domain.gr_info>, method=PLAIN, rip=::ffff:127.0.0.1, lip=::ffff:127.0.0.1, secured

    (assume that the username I enter in the webmail is info@domain.gr).

    I suppose that the problem is the leading _, however I don't know how it appears there...

    Any help?

    P.S. If I comment out the auth_username_format line, everything works fine.
     
  8. till

    till Super Moderator

    If I remeber correctly, the uebimiau package tries to lookup the email address in the database and this fails when you modify the login format. This can not be switched of in the ISPConfig UbeiMiau package, the easiest solution might be to install another webmail program which is not modified to lookup usernames in the ISPConfig database.
     
  9. Acker

    Acker New Member

    Hi!

    I think i've managed to get the script for converting the users working. So my userdb file contains this row:

    test@server.com uid=10015|gid=10005|home=/var/www/web5/user/server.com_test|shell=/bin/false|systempw=gdfGefd4YUcGFg|/var/www/www.server.com/user/server.com_test/Maildir

    But courierauthtest test@server.com password brings:
    Trying authdaemon...
    Authentication FAILED!

    Any ideas?
    Thx,
    acker
     
  10. Melchior

    Melchior New Member

    Hello,

    I can't get the patch to work :(
    I think the problem is in the converter-script that creates the userdb for courier.

    I little modified the script to get debug messages:

    Code:
    #!/bin/bash
    delim="_"
    
    OIFS=$IFS
    IFS="
    "
    rm -rf /etc/courier/userdb
    touch /etc/courier/userdb
    chmod 600 /etc/courier/userdb
    for line in `pw2userdb | grep -ir user`
    do
    	clear
    	echo $line
    
    	domain=$( echo $line | cut -d"$delim" -f1 )
    	
    	useruid=$( echo $line | cut -d"$delim" -f2 )
    	
    	username=$( echo $useruid | cut -d'	' -f1 )
    	
    	uid=$( echo $useruid | cut -d'	' -f2 )
    	gid=$( echo $line | cut -d"$delim" -f3 )
    	home=$( echo $line | cut -d"$delim" -f4 )
    	shell=$( echo $line | cut -d"$delim" -f6 )
    	password=$( echo $line | cut -d"$delim" -f7)
    	
    	#echo "$username@$domain $uid|$gid|${home}_$username|$shell|$password| /var/www/www.$domain/user/${domain}_$username/Maildir" >> /etc/courier/userdb
    	
    	echo "
    	useruid: $useruid|
    	
    	domain: $domain 
    	username: $username
    	login: $username@$domain
    	
    	uid: $uid|
    	gid: $gid|
    	home: $home
    	homedir: ${home}_$username|
    	shell: $shell| 
    	pass: $password|
    	maildir /var/www/www.$domain/user/${domain}_$username/Maildir"
    	#/usr/sbin/makeuserdb
    done
    
    IFS=$OIFS
    
    And if I run the script with this single return of pw2userdb ...

    XXX.org_mar uid=10018|gid=10002|home=/var/www/web2/user/XXX.org_mar|shell=/bin/false|systempw=^iaesnI7fcz/.|gecos=mar

    ... I got this output.

    Code:
    
    XXX.org_mar      uid=10018|gid=10002|home=/var/www/web2/user/XXX.org_mar|shell=/bin/false|systempw=^iaesnI7fcz/.|gecos=mar
    
    
            useruid: mar uid=10018|gid=10002|home=/var/www/web2/user/XX.org|
    
            domain: XX.org 
            username: mar
            login: mar@XX.org
    
            uid: uid=10018|gid=10002|home=/var/www/web2/user/XX.org|
            gid: mar|shell=/bin/false|systempw=^iaesnI7fcz/.|gecos=mar|
            home: 
            homedir: _mar|
            shell: | 
            pass: |
            maildir /var/www/www.XX.org/user/XX.org_mar/Maildir
    
    Anybody an idea whats going wrong?
    Courier-Auth is opening the userdb, but can't find a valid login. I think the email-account was written down by wrong-syntax.

    I'am using ISPConfig 2.2.17 with Debian 4.0

    greetings! :D
    melchior
     
    Last edited: Oct 3, 2007
  11. till

    till Super Moderator

  12. Melchior

    Melchior New Member

    hi till,
    I am now using dovecot and its working very well :)

    but now there's another problem. The isp's email-username is limited to n-characters so I get in trouble while using 'large-email-adresses'

    in another post, grant is telling about a solution how to fix this by patching the couriers-user-workflow mentioned by desmondk in first post here.

    perhaps you know a working solution for dovecot? Would like to use it furthermore cause there's a webmin module available :)

    greetings,
    m.
     
  13. Rockdrala

    Rockdrala New Member


    Ah poop. lol.

    I just just saw. And ive already done the SMTP instructions posted in the other post.

    THe SMTP works trying to login from email clients but the pop doest becuase i havent done this step.

    Does anyone know what the = is in saslauthd/dovecot.
     
  14. bbrendon

    bbrendon New Member

    How do users login once they are set to administrators and the prefix is "[DOMAIN]_"
    I haven't been able to get users to login.
     
  15. hahni

    hahni New Member

    The for Ubuntu 8.04LTS und Ubuntu 10.04LTS modified Skript for "userdb"-Creation is:

    Code:
    #!/bin/bash
    # http://www.howtoforge.com/forums/showthread.php?t=7881&highlight=mailuser
    
    delim="_"
    
    OIFS=$IFS
    IFS="
    "
    
    rm -rf /etc/courier/userdb
    touch /etc/courier/userdb
    chmod 600 /etc/courier/userdb
    
    for line in `/usr/sbin/pw2userdb | grep -ir home=/var/www/web`
     do
       full=$( echo $line )
       domain=$( echo $line | cut -d"$delim" -f1 )
       remain=$( echo $line | cut -d"$delim" -f2,3,4 )
       username=$(echo $remain | cut -d "   " -f1 ) # tab inside
       remain2=$(echo $remain | cut -d "    " -f2 ) # tab inside
       uid=$( echo $remain2 | cut -d '|' -f1 )
       gid=$( echo $remain2 | cut -d '|' -f2 )
       home=$( echo $remain2 | cut -d '|' -f3 )
       shell=$( echo $remain2 | cut -d '|' -f4 )
       password=$( echo $remain2 | cut -d '|' -f5)
       echo "$username@$domain $uid|$gid|$home|$shell|$password|/var/www/www.$domain/user/${domain}_$username/Maildir" >> /etc/courier/userdb
       /usr/sbin/makeuserdb
     done
    
    IFS=$OIFS
    
    The content in /etc/courier/userdb is:

    Code:
    user1@domain.de uid=10014|gid=10006|home=/var/www/web6|shell=/bin/false|systempw=$1$CwvHHL@}$vLvpPKT6FN1Nxa1E5hDDC0|/var/www/www.domain.de/user/domain.de_werner/Maildir
    user1@domain.us uid=10013|gid=10003|home=/var/www/web3|shell=/bin/false|systempw=$1$QJqPJviI$JU3UO4bOF.vL7CotHntuh1|/var/www/www.domain.us/user/domain.us_michael/Maildir
    But the login does not work! What is wrong in the generated userdb-file?
     
    Last edited: Mar 25, 2011
  16. till

    till Super Moderator

    Which error message do you get in the mail.log? You can also try to enable debuggong in courier for more detailed error messages.
     
  17. hahni

    hahni New Member

    Hi Till,

    Thanks a lot for helping me. This is a part of the log:

    Code:
    Mar 25 16:21:32 server imapd: LOGIN FAILED, user=michael@domain.us, ip=[::ffff:127.0.0.1]
    Mar 25 16:21:37 server imapd: Disconnected, ip=[::ffff:127.0.0.1], time=5
    Mar 25 16:22:13 server imapd: Connection, ip=[::ffff:127.0.0.1]
    Mar 25 16:22:13 server imapd: LOGIN FAILED, user=michael@domain.us, ip=[::ffff:127.0.0.1]
    Mar 25 16:22:18 server imapd: Disconnected, ip=[::ffff:127.0.0.1], time=5
    Mar 25 16:23:04 server imapd: Connection, ip=[::ffff:127.0.0.1]
    Mar 25 16:23:04 server imapd: LOGIN FAILED, user=michael@domain.us, ip=[::ffff:127.0.0.1]
    Mar 25 16:23:09 server imapd: Disconnected, ip=[::ffff:127.0.0.1], time=5
    
    I hope, that helps?

    Hahni
     
  18. hahni

    hahni New Member

    The script now works, if I start it manually.

    The job-job file is:

    --
    # /etc/cron.d/courier_userdb
    # E-Mail-Login with "user@domain.tld"

    */5 * * * * root /usr/local/sbin/courier_userdb
    --

    But the Cron-Job makes the file clean and do not create the recordsets. What could be the reason?
     
  19. falko

    falko Super Moderator

    You might have to use absolute paths in the script (or set the PATH variable in the script).
     
  20. hahni

    hahni New Member

    Hi Falko,

    Thanks a lot. I could sort out this problem. Is there an manual for installation of StartSLL-certificates? I saved the server.key and server.crt. But the cert is not valid. What could be the problem?

    Thanks a lot!

    Hahni
     

Share This Page