diff options
Diffstat (limited to 'src/tar.c')
-rw-r--r-- | src/tar.c | 89 |
1 files changed, 82 insertions, 7 deletions
@@ -247,7 +247,8 @@ tar_set_quoting_style (char *arg) enum { - ANCHORED_OPTION = CHAR_MAX + 1, + ACLS_OPTION = CHAR_MAX + 1, + ANCHORED_OPTION, ATIME_PRESERVE_OPTION, BACKUP_OPTION, CHECKPOINT_OPTION, @@ -271,6 +272,7 @@ enum MODE_OPTION, MTIME_OPTION, NEWER_MTIME_OPTION, + NO_ACLS_OPTION, NO_ANCHORED_OPTION, NO_DELAY_DIRECTORY_RESTORE_OPTION, NO_IGNORE_CASE_OPTION, @@ -280,9 +282,11 @@ enum NO_RECURSION_OPTION, NO_SAME_OWNER_OPTION, NO_SAME_PERMISSIONS_OPTION, + NO_SELINUX_CONTEXT_OPTION, NO_UNQUOTE_OPTION, NO_WILDCARDS_MATCH_SLASH_OPTION, NO_WILDCARDS_OPTION, + NO_XATTR_OPTION, NULL_OPTION, NUMERIC_OWNER_OPTION, OCCURRENCE_OPTION, @@ -304,6 +308,7 @@ enum RMT_COMMAND_OPTION, RSH_COMMAND_OPTION, SAME_OWNER_OPTION, + SELINUX_CONTEXT_OPTION, SHOW_DEFAULTS_OPTION, SHOW_OMITTED_DIRS_OPTION, SHOW_TRANSFORMED_NAMES_OPTION, @@ -321,7 +326,8 @@ enum VERSION_OPTION, VOLNO_FILE_OPTION, WILDCARDS_MATCH_SLASH_OPTION, - WILDCARDS_OPTION + WILDCARDS_OPTION, + XATTR_OPTION }; const char *argp_program_version = "tar (" PACKAGE_NAME ") " VERSION; @@ -453,6 +459,10 @@ static struct argp_option options[] = { {NULL, 0, NULL, 0, N_("Handling of file attributes:"), GRID }, + {"acls", ACLS_OPTION, 0, 0, + N_("Save the ACLs to the archive"), GRID+1 }, + {"no-acls", NO_ACLS_OPTION, 0, 0, + N_("Don't extract the ACLs from the archive"), GRID+1 }, {"owner", OWNER_OPTION, N_("NAME"), 0, N_("force NAME as owner for added files"), GRID+1 }, {"group", GROUP_OPTION, N_("NAME"), 0, @@ -483,6 +493,14 @@ static struct argp_option options[] = { {"preserve-order", 's', 0, 0, N_("sort names to extract to match archive"), GRID+1 }, {"same-order", 0, 0, OPTION_ALIAS, NULL, GRID+1 }, + {"selinux", SELINUX_CONTEXT_OPTION, 0, 0, + N_("Save the SELinux context to the archive"), GRID+1 }, + {"no-selinux", NO_SELINUX_CONTEXT_OPTION, 0, 0, + N_("Don't extract the SELinux context from the archive"), GRID+1 }, + {"xattrs", XATTR_OPTION, 0, 0, + N_("Save the user/root xattrs to the archive"), GRID+1 }, + {"no-xattrs", NO_XATTR_OPTION, 0, 0, + N_("Don't extract the user/root xattrs from the archive"), GRID+1 }, {"preserve", PRESERVE_OPTION, 0, 0, N_("same as both -p and -s"), GRID+1 }, {"delay-directory-restore", DELAY_DIRECTORY_RESTORE_OPTION, 0, 0, @@ -668,7 +686,7 @@ static struct argp_option options[] = { {"no-ignore-case", NO_IGNORE_CASE_OPTION, 0, 0, N_("case sensitive matching (default)"), GRID+1 }, {"wildcards", WILDCARDS_OPTION, 0, 0, - N_("use wildcards (default for exclusion)"), GRID+1 }, + N_("use wildcards (default)"), GRID+1 }, {"no-wildcards", NO_WILDCARDS_OPTION, 0, 0, N_("verbatim string matching"), GRID+1 }, {"no-wildcards-match-slash", NO_WILDCARDS_MATCH_SLASH_OPTION, 0, 0, @@ -762,8 +780,7 @@ ARGMATCH_VERIFY (atime_preserve_args, atime_preserve_types); /* Wildcard matching settings */ enum wildcards { - default_wildcards, /* For exclusion == enable_wildcards, - for inclusion == disable_wildcards */ + default_wildcards, /* enable_wildcards */ disable_wildcards, enable_wildcards }; @@ -791,7 +808,7 @@ struct tar_args /* Variables used during option parsing */ | recursion_option) #define MAKE_INCL_OPTIONS(args) \ - ((((args)->wildcards == enable_wildcards) ? EXCLUDE_WILDCARDS : 0) \ + ((((args)->wildcards != disable_wildcards) ? EXCLUDE_WILDCARDS : 0) \ | (args)->include_anchored \ | (args)->matching_flags \ | recursion_option) @@ -1805,6 +1822,37 @@ parse_opt (int key, char *arg, struct argp_state *state) same_permissions_option = -1; break; + case ACLS_OPTION: + set_archive_format ("posix"); + acls_option = 1; + break; + + case NO_ACLS_OPTION: + acls_option = -1; + break; + + case SELINUX_CONTEXT_OPTION: + set_archive_format ("posix"); + selinux_context_option = 1; + break; + + case NO_SELINUX_CONTEXT_OPTION: + selinux_context_option = -1; + break; + + case XATTR_OPTION: + set_archive_format ("posix"); + if (!acls_option) acls_option = 1; + if (!selinux_context_option) selinux_context_option = 1; + xattrs_option = 1; + break; + + case NO_XATTR_OPTION: + if (!acls_option) acls_option = -1; + if (!selinux_context_option) selinux_context_option = -1; + xattrs_option = -1; + break; + case RECURSION_OPTION: recursion_option = FNM_LEADING_DIR; break; @@ -2077,7 +2125,7 @@ decode_options (int argc, char **argv) /* Warn about implicit use of the wildcards in command line arguments. See TODO */ - warn_regex_usage = args.wildcards == default_wildcards; + warn_regex_usage = 0; //args.wildcards == default_wildcards; /* Derive option values and check option consistency. */ @@ -2200,6 +2248,29 @@ decode_options (int argc, char **argv) || subcommand_option != LIST_SUBCOMMAND)) USAGE_ERROR ((0, 0, _("--pax-option can be used only on POSIX archives"))); + /* star create's non-POSIX typed archives with xattr support, so allow the + extra headers */ + if ((acls_option > 0) + && archive_format != POSIX_FORMAT + && (subcommand_option != EXTRACT_SUBCOMMAND + || subcommand_option != DIFF_SUBCOMMAND + || subcommand_option != LIST_SUBCOMMAND)) + USAGE_ERROR ((0, 0, _("--acls can be used only on POSIX archives"))); + + if ((selinux_context_option > 0) + && archive_format != POSIX_FORMAT + && (subcommand_option != EXTRACT_SUBCOMMAND + || subcommand_option != DIFF_SUBCOMMAND + || subcommand_option != LIST_SUBCOMMAND)) + USAGE_ERROR ((0, 0, _("--selinux can be used only on POSIX archives"))); + + if ((xattrs_option > 0) + && archive_format != POSIX_FORMAT + && (subcommand_option != EXTRACT_SUBCOMMAND + || subcommand_option != DIFF_SUBCOMMAND + || subcommand_option != LIST_SUBCOMMAND)) + USAGE_ERROR ((0, 0, _("--xattrs can be used only on POSIX archives"))); + /* If ready to unlink hierarchies, so we are for simpler files. */ if (recursive_unlink_option) old_files_option = UNLINK_FIRST_OLD_FILES; @@ -2401,11 +2472,15 @@ tar_stat_init (struct tar_stat_info *st) void tar_stat_destroy (struct tar_stat_info *st) { + xheader_xattr_free (st->xattr_map, st->xattr_map_size); free (st->orig_file_name); free (st->file_name); free (st->link_name); free (st->uname); free (st->gname); + free (st->cntx_name); + free (st->acls_a_ptr); + free (st->acls_d_ptr); free (st->sparse_map); free (st->dumpdir); xheader_destroy (&st->xhdr); |