=================================================================== RCS file: /cvsrepo/anoncvs/cvs/src/usr.bin/which/which.c,v retrieving revision 1.3 retrieving revision 1.4 diff -c -r1.3 -r1.4 *** src/usr.bin/which/which.c 1998/01/28 17:18:53 1.3 --- src/usr.bin/which/which.c 1998/05/07 19:12:20 1.4 *************** *** 1,4 **** ! /* $OpenBSD: which.c,v 1.3 1998/01/28 17:18:53 millert Exp $ */ /* * Copyright (c) 1997 Todd C. Miller --- 1,4 ---- ! /* $OpenBSD: which.c,v 1.4 1998/05/07 19:12:20 deraadt Exp $ */ /* * Copyright (c) 1997 Todd C. Miller *************** *** 31,37 **** */ #ifndef lint ! static char rcsid[] = "$OpenBSD: which.c,v 1.3 1998/01/28 17:18:53 millert Exp $"; #endif /* not lint */ #include --- 31,37 ---- */ #ifndef lint ! static char rcsid[] = "$OpenBSD: which.c,v 1.4 1998/05/07 19:12:20 deraadt Exp $"; #endif /* not lint */ #include *************** *** 100,122 **** mib[0] = CTL_USER; mib[1] = USER_CS_PATH; if (sysctl(mib, 2, NULL, &n, NULL, 0) == -1) ! err(-1, "unable to get length of user.cs_path"); if (n == 0) ! errx(-1, "user.cs_path was zero length!"); if ((path = (char *)malloc(n)) == NULL) ! errx(-1, "can't allocate memory."); if (sysctl(mib, 2, path, &n, NULL, 0) == -1) ! err(-1, "unable to get user.cs_path"); } else { if ((path = getenv("PATH")) == NULL) ! err(-1, "can't get $PATH from environment"); } /* To make access(2) do what we want */ if (setgid(getegid())) ! err(-1, "Can't set gid to %u", getegid()); if (setuid(geteuid())) ! err(-1, "Can't set uid to %u", geteuid()); for (n = optind; n < argc; n++) if (findprog(argv[n], path, progmode, allmatches) == 0) --- 100,122 ---- mib[0] = CTL_USER; mib[1] = USER_CS_PATH; if (sysctl(mib, 2, NULL, &n, NULL, 0) == -1) ! err(1, "unable to get length of user.cs_path"); if (n == 0) ! errx(1, "user.cs_path was zero length!"); if ((path = (char *)malloc(n)) == NULL) ! errx(1, "can't allocate memory."); if (sysctl(mib, 2, path, &n, NULL, 0) == -1) ! err(1, "unable to get user.cs_path"); } else { if ((path = getenv("PATH")) == NULL) ! err(1, "can't get $PATH from environment"); } /* To make access(2) do what we want */ if (setgid(getegid())) ! err(1, "Can't set gid to %u", getegid()); if (setuid(geteuid())) ! err(1, "Can't set uid to %u", geteuid()); for (n = optind; n < argc; n++) if (findprog(argv[n], path, progmode, allmatches) == 0) *************** *** 149,155 **** } if ((path = strdup(path)) == NULL) ! errx(-1, "Can't allocate memory."); proglen = strlen(prog); while ((p = strsep(&path, ":")) != NULL) { --- 149,155 ---- } if ((path = strdup(path)) == NULL) ! errx(1, "Can't allocate memory."); proglen = strlen(prog); while ((p = strsep(&path, ":")) != NULL) {