From: Christian Weisgerber Subject: got_repo_map_path() To: gameoftrees@openbsd.org Date: Wed, 21 Oct 2020 22:04:36 +0200 I tried to take another look at got_repo_map_path(). Reminder: If unveil() is disabled, some command line uses break. $ cd /home/naddy/got # a worktree $ cd tog $ got log -r /home/naddy/got.git tog.1 got: home/naddy/got/tog/tog.1: no such entry found in tree The problem is in got_repo_map_path(), principally in the block that starts with path = realpath(canonpath, NULL); If unveil() is enabled, the realpath() call will fail, which looks like a bug. However, without unveil() the rest of the block is executed and the example above ends up here: /* * Matched unrelated on-disk path. * Treat it as repository-relative. */ I'm struggling to understand the _intended_ semantics of the various cases handled by realpath(), so I can't tell what's actually wrong. Generally speaking, the idea of converting a relative path into an absolute filesystem path and using that one again as relative path inside the repository, well, that seems odd. Help!? To reproduce: diff refs/heads/main refs/heads/nounveil blob - f7f14b9cb2d386242d73d208d79ef3e9df874bab blob + e8abfd8f8a549cb0eac59cacfe6c63c122afc494 --- got/got.c +++ got/got.c @@ -56,6 +56,8 @@ #include "got_opentemp.h" #include "got_gotconfig.h" +#define unveil(path, permissions) 0 + #ifndef nitems #define nitems(_a) (sizeof((_a)) / sizeof((_a)[0])) #endif blob - d15fdd1c19625c14f12b9ef6c2f0a764fc43a0da blob + 39236a84794f208a9dfc20a6e981cf62b4cc6c0a --- lib/privsep.c +++ lib/privsep.c @@ -47,6 +47,8 @@ #include "got_lib_privsep.h" #include "got_lib_pack.h" +#define unveil(path, permissions) 0 + #ifndef MIN #define MIN(_a,_b) ((_a) < (_b) ? (_a) : (_b)) #endif blob - 1b0d1ec057af633bce4d306c98106dd9eb8eedb2 blob + f9522ec74ce4d1f505126d38a18dcb11c792f9b8 --- tog/tog.c +++ tog/tog.c @@ -56,6 +56,8 @@ #include "got_path.h" #include "got_worktree.h" +#define unveil(path, permissions) 0 + #ifndef MIN #define MIN(_a,_b) ((_a) < (_b) ? (_a) : (_b)) #endif -- Christian "naddy" Weisgerber naddy@mips.inka.de