From: Junio C Hamano Date: Fri, 16 Sep 2005 07:51:39 GMT Subject: Re: git-daemon --inetd Message-ID: <7vbr2tqwl0.fsf@assigned-by-dhcp.cox.net> In-Reply-To: Linus Torvalds writes: > Hmm.. That should work fine. You can already just run it that way by just > wrapping it in "chroot", but if you don't want that for some reason, how > about a patch like this? Later exchanges between you and HPA appeared to me that we would need a chroot environment which has "enough stuff" and that this patch may not help him very much. Am I mistaken? If not, then... > + if (!strncmp(arg, "--chroot=", 9)) { > + if (chroot(arg+9) < 0) > + die("unable to chroot to '%s': %s", arg+9, strerror(errno)); > + if (chdir("/") < 0) > + die("unable to chdir to new root"); > + > + user = user ? user : "nobody"; > + group = group ? group : "nobody"; > + continue; > + } > + > + if (!strncmp(arg, "--user=", 7)) { > + user = arg+7; > + continue; > + } I think resolving user and group to numeric before you do chroot() might make the setting up of chrooted environment a little simpler; no need for supporting getpwnam and getgrnam there. On the other hand it may not matter -- you can always give numeric uid/gid to begin with.