On OpenBSD 6.1, running "fossil uv edit" will result in the
following error:
unable to create directory /var/tmp
Upon digging through this, I found Fossil was following the "/var/tmp"
symlink that recent OpenBSD versions create:
lrwxrwx--- 1 root wheel 6 Apr 1 2017 /var/tmp -> ../tmp
Of course, Fossil was trying to find a folder called ../tmp", but
it doesn't exist, and so the code cascades into the above error.
This change allows the symlink to be followed correctly, and Fossil
will attempt to test "/var/../tmp" (ie. /tmp) in the above example.
This succeeds, and also has a check in case the symlink points to
an absolute path (beginning with '/').
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(&content, zFN); /* It exists and is a link. */
- rc = file_wd_isdir(blob_str(&content)); /* Points to directory? */
+ if(*blob_str(&content) != '/')
+ while( nFN>0 && zFN[nFN-1]!='/' ){ nFN--; }
+ } else { nFN == 0; }
+ zFullName = mprintf("%.*s%s", nFN, zFN, blob_str(&content));
+ rc = file_wd_isdir(zFullName); /* Points to directory? */
+ free(zFullName);
blob_reset(&content);
}else{
rc = 2; /* It exists and is something else. */
}
free(zFN);
_______________________________________________
fossil-users mailing list
[email protected]
http://lists.fossil-scm.org:8080/cgi-bin/mailman/listinfo/fossil-users