From: b Date: Sat, 12 Nov 2022 20:24:35 +0000 (+0000) Subject: correct SETUID handling X-Git-Url: http://bicyclesonthemoon.info/git-projects/?a=commitdiff_plain;h=77358d32a0dc0037d0be40dc52a3bdc79fc269fb;p=botm%2Fgit correct SETUID handling --- diff --git a/exec.c b/exec.c index c747a98..5094091 100644 --- a/exec.c +++ b/exec.c @@ -1,10 +1,20 @@ +// 12.11.2022 #include +#include #define TARGET "###TARGET;" int main(int argc, char *argv[], char *envp[]) { + uid_t euid; + gid_t egid; int r; + euid = geteuid(); + egid = getegid(); + if ((r = setreuid(euid, euid))) + return (r = errno); + if ((r = setregid(egid, egid))) + return (r = errno); r=execve(TARGET,argv,envp); return r; } diff --git a/makefile b/makefile index f1a3a17..ec0c3ab 100644 --- a/makefile +++ b/makefile @@ -23,7 +23,7 @@ git-http-backend: git-http-backend.c cpbin: git-http-backend $(MKDIR) -p $(OD) - $(CP) git-http-backend $(OD) + $(CP) -p git-http-backend $(OD) rmbin: $rm -f $(OD)/git-http-backend