Go Back   HowtoForge Forums | HowtoForge - Linux Howtos and Tutorials > ISPConfig 2 > Tips/Tricks/Mods

Do you like HowtoForge? Please consider supporting us by becoming a subscriber.
Reply
 
Thread Tools Display Modes
  #1  
Old 2nd November 2006, 21:28
desmondk desmondk is offline
Junior Member
 
Join Date: Nov 2006
Posts: 5
Thanks: 0
Thanked 4 Times in 2 Posts
Default ISPconfig user@domain email login HOW TO

For those that want to log into your email with user@domain here it is.
In ispconfig control panel , log in as admin and go to Management -> system config -> settings -> ISP manager ; and change "User Prefix" to [DOMAIN]_

We wil be using couriers userdb for authentication purposes.
Users wil now be added to the system as domain_user using the ispconfig frontend.

Edit authdaemonrc located at /etc/courier/ (on my ubuntu system) and change the line reading authmodulelist so it look like this

Code:
authmodulelist="authuserdb authpam"
Save and restart courier authdaemon.

Here is the code for the script that wil convert the text to user@domain that you would be able to login in with
Code:
#!/bin/bash

delim="_"

OIFS=$IFS
IFS="
"
rm -rf /etc/courier/userdb
touch /etc/courier/userdb
chmod 600 /etc/courier/userdb
for line in `pw2userdb2 | grep -ir user`
do
        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
        /usr/lib/courier/makeuserdb
done

IFS=$OIFS
Also replace pw2userdb that is located in /usr/sbin on my system , it may be at a dif location to mine, in that case just use the following command to see where the file is located "which pw2userdb" and replace the code inside with this:
Code:
#! /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;
}


Put he first script in a crontab to remake the userdb file. like this: run the command "crontab -e"
Add into the file:
Code:
*/5 * * * * /location_of_the_script/script_name
And Save.



I am busy changing the script so that it would check to see if there has been any changes made before rebuilding the userdb file and if there wasn't any changes it won't do anything.
Hope this helps some people in the mean time. Still busy improving it.

Last edited by desmondk; 2nd November 2006 at 21:51.
Reply With Quote
The Following 2 Users Say Thank You to desmondk For This Useful Post:
soho (29th April 2009), Telesat (8th September 2007)
Sponsored Links
  #2  
Old 3rd November 2006, 11:49
till till is online now
Super Moderator
 
Join Date: Apr 2005
Location: Lüneburg, Germany
Posts: 36,788
Thanks: 840
Thanked 5,612 Times in 4,423 Posts
Default

This looks like a interesting solution.

You may add a exec command to run the script e.g. at the end of /root/ispconfig/scripts/writeconf.php script right before the ispconfig_lock file is deleted.

Have you solved this problem for smtp-auth in postfix too?
__________________
Till Brehm
--
Get ISPConfig support and the ISPConfig 3 manual from ispconfig.org.
Reply With Quote
The Following User Says Thank You to till For This Useful Post:
Telesat (8th September 2007)
  #3  
Old 3rd November 2006, 17:27
desmondk desmondk is offline
Junior Member
 
Join Date: Nov 2006
Posts: 5
Thanks: 0
Thanked 4 Times in 2 Posts
Default

Thanks for the reply. No i can get rid of the crontab and that also solves my problem with the checking if the file have changed.

i wil have a look at the smtp-auth and give a reply if i have a solution.
Reply With Quote
  #4  
Old 17th November 2006, 17:10
IKShadow IKShadow is offline
Member
 
Join Date: Jan 2006
Location: Slovenia
Posts: 85
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to IKShadow
Default

I just deleted User Prefix.(now is blank ) and had same effect.
Reply With Quote
  #5  
Old 28th November 2006, 21:35
jwan jwan is offline
Junior Member
 
Join Date: Oct 2006
Posts: 23
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by IKShadow
I just deleted User Prefix.(now is blank ) and had same effect.
Hi... do you mean you just leave the user prefix blank and didn't go through the how-tos on the courier and pw2userdb?
Reply With Quote
  #6  
Old 27th February 2007, 03:31
Telesat Telesat is offline
Junior Member
 
Join Date: Feb 2007
Posts: 28
Thanks: 18
Thanked 1 Time in 1 Post
Default Status review?

Hello, I'd like to review the status of this patch. Is it working wih 2.2.10?

I have tried it, but it didn't work as long as 'pw2userdb | grep -ir user' returns nothing. I only have a user with email, which is the admin for his domain, the username is domain.com_info.

Does the patch apply only to normal users or it should work also with admins?

I think there is a typo in:

for line in `pw2userdb2 | grep -ir user`

and it should be:

for line in `pw2userdb | grep -ir user`

I have put the exec sentence in /root/ispconfig/scripts/writeconf.php, as stated by till. I understand there is no more the need for the cron job.

desmondk: did you solve the smtp-auth scenario?

IKShadow: I guess that deleting the prefix is a solution when you intend to have only one domain, because you won't be able to have the same user for different domains (e.g. info). Please correct me in case I'm wrong.

jwan: when you remove prefix, you only need the username to log in, there is no more need of attaching the domain name, but as stated above, I guess that it is good only when you only intend to have one domain.

Thank you very much for your work and your replies, I'd really love to have this feature working.

Last edited by Telesat; 27th February 2007 at 03:35.
Reply With Quote
  #7  
Old 27th February 2007, 08:02
Telesat Telesat is offline
Junior Member
 
Join Date: Feb 2007
Posts: 28
Thanks: 18
Thanked 1 Time in 1 Post
Default I've seen the other post

I've seen the other post:

http://www.howtoforge.com/forums/showthread.php?t=7881
Reply With Quote
The Following User Says Thank You to Telesat For This Useful Post:
ottojan (8th March 2008)
  #8  
Old 7th March 2007, 20:24
kainhofer kainhofer is offline
Junior Member
 
Join Date: Mar 2007
Posts: 6
Thanks: 0
Thanked 1 Time in 1 Post
Thumbs up Simpler script to create the userdb

I setup my server similarly. However the first script of the original post can be considerably simplified using awk:

Code:
#!/bin/bash
delim="_"

rm -rf /etc/courier/userdb
touch /etc/courier/userdb
chmod 600 /etc/courier/userdb
pw2userdb | grep -ir www/web | awk -F"\t" '
{
  count = split($1,emailparts,"'$delim'");
  if ( count > 1 ) {
    print emailparts[2]"@"emailparts[1]"\t"$2;
  }
}'  >> /etc/courier/userdb
makeuserdb
Of course, this assumes that courier is already setup correctly to look into $HOMEDIR/Maildir for the mailboxes...
Also notice that I didn't grep for "user", but rather for the www/web part of the homedir. I had problems with other system users that also had the string "user" somewhere in their passwd entry.
Reply With Quote
The Following User Says Thank You to kainhofer For This Useful Post:
Telesat (8th September 2007)
  #9  
Old 12th April 2007, 00:33
advinser advinser is offline
Junior Member
 
Join Date: Nov 2006
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

I try the solutions of desmondk with some correction.

If I run manualy the script (I put it in my /usr/sbin/ folder and I rename it my_email ) it doesn't return errors and it execute.

But if I try to login with user@domain.tld i receive an error from my client.

Can you explain me: I add a new user than I run the script, but the script from where take the user datails?
The file /etc/courier/userdb is always empty (also if I comment the line makeuserdb in the script).

Can you suggest me a debug solutions? I'm not able with linux but I have to understand.

Thank you.

Andrea
Reply With Quote
  #10  
Old 4th June 2007, 21:44
kassie kassie is offline
Senior Member
 
Join Date: May 2007
Location: Johannesburg, South Africa
Posts: 136
Thanks: 13
Thanked 0 Times in 0 Posts
 
Default

Hi All,

I have applied this patch. It works great except for 1 thing. When i send(SMTP) through my server, the authentication requires domain_user and not user@doman.com

Can anybody please help me with this.
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Cannot send email from OE through ISPconfig site tomd General 10 12th March 2009 07:05
SP-Server Setup - Ubuntu 5.10 "Breezy Badger" - Page 6 (changes) LuisC-SM HOWTO-Related Questions 0 21st April 2006 16:16
ISPConfig 2.2.0 problem with email addresses DataJet General 1 29th March 2006 14:29
Debian Sarge, ISPConfig, perfect setup followed, email can't login! Zoon Installation/Configuration 3 12th February 2006 21:58
ISP-Ubuntu breezy ispconfig dns email e-mail working finally yellowjelly HOWTO-Related Questions 0 19th November 2005 21:30


All times are GMT +2. The time now is 21:04.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2014, vBulletin Solutions, Inc.