Re: a problem with git describe

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Sat, Apr 23, 2022 at 04:44:57PM -0700, Junio C Hamano wrote:
> 
> Actually, not quite.  when "git" runs in "sudo git", the real
> identity has long lost

Right, but in this specific case, the terminal is still a good indication
of who the user is, so the following would work.

diff --git a/git-compat-util.h b/git-compat-util.h
index 58fd813bd01..5d5d91688ee 100644
--- a/git-compat-util.h
+++ b/git-compat-util.h
@@ -442,6 +442,11 @@ static inline int is_path_owned_by_current_uid(const char *path)
 	struct stat st;
 	if (lstat(path, &st))
 		return 0;
+	if (isatty(1)) {
+		struct stat ttyst;
+		if (!stat(ttyname(1), &ttyst))
+			return st.st_uid == ttyst.st_uid;
+	}
 	return st.st_uid == geteuid();
 }
 
It obviously needs more polishing and portability work, though, and I don't
like that it makes the general case more complicated, so maybe would be better
to only do it running as root?

At that point, though you might as well excempt root from this check

Carlo



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux