Sun Aug 28 08:32:47 2011 UTC ()
Initialize local variables that previously were global (user, group).


(mbalmer)
diff -r1.17 -r1.18 src/usr.sbin/chroot/chroot.c

cvs diff -r1.17 -r1.18 src/usr.sbin/chroot/chroot.c (expand / switch to unified diff)

--- src/usr.sbin/chroot/chroot.c 2011/08/27 22:32:44 1.17
+++ src/usr.sbin/chroot/chroot.c 2011/08/28 08:32:47 1.18
@@ -1,14 +1,14 @@ @@ -1,14 +1,14 @@
1/* $NetBSD: chroot.c,v 1.17 2011/08/27 22:32:44 joerg Exp $ */ 1/* $NetBSD: chroot.c,v 1.18 2011/08/28 08:32:47 mbalmer Exp $ */
2 2
3/* 3/*
4 * Copyright (c) 1988, 1993 4 * Copyright (c) 1988, 1993
5 * The Regents of the University of California. All rights reserved. 5 * The Regents of the University of California. All rights reserved.
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer. 11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright 12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the 13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution. 14 * documentation and/or other materials provided with the distribution.
@@ -29,27 +29,27 @@ @@ -29,27 +29,27 @@
29 * SUCH DAMAGE. 29 * SUCH DAMAGE.
30 */ 30 */
31 31
32#include <sys/cdefs.h> 32#include <sys/cdefs.h>
33#ifndef lint 33#ifndef lint
34__COPYRIGHT("@(#) Copyright (c) 1988, 1993\ 34__COPYRIGHT("@(#) Copyright (c) 1988, 1993\
35 The Regents of the University of California. All rights reserved."); 35 The Regents of the University of California. All rights reserved.");
36#endif /* not lint */ 36#endif /* not lint */
37 37
38#ifndef lint 38#ifndef lint
39#if 0 39#if 0
40static char sccsid[] = "@(#)chroot.c 8.1 (Berkeley) 6/9/93"; 40static char sccsid[] = "@(#)chroot.c 8.1 (Berkeley) 6/9/93";
41#else 41#else
42__RCSID("$NetBSD: chroot.c,v 1.17 2011/08/27 22:32:44 joerg Exp $"); 42__RCSID("$NetBSD: chroot.c,v 1.18 2011/08/28 08:32:47 mbalmer Exp $");
43#endif 43#endif
44#endif /* not lint */ 44#endif /* not lint */
45 45
46#include <sys/param.h> 46#include <sys/param.h>
47 47
48#include <ctype.h> 48#include <ctype.h>
49#include <err.h> 49#include <err.h>
50#include <errno.h> 50#include <errno.h>
51#include <grp.h> 51#include <grp.h>
52#include <paths.h> 52#include <paths.h>
53#include <pwd.h> 53#include <pwd.h>
54#include <stdio.h> 54#include <stdio.h>
55#include <stdlib.h> 55#include <stdlib.h>
@@ -62,26 +62,28 @@ int @@ -62,26 +62,28 @@ int
62main(int argc, char *argv[]) 62main(int argc, char *argv[])
63{ 63{
64 char *user; /* user to switch to before running program */ 64 char *user; /* user to switch to before running program */
65 char *group; /* group to switch to ... */ 65 char *group; /* group to switch to ... */
66 char *grouplist; /* group list to switch to ... */ 66 char *grouplist; /* group list to switch to ... */
67 struct group *gp; 67 struct group *gp;
68 struct passwd *pw; 68 struct passwd *pw;
69 char *endp, *p; 69 char *endp, *p;
70 const char *shell; 70 const char *shell;
71 gid_t gid, gidlist[NGROUPS_MAX]; 71 gid_t gid, gidlist[NGROUPS_MAX];
72 uid_t uid; 72 uid_t uid;
73 int ch, gids; 73 int ch, gids;
74 74
 75 user = NULL;
 76 group = NULL;
75 gid = 0; 77 gid = 0;
76 uid = 0; 78 uid = 0;
77 while ((ch = getopt(argc, argv, "G:g:u:")) != -1) { 79 while ((ch = getopt(argc, argv, "G:g:u:")) != -1) {
78 switch(ch) { 80 switch(ch) {
79 case 'u': 81 case 'u':
80 user = optarg; 82 user = optarg;
81 if (*user == '\0') 83 if (*user == '\0')
82 usage(); 84 usage();
83 break; 85 break;
84 case 'g': 86 case 'g':
85 group = optarg; 87 group = optarg;
86 if (*group == '\0') 88 if (*group == '\0')
87 usage(); 89 usage();