Commit Graph

10039 Commits

Author SHA1 Message Date
Karel Zak a29edd057c Merge branch 'cal-span' of https://github.com/Deiz/util-linux
* 'cal-span' of https://github.com/Deiz/util-linux:
  cal: Add --span option
  cal: Track date span independently from months_in_row
2015-11-05 11:32:10 +01:00
Karel Zak b0e6b25e64 build-sys: bump also PACKAGE_VERSION_RELEASE number
Now we bump only PACKAGE_VERSION_MAJOR and PACKAGE_VERSION_MINOR
numbers. The PACKAGE_VERSION_RELEASE is always zero.

These numbers are used for LIBxxx_VERSION strings and Version: field
in the .pc files.

Unfortunately, if we keep PACKAGE_VERSION_RELEASE= always zero then
our bugfix releases are invisible for pkg-config.

(Although I don't think it's good idea to depend in code on any
 library bugfix release, code should be about APIs).

Addresses: https://github.com/systemd/systemd/pull/1754
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-11-04 17:19:41 +01:00
Karel Zak 4419ffb9ef lib/sysfs: make sysfs_get_devname()/blkid_devno_to_wholedisk() more robust
Now the function uses result buffer for internal stuff (readlink), so
it requires that the buffer is large enough. This is unexpected as
caller assumes that the buffer has to be large enough for devname only.

References: http://www.spinics.net/lists/util-linux-ng/msg12015.html
Reported-by: Tom Yan <tom.ty89@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-10-30 11:08:32 +01:00
Karel Zak 9b28da2d1f logger: remove unnecessary comment
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-10-29 11:32:50 +01:00
Karel Zak 27a9eb5359 logger: use --id as local socket credentials
If you have really paranoid syslog (or systemd who listens on /dev/log)
then it replaces in the message PID with a real PID from socket header
credentials:

 # echo $PPID
 1550

 # logger -p info --stderr --id=$PPID "This is message baby!"
 <14>Oct 29 11:22:13 kzak[1550]: This is message baby!

 # journald -n 1
 Oct 29 11:22:13 ws kzak[22100]: This is message baby!
                         ^^^^^

This patch forces kernel to accept another *valid* PID if logger(1)
executed with root permissions; improved version:

 # logger -p info --stderr --id=$PPID "This is message baby!"
 <14>Oct 29 11:26:00 kzak[1550]: This is message baby!

 # journald -n 1
 Oct 29 11:26:00 ws kzak[1550]: This is message baby!

Signed-off-by: Karel Zak <kzak@redhat.com>
2015-10-29 11:18:21 +01:00
Karel Zak 17c8aa1dc0 logger: use iovec for all message
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-10-27 18:44:00 +01:00
Karel Zak 94a28496aa logger: use iovec and sendmsg() to send message
The iovec based solutions allow to send multiple strings by one
syscall (for example additional \n messages separator). We can also
use it to send additional socket header metadata (e.g.
SCM_CREDENTIALS) later.

Signed-off-by: Karel Zak <kzak@redhat.com>
2015-10-27 13:19:16 +01:00
Karel Zak da0c95128c Merge branch 'uuid' of git://github.com/kerolasa/lelux-utiliteetit
* 'uuid' of git://github.com/kerolasa/lelux-utiliteetit:
  tests: add uuidd output check
  tests: add uuidgen output check
  tests: make test_uuid_parser to read files
  tests: add uuid parser check
2015-10-27 12:01:22 +01:00
Karel Zak 741d478eeb ctrlaltdel: use path.h to read /proc
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-10-27 11:56:51 +01:00
Sami Kerola 244d48331e
tests: add uuidd output check
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-10-18 20:17:07 +01:00
Sami Kerola 4bd90ec864
tests: add uuidgen output check
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-10-18 20:17:01 +01:00
Sami Kerola 85638702ed
tests: make test_uuid_parser to read files
This allows using the command to check uuidgen and uuidd are generating
valid outputs.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-10-18 19:12:30 +01:00
Sami Kerola 4d3f964e4a
tests: add uuid parser check
The check is based on code by Theodore Ts'o to test libuuid, from which
unstable output is commented out.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-10-18 18:39:21 +01:00
Sami Kerola 82cac34889
ctrlaltdel: display setting when ran without arguments
This is more useful than printing an error.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-10-18 18:03:57 +01:00
Sami Kerola 6e82b1f3ef
docs: update ctrlaltdel.8 man page
Most significant clarification is to tell hard C_A_D is the default in linux
kernel.  Update also kernel reference, and improve readability.

Reference: http://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/tree/kernel/reboot.c
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-10-18 18:03:52 +01:00
Sami Kerola 8137c98f83
ctrlaltdel: improve error messaging
Tell user what is wrong rather than print usage().

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-10-18 18:03:47 +01:00
Sami Kerola bd299782ca
nologin: require /etc/nologin.txt to be file
This makes silly practical jokes impossible, like for example symlinking
/dev/null or dev/random to /etc/nologin.txt

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-10-18 18:03:38 +01:00
Sami Kerola f06abd22be
last: display input file in usage() according to command name
Default depends on whether the executable is called 'lastb' or something
else.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-10-18 18:03:34 +01:00
Karel Zak c2f03da93d script: be pedantic and use "%"SCNi64
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-10-16 11:48:47 +02:00
Isaac Dunham 345208a5ab script: don't assume that time_t is compatible with long
time_t may change to 64-bit on 32-bit Linux kernels at some point;
at that point, it may be desireable to test for issues with dates
past 2038.

[kzak@redhat.com: - use %jd rather than %lld]

Signed-off-by: Karel Zak <kzak@redhat.com>
2015-10-16 11:31:22 +02:00
James Clarke 99eadc9e3f sulogin: Use fallback method on the Hurd for detecting consoles
Signed-off-by: James Clarke <jrtc27@jrtc27.com>
2015-10-16 09:52:16 +02:00
Karel Zak 1bb02a2da9 libmount: follow docs with parse-error callback return code
The docs says that recoverable errors have rc > 0.

Signed-off-by: Karel Zak <kzak@redhat.com>
2015-10-15 12:12:11 +02:00
Karel Zak 4546fd398f Revert "libblkid: support LSI RAID on partition too"
This reverts commit bc9007c372.

We need a better way, it seems that the original report is mostly
about udev rules disadvantages than about libblkid bug. See RH
bugzilla (#1172510) for more details.
2015-10-15 12:04:35 +02:00
Karel Zak 1cd9d0d746 mount, umount, swapon, fsck, lsblk, findmnt: ignore malformed lines
The libmount provides way how to deal with parsing errors in fstab --
on error callback function is executed and according to the return
libmount manipulate with the malformed line, possible are three
states:

  1/ fatal error; all file ignored              (callback rc < 0)
  2/ recoverable error; malformed line ignored  (callback rc > 0)
  3/ ignore the error                           (callback rc == 0)

The 2/ is the default if no callback specified.

Unfortunately our utils uses 3/. The correct way is to use 2/.

Signed-off-by: Karel Zak <kzak@redhat.com>
2015-10-15 12:01:48 +02:00
Karel Zak d5b7d2912a libblkid: make XFS Log visible for wipefs
Reported-by: Peter Rajnoha <prajnoha@redhat.com>
Signed-off-by: root <root@ws.net.home>
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-10-13 12:02:17 +02:00
Karel Zak bc9007c372 libblkid: support LSI RAID on partition too
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1172510
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-10-13 10:55:47 +02:00
Karel Zak 440a355a3d libmount: fix uid= and gid= translation
The current libmount version returns error when no able to convert
username/groupname to uid/git.

 # mount mount /dev/sda1 /mnt/test -o uid=ignore
 # mount: failed to parse mount options

This is regression, the original mount(8) has ignored possible unknown
user/group names and the option has been used unconverted (with the
original value). For example UDF kernel driver depends on this behavior
and "uid=ignore" (or "forgot") is a valid mount option.

Fixed version (unit test):

./test_mount_optstr  --fix uid=kzak,gid=forgot,aaa,bbb
optstr: uid=kzak,gid=forgot,aaa,bbb
fixed:  uid=1000,gid=forgot,aaa,bbb

Reported-By: Anthony DeRobertis <anthony@derobert.net>
Addresses: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=801527
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-10-12 11:42:13 +02:00
Deiz ccf3dd50ce cal: Add --span option
This allows the date spanning behaviour of -3 to be used with other
month ranges.

Signed-off-by: Deiz <silverwraithii@gmail.com>
2015-10-09 20:39:02 -04:00
Deiz d4cb626da2 cal: Track date span independently from months_in_row
This fixes a minor issue where cal -n 3 would mirror the spanning
behaviour of cal -3 with Gregorian calendars, instead of starting with
the current month.

Signed-off-by: Deiz <silverwraithii@gmail.com>
2015-10-09 20:35:17 -04:00
Karel Zak 3ebfa6882a include/pt-mbr-partnames: remove '|' from partition type name
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-10-09 13:13:59 +02:00
Ian Wienand 240ddd3a5f libfdisk: Detect out-of-space when adding new primary partition
I got a bit confused with the interaction below:

  Command (m for help): p
  Disk /dev/sda: 41 GiB, 43965677568 bytes, 85870464 sectors
    ...
  Device     Boot   Start      End  Sectors  Size Id Type
  /dev/sda1  *       2048  1026047  1024000  500M 83 Linux
  /dev/sda2       1026048 85868543 84842496 40.5G 8e Linux LVM

  Command (m for help): n
  To create more partitions, first replace a primary with an extended partition.

I knew I should have had two primary partitions available, but I did
not notice that the disk was seen as full (I was trying to grow it)

This change detects available primary partitions, and if so indicates
we are out of space, rather than out of partitions.

Signed-off-by: Ian Wienand <iwienand@redhat.com>
2015-10-09 13:07:41 +02:00
Jörg Jenderek 3e9a2bbb94 fdisk: to recognize Intel Rapid Start hibernation partition
I use Intel Rapid Start Technology on my PC. According to their User Guide
"Rapid_Start_Technology_User_Guide_v1.4.pdf" I create a partition with id=84
for hibernation by this Technology.

Unfortunately the software fdisk (util-linux-2.27) classifies that partition as
"OS/2 hidden C:".  That is not wrong, but on website
https://en.wikipedia.org/wiki/Partition_type is written, that id 0x84 beside
using for hiding drive C: this type is a also used as hibernation partition for
Microsoft  APM and also for Intel Rapid Start

So I patched 2 header files so that fdisk recognize this partition type variation.

Signed-off-by: Karel Zak <kzak@redhat.com>
2015-10-09 13:07:31 +02:00
Karel Zak 24b7db7e4e partx: prevent code duplication
Reported-by: Alexander Kuleshov <kuleshovmail@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-10-09 12:18:28 +02:00
Karel Zak 3d6250e96b uuidd: add debug message for timeout
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-10-09 11:46:49 +02:00
Karel Zak b97edfe731 build-sys: use REALTIME_LIBS
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-10-09 11:31:49 +02:00
Karel Zak b85df4b738 uuidd: use cxt->quiet
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-10-09 11:26:28 +02:00
Karel Zak 4b09b1c253 uuidd: fix compiler warning [-Wsign-compare]
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-10-09 11:23:16 +02:00
Sami Kerola fd346daf89 uuidd: fix shadow declaration
misc-utils/uuidd.c:384:13: warning: declaration of 'ret' shadows a previous
			   local [-Wshadow]
misc-utils/uuidd.c:327:6: note: shadowed declaration is here

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-10-09 11:17:12 +02:00
Sami Kerola 25d66b4e32 uuidd: use signalfd() and setup_timer()
Point of this change is to replace use of signal() and alarm() system calls
using newer interfaces.  Nice side effect is that the point where timer was
earlier used cannot be distracted by sending rogue SIGALRM.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-10-09 11:17:11 +02:00
Sami Kerola 67791b7787 blkid, uuidd, uuidgen: assume getopt.h and getopt.h are available
These headers are in use allover this project without issues.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-10-09 11:17:09 +02:00
Sami Kerola 61b6427638 uuidd: slice up the usage text and normalize its layout
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-10-09 11:17:08 +02:00
Karel Zak 64b5e362a9 tests: replace username with tag in logger test
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-10-06 11:06:21 +02:00
Karel Zak 9baf46ea54 tests: add missing files
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-10-06 10:46:37 +02:00
Karel Zak 5b90a8f38f tests: update and extend logger tests
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-10-06 10:17:11 +02:00
Karel Zak fc20393cdb logger: fix messages separation on UNIX socket
The function write_output() add additional \n after each message on
TYPE_TPC. This is required by syslog daemons, otherwise you will see
multiple log messages merged together in your log file, for example:

  Oct  6 09:01:40 ws kzak: AAA<14>Oct  6 09:01:40 kzak: BBB

for

  printf "AAA\nBBB\n" | logger -p info -u <any-socket>

Unfortunately, the connection initialization functions keep the
default ALL_TYPES as connection type and nowhere in the control struct
is info about the final real connection type. The problem is invisible
when you specify --tpc or --udp on logger command line.

Addresses: https://github.com/karelzak/util-linux/issues/225
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-10-06 09:16:33 +02:00
Sami Kerola fa8945db4a uuidd: improve socket activation error messaging
Tell more exactly what is wrong and how, and give hint how to recover
when possible.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-10-02 12:38:30 +02:00
Alexander Kuleshov 100a43932c bash-completion: curly brace missed for findmnt
This patch provides fix for bash-completion/fndmt script. There
is curly brace missed in the completion generation for the -M/--mountpoint
option.

In other way we will get following messages:

bash: /etc/bash_completion.d/findmnt: line 91: unexpected EOF while looking for matching `)'
bash: /etc/bash_completion.d/findmnt: line 141: syntax error: unexpected end of file

Signed-off-by: Alexander Kuleshov <kuleshovmail@gmail.com>
2015-10-02 12:34:23 +02:00
Jörg Jenderek b12b07e361 fdisk: to recognize partition type 0xEA (Rufus)
i used a partitioning+formatting tool product rufus 2.2. of
https://rufus.akeo.ie/ This software has an extra format option for older BIOS.
With this fix the main partition is created with some alignments and for the
remaining unallocated space a small extra and empty partition with
identification 0xEA is created.

On the List of partition identifiers for PCs at
http://www.win.tue.nl/~aeb/partitions/partition_types-1.html is is said that
there is a freedesktop proposal to use also type ea as boot partition

Unfortunately the software fdisk (util-linux-2.27) can not classify that
partition.  I send for the fdisk program my 2 patches so that fdisk recognize
this partition type.

Signed-off-by: Karel Zak <kzak@redhat.com>
2015-10-02 12:34:01 +02:00
Karel Zak 2b29b8734a Merge branch 'logger' 2015-10-01 14:51:49 +02:00
Karel Zak 4299ed1ce2 logger: add --sd-id and -sd-param
This patch add support for RFC 5424 structured data elements. For
example:

     logger --rfc5424 --sd-id zoo@123                \
                      --sd-param tiger=\"hungry\"    \
                      --sd-param zebra=\"running\"   \
                      --sd-id manager@123            \
                      --sd-param onMeeting=\"yes\"   \
                      "this is message"

produces:

     <13>1 2015-10-01T14:07:59.168662+02:00 ws kzak - - [timeQuality tzKnown="1" isSynced="1" syncAccuracy="218616"][zoo@123 tiger="hungry" zebra="running"][manager@123 onMeeting="yes"] this is message

Signed-off-by: Karel Zak <kzak@redhat.com>
2015-10-01 14:48:15 +02:00