Commit Graph

1824 Commits

Author SHA1 Message Date
sin
bb7427f6c1 Fix type mismatch in split(1)
Adapted from a patch sent by Random832.
2015-11-26 10:35:46 +00:00
sin
67157b7c4e Use SSIZE_MAX for overflow check in parseoffset()
There's no such thing as OFF_MAX so we can't use that.  off_t is
signed, so use SSIZE_MAX which will typically match the range of
off_t.
2015-11-26 10:35:46 +00:00
sin
1be832320c Fix type mismatches
Thanks to Random832 for the patch.
2015-11-26 10:35:46 +00:00
sin
41a9742037 cal: Highlight current day
Thanks cls!
2015-11-21 10:20:07 +00:00
Brad Barden
211c565b3d tar: improve file status handling on extract
by re-ordering when chmod/chown is done, only a list of directories (not
all files) need be kept for fixing mtime.

this also fixes an issue where set-user-id files in a tar may not work. chmod
is done before chown and before the file is written. if ownership changes, or
the file is being written as a normal user, the setuid bit would be cleared.

also fixes ownership of symbolic links. previously a chown() was called,
which would change the ownership of the link target. lchown() is now
used for symbolic links.

renamed all ent, ent* functions to dir* as it better describes what they
do.

use timespec/utimensat instead of timeval/utimes to get AT_SYMLINK_NOFOLLOW
2015-11-20 09:58:38 +00:00
Brad Barden
85a9254d3a tar: extract creation mode
mode for newly-created files should be restrictive. chmod is always
called soon after to set correct mode from the archive.
2015-11-20 09:58:38 +00:00
sin
11fee4c8ba readlink: Remove broken support for -m and -e
There is no need to bloat readlink with these options.  No one has
ever used them anyway.
2015-11-16 16:30:19 +00:00
sin
d24584466c Revert "enmasse: For the special case of 2 args, do not distinguish between dirs and files"
This reverts commit a564a67c4ea70e90a4dc543814458e4903869d3e.

Not as trivial as I thought.  This breaks cp when used as:
cp -r /foo/bar /baz

The old code expands this to:
cp -r /foo/bar /baz/bar
2015-11-13 14:31:34 +00:00
sin
4c1f9ecdd2 Align end of comment 2015-11-13 14:24:09 +00:00
sin
996f992ac6 enmasse: For the special case of 2 args, do not distinguish between dirs and files
This produces consistent error messages when moving or copying a file or dir to
itself.
2015-11-13 14:21:07 +00:00
sin
2f4ab52739 mv: Ensure stat is initialized when we prune a tree
This can happen if you move a file from one filesystem to another.
rename(2) will fail and we will fall through to a manual cp + rm.
Initiate the rm through recurse() like we do for rm(1).

Thanks to Heiko for reporting this.
2015-11-13 14:21:07 +00:00
sin
debf9d2275 Include sys/time.h for timeval structure
Without this, it breaks on NetBSD.
2015-11-13 11:32:11 +00:00
sin
eaf3f4811b Use -D_FILE_OFFSET_BITS=64 by default
Maybe people seem to stumble upon this problem on 32-bit glibc based
systems.  Just set it by default.
2015-11-13 11:01:00 +00:00
sin
a1c04e932b Sync cron with latest scron 2015-11-06 11:01:00 +00:00
sin
b553349251 env: Check unsetenv() return value
./env -u "" foo and ./env -u "A=123" foo should both fail.
2015-11-06 10:52:49 +00:00
sin
1b32732887 env: environ can never be NULL so don't check for it 2015-11-06 10:52:49 +00:00
sin
75b848bb09 Mark grep and tftp as audited
Gone through the code quite a few times.  Been using them frequently
without problems.
2015-11-06 10:52:49 +00:00
sin
f76dee45e5 Update TODO regarding imported programs
We haven't imported anything in a while and there are no plans to
import anything else.
2015-11-06 10:52:49 +00:00
Greg Reagle
c0a63db7f2 od: document skip (-j) option 2015-11-06 10:18:56 +00:00
Michael Forney
7604f99003 tail: Fix operation with +n argument
POSIX says

  Copying shall begin at the point in the file indicated by the -c
  number or -n number options.

  The origin for counting shall be 1; that is, -c +1 represents the
  first byte of the file, -c -1 the last.

  The origin for counting shall be 1; that is, -n +1 represents the
  first line of the file, -n -1 the last.
2015-11-02 21:09:36 +00:00
Quentin Rameau
4859f4c825 ls: fix time handling by augmenting time resolution
ls was using (old) UNIX spec (struct stat).st_[acm]time.
It now uses POSIX (struct stat).(struct timespec st_[acm]tim) which
gives time resolution in seconds and nanoseconds.
If two files have the same time in seconds, we extend the comparision to
nanoseconds.
2015-11-01 17:29:39 +00:00
Quentin Rameau
57d220b3dc ls: fix entities arrays handling in main()
Entities arrays in main() were arrays of pointer to entities and were
not compatible with entcmp().
They have been changed to being arrays of entities.
Thanks to Michael Forney <mforney@mforney.org> for having seen that.
2015-11-01 17:29:39 +00:00
sin
aa8112a408 Revert "ls: Fix sorting of named entries"
This reverts commit ff78d03791cc7c24dfc407c39dd2158451c9ad12.
2015-11-01 17:29:39 +00:00
sin
2366164de7 No need for semicolon after ARGEND
This is also the style used in Plan 9.
2015-11-01 10:18:55 +00:00
sin
27f9163d2e getconf: Fix trailing whitespace 2015-11-01 09:36:41 +00:00
Michael Forney
674d1636f8 ls: Fix sorting of named entries
Previously, entcmp was being passed struct entry **, when it expected
struct entry *.

Many autoconf-generated configure scripts use `ls -t` to determine whether or
not the system clock is behaving correctly. If they are sorted in the wrong
order, it produces an error.

  checking whether build environment is sane... configure: error: newly created file is older than distributed files!
  Check your system clock
2015-11-01 09:36:41 +00:00
FRIGN
b70d2857ab Use ifdef in getconf(1) instead of commenting out missing defines
Thanks k0ga for the suggestion!
2015-11-01 09:36:41 +00:00
Greg Reagle
9b7e560781 od: more accurate statement of compliance with POSIX 2015-10-31 10:41:33 +00:00
FRIGN
dae33f42d4 Fix typo in libutil/fshut.c 2015-10-26 16:53:28 +00:00
FRIGN
91ab4e80b9 Fix multiple file handling
1) Fix skip overflow for negative numbers
2) Print proper trailing lines and addresses according to the last
   element.
2015-10-26 16:53:28 +00:00
sin
1e4ab5ec9a Minor style fix 2015-10-26 11:57:04 +00:00
FRIGN
ecb351f1d5 Properly parse numbers in od(1)
Previously, it'd drop right through in the number case and return
crazy-long numbers (like 28 for L), resulting in unexpected behaviour.
2015-10-26 11:55:41 +00:00
FRIGN
1eff1e8214 Properly handle partial chunks in od(1)
Grab the remaining bytes and fill them up with zeroes in a
temporary buffer.
2015-10-26 11:55:41 +00:00
FRIGN
914991f5f6 Fix remaining endian-issue in od(1)
After setting up qemu and testing od(1) in a Big Endian environment,
I found out that the conditional in the printing function was not
right.
Instead, it's supposed to be way simpler. While at it, we don't need
HOST_BIG_ENDIAN any more. Just set big_endian properly in main()
and be done with it.
2015-10-26 11:55:41 +00:00
FRIGN
a2536328aa Mark getconf as audited in README 2015-10-26 11:55:41 +00:00
FRIGN
86a99c5a03 Mark od(1) and getconf(1) as audited
They have just been (re)written, nothing to do here...
2015-10-26 11:55:41 +00:00
FRIGN
eeccb0a5ea Fix od(1) output
Of course, for right-justification we want no "+"'s in the output.
2015-10-26 11:55:41 +00:00
FRIGN
d03baf1697 Add -e and -E flags to od(1) and properly handle endianness
The -e and -E flags allow the user to override the host endianness
and force od(1) to handle input according to a little (-e) or big (-E)
endian environment.
The previous handling was broken as bitshifts alone are already
endian-independent.
2015-10-26 11:55:41 +00:00
FRIGN
c619e168c9 Update od(1)-documentation 2015-10-26 11:55:41 +00:00
FRIGN
092c95b66c Rewrite od(1)
Looking at the old code, it became clear that the desired
functionality with the t-flag could not be added unless the
underlying data-structures were reworked.
Thus the only way to be successful was to rewrite the whole thing.

od(1) allows giving arbitrarily many type-specs per call, both via
-t x1o2... and -t x1 -t o2 and intermixed.
This fortunately is easy to parse.
Now, to be flexible, it should not only support types of integral
length. Erroring out like this is inacceptable:

$ echo -n "shrek"| od -t u3
od: invalid type string ‘u3’;
this system doesn't provide a 3-byte integral type

Thus, this new od(1) just collects the bytes until shortly before
printing, when the numbers are written into a long long with the
proper offset.
The bytes per line are just the lcm of all given type-lengths and >= 16.
They are equal to 16 for all types that are possible to print using
the old od(1)'s.

Endianness is of course also supported, needs some testing though,
especially on Big Endian systems.
2015-10-26 11:55:41 +00:00
sin
7b9988c7ff Implement -o for flock(1) to close fd before exec 2015-10-26 11:55:41 +00:00
Hiltjo Posthuma
09c3caa56d getconf.1: fix: end list (El) 2015-10-10 01:18:24 +02:00
sin
435b7b5d20 Convert leading whitespace to tabs 2015-10-08 16:18:45 +01:00
FRIGN
e51a2e6d2f Use ISO-date-format in manpages
The one specified by mdoc is hard to read for non-native
speakers from countries which read the date day-first (like
Germany, Greece, North-Korea, Swamp,...).
This is also consistent with how we generally specify dates
at suckless.org.
2015-10-08 17:15:08 +02:00
sin
979f3cb844 env: Fix return value if the command could not be found 2015-10-07 16:25:54 +01:00
sin
fb4ca81fe8 Include fcntl.h for open(2)
It was implicitly included via sys/file.h on my system.
2015-10-07 15:21:24 +01:00
sin
acca463813 If multiple modes are supplied to flock(1), the last one wins 2015-10-07 10:27:47 +01:00
sin
9a176e4011 Add flock entry in README 2015-10-07 10:27:47 +01:00
sin
386fa3d2a7 flock: Set default mode for open(2) 2015-10-07 10:27:47 +01:00
sin
2652dcfd6c Initial implementation of flock(1)
Very useful to prevent overlapping cron jobs amongst other things.
2015-10-07 10:27:47 +01:00