Fix broken PSID problem on cygheap in account handling

* pwdgrp.h: Add comment to explain below change.
        (struct pg_pwd): Convert sid member to BYTE array.
        (struct pg_grp): Ditto.
        * grp.cc (pwdgrp::parse_group): Accommodate above change.
        * passwd.cc (pwdgrp::parse_passwd): Ditto.

Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
This commit is contained in:
Corinna Vinschen 2015-04-17 11:56:15 +02:00
parent e26cf1c5d7
commit ecc6cfeb7e
4 changed files with 20 additions and 4 deletions

View File

@ -1,3 +1,11 @@
2015-04-17 Corinna Vinschen <corinna@vinschen.de>
* pwdgrp.h: Add comment to explain below change.
(struct pg_pwd): Convert sid member to BYTE array.
(struct pg_grp): Ditto.
* grp.cc (pwdgrp::parse_group): Accommodate above change.
* passwd.cc (pwdgrp::parse_passwd): Ditto.
2015-04-16 Corinna Vinschen <corinna@vinschen.de> 2015-04-16 Corinna Vinschen <corinna@vinschen.de>
* sec_acl.cc (set_posix_access): Move merging group perms into owner * sec_acl.cc (set_posix_access): Move merging group perms into owner

View File

@ -47,7 +47,9 @@ pwdgrp::parse_group ()
return false; return false;
/* Don't generate gr_mem entries. */ /* Don't generate gr_mem entries. */
grp.g.gr_mem = &null_ptr; grp.g.gr_mem = &null_ptr;
grp.sid.getfromgr_passwd (&grp.g); cygsid csid;
csid.getfromgr_passwd (&grp.g);
RtlCopySid (SECURITY_MAX_SID_SIZE, grp.sid, csid);
return true; return true;
} }

View File

@ -40,7 +40,9 @@ pwdgrp::parse_passwd ()
res.p.pw_gecos = next_str (':'); res.p.pw_gecos = next_str (':');
res.p.pw_dir = next_str (':'); res.p.pw_dir = next_str (':');
res.p.pw_shell = next_str (':'); res.p.pw_shell = next_str (':');
res.sid.getfrompw_gecos (&res.p); cygsid csid;
csid.getfrompw_gecos (&res.p);
RtlCopySid (SECURITY_MAX_SID_SIZE, res.sid, csid);
/* lptr points to the \0 after pw_shell. Increment by one to get the correct /* lptr points to the \0 after pw_shell. Increment by one to get the correct
required buffer len in getpw_cp. */ required buffer len in getpw_cp. */
res.len = lptr - res.p.pw_name + 1; res.len = lptr - res.p.pw_name + 1;

View File

@ -38,17 +38,21 @@ void *setgrent_filtered (int enums, PCWSTR enum_tdoms);
void *getgrent_filtered (void *gr); void *getgrent_filtered (void *gr);
void endgrent_filtered (void *gr); void endgrent_filtered (void *gr);
/* NOTE: The below sid members were cygsid's originally. Don't do that.
cygsid's are pointer based. When adding new entries to the passwd or
group caches, a crealloc call potenitally moves the entries and then
the cygsid pointers point into neverneverland. */
struct pg_pwd struct pg_pwd
{ {
struct passwd p; struct passwd p;
cygsid sid; BYTE sid[SECURITY_MAX_SID_SIZE];
size_t len; size_t len;
}; };
struct pg_grp struct pg_grp
{ {
struct group g; struct group g;
cygsid sid; BYTE sid[SECURITY_MAX_SID_SIZE];
size_t len; size_t len;
}; };