]> git.ipfire.org Git - thirdparty/util-linux.git/log
thirdparty/util-linux.git
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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

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

10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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

10 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

10 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

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

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

10 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

10 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

10 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

10 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

10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 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>
10 years agolib/colors: fix double free on error path
Andreas Henriksson [Wed, 19 Nov 2014 11:03:35 +0000 (12:03 +0100)] 
lib/colors: fix double free on error path

The error path was a bit unclear on the semantics. The seq argument
would get freed but not the name argument. Then the caller frees
them both when the function returns an error.
This fixes the problem my making the function not touch the arguments
unless we're going to return success. Also improve the description
for this function to make it more obvious what the callers should expect.

Addresses: CID#77487 (on scan.coverity.com for JIghtuse/util-linux)
Signed-off-by: Andreas Henriksson <andreas@fatal.se>
10 years agobuild-sys: move all around clock_gettime() to monotonic.c
Karel Zak [Wed, 19 Nov 2014 10:54:47 +0000 (11:54 +0100)] 
build-sys: move all around clock_gettime() to monotonic.c

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agobuild-sys: use CLOCKGETTIME_LIBS
Karel Zak [Wed, 19 Nov 2014 10:23:05 +0000 (11:23 +0100)] 
build-sys: use CLOCKGETTIME_LIBS

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolibmount: fix utab entry on remount
Karel Zak [Wed, 19 Nov 2014 10:10:55 +0000 (11:10 +0100)] 
libmount: fix utab entry on remount

mount(8) command does not set ROOT= field to utab entry on remount,
for example:

mount -oremount,_netdev /mnt

Reported-by: Chris Leech <cleech@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolibmount: add private mnt_context_get_mtab_for_target()
Karel Zak [Wed, 19 Nov 2014 10:07:40 +0000 (11:07 +0100)] 
libmount: add private mnt_context_get_mtab_for_target()

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolibmount: reuse allocated fs in parser
Karel Zak [Wed, 19 Nov 2014 10:07:11 +0000 (11:07 +0100)] 
libmount: reuse allocated fs in parser

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolibmount: improve mnt_reset_fs()
Karel Zak [Wed, 19 Nov 2014 10:06:24 +0000 (11:06 +0100)] 
libmount: improve mnt_reset_fs()

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agomisc: use monotonic time rater than gettimeofday
Karel Zak [Tue, 18 Nov 2014 13:35:21 +0000 (14:35 +0100)] 
misc: use monotonic time rater than gettimeofday

Based on patch Alexander Samilovskih <alexsamilovskih@gmail.com>

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agouuidd: Fixed a typo in daemon logging message
Nikolay Sivov [Tue, 18 Nov 2014 13:14:47 +0000 (14:14 +0100)] 
uuidd: Fixed a typo in daemon logging message

Signed-off-by: Nikolay Sivov <nsivov@codeweavers.com>
10 years agodocs: Spelling fixes
Ville Skyttä [Sat, 15 Nov 2014 20:41:43 +0000 (22:41 +0200)] 
docs: Spelling fixes

Signed-off-by: Ville Skyttä <ville.skytta@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agobash-completion: Invoke actual commands to be completed, not basenames
Ville Skyttä [Sat, 15 Nov 2014 20:36:04 +0000 (22:36 +0200)] 
bash-completion: Invoke actual commands to be completed, not basenames

Addresses partially: http://bugs.debian.org/769462
Signed-off-by: Ville Skyttä <ville.skytta@iki.fi>
10 years agoldattach: GSM0710 support, add intro modem command
Karel Zak [Tue, 18 Nov 2014 12:48:34 +0000 (13:48 +0100)] 
ldattach: GSM0710 support, add intro modem command

Patch add:
 --intro-command string  : send command to modem
 --pause value           : define delay between intro command and ldattach

Based on patch from Martin Schmid <scm@aps-systems.ch>

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agomkswap: remove memory leaks [LeakSanitizer] [valgrind]
Sami Kerola [Tue, 11 Nov 2014 21:34:30 +0000 (21:34 +0000)] 
mkswap: remove memory leaks [LeakSanitizer] [valgrind]

==18922==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 8 byte(s) in 1 object(s) allocated from:
    #0 0x49d12b in __interceptor_malloc (/home/src/util-linux/.libs/lt-mkswap+0x49d12b)
    #1 0x7faf2a5069c9 in __GI___strdup (/usr/lib/libc.so.6+0x819c9)
    #2 0xffff96e7e33 (<unknown module>)

SUMMARY: AddressSanitizer: 8 byte(s) leaked in 1 allocation(s).

And another one that valgrind found.

==6316== 8 bytes in 1 blocks are definitely lost in loss record 1 of 1
==6316==    at 0x4C29F90: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==6316==    by 0x5E3F9C9: strdup (in /usr/lib/libc-2.20.so)
==6316==    by 0x43A25F: size_to_human_string (strutils.c:495)
==6316==    by 0x42B35C: main (mkswap.c:488)

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agotests: mark python libmount tests known to fail with AddressSanitizer
Sami Kerola [Sun, 9 Nov 2014 21:54:27 +0000 (21:54 +0000)] 
tests: mark python libmount tests known to fail with AddressSanitizer

The tests fail with an error similar to this.

Traceback (most recent call last):
  File "/home/src/util-linux/libmount/python/test_mount_tab_update.py", line 7, in <module>
    import pylibmount as mnt
ImportError: /home/src/util-linux/.libs/libuuid.so.1: undefined symbol: __asan_option_detect_stack_use_after_return

It might be possible to build ASAN-DSO and set LD_PRELOAD, but this
solution is not officially supported.  See the reference for details.

Reference: https://code.google.com/p/address-sanitizer/wiki/AsanAsDso
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agotests: skip kill -SEGV test when running AddressSanitizer
Sami Kerola [Sun, 9 Nov 2014 21:22:52 +0000 (21:22 +0000)] 
tests: skip kill -SEGV test when running AddressSanitizer

Sending signal indicating invalid memory reference makes AddressSanitizer
to report false positive test failure.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agolibmount: fix memory overflow [AddressSanitizer]
Sami Kerola [Sun, 9 Nov 2014 15:26:05 +0000 (15:26 +0000)] 
libmount: fix memory overflow [AddressSanitizer]

==10918==ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7fffd795b680 at pc 0x0000004447c6 bp 0x7fffd795b3e0 sp 0x7fffd795ab78
WRITE of size 129 at 0x7fffd795b680 thread T0
    #0 0x4447c5 in scanf_common(void*, int, bool, char const*, __va_list_tag*) (/home/src/util-linux/.libs/lt-mount+0x4447c5)
    #1 0x445892 in sscanf (/home/src/util-linux/.libs/lt-mount+0x445892)
    #2 0x7fe78709a3d3 in get_filesystems /home/src/util-linux/libmount/src/utils.c:581:7
    #3 0x7fe78709a1ba in mnt_get_filesystems /home/src/util-linux/libmount/src/utils.c:622:7
    #4 0x7fe7870aa78f in do_mount_by_pattern /home/src/util-linux/libmount/src/context_mount.c:833:7
    #5 0x7fe7870a9534 in mnt_context_do_mount /home/src/util-linux/libmount/src/context_mount.c:951:9
    #6 0x7fe7870aab2b in mnt_context_mount /home/src/util-linux/libmount/src/context_mount.c:1051:8
    #7 0x4ba9f5 in main /home/src/util-linux/sys-utils/mount.c:1107:7
    #8 0x7fe785caa03f in __libc_start_main (/usr/lib/libc.so.6+0x2003f)
    #9 0x4b9f9c in _start (/home/src/util-linux/.libs/lt-mount+0x4b9f9c)

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agotests: fix memory leak [AddressSanitizer]
Sami Kerola [Sun, 2 Nov 2014 22:26:48 +0000 (22:26 +0000)] 
tests: fix memory leak [AddressSanitizer]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agobuild-sys: make scanf_cv_alloc_modifier to work [LeakSanitizer]
Sami Kerola [Sun, 2 Nov 2014 22:06:15 +0000 (22:06 +0000)] 
build-sys: make scanf_cv_alloc_modifier to work [LeakSanitizer]

The tests failed with following message in config.log

ERROR: LeakSanitizer: detected memory leaks

Direct leak of 2 byte(s) in 1 object(s) allocated from:
    #0 0x49a40e in realloc (/home/src/util-linux/conftest+0x49a40e)
    #1 0x7fbe48633e69 in __GI__IO_vfscanf (/usr/lib/libc.so.6+0x56e69)
    #2 0x7fbe48649786 in _IO_vsscanf (/usr/lib/libc.so.6+0x6c786)

which knocked out libmount from build, and commands depending on it.

The reason this change makes sense is that AddressSanitizer seems like a
good addition to set of tools that util-linux package can use, when and
if needed.

Reference: https://code.google.com/p/address-sanitizer/wiki/AddressSanitizer
Reviewed-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
10 years agolscpu: theoretical buffer overflow
Tobias Stoeckmann [Sun, 26 Oct 2014 17:41:24 +0000 (18:41 +0100)] 
lscpu: theoretical buffer overflow

there is a theoretical buffer overflow possible in the hypervisor
parsing code of lscpu.  It would require a proc entry to return way more
than expected so it's no high priority.  But better be safe than sorry.

At first I thought about switching to fgets but there is another
code file that adds a format specifier.  The diff is less intrusive
that way, too.

Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolibfdisk: fix partition names on GNU Hurd.
Gabriele Giacone [Tue, 18 Nov 2014 01:13:22 +0000 (02:13 +0100)] 
libfdisk: fix partition names on GNU Hurd.

10 years agolibfdisk: fix get_partition_unused_primary()
Boris Egorov [Fri, 14 Nov 2014 05:27:16 +0000 (11:27 +0600)] 
libfdisk: fix get_partition_unused_primary()

Was:
Mentioned function returns -1 if adding of primary partition is
impossible. Caller treats this value as size_t (res variable) and then
compares it for negative values, totally ignoring errors.

Becomes:
Now function takes address to variable and fills it with partition
number. Caller treats return value as int and use it appropriately.

[kzak@redhat.com: - don't mix return code and partno at all]

Signed-off-by: Boris Egorov <egorov@linux.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agofdisk: missing break in switch
Boris Egorov [Wed, 12 Nov 2014 15:49:01 +0000 (21:49 +0600)] 
fdisk: missing break in switch

Signed-off-by: Boris Egorov <egorov@linux.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
10 years agolibblkid: (nilfs) fix typo
Boris Egorov [Wed, 12 Nov 2014 15:49:01 +0000 (21:49 +0600)] 
libblkid: (nilfs) fix typo

Signed-off-by: Boris Egorov <egorov@linux.com>
Signed-off-by: Karel Zak <kzak@redhat.com>