Commit Graph

67 Commits

Author SHA1 Message Date
Karel Zak 1c75a85101 libfdisk: use open(O_EXCL) to detect if device is used
It's seems detection by BLKRRPART is broken in recent kernels
(probably regression), and it's also overkill to force kernel re-read
all and generate all the events. It seems more elegant to use O_EXCL.

Signed-off-by: Karel Zak <kzak@redhat.com>
2021-04-15 15:14:52 +02:00
Karel Zak 734678205a tests: improve u64 use in ipcs test
UINT64_MAX is 18446744073709551615, but 2^64 is 18446744073709551616.
We also need to use kbytes in all calculation in the test than bytes
as ipcs by default do not use bytes anymore.

Signed-off-by: Karel Zak <kzak@redhat.com>
2021-01-19 16:25:33 +01:00
Karel Zak f596692030 test_tiocsti: check ioctl() return code [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2020-07-14 11:43:38 +02:00
Rosen Penev ad296391f9
[clang-tidy] fix wrong *cmp usage
Found with bugprone-suspicious-string-compare

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2020-04-20 13:21:00 -07:00
Patrick Steinhardt 2ede7ec214 tests: (fdisk) avoid hardcoding of errno string
The test fdisk/oddinput hardcodes strings returned by strerror(3P) for
both the errors ENOENT and ENOTTY. As these strings are unportable,
convert the tests to use the test_strerror helper instead to convert
them with sed(1).

Signed-off-by: Patrick Steinhardt <ps@pks.im>
2019-08-27 14:25:32 +02:00
Patrick Steinhardt eebc9e4dc2 tests: (col) avoid hardcoding of errno string
The col/multibyte test has a hardcoded error string as part of its
expected output that is returned by glibc's strerror(3P) function. Even
though many of these strings are the same across libc implementations,
they are not standardiced and some are certainly different. One example
is the string for EILSEQ on musl libc.

To fix this, we introduce a new test helper "test_strerror". The helper
can be invoked with an error code like "EILSEQ", which will cause it to
print out the the respective error message for that code. Note that
"test_strerror" cannot act on the error's value (e.g. 84 for EILSEQ), as
these aren't standardized either. Instead, we thus need to have an array
of the error's string representation ("EILSEQ") to its respective error
code (the define EILSEQ). The array can trivially be extended as
required, thus it is only sparsely populated with EILSEQ right now.

To fix the col/multibyte test, we introduce a call to sed(1) to replace
the strerror(3P) message from EILSEQ with "EILSEQ". Furthermore, as
we're running tests with the POSIX locale by default which treats all
bytes as valid multibyte sequences, we have to change to the C.UTF-8
locale instead to actually get an error.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
2019-08-27 09:37:01 +02:00
Vaclav Dolezal cad13ba344 tests: add tests for encode functions from lib/mbsalign.c
Signed-off-by: Vaclav Dolezal <vdolezal@redhat.com>
2018-01-10 17:40:53 +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 b4db227582 test_sha1: update helper
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-12-12 11:38:17 +01:00
Philip Prindeville b443c1779e misc: replace magic number 37 with UUID_STR_LEN
Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
2017-09-05 11:49:21 +02:00
Philip Prindeville 0047626887 libuuid: add support for hash-based UUIDs
Adding V3 and V5 UUIDs per RFC-4122.

[kzak@redhat.com: - fix symbols file]

Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2017-09-05 11:26:39 +02:00
Sami Kerola 41427f97d9
tests: add static keyword where needed [smatch scan]
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2017-03-17 21:22:26 +00:00
Ruediger Meier 81580f79fa agetty: remove obsolete HAVE_UPDWTMP fallback
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-12-07 12:35:24 +01:00
Stanislav Brabec a0a8e98844 tests: Add helper for TIOCSTI exploit
This helper/exploit injects "id -u -n\n" to the vulnerable calling terminal.

Use id -u -n to get a reproducible output of test cases based on it.

What can happen:

Nothing, no exploit: pty is not accessible, sedsid() disconnected the task from
pty, TIOCSTI failed.

The command is injected to the unprivileged environment pty, and you see e. g.
"nobody": This is acceptable.

The command is injected to the caller (privileged) pty, and you see "root" (or
caller uid name): This is not acceptable and has security implications.

References:

CVE-2016-2779
http://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2016-2779
http://seclists.org/oss-sec/2016/q1/448
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=815922
https://bugzilla.redhat.com/show_bug.cgi?id=173008
https://bugzilla.suse.com/show_bug.cgi?id=968674
https://bugzilla.suse.com/show_bug.cgi?id=968675

CVE-2016-2781
http://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2016-2781
http://seclists.org/oss-sec/2016/q1/452

Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
Cc: Federico Bento <up201407890@alunos.dcc.fc.up.pt>
2016-09-29 14:24:00 +02:00
Ruediger Meier c8d211478f tests: test_md5 prints md5sum only
We want to to use it for other tests without depending on
gnu md5sum and without cut or awk.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-04-13 12:29:16 +02:00
Sami Kerola 652822e08b misc: remove path name definitions that are unused
After this commit the following produces zero matches.

$ for i in \
_PATH_DEV_TTY \
_PATH_INITTAB \
_PATH_MNTTAB_DIR \
_PATH_MOUNTED_LOCK \
_PATH_MOUNTED_TMP \
_PATH_RC \
_PATH_REBOOT \
_PATH_SECURE \
_PATH_SECURETTY \
_PATH_SHUTDOWN_CONF \
_PATH_SINGLE \
_PATH_UMOUNT \
_PATH_USERTTY
do git grep $i; done

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2016-03-09 11:44:05 +01:00
Ruediger Meier 0ec9bba2ca misc-utils: build test_uuidd only if BUILD_UUIDD
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-02-12 14:11:19 +01:00
Boris Egorov 4ec6062678 tests: remove redundant check for NULL [cppcheck]
We set SA_SIGINFO flag, so we should not get NULL.

[tests/helpers/test_sigreceive.c:45] -> [tests/helpers/test_sigreceive.c:47]: (warning) Either the condition 'if(info)' is redundant or there is possible null pointer dereference: info.
2016-01-19 12:59:12 +06:00
Karel Zak 28f47fd2e0 test_uuidd: add comment
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-04-24 17:09:17 +02:00
Karel Zak a539def589 test_uuidd: add pid, tid and idx back to object
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-04-24 15:53:28 +02:00
Karel Zak 032776e8b0 test_uuidd: make objdump more robust
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-04-24 15:01:23 +02:00
Karel Zak adbc73eb61 test_uuidd: fix include
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-04-24 14:54:09 +02:00
Karel Zak cfa4171a14 test_uuidd: don't exit on failed pthread_create()
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-04-24 14:47:49 +02:00
Karel Zak 4d5241584f test_uuidd: don't exit on failed pthread_create()
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-04-24 14:47:09 +02:00
Karel Zak 1d27cd1193 test_uuidd: improve readability
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-04-24 14:25:30 +02:00
Karel Zak 179306122c test_uuidd: cleanup counters names
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-04-24 13:39:17 +02:00
Karel Zak 7eeb7e1d56 test_uuidd: cleanup pid usage
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-04-24 13:35:54 +02:00
Karel Zak f4be1406a3 test_uuidd: cleanup used types
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-04-24 13:28:12 +02:00
Karel Zak 0f2b00ce0a test_uuidd: err messages, argv[] parsing and another cleanups
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-04-24 12:40:51 +02:00
Huschaam Hussain 963f128cfa tests: add uuidd test program
References: https://bugzilla.redhat.com/show_bug.cgi?id=678306
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-04-24 11:30:49 +02:00
Sami Kerola 558445c93d tests: add kill --queue check
Correction.  The final failure to catch signal exit should not use
exiter() function.

--->8----
From: Sami Kerola <kerolasa@iki.fi>
Date: Mon, 14 Jul 2014 18:35:56 +0100
Subject: [PATCH] tests: add kill --queue check

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-07-15 13:22:24 +02:00
Ruediger Meier 60cb2c3720 build: fix some compiler warnings
Most of them catched on 32bit gcc and icc.

disk-utils/fsck.cramfs.c:     printf format type
lib/boottime.c:               unused variables
misc-utils/cal.c:             set but never used
sys-utils/losetup.c:          set but never used
sys-utils/lscpu-dmi.c:        defined but not used
sys-utils/switch_root.c:      comparison between signed and unsigned
tests/helpers/test_sysinfo.c: printf format type
2014-05-30 01:18:09 +02:00
Sami Kerola 6b93dcbee1 tests: add signal receiver program
Target to kill with a check that will be written later.

CC: Bernhard Voelker <mail@bernhard-voelker.de>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-04-26 19:04:52 +01:00
Gilles Espinasse e992a7b20d tests: new warning fix
2.23 added -Wstrict-prototypes check. Fix make check showing
CC tests/helpers/test_md5.o
tests/helpers/test_md5.c:8: warning: function declaration isn't a prototype

Signed-off-by: Gilles Espinasse <g.esp@free.fr>
2013-05-21 11:38:55 +02:00
Karel Zak 7194825b7b tests: fix compiler warning
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-04-18 11:23:34 +02:00
Karel Zak 922e6775e0 build-sys: move tests to check_PROGRAMS
Thanks to Mike Frysinger.

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-07-30 17:59:16 +02:00
Karel Zak c5e8db5f46 test_sysinfo: fix compiler warning [-Wmissing-prototypes]
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-07-16 18:38:14 +02:00
Karel Zak f38e5ff355 build-sys: cleanup .gitignore files
- move all binaries to top-level .gitignore
 - remove unnecessary */.gitignore files

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-06-26 20:50:54 +02:00
Karel Zak ac73480a34 build-sys: convert tests/ to module
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-06-26 20:50:53 +02:00
Sami Kerola 6a91958bf8 pathnames: clean up various user database paths
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-03-18 14:28:05 +01:00
Sami Kerola f06b43285d build-sys: enhance readability of the autotools files
Several horizontal lists are turned to vertical, and sorted to
alphabetical order. Additionally spaces are converted to tabs where
ever possible.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-02-28 13:29:35 +01:00
Karel Zak 6301d23a65 tests: fix compiler warnings [-Wunused-parameter]
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-08-01 15:27:26 +02:00
Sami Kerola e429d14106 md5: use symbolical digest length
Magic hash lenght number 16 is turned to a definition MD5LENGTH,
and put into use everywhere where md5 checksum is in use.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-07-21 23:56:48 +02:00
Karel Zak aeefa8a416 test_sysinfo: fix printf format
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-06-14 14:22:58 +02:00
Josiah Worcester 416723f089 test_sysinfo: Use CHAR_BIT*sizeof(void*) instead of __WORDSIZE.
Signed-off-by: Josiah Worcester <josiahw@gmail.com>
2011-06-14 13:59:07 +02:00
Fabian Groffen aabe244176 build-sys: use WORDS_BIGENDIAN to determine platform byte-order
Autoconf contains the right magic to determine the endianness on many
platforms next to Linux.  This reverses previous commits to move away
from WORDS_BIGENDIAN:
"use __BYTE_ORDER rather than AC specific WORDS_BIGENDIAN"

This is necessary to compile on non Linux platforms like Darwin and
Solaris.

Signed-off-by: Fabian Groffen <grobian@gentoo.org>
2011-01-17 15:34:45 +01:00
Karel Zak 601d12fb10 rename util-linux-ng back to util-linux
Signed-off-by: Karel Zak <kzak@redhat.com>
2010-11-30 11:41:59 +01:00
Karel Zak c74c0dafff include: clean up _PATH_DEV_* macros
Signed-off-by: Karel Zak <kzak@redhat.com>
2009-06-30 01:13:42 +02:00
Karel Zak 1f94344954 tests: add "byte-order" to helpers/test_sysinfo
Signed-off-by: Karel Zak <kzak@redhat.com>
2009-02-11 23:32:58 +01:00
Karel Zak 788a14403d tests: add MD5 regression test
Signed-off-by: Karel Zak <kzak@redhat.com>
2008-12-06 01:43:55 +01:00