Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 7 Sep 2003 16:32:13 +0800
From:      =?koi8-r?B?5sXO2MXXIOvJ0snMzCDhzMXL08HOxNLP18ne?= <cyrill@econ.krasnoyarsk.su>
To:        <cyrille.lefevre@laposte.net>
Cc:        ports@FreeBSD.org
Subject:   FreeBSD Port: op-1.11
Message-ID:  <199F4C47F5056A47938D39C21423B92C1F3C05@ecnts2.intranet.econ.krasnoyarsk.su>

next in thread | raw e-mail | index | archive | help

Patch for 'gid' option (doesn't work at all)

--- main.c.original	Thu Jan  1 08:03:17 1970
+++ main.c	Sun Sep  7 15:14:30 2003
@@ -448,29 +448,17 @@
 	char		*cp, *np;
 	struct passwd	*pw;
 	struct group	*gr;
-	int		ngroups, gidset[256];
+	int		ngroups =3D 0, gidset[256];
 	int		curenv =3D 0, curarg =3D 0;
 	char		*new_envp[MAXENV];
 	char		*new_argv[MAXARG];
 	char		str[MAXSTRLEN], buf[4*MAXSTRLEN];
=20
-	if ((cp =3D FindOpt(cmd, "uid")) =3D=3D NULL) {
-		if (setuid(0) < 0)
-			fatal("Unable to set uid to default", cp);
-	} else {
-		if ((pw =3D getpwnam(cp)) =3D=3D NULL) {
-			if (setuid(atoi(cp)) < 0)
-				fatal("Unable to set uid to %s", cp);
-		}
-		if (setuid(pw->pw_uid) < 0)
-			fatal("Unable to set uid to %s", cp);
-	}
-
 	if ((cp =3D FindOpt(cmd, "gid")) =3D=3D NULL) {
 		;		/* don't have a default */
 	} else {
 		for (cp=3DGetField(cp, str); cp!=3DNULL; cp=3DGetField(cp, str)) {
-			if ((gr =3D getgrnam(cp)) !=3D NULL)
+			if ((gr =3D getgrnam(str)) !=3D NULL)
 				gidset[ngroups++] =3D gr->gr_gid;
 		}
 		if (ngroups =3D=3D 0)=20
@@ -533,6 +521,18 @@
 			new_envp[curenv++] =3D environ[i];
 	}
 	new_envp[curenv] =3D NULL;
+
+	if ((cp =3D FindOpt(cmd, "uid")) =3D=3D NULL) {
+		if (setuid(0) < 0)
+			fatal("Unable to set uid to default", cp);
+	} else {
+		if ((pw =3D getpwnam(cp)) =3D=3D NULL) {
+			if (setuid(atoi(cp)) < 0)
+				fatal("Unable to set uid to %s", cp);
+		}
+		if (setuid(pw->pw_uid) < 0)
+			fatal("Unable to set uid to %s", cp);
+	}
=20
 	if (strcmp("MAGIC_SHELL", cmd->args[0]) =3D=3D 0) {
 		for (i =3D 0; environ[i] !=3D NULL; i++)=20



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199F4C47F5056A47938D39C21423B92C1F3C05>