From 33c65b85425187f4cb06f7c8302e49d571c4c3a7 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Mon, 2 Aug 2010 22:11:13 -0700 Subject: [PATCH] Replace S_I[RWX]{USR,GRP,OTH} macros by their values. POSIX 2008 guarantees that these macros have their traditional Unix values, so it should no be longer necessary to use the macros for portability's sake. Personally, I find the values easier to read, especially when several of them are OR'd together. --- src/data/por-file-writer.c | 6 +++--- src/data/sys-file-writer.c | 4 ++-- src/language/data-io/data-writer.c | 7 +++---- src/language/utilities/permissions.c | 6 +++--- 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/data/por-file-writer.c b/src/data/por-file-writer.c index 22656f19..9889cfd9 100644 --- a/src/data/por-file-writer.c +++ b/src/data/por-file-writer.c @@ -1,5 +1,5 @@ /* PSPP - a program for statistical analysis. - Copyright (C) 1997-9, 2000, 2006, 2009 Free Software Foundation, Inc. + Copyright (C) 1997-9, 2000, 2006, 2009, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -150,9 +150,9 @@ pfm_open_writer (struct file_handle *fh, struct dictionary *dict, goto error; /* Create file. */ - mode = S_IRUSR | S_IRGRP | S_IROTH; + mode = 0444; if (opts.create_writeable) - mode |= S_IWUSR | S_IWGRP | S_IWOTH; + mode |= 0222; w->rf = replace_file_start (fh_get_file_name (fh), "w", mode, &w->file, NULL); if (w->rf == NULL) diff --git a/src/data/sys-file-writer.c b/src/data/sys-file-writer.c index 729213bf..fcb40d37 100644 --- a/src/data/sys-file-writer.c +++ b/src/data/sys-file-writer.c @@ -209,9 +209,9 @@ sfm_open_writer (struct file_handle *fh, struct dictionary *d, goto error; /* Create the file on disk. */ - mode = S_IRUSR | S_IRGRP | S_IROTH; + mode = 0444; if (opts.create_writeable) - mode |= S_IWUSR | S_IWGRP | S_IWOTH; + mode |= 0222; w->rf = replace_file_start (fh_get_file_name (fh), "wb", mode, &w->file, NULL); if (w->rf == NULL) diff --git a/src/language/data-io/data-writer.c b/src/language/data-io/data-writer.c index 85b11d4c..f7365687 100644 --- a/src/language/data-io/data-writer.c +++ b/src/language/data-io/data-writer.c @@ -1,5 +1,5 @@ /* PSPP - a program for statistical analysis. - Copyright (C) 1997-2004, 2006 Free Software Foundation, Inc. + Copyright (C) 1997-2004, 2006, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -66,9 +66,8 @@ dfm_open_writer (struct file_handle *fh) w = xmalloc (sizeof *w); w->fh = fh_ref (fh); w->lock = lock; - w->rf = replace_file_start (fh_get_file_name (w->fh), "wb", - (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP - | S_IROTH | S_IWOTH), &w->file, NULL); + w->rf = replace_file_start (fh_get_file_name (w->fh), "wb", 0666, + &w->file, NULL); if (w->rf == NULL) { msg (ME, _("An error occurred while opening \"%s\" for writing " diff --git a/src/language/utilities/permissions.c b/src/language/utilities/permissions.c index fec6b4fc..03458fce 100644 --- a/src/language/utilities/permissions.c +++ b/src/language/utilities/permissions.c @@ -1,5 +1,5 @@ /* PSPP - a program for statistical analysis. - Copyright (C) 2004 Free Software Foundation, Inc. + Copyright (C) 2004, 2010 Free Software Foundation, Inc. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -108,9 +108,9 @@ change_permissions (const char *file_name, enum PER per) } if ( per == PER_RW ) - mode = buf.st_mode | S_IWUSR ; + mode = buf.st_mode | 0200; else - mode = buf.st_mode & ~( S_IWOTH | S_IWUSR | S_IWGRP ); + mode = buf.st_mode & ~0222; if ( -1 == chmod(file_name, mode)) -- 2.30.2