Make 'fstat' on MS-Windows behave more like 'stat' and 'lstat'.

src/w32.c (fstat): Return owner and group like 'stat' and 'lstat' do.
This commit is contained in:
Eli Zaretskii 2013-01-19 09:32:36 +02:00
parent 6a9465f387
commit 76e9f7b9a1
2 changed files with 18 additions and 7 deletions

View file

@ -3,6 +3,7 @@
* w32.c (acl_set_file): Treat ERROR_ACCESS_DENIED from
set_file_security as failure due to insufficient privileges.
Reported by Fabrice Popineau <fabrice.popineau@supelec.fr>.
(fstat): Return owner and group like 'stat' and 'lstat' do.
2013-01-19 Paul Eggert <eggert@cs.ucla.edu>

View file

@ -4164,13 +4164,23 @@ fstat (int desc, struct stat * buf)
else
buf->st_ino = fake_inode;
/* Consider files to belong to current user.
FIXME: this should use GetSecurityInfo API, but it is only
available for _WIN32_WINNT >= 0x501. */
buf->st_uid = dflt_passwd.pw_uid;
buf->st_gid = dflt_passwd.pw_gid;
strcpy (buf->st_uname, dflt_passwd.pw_name);
strcpy (buf->st_gname, dflt_group.gr_name);
/* If the caller so requested, get the true file owner and group.
Otherwise, consider the file to belong to the current user. */
if (!w32_stat_get_owner_group || is_windows_9x () == TRUE)
get_file_owner_and_group (NULL, buf);
else
{
PSECURITY_DESCRIPTOR psd = NULL;
psd = get_file_security_desc_by_handle (fh);
if (psd)
{
get_file_owner_and_group (psd, buf);
LocalFree (psd);
}
else
get_file_owner_and_group (NULL, buf);
}
buf->st_dev = info.dwVolumeSerialNumber;
buf->st_rdev = info.dwVolumeSerialNumber;