Cygwin: fhandler_socket_unix: store peer credentials in ucred member
* Split out cygwin/_ucred.h file * drop local credentials Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
parent
25ea6af172
commit
892efccb25
@ -11,6 +11,7 @@ details. */
|
||||
|
||||
#include "tty.h"
|
||||
#include <cygwin/_socketflags.h>
|
||||
#include <cygwin/_ucred.h>
|
||||
|
||||
/* fcntl flags used only internaly. */
|
||||
#define O_NOSYMLINK 0x080000
|
||||
@ -824,15 +825,10 @@ class fhandler_socket_unix : public fhandler_socket
|
||||
char *get_sun_path () {return sun_path;}
|
||||
void set_peer_sun_path (const char *path);
|
||||
char *get_peer_sun_path () {return peer_sun_path;}
|
||||
void set_cred ();
|
||||
|
||||
protected:
|
||||
pid_t sec_pid;
|
||||
uid_t sec_uid;
|
||||
gid_t sec_gid;
|
||||
pid_t sec_peer_pid;
|
||||
uid_t sec_peer_uid;
|
||||
gid_t sec_peer_gid;
|
||||
struct ucred peer_cred;
|
||||
void set_cred ();
|
||||
|
||||
public:
|
||||
fhandler_socket_unix ();
|
||||
|
@ -178,12 +178,9 @@ fhandler_socket_unix::set_peer_sun_path (const char *path)
|
||||
void
|
||||
fhandler_socket_unix::set_cred ()
|
||||
{
|
||||
sec_pid = getpid ();
|
||||
sec_uid = geteuid32 ();
|
||||
sec_gid = getegid32 ();
|
||||
sec_peer_pid = (pid_t) 0;
|
||||
sec_peer_uid = (uid_t) -1;
|
||||
sec_peer_gid = (gid_t) -1;
|
||||
peer_cred.pid = (pid_t) 0;
|
||||
peer_cred.uid = (uid_t) -1;
|
||||
peer_cred.gid = (gid_t) -1;
|
||||
}
|
||||
|
||||
int
|
||||
@ -317,11 +314,11 @@ fhandler_socket_unix::getpeereid (pid_t *pid, uid_t *euid, gid_t *egid)
|
||||
__try
|
||||
{
|
||||
if (pid)
|
||||
*pid = sec_peer_pid;
|
||||
*pid = peer_cred.pid;
|
||||
if (euid)
|
||||
*euid = sec_peer_uid;
|
||||
*euid = peer_cred.uid;
|
||||
if (egid)
|
||||
*egid = sec_peer_gid;
|
||||
*egid = peer_cred.gid;
|
||||
return 0;
|
||||
}
|
||||
__except (EFAULT) {}
|
||||
|
20
winsup/cygwin/include/cygwin/_ucred.h
Normal file
20
winsup/cygwin/include/cygwin/_ucred.h
Normal file
@ -0,0 +1,20 @@
|
||||
/* cygwin/_ucred.h
|
||||
|
||||
This file is part of Cygwin.
|
||||
|
||||
This software is a copyrighted work licensed under the terms of the
|
||||
Cygwin license. Please consult the file "CYGWIN_LICENSE" for
|
||||
details. */
|
||||
|
||||
#ifndef _CYGWIN__UCRED_H
|
||||
#define _CYGWIN__UCRED_H
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
struct ucred {
|
||||
pid_t pid;
|
||||
uid_t uid;
|
||||
gid_t gid;
|
||||
};
|
||||
|
||||
#endif /* _CYGWIN__UCRED_H */
|
@ -47,12 +47,7 @@ struct sockaddr_storage {
|
||||
#include <asm/socket.h> /* arch-dependent defines */
|
||||
#include <cygwin/sockios.h> /* the SIOCxxx I/O controls */
|
||||
#include <sys/uio.h> /* iovec support */
|
||||
|
||||
struct ucred {
|
||||
pid_t pid;
|
||||
uid_t uid;
|
||||
gid_t gid;
|
||||
};
|
||||
#include <cygwin/_ucred.h> /* struct ucred */
|
||||
|
||||
struct linger {
|
||||
unsigned short l_onoff; /* Linger active */
|
||||
|
Loading…
x
Reference in New Issue
Block a user