* 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'.
			
			
This commit is contained in:
		| @@ -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> | Tue Mar 13 13:52:00 2001  Corinna Vinschen <corinna@vinschen.de> | ||||||
|  |  | ||||||
| 	* fhandler.cc (fhandler_disk_file::fstat): Add correct modes to | 	* fhandler.cc (fhandler_disk_file::fstat): Add correct modes to | ||||||
|   | |||||||
| @@ -96,13 +96,6 @@ struct symlink_info | |||||||
|   int check (const char *path, const suffix_info *suffixes); |   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. */ | cwdstuff cygcwd;	/* The current working directory. */ | ||||||
|  |  | ||||||
| #define path_prefix_p(p1, p2, l1) \ | #define path_prefix_p(p1, p2, l1) \ | ||||||
| @@ -2411,12 +2404,13 @@ class suffix_scan | |||||||
|   char *ext_here; |   char *ext_here; | ||||||
|   const suffix_info *suffixes; |   const suffix_info *suffixes; | ||||||
|   int state; |   int state; | ||||||
|  |   int lnk_state; | ||||||
|   int nullterm; |   int nullterm; | ||||||
| public: | public: | ||||||
|   const char *path; |   const char *path; | ||||||
|   char *has (const char *, const suffix_info *, char **); |   char *has (const char *, const suffix_info *, char **); | ||||||
|   int next (); |   int next (); | ||||||
|   int lnk_match () {return state == SCAN_LNK + 1;} |   int lnk_match () {return lnk_state;} | ||||||
| }; | }; | ||||||
|  |  | ||||||
| char * | char * | ||||||
| @@ -2426,6 +2420,7 @@ suffix_scan::has (const char *in_path, const suffix_info *in_suffixes, char **ex | |||||||
|   suffixes = in_suffixes; |   suffixes = in_suffixes; | ||||||
|   nullterm = 0; |   nullterm = 0; | ||||||
|   state = SCAN_BEG; |   state = SCAN_BEG; | ||||||
|  |   lnk_state = 0; | ||||||
|   ext_here = *ext_where = strrchr (in_path, '.'); |   ext_here = *ext_where = strrchr (in_path, '.'); | ||||||
|   if (ext_here) |   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)) | 	    if (strcasematch (ext_here, ex->name)) | ||||||
| 	      { | 	      { | ||||||
| 		state = SCAN_JUSTCHECK; | 		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. */ |       /* Didn't match.  Use last resort -- .lnk. */ | ||||||
|       if (strcasematch (ext_here, ".lnk")) |       if (strcasematch (ext_here, ".lnk")) | ||||||
| 	{ | 	{ | ||||||
| 	  state = SCAN_LNK; | 	  lnk_state = 1; | ||||||
| 	  goto known_suffix; | 	  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'); |   ext_here = *ext_where = strchr (path, '\0'); | ||||||
|   nullterm = 1; |   nullterm = 1; | ||||||
|   return NULL; |   return NULL; | ||||||
|  |  | ||||||
|  known_suffix: |  | ||||||
|   suffixes = NULL;		/* Has an extension so don't scan for one. */ |  | ||||||
|   return ext_here; |  | ||||||
| } | } | ||||||
|  |  | ||||||
| int | int | ||||||
| @@ -2478,6 +2470,7 @@ suffix_scan::next () | |||||||
|   switch (state++) |   switch (state++) | ||||||
|     { |     { | ||||||
|     case SCAN_LNK: |     case SCAN_LNK: | ||||||
|  |       lnk_state = 1; | ||||||
|       strcpy (ext_here, ".lnk"); |       strcpy (ext_here, ".lnk"); | ||||||
|       /* fall through */ |       /* fall through */ | ||||||
|     case SCAN_BEG: |     case SCAN_BEG: | ||||||
| @@ -2566,7 +2559,7 @@ symlink_info::check (const char *path, const suffix_info *suffixes) | |||||||
| 	  if (suffix.lnk_match ()) | 	  if (suffix.lnk_match ()) | ||||||
| 	    { | 	    { | ||||||
| 	      fileattr = (DWORD)-1; | 	      fileattr = (DWORD)-1; | ||||||
| 	      break; | 	      continue; | ||||||
| 	    } | 	    } | ||||||
| 	  goto file_not_symlink; | 	  goto file_not_symlink; | ||||||
| 	} | 	} | ||||||
|   | |||||||
| @@ -762,7 +762,7 @@ chown_worker (const char *name, unsigned fmode, uid_t uid, gid_t gid) | |||||||
|  |  | ||||||
| done: | done: | ||||||
|   syscall_printf ("%d = %schown (%s,...)", |   syscall_printf ("%d = %schown (%s,...)", | ||||||
| 		  res, (fmode & PC_SYM_IGNORE) ? "l" : "", name); | 		  res, (fmode & PC_SYM_NOFOLLOW) ? "l" : "", name); | ||||||
|   return res; |   return res; | ||||||
| } | } | ||||||
|  |  | ||||||
| @@ -777,7 +777,7 @@ extern "C" int | |||||||
| lchown (const char * name, uid_t uid, gid_t gid) | lchown (const char * name, uid_t uid, gid_t gid) | ||||||
| { | { | ||||||
|   sigframe thisframe (mainthread); |   sigframe thisframe (mainthread); | ||||||
|   return chown_worker (name, PC_SYM_IGNORE, uid, gid); |   return chown_worker (name, PC_SYM_NOFOLLOW, uid, gid); | ||||||
| } | } | ||||||
|  |  | ||||||
| extern "C" int | extern "C" int | ||||||
| @@ -1279,9 +1279,7 @@ _rename (const char *oldpath, const char *newpath) | |||||||
|   if (real_old.issymlink () && !real_new.error) |   if (real_old.issymlink () && !real_new.error) | ||||||
|     { |     { | ||||||
|       int len_old = strlen (real_old.get_win32 ()); |       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")) | ||||||
|       if (!strcasecmp (real_old.get_win32 () + len_old - 4, ".lnk") && |  | ||||||
| 	  strcasecmp (real_new.get_win32 () + len_new - 4, ".lnk")) |  | ||||||
| 	{ | 	{ | ||||||
| 	  strcpy (new_lnk_buf, newpath); | 	  strcpy (new_lnk_buf, newpath); | ||||||
| 	  strcat (new_lnk_buf, ".lnk"); | 	  strcat (new_lnk_buf, ".lnk"); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user