* path.cc (symlink_info::check): Set executable bit for a file if the first two

characters are 'MZ' to mirror spawn_guts check.
This commit is contained in:
Christopher Faylor 2000-09-30 01:56:40 +00:00
parent 84ecbb38d6
commit 90fe77395a
4 changed files with 58 additions and 97 deletions

View File

@ -1,3 +1,8 @@
Fri Sep 29 21:49:27 2000 Christopher Faylor <cgf@cygnus.com>
* path.cc (symlink_info::check): Set executable bit for a file if the
first two characters are 'MZ' to mirror spawn_guts check.
Sat Sep 30 03:34:00 2000 Corinna Vinschen <corinna@vinschen.de> Sat Sep 30 03:34:00 2000 Corinna Vinschen <corinna@vinschen.de>
* winsup.h: Add `winME' to os_type symbols. * winsup.h: Add `winME' to os_type symbols.

View File

@ -2097,7 +2097,7 @@ symlink (const char *topath, const char *frompath)
goto done; goto done;
} }
h = CreateFileA(win32_path.get_win32 (), GENERIC_WRITE, 0, &sec_none_nih, h = CreateFileA(win32_path, GENERIC_WRITE, 0, &sec_none_nih,
CREATE_NEW, FILE_ATTRIBUTE_NORMAL, 0); CREATE_NEW, FILE_ATTRIBUTE_NORMAL, 0);
if (h == INVALID_HANDLE_VALUE) if (h == INVALID_HANDLE_VALUE)
__seterrno (); __seterrno ();
@ -2297,7 +2297,8 @@ symlink_info::check (const char *in_path, const suffix_info *suffixes)
/* Not a symlink, see if executable. */ /* Not a symlink, see if executable. */
if (!(pflags & (PATH_EXEC | PATH_CYGWIN_EXEC)) && got >= 2 && if (!(pflags & (PATH_EXEC | PATH_CYGWIN_EXEC)) && got >= 2 &&
((cookie_buf[0] == '#' && cookie_buf[1] == '!') || ((cookie_buf[0] == '#' && cookie_buf[1] == '!') ||
(cookie_buf[0] == ':' && cookie_buf[1] == '\n'))) (cookie_buf[0] == ':' && cookie_buf[1] == '\n') ||
(cookie_buf[0] == 'M' && cookie_buf[1] == 'Z')))
pflags |= PATH_EXEC; pflags |= PATH_EXEC;
close_and_return: close_and_return:
CloseHandle (h); CloseHandle (h);

View File

@ -423,7 +423,7 @@ spawn_guts (HANDLE hToken, const char * prog_arg, const char *const *argv,
char buf[2 * MAX_PATH + 1]; char buf[2 * MAX_PATH + 1];
buf[0] = buf[1] = buf[2] = buf[sizeof(buf) - 1] = '\0'; buf[0] = buf[1] = buf[2] = buf[sizeof(buf) - 1] = '\0';
if (! ReadFile (hnd, buf, sizeof (buf) - 1, &done, 0)) if (!ReadFile (hnd, buf, sizeof (buf) - 1, &done, 0))
{ {
CloseHandle (hnd); CloseHandle (hnd);
__seterrno (); __seterrno ();
@ -456,8 +456,8 @@ spawn_guts (HANDLE hToken, const char * prog_arg, const char *const *argv,
{ {
/* Null terminate the initial command and step over /* Null terminate the initial command and step over
any additional white space. If we've hit the any additional white space. If we've hit the
end of the line, exit the loop. Otherwise, position end of the line, exit the loop. Otherwise, we've
we've found the first argument. Position the current found the first argument. Position the current
pointer on the last known white space. */ pointer on the last known white space. */
*ptr = '\0'; *ptr = '\0';
char *newptr = ptr + 1; char *newptr = ptr + 1;

View File

@ -55,8 +55,7 @@ close_all_files (void)
cygwin_shared->delqueue.process_queue (); cygwin_shared->delqueue.process_queue ();
} }
extern "C" extern "C" int
int
_unlink (const char *ourname) _unlink (const char *ourname)
{ {
int res = -1; int res = -1;
@ -161,24 +160,21 @@ done:
return res; return res;
} }
extern "C" extern "C" pid_t
pid_t
_getpid () _getpid ()
{ {
return myself->pid; return myself->pid;
} }
/* getppid: POSIX 4.1.1.1 */ /* getppid: POSIX 4.1.1.1 */
extern "C" extern "C" pid_t
pid_t
getppid () getppid ()
{ {
return myself->ppid; return myself->ppid;
} }
/* setsid: POSIX 4.3.2.1 */ /* setsid: POSIX 4.3.2.1 */
extern "C" extern "C" pid_t
pid_t
setsid (void) setsid (void)
{ {
/* FIXME: for now */ /* FIXME: for now */
@ -242,8 +238,7 @@ out:
return res; return res;
} }
extern "C" extern "C" int
int
_write (int fd, const void *ptr, size_t len) _write (int fd, const void *ptr, size_t len)
{ {
int res = -1; int res = -1;
@ -288,8 +283,7 @@ done:
* these. * these.
*/ */
extern "C" extern "C" ssize_t
ssize_t
writev (int fd, const struct iovec *iov, int iovcnt) writev (int fd, const struct iovec *iov, int iovcnt)
{ {
int i; int i;
@ -343,8 +337,7 @@ writev (int fd, const struct iovec *iov, int iovcnt)
* these. * these.
*/ */
extern "C" extern "C" ssize_t
ssize_t
readv (int fd, const struct iovec *iov, int iovcnt) readv (int fd, const struct iovec *iov, int iovcnt)
{ {
int i; int i;
@ -374,8 +367,7 @@ readv (int fd, const struct iovec *iov, int iovcnt)
/* _open */ /* _open */
/* newlib's fcntl.h defines _open as taking variable args so we must /* newlib's fcntl.h defines _open as taking variable args so we must
correspond. The third arg if it exists is: mode_t mode. */ correspond. The third arg if it exists is: mode_t mode. */
extern "C" extern "C" int
int
_open (const char *unix_path, int flags, ...) _open (const char *unix_path, int flags, ...)
{ {
int fd; int fd;
@ -414,8 +406,7 @@ _open (const char *unix_path, int flags, ...)
return res; return res;
} }
extern "C" extern "C" off_t
off_t
_lseek (int fd, off_t pos, int dir) _lseek (int fd, off_t pos, int dir)
{ {
off_t res; off_t res;
@ -434,8 +425,7 @@ _lseek (int fd, off_t pos, int dir)
return res; return res;
} }
extern "C" extern "C" int
int
_close (int fd) _close (int fd)
{ {
int res; int res;
@ -462,8 +452,7 @@ _close (int fd)
return res; return res;
} }
extern "C" extern "C" int
int
isatty (int fd) isatty (int fd)
{ {
int res; int res;
@ -486,8 +475,7 @@ isatty (int fd)
we should just copy the file. we should just copy the file.
*/ */
extern "C" extern "C" int
int
_link (const char *a, const char *b) _link (const char *a, const char *b)
{ {
int res = -1; int res = -1;
@ -718,22 +706,19 @@ done:
return res; return res;
} }
extern "C" extern "C" int
int
chown (const char * name, uid_t uid, gid_t gid) chown (const char * name, uid_t uid, gid_t gid)
{ {
return chown_worker (name, PC_SYM_FOLLOW, uid, gid); return chown_worker (name, PC_SYM_FOLLOW, uid, gid);
} }
extern "C" extern "C" int
int
lchown (const char * name, uid_t uid, gid_t gid) lchown (const char * name, uid_t uid, gid_t gid)
{ {
return chown_worker (name, PC_SYM_IGNORE, uid, gid); return chown_worker (name, PC_SYM_IGNORE, uid, gid);
} }
extern "C" extern "C" int
int
fchown (int fd, uid_t uid, gid_t gid) fchown (int fd, uid_t uid, gid_t gid)
{ {
if (fdtab.not_open (fd)) if (fdtab.not_open (fd))
@ -758,8 +743,7 @@ fchown (int fd, uid_t uid, gid_t gid)
} }
/* umask: POSIX 5.3.3.1 */ /* umask: POSIX 5.3.3.1 */
extern "C" extern "C" mode_t
mode_t
umask (mode_t mask) umask (mode_t mask)
{ {
mode_t oldmask; mode_t oldmask;
@ -770,8 +754,7 @@ umask (mode_t mask)
} }
/* chmod: POSIX 5.6.4.1 */ /* chmod: POSIX 5.6.4.1 */
extern "C" extern "C" int
int
chmod (const char *path, mode_t mode) chmod (const char *path, mode_t mode)
{ {
int res = -1; int res = -1;
@ -845,8 +828,7 @@ done:
/* fchmod: P96 5.6.4.1 */ /* fchmod: P96 5.6.4.1 */
extern "C" extern "C" int
int
fchmod (int fd, mode_t mode) fchmod (int fd, mode_t mode)
{ {
if (fdtab.not_open (fd)) if (fdtab.not_open (fd))
@ -900,8 +882,7 @@ num_entries (const char *win32_name)
return count; return count;
} }
extern "C" extern "C" int
int
_fstat (int fd, struct stat *buf) _fstat (int fd, struct stat *buf)
{ {
int r; int r;
@ -923,8 +904,7 @@ _fstat (int fd, struct stat *buf)
} }
/* fsync: P96 6.6.1.1 */ /* fsync: P96 6.6.1.1 */
extern "C" extern "C" int
int
fsync (int fd) fsync (int fd)
{ {
if (fdtab.not_open (fd)) if (fdtab.not_open (fd))
@ -945,8 +925,7 @@ fsync (int fd)
} }
/* sync: standards? */ /* sync: standards? */
extern "C" extern "C" int
int
sync () sync ()
{ {
return 0; return 0;
@ -1097,16 +1076,14 @@ stat_worker (const char *caller, const char *name, struct stat *buf,
return res; return res;
} }
extern "C" extern "C" int
int
_stat (const char *name, struct stat *buf) _stat (const char *name, struct stat *buf)
{ {
return stat_worker ("stat", name, buf, 0); return stat_worker ("stat", name, buf, 0);
} }
/* lstat: Provided by SVR4 and 4.3+BSD, POSIX? */ /* lstat: Provided by SVR4 and 4.3+BSD, POSIX? */
extern "C" extern "C" int
int
lstat (const char *name, struct stat *buf) lstat (const char *name, struct stat *buf)
{ {
return stat_worker ("lstat", name, buf, 1); return stat_worker ("lstat", name, buf, 1);
@ -1114,8 +1091,7 @@ lstat (const char *name, struct stat *buf)
extern int acl_access (const char *, int); extern int acl_access (const char *, int);
extern "C" extern "C" int
int
access (const char *fn, int flags) access (const char *fn, int flags)
{ {
// flags were incorrectly specified // flags were incorrectly specified
@ -1185,8 +1161,7 @@ done:
return r; return r;
} }
extern "C" extern "C" int
int
_rename (const char *oldpath, const char *newpath) _rename (const char *oldpath, const char *newpath)
{ {
int res = 0; int res = 0;
@ -1282,8 +1257,7 @@ done:
return res; return res;
} }
extern "C" extern "C" int
int
system (const char *cmdstring) system (const char *cmdstring)
{ {
int res; int res;
@ -1318,31 +1292,27 @@ system (const char *cmdstring)
return res; return res;
} }
extern "C" extern "C" void
void
setdtablesize (int size) setdtablesize (int size)
{ {
if (size > (int)fdtab.size) if (size > (int)fdtab.size)
fdtab.extend (size); fdtab.extend (size);
} }
extern "C" extern "C" int
int
getdtablesize () getdtablesize ()
{ {
return fdtab.size; return fdtab.size;
} }
extern "C" extern "C" size_t
size_t
getpagesize () getpagesize ()
{ {
return sysconf (_SC_PAGESIZE); return sysconf (_SC_PAGESIZE);
} }
/* FIXME: not all values are correct... */ /* FIXME: not all values are correct... */
extern "C" extern "C" long int
long int
fpathconf (int fd, int v) fpathconf (int fd, int v)
{ {
switch (v) switch (v)
@ -1380,8 +1350,7 @@ fpathconf (int fd, int v)
} }
} }
extern "C" extern "C" long int
long int
pathconf (const char *file, int v) pathconf (const char *file, int v)
{ {
switch (v) switch (v)
@ -1872,8 +1841,7 @@ seteuid (uid_t uid)
} }
/* setegid: from System V. */ /* setegid: from System V. */
extern "C" extern "C" int
int
setegid (gid_t gid) setegid (gid_t gid)
{ {
if (os_being_run == winNT) if (os_being_run == winNT)
@ -1895,8 +1863,7 @@ setegid (gid_t gid)
/* chroot: privileged Unix system call. */ /* chroot: privileged Unix system call. */
/* FIXME: Not privileged here. How should this be done? */ /* FIXME: Not privileged here. How should this be done? */
extern "C" extern "C" int
int
chroot (const char *newroot) chroot (const char *newroot)
{ {
int ret = -1; int ret = -1;
@ -1932,22 +1899,19 @@ done:
return ret; return ret;
} }
extern "C" extern "C" int
int
creat (const char *path, mode_t mode) creat (const char *path, mode_t mode)
{ {
return open (path, O_WRONLY | O_CREAT | O_TRUNC, mode); return open (path, O_WRONLY | O_CREAT | O_TRUNC, mode);
} }
extern "C" extern "C" void
void
__assertfail () __assertfail ()
{ {
exit (99); exit (99);
} }
extern "C" extern "C" int
int
getw (FILE *fp) getw (FILE *fp)
{ {
int w, ret; int w, ret;
@ -1955,8 +1919,7 @@ getw (FILE *fp)
return ret != 1 ? EOF : w; return ret != 1 ? EOF : w;
} }
extern "C" extern "C" int
int
putw (int w, FILE *fp) putw (int w, FILE *fp)
{ {
int ret; int ret;
@ -1966,8 +1929,7 @@ putw (int w, FILE *fp)
return 0; return 0;
} }
extern "C" extern "C" int
int
wcscmp (const wchar_t *s1, const wchar_t *s2) wcscmp (const wchar_t *s1, const wchar_t *s2)
{ {
while (*s1 && *s1 == *s2) while (*s1 && *s1 == *s2)
@ -1979,8 +1941,7 @@ wcscmp (const wchar_t *s1, const wchar_t *s2)
return (*(unsigned short *) s1) - (*(unsigned short *) s2); return (*(unsigned short *) s1) - (*(unsigned short *) s2);
} }
extern "C" extern "C" size_t
size_t
wcslen (const wchar_t *s1) wcslen (const wchar_t *s1)
{ {
int l = 0; int l = 0;
@ -1992,8 +1953,7 @@ wcslen (const wchar_t *s1)
/* FIXME: to do this right, maybe work out the usoft va_list machine /* FIXME: to do this right, maybe work out the usoft va_list machine
and use wsvprintfW instead? and use wsvprintfW instead?
*/ */
extern "C" extern "C" int
int
wprintf (const char *fmt, ...) wprintf (const char *fmt, ...)
{ {
va_list ap; va_list ap;
@ -2005,16 +1965,14 @@ wprintf (const char *fmt, ...)
return ret; return ret;
} }
extern "C" extern "C" int
int
vhangup () vhangup ()
{ {
set_errno (ENOSYS); set_errno (ENOSYS);
return -1; return -1;
} }
extern "C" extern "C" _PTR
_PTR
memccpy (_PTR out, const _PTR in, int c, size_t len) memccpy (_PTR out, const _PTR in, int c, size_t len)
{ {
const char *inc = (char *) in; const char *inc = (char *) in;
@ -2031,8 +1989,7 @@ memccpy (_PTR out, const _PTR in, int c, size_t len)
return 0; return 0;
} }
extern "C" extern "C" int
int
nice (int incr) nice (int incr)
{ {
DWORD priority[] = DWORD priority[] =
@ -2079,8 +2036,7 @@ nice (int incr)
* Find the first bit set in I. * Find the first bit set in I.
*/ */
extern "C" extern "C" int
int
ffs (int i) ffs (int i)
{ {
static const unsigned char table[] = static const unsigned char table[] =
@ -2102,8 +2058,7 @@ ffs (int i)
return table[x >> a] + a; return table[x >> a] + a;
} }
extern "C" extern "C" void
void
login (struct utmp *ut) login (struct utmp *ut)
{ {
register int fd; register int fd;
@ -2125,9 +2080,9 @@ login (struct utmp *ut)
/* It isn't possible to use unix-style I/O function in logout code because /* It isn't possible to use unix-style I/O function in logout code because
cygwin's I/O subsystem may be inaccessible at logout() call time. cygwin's I/O subsystem may be inaccessible at logout() call time.
FIXME (cgf): huh?
*/ */
extern "C" extern "C" int
int
logout (char *line) logout (char *line)
{ {
int res = 0; int res = 0;