Welcome! Log In Create A New Profile


Re: [PATCH] fix ngx_realpath() for win32

Won-Kyu Park
November 02, 2022 02:46AM
> Hello!
> On Tue, Nov 01, 2022 at 08:15:48PM +0900, Won-Kyu Park wrote:
> ...
> Could you please clarify "as expected"?
> It doesn't look like _fullpath() resolves symbolic links, which is expected behaviour for $realpath_root.

You are right but for most situations, translating a relative path to
fullpath is enough, at least for me. (please see use case)

> Rather, it looks like GetFinalPathNameByHandle() should be used if we want to actually support $realpath_root as it is expected to work, that is, providing path with symlinks resolved. It might
> be tricky to use it though, as it is only available in Windows Vista or later.
> -- Maxim Dounin http://mdounin.ru/

yes. GetFinalPathNameByHandle() is not available in pre-Vista.
full implementation might be preferred but this simple oneliner solve
most use cases I guess.

- win32/mingw32 only support _fullpath()
- PHP7 use GetFinalPathNameByHandleW()

use case:

server {
location / {
root ../to/html; # works nicely without problem
index index.php index.html index.htm;

location ~ \.php$ {
root ../to/html; # not work. $realpath_root
gives wrong value (c:\foobar\nginxroot\..\wiki), $document_root
returns relative path
# for this case, $realpath_root gives expected value with
this _fullpath fix.
#root c:/to/my/absolute/path/html; # works fine
fastcgi_index index.php;

# fix to use realpath_root
#fastcgi_param SCRIPT_FILENAME
$document_root$fastcgi_script_name; # not work.
fastcgi_param SCRIPT_FILENAME
$realpath_root$fastcgi_script_name; # works fine with _fullpath fix.
nginx-devel mailing list -- nginx-devel@nginx.org
To unsubscribe send an email to nginx-devel-leave@nginx.org
Subject Author Views Posted

[PATCH] fix ngx_realpath() for win32

Won-Kyu Park 303 November 01, 2022 07:18AM

Re: [PATCH] fix ngx_realpath() for win32

Maxim Dounin 59 November 01, 2022 11:30AM

Re: [PATCH] fix ngx_realpath() for win32

Won-Kyu Park 58 November 02, 2022 02:46AM

Re: [PATCH] fix ngx_realpath() for win32

Maxim Dounin 77 November 02, 2022 08:16PM

Sorry, you do not have permission to post/reply in this forum.

Online Users

Guests: 73
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready