Utilize clearenv(3).
authorshort <>
Tue, 13 Dec 2005 13:20:05 +0000 (13:20 +0000)
committershort <>
Tue, 13 Dec 2005 13:20:05 +0000 (13:20 +0000)
Update for: manon.vellum.cz

src/pserverchroot.c

index 3258147..2ce5dd7 100644 (file)
@@ -4,12 +4,10 @@
 #include <string.h>
 #include <errno.h>
 
-extern const char **environ;
 
-
-#define SETUID 554 /* "pserver" user  UID */
-#define SETGID 554 /* "pserver" group GID */
-#define PERMITTED_ENV_LIST "PWD"
+#define SETUID 503 /* "pserver" user  UID */
+#define SETGID 503 /* "pserver" group GID */
+#define CHROOT_DIR "/home/lace/pserver"
 #define EXEC_PATHNAME "/usr/bin/cvs"
 
 
@@ -43,26 +41,9 @@ static void funcfail(const char *funcname)
 
 int main(int argc,char **argv)
 {
-int total=0;
-const char *allowed[]={ PERMITTED_ENV_LIST };
-const char **allp,**envp;
-char *dup=NULL,*s;
-
-retry:
-       for (envp=environ;*envp;envp++) {
-               if (dup) free(dup);
-               dup=strdup(*envp);
-               if ((s=strchr(dup,'='))) *s='\0';
-               for (allp=allowed;allp<allowed+LENGTH(allowed);allp++)
-                       if (!strcmp(dup,*allp)) goto ok;
-               if (total++>1000)
-                       EXITLOG("Unable to clean environment for CVS pserver: %s",*envp);
-               unsetenv(dup);
-               goto retry;
-ok:;
-               }
+       FUNCCHK(clearenv);
        FUNCCHK(setenv,"PATH","/usr/bin",1);
-       FUNCCHK(chroot,"/home/short/pserver");
+       FUNCCHK(chroot,CHROOT_DIR);
        FUNCCHK(chdir,"/");
        FUNCCHK(setgid,SETGID);
        FUNCCHK(setuid,SETUID);