Add cygsid methods to create SIDs from scratch

So far creating cygsids requires to generate an "S-1-..." string
which is then converted to a SID by cygsid::getfromstr.

Add two new methods:

- cygsid::create (DWORD auth, DWORD subauth_count, ...)

    ... is a variable length list of subauth_count DWORD values being
    the actual subauths.

- cygsid::append (DWORD rid)

    allows to append a single RID to an alreaday constituted SID.

	* security.h (cygsid::create): Declare public.
	(cygsid::append): Ditto.
	* sec_helper.cc (cygsid::create): Implement.
	(cygsid::append): Implement.
	* uinfo.cc (pwdgrp::fetch_account_from_windows): Use both new
	methods as appropriate.  Drop setting csid from string.  Create
	SID strings for printing SIDs only.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
Corinna Vinschen
2016-03-12 16:39:19 +01:00
parent 5b972d5b29
commit 018fa93e2b
3 changed files with 54 additions and 23 deletions

View File

@ -248,6 +248,9 @@ public:
return (*this = sp) != NO_SID;
}
const PSID create (DWORD auth, DWORD subauth_cnt, ...);
bool append (DWORD rid);
/* Implemented in pwdgrp.h. */
BOOL getfrompw (const struct passwd *pw);
BOOL getfromgr (const struct group *gr);