diff options
author | Daniel Baumann <mail@daniel-baumann.ch> | 2015-11-08 04:31:08 +0000 |
---|---|---|
committer | Daniel Baumann <mail@daniel-baumann.ch> | 2015-11-08 04:31:08 +0000 |
commit | 28661ee11a284a36eeab97b20ea85e9286c6f7ae (patch) | |
tree | de1540839a3b3426dabd8474d1be65938adb4dc0 /zupdate.cc | |
parent | Adding upstream version 1.2~pre3. (diff) | |
download | zutils-28661ee11a284a36eeab97b20ea85e9286c6f7ae.tar.xz zutils-28661ee11a284a36eeab97b20ea85e9286c6f7ae.zip |
Adding upstream version 1.2.upstream/1.2
Signed-off-by: Daniel Baumann <mail@daniel-baumann.ch>
Diffstat (limited to '')
-rw-r--r-- | zupdate.cc | 22 |
1 files changed, 13 insertions, 9 deletions
@@ -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; |