|
Lines 135-140
extern char *__progname;
Link Here
|
| 135 |
/* Default lifetime (0 == forever) */ |
135 |
/* Default lifetime (0 == forever) */ |
| 136 |
static int lifetime = 0; |
136 |
static int lifetime = 0; |
| 137 |
|
137 |
|
|
|
138 |
/* Perform user identity check on auth sock access */ |
| 139 |
static int check_peer_id = 1; |
| 140 |
|
| 138 |
static void |
141 |
static void |
| 139 |
close_socket(SocketEntry *e) |
142 |
close_socket(SocketEntry *e) |
| 140 |
{ |
143 |
{ |
|
Lines 899-904
prepare_select(fd_set **fdrp, fd_set **f
Link Here
|
| 899 |
return (1); |
902 |
return (1); |
| 900 |
} |
903 |
} |
| 901 |
|
904 |
|
|
|
905 |
static int |
| 906 |
check_peer(int sock) |
| 907 |
{ |
| 908 |
uid_t euid; |
| 909 |
gid_t egid; |
| 910 |
|
| 911 |
if (check_peer_id == 0) |
| 912 |
return 0; |
| 913 |
if (getpeereid(sock, &euid, &egid) < 0) { |
| 914 |
error("getpeereid %d failed: %s", sock, strerror(errno)); |
| 915 |
return -1; |
| 916 |
} |
| 917 |
if ((euid != 0) && (getuid() != euid)) { |
| 918 |
error("uid mismatch: peer euid %u != uid %u", (u_int)euid, |
| 919 |
(u_int)getuid()); |
| 920 |
return -1; |
| 921 |
} |
| 922 |
return 0; |
| 923 |
} |
| 924 |
|
| 902 |
static void |
925 |
static void |
| 903 |
after_select(fd_set *readset, fd_set *writeset) |
926 |
after_select(fd_set *readset, fd_set *writeset) |
| 904 |
{ |
927 |
{ |
|
Lines 907-914
after_select(fd_set *readset, fd_set *wr
Link Here
|
| 907 |
char buf[1024]; |
930 |
char buf[1024]; |
| 908 |
int len, sock; |
931 |
int len, sock; |
| 909 |
u_int i; |
932 |
u_int i; |
| 910 |
uid_t euid; |
|
|
| 911 |
gid_t egid; |
| 912 |
|
933 |
|
| 913 |
for (i = 0; i < sockets_alloc; i++) |
934 |
for (i = 0; i < sockets_alloc; i++) |
| 914 |
switch (sockets[i].type) { |
935 |
switch (sockets[i].type) { |
|
Lines 924-939
after_select(fd_set *readset, fd_set *wr
Link Here
|
| 924 |
strerror(errno)); |
945 |
strerror(errno)); |
| 925 |
break; |
946 |
break; |
| 926 |
} |
947 |
} |
| 927 |
if (getpeereid(sock, &euid, &egid) < 0) { |
948 |
if (check_peer(sock) != 0) { |
| 928 |
error("getpeereid %d failed: %s", |
|
|
| 929 |
sock, strerror(errno)); |
| 930 |
close(sock); |
| 931 |
break; |
| 932 |
} |
| 933 |
if ((euid != 0) && (getuid() != euid)) { |
| 934 |
error("uid mismatch: " |
| 935 |
"peer euid %u != uid %u", |
| 936 |
(u_int) euid, (u_int) getuid()); |
| 937 |
close(sock); |
949 |
close(sock); |
| 938 |
break; |
950 |
break; |
| 939 |
} |
951 |
} |
|
Lines 1065-1072
main(int ac, char **av)
Link Here
|
| 1065 |
init_rng(); |
1077 |
init_rng(); |
| 1066 |
seed_rng(); |
1078 |
seed_rng(); |
| 1067 |
|
1079 |
|
| 1068 |
while ((ch = getopt(ac, av, "cdksa:t:")) != -1) { |
1080 |
while ((ch = getopt(ac, av, "Pcdksa:t:")) != -1) { |
| 1069 |
switch (ch) { |
1081 |
switch (ch) { |
|
|
1082 |
case 'P': |
| 1083 |
check_peer_id = 0; |
| 1084 |
break; |
| 1070 |
case 'c': |
1085 |
case 'c': |
| 1071 |
if (s_flag) |
1086 |
if (s_flag) |
| 1072 |
usage(); |
1087 |
usage(); |