Commit Graph

12285 Commits

Author SHA1 Message Date
Karel Zak b9c650106b Revert "cal: simplify leap year rule"
It was mistake, we use extra rule for date < 1752 from the beginning
and another calculations depends on this.

This reverts commit b9bd8dc267.
2017-12-14 13:19:08 +01:00
Karel Zak 3c49b23ad6 cal: explain magic values for day of week calculation
Based on BERNDT E.SCHWERDTFEGER papers.

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-12-13 19:09:56 +01:00
Masatake YAMATO 616e75c02c fincore: fix a typo in fincore.1
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2017-12-13 13:06:54 +01:00
Karel Zak 68452bb568 tests: update libsmartcols/title
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-12-13 12:57:22 +01:00
Karel Zak 3fa48b118a libsmartcols: don't add blank padding after left aligned title
Let's use the same semantic for the title as for the last column in
the table. If aligned on left, table is not "maxout" and title padding
symbol is undefined (or blank) then keep title as short as possible.

Addresses: https://github.com/karelzak/util-linux/issues/549
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-12-12 13:19:36 +01:00
Karel Zak 8aeda56b5d sample-scols-title: add left title without padding
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-12-12 13:16:54 +01:00
Karel Zak 856d856a98 mcookie: properly initialize hash
This stupid mistake has been introduced by commit 46ae163a8e.

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-12-12 12:09:13 +01:00
Karel Zak 42dea85c5a lib/md5: use ul_/UL_ prefix
The symbols names are too generic.

Addresses: https://github.com/karelzak/util-linux/issues/548
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-12-12 12:06:15 +01:00
Karel Zak 3ae2cb49d9 lib/sha1: fix indention
* indent -linux -psl -blf  lib/sha1.c
* manually fix comments

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-12-12 11:42:28 +01:00
Karel Zak b4db227582 test_sha1: update helper
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-12-12 11:38:17 +01:00
Karel Zak 3bd55be742 lib/sha1: use ul_/UL_prefix for symbols
Unfortunately, the symbols are visible in statically compiled libuuid
and the names are too generic.

Addresses: https://github.com/karelzak/util-linux/issues/548
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-12-12 11:29:02 +01:00
Karel Zak 50695114be Merge branch '2017wk48' of https://github.com/kerolasa/lelux-utiliteetit 2017-12-11 16:03:39 +01:00
Sami Kerola 2b798ecde9
docs: improve setarch(8) manual page
Add more information when and why one might want to use various options.

Reviewed-by: Dmitry V. Levin <ldv@altlinux.org>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-12-10 10:50:32 +00:00
J William Piggott 6cdc7b9c02 lib/timeutils.c: warn format_iso_time() overflow
Print a message when the format_iso_time() buffer is exceeded, because
there is more than one type of failure that returns -1.

Also remove the corresponding message from hwclock.c.

Signed-off-by: J William Piggott <elseifthen@gmx.com>
2017-12-09 18:43:29 -05:00
J William Piggott 2d9a0b0adb lib/timeutils.c:strxxx_iso: do not wrap tm_year
Year can wrap when adding the tm struct epoch during iso formatting:
hwclock --utc --noadjfile --predict --date '67768034678844900 seconds'
-2147481749-12-31 23:59:59.000000-05:00

Patched:
hwclock --utc --noadjfile --predict --date '67768034678844900 seconds'
2147485547-12-31 23:59:59.000000-05:00

Comparable to date(1):
date -Ins --date '67768034678844900 seconds'
2147485547-12-31T23:59:59,547886165-0500

Note: the 'seconds' argument is relative to the current time, so
      reaching this max year output is a moving target. The values shown
      above were invalid one second later. They then overflow tm_year
      upon conversion with localtime(3) and friends, which causes them
      to return NULL indicating that an error occurred.

Signed-off-by: J William Piggott <elseifthen@gmx.com>
2017-12-09 15:05:38 -05:00
J William Piggott ee475ab23e lib/timeutils.c:strxxx_iso: test conversion errors
Test for libc time conversion errors in ISO time format functions.

hwclock --utc --noadjfile --predict --date '67768034678846520 seconds'
Segmentation fault

Patched:
hwclock --utc --noadjfile --predict --date '67768034678846520 seconds'
hwclock: time 67768036191695381 is out of range.

Comparable to date(1):
date --date '67768034678846520 seconds'
date: time 67768036191695384 is out of range

Signed-off-by: J William Piggott <elseifthen@gmx.com>
2017-12-09 14:40:05 -05:00
J William Piggott 97772cc329 lib/timeutils.c: bug fix Segmentation fault
Use reentrant time functions to avoid sending a NULL pointer to
format_iso_time() (and to be reentrant ;). Followup commits test for
errors and tm_year wrapping (illustrated below).

hwclock --utc --noadjfile --predict --date '67768034678849400 seconds'
Segmentation fault

Patched
hwclock --utc --noadjfile --predict --date '67768034678849400 seconds'
-2147481748-01-00 00:10:46.000000-05:00

Signed-off-by: J William Piggott <elseifthen@gmx.com>
2017-12-09 14:01:33 -05:00
Karel Zak 44d753407d tests: unlocks on failed ts_scsi_debug_init
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-12-07 15:08:29 +01:00
Karel Zak 9212134d53 tests: don't call tests with races in --parallel
Some of the tests have a race by design (=wanted).

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-12-07 14:41:49 +01:00
Karel Zak 7acd4b463a tests: support multiple locks
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-12-07 14:41:08 +01:00
Karel Zak f1254fae6d tests: add mdadm locks
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-12-07 12:31:41 +01:00
Karel Zak b480afcaba libblkid: add debug messages when ignore useless devices
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-12-07 12:15:48 +01:00
Sweet Tea Dorminy 6418cba457 libblkid: Add VDO superblock information into blkid
[kzak@redhat.com: - add tests/expected/blkid/low-probe-vdo
                  - enlarge the image (must be > 1024)]

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-12-07 12:11:32 +01:00
Karel Zak e140506af3 tests: use flock to modify fstab
Note that for btrfs test we need to use low-level ts_fstab_addline,
because we add multiple lines there.

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-12-06 15:55:09 +01:00
Karel Zak 9deb8c7dfd tests: add lock on shared resources (e.g. scsi_debug)
The patch enables flock for scsi_debug to avoid collision between
tests. The patch also adds ./run.sh --nolocks to disable this feature.

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-12-06 14:21:38 +01:00
Sami Kerola cbfa144276 setarch: minor code clean up
Remove global variable, skip unnecessary comparison, and remove version
printing function when a simple printf() can do the job.  In same go fix
compiler warning.

sys-utils/setarch.c:296:4: warning: null argument where non-null required
(argument 2) [-Wnonnull]
    execl("/bin/bash", NULL);

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-12-04 13:04:16 +01:00
Sami Kerola 378d58abb1 rename: use access(3) to check if a file exists
This is more lightweight than calling stat(3).  In same go add a regression
test to ensure changes like this will not break --no-overwrite option.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-12-04 13:04:12 +01:00
Sami Kerola a16f45d4f6 vipw: do not let editor to inherit open file descriptors
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-12-04 13:04:11 +01:00
Karel Zak e6b32e7d1a login: add LOGIN_PLAIN_PROMPT to login.defs
We have command line option -H to disable hostname in login prompt.
Unfortunately, in same cases (e.g. telnetd) it's impossible to specify
login(1) command line options due to hardcoded execl()...

This patch introduces LOGIN_PLAIN_PROMPT boolean for /etc/login.defs
to suppress hostname in the prompt.

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-12-04 12:31:29 +01:00
Karel Zak 09cb6b42c9 fallocate: remove typo
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-11-29 15:13:24 +01:00
Karel Zak 173ef88237 fallocate: dig holes only in data extents
Based on patch from Vaclav Dolezal <vdolezal@redhat.com>, this
implementation is less invasive.

The patch adds a new while() for pread() call (so diff is mostly code
indention). The pread() is called for a real data only (addressed by
'off' and 'end') and we use SEEK_{DATA,HOLE} before the pread() to
skip already existing holes. The variables 'file_off' and 'file_end'
addresses area in the file as specified on fallocate command line.

Test:

$ truncate -s 10G testfile
$ dd if=/dev/zero of=testfile count=10 bs=1M conv=notrunc

old version:

	$ time /usr/bin/fallocate --dig-holes --verbose testfile
	testfile: 10 GiB (10737418240 bytes) converted to sparse holes.

	real	0m3.013s
	user	0m0.700s
	sys	0m2.304s

new version:

	$ time ./fallocate --dig-holes --verbose testfile
	testfile: 10 MiB (10485760 bytes) converted to sparse holes.

	real	0m0.026s
	user	0m0.002s
	sys	0m0.004s

The old version scans all file.

The change has minimal overhead for files without holes.

Addresses: https://github.com/karelzak/util-linux/issues/421
Co-Author: Vaclav Dolezal <vdolezal@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-11-29 15:01:39 +01:00
Karel Zak f4b03edb73 login-utils: use free_getlogindefs_data()
It seems better to deallocate logindefs.conf stuff in long time
running (=waiting) processes like login(1) and su(1).

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-11-28 14:49:05 +01:00
Sami Kerola 6ce4256ecd eject: remove list_speeds() #ifdef CDROM_SELECT_SPEED protection
The CDROM_SELECT_SPEED should be available practically everywhere.  Where
the define is missing an error message about path /proc/sys/dev/cdrom/info
cannot be opened is better error than a warnx() about kernel support.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-11-28 14:39:19 +01:00
Sami Kerola 0b7e477188 lib/signames: remove unused function
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-11-28 14:39:17 +01:00
Sami Kerola bfcd327541 man: use long options in text and add example to uuidgen
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-11-28 14:39:15 +01:00
Sami Kerola fcf841f8d3 misc: fix typos
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-11-28 14:39:13 +01:00
Karel Zak 57358f50f3 tests: check for HAVE_LINUX_NET_NAMESPACE_H
* use one cleanup function
* check if kernel headers support net namespace
* enable netnsid test

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-11-28 13:19:20 +01:00
Karel Zak 68433f1e31 tests: add set-x to lsns test
.. just to see why does it fail on Travis.

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-11-28 12:00:58 +01:00
Karel Zak 29f966a57b tests: better lsns report on fail
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-11-28 11:17:18 +01:00
Karel Zak c3487d5955 tests: make lsns test more robust
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-11-28 10:58:37 +01:00
Karel Zak b9e4ee42c2 nsenter: fix compiler warning [-Wuninitialized]
sys-utils/nsenter.c: In function ‘is_same_namespace’:
sys-utils/nsenter.c:170:2: warning: ‘b_ino’ may be used uninitialized in this function [-Wuninitialized]
sys-utils/nsenter.c:170:2: warning: ‘a_ino’ may be used uninitialized in this function [-Wuninitialized]

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-11-28 10:53:35 +01:00
Karel Zak aec01d7211 dmesg: fix compiler warning [-Wuninitialized]
sys-utils/dmesg.c: In function ‘print_record.constprop.12’:
sys-utils/dmesg.c:1039:14: warning: ‘mesg_size’ may be used uninitialized in this function [-Wuninitialized]

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-11-28 10:45:06 +01:00
Karel Zak 4b328279ce build-sys: lsns requires libmount
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-11-27 17:44:43 +01:00
Karel Zak f593e2797e lsns: initialize stuff when really necessary
It's more robust to depend on list of the wanted columns than on
another variables.

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-11-27 17:40:56 +01:00
Karel Zak 5a0d3030ca tests: fix lsns perms
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-11-27 17:33:28 +01:00
Karel Zak deb3f5180c lsns: rename notruns to no_trunc
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-11-27 17:13:50 +01:00
Karel Zak 7eda2400db lsns: nsfs stuff cleanup
* don't use booleans
* use is_ prefix for boolean-like functions
* make nsfs_xasputs() more readable
* enable 'nowrap' together with 'raw' and don't test for "nowrap || raw"
* add missing 'W' to getopt_long()

Signed-off-by: Karel Zak <kzak@redhat.com>
2017-11-27 17:13:50 +01:00
Masatake YAMATO 7817b2ad08 lsns: (man) write about using multi-line in NSFS cell of lsns
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2017-11-27 17:13:40 +01:00
Masatake YAMATO 94d4ccd7a2 lsns: add a case for testing nsfs column
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2017-11-27 15:54:57 +01:00
Masatake YAMATO 0a32d39a0b lsns: add --nowrap(-W) option
This option forces lsns command not use
multi-line presentation when printing a cell.

Currently, it affects only NSFS column.

Implementing this option is suggested by Karl Zak.

Signed-off-by: Masatake YAMATO <yamato@redhat.com>
2017-11-27 15:54:56 +01:00