[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Bug-tar] GNUTYPE_NAMES dangerous
From: |
Sergey Poznyakoff |
Subject: |
Re: [Bug-tar] GNUTYPE_NAMES dangerous |
Date: |
Thu, 30 Nov 2006 11:47:56 +0200 |
Paul Eggert <address@hidden> wrote:
> To implement Sergey's suggestion to remove mangle.c, I installed the
> following patch against the main CVS branch of GNU tar.
Thank you.
> Sergey, if you see anything wrong with this please let me know.
It's ok, except that you've forgotten to remove mangle.c from
POTFILES.in. I have fixed this in repository.
> Also, I'd be inclined to generate a new official release soon. Shall we
> just increment the version number (to 1.16.1, say?) and ship CVS head?
Yes, these are minor changes so 1.16.1 is OK. I will need a week or so
to flush my local changes. In the meantime, I have installed the
following patch:
2006-11-30 Sergey Poznyakoff <address@hidden>
* po/POTFILES.in: Remove src/mangle.c
* bootstrap: Implement --update-po option and .bootstrap
local config file.
* src/create.c (dump_dir0): Implement --exclude-tag option
* src/tar.c: Likewise
* doc/tar.texi (exclude): Document --exclude-tag
Index: bootstrap
===================================================================
RCS file: /cvsroot/tar/tar/bootstrap,v
retrieving revision 1.49
diff -p -u -r1.49 bootstrap
--- bootstrap 30 Nov 2006 00:14:10 -0000 1.49
+++ bootstrap 30 Nov 2006 09:19:47 -0000
@@ -49,12 +49,18 @@ Options:
--force Attempt to bootstrap even if the sources seem
not to have been checked out.
--skip-po Do not download po files.
+ --update-po[=LANG] Update po file(s) and exit.
--cvs-user=USERNAME Set the CVS username to be used when accessing
the gnulib repository.
-If the file .bootstrap.conf exists in the current working directory, its
+If the file bootstrap.conf exists in the current working directory, its
contents are read as shell variables to configure the bootstrap.
+Local defaults can be provided by placing the file \`.bootstrap' in the
+current working directory. The file is read after bootstrap.conf, comments
+and empty lines are removed, shell variables expanded and the result is
+prepended to the command line options.
+
Running without arguments will suffice in most cases.
"
}
@@ -159,6 +165,12 @@ copy=false
# Override the default configuration, if necessary.
test -r bootstrap.conf && . ./bootstrap.conf
+# Read local configuration file
+if [ -r .bootstrap ]; then
+ echo "$0: Reading configuration file .bootstrap"
+ eval set -- "`sed 's/#.*$//;/^$/d' .bootstrap | tr '\n' ' '` $*"
+fi
+
# Translate configuration into internal form.
# Parse options.
@@ -176,7 +188,11 @@ do
--cvs-user=*)
CVS_USER=`expr "$option" : '--cvs-user=\(.*\)'`;;
--skip-po | --no-po) # --no-po is for compatibility with 'tar' tradition.
- SKIP_PO=t;;
+ DOWNLOAD_PO=skip;;
+ --update-po=*)
+ DOWNLOAD_PO=`expr "$option" : '--update-po=\(.*\)'`;;
+ --update-po)
+ DOWNLOAD_PO=only;;
--force)
CVS_only_file=;;
--copy)
@@ -194,6 +210,80 @@ fi
echo "$0: Bootstrapping CVS $package..."
+# Get translations.
+
+get_translations() {
+ subdir=$1
+ domain=$2
+ po_file=$3
+
+ case $WGET_COMMAND in
+ '')
+ echo "$0: wget not available; skipping translations";;
+ ?*)
+ echo "$0: getting ${po_file:-translations} into $subdir for $domain..." &&
+ case $po_file in
+ '') (cd $subdir && rm -f dummy `ls | sed -n '/\.gmo$/p; /\.po/p'`);;
+ esac &&
+
+ $WGET_COMMAND -O "$subdir/$domain.html" "$TP_URL$domain" &&
+
+ sed -n
's|.*"http://[^"]*/translation/teams/PO/\([^/"]*\)/'"$domain"'-\([^/"]*\)\.[^."]*\.po".*|\1.\2|p'
<"$subdir/$domain.html" |
+ sort -k 1,1 -k 2,2n -k2,2 -k3,3n -k3,3 -k4,4n -k4,4 -k5,5n -k5.5 |
+ awk -F. '
+ { if (lang && $1 != lang) print lang, ver }
+ { lang = $1; ver = substr($0, index($0, ".") + 1) }
+ END { if (lang) print lang, ver }
+ ' | awk -v domain="$domain" -v po_file="$po_file" -v subdir="$subdir" '
+ {
+ lang = $1
+ if (po_file && po_file != (lang ".po")) next
+
+ ver = $2
+ urlfmt = ""
+ printf "{ $WGET_COMMAND -O %s/%s.po '\'"$TP_PO_URL"'/%s/%s-%s.%s.po'\''
&&\n", subdir, lang, lang, domain, ver, lang
+ printf " msgfmt -c -o /dev/null %s/%s.po || {\n", subdir, lang
+ printf " echo >&2 '\'"$0"': omitting translation for %s'\''\n", lang
+ printf " rm -f %s/%s.po; }; } &&\n", subdir, lang
+ }
+ END { print ":" }
+ ' | WGET_COMMAND="$WGET_COMMAND" sh;;
+ esac &&
+ ls "$subdir"/*.po 2>/dev/null |
+ sed 's|.*/||; s|\.po$||' >"$subdir/LINGUAS" &&
+ rm -f "$subdir/$domain.html"
+}
+
+case `wget --help` in
+*'--no-cache'*)
+ WGET_COMMAND='wget -nv --no-cache';;
+*'--cache=on/off'*)
+ WGET_COMMAND='wget -nv --cache=off';;
+*'--non-verbose'*)
+ WGET_COMMAND='wget -nv';;
+*)
+ WGET_COMMAND='';;
+esac
+
+case $DOWNLOAD_PO in
+'skip')
+ ;;
+'')
+ get_translations po $package || exit
+ ;;
+'only')
+ get_translations po $package
+ exit
+ ;;
+*.po)
+ get_translations po $package "$DOWNLOAD_PO"
+ exit
+ ;;
+*)
+ get_translations po $package "${DOWNLOAD_PO}.po"
+ exit
+esac
+
# Get paxutils files.
case ${PAXUTILS_SRCDIR--} in
@@ -259,65 +349,6 @@ esac
gnulib_tool=$GNULIB_SRCDIR/gnulib-tool
<$gnulib_tool || exit
-# Get translations.
-
-get_translations() {
- subdir=$1
- domain=$2
-
- case $WGET_COMMAND in
- '')
- echo "$0: wget not available; skipping translations";;
- ?*)
- echo "$0: getting translations into $subdir for $domain..." &&
-
- (cd $subdir && rm -f dummy `ls | sed -n '/\.gmo$/p; /\.po/p'`) &&
- $WGET_COMMAND -O "$subdir/$domain.html" "$TP_URL$domain" &&
-
- sed -n
's|.*"http://[^"]*/translation/teams/PO/\([^/"]*\)/'"$domain"'-\([^/"]*\)\.[^."]*\.po".*|\1.\2|p'
<"$subdir/$domain.html" |
- sort -k 1,1 -k 2,2n -k2,2 -k3,3n -k3,3 -k4,4n -k4,4 -k5,5n -k5.5 |
- awk -F. '
- { if (lang && $1 != lang) print lang, ver }
- { lang = $1; ver = substr($0, index($0, ".") + 1) }
- END { if (lang) print lang, ver }
- ' | awk -v domain="$domain" -v subdir="$subdir" '
- {
- lang = $1
- ver = $2
- urlfmt = ""
- printf "{ $WGET_COMMAND -O %s/%s.po '\'"$TP_PO_URL"'/%s/%s-%s.%s.po'\''
&&\n", subdir, lang, lang, domain, ver, lang
- printf " msgfmt -c -o /dev/null %s/%s.po || {\n", subdir, lang
- printf " echo >&2 '\'"$0"': omitting translation for %s'\''\n", lang
- printf " rm -f %s/%s.po; }; } &&\n", subdir, lang
- }
- END { print ":" }
- ' | WGET_COMMAND="$WGET_COMMAND" sh;;
- esac &&
- ls "$subdir"/*.po 2>/dev/null |
- sed 's|.*/||; s|\.po$||' >"$subdir/LINGUAS" &&
- rm -f "$subdir/$domain.html"
-}
-
-case $SKIP_PO in
-'')
- case `wget --help` in
- *'--no-cache'*)
- WGET_COMMAND='wget -nv --no-cache';;
- *'--cache=on/off'*)
- WGET_COMMAND='wget -nv --cache=off';;
- *'--non-verbose'*)
- WGET_COMMAND='wget -nv';;
- *)
- WGET_COMMAND='';;
- esac
-
- get_translations po $package || exit
-
- if test -d runtime-po; then
- get_translations runtime-po $package-runtime || exit
- fi;;
-esac
-
symlink_to_gnulib()
{
src=$GNULIB_SRCDIR/$1
Index: doc/tar.texi
===================================================================
RCS file: /cvsroot/tar/tar/doc/tar.texi,v
retrieving revision 1.124
diff -p -u -r1.124 tar.texi
--- doc/tar.texi 30 Nov 2006 06:39:29 -0000 1.124
+++ doc/tar.texi 30 Nov 2006 09:20:58 -0000
@@ -2505,6 +2505,11 @@ patterns in the file @var{file}. @xref{
Automatically excludes all directories
containing a cache directory tag. @xref{exclude}.
address@hidden
address@hidden address@hidden
+
+Exclude all directories, containing file named @var{file}. @xref{exclude}.
+
@opsummary{file}
@item address@hidden
@itemx -f @var{archive}
@@ -6481,6 +6486,43 @@ Various applications write cache directo
use to hold regenerable, non-precious data, so that such data can be
more easily excluded from backups.
address@hidden exclude-tag
+Another option, @option{--exclude-tag}, provides a generalization of
+this concept. It takes a single argument, a file name to look for.
+Any directory that contains this file will be excluded from the dump.
+
address@hidden @option
address@hidden exclude-tag
address@hidden address@hidden
+Causes @command{tar} to ignore directories containing @var{file}.
address@hidden table
+
+You can specify as many exclusion tags as you like.
+
+Notice, that when speaking about ``excluding the directory'' we mean
+that the files and subdirectories it contains will not get into the
+archive, while the entry for the directory itself will, e.g.:
+
address@hidden
+$ @kbd{find dir}
+dir
+dir/blues
+dir/jazz
+dir/folk
+dir/folk/tagfile
+$ @kbd{tar -cf archive.tar --extract-tag=tagfile -v}
+dir/
+dir/blues
+dir/jazz
+dir/folk/
+./tar: dir/folk/: contains a cache directory tag tagfile; not dumped
+$ @kbd{tar -tf archive.tar}
+dir/
+dir/blues
+dir/jazz
+dir/folk/
address@hidden smallexample
+
@menu
* problems with exclude::
@end menu
Index: lib/.cvsignore
===================================================================
RCS file: /cvsroot/tar/tar/lib/.cvsignore,v
retrieving revision 1.41
diff -p -u -r1.41 .cvsignore
--- lib/.cvsignore 30 Nov 2006 06:27:24 -0000 1.41
+++ lib/.cvsignore 30 Nov 2006 09:20:58 -0000
@@ -135,6 +135,7 @@ paxnames.c
pipe-safer.c
printf-args.c
printf-args.h
+printf-parse.c
printf-parse.h
quote.c
quote.h
@@ -215,6 +216,7 @@ unsetenv.c
utime.c
utimens.c
utimens.h
+vasnprintf.c
vasnprintf.h
verify.h
version-etc-fsf.c
Index: m4/.cvsignore
===================================================================
RCS file: /cvsroot/tar/tar/m4/.cvsignore,v
retrieving revision 1.17
diff -p -u -r1.17 .cvsignore
--- m4/.cvsignore 1 Feb 2005 05:51:24 -0000 1.17
+++ m4/.cvsignore 30 Nov 2006 09:20:58 -0000
@@ -1,3 +1,135 @@
+*.m4
Makefile
Makefile.in
-*.m4
+absolute-header.m4
+alloca.m4
+allocsa.m4
+argmatch.m4
+argp.m4
+backupfile.m4
+bison.m4
+chdir-long.m4
+chown.m4
+clock_time.m4
+close-stream.m4
+closeout.m4
+codeset.m4
+d-ino.m4
+dirname.m4
+dos.m4
+double-slash-root.m4
+eealloc.m4
+eoverflow.m4
+error.m4
+exclude.m4
+exitfail.m4
+extensions.m4
+fcntl-safer.m4
+fcntl_h.m4
+fileblocks.m4
+fnmatch.m4
+fpending.m4
+ftruncate.m4
+getcwd-abort-bug.m4
+getcwd-path-max.m4
+getcwd.m4
+getdate.m4
+getdelim.m4
+getline.m4
+getopt.m4
+getpagesize.m4
+gettext.m4
+gettime.m4
+gettimeofday.m4
+glibc21.m4
+gnulib-cache.m4
+gnulib-comp.m4
+gnulib-tool.m4
+hash.m4
+human.m4
+iconv.m4
+inline.m4
+intl.m4
+intldir.m4
+intmax.m4
+intmax_t.m4
+inttostr.m4
+inttypes-pri.m4
+inttypes.m4
+inttypes_h.m4
+lchown.m4
+lib-ld.m4
+lib-link.m4
+lib-prefix.m4
+localcharset.m4
+longdouble.m4
+longlong.m4
+lstat.m4
+mbchar.m4
+mbiter.m4
+mbrtowc.m4
+mbstate_t.m4
+memchr.m4
+mempcpy.m4
+memrchr.m4
+memset.m4
+minmax.m4
+mkdtemp.m4
+mktime.m4
+modechange.m4
+nls.m4
+openat.m4
+po.m4
+progtest.m4
+quote.m4
+quotearg.m4
+regex.m4
+rmdir.m4
+rpmatch.m4
+safe-read.m4
+safe-write.m4
+save-cwd.m4
+savedir.m4
+setenv.m4
+ssize_t.m4
+stat-time.m4
+stdarg.m4
+stdbool.m4
+stdint.m4
+stdint_h.m4
+stpcpy.m4
+strcase.m4
+strchrnul.m4
+strdup.m4
+strndup.m4
+strnlen.m4
+strtoimax.m4
+strtol.m4
+strtoll.m4
+strtoul.m4
+strtoull.m4
+strtoumax.m4
+sys_stat_h.m4
+sysexits.m4
+tempname.m4
+time_r.m4
+timespec.m4
+tm_gmtoff.m4
+unistd-safer.m4
+unistd_h.m4
+unlinkdir.m4
+unlocked-io.m4
+utimbuf.m4
+utime.m4
+utimens.m4
+utimes-null.m4
+utimes.m4
+vasnprintf.m4
+vsnprintf.m4
+wchar_t.m4
+wcwidth.m4
+wint_t.m4
+xalloc.m4
+xgetcwd.m4
+xstrndup.m4
+xstrtol.m4
Index: src/create.c
===================================================================
RCS file: /cvsroot/tar/tar/src/create.c,v
retrieving revision 1.121
diff -p -u -r1.121 create.c
--- src/create.c 13 Nov 2006 10:39:51 -0000 1.121
+++ src/create.c 30 Nov 2006 09:21:06 -0000
@@ -33,6 +33,65 @@ struct link
size_t nlink;
char name[1];
};
+
+struct exclude_tag
+{
+ const char *name;
+ size_t length;
+ struct exclude_tag *next;
+};
+
+static struct exclude_tag *exclude_tags;
+
+void
+add_exclude_tag (const char *name)
+{
+ struct exclude_tag *tag = xmalloc (sizeof tag[0]);
+ tag->next = exclude_tags;
+ tag->name = name;
+ tag->length = strlen (name);
+ exclude_tags = tag;
+}
+
+static bool
+check_exclude_tags (char *dirname)
+{
+ static char *tagname;
+ static size_t tagsize;
+ struct exclude_tag *tag;
+ size_t dlen = strlen (dirname);
+ char *nptr = NULL;
+ char *ret = NULL;
+
+ for (tag = exclude_tags; tag; tag = tag->next)
+ {
+ size_t size = dlen + tag->length + 1;
+ if (size > tagsize)
+ {
+ tagsize = size;
+ tagname = xrealloc (tagname, tagsize);
+ }
+
+ if (!nptr)
+ {
+ strcpy (tagname, dirname);
+ nptr = tagname + dlen;
+ }
+ strcpy (nptr, tag->name);
+ if (access (tagname, F_OK) == 0)
+ {
+ if (verbose_option)
+ WARN ((0, 0,
+ _("%s: contains a cache directory tag %s; not dumped"),
+ quotearg_colon (dirname),
+ quotearg_n (1, tag->name)));
+ return true;
+ }
+ }
+
+ return false;
+}
+
/* The maximum uintmax_t value that can be represented with DIGITS digits,
assuming that each digit is BITS_PER_DIGIT wide. */
@@ -983,6 +1042,7 @@ dump_regular_file (int fd, struct tar_st
return dump_status_ok;
}
+
/* Look in directory DIRNAME for a cache directory tag file
with the magic name "CACHEDIR.TAG" and a standard header,
as described at:
@@ -1000,7 +1060,7 @@ check_cache_directory (char *dirname)
static char tagname[] = "CACHEDIR.TAG";
char *tagpath;
int fd;
- int tag_present = false;
+ bool tag_present = false;
tagpath = xmalloc (strlen (dirname) + strlen (tagname) + 1);
strcpy (tagpath, dirname);
@@ -1124,6 +1184,9 @@ dump_dir0 (char *directory,
return;
}
+ if (check_exclude_tags (st->orig_file_name))
+ return;
+
{
char const *entry;
size_t entry_len;
Index: src/tar.c
===================================================================
RCS file: /cvsroot/tar/tar/src/tar.c,v
retrieving revision 1.162
diff -p -u -r1.162 tar.c
--- src/tar.c 30 Nov 2006 00:14:11 -0000 1.162
+++ src/tar.c 30 Nov 2006 09:21:19 -0000
@@ -255,6 +255,7 @@ enum
DELETE_OPTION,
EXCLUDE_CACHES_OPTION,
EXCLUDE_OPTION,
+ EXCLUDE_TAG_OPTION,
FORCE_LOCAL_OPTION,
GROUP_OPTION,
HANG_OPTION,
@@ -604,6 +605,8 @@ static struct argp_option options[] = {
N_("exclude patterns listed in FILE"), GRID+1 },
{"exclude-caches", EXCLUDE_CACHES_OPTION, 0, 0,
N_("exclude directories containing a cache tag"), GRID+1 },
+ {"exclude-tag", EXCLUDE_TAG_OPTION, N_("FILE"), 0,
+ N_("exclude directories containing FILE"), GRID+1 },
{"no-recursion", NO_RECURSION_OPTION, 0, 0,
N_("avoid descending automatically in directories"), GRID+1 },
{"one-file-system", ONE_FILE_SYSTEM_OPTION, 0, 0,
@@ -1507,6 +1510,10 @@ parse_opt (int key, char *arg, struct ar
exclude_caches_option = true;
break;
+ case EXCLUDE_TAG_OPTION:
+ add_exclude_tag (arg);
+ break;
+
case FORCE_LOCAL_OPTION:
force_local_option = true;
break;
Regards,
Sergey
- [Bug-tar] GNUTYPE_NAMES dangerous, Kees Cook, 2006/11/24
- Re: [Bug-tar] GNUTYPE_NAMES dangerous, Sergey Poznyakoff, 2006/11/24
- Re: [Bug-tar] GNUTYPE_NAMES dangerous, Paul Eggert, 2006/11/24
- Re: [Bug-tar] GNUTYPE_NAMES dangerous, Albert Chin, 2006/11/29
- Re: [Bug-tar] GNUTYPE_NAMES dangerous, Kees Cook, 2006/11/29
- Re: [Bug-tar] GNUTYPE_NAMES dangerous, Paul Eggert, 2006/11/30
- Re: [Bug-tar] GNUTYPE_NAMES dangerous,
Sergey Poznyakoff <=
- Re: [Bug-tar] GNUTYPE_NAMES dangerous, Paul Eggert, 2006/11/30
- Re: [Bug-tar] GNUTYPE_NAMES dangerous, Sergey Poznyakoff, 2006/11/30