]> git.ipfire.org Git - thirdparty/util-linux.git/log
thirdparty/util-linux.git
9 years agochfn: clean up parse_argv()
Sami Kerola [Sun, 14 Dec 2014 13:56:32 +0000 (13:56 +0000)] 
chfn: clean up parse_argv()

Use switch() case ?: for all option parsing, as in most of the other
source files.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
9 years agochfn: add minimalistic struct chfn_control
Sami Kerola [Sun, 14 Dec 2014 13:48:17 +0000 (13:48 +0000)] 
chfn: add minimalistic struct chfn_control

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
9 years agochfn: simplify parse_passwd() by using strsep()
Sami Kerola [Sun, 14 Dec 2014 13:28:57 +0000 (13:28 +0000)] 
chfn: simplify parse_passwd() by using strsep()

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
9 years agochfn: fix usage() regression
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.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
9 years agochfn: use xasprintf() rather than bunch of strlen() and malloc() calls
Sami Kerola [Sun, 14 Dec 2014 12:28:26 +0000 (12:28 +0000)] 
chfn: use xasprintf() rather than bunch of strlen() and malloc() calls

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
9 years agochfn: rewrite prompt() to use strutils
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.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
9 years agochfn: remove function prototypes
Sami Kerola [Sat, 13 Dec 2014 22:16:21 +0000 (22:16 +0000)] 
chfn: remove function prototypes

Requires resuffling functions order they work without issues.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
9 years agolslogins: use hardcoded paths from pathnames.h
Sami Kerola [Sat, 13 Dec 2014 18:07:44 +0000 (18:07 +0000)] 
lslogins: use hardcoded paths from pathnames.h

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
9 years agolslogins: add space to systemd journal header and message
Sami Kerola [Sat, 13 Dec 2014 17:49:20 +0000 (17:49 +0000)] 
lslogins: add space to systemd journal header and message

This commit changes journal messages in individual user printout the
following way.

Dec 13 16:02:05 systemd[324]:Time has been changed (old)
Dec 13 16:02:05 systemd[324]: Time has been changed (new)

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
9 years agolslogins: reject unknown time format arguments
Sami Kerola [Sat, 13 Dec 2014 17:11:04 +0000 (17:11 +0000)] 
lslogins: reject unknown time format arguments

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
9 years agolslogins: fix short options
Sami Kerola [Sat, 13 Dec 2014 16:58:37 +0000 (16:58 +0000)] 
lslogins: fix short options

Usage is promising -e is an option alias of --export, so make it work.
And get rid of -x that was accepted, but not in use.

Long only enum member OPT_VER was probably a development time idea, that
never got to be used.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
9 years agolslogins: tell why command failed
Sami Kerola [Sat, 13 Dec 2014 16:41:06 +0000 (16:41 +0000)] 
lslogins: tell why command failed

Printing usage() without hint what is wrong does not help an user.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
9 years agolslogins: make journald last logs time stamps to honor --time-format
Sami Kerola [Fri, 12 Dec 2014 23:07:28 +0000 (23:07 +0000)] 
lslogins: make journald last logs time stamps to honor --time-format

This makes by default the last logs to have year in output when necessary.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
9 years agolslogins: allow changing password changed and expiration time formats
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

$ lslogins --time-format=iso --user --output=pwd-change,user | sort -n

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
9 years agosfdisk: in the usage text show -v for --version instead of -V
Benno Schulenberg [Sun, 14 Dec 2014 19:45:33 +0000 (20:45 +0100)] 
sfdisk: in the usage text show -v for --version instead of -V

In sfdisk -V is taken by --verify.  Use for the description of --version
the same indentation as for --help, not that of the other options.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
9 years agodocs: fix the grammar and formatting in the man page of sfdisk
Benno Schulenberg [Sun, 14 Dec 2014 19:45:32 +0000 (20:45 +0100)] 
docs: fix the grammar and formatting in the man page of sfdisk

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
9 years agodocs: adjust some formatting and wordings in a handful of man pages
Benno Schulenberg [Sun, 14 Dec 2014 19:45:31 +0000 (20:45 +0100)] 
docs: adjust some formatting and wordings in a handful of man pages

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
9 years agodocs: adjust the grammar, text, sorting and formatting of logger man page
Benno Schulenberg [Sun, 14 Dec 2014 19:45:30 +0000 (20:45 +0100)] 
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).

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
9 years agodocs: don't use bold or italics for "[option]" in synopsis of man pages
Benno Schulenberg [Sun, 14 Dec 2014 19:45:29 +0000 (20:45 +0100)] 
docs: don't use bold or italics for "[option]" in synopsis of man pages

As per the convention shown in Documentation/howto-man-page.txt.
Also make a few other tiny adjustments along the way.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
9 years agodocs: improve the sorting of the options in the man page of getopt
Benno Schulenberg [Sun, 14 Dec 2014 19:45:28 +0000 (20:45 +0100)] 
docs: improve the sorting of the options in the man page of getopt

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
9 years agotextual: do not start option descriptions with a capital
Benno Schulenberg [Sun, 14 Dec 2014 19:45:27 +0000 (20:45 +0100)] 
textual: do not start option descriptions with a capital

This normalizes the help text of getopt, clarifies one description,
and also adjust two comments.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
9 years agodocs: fix the grammar of the recent comment about comments
Benno Schulenberg [Sun, 14 Dec 2014 19:45:26 +0000 (20:45 +0100)] 
docs: fix the grammar of the recent comment about comments

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
9 years agologin: Fix unused variables in login.c if _HAVE_UT_TV isn't defined
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>
9 years agolibmount: allow unspecified source on remount
Karel Zak [Thu, 18 Dec 2014 09:30:14 +0000 (10:30 +0100)] 
libmount: allow unspecified source on remount

kernel does not require mount source (e.g. device name) on remount, it
means that fstab/mtab/mountinfo should be optional in this case.
For example:

 mount -o rw,remount /

has to work on system without mounted /proc.

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agologin-utils: Enable building util-linux against OpenPAM
Will Johansson [Wed, 10 Dec 2014 02:40:31 +0000 (18:40 -0800)] 
login-utils: Enable building util-linux against OpenPAM

OpenPAM is compatible with util-linux, with a few changes, namely
using OpenPAM's conversation function, openpam_ttyconv.

We check for Linux-PAM by querying for security/pam_misc.h, and OpenPAM
by querying for security/openpam.h.

Signed-off-by: Will Johansson <will.johansson@gmail.com>
9 years agolslogins: fix -l -g logic
Karel Zak [Fri, 12 Dec 2014 14:17:19 +0000 (15:17 +0100)] 
lslogins: fix -l -g logic

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agoterminal-colors.d: add note about comments to man page
Karel Zak [Fri, 12 Dec 2014 13:02:21 +0000 (14:02 +0100)] 
terminal-colors.d: add note about comments to man page

Reported-by: Jan Pokorný <jpokorny@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agogetopt: cleanup add_log_options()
Karel Zak [Tue, 9 Dec 2014 11:21:33 +0000 (12:21 +0100)] 
getopt: cleanup add_log_options()

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agogetopt: rename function to keep code readable
Karel Zak [Tue, 9 Dec 2014 11:17:57 +0000 (12:17 +0100)] 
getopt: rename function to keep code readable

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agogetopt: fix compiler warning
Karel Zak [Tue, 9 Dec 2014 11:17:22 +0000 (12:17 +0100)] 
getopt: fix compiler warning

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agoMerge branch '2014wk48' of git://github.com/kerolasa/lelux-utiliteetit
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

9 years agolslogins: align usage() and manual with struct option longopts
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.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
9 years agolslogins: fix assertion failure for none existing logins
Sami Kerola [Mon, 8 Dec 2014 22:20:55 +0000 (22:20 +0000)] 
lslogins: fix assertion failure for none existing logins

This cange makes the following to retun none-zero value instead of a core
dump.

$ lslogins qwertyuiopasdfghjklzxcvbnm1234567
lslogins: libsmartcols/src/line.c:362: scols_line_get_cell: Assertion `ln' failed.
Aborted (core dumped)

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
9 years agobuild-sys: hwclock requires -lm
Cristian Rodríguez [Mon, 8 Dec 2014 20:30:10 +0000 (17:30 -0300)] 
build-sys: hwclock requires -lm

hwclock uses fabs and therefore needs libm, otherwise a linking
error ocurrs when building with -fno-builtin.

9 years agoline: use util-linux conventions
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.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
9 years agotextual: improve error messages
Sami Kerola [Sun, 7 Dec 2014 10:13:03 +0000 (10:13 +0000)] 
textual: improve error messages

Use error printing facilities that add command name in front of the error
message, and add explanation that is part of existing translations.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
9 years agologin-utils: use libc error printing facility
Sami Kerola [Sun, 7 Dec 2014 10:13:02 +0000 (10:13 +0000)] 
login-utils: use libc error printing facility

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
9 years agogetopt: avoid re-terminating long_option list at every update
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>
9 years agogetopt: change --shell argument parsing function
Sami Kerola [Sun, 7 Dec 2014 00:40:11 +0000 (00:40 +0000)] 
getopt: change --shell argument parsing function

Avoid passing getopt_control stucture in when returning a value is enough.

CC: Frodo Looijaard <frodo@frodo.looijaard.name>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
9 years agogetopt: prefer switch-case rather than long if statement
Sami Kerola [Sun, 7 Dec 2014 00:16:56 +0000 (00:16 +0000)] 
getopt: prefer switch-case rather than long if statement

And avoid testing same thing time after time.

CC: Frodo Looijaard <frodo@frodo.looijaard.name>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
9 years agogetopt: remove unnecessary code
Sami Kerola [Sat, 6 Dec 2014 18:21:56 +0000 (18:21 +0000)] 
getopt: remove unnecessary code

The control structure is initialized in main().

CC: Frodo Looijaard <frodo@frodo.looijaard.name>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
9 years agogetopt: make normalize() print strings
Sami Kerola [Sat, 6 Dec 2014 17:58:16 +0000 (17:58 +0000)] 
getopt: make normalize() print strings

A change towards less indirection, and a change to free allocated memory.

CC: Frodo Looijaard <frodo@frodo.looijaard.name>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
9 years agogetopt: use xstrdup rather than malloc + strcpy
Sami Kerola [Sat, 6 Dec 2014 11:50:03 +0000 (11:50 +0000)] 
getopt: use xstrdup rather than malloc + strcpy

CC: Frodo Looijaard <frodo@frodo.looijaard.name>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
9 years agogetopt: add struct getopt_control and remove global variables
Sami Kerola [Sat, 6 Dec 2014 11:32:46 +0000 (11:32 +0000)] 
getopt: add struct getopt_control and remove global variables

CC: Frodo Looijaard <frodo@frodo.looijaard.name>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
9 years agogetopt: remove function prototypes
Sami Kerola [Sat, 6 Dec 2014 16:48:57 +0000 (16:48 +0000)] 
getopt: remove function prototypes

Functions are in right order so they do not need prototypes, with effect
of not needing to keep function argument changes in sync in two locations.

CC: Frodo Looijaard <frodo@frodo.looijaard.name>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
9 years agogetopt: make nonoptions optstring comment correct
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>
9 years agotests: add more getopt tests
Sami Kerola [Fri, 5 Dec 2014 22:49:48 +0000 (22:49 +0000)] 
tests: add more getopt tests

After importing Frodo's tests I ran coverage to see if something had
remained unchecked, and there were couple tests that could be done.

CC: Frodo Looijaard <frodo@frodo.looijaard.name>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
9 years agotests: copy test-suite from Frodo Looijaard's getopt
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>
9 years agogetopt: sync with 1.1.6 release
Sami Kerola [Thu, 4 Dec 2014 22:04:08 +0000 (22:04 +0000)] 
getopt: sync with 1.1.6 release

Reference: http://www.spinics.net/lists/util-linux-ng/msg10556.html
CC: Frodo Looijaard <frodo@frodo.looijaard.name>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
9 years agoline: use util-linux conventions
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.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
9 years agotextual: improve error messages
Sami Kerola [Thu, 4 Dec 2014 21:10:44 +0000 (21:10 +0000)] 
textual: improve error messages

Use error printing facilities that add command name in front of the error
message, and add explanation that is part of existing translations.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
9 years agologin-utils: use libc error printing facility
Sami Kerola [Sun, 30 Nov 2014 18:10:57 +0000 (18:10 +0000)] 
login-utils: use libc error printing facility

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
9 years agolibmount: add new libmnt_monitor API
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.

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agolibblkid: fix potential bufer overflows
Sebastian Krahmer [Fri, 5 Dec 2014 09:06:42 +0000 (10:06 +0100)] 
libblkid: fix potential bufer overflows

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).

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agolibfdisk: fix bug in cmp_numbers() and partitions sorting
Karel Zak [Thu, 4 Dec 2014 12:06:03 +0000 (13:06 +0100)] 
libfdisk: fix bug in cmp_numbers() and partitions sorting

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1170191
Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agolibfdisk: remove 'end' from struct fdisk_partition
Karel Zak [Thu, 4 Dec 2014 11:24:31 +0000 (12:24 +0100)] 
libfdisk: remove 'end' from struct fdisk_partition

This struct member duplicate "start+size".

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agolibfdisk: rename sector_t to fdisk_sector_t
Karel Zak [Thu, 4 Dec 2014 10:41:51 +0000 (11:41 +0100)] 
libfdisk: rename sector_t to fdisk_sector_t

.. just to avoid too generic names for public API.

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agolibfdisk: fix cfdisk freespace analyze
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>
9 years agolsblk: add SUBSYSTEMS column
Karel Zak [Tue, 2 Dec 2014 10:38:15 +0000 (11:38 +0100)] 
lsblk: add SUBSYSTEMS column

 $ lsblk -oNAME,SIZE,TYPE,SUBSYSTEMS /dev/sr0
 NAME  SIZE TYPE SUBSYSTEMS
 sr0   7.8M rom  block:scsi:usb:pci

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agodocs: update TODO file
Karel Zak [Tue, 2 Dec 2014 10:09:31 +0000 (11:09 +0100)] 
docs: update TODO file

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agolsblk: add HOTPLUG column
Karel Zak [Tue, 2 Dec 2014 10:09:04 +0000 (11:09 +0100)] 
lsblk: add HOTPLUG column

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agoeject: use sysfs API to detect hotplug
Karel Zak [Tue, 2 Dec 2014 10:00:19 +0000 (11:00 +0100)] 
eject: use sysfs API to detect hotplug

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agolib/sysfs: add subsystem and hotplug detection
Karel Zak [Tue, 2 Dec 2014 09:59:48 +0000 (10:59 +0100)] 
lib/sysfs: add subsystem and hotplug detection

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agodocs: update TODO file
Karel Zak [Fri, 28 Nov 2014 12:29:15 +0000 (13:29 +0100)] 
docs: update TODO file

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agolibblkid: care about unsafe chars in cache
Karel Zak [Thu, 27 Nov 2014 12:39:35 +0000 (13:39 +0100)] 
libblkid: care about unsafe chars in cache

The high-level libblkid API uses /run/blkid/blkid.tab cache to
store probing results. The cache format is

   <device NAME="value" ...>devname</device>

and unfortunately the cache code does not escape quotation marks:

   # mkfs.ext4 -L 'AAA"BBB'

   # cat /run/blkid/blkid.tab
   ...
   <device ... LABEL="AAA"BBB" ...>/dev/sdb1</device>

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.

   # mkfs.ext4 -L 'X"`/tmp/foo` "' /dev/sdb1
   # udevadm info --export-db | grep LABEL
   ...
   E: ID_FS_LABEL=X__/tmp/foo___
   E: ID_FS_LABEL_ENC=X\x22\x60\x2ftmp\x2ffoo\x60\x20\x22

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agoinclude/carefulputc: encode also ' and $ in fputs_quoted() output
Karel Zak [Thu, 27 Nov 2014 12:36:09 +0000 (13:36 +0100)] 
include/carefulputc: encode also ' and $ in fputs_quoted() output

This change is important for commands linked with libsmartcols (e.g. lsblk(1))
to make it more safe for crazy scenarios like

   eval $(lsblk --fs --pairs /dev/sdb1)

where the command returns NAME="value" from filesystem LABELS (etc.)

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agolibfdisk: add API docs
Karel Zak [Wed, 26 Nov 2014 18:13:57 +0000 (19:13 +0100)] 
libfdisk: add API docs

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agolibfdisk: rename and move function
Karel Zak [Wed, 26 Nov 2014 16:33:07 +0000 (17:33 +0100)] 
libfdisk: rename and move function

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agolibsmartcols: fix docs namespace
Karel Zak [Wed, 26 Nov 2014 15:53:48 +0000 (16:53 +0100)] 
libsmartcols: fix docs namespace

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agobuild-sys: add fdisk.pc
Karel Zak [Wed, 26 Nov 2014 12:20:16 +0000 (13:20 +0100)] 
build-sys: add fdisk.pc

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agobuild-sys: add fdiskP.h to sources
Karel Zak [Wed, 26 Nov 2014 11:51:15 +0000 (12:51 +0100)] 
build-sys: add fdiskP.h to sources

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agobuild-sys: create a regular shared libfdisk.so
Karel Zak [Wed, 26 Nov 2014 11:45:24 +0000 (12:45 +0100)] 
build-sys: create a regular shared libfdisk.so

- symbols versioning
- SONAME from configure.ac
- library version to header file
- modify build-sys to compile and install shared lib

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agoblkdiscard: fix compiler warning
Karel Zak [Wed, 26 Nov 2014 11:38:53 +0000 (12:38 +0100)] 
blkdiscard: fix compiler warning

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agobuild-sys: cleanup in libmount Makemodule
Karel Zak [Wed, 26 Nov 2014 11:14:18 +0000 (12:14 +0100)] 
build-sys: cleanup in libmount Makemodule

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agolibfdisk: add comments to header file
Karel Zak [Wed, 26 Nov 2014 10:55:45 +0000 (11:55 +0100)] 
libfdisk: add comments to header file

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agolibfdisk: add docs for SGI functions
Karel Zak [Wed, 26 Nov 2014 10:45:00 +0000 (11:45 +0100)] 
libfdisk: add docs for SGI functions

9 years agolibfdisk: add docs for SUN functions
Karel Zak [Wed, 26 Nov 2014 10:34:57 +0000 (11:34 +0100)] 
libfdisk: add docs for SUN functions

9 years agolibfdisk: cleanup fdisk_partition_to_string() comment
Karel Zak [Wed, 26 Nov 2014 10:26:31 +0000 (11:26 +0100)] 
libfdisk: cleanup fdisk_partition_to_string() comment

9 years agolibfdisk: fix typo
Karel Zak [Wed, 26 Nov 2014 10:23:27 +0000 (11:23 +0100)] 
libfdisk: fix typo

9 years agolibfdisk: add docs for iterator
Karel Zak [Wed, 26 Nov 2014 10:21:16 +0000 (11:21 +0100)] 
libfdisk: add docs for iterator

9 years agolibfdisk: add docs for init functions
Karel Zak [Wed, 26 Nov 2014 10:13:11 +0000 (11:13 +0100)] 
libfdisk: add docs for init functions

9 years agolibfdisk: add docs for GPT functions
Karel Zak [Wed, 26 Nov 2014 10:11:19 +0000 (11:11 +0100)] 
libfdisk: add docs for GPT functions

9 years agolibfdisk: add docs for DOS functions
Karel Zak [Wed, 26 Nov 2014 10:00:43 +0000 (11:00 +0100)] 
libfdisk: add docs for DOS functions

9 years agolibfdisk: add docs for BSD functions
Karel Zak [Wed, 26 Nov 2014 09:28:37 +0000 (10:28 +0100)] 
libfdisk: add docs for BSD functions

9 years agolibfdisk: cleanup ask API, add comments
Karel Zak [Tue, 25 Nov 2014 13:36:50 +0000 (14:36 +0100)] 
libfdisk: cleanup ask API, add comments

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agolibfdisk: remove flags from fdisk_ask API
Karel Zak [Fri, 21 Nov 2014 14:31:55 +0000 (15:31 +0100)] 
libfdisk: remove flags from fdisk_ask API

We don't use it for anything usable, lets kill this over-engineering.

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agoldattach: add fallback for N_GSM0710
Karel Zak [Fri, 21 Nov 2014 12:57:14 +0000 (13:57 +0100)] 
ldattach: add fallback for N_GSM0710

Addresses: https://github.com/karelzak/util-linux/issues/133
Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agolib/colors: use static buffers when parse scheme
Karel Zak [Fri, 21 Nov 2014 11:23:47 +0000 (12:23 +0100)] 
lib/colors: use static buffers when parse scheme

* use static buffers when parse scheme colors
* cleanup deallocation on error in sequence parser

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agoagetty: use futimens, check for all in configure.ac
Karel Zak [Fri, 21 Nov 2014 10:38:11 +0000 (11:38 +0100)] 
agetty: use futimens, check for all in configure.ac

It seems better to warn about --reload in ./configure if futimens or
inotify_init1 are missing.

The patch also replaces futimes() with futimens() to make the code
compatible with Uclibc.

Addresses: https://github.com/karelzak/util-linux/issues/133
Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agolibfdisk: add ref.counting to ask API
Karel Zak [Fri, 21 Nov 2014 10:03:08 +0000 (11:03 +0100)] 
libfdisk: add ref.counting to ask API

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agoagetty: fix typo
Karel Zak [Fri, 21 Nov 2014 08:42:23 +0000 (09:42 +0100)] 
agetty: fix typo

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agoagetty: keep the current baud before try 9600 on serial lines
Karel Zak [Fri, 21 Nov 2014 08:03:00 +0000 (09:03 +0100)] 
agetty: keep the current baud before try 9600 on serial lines

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agoagetty: don't ignore TERM
Karel Zak [Fri, 21 Nov 2014 07:43:14 +0000 (08:43 +0100)] 
agetty: don't ignore TERM

Fix command line parsing to not ignore term setting if no baud
specified, for example:

  /sbin/agetty ttyS0 vt100

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agobuild-sys: cleanup library symbol files
Karel Zak [Thu, 20 Nov 2014 13:01:03 +0000 (14:01 +0100)] 
build-sys: cleanup library symbol files

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agoibfdisk: (gpt) allow to maximize partition
Karel Zak [Thu, 20 Nov 2014 12:28:41 +0000 (13:28 +0100)] 
ibfdisk: (gpt) allow to maximize partition

enlarge second partition:

# echo ',+' | ./sfdisk -N2 /dev/sdb
...
Disk /dev/sdb: 100 MiB, 104857600 bytes, 204800 sectors

Old situation:
Device     Start   End Sectors Size Type
/dev/sdb1   2048 22527   20480  10M Linux filesystem
/dev/sdb2  22528 43007   20480  10M Linux filesystem

New situation:
Device     Start    End Sectors Size Type
/dev/sdb1   2048  22527   20480  10M Linux filesystem
/dev/sdb2  22528 204766  182239  89M Linux filesystem

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agolibfdisk: (dos) allow to maximize partition
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
      ^^^^^^

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agoaggety: always set default serial line speed
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>
9 years agolibmount: fix lock test to use real time to sync
Karel Zak [Wed, 19 Nov 2014 15:50:08 +0000 (16:50 +0100)] 
libmount: fix lock test to use real time to sync

Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agologin: ignore SIGXFSZ when write to lastlog
Karel Zak [Wed, 19 Nov 2014 14:45:42 +0000 (15:45 +0100)] 
login: ignore SIGXFSZ when write to lastlog

the lastlog file is huge and on systems with large UIDs, it's so huge that
it generates SIGXFSZ when the FSIZE limit is too small.

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1165702
Signed-off-by: Karel Zak <kzak@redhat.com>
9 years agoblkid: add hint about lsblk to the man page
Karel Zak [Wed, 19 Nov 2014 13:43:38 +0000 (14:43 +0100)] 
blkid: add hint about lsblk to the man page

Signed-off-by: Karel Zak <kzak@redhat.com>