diff options
author | Corinna Vinschen <corinna@vinschen.de> | 2005-02-23 17:39:46 +0000 |
---|---|---|
committer | Corinna Vinschen <corinna@vinschen.de> | 2005-02-23 17:39:46 +0000 |
commit | c8b404bf5c8c5268ef9a288d8c59b7e3ea935e8b (patch) | |
tree | 619b38b52fa65a469b1d8ca788b9a834a15768c9 /winsup/cygwin/net.cc | |
parent | 81d0376064d861df4d70f1263ec627af96486443 (diff) | |
download | cygnal-c8b404bf5c8c5268ef9a288d8c59b7e3ea935e8b.tar.gz cygnal-c8b404bf5c8c5268ef9a288d8c59b7e3ea935e8b.tar.bz2 cygnal-c8b404bf5c8c5268ef9a288d8c59b7e3ea935e8b.zip |
* cygwin.din (getpeereid): Export.
* fhandler.h (class fhandler_socket): Add pipe and id members to
exchange eid credentials for AF_LOCAL sockets.
(eid_pipe_name): Declare new method.
(getpeereid): Ditto.
* fhandler_socket.cc (fhandler_socket::eid_pipe_name): New method.
(fhandler_socket::fhandler_socket): Initialize sec_pipe.
(fhandler_socket::connect): Exchange eid credentials with accepting
socket process.
(fhandler_socket::listen): Prepare eid credential transaction.
(fhandler_socket::accept): Exchange eid credentials with connecting
socket process.
(fhandler_socket::close): Close eid credentials pipe if open.
(fhandler_socket::getpeereid): New method.
* net.cc (cygwin_getsockopt): Add SO_PEERCRED handling.
(getpeereid): New function.
* include/asm/socket.h (SO_PEERCRED): Define.
* include/cygwin/socket.h (struct ucred): Define new type.
* include/cygwin/version.h: Bump API minor version.
Diffstat (limited to 'winsup/cygwin/net.cc')
-rw-r--r-- | winsup/cygwin/net.cc | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/winsup/cygwin/net.cc b/winsup/cygwin/net.cc index 33356d13e..98e121c5a 100644 --- a/winsup/cygwin/net.cc +++ b/winsup/cygwin/net.cc @@ -780,6 +780,8 @@ cygwin_getsockopt (int fd, int level, int optname, void *optval, int *optlen) case SO_ERROR: name = "SO_ERROR"; break; + case SO_PEERCRED: + name = "SO_PEERCRED"; } if ((optval @@ -787,6 +789,11 @@ cygwin_getsockopt (int fd, int level, int optname, void *optval, int *optlen) || __check_null_invalid_struct_errno (optval, (unsigned) *optlen))) || !fh) res = -1; + else if (optname == SO_PEERCRED) + { + struct ucred *cred = (struct ucred *) optval; + res = fh->getpeereid (&cred->pid, &cred->uid, &cred->gid); + } else { res = getsockopt (fh->get_socket (), level, optname, (char *) optval, @@ -808,6 +815,16 @@ cygwin_getsockopt (int fd, int level, int optname, void *optval, int *optlen) return res; } +extern "C" int +getpeereid (int fd, __uid32_t *euid, __gid32_t *egid) +{ + sig_dispatch_pending (); + fhandler_socket *fh = get (fd); + if (fh) + return fh->getpeereid (NULL, euid, egid); + return -1; +} + /* exported as connect: standards? */ extern "C" int cygwin_connect (int fd, const struct sockaddr *name, int namelen) |