Sami Kerola [Sun, 14 Dec 2014 12:31:11 +0000 (12:31 +0000)]
chfn: fix usage() regression
Commit db433bf737a5fd4e1c7cca5e3603934743eebd1c changed -u for --help to
-h, that is not true. The -h is short hand for --home-phone. And the
--version is accompanied with -v not -V.
Sami Kerola [Sun, 14 Dec 2014 11:37:03 +0000 (11:37 +0000)]
chfn: rewrite prompt() to use strutils
The left and right white space trimming can be done with strutils.h
[lr]trim_whitespace() functions.
As a minor fix when user input exceeds maxium allowed gecos field length
the remaining characters in stdin are purged so that re-prompting works
correctly.
Additionally the prompt() is made to add message to check_gecos_string(),
so that there are less similar strings for translation project to deal.
Sami Kerola [Fri, 12 Dec 2014 22:46:04 +0000 (22:46 +0000)]
lslogins: allow changing password changed and expiration time formats
The password change and expiry has are marked with resolution of a day,
so add a new short iso-8601 format. With this system admins can easily
find users has not updated their password lately
docs: adjust the grammar, text, sorting and formatting of logger man page
The message argument is not an option and should not be listed among
those. Describe the optional argument of --rfc5424 better. Use the
= and no space for optional option arguments. Don't italicize words
unnecessarily. Use bold for literal things. And sort the options
alphabetically (apart from -V and -h).
Will Johansson [Mon, 15 Dec 2014 11:51:29 +0000 (03:51 -0800)]
login: Fix unused variables in login.c if _HAVE_UT_TV isn't defined
Wrap around the variable declaration for `tv' with ifdef so the compilers
don't warn about unused variables if we're compiling without UT_TV. This
happens with the musl libc, since it doesn't define _HAVE_UT_TV, even
though it _does_ have the ut_tv field in the utmp struct.
Signed-off-by: Will Johansson <will.johansson@gmail.com>
Karel Zak [Tue, 9 Dec 2014 10:53:39 +0000 (11:53 +0100)]
Merge branch '2014wk48' of git://github.com/kerolasa/lelux-utiliteetit
* '2014wk48' of git://github.com/kerolasa/lelux-utiliteetit:
getopt: avoid re-terminating long_option list at every update
getopt: change --shell argument parsing function
getopt: prefer switch-case rather than long if statement
getopt: remove unnecessary code
getopt: make normalize() print strings
getopt: use xstrdup rather than malloc + strcpy
getopt: add struct getopt_control and remove global variables
getopt: remove function prototypes
getopt: make nonoptions optstring comment correct
tests: add more getopt tests
tests: copy test-suite from Frodo Looijaard's getopt
getopt: sync with 1.1.6 release
line: use util-linux conventions
textual: improve error messages
login-utils: use libc error printing facility
Sami Kerola [Mon, 8 Dec 2014 22:20:56 +0000 (22:20 +0000)]
lslogins: align usage() and manual with struct option longopts
Short option -G goes together with long option --supp-groups, while
neither of -m or --groups-info has worked in a release so remove them
from usage() and manual.
Sami Kerola [Sun, 7 Dec 2014 10:13:04 +0000 (10:13 +0000)]
line: use util-linux conventions
This change add --help and --version print outs, checking at exit the
stdout write was successful, and as a minor thing the command is made to
use wide char functions to read and write inputs.
Sami Kerola [Sun, 7 Dec 2014 09:55:08 +0000 (09:55 +0000)]
getopt: avoid re-terminating long_option list at every update
Terminating the ctl->long_options list once when adding options is
completed is enough. This also allows moving ctl->long_options_nr
increment to more appropriate location.
CC: Frodo Looijaard <frodo@frodo.looijaard.name> Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Sami Kerola [Sat, 6 Dec 2014 10:47:53 +0000 (10:47 +0000)]
getopt: make nonoptions optstring comment correct
From manual page: 'If the first character of optstring is '-', then each
nonoption argv-element is handled as if it were the argument of an option
with character code 1.'
Reference: http://man7.org/linux/man-pages/man3/getopt.3.html CC: Frodo Looijaard <frodo@frodo.looijaard.name> Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Sami Kerola [Thu, 4 Dec 2014 22:39:21 +0000 (22:39 +0000)]
tests: copy test-suite from Frodo Looijaard's getopt
The test cases and their names are the same, but the surrounding testing
facility with Frodo's svn and util-linux are pretty different so this is
not exactly 1:1 copy.
Reference: svn://svn.frodo.looijaard.name/public/getopt/trunk/tests CC: Frodo Looijaard <frodo@frodo.looijaard.name> Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Sami Kerola [Thu, 4 Dec 2014 21:49:13 +0000 (21:49 +0000)]
line: use util-linux conventions
This change add --help and --version print outs, checking at exit the
stdout write was successful, and as a minor thing the command is made to
use wide char functions to read and write inputs.
Karel Zak [Fri, 5 Dec 2014 14:30:04 +0000 (15:30 +0100)]
libmount: add new libmnt_monitor API
It's usually enough to us [e]poll() to monitor kernel mount table, but
there is no way how to monitor changes in userspace mount options
(e.g. _netdev). The management of these mount options is completely
hidden in libmount and /rub/mount/utab is private libmount file.
This patch introduces new libmnt_mount API to monitor also userspace
mount table.
While digging deeper into libblk probing, I found that some
computations might wrap and allocate too few buffer space which then
overflows. In particular on 32bit systems (chromebook) where size_t is
32bit, this is problematic (for 64bit the result fits into the calloc
size_t).
Karel Zak [Thu, 4 Dec 2014 09:27:39 +0000 (10:27 +0100)]
libfdisk: fix cfdisk freespace analyze
The problem is how fdisk_partition_cmp_start() compare numbers, the
function returns result from "a->start - b->start", unfortunately the
numbers are uint64, but function returns "int".
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1170191 Signed-off-by: Karel Zak <kzak@redhat.com>
such string is later incorrectly parsed and blkid(8) returns
nonsenses. And for use-cases like
# eval $(blkid -o export /dev/sdb1)
it's also insecure.
Note that mount, udevd and blkid -p are based on low-level libblkid
API, it bypass the cache and directly read data from the devices.
The current udevd upstream does not depend on blkid(8) output at all,
it's directly linked with the library and all unsafe chars are encoded by
\x<hex> notation.
Karel Zak [Thu, 20 Nov 2014 12:11:38 +0000 (13:11 +0100)]
libfdisk: (dos) allow to maximize partition
The struct fdisk_partition has special flag "end_follow_default" to
make the partition large as much as possible. This patch makes this
flag usable for fdisk_set_partition() function.
Command line example (enlarge the first partition):
# echo ',+' | ./sfdisk -N1 /dev/sdb
...
Disk /dev/sdb: 100 MiB, 104857600 bytes, 204800 sectors
...
Old situation:
Device Boot Start End Sectors Size Id Type
/dev/sdb1 2048 22527 20480 10M 83 Linux
^^^^^
New situation:
Device Boot Start End Sectors Size Id Type
/dev/sdb1 2048 204799 202752 99M 83 Linux
^^^^^^
Karel Zak [Thu, 20 Nov 2014 09:56:03 +0000 (10:56 +0100)]
aggety: always set default serial line speed
* makes speeds table usage more robust
* don't call next_speed() for empty speeds table to avoid division by zero
* default to 9600 when port baud unspecified
Addresses: https://github.com/karelzak/util-linux/pull/131 Signed-off-by: Karel Zak <kzak@redhat.com>