|
Lines 5-10
Link Here
|
| 5 |
#include <pwd.h> |
5 |
#include <pwd.h> |
| 6 |
#include <stdio.h> |
6 |
#include <stdio.h> |
| 7 |
#include <unistd.h> |
7 |
#include <unistd.h> |
|
|
8 |
#include <sys/types.h> |
| 8 |
|
9 |
|
| 9 |
#define LINE_MAX 256 |
10 |
#define LINE_MAX 256 |
| 10 |
#define SASLUSERFILE "/var/qmail/users/authuser" |
11 |
#define SASLUSERFILE "/var/qmail/users/authuser" |
|
Lines 23-32
int doit(unsigned char *testlogin, unsig
Link Here
|
| 23 |
unsigned char h; |
24 |
unsigned char h; |
| 24 |
FILE *fp; |
25 |
FILE *fp; |
| 25 |
int j; |
26 |
int j; |
| 26 |
|
27 |
uid_t uid; |
|
|
28 |
gid_t gid; |
| 27 |
char *linepnt; |
29 |
char *linepnt; |
| 28 |
|
30 |
|
| 29 |
if ((fp = fopen(SASLUSERFILE, READONLY)) == NULL) _exit(2); |
31 |
if ((fp = fopen(SASLUSERFILE, READONLY)) == NULL) _exit(2); |
|
|
32 |
|
| 33 |
uid = getuid(); |
| 34 |
gid = getgid(); |
| 35 |
|
| 36 |
if (gid != getegid()) { |
| 37 |
if (setegid(gid)) |
| 38 |
_exit(2); |
| 39 |
} |
| 40 |
|
| 41 |
|
| 42 |
if (uid && (uid != geteuid())) { |
| 43 |
if (seteuid(uid)) |
| 44 |
_exit(2); |
| 45 |
} |
| 46 |
|
| 30 |
while (fgets(line, LINE_MAX, fp) != NULL) { |
47 |
while (fgets(line, LINE_MAX, fp) != NULL) { |
| 31 |
if ((linepnt = strchr(line, '\n')) != NULL) { |
48 |
if ((linepnt = strchr(line, '\n')) != NULL) { |
| 32 |
*linepnt = 0; |
49 |
*linepnt = 0; |
|
Lines 39-45
int doit(unsigned char *testlogin, unsig
Link Here
|
| 39 |
break; |
56 |
break; |
| 40 |
} |
57 |
} |
| 41 |
} |
58 |
} |
| 42 |
fclose(fp); |
59 |
|
|
|
60 |
if (EOF == fclose(fp)) _exit(2); |
| 43 |
|
61 |
|
| 44 |
if (!found_user) return(1); |
62 |
if (!found_user) return(1); |
| 45 |
|
63 |
|