struct vqpasswd *vpopmail_lookup_vqp(struct auth_request *request, char vpop_user[VPOPMAIL_LIMIT], char vpop_domain[VPOPMAIL_LIMIT]) { struct vqpasswd *vpw; /* vpop_user must be zero-filled or parse_email() leaves an extra character after the user name. we'll fill vpop_domain as well just to be sure... */ memset(vpop_user, '\0', VPOPMAIL_LIMIT); memset(vpop_domain, '\0', VPOPMAIL_LIMIT); if (parse_email(request->user, vpop_user, vpop_domain, VPOPMAIL_LIMIT-1) < 0) { auth_request_log_info(request, "vpopmail", "parse_email() failed"); return NULL; } auth_request_log_debug(request, "vpopmail", "lookup user=%s domain=%s", vpop_user, vpop_domain); vpw = vauth_getpw(vpop_user, vpop_domain); if (vpw == NULL) { auth_request_log_unknown_user(request, "vpopmail"); return NULL; } return vpw; }
int parseopts(qMailOpts *popts, int &argc, char **&argv) { // arg init setarg(&argc, argv); char *popt; char *pend; if ((popt = getopt("ti*meout"))) { popts->timeout = (float) strtod(popt, &pend); if (popts->timeout < Q_MINTIMEOUT) popts->timeout = Q_MINTIMEOUT; } if (popts->host) { pend = 0; parse_email(popts->host.GetBuffer(), popts->user, pend, popts->port, popts->desc); if (pend) popts->smtp = pend; else popts->smtp = popts->host; } if ((popt = getopt("u*sername"))) { pend = 0; popts->user = 0; parse_email(popt, popts->user, pend, popts->port, popts->desc); if (pend) popts->smtp = pend; if (!popts->user) popts->user = popt; } if (((popt = getopt("h*ost")))) { pend = 0; popts->host = popt; parse_email(popt, popts->user, pend, popts->port, popts->desc); popts->smtp = pend ? pend : popt; } if (popts->smtp) { if ((popt = getopt("p*assword"))) popts->pass = popt; if ((popt = getopt("to"))) popts->to = popt; if ((popt = getopt("f*rom"))) popts->from = popt; if ((popt = getopt("r*eply"))) popts->reply = popt; int o = 0; while ((o < 7) && (popt = getopt("o*ther"))) popts->other.SetAt(o++,popt); popts->other.SetAt(o++,0); int i = 0; while ((i < 7) && (popt = getopt("b*ody"))) popts->body.SetAt(i++,popt); char *p = getarg(3); if (p && *p) { p = strtok(p, ";"); while (p) { popts->body.SetAt(i++,p); p = strtok(NULL, ";"); } } popts->body.SetAt(i++,0); popts->subj = getarg(2); popt = getarg(1); if (popt) { popts->rcpt = popt; if (!popts->from) popts->from = ""; if (!popts->to && !strchr((const char *) popts->rcpt,';')) popts->to = popts->rcpt; if (!popts->helo) popts->helo = popts->smtp; } } popts->save = getoptbool("s*ave"); if (argc > 1) { fprintf(stderr, QM_ERR_UNK_OPT_RC, argv[1]); fprintf(stderr, "\n"); return QM_ERR_UNK_OPT; } else if (!popts->smtp) { fprintf(stderr, QM_ERR_NEED_HOST_RC); fprintf(stderr, "\n"); return QM_ERR_NEED_HOST; } else if (!popts->rcpt && !popts->save) { fprintf(stderr, QM_ERR_NEED_RCPT_RC); fprintf(stderr, "\n"); return QM_ERR_NEED_RCPT; } return 0; }