From fd6d25069f7b9016edd38d54d535be381be64c87 Mon Sep 17 00:00:00 2001 From: corinna Date: Tue, 4 Nov 2003 15:48:18 +0000 Subject: [PATCH] * external.cc (cygwin_internal): Add CW_GET_POSIX_SECURITY_ATTRIBUTE handling. * include/cygwin/version.h: Bump API minor number. * include/sys/cygwin.h (cygwin_getinfo_types): Add CW_GET_POSIX_SECURITY_ATTRIBUTE. * exceptions.cc (init_global_security): Move from here... * sec_helper.cc (init_global_security): ...to here. --- winsup/cygwin/ChangeLog | 11 +++++++++++ winsup/cygwin/exceptions.cc | 14 -------------- winsup/cygwin/external.cc | 9 +++++++++ winsup/cygwin/include/cygwin/version.h | 3 ++- winsup/cygwin/include/sys/cygwin.h | 3 ++- winsup/cygwin/sec_helper.cc | 18 ++++++++++++++++++ 6 files changed, 42 insertions(+), 16 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index beea371aa4..4bc145fab3 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,14 @@ +2003-11-04 Corinna Vinschen + + * external.cc (cygwin_internal): Add CW_GET_POSIX_SECURITY_ATTRIBUTE + handling. + * include/cygwin/version.h: Bump API minor number. + * include/sys/cygwin.h (cygwin_getinfo_types): Add + CW_GET_POSIX_SECURITY_ATTRIBUTE. + + * exceptions.cc (init_global_security): Move from here... + * sec_helper.cc (init_global_security): ...to here. + 2003-11-04 Christopher Faylor * net.cc (dup_ent): Use IsBadStringPtr for alignment checks. Don't use diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc index 65d57b3610..194aa33948 100644 --- a/winsup/cygwin/exceptions.cc +++ b/winsup/cygwin/exceptions.cc @@ -126,20 +126,6 @@ init_console_handler () system_printf ("SetConsoleCtrlHandler failed, %E"); } -void -init_global_security () -{ - /* Initialize global security attribute stuff */ - - sec_none.nLength = sec_none_nih.nLength = - sec_all.nLength = sec_all_nih.nLength = sizeof (SECURITY_ATTRIBUTES); - sec_none.bInheritHandle = sec_all.bInheritHandle = TRUE; - sec_none_nih.bInheritHandle = sec_all_nih.bInheritHandle = FALSE; - sec_none.lpSecurityDescriptor = sec_none_nih.lpSecurityDescriptor = NULL; - sec_all.lpSecurityDescriptor = sec_all_nih.lpSecurityDescriptor = - get_null_sd (); -} - extern "C" void init_exceptions (exception_list *el) { diff --git a/winsup/cygwin/external.cc b/winsup/cygwin/external.cc index 114a3de7c9..839d38050f 100644 --- a/winsup/cygwin/external.cc +++ b/winsup/cygwin/external.cc @@ -265,6 +265,15 @@ cygwin_internal (cygwin_getinfo_types t, ...) int deferrno = va_arg (arg, int); return geterrno_from_win_error (error, deferrno); } + case CW_GET_POSIX_SECURITY_ATTRIBUTE: + { + int attribute = va_arg (arg, int); + PSECURITY_ATTRIBUTES psa = va_arg (arg, PSECURITY_ATTRIBUTES); + void *sd_buf = va_arg (arg, void *); + DWORD sd_buf_size = va_arg (arg, DWORD); + set_security_attribute (attribute, psa, sd_buf, sd_buf_size); + return psa->lpSecurityDescriptor ? 0 : -1; + } default: return (DWORD) -1; } diff --git a/winsup/cygwin/include/cygwin/version.h b/winsup/cygwin/include/cygwin/version.h index f2c0338281..57ade5d66a 100644 --- a/winsup/cygwin/include/cygwin/version.h +++ b/winsup/cygwin/include/cygwin/version.h @@ -223,13 +223,14 @@ details. */ 96: CW_GET_ERRNO_FROM_WINERROR addition to external.cc 97: Export sem_open, sem_close, sem_timedwait, sem_getvalue. 98: Export _tmpfile64. + 99: CW_GET_POSIX_SECURITY_ATTRIBUTE addition to external.cc. */ /* Note that we forgot to bump the api for ualarm, strtoll, strtoull */ #define CYGWIN_VERSION_API_MAJOR 0 -#define CYGWIN_VERSION_API_MINOR 98 +#define CYGWIN_VERSION_API_MINOR 99 /* There is also a compatibity version number associated with the shared memory regions. It is incremented when incompatible diff --git a/winsup/cygwin/include/sys/cygwin.h b/winsup/cygwin/include/sys/cygwin.h index d2e1a4171b..4aec8c358f 100644 --- a/winsup/cygwin/include/sys/cygwin.h +++ b/winsup/cygwin/include/sys/cygwin.h @@ -73,7 +73,8 @@ typedef enum CW_EXTRACT_DOMAIN_AND_USER, CW_CMDLINE, CW_CHECK_NTSEC, - CW_GET_ERRNO_FROM_WINERROR + CW_GET_ERRNO_FROM_WINERROR, + CW_GET_POSIX_SECURITY_ATTRIBUTE } cygwin_getinfo_types; #define CW_NEXTPID 0x80000000 /* or with pid to get next one */ diff --git a/winsup/cygwin/sec_helper.cc b/winsup/cygwin/sec_helper.cc index dda3525438..ccd8d4487c 100644 --- a/winsup/cygwin/sec_helper.cc +++ b/winsup/cygwin/sec_helper.cc @@ -371,6 +371,24 @@ get_null_sd () return null_sdp; } +/* + * Initialize global security attributes. + * + * Called from dcrt0.cc (_dll_crt0). + */ + +void +init_global_security () +{ + sec_none.nLength = sec_none_nih.nLength = + sec_all.nLength = sec_all_nih.nLength = sizeof (SECURITY_ATTRIBUTES); + sec_none.bInheritHandle = sec_all.bInheritHandle = TRUE; + sec_none_nih.bInheritHandle = sec_all_nih.bInheritHandle = FALSE; + sec_none.lpSecurityDescriptor = sec_none_nih.lpSecurityDescriptor = NULL; + sec_all.lpSecurityDescriptor = sec_all_nih.lpSecurityDescriptor = + get_null_sd (); +} + BOOL sec_acl (PACL acl, bool original, bool admins, PSID sid1, PSID sid2, DWORD access2) { -- 2.11.0