version 1.34, 2020/04/25 05:03:54 |
version 1.35, 2020/04/26 14:13:22 |
|
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. |
*/ |
*/ |
#include <sys/types.h> |
#include <sys/types.h> |
|
#include <sys/socket.h> |
#include <netinet/in.h> |
#include <netinet/in.h> |
#include <errno.h> |
#include <errno.h> |
#include <poll.h> |
#include <poll.h> |
|
|
} |
} |
#endif |
#endif |
if (f->pstate > SOCK_AUTH) |
if (f->pstate > SOCK_AUTH) |
sock_sesrefs--; |
sock_sesrefs -= f->sesrefs; |
if (f->slot) { |
if (f->slot) { |
slot_del(f->slot); |
slot_del(f->slot); |
f->slot = NULL; |
f->slot = NULL; |
|
|
sock_auth(struct sock *f) |
sock_auth(struct sock *f) |
{ |
{ |
struct amsg_auth *p = &f->rmsg.u.auth; |
struct amsg_auth *p = &f->rmsg.u.auth; |
|
uid_t euid; |
|
gid_t egid; |
|
|
|
/* |
|
* root bypasses any authenication checks and has no session |
|
*/ |
|
if (getpeereid(f->fd, &euid, &egid) == 0 && euid == 0) { |
|
f->pstate = SOCK_HELLO; |
|
f->sesrefs = 0; |
|
return 1; |
|
} |
|
|
if (sock_sesrefs == 0) { |
if (sock_sesrefs == 0) { |
/* start a new session */ |
/* start a new session */ |
memcpy(sock_sescookie, p->cookie, AMSG_COOKIELEN); |
memcpy(sock_sescookie, p->cookie, AMSG_COOKIELEN); |
|
f->sesrefs = 1; |
} else if (memcmp(sock_sescookie, p->cookie, AMSG_COOKIELEN) != 0) { |
} else if (memcmp(sock_sescookie, p->cookie, AMSG_COOKIELEN) != 0) { |
/* another session is active, drop connection */ |
/* another session is active, drop connection */ |
return 0; |
return 0; |
} |
} |
sock_sesrefs++; |
sock_sesrefs += f->sesrefs; |
f->pstate = SOCK_HELLO; |
f->pstate = SOCK_HELLO; |
return 1; |
return 1; |
} |
} |