mirror of
https://git.savannah.gnu.org/git/coreutils.git
synced 2025-09-10 07:59:52 +02:00
Compare commits
196 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
447d245551 | ||
|
|
fee722471c | ||
|
|
630f4ba107 | ||
|
|
2fccfaab19 | ||
|
|
2b18a4c138 | ||
|
|
6609ccbf87 | ||
|
|
d863533752 | ||
|
|
bf5af9aef8 | ||
|
|
161e5120d4 | ||
|
|
3b997a9bcb | ||
|
|
00f0cabaec | ||
|
|
5cf6fb3b12 | ||
|
|
9ed5048148 | ||
|
|
c3744b25f2 | ||
|
|
49741b61b7 | ||
|
|
9a91b2a928 | ||
|
|
4c9e7e01fa | ||
|
|
6a31fd8d73 | ||
|
|
719a95aa9d | ||
|
|
1313107c5c | ||
|
|
cf1bc9810d | ||
|
|
622cf39be6 | ||
|
|
3aff3ed137 | ||
|
|
10d97b3191 | ||
|
|
56b85e035b | ||
|
|
c768e2231b | ||
|
|
9a8d8f46a5 | ||
|
|
d9dbbb9a45 | ||
|
|
74cf4cb26d | ||
|
|
41456fac8a | ||
|
|
dde83c27b4 | ||
|
|
20e5a0d562 | ||
|
|
22e4276ed1 | ||
|
|
25d2460ae3 | ||
|
|
31a9937081 | ||
|
|
d431c61873 | ||
|
|
5f29d118df | ||
|
|
0c5ae3a8ac | ||
|
|
e89a5e9b13 | ||
|
|
bcca26e838 | ||
|
|
41b3a8ed8b | ||
|
|
cd65f11c4f | ||
|
|
8ba5d1a70c | ||
|
|
38cb824673 | ||
|
|
d4b96c26ce | ||
|
|
7bf2e3db23 | ||
|
|
87bf834dd3 | ||
|
|
8fe40b84bd | ||
|
|
565e5f6827 | ||
|
|
6eb457eaba | ||
|
|
a276ba2dd4 | ||
|
|
71c2f88155 | ||
|
|
3c88587b2e | ||
|
|
12a0a583f6 | ||
|
|
39da66f979 | ||
|
|
22776f84cb | ||
|
|
17b7d09bf2 | ||
|
|
f2859424cb | ||
|
|
56a66d78ff | ||
|
|
e26cb21e6b | ||
|
|
1c59bb3cef | ||
|
|
536a1fbe5f | ||
|
|
ce22916610 | ||
|
|
da17f99b20 | ||
|
|
c07b181396 | ||
|
|
2904d675a4 | ||
|
|
54491d2751 | ||
|
|
42d12b45d3 | ||
|
|
75efc921b0 | ||
|
|
d6de2f198e | ||
|
|
1a81342089 | ||
|
|
0cc0424119 | ||
|
|
f00bbe33e4 | ||
|
|
0f3f6bf6bf | ||
|
|
243f1b1c71 | ||
|
|
c6900474ef | ||
|
|
dae24f5ffc | ||
|
|
c695781753 | ||
|
|
d9cf7c911f | ||
|
|
50e837b1c4 | ||
|
|
501bf7b589 | ||
|
|
69fbfd400c | ||
|
|
30e4b6e84b | ||
|
|
2122247aca | ||
|
|
bd933c1250 | ||
|
|
1ce9e1e5ca | ||
|
|
b6540b96ba | ||
|
|
97777f559a | ||
|
|
c0dcf3238b | ||
|
|
a08e13a0fb | ||
|
|
5e361387d0 | ||
|
|
cbf36952d8 | ||
|
|
029b6b14c5 | ||
|
|
cd0f3036f6 | ||
|
|
9abbe32c2e | ||
|
|
54645c195c | ||
|
|
710fe413fe | ||
|
|
71adb516de | ||
|
|
6ac6c7e4b7 | ||
|
|
f26508204b | ||
|
|
9e13b6a0b4 | ||
|
|
527fb951de | ||
|
|
f8653f2af3 | ||
|
|
2fa407885c | ||
|
|
b3cfa712ca | ||
|
|
f25273d7f1 | ||
|
|
26e8e602a8 | ||
|
|
7280a913a1 | ||
|
|
7ff00ca82f | ||
|
|
f7b1873805 | ||
|
|
c2bebf63ed | ||
|
|
d74a1b005c | ||
|
|
4f1a3eda10 | ||
|
|
c9e7b8844b | ||
|
|
219f2f0538 | ||
|
|
78c9360178 | ||
|
|
0023f65fd7 | ||
|
|
57d9263ca5 | ||
|
|
e11a0319b3 | ||
|
|
c039c96449 | ||
|
|
aa092ccf6a | ||
|
|
2a876d901d | ||
|
|
a797c4d7d3 | ||
|
|
7a3bc1bf27 | ||
|
|
00674c7475 | ||
|
|
eb5f06f2a6 | ||
|
|
8e32390716 | ||
|
|
b95be30e3f | ||
|
|
d183a15cbb | ||
|
|
96829a9ff0 | ||
|
|
ca1e31f3c5 | ||
|
|
3c40fdfba6 | ||
|
|
3a97d664b9 | ||
|
|
addb62da92 | ||
|
|
569df689e3 | ||
|
|
df0c0381ab | ||
|
|
f8726e05c4 | ||
|
|
95c01c656e | ||
|
|
8a7f66feb4 | ||
|
|
30a227673e | ||
|
|
dd8db19cc7 | ||
|
|
569e387b8a | ||
|
|
9ca7d6b49e | ||
|
|
d4c7114bce | ||
|
|
ce1069c215 | ||
|
|
a033e28737 | ||
|
|
b7aaa0da8b | ||
|
|
36edf7bad2 | ||
|
|
242689c7f9 | ||
|
|
30c65cd49c | ||
|
|
ca9e212cf8 | ||
|
|
efcee783e4 | ||
|
|
fb59d72f0a | ||
|
|
a037e838e1 | ||
|
|
ade8dd2096 | ||
|
|
0cce690850 | ||
|
|
82124c3c06 | ||
|
|
38f1c2006e | ||
|
|
8a1edc971f | ||
|
|
70253e9179 | ||
|
|
b18b6912e8 | ||
|
|
fbfca3c675 | ||
|
|
7a404d10f5 | ||
|
|
8c92bb3441 | ||
|
|
32f987af12 | ||
|
|
fee8694886 | ||
|
|
3a169f4c5d | ||
|
|
29ec834c3b | ||
|
|
9837344837 | ||
|
|
5d4f09d83a | ||
|
|
c48003a53c | ||
|
|
a2883947bc | ||
|
|
99f59aaaf8 | ||
|
|
6504d7e193 | ||
|
|
2bad8c0dea | ||
|
|
fe6f4e305c | ||
|
|
a77fb35364 | ||
|
|
94eca76776 | ||
|
|
20761ce686 | ||
|
|
df84346ebc | ||
|
|
71bac0dac3 | ||
|
|
d41dbb187f | ||
|
|
cca83fafa6 | ||
|
|
eb1299481a | ||
|
|
255a6a201e | ||
|
|
f6f78f093b | ||
|
|
21b617b78b | ||
|
|
ebbf0a1f0f | ||
|
|
398749b0cc | ||
|
|
e5dba03d2f | ||
|
|
c756343503 | ||
|
|
722287e443 | ||
|
|
9966c92dd4 | ||
|
|
4f73ecaf7d | ||
|
|
880a6e7723 | ||
|
|
bd11475627 |
2
.gitattributes
vendored
2
.gitattributes
vendored
@@ -5,3 +5,5 @@
|
||||
# # Derived from the regexp in emacs' lisp/add-log.el.
|
||||
# [diff "texinfo"]
|
||||
# funcname = "^@node[ \t][ \t]*\\([^,][^,]*\\)"
|
||||
|
||||
gl/lib/*.diff -whitespace
|
||||
|
||||
5
.gitignore
vendored
5
.gitignore
vendored
@@ -3,6 +3,7 @@
|
||||
*.o
|
||||
*/.deps
|
||||
*~
|
||||
._bootmp
|
||||
.gdb-history
|
||||
.kludge-stamp
|
||||
.tarball-version
|
||||
@@ -47,11 +48,13 @@ lib/arpa
|
||||
lib/binary-io.h
|
||||
lib/charset.alias
|
||||
lib/configmake.h
|
||||
lib/glthread
|
||||
lib/libcoreutils.a
|
||||
lib/printf.c
|
||||
lib/progname.c
|
||||
lib/progname.h
|
||||
lib/selinux
|
||||
lib/unistr
|
||||
lib/uniwidth
|
||||
m4/.cvsignore
|
||||
m4/.gitignore
|
||||
@@ -72,3 +75,5 @@ src/version.c
|
||||
src/version.h
|
||||
stamp-h1
|
||||
tests/*/*.log
|
||||
tests/t?
|
||||
tests/test-suite.log
|
||||
|
||||
@@ -1 +1 @@
|
||||
7.5
|
||||
8.0
|
||||
|
||||
3
.x-sc_prohibit_fail_0
Normal file
3
.x-sc_prohibit_fail_0
Normal file
@@ -0,0 +1,3 @@
|
||||
\.mk$
|
||||
/Makefile\.am$
|
||||
^tests/test-lib\.sh$
|
||||
3
.x-sc_prohibit_magic_number_exit
Normal file
3
.x-sc_prohibit_magic_number_exit
Normal file
@@ -0,0 +1,3 @@
|
||||
configure.ac
|
||||
*.m4
|
||||
ChangeLog*
|
||||
@@ -4,3 +4,4 @@ Makefile\.am$
|
||||
^tests/pr/
|
||||
ChangeLog.*
|
||||
^man/help2man$
|
||||
^gl/lib/.*\.c\.diff$
|
||||
|
||||
@@ -9,3 +9,4 @@ m4/lib-prefix.m4
|
||||
m4/po.m4
|
||||
aclocal.m4
|
||||
src/c99-to-c89.diff
|
||||
^gl/lib/.*\.c\.diff$
|
||||
|
||||
3
AUTHORS
3
AUTHORS
@@ -46,11 +46,12 @@ md5sum: Ulrich Drepper, Scott Miller, David Madore
|
||||
mkdir: David MacKenzie
|
||||
mkfifo: David MacKenzie
|
||||
mknod: David MacKenzie
|
||||
mktemp: Jim Meyering
|
||||
mktemp: Jim Meyering, Eric Blake
|
||||
mv: Mike Parker, David MacKenzie, Jim Meyering
|
||||
nice: David MacKenzie
|
||||
nl: Scott Bartram, David MacKenzie
|
||||
nohup: Jim Meyering
|
||||
nproc: Giuseppe Scrivano
|
||||
od: Jim Meyering
|
||||
paste: David M. Ihnat, David MacKenzie
|
||||
pathchk: Paul Eggert, David MacKenzie, Jim Meyering
|
||||
|
||||
@@ -47,6 +47,8 @@ syntax_check_exceptions = \
|
||||
.x-sc_po_check \
|
||||
.x-sc_program_name \
|
||||
.x-sc_prohibit_atoi_atof \
|
||||
.x-sc_prohibit_fail_0 \
|
||||
.x-sc_prohibit_magic_number_exit \
|
||||
.x-sc_prohibit_stat_st_blocks \
|
||||
.x-sc_prohibit_strcmp \
|
||||
.x-sc_prohibit_tab_based_indentation \
|
||||
|
||||
171
NEWS
171
NEWS
@@ -1,5 +1,176 @@
|
||||
GNU coreutils NEWS -*- outline -*-
|
||||
|
||||
* Noteworthy changes in release 8.1 (2009-11-18) [stable]
|
||||
|
||||
** Bug fixes
|
||||
|
||||
chcon no longer exits immediately just because SELinux is disabled.
|
||||
Even then, chcon may still be useful.
|
||||
[bug introduced in coreutils-8.0]
|
||||
|
||||
chcon, chgrp, chmod, chown and du now diagnose an ostensible directory cycle
|
||||
and arrange to exit nonzero. Before, they would silently ignore the
|
||||
offending directory and all "contents."
|
||||
|
||||
env -u A=B now fails, rather than silently adding A to the
|
||||
environment. Likewise, printenv A=B silently ignores the invalid
|
||||
name. [the bugs date back to the initial implementation]
|
||||
|
||||
ls --color now handles files with capabilities correctly. Previously
|
||||
files with capabilities were often not colored, and also sometimes, files
|
||||
without capabilites were colored in error. [bug introduced in coreutils-7.0]
|
||||
|
||||
md5sum now prints checksums atomically so that concurrent
|
||||
processes will not intersperse their output.
|
||||
This also affected sum, sha1sum, sha224sum, sha384sum and sha512sum.
|
||||
[the bug dates back to the initial implementation]
|
||||
|
||||
mktemp no longer leaves a temporary file behind if it was unable to
|
||||
output the name of the file to stdout.
|
||||
[the bug dates back to the initial implementation]
|
||||
|
||||
nice -n -1 PROGRAM now runs PROGRAM even when its internal setpriority
|
||||
call fails with errno == EACCES.
|
||||
[the bug dates back to the initial implementation]
|
||||
|
||||
nice, nohup, and su now refuse to execute the subsidiary program if
|
||||
they detect write failure in printing an otherwise non-fatal warning
|
||||
message to stderr.
|
||||
|
||||
stat -f recognizes more file system types: afs, cifs, anon-inode FS,
|
||||
btrfs, cgroupfs, cramfs-wend, debugfs, futexfs, hfs, inotifyfs, minux3,
|
||||
nilfs, securityfs, selinux, xenfs
|
||||
|
||||
tail -f (inotify-enabled) now avoids a race condition.
|
||||
Before, any data appended in the tiny interval between the initial
|
||||
read-to-EOF and the inotify watch initialization would be ignored
|
||||
initially (until more data was appended), or forever, if the file
|
||||
were first renamed or unlinked or never modified.
|
||||
[The race was introduced in coreutils-7.5]
|
||||
|
||||
tail -F (inotify-enabled) now consistently tails a file that has been
|
||||
replaced via renaming. That operation provokes either of two sequences
|
||||
of inotify events. The less common sequence is now handled as well.
|
||||
[The bug came with the implementation change in coreutils-7.5]
|
||||
|
||||
timeout now doesn't exit unless the command it is monitoring does,
|
||||
for any specified signal. [bug introduced in coreutils-7.0].
|
||||
|
||||
** Changes in behavior
|
||||
|
||||
chroot, env, nice, and su fail with status 125, rather than 1, on
|
||||
internal error such as failure to parse command line arguments; this
|
||||
is for consistency with stdbuf and timeout, and avoids ambiguity
|
||||
with the invoked command failing with status 1. Likewise, nohup
|
||||
fails with status 125 instead of 127.
|
||||
|
||||
du (due to a change in gnulib's fts) can now traverse NFSv4 automounted
|
||||
directories in which the stat'd device number of the mount point differs
|
||||
during a traversal. Before, it would fail, because such a mismatch would
|
||||
usually represent a serious error or a subversion attempt.
|
||||
|
||||
echo and printf now interpret \e as the Escape character (0x1B).
|
||||
|
||||
rm -f /read-only-fs/nonexistent now succeeds and prints no diagnostic
|
||||
on systems with an unlinkat syscall that sets errno to EROFS in that case.
|
||||
Before, it would fail with a "Read-only file system" diagnostic.
|
||||
Also, "rm /read-only-fs/nonexistent" now reports "file not found" rather
|
||||
than the less precise "Read-only file system" error.
|
||||
|
||||
** New programs
|
||||
|
||||
nproc: Print the number of processing units available to a process.
|
||||
|
||||
** New features
|
||||
|
||||
env and printenv now accept the option --null (-0), as a means to
|
||||
avoid ambiguity with newlines embedded in the environment.
|
||||
|
||||
md5sum --check now also accepts openssl-style checksums.
|
||||
So do sha1sum, sha224sum, sha384sum and sha512sum.
|
||||
|
||||
mktemp now accepts the option --suffix to provide a known suffix
|
||||
after the substitution in the template. Additionally, uses such as
|
||||
"mktemp fileXXXXXX.txt" are able to infer an appropriate --suffix.
|
||||
|
||||
touch now accepts the option --no-dereference (-h), as a means to
|
||||
change symlink timestamps on platforms with enough support.
|
||||
|
||||
|
||||
* Noteworthy changes in release 8.0 (2009-10-06) [beta]
|
||||
|
||||
** Bug fixes
|
||||
|
||||
cp --preserve=xattr and --archive now preserve extended attributes even
|
||||
when the source file doesn't have write access.
|
||||
[bug introduced in coreutils-7.1]
|
||||
|
||||
touch -t [[CC]YY]MMDDhhmm[.ss] now accepts a timestamp string ending in .60,
|
||||
to accommodate leap seconds.
|
||||
[the bug dates back to the initial implementation]
|
||||
|
||||
ls --color now reverts to the color of a base file type consistently
|
||||
when the color of a more specific type is disabled.
|
||||
[bug introduced in coreutils-5.90]
|
||||
|
||||
ls -LR exits with status 2, not 0, when it encounters a cycle
|
||||
|
||||
ls -is is now consistent with ls -lis in ignoring values returned
|
||||
from a failed stat/lstat. For example ls -Lis now prints "?", not "0",
|
||||
for the inode number and allocated size of a dereferenced dangling symlink.
|
||||
|
||||
tail --follow --pid now avoids a race condition where data written
|
||||
just before the process dies might not have been output by tail.
|
||||
Also, tail no longer delays at all when the specified pid is not live.
|
||||
[The race was introduced in coreutils-7.5,
|
||||
and the unnecessary delay was present since textutils-1.22o]
|
||||
|
||||
** Portability
|
||||
|
||||
On Solaris 9, many commands would mistakenly treat file/ the same as
|
||||
file. Now, even on such a system, path resolution obeys the POSIX
|
||||
rules that a trailing slash ensures that the preceeding name is a
|
||||
directory or a symlink to a directory.
|
||||
|
||||
** Changes in behavior
|
||||
|
||||
id no longer prints SELinux " context=..." when the POSIXLY_CORRECT
|
||||
environment variable is set.
|
||||
|
||||
readlink -f now ignores a trailing slash when deciding if the
|
||||
last component (possibly via a dangling symlink) can be created,
|
||||
since mkdir will succeed in that case.
|
||||
|
||||
** New features
|
||||
|
||||
ln now accepts the options --logical (-L) and --physical (-P),
|
||||
added by POSIX 2008. The default behavior is -P on systems like
|
||||
GNU/Linux where link(2) creates hard links to symlinks, and -L on
|
||||
BSD systems where link(2) follows symlinks.
|
||||
|
||||
stat: without -f, a command-line argument of "-" now means standard input.
|
||||
With --file-system (-f), an argument of "-" is now rejected.
|
||||
If you really must operate on a file named "-", specify it as
|
||||
"./-" or use "--" to separate options from arguments.
|
||||
|
||||
** Improvements
|
||||
|
||||
rm: rewrite to use gnulib's fts
|
||||
This makes rm -rf significantly faster (400-500%) in some pathological
|
||||
cases, and slightly slower (20%) in at least one pathological case.
|
||||
|
||||
rm -r deletes deep hierarchies more efficiently. Before, execution time
|
||||
was quadratic in the depth of the hierarchy, now it is merely linear.
|
||||
However, this improvement is not as pronounced as might be expected for
|
||||
very deep trees, because prior to this change, for any relative name
|
||||
length longer than 8KiB, rm -r would sacrifice official conformance to
|
||||
avoid the disproportionate quadratic performance penalty. Leading to
|
||||
another improvement:
|
||||
|
||||
rm -r is now slightly more standards-conformant when operating on
|
||||
write-protected files with relative names longer than 8KiB.
|
||||
|
||||
|
||||
* Noteworthy changes in release 7.6 (2009-09-11) [stable]
|
||||
|
||||
** Bug fixes
|
||||
|
||||
2
README
2
README
@@ -11,7 +11,7 @@ The programs that can be built with this package are:
|
||||
csplit cut date dd df dir dircolors dirname du echo env expand expr
|
||||
factor false fmt fold groups head hostid hostname id install join kill
|
||||
link ln logname ls md5sum mkdir mkfifo mknod mktemp mv nice nl nohup
|
||||
od paste pathchk pinky pr printenv printf ptx pwd readlink rm rmdir
|
||||
nproc od paste pathchk pinky pr printenv printf ptx pwd readlink rm rmdir
|
||||
runcon seq sha1sum sha224sum sha256sum sha384sum sha512sum shred shuf
|
||||
sleep sort split stat stdbuf stty su sum sync tac tail tee test timeout
|
||||
touch tr true truncate tsort tty uname unexpand uniq unlink uptime users
|
||||
|
||||
@@ -35,7 +35,7 @@ which are extracted from other source packages:
|
||||
|
||||
And there you are! Just
|
||||
|
||||
$ ./configure #[--enable-gcc-warnings]
|
||||
$ ./configure --quiet #[--enable-gcc-warnings] [*]
|
||||
$ make
|
||||
$ make check
|
||||
|
||||
@@ -48,6 +48,12 @@ should output no difference.
|
||||
|
||||
Enjoy!
|
||||
|
||||
[*] The --enable-gcc-warnings option is useful only with glibc
|
||||
and with a very recent version of gcc. You'll probably also have
|
||||
to use recent system headers. If you configure with this option,
|
||||
and spot a problem, please be sure to send the report to the bug
|
||||
reporting address of this package, and not to that of gnulib, even
|
||||
if the problem seems to originate in a gnulib-provided file.
|
||||
-----
|
||||
|
||||
Copyright (C) 2002-2009 Free Software Foundation, Inc.
|
||||
|
||||
@@ -7,19 +7,18 @@ Here are most of the steps we (maintainers) follow when making a release.
|
||||
* Run ./configure && make maintainer-clean
|
||||
|
||||
* Ensure that the desired versions of autoconf, automake, bison, etc.
|
||||
are in your PATH. See HACKING for the complete list.
|
||||
are in your PATH. See the buildreq list in bootstrap.conf for
|
||||
the complete list.
|
||||
|
||||
* Ensure that you're on "master" with no uncommitted diffs.
|
||||
This should produce no output: git checkout master; git diff
|
||||
|
||||
* Make sure your local gnulib directory is up to date.
|
||||
|
||||
* Run bootstrap, (assuming your local copy of gnulib is in /gnulib):
|
||||
./bootstrap --gnulib-srcdir=/gnulib
|
||||
* Run bootstrap: ./bootstrap
|
||||
|
||||
FIXME: enable excluded programs like arch? to get their manual pages?
|
||||
|
||||
* Pre-release testing:
|
||||
Ensure that make check syntax-check succeeds.
|
||||
On at least one SELinux-enabled (enforcing) and one non-SELinux system,
|
||||
run all tests, both root-only and regular.
|
||||
Run *all* non-root tests, including expensive and very expensive ones i.e.,
|
||||
@@ -30,19 +29,17 @@ FIXME: enable excluded programs like arch? to get their manual pages?
|
||||
|
||||
* Run "make distcheck"
|
||||
|
||||
* Manually set the date, version number, and [stable/alpha/beta] on
|
||||
line 3 of NEWS, then do e.g.,:
|
||||
* Set the date, version number, and release type [stable/alpha/beta] on
|
||||
line 3 of NEWS, commit that, and tag the release by running e.g.,
|
||||
|
||||
v=7.3
|
||||
git commit -F <(printf 'version '$v'\n\n* NEWS: Record release date.\n') -a
|
||||
git tag -s -m "coreutils $v" v$v HEAD
|
||||
build-aux/do-release-commit-and-tag 8.1 beta
|
||||
|
||||
* Run the following to create release tarballs. Your choice selects the
|
||||
corresponding upload-to destination in the emitted gnupload command.
|
||||
The different destinations are specified in cfg.mk. See the definitions
|
||||
of gnu_ftp_host-{alpha,beta,major}.
|
||||
of gnu_ftp_host-{alpha,beta,stable}.
|
||||
|
||||
# "TYPE" must be major, beta or alpha
|
||||
# "TYPE" must be stable, beta or alpha
|
||||
make TYPE
|
||||
|
||||
* Test the tarball. copy it to a few odd-ball systems and ensure that
|
||||
@@ -60,12 +57,15 @@ Once all the builds and tests have passed,
|
||||
that they're all valid.
|
||||
|
||||
* Push the new tag:
|
||||
git push origin tag v<JUST_RELEASED_VERSION_NUMBER>
|
||||
|
||||
v=$(cat .prev-version)
|
||||
git push origin tag v$v
|
||||
|
||||
* Send the gpg-signed announcement mail, e.g.,
|
||||
|
||||
To: info-gnu@gnu.org, coreutils-announce@gnu.org
|
||||
Cc: coordinator@translationproject.org, bug-coreutils@gnu.org
|
||||
Subject: coreutils-7.1 released [stable]
|
||||
Subject: coreutils-8.0 released [beta]
|
||||
|
||||
* Approve the announcement here:
|
||||
http://lists.gnu.org/mailman/admindb/coreutils-announce
|
||||
@@ -74,25 +74,21 @@ Once all the builds and tests have passed,
|
||||
From here:
|
||||
https://savannah.gnu.org/projects/coreutils/
|
||||
click on the "submit news", then write something like the following:
|
||||
(If there is no such button, then enable "News" for the project via
|
||||
the Main -> "Select Features" menu item, or via this link:
|
||||
https://savannah.gnu.org/project/admin/editgroupfeatures.php?group=coreutils)
|
||||
|
||||
Subject: coreutils-7.2 released [stable]
|
||||
Subject: coreutils-0.0 released [beta]
|
||||
The announcement is here:
|
||||
http://article.gmane.org/gmane.comp.gnu.core-utils.announce/49
|
||||
http://article.gmane.org/gmane.comp.gnu.core-utils.announce/54
|
||||
|
||||
Then go here to approve it:
|
||||
https://savannah.gnu.org/news/approve.php?group=coreutils
|
||||
|
||||
* For non-alpha releases, update the on-line manual at
|
||||
* After each non-alpha release, update the on-line manual accessible via
|
||||
|
||||
http://www.gnu.org/software/coreutils/manual/
|
||||
|
||||
Run `make web-manual', then copy the contents of doc/manual
|
||||
into a CVS checkout of the coreutils manual repository.
|
||||
Also edit coreutils.html (FIXME? why?) before doing a CVS commit.
|
||||
by running this:
|
||||
|
||||
CVS_RSH=ssh \
|
||||
cvs -d:ext:$USER@cvs.savannah.gnu.org:/web/coreutils co coreutils
|
||||
|
||||
Be sure to "cvs add -ko" any files that "cvs status" marks with "?".
|
||||
That is necessary whenever a new texinfo node is added. Each becomes
|
||||
a new file in html_node that must then be "cvs add"ed.
|
||||
build-aux/gnu-web-doc-update
|
||||
|
||||
17
THANKS
17
THANKS
@@ -52,6 +52,7 @@ Andy Longton alongton@metamark.com
|
||||
Anthony Thyssen anthony@griffith.edu.au
|
||||
Antonio Rendas ajrendas@yahoo.com
|
||||
Ariel Faigon ariel@cthulhu.engr.sgi.com
|
||||
Arjan Opmeer arjan.opmeer@gmail.com
|
||||
Arne H. Juul arnej@solan.unit.no
|
||||
Arne Henrik Juul arnej@imf.unit.no
|
||||
Arnold Robbins arnold@skeeve.com
|
||||
@@ -66,8 +67,9 @@ Barry Kelly http://barrkel.blogspot.com/
|
||||
Bauke Jan Douma bjdouma@xs4all.nl
|
||||
Ben Elliston bje@air.net.au
|
||||
Ben Harris bjh21@netbsd.org
|
||||
Benjamin Cutler cutlerbc@simla.colostate.edu
|
||||
Bengt Martensson bengt@mathematik.uni-Bremen.de
|
||||
Benjamin Cutler cutlerbc@simla.colostate.edu
|
||||
Benno Schulenberg bensberg@justemail.net
|
||||
Bernard Giroud bernard.giroud@creditlyonnais.ch
|
||||
Bernd Eckenfels ecki@debian.org
|
||||
Bernd Leibing bernd.leibing@rz.uni-ulm.de
|
||||
@@ -209,6 +211,7 @@ Geoff Whale geoffw@cse.unsw.EDU.AU
|
||||
Gerald Pfeifer gerald@pfeifer.com
|
||||
Gerhard Poul gpoul@gnu.org
|
||||
Germano Leichsenring germano@jedi.cs.kobe-u.ac.jp
|
||||
Gilles Espinasse g.esp@free.fr
|
||||
Glen Lenker glen.lenker@gmail.com
|
||||
Göran Uddeborg goeran@uddeborg.se
|
||||
Guochun Shi gshi@ncsa.uiuc.edu
|
||||
@@ -245,12 +248,14 @@ Ian Turner vectro@pipeline.com
|
||||
Iida Yosiaki iida@gnu.org
|
||||
Ilya N. Golubev gin@mo.msk.ru
|
||||
Ingo Saitz ingo@debian.org
|
||||
Ivan Labath labath3@st.fmph.uniba.sk
|
||||
Ivo Timmermans ivo@debian.org
|
||||
James james@albion.glarp.com
|
||||
James Antill jmanti%essex.ac.uk@seralph21.essex.ac.uk
|
||||
James Lemley James.Lemley@acxiom.com
|
||||
James Hunt jamesodhunt@hotmail.com
|
||||
James Ralston ralston@pobox.com
|
||||
James R. Van Zandt jrvz@comcast.net
|
||||
James Sneeringer jvs@ocslink.com
|
||||
James Tanis jtt@soscorp.com
|
||||
James Youngman jay@gnu.org
|
||||
@@ -260,6 +265,7 @@ Jan Engelhardt jengelh@medozas.de
|
||||
Jan Fedak J.Fedak@sh.cvut.cz
|
||||
Jan Moringen jan.moringen@uni-bielefeld.de
|
||||
Jan Nieuwenhuizen janneke@gnu.org
|
||||
Jan-Pawel Wrozstinski jpwroz@gmail.com
|
||||
Janos Farkas chexum@shadow.banki.hu
|
||||
Jarkko Hietaniemi jhi@epsilon.hut.fi
|
||||
Jarod Wilson jwilson@redhat.com
|
||||
@@ -334,6 +340,7 @@ Leah Q eequor@earthlink.net
|
||||
Lehti Rami rammer@cs.tut.fi
|
||||
Leonard N. Zubkoff lnz@dandelion.com
|
||||
Leonardo Milano lmilano@udel.edu
|
||||
Lluís Batlle viriketo@gmail.com
|
||||
Lorne Baker lbaker@nitro.avint.net
|
||||
Luke Hassell lukehassell@yahoo.com
|
||||
Luke Kendall lukekendall@optushome.com.au
|
||||
@@ -365,6 +372,7 @@ Martin martin@dresden.nacamar.de
|
||||
Martin Buck martin.buck@ascom.ch
|
||||
Martin Gallant martyg@goodbit.net
|
||||
Martin Hippe martin.hippe@schlund.de
|
||||
Martin Jacobs martin.jacobs@arcor.de
|
||||
Martin Michlmayr tbm@cyrius.com
|
||||
Martin Mitchell martin@debian.org
|
||||
Martin P.J. Zinser zinser@decus.de
|
||||
@@ -372,6 +380,7 @@ Marty Leisner leisner@sdsp.mc.xerox.com
|
||||
Masami Takikawa takikawm@CS.ORST.EDU
|
||||
Mate Wierdl mw@moni.msci.memphis.edu
|
||||
Matej Vela mvela@public.srce.hr
|
||||
Matias A. Fonzo selk@dragora.org
|
||||
Matt Kraai kraai@ftbfs.org
|
||||
Matt Perry matt@primefactor.com
|
||||
Matt Pham mattvpham@gmail.com
|
||||
@@ -393,7 +402,7 @@ Max Chang maxchang@ucla.edu
|
||||
Meelis Roos mroos@tartu.cyber.ee
|
||||
Michael michael@aplatform.com
|
||||
Michael ??? michael@roka.net
|
||||
Michael Bacarella mbac@netgraft.com>
|
||||
Michael Bacarella mbac@netgraft.com
|
||||
Michael Deutschmann michael@talamasca.ocis.net
|
||||
Michael Elizabeth Chastain mec.gnu@mindspring.com
|
||||
Michael Gaughen mgaughen@polyserve.com
|
||||
@@ -490,7 +499,7 @@ Ralph Loader loader@maths.ox.ac.uk
|
||||
Raul Miller moth@magenta.com
|
||||
Raúl Núñez de Arenas Coronado raul@pleyades.net
|
||||
Reuben Thomas rrt@sc3d.org
|
||||
Ren Yang ryang@redhat.com
|
||||
Yang Ren ryang@redhat.com
|
||||
Richard A Downing richard.downing@bcs.org.uk
|
||||
Richard Braakman dark@xs4all.nl
|
||||
Richard Dawe rich@phekda.freeserve.co.uk
|
||||
@@ -535,6 +544,7 @@ Stephen Smoogen smooge@mindspring.com
|
||||
Steve McConnel steve@acadcomp.sil.org
|
||||
Steve McIntyre steve@einval.com
|
||||
Steve Ward planet36@gmail.com
|
||||
Steven Drake sbd@users.sourceforge.net
|
||||
Steven G. Johnson stevenj@alum.mit.edu
|
||||
Steven Mocking ufo@quicknet.nl
|
||||
Steven Parkes smparkes@smparkes.net
|
||||
@@ -608,6 +618,7 @@ Wis Macomson wis.macomson@intel.com
|
||||
Wojciech Purczynski cliph@isec.pl
|
||||
Wolfram Kleff kleff@cs.uni-bonn.de
|
||||
Won-kyu Park wkpark@chem.skku.ac.kr
|
||||
Yanko Kaneti yaneti@declera.com
|
||||
Yann Dirson dirson@debian.org
|
||||
Zvi Har'El rl@math.technion.ac.il
|
||||
|
||||
|
||||
1
TODO
1
TODO
@@ -12,7 +12,6 @@ Modify chmod so that it does not change an inode's st_ctime
|
||||
Discussed more recently on <http://bugs.debian.org/497514>.
|
||||
|
||||
document the following in coreutils.texi:
|
||||
mktemp
|
||||
[
|
||||
pinky
|
||||
|
||||
|
||||
32
bootstrap
32
bootstrap
@@ -70,6 +70,10 @@ gnulib_modules=
|
||||
# Any gnulib files needed that are not in modules.
|
||||
gnulib_files=
|
||||
|
||||
# A function to be called after everything else in this script.
|
||||
# Override it via your own definition in bootstrap.conf.
|
||||
bootstrap_epilogue() { :; }
|
||||
|
||||
# The command to download all .po files for a specified domain into
|
||||
# a specified directory. Fill in the first %s is the domain name, and
|
||||
# the second with the destination directory. Use rsync's -L and -r
|
||||
@@ -150,12 +154,18 @@ vc_ignore=auto
|
||||
|
||||
# find_tool ENVVAR NAMES...
|
||||
# -------------------------
|
||||
# Search for a required program. Use the value of ENVVAR, if set,
|
||||
# otherwise find the first of the NAMES that can be run (i.e.,
|
||||
# supports --version). If found, set ENVVAR to the program name,
|
||||
# die otherwise.
|
||||
find_tool ()
|
||||
{
|
||||
# Find sha1sum, named gsha1sum on MacPorts.
|
||||
find_tool_envvar=$1
|
||||
shift
|
||||
if eval test x"\$$find_tool_envvar" = x; then
|
||||
find_tool_names=$@
|
||||
eval "find_tool_res=\$$find_tool_envvar"
|
||||
if test x"$find_tool_res" = x; then
|
||||
for i
|
||||
do
|
||||
if ($i --version </dev/null) >/dev/null 2>&1; then
|
||||
@@ -163,16 +173,18 @@ find_tool ()
|
||||
break
|
||||
fi
|
||||
done
|
||||
else
|
||||
find_tool_error_prefix="\$$find_tool_envvar: "
|
||||
fi
|
||||
if test x"$find_tool_res" = x; then
|
||||
echo >&2 "$0: $find_tool_name is required"
|
||||
echo >&2 "$0: one of these is required: $find_tool_names"
|
||||
exit 1
|
||||
fi
|
||||
($find_tool_res --version </dev/null) >/dev/null 2>&1 || {
|
||||
echo >&2 "$0: cannot run $find_tool_res --version"
|
||||
echo >&2 "$0: ${find_tool_error_prefix}cannot run $find_tool_res --version"
|
||||
exit 1
|
||||
}
|
||||
eval "$find_tool_envvar=\"$find_tool_res\""
|
||||
eval "$find_tool_envvar=\$find_tool_res"
|
||||
eval "export $find_tool_envvar"
|
||||
}
|
||||
|
||||
@@ -405,7 +417,7 @@ case ${GNULIB_SRCDIR--} in
|
||||
git_modules_config submodule.gnulib.url >/dev/null; then
|
||||
git submodule init
|
||||
GNULIB_SRCDIR=`cd $GNULIB_SRCDIR && pwd`
|
||||
git config --replace-all submodule.gnulib.url $GNULIB_SRCDIR
|
||||
git_modules_config --replace-all submodule.gnulib.url $GNULIB_SRCDIR
|
||||
echo "$0: getting gnulib files..."
|
||||
git submodule update || exit $?
|
||||
GNULIB_SRCDIR=gnulib
|
||||
@@ -721,6 +733,10 @@ find "$m4_base" "$source_base" \
|
||||
|
||||
# Reconfigure, getting other files.
|
||||
|
||||
# Skip autoheader if it's not needed.
|
||||
grep -E '^[ ]*AC_CONFIG_HEADERS?\>' configure.ac >/dev/null ||
|
||||
AUTOHEADER=true
|
||||
|
||||
for command in \
|
||||
libtool \
|
||||
"${ACLOCAL-aclocal} --force -I m4" \
|
||||
@@ -789,10 +805,6 @@ if test $with_gettext = yes; then
|
||||
fi
|
||||
fi
|
||||
|
||||
# Horrible, coreutils-specific kludges.
|
||||
# Change paths in gnulib-tests/gnulib.mk from "../.." to "..".
|
||||
m=gnulib-tests/gnulib.mk
|
||||
sed 's,\.\./\.\.,..,g' $m > $m-t
|
||||
mv -f $m-t $m
|
||||
bootstrap_epilogue
|
||||
|
||||
echo "$0: done. Now you can run './configure'."
|
||||
|
||||
@@ -20,7 +20,6 @@
|
||||
avoided_gnulib_modules='
|
||||
--avoid=canonicalize-lgpl
|
||||
--avoid=dummy
|
||||
--avoid=lock
|
||||
'
|
||||
|
||||
# These modules are obsolete and can probably be removed soon,
|
||||
@@ -31,7 +30,6 @@ obsolete_gnulib_modules='
|
||||
memcpy
|
||||
memmove
|
||||
memset
|
||||
rename
|
||||
strcspn
|
||||
strtod
|
||||
strtol
|
||||
@@ -73,11 +71,14 @@ gnulib_modules="
|
||||
diacrit
|
||||
dirfd
|
||||
dirname
|
||||
do-release-commit-and-tag
|
||||
dup2
|
||||
environ
|
||||
error
|
||||
euidaccess
|
||||
exclude
|
||||
exitfail
|
||||
faccessat
|
||||
fchdir
|
||||
fcntl
|
||||
fcntl-safer
|
||||
@@ -90,12 +91,14 @@ gnulib_modules="
|
||||
fnmatch-gnu
|
||||
fopen-safer
|
||||
fprintftime
|
||||
freopen
|
||||
freopen-safer
|
||||
fseeko
|
||||
fsusage
|
||||
fsync
|
||||
ftello
|
||||
ftruncate
|
||||
fts
|
||||
gendocs
|
||||
getdate
|
||||
getgroups
|
||||
gethrxtime
|
||||
@@ -113,6 +116,7 @@ gnulib_modules="
|
||||
git-version-gen
|
||||
gitlog-to-changelog
|
||||
gnu-make
|
||||
gnu-web-doc-update
|
||||
gnumakefile
|
||||
gnupload
|
||||
group-member
|
||||
@@ -126,12 +130,14 @@ gnulib_modules="
|
||||
inttostr
|
||||
inttypes
|
||||
isapipe
|
||||
isblank
|
||||
lchmod
|
||||
lchown
|
||||
lib-ignore
|
||||
linebuffer
|
||||
link
|
||||
link-follow
|
||||
linkat
|
||||
long-options
|
||||
lstat
|
||||
maintainer-makefile
|
||||
@@ -154,6 +160,7 @@ gnulib_modules="
|
||||
modechange
|
||||
mountlist
|
||||
mpsort
|
||||
nproc
|
||||
obstack
|
||||
pathmax
|
||||
perl
|
||||
@@ -176,9 +183,9 @@ gnulib_modules="
|
||||
readutmp
|
||||
realloc
|
||||
regex
|
||||
rename-dest-slash
|
||||
remove
|
||||
rename
|
||||
rmdir
|
||||
rmdir-errno
|
||||
root-dev-ino
|
||||
rpmatch
|
||||
safe-read
|
||||
@@ -197,20 +204,23 @@ gnulib_modules="
|
||||
stdlib-safer
|
||||
stpcpy
|
||||
stpncpy
|
||||
strdup
|
||||
strdup-posix
|
||||
strftime
|
||||
strpbrk
|
||||
strsignal
|
||||
strtoimax
|
||||
strtoumax
|
||||
strverscmp
|
||||
symlink
|
||||
sys_stat
|
||||
timespec
|
||||
tzset
|
||||
uname
|
||||
unicodeio
|
||||
unistd-safer
|
||||
unlink-busy
|
||||
unlinkdir
|
||||
unlocked-io
|
||||
unsetenv
|
||||
update-copyright
|
||||
uptime
|
||||
useless-if-before-free
|
||||
@@ -235,6 +245,7 @@ gnulib_modules="
|
||||
xnanosleep
|
||||
xprintf
|
||||
xprintf-posix
|
||||
xreadlink
|
||||
xstrtod
|
||||
xstrtoimax
|
||||
xstrtol
|
||||
@@ -291,7 +302,6 @@ if test $gettext_external = 1; then
|
||||
m4/glibc2.m4
|
||||
m4/intdiv0.m4
|
||||
m4/lcmessage.m4
|
||||
m4/lock.m4
|
||||
m4/uintmax_t.m4
|
||||
m4/ulonglong.m4
|
||||
m4/visibility.m4
|
||||
@@ -318,3 +328,11 @@ tar -
|
||||
|
||||
# Automake requires that ChangeLog exist.
|
||||
touch ChangeLog || exit 1
|
||||
|
||||
bootstrap_epilogue()
|
||||
{
|
||||
# Change paths in gnulib-tests/gnulib.mk from "../.." to "..".
|
||||
m=gnulib-tests/gnulib.mk
|
||||
sed 's,\.\./\.\.,..,g' $m > $m-t
|
||||
mv -f $m-t $m
|
||||
}
|
||||
|
||||
35
cfg.mk
35
cfg.mk
@@ -31,7 +31,7 @@ url_dir_list = \
|
||||
gpg_key_ID = B9AB9A16
|
||||
|
||||
# Tests not to run as part of "make distcheck".
|
||||
local-checks-to-skip = strftime-check
|
||||
local-checks-to-skip =
|
||||
|
||||
# Tools used to bootstrap this package, used for "announcement".
|
||||
bootstrap-tools = autoconf,automake,gnulib,bison
|
||||
@@ -39,7 +39,7 @@ bootstrap-tools = autoconf,automake,gnulib,bison
|
||||
# Now that we have better tests, make this the default.
|
||||
export VERBOSE = yes
|
||||
|
||||
old_NEWS_hash = 93ff8e5850f630855f9e834fec416830
|
||||
old_NEWS_hash = 785e51bc9af87e7eb004f9ba24a0ca27
|
||||
|
||||
# Ensure that the list of O_ symbols used to compute O_FULLBLOCK is complete.
|
||||
dd = $(srcdir)/src/dd.c
|
||||
@@ -191,6 +191,18 @@ sc_no_exec_perl_coreutils:
|
||||
exit 1; } || :; \
|
||||
fi
|
||||
|
||||
# Don't use "readlink" or "readlinkat" directly
|
||||
sc_prohibit_readlink:
|
||||
@re='\<readlink(at)? \(' \
|
||||
msg='do not use readlink(at); use via xreadlink or areadlink*' \
|
||||
$(_prohibit_regexp)
|
||||
|
||||
# Don't use address of "stat" or "lstat" functions
|
||||
sc_prohibit_stat_macro_address:
|
||||
@re='\<l?stat '':|&l?stat\>' \
|
||||
msg='stat() and lstat() may be function-like macros' \
|
||||
$(_prohibit_regexp)
|
||||
|
||||
# Ensure that date's --help output stays in sync with the info
|
||||
# documentation for GNU strftime. The only exception is %N,
|
||||
# which date accepts but GNU strftime does not.
|
||||
@@ -218,4 +230,23 @@ sc_prohibit_emacs__indent_tabs_mode__setting:
|
||||
msg='use of emacs indent-tabs-mode: setting' \
|
||||
$(_prohibit_regexp)
|
||||
|
||||
# Ensure that each file that contains fail=1 also contains fail=0.
|
||||
# Otherwise, setting file=1 in the environment would make tests fail unexpectedly.
|
||||
sc_prohibit_fail_0:
|
||||
@re='\<fail=0\>' \
|
||||
msg='fail=0 initialization' \
|
||||
$(_prohibit_regexp)
|
||||
|
||||
# Ensure that "stdio--.h" is used where appropriate.
|
||||
sc_require_stdio_safer:
|
||||
@if $(VC_LIST_EXCEPT) | grep -l '\.[ch]$$' > /dev/null; then \
|
||||
files=$$(grep -l '\bfreopen \?(' $$($(VC_LIST_EXCEPT) \
|
||||
| grep '\.[ch]$$')); \
|
||||
test -n "$$files" && grep -LE 'include "stdio--.h"' $$files \
|
||||
| grep . && \
|
||||
{ echo '$(ME): the above files should use "stdio--.h"' \
|
||||
1>&2; exit 1; } || :; \
|
||||
else :; \
|
||||
fi
|
||||
|
||||
include $(srcdir)/dist-check.mk
|
||||
|
||||
20
configure.ac
20
configure.ac
@@ -101,14 +101,12 @@ if test "$gl_gcc_warnings" = yes; then
|
||||
gl_WARN_ADD([-Wno-pointer-sign]) # Too many warnings for now
|
||||
gl_WARN_ADD([-Wno-unused-parameter]) # Too many warnings for now
|
||||
|
||||
# Offenders in pre-fts remove.c; FIXME: remove upon remove.c rewrite
|
||||
gl_WARN_ADD([-Wno-jump-misses-init])
|
||||
|
||||
# In spite of excluding -Wlogical-op above, it is enabled, as of
|
||||
# gcc 4.5.0 20090517, and it provokes warnings in cat.c, dd.c, truncate.c
|
||||
gl_WARN_ADD([-Wno-logical-op])
|
||||
|
||||
gl_WARN_ADD([-fdiagnostics-show-option])
|
||||
gl_WARN_ADD([-funit-at-a-time])
|
||||
|
||||
AC_SUBST([WARN_CFLAGS])
|
||||
|
||||
@@ -116,13 +114,21 @@ if test "$gl_gcc_warnings" = yes; then
|
||||
AC_DEFINE([_FORTIFY_SOURCE], [2],
|
||||
[enable compile-time and run-time bounds-checking, and some warnings])
|
||||
AC_DEFINE([GNULIB_PORTCHECK], [1], [enable some gnulib portability checks])
|
||||
|
||||
# We use a slightly smaller set of warning options for lib/.
|
||||
# Remove the following and save the result in GNULIB_WARN_CFLAGS.
|
||||
nw=
|
||||
nw="$nw -Wuninitialized"
|
||||
nw="$nw -Wunused-macros"
|
||||
nw="$nw -Wmissing-prototypes"
|
||||
nw="$nw -Wold-style-definition"
|
||||
gl_MANYWARN_COMPLEMENT([GNULIB_WARN_CFLAGS], [$WARN_CFLAGS], [$nw])
|
||||
AC_SUBST([GNULIB_WARN_CFLAGS])
|
||||
fi
|
||||
|
||||
AC_FUNC_FORK
|
||||
|
||||
optional_bin_progs=
|
||||
AC_CHECK_FUNCS([uname],
|
||||
gl_ADD_PROG([optional_bin_progs], [uname]))
|
||||
AC_CHECK_FUNCS([chroot],
|
||||
gl_ADD_PROG([optional_bin_progs], [chroot]))
|
||||
AC_CHECK_FUNCS([gethostid],
|
||||
@@ -423,8 +429,10 @@ CONFIG_STATUS_DEPENDENCIES='$(top_srcdir)/src/Makefile.am'
|
||||
AC_SUBST([CONFIG_STATUS_DEPENDENCIES])
|
||||
############################################################################
|
||||
|
||||
# As long as "grep 'PRI[diouxX]' po/*.pot" reports matches in
|
||||
# translatable strings, we must use need-formatstring-macros here.
|
||||
AM_GNU_GETTEXT([external], [need-formatstring-macros])
|
||||
AM_GNU_GETTEXT_VERSION([0.15])
|
||||
AM_GNU_GETTEXT_VERSION([0.17])
|
||||
|
||||
# For a test of uniq: it uses the $LOCALE_FR envvar.
|
||||
gt_LOCALE_FR
|
||||
|
||||
@@ -48,8 +48,10 @@ _W = (^|[^A-Za-z0-9_])
|
||||
W_ = ([^A-Za-z0-9_]|$$)
|
||||
|
||||
syntax_checks = \
|
||||
sc-avoid-builtin \
|
||||
sc-avoid-io \
|
||||
sc-avoid-non-zero \
|
||||
sc-avoid-path \
|
||||
sc-avoid-timezone \
|
||||
sc-avoid-zeroes \
|
||||
sc-exponent-grouping \
|
||||
@@ -70,9 +72,18 @@ check-texinfo: $(syntax_checks)
|
||||
$(PERL) -e 1 2> /dev/null && { $(PERL) -ne \
|
||||
'/\bPOSIX\b/ && !/\@acronym{POSIX}/ && !/^\* / || /{posix}/ and print,exit 1' \
|
||||
$(srcdir)/*.texi 2> /dev/null || fail=1; }; \
|
||||
$(EGREP) -i '$(_W)builtins?$(W_)' $(srcdir)/*.texi && fail=1; \
|
||||
exit $$fail
|
||||
|
||||
sc-avoid-builtin:
|
||||
$(AM_V_GEN)$(EGREP) -i '$(_W)builtins?$(W_)' $(srcdir)/*.texi \
|
||||
&& exit 1 || :
|
||||
|
||||
sc-avoid-path:
|
||||
$(AM_V_GEN)fail=0; \
|
||||
$(EGREP) -i '$(_W)path(name)?s?$(W_)' $(srcdir)/*.texi \
|
||||
| $(EGREP) -v 'search path|@vindex PATH$$|@env[{]PATH[}]' && fail=1; \
|
||||
| $(EGREP) -v \
|
||||
'PATH=|path search|search path|@vindex PATH$$|@env[{]PATH[}]' \
|
||||
&& fail=1; \
|
||||
exit $$fail
|
||||
|
||||
# Use `time zone', not `timezone'.
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -129,7 +129,7 @@ mbs_align_pad (char *dest, const char* dest_end, size_t n_spaces)
|
||||
|
||||
size_t
|
||||
mbsalign (const char *src, char *dest, size_t dest_size,
|
||||
size_t *width, mbs_align_t align, int flags)
|
||||
size_t *width, mbs_align_t align, int flags _UNUSED_PARAMETER_)
|
||||
{
|
||||
size_t ret = -1;
|
||||
size_t src_size = strlen (src) + 1;
|
||||
|
||||
@@ -1,142 +0,0 @@
|
||||
/* mgetgroups.c -- return a list of the groups a user is in
|
||||
|
||||
Copyright (C) 2007-2009 Free Software Foundation, Inc.
|
||||
|
||||
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
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
/* Extracted from coreutils' src/id.c. */
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include "mgetgroups.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
#if HAVE_GETGROUPLIST
|
||||
# include <grp.h>
|
||||
#endif
|
||||
#include "getugroups.h"
|
||||
#include "xalloc.h"
|
||||
|
||||
|
||||
static GETGROUPS_T *
|
||||
realloc_groupbuf (GETGROUPS_T *g, size_t num)
|
||||
{
|
||||
if (xalloc_oversized (num, sizeof (*g)))
|
||||
{
|
||||
errno = ENOMEM;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return realloc (g, num * sizeof (*g));
|
||||
}
|
||||
|
||||
/* Like getugroups, but store the result in malloc'd storage.
|
||||
Set *GROUPS to the malloc'd list of all group IDs of which USERNAME
|
||||
is a member. If GID is not -1, store it first. GID should be the
|
||||
group ID (pw_gid) obtained from getpwuid, in case USERNAME is not
|
||||
listed in the groups database (e.g., /etc/groups). Upon failure,
|
||||
don't modify *GROUPS, set errno, and return -1. Otherwise, return
|
||||
the number of groups. */
|
||||
|
||||
int
|
||||
mgetgroups (char const *username, gid_t gid, GETGROUPS_T **groups)
|
||||
{
|
||||
int max_n_groups;
|
||||
int ng;
|
||||
GETGROUPS_T *g;
|
||||
|
||||
#if HAVE_GETGROUPLIST
|
||||
/* We prefer to use getgrouplist if available, because it has better
|
||||
performance characteristics.
|
||||
|
||||
In glibc 2.3.2, getgrouplist is buggy. If you pass a zero as the
|
||||
length of the output buffer, getgrouplist will still write to the
|
||||
buffer. Contrary to what some versions of the getgrouplist
|
||||
manpage say, this doesn't happen with nonzero buffer sizes.
|
||||
Therefore our usage here just avoids a zero sized buffer. */
|
||||
if (username)
|
||||
{
|
||||
enum { N_GROUPS_INIT = 10 };
|
||||
max_n_groups = N_GROUPS_INIT;
|
||||
|
||||
g = realloc_groupbuf (NULL, max_n_groups);
|
||||
if (g == NULL)
|
||||
return -1;
|
||||
|
||||
while (1)
|
||||
{
|
||||
GETGROUPS_T *h;
|
||||
int last_n_groups = max_n_groups;
|
||||
|
||||
/* getgrouplist updates max_n_groups to num required. */
|
||||
ng = getgrouplist (username, gid, g, &max_n_groups);
|
||||
|
||||
/* Some systems (like Darwin) have a bug where they
|
||||
never increase max_n_groups. */
|
||||
if (ng < 0 && last_n_groups == max_n_groups)
|
||||
max_n_groups *= 2;
|
||||
|
||||
if ((h = realloc_groupbuf (g, max_n_groups)) == NULL)
|
||||
{
|
||||
int saved_errno = errno;
|
||||
free (g);
|
||||
errno = saved_errno;
|
||||
return -1;
|
||||
}
|
||||
g = h;
|
||||
|
||||
if (0 <= ng)
|
||||
{
|
||||
*groups = g;
|
||||
/* On success some systems just return 0 from getgrouplist,
|
||||
so return max_n_groups rather than ng. */
|
||||
return max_n_groups;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* else no username, so fall through and use getgroups. */
|
||||
#endif
|
||||
|
||||
max_n_groups = (username
|
||||
? getugroups (0, NULL, username, gid)
|
||||
: getgroups (0, NULL));
|
||||
|
||||
/* If we failed to count groups with NULL for a buffer,
|
||||
try again with a non-NULL one, just in case. */
|
||||
if (max_n_groups < 0)
|
||||
max_n_groups = 5;
|
||||
|
||||
g = realloc_groupbuf (NULL, max_n_groups);
|
||||
if (g == NULL)
|
||||
return -1;
|
||||
|
||||
ng = (username
|
||||
? getugroups (max_n_groups, g, username, gid)
|
||||
: getgroups (max_n_groups, g));
|
||||
|
||||
if (ng < 0)
|
||||
{
|
||||
int saved_errno = errno;
|
||||
free (g);
|
||||
errno = saved_errno;
|
||||
return -1;
|
||||
}
|
||||
|
||||
*groups = g;
|
||||
return ng;
|
||||
}
|
||||
@@ -1,19 +0,0 @@
|
||||
/* Get a list of all group IDs associated with a specified user ID.
|
||||
Copyright (C) 2007, 2009 Free Software Foundation, Inc.
|
||||
|
||||
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
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
#include <sys/types.h>
|
||||
|
||||
int mgetgroups (const char *username, gid_t gid, GETGROUPS_T **groups);
|
||||
82
gl/lib/regcomp.c.diff
Normal file
82
gl/lib/regcomp.c.diff
Normal file
@@ -0,0 +1,82 @@
|
||||
diff --git c/lib/regcomp.c i/lib/regcomp.c
|
||||
index 6472ff6..665b2ab 100644
|
||||
--- c/lib/regcomp.c
|
||||
+++ i/lib/regcomp.c
|
||||
@@ -18,6 +18,8 @@
|
||||
with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
|
||||
|
||||
+#include "intprops.h"
|
||||
+#include "verify.h"
|
||||
static reg_errcode_t re_compile_internal (regex_t *preg, const char * pattern,
|
||||
size_t length, reg_syntax_t syntax);
|
||||
static void re_compile_fastmap_iter (regex_t *bufp,
|
||||
@@ -541,7 +543,7 @@ regerror (errcode, preg, errbuf, errbuf_size)
|
||||
size_t errbuf_size;
|
||||
#else /* size_t might promote */
|
||||
size_t
|
||||
-regerror (int errcode, const regex_t *_Restrict_ preg,
|
||||
+regerror (int errcode, const regex_t *_Restrict_ preg _UNUSED_PARAMETER_,
|
||||
char *_Restrict_ errbuf, size_t errbuf_size)
|
||||
#endif
|
||||
{
|
||||
@@ -1375,7 +1377,7 @@ calc_first (void *extra, bin_tree_t *node)
|
||||
|
||||
/* Pass 2: compute NEXT on the tree. Preorder visit. */
|
||||
static reg_errcode_t
|
||||
-calc_next (void *extra, bin_tree_t *node)
|
||||
+calc_next (void *extra _UNUSED_PARAMETER_, bin_tree_t *node)
|
||||
{
|
||||
switch (node->token.type)
|
||||
{
|
||||
@@ -2571,7 +2573,8 @@ parse_dup_op (bin_tree_t *elem, re_string_t *regexp, re_dfa_t *dfa,
|
||||
/* This loop is actually executed only when end != REG_MISSING,
|
||||
to rewrite <re>{0,n} as (<re>(<re>...<re>?)?)?... We have
|
||||
already created the start+1-th copy. */
|
||||
- if ((Idx) -1 < 0 || end != REG_MISSING)
|
||||
+ verify (! TYPE_SIGNED (Idx));
|
||||
+ if (end != REG_MISSING)
|
||||
for (i = start + 2; i <= end; ++i)
|
||||
{
|
||||
elem = duplicate_tree (elem, dfa);
|
||||
@@ -2731,7 +2734,8 @@ static reg_errcode_t
|
||||
internal_function
|
||||
build_collating_symbol (bitset_t sbcset,
|
||||
# ifdef RE_ENABLE_I18N
|
||||
- re_charset_t *mbcset, Idx *coll_sym_alloc,
|
||||
+ re_charset_t *mbcset _UNUSED_PARAMETER_,
|
||||
+ Idx *coll_sym_alloc _UNUSED_PARAMETER_,
|
||||
# endif
|
||||
const unsigned char *name)
|
||||
{
|
||||
@@ -3309,7 +3313,8 @@ parse_bracket_exp (re_string_t *regexp, re_dfa_t *dfa, re_token_t *token,
|
||||
|
||||
static reg_errcode_t
|
||||
parse_bracket_element (bracket_elem_t *elem, re_string_t *regexp,
|
||||
- re_token_t *token, int token_len, re_dfa_t *dfa,
|
||||
+ re_token_t *token, int token_len,
|
||||
+ re_dfa_t *dfa _UNUSED_PARAMETER_,
|
||||
reg_syntax_t syntax, bool accept_hyphen)
|
||||
{
|
||||
#ifdef RE_ENABLE_I18N
|
||||
@@ -3396,8 +3401,9 @@ parse_bracket_symbol (bracket_elem_t *elem, re_string_t *regexp,
|
||||
|
||||
static reg_errcode_t
|
||||
#ifdef RE_ENABLE_I18N
|
||||
-build_equiv_class (bitset_t sbcset, re_charset_t *mbcset,
|
||||
- Idx *equiv_class_alloc, const unsigned char *name)
|
||||
+build_equiv_class (bitset_t sbcset, re_charset_t *mbcset _UNUSED_PARAMETER_,
|
||||
+ Idx *equiv_class_alloc _UNUSED_PARAMETER_,
|
||||
+ const unsigned char *name)
|
||||
#else /* not RE_ENABLE_I18N */
|
||||
build_equiv_class (bitset_t sbcset, const unsigned char *name)
|
||||
#endif /* not RE_ENABLE_I18N */
|
||||
@@ -3798,7 +3804,7 @@ free_token (re_token_t *node)
|
||||
and its children. */
|
||||
|
||||
static reg_errcode_t
|
||||
-free_tree (void *extra, bin_tree_t *node)
|
||||
+free_tree (void *extra _UNUSED_PARAMETER_, bin_tree_t *node)
|
||||
{
|
||||
free_token (&node->token);
|
||||
return REG_NOERROR;
|
||||
25
gl/lib/regex_internal.c.diff
Normal file
25
gl/lib/regex_internal.c.diff
Normal file
@@ -0,0 +1,25 @@
|
||||
diff --git a/lib/regex_internal.c b/lib/regex_internal.c
|
||||
index 904b88e..61c8d9d 100644
|
||||
--- a/lib/regex_internal.c
|
||||
+++ b/lib/regex_internal.c
|
||||
@@ -18,6 +18,8 @@
|
||||
with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
|
||||
|
||||
+#include "verify.h"
|
||||
+#include "intprops.h"
|
||||
static void re_string_construct_common (const char *str, Idx len,
|
||||
re_string_t *pstr,
|
||||
RE_TRANSLATE_TYPE trans, bool icase,
|
||||
@@ -1390,7 +1392,10 @@ static void
|
||||
internal_function
|
||||
re_node_set_remove_at (re_node_set *set, Idx idx)
|
||||
{
|
||||
- if (idx < 0 || idx >= set->nelem)
|
||||
+ verify (! TYPE_SIGNED (Idx));
|
||||
+ /* if (idx < 0)
|
||||
+ return; */
|
||||
+ if (idx >= set->nelem)
|
||||
return;
|
||||
--set->nelem;
|
||||
for (; idx < set->nelem; idx++)
|
||||
14
gl/lib/regex_internal.h.diff
Normal file
14
gl/lib/regex_internal.h.diff
Normal file
@@ -0,0 +1,14 @@
|
||||
diff --git i/lib/regex_internal.h w/lib/regex_internal.h
|
||||
index 859832f..3c7fe06 100644
|
||||
--- i/lib/regex_internal.h
|
||||
+++ w/lib/regex_internal.h
|
||||
@@ -826,7 +826,8 @@ re_string_wchar_at (const re_string_t *pstr, Idx idx)
|
||||
|
||||
static int
|
||||
internal_function __attribute ((pure))
|
||||
-re_string_elem_size_at (const re_string_t *pstr, Idx idx)
|
||||
+re_string_elem_size_at (const re_string_t *pstr _UNUSED_PARAMETER_,
|
||||
+ Idx idx _UNUSED_PARAMETER_)
|
||||
{
|
||||
# ifdef _LIBC
|
||||
const unsigned char *p, *extra;
|
||||
45
gl/lib/regexec.c.diff
Normal file
45
gl/lib/regexec.c.diff
Normal file
@@ -0,0 +1,45 @@
|
||||
diff --git a/lib/regexec.c b/lib/regexec.c
|
||||
index 21a8166..7762437 100644
|
||||
--- a/lib/regexec.c
|
||||
+++ b/lib/regexec.c
|
||||
@@ -18,6 +18,8 @@
|
||||
with this program; if not, write to the Free Software Foundation,
|
||||
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */
|
||||
|
||||
+#include "verify.h"
|
||||
+#include "intprops.h"
|
||||
static reg_errcode_t match_ctx_init (re_match_context_t *cache, int eflags,
|
||||
Idx n) internal_function;
|
||||
static void match_ctx_clean (re_match_context_t *mctx) internal_function;
|
||||
@@ -378,8 +380,11 @@ re_search_2_stub (struct re_pattern_buffer *bufp,
|
||||
Idx len = length1 + length2;
|
||||
char *s = NULL;
|
||||
|
||||
- if (BE (length1 < 0 || length2 < 0 || stop < 0 || len < length1, 0))
|
||||
- return -2;
|
||||
+ verify (! TYPE_SIGNED (Idx));
|
||||
+ if (BE (len < length1, 0))
|
||||
+ return -2;
|
||||
+ /* if (BE (length1 < 0 || length2 < 0 || stop < 0, 0))
|
||||
+ return -2; */
|
||||
|
||||
/* Concatenate the strings. */
|
||||
if (length2 > 0)
|
||||
@@ -431,11 +436,14 @@ re_search_stub (struct re_pattern_buffer *bufp,
|
||||
Idx last_start = start + range;
|
||||
|
||||
/* Check for out-of-range. */
|
||||
- if (BE (start < 0 || start > length, 0))
|
||||
- return -1;
|
||||
+ verify (! TYPE_SIGNED (Idx));
|
||||
+ /* if (BE (start < 0, 0))
|
||||
+ return -1; */
|
||||
+ if (BE (start > length, 0))
|
||||
+ return -1;
|
||||
if (BE (length < last_start || (0 <= range && last_start < start), 0))
|
||||
last_start = length;
|
||||
- else if (BE (last_start < 0 || (range < 0 && start <= last_start), 0))
|
||||
+ else if (BE (/* last_start < 0 || */ (range < 0 && start <= last_start), 0))
|
||||
last_start = 0;
|
||||
|
||||
__libc_lock_lock (dfa->lock);
|
||||
@@ -1,301 +0,0 @@
|
||||
/* tempname.c - generate the name of a temporary file.
|
||||
|
||||
Copyright (C) 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
|
||||
2000, 2001, 2002, 2003, 2005, 2006, 2007, 2009 Free Software Foundation,
|
||||
Inc.
|
||||
|
||||
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
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
/* Extracted from glibc sysdeps/posix/tempname.c. See also tmpdir.c. */
|
||||
|
||||
#if !_LIBC
|
||||
# include <config.h>
|
||||
# include "tempname.h"
|
||||
# include "randint.h"
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <errno.h>
|
||||
#ifndef __set_errno
|
||||
# define __set_errno(Val) errno = (Val)
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#ifndef P_tmpdir
|
||||
# define P_tmpdir "/tmp"
|
||||
#endif
|
||||
#ifndef TMP_MAX
|
||||
# define TMP_MAX 238328
|
||||
#endif
|
||||
#ifndef __GT_FILE
|
||||
# define __GT_FILE 0
|
||||
# define __GT_BIGFILE 1
|
||||
# define __GT_DIR 2
|
||||
# define __GT_NOCREATE 3
|
||||
#endif
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <fcntl.h>
|
||||
#include <sys/time.h>
|
||||
#include <stdint.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <sys/stat.h>
|
||||
|
||||
#if _LIBC
|
||||
# define struct_stat64 struct stat64
|
||||
# define small_open __open
|
||||
# define large_open __open64
|
||||
#else
|
||||
# define struct_stat64 struct stat
|
||||
# define small_open open
|
||||
# define large_open open
|
||||
# define __gen_tempname gen_tempname
|
||||
# define __getpid getpid
|
||||
# define __gettimeofday gettimeofday
|
||||
# define __mkdir mkdir
|
||||
# define __lxstat64(version, file, buf) lstat (file, buf)
|
||||
# define __xstat64(version, file, buf) stat (file, buf)
|
||||
#endif
|
||||
|
||||
#if ! (HAVE___SECURE_GETENV || _LIBC)
|
||||
# define __secure_getenv getenv
|
||||
#endif
|
||||
|
||||
#if _LIBC
|
||||
/* Return nonzero if DIR is an existent directory. */
|
||||
static int
|
||||
direxists (const char *dir)
|
||||
{
|
||||
struct_stat64 buf;
|
||||
return __xstat64 (_STAT_VER, dir, &buf) == 0 && S_ISDIR (buf.st_mode);
|
||||
}
|
||||
|
||||
/* Path search algorithm, for tmpnam, tmpfile, etc. If DIR is
|
||||
non-null and exists, uses it; otherwise uses the first of $TMPDIR,
|
||||
P_tmpdir, /tmp that exists. Copies into TMPL a template suitable
|
||||
for use with mk[s]temp. Will fail (-1) if DIR is non-null and
|
||||
doesn't exist, none of the searched dirs exists, or there's not
|
||||
enough space in TMPL. */
|
||||
int
|
||||
__path_search (char *tmpl, size_t tmpl_len, const char *dir, const char *pfx,
|
||||
int try_tmpdir)
|
||||
{
|
||||
const char *d;
|
||||
size_t dlen, plen;
|
||||
|
||||
if (!pfx || !pfx[0])
|
||||
{
|
||||
pfx = "file";
|
||||
plen = 4;
|
||||
}
|
||||
else
|
||||
{
|
||||
plen = strlen (pfx);
|
||||
if (plen > 5)
|
||||
plen = 5;
|
||||
}
|
||||
|
||||
if (try_tmpdir)
|
||||
{
|
||||
d = __secure_getenv ("TMPDIR");
|
||||
if (d != NULL && direxists (d))
|
||||
dir = d;
|
||||
else if (dir != NULL && direxists (dir))
|
||||
/* nothing */ ;
|
||||
else
|
||||
dir = NULL;
|
||||
}
|
||||
if (dir == NULL)
|
||||
{
|
||||
if (direxists (P_tmpdir))
|
||||
dir = P_tmpdir;
|
||||
else if (strcmp (P_tmpdir, "/tmp") != 0 && direxists ("/tmp"))
|
||||
dir = "/tmp";
|
||||
else
|
||||
{
|
||||
__set_errno (ENOENT);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
dlen = strlen (dir);
|
||||
while (dlen > 1 && dir[dlen - 1] == '/')
|
||||
dlen--; /* remove trailing slashes */
|
||||
|
||||
/* check we have room for "${dir}/${pfx}XXXXXX\0" */
|
||||
if (tmpl_len < dlen + 1 + plen + 6 + 1)
|
||||
{
|
||||
__set_errno (EINVAL);
|
||||
return -1;
|
||||
}
|
||||
|
||||
sprintf (tmpl, "%.*s/%.*sXXXXXX", (int) dlen, dir, (int) plen, pfx);
|
||||
return 0;
|
||||
}
|
||||
#endif /* _LIBC */
|
||||
|
||||
static inline bool
|
||||
check_x_suffix (char const *s, size_t len)
|
||||
{
|
||||
return strspn (s, "X") == len;
|
||||
}
|
||||
|
||||
/* These are the characters used in temporary file names. */
|
||||
static const char letters[] =
|
||||
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
||||
|
||||
/* Generate a temporary file name based on TMPL. TMPL must end in a
|
||||
a sequence of at least X_SUFFIX_LEN "X"s. The name constructed
|
||||
does not exist at the time of the call to __gen_tempname. TMPL is
|
||||
overwritten with the result.
|
||||
|
||||
KIND may be one of:
|
||||
__GT_NOCREATE: simply verify that the name does not exist
|
||||
at the time of the call.
|
||||
__GT_FILE: create the file using open(O_CREAT|O_EXCL)
|
||||
and return a read-write fd. The file is mode 0600.
|
||||
__GT_BIGFILE: same as __GT_FILE but use open64().
|
||||
__GT_DIR: create a directory, which will be mode 0700.
|
||||
|
||||
We use a clever algorithm to get hard-to-predict names. */
|
||||
int
|
||||
gen_tempname_len (char *tmpl, int kind, size_t x_suffix_len)
|
||||
{
|
||||
size_t len;
|
||||
char *XXXXXX;
|
||||
unsigned int count;
|
||||
int fd = -1;
|
||||
int save_errno = errno;
|
||||
struct_stat64 st;
|
||||
struct randint_source *rand_src;
|
||||
|
||||
/* A lower bound on the number of temporary files to attempt to
|
||||
generate. The maximum total number of temporary file names that
|
||||
can exist for a given template is 62**6. It should never be
|
||||
necessary to try all these combinations. Instead if a reasonable
|
||||
number of names is tried (we define reasonable as 62**3) fail to
|
||||
give the system administrator the chance to remove the problems. */
|
||||
#define ATTEMPTS_MIN (62 * 62 * 62)
|
||||
|
||||
/* The number of times to attempt to generate a temporary file. To
|
||||
conform to POSIX, this must be no smaller than TMP_MAX. */
|
||||
#if ATTEMPTS_MIN < TMP_MAX
|
||||
unsigned int attempts = TMP_MAX;
|
||||
#else
|
||||
unsigned int attempts = ATTEMPTS_MIN;
|
||||
#endif
|
||||
|
||||
len = strlen (tmpl);
|
||||
if (len < x_suffix_len || ! check_x_suffix (&tmpl[len - x_suffix_len],
|
||||
x_suffix_len))
|
||||
{
|
||||
__set_errno (EINVAL);
|
||||
return -1;
|
||||
}
|
||||
|
||||
rand_src = randint_all_new (NULL, 8);
|
||||
if (! rand_src)
|
||||
return -1;
|
||||
|
||||
/* This is where the Xs start. */
|
||||
XXXXXX = &tmpl[len - x_suffix_len];
|
||||
|
||||
for (count = 0; count < attempts; ++count)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < x_suffix_len; i++)
|
||||
{
|
||||
XXXXXX[i] = letters[randint_genmax (rand_src, sizeof letters - 2)];
|
||||
}
|
||||
|
||||
switch (kind)
|
||||
{
|
||||
case __GT_FILE:
|
||||
fd = small_open (tmpl, O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR);
|
||||
break;
|
||||
|
||||
case __GT_BIGFILE:
|
||||
fd = large_open (tmpl, O_RDWR | O_CREAT | O_EXCL, S_IRUSR | S_IWUSR);
|
||||
break;
|
||||
|
||||
case __GT_DIR:
|
||||
fd = __mkdir (tmpl, S_IRUSR | S_IWUSR | S_IXUSR);
|
||||
break;
|
||||
|
||||
case __GT_NOCREATE:
|
||||
/* This case is backward from the other three. This function
|
||||
succeeds if __xstat fails because the name does not exist.
|
||||
Note the continue to bypass the common logic at the bottom
|
||||
of the loop. */
|
||||
if (__lxstat64 (_STAT_VER, tmpl, &st) < 0)
|
||||
{
|
||||
if (errno == ENOENT)
|
||||
{
|
||||
__set_errno (save_errno);
|
||||
fd = 0;
|
||||
goto done;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Give up now. */
|
||||
fd = -1;
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
continue;
|
||||
|
||||
default:
|
||||
assert (! "invalid KIND in __gen_tempname");
|
||||
}
|
||||
|
||||
if (fd >= 0)
|
||||
{
|
||||
__set_errno (save_errno);
|
||||
goto done;
|
||||
}
|
||||
else if (errno != EEXIST)
|
||||
{
|
||||
fd = -1;
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
|
||||
randint_all_free (rand_src);
|
||||
|
||||
/* We got out of the loop because we ran out of combinations to try. */
|
||||
__set_errno (EEXIST);
|
||||
return -1;
|
||||
|
||||
done:
|
||||
{
|
||||
int saved_errno = errno;
|
||||
randint_all_free (rand_src);
|
||||
__set_errno (saved_errno);
|
||||
}
|
||||
return fd;
|
||||
}
|
||||
|
||||
int
|
||||
__gen_tempname (char *tmpl, int kind)
|
||||
{
|
||||
return gen_tempname_len (tmpl, kind, 6);
|
||||
}
|
||||
193
gl/lib/tempname.c.diff
Normal file
193
gl/lib/tempname.c.diff
Normal file
@@ -0,0 +1,193 @@
|
||||
diff --git c/lib/tempname.c i/lib/tempname.c
|
||||
index 2da5afe..562955a 100644
|
||||
--- c/lib/tempname.c
|
||||
+++ i/lib/tempname.c
|
||||
@@ -22,6 +22,7 @@
|
||||
#if !_LIBC
|
||||
# include <config.h>
|
||||
# include "tempname.h"
|
||||
+# include "randint.h"
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
@@ -49,6 +50,7 @@
|
||||
# error report this to bug-gnulib@gnu.org
|
||||
#endif
|
||||
|
||||
+#include <stdbool.h>
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
@@ -179,14 +181,21 @@ __path_search (char *tmpl, size_t tmpl_len, const char *dir, const char *pfx,
|
||||
}
|
||||
#endif /* _LIBC */
|
||||
|
||||
+static inline bool
|
||||
+check_x_suffix (char const *s, size_t len)
|
||||
+{
|
||||
+ return len <= strspn (s, "X");
|
||||
+}
|
||||
+
|
||||
/* These are the characters used in temporary file names. */
|
||||
static const char letters[] =
|
||||
"abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
|
||||
|
||||
/* Generate a temporary file name based on TMPL. TMPL must match the
|
||||
- rules for mk[s]temp (i.e. end in "XXXXXX", possibly with a suffix).
|
||||
+ rules for mk[s]temp (i.e. end in at least X_SUFFIX_LEN "X"s,
|
||||
+ possibly with a suffix).
|
||||
The name constructed does not exist at the time of the call to
|
||||
- __gen_tempname. TMPL is overwritten with the result.
|
||||
+ this function. TMPL is overwritten with the result.
|
||||
|
||||
KIND may be one of:
|
||||
__GT_NOCREATE: simply verify that the name does not exist
|
||||
@@ -197,23 +206,24 @@ static const char letters[] =
|
||||
|
||||
We use a clever algorithm to get hard-to-predict names. */
|
||||
int
|
||||
-__gen_tempname (char *tmpl, int suffixlen, int flags, int kind)
|
||||
+gen_tempname_len (char *tmpl, int suffixlen, int flags, int kind,
|
||||
+ size_t x_suffix_len)
|
||||
{
|
||||
- int len;
|
||||
+ size_t len;
|
||||
char *XXXXXX;
|
||||
- static uint64_t value;
|
||||
- uint64_t random_time_bits;
|
||||
unsigned int count;
|
||||
int fd = -1;
|
||||
int save_errno = errno;
|
||||
struct_stat64 st;
|
||||
+ struct randint_source *rand_src;
|
||||
|
||||
/* A lower bound on the number of temporary files to attempt to
|
||||
generate. The maximum total number of temporary file names that
|
||||
can exist for a given template is 62**6. It should never be
|
||||
necessary to try all these combinations. Instead if a reasonable
|
||||
number of names is tried (we define reasonable as 62**3) fail to
|
||||
- give the system administrator the chance to remove the problems. */
|
||||
+ give the system administrator the chance to remove the problems.
|
||||
+ This value requires that X_SUFFIX_LEN be at least 3. */
|
||||
#define ATTEMPTS_MIN (62 * 62 * 62)
|
||||
|
||||
/* The number of times to attempt to generate a temporary file. To
|
||||
@@ -225,43 +235,28 @@ __gen_tempname (char *tmpl, int suffixlen, int flags, int kind)
|
||||
#endif
|
||||
|
||||
len = strlen (tmpl);
|
||||
- if (len < 6 + suffixlen || memcmp (&tmpl[len - 6 - suffixlen], "XXXXXX", 6))
|
||||
+ if (len < x_suffix_len + suffixlen
|
||||
+ || ! check_x_suffix (&tmpl[len - x_suffix_len - suffixlen],
|
||||
+ x_suffix_len))
|
||||
{
|
||||
__set_errno (EINVAL);
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* This is where the Xs start. */
|
||||
- XXXXXX = &tmpl[len - 6 - suffixlen];
|
||||
+ XXXXXX = &tmpl[len - x_suffix_len - suffixlen];
|
||||
|
||||
/* Get some more or less random data. */
|
||||
-#ifdef RANDOM_BITS
|
||||
- RANDOM_BITS (random_time_bits);
|
||||
-#else
|
||||
- {
|
||||
- struct timeval tv;
|
||||
- __gettimeofday (&tv, NULL);
|
||||
- random_time_bits = ((uint64_t) tv.tv_usec << 16) ^ tv.tv_sec;
|
||||
- }
|
||||
-#endif
|
||||
- value += random_time_bits ^ __getpid ();
|
||||
+ rand_src = randint_all_new (NULL, 8);
|
||||
+ if (! rand_src)
|
||||
+ return -1;
|
||||
|
||||
- for (count = 0; count < attempts; value += 7777, ++count)
|
||||
+ for (count = 0; count < attempts; ++count)
|
||||
{
|
||||
- uint64_t v = value;
|
||||
-
|
||||
- /* Fill in the random bits. */
|
||||
- XXXXXX[0] = letters[v % 62];
|
||||
- v /= 62;
|
||||
- XXXXXX[1] = letters[v % 62];
|
||||
- v /= 62;
|
||||
- XXXXXX[2] = letters[v % 62];
|
||||
- v /= 62;
|
||||
- XXXXXX[3] = letters[v % 62];
|
||||
- v /= 62;
|
||||
- XXXXXX[4] = letters[v % 62];
|
||||
- v /= 62;
|
||||
- XXXXXX[5] = letters[v % 62];
|
||||
+ size_t i;
|
||||
+
|
||||
+ for (i = 0; i < x_suffix_len; i++)
|
||||
+ XXXXXX[i] = letters[randint_genmax (rand_src, sizeof letters - 2)];
|
||||
|
||||
switch (kind)
|
||||
{
|
||||
@@ -276,7 +271,7 @@ __gen_tempname (char *tmpl, int suffixlen, int flags, int kind)
|
||||
break;
|
||||
|
||||
case __GT_NOCREATE:
|
||||
- /* This case is backward from the other three. __gen_tempname
|
||||
+ /* This case is backward from the other three. This function
|
||||
succeeds if __xstat fails because the name does not exist.
|
||||
Note the continue to bypass the common logic at the bottom
|
||||
of the loop. */
|
||||
@@ -285,11 +280,15 @@ __gen_tempname (char *tmpl, int suffixlen, int flags, int kind)
|
||||
if (errno == ENOENT)
|
||||
{
|
||||
__set_errno (save_errno);
|
||||
- return 0;
|
||||
+ fd = 0;
|
||||
+ goto done;
|
||||
}
|
||||
else
|
||||
- /* Give up now. */
|
||||
- return -1;
|
||||
+ {
|
||||
+ /* Give up now. */
|
||||
+ fd = -1;
|
||||
+ goto done;
|
||||
+ }
|
||||
}
|
||||
continue;
|
||||
|
||||
@@ -301,13 +300,32 @@ __gen_tempname (char *tmpl, int suffixlen, int flags, int kind)
|
||||
if (fd >= 0)
|
||||
{
|
||||
__set_errno (save_errno);
|
||||
- return fd;
|
||||
+ goto done;
|
||||
}
|
||||
else if (errno != EEXIST)
|
||||
- return -1;
|
||||
+ {
|
||||
+ fd = -1;
|
||||
+ goto done;
|
||||
+ }
|
||||
}
|
||||
|
||||
+ randint_all_free (rand_src);
|
||||
+
|
||||
/* We got out of the loop because we ran out of combinations to try. */
|
||||
__set_errno (EEXIST);
|
||||
return -1;
|
||||
+
|
||||
+ done:
|
||||
+ {
|
||||
+ int saved_errno = errno;
|
||||
+ randint_all_free (rand_src);
|
||||
+ __set_errno (saved_errno);
|
||||
+ }
|
||||
+ return fd;
|
||||
+}
|
||||
+
|
||||
+int
|
||||
+__gen_tempname (char *tmpl, int suffixlen, int flags, int kind)
|
||||
+{
|
||||
+ return gen_tempname_len (tmpl, suffixlen, flags, kind, 6);
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
/* Create a temporary file or directory.
|
||||
|
||||
Copyright (C) 2006, 2007, 2009 Free Software Foundation, Inc.
|
||||
|
||||
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
|
||||
the Free Software Foundation; either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>. */
|
||||
|
||||
/* header written by Eric Blake */
|
||||
|
||||
/* In gnulib, always prefer large files. GT_FILE maps to
|
||||
__GT_BIGFILE, not __GT_FILE, for a reason. */
|
||||
#define GT_FILE 1
|
||||
#define GT_DIR 2
|
||||
#define GT_NOCREATE 3
|
||||
|
||||
/* Generate a temporary file name based on TMPL. TMPL must match the
|
||||
rules for mk[s]temp (i.e. end in "XXXXXX"). The name constructed
|
||||
does not exist at the time of the call to gen_tempname. TMPL is
|
||||
overwritten with the result.
|
||||
|
||||
KIND may be one of:
|
||||
GT_NOCREATE: simply verify that the name does not exist
|
||||
at the time of the call.
|
||||
GT_FILE: create a large file using open(O_CREAT|O_EXCL)
|
||||
and return a read-write fd. The file is mode 0600.
|
||||
GT_DIR: create a directory, which will be mode 0700.
|
||||
|
||||
We use a clever algorithm to get hard-to-predict names. */
|
||||
#include <stddef.h>
|
||||
extern int gen_tempname (char *tmpl, int kind);
|
||||
extern int gen_tempname_len (char *tmpl, int kind, size_t x_suffix_len);
|
||||
12
gl/lib/tempname.h.diff
Normal file
12
gl/lib/tempname.h.diff
Normal file
@@ -0,0 +1,12 @@
|
||||
diff --git c/lib/tempname.h i/lib/tempname.h
|
||||
index cd69e7d..9757db2 100644
|
||||
--- c/lib/tempname.h
|
||||
+++ i/lib/tempname.h
|
||||
@@ -46,5 +46,7 @@
|
||||
|
||||
We use a clever algorithm to get hard-to-predict names. */
|
||||
extern int gen_tempname (char *tmpl, int suffixlen, int flags, int kind);
|
||||
+extern int gen_tempname_len (char *tmpl, int suffixlen, int flags, int kind,
|
||||
+ size_t x_suffix_len);
|
||||
|
||||
#endif /* GL_TEMPNAME_H */
|
||||
@@ -21,6 +21,7 @@
|
||||
#include "error.h"
|
||||
#include "exitfail.h"
|
||||
#include "quote.h"
|
||||
#include "stdio--.h"
|
||||
|
||||
#include "gettext.h"
|
||||
#define _(msgid) gettext (msgid)
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
#serial 3
|
||||
dnl Copyright (C) 2007-2009 Free Software Foundation, Inc.
|
||||
dnl This file is free software; the Free Software Foundation
|
||||
dnl gives unlimited permission to copy and/or distribute it,
|
||||
dnl with or without modifications, as long as this notice is preserved.
|
||||
|
||||
AC_DEFUN([gl_MGETGROUPS],
|
||||
[
|
||||
AC_CHECK_FUNCS([getgrouplist])
|
||||
AC_LIBOBJ([mgetgroups])
|
||||
])
|
||||
@@ -1,24 +0,0 @@
|
||||
Description:
|
||||
Return the group IDs of a user in malloc'd storage.
|
||||
|
||||
Files:
|
||||
lib/mgetgroups.c
|
||||
lib/mgetgroups.h
|
||||
m4/mgetgroups.m4
|
||||
|
||||
Depends-on:
|
||||
getugroups
|
||||
xalloc
|
||||
|
||||
configure.ac:
|
||||
gl_MGETGROUPS
|
||||
|
||||
Makefile.am:
|
||||
|
||||
Include:
|
||||
|
||||
License:
|
||||
LGPL
|
||||
|
||||
Maintainer:
|
||||
Jim Meyering
|
||||
9
gl/modules/rename-tests.diff
Normal file
9
gl/modules/rename-tests.diff
Normal file
@@ -0,0 +1,9 @@
|
||||
diff --git a/modules/rename-tests b/modules/rename-tests
|
||||
index be1b423..fea330a 100644
|
||||
--- a/modules/rename-tests
|
||||
+++ b/modules/rename-tests
|
||||
@@ -14,3 +14,4 @@ configure.ac:
|
||||
Makefile.am:
|
||||
TESTS += test-rename
|
||||
check_PROGRAMS += test-rename
|
||||
+test_rename_LDADD = $(LDADD) @LIBINTL@
|
||||
@@ -8,6 +8,7 @@ lib/xfreopen.h
|
||||
Depends-on:
|
||||
error
|
||||
exitfail
|
||||
freopen-safer
|
||||
quote
|
||||
|
||||
configure.ac:
|
||||
|
||||
2
gnulib
2
gnulib
Submodule gnulib updated: 10322ac9be...0883405cc7
@@ -1 +1,3 @@
|
||||
include gnulib.mk
|
||||
|
||||
AM_CFLAGS = $(GNULIB_WARN_CFLAGS) # $(WERROR_CFLAGS)
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
|
||||
include gnulib.mk
|
||||
|
||||
AM_CFLAGS += $(WARN_CFLAGS) # $(WERROR_CFLAGS)
|
||||
AM_CFLAGS += $(GNULIB_WARN_CFLAGS) $(WERROR_CFLAGS)
|
||||
|
||||
libcoreutils_a_SOURCES += \
|
||||
buffer-lcm.c buffer-lcm.h \
|
||||
|
||||
@@ -25,13 +25,6 @@
|
||||
|
||||
#include <unistd.h>
|
||||
|
||||
#ifndef F_OK
|
||||
# define F_OK 0
|
||||
# define X_OK 1
|
||||
# define W_OK 2
|
||||
# define R_OK 4
|
||||
#endif
|
||||
|
||||
#include "group-member.h"
|
||||
#include "stat-macros.h"
|
||||
|
||||
@@ -137,6 +130,6 @@ main (int argc, char **argv)
|
||||
|
||||
ok = euidaccess_stat (&st, mode);
|
||||
printf ("%s: %s\n", file, ok ? "y" : "n");
|
||||
exit (0);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
19
lib/xfts.c
19
lib/xfts.c
@@ -61,3 +61,22 @@ xfts_open (char * const *argv, int options,
|
||||
|
||||
return fts;
|
||||
}
|
||||
|
||||
/* When fts_read returns FTS_DC to indicate a directory cycle,
|
||||
it may or may not indicate a real problem. When a program like
|
||||
chgrp performs a recursive traversal that requires traversing
|
||||
symbolic links, it is *not* a problem. However, when invoked
|
||||
with "-P -R", it deserves a warning. The fts_options member
|
||||
records the options that control this aspect of fts's behavior,
|
||||
so test that. */
|
||||
bool
|
||||
cycle_warning_required (FTS const *fts, FTSENT const *ent)
|
||||
{
|
||||
#define ISSET(Fts,Opt) ((Fts)->fts_options & (Opt))
|
||||
/* When dereferencing no symlinks, or when dereferencing only
|
||||
those listed on the command line and we're not processing
|
||||
a command-line argument, then a cycle is a serious problem. */
|
||||
return ((ISSET (fts, FTS_PHYSICAL) && !ISSET (fts, FTS_COMFOLLOW))
|
||||
|| (ISSET (fts, FTS_PHYSICAL) && ISSET (fts, FTS_COMFOLLOW)
|
||||
&& ent->fts_level != FTS_ROOTLEVEL));
|
||||
}
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
#include <stdbool.h>
|
||||
#include "fts_.h"
|
||||
|
||||
FTS *
|
||||
xfts_open (char * const *, int options,
|
||||
int (*) (const FTSENT **, const FTSENT **));
|
||||
|
||||
bool
|
||||
cycle_warning_required (FTS const *fts, FTSENT const *ent);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#serial 24
|
||||
#serial 26
|
||||
# Check declarations for this package.
|
||||
|
||||
dnl Copyright (C) 1997-2001, 2003-2006, 2008-2009 Free Software
|
||||
@@ -35,15 +35,7 @@ AC_DEFUN([gl_CHECK_DECLS],
|
||||
getpwuid,
|
||||
ttyname], , , $headers)
|
||||
|
||||
AC_CHECK_DECLS([isblank], [], [], [#include <ctype.h>])
|
||||
|
||||
AC_CHECK_DECLS_ONCE([free])
|
||||
AC_CHECK_DECLS_ONCE([getenv])
|
||||
AC_CHECK_DECLS_ONCE([geteuid])
|
||||
AC_CHECK_DECLS_ONCE([getlogin])
|
||||
AC_CHECK_DECLS_ONCE([getuid])
|
||||
AC_CHECK_DECLS_ONCE([lseek])
|
||||
AC_CHECK_DECLS_ONCE([malloc])
|
||||
AC_CHECK_DECLS_ONCE([memchr])
|
||||
AC_CHECK_DECLS_ONCE([realloc])
|
||||
])
|
||||
|
||||
@@ -30,7 +30,9 @@ AC_DEFUN([cu_GMP],
|
||||
LIB_GMP=$ac_cv_search___gmpz_init
|
||||
AC_DEFINE([HAVE_GMP], [1],
|
||||
[Define if you have GNU libgmp (or replacement)])
|
||||
}])
|
||||
}],
|
||||
[AC_MSG_WARN([libgmp development library was not found or not usable.])
|
||||
AC_MSG_WARN([AC_PACKAGE_NAME will be built without GMP support.])])
|
||||
LIBS=$cu_saved_libs
|
||||
fi
|
||||
])
|
||||
|
||||
@@ -89,14 +89,12 @@ AC_DEFUN([coreutils_MACROS],
|
||||
tcgetpgrp \
|
||||
)
|
||||
|
||||
# for cp.c
|
||||
AC_CHECK_FUNCS_ONCE([utimensat])
|
||||
|
||||
dnl This can't use AC_REQUIRE; I'm not quite sure why.
|
||||
cu_PREREQ_STAT_PROG
|
||||
|
||||
# for dd.c and shred.c
|
||||
coreutils_saved_libs=$LIBS
|
||||
LIB_FDATASYNC=
|
||||
AC_SEARCH_LIBS([fdatasync], [rt posix4],
|
||||
[test "$ac_cv_search_fdatasync" = "none required" ||
|
||||
LIB_FDATASYNC=$ac_cv_search_fdatasync])
|
||||
@@ -118,7 +116,8 @@ AC_DEFUN([coreutils_MACROS],
|
||||
if test "X$enable_libcap" = "Xyes"; then
|
||||
AC_MSG_ERROR([libcap library was not found or not usable])
|
||||
else
|
||||
AC_MSG_WARN([libcap library was not found or not usable, support for libcap will not be built])
|
||||
AC_MSG_WARN([libcap library was not found or not usable.])
|
||||
AC_MSG_WARN([AC_PACKAGE_NAME will be built without capability support.])
|
||||
fi
|
||||
fi
|
||||
else
|
||||
|
||||
@@ -51,6 +51,7 @@ $ac_includes_default
|
||||
|
||||
# SCO-ODT-3.0 is reported to need -lufc for crypt.
|
||||
# NetBSD needs -lcrypt for crypt.
|
||||
LIB_CRYPT=
|
||||
cu_saved_libs="$LIBS"
|
||||
AC_SEARCH_LIBS([crypt], [ufc crypt],
|
||||
[test "$ac_cv_search_crypt" = "none required" ||
|
||||
|
||||
@@ -22,9 +22,12 @@ AC_DEFUN([gl_FUNC_XATTR],
|
||||
use_xattr=1
|
||||
else
|
||||
use_xattr=0
|
||||
AC_MSG_WARN([libattr development library was not found or not usable.])
|
||||
AC_MSG_WARN([AC_PACKAGE_NAME will be built without xattr support.])
|
||||
fi
|
||||
AC_DEFINE_UNQUOTED([USE_XATTR], [$use_xattr],
|
||||
[Define if you want extended attribute support.])
|
||||
LIB_XATTR=
|
||||
xattr_saved_LIBS=$LIBS
|
||||
AC_SEARCH_LIBS([attr_copy_file], [attr],
|
||||
[test "$ac_cv_search_attr_copy_file" = "none required" ||
|
||||
|
||||
1
man/.gitignore
vendored
1
man/.gitignore
vendored
@@ -48,6 +48,7 @@ mv.1
|
||||
nice.1
|
||||
nl.1
|
||||
nohup.1
|
||||
nproc.1
|
||||
od.1
|
||||
paste.1
|
||||
pathchk.1
|
||||
|
||||
@@ -80,6 +80,7 @@ mv.1: $(common_dep) $(srcdir)/mv.x ../src/mv.c
|
||||
nice.1: $(common_dep) $(srcdir)/nice.x ../src/nice.c
|
||||
nl.1: $(common_dep) $(srcdir)/nl.x ../src/nl.c
|
||||
nohup.1: $(common_dep) $(srcdir)/nohup.x ../src/nohup.c
|
||||
nproc.1: $(common_dep) $(srcdir)/nproc.x ../src/nproc.c
|
||||
od.1: $(common_dep) $(srcdir)/od.x ../src/od.c
|
||||
paste.1: $(common_dep) $(srcdir)/paste.x ../src/paste.c
|
||||
pathchk.1: $(common_dep) $(srcdir)/pathchk.x ../src/pathchk.c
|
||||
|
||||
@@ -373,6 +373,7 @@ my $PAT_AUTHOR = _('Written +by');
|
||||
my $PAT_OPTIONS = _('Options');
|
||||
my $PAT_EXAMPLES = _('Examples');
|
||||
my $PAT_FREE_SOFTWARE = _('This +is +free +software');
|
||||
my $PAT_INFO = _('For +complete +documentation');
|
||||
|
||||
# Start a new paragraph (if required) for these.
|
||||
s/([^\n])\n($PAT_BUGS|$PAT_AUTHOR)/$1\n\n$2/og;
|
||||
@@ -392,6 +393,11 @@ while (length)
|
||||
$sect = _('EXAMPLES');
|
||||
next;
|
||||
}
|
||||
# Skip any texinfo reference as that's handled separately
|
||||
if (s/($PAT_INFO).*\n//o)
|
||||
{
|
||||
next;
|
||||
}
|
||||
|
||||
# Copyright section
|
||||
if (/^Copyright +[(\xa9]/)
|
||||
|
||||
4
man/nproc.x
Normal file
4
man/nproc.x
Normal file
@@ -0,0 +1,4 @@
|
||||
[NAME]
|
||||
nproc \- print the number of processing units available
|
||||
[DESCRIPTION]
|
||||
.\" Add any additional description here
|
||||
@@ -20,6 +20,8 @@ lib/regcomp.c
|
||||
lib/root-dev-ino.h
|
||||
lib/rpmatch.c
|
||||
lib/set-mode-acl.c
|
||||
lib/siglist.h
|
||||
lib/strsignal.c
|
||||
lib/unicodeio.c
|
||||
lib/userspec.c
|
||||
lib/verror.c
|
||||
@@ -87,6 +89,7 @@ src/mv.c
|
||||
src/nice.c
|
||||
src/nl.c
|
||||
src/nohup.c
|
||||
src/nproc.c
|
||||
src/od.c
|
||||
src/operand2sig.c
|
||||
src/paste.c
|
||||
|
||||
1
src/.gitignore
vendored
1
src/.gitignore
vendored
@@ -56,6 +56,7 @@ mv
|
||||
nice
|
||||
nl
|
||||
nohup
|
||||
nproc
|
||||
od
|
||||
paste
|
||||
pathchk
|
||||
|
||||
434
src/Makefile.am
434
src/Makefile.am
@@ -24,25 +24,115 @@ no_install__progs = \
|
||||
arch hostname su
|
||||
|
||||
build_if_possible__progs = \
|
||||
chroot df hostid nice pinky stdbuf libstdbuf.so stty su uname uptime users who
|
||||
chroot \
|
||||
df \
|
||||
hostid \
|
||||
libstdbuf.so \
|
||||
nice \
|
||||
pinky \
|
||||
stdbuf \
|
||||
stty \
|
||||
su \
|
||||
uptime \
|
||||
users \
|
||||
who
|
||||
|
||||
AM_CFLAGS = $(WARN_CFLAGS) $(WERROR_CFLAGS)
|
||||
|
||||
EXTRA_PROGRAMS = \
|
||||
$(no_install__progs) \
|
||||
$(build_if_possible__progs) \
|
||||
[ chcon chgrp chown chmod cp dd dircolors du \
|
||||
ginstall link ln dir vdir ls mkdir \
|
||||
mkfifo mknod mktemp \
|
||||
mv nohup readlink rm rmdir shred stat sync touch unlink \
|
||||
cat cksum comm csplit cut expand fmt fold head join groups md5sum \
|
||||
nl od paste pr ptx sha1sum sha224sum sha256sum sha384sum sha512sum \
|
||||
shuf sort split sum tac tail tr tsort unexpand uniq wc \
|
||||
basename date dirname echo env expr factor false \
|
||||
id kill logname pathchk printenv printf pwd \
|
||||
runcon seq sleep tee \
|
||||
test timeout true truncate tty whoami yes \
|
||||
base64
|
||||
[ \
|
||||
base64 \
|
||||
basename \
|
||||
cat \
|
||||
chcon \
|
||||
chgrp \
|
||||
chmod \
|
||||
chown \
|
||||
cksum \
|
||||
comm \
|
||||
cp \
|
||||
csplit \
|
||||
cut \
|
||||
date \
|
||||
dd \
|
||||
dir \
|
||||
dircolors \
|
||||
dirname \
|
||||
du \
|
||||
echo \
|
||||
env \
|
||||
expand \
|
||||
expr \
|
||||
factor \
|
||||
false \
|
||||
fmt \
|
||||
fold \
|
||||
ginstall \
|
||||
groups \
|
||||
head \
|
||||
id \
|
||||
join \
|
||||
kill \
|
||||
link \
|
||||
ln \
|
||||
logname \
|
||||
ls \
|
||||
md5sum \
|
||||
mkdir \
|
||||
mkfifo \
|
||||
mknod \
|
||||
mktemp \
|
||||
mv \
|
||||
nl \
|
||||
nproc \
|
||||
nohup \
|
||||
od \
|
||||
paste \
|
||||
pathchk \
|
||||
pr \
|
||||
printenv \
|
||||
printf \
|
||||
ptx \
|
||||
pwd \
|
||||
readlink \
|
||||
rm \
|
||||
rmdir \
|
||||
runcon \
|
||||
seq \
|
||||
sha1sum \
|
||||
sha224sum \
|
||||
sha256sum \
|
||||
sha384sum \
|
||||
sha512sum \
|
||||
shred \
|
||||
shuf \
|
||||
sleep \
|
||||
sort \
|
||||
split \
|
||||
stat \
|
||||
sum \
|
||||
sync \
|
||||
tac \
|
||||
tail \
|
||||
tee \
|
||||
test \
|
||||
timeout \
|
||||
touch \
|
||||
tr \
|
||||
true \
|
||||
truncate \
|
||||
tsort \
|
||||
tty \
|
||||
uname \
|
||||
unexpand \
|
||||
uniq \
|
||||
unlink \
|
||||
vdir \
|
||||
wc \
|
||||
whoami \
|
||||
yes
|
||||
|
||||
bin_PROGRAMS = $(OPTIONAL_BIN_PROGS)
|
||||
|
||||
@@ -50,20 +140,20 @@ noinst_PROGRAMS = setuidgid getlimits
|
||||
|
||||
pkglib_PROGRAMS = $(OPTIONAL_PKGLIB_PROGS)
|
||||
|
||||
noinst_HEADERS = \
|
||||
chown-core.h \
|
||||
copy.h \
|
||||
cp-hash.h \
|
||||
dircolors.h \
|
||||
fs.h \
|
||||
group-list.h \
|
||||
ls.h \
|
||||
operand2sig.h \
|
||||
prog-fprintf.h \
|
||||
remove.h \
|
||||
system.h \
|
||||
wheel-size.h \
|
||||
wheel.h \
|
||||
noinst_HEADERS = \
|
||||
chown-core.h \
|
||||
copy.h \
|
||||
cp-hash.h \
|
||||
dircolors.h \
|
||||
fs.h \
|
||||
group-list.h \
|
||||
ls.h \
|
||||
operand2sig.h \
|
||||
prog-fprintf.h \
|
||||
remove.h \
|
||||
system.h \
|
||||
wheel-size.h \
|
||||
wheel.h \
|
||||
uname.h
|
||||
|
||||
EXTRA_DIST = dcgen dircolors.hin tac-pipe.c \
|
||||
@@ -87,99 +177,217 @@ nodist_libver_a_SOURCES = version.c version.h
|
||||
# replacement functions defined in libcoreutils.a.
|
||||
LDADD = libver.a ../lib/libcoreutils.a $(LIBINTL) ../lib/libcoreutils.a
|
||||
|
||||
# First, list all programs, to make listing per-program libraries easier.
|
||||
# See [ below.
|
||||
arch_LDADD = $(LDADD)
|
||||
base64_LDADD = $(LDADD)
|
||||
basename_LDADD = $(LDADD)
|
||||
cat_LDADD = $(LDADD)
|
||||
chcon_LDADD = $(LDADD)
|
||||
chgrp_LDADD = $(LDADD)
|
||||
chmod_LDADD = $(LDADD)
|
||||
chown_LDADD = $(LDADD)
|
||||
chroot_LDADD = $(LDADD)
|
||||
cksum_LDADD = $(LDADD)
|
||||
comm_LDADD = $(LDADD)
|
||||
nproc_LDADD = $(LDADD)
|
||||
cp_LDADD = $(LDADD)
|
||||
csplit_LDADD = $(LDADD)
|
||||
cut_LDADD = $(LDADD)
|
||||
date_LDADD = $(LDADD)
|
||||
dd_LDADD = $(LDADD)
|
||||
df_LDADD = $(LDADD)
|
||||
# See dir_LDADD below
|
||||
dircolors_LDADD = $(LDADD)
|
||||
dirname_LDADD = $(LDADD)
|
||||
du_LDADD = $(LDADD)
|
||||
echo_LDADD = $(LDADD)
|
||||
env_LDADD = $(LDADD)
|
||||
expand_LDADD = $(LDADD)
|
||||
expr_LDADD = $(LDADD)
|
||||
factor_LDADD = $(LDADD)
|
||||
false_LDADD = $(LDADD)
|
||||
fmt_LDADD = $(LDADD)
|
||||
fold_LDADD = $(LDADD)
|
||||
getlimits_LDADD = $(LDADD)
|
||||
ginstall_LDADD = $(LDADD)
|
||||
groups_LDADD = $(LDADD)
|
||||
head_LDADD = $(LDADD)
|
||||
hostid_LDADD = $(LDADD)
|
||||
hostname_LDADD = $(LDADD)
|
||||
id_LDADD = $(LDADD)
|
||||
join_LDADD = $(LDADD)
|
||||
kill_LDADD = $(LDADD)
|
||||
link_LDADD = $(LDADD)
|
||||
ln_LDADD = $(LDADD)
|
||||
logname_LDADD = $(LDADD)
|
||||
ls_LDADD = $(LDADD)
|
||||
md5sum_LDADD = $(LDADD)
|
||||
mkdir_LDADD = $(LDADD)
|
||||
mkfifo_LDADD = $(LDADD)
|
||||
mknod_LDADD = $(LDADD)
|
||||
mktemp_LDADD = $(LDADD)
|
||||
mv_LDADD = $(LDADD)
|
||||
nice_LDADD = $(LDADD)
|
||||
nl_LDADD = $(LDADD)
|
||||
nohup_LDADD = $(LDADD)
|
||||
od_LDADD = $(LDADD)
|
||||
paste_LDADD = $(LDADD)
|
||||
pathchk_LDADD = $(LDADD)
|
||||
pinky_LDADD = $(LDADD)
|
||||
pr_LDADD = $(LDADD)
|
||||
printenv_LDADD = $(LDADD)
|
||||
printf_LDADD = $(LDADD)
|
||||
ptx_LDADD = $(LDADD)
|
||||
pwd_LDADD = $(LDADD)
|
||||
readlink_LDADD = $(LDADD)
|
||||
rm_LDADD = $(LDADD)
|
||||
rmdir_LDADD = $(LDADD)
|
||||
runcon_LDADD = $(LDADD)
|
||||
seq_LDADD = $(LDADD)
|
||||
setuidgid_LDADD = $(LDADD)
|
||||
sha1sum_LDADD = $(LDADD)
|
||||
sha224sum_LDADD = $(LDADD)
|
||||
sha256sum_LDADD = $(LDADD)
|
||||
sha384sum_LDADD = $(LDADD)
|
||||
sha512sum_LDADD = $(LDADD)
|
||||
shred_LDADD = $(LDADD)
|
||||
shuf_LDADD = $(LDADD)
|
||||
sleep_LDADD = $(LDADD)
|
||||
sort_LDADD = $(LDADD)
|
||||
split_LDADD = $(LDADD)
|
||||
stat_LDADD = $(LDADD)
|
||||
stdbuf_LDADD = $(LDADD)
|
||||
stty_LDADD = $(LDADD)
|
||||
su_LDADD = $(LDADD)
|
||||
sum_LDADD = $(LDADD)
|
||||
sync_LDADD = $(LDADD)
|
||||
tac_LDADD = $(LDADD)
|
||||
tail_LDADD = $(LDADD)
|
||||
tee_LDADD = $(LDADD)
|
||||
test_LDADD = $(LDADD)
|
||||
timeout_LDADD = $(LDADD)
|
||||
touch_LDADD = $(LDADD)
|
||||
tr_LDADD = $(LDADD)
|
||||
true_LDADD = $(LDADD)
|
||||
truncate_LDADD = $(LDADD)
|
||||
tsort_LDADD = $(LDADD)
|
||||
tty_LDADD = $(LDADD)
|
||||
uname_LDADD = $(LDADD)
|
||||
unexpand_LDADD = $(LDADD)
|
||||
uniq_LDADD = $(LDADD)
|
||||
unlink_LDADD = $(LDADD)
|
||||
uptime_LDADD = $(LDADD)
|
||||
users_LDADD = $(LDADD)
|
||||
# See vdir_LDADD below
|
||||
wc_LDADD = $(LDADD)
|
||||
who_LDADD = $(LDADD)
|
||||
whoami_LDADD = $(LDADD)
|
||||
yes_LDADD = $(LDADD)
|
||||
|
||||
# for eaccess in lib/euidaccess.c.
|
||||
chcon_LDADD = $(LDADD) $(LIB_SELINUX)
|
||||
cp_LDADD = $(LDADD) $(LIB_EACCESS) $(LIB_SELINUX)
|
||||
ginstall_LDADD = $(LDADD) $(LIB_EACCESS) $(LIB_SELINUX)
|
||||
mkdir_LDADD = $(LDADD) $(LIB_SELINUX)
|
||||
mkfifo_LDADD = $(LDADD) $(LIB_SELINUX)
|
||||
mknod_LDADD = $(LDADD) $(LIB_SELINUX)
|
||||
mv_LDADD = $(LDADD) $(LIB_EACCESS) $(LIB_SELINUX)
|
||||
runcon_LDADD = $(LDADD) $(LIB_SELINUX)
|
||||
pathchk_LDADD = $(LDADD) $(LIB_EACCESS)
|
||||
rm_LDADD = $(LDADD) $(LIB_EACCESS)
|
||||
test_LDADD = $(LDADD) $(LIB_EACCESS)
|
||||
# This is for the '[' program. Automake transliterates '[' to '_'.
|
||||
__LDADD = $(LDADD) $(LIB_EACCESS)
|
||||
# Synonyms. Recall that Automake transliterates '[' to '_'.
|
||||
__LDADD = $(test_LDADD)
|
||||
dir_LDADD = $(ls_LDADD)
|
||||
vdir_LDADD = $(ls_LDADD)
|
||||
|
||||
# for clock_gettime and fdatasync
|
||||
dd_LDADD = $(LDADD) $(LIB_GETHRXTIME) $(LIB_FDATASYNC)
|
||||
dir_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME) $(LIB_SELINUX) $(LIB_CAP)
|
||||
id_LDADD = $(LDADD) $(LIB_SELINUX)
|
||||
ls_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME) $(LIB_SELINUX) $(LIB_CAP)
|
||||
mktemp_LDADD = $(LDADD) $(LIB_GETHRXTIME)
|
||||
pr_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME)
|
||||
shred_LDADD = $(LDADD) $(LIB_GETHRXTIME) $(LIB_FDATASYNC)
|
||||
shuf_LDADD = $(LDADD) $(LIB_GETHRXTIME)
|
||||
tac_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME)
|
||||
vdir_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME) $(LIB_SELINUX) $(LIB_CAP)
|
||||
# Shared files
|
||||
copy_LDADD =
|
||||
cp_LDADD += $(copy_LDADD)
|
||||
ginstall_LDADD += $(copy_LDADD)
|
||||
mv_LDADD += $(copy_LDADD)
|
||||
|
||||
## If necessary, add -lm to resolve use of pow in lib/strtod.c.
|
||||
sort_LDADD = $(LDADD) $(POW_LIB) $(LIB_GETHRXTIME)
|
||||
remove_LDADD =
|
||||
mv_LDADD += $(remove_LDADD)
|
||||
rm_LDADD += $(remove_LDADD)
|
||||
|
||||
# for get_date and gettime
|
||||
date_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME)
|
||||
touch_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME)
|
||||
# for eaccess, euidaccess
|
||||
copy_LDADD += $(LIB_EACCESS)
|
||||
remove_LDADD += $(LIB_EACCESS)
|
||||
test_LDADD += $(LIB_EACCESS)
|
||||
|
||||
# If necessary, add -lm to resolve use of pow in lib/strtod.c.
|
||||
# If necessary, add -liconv to resolve use of iconv in lib/unicodeio.c.
|
||||
printf_LDADD = $(LDADD) $(POW_LIB) $(LIBICONV)
|
||||
# for selinux use
|
||||
chcon_LDADD += $(LIB_SELINUX)
|
||||
copy_LDADD += $(LIB_SELINUX)
|
||||
ginstall_LDADD += $(LIB_SELINUX)
|
||||
id_LDADD += $(LIB_SELINUX)
|
||||
ls_LDADD += $(LIB_SELINUX)
|
||||
mkdir_LDADD += $(LIB_SELINUX)
|
||||
mkfifo_LDADD += $(LIB_SELINUX)
|
||||
mknod_LDADD += $(LIB_SELINUX)
|
||||
runcon_LDADD += $(LIB_SELINUX)
|
||||
stat_LDADD += $(LIB_SELINUX)
|
||||
|
||||
# If necessary, add -lm to resolve use of pow in lib/strtod.c.
|
||||
seq_LDADD = $(LDADD) $(POW_LIB)
|
||||
# for gettime, settime, utimecmp, utimens
|
||||
copy_LDADD += $(LIB_CLOCK_GETTIME)
|
||||
date_LDADD += $(LIB_CLOCK_GETTIME)
|
||||
ginstall_LDADD += $(LIB_CLOCK_GETTIME)
|
||||
ls_LDADD += $(LIB_CLOCK_GETTIME)
|
||||
pr_LDADD += $(LIB_CLOCK_GETTIME)
|
||||
touch_LDADD += $(LIB_CLOCK_GETTIME)
|
||||
|
||||
# If necessary, add libraries to resolve the `pow' reference in lib/strtod.c
|
||||
# and the `nanosleep' reference in lib/xnanosleep.c.
|
||||
nanosec_libs = $(LDADD) $(POW_LIB) $(LIB_NANOSLEEP)
|
||||
# for gethrxtime, randint, randread, gen_tempname
|
||||
dd_LDADD += $(LIB_GETHRXTIME)
|
||||
mktemp_LDADD += $(LIB_GETHRXTIME)
|
||||
shred_LDADD += $(LIB_GETHRXTIME)
|
||||
shuf_LDADD += $(LIB_GETHRXTIME)
|
||||
sort_LDADD += $(LIB_GETHRXTIME)
|
||||
|
||||
# for cap_get_file
|
||||
ls_LDADD += $(LIB_CAP)
|
||||
|
||||
# for fdatasync
|
||||
dd_LDADD += $(LIB_FDATASYNC)
|
||||
shred_LDADD += $(LIB_FDATASYNC)
|
||||
|
||||
# for strtod, strtold
|
||||
printf_LDADD += $(POW_LIB)
|
||||
seq_LDADD += $(POW_LIB)
|
||||
sleep_LDADD += $(POW_LIB)
|
||||
sort_LDADD += $(POW_LIB)
|
||||
tail_LDADD += $(POW_LIB)
|
||||
uptime_LDADD += $(POW_LIB)
|
||||
|
||||
# for xnanosleep
|
||||
sleep_LDADD += $(LIB_NANOSLEEP)
|
||||
tail_LDADD += $(LIB_NANOSLEEP)
|
||||
|
||||
# for various GMP functions
|
||||
expr_LDADD = $(LDADD) $(LIB_GMP)
|
||||
expr_LDADD += $(LIB_GMP)
|
||||
factor_LDADD += $(LIB_GMP)
|
||||
|
||||
# for various GMP functions
|
||||
factor_LDADD = $(LDADD) $(LIB_GMP)
|
||||
# for getloadavg
|
||||
uptime_LDADD += $(GETLOADAVG_LIBS)
|
||||
|
||||
sleep_LDADD = $(nanosec_libs)
|
||||
tail_LDADD = $(nanosec_libs)
|
||||
# for crypt
|
||||
su_LDADD += $(LIB_CRYPT)
|
||||
|
||||
# If necessary, add -lm to resolve use of pow in lib/strtod.c.
|
||||
uptime_LDADD = $(LDADD) $(POW_LIB) $(GETLOADAVG_LIBS)
|
||||
|
||||
su_LDADD = $(LDADD) $(LIB_CRYPT)
|
||||
|
||||
dir_LDADD += $(LIB_ACL)
|
||||
# for various ACL functions
|
||||
copy_LDADD += $(LIB_ACL)
|
||||
ls_LDADD += $(LIB_ACL)
|
||||
vdir_LDADD += $(LIB_ACL)
|
||||
cp_LDADD += $(LIB_ACL) $(LIB_XATTR)
|
||||
mv_LDADD += $(LIB_ACL) $(LIB_XATTR)
|
||||
ginstall_LDADD += $(LIB_ACL) $(LIB_XATTR)
|
||||
|
||||
stat_LDADD = $(LDADD) $(LIB_SELINUX)
|
||||
# for various xattr functions
|
||||
copy_LDADD += $(LIB_XATTR)
|
||||
|
||||
# Append $(LIBICONV) to each program that uses proper_name_utf8.
|
||||
# for print_unicode_char, proper_name_utf8
|
||||
cat_LDADD += $(LIBICONV)
|
||||
cp_LDADD += $(LIBICONV)
|
||||
df_LDADD += $(LIBICONV)
|
||||
du_LDADD += $(LIBICONV)
|
||||
getlimits_LDADD += $(LIBICONV)
|
||||
printf_LDADD += $(LIBICONV)
|
||||
ptx_LDADD += $(LIBICONV)
|
||||
split_LDADD += $(LIBICONV)
|
||||
stdbuf_LDADD += $(LIBICONV)
|
||||
timeout_LDADD += $(LIBICONV)
|
||||
truncate_LDADD += $(LIBICONV)
|
||||
|
||||
# programs that use getaddrinfo (e.g., via canon_host)
|
||||
pinky_LDADD = $(LDADD) $(GETADDRINFO_LIB)
|
||||
who_LDADD = $(LDADD) $(GETADDRINFO_LIB)
|
||||
# for canon_host
|
||||
pinky_LDADD += $(GETADDRINFO_LIB)
|
||||
who_LDADD += $(GETADDRINFO_LIB)
|
||||
|
||||
# for gethostname, uname
|
||||
hostname_LDADD += $(GETHOSTNAME_LIB)
|
||||
uname_LDADD += $(GETHOSTNAME_LIB)
|
||||
|
||||
$(PROGRAMS): ../lib/libcoreutils.a
|
||||
|
||||
@@ -274,6 +482,7 @@ rmdir_SOURCES = rmdir.c prog-fprintf.c
|
||||
|
||||
uname_SOURCES = uname.c uname-uname.c
|
||||
arch_SOURCES = uname.c uname-arch.c
|
||||
nproc_SOURCES = nproc.c
|
||||
|
||||
md5sum_SOURCES = md5sum.c
|
||||
md5sum_CPPFLAGS = -DHASH_ALGO_MD5=1 $(AM_CPPFLAGS)
|
||||
@@ -330,6 +539,59 @@ wheel.h: wheel-gen.pl Makefile.am
|
||||
# Tell automake to exempt then from that installcheck test.
|
||||
AM_INSTALLCHECK_STD_OPTIONS_EXEMPT = false test
|
||||
|
||||
# Compare fs.h with the list of file system names/magic-numbers in the
|
||||
# Linux statfs man page. This target prints any new name/number pairs.
|
||||
# Also compare against /usr/include/linux/magic.h
|
||||
.PHONY: fs-magic-compare
|
||||
fs-magic-compare: fs-magic fs-kernel-magic fs-def
|
||||
join -v1 -t@ fs-magic fs-def
|
||||
join -v1 -t@ fs-kernel-magic fs-def
|
||||
|
||||
CLEANFILES += fs-def
|
||||
fs-def: fs.h
|
||||
grep '^# *define ' $< > $@-t && mv $@-t $@
|
||||
|
||||
# Massage bits of the statfs man page and definitions from
|
||||
# /usr/include/linux/magic.h to be in a form consistent with what's in fs.h.
|
||||
fs_normalize_perl_subst = \
|
||||
-e 's/MINIX_SUPER_MAGIC\b/MINIX/;' \
|
||||
-e 's/MINIX_SUPER_MAGIC2\b/MINIX_30/;' \
|
||||
-e 's/MINIX2_SUPER_MAGIC\b/MINIX_V2/;' \
|
||||
-e 's/MINIX2_SUPER_MAGIC2\b/MINIX_V2_30/;' \
|
||||
-e 's/MINIX3_SUPER_MAGIC\b/MINIX_V3/;' \
|
||||
-e 's/CIFS_MAGIC_NUMBER/CIFS/;' \
|
||||
-e 's/(_SUPER)?_MAGIC//;' \
|
||||
-e 's/\s+0x(\S+)/" 0x" . uc $$1/e;' \
|
||||
-e 's/(\s+0x)(\X{3})\b/$${1}0$$2/;' \
|
||||
-e 's/(\s+0x)(\X{6})\b/$${1}00$$2/;' \
|
||||
-e 's/(\s+0x)(\X{7})\b/$${1}0$$2/;' \
|
||||
-e 's/^\s+//;' \
|
||||
-e 's/^\#define\s+//;' \
|
||||
-e 's/^_(XIAFS)/$$1/;' \
|
||||
-e 's/^USBDEVICE/USBDEVFS/;' \
|
||||
-e 's/NTFS_SB/NTFS/;' \
|
||||
-e 's/^/\# define S_MAGIC_/;' \
|
||||
-e 's,\s*/\* .*? \*/,,;'
|
||||
|
||||
CLEANFILES += fs-magic
|
||||
fs-magic: Makefile
|
||||
man statfs \
|
||||
|perl -ne '/File system types:/.../Nobody kno/ and print' \
|
||||
|grep 0x | perl -p \
|
||||
$(fs_normalize_perl_subst) \
|
||||
| grep -Ev 'S_MAGIC_EXT[34]|STACK_END' \
|
||||
| LC_ALL=C sort \
|
||||
> $@-t && mv $@-t $@
|
||||
|
||||
CLEANFILES += fs-kernel-magic
|
||||
fs-kernel-magic: Makefile
|
||||
perl -ne '/^#define.*0x/ and print' /usr/include/linux/magic.h \
|
||||
| perl -p \
|
||||
$(fs_normalize_perl_subst) \
|
||||
| grep -Ev 'S_MAGIC_EXT[34]|STACK_END' \
|
||||
| LC_ALL=C sort \
|
||||
> $@-t && mv $@-t $@
|
||||
|
||||
BUILT_SOURCES += fs.h
|
||||
fs.h: stat.c extract-magic
|
||||
$(AM_V_GEN)rm -f $@
|
||||
@@ -453,7 +715,7 @@ sc_tight_scope: $(bin_PROGRAMS)
|
||||
( printf 'main\nusage\n_.*\n'; \
|
||||
grep -h -A1 '^extern .*[^;]$$' $$src \
|
||||
| grep -vE '^(extern |--)' | sed 's/ .*//'; \
|
||||
perl -ne '/^extern \S+ (\S*) \(/ and print "$$1\n"' $$hdr; \
|
||||
perl -ne '/^extern (?:enum )?\S+ (\S*) \(/ and print "$$1\n"' $$hdr; \
|
||||
) | $(ASSORT) -u | sed 's/^/^/;s/$$/$$/' > $$t; \
|
||||
nm -e *.$(OBJEXT) \
|
||||
| sed -n 's/.* T //p' \
|
||||
|
||||
@@ -81,7 +81,7 @@ When decoding, the input may contain newlines in addition to the bytes of\n\
|
||||
the formal base64 alphabet. Use --ignore-garbage to attempt to recover\n\
|
||||
from any other non-alphabet bytes in the encoded stream.\n"),
|
||||
stdout);
|
||||
emit_bug_reporting_address ();
|
||||
emit_ancillary_info ();
|
||||
}
|
||||
|
||||
exit (status);
|
||||
|
||||
@@ -66,7 +66,7 @@ Examples:\n\
|
||||
%s include/stdio.h .h Output \"stdio\".\n\
|
||||
"),
|
||||
program_name, program_name);
|
||||
emit_bug_reporting_address ();
|
||||
emit_ancillary_info ();
|
||||
}
|
||||
exit (status);
|
||||
}
|
||||
|
||||
10
src/cat.c
10
src/cat.c
@@ -119,7 +119,7 @@ Examples:\n\
|
||||
%s Copy standard input to standard output.\n\
|
||||
"),
|
||||
program_name, program_name);
|
||||
emit_bug_reporting_address ();
|
||||
emit_ancillary_info ();
|
||||
}
|
||||
exit (status);
|
||||
}
|
||||
@@ -388,7 +388,7 @@ cat (
|
||||
|
||||
/* Are line numbers to be written at empty lines (-n)? */
|
||||
|
||||
if (number & !number_nonblank)
|
||||
if (number && !number_nonblank)
|
||||
{
|
||||
next_line_num ();
|
||||
bpout = stpcpy (bpout, line_num_print);
|
||||
@@ -657,7 +657,7 @@ main (int argc, char **argv)
|
||||
#endif
|
||||
}
|
||||
|
||||
if (! (number | show_ends | squeeze_blank))
|
||||
if (! (number || show_ends || squeeze_blank))
|
||||
{
|
||||
file_open_mode |= O_BINARY;
|
||||
if (O_BINARY && ! isatty (STDOUT_FILENO))
|
||||
@@ -719,8 +719,8 @@ main (int argc, char **argv)
|
||||
/* Select which version of `cat' to use. If any format-oriented
|
||||
options were given use `cat'; otherwise use `simple_cat'. */
|
||||
|
||||
if (! (number | show_ends | show_nonprinting
|
||||
| show_tabs | squeeze_blank))
|
||||
if (! (number || show_ends || show_nonprinting
|
||||
|| show_tabs || squeeze_blank))
|
||||
{
|
||||
insize = MAX (insize, outsize);
|
||||
inbuf = xmalloc (insize + page_size - 1);
|
||||
|
||||
14
src/chcon.c
14
src/chcon.c
@@ -267,6 +267,14 @@ process_file (FTS *fts, FTSENT *ent)
|
||||
ok = false;
|
||||
break;
|
||||
|
||||
case FTS_DC: /* directory that causes cycles */
|
||||
if (cycle_warning_required (fts, ent))
|
||||
{
|
||||
emit_cycle_warning (file_full_name);
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -380,7 +388,7 @@ one takes effect.\n\
|
||||
"), stdout);
|
||||
fputs (HELP_OPTION_DESCRIPTION, stdout);
|
||||
fputs (VERSION_OPTION_DESCRIPTION, stdout);
|
||||
emit_bug_reporting_address ();
|
||||
emit_ancillary_info ();
|
||||
}
|
||||
exit (status);
|
||||
}
|
||||
@@ -546,10 +554,10 @@ main (int argc, char **argv)
|
||||
if (reference_file && component_specified)
|
||||
{
|
||||
error (0, 0, _("conflicting security context specifiers given"));
|
||||
usage (1);
|
||||
usage (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (recurse & preserve_root)
|
||||
if (recurse && preserve_root)
|
||||
{
|
||||
static struct dev_ino dev_ino_buf;
|
||||
root_dev_ino = get_root_dev_ino (&dev_ino_buf);
|
||||
|
||||
@@ -158,7 +158,7 @@ Examples:\n\
|
||||
%s -hR staff /u Change the group of /u and subfiles to \"staff\".\n\
|
||||
"),
|
||||
program_name, program_name);
|
||||
emit_bug_reporting_address ();
|
||||
emit_ancillary_info ();
|
||||
}
|
||||
exit (status);
|
||||
}
|
||||
@@ -293,7 +293,7 @@ main (int argc, char **argv)
|
||||
gid = parse_group (group_name);
|
||||
}
|
||||
|
||||
if (chopt.recurse & preserve_root)
|
||||
if (chopt.recurse && preserve_root)
|
||||
{
|
||||
static struct dev_ino dev_ino_buf;
|
||||
chopt.root_dev_ino = get_root_dev_ino (&dev_ino_buf);
|
||||
|
||||
15
src/chmod.c
15
src/chmod.c
@@ -228,6 +228,15 @@ process_file (FTS *fts, FTSENT *ent)
|
||||
error (0, 0, _("cannot operate on dangling symlink %s"),
|
||||
quote (file_full_name));
|
||||
ok = false;
|
||||
break;
|
||||
|
||||
case FTS_DC: /* directory that causes cycles */
|
||||
if (cycle_warning_required (fts, ent))
|
||||
{
|
||||
emit_cycle_warning (file_full_name);
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
@@ -279,7 +288,7 @@ process_file (FTS *fts, FTSENT *ent)
|
||||
}
|
||||
}
|
||||
|
||||
if (chmod_succeeded & diagnose_surprises)
|
||||
if (chmod_succeeded && diagnose_surprises)
|
||||
{
|
||||
mode_t naively_expected_mode =
|
||||
mode_adjust (old_mode, S_ISDIR (old_mode) != 0, 0, change, NULL);
|
||||
@@ -379,7 +388,7 @@ Change the mode of each FILE to MODE.\n\
|
||||
\n\
|
||||
Each MODE is of the form `[ugoa]*([-+=]([rwxXst]*|[ugo]))+'.\n\
|
||||
"), stdout);
|
||||
emit_bug_reporting_address ();
|
||||
emit_ancillary_info ();
|
||||
}
|
||||
exit (status);
|
||||
}
|
||||
@@ -523,7 +532,7 @@ main (int argc, char **argv)
|
||||
umask_value = umask (0);
|
||||
}
|
||||
|
||||
if (recurse & preserve_root)
|
||||
if (recurse && preserve_root)
|
||||
{
|
||||
static struct dev_ino dev_ino_buf;
|
||||
root_dev_ino = get_root_dev_ino (&dev_ino_buf);
|
||||
|
||||
@@ -316,6 +316,14 @@ change_file_owner (FTS *fts, FTSENT *ent,
|
||||
ok = false;
|
||||
break;
|
||||
|
||||
case FTS_DC: /* directory that causes cycles */
|
||||
if (cycle_warning_required (fts, ent))
|
||||
{
|
||||
emit_cycle_warning (file_full_name);
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@@ -440,7 +448,7 @@ change_file_owner (FTS *fts, FTSENT *ent,
|
||||
if (chopt->verbosity != V_off)
|
||||
{
|
||||
bool changed =
|
||||
((do_chown & ok & symlink_changed)
|
||||
((do_chown && ok && symlink_changed)
|
||||
&& ! ((uid == (uid_t) -1 || uid == file_stats->st_uid)
|
||||
&& (gid == (gid_t) -1 || gid == file_stats->st_gid)));
|
||||
|
||||
|
||||
@@ -153,7 +153,7 @@ Examples:\n\
|
||||
%s -hR root /u Change the owner of /u and subfiles to \"root\".\n\
|
||||
"),
|
||||
program_name, program_name, program_name);
|
||||
emit_bug_reporting_address ();
|
||||
emit_ancillary_info ();
|
||||
}
|
||||
exit (status);
|
||||
}
|
||||
@@ -317,7 +317,7 @@ main (int argc, char **argv)
|
||||
optind++;
|
||||
}
|
||||
|
||||
if (chopt.recurse & preserve_root)
|
||||
if (chopt.recurse && preserve_root)
|
||||
{
|
||||
static struct dev_ino dev_ino_buf;
|
||||
chopt.root_dev_ino = get_root_dev_ino (&dev_ino_buf);
|
||||
|
||||
18
src/chroot.c
18
src/chroot.c
@@ -91,7 +91,7 @@ set_additional_groups (char const *groups)
|
||||
}
|
||||
|
||||
if (n_gids == n_gids_allocated)
|
||||
gids = x2nrealloc (gids, &n_gids_allocated, sizeof *gids);
|
||||
gids = X2NREALLOC (gids, &n_gids_allocated);
|
||||
gids[n_gids++] = value;
|
||||
}
|
||||
|
||||
@@ -142,7 +142,7 @@ Run COMMAND with root directory set to NEWROOT.\n\
|
||||
\n\
|
||||
If no command is given, run ``${SHELL} -i'' (default: /bin/sh).\n\
|
||||
"), stdout);
|
||||
emit_bug_reporting_address ();
|
||||
emit_ancillary_info ();
|
||||
}
|
||||
exit (status);
|
||||
}
|
||||
@@ -160,7 +160,7 @@ main (int argc, char **argv)
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
initialize_exit_failure (EXIT_FAILURE);
|
||||
initialize_exit_failure (EXIT_CANCELED);
|
||||
atexit (close_stdout);
|
||||
|
||||
parse_long_options (argc, argv, PROGRAM_NAME, PACKAGE_NAME, Version,
|
||||
@@ -177,22 +177,22 @@ main (int argc, char **argv)
|
||||
groups = optarg;
|
||||
break;
|
||||
default:
|
||||
usage (EXIT_FAILURE);
|
||||
usage (EXIT_CANCELED);
|
||||
}
|
||||
}
|
||||
|
||||
if (argc <= optind)
|
||||
{
|
||||
error (0, 0, _("missing operand"));
|
||||
usage (EXIT_FAILURE);
|
||||
usage (EXIT_CANCELED);
|
||||
}
|
||||
|
||||
if (chroot (argv[optind]) != 0)
|
||||
error (EXIT_FAILURE, errno, _("cannot change root directory to %s"),
|
||||
error (EXIT_CANCELED, errno, _("cannot change root directory to %s"),
|
||||
argv[optind]);
|
||||
|
||||
if (chdir ("/"))
|
||||
error (EXIT_FAILURE, errno, _("cannot chdir to root directory"));
|
||||
error (EXIT_CANCELED, errno, _("cannot chdir to root directory"));
|
||||
|
||||
if (argc == optind + 1)
|
||||
{
|
||||
@@ -223,7 +223,7 @@ main (int argc, char **argv)
|
||||
char const *err = parse_user_spec (userspec, &uid, &gid, &user, &group);
|
||||
|
||||
if (err)
|
||||
error (EXIT_FAILURE, errno, "%s", err);
|
||||
error (EXIT_CANCELED, errno, "%s", err);
|
||||
|
||||
free (user);
|
||||
free (group);
|
||||
@@ -254,7 +254,7 @@ main (int argc, char **argv)
|
||||
}
|
||||
|
||||
if (fail)
|
||||
exit (EXIT_FAILURE);
|
||||
exit (EXIT_CANCELED);
|
||||
|
||||
/* Execute the given command. */
|
||||
execvp (argv[0], argv);
|
||||
|
||||
@@ -269,7 +269,7 @@ Print CRC checksum and byte counts of each FILE.\n\
|
||||
"), stdout);
|
||||
fputs (HELP_OPTION_DESCRIPTION, stdout);
|
||||
fputs (VERSION_OPTION_DESCRIPTION, stdout);
|
||||
emit_bug_reporting_address ();
|
||||
emit_ancillary_info ();
|
||||
}
|
||||
exit (status);
|
||||
}
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "system.h"
|
||||
#include "linebuffer.h"
|
||||
#include "error.h"
|
||||
#include "hard-locale.h"
|
||||
#include "quote.h"
|
||||
#include "stdio--.h"
|
||||
#include "memcmp2.h"
|
||||
@@ -140,7 +141,7 @@ Examples:\n\
|
||||
%s -3 file1 file2 Print lines in file1 not in file2, and vice versa.\n\
|
||||
"),
|
||||
program_name, program_name);
|
||||
emit_bug_reporting_address ();
|
||||
emit_ancillary_info ();
|
||||
}
|
||||
exit (status);
|
||||
}
|
||||
|
||||
63
src/copy.c
63
src/copy.c
@@ -123,17 +123,12 @@ static char const *top_level_dst_name;
|
||||
static inline int
|
||||
utimens_symlink (char const *file, struct timespec const *timespec)
|
||||
{
|
||||
int err = 0;
|
||||
|
||||
#if HAVE_UTIMENSAT
|
||||
err = utimensat (AT_FDCWD, file, timespec, AT_SYMLINK_NOFOLLOW);
|
||||
int err = lutimens (file, timespec);
|
||||
/* When configuring on a system with new headers and libraries, and
|
||||
running on one with a kernel that is old enough to lack the syscall,
|
||||
utimensat fails with ENOSYS. Ignore that. */
|
||||
if (err && errno == ENOSYS)
|
||||
err = 0;
|
||||
#endif
|
||||
|
||||
return err;
|
||||
}
|
||||
|
||||
@@ -360,11 +355,11 @@ set_owner (const struct cp_options *x, char const *dst_name, int dest_desc,
|
||||
group. Avoid the window by first changing to a restrictive
|
||||
temporary mode if necessary. */
|
||||
|
||||
if (!new_dst && (x->preserve_mode | x->move_mode | x->set_mode))
|
||||
if (!new_dst && (x->preserve_mode || x->move_mode || x->set_mode))
|
||||
{
|
||||
mode_t old_mode = dst_sb->st_mode;
|
||||
mode_t new_mode =
|
||||
(x->preserve_mode | x->move_mode ? src_sb->st_mode : x->mode);
|
||||
(x->preserve_mode || x->move_mode ? src_sb->st_mode : x->mode);
|
||||
mode_t restrictive_temp_mode = old_mode & new_mode & S_IRWXU;
|
||||
|
||||
if ((USE_ACL
|
||||
@@ -834,6 +829,24 @@ copy_reg (char const *src_name, char const *dst_name,
|
||||
}
|
||||
}
|
||||
|
||||
/* To allow copying xattrs on read-only files, temporarily chmod u+rw.
|
||||
This workaround is required as an inode permission check is done
|
||||
by xattr_permission() in fs/xattr.c of the GNU/Linux kernel tree. */
|
||||
if (x->preserve_xattr)
|
||||
{
|
||||
bool access_changed = false;
|
||||
|
||||
if (!(sb.st_mode & S_IWUSR) && geteuid() != 0)
|
||||
access_changed = fchmod_or_lchmod (dest_desc, dst_name, 0600) == 0;
|
||||
|
||||
if (!copy_attr_by_fd (src_name, source_desc, dst_name, dest_desc, x)
|
||||
&& x->require_preserve_xattr)
|
||||
return_val = false;
|
||||
|
||||
if (access_changed)
|
||||
fchmod_or_lchmod (dest_desc, dst_name, dst_mode & ~omitted_permissions);
|
||||
}
|
||||
|
||||
if (x->preserve_ownership && ! SAME_OWNER_AND_GROUP (*src_sb, sb))
|
||||
{
|
||||
switch (set_owner (x, dst_name, dest_desc, src_sb, *new_dst, &sb))
|
||||
@@ -850,11 +863,6 @@ copy_reg (char const *src_name, char const *dst_name,
|
||||
|
||||
set_author (dst_name, dest_desc, src_sb);
|
||||
|
||||
if (x->preserve_xattr && ! copy_attr_by_fd (src_name, source_desc,
|
||||
dst_name, dest_desc, x)
|
||||
&& x->require_preserve_xattr)
|
||||
return_val = false;
|
||||
|
||||
if (x->preserve_mode || x->move_mode)
|
||||
{
|
||||
if (copy_acl (src_name, source_desc, dst_name, dest_desc, src_mode) != 0
|
||||
@@ -1671,7 +1679,9 @@ copy_internal (char const *src_name, char const *dst_name,
|
||||
}
|
||||
else
|
||||
{
|
||||
bool link_failed = (link (earlier_file, dst_name) != 0);
|
||||
/* We want to guarantee that symlinks are not followed. */
|
||||
bool link_failed = (linkat (AT_FDCWD, earlier_file, AT_FDCWD,
|
||||
dst_name, 0) != 0);
|
||||
|
||||
/* If the link failed because of an existing destination,
|
||||
remove that file and then call link again. */
|
||||
@@ -1684,7 +1694,8 @@ copy_internal (char const *src_name, char const *dst_name,
|
||||
}
|
||||
if (x->verbose)
|
||||
printf (_("removed %s\n"), quote (dst_name));
|
||||
link_failed = (link (earlier_file, dst_name) != 0);
|
||||
link_failed = (linkat (AT_FDCWD, earlier_file, AT_FDCWD,
|
||||
dst_name, 0) != 0);
|
||||
}
|
||||
|
||||
if (link_failed)
|
||||
@@ -1974,25 +1985,15 @@ copy_internal (char const *src_name, char const *dst_name,
|
||||
}
|
||||
}
|
||||
|
||||
/* POSIX 2008 states that it is implementation-defined whether
|
||||
link() on a symlink creates a hard-link to the symlink, or only
|
||||
to the referent (effectively dereferencing the symlink) (POSIX
|
||||
2001 required the latter behavior, although many systems provided
|
||||
the former). Yet cp, invoked with `--link --no-dereference',
|
||||
should not follow the link. We can approximate the desired
|
||||
behavior by skipping this hard-link creating block and instead
|
||||
copying the symlink, via the `S_ISLNK'- copying code below.
|
||||
LINK_FOLLOWS_SYMLINKS is tri-state; if it is -1, we don't know
|
||||
how link() behaves, so we use the fallback case for safety.
|
||||
|
||||
FIXME - use a gnulib linkat emulation for more fine-tuned
|
||||
emulation, particularly when LINK_FOLLOWS_SYMLINKS is -1. */
|
||||
/* cp, invoked with `--link --no-dereference', should not follow the
|
||||
link; we guarantee this with gnulib's linkat module (on systems
|
||||
where link(2) follows the link, gnulib creates a symlink with
|
||||
identical contents, which is good enough for our purposes). */
|
||||
else if (x->hard_link
|
||||
&& (!LINK_FOLLOWS_SYMLINKS
|
||||
|| !S_ISLNK (src_mode)
|
||||
&& (!S_ISLNK (src_mode)
|
||||
|| x->dereference != DEREF_NEVER))
|
||||
{
|
||||
if (link (src_name, dst_name))
|
||||
if (linkat (AT_FDCWD, src_name, AT_FDCWD, dst_name, 0))
|
||||
{
|
||||
error (0, errno, _("cannot create link %s"), quote (dst_name));
|
||||
goto un_backup;
|
||||
|
||||
6
src/cp.c
6
src/cp.c
@@ -257,7 +257,7 @@ As a special case, cp makes a backup of SOURCE when the force and backup\n\
|
||||
options are given and SOURCE and DEST are the same name for an existing,\n\
|
||||
regular file.\n\
|
||||
"), stdout);
|
||||
emit_bug_reporting_address ();
|
||||
emit_ancillary_info ();
|
||||
}
|
||||
exit (status);
|
||||
}
|
||||
@@ -1089,7 +1089,7 @@ main (int argc, char **argv)
|
||||
}
|
||||
}
|
||||
|
||||
if (x.hard_link & x.symbolic_link)
|
||||
if (x.hard_link && x.symbolic_link)
|
||||
{
|
||||
error (0, 0, _("cannot make both hard and symbolic links"));
|
||||
usage (EXIT_FAILURE);
|
||||
@@ -1130,7 +1130,7 @@ main (int argc, char **argv)
|
||||
|
||||
/* If --force (-f) was specified and we're in link-creation mode,
|
||||
first remove any existing destination file. */
|
||||
if (x.unlink_dest_after_failed_open & (x.hard_link | x.symbolic_link))
|
||||
if (x.unlink_dest_after_failed_open && (x.hard_link || x.symbolic_link))
|
||||
x.unlink_dest_before_opening = true;
|
||||
|
||||
if (x.preserve_security_context)
|
||||
|
||||
@@ -1481,7 +1481,7 @@ Read standard input if FILE is -. Each PATTERN may be:\n\
|
||||
\n\
|
||||
A line OFFSET is a required `+' or `-' followed by a positive integer.\n\
|
||||
"), stdout);
|
||||
emit_bug_reporting_address ();
|
||||
emit_ancillary_info ();
|
||||
}
|
||||
exit (status);
|
||||
}
|
||||
|
||||
@@ -235,7 +235,7 @@ Each range is one of:\n\
|
||||
\n\
|
||||
With no FILE, or when FILE is -, read standard input.\n\
|
||||
"), stdout);
|
||||
emit_bug_reporting_address ();
|
||||
emit_ancillary_info ();
|
||||
}
|
||||
exit (status);
|
||||
}
|
||||
|
||||
@@ -236,7 +236,7 @@ then an optional modifier, which is either\n\
|
||||
E to use the locale's alternate representations if available, or\n\
|
||||
O to use the locale's alternate numeric symbols if available.\n\
|
||||
"), stdout);
|
||||
emit_bug_reporting_address ();
|
||||
emit_ancillary_info ();
|
||||
}
|
||||
exit (status);
|
||||
}
|
||||
|
||||
4
src/dd.c
4
src/dd.c
@@ -575,7 +575,7 @@ Options are:\n\
|
||||
|
||||
fputs (HELP_OPTION_DESCRIPTION, stdout);
|
||||
fputs (VERSION_OPTION_DESCRIPTION, stdout);
|
||||
emit_bug_reporting_address ();
|
||||
emit_ancillary_info ();
|
||||
}
|
||||
exit (status);
|
||||
}
|
||||
@@ -769,7 +769,7 @@ install_signal_handlers (void)
|
||||
static void
|
||||
process_signals (void)
|
||||
{
|
||||
while (interrupt_signal | info_signal_count)
|
||||
while (interrupt_signal || info_signal_count)
|
||||
{
|
||||
int interrupt;
|
||||
int infos;
|
||||
|
||||
9
src/df.c
9
src/df.c
@@ -24,7 +24,6 @@
|
||||
#include <getopt.h>
|
||||
|
||||
#include "system.h"
|
||||
#include "canonicalize.h"
|
||||
#include "error.h"
|
||||
#include "fsusage.h"
|
||||
#include "human.h"
|
||||
@@ -333,10 +332,10 @@ show_dev (char const *disk, char const *mount_point,
|
||||
bool negate_used;
|
||||
double pct = -1;
|
||||
|
||||
if (me_remote & show_local_fs)
|
||||
if (me_remote && show_local_fs)
|
||||
return;
|
||||
|
||||
if (me_dummy & !show_all_fs & !show_listed_fs)
|
||||
if (me_dummy && !show_all_fs && !show_listed_fs)
|
||||
return;
|
||||
|
||||
if (!selected_fstype (fstype) || excluded_fstype (fstype))
|
||||
@@ -431,7 +430,7 @@ show_dev (char const *disk, char const *mount_point,
|
||||
total = fsu.fsu_blocks;
|
||||
available = fsu.fsu_bavail;
|
||||
negate_available = (fsu.fsu_bavail_top_bit_set
|
||||
& known_value (available));
|
||||
&& known_value (available));
|
||||
available_to_root = fsu.fsu_bfree;
|
||||
|
||||
if (known_value (total))
|
||||
@@ -835,7 +834,7 @@ Mandatory arguments to long options are mandatory for short options too.\n\
|
||||
fputs (VERSION_OPTION_DESCRIPTION, stdout);
|
||||
emit_blocksize_note ("DF");
|
||||
emit_size_note ();
|
||||
emit_bug_reporting_address ();
|
||||
emit_ancillary_info ();
|
||||
}
|
||||
exit (status);
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <getopt.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#include "system.h"
|
||||
#include "dircolors.h"
|
||||
@@ -27,6 +26,7 @@
|
||||
#include "error.h"
|
||||
#include "obstack.h"
|
||||
#include "quote.h"
|
||||
#include "stdio--.h"
|
||||
#include "xstrndup.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
@@ -112,7 +112,7 @@ If FILE is specified, read it to determine which colors to use for which\n\
|
||||
file types and extensions. Otherwise, a precompiled database is used.\n\
|
||||
For details on the format of these files, run `dircolors --print-database'.\n\
|
||||
"), stdout);
|
||||
emit_bug_reporting_address ();
|
||||
emit_ancillary_info ();
|
||||
}
|
||||
|
||||
exit (status);
|
||||
|
||||
@@ -116,6 +116,7 @@ EXEC 01;32
|
||||
.Z 01;31
|
||||
.dz 01;31
|
||||
.gz 01;31
|
||||
.lz 01;31
|
||||
.xz 01;31
|
||||
.bz2 01;31
|
||||
.bz 01;31
|
||||
@@ -175,6 +176,8 @@ EXEC 01;32
|
||||
.xcf 01;35
|
||||
.xwd 01;35
|
||||
.yuv 01;35
|
||||
.cgm 01;35
|
||||
.emf 01;35
|
||||
|
||||
# http://wiki.xiph.org/index.php/MIME_Types_and_File_Extensions
|
||||
.axv 01;35
|
||||
|
||||
@@ -61,7 +61,7 @@ Examples:\n\
|
||||
%s stdio.h Output \".\".\n\
|
||||
"),
|
||||
program_name, program_name);
|
||||
emit_bug_reporting_address ();
|
||||
emit_ancillary_info ();
|
||||
}
|
||||
exit (status);
|
||||
}
|
||||
|
||||
21
src/du.c
21
src/du.c
@@ -24,7 +24,6 @@
|
||||
Rewritten to use nftw, then to use fts by Jim Meyering. */
|
||||
|
||||
#include <config.h>
|
||||
#include <stdio.h>
|
||||
#include <getopt.h>
|
||||
#include <sys/types.h>
|
||||
#include <assert.h>
|
||||
@@ -40,6 +39,7 @@
|
||||
#include "quotearg.h"
|
||||
#include "same.h"
|
||||
#include "stat-time.h"
|
||||
#include "stdio--.h"
|
||||
#include "xfts.h"
|
||||
#include "xstrtol.h"
|
||||
|
||||
@@ -67,7 +67,6 @@ extern bool fts_debug;
|
||||
|
||||
/* Hash structure for inode and device numbers. The separate entry
|
||||
structure makes it easier to rehash "in place". */
|
||||
|
||||
struct entry
|
||||
{
|
||||
ino_t st_ino;
|
||||
@@ -194,7 +193,6 @@ enum
|
||||
FILES0_FROM_OPTION,
|
||||
HUMAN_SI_OPTION,
|
||||
MAX_DEPTH_OPTION,
|
||||
MEGABYTES_LONG_OPTION,
|
||||
TIME_OPTION,
|
||||
TIME_STYLE_OPTION
|
||||
};
|
||||
@@ -332,7 +330,7 @@ Mandatory arguments to long options are mandatory for short options too.\n\
|
||||
fputs (VERSION_OPTION_DESCRIPTION, stdout);
|
||||
emit_blocksize_note ("DU");
|
||||
emit_size_note ();
|
||||
emit_bug_reporting_address ();
|
||||
emit_ancillary_info ();
|
||||
}
|
||||
exit (status);
|
||||
}
|
||||
@@ -495,6 +493,15 @@ process_file (FTS *fts, FTSENT *ent)
|
||||
ok = false;
|
||||
break;
|
||||
|
||||
case FTS_DC: /* directory that causes cycles */
|
||||
if (cycle_warning_required (fts, ent))
|
||||
{
|
||||
emit_cycle_warning (file);
|
||||
return false;
|
||||
}
|
||||
ok = true;
|
||||
break;
|
||||
|
||||
default:
|
||||
ok = true;
|
||||
break;
|
||||
@@ -755,10 +762,6 @@ main (int argc, char **argv)
|
||||
}
|
||||
break;
|
||||
|
||||
case MEGABYTES_LONG_OPTION: /* FIXME: remove in 2009 */
|
||||
error (0, 0,
|
||||
_("the --megabytes option is deprecated; use -m instead"));
|
||||
/* fall through */
|
||||
case 'm':
|
||||
human_output_opts = 0;
|
||||
output_block_size = 1024 * 1024;
|
||||
@@ -843,7 +846,7 @@ main (int argc, char **argv)
|
||||
if (!ok)
|
||||
usage (EXIT_FAILURE);
|
||||
|
||||
if (opt_all & opt_summarize_only)
|
||||
if (opt_all && opt_summarize_only)
|
||||
{
|
||||
error (0, 0, _("cannot both summarize and show all entries"));
|
||||
usage (EXIT_FAILURE);
|
||||
|
||||
27
src/echo.c
27
src/echo.c
@@ -63,21 +63,25 @@ Echo the STRING(s) to standard output.\n\
|
||||
\n\
|
||||
If -e is in effect, the following sequences are recognized:\n\
|
||||
\n\
|
||||
\\0NNN the character whose ASCII code is NNN (octal)\n\
|
||||
\\\\ backslash\n\
|
||||
\\a alert (BEL)\n\
|
||||
\\b backspace\n\
|
||||
"), stdout);
|
||||
fputs (_("\
|
||||
\\c produce no further output\n\
|
||||
\\f form feed\n\
|
||||
\\n new line\n\
|
||||
\\r carriage return\n\
|
||||
\\t horizontal tab\n\
|
||||
\\v vertical tab\n\
|
||||
\\\\ backslash\n\
|
||||
\\a alert (BEL)\n\
|
||||
\\b backspace\n\
|
||||
\\c produce no further output\n\
|
||||
\\e escape\n\
|
||||
\\f form feed\n\
|
||||
\\n new line\n\
|
||||
\\r carriage return\n\
|
||||
\\t horizontal tab\n\
|
||||
\\v vertical tab\n\
|
||||
"), stdout);
|
||||
fputs (_("\
|
||||
\\0NNN byte with octal value NNN (1 to 3 digits)\n\
|
||||
\\xHH byte with hexadecimal value HH (1 to 2 digits)\n\
|
||||
"), stdout);
|
||||
printf (USAGE_BUILTIN_WARNING, PROGRAM_NAME);
|
||||
emit_bug_reporting_address ();
|
||||
emit_ancillary_info ();
|
||||
}
|
||||
exit (status);
|
||||
}
|
||||
@@ -203,6 +207,7 @@ just_echo:
|
||||
case 'a': c = '\a'; break;
|
||||
case 'b': c = '\b'; break;
|
||||
case 'c': exit (EXIT_SUCCESS);
|
||||
case 'e': c = '\x1B'; break;
|
||||
case 'f': c = '\f'; break;
|
||||
case 'n': c = '\n'; break;
|
||||
case 'r': c = '\r'; break;
|
||||
|
||||
102
src/env.c
102
src/env.c
@@ -16,66 +16,6 @@
|
||||
|
||||
/* Richard Mlynarik and David MacKenzie */
|
||||
|
||||
/* Options:
|
||||
-
|
||||
-i
|
||||
--ignore-environment
|
||||
Construct a new environment from scratch; normally the
|
||||
environment is inherited from the parent process, except as
|
||||
modified by other options.
|
||||
|
||||
-u variable
|
||||
--unset=variable
|
||||
Unset variable VARIABLE (remove it from the environment).
|
||||
If VARIABLE was not set, does nothing.
|
||||
|
||||
variable=value (an arg containing a "=" character)
|
||||
Set the environment variable VARIABLE to value VALUE. VALUE
|
||||
may be of zero length ("variable="). Setting a variable to a
|
||||
zero-length value is different from unsetting it.
|
||||
|
||||
--
|
||||
Indicate that the following argument is the program
|
||||
to invoke. This is necessary when the program's name
|
||||
begins with "-" or contains a "=".
|
||||
|
||||
The first remaining argument specifies a program to invoke;
|
||||
it is searched for according to the specification of the PATH
|
||||
environment variable. Any arguments following that are
|
||||
passed as arguments to that program.
|
||||
|
||||
If no command name is specified following the environment
|
||||
specifications, the resulting environment is printed.
|
||||
This is like specifying a command name of "printenv".
|
||||
|
||||
Examples:
|
||||
|
||||
If the environment passed to "env" is
|
||||
{ LOGNAME=rms EDITOR=emacs PATH=.:/gnubin:/hacks }
|
||||
|
||||
env - foo
|
||||
runs "foo" in a null environment.
|
||||
|
||||
env foo
|
||||
runs "foo" in the environment
|
||||
{ LOGNAME=rms EDITOR=emacs PATH=.:/gnubin:/hacks }
|
||||
|
||||
env DISPLAY=gnu:0 nemacs
|
||||
runs "nemacs" in the environment
|
||||
{ LOGNAME=rms EDITOR=emacs PATH=.:/gnubin:/hacks DISPLAY=gnu:0 }
|
||||
|
||||
env - LOGNAME=foo /hacks/hack bar baz
|
||||
runs the "hack" program on arguments "bar" and "baz" in an
|
||||
environment in which the only variable is "LOGNAME". Note that
|
||||
the "-" option clears out the PATH variable, so one should be
|
||||
careful to specify in which directory to find the program to
|
||||
call.
|
||||
|
||||
env -u EDITOR LOGNAME=foo PATH=/energy -- e=mc2 bar baz
|
||||
runs the program "/energy/e=mc2" with environment
|
||||
{ LOGNAME=foo PATH=/energy }
|
||||
*/
|
||||
|
||||
#include <config.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
@@ -83,6 +23,7 @@
|
||||
|
||||
#include "system.h"
|
||||
#include "error.h"
|
||||
#include "quote.h"
|
||||
|
||||
/* The official name of this program (e.g., no `g' prefix). */
|
||||
#define PROGRAM_NAME "env"
|
||||
@@ -91,11 +32,10 @@
|
||||
proper_name ("Richard Mlynarik"), \
|
||||
proper_name ("David MacKenzie")
|
||||
|
||||
extern char **environ;
|
||||
|
||||
static struct option const longopts[] =
|
||||
{
|
||||
{"ignore-environment", no_argument, NULL, 'i'},
|
||||
{"null", no_argument, NULL, '0'},
|
||||
{"unset", required_argument, NULL, 'u'},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
{GETOPT_VERSION_OPTION_DECL},
|
||||
@@ -116,8 +56,9 @@ Usage: %s [OPTION]... [-] [NAME=VALUE]... [COMMAND [ARG]...]\n"),
|
||||
fputs (_("\
|
||||
Set each NAME to VALUE in the environment and run COMMAND.\n\
|
||||
\n\
|
||||
-i, --ignore-environment start with an empty environment\n\
|
||||
-u, --unset=NAME remove variable from the environment\n\
|
||||
-i, --ignore-environment start with an empty environment\n\
|
||||
-0, --null end each output line with 0 byte rather than newline\n\
|
||||
-u, --unset=NAME remove variable from the environment\n\
|
||||
"), stdout);
|
||||
fputs (HELP_OPTION_DESCRIPTION, stdout);
|
||||
fputs (VERSION_OPTION_DESCRIPTION, stdout);
|
||||
@@ -125,7 +66,7 @@ Set each NAME to VALUE in the environment and run COMMAND.\n\
|
||||
\n\
|
||||
A mere - implies -i. If no COMMAND, print the resulting environment.\n\
|
||||
"), stdout);
|
||||
emit_bug_reporting_address ();
|
||||
emit_ancillary_info ();
|
||||
}
|
||||
exit (status);
|
||||
}
|
||||
@@ -135,6 +76,7 @@ main (int argc, char **argv)
|
||||
{
|
||||
int optc;
|
||||
bool ignore_environment = false;
|
||||
bool opt_nul_terminate_output = false;
|
||||
|
||||
initialize_main (&argc, &argv);
|
||||
set_program_name (argv[0]);
|
||||
@@ -142,10 +84,10 @@ main (int argc, char **argv)
|
||||
bindtextdomain (PACKAGE, LOCALEDIR);
|
||||
textdomain (PACKAGE);
|
||||
|
||||
initialize_exit_failure (EXIT_FAILURE);
|
||||
initialize_exit_failure (EXIT_CANCELED);
|
||||
atexit (close_stdout);
|
||||
|
||||
while ((optc = getopt_long (argc, argv, "+iu:", longopts, NULL)) != -1)
|
||||
while ((optc = getopt_long (argc, argv, "+iu:0", longopts, NULL)) != -1)
|
||||
{
|
||||
switch (optc)
|
||||
{
|
||||
@@ -154,10 +96,13 @@ main (int argc, char **argv)
|
||||
break;
|
||||
case 'u':
|
||||
break;
|
||||
case '0':
|
||||
opt_nul_terminate_output = true;
|
||||
break;
|
||||
case_GETOPT_HELP_CHAR;
|
||||
case_GETOPT_VERSION_CHAR (PROGRAM_NAME, AUTHORS);
|
||||
default:
|
||||
usage (EXIT_FAILURE);
|
||||
usage (EXIT_CANCELED);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -171,25 +116,36 @@ main (int argc, char **argv)
|
||||
}
|
||||
|
||||
optind = 0; /* Force GNU getopt to re-initialize. */
|
||||
while ((optc = getopt_long (argc, argv, "+iu:", longopts, NULL)) != -1)
|
||||
if (optc == 'u')
|
||||
putenv (optarg); /* Requires GNU putenv. */
|
||||
while ((optc = getopt_long (argc, argv, "+iu:0", longopts, NULL)) != -1)
|
||||
if (optc == 'u' && unsetenv (optarg))
|
||||
error (EXIT_CANCELED, errno, _("cannot unset %s"), quote (optarg));
|
||||
|
||||
if (optind < argc && STREQ (argv[optind], "-"))
|
||||
++optind;
|
||||
|
||||
while (optind < argc && strchr (argv[optind], '='))
|
||||
putenv (argv[optind++]);
|
||||
if (putenv (argv[optind++]))
|
||||
{
|
||||
char *name = argv[optind - 1];
|
||||
*(strchr (name, '=')) = '\0';
|
||||
error (EXIT_CANCELED, errno, _("cannot set %s"), quote (name));
|
||||
}
|
||||
|
||||
/* If no program is specified, print the environment and exit. */
|
||||
if (argc <= optind)
|
||||
{
|
||||
char *const *e = environ;
|
||||
while (*e)
|
||||
puts (*e++);
|
||||
printf ("%s%c", *e++, opt_nul_terminate_output ? '\0' : '\n');
|
||||
exit (EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
if (opt_nul_terminate_output)
|
||||
{
|
||||
error (0, errno, _("cannot specify --null (-0) with command"));
|
||||
usage (EXIT_CANCELED);
|
||||
}
|
||||
|
||||
execvp (argv[optind], &argv[optind]);
|
||||
|
||||
{
|
||||
|
||||
@@ -121,7 +121,7 @@ Mandatory arguments to long options are mandatory for short options too.\n\
|
||||
"), stdout);
|
||||
fputs (HELP_OPTION_DESCRIPTION, stdout);
|
||||
fputs (VERSION_OPTION_DESCRIPTION, stdout);
|
||||
emit_bug_reporting_address ();
|
||||
emit_ancillary_info ();
|
||||
}
|
||||
exit (status);
|
||||
}
|
||||
@@ -344,7 +344,7 @@ expand (void)
|
||||
error (EXIT_FAILURE, 0, _("input line is too long"));
|
||||
}
|
||||
|
||||
convert &= convert_entire_line | !! isblank (c);
|
||||
convert &= convert_entire_line || !! isblank (c);
|
||||
}
|
||||
|
||||
if (c < 0)
|
||||
|
||||
10
src/expr.c
10
src/expr.c
@@ -55,7 +55,7 @@ static void integer_overflow (char) ATTRIBUTE_NORETURN;
|
||||
#else
|
||||
/* Approximate gmp.h well enough for expr.c's purposes. */
|
||||
typedef intmax_t mpz_t[1];
|
||||
static void mpz_clear (mpz_t z) {}
|
||||
static void mpz_clear (mpz_t z) { (void) z; }
|
||||
static void mpz_init_set_ui (mpz_t z, unsigned long int i) { z[0] = i; }
|
||||
static int
|
||||
mpz_init_set_str (mpz_t z, char *s, int base)
|
||||
@@ -116,6 +116,7 @@ mpz_tdiv_r (mpz_t r, mpz_t a0, mpz_t b0)
|
||||
static char *
|
||||
mpz_get_str (char const *str, int base, mpz_t z)
|
||||
{
|
||||
(void) str; (void) base;
|
||||
char buf[INT_BUFSIZE_BOUND (intmax_t)];
|
||||
return xstrdup (imaxtostr (z[0], buf));
|
||||
}
|
||||
@@ -137,6 +138,7 @@ mpz_get_ui (mpz_t z)
|
||||
static int
|
||||
mpz_out_str (FILE *stream, int base, mpz_t z)
|
||||
{
|
||||
(void) base;
|
||||
char buf[INT_BUFSIZE_BOUND (intmax_t)];
|
||||
return fputs (imaxtostr (z[0], buf), stream) != EOF;
|
||||
}
|
||||
@@ -265,7 +267,7 @@ Pattern matches return the string matched between \\( and \\) or null; if\n\
|
||||
Exit status is 0 if EXPRESSION is neither null nor 0, 1 if EXPRESSION is null\n\
|
||||
or 0, 2 if EXPRESSION is syntactically invalid, and 3 if an error occurred.\n\
|
||||
"), stdout);
|
||||
emit_bug_reporting_address ();
|
||||
emit_ancillary_info ();
|
||||
}
|
||||
exit (status);
|
||||
}
|
||||
@@ -923,7 +925,7 @@ eval1 (bool evaluate)
|
||||
{
|
||||
if (nextarg ("&"))
|
||||
{
|
||||
r = eval2 (evaluate & ~ null (l));
|
||||
r = eval2 (evaluate && !null (l));
|
||||
if (null (l) || null (r))
|
||||
{
|
||||
freev (l);
|
||||
@@ -954,7 +956,7 @@ eval (bool evaluate)
|
||||
{
|
||||
if (nextarg ("|"))
|
||||
{
|
||||
r = eval1 (evaluate & null (l));
|
||||
r = eval1 (evaluate && null (l));
|
||||
if (null (l))
|
||||
{
|
||||
freev (l);
|
||||
|
||||
@@ -26,7 +26,7 @@
|
||||
#include <stdio.h>
|
||||
#include <sys/types.h>
|
||||
#if HAVE_GMP
|
||||
#include <gmp.h>
|
||||
# include <gmp.h>
|
||||
#endif
|
||||
|
||||
#include <assert.h>
|
||||
@@ -67,7 +67,7 @@ static void
|
||||
emit_factor (mpz_t n)
|
||||
{
|
||||
if (nfactors_found == nfactors_allocated)
|
||||
factor = x2nrealloc (factor, &nfactors_allocated, sizeof *factor);
|
||||
factor = X2NREALLOC (factor, &nfactors_allocated);
|
||||
mpz_init (factor[nfactors_found]);
|
||||
mpz_set (factor[nfactors_found], n);
|
||||
++nfactors_found;
|
||||
@@ -502,7 +502,7 @@ are specified on the command line, read them from standard input.\n\
|
||||
"), stdout);
|
||||
fputs (HELP_OPTION_DESCRIPTION, stdout);
|
||||
fputs (VERSION_OPTION_DESCRIPTION, stdout);
|
||||
emit_bug_reporting_address ();
|
||||
emit_ancillary_info ();
|
||||
}
|
||||
exit (status);
|
||||
}
|
||||
|
||||
@@ -293,7 +293,7 @@ Mandatory arguments to long options are mandatory for short options too.\n\
|
||||
\n\
|
||||
With no FILE, or when FILE is -, read standard input.\n"),
|
||||
stdout);
|
||||
emit_bug_reporting_address ();
|
||||
emit_ancillary_info ();
|
||||
}
|
||||
exit (status);
|
||||
}
|
||||
|
||||
@@ -82,7 +82,7 @@ Mandatory arguments to long options are mandatory for short options too.\n\
|
||||
"), stdout);
|
||||
fputs (HELP_OPTION_DESCRIPTION, stdout);
|
||||
fputs (VERSION_OPTION_DESCRIPTION, stdout);
|
||||
emit_bug_reporting_address ();
|
||||
emit_ancillary_info ();
|
||||
}
|
||||
exit (status);
|
||||
}
|
||||
|
||||
@@ -73,7 +73,7 @@ Output platform dependent limits in a format useful for shell scripts.\n\
|
||||
"), stdout);
|
||||
fputs (HELP_OPTION_DESCRIPTION, stdout);
|
||||
fputs (VERSION_OPTION_DESCRIPTION, stdout);
|
||||
emit_bug_reporting_address ();
|
||||
emit_ancillary_info ();
|
||||
}
|
||||
exit (status);
|
||||
}
|
||||
|
||||
@@ -54,14 +54,13 @@ print_group_list (const char *username,
|
||||
ok = false;
|
||||
}
|
||||
|
||||
#if HAVE_GETGROUPS
|
||||
{
|
||||
GETGROUPS_T *groups;
|
||||
gid_t *groups;
|
||||
int i;
|
||||
|
||||
int n_groups = mgetgroups (username, (pwd ? pwd->pw_gid : (gid_t) -1),
|
||||
&groups);
|
||||
if (n_groups < 0)
|
||||
if (n_groups < 0 && errno != ENOSYS)
|
||||
{
|
||||
if (username)
|
||||
{
|
||||
@@ -84,7 +83,6 @@ print_group_list (const char *username,
|
||||
}
|
||||
free (groups);
|
||||
}
|
||||
#endif /* HAVE_GETGROUPS */
|
||||
return ok;
|
||||
}
|
||||
|
||||
|
||||
@@ -58,7 +58,7 @@ the current process (which may differ if the groups database has changed).\n"),
|
||||
stdout);
|
||||
fputs (HELP_OPTION_DESCRIPTION, stdout);
|
||||
fputs (VERSION_OPTION_DESCRIPTION, stdout);
|
||||
emit_bug_reporting_address ();
|
||||
emit_ancillary_info ();
|
||||
}
|
||||
exit (status);
|
||||
}
|
||||
|
||||
@@ -138,7 +138,7 @@ K may have a multiplier suffix:\n\
|
||||
b 512, kB 1000, K 1024, MB 1000*1000, M 1024*1024,\n\
|
||||
GB 1000*1000*1000, G 1024*1024*1024, and so on for T, P, E, Z, Y.\n\
|
||||
"), stdout);
|
||||
emit_bug_reporting_address ();
|
||||
emit_ancillary_info ();
|
||||
}
|
||||
exit (status);
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ Print the numeric identifier (in hexadecimal) for the current host.\n\
|
||||
"), program_name);
|
||||
fputs (HELP_OPTION_DESCRIPTION, stdout);
|
||||
fputs (VERSION_OPTION_DESCRIPTION, stdout);
|
||||
emit_bug_reporting_address ();
|
||||
emit_ancillary_info ();
|
||||
}
|
||||
exit (status);
|
||||
}
|
||||
|
||||
@@ -63,7 +63,7 @@ Print or set the hostname of the current system.\n\
|
||||
program_name, program_name);
|
||||
fputs (HELP_OPTION_DESCRIPTION, stdout);
|
||||
fputs (VERSION_OPTION_DESCRIPTION, stdout);
|
||||
emit_bug_reporting_address ();
|
||||
emit_ancillary_info ();
|
||||
}
|
||||
exit (status);
|
||||
}
|
||||
|
||||
15
src/id.c
15
src/id.c
@@ -98,7 +98,7 @@ or (when USERNAME omitted) for the current user.\n\
|
||||
\n\
|
||||
Without any OPTION, print some useful set of identified information.\n\
|
||||
"), stdout);
|
||||
emit_bug_reporting_address ();
|
||||
emit_ancillary_info ();
|
||||
}
|
||||
exit (status);
|
||||
}
|
||||
@@ -187,7 +187,7 @@ main (int argc, char **argv)
|
||||
if (just_user + just_group + just_group_list + just_context > 1)
|
||||
error (EXIT_FAILURE, 0, _("cannot print \"only\" of more than one choice"));
|
||||
|
||||
if (just_user + just_group + just_group_list == 0 && (use_real | use_name))
|
||||
if (just_user + just_group + just_group_list == 0 && (use_real || use_name))
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("cannot print only names or real IDs in default format"));
|
||||
|
||||
@@ -292,14 +292,13 @@ print_full_info (const char *username)
|
||||
printf ("(%s)", grp->gr_name);
|
||||
}
|
||||
|
||||
#if HAVE_GETGROUPS
|
||||
{
|
||||
GETGROUPS_T *groups;
|
||||
gid_t *groups;
|
||||
int i;
|
||||
|
||||
int n_groups = mgetgroups (username, (pwd ? pwd->pw_gid : (gid_t) -1),
|
||||
&groups);
|
||||
if (n_groups < 0)
|
||||
if (n_groups < 0 && errno != ENOSYS)
|
||||
{
|
||||
if (username)
|
||||
{
|
||||
@@ -327,7 +326,9 @@ print_full_info (const char *username)
|
||||
}
|
||||
free (groups);
|
||||
}
|
||||
#endif /* HAVE_GETGROUPS */
|
||||
if (context != NULL)
|
||||
|
||||
/* POSIX mandates the precise output format, and that it not include
|
||||
any context=... part, so skip that if POSIXLY_CORRECT is set. */
|
||||
if (context != NULL && ! getenv ("POSIXLY_CORRECT"))
|
||||
printf (_(" context=%s"), context);
|
||||
}
|
||||
|
||||
@@ -563,7 +563,7 @@ main (int argc, char **argv)
|
||||
}
|
||||
|
||||
/* Check for invalid combinations of arguments. */
|
||||
if (dir_arg & strip_files)
|
||||
if (dir_arg && strip_files)
|
||||
error (EXIT_FAILURE, 0,
|
||||
_("the strip option may not be used when installing a directory"));
|
||||
if (dir_arg && target_directory)
|
||||
@@ -1005,7 +1005,7 @@ the VERSION_CONTROL environment variable. Here are the values:\n\
|
||||
existing, nil numbered if numbered backups exist, simple otherwise\n\
|
||||
simple, never always make simple backups\n\
|
||||
"), stdout);
|
||||
emit_bug_reporting_address ();
|
||||
emit_ancillary_info ();
|
||||
}
|
||||
exit (status);
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
|
||||
#include "system.h"
|
||||
#include "error.h"
|
||||
#include "hard-locale.h"
|
||||
#include "linebuffer.h"
|
||||
#include "memcasecmp.h"
|
||||
#include "quote.h"
|
||||
@@ -208,7 +209,7 @@ Note, comparisons honor the rules specified by `LC_COLLATE'.\n\
|
||||
If the input is not sorted and some lines cannot be joined, a\n\
|
||||
warning message will be given.\n\
|
||||
"), stdout);
|
||||
emit_bug_reporting_address ();
|
||||
emit_ancillary_info ();
|
||||
}
|
||||
exit (status);
|
||||
}
|
||||
|
||||
@@ -111,7 +111,7 @@ or the exit status of a process terminated by a signal.\n\
|
||||
PID is an integer; if negative it identifies a process group.\n\
|
||||
"), stdout);
|
||||
printf (USAGE_BUILTIN_WARNING, PROGRAM_NAME);
|
||||
emit_bug_reporting_address ();
|
||||
emit_ancillary_info ();
|
||||
}
|
||||
exit (status);
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ Usage: %s FILE1 FILE2\n\
|
||||
stdout);
|
||||
fputs (HELP_OPTION_DESCRIPTION, stdout);
|
||||
fputs (VERSION_OPTION_DESCRIPTION, stdout);
|
||||
emit_bug_reporting_address ();
|
||||
emit_ancillary_info ();
|
||||
}
|
||||
exit (status);
|
||||
}
|
||||
|
||||
65
src/ln.c
65
src/ln.c
@@ -39,26 +39,15 @@
|
||||
proper_name ("Mike Parker"), \
|
||||
proper_name ("David MacKenzie")
|
||||
|
||||
/* In being careful not even to try to make hard links to directories,
|
||||
we have to know whether link(2) follows symlinks. If it does, then
|
||||
we have to *stat* the `source' to see if the resulting link would be
|
||||
to a directory. Otherwise, we have to use *lstat* so that we allow
|
||||
users to make hard links to symlinks-that-point-to-directories. */
|
||||
|
||||
#if LINK_FOLLOWS_SYMLINKS
|
||||
# define STAT_LIKE_LINK(File, Stat_buf) \
|
||||
stat (File, Stat_buf)
|
||||
#else
|
||||
# define STAT_LIKE_LINK(File, Stat_buf) \
|
||||
lstat (File, Stat_buf)
|
||||
#endif
|
||||
|
||||
/* FIXME: document */
|
||||
static enum backup_type backup_type;
|
||||
|
||||
/* If true, make symbolic links; otherwise, make hard links. */
|
||||
static bool symbolic_link;
|
||||
|
||||
/* If true, hard links are logical rather than physical. */
|
||||
static bool logical = !!LINK_FOLLOWS_SYMLINKS;
|
||||
|
||||
/* If true, ask the user before removing existing files. */
|
||||
static bool interactive;
|
||||
|
||||
@@ -71,7 +60,7 @@ static bool verbose;
|
||||
/* If true, allow the superuser to *attempt* to make hard links
|
||||
to directories. However, it appears that this option is not useful
|
||||
in practice, since even the superuser is prohibited from hard-linking
|
||||
directories on most (all?) existing systems. */
|
||||
directories on most existing systems (Solaris being an exception). */
|
||||
static bool hard_dir_link;
|
||||
|
||||
/* If nonzero, and the specified destination is a symbolic link to a
|
||||
@@ -99,6 +88,8 @@ static struct option const long_options[] =
|
||||
{"interactive", no_argument, NULL, 'i'},
|
||||
{"suffix", required_argument, NULL, 'S'},
|
||||
{"target-directory", required_argument, NULL, 't'},
|
||||
{"logical", no_argument, NULL, 'L'},
|
||||
{"physical", no_argument, NULL, 'P'},
|
||||
{"symbolic", no_argument, NULL, 's'},
|
||||
{"verbose", no_argument, NULL, 'v'},
|
||||
{GETOPT_HELP_OPTION_DECL},
|
||||
@@ -143,18 +134,15 @@ do_link (const char *source, const char *dest)
|
||||
bool source_is_dir = false;
|
||||
bool ok;
|
||||
|
||||
/* Use stat here instead of lstat.
|
||||
On SVR4, link does not follow symlinks, so this check disallows
|
||||
making hard links to symlinks that point to directories. Big deal.
|
||||
On other systems, link follows symlinks, so this check is right.
|
||||
|
||||
FIXME - POSIX 2008 added the AT_SYMLINK_FOLLOW flag to linkat so
|
||||
that we can specify either behavior, via the new options -L
|
||||
(hard-link to symlinks) and -P (hard-link to the referent). Once
|
||||
gnulib has a decent implementation, we should use it here. */
|
||||
if (!symbolic_link)
|
||||
{
|
||||
if (STAT_LIKE_LINK (source, &source_stats) != 0)
|
||||
/* Which stat to use depends on whether linkat will follow the
|
||||
symlink. We can't use the shorter
|
||||
(logical?stat:lstat) (source, &source_stats)
|
||||
since stat might be a function-like macro. */
|
||||
if ((logical ? stat (source, &source_stats)
|
||||
: lstat (source, &source_stats))
|
||||
!= 0)
|
||||
{
|
||||
error (0, errno, _("accessing %s"), quote (source));
|
||||
return false;
|
||||
@@ -258,7 +246,9 @@ do_link (const char *source, const char *dest)
|
||||
}
|
||||
}
|
||||
|
||||
ok = ((symbolic_link ? symlink (source, dest) : link (source, dest))
|
||||
ok = ((symbolic_link ? symlink (source, dest)
|
||||
: linkat (AT_FDCWD, source, AT_FDCWD, dest,
|
||||
logical ? AT_SYMLINK_FOLLOW : 0))
|
||||
== 0);
|
||||
|
||||
/* If the attempt to create a link failed and we are removing or
|
||||
@@ -289,7 +279,9 @@ do_link (const char *source, const char *dest)
|
||||
return false;
|
||||
}
|
||||
|
||||
ok = ((symbolic_link ? symlink (source, dest) : link (source, dest))
|
||||
ok = ((symbolic_link ? symlink (source, dest)
|
||||
: linkat (AT_FDCWD, source, AT_FDCWD, dest,
|
||||
logical ? AT_SYMLINK_FOLLOW : 0))
|
||||
== 0);
|
||||
}
|
||||
|
||||
@@ -370,9 +362,11 @@ Mandatory arguments to long options are mandatory for short options too.\n\
|
||||
-f, --force remove existing destination files\n\
|
||||
"), stdout);
|
||||
fputs (_("\
|
||||
-i, --interactive prompt whether to remove destinations\n\
|
||||
-L, --logical make hard links to symbolic link references\n\
|
||||
-n, --no-dereference treat destination that is a symlink to a\n\
|
||||
directory as if it were a normal file\n\
|
||||
-i, --interactive prompt whether to remove destinations\n\
|
||||
-P, --physical make hard links directly to symbolic links\n\
|
||||
-s, --symbolic make symbolic links instead of hard links\n\
|
||||
"), stdout);
|
||||
fputs (_("\
|
||||
@@ -391,13 +385,18 @@ The version control method may be selected via the --backup option or through\n\
|
||||
the VERSION_CONTROL environment variable. Here are the values:\n\
|
||||
\n\
|
||||
"), stdout);
|
||||
printf (_("\
|
||||
Using -s ignores -L and -P. Otherwise, the last option specified controls\n\
|
||||
behavior when the source is a symbolic link, defaulting to %s.\n\
|
||||
\n\
|
||||
"), LINK_FOLLOWS_SYMLINKS ? "-L" : "-P");
|
||||
fputs (_("\
|
||||
none, off never make backups (even if --backup is given)\n\
|
||||
numbered, t make numbered backups\n\
|
||||
existing, nil numbered if numbered backups exist, simple otherwise\n\
|
||||
simple, never always make simple backups\n\
|
||||
"), stdout);
|
||||
emit_bug_reporting_address ();
|
||||
emit_ancillary_info ();
|
||||
}
|
||||
exit (status);
|
||||
}
|
||||
@@ -430,7 +429,7 @@ main (int argc, char **argv)
|
||||
symbolic_link = remove_existing_files = interactive = verbose
|
||||
= hard_dir_link = false;
|
||||
|
||||
while ((c = getopt_long (argc, argv, "bdfinst:vFS:T", long_options, NULL))
|
||||
while ((c = getopt_long (argc, argv, "bdfinst:vFLPS:T", long_options, NULL))
|
||||
!= -1)
|
||||
{
|
||||
switch (c)
|
||||
@@ -452,9 +451,15 @@ main (int argc, char **argv)
|
||||
remove_existing_files = false;
|
||||
interactive = true;
|
||||
break;
|
||||
case 'L':
|
||||
logical = true;
|
||||
break;
|
||||
case 'n':
|
||||
dereference_dest_dir_symlinks = false;
|
||||
break;
|
||||
case 'P':
|
||||
logical = false;
|
||||
break;
|
||||
case 's':
|
||||
symbolic_link = true;
|
||||
break;
|
||||
|
||||
@@ -44,7 +44,7 @@ Print the name of the current user.\n\
|
||||
"), stdout);
|
||||
fputs (HELP_OPTION_DESCRIPTION, stdout);
|
||||
fputs (VERSION_OPTION_DESCRIPTION, stdout);
|
||||
emit_bug_reporting_address ();
|
||||
emit_ancillary_info ();
|
||||
}
|
||||
exit (status);
|
||||
}
|
||||
|
||||
236
src/ls.c
236
src/ls.c
@@ -93,6 +93,7 @@
|
||||
#include "dev-ino.h"
|
||||
#include "error.h"
|
||||
#include "filenamecat.h"
|
||||
#include "hard-locale.h"
|
||||
#include "hash.h"
|
||||
#include "human.h"
|
||||
#include "filemode.h"
|
||||
@@ -213,6 +214,9 @@ struct fileinfo
|
||||
/* For long listings, true if the file has an access control list,
|
||||
or an SELinux security context. */
|
||||
enum acl_type acl_type;
|
||||
|
||||
/* For color listings, true if a regular file has capability info. */
|
||||
bool has_capability;
|
||||
};
|
||||
|
||||
#define LEN_STR_PAIR(s) sizeof (s) - 1, s
|
||||
@@ -240,9 +244,8 @@ static bool file_ignored (char const *name);
|
||||
static uintmax_t gobble_file (char const *name, enum filetype type,
|
||||
ino_t inode, bool command_line_arg,
|
||||
char const *dirname);
|
||||
static bool print_color_indicator (const char *name, mode_t mode, int linkok,
|
||||
bool stat_ok, enum filetype type,
|
||||
nlink_t nlink);
|
||||
static bool print_color_indicator (const struct fileinfo *f,
|
||||
bool symlink_target);
|
||||
static void put_indicator (const struct bin_str *ind);
|
||||
static void add_ignore_pattern (const char *pattern);
|
||||
static void attach (char *dest, const char *dirname, const char *name);
|
||||
@@ -263,11 +266,9 @@ static int format_user_width (uid_t u);
|
||||
static int format_group_width (gid_t g);
|
||||
static void print_long_format (const struct fileinfo *f);
|
||||
static void print_many_per_line (void);
|
||||
static size_t print_name_with_quoting (const char *p, mode_t mode,
|
||||
int linkok, bool stat_ok,
|
||||
enum filetype type,
|
||||
static size_t print_name_with_quoting (const struct fileinfo *f,
|
||||
bool symlink_target,
|
||||
struct obstack *stack,
|
||||
nlink_t nlink,
|
||||
size_t start_col);
|
||||
static void prep_non_filename_text (void);
|
||||
static bool print_type_indicator (bool stat_ok, mode_t mode,
|
||||
@@ -323,7 +324,7 @@ static bool color_symlink_as_referent;
|
||||
|
||||
/* mode of appropriate file for colorization */
|
||||
#define FILE_OR_LINK_MODE(File) \
|
||||
((color_symlink_as_referent & (File)->linkok) \
|
||||
((color_symlink_as_referent && (File)->linkok) \
|
||||
? (File)->linkmode : (File)->stat.st_mode)
|
||||
|
||||
|
||||
@@ -1175,7 +1176,7 @@ stophandler (int sig)
|
||||
static void
|
||||
process_signals (void)
|
||||
{
|
||||
while (interrupt_signal | stop_signal_count)
|
||||
while (interrupt_signal || stop_signal_count)
|
||||
{
|
||||
int sig;
|
||||
int stops;
|
||||
@@ -2470,13 +2471,14 @@ print_dir (char const *name, char const *realname, bool command_line_arg)
|
||||
error (0, 0, _("%s: not listing already-listed directory"),
|
||||
quotearg_colon (name));
|
||||
closedir (dirp);
|
||||
set_exit_status (true);
|
||||
return;
|
||||
}
|
||||
|
||||
DEV_INO_PUSH (dir_stat.st_dev, dir_stat.st_ino);
|
||||
}
|
||||
|
||||
if (recursive | print_dir_name)
|
||||
if (recursive || print_dir_name)
|
||||
{
|
||||
if (!first)
|
||||
DIRED_PUTCHAR ('\n');
|
||||
@@ -2635,6 +2637,37 @@ unsigned_file_size (off_t size)
|
||||
return size + (size < 0) * ((uintmax_t) OFF_T_MAX - OFF_T_MIN + 1);
|
||||
}
|
||||
|
||||
#ifdef HAVE_CAP
|
||||
/* Return true if NAME has a capability (see linux/capability.h) */
|
||||
static bool
|
||||
has_capability (char const *name)
|
||||
{
|
||||
char *result;
|
||||
bool has_cap;
|
||||
|
||||
cap_t cap_d = cap_get_file (name);
|
||||
if (cap_d == NULL)
|
||||
return false;
|
||||
|
||||
result = cap_to_text (cap_d, NULL);
|
||||
cap_free (cap_d);
|
||||
if (!result)
|
||||
return false;
|
||||
|
||||
/* check if human-readable capability string is empty */
|
||||
has_cap = !!*result;
|
||||
|
||||
cap_free (result);
|
||||
return has_cap;
|
||||
}
|
||||
#else
|
||||
static bool
|
||||
has_capability (char const *name ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Enter and remove entries in the table `cwd_file'. */
|
||||
|
||||
/* Empty the table of files. */
|
||||
@@ -2716,11 +2749,16 @@ gobble_file (char const *name, enum filetype type, ino_t inode,
|
||||
to see if it's executable. */
|
||||
|| (type == normal && (indicator_style == classify
|
||||
/* This is so that --color ends up
|
||||
highlighting files with the executable
|
||||
bit set even when options like -F are
|
||||
not specified. */
|
||||
highlighting files with these mode
|
||||
bits set even when options like -F are
|
||||
not specified. Note we do a redundant
|
||||
stat in the very unlikely case where
|
||||
C_CAP is set but not the others. */
|
||||
|| (print_with_color
|
||||
&& is_colored (C_EXEC))
|
||||
&& (is_colored (C_EXEC)
|
||||
|| is_colored (C_SETUID)
|
||||
|| is_colored (C_SETGID)
|
||||
|| is_colored (C_CAP)))
|
||||
)))))
|
||||
|
||||
{
|
||||
@@ -2791,6 +2829,11 @@ gobble_file (char const *name, enum filetype type, ino_t inode,
|
||||
|
||||
f->stat_ok = true;
|
||||
|
||||
/* Note has_capability() adds around 30% runtime to `ls --color` */
|
||||
if ((type == normal || S_ISREG (f->stat.st_mode))
|
||||
&& print_with_color && is_colored (C_CAP))
|
||||
f->has_capability = has_capability (absolute_name);
|
||||
|
||||
if (format == long_format || print_scontext)
|
||||
{
|
||||
bool have_selinux = false;
|
||||
@@ -2800,17 +2843,6 @@ gobble_file (char const *name, enum filetype type, ino_t inode,
|
||||
: lgetfilecon (absolute_name, &f->scontext));
|
||||
err = (attr_len < 0);
|
||||
|
||||
/* Contrary to its documented API, getfilecon may return 0,
|
||||
yet set f->scontext to NULL (on at least Debian's libselinux1
|
||||
2.0.15-2+b1), so work around that bug.
|
||||
FIXME: remove this work-around in 2011, or whenever affected
|
||||
versions of libselinux are long gone. */
|
||||
if (attr_len == 0)
|
||||
{
|
||||
err = 0;
|
||||
f->scontext = xstrdup ("unlabeled");
|
||||
}
|
||||
|
||||
if (err == 0)
|
||||
have_selinux = ! STREQ ("unlabeled", f->scontext);
|
||||
else
|
||||
@@ -2884,7 +2916,7 @@ gobble_file (char const *name, enum filetype type, ino_t inode,
|
||||
f->filetype = symbolic_link;
|
||||
else if (S_ISDIR (f->stat.st_mode))
|
||||
{
|
||||
if (command_line_arg & !immediate_dirs)
|
||||
if (command_line_arg && !immediate_dirs)
|
||||
f->filetype = arg_directory;
|
||||
else
|
||||
f->filetype = directory;
|
||||
@@ -3554,9 +3586,19 @@ format_group_width (gid_t g)
|
||||
return format_user_or_group_width (numeric_ids ? NULL : getgroup (g), g);
|
||||
}
|
||||
|
||||
/* Return a pointer to a formatted version of F->stat.st_ino,
|
||||
possibly using buffer, BUF, of length BUFLEN, which must be at least
|
||||
INT_BUFSIZE_BOUND (uintmax_t) bytes. */
|
||||
static char *
|
||||
format_inode (char *buf, size_t buflen, const struct fileinfo *f)
|
||||
{
|
||||
assert (INT_BUFSIZE_BOUND (uintmax_t) <= buflen);
|
||||
return (f->stat_ok && f->stat.st_ino != NOT_AN_INODE_NUMBER
|
||||
? umaxtostr (f->stat.st_ino, buf)
|
||||
: (char *) "?");
|
||||
}
|
||||
|
||||
/* Print information about F in long format. */
|
||||
|
||||
static void
|
||||
print_long_format (const struct fileinfo *f)
|
||||
{
|
||||
@@ -3613,9 +3655,7 @@ print_long_format (const struct fileinfo *f)
|
||||
{
|
||||
char hbuf[INT_BUFSIZE_BOUND (uintmax_t)];
|
||||
sprintf (p, "%*s ", inode_number_width,
|
||||
(f->stat.st_ino == NOT_AN_INODE_NUMBER
|
||||
? "?"
|
||||
: umaxtostr (f->stat.st_ino, hbuf)));
|
||||
format_inode (hbuf, sizeof hbuf, f));
|
||||
/* Increment by strlen (p) here, rather than by inode_number_width + 1.
|
||||
The latter is wrong when inode_number_width is zero. */
|
||||
p += strlen (p);
|
||||
@@ -3651,7 +3691,7 @@ print_long_format (const struct fileinfo *f)
|
||||
|
||||
DIRED_INDENT ();
|
||||
|
||||
if (print_owner | print_group | print_author | print_scontext)
|
||||
if (print_owner || print_group || print_author || print_scontext)
|
||||
{
|
||||
DIRED_FPUTS (buf, stdout, p - buf);
|
||||
|
||||
@@ -3762,18 +3802,14 @@ print_long_format (const struct fileinfo *f)
|
||||
}
|
||||
|
||||
DIRED_FPUTS (buf, stdout, p - buf);
|
||||
size_t w = print_name_with_quoting (f->name, FILE_OR_LINK_MODE (f), f->linkok,
|
||||
f->stat_ok, f->filetype, &dired_obstack,
|
||||
f->stat.st_nlink, p - buf);
|
||||
size_t w = print_name_with_quoting (f, false, &dired_obstack, p - buf);
|
||||
|
||||
if (f->filetype == symbolic_link)
|
||||
{
|
||||
if (f->linkname)
|
||||
{
|
||||
DIRED_FPUTS_LITERAL (" -> ", stdout);
|
||||
print_name_with_quoting (f->linkname, f->linkmode, f->linkok - 1,
|
||||
f->stat_ok, f->filetype, NULL,
|
||||
f->stat.st_nlink, (p - buf) + w + 4);
|
||||
print_name_with_quoting (f, true, NULL, (p - buf) + w + 4);
|
||||
if (indicator_style != none)
|
||||
print_type_indicator (true, f->linkmode, unknown);
|
||||
}
|
||||
@@ -3949,19 +3985,20 @@ quote_name (FILE *out, const char *name, struct quoting_options const *options,
|
||||
}
|
||||
|
||||
static size_t
|
||||
print_name_with_quoting (const char *p, mode_t mode, int linkok,
|
||||
bool stat_ok, enum filetype type,
|
||||
struct obstack *stack, nlink_t nlink,
|
||||
print_name_with_quoting (const struct fileinfo *f,
|
||||
bool symlink_target,
|
||||
struct obstack *stack,
|
||||
size_t start_col)
|
||||
{
|
||||
const char* name = symlink_target ? f->linkname : f->name;
|
||||
|
||||
bool used_color_this_time
|
||||
= (print_with_color
|
||||
&& print_color_indicator (p, mode, linkok, stat_ok, type, nlink));
|
||||
= (print_with_color && print_color_indicator (f, symlink_target));
|
||||
|
||||
if (stack)
|
||||
PUSH_CURRENT_DIRED_POS (stack);
|
||||
|
||||
size_t width = quote_name (stdout, p, filename_quoting_options, NULL);
|
||||
size_t width = quote_name (stdout, name, filename_quoting_options, NULL);
|
||||
dired_pos += width;
|
||||
|
||||
if (stack)
|
||||
@@ -4002,19 +4039,18 @@ print_file_name_and_frills (const struct fileinfo *f, size_t start_col)
|
||||
|
||||
if (print_inode)
|
||||
printf ("%*s ", format == with_commas ? 0 : inode_number_width,
|
||||
umaxtostr (f->stat.st_ino, buf));
|
||||
format_inode (buf, sizeof buf, f));
|
||||
|
||||
if (print_block_size)
|
||||
printf ("%*s ", format == with_commas ? 0 : block_size_width,
|
||||
human_readable (ST_NBLOCKS (f->stat), buf, human_output_opts,
|
||||
ST_NBLOCKSIZE, output_block_size));
|
||||
! f->stat_ok ? "?"
|
||||
: human_readable (ST_NBLOCKS (f->stat), buf, human_output_opts,
|
||||
ST_NBLOCKSIZE, output_block_size));
|
||||
|
||||
if (print_scontext)
|
||||
printf ("%*s ", format == with_commas ? 0 : scontext_width, f->scontext);
|
||||
|
||||
size_t width = print_name_with_quoting (f->name, FILE_OR_LINK_MODE (f),
|
||||
f->linkok, f->stat_ok, f->filetype,
|
||||
NULL, f->stat.st_nlink, start_col);
|
||||
size_t width = print_name_with_quoting (f, false, NULL, start_col);
|
||||
|
||||
if (indicator_style != none)
|
||||
width += print_type_indicator (f->stat_ok, f->stat.st_mode, f->filetype);
|
||||
@@ -4065,82 +4101,67 @@ print_type_indicator (bool stat_ok, mode_t mode, enum filetype type)
|
||||
return !!c;
|
||||
}
|
||||
|
||||
#ifdef HAVE_CAP
|
||||
/* Return true if NAME has a capability (see linux/capability.h) */
|
||||
static bool
|
||||
has_capability (char const *name)
|
||||
{
|
||||
char *result;
|
||||
bool has_cap;
|
||||
|
||||
cap_t cap_d = cap_get_file (name);
|
||||
if (cap_d == NULL)
|
||||
return false;
|
||||
|
||||
result = cap_to_text (cap_d, NULL);
|
||||
cap_free (cap_d);
|
||||
if (!result)
|
||||
return false;
|
||||
|
||||
/* check if human-readable capability string is empty */
|
||||
has_cap = !!*result;
|
||||
|
||||
cap_free (result);
|
||||
return has_cap;
|
||||
}
|
||||
#else
|
||||
static bool
|
||||
has_capability (char const *name ATTRIBUTE_UNUSED)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Returns whether any color sequence was printed. */
|
||||
static bool
|
||||
print_color_indicator (const char *name, mode_t mode, int linkok,
|
||||
bool stat_ok, enum filetype filetype,
|
||||
nlink_t nlink)
|
||||
print_color_indicator (const struct fileinfo *f, bool symlink_target)
|
||||
{
|
||||
int type;
|
||||
enum indicator_no type;
|
||||
struct color_ext_type *ext; /* Color extension */
|
||||
size_t len; /* Length of name */
|
||||
|
||||
const char* name;
|
||||
mode_t mode;
|
||||
int linkok;
|
||||
if (symlink_target)
|
||||
{
|
||||
name = f->linkname;
|
||||
mode = f->linkmode;
|
||||
linkok = f->linkok - 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
name = f->name;
|
||||
mode = FILE_OR_LINK_MODE (f);
|
||||
linkok = f->linkok;
|
||||
}
|
||||
|
||||
/* Is this a nonexistent file? If so, linkok == -1. */
|
||||
|
||||
if (linkok == -1 && color_indicator[C_MISSING].string != NULL)
|
||||
type = C_MISSING;
|
||||
else if (! stat_ok)
|
||||
else if (!f->stat_ok)
|
||||
{
|
||||
static enum indicator_no filetype_indicator[] = FILETYPE_INDICATORS;
|
||||
type = filetype_indicator[filetype];
|
||||
type = filetype_indicator[f->filetype];
|
||||
}
|
||||
else
|
||||
{
|
||||
if (S_ISREG (mode))
|
||||
{
|
||||
type = C_FILE;
|
||||
if ((mode & S_ISUID) != 0)
|
||||
|
||||
if ((mode & S_ISUID) != 0 && is_colored (C_SETUID))
|
||||
type = C_SETUID;
|
||||
else if ((mode & S_ISGID) != 0)
|
||||
else if ((mode & S_ISGID) != 0 && is_colored (C_SETGID))
|
||||
type = C_SETGID;
|
||||
else if (is_colored (C_CAP) && has_capability (name))
|
||||
else if (is_colored (C_CAP) && f->has_capability)
|
||||
type = C_CAP;
|
||||
else if ((mode & S_IXUGO) != 0)
|
||||
else if ((mode & S_IXUGO) != 0 && is_colored (C_EXEC))
|
||||
type = C_EXEC;
|
||||
else if (is_colored (C_MULTIHARDLINK) && (1 < nlink))
|
||||
else if ((1 < f->stat.st_nlink) && is_colored (C_MULTIHARDLINK))
|
||||
type = C_MULTIHARDLINK;
|
||||
}
|
||||
else if (S_ISDIR (mode))
|
||||
{
|
||||
if ((mode & S_ISVTX) && (mode & S_IWOTH))
|
||||
type = C_DIR;
|
||||
|
||||
if ((mode & S_ISVTX) && (mode & S_IWOTH)
|
||||
&& is_colored (C_STICKY_OTHER_WRITABLE))
|
||||
type = C_STICKY_OTHER_WRITABLE;
|
||||
else if ((mode & S_IWOTH) != 0)
|
||||
else if ((mode & S_IWOTH) != 0 && is_colored (C_OTHER_WRITABLE))
|
||||
type = C_OTHER_WRITABLE;
|
||||
else if ((mode & S_ISVTX) != 0)
|
||||
else if ((mode & S_ISVTX) != 0 && is_colored (C_STICKY))
|
||||
type = C_STICKY;
|
||||
else
|
||||
type = C_DIR;
|
||||
}
|
||||
else if (S_ISLNK (mode))
|
||||
type = ((!linkok && color_indicator[C_ORPHAN].string)
|
||||
@@ -4221,9 +4242,10 @@ length_of_file_name_and_frills (const struct fileinfo *f)
|
||||
|
||||
if (print_block_size)
|
||||
len += 1 + (format == with_commas
|
||||
? strlen (human_readable (ST_NBLOCKS (f->stat), buf,
|
||||
human_output_opts, ST_NBLOCKSIZE,
|
||||
output_block_size))
|
||||
? strlen (! f->stat_ok ? "?"
|
||||
: human_readable (ST_NBLOCKS (f->stat), buf,
|
||||
human_output_opts, ST_NBLOCKSIZE,
|
||||
output_block_size))
|
||||
: block_size_width);
|
||||
|
||||
if (print_scontext)
|
||||
@@ -4552,8 +4574,8 @@ Mandatory arguments to long options are mandatory for short options too.\n\
|
||||
"), stdout);
|
||||
fputs (_("\
|
||||
-C list entries by columns\n\
|
||||
--color[=WHEN] control whether color is used to distinguish file\n\
|
||||
types. WHEN may be `never', `always', or `auto'\n\
|
||||
--color[=WHEN] colorize the output. WHEN defaults to `always'\n\
|
||||
or can be `never' or `auto'. More info below\n\
|
||||
-d, --directory list directory entries instead of contents,\n\
|
||||
and do not dereference symbolic links\n\
|
||||
-D, --dired generate output designed for Emacs' dired mode\n\
|
||||
@@ -4667,12 +4689,10 @@ Mandatory arguments to long options are mandatory for short options too.\n\
|
||||
emit_size_note ();
|
||||
fputs (_("\
|
||||
\n\
|
||||
By default, color is not used to distinguish types of files. That is\n\
|
||||
equivalent to using --color=none. Using the --color option without the\n\
|
||||
optional WHEN argument is equivalent to using --color=always. With\n\
|
||||
--color=auto, color codes are output only if standard output is connected\n\
|
||||
to a terminal (tty). The environment variable LS_COLORS can influence the\n\
|
||||
colors, and can be set easily by the dircolors command.\n\
|
||||
Using color to distinguish file types is disabled both by default and\n\
|
||||
with --color=never. With --color=auto, ls emits color codes only when\n\
|
||||
standard output is connected to a terminal. The LS_COLORS environment\n\
|
||||
variable can change the settings. Use the dircolors command to set it.\n\
|
||||
"), stdout);
|
||||
fputs (_("\
|
||||
\n\
|
||||
@@ -4681,7 +4701,7 @@ Exit status:\n\
|
||||
1 if minor problems (e.g., cannot access subdirectory),\n\
|
||||
2 if serious trouble (e.g., cannot access command-line argument).\n\
|
||||
"), stdout);
|
||||
emit_bug_reporting_address ();
|
||||
emit_ancillary_info ();
|
||||
}
|
||||
exit (status);
|
||||
}
|
||||
|
||||
25
src/md5sum.c
25
src/md5sum.c
@@ -195,7 +195,7 @@ should be a former output of this program. The default mode is to print\n\
|
||||
a line with checksum, a character indicating type (`*' for binary, ` ' for\n\
|
||||
text), and name for each FILE.\n"),
|
||||
DIGEST_REFERENCE);
|
||||
emit_bug_reporting_address ();
|
||||
emit_ancillary_info ();
|
||||
}
|
||||
|
||||
exit (status);
|
||||
@@ -251,11 +251,10 @@ static bool
|
||||
split_3 (char *s, size_t s_len,
|
||||
unsigned char **hex_digest, int *binary, char **file_name)
|
||||
{
|
||||
size_t i;
|
||||
bool escaped_filename = false;
|
||||
size_t algo_name_len;
|
||||
|
||||
i = 0;
|
||||
size_t i = 0;
|
||||
while (ISWHITE (s[i]))
|
||||
++i;
|
||||
|
||||
@@ -263,11 +262,13 @@ split_3 (char *s, size_t s_len,
|
||||
algo_name_len = strlen (DIGEST_TYPE_STRING);
|
||||
if (strncmp (s + i, DIGEST_TYPE_STRING, algo_name_len) == 0)
|
||||
{
|
||||
if (strncmp (s + i + algo_name_len, " (", 2) == 0)
|
||||
if (s[i + algo_name_len] == ' ')
|
||||
++i;
|
||||
if (s[i + algo_name_len] == '(')
|
||||
{
|
||||
*binary = 0;
|
||||
return bsd_split_3 (s + i + algo_name_len + 2,
|
||||
s_len - (i + algo_name_len + 2),
|
||||
return bsd_split_3 (s + i + algo_name_len + 1,
|
||||
s_len - (i + algo_name_len + 1),
|
||||
hex_digest, file_name);
|
||||
}
|
||||
}
|
||||
@@ -512,7 +513,6 @@ digest_check (const char *checkfile_name)
|
||||
if (!status_only)
|
||||
{
|
||||
printf (_("%s: FAILED open or read\n"), filename);
|
||||
fflush (stdout);
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -538,7 +538,6 @@ digest_check (const char *checkfile_name)
|
||||
printf ("%s: %s\n", filename, _("FAILED"));
|
||||
else if (!quiet)
|
||||
printf ("%s: %s\n", filename, _("OK"));
|
||||
fflush (stdout);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -618,6 +617,10 @@ main (int argc, char **argv)
|
||||
|
||||
atexit (close_stdout);
|
||||
|
||||
/* Line buffer stdout to ensure lines are written atomically and immediately
|
||||
so that processes running in parallel do not intersperse their output. */
|
||||
setvbuf (stdout, NULL, _IOLBF, 0);
|
||||
|
||||
while ((opt = getopt_long (argc, argv, "bctw", long_options, NULL)) != -1)
|
||||
switch (opt)
|
||||
{
|
||||
@@ -661,21 +664,21 @@ main (int argc, char **argv)
|
||||
usage (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (status_only & !do_check)
|
||||
if (status_only && !do_check)
|
||||
{
|
||||
error (0, 0,
|
||||
_("the --status option is meaningful only when verifying checksums"));
|
||||
usage (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (warn & !do_check)
|
||||
if (warn && !do_check)
|
||||
{
|
||||
error (0, 0,
|
||||
_("the --warn option is meaningful only when verifying checksums"));
|
||||
usage (EXIT_FAILURE);
|
||||
}
|
||||
|
||||
if (quiet & !do_check)
|
||||
if (quiet && !do_check)
|
||||
{
|
||||
error (0, 0,
|
||||
_("the --quiet option is meaningful only when verifying checksums"));
|
||||
|
||||
@@ -71,7 +71,7 @@ Mandatory arguments to long options are mandatory for short options too.\n\
|
||||
"), stdout);
|
||||
fputs (HELP_OPTION_DESCRIPTION, stdout);
|
||||
fputs (VERSION_OPTION_DESCRIPTION, stdout);
|
||||
emit_bug_reporting_address ();
|
||||
emit_ancillary_info ();
|
||||
}
|
||||
exit (status);
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user