From: Donald Douwsma Date: Thu, 17 May 2007 15:57:27 +0000 (+0000) Subject: Prevent project commands from operating on special files. X-Git-Tag: v2.9.0~4 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=366127f79a9900c40818907055d372eff2ff6cd8;p=thirdparty%2Fxfsprogs-dev.git Prevent project commands from operating on special files. Merge of master-melb:xfs-cmds:28597a by kenmcd. --- diff --git a/doc/CHANGES b/doc/CHANGES index 3d7e8c8b8..9517afe2d 100644 --- a/doc/CHANGES +++ b/doc/CHANGES @@ -1,3 +1,7 @@ +xfsprogs-2.8.21 + - Fix xfs_quota project command to stop it operating on speical files. + Thanks to Leo Baltus. + xfsprogs-2.8.20 (23 February 2007) - Fix xfs_repair not detecting invalid btree root in inodes. - Fix xfs_repair restoring corrupted superblock after repairing it. diff --git a/quota/project.c b/quota/project.c index 6eae4dff2..e2e61c37b 100644 --- a/quota/project.c +++ b/quota/project.c @@ -30,6 +30,13 @@ enum { CLEAR_PROJECT = 0x4, }; +#define EXCLUDED_FILE_TYPES(x) \ + S_ISCHR((x)) \ + || S_ISBLK((x)) \ + || S_ISFIFO((x)) \ + || S_ISLNK((x)) \ + || S_ISSOCK((x)) + static void project_help(void) { @@ -77,12 +84,21 @@ static int check_project( const char *path, const struct stat *stat, - int status, + int flag, struct FTW *data) { struct fsxattr fsx; int fd; + if (flag == FTW_NS ){ + fprintf(stderr, _("%s: cannot stat file %s\n"), progname, path); + return 0; + } + if (EXCLUDED_FILE_TYPES(stat->st_mode)) { + fprintf(stderr, _("%s: skipping special file %s\n"), progname, path); + return 0; + } + if ((fd = open(path, O_RDONLY|O_NOCTTY)) == -1) fprintf(stderr, _("%s: cannot open %s: %s\n"), progname, path, strerror(errno)); @@ -107,12 +123,21 @@ static int clear_project( const char *path, const struct stat *stat, - int status, + int flag, struct FTW *data) { struct fsxattr fsx; int fd; + if (flag == FTW_NS ){ + fprintf(stderr, _("%s: cannot stat file %s\n"), progname, path); + return 0; + } + if (EXCLUDED_FILE_TYPES(stat->st_mode)) { + fprintf(stderr, _("%s: skipping special file %s\n"), progname, path); + return 0; + } + if ((fd = open(path, O_RDONLY|O_NOCTTY)) == -1) { fprintf(stderr, _("%s: cannot open %s: %s\n"), progname, path, strerror(errno)); @@ -137,12 +162,21 @@ static int setup_project( const char *path, const struct stat *stat, - int status, + int flag, struct FTW *data) { struct fsxattr fsx; int fd; + if (flag == FTW_NS ){ + fprintf(stderr, _("%s: cannot stat file %s\n"), progname, path); + return 0; + } + if (EXCLUDED_FILE_TYPES(stat->st_mode)) { + fprintf(stderr, _("%s: skipping special file %s\n"), progname, path); + return 0; + } + if ((fd = open(path, O_RDONLY|O_NOCTTY)) == -1) { fprintf(stderr, _("%s: cannot open %s: %s\n"), progname, path, strerror(errno));