Problem with logging in at mail

Discussion in 'General' started by Schwartz, Aug 31, 2007.

  1. Schwartz

    Schwartz New Member


    I have a problem, i have a ISPConfig system installed with postfix.

    When i then add a mail user with username web4_jonas and E-Mail [email protected] , i try to login at outlook, but here is my problem , the login username is web4_jonas and not the email adress.

    My question is, is there a way to change this so my users can login with their E-Mail and not the web4_**** username?

    Thank you :)

    Kind regards
    Jonas H. Schwartz
  2. gabriel925fm

    gabriel925fm New Member


    I'm having the same problem...
    Last edited: Aug 31, 2007
  3. falko

    falko Super Moderator ISPConfig Developer

    No, this isn't possible because ISPConfig is using system users, not virtual email users.
  4. jmroth

    jmroth ISPConfig Developer ISPConfig Developer

    There is another thread
    But ISPConfig is designed to use prefixes to usernames, not suffixes, also @ is not allowed in a unix username.
    I personally would not do such low level hacks. Then better choose a control panel which supports virtual users officially.

    ** edit by edge.

    Please send a PM to the person about the part that I removed here.
    Last edited by a moderator: Sep 2, 2007
  5. jmroth

    jmroth ISPConfig Developer ISPConfig Developer

    I have done some little hacking to the PAM module of Courier-Authdaemon so that it also accepts email addresses as authentication for getting mails.
    Actually it uses the postfix virtusertable created by ISPconfig as lookup table from email address to system account. (Of course using the system user names still works too)
    (I guess when it gets very big, it would be better not to use the text file but the db instead...)

    Here is the diff
    --- courier-authlib-0.58/authpam.c      2005-12-09 00:15:55.000000000 +0100
    +++ authpam.c   2007-09-03 01:14:38.000000000 +0200
    @@ -27,6 +27,10 @@
     #include       <Pam/pam_appl.h>
    +#include <fcntl.h>
    +#include <unistd.h>
     static const char rcsid[]="$Id: authpam.c,v 1.22 2005/12/08 23:15:55 mrsam Exp $";
     static const char *pam_username, *pam_password, *pam_service;
    @@ -302,6 +306,48 @@
    +        FILE *infile;
    +        char line[256];
    +       memset(&line, 0, sizeof(line));
    +       char token[256];
    +       memset(&token, 0, sizeof(token));
    +        size_t length;
    +       short done=0;
    +        int fd = open("/etc/postfix/virtusertable", O_RDONLY);
    +        if (fd == -1) {
    +         // ERROR
    +         return (1);
    +       }
    +        fcntl(fd, F_SETFD, FD_CLOEXEC);
    +        infile = fdopen(fd, "r");
    +        while( fgets(line, sizeof(line), infile) != NULL ) {
    +         if (done>0)
    +           break;
    +          if (line[0]=='#')
    +           continue;
    +         strcpy(token, strtok(line, " "));
    +          while (token != NULL) {
    +            if (strcmp(pam_username, token) != 0) // does NOT match
    +              break;
    +           strcpy(token, strtok(NULL, " "));
    +            if (token!=NULL) {
    +              length = strlen(token);
    +              if (length>0 && token[length-1] == '\n') {
    +               token[length-1]= '\0';
    +               done++;
    +             }
    +            }
    +          }
    +        }
    +       close(fd);
    +       if (done>0)
    +         strcpy(pam_username, token);
             return auth_pam_pre(pam_username, service, &callback_pam, &ci);
    I also have the library compiled for IA32 (I use Debian Etch) here

   =>  (0xffffe000)
   => /lib/ (0xb7f4d000)
   => /lib/tls/ (0xb7f49000)
   => /usr/lib/courier-authlib/ (0xb7f45000)
   => /lib/tls/ (0xb7e13000)
            /lib/ (0x80000000)
   => /lib/tls/ (0xb7de5000)
   => /usr/lib/courier-authlib/ (0xb7dda000)
    I assume no responsibilty if this fails at some point in the future but for now it seems to work well!
    have fun
    Last edited: Sep 3, 2007
  6. jmroth

    jmroth ISPConfig Developer ISPConfig Developer

    Ehm.. maybe someone could also move this thread from "Linux Forums" to ISPConfig -> Installation/Configuration?
  7. Schwartz

    Schwartz New Member

    Hey jmroth, sounds really nice, i just have one question, where did you put this code..

    Thank you very much
  8. jmroth

    jmroth ISPConfig Developer ISPConfig Developer

    Its all in there, you just have to read it ;)

    (BTW it would be even cooler to put this hack directly into PAM, not into Courier, maybe I'll do that later :rolleyes:)
  9. jmroth

    jmroth ISPConfig Developer ISPConfig Developer

    BTW I tested this code a little and it produces problems. Probably memory leaks or some other resource issues. So I would not recommend you use it. However if you clean it up, let me know :rolleyes:
  10. grant

    grant New Member

    I wrote a tutorial on doing it, assuming you are using postfix+courier

    With my method users can login with either their "web##_name", or any of their associated email addresses. And there's no hacking the auth programs. And it uses a db for all its lookups, so it should work well even with a significant number of accounts.

Share This Page