"GOT", but the "O" is a cute, smiling pufferfish. Index | Thread | Search

From:
Christian Weisgerber <naddy@mips.inka.de>
Subject:
Disabling unveil breaks "got log -r repo entry"
To:
gameoftrees@openbsd.org
Date:
Tue, 15 Sep 2020 23:15:16 +0200

Download raw body.

Thread
If unveil() is replaced by a dummy that does nothing and always
returns 0, "got log -r repo entry" in a work tree breaks.

regress/cmdline/log.sh reproduces this, specifically
test_log_in_worktree_different_repo:

test_log_in_worktree_different_repo got: tmp/got-test-log_in_worktree_different_repo-ERkpS88v/wt/alpha: no such entry found in tree
--- /tmp/got-test-log_in_worktree_different_repo-ERkpS88v/stdout.expected      Tue Sep 15 22:42:32 2020
+++ /tmp/got-test-log_in_worktree_different_repo-ERkpS88v/stdout        Tue Sep 15 22:42:32 2020
@@ -1 +0,0 @@
-commit 4b955087b291a4cc5568d53b625e66d4e59caa95 (master)
test failed; leaving test data in /tmp/got-test-log_in_worktree_different_repo-ERkpS88v

The call chain is this:
cmd_log() -> got_repo_map_path() -> realpath()

With unveil(), the realpath() call fails.

Without unveil(), realpath() succeeds.  This effectively expands
"got log -r repo entry" into "got log -r entry /path/entry", which
then fails because there is no /path/entry in the repository.

Sorry, that's all I have.


You can use the following to short-ciruit unveil().  Something like
this is required when porting got to other platforms.

diff 0429cd76586cecb81d322546ab686ce527eb8f83 /home/naddy/got
blob - fff8cb02da0feb500622e5a857ec563f0947bc8d
file + got/got.c
--- 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 - adef301b3a4e820cb8b7d8a826cfbdfe0c69a60e
file + lib/privsep.c
--- lib/privsep.c
+++ lib/privsep.c
@@ -51,6 +51,8 @@
 #define	MIN(_a,_b) ((_a) < (_b) ? (_a) : (_b))
 #endif
 
+#define unveil(path, permissions)	0
+
 #ifndef nitems
 #define nitems(_a)	(sizeof((_a)) / sizeof((_a)[0]))
 #endif
-- 
Christian "naddy" Weisgerber                          naddy@mips.inka.de