* fhandler.cc (fhandler_disk_file::fstat): Properly set executable bits for
directory when !ntsec && !ntea. Also move common code prior to call to get_attributes.
This commit is contained in:
parent
47132198ad
commit
e8d6e78f34
|
@ -1,3 +1,9 @@
|
||||||
|
Thu Jun 14 20:19:46 2001 Christopher Faylor <cgf@cygnus.com>
|
||||||
|
|
||||||
|
* fhandler.cc (fhandler_disk_file::fstat): Properly set executable bits
|
||||||
|
for directory when !ntsec && !ntea. Also move common code prior to
|
||||||
|
call to get_attributes.
|
||||||
|
|
||||||
Fri June 15 09:25:00 Robert Collins <rbtcollins@hotmail.com>
|
Fri June 15 09:25:00 Robert Collins <rbtcollins@hotmail.com>
|
||||||
|
|
||||||
* thread.cc (pthread_cond::Signal): Release the condition access
|
* thread.cc (pthread_cond::Signal): Release the condition access
|
||||||
|
|
|
@ -928,27 +928,20 @@ fhandler_disk_file::fstat (struct stat *buf)
|
||||||
/* Using a side effect: get_file_attibutes checks for
|
/* Using a side effect: get_file_attibutes checks for
|
||||||
directory. This is used, to set S_ISVTX, if needed. */
|
directory. This is used, to set S_ISVTX, if needed. */
|
||||||
if (local.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
if (local.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
||||||
buf->st_mode |= S_IFDIR;
|
buf->st_mode = S_IFDIR;
|
||||||
if (get_symlink_p ())
|
else if (get_symlink_p ())
|
||||||
buf->st_mode |= S_IFLNK;
|
buf->st_mode = S_IFLNK;
|
||||||
if (!get_file_attribute (has_acls (),
|
else if (get_socket_p ())
|
||||||
get_win32_name (),
|
buf->st_mode = S_IFSOCK;
|
||||||
&buf->st_mode,
|
if (get_file_attribute (has_acls (), get_win32_name (), &buf->st_mode,
|
||||||
&buf->st_uid,
|
&buf->st_uid, &buf->st_gid) == 0)
|
||||||
&buf->st_gid))
|
|
||||||
{
|
{
|
||||||
/* If read-only attribute is set, modify ntsec return value */
|
/* If read-only attribute is set, modify ntsec return value */
|
||||||
if ((local.dwFileAttributes & FILE_ATTRIBUTE_READONLY)
|
if ((local.dwFileAttributes & FILE_ATTRIBUTE_READONLY)
|
||||||
&& !get_symlink_p ())
|
&& !get_symlink_p ())
|
||||||
buf->st_mode &= ~(S_IWUSR | S_IWGRP | S_IWOTH);
|
buf->st_mode &= ~(S_IWUSR | S_IWGRP | S_IWOTH);
|
||||||
|
|
||||||
if (buf->st_mode & S_IFMT)
|
if (!(buf->st_mode & S_IFMT))
|
||||||
/* already set */;
|
|
||||||
else if (get_socket_p ())
|
|
||||||
buf->st_mode |= S_IFSOCK;
|
|
||||||
else if (local.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
|
||||||
buf->st_mode |= S_IFDIR;
|
|
||||||
else
|
|
||||||
buf->st_mode |= S_IFREG;
|
buf->st_mode |= S_IFREG;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -959,8 +952,10 @@ fhandler_disk_file::fstat (struct stat *buf)
|
||||||
buf->st_mode |= STD_WBITS;
|
buf->st_mode |= STD_WBITS;
|
||||||
/* | S_IWGRP | S_IWOTH; we don't give write to group etc */
|
/* | S_IWGRP | S_IWOTH; we don't give write to group etc */
|
||||||
|
|
||||||
if (buf->st_mode & S_IFMT)
|
if (buf->st_mode & S_IFDIR)
|
||||||
/* already set */;
|
buf->st_mode |= S_IFDIR | STD_XBITS;
|
||||||
|
else if (buf->st_mode & S_IFMT)
|
||||||
|
/* nothing */;
|
||||||
else if (get_socket_p ())
|
else if (get_socket_p ())
|
||||||
buf->st_mode |= S_IFSOCK;
|
buf->st_mode |= S_IFSOCK;
|
||||||
else
|
else
|
||||||
|
@ -971,35 +966,30 @@ fhandler_disk_file::fstat (struct stat *buf)
|
||||||
buf->st_mode |= S_IFCHR;
|
buf->st_mode |= S_IFCHR;
|
||||||
break;
|
break;
|
||||||
case FILE_TYPE_DISK:
|
case FILE_TYPE_DISK:
|
||||||
if (local.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
|
buf->st_mode |= S_IFREG;
|
||||||
buf->st_mode |= S_IFDIR | STD_XBITS;
|
if (!dont_care_if_execable () && !get_execable_p ())
|
||||||
else
|
{
|
||||||
{
|
DWORD cur, done;
|
||||||
buf->st_mode |= S_IFREG;
|
char magic[3];
|
||||||
if (!dont_care_if_execable () && !get_execable_p ())
|
|
||||||
{
|
|
||||||
DWORD cur, done;
|
|
||||||
char magic[3];
|
|
||||||
|
|
||||||
/* First retrieve current position, set to beginning
|
/* First retrieve current position, set to beginning
|
||||||
of file if not already there. */
|
of file if not already there. */
|
||||||
cur = SetFilePointer (get_handle(), 0, NULL, FILE_CURRENT);
|
cur = SetFilePointer (get_handle(), 0, NULL, FILE_CURRENT);
|
||||||
if (cur != INVALID_SET_FILE_POINTER &&
|
if (cur != INVALID_SET_FILE_POINTER &&
|
||||||
(!cur ||
|
(!cur ||
|
||||||
SetFilePointer (get_handle(), 0, NULL, FILE_BEGIN)
|
SetFilePointer (get_handle(), 0, NULL, FILE_BEGIN)
|
||||||
!= INVALID_SET_FILE_POINTER))
|
!= INVALID_SET_FILE_POINTER))
|
||||||
{
|
{
|
||||||
/* FIXME should we use /etc/magic ? */
|
/* FIXME should we use /etc/magic ? */
|
||||||
magic[0] = magic[1] = magic[2] = '\0';
|
magic[0] = magic[1] = magic[2] = '\0';
|
||||||
if (ReadFile (get_handle (), magic, 3, &done, 0) &&
|
if (ReadFile (get_handle (), magic, 3, &done, 0) &&
|
||||||
done == 3 && has_exec_chars (magic, done))
|
done == 3 && has_exec_chars (magic, done))
|
||||||
set_execable_p ();
|
set_execable_p ();
|
||||||
SetFilePointer (get_handle(), cur, NULL, FILE_BEGIN);
|
SetFilePointer (get_handle(), cur, NULL, FILE_BEGIN);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (get_execable_p ())
|
}
|
||||||
buf->st_mode |= STD_XBITS;
|
if (get_execable_p ())
|
||||||
}
|
buf->st_mode |= STD_XBITS;
|
||||||
break;
|
break;
|
||||||
case FILE_TYPE_PIPE:
|
case FILE_TYPE_PIPE:
|
||||||
buf->st_mode |= S_IFSOCK;
|
buf->st_mode |= S_IFSOCK;
|
||||||
|
|
Loading…
Reference in New Issue