Files
mtkports/dev-vcs/git/compat/montauk-ownership.h
2026-08-09 10:47:07 +02:00

46 lines
2.1 KiB
C

/*
* montauk-ownership.h -- answer git's "is this repository mine?" question.
*
* FORCE-INCLUDED into every translation unit (-include, see the port
* Makefile), because it has to win the #ifndef guard in git-compat-util.h.
*
* git's safe.directory check exists because on a multi-user system a
* repository owned by somebody else can attack you the moment you run git in
* it -- its config names hooks, pagers and external diff commands that would
* run as you. The default implementation answers by comparing the owner
* reported by lstat() against geteuid().
*
* Neither side of that comparison means anything on MontaukOS. The VFS stores
* no owner at all -- stat() zero-fills st_uid, on the ramdisk, on ext2 and on
* FAT32 alike -- and there is one session user, so the compat layer reports a
* single fixed uid for everybody (see montauk-compat.c). The comparison is
* therefore 0 == 1000, false for EVERY repository: unpatched, git refuses to
* work in any directory on the system, which is what
*
* fatal: detected dubious ownership in repository at '0:/users/...'
*
* was. Picking the uid to match the zero from stat() would only paper over it,
* and would mean claiming to be root.
*
* So answer honestly: every file belongs to the one user, and the check has
* nothing to distinguish. This is the same seam Windows uses for the same
* reason (compat/mingw.h defines is_path_owned_by_current_sid here).
*
* WHAT THIS GIVES UP: nothing today, and something real later. When MontaukOS
* grows per-file ownership, this must go back to comparing owners -- otherwise
* git in another user's repository will run that repository's hooks as you.
*/
#ifndef _MONTAUK_GIT_OWNERSHIP_H_
#define _MONTAUK_GIT_OWNERSHIP_H_
/*
* A macro, not a function: this header is force-included before anything
* declares struct strbuf, so the report parameter cannot be named in a
* prototype here. Both arguments are still evaluated-as-void so an unused
* variable at a call site does not start warning.
*/
#define is_path_owned_by_current_user(path, report) \
((void)(path), (void)(report), 1)
#endif /* _MONTAUK_GIT_OWNERSHIP_H_ */