summaryrefslogtreecommitdiffstats
path: root/zupdate.cc
diff options
context:
space:
mode:
authorDaniel Baumann <mail@daniel-baumann.ch>2015-11-08 04:31:16 +0000
committerDaniel Baumann <mail@daniel-baumann.ch>2015-11-08 04:31:16 +0000
commit50c0d5bace5875eb0a3c4c7aafa564244e46e59c (patch)
tree9bf9dc3a57107e9c8d8a76f5bff5cca6eee9d5f1 /zupdate.cc
parentAdding debian version 1.2~pre3-1. (diff)
downloadzutils-50c0d5bace5875eb0a3c4c7aafa564244e46e59c.tar.xz
zutils-50c0d5bace5875eb0a3c4c7aafa564244e46e59c.zip
Merging upstream version 1.2.
Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
Diffstat (limited to '')
-rw-r--r--zupdate.cc22
1 files changed, 13 insertions, 9 deletions
diff --git a/zupdate.cc b/zupdate.cc
index 2b88c79..2b6caaf 100644
--- a/zupdate.cc
+++ b/zupdate.cc
@@ -1,5 +1,5 @@
/* Zupdate - recompress bzip2, gzip, xz files to lzip files
- Copyright (C) 2013 Antonio Diaz Diaz.
+ Copyright (C) 2013, 2014 Antonio Diaz Diaz.
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
@@ -60,10 +60,10 @@ void show_help()
"appropriate for long-term data archiving.\n"
"\nIf the lzip compressed version of a file already exists, the file is\n"
"skipped unless the '--force' option is given. In this case, if the\n"
- "comparison fails, an error is returned and the original file is not\n"
- "deleted. The operation of zupdate is meant to be safe and not produce\n"
- "any data loss. Therefore, existing lzip compressed files are never\n"
- "overwritten nor deleted.\n"
+ "comparison with the existing lzip version fails, an error is returned\n"
+ "and the original file is not deleted. The operation of zupdate is meant\n"
+ "to be safe and not produce any data loss. Therefore, existing lzip\n"
+ "compressed files are never overwritten nor deleted.\n"
"\nUsage: zupdate [options] [files]\n"
"\nExit status is 0 if all the compressed files were successfully\n"
"recompressed (if needed), compared and deleted. Non-zero otherwise.\n"
@@ -105,10 +105,14 @@ int cant_execute( const std::string & command, const int status )
void set_permissions( const char * const rname, const struct stat & in_stats )
{
bool warning = false;
- // fchown will in many cases return with EPERM, which can be safely ignored.
- if( ( chown( rname, in_stats.st_uid, in_stats.st_gid ) != 0 &&
- errno != EPERM ) ||
- chmod( rname, in_stats.st_mode ) != 0 ) warning = true;
+ const mode_t mode = in_stats.st_mode;
+ // chown will in many cases return with EPERM, which can be safely ignored.
+ if( chown( rname, in_stats.st_uid, in_stats.st_gid ) == 0 )
+ { if( chmod( rname, mode ) != 0 ) warning = true; }
+ else
+ if( errno != EPERM ||
+ chmod( rname, mode & ~( S_ISUID | S_ISGID | S_ISVTX ) ) != 0 )
+ warning = true;
struct utimbuf t;
t.actime = in_stats.st_atime;
t.modtime = in_stats.st_mtime;