userdb-vpopmail.c revision 356303df200c991580bd24041996a070ad08c05e
45312f52ff3a3d4c137447be4c7556500c2f8bf2Timo Sirainen/* Copyright (C) 2002-2003 Timo Sirainen */
c6a57378d3c54988f525f81e19c0c5d132a0770dTimo Sirainen/* Thanks to Courier-IMAP for showing how the vpopmail API should be used */
c6a57378d3c54988f525f81e19c0c5d132a0770dTimo Sirainen#if defined(PASSDB_VPOPMAIL) || defined(USERDB_VPOPMAIL)
c6a57378d3c54988f525f81e19c0c5d132a0770dTimo Sirainenstruct vqpasswd *vpopmail_lookup_vqp(struct auth_request *request,
2615df45a8027948a474abe5e817b34b0499c171Timo Sirainen /* vpop_user must be zero-filled or parse_email() leaves an
2615df45a8027948a474abe5e817b34b0499c171Timo Sirainen extra character after the user name. we'll fill vpop_domain
2615df45a8027948a474abe5e817b34b0499c171Timo Sirainen as well just to be sure... */
c6a57378d3c54988f525f81e19c0c5d132a0770dTimo Sirainen if (parse_email(request->user, vpop_user, vpop_domain,
2615df45a8027948a474abe5e817b34b0499c171Timo Sirainen "parse_email() failed");
f7539a17ea306191b53b8f5e752e228937df9ec3Timo Sirainen auth_request_log_info(request, "vpopmail", "unknown user");
2615df45a8027948a474abe5e817b34b0499c171Timo Sirainenstatic void vpopmail_lookup(struct auth_request *auth_request,
f7539a17ea306191b53b8f5e752e228937df9ec3Timo Sirainen char vpop_user[VPOPMAIL_LIMIT], vpop_domain[VPOPMAIL_LIMIT];
2615df45a8027948a474abe5e817b34b0499c171Timo Sirainen vpw = vpopmail_lookup_vqp(auth_request, vpop_user, vpop_domain);
2615df45a8027948a474abe5e817b34b0499c171Timo Sirainen /* we have to get uid/gid separately, because the gid field in
2615df45a8027948a474abe5e817b34b0499c171Timo Sirainen struct vqpasswd isn't really gid at all but just some flags... */
2615df45a8027948a474abe5e817b34b0499c171Timo Sirainen if (vget_assign(vpop_domain, NULL, 0, &uid, &gid) == NULL) {
2615df45a8027948a474abe5e817b34b0499c171Timo Sirainen auth_request_log_info(auth_request, "vpopmail",
fea7b8b3fc182e415b1875d79587c0aa1adb09d7Timo Sirainen if (vpw->pw_dir == NULL || vpw->pw_dir[0] == '\0') {
fea7b8b3fc182e415b1875d79587c0aa1adb09d7Timo Sirainen /* user's homedir doesn't exist yet, create it */
ff7056842f14fd3b30a2d327dfab165b9d15dd30Timo Sirainen auth_request_log_info(auth_request, "vpopmail",
ff7056842f14fd3b30a2d327dfab165b9d15dd30Timo Sirainen "pw_dir isn't set, creating");
c6a57378d3c54988f525f81e19c0c5d132a0770dTimo Sirainen if (make_user_dir(vpop_user, vpop_domain, uid, gid) == NULL) {
c6a57378d3c54988f525f81e19c0c5d132a0770dTimo Sirainen auth_request_log_error(auth_request, "vpopmail",
c6a57378d3c54988f525f81e19c0c5d132a0770dTimo Sirainen "make_user_dir(%s, %s) failed",
2615df45a8027948a474abe5e817b34b0499c171Timo Sirainen /* get the user again so pw_dir is visible */