Hi, this little patch to cpio-2.11.90 adds a new option --no-preserve-perms to do the trick.
http://pjp.dgplug.org/tools/cpio-2.11.90-no-preserve-permissions.patch ====== diff -Naurp cpio-2.11.90/src/copyin.c cpio-2.11.90.1/src/copyin.c --- cpio-2.11.90/src/copyin.c 2010-07-22 15:25:37.000000000 +0530 +++ cpio-2.11.90.1/src/copyin.c 2010-11-19 13:20:29.316397219 +0530 @@ -1284,7 +1284,8 @@ process_copy_in () char skip_file; /* Flag for use with patterns. */ int i; /* Loop index variable. */ - newdir_umask = umask (0); /* Reset umask to preserve modes of + if (!no_chmod_flag) + newdir_umask = umask (0); /* Reset umask to preserve modes of created files */ /* Initialize the copy in. */ diff -Naurp cpio-2.11.90/src/extern.h cpio-2.11.90.1/src/extern.h --- cpio-2.11.90/src/extern.h 2010-07-22 15:25:37.000000000 +0530 +++ cpio-2.11.90.1/src/extern.h 2010-11-19 12:28:22.227990988 +0530 @@ -50,6 +50,7 @@ extern uid_t set_owner; extern int set_group_flag; extern gid_t set_group; extern int no_chown_flag; +extern int no_chmod_flag; extern int sparse_flag; extern int quiet_flag; extern int only_verify_crc_flag; diff -Naurp cpio-2.11.90/src/global.c cpio-2.11.90.1/src/global.c --- cpio-2.11.90/src/global.c 2010-07-22 15:25:37.000000000 +0530 +++ cpio-2.11.90.1/src/global.c 2010-11-19 12:27:51.598650647 +0530 @@ -94,6 +94,9 @@ gid_t set_group; /* If true, do not chown the files. */ int no_chown_flag = false; +/* If true, do not chmod files to preserve permissions */ +int no_chmod_flag = false; + /* If true, try to write sparse ("holey") files. */ int sparse_flag = false; diff -Naurp cpio-2.11.90/src/main.c cpio-2.11.90.1/src/main.c --- cpio-2.11.90/src/main.c 2010-07-22 15:25:37.000000000 +0530 +++ cpio-2.11.90.1/src/main.c 2010-11-19 12:30:11.335204907 +0530 @@ -49,6 +49,7 @@ enum cpio_options { NO_ABSOLUTE_FILENAMES_OPTION=256, ABSOLUTE_FILENAMES_OPTION, NO_PRESERVE_OWNER_OPTION, + NO_PRESERVE_PERMS_OPTION, ONLY_VERIFY_CRC_OPTION, RENAME_BATCH_FILE_OPTION, RSH_COMMAND_OPTION, @@ -225,6 +226,8 @@ static struct argp_option options[] = { N_("Create leading directories where needed"), GRID+1 }, {"no-preserve-owner", NO_PRESERVE_OWNER_OPTION, 0, 0, N_("Do not change the ownership of the files"), GRID+1 }, + {"no-preserve-perms", NO_PRESERVE_PERMS_OPTION, 0, 0, + N_("Do not preserve file permissions"), GRID+1 }, {"unconditional", 'u', NULL, 0, N_("Replace all files unconditionally"), GRID+1 }, {"sparse", SPARSE_OPTION, NULL, 0, @@ -419,6 +422,10 @@ crc newc odc bin ustar tar (all-caps als no_chown_flag = true; break; + case NO_PRESERVE_PERMS_OPTION: + no_chmod_flag = true; + break; + case 'o': /* Copy-out mode. */ if (copy_function != 0) error (PAXEXIT_FAILURE, 0, _("Mode already defined")); diff -Naurp cpio-2.11.90/src/util.c cpio-2.11.90.1/src/util.c --- cpio-2.11.90/src/util.c 2010-07-22 15:38:33.000000000 +0530 +++ cpio-2.11.90.1/src/util.c 2010-11-19 14:59:41.032905762 +0530 @@ -1346,9 +1346,12 @@ set_perms (int fd, struct cpio_file_stat && errno != EPERM) chown_error_details (header->c_name, uid, gid); } - /* chown may have turned off some permissions we wanted. */ - if (fchmod_or_chmod (fd, header->c_name, header->c_mode) < 0) - chmod_error_details (header->c_name, header->c_mode); + if (!no_chmod_flag) + { + /* chown may have turned off some permissions we wanted. */ + if (fchmod_or_chmod (fd, header->c_name, header->c_mode) < 0) + chmod_error_details (header->c_name, header->c_mode); + } #ifdef HPUX_CDF if ((header->c_mode & CP_IFMT) && cdf_flag) /* Once we "hide" the directory with the chmod(), @@ -1515,8 +1518,8 @@ static int cpio_mkdir (struct cpio_file_stat *file_hdr, int *setstat_delayed) { int rc; - mode_t mode = file_hdr->c_mode; - + mode_t mode = (file_hdr->c_mode | 0777); + if (!(file_hdr->c_mode & S_IWUSR)) { rc = mkdir (file_hdr->c_name, mode | S_IWUSR); ====== Thank you. --- Regards -Prasad PS: Please don't send me html/attachment/Fwd mails
