public inbox for goredo-devel@lists.cypherpunks.ru
Atom feed
From: "Jan Niklas Böhm" <mail@jnboehm•com>
To: goredo-devel@lists.cypherpunks.ru
Subject: Re: Resolving paths within symlinked dirs targets
Date: Fri, 22 Apr 2022 22:42:31 +0200	[thread overview]
Message-ID: <e2317651-637f-1149-c0e2-ed5b6a15336e@jnboehm.com> (raw)
In-Reply-To: <YmJ1AoZ7gcXKsU4a@stargrave.org>

Thanks for the thorough response!  I appreciate it.


> Actually initially goredo used to resolve its "physical" (pwd -P) path
> to the current directory. But one of its users gave very good example
> where it makes things very inconvenient in practice: for example in
> FreeBSD /home/user is actually a symlink to /usr/home/user by default.
> That is why pwd -P will return paths like that, when located in /home/user:
> 
>      ../../../../../../home/user/docs/3rd/goredo/all.do
>      ../../../../../../home/user/docs/3rd/goredo/default.do
>      ../../../../../../home/user/docs/3rd/default.do
>      ../../../../../../home/user/docs/default.do
>      ../../../../../../home/user/default.do
>      ../../../../../../home/default.do
>      ../../../../../../default.do
> 
> and that is clearly something user do not expect and do not want to. So
> the better way from the point of convenience was to behave as pwd -L by
> default.

I can see why this is not ideal from a users perspective, but to me it 
strikes me as the correct location of the path.  Having those paths 
fully resolved as well should still point to the correct location, as 
the /home/user path should resolve properly to its --physical location, 
or am I mistaken?

The above example could be completely resolved by resolving both the pwd 
and the target (in this case the .do files) to their physical location. 
  That should turn your example into (assuming that pwd = /home/user/):
	docs/3rd/goredo/all.do

	docs/3rd/goredo/default.do

	docs/3rd/default.do

	docs/default.do

	default.do

	../default.do

	../../default.do

This should be equal to the current behavior, but irrespective of 
whether we have cd'd into the directory through their physical path or 
the symlink, unless I am missing something.

Of course this will come at a minor performance penalty since all the 
paths and the pwd have to be resolved through the file system, but I 
think that it is worth it.

> Probably we can check both -L/-P behaviours during path resolution to
> the target to check if the target is actually something known and
> existing? Unfortunately no, we can not do that at all, according to:
> https://unix.stackexchange.com/questions/79571/symbolic-link-recursion-what-makes-it-reset/79621#79621
> With the path a/b/c, where a/b/c is a symlink to /somewhere, a/b/c/../d
> may lead both to a/b/d, or to /somewhere/d, that are completely
> different paths, but pretty valid from the point of symlinked paths. And
> both a/b/d and /somewhere/d can be existing files. So there just can not
> be any "valid" way of behaving when dealing with symlinks. That is one
> of the reason Plan9 completely criticise and abandoned that idea:
> http://harmful.cat-v.org/software/symlinks

I  agree that this option cannot work out and is not worth pursuing.

Thank you again, I really appreciate your answers.

  reply	other threads:[~2022-04-22 20:43 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-16 19:13 Support for virtual targets Jan Niklas Böhm
2022-04-16 21:11 ` Sergey Matveev
2022-04-17 20:37   ` Resolving paths within symlinked dirs (Re: Support for virtual targets) Jan Niklas Böhm
2022-04-22  9:27     ` Resolving paths within symlinked dirs targets) Sergey Matveev
2022-04-22 20:42       ` Jan Niklas Böhm [this message]
2022-04-24 18:34         ` Resolving paths within symlinked dirs targets Sergey Matveev