From owner-svn-src-stable@FreeBSD.ORG Mon Jul 6 01:32:30 2009 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 42A751065675; Mon, 6 Jul 2009 01:32:30 +0000 (UTC) (envelope-from brooks@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 152688FC13; Mon, 6 Jul 2009 01:32:30 +0000 (UTC) (envelope-from brooks@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n661WTQt064917; Mon, 6 Jul 2009 01:32:29 GMT (envelope-from brooks@svn.freebsd.org) Received: (from brooks@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n661WT0L064915; Mon, 6 Jul 2009 01:32:29 GMT (envelope-from brooks@svn.freebsd.org) Message-Id: <200907060132.n661WT0L064915@svn.freebsd.org> From: Brooks Davis Date: Mon, 6 Jul 2009 01:32:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r195388 - stable/7/usr.bin/catman X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 06 Jul 2009 01:32:31 -0000 Author: brooks Date: Mon Jul 6 01:32:29 2009 New Revision: 195388 URL: http://svn.freebsd.org/changeset/base/195388 Log: MFC r194493 and r194548 When checking if we can write to a file, use access() instead of a manual permission check based on stat output. Also, get rid of the executability check since it is not used. Modified: stable/7/usr.bin/catman/ (props changed) stable/7/usr.bin/catman/catman.c Modified: stable/7/usr.bin/catman/catman.c ============================================================================== --- stable/7/usr.bin/catman/catman.c Mon Jul 6 01:04:45 2009 (r195387) +++ stable/7/usr.bin/catman/catman.c Mon Jul 6 01:32:29 2009 (r195388) @@ -57,7 +57,6 @@ __FBSDID("$FreeBSD$"); #define TEST_FILE 0x04 #define TEST_READABLE 0x08 #define TEST_WRITABLE 0x10 -#define TEST_EXECUTABLE 0x20 static int verbose; /* -v flag: be verbose with warnings */ static int pretend; /* -n, -p flags: print out what would be done @@ -93,8 +92,6 @@ static const char *locale_device[] = { enum Ziptype {NONE, BZIP, GZIP}; static uid_t uid; -static gid_t gids[NGROUPS_MAX]; -static int ngids; static int starting_dir; static char tmp_file[MAXPATHLEN]; struct stat test_st; @@ -320,23 +317,10 @@ test_path(char *name, time_t *mod_time) result |= TEST_DIR; else if (S_ISREG(test_st.st_mode)) result |= TEST_FILE; - if (test_st.st_uid == uid) { - test_st.st_mode >>= 6; - } else { - int i; - for (i = 0; i < ngids; i++) { - if (test_st.st_gid == gids[i]) { - test_st.st_mode >>= 3; - break; - } - } - } - if (test_st.st_mode & S_IROTH) + if (access(name, R_OK)) result |= TEST_READABLE; - if (test_st.st_mode & S_IWOTH) + if (access(name, W_OK)) result |= TEST_WRITABLE; - if (test_st.st_mode & S_IXOTH) - result |= TEST_EXECUTABLE; return result; } @@ -789,7 +773,6 @@ main(int argc, char **argv) /* NOTREACHED */ } } - ngids = getgroups(NGROUPS_MAX, gids); if ((starting_dir = open(".", 0)) < 0) { err(1, "."); }