]> git.ipfire.org Git - thirdparty/util-linux.git/log
thirdparty/util-linux.git
11 years agofdisk: add sun menu
Karel Zak [Fri, 17 May 2013 11:44:29 +0000 (13:44 +0200)] 
fdisk: add sun menu

Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agofdisk: add new stuff to display menus
Karel Zak [Fri, 17 May 2013 10:35:23 +0000 (12:35 +0200)] 
fdisk: add new stuff to display menus

fdisk menus:

 - driven by menu and menu_entry structs
 - supports normal and expect mode
 - supports multiple independent menus
 - supports menu separators to make output more readable
 - allows to exclude by whole menu or menu entries by label type

TODO:
 - define per label menus
 - per menu callback
 - sensitive only to keys defined in the currently printed menu

Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agolibfdisk: make the library usable with tests
Karel Zak [Fri, 17 May 2013 10:24:05 +0000 (12:24 +0200)] 
libfdisk: make the library usable with tests

We don't have completely initialized all label drivers in the tests, so
make the code more robust.

Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agolibfdisk: remove unnecessary code from test_fdisk_ask
Karel Zak [Fri, 17 May 2013 08:18:57 +0000 (10:18 +0200)] 
libfdisk: remove unnecessary code from test_fdisk_ask

.. 'sun' stuff is already in the library.

Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agofdisk: (gpt) add t, v and x to menu
Karel Zak [Wed, 15 May 2013 14:07:39 +0000 (16:07 +0200)] 
fdisk: (gpt) add t, v and x to menu

Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agofdisk: revert add 'G' to create SGI label to the main menu
Karel Zak [Wed, 15 May 2013 13:34:54 +0000 (15:34 +0200)] 
fdisk: revert add 'G' to create SGI label to the main menu

'G' does not make sense, fdisk menus are case insensitive. Yes...

Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agofdisk: always allow 'p'rint command in expert menu
Karel Zak [Wed, 15 May 2013 12:07:14 +0000 (14:07 +0200)] 
fdisk: always allow 'p'rint command in expert menu

Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agolibfdisk: (gpt) print UUID and NAME in expert mode only
Karel Zak [Wed, 15 May 2013 12:06:34 +0000 (14:06 +0200)] 
libfdisk: (gpt) print UUID and NAME in expert mode only

Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agolibfdisk: (gpt) cleanup structs members names
Karel Zak [Wed, 15 May 2013 11:43:00 +0000 (13:43 +0200)] 
libfdisk: (gpt) cleanup structs members names

Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agofdisk: add asktype "string" and support UUID partition change
Karel Zak [Wed, 15 May 2013 11:33:24 +0000 (13:33 +0200)] 
fdisk: add asktype "string" and support UUID partition change

Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agolibfdisk: add asktype "string" and support UUID partition change
Karel Zak [Wed, 15 May 2013 11:33:24 +0000 (13:33 +0200)] 
libfdisk: add asktype "string" and support UUID partition change

Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agolibfdisk: (sun) move driver from fdisk to library
Karel Zak [Thu, 2 May 2013 13:40:36 +0000 (15:40 +0200)] 
libfdisk: (sun) move driver from fdisk to library

 ... and also add fdisk_info_new_partition()

Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agolibfdisk: add fdisk_scround()
Karel Zak [Thu, 2 May 2013 12:54:55 +0000 (14:54 +0200)] 
libfdisk: add fdisk_scround()

Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agofdisk: (gpt, sun) use fdisk_partname()
Karel Zak [Thu, 2 May 2013 11:39:46 +0000 (13:39 +0200)] 
fdisk: (gpt, sun) use fdisk_partname()

Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agolibfdisk: add fdisk_partname()
Karel Zak [Thu, 2 May 2013 11:39:01 +0000 (13:39 +0200)] 
libfdisk: add fdisk_partname()

Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agofdisk: (sun) use tt.c to list disk label
Karel Zak [Thu, 2 May 2013 10:29:01 +0000 (12:29 +0200)] 
fdisk: (sun) use tt.c to list disk label

Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agofdisk: (sun) consolidate 'p'rint output
Karel Zak [Thu, 2 May 2013 09:49:28 +0000 (11:49 +0200)] 
fdisk: (sun) consolidate 'p'rint output

 * use label operation list()
 * use generic fdisk geometry output for sun
 * don't duplicate geometry information

Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agolibfdisk: add fdisk_context_enable_details()
Karel Zak [Thu, 2 May 2013 09:23:25 +0000 (11:23 +0200)] 
libfdisk: add fdisk_context_enable_details()

Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agolibfdisk: add list() label operation
Karel Zak [Tue, 30 Apr 2013 09:57:30 +0000 (11:57 +0200)] 
libfdisk: add list() label operation

... and use it for GPT

Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agolibfdisk: (gpt) use lib/tt.c to list partitions
Karel Zak [Mon, 29 Apr 2013 13:30:55 +0000 (15:30 +0200)] 
libfdisk: (gpt) use lib/tt.c to list partitions

Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agolibfdisk: add new 'ask' type TABLE
Karel Zak [Mon, 29 Apr 2013 13:29:48 +0000 (15:29 +0200)] 
libfdisk: add new 'ask' type TABLE

The new type could be used to print table-like output (for example
list of the partitions).

Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agolib/tt: add TT_FL_FREEDATA
Karel Zak [Mon, 29 Apr 2013 13:27:42 +0000 (15:27 +0200)] 
lib/tt: add TT_FL_FREEDATA

... to call free() for line data.

Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agofdisk: (sun) remove dead code
Karel Zak [Tue, 23 Apr 2013 13:25:53 +0000 (15:25 +0200)] 
fdisk: (sun) remove dead code

Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agoagetty: add \S to output /etc/os-release data
Karel Zak [Thu, 12 Sep 2013 10:44:09 +0000 (12:44 +0200)] 
agetty: add \S to output /etc/os-release data

This patch allows to use a new \S or \S{VARNAME} sequence in the
/etc/issue file. The sequence prints data from /etc/os-release.  The
reason is to keep /etc/issue file distribution and release
independent.

The \S{ANSI_COLOR} is converted to the real terminal escape seq.

For example:

   \S
   Kernel \r on an \m (\l)

or more complex example:

   Welcome to \S{ANSI_COLOR}\S{NAME}\e0m \S{VERSION}
   Report bugs at \S{BUG_REPORT_URL}.

See http://www.freedesktop.org/software/systemd/man/os-release.html
fr more details about /etc/issue.

Based on patch from Bill Nottingham <notting@redhat.com>.

Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agobuild-sys: add *vim and clang_complete to gitignore
Karel Zak [Thu, 12 Sep 2013 09:11:15 +0000 (11:11 +0200)] 
build-sys: add *vim and clang_complete to gitignore

Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agorev: fix new line regression
Sami Kerola [Tue, 10 Sep 2013 19:51:14 +0000 (20:51 +0100)] 
rev: fix new line regression

Commit 4b4eb34004378fe70259acd8f2f859e7b5cc3726 made output incorrect for
input lines that does not have new line.  For example

$ printf "a b c\n1 2 3" | rev
c b a
 2 13

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
11 years agotests: lscpu: add CPU max MHz to test results
Sami Kerola [Tue, 10 Sep 2013 19:51:13 +0000 (20:51 +0100)] 
tests: lscpu: add CPU max MHz to test results

Commit 44320710bdb98a3036e8297d0e0af043fb72d702 changed default output.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
11 years agoagetty: add baud rates available from glibc that are not already supported
James Buren [Tue, 3 Sep 2013 08:01:42 +0000 (03:01 -0500)] 
agetty: add baud rates available from glibc that are not already supported

This adds userspace support for baud rates reater than 230400, provided the tty
also supports it.

11 years agoagetty: only use EXTA/EXTB macros if B19200/B38400 macros are not present
James Buren [Tue, 3 Sep 2013 07:50:57 +0000 (02:50 -0500)] 
agetty: only use EXTA/EXTB macros if B19200/B38400 macros are not present

11 years agolibblkid: export info about bad csum
Karel Zak [Wed, 11 Sep 2013 15:42:48 +0000 (17:42 +0200)] 
libblkid: export info about bad csum

If a bad check sum is detected and BLKID_SUBLKS_BADCSUM is enabled
than SBBADCSUM=1 is added to the probing result.

Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agotests: add bcache images
Karel Zak [Wed, 11 Sep 2013 15:16:18 +0000 (17:16 +0200)] 
tests: add bcache images

 images generated by Rolf Fokkens <rolf@rolffokkens.nl>

Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agolibblkid: Add bcache support
Rolf Fokkens [Fri, 6 Sep 2013 10:58:45 +0000 (12:58 +0200)] 
libblkid: Add bcache support

From https://bugzilla.redhat.com/show_bug.cgi?id=1001120#c11

[kzak@redhat.com: - move crc64 code to lib/ by separate patch,
                  - use BLKID_USAGE_OTHER rather than _RAID]

Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agolib: add crc64()
Karel Zak [Wed, 11 Sep 2013 12:37:22 +0000 (14:37 +0200)] 
lib: add crc64()

Based on bcache code from Rolf Fokkens.

Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agowipefs: Also wipe superblocks with bad checksums
Gabriel de Perthuis [Fri, 6 Sep 2013 17:18:15 +0000 (19:18 +0200)] 
wipefs: Also wipe superblocks with bad checksums

[kzak@redhat.com: - move BLKID_SUBLKS_BADCSUM login to
                    blkid_probe_verify_csum()]

Signed-off-by: Gabriel de Perthuis <g2p.code@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agolibblkid: use separate function to verify checksums
Karel Zak [Wed, 11 Sep 2013 11:19:44 +0000 (13:19 +0200)] 
libblkid: use separate function to verify checksums

 * consolidate "incorrect checksum" debug messages
 * verify all on one place

Based on patch from Gabriel de Perthuis <g2p.code@gmail.com>

Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agotests: use stable MBR ID
Karel Zak [Wed, 11 Sep 2013 14:21:16 +0000 (16:21 +0200)] 
tests: use stable MBR ID

Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agotests: refresh jbd blkid test
Karel Zak [Wed, 11 Sep 2013 13:47:02 +0000 (15:47 +0200)] 
tests: refresh jbd blkid test

Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agotests: add XFS log image
Karel Zak [Wed, 11 Sep 2013 13:45:52 +0000 (15:45 +0200)] 
tests: add XFS log image

Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agolibblkid: don't use UUID= for xfs external log
Karel Zak [Wed, 11 Sep 2013 13:37:05 +0000 (15:37 +0200)] 
libblkid: don't use UUID= for xfs external log

The log UUID is usually the same as filesystem UUID, it is bad idea to
have two devices with the same UUID in the system. It seems batter to
use only LOGUUID= for xfs external log.

 # mkfs.xfs -l logdev=/dev/sdb1 /dev/sdb2

 # blkid -p -o udev /dev/sdb1 | grep FS
 ID_FS_LOGUUID=4063d453-5c01-46ce-b92f-9523d64aecc7
 ID_FS_TYPE=xfs_external_log
 ID_FS_USAGE=other

 # blkid -p -o udev /dev/sdb2 | grep FS
 ID_FS_UUID=4063d453-5c01-46ce-b92f-9523d64aecc7
 ID_FS_TYPE=xfs
 ID_FS_USAGE=filesystem

The filesystem (sdb2) uses UUID= and log (sdb1) uses LOGUUID=.

Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agolibblkid: don't interpret regual XFS as external xfs log
Karel Zak [Wed, 11 Sep 2013 13:33:26 +0000 (15:33 +0200)] 
libblkid: don't interpret regual XFS as external xfs log

 $ blkid -o udev -p tests/output/blkid/images-fs/xfs.img
 ID_FS_AMBIVALENT=filesystem:xfs other:xfs_external_log

it seems that regular XFS with internal log may be interpreted as log
device. This is incorrect.

This patch checks for XFS magic string to avoid this collision.

Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agolibblkid: diffs between errors and failed probing in via raid
Karel Zak [Wed, 11 Sep 2013 10:54:19 +0000 (12:54 +0200)] 
libblkid: diffs between errors and failed probing in via raid

Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agolibblkid: diffs between errors and failed probing in silicon raid
Karel Zak [Wed, 11 Sep 2013 10:54:19 +0000 (12:54 +0200)] 
libblkid: diffs between errors and failed probing in silicon raid

Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agolibblkid: populate jbd LOGUUID in addition to UUID
Karel Zak [Wed, 11 Sep 2013 09:15:33 +0000 (11:15 +0200)] 
libblkid: populate jbd LOGUUID in addition to UUID

The LOGUUID is alias for UUID, this alias is necessary to standardize
the tag name (we want to use the same tag LOGUUID= for all external
logs on all filesystems).

Note that for another filesystems (e.g. xfs) we have to differentiate
between the journal and filesystem uuids to avoid collisions, because
both devices use the same uuid.

Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agolibblkid: rename UUID_LOG to LOGUUID
Karel Zak [Wed, 11 Sep 2013 08:40:13 +0000 (10:40 +0200)] 
libblkid: rename UUID_LOG to LOGUUID

 * the goal is to make the uuid visible and usable it as mount
   variable/spec, then LOGUUID= seems better than UUID_LOG=

 * we already have PARTUUID=

 * the UUID_RAW and UUID_SUB are not used by mount(8)

Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agolibblkid: Detect external XFS log device
Eric Sandeen [Mon, 5 Aug 2013 23:09:35 +0000 (18:09 -0500)] 
libblkid: Detect external XFS log device

Detects external XFS log devices with a minimum size of 10MB.  It's possible to
craft a smaller log, but that would be very unlikely; it'd require a small XFS
filesystem and an intentionally small log, which would defeat the performance
goal of an external log in the first place.

[kzak@redhat.com: - use UUID_LOG variable name for the log uuid]

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agolib: rename time-util.c to timeutils.c, fix headers
Karel Zak [Tue, 10 Sep 2013 11:11:02 +0000 (13:11 +0200)] 
lib: rename time-util.c to timeutils.c, fix headers

Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agohexdump: revert global exitval variable change
Sami Kerola [Sun, 8 Sep 2013 16:09:09 +0000 (17:09 +0100)] 
hexdump: revert global exitval variable change

The change f2a037fb7b153954d5d34cca48182b6d8832fcfa had unfavorable
effect of making hexdump to return non-zero exit value always.

This happen because oversight when 'exitval' gets to be set.  By clance,
one might expect main() to call next() which will return value for
'exitval'.  That assessment misses later call chain main() -> display()
-> get() -> next(), which in reverse should return correct value for
'exitval'.

It was mentioned in util-linux maillist that Ondrej Oprala is working on
major renewal of the hexdump .  That in mind it seems best to simply to
revert the global 'exitval' and avoid conflict with Ondrej's work.

Reference: http://markmail.org/message/sbnvuhkboreujj5p
Reported-by: Dave Reisner <d@falconindy.com>
CC: Ondrej Oprala <ooprala@redhat.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
11 years agotools: generate autotools files if missing
Sami Kerola [Sun, 8 Sep 2013 16:09:07 +0000 (17:09 +0100)] 
tools: generate autotools files if missing

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
11 years agolast: fix memory leak
Sami Kerola [Sun, 8 Sep 2013 16:09:06 +0000 (17:09 +0100)] 
last: fix memory leak

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
11 years agolib/strutils: optimalize {starts,ends}with()
Karel Zak [Tue, 10 Sep 2013 10:18:20 +0000 (12:18 +0200)] 
lib/strutils: optimalize {starts,ends}with()

Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agosu: fix lastlog and btmp logging
Karel Zak [Mon, 9 Sep 2013 10:24:01 +0000 (12:24 +0200)] 
su: fix lastlog and btmp logging

The su(1) logging code mix ups "old" and "new" passwd structs. The
result is things like

Sep  9 11:50:45 x2 su: (to kzak) kzak on none

in /var/log/messages. The right log entry is

Sep  9 11:50:45 x2 su: (to root) kzak on pts/3

The bug has been introduced by commit c74a7af17c7a176c358dfaa8e1814786c89ebc14.

References: https://bugzilla.redhat.com/show_bug.cgi?id=1005194
Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agoagetty: cleanup debug ifdefs
Karel Zak [Mon, 9 Sep 2013 07:06:50 +0000 (09:06 +0200)] 
agetty: cleanup debug ifdefs

Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agolast: --fulltime and --time-format are mutually exclusive
Karel Zak [Mon, 2 Sep 2013 09:42:44 +0000 (11:42 +0200)] 
last: --fulltime and --time-format are mutually exclusive

Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agolast: consolidate time formatting to one struct
Karel Zak [Mon, 2 Sep 2013 09:28:43 +0000 (11:28 +0200)] 
last: consolidate time formatting to one struct

Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agolast: use bit array
Karel Zak [Mon, 2 Sep 2013 09:11:38 +0000 (11:11 +0200)] 
last: use bit array

Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agotests: check last(1) and utmpdump(1) IPv6 functionality
Sami Kerola [Thu, 29 Aug 2013 09:56:47 +0000 (10:56 +0100)] 
tests: check last(1) and utmpdump(1) IPv6 functionality

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
11 years agoutmpdump: make IPv6 addresses work
Sami Kerola [Thu, 29 Aug 2013 09:34:00 +0000 (10:34 +0100)] 
utmpdump: make IPv6 addresses work

(unless bug[s]) This change is backwards compatibile.  Earlier binary to
text dumps can be converted back to binary, or otherway around.

The only thing that will not work are IPv6 addresses that possible
earlier conversion had broke.  Such conversions resulted with random IPv4
in place of IPv6 address in text format, and original information is gone
forever.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
11 years agolast, utmpdump, agetty, wall, write: avoid compatibility hacks
Sami Kerola [Thu, 29 Aug 2013 06:46:46 +0000 (07:46 +0100)] 
last, utmpdump, agetty, wall, write: avoid compatibility hacks

In include/bits/utmp.h the ut_user and ut_time macros are marked with
comment they are backwards compatibility hacks.  It is probably best to
avoid use of these macros where ever possible.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
11 years agolast: tell verbally system is still running
Sami Kerola [Wed, 28 Aug 2013 17:53:22 +0000 (18:53 +0100)] 
last: tell verbally system is still running

Use of uptime time stamp as previous boot login time makes the output not
constant, which is rather difficult to test.  Verbal message 'system is
still running' makes testing easy, and noticing which boot is still
running clear to a person.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
11 years agolast: trim trailing white spaces
Sami Kerola [Wed, 28 Aug 2013 17:31:48 +0000 (18:31 +0100)] 
last: trim trailing white spaces

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
11 years agotests: add last(1) test
Sami Kerola [Wed, 28 Aug 2013 17:00:35 +0000 (18:00 +0100)] 
tests: add last(1) test

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
11 years agolast: never restrict session time
Sami Kerola [Wed, 28 Aug 2013 14:37:46 +0000 (15:37 +0100)] 
last: never restrict session time

When a session time will reach whopping 10000 days the last round bracket
is unnecessarily removed from output.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
11 years agodocs: add --time-format to last(1) manual page
Sami Kerola [Tue, 27 Aug 2013 17:15:00 +0000 (18:15 +0100)] 
docs: add --time-format to last(1) manual page

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
11 years agolast: add --time-format with iso-8601 format
Sami Kerola [Tue, 27 Aug 2013 12:48:27 +0000 (13:48 +0100)] 
last: add --time-format with iso-8601 format

The ISO-8601 format makes consuming time stamps easy with various
parsers.  The format includes time zone information which is crucial when
an investigator is trying to make sense outputs collected from systems
all a across planet.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
11 years agolast: use configuration struct
Sami Kerola [Tue, 27 Aug 2013 12:15:08 +0000 (13:15 +0100)] 
last: use configuration struct

This allows reducing global variables and will minimize number of
arguments for functions making code a little bit easier to read, and
maintain.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
11 years agolast: fix --present option logic error
Sami Kerola [Tue, 27 Aug 2013 10:48:54 +0000 (11:48 +0100)] 
last: fix --present option logic error

Printing of sessions 'still logged in' was skipped because an error in
logic.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
11 years agodocs: add --since and time option formats to last(1) manual
Sami Kerola [Mon, 26 Aug 2013 21:14:19 +0000 (22:14 +0100)] 
docs: add --since and time option formats to last(1) manual

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
11 years agolast: add --since time spec option
Sami Kerola [Mon, 26 Aug 2013 20:52:54 +0000 (21:52 +0100)] 
last: add --since time spec option

The --since and --until options are companions often needed together.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
11 years agolib/time-util: move YYYYMMDDHHMMSS to common parser
Sami Kerola [Thu, 29 Aug 2013 15:11:41 +0000 (16:11 +0100)] 
lib/time-util: move YYYYMMDDHHMMSS to common parser

Even while the YYYYMMDDHHMMSS time format it not magnificent it is best
to make it to be part of the one, and only, time format parser.

Proposed-by: Karel Zak <kzak@redhat.com>
References: http://markmail.org/message/6baqt4ttkopu7ra6
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
11 years agolast: parse easy to use time formats
Sami Kerola [Mon, 26 Aug 2013 20:43:05 +0000 (21:43 +0100)] 
last: parse easy to use time formats

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
11 years agolib/strutils: move *swith() functions to private library
Sami Kerola [Thu, 29 Aug 2013 14:50:17 +0000 (15:50 +0100)] 
lib/strutils: move *swith() functions to private library

Avoid code dublication in libmount and time-util.

Proposed-by: Karel Zak <kzak@redhat.com>
Reference: http://markmail.org/message/h7zexvqsieqngtmx
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
11 years agolib/time-util: copy time parsing functions from systemd
Sami Kerola [Mon, 26 Aug 2013 15:53:57 +0000 (16:53 +0100)] 
lib/time-util: copy time parsing functions from systemd

The functions are copied nearly as-is.  Coding style has been modified to
match with util-linux project, while the functionality remains untouched.

CC: Lennart Poettering <lennart@poettering.net>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
11 years agowrite: change determination can user write to a terminal
Sami Kerola [Sun, 18 Aug 2013 09:44:13 +0000 (10:44 +0100)] 
write: change determination can user write to a terminal

Earlier test failed when user had write permission, but was not in
special group that owns terminal devices, usually tty.

This made write(1) to fail for root, if the root did not happen to be in
tty group.  In this commit root is granted ot write to anyone, even if
they have mesg(1) turned off.  For an user who is trying to write to own
other session the group write bit is significant only for whether mesg(1)
are enabled.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
11 years agodocs: add note to wall(1) about sessions which will not get message
Sami Kerola [Sun, 18 Aug 2013 08:51:46 +0000 (09:51 +0100)] 
docs: add note to wall(1) about sessions which will not get message

Sessions that has in utmp data ut_line begining with ':' are skipped.
This is done to avoid write errors to devices such as '/dev/:0'.  For
example wdm is reported to to generate such utmp line.

Perhaps in future this code should be revalidated.  If an utmp data
contains broken device lines it might be best inform user with a error
message, rather than skipping silently suspicious device entries.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
11 years agodocs: add --present to last(1) manual page
Sami Kerola [Sun, 18 Aug 2013 08:33:40 +0000 (09:33 +0100)] 
docs: add --present to last(1) manual page

I forgot to update manual after writing this functionality.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
11 years agowall: line wrap at column 79 also when line has tab chars
Sami Kerola [Sun, 18 Aug 2013 00:17:34 +0000 (01:17 +0100)] 
wall: line wrap at column 79 also when line has tab chars

Earlier tabs caused random ragged right indentation, because the tab
length was assumed to be 1 char which is not the case most of the time.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
11 years agomesg: sync usage() with howto-usage-function.txt
Sami Kerola [Sat, 17 Aug 2013 23:50:08 +0000 (00:50 +0100)] 
mesg: sync usage() with howto-usage-function.txt

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
11 years agowall: sync usage() with howto-usage-function.txt
Sami Kerola [Sat, 17 Aug 2013 23:46:02 +0000 (00:46 +0100)] 
wall: sync usage() with howto-usage-function.txt

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
11 years agolast: fix typo
Sami Kerola [Sat, 17 Aug 2013 23:40:52 +0000 (00:40 +0100)] 
last: fix typo

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
11 years agowall: send message also to sessions opened by user 'sleeper'
Sami Kerola [Sat, 17 Aug 2013 23:36:57 +0000 (00:36 +0100)] 
wall: send message also to sessions opened by user 'sleeper'

Ignoring an user by name, and not telling about it in manual page, is
unexpected.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
11 years agobuild-sys: pylibmount will not work when python3 is present
Sami Kerola [Mon, 26 Aug 2013 12:11:44 +0000 (13:11 +0100)] 
build-sys: pylibmount will not work when python3 is present

While compiling with up to date Archlinux I notice the recently added
pylibmount does not link correctly.  Failures inform fundamental types
such as PyFileObject and PyFile_Type being missing.

It seems automake AM_PATH_PYTHON will prefer the python in path, which
for this distribution right now is python3.  As some sort of go-around
one can install older python, and symlink it to earlier in PATH lookup.

$ ln -s /usr/bin/python2 $HOME/bin/python
$ export PATH=$HOME/bin:$PATH

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
11 years agosu: suppress PAM info messages for -c or non-login sessions
Karel Zak [Tue, 27 Aug 2013 09:23:54 +0000 (11:23 +0200)] 
su: suppress PAM info messages for -c or non-login sessions

The 'Last login:' messages from PAM lastlogin module is unexpected
for non-login sessions or when -c <command> executed.

For example:

  $ su - -c id
  Last login: Wed Jul 24 08:36:28 CEST 2013 from dhcp-25-161.brq.redhat.com on pts/18
  uid=0(root) gid=0(root) skupiny=0(root)

this makes 'su' useless in scripts.

This patch suppress all PAM_TEXT_INFO messages for -c and for
non-login session ('-' is not specified) after pam_authenticate() and
pam_acct_mgmt().

Note that the new PAM conversation function checks the first message
in the msg[] array only. It seems good enough as PAM internally uses
pam_info() function that does not use multiple messages for one conv
call.

References: https://bugzilla.redhat.com/show_bug.cgi?id=987787
Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agobuild-sys: add CFLAGS and LDFLAGS for daemons and shared libs
Karel Zak [Tue, 27 Aug 2013 08:02:04 +0000 (10:02 +0200)] 
build-sys: add CFLAGS and LDFLAGS for daemons and shared libs

This is necessary for paranoid security guys who believe that things
like "-Wl,-z,relro" or "-Wl,-z,bind_now" is a way how to make the
world a safer place...

Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agotests: minor changes to make tests more portable
Karel Zak [Mon, 26 Aug 2013 11:48:40 +0000 (13:48 +0200)] 
tests: minor changes to make tests more portable

Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agoswapon: cleanup man page
Karel Zak [Fri, 23 Aug 2013 11:02:18 +0000 (13:02 +0200)] 
swapon: cleanup man page

Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agoswapon: allow a more flexible swap discard policy
Rafael Aquini [Sun, 26 May 2013 04:31:56 +0000 (01:31 -0300)] 
swapon: allow a more flexible swap discard policy

Introduce the necessary changes to swapon(8) allowing a sysadmin to leverage
the new changes introduced to sys_swapon by "swap: discard while swapping
only if SWAP_FLAG_DISCARD_PAGES", therefore allowing a more flexible set of
choices when selection the discard policy for mounted swap areas.
This patch introduces the following optional arguments to the already
existent swapon(8) "--discard" option, in order to allow a discard type to
be selected at swapon time:
 * once    : only single-time area discards are issued. (swapon)
 * pages   : discard freed pages before they are reused.
If no policy is selected both discard types are enabled. (default)

[kzak@redhat.com: - support <policy> argument for short -d option too,
                  - add errx() on unsupported policy name]

Signed-off-by: Rafael Aquini <aquini@redhat.com>
Acked-by: KOSAKI Motohiro <kosaki.motohiro@jp.fujitsu.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agolast: mention optional arguments in usage
Karel Zak [Fri, 23 Aug 2013 10:01:01 +0000 (12:01 +0200)] 
last: mention optional arguments in usage

Reported-by: Bernhard Voelker <mail@bernhard-voelker.de>
Signed-off-by: Karel Zak <kzak@redhat.com>
11 years agolast: add --present option
Sami Kerola [Sat, 17 Aug 2013 18:15:21 +0000 (19:15 +0100)] 
last: add --present option

The --present option will allow user to easily determine who where logged
in at a given time.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
11 years agolast: allow --file to be defined multiple times
Sami Kerola [Sat, 17 Aug 2013 18:15:20 +0000 (19:15 +0100)] 
last: allow --file to be defined multiple times

This is useful when an admin is trying to find something, and has to
process all available data.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
11 years agolast: global variables are initialize automatically to zero
Sami Kerola [Sat, 17 Aug 2013 18:15:19 +0000 (19:15 +0100)] 
last: global variables are initialize automatically to zero

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
11 years agolast: use as narrow variable scoping as possible
Sami Kerola [Sat, 17 Aug 2013 18:15:17 +0000 (19:15 +0100)] 
last: use as narrow variable scoping as possible

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
11 years agolast: remove broken code
Sami Kerola [Sat, 17 Aug 2013 18:15:16 +0000 (19:15 +0100)] 
last: remove broken code

Comment in the deletion tells everything necessary.

"This doesn't work on modern systems, where only a DNS lookup of the
result from hostname() will get you the domainname.  Remember that
domainname() is the NIS domainname, not DNS.  So basically this whole
piece of code is bullshit."

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
11 years agolast: prefer enum rather than #definition list
Sami Kerola [Sat, 17 Aug 2013 18:15:15 +0000 (19:15 +0100)] 
last: prefer enum rather than #definition list

Incremental number lists are more hard to get wrong with enum, and they
are nicer to debug as for example gdb is aware of these symbolic names.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
11 years agolast: make switch cases complete, and inform if impossible occurs
Sami Kerola [Sat, 17 Aug 2013 18:15:14 +0000 (19:15 +0100)] 
last: make switch cases complete, and inform if impossible occurs

Some of the ut_type numbers does not seem to be recognized by last(1) so
they are, at least for now, silently ignored.  See glibc documentation
for information what the ignored EMPTY, INIT_PROCESS, LOGIN_PROCESS, and
ACCOUNTING mean.

Reference: FIXME
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
11 years agolast: check expected numeric user input is number
Sami Kerola [Sat, 17 Aug 2013 18:15:13 +0000 (19:15 +0100)] 
last: check expected numeric user input is number

This commit also changes the line count to use unsigned integers, as
negative numbers in this context does not make sense.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
11 years agolast: use carefulput() for printable character output
Sami Kerola [Sat, 17 Aug 2013 18:15:12 +0000 (19:15 +0100)] 
last: use carefulput() for printable character output

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
11 years agoinclude: carefulput: print determined char when unprintable char is found
Sami Kerola [Sat, 17 Aug 2013 18:15:11 +0000 (19:15 +0100)] 
include: carefulput: print determined char when unprintable char is found

This is done to allow reuse of the functin in last(1).

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
11 years agodocs: add long options to last.1 manual page
Sami Kerola [Sat, 17 Aug 2013 18:15:10 +0000 (19:15 +0100)] 
docs: add long options to last.1 manual page

And align the manual page with Documentation/howto-man-page.txt

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
11 years agodocs: be clear which last(1) is deprecated
Sami Kerola [Sat, 17 Aug 2013 18:15:09 +0000 (19:15 +0100)] 
docs: be clear which last(1) is deprecated

The recently merged sysvinit last(1) and lastb(1) are supported.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
11 years agobuild-sys: complete elvtune removal
Sami Kerola [Sat, 17 Aug 2013 18:15:08 +0000 (19:15 +0100)] 
build-sys: complete elvtune removal

The first removal managed to remove only most of the elvtune, this commit
will complete the task.

Original-removal: 7f1fe74248290c50f5447c2c09fcf0f0575a7666
Signed-off-by: Sami Kerola <kerolasa@iki.fi>