From d1c7f62ba8b3a5de6fd66873e49359aa9c4c863e Mon Sep 17 00:00:00 2001 From: Jim Meyering Date: Mon, 26 Apr 1999 12:54:51 +0000 Subject: [PATCH] (copy_reg, copy_internal): Use proper mode_t types and macros. Don't assume the traditional Unix values for mode bits. --- src/copy.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/copy.c b/src/copy.c index 675d813f9..c8a3d92ca 100644 --- a/src/copy.c +++ b/src/copy.c @@ -195,7 +195,7 @@ copy_reg (const char *src_path, const char *dst_path, /* Create the new regular file with small permissions initially, to not create a security hole. */ - dest_desc = open (dst_path, O_WRONLY | O_CREAT | O_TRUNC, 0600); + dest_desc = open (dst_path, O_WRONLY | O_CREAT | O_TRUNC, S_IRUSR | S_IWUSR); if (dest_desc < 0) { error (0, errno, _("cannot create regular file `%s'"), dst_path); @@ -488,9 +488,9 @@ copy_internal (const char *src_path, const char *dst_path, if (euidaccess (dst_path, W_OK) != 0) { fprintf (stderr, - _("%s: overwrite `%s', overriding mode %04o? "), + _("%s: overwrite `%s', overriding mode %04lo? "), program_name, dst_path, - (unsigned int) (dst_sb.st_mode & 07777)); + (unsigned long) (dst_sb.st_mode & CHMOD_MODE_BITS)); } else { @@ -558,7 +558,7 @@ copy_internal (const char *src_path, const char *dst_path, /* Temporarily change mode to allow overwriting. */ if (euidaccess (dst_path, W_OK | X_OK) != 0) { - if (chmod (dst_path, 0700)) + if (chmod (dst_path, S_IRWXU)) { error (0, errno, "%s", dst_path); return 1; @@ -682,7 +682,7 @@ copy_internal (const char *src_path, const char *dst_path, /* Create the new directory writable and searchable, so we can create new entries in it. */ - if (mkdir (dst_path, (src_mode & x->umask_kill) | 0700)) + if (mkdir (dst_path, (src_mode & x->umask_kill) | S_IRWXU)) { error (0, errno, _("cannot create directory `%s'"), dst_path); goto un_backup; -- 2.34.1