* path.cc (path_conv::check): Don't follow reparse point symlinks if

PC_SYM_NOFOLLOW_REP flag is set.
	(cygwin_conv_path): Set PC_SYM_NOFOLLOW_REP flag when converting from
	POSIX to Win32.
	* path.h (enum pathconv_arg): Define PC_SYM_NOFOLLOW_REP flag.
This commit is contained in:
Corinna Vinschen 2011-01-17 14:19:39 +00:00
parent 483e9d0022
commit be37165114
3 changed files with 19 additions and 8 deletions

View File

@ -1,3 +1,11 @@
2011-01-17 Corinna Vinschen <corinna@vinschen.de>
* path.cc (path_conv::check): Don't follow reparse point symlinks if
PC_SYM_NOFOLLOW_REP flag is set.
(cygwin_conv_path): Set PC_SYM_NOFOLLOW_REP flag when converting from
POSIX to Win32.
* path.h (enum pathconv_arg): Define PC_SYM_NOFOLLOW_REP flag.
2011-01-17 Corinna Vinschen <corinna@vinschen.de> 2011-01-17 Corinna Vinschen <corinna@vinschen.de>
* fhandler_proc.cc (proc_tab_cmp): Fix typo in comment. * fhandler_proc.cc (proc_tab_cmp): Fix typo in comment.

View File

@ -1,7 +1,7 @@
/* path.cc: path support. /* path.cc: path support.
Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, Copyright 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
2006, 2007, 2008, 2009, 2010 Red Hat, Inc. 2006, 2007, 2008, 2009, 2010, 2011 Red Hat, Inc.
This file is part of Cygwin. This file is part of Cygwin.
@ -920,7 +920,9 @@ is_virtual_symlink:
else if (symlen > 0) else if (symlen > 0)
{ {
saw_symlinks = 1; saw_symlinks = 1;
if (component == 0 && !need_directory && !(opt & PC_SYM_FOLLOW)) if (component == 0 && !need_directory
&& (!(opt & PC_SYM_FOLLOW)
|| (is_rep_symlink () && (opt & PC_SYM_NOFOLLOW_REP))))
{ {
set_symlink (symlen); // last component of path is a symlink. set_symlink (symlen); // last component of path is a symlink.
if (opt & PC_SYM_CONTENTS) if (opt & PC_SYM_CONTENTS)
@ -2917,8 +2919,8 @@ cygwin_conv_path (cygwin_conv_path_t what, const void *from, void *to,
case CCP_POSIX_TO_WIN_A: case CCP_POSIX_TO_WIN_A:
{ {
p.check ((const char *) from, p.check ((const char *) from,
PC_POSIX | PC_SYM_FOLLOW | PC_NO_ACCESS_CHECK | PC_NOWARN PC_POSIX | PC_SYM_FOLLOW | PC_SYM_NOFOLLOW_REP
| (relative ? PC_NOFULL : 0)); | PC_NO_ACCESS_CHECK | PC_NOWARN | (relative ? PC_NOFULL : 0));
if (p.error) if (p.error)
return_with_errno (p.error); return_with_errno (p.error);
PUNICODE_STRING up = p.get_nt_native_path (); PUNICODE_STRING up = p.get_nt_native_path ();
@ -2953,9 +2955,9 @@ cygwin_conv_path (cygwin_conv_path_t what, const void *from, void *to,
} }
break; break;
case CCP_POSIX_TO_WIN_W: case CCP_POSIX_TO_WIN_W:
p.check ((const char *) from, PC_POSIX | PC_SYM_FOLLOW p.check ((const char *) from,
| PC_NO_ACCESS_CHECK | PC_NOWARN PC_POSIX | PC_SYM_FOLLOW | PC_SYM_NOFOLLOW_REP
| (relative ? PC_NOFULL : 0)); | PC_NO_ACCESS_CHECK | PC_NOWARN | (relative ? PC_NOFULL : 0));
if (p.error) if (p.error)
return_with_errno (p.error); return_with_errno (p.error);
/* Relative Windows paths are always restricted to MAX_PATH chars. */ /* Relative Windows paths are always restricted to MAX_PATH chars. */

View File

@ -1,7 +1,7 @@
/* path.h: path data structures /* path.h: path data structures
Copyright 1996, 1997, 1998, 2000, 2001, 2002, 2003, 2004, 2005, Copyright 1996, 1997, 1998, 2000, 2001, 2002, 2003, 2004, 2005,
2006, 2007, 2008, 2009, 2010 Red Hat, Inc. 2006, 2007, 2008, 2009, 2010, 2011 Red Hat, Inc.
This file is part of Cygwin. This file is part of Cygwin.
@ -54,6 +54,7 @@ enum pathconv_arg
{ {
PC_SYM_FOLLOW = 0x0001, PC_SYM_FOLLOW = 0x0001,
PC_SYM_NOFOLLOW = 0x0002, PC_SYM_NOFOLLOW = 0x0002,
PC_SYM_NOFOLLOW_REP = 0x0004,
PC_SYM_CONTENTS = 0x0008, PC_SYM_CONTENTS = 0x0008,
PC_NOFULL = 0x0010, PC_NOFULL = 0x0010,
PC_NULLEMPTY = 0x0020, PC_NULLEMPTY = 0x0020,