Re: [fossil-users] [PATCH] Improve symlink following offile_wd_isdir()

2017-11-30 Thread bytevolcano
On Thu, 30 Nov 2017 13:19:38 +0100
Jan Nijtmans  wrote:

> This patch has no relation to fossil's symlink support, it's just part
> of the code to find a suitable temporary directory to write some
> intermediate file. It's unfortunate it's that complicated, but useful
> because sometimes the working directory or the current directory
> is read-only, That's what this code is about.

That is my initial impression when I wrote the patch; it was to do with
Fossil creating the temp folder before writing to the file. This issue
is a showstopper for those who use recent OpenBSD versions, as OpenBSD
now has a symlink from /var/tmp to "../tmp", which confuses Fossil.

The patch fixes this situation:

 $ cd /home/test/fossil/wdir1
 $ fossil uv edit 
  (try to create directory /home/test/fossil/wdir1/../tmp
  i.e. /home/test/fossil/tmp)
 
> I sometimes use symlink support in fossil, but it shouldn't be fancy
> at all. When committing a symlink, someone else checking it out
> should get the same symlink. This - generally - only makes sense
> when the symlink is relative and points to somewhere else in
> the working directory. Otherwise - indeed - it doesn't make sense.
> This is the way that - for example - Subversion handles symlinks,
> it would be a loss to remove it from fossil. It's just like the 'x'
> (executable) flag: unfortunate that Windows doesn't handle it the way
> UNIX does, that's the reason why fossil has to do tricky things 

What Fossil should do is have a reliable way to determine what should
be written first. A "racish" condition can exist with symlink support
where files that go into a symlinked directory are written first, and
when it's time to create the symlink, the name of the link itself is
taken because Fossil has written the directory.

> 
> That said, symlinks are actually a UNIX-only feature: I don't
> mind that - on Windows - symlinks check-out as being a file with
> the link path as content (that's what Subversion does as well ...)

Since Windows Vista and Windows Server 2008:
https://msdn.microsoft.com/en-us/library/windows/desktop/aa363866%28v=vs.85%29.aspx

> 
> Regards,
>Jan Nijtmans
> ___
> fossil-users mailing list
> fossil-users@lists.fossil-scm.org
> http://lists.fossil-scm.org:8080/cgi-bin/mailman/listinfo/fossil-users

___
fossil-users mailing list
fossil-users@lists.fossil-scm.org
http://lists.fossil-scm.org:8080/cgi-bin/mailman/listinfo/fossil-users


Re: [fossil-users] [PATCH] Improve symlink following offile_wd_isdir()

2017-11-30 Thread Dominique Devienne
On Thu, Nov 30, 2017 at 1:19 PM, Jan Nijtmans 
wrote:

> 2017-11-28 0:20 GMT+01:00  :
> > On Mon, 27 Nov 2017 09:52:19 -0500
> > Richard Hipp  wrote:
> >> I am very sorry that I allowed symbolic link support into Fossil in
> >> the first place.   (Symbolic link support was neither designed nor
> >> written by me - it is contributed code.)  I would really like to get
> >> rid of symbolic link support.  Symbolic links seem out-of-place in a
> >> version control system.  As implemented, symbolic links are a point of
> >> confusion which (as far as I can see) adds no useful capabilities.
>

Here, they are used mostly for 3rd parties under SCM control.
So "map" architecture/compiler/etc... specific folders or binaries/libraries
to another architecture/compiler/etc... folder the first one is compatible
with.

I'm not saying that's a good thing, just saying how symlinks are used in a
concrete example.


> [...]. This - generally - only makes sense
> when the symlink is relative and points to somewhere else in
> the working directory. Otherwise - indeed - it doesn't make sense.
>

Agreed. Could even error out when that's not the case.


> That said, symlinks are actually a UNIX-only feature: I don't
> mind that -


Well, not exactly, no? [1]. "Reparse points" have been part of Windows for
a while I think.
Sure it depends on the Windows version, and the filesystem used, still,
they exist.

Of course, that implies Fossil would correctly interpret them on add too.
Which probably needs to use special APIs.


> on Windows - symlinks check-out as being a file with
> the link path as content (that's what Subversion does as well ...)
>

That's IMHO not a very good example to follow. Mapping *nix symlinks
to Windows reparse points would be much better. FWIW. --DD

[1]
https://www.howtogeek.com/howto/16226/complete-guide-to-symbolic-links-symlinks-on-windows-or-linux/
___
fossil-users mailing list
fossil-users@lists.fossil-scm.org
http://lists.fossil-scm.org:8080/cgi-bin/mailman/listinfo/fossil-users


Re: [fossil-users] [PATCH] Improve symlink following offile_wd_isdir()

2017-11-30 Thread Jan Nijtmans
2017-11-28 0:20 GMT+01:00  :
> On Mon, 27 Nov 2017 09:52:19 -0500
> Richard Hipp  wrote:
>> I am very sorry that I allowed symbolic link support into Fossil in
>> the first place.   (Symbolic link support was neither designed nor
>> written by me - it is contributed code.)  I would really like to get
>> rid of symbolic link support.  Symbolic links seem out-of-place in a
>> version control system.  As implemented, symbolic links are a point of
>> confusion which (as far as I can see) adds no useful capabilities.
>
> Are you referring to symlinks inside a working directory, or Fossil's
> ability to "follow" them? If so have a survey of users, or a
> disabled-by-default policy to see if any users need it.

This patch has no relation to fossil's symlink support, it's just part
of the code to find a suitable temporary directory to write some
intermediate file. It's unfortunate it's that complicated, but useful
because sometimes the working directory or the current directory
is read-only, That's what this code is about.

I sometimes use symlink support in fossil, but it shouldn't be fancy
at all. When committing a symlink, someone else checking it out
should get the same symlink. This - generally - only makes sense
when the symlink is relative and points to somewhere else in
the working directory. Otherwise - indeed - it doesn't make sense.
This is the way that - for example - Subversion handles symlinks,
it would be a loss to remove it from fossil. It's just like the 'x'
(executable) flag: unfortunate that Windows doesn't handle it the way
UNIX does, that's the reason why fossil has to do tricky things 

That said, symlinks are actually a UNIX-only feature: I don't
mind that - on Windows - symlinks check-out as being a file with
the link path as content (that's what Subversion does as well ...)

Regards,
   Jan Nijtmans
___
fossil-users mailing list
fossil-users@lists.fossil-scm.org
http://lists.fossil-scm.org:8080/cgi-bin/mailman/listinfo/fossil-users


Re: [fossil-users] [PATCH] Improve symlink following offile_wd_isdir()

2017-11-27 Thread David Mason
I use symlinks *very* heavily. Almost exactly 10% of the files in my main
fossil hierarchy are actually symlinks. Fossil not supporting them would be
a huge drawback for me. Good support for symlinks and nested repositories
are 2 of the details I like best about Fossil (in addition to the obvious
features).

../Dave

On 27 November 2017 at 18:20,  wrote:

> On Mon, 27 Nov 2017 09:52:19 -0500
> Richard Hipp  wrote:
>
> > I am in receipt of your patch.  I have not evaluated it yet because
> > the entire symbolic-link mechanism in Fossil is confused and very
> > difficult to manage.  It mostly works now, but is brittle.  A
> > seemingly simple patch like what you sent could cause breakage.
>
> Perhaps a separate function "make_path()" just to create any
> directories that may not exist, rather than stuffing it all in
> blob_write_to_file(). It can be called as follows if needed:
>
>   make_path(zFile);
>   blob_write_to_file(, zFile);
>
> >
> > I am very sorry that I allowed symbolic link support into Fossil in
> > the first place.   (Symbolic link support was neither designed nor
> > written by me - it is contributed code.)  I would really like to get
> > rid of symbolic link support.  Symbolic links seem out-of-place in a
> > version control system.  As implemented, symbolic links are a point of
> > confusion which (as far as I can see) adds no useful capabilities.
>
> Are you referring to symlinks inside a working directory, or Fossil's
> ability to "follow" them? If so have a survey of users, or a
> disabled-by-default policy to see if any users need it.
> ___
> fossil-users mailing list
> fossil-users@lists.fossil-scm.org
> http://lists.fossil-scm.org:8080/cgi-bin/mailman/listinfo/fossil-users
>
___
fossil-users mailing list
fossil-users@lists.fossil-scm.org
http://lists.fossil-scm.org:8080/cgi-bin/mailman/listinfo/fossil-users


Re: [fossil-users] [PATCH] Improve symlink following offile_wd_isdir()

2017-11-27 Thread bytevolcano
On Mon, 27 Nov 2017 09:52:19 -0500
Richard Hipp  wrote:

> I am in receipt of your patch.  I have not evaluated it yet because
> the entire symbolic-link mechanism in Fossil is confused and very
> difficult to manage.  It mostly works now, but is brittle.  A
> seemingly simple patch like what you sent could cause breakage.

Perhaps a separate function "make_path()" just to create any
directories that may not exist, rather than stuffing it all in
blob_write_to_file(). It can be called as follows if needed:

  make_path(zFile);
  blob_write_to_file(, zFile);

> 
> I am very sorry that I allowed symbolic link support into Fossil in
> the first place.   (Symbolic link support was neither designed nor
> written by me - it is contributed code.)  I would really like to get
> rid of symbolic link support.  Symbolic links seem out-of-place in a
> version control system.  As implemented, symbolic links are a point of
> confusion which (as far as I can see) adds no useful capabilities.

Are you referring to symlinks inside a working directory, or Fossil's
ability to "follow" them? If so have a survey of users, or a
disabled-by-default policy to see if any users need it.
___
fossil-users mailing list
fossil-users@lists.fossil-scm.org
http://lists.fossil-scm.org:8080/cgi-bin/mailman/listinfo/fossil-users


Re: [fossil-users] [PATCH] Improve symlink following offile_wd_isdir()

2017-11-27 Thread Richard Hipp
On 11/27/17, bytevolc...@safe-mail.net  wrote:
> Ping.

I am in receipt of your patch.  I have not evaluated it yet because
the entire symbolic-link mechanism in Fossil is confused and very
difficult to manage.  It mostly works now, but is brittle.  A
seemingly simple patch like what you sent could cause breakage.

I am very sorry that I allowed symbolic link support into Fossil in
the first place.   (Symbolic link support was neither designed nor
written by me - it is contributed code.)  I would really like to get
rid of symbolic link support.  Symbolic links seem out-of-place in a
version control system.  As implemented, symbolic links are a point of
confusion which (as far as I can see) adds no useful capabilities.

-- 
D. Richard Hipp
d...@sqlite.org
___
fossil-users mailing list
fossil-users@lists.fossil-scm.org
http://lists.fossil-scm.org:8080/cgi-bin/mailman/listinfo/fossil-users


Re: [fossil-users] [PATCH] Improve symlink following offile_wd_isdir()

2017-11-27 Thread bytevolcano
Ping.

On Sat, 25 Nov 2017 11:42:29 +
bytevolc...@safe-mail.net wrote:
Index: src/file.c
==
--- src/file.c
+++ src/file.c
@@ -327,24 +327,30 @@
 ** zFilename is a directory -OR- a symlink that points to a directory.
 ** Return 0 if zFilename does not exist.  Return 2 if zFilename exists
 ** but is something other than a directory.
 */
 int file_wd_isdir(const char *zFilename){
-  int rc;
+  int rc, nFN;
   char *zFN;


   zFN = mprintf("%s", zFilename);
-  file_simplify_name(zFN, -1, 0);
+  nFN = file_simplify_name(zFN, -1, 0);
   rc = getStat(zFN, 1);
   if( rc ){
 rc = 0; /* It does not exist at all. */
   }else if( S_ISDIR(fileStat.st_mode) ){
 rc = 1; /* It exists and is a real directory. */
   }else if( S_ISLNK(fileStat.st_mode) ){
 Blob content;
+char *zFullName;
 blob_read_link(, zFN); /* It exists and is a link. */
-rc = file_wd_isdir(blob_str()); /* Points to directory? */
+if(*blob_str() != '/') {
+  while( nFN>0 && zFN[nFN-1]!='/' ){ nFN--; }
+} else { nFN = 0; }
+zFullName = mprintf("%.*s%s", nFN, zFN, blob_str());
+rc = file_wd_isdir(zFullName); /* Points to directory? */
+free(zFullName);
 blob_reset();
   }else{
 rc = 2; /* It exists and is something else. */
   }
   free(zFN);

___
fossil-users mailing list
fossil-users@lists.fossil-scm.org
http://lists.fossil-scm.org:8080/cgi-bin/mailman/listinfo/fossil-users


Re: [fossil-users] [PATCH] Improve symlink following offile_wd_isdir()

2017-11-25 Thread bytevolcano
Fixed a typo resulting in absolute cases not being picked up well.

Index: src/file.c
==
--- src/file.c
+++ src/file.c
@@ -327,24 +327,30 @@
 ** zFilename is a directory -OR- a symlink that points to a directory.
 ** Return 0 if zFilename does not exist.  Return 2 if zFilename exists
 ** but is something other than a directory.
 */
 int file_wd_isdir(const char *zFilename){
-  int rc;
+  int rc, nFN;
   char *zFN;


   zFN = mprintf("%s", zFilename);
-  file_simplify_name(zFN, -1, 0);
+  nFN = file_simplify_name(zFN, -1, 0);
   rc = getStat(zFN, 1);
   if( rc ){
 rc = 0; /* It does not exist at all. */
   }else if( S_ISDIR(fileStat.st_mode) ){
 rc = 1; /* It exists and is a real directory. */
   }else if( S_ISLNK(fileStat.st_mode) ){
 Blob content;
+char *zFullName;
 blob_read_link(, zFN); /* It exists and is a link. */
-rc = file_wd_isdir(blob_str()); /* Points to directory? */
+if(*blob_str() != '/') {
+  while( nFN>0 && zFN[nFN-1]!='/' ){ nFN--; }
+} else { nFN = 0; }
+zFullName = mprintf("%.*s%s", nFN, zFN, blob_str());
+rc = file_wd_isdir(zFullName); /* Points to directory? */
+free(zFullName);
 blob_reset();
   }else{
 rc = 2; /* It exists and is something else. */
   }
   free(zFN);
___
fossil-users mailing list
fossil-users@lists.fossil-scm.org
http://lists.fossil-scm.org:8080/cgi-bin/mailman/listinfo/fossil-users