diff options
-rw-r--r-- | winsup/cygwin/ChangeLog | 13 | ||||
-rw-r--r-- | winsup/cygwin/path.cc | 25 | ||||
-rw-r--r-- | winsup/cygwin/syscalls.cc | 8 |
3 files changed, 25 insertions, 21 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index ac3dbf423..899c7114e 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,16 @@ +Wed Mar 14 10:11:00 2001 Corinna Vinschen <corinna@vinschen.de> + + * path.cc (lnk_suffixes): Remove. + (class suffix_scan): Add `lnk_state' flag. + (suffix_scan::lnk_match): Return state of `lnk_state' now. + (suffix_scan::has): Changed behaviour if file has `.lnk' suffix. + (suffix_scan::next): Set `lnk_state' where appropriate. + (symlink_info::check): Fix a wrong `break'. + * syscalls.cc (chown_worker): Change debug statement to reflect + lchown fix. + (lchown): Call chown_worker with `PC_SYM_NOFOLLOW' instead of + `PC_SYM_IGNORE'. + Tue Mar 13 13:52:00 2001 Corinna Vinschen <corinna@vinschen.de> * fhandler.cc (fhandler_disk_file::fstat): Add correct modes to diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc index 94111ad12..3a84b0936 100644 --- a/winsup/cygwin/path.cc +++ b/winsup/cygwin/path.cc @@ -96,13 +96,6 @@ struct symlink_info int check (const char *path, const suffix_info *suffixes); }; -/* These suffixes are the only ones allowed in inner path components. */ -suffix_info lnk_suffixes[] = -{ - suffix_info (".lnk", 1), - suffix_info (NULL) -}; - cwdstuff cygcwd; /* The current working directory. */ #define path_prefix_p(p1, p2, l1) \ @@ -2411,12 +2404,13 @@ class suffix_scan char *ext_here; const suffix_info *suffixes; int state; + int lnk_state; int nullterm; public: const char *path; char *has (const char *, const suffix_info *, char **); int next (); - int lnk_match () {return state == SCAN_LNK + 1;} + int lnk_match () {return lnk_state;} }; char * @@ -2426,6 +2420,7 @@ suffix_scan::has (const char *in_path, const suffix_info *in_suffixes, char **ex suffixes = in_suffixes; nullterm = 0; state = SCAN_BEG; + lnk_state = 0; ext_here = *ext_where = strrchr (in_path, '.'); if (ext_here) { @@ -2436,14 +2431,15 @@ suffix_scan::has (const char *in_path, const suffix_info *in_suffixes, char **ex if (strcasematch (ext_here, ex->name)) { state = SCAN_JUSTCHECK; - goto known_suffix; + suffixes = NULL; /* Has an extension so don't scan for one. */ + return ext_here; } } /* Didn't match. Use last resort -- .lnk. */ if (strcasematch (ext_here, ".lnk")) { - state = SCAN_LNK; - goto known_suffix; + lnk_state = 1; + suffixes = NULL; } } @@ -2451,10 +2447,6 @@ suffix_scan::has (const char *in_path, const suffix_info *in_suffixes, char **ex ext_here = *ext_where = strchr (path, '\0'); nullterm = 1; return NULL; - - known_suffix: - suffixes = NULL; /* Has an extension so don't scan for one. */ - return ext_here; } int @@ -2478,6 +2470,7 @@ suffix_scan::next () switch (state++) { case SCAN_LNK: + lnk_state = 1; strcpy (ext_here, ".lnk"); /* fall through */ case SCAN_BEG: @@ -2566,7 +2559,7 @@ symlink_info::check (const char *path, const suffix_info *suffixes) if (suffix.lnk_match ()) { fileattr = (DWORD)-1; - break; + continue; } goto file_not_symlink; } diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc index 134ad8c59..428ee28c4 100644 --- a/winsup/cygwin/syscalls.cc +++ b/winsup/cygwin/syscalls.cc @@ -762,7 +762,7 @@ chown_worker (const char *name, unsigned fmode, uid_t uid, gid_t gid) done: syscall_printf ("%d = %schown (%s,...)", - res, (fmode & PC_SYM_IGNORE) ? "l" : "", name); + res, (fmode & PC_SYM_NOFOLLOW) ? "l" : "", name); return res; } @@ -777,7 +777,7 @@ extern "C" int lchown (const char * name, uid_t uid, gid_t gid) { sigframe thisframe (mainthread); - return chown_worker (name, PC_SYM_IGNORE, uid, gid); + return chown_worker (name, PC_SYM_NOFOLLOW, uid, gid); } extern "C" int @@ -1279,9 +1279,7 @@ _rename (const char *oldpath, const char *newpath) if (real_old.issymlink () && !real_new.error) { int len_old = strlen (real_old.get_win32 ()); - int len_new = strlen (real_new.get_win32 ()); - if (!strcasecmp (real_old.get_win32 () + len_old - 4, ".lnk") && - strcasecmp (real_new.get_win32 () + len_new - 4, ".lnk")) + if (!strcasecmp (real_old.get_win32 () + len_old - 4, ".lnk")) { strcpy (new_lnk_buf, newpath); strcat (new_lnk_buf, ".lnk"); |