From 54f79f8650452cafde18d54d54c38d0990a91eda Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Wed, 12 Nov 2014 11:19:08 +0000 Subject: [PATCH] * cygheap.h (cygheap_pwdgrp): Remove constants NSS_FILES and NSS_DB. Use NSS_SRC_FILES and NSS_SRC_DB throughout instead. (cygheap_pwdgrp::nss_pwd_src): New inline method. (cygheap_pwdgrp::nss_grp_src): Ditto. * external.cc (cygwin_internal): Add CW_GETNSS_PWD_SRC and CW_GETNSS_GRP_SRC cases. * uinfo.cc: Use NSS_SRC_FILES and NSS_SRC_DB throughout. * include/cygwin/version.h (CYGWIN_VERSION_API_MINOR): Bump. * include/sys/cygwin.h (cygwin_getinfo_types): Add CW_GETNSS_PWD_SRC and CW_GETNSS_GRP_SRC. (NSS_SRC_FILES): Define. (NSS_SRC_DB): Define. --- winsup/cygwin/ChangeLog | 15 +++++++++++++++ winsup/cygwin/cygheap.h | 12 ++++++------ winsup/cygwin/external.cc | 8 ++++++++ winsup/cygwin/include/cygwin/version.h | 3 ++- winsup/cygwin/include/sys/cygwin.h | 13 ++++++++++++- winsup/cygwin/uinfo.cc | 10 +++++----- 6 files changed, 48 insertions(+), 13 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index fa5ca1947..a4f2bd71f 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,18 @@ +2014-11-12 Corinna Vinschen + + * cygheap.h (cygheap_pwdgrp): Remove constants NSS_FILES and NSS_DB. + Use NSS_SRC_FILES and NSS_SRC_DB throughout instead. + (cygheap_pwdgrp::nss_pwd_src): New inline method. + (cygheap_pwdgrp::nss_grp_src): Ditto. + * external.cc (cygwin_internal): Add CW_GETNSS_PWD_SRC and + CW_GETNSS_GRP_SRC cases. + * uinfo.cc: Use NSS_SRC_FILES and NSS_SRC_DB throughout. + * include/cygwin/version.h (CYGWIN_VERSION_API_MINOR): Bump. + * include/sys/cygwin.h (cygwin_getinfo_types): Add CW_GETNSS_PWD_SRC + and CW_GETNSS_GRP_SRC. + (NSS_SRC_FILES): Define. + (NSS_SRC_DB): Define. + 2014-11-07 Corinna Vinschen * dcrt0.cc (cygwin__cxa_atexit): Fetch correct DSO handle value diff --git a/winsup/cygwin/cygheap.h b/winsup/cygwin/cygheap.h index ff86d5ef3..aa2a7f65a 100644 --- a/winsup/cygwin/cygheap.h +++ b/winsup/cygwin/cygheap.h @@ -400,8 +400,6 @@ public: class cygheap_pwdgrp { - static const int NSS_FILES = 1; - static const int NSS_DB = 2; enum pfx_t { NSS_AUTO = 0, NSS_PRIMARY, @@ -434,10 +432,12 @@ public: void init (); inline void nss_init () { if (!nss_inited) _nss_init (); } - inline bool nss_pwd_files () const { return !!(pwd_src & NSS_FILES); } - inline bool nss_pwd_db () const { return !!(pwd_src & NSS_DB); } - inline bool nss_grp_files () const { return !!(grp_src & NSS_FILES); } - inline bool nss_grp_db () const { return !!(grp_src & NSS_DB); } + inline bool nss_pwd_files () const { return !!(pwd_src & NSS_SRC_FILES); } + inline bool nss_pwd_db () const { return !!(pwd_src & NSS_SRC_DB); } + inline int nss_pwd_src () const { return pwd_src; } /* CW_GETNSS_PWD_SRC */ + inline bool nss_grp_files () const { return !!(grp_src & NSS_SRC_FILES); } + inline bool nss_grp_db () const { return !!(grp_src & NSS_SRC_DB); } + inline int nss_grp_src () const { return grp_src; } /* CW_GETNSS_GRP_SRC */ inline bool nss_prefix_auto () const { return prefix == NSS_AUTO; } inline bool nss_prefix_primary () const { return prefix == NSS_PRIMARY; } inline bool nss_prefix_always () const { return prefix == NSS_ALWAYS; } diff --git a/winsup/cygwin/external.cc b/winsup/cygwin/external.cc index fce161192..b42c284e1 100644 --- a/winsup/cygwin/external.cc +++ b/winsup/cygwin/external.cc @@ -601,6 +601,14 @@ cygwin_internal (cygwin_getinfo_types t, ...) res = (uintptr_t) cygheap->pg.nss_separator (); break; + case CW_GETNSS_PWD_SRC: + res = (uintptr_t) cygheap->pg.nss_pwd_src (); + break; + + case CW_GETNSS_GRP_SRC: + res = (uintptr_t) cygheap->pg.nss_grp_src (); + break; + case CW_GETPWSID: { int db_only = va_arg (arg, int); diff --git a/winsup/cygwin/include/cygwin/version.h b/winsup/cygwin/include/cygwin/version.h index e1ac2cee9..db19f8f18 100644 --- a/winsup/cygwin/include/cygwin/version.h +++ b/winsup/cygwin/include/cygwin/version.h @@ -456,12 +456,13 @@ details. */ 278: Add quotactl. 279: Export stime. 280: Static atexit in libcygwin.a, CW_FIXED_ATEXIT. + 281: Add CW_GETNSS_PWD_SRC, CW_GETNSS_GRP_SRC. */ /* Note that we forgot to bump the api for ualarm, strtoll, strtoull */ #define CYGWIN_VERSION_API_MAJOR 0 -#define CYGWIN_VERSION_API_MINOR 280 +#define CYGWIN_VERSION_API_MINOR 281 /* 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 7f40475e8..edfcc565a 100644 --- a/winsup/cygwin/include/sys/cygwin.h +++ b/winsup/cygwin/include/sys/cygwin.h @@ -151,7 +151,9 @@ typedef enum CW_GETPWSID, CW_GETGRSID, CW_CYGNAME_FROM_WINNAME, - CW_FIXED_ATEXIT + CW_FIXED_ATEXIT, + CW_GETNSS_PWD_SRC, + CW_GETNSS_GRP_SRC } cygwin_getinfo_types; #define CW_LOCK_PINFO CW_LOCK_PINFO @@ -210,6 +212,8 @@ typedef enum #define CW_GETGRSID CW_GETGRSID #define CW_CYGNAME_FROM_WINNAME CW_CYGNAME_FROM_WINNAME #define CW_FIXED_ATEXIT CW_FIXED_ATEXIT +#define CW_GETNSS_PWD_SRC CW_GETNSS_PWD_SRC +#define CW_GETNSS_GRP_SRC CW_GETNSS_GRP_SRC /* Token type for CW_SET_EXTERNAL_TOKEN */ enum @@ -218,6 +222,13 @@ enum CW_TOKEN_RESTRICTED = 1 }; +/* Source type for CW_GETNSS_PWD_SRC and CW_GETNSS_GRP_SRC. */ +enum +{ + NSS_SRC_FILES = 1, + NSS_SRC_DB = 2 +}; + /* Enumeration source constants for CW_SETENT called from mkpasswd/mkgroup. */ enum nss_enum_t { diff --git a/winsup/cygwin/uinfo.cc b/winsup/cygwin/uinfo.cc index 8b9266f9d..dc76ae92f 100644 --- a/winsup/cygwin/uinfo.cc +++ b/winsup/cygwin/uinfo.cc @@ -586,8 +586,8 @@ cygheap_pwdgrp::init () db_separator: + DISABLED db_enum: cache builtin */ - pwd_src = (NSS_FILES | NSS_DB); - grp_src = (NSS_FILES | NSS_DB); + pwd_src = (NSS_SRC_FILES | NSS_SRC_DB); + grp_src = (NSS_SRC_FILES | NSS_SRC_DB); prefix = NSS_AUTO; separator[0] = L'+'; enums = (ENUM_CACHE | ENUM_BUILTIN); @@ -628,12 +628,12 @@ cygheap_pwdgrp::nss_init_line (const char *line) break; if (!strncmp (c, "files", 5) && strchr (" \t", c[5])) { - *src |= NSS_FILES; + *src |= NSS_SRC_FILES; c += 5; } else if (!strncmp (c, "db", 2) && strchr (" \t", c[2])) { - *src |= NSS_DB; + *src |= NSS_SRC_DB; c += 2; } else @@ -643,7 +643,7 @@ cygheap_pwdgrp::nss_init_line (const char *line) } } if (*src == 0) - *src = (NSS_FILES | NSS_DB); + *src = (NSS_SRC_FILES | NSS_SRC_DB); } } break;