* include/cygwin/in.h (in_attr_t): Define new type.

* include/arpa/inet.h (inet_addr): Change return type to in_addr_t.
(inet_lnaof): Ditto.
(inet_netof): Ditto.
(inet_network): Ditto.
* include/cygwin/types.h: Move many *_t typedefs here.  Protect them with
ifdefs.
* fhandler_disk_file.cc (fhandler_disk_file::fstat): Change ntsec_atts to
mode_t.
* security.cc (get_attribute_from_acl): Accept mode_t attribute.
(get_nt_attribute): Ditto.
(get_file_attribute): Ditto.
(get_nt_object_attribute): Ditto.
(get_object_attribute): Ditto.
* security.h: Reflect above changes.
* syscalls.cc (chown_worker): Change attrib to mode_t.
This commit is contained in:
Christopher Faylor 2003-02-10 22:43:29 +00:00
parent eff24ab9c5
commit 407b8df695
8 changed files with 226 additions and 77 deletions

View File

@ -1,3 +1,24 @@
2003-02-10 Ralf Habacker <ralf.habacker@freenet.de>
* include/cygwin/in.h (in_attr_t): Define new type.
* include/arpa/inet.h (inet_addr): Change return type to in_addr_t.
(inet_lnaof): Ditto.
(inet_netof): Ditto.
(inet_network): Ditto.
2003-02-10 Christopher Faylor <cgf@redhat.com>
* include/cygwin/types.h: Move many *_t typedefs here. Protect them
with ifdefs.
* fhandler_disk_file.cc (fhandler_disk_file::fstat): Change ntsec_atts to mode_t.
* security.cc (get_attribute_from_acl): Accept mode_t attribute.
(get_nt_attribute): Ditto.
(get_file_attribute): Ditto.
(get_nt_object_attribute): Ditto.
(get_object_attribute): Ditto.
* security.h: Reflect above changes.
* syscalls.cc (chown_worker): Change attrib to mode_t.
2003-02-08 Christopher Faylor <cgf@redhat.com> 2003-02-08 Christopher Faylor <cgf@redhat.com>
* include/cygwin/version.h: Bump DLL minor number to 21. * include/cygwin/version.h: Bump DLL minor number to 21.

View File

@ -174,7 +174,7 @@ fhandler_disk_file::fstat (struct __stat64 *buf, path_conv *pc)
oret = 0; oret = 0;
else if (!(oret = open (pc, open_flags, 0))) else if (!(oret = open (pc, open_flags, 0)))
{ {
int ntsec_atts = 0; mode_t ntsec_atts = 0;
/* If we couldn't open the file, try a "query open" with no permissions. /* If we couldn't open the file, try a "query open" with no permissions.
This will allow us to determine *some* things about the file, at least. */ This will allow us to determine *some* things about the file, at least. */
set_query_open (true); set_query_open (true);

View File

@ -1,6 +1,6 @@
/* arpa/inet.h /* arpa/inet.h
Copyright 1997, 1998, 2001 Red Hat, Inc. Copyright 1997, 1998, 2001, 2002, 2003 Red Hat, Inc.
This file is part of Cygwin. This file is part of Cygwin.
@ -19,12 +19,12 @@ extern "C"
#endif #endif
#ifndef __INSIDE_CYGWIN_NET__ #ifndef __INSIDE_CYGWIN_NET__
unsigned long inet_addr (const char *); in_addr_t inet_addr (const char *);
int inet_aton (const char *, struct in_addr *); int inet_aton (const char *, struct in_addr *);
unsigned long inet_lnaof (struct in_addr); in_addr_t inet_lnaof (struct in_addr);
struct in_addr inet_makeaddr (unsigned long , unsigned long); struct in_addr inet_makeaddr (unsigned long , unsigned long);
unsigned int inet_netof (struct in_addr); in_addr_t inet_netof (struct in_addr);
unsigned int inet_network (const char *); in_addr_t inet_network (const char *);
char *inet_ntoa (struct in_addr); char *inet_ntoa (struct in_addr);
#endif #endif

View File

@ -21,7 +21,8 @@
#include <cygwin/types.h> #include <cygwin/types.h>
/* Standard well-defined IP protocols. */ /* Standard well-defined IP protocols. */
enum { enum
{
IPPROTO_IP = 0, /* Dummy protocol for TCP */ IPPROTO_IP = 0, /* Dummy protocol for TCP */
IPPROTO_ICMP = 1, /* Internet Control Message Protocol */ IPPROTO_ICMP = 1, /* Internet Control Message Protocol */
IPPROTO_IGMP = 2, /* Internet Gateway Management Protocol */ IPPROTO_IGMP = 2, /* Internet Gateway Management Protocol */
@ -36,9 +37,10 @@ enum {
IPPROTO_MAX IPPROTO_MAX
}; };
typedef uint16_t in_port_t;
/* Standard well-known ports. *//* from winsup/include/netinet/in.h */ /* Standard well-known ports. *//* from winsup/include/netinet/in.h */
enum enum
{ {
IPPORT_ECHO = 7, /* Echo service. */ IPPORT_ECHO = 7, /* Echo service. */
IPPORT_DISCARD = 9, /* Discard transmissions service. */ IPPORT_DISCARD = 9, /* Discard transmissions service. */
IPPORT_SYSTAT = 11, /* System status service. */ IPPORT_SYSTAT = 11, /* System status service. */
@ -74,11 +76,12 @@ enum
/* Ports greater this value are reserved for (non-privileged) servers. */ /* Ports greater this value are reserved for (non-privileged) servers. */
IPPORT_USERRESERVED = 5000 IPPORT_USERRESERVED = 5000
}; };
typedef uint32_t in_addr_t;
/* Internet address. */ /* Internet address. */
struct in_addr { struct in_addr
{
unsigned int s_addr; unsigned int s_addr;
}; };
@ -93,18 +96,18 @@ struct ip_mreq
/* Structure describing an Internet (IP) socket address. */ /* Structure describing an Internet (IP) socket address. */
#define __SOCK_SIZE__ 16 /* sizeof(struct sockaddr) */ #define __SOCK_SIZE__ 16 /* sizeof(struct sockaddr) */
struct sockaddr_in { struct sockaddr_in
{
short int sin_family; /* Address family */ short int sin_family; /* Address family */
unsigned short int sin_port; /* Port number */ unsigned short int sin_port; /* Port number */
struct in_addr sin_addr; /* Internet address */ struct in_addr sin_addr; /* Internet address */
/* Pad to size of `struct sockaddr'. */ /* Pad to size of `struct sockaddr'. */
unsigned char __pad[__SOCK_SIZE__ - sizeof(short int) - unsigned chari __pad[__SOCK_SIZE__ - sizeof(short int)
sizeof(unsigned short int) - sizeof(struct in_addr)]; - sizeof(unsigned short int) - sizeof(struct in_addr)];
}; };
#define sin_zero __pad /* for BSD UNIX comp. -FvK */ #define sin_zero __pad /* for BSD UNIX comp. -FvK */
/* /*
* Definitions of the bits in an Internet address integer. * Definitions of the bits in an Internet address integer.
* On subnets, host and network parts are found according * On subnets, host and network parts are found according
@ -167,11 +170,8 @@ struct sockaddr_in {
#endif #endif
/* /* IPv6 definitions as we start to include them. This is just
* IPv6 definitions as we start to include them. This is just a beginning dont get excited 8) */
* a beginning dont get excited 8)
*/
struct in6_addr struct in6_addr
{ {
unsigned char s6_addr[16]; unsigned char s6_addr[16];
@ -184,5 +184,4 @@ struct sockaddr_in6
unsigned long sin6_flowinfo; unsigned long sin6_flowinfo;
struct in6_addr sin6_addr; struct in6_addr sin6_addr;
}; };
#endif /* _CYGWIN_IN_H */ #endif /* _CYGWIN_IN_H */

View File

@ -19,8 +19,18 @@ extern "C"
#include <sys/sysmacros.h> #include <sys/sysmacros.h>
typedef struct timespec timespec_t, timestruc_t; #ifndef __timespec_t_defined
#define __timespec_t_defined
typedef struct timespec timespec_t;
#endif /*__timespec_t_defined*/
#ifndef __timestruc_t_defined
#define __timestruc_t_defined
typedef struct timespec timestruc_t;
#endif /*__timestruc_t_defined*/
#ifndef __off_t_defined
#define __off_t_defined
typedef long __off32_t; typedef long __off32_t;
typedef long long __off64_t; typedef long long __off64_t;
#ifdef __CYGWIN_USE_BIG_TYPES__ #ifdef __CYGWIN_USE_BIG_TYPES__
@ -28,7 +38,10 @@ typedef __off64_t off_t;
#else #else
typedef __off32_t off_t; typedef __off32_t off_t;
#endif #endif
#endif /*__off_t_defined*/
#ifndef __dev_t_defined
#define __dev_t_defined
typedef short __dev16_t; typedef short __dev16_t;
typedef unsigned long __dev32_t; typedef unsigned long __dev32_t;
#ifdef __CYGWIN_USE_BIG_TYPES__ #ifdef __CYGWIN_USE_BIG_TYPES__
@ -36,9 +49,15 @@ typedef __dev32_t dev_t;
#else #else
typedef __dev16_t dev_t; typedef __dev16_t dev_t;
#endif #endif
#endif /*__dev_t_defined*/
#ifndef __blksize_t_defined
#define __blksize_t_defined
typedef long blksize_t; typedef long blksize_t;
#endif /*__blksize_t_defined*/
#ifndef __blkcnt_t_defined
#define __blkcnt_t_defined
typedef long __blkcnt32_t; typedef long __blkcnt32_t;
typedef long long __blkcnt64_t; typedef long long __blkcnt64_t;
#ifdef __CYGWIN_USE_BIG_TYPES__ #ifdef __CYGWIN_USE_BIG_TYPES__
@ -46,18 +65,128 @@ typedef __blkcnt64_t blkcnt_t;
#else #else
typedef __blkcnt32_t blkcnt_t; typedef __blkcnt32_t blkcnt_t;
#endif #endif
#endif /*__blkcnt_t_defined*/
#ifndef __uid_t_defined
#define __uid_t_defined
typedef unsigned short __uid16_t; typedef unsigned short __uid16_t;
typedef unsigned short __gid16_t;
typedef unsigned long __uid32_t; typedef unsigned long __uid32_t;
typedef unsigned long __gid32_t;
#ifdef __CYGWIN_USE_BIG_TYPES__ #ifdef __CYGWIN_USE_BIG_TYPES__
typedef __uid32_t uid_t; typedef __uid32_t uid_t;
typedef __gid32_t gid_t;
#else #else
typedef __uid16_t uid_t; typedef __uid16_t uid_t;
#endif
#endif /*__uid_t_defined*/
#ifndef __gid_t_defined
#define __gid_t_defined
typedef unsigned short __gid16_t;
typedef unsigned long __gid32_t;
#ifdef __CYGWIN_USE_BIG_TYPES__
typedef __gid32_t gid_t;
#else
typedef __gid16_t gid_t; typedef __gid16_t gid_t;
#endif #endif
#endif /*__gid_t_defined*/
#ifndef __ino_t_defined
#define __ino_t_defined
#ifdef __CYGWIN_USE_BIG_TYPES1__
typedef unsigned long long ino_t;
#else
typedef unsigned long ino_t;
#endif
#endif /*__ino_t_defined*/
#ifndef __BIT_TYPES_DEFINED
#define __BIT_TYPES_DEFINED__ 1
#ifndef __vm_offset_t
#define __vm_offset_t_defined
typedef unsigned long vm_offset_t;
#endif /*__vm_offset_t_defined*/
#ifndef __vm_size_t
#define __vm_size_t_defined
typedef unsigned long vm_size_t;
#endif /*__vm_size_t_defined*/
#ifndef __int8_t_defined
#define __int8_t_defined
typedef char int8_t;
#endif
#ifndef __int16_t_defined
#define __int16_t_defined
typedef __int16_t int16_t;
#endif
#ifndef __int32_t_defined
#define __int32_t_defined
typedef __int32_t int32_t;
#endif
#ifndef __int64_t_defined
#define __int64_t_defined
typedef __int64_t int64_t;
#endif
#ifndef __uint8_t_defined
#define __uint8_t_defined
typedef unsigned char uint8_t;
#endif
#ifndef __uint16_t_defined
#define __uint16_t_defined
typedef __uint16_t uint16_t;
#endif
#ifndef __uint32_t_defined
#define __uint32_t_defined
typedef __uint32_t uint32_t;
#endif
#ifndef __uint64_t_defined
#define __uint64_t_defined
typedef __uint64_t uint64_t;
#endif
#ifndef __uint8_t_defined
#define __uint8_t_defined
typedef unsigned char u_int8_t;
#endif
#ifndef __uint16_t_defined
#define __uint16_t_defined
typedef __uint16_t u_int16_t;
#endif
#ifndef __uint32_t_defined
#define __uint32_t_defined
typedef __uint32_t u_int32_t;
#endif
#ifndef __uint64_t_defined
#define __uint64_t_defined
typedef __uint64_t u_int64_t;
#endif
#ifndef __uintptr_t_defined
#define __uintptr_t_defined
typedef unsigned long uintptr_t;
#endif
#ifndef __intptr_t_defined
#define __intptr_t_defined
typedef long intptr_t;
#endif
#ifndef __register_t_defined
#define __register_t_defined
typedef __int32_t register_t;
#endif
#ifndef __addr_t_defined
#define __addr_t_defined
typedef char *addr_t;
#endif
#ifndef __mode_t_defined
#define __mode_t_defined
typedef unsigned mode_t;
#endif
#endif /*__BIT_TYPES_DEFINED*/
#if !defined(__INSIDE_CYGWIN__) || !defined(__cplusplus) #if !defined(__INSIDE_CYGWIN__) || !defined(__cplusplus)

View File

@ -1224,7 +1224,7 @@ write_sd (const char *file, PSECURITY_DESCRIPTOR sd_buf, DWORD sd_size)
} }
static void static void
get_attribute_from_acl (int * attribute, PACL acl, PSID owner_sid, get_attribute_from_acl (mode_t *attribute, PACL acl, PSID owner_sid,
PSID group_sid, BOOL grp_member) PSID group_sid, BOOL grp_member)
{ {
ACCESS_ALLOWED_ACE *ace; ACCESS_ALLOWED_ACE *ace;
@ -1319,7 +1319,7 @@ get_attribute_from_acl (int * attribute, PACL acl, PSID owner_sid,
} }
static int static int
get_nt_attribute (const char *file, int *attribute, get_nt_attribute (const char *file, mode_t *attribute,
__uid32_t *uidret, __gid32_t *gidret) __uid32_t *uidret, __gid32_t *gidret)
{ {
if (!wincap.has_security ()) if (!wincap.has_security ())
@ -1387,7 +1387,7 @@ get_nt_attribute (const char *file, int *attribute,
int int
get_file_attribute (int use_ntsec, const char *file, get_file_attribute (int use_ntsec, const char *file,
int *attribute, __uid32_t *uidret, __gid32_t *gidret) mode_t *attribute, __uid32_t *uidret, __gid32_t *gidret)
{ {
int res; int res;
@ -1435,7 +1435,7 @@ get_file_attribute (int use_ntsec, const char *file,
static int static int
get_nt_object_attribute (HANDLE handle, SE_OBJECT_TYPE object_type, get_nt_object_attribute (HANDLE handle, SE_OBJECT_TYPE object_type,
int *attribute, __uid32_t *uidret, __gid32_t *gidret) mode_t *attribute, __uid32_t *uidret, __gid32_t *gidret)
{ {
if (!wincap.has_security ()) if (!wincap.has_security ())
return 0; return 0;
@ -1492,7 +1492,7 @@ get_nt_object_attribute (HANDLE handle, SE_OBJECT_TYPE object_type,
int int
get_object_attribute (HANDLE handle, SE_OBJECT_TYPE object_type, get_object_attribute (HANDLE handle, SE_OBJECT_TYPE object_type,
int *attribute, __uid32_t *uidret, __gid32_t *gidret) mode_t *attribute, __uid32_t *uidret, __gid32_t *gidret)
{ {
if (allow_ntsec) if (allow_ntsec)
{ {

View File

@ -215,11 +215,11 @@ extern BOOL allow_smbntsec;
/* File manipulation */ /* File manipulation */
int __stdcall set_process_privileges (); int __stdcall set_process_privileges ();
int __stdcall get_file_attribute (int, const char *, int *, int __stdcall get_file_attribute (int, const char *, mode_t *,
__uid32_t * = NULL, __gid32_t * = NULL); __uid32_t * = NULL, __gid32_t * = NULL);
int __stdcall set_file_attribute (int, const char *, int); int __stdcall set_file_attribute (int, const char *, int);
int __stdcall set_file_attribute (int, const char *, __uid32_t, __gid32_t, int); int __stdcall set_file_attribute (int, const char *, __uid32_t, __gid32_t, int);
int __stdcall get_object_attribute (HANDLE handle, SE_OBJECT_TYPE object_type, int *, int __stdcall get_object_attribute (HANDLE handle, SE_OBJECT_TYPE object_type, mode_t *,
__uid32_t * = NULL, __gid32_t * = NULL); __uid32_t * = NULL, __gid32_t * = NULL);
LONG __stdcall read_sd(const char *file, PSECURITY_DESCRIPTOR sd_buf, LPDWORD sd_size); LONG __stdcall read_sd(const char *file, PSECURITY_DESCRIPTOR sd_buf, LPDWORD sd_size);
LONG __stdcall write_sd(const char *file, PSECURITY_DESCRIPTOR sd_buf, DWORD sd_size); LONG __stdcall write_sd(const char *file, PSECURITY_DESCRIPTOR sd_buf, DWORD sd_size);

View File

@ -803,12 +803,12 @@ chown_worker (const char *name, unsigned fmode, __uid32_t uid, __gid32_t gid)
goto done; goto done;
} }
DWORD attrib = 0; mode_t attrib = 0;
if (win32_path.isdir ()) if (win32_path.isdir ())
attrib |= S_IFDIR; attrib |= S_IFDIR;
res = get_file_attribute (win32_path.has_acls (), res = get_file_attribute (win32_path.has_acls (),
win32_path.get_win32 (), win32_path.get_win32 (),
(int *) &attrib); &attrib);
if (!res) if (!res)
res = set_file_attribute (win32_path.has_acls (), win32_path, uid, res = set_file_attribute (win32_path.has_acls (), win32_path, uid,
gid, attrib); gid, attrib);