* path.h (has_exec_chars): Standard function for checking for executable magic
numbers. * path.cc (symlink_info::check): Use the above function. * fhandler.cc (fhandler_disk_file::open): Ditto.
This commit is contained in:
parent
772e2322bd
commit
b12796a06d
@ -1,3 +1,10 @@
|
||||
Tue Oct 31 18:12:56 2000 Christopher Faylor <cgf@cygnus.com>
|
||||
|
||||
* path.h (has_exec_chars): Standard function for checking for
|
||||
executable magic numbers.
|
||||
* path.cc (symlink_info::check): Use the above function.
|
||||
* fhandler.cc (fhandler_disk_file::open): Ditto.
|
||||
|
||||
Tue Oct 31 17:57:52 2000 Christopher Faylor <cgf@cygnus.com>
|
||||
|
||||
* path.cc (_readlink): Return ENOENT when file does not exist.
|
||||
|
@ -1227,8 +1227,7 @@ fhandler_disk_file::open (path_conv& real_path, int flags, mode_t mode)
|
||||
/* FIXME should we use /etc/magic ? */
|
||||
magic[0] = magic[1] = magic[2] = '\0';
|
||||
ReadFile (get_handle (), magic, 3, &done, 0);
|
||||
if ((magic[0] == ':' && magic[1] == '\n') ||
|
||||
(magic[0] == '#' && magic[1] == '!'))
|
||||
if (has_exec_chars (magic, done))
|
||||
real_path.set_exec ();
|
||||
if (!(flags & O_APPEND))
|
||||
SetFilePointer (get_handle(), 0, 0, FILE_BEGIN);
|
||||
|
@ -2319,11 +2319,12 @@ symlink_info::check (const char *in_path, const suffix_info *suffixes)
|
||||
else
|
||||
{
|
||||
/* Not a symlink, see if executable. */
|
||||
if (!(pflags & PATH_ALL_EXEC) && got >= 2 &&
|
||||
((cookie_buf[0] == '#' && cookie_buf[1] == '!') ||
|
||||
(cookie_buf[0] == ':' && cookie_buf[1] == '\n') ||
|
||||
(cookie_buf[0] == 'M' && cookie_buf[1] == 'Z')))
|
||||
if (!(pflags & PATH_ALL_EXEC) &&
|
||||
has_exec_chars (cookie_buf, got))
|
||||
{
|
||||
debug_printf ("setting exec flag");
|
||||
pflags |= PATH_EXEC;
|
||||
}
|
||||
close_and_return:
|
||||
CloseHandle (h);
|
||||
goto file_not_symlink;
|
||||
|
@ -122,6 +122,15 @@ const char * __stdcall find_exec (const char *name, path_conv& buf, const char *
|
||||
|
||||
#define isdrive(s) (isalpha (*(s)) && (s)[1] == ':')
|
||||
|
||||
static inline bool
|
||||
has_exec_chars (const char *buf, int len)
|
||||
{
|
||||
return len >= 2 &&
|
||||
((buf[0] == '#' && buf[1] == '!') ||
|
||||
(buf[0] == ':' && buf[1] == '\n') ||
|
||||
(buf[0] == 'M' && buf[1] == 'Z'));
|
||||
}
|
||||
|
||||
/* cwd cache stuff. */
|
||||
|
||||
class muto;
|
||||
|
Loading…
Reference in New Issue
Block a user