From b5aefad2f9efa2b244146503aa4ad6f1023f5805 Mon Sep 17 00:00:00 2001 From: cgf Date: Sun, 26 Mar 2000 01:54:21 +0000 Subject: [PATCH] * path.cc (symlink_check_one): Recognize symlink settings from the mount table. * path.h: Make PATH_SYMLINK an alias for MOUNT_SYMLINK. * syscalls.cc (stat_worker): Use extension search mechanism in path_conv to look for .exe rather than trying to special case it here. * mount.h: Make MOUNT_SYMLINK a real option. --- winsup/cygwin/ChangeLog | 69 ++++++++++++++++++++++----------------- winsup/cygwin/include/sys/mount.h | 2 +- winsup/cygwin/path.cc | 2 +- winsup/cygwin/path.h | 2 +- winsup/cygwin/syscalls.cc | 29 +++++----------- 5 files changed, 51 insertions(+), 53 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index ebaefe9468..e3793d1271 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,12 @@ +Sat Mar 25 20:46:39 2000 Christopher Faylor + + * path.cc (symlink_check_one): Recognize symlink settings from the + mount table. + * path.h: Make PATH_SYMLINK an alias for MOUNT_SYMLINK. + * syscalls.cc (stat_worker): Use extension search mechanism in + path_conv to look for .exe rather than trying to special case it here. + * mount.h: Make MOUNT_SYMLINK a real option. + Sat Mar 25 00:22:32 2000 Christopher Faylor * environ.cc: Add TMPDIR to the list of environment variables which are @@ -7,7 +16,7 @@ Sat Mar 25 00:22:32 2000 Christopher Faylor Sun Mar 19 12:01:00 2000 Corinna Vinschen - * syscalls.cc (stat_worker): Set st_nlink to 1 on remote drives. + * syscalls.cc (stat_worker): Set st_nlink to 1 on remote drives. Sat Mar 18 23:04:27 2000 Christopher Faylor @@ -30,41 +39,41 @@ Sat Mar 18 01:24:25 2000 Christopher Faylor Fri Mar 17 18:16:00 2000 Corinna Vinschen Patch suggested by Eric Fifer - * fhandler.cc (fhandler_base::open): Call set_file_attribute() - only if a file is really created. + * fhandler.cc (fhandler_base::open): Call set_file_attribute() + only if a file is really created. Thu Mar 16 14:15:00 2000 Corinna Vinschen - * security.cc (set_process_privileges): Remove `static'. - (get_nt_attribute): Returns uid and gid additionally. Remove call - to set_process_privileges(). - (get_file_attribute): Returns uid and gid additionally. Don't - call ntea if ntsec is ON. - (set_nt_attribute): Remove call to set_process_privileges(). - Don't call ntea if ntsec is ON. - (acl): Remove call to set_process_privileges(). - * dcrt0.cc (dll_crt0_1): Call set_process_privileges(). - * winsup.h: New prototype for set_process_privileges(), - changed prototype for get_file_attribute(). - * fhandler.cc (get_file_owner): Discard function. - (get_file_group): Ditto. - (fhandler_disk_file::fstat): Discard calls to get_file_owner() and - get_file_group(). - * path.cc (path_conv::path_conv): New debugging output for result - of GetVolumeInformation(). - (mount_info::conv_to_win32_path): Call backslashify() with pathbuf - instead of src_path. - * syscalls.cc (chown): Reformat slightly. - (chmod): Replace get_file_owner() and get_file_group() calls - by a call to get_file_attribute(). Discard local variable has_acls. - Reformat slightly. - (stat_worker): Root dir check now done by a call to rootdir(). - Don't call num_entries() on remote drives. - Discard local variable has_acls. + * security.cc (set_process_privileges): Remove `static'. + (get_nt_attribute): Returns uid and gid additionally. Remove call + to set_process_privileges(). + (get_file_attribute): Returns uid and gid additionally. Don't + call ntea if ntsec is ON. + (set_nt_attribute): Remove call to set_process_privileges(). + Don't call ntea if ntsec is ON. + (acl): Remove call to set_process_privileges(). + * dcrt0.cc (dll_crt0_1): Call set_process_privileges(). + * winsup.h: New prototype for set_process_privileges(), + changed prototype for get_file_attribute(). + * fhandler.cc (get_file_owner): Discard function. + (get_file_group): Ditto. + (fhandler_disk_file::fstat): Discard calls to get_file_owner() and + get_file_group(). + * path.cc (path_conv::path_conv): New debugging output for result + of GetVolumeInformation(). + (mount_info::conv_to_win32_path): Call backslashify() with pathbuf + instead of src_path. + * syscalls.cc (chown): Reformat slightly. + (chmod): Replace get_file_owner() and get_file_group() calls + by a call to get_file_attribute(). Discard local variable has_acls. + Reformat slightly. + (stat_worker): Root dir check now done by a call to rootdir(). + Don't call num_entries() on remote drives. + Discard local variable has_acls. Wed Mar 15 20:38:06 2000 Corinna Vinschen - * errno.cc: Map ERROR_NOACCESS to EFAULT. + * errno.cc: Map ERROR_NOACCESS to EFAULT. Wed Mar 15 14:25:38 2000 Christopher Faylor diff --git a/winsup/cygwin/include/sys/mount.h b/winsup/cygwin/include/sys/mount.h index 2c4ad30a3c..5f640178f5 100644 --- a/winsup/cygwin/include/sys/mount.h +++ b/winsup/cygwin/include/sys/mount.h @@ -7,7 +7,7 @@ extern "C" { enum { - /* MOUNT_SYMLINK = 1, place holder. Do not use it. */ + MOUNT_SYMLINK = 1, /* "mount point" is a symlink */ MOUNT_BINARY = 2, /* "binary" format read/writes */ MOUNT_SYSTEM = 8, /* mount point came from system table */ MOUNT_EXEC = 16, /* Any file in the mounted directory gets 'x' bit */ diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc index 8aa8bbce3f..6a18dc1ff2 100644 --- a/winsup/cygwin/path.cc +++ b/winsup/cygwin/path.cc @@ -2156,7 +2156,7 @@ symlink_check_one (const char *in_path, char *buf, int buflen, DWORD& fileattr, /* A symlink will have the `system' file attribute. */ /* Only files can be symlinks (which can be symlinks to directories). */ - if (!SYMLINKATTR (fileattr)) + if (!(*pflags & PATH_SYMLINK) && !SYMLINKATTR (fileattr)) goto file_not_symlink; /* Check the file's extended attributes, if it has any. */ diff --git a/winsup/cygwin/path.h b/winsup/cygwin/path.h index 01058a49b9..f3be6b5425 100644 --- a/winsup/cygwin/path.h +++ b/winsup/cygwin/path.h @@ -28,7 +28,7 @@ enum symlink_follow enum { PATH_NOTHING = 0, - PATH_SYMLINK = 1, + PATH_SYMLINK = MOUNT_SYMLINK, PATH_BINARY = MOUNT_BINARY, PATH_EXEC = MOUNT_EXEC, PATH_SOCKET = 0x40000000, diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc index a52faf8aa3..dba72590d3 100644 --- a/winsup/cygwin/syscalls.cc +++ b/winsup/cygwin/syscalls.cc @@ -917,6 +917,12 @@ stat_dev (DWORD devn, int unit, unsigned long ino, struct stat *buf) return 0; } +static suffix_info stat_suffixes[] = +{ + suffix_info ("", 1), + suffix_info (".exe", 1) +}; + /* Cygwin internal */ static int stat_worker (const char *caller, const char *name, struct stat *buf, @@ -931,7 +937,9 @@ stat_worker (const char *caller, const char *name, struct stat *buf, debug_printf ("%s (%s, %p)", caller, name, buf); - path_conv real_path (name, nofollow ? SYMLINK_NOFOLLOW : SYMLINK_FOLLOW, 1); + path_conv real_path (name, nofollow ? SYMLINK_NOFOLLOW : SYMLINK_FOLLOW, 1, + stat_suffixes); + if (real_path.error) { set_errno (real_path.error); @@ -947,25 +955,6 @@ stat_worker (const char *caller, const char *name, struct stat *buf, atts = real_path.file_attributes (); -/* FIXME: this is of dubious merit and is fundamentally flawed. - E.g., what if the .exe file is a symlink? This is not accounted - for here. Also, what about all of the other special extensions? - - This could be "fixed" by passing the appropriate extension list - to path_conv but I'm not sure that this is really justified. */ - - /* If we can't find the name, try again with a .exe suffix - [but only if not already present]. */ - if (atts == -1 && GetLastError () == ERROR_FILE_NOT_FOUND && - !(strrchr (win32_name, '.') > strrchr (win32_name, '\\'))) - { - debug_printf ("trying with .exe suffix"); - strcat (win32_name, ".exe"); - atts = (int) GetFileAttributesA (win32_name); - if (atts == -1) - strchr (win32_name, '\0')[4] = '\0'; - } - debug_printf ("%d = GetFileAttributesA (%s)", atts, win32_name); strcpy (root, win32_name); -- 2.11.0