diff --new-file --recursive qpopper4.0.4/popper/pop_pass.c qpopper4.0.4.nikm/popper/pop_pass.c 109a110,111 > #include > 1234a1237,1316 > #define POP_BEFORE_SMTP > #ifdef POP_BEFORE_SMTP > > > #define STRLEN 80 > #define MAIL_DIR "/etc/mail" > > unsigned short add_smtp_relay_ip(char *name, char *ip) > { > FILE *old_file; > FILE *new_file; > char ofn[STRLEN+1]; > char nfn[STRLEN+1]; > char cmd[STRLEN+1]; > char input[STRLEN+1]; > char user_ip[STRLEN+1], user_name[STRLEN+1], user_date[STRLEN+1]; > char *sptr; > char date_str[STRLEN+1]; > time_t now; > struct tm *tm_now; > > now = time(NULL); > tm_now = localtime(&now); > strftime(date_str, STRLEN, "%m-%d-%Y/%H:%M", tm_now); > > sprintf(ofn, "%s/popauth", MAIL_DIR); > sprintf(nfn, "%s/popauth.new", MAIL_DIR); > > old_file = fopen(ofn, "r"); > > if (old_file == NULL) { > return 0; > } > > /* first look through the database for this IP, if it exists, get out */ > while (fgets(input, STRLEN, old_file)) { > if (sscanf(input, "%s\tOK\t%s\t%s\n", user_ip, user_name, user_date) >= 2) { > sptr = user_ip + strlen("POP:"); > if (!strcmp(sptr, ip)) { > /* this ip exists, we're OK! */ > fclose(old_file); > return 1; > } > } > } > > new_file = fopen(nfn, "w"); > if (new_file == NULL) { > fclose(old_file); > return 0; > } > rewind(old_file); > > /* if it does not exist, then let's look through for entries with this */ > /* user, and delete them. */ > while (fgets(input, STRLEN, old_file)) { > if (sscanf(input, "%s\tOK\t%s\t%s\n", user_ip, user_name, user_date) == 3) { > sptr = user_ip + strlen("POP:"); > if (!strcmp(user_name, name)) { > /* match on user name, but mismatch on IP, so do not copy */ > /* this over */ > } else { > fprintf(new_file, "%s\tOK\t%s\t%s\n", user_ip, user_name, user_date); > } > } > } > > /* now add this IP + user */ > fprintf(new_file, "POP:%s\tOK\t%s\t%s\n", ip, name, date_str); > fclose(new_file); > fclose(old_file); > > rename(nfn, ofn); > > /* now remake our files.. */ > chdir(MAIL_DIR); > system("make > /dev/null"); > } > #endif /* POP_BEFORE_SMTP */ > 1384a1467,1474 > #ifdef POP_BEFORE_SMTP > if (p->user == NULL) { > add_smtp_relay_ip("unknown", p->ipaddr); > } else { > add_smtp_relay_ip(p->user, p->ipaddr); > } > #endif >