* syscalls.cc (stat_worker): Add a check for the special case when
a process creates a file using mode 000 using ntsec.
This commit is contained in:
parent
31f5feea33
commit
d7ed877ba3
|
@ -1,3 +1,8 @@
|
||||||
|
Tue Feb 6 15:04:00 2001 Corinna Vinschen <corinna@vinschen.de>
|
||||||
|
|
||||||
|
* syscalls.cc (stat_worker): Add a check for the special case when
|
||||||
|
a process creates a file using mode 000 using ntsec.
|
||||||
|
|
||||||
Mon Feb 5 17:00:00 2001 Corinna Vinschen <corinna@vinschen.de>
|
Mon Feb 5 17:00:00 2001 Corinna Vinschen <corinna@vinschen.de>
|
||||||
|
|
||||||
* fhandler.cc (fhandler_base::open): Always add GENERIC_READ access
|
* fhandler.cc (fhandler_base::open): Always add GENERIC_READ access
|
||||||
|
|
|
@ -1027,6 +1027,11 @@ stat_worker (const char *caller, const char *name, struct stat *buf,
|
||||||
int res = -1;
|
int res = -1;
|
||||||
int oret = 1;
|
int oret = 1;
|
||||||
int atts;
|
int atts;
|
||||||
|
|
||||||
|
int attribute = 0;
|
||||||
|
uid_t uid;
|
||||||
|
gid_t gid;
|
||||||
|
|
||||||
char root[MAX_PATH];
|
char root[MAX_PATH];
|
||||||
UINT dtype;
|
UINT dtype;
|
||||||
fhandler_disk_file fh (NULL);
|
fhandler_disk_file fh (NULL);
|
||||||
|
@ -1060,25 +1065,44 @@ stat_worker (const char *caller, const char *name, struct stat *buf,
|
||||||
if ((atts == -1 || !(atts & FILE_ATTRIBUTE_DIRECTORY) ||
|
if ((atts == -1 || !(atts & FILE_ATTRIBUTE_DIRECTORY) ||
|
||||||
(os_being_run == winNT
|
(os_being_run == winNT
|
||||||
&& dtype != DRIVE_NO_ROOT_DIR
|
&& dtype != DRIVE_NO_ROOT_DIR
|
||||||
&& dtype != DRIVE_UNKNOWN))
|
&& dtype != DRIVE_UNKNOWN)))
|
||||||
&& (oret = fh.open (real_path, O_RDONLY | O_BINARY | O_DIROPEN |
|
|
||||||
(nofollow ? O_NOSYMLINK : 0), 0)))
|
|
||||||
{
|
{
|
||||||
res = fh.fstat (buf);
|
oret = fh.open (real_path, O_RDONLY | O_BINARY | O_DIROPEN |
|
||||||
fh.close ();
|
(nofollow ? O_NOSYMLINK : 0), 0);
|
||||||
/* The number of links to a directory includes the
|
/* Check a special case here. If ntsec is ON it happens
|
||||||
number of subdirectories in the directory, since all
|
that a process creates a file using mode 000 to disallow
|
||||||
those subdirectories point to it.
|
other processes access. In contrast to UNIX, this results
|
||||||
This is too slow on remote drives, so we do without it and
|
in a failing open call in the same process. Check that
|
||||||
set the number of links to 2. */
|
case. */
|
||||||
/* Unfortunately the count of 2 confuses `find(1)' command. So
|
if (!oret && allow_ntsec && get_errno () == EACCES
|
||||||
let's try it with `1' as link count. */
|
&& !get_file_attribute (TRUE, real_path, &attribute, &uid, &gid)
|
||||||
if (atts != -1 && (atts & FILE_ATTRIBUTE_DIRECTORY))
|
&& !attribute && uid == myself->uid && gid == myself->gid)
|
||||||
buf->st_nlink =
|
{
|
||||||
(dtype == DRIVE_REMOTE ? 1 : num_entries (real_path.get_win32 ()));
|
set_file_attribute (TRUE, real_path, 0400);
|
||||||
|
oret = fh.open (real_path, O_RDONLY | O_BINARY | O_DIROPEN |
|
||||||
|
(nofollow ? O_NOSYMLINK : 0), 0);
|
||||||
|
set_file_attribute (TRUE, real_path.get_win32 (), 0);
|
||||||
|
}
|
||||||
|
if (oret)
|
||||||
|
{
|
||||||
|
res = fh.fstat (buf);
|
||||||
|
fh.close ();
|
||||||
|
/* The number of links to a directory includes the
|
||||||
|
number of subdirectories in the directory, since all
|
||||||
|
those subdirectories point to it.
|
||||||
|
This is too slow on remote drives, so we do without it and
|
||||||
|
set the number of links to 2. */
|
||||||
|
/* Unfortunately the count of 2 confuses `find(1)' command. So
|
||||||
|
let's try it with `1' as link count. */
|
||||||
|
if (atts != -1 && (atts & FILE_ATTRIBUTE_DIRECTORY))
|
||||||
|
buf->st_nlink = (dtype == DRIVE_REMOTE
|
||||||
|
? 1
|
||||||
|
: num_entries (real_path.get_win32 ()));
|
||||||
|
goto done;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (atts != -1 || (!oret && get_errno () != ENOENT
|
if (atts != -1 || (!oret && get_errno () != ENOENT
|
||||||
&& get_errno () != ENOSHARE))
|
&& get_errno () != ENOSHARE))
|
||||||
{
|
{
|
||||||
/* Unfortunately, the above open may fail if the file exists, though.
|
/* Unfortunately, the above open may fail if the file exists, though.
|
||||||
So we have to care for this case here, too. */
|
So we have to care for this case here, too. */
|
||||||
|
|
Loading…
Reference in New Issue