diff --git a/winsup/cygwin/release/2.11.0 b/winsup/cygwin/release/2.11.0 index 8f308c8d3..ca6c8b5e3 100644 --- a/winsup/cygwin/release/2.11.0 +++ b/winsup/cygwin/release/2.11.0 @@ -78,3 +78,6 @@ Bug Fixes - Fix handling of unknown accounts in file ACLs. Add name->SID conversion for (most) self-constructed account names. Addresses: https://cygwin.com/ml/cygwin/2018-08/msg00295.html + +- Correctly handle Logon Session accounts on Windows 10. + Addresses: Found during debugging diff --git a/winsup/cygwin/uinfo.cc b/winsup/cygwin/uinfo.cc index eceaccab7..c2f4803ce 100644 --- a/winsup/cygwin/uinfo.cc +++ b/winsup/cygwin/uinfo.cc @@ -1821,6 +1821,14 @@ pwdgrp::construct_sid_from_name (cygsid &sid, wchar_t *name, wchar_t *sep) } return false; } + if (!sep && wcscmp (name, L"CurrentSession") == 0) + { + get_logon_sid (); + if (PSID (logon_sid) == NO_SID) + return false; + sid = logon_sid; + return true; + } if (!sep && wcscmp (name, L"Authentication authority asserted identity") == 0) { sid.create (18, 1, 1); @@ -1903,6 +1911,8 @@ pwdgrp::construct_sid_from_name (cygsid &sid, wchar_t *name, wchar_t *sep) return false; } +/* CV 2018-08-28: SidTypeLogonSession is not yet defined in Mingw64. */ +#define SidTypeLogonSession 11 char * pwdgrp::fetch_account_from_windows (fetch_user_arg_t &arg, cyg_ldap *pldap) @@ -2268,7 +2278,7 @@ pwdgrp::fetch_account_from_windows (fetch_user_arg_t &arg, cyg_ldap *pldap) if (acc_type == SidTypeUser && (sid_sub_auth_count (sid) <= 3 || sid_id_auth (sid) == 11)) acc_type = SidTypeWellKnownGroup; - switch (acc_type) + switch ((int) acc_type) { case SidTypeUser: if (is_group ()) @@ -2598,6 +2608,26 @@ pwdgrp::fetch_account_from_windows (fetch_user_arg_t &arg, cyg_ldap *pldap) if (uid == 0x10000 || uid == 0x10100) return NULL; break; + case SidTypeLogonSession: + /* Starting with Windows 10, LookupAccountSid/Name return valid + info for the login session with new SID_NAME_USE value + SidTypeLogonSession. To return the same info as on + pre-Windows 10, we have to handle this type explicitely here + now and convert the name to "CurrentSession". */ + get_logon_sid (); + if (PSID (logon_sid) == NO_SID) + return NULL; + if (RtlEqualSid (sid, logon_sid)) + { + uid = 0xfff; + wcpcpy (name = namebuf, L"CurrentSession"); + } + else + { + uid = 0xffe; + wcpcpy (name = namebuf, L"OtherSession"); + } + break; case SidTypeLabel: uid = 0x60000 + sid_sub_auth_rid (sid); fully_qualified_name = cygheap->pg.nss_prefix_always ();