|
|
1.1 ! root 1: /* ! 2: * chk_srlno.c ! 3: * ! 4: * serial number checker for BBS version of login ! 5: * ! 6: * perform 2 checks: ! 7: * use algorithm to verify validity ! 8: * make sure password is NOT in exclusion list ! 9: * ! 10: * "exclusion list" is a file (EXCL_FILE below) within with each ! 11: * line begins with a serial number, followed by an optional comment ! 12: * Any serial number appearing in the file is to be considered invalid. ! 13: * ! 14: * return 1 if serial number is valid, 0 if not ! 15: */ ! 16: ! 17: #include <stdio.h> ! 18: #include <string.h> ! 19: #include "unumber.h" ! 20: ! 21: #define SRLNUM_LEN 9 ! 22: #define LBUF_LEN 20 ! 23: #define EXCL_FILE "/etc/noaccess" ! 24: ! 25: int chk_srlno(s) ! 26: char *s; ! 27: { ! 28: int c, susp, suspen; ! 29: int ret; ! 30: char lbuf[LBUF_LEN]; ! 31: FILE *fp; ! 32: ! 33: ret = (strlen(s) == SRLNUM_LEN); ! 34: if (ret) ! 35: ret = (sscanf(s, "%1d%3d%5d", &c, &susp, &suspen) == 3); ! 36: if (ret) ! 37: ret = (c >= 1 && c <= VERSIONS); ! 38: if (ret) { ! 39: c--; ! 40: ret = (((suspen ^ magic3[c]) % magic2[c]) ! 41: == (susp ^ magic1[c])); ! 42: } ! 43: if (ret) { ! 44: if (fp = fopen(EXCL_FILE, "r")) { ! 45: while (fgets(lbuf, LBUF_LEN, fp)) { ! 46: if (strncmp(lbuf, s, SRLNUM_LEN) == 0) { ! 47: ret = 0; ! 48: break; ! 49: } ! 50: } ! 51: fclose(fp); ! 52: } ! 53: } ! 54: return ret; ! 55: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.