#include <utimens.h>
#include <errno.h>
#include <xgetcwd.h>
+#include <priv-set.h>
#include "common.h"
char typeflag)
{
mode_t mode;
-
+ bool failed;
+
if (0 < same_permissions_option
&& permstatus != INTERDIR_PERMSTATUS)
{
mode = cur_info->st_mode ^ invert_permissions;
}
- if (chmod (file_name, mode) != 0)
+ failed = chmod (file_name, mode) != 0;
+ if (failed && errno == EPERM)
+ {
+ /* On Solaris, chmod may fail if we don't have PRIV_ALL. */
+ if (priv_set_restore_linkdir () == 0)
+ {
+ failed = chmod (file_name, mode) != 0;
+ priv_set_remove_linkdir ();
+ }
+ }
+ if (failed)
chmod_error_details (file_name, mode);
}
if (stat (file_name, &st))
{
- stat_warn (file_name);
- /* Be on the safe side: if the file does exist assume it is newer */
- return errno != ENOENT;
+ if (errno != ENOENT)
+ {
+ stat_warn (file_name);
+ /* Be on the safe side: if the file does exist assume it is newer */
+ return true;
+ }
+ return false;
}
if (!S_ISDIR (st.st_mode)
&& tar_timespec_cmp (tar_stat->mtime, get_stat_mtime (&st)) <= 0)
}
if (S_ISDIR (st.st_mode))
{
+ status = 0;
mode = st.st_mode;
break;
}
char typeflag;
tar_extractor_t fun;
+ /* Try to disable the ability to unlink a directory. */
+ priv_set_remove_linkdir ();
+
set_next_block_after (current_header);
decode_header (current_header, ¤t_stat_info, ¤t_format, 1);
if (!current_stat_info.file_name[0]