Commit Graph

835 Commits

Author SHA1 Message Date
Sami Kerola 652822e08b misc: remove path name definitions that are unused
After this commit the following produces zero matches.

$ for i in \
_PATH_DEV_TTY \
_PATH_INITTAB \
_PATH_MNTTAB_DIR \
_PATH_MOUNTED_LOCK \
_PATH_MOUNTED_TMP \
_PATH_RC \
_PATH_REBOOT \
_PATH_SECURE \
_PATH_SECURETTY \
_PATH_SHUTDOWN_CONF \
_PATH_SINGLE \
_PATH_UMOUNT \
_PATH_USERTTY
do git grep $i; done

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2016-03-09 11:44:05 +01:00
Ruediger Meier d20eb029d5 include/bitops: avoid fallbacks for more systems
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-03-08 14:55:38 +01:00
Ruediger Meier d01c0adb83 include/bitops: add casts to bswap functions
Based on kernel sources include/uapi/linux/swab.h.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-03-08 14:55:17 +01:00
Karel Zak 075d2c0754 include: move sys/sysmacros.h to c.h
The file is no portable (#ifdef HAVE_SYS_SYSMACROS_H is necessary),
but needed on many places. It seems better to keep it in c.h.

Signed-off-by: Karel Zak <kzak@redhat.com>
2016-03-08 14:29:45 +01:00
Ruediger Meier e210cfc8c8 lib: include sys/stat.h for struct stat
Compiler warning:
'struct stat' will not be visible outside of this function [-Wvisibility]

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-03-07 23:17:12 +01:00
Ruediger Meier dc0495166f build-sys: add and use openat build conditionals
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-03-07 15:37:25 +01:00
Ruediger Meier 1a048dc5e2 lib: move fopen_at() to fileutils.h, remove at.h
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-03-07 15:36:00 +01:00
Ruediger Meier 2208b3ccb2 lib: remove openat fallback functions (include/at.h)
I have validated that we are still compatible at least back to
  - openSUSE 11.4
  - SLE 11
  - RHEL/CentOS 6
  - OSX 10.10.x, (Xcode 6.3)
  - FreeBSD 10.2

Confirmed incompatibility:
  - OSX 10.9.x, (Xcode 6.2)

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-03-07 15:33:56 +01:00
Serge Hallyn f9e7b66dbd Implement support for cgroup namespaces
Currently these are supported in #for-next.

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
2016-03-02 17:53:42 -08:00
Ruediger Meier 4d751c008e lib: provide fallback if mkostemp(3) missing
It's missing on OSX.

CC: Yuriy M. Kaminskiy <yumkam@gmail.com>
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-02-29 13:05:18 +01:00
Ruediger Meier 40733239a7 include: provide MAP_ANONYMOUS on OSX
Hope there are no side effect when defining _DARWIN_C_SOURCE
globally.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-02-18 16:54:05 +01:00
Ruediger Meier b0b24b11f8 lib: rename strmode() and setmode()
On BSD they are part of the standard C library.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-02-18 12:53:48 +01:00
Karel Zak 4683cf3673 lib/color: add more ESC seq.
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-02-17 12:51:15 +01:00
Karel Zak 57867795aa libsmartcols: support multibyte titles, rename wrap to padding
- let's support multibyte table titles
- use lib/mbalign.c to align the title
- rename title_wrap to title_padding (we already use "wrap" on another
  places for another things)

Signed-off-by: Karel Zak <kzak@redhat.com>
2016-01-22 16:51:59 +01:00
Karel Zak 6426f926ee lib/mbsalign: fix warnings when compile without widechars
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-01-13 10:08:13 +01:00
Boris Egorov 43b4f7ea5f lib/tty: Pass default width to get_terminal_width()
Almost any code calling get_terminal_width() checks returned width for
non-positive values and sets it to some default value (say, 80). So,
let's pass this default value directly to the function.

[kzak@redhat.com: - get_terminal_width() refactoring]

Signed-off-by: Karel Zak <kzak@redhat.com>
2016-01-06 12:22:07 +01:00
Karel Zak f7ac9e71b1 login, mount: fix __SC_GETPW_R_SIZE_MAX usage
sysconf(_SC_GETPW_R_SIZE_MAX) returns initial suggested size for pwd
buffer (see getpwnam_r man page or POSIX). This is not large enough in
some cases.

Yes, this sysconf option is misnamed (should be _SC_GETPW_R_SIZE_MIN).

Signed-off-by: Karel Zak <kzak@redhat.com>
2015-12-15 12:33:34 +01:00
Karel Zak 624996a950 libmount: add cgroup2 pseudo FS
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-12-08 12:16:27 +01:00
Karel Zak 4ba2a6e515 Merge branch 'races' of git://github.com/kerolasa/lelux-utiliteetit 2015-12-02 10:27:43 +01:00
Karel Zak e069296ed8 include: add missing header file
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-12-01 15:44:26 +01:00
Karel Zak 04a5cb58b6 namei: move icache to lib/
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-11-27 13:56:01 +01:00
Karel Zak 0e756daeb6 lslocks: use stuff from lib/procutils
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-11-25 14:17:22 +01:00
Sami Kerola 8fe1e638fa
lib/blkdev: add open_blkdev_or_file() function
Purpose of this function is to open a path that is potentially pointing to a
block device or file without races.  The function also proper open(3) flags
are used to check the device is not busy, and finally warning is been
printed if a block device happens to be misaligned.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-11-22 20:56:05 +00:00
Sami Kerola 3f684db0d9
include/fileutils: add is_same_inode() check
Check if a file descriptor and path or stat structure are represent the same
file.  This function is needed for TACTOU avoidance.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-11-22 20:55:34 +00:00
Casper Ti. Vector dcbba45cc5 include: remove now useless linux_reboot.h. 2015-11-19 12:07:41 +01:00
Ming Lei faeef4d2e9 losetup: support list direct io
So that user can see if DIO is set for current loop device.

Signed-off-by: Ming Lei <tom.leiming@gmail.com>
2015-11-19 11:27:36 +01:00
Ming Lei 64c3bb3cb7 losetup: support ioctl cmd of LOOP_SET_DIRECT_IO
From v4.4, linux kernel starts to support direct I/O and
AIO to backing file for loop driver, so allow losetup to
enable the feature by using LOOP_SET_DIRECT_IO ioctl cmd.

Signed-off-by: Ming Lei <tom.leiming@gmail.com>
2015-11-19 11:27:36 +01:00
Sami Kerola 82cac34889
ctrlaltdel: display setting when ran without arguments
This is more useful than printing an error.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-10-18 18:03:57 +01:00
Karel Zak 3ebfa6882a include/pt-mbr-partnames: remove '|' from partition type name
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-10-09 13:13:59 +02:00
Jörg Jenderek 3e9a2bbb94 fdisk: to recognize Intel Rapid Start hibernation partition
I use Intel Rapid Start Technology on my PC. According to their User Guide
"Rapid_Start_Technology_User_Guide_v1.4.pdf" I create a partition with id=84
for hibernation by this Technology.

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

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

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

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

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

Signed-off-by: Karel Zak <kzak@redhat.com>
2015-10-02 12:34:01 +02:00
Karel Zak de8d3863c8 lib/strv: add strv_extendv()
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-10-01 14:43:05 +02:00
Karel Zak 7020de0be8 lib/crc32: don't require to modify GPT header
This patch introduces smart crc32 function that is able to exclude
specified. The advantage is that we does not have to modify GPT header
(set the current in-header crc field to zero) when we count crc32.

This allows to keep GPT header in read-only buffers and simplify code.

Signed-off-by: Karel Zak <kzak@redhat.com>
2015-09-24 09:26:42 +02:00
Karel Zak bde91c85bd chsh, chfn, vipw: fix filenames collision
The utils when compiled WITHOUT libuser then mkostemp()ing
"/etc/%s.XXXXXX" where the filename prefix is argv[0] basename.

An attacker could repeatedly execute the util with modified argv[0]
and after many many attempts mkostemp() may generate suffix which
makes sense. The result maybe temporary file with name like rc.status
ld.so.preload or krb5.keytab, etc.

Note that distros usually use libuser based ch{sh,fn} or stuff from
shadow-utils.

It's probably very minor security bug.

Addresses: CVE-2015-5224
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-08-24 10:05:55 +02:00
Karel Zak 2c6567799d build-sys: add --disable-assert
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-08-04 13:40:44 +02:00
Benno Schulenberg 62eea9ce12 textual: adjust grammar and punctuation of some messages
Also equalize three messages to one other one,
and fix a typo in USE_COLORS_BY_DEFAULT.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2015-08-03 11:18:56 +02:00
Karel Zak 0bef6f759b libsmartcols: don't link with tinfo
Let's move color names to sequence translation to separate file to
make it usable without all the stuff in lib/colors.c.

Signed-off-by: Karel Zak <kzak@redhat.com>
2015-07-24 12:57:46 +02:00
Karel Zak 16c9f32f07 include/xalloc: add err_oom()
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-07-20 11:48:09 +02:00
Karel Zak f6c01f4eed lib/procutils: add proc_get_cmdline()
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-07-20 11:48:09 +02:00
Karel Zak 1e0cd7ae9e include/all-io: read_all() don't retry on EOF
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-07-20 11:48:09 +02:00
Karel Zak a6bf40ee77 lslogins: merge read_utmp() code
The code is used only in lslogins, so it does not make sense to
maintain it in libcommon.

Signed-off-by: Karel Zak <kzak@redhat.com>
2015-07-16 11:26:14 +02:00
Sami Kerola 3e5a54554d rtcwake: improve read_clock_mode()
Make skipping two lines more robust, and add message about unexpected
adjfile contents when running with --verbose.

Reviewed-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-06-29 13:39:37 +02:00
Guillem Jover f51275eedb include/c: Define F_DUPFD_CLOEXEC on kFreeBSD systems if missing
The kernel of FreeBSD version 10 and higher supports this fcntl command,
but the system libc, in this case glibc, might not yet know about it.

Signed-off-by: Guillem Jover <guillem@hadrons.org>
2015-06-08 12:10:04 +02:00
Guillem Jover 8e86d93d1e lib/fileutils: Add new dup_fd_cloexec function
This function duplicates and marks a file descriptor as close-on-exec.
Takes care of build and run-time support for the fcntl F_DUPFD_CLOEXEC
command, and other errors.

Signed-off-by: Guillem Jover <guillem@hadrons.org>
2015-06-08 12:10:02 +02:00
Karel Zak 6a768b5516 libsmartcols: keep JSON field names lower-case
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-06-05 11:58:42 +02:00
Karel Zak 6c62abc42b lib/sysfs: rename devname functions, cleanup
Well, I don't have mental power to use function names like

 sysfs_devname_to_dev_name()

so this patch renames to

 sysfs_devname_sys_to_dev()
 sysfs_devname_dev_to_sys()

It also cleanups usage of the functions. We have to be sure that
sysfs.c code returns regular devnames. The existence of the sysfs
devnames (with '!') should be completely hidden in sysfs specific
code.

Signed-off-by: Karel Zak <kzak@redhat.com>
2015-05-28 12:09:41 +02:00
Stanislav Brabec 759b120d85 lib/sysfs: Fix /dev to /sys node name translation
d0dc6c1 introduced translation of /sys names to /dev names, as required
by the kernel linux/drivers/base/core.c: device_get_devnode(). But there
are other places of code that use /dev names in /sys. They need reverse
translation from '/' to '!'.

For example, fdisk -l returns empty list since a22c6eb for device nodes
in subdirectories (used e. g. by cciss driver).

Introduce yet another helper sysfs_dev_name_to_devname() and use it where
appropriate.

Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
2015-05-28 10:27:20 +02:00
Stanislav Brabec d0dc6c17c5 Fix /sys to /dev node name translation
linux/drivers/base/core.c: device_get_devnode() defines a translation of
'!' in sysfs nodes to '/' in /dev nodes. The same translation has to be
done to properly support device nodes with slash (e. g. device nodes of
cciss driver and several other drivers).

Introduce new helper sysfs_devname_to_devno() and use it where
appropriate.

Fixes for example lsblk -f on devices using cciss driver.

Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
2015-05-26 11:42:38 +02:00
Karel Zak 548b9714e8 lib/strv: add new functions (from systemd)
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-05-15 14:57:04 +02:00
Karel Zak 40b175084f lib/strutils: fix string_add_to_idarray() int vs. size_t
The function uses "int" as argument, but for array size (and index) is better
to use unsigned type (size_t). If we mix "size_t" in util (e.g. fdisk)
and "int" in lib/strutils.c then result is unexpected behavior on
ppc64.

	# sfdisk --list -o DEVICE,START,SIZE /dev/sdb
	Disk /dev/sdb: 50 MiB, 52428800 bytes, 102400 sectors
	Units: sectors of 1 * 512 = 512 bytes
	Sector size (logical/physical): 512 bytes / 4096 bytes
	I/O size (minimum/optimal): 4096 bytes / 32768 bytes
	Disklabel type: gpt
	Disk identifier: 3B8559DB-33AF-43E9-BEFC-C331D829B539
	lt-sfdisk: libfdisk/src/label.c:178: fdisk_label_get_field: Assertion `id > 0' failed.

The patch cleanup all code to use size_t everywhere.

Signed-off-by: Karel Zak <kzak@redhat.com>
2015-04-22 11:08:05 +02:00
Karel Zak 3457d90e30 libfdisk: support bootbits protection from (p)MBR
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-04-13 13:40:25 +02:00
Jörg Jenderek 25156ba16b libfdisk: recognize FAT32 partitions hidden by Acronis software
References: http://www.acronis.de/products/trueimage
Signed-off-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Jörg Jenderek <joerg.jen.der.ek@gmx.net>
2015-04-08 10:24:26 +02:00
Rainer Gerhards 3eb3c8d77e silence compiler warning
This is primarily cosmetic, albeit it also provides an only very
slight improvement in compile time error checking.
2015-03-10 14:13:38 +01:00
Karel Zak c958032a6d build-sys: fix typo 2015-03-06 14:32:12 +01:00
Karel Zak 26e8964b9d lib/timer: use separate file for timers
It seems that static builds require -lpthread for timer_* functions.
It's better to keep it out of our libs (e.g. libmount) to avoid
unnecessary dependence.

Signed-off-by: Karel Zak <kzak@redhat.com>
2015-03-06 13:17:20 +01:00
Karel Zak b9dedd3d34 lib/monotonic: fix compiler warnings
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-03-05 13:32:53 +01:00
Karel Zak b28842ae67 agetty: support /usr/lib/os-release too
http://www.freedesktop.org/software/systemd/man/os-release.html

The file /etc/os-release takes precedence over /usr/lib/os-release.
Applications should check for the former, and exclusively use its data
if it exists, and only fall back to /usr/lib/os-release if it is
missing.

Reported-by: Dimitri John Ledkov <dimitri.j.ledkov@intel.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-03-05 12:25:28 +01:00
Karel Zak 46cd5b1767 flock: fix timeout handler pointer usage
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-03-05 10:47:59 +01:00
Sami Kerola 378543e13f flock: improve timeout handling
Signal ALRM raised by the timer, and the timer only, will be considered
as a timeout criteria.

Secondly time interval is made to use monotonic clock.  Documentation of
ITIMER_REAL is unclear whether that time is affected various sources of
clock skew, or does it even tick when system is suspended.

Reviewed-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-03-05 10:31:01 +01:00
Karel Zak f71d1104df build-sys: add --enable-usrdir-path
The directories /{sbin,bin} are symliks to /usr/{sbin,bin} on many
systems. This patch add new ./configure option to remove the non-usr
paths from the default $PATH environment variable.

The default $PATH is hardcoded in login(1) and can be overwritten
by /etc/login.defs.

default:

./test_pathnames | grep DEFPATH
       _PATH_DEFPATH /usr/local/bin:/bin:/usr/bin
  _PATH_DEFPATH_ROOT /usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin

--enable-usrdir-path:

./test_pathnames | grep DEFPATH
       _PATH_DEFPATH /usr/local/bin:/usr/bin
  _PATH_DEFPATH_ROOT /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin

This patch does not modify install paths, you still have to care about
--{bin,lib}dir configure options.

Signed-off-by: Karel Zak <kzak@redhat.com>
2015-03-03 11:43:01 +01:00
Karel Zak 62dc0ee83b lib/colors: add USAGE_COLORS_DEFAULT
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-02-25 12:35:05 +01:00
Sami Kerola 52a49e9add logger: move /dev/log to pathnames.h
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-02-24 13:18:49 +01:00
Sami Kerola cd2a6f1cfd rpmatch: use symbolic value when evaluation return codes
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-02-24 12:42:06 +01:00
Karel Zak 30b294c491 lib/strutils: extend parse_switch() to accept more options
* allow to specify more 0|1 pairs
* allow to specify error message

Signed-off-by: Karel Zak <kzak@redhat.com>
2015-02-24 12:04:22 +01:00
Sami Kerola e5cf147655 lib/strutils: move parse_switch() from setterm(1) to library
To allow sharing the code with other utilities.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-02-24 11:33:31 +01:00
Eric W. Biederman 0bf159413b unshare: Fix --map-root-user to work on new kernels
In rare cases droping groups with setgroups(0, NULL) is an operation
that can grant a user additional privileges.  User namespaces were
allwoing that operation to unprivileged users and that had to be
fixed.

Update unshare --map-root-user to disable the setgroups operation
before setting the gid_map.

This is needed as after the security fix gid_map is restricted to
privileged users unless setgroups has been disabled.

Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
2015-01-09 10:32:33 +01:00
Karel Zak 47123602e6 Merge remote-tracking branch 'sami/2014wk49'
* sami/2014wk49:
  chfn: make command to obey login.defs CHFN_RESTRICT instructions
  chfn: remove set_changed_data() and add add_missing()
  chfn: rename prompt() to ask_new_field()
  chfn: move new and old finger structs to chfn control struct
  chfn: clean up parse_argv()
  chfn: add minimalistic struct chfn_control
  chfn: simplify parse_passwd() by using strsep()
  chfn: fix usage() regression
  chfn: use xasprintf() rather than bunch of strlen() and malloc() calls
  chfn: rewrite prompt() to use strutils
  chfn: remove function prototypes
  lslogins: use hardcoded paths from pathnames.h
  lslogins: add space to systemd journal header and message
  lslogins: reject unknown time format arguments
  lslogins: fix short options
  lslogins: tell why command failed
  lslogins: make journald last logs time stamps to honor --time-format
  lslogins: allow changing password changed and expiration time formats
2014-12-19 14:28:42 +01:00
Sami Kerola d763c23081 include/c: define UL_ASAN_BLACKLIST address_sanitizer function attribute
The UL_ASAN_BLACKLIST allows AddressSanitizer to be switched off for
functions that cannot be checked.

Reference: http://dxr.mozilla.org/mozilla-central/source/mfbt/Attributes.h
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-12-19 11:32:38 +01:00
Sami Kerola 4ecc6dbb53 lslogins: use hardcoded paths from pathnames.h
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-12-19 09:11:03 +00:00
Sami Kerola 2f8610ee95 strutils: fix unsigned integer overflows [AddressSanitizer]
include/strutils.h:174:10: runtime error: unsigned integer overflow: 0 -
1 cannot be represented in type 'size_t' (aka 'unsigned long')

include/strutils.h:178:6: runtime error: unsigned integer overflow:
18446744073709551615 + 1 cannot be represented in type 'size_t' (aka
'unsigned long')

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-12-19 09:10:48 +00:00
Sami Kerola 737532efe5 fdisk: (sgi) fix unsigned integer overflow [AddressSanitizer]
include/pt-sgi.h:103:7: runtime error: unsigned integer overflow: 0 -
1186450447 cannot be represented in type 'unsigned int'

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-12-19 09:10:48 +00:00
Will Johansson fe2c9909cd 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>
2014-12-15 10:16:03 +01:00
Karel Zak 372112e908 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>
2014-12-05 15:30:04 +01:00
Karel Zak 764b697c56 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>
2014-12-04 13:06:03 +01:00
Karel Zak 19ff8ff7c4 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>
2014-12-04 10:27:39 +01:00
Karel Zak e017ef8bb9 lib/sysfs: add subsystem and hotplug detection
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-12-02 10:59:48 +01:00
Karel Zak cca51b9e45 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>
2014-11-27 13:36:09 +01:00
Karel Zak cd2876d252 build-sys: move all around clock_gettime() to monotonic.c
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-11-19 11:54:47 +01:00
Karel Zak 700031ade7 misc: use monotonic time rater than gettimeofday
Based on patch Alexander Samilovskih <alexsamilovskih@gmail.com>

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-11-18 14:35:21 +01:00
Karel Zak 64d0cee6c0 include/statfs_magic: use macro rather than type for f_type
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-11-10 11:29:42 +01:00
Sami Kerola c181617cfb mkswap: remove unnecessary size check
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-11-07 13:21:05 +01:00
Karel Zak 8f806bb1ea switch_root: improve statfs->f_type portability
__SWORD_TYPE is not available everywhere, for example it's not defined
by musl libc. It also seems that __SWORD_TYPE is not used for f_type
on some architectures (s390x).

Reported-by: Natanael Copa <ncopa@alpinelinux.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-11-06 12:50:27 +01:00
Karel Zak 0bf037402a lib/loopdev: replace custom DBG() with include/debug.h
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-11-04 14:08:45 +01:00
Karel Zak ef316a27de include/debug: improve and cleanup
* use ul_debug_ prefix for all routines
* support <NAME>_DEBUG=all also for programs without debug mask names
  (so we can avoid 0xffff mask in man pages)
* add function to print debug help

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-11-03 12:51:17 +01:00
Karel Zak 8fc4a88630 build-sys: properly check for -lrt
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-27 11:05:14 +01:00
Karel Zak 819d9a2975 include/debug: fix typo
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-24 11:19:23 +02:00
Karel Zak 3635f53ca2 whereis: cleanup debug stuff, fix argv[] usage
* use debug stuff from include/debug.h and make whereis(1) sensitive
  to WHEREIS_DEBUG=0xffff mask

* fix problem with argv[] usage

  # whereis -b -m -M /usr/share/man/man1 -B /usr/bin -f gcc
  bin: /usr/local/bin
  gcc: /usr/bin/gcc /usr/lib/gcc /usr/libexec/gcc /usr/share/man/man1/gcc.1.gz

the code ignores "-B" and /usr/bin is interpreted as search pattern,
expected result is:

  # whereis -b -m -M /usr/share/man/man1 -B /usr/bin -f gcc
  gcc: /usr/share/man/man1/gcc.1.gz /usr/bin/gcc

Addresses: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=765306
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-10-23 13:44:00 +02:00
Sami Kerola aeeb81317e include/debug: remove duplicate 'const' declaration warning
./include/debug.h:89:55: warning: duplicate 'const' declaration specifier [-Wduplicate-decl-specifier]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-10-01 13:09:35 +02:00
Sami Kerola 2a0d2a8e11 include: fix compiler warnings
This change has motivation to make -Wall -pedantic compiler options to
spit a little bit less noise, which with luck will increase change to
notice real issues.

Multiple of these:

warning: ISO C forbids braced-groups within expressions [-Wpedantic]

And nearly 300 times reported:

include/c.h:75:41: warning: struct has no named members [-Wpedantic]
 #define UL_BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:-!!(e); }))

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-10-01 12:33:35 +02:00
Karel Zak 286f1e229b Merge branch 'misc' of git://github.com/kerolasa/lelux-utiliteetit
* 'misc' of git://github.com/kerolasa/lelux-utiliteetit:
  textual: share crypt() error message in sulogin and newgrp
  newgrp: avoid use of obsolete getpass() function
  newgrp: use libc function to read gshadow if it is available
  setarch: use personality() system call when it is available
  setarch: reindent code
  hwclock: remove referal to deprecated keyboard interface
  eject: make open_device() and select_speed() to use struct eject_control
  eject: add struct eject_control to remove global variables
  mountpoint: simplify if statement
  mkfs.minix: fix couple compiler warnings
  mountpoint: add struct mountpoint_control
  last: improve code readability by renaming variable names
  last: make is_phantom() when kernel config does not include audit support
  lib: remove xgetpass()
  include: simplify fputc_careful() in carefulputc.h
  libuuid: add extern qualifiers to uuid/uuid.h system header
2014-09-22 14:55:37 +02:00
Karel Zak 18b3e5495b swapon: split swapon-common.c
swapon    - requires libmount and libblkid
 swapoff   - requires libmount
 swaplabel - requires libblkid

This patch add lib/swapprober.c with blkid stuff for swap. It allows
to use and link libblkid only when necessary.

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-09-22 13:16:25 +02:00
Sami Kerola 96c4bc4dd2 lib: remove xgetpass()
This function is not in use, and it has reference to obsoleted getpass().

Reference: http://man7.org/linux/man-pages/man3/getpass.3.html
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-09-19 19:31:01 +01:00
Sami Kerola c6d2d74ea0 include: simplify fputc_careful() in carefulputc.h
New version of comparisions does the same thing as the old without being
quite as difficult to understand.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-09-19 19:31:01 +01:00
Christoph Egger c32270d41f agetty: fixing FTBFS on !linux (Debian util-linux 2.20.1-1.2)
Handle vc flags missing on FreeBSD
Fix tty creation on kFreeBSD taking patch from 2.19

Addresses-Debian-Bug: #650185
2014-09-17 10:14:50 +02:00
Karel Zak d947f85df4 include/optutils: fix typo
Reported-by: Rafael Ferreira <rafael.f.f1@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-08-28 08:39:54 +02:00
Karel Zak 22e9e9c8e9 libblkid: move string trim function to strutils.h
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-08-25 15:31:53 +02:00
Karel Zak 1e06330329 include/debug: allow to speficy empty masknames
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-08-13 14:19:21 +02:00
Karel Zak 03e4220d29 include/debug: cleanup masks
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-08-13 14:13:32 +02:00
Karel Zak 6d577b7089 include/debug: make masknames optional
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-08-13 13:51:42 +02:00
Ondrej Oprala 14ad2353cc libs/debug: accept human readable names for _DEBUG=
For example
	$ LIBMOUNT_DEBUG=tab,cache findmnt

to debug only TAB and CACHE subsystem.

Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-08-13 12:33:47 +02:00
Karel Zak b8731ebcf2 lib/colors: add function to return color from scheme
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-08-13 10:09:08 +02:00
Benno Schulenberg 1d23119072 textual: remove some inconsistent periods from error messages
While doing so, also improve translatability and some wordings.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2014-08-11 14:51:54 +02:00
Karel Zak 6c987ca9d7 lib/sysfs: allow to write to sysfs attributes
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-08-01 12:08:44 +02:00
Sami Kerola 25a365ef5a swaplabel: move swapon-common to include directory
This fixes the following compiler warning.

disk-utils/swaplabel.c:175:2: warning: implicit declaration of function
'get_swap_prober' [-Wimplicit-function-declaration]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-07-28 12:28:05 +02:00
Lauri Nurmi a5c523a0e7 Fix typo "ioclt" in various files. 2014-07-11 22:52:09 +03:00
Karel Zak 2ad2196349 build-sys: support ./configure ADJTIME_PATH=
.. to override the default /etc/adjtime path.

Reported-by: Bruce Dubbs <bruce.dubbs@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-06-19 10:30:56 +02:00
Karel Zak f272b32c57 lib/fileutils: xalloc stuff in library-like code
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-06-18 12:57:42 +02:00
Karel Zak 62acb047a6 build-sys: remove obsolete wholedisk.c
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-06-17 12:16:29 +02:00
Karel Zak b55e5886ea lib/sysfs: add sysfs_devno_is_wholedisk()
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-06-17 12:15:01 +02:00
Karel Zak 39866431ee lib/sysfs: add sysfs_devno_is_lvm_private() from libblkid
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-06-17 11:20:32 +02:00
Karel Zak d4eaabc86a lib/fileutils: add stripoff_last_component() from libmount
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-06-09 11:54:32 +02:00
Karel Zak 934530c7e8 lib/fileutils: add mkdir_p() from libmount 2014-06-09 10:59:18 +02:00
Ondrej Oprala f1728a4cbd lslogins: add readtump.h header 2014-05-15 13:55:59 +02:00
Ondrej Oprala 29cc2a5568 lslogins: add functionality
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2014-05-15 13:55:59 +02:00
Karel Zak 7a4704d826 lib/colors: support schemes customization
* parse terminal-colors.d/*.scheme files, expected format is

    <name> <color-sequence>

 * supported color sequences:

     - color name (e.g. "red")
     - dir_colors compatible xx;yy (e.g. 01;31) where the sequence may
       contains control chars like \e \a  ..etc.

 * scheme is parsed on demand

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-05-13 12:09:03 +02:00
Karel Zak e66a662726 lib/colors: allow to temporary disable colors
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-05-13 12:09:02 +02:00
Karel Zak 570b32100f lib/colors: add support for @term and /home/kzak
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-05-13 12:09:02 +02:00
Karel Zak 5d7bdfd653 include/boottime: add a new file
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-05-06 16:38:53 +02:00
Karel Zak 08ca3e26a8 lib/timeutils: remove get_boot_time from libcommon
clock_gettime() needs -lrt, so let's keep this stuff
outside libcommon.la

Reported-by: Ruediger Meier <sweet_f_a@gmx.de>
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-05-06 13:16:05 +02:00
Benno Schulenberg 82b219f706 include/c: do not gettextize a wordless string
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2014-05-06 11:09:26 +02:00
Benno Schulenberg 459e95f391 include/carefulputc: remove a duplicate include
Also tweak a comment.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2014-05-06 11:09:22 +02:00
Benno Schulenberg 68411ba260 include/c: remove a duplicate include
Also tweak some comments.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2014-05-06 11:09:21 +02:00
Sami Kerola 24f83f7392 swapon, swapheader, mkswap: move swap signature to header
Both swapon and mkswap need to know what is valid device signature, so
share the value.

[kzak@redhat.com: - use SWAP_SIGNATURE_SZ properly in write_signature()]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-05-06 10:16:54 +02:00
Sami Kerola d38b55375f include/swapheader.h: ensure type sizes
Use consistently the same type sizes as in libblkid and kernel.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-05-06 10:12:14 +02:00
Sami Kerola 506b499991 mkswap: remove legacy swap structure
If software archeolgists want to know how the old, and unused, swap
header looked they can dig it from the revision history.

[kzak@redhat.com: - use sizeof() for SWAP_HEADER_SIZE]

Reference: 4c85aa3a4c
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-05-06 10:08:51 +02:00
Sami Kerola 8a101b1447 mkswap, swaplabel: move version number to header
Corrently only the swap version 1 is supported, which is a magic value so
move it to header.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-05-04 11:42:03 +01:00
Sami Kerola ff1aaf9966 include/c.h: add macro to print definitions as string
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-05-04 11:42:03 +01:00
Sami Kerola 929f939e6a dmesg: move get_boot_time() to lib/timeutils
In future the last(1) will use get_boot_time() as well.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-05-04 11:42:03 +01:00
Karel Zak 0c33fcbf23 lib/mbalign: report also size in bytes
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-04-15 15:25:18 +02:00
Karel Zak c426f70fd4 lib/mbsalign: split mbs_safe_encode()
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-04-15 13:58:34 +02:00
Ondrej Oprala 10a628c8b3 lib/tt.c: Goodbye!
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2014-04-03 12:29:19 +02:00
Karel Zak 78a3b0af30 include/carefulputc: cleanup and add fputs_{quoted,nonblank}()
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-04-03 12:29:16 +02:00
Sami Kerola 0720d60cc1 mcookie: use lib/randutils
The mcookie should reuse existing code, and there is definitely no need
to prefer /dev/random for this utility.  See reference for explanation
about later statement.

References: http://www.2uo.de/myths-about-urandom/
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-03-26 10:36:18 +01:00
Karel Zak e7b49879ad include/debug: add another debug macros
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-21 12:04:12 +01:00
Karel Zak d282c88df5 include/debug: fix coding style
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-21 11:21:56 +01:00
Karel Zak 9a7769141a Merge branch 'common_debug' of https://github.com/ooprala/util-linux
* 'common_debug' of https://github.com/ooprala/util-linux:
  clean up redundant macros and defines
  libfdisk: use include/debug.h
  libblkid: use include/debug.h
  libmount: further debug.h integration
  libcommon: don't mention lib versions in debug macros
  libcommon: define more debugging macros
  libmount: use macros from include/debug.h
  libcommon: add common debugging routines
2014-03-21 10:59:58 +01:00
Karel Zak 422f93bfbb include/closestream: don't wipe errno on EPIPE
... the code in close_stdout() is sensitive to EPIPE, so
wipe errno is close_stream() is probably bad idea.

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-13 12:41:03 +01:00
Ondrej Oprala 274228fecc clean up redundant macros and defines
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2014-03-13 11:53:31 +01:00
Ondrej Oprala b681c25834 libcommon: don't mention lib versions in debug macros
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2014-03-13 10:42:11 +01:00
Ondrej Oprala cb3fa84753 libcommon: define more debugging macros
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2014-03-12 15:40:40 +01:00
Ondrej Oprala db08389d87 libcommon: add common debugging routines
Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
2014-03-12 14:37:41 +01:00
Karel Zak e11040bdfc lib/tt: keep track about output order
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-11 11:35:14 +01:00
Karel Zak 9a66e1e76f lib/tt: add tt_line_get_userdata()
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-11 11:35:14 +01:00
Karel Zak 6736192af4 include/list: add void data to the sort cmp function
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-11 11:35:13 +01:00
Karel Zak 1b1f66e477 lib/mbalign: add mbs_safe_width() from tt.c
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-11 11:35:13 +01:00
Karel Zak 2e6c3a53f9 include/xalloc: add xvasprintf()
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-11 11:35:13 +01:00
Karel Zak ed494c8d50 include/tt: add function to convert table to string
Note that open_memstream() is POSIX-1.2008, so it's possible than not
all libc have already implemented this function.

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-11 11:35:12 +01:00
Karel Zak 7358229637 lib/tt: add reduce term width functionality
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-11 11:35:12 +01:00
Karel Zak b839bd4fa1 lib/tt: add TT_FL_MAX to fill screen
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-11 11:35:12 +01:00
Karel Zak 575a1de03a lib/tt: add tb_get_nlines()
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-11 11:35:12 +01:00
Karel Zak 0cd73f41e8 lib/tt: don't hardcode stdout as output
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-11 11:35:12 +01:00
Karel Zak 11fd5edb9d include/tt: add tt_is_empty()
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-11 11:35:11 +01:00
Ondrej Oprala d0c9ddc3cc lib/colors: check for /etc/terminal-colors.d/[util].disable
[kzak@redhat.com: - move paths to pathnames.h,
                  - use static path buffer]

Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-11 09:38:09 +01:00
Karel Zak df019e9be7 libmount: add statfs_magic.h
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-03-06 13:09:16 +01:00
Karel Zak 68f7b572ba lib/color: add colorscheme parser 2014-02-10 14:50:12 +01:00
Karel Zak 663bf04061 losetup: wait for udev
On system with /dev/lop-control the udevd creates /dev/loopN nodes.
It seems better to wait a moment after unsuccessful open(/dev/loopN)
and try it to open again.

The problem is pretty visible on systems where udevd also modifies
permission for loopN devices, then open() fails with EACCES when
losetup executed by non-root user (but user who is in "disk" group).

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1045432
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-01-24 13:58:40 +01:00
Karel Zak a5bd793996 include/c.h: prefer nanosleep() over usleep()
Let's use nanosleep() although if usleep() exists. The nanosleep
function does no interact with signals and other timers.

The patch introduces xusleep() as replacement to libc (or our fallback)
usleep(). Yes, we don't want to use struct timespec + nanosleep()
everywhere in code as nano-time resolution is useless for us.

The patch also enlarges delays in some busy wait loops. It seems
enough to try read/write 4x per second.

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-01-24 13:04:14 +01:00
Lubomir Rintel 4da21e374e unshare: Add possibility to add mapping into root user in user namespace
This makes it very convenient to use make use of privileged actions
on CONFIG_USER_NS enabled kernels, without having to manually tinker
with uid_map and gid_map to obtain required credentials (as those
given upon unshare() vanish with call to execve() and lot of userspace
checks for euid==0 anyway).

Usage example:

$ unshare --uts
unshare: unshare failed: Operation not permitted

$ unshare --user --uts
[nfsnobody@odvarok ~]$ hostname swag
hostname: you must be root to change the host name

$ unshare -r --uts
[root@odvarok util-linux]# hostname swag
[root@odvarok util-linux]#

[kzak@redhat.com: - move code to map_id()
                  - use all-io.h
                  - add paths to pathnames.h]

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-01-07 11:04:42 +01:00
Karel Zak dd3bc51a53 lib/path: add path_strdup()
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-01-06 16:48:13 +01:00
Sami Kerola d8a9b90756 docs: update links to http://git.kernel.org/ web repository views
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-11-12 11:47:57 +01:00
Ondrej Oprala 675de3f5c1 strutils: add skip_space() function
[kzak@redhat.com: - add also skip_blank(),
                  - remove duplicate implementation from libmount]

Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-11-08 14:14:34 +01:00
Michael Forney 00c505d9cf include: Add missing includes
sys/types.h: For u_char typedef
sys/params.h: For MAXNAMLEN
sys/ttydefaults.h: For various tty definitions (also add configure check)

Signed-off-by: Karel Zak <kzak@redhat.com>
2013-10-04 11:51:21 +02:00
Karel Zak 88407b9321 nologin: add new command
Currently it's maintained as distro specific (or people use impolite
/bin/false way).

Signed-off-by: Karel Zak <kzak@redhat.com>
2013-09-30 13:36:26 +02:00
Karel Zak e93d5475fe build-sys: fix include Makemodule.am
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-09-26 10:41:18 +02:00
Karel Zak 80a1712f54 fdisk: add -L to colorize output
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-09-16 16:47:09 +02:00
Karel Zak 0dd3dfb8e3 fdisk: (bsd) write/read PT code cleanup
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-09-16 16:47:06 +02:00
Karel Zak cc3d127e4c libblkid: move bsd definitions to pt-bsd.h
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-09-16 16:47:04 +02:00
Karel Zak 5099226711 libfdisk: move mbr code to the library
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-09-16 16:47:04 +02:00
Karel Zak e8bf93ded2 fdisk: add mbr_get_partition()
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-09-16 16:47:02 +02:00
Karel Zak b44244cb98 fdisk: use functions from pt-mbr.h
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-09-16 16:47:02 +02:00
Karel Zak 71ade4da58 libblkid: rename sys_type to sys_ind
This makes struct dos_partition more compatible with the current fdisk
code.

Signed-off-by: Karel Zak <kzak@redhat.com>
2013-09-16 16:47:02 +02:00
Karel Zak b198111523 include/pt-mbr: add functio to store le
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-09-16 16:47:02 +02:00
Karel Zak f917738efa libblkid: move MBR definitions to include/pt-mbr.h 2013-09-16 16:47:02 +02:00
Karel Zak d4caf70067 fdisk: (sgi) fix checksum calculation
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-09-16 16:46:58 +02:00
Karel Zak 7e5f8f3824 libblkid: move MBR partition types to include/
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-09-16 16:46:58 +02:00
Karel Zak 9fc1f5d809 fdisk: (sgi) cleanup devparams flags
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-09-16 16:46:58 +02:00
Karel Zak 1a9889ad7f fdisk: (sgi) cleanu sgi_info stuff
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-09-16 16:46:57 +02:00
Karel Zak 5105f75f67 fdisk: (sgi) remove magic strings
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-09-16 16:46:57 +02:00
Karel Zak a78651d778 fdisk: (sgi) share disk label definition with libblkid
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-09-16 16:46:57 +02:00
Karel Zak 1c314b3183 libblkid: move SGI disklabel definitions to include/
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-09-16 16:46:57 +02:00
Karel Zak f234cc3b51 lib/tt: add TT_FL_FREEDATA
... to call free() for line data.

Signed-off-by: Karel Zak <kzak@redhat.com>
2013-09-16 16:46:53 +02:00
Karel Zak b34f097e75 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}0m \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>
2013-09-12 12:44:09 +02:00
Karel Zak db2a3dda74 lib: add crc64()
Based on bcache code from Rolf Fokkens.

Signed-off-by: Karel Zak <kzak@redhat.com>
2013-09-11 16:40:06 +02:00
Karel Zak 60f25deae7 lib: rename time-util.c to timeutils.c, fix headers
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-09-10 13:11:02 +02:00
Karel Zak 646e159aa9 lib/strutils: optimalize {starts,ends}with()
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-09-10 12:18:20 +02:00
Sami Kerola 199e939d88 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>
2013-08-29 18:14:08 +01:00
Sami Kerola 2659a49ef0 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>
2013-08-29 18:14:08 +01:00
Sami Kerola ada6c48f06 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>
2013-08-23 10:58:48 +02:00
Karel Zak 3cb2413b02 losetup: use loop-control to explicitly ask for device
Now we use LOOP_CTL_GET_FREE ioctl to ask for free device, for example

  losetup -f foo.img

Unfortunately, losetup(8) allows to ask for specified device

  losetup /dev/loop100 foo.img

and in this case we assume that the device already exists in the
system. This is incorrect, we should be able to use loop-control
LOOP_CTL_ADD ioctl to ask for the specified device.

Signed-off-by: Karel Zak <kzak@redhat.com>
2013-08-06 11:04:35 +02:00
Karel Zak c9678832b1 include/xalloc: add warn_unused_result to allocation functions
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-07-09 10:44:06 +02:00
Karel Zak b8b8e76806 agetty: don't remove ECHOCTL from c_lflag
It's really unexpected that arrows keys move cursor when agetty/login
asks for login name or password.

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=969458
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-06-03 14:06:18 +02:00
Ondrej Oprala fb2627cec4 lscpu: detect more hypervisor vendors
[kzak@redhat.com: - cleanup coding style,
                  - use path_exist()]

Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-05-20 16:30:23 +02:00
Karel Zak 507341f832 lib/tty: don't hardcode terminal fd in get_terminal_name()
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-05-13 15:40:57 +02:00
Karel Zak b7faf99128 lib/colors: add colormode_or_err()
... to make the code easy to use in utils.

Signed-off-by: Karel Zak <kzak@redhat.com>
2013-05-07 09:09:35 +02:00
Karel Zak a10c043493 lib/colors: add support for auto, always and never modes
... to implement --color[=<when>]

Signed-off-by: Karel Zak <kzak@redhat.com>
2013-05-06 19:07:23 +02:00
Sami Kerola f416563b28 include: add close_fd() for noticing write errors before close()
Essentially this helper function is similar to close_stream(), but for
file descriptors.

When a file descriptors are close()'d status of write is often
overlooked.  The close_fd() will try to determine what happen to writes
with fsync() before closing the file descriptor.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-04-26 13:26:06 +02:00
Karel Zak 6d791b4cc0 include: fix SYS_{unshare,nsenter} usage
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-04-17 16:58:00 +02:00
Karel Zak 09daba4069 libblkid: arch independent minix detection
It seems that on-disk MINIX FS superblock is native-endian.

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=833841
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-04-15 15:14:33 +02:00
Karel Zak 2b88d3d72b lib/xalloc: add xstrndup()
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-04-10 17:16:01 +02:00
Jeff Mahoney 293714c0d1 loopdev: sync capacity after setting it
I recently tried to mount an hfsplus file system from an image file with
a partition table by using the loop offset and sizelimit options to specify
the location of the file system.

hfsplus stores some metadata at a set offset from the end of the partition,
so it's sensitive to the device size reported by the kernel.

It worked with this:

But failed with this:

/dev/loop0: [0089]:2 (<imagefile>), offset 32768, sizelimit 102400000
/dev/loop1: [0089]:2 (<imagefile>), offset 32768, sizelimit 102400000

/proc/partitions shows the correct number of blocks to match the sizelimit.

But if I set a breakpoint in mount before the mount syscall, I could see:
102400000
102432768

The kernel loop driver will set the gendisk capacity of the device at
LOOP_SET_STATUS64 but won't sync it to the block device until one of two
conditions are met: All open file descriptors referring to the device are
closed (and it will sync when re-opened) or if the LOOP_SET_CAPACITY ioctl
is called to sync it. Since mount opens the device and passes it directly
to the mount syscall after LOOP_SET_STATUS64 without closing and reopening
it, the sizelimit argument is effectively ignroed. The capacity needs to
be synced immediately for it to work as expected.

This patch adds the LOOP_SET_CAPACITY call to loopctx_setup_device since
the device isn't yet released to the user, so it's safe to sync the capacity
immediately.

[kzak@redhat.com: - port to the current git HEAD,
                  - use uint64_t]

Signed-off-by: Jeff Mahoney <jeffm@suse.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-04-09 14:32:50 +02:00
Karel Zak 7e3729e750 include/fileutils: use O_CLOEXEC for mktemp stuff
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-04-03 16:12:34 +02:00
Karel Zak 2ffad204c0 include/c: add macro UL_CLOEXECSTR
... to make "e" for fopen() portable to systems without O_CLOEXEC.

Signed-off-by: Karel Zak <kzak@redhat.com>
2013-04-03 16:11:19 +02:00
Karel Zak 8362545b4a lib/xalloc: fix mamory leak in xgethostname() [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-03-27 16:08:47 +01:00
Karel Zak 7528fae9e9 include/pathnames: rename _PATH_ADJPATH to _PATH_ADJTIME
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-03-26 11:45:45 +01:00
Sami Kerola 2ba83ec2e0 docs: arch is gone, use delpart as usage() function example
The arch.c was removed in commit 27abd809.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-03-26 10:53:30 +01:00
Karel Zak 5ad0923904 remove duplicate includes
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-03-20 14:40:19 +01:00
Pádraig Brady 36c7f78524 lib/mbsalign: correct license header from GPLv[23] to LGPLv2+
* lib/mbsalign.c: s/GPLv3/LGPLv2+/
* include/mbsalign.h: s/GPLv2/LGPLv2+/
* README.licensing: Remove mention GPLv3 as it's not actually used.
2013-03-20 14:03:28 +01:00
Karel Zak 5aaee63cdf dmesg: more colors, more fun
* colorize subsystem prefix
 * colorize time
 * colorize by keywords (now "segfault" only)

Signed-off-by: Karel Zak <kzak@redhat.com>
2013-03-18 12:28:32 +01:00
Josh Triplett b00456d2f0 namespace.h: Fix typo: s/CLONE_NEWSNS/CLONE_NEWNS/
This typo causes namespace.h to always unconditionally define
CLONE_NEWNS rather than using the system definition.

Bug present since the initial version of unshare in commit
4205f1fda1.

Signed-off-by: Josh Triplett <josh@joshtriplett.org>
Signed-off-by: Anton Cherkashyn <mail@antonc.com>
2013-03-13 14:47:25 +01:00
Karel Zak 77fa36d7c6 include/timer: return setitimer return value
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-03-13 14:07:23 +01:00
Karel Zak 2c7bcdf868 include/optutils: make collisions detection between options more robust
- don't rely on the correct ul_excl_t usage
 - don't print --(null) for non-existing long options

Signed-off-by: Karel Zak <kzak@redhat.com>
2013-03-13 13:04:02 +01:00
Karel Zak 01acff6e09 include: add timer.h
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-03-13 12:13:11 +01:00
Karel Zak 477254da93 lib/strutils: add strtotimeval_or_err()
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-03-13 11:51:15 +01:00
Karel Zak 13377dd64a lib/procutils: add simple API to scan /proc/PID/*
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-03-12 17:24:14 +01:00
Karel Zak 9d3d9754e7 libblkid: rename in sun_disklabel for compatibility with fdisk
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-03-11 13:00:55 +01:00
Karel Zak ce337318fa inlude/pt-sun: add flags and tags
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-03-11 13:00:55 +01:00
Karel Zak a08dc0ca89 libblkid: move sun PT definition to include/
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-03-11 13:00:55 +01:00
Karel Zak 23106a29b0 lib/strutils: simplify strtosize(), return info about suffix
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-03-11 13:00:54 +01:00
Karel Zak 416c43a9a5 fdisk: add callback for ask-numbers API
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-03-11 13:00:54 +01:00
Bernhard Voelker 96f4747712 build-sys: add exec_shell.h to distribution
Signed-off-by: Bernhard Voelker <mail@bernhard-voelker.de>
2013-03-04 12:28:39 +01:00
Karel Zak d48f6c5db8 Merge branch 'patch-1' of https://github.com/dtrebbien/util-linux
* 'patch-1' of https://github.com/dtrebbien/util-linux:
  Implement mempcpy() in terms of memcpy() if mempcpy() is unavailable
2013-02-20 13:07:07 +01:00
Karel Zak 3785056ca8 lib/tty: don't truncate output on non-terminals
for example:

	$ findmnt | cat
	$ lslocks > foo

 the output should not be truncated.

Signed-off-by: Karel Zak <kzak@redhat.com>
2013-02-19 14:10:24 +01:00
Zbigniew Jędrzejewski-Szmek 5758069426 unshare,nsenter: spawn shell by default
The behaviour mimics chroot.

Possibly it would have been nicer to to query the password database in
the new namepace and run the shell of the user there, but it's hard to
do correctly. getpwuid() might need to load nss plugins, and the arch
in the new namespace might be different (in case of NEWNS mounts), or
the hostname might be different, etc. So in general it's not possible
to do it reliably.

Signed-off-by: Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
2013-02-14 14:42:35 +01:00
Sami Kerola 4190e08e8d build-sys: add namespace.h to distribution
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-02-06 12:03:04 +01:00
Karel Zak 59c68b4368 setpriv: move paths to pathnames.h
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-02-05 11:48:55 +01:00
Daniel Trebbien 02887b73eb Implement mempcpy() in terms of memcpy() if mempcpy() is unavailable 2013-01-30 18:53:00 -05:00
Sami Kerola a167328a74 nsenter: fix indentation
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-01-25 15:42:11 +01:00
Sami Kerola f5152f1aad include: add missing values to sysfs_cxt initializer definition
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-01-24 16:33:30 +01:00
Eric W. Biederman c91280a4bd unshare,nsenter: Move the old libc handling into a common header namespace.h
Move the defitions of CLONE_NEWNS, CLONE_NEWUTS, CLONE_NEWIPC,
CLONE_NEWNET, CLONE_NEWUSER, CLONE_NEWPID into namespace.h in case
sched.h does not provide those definitions.  Are there systems
around that are old enough that still need this?

Move the definitions of unshare() and setns() into namespace.h
for supporting old versions of libc that does not provice these.
I have tested this support with setns as I still have systems
old enough that glibc does not wrap setns.

Signed-off-by: "Eric W. Biederman" <ebiederm@xmission.com>
2013-01-17 13:18:08 +01:00
Sami Kerola fb26bfaf6b build-sys: add files to distribution
To fix 'make distcheck' compilation.  The fdisks/Makemodule.am has one
new entry 'dos_part_types.h', the rest is about sorting the list.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2013-01-10 11:26:55 +01:00
Werner Fink f5664477cb include/ttyutils: add default chardata
this one moves the init_chardata to include/ttyutils.h as well as to
lib/include/ttyutils.c.  Also the macros CTL/CTRL are fixed in
agetty.c and sulogin.c to use the XOR variant CTL.

[kzak@redhat.com: use macro rather than global variable for default
                  chardata]

Signed-off-by: Werner Fink <werner@suse.de>
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-01-08 15:42:12 +01:00
Karel Zak 0f23ee0c85 include: cleanup copyright headers
We use the code from include/ and lib/ on many places, so use public
domain if possible or LGPL for code copied from libs.

Signed-off-by: Karel Zak <kzak@redhat.com>
2013-01-08 15:10:17 +01:00
Karel Zak 1a1eb4e188 include/bitopts: Use the operating system byteswapping functions
The swap macros are already in libc.

Co-Author: Cristian Rodríguez <crrodriguez@opensuse.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-01-08 14:07:48 +01:00
Karel Zak f35336526f build-sys: remove consoles.h
Reported-by: Bernhard Voelker <mail@bernhard-voelker.de>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-12-27 17:37:27 +01:00
Karel Zak a73f59fa03 sulogin: remove consoles.c from libcommon
- move struct chardata to include/ttyutils.h
- move console.{h,c} to login-utils/sulogin-* (it's sulogin specific)
- fix sulogin and agetty includes

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-12-23 22:14:21 +01:00
Werner Fink b33f24b250 sulogin: make usleep() workaround work
Simply fix a compile problem found during debugging console.c

Signed-off-by: Werner Fink <werner@suse.de>
2012-12-18 15:07:58 +01:00
Werner Fink cae29b3717 sulogin: use the linked lists from list.h for consoles list
with this the double linked list feature from util-linux is used
instead of the single linked list.

[kzak@redhat.com: use list_last_entry() and list INIT macros]

Signed-off-by: Werner Fink <werner@suse.de>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-12-18 15:02:35 +01:00
Karel Zak 59da1544ce include/list: add list_last_entry()
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-12-18 15:00:03 +01:00
Sami Liedes becd09500f include/list: fix undefined behavior in list_entry() macro
Update list_entry() macro, which is basically the same as the
container_of() macro in the kernel, to use offsetof() to fix undefined
behavior.

Caught using clang -fsanitize=undefined.

[kzak@redhat.com: port from e2fsprogs]

Signed-off-by: Sami Liedes <sami.liedes@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-12-17 16:23:35 +01:00
Karel Zak 33c5fd0c5a lib/canonicalize: add canonicalize_path_restricted() to canonicalize without suid permisssions
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-11-26 16:24:28 +01:00
Sami Kerola e5995acda2 ipcs: determine ipc limits from /proc
Some of the limit values are not dynamic.  Like in kernel these values
are #defined.

[kzak@redhat.com: - use better names for functions,
                  - add ipcutils.{c,h}
                  - read also shmmax from /proc]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-11-23 14:58:21 +01:00
Karel Zak 37a5c7ee41 lib/path: add path_read_u64()
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-11-23 14:58:21 +01:00
Karel Zak ca01695b77 lib/path: rename functions to be more explicit
... and to have names compatible with lib/sysfs.c

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-11-23 14:58:21 +01:00
Sami Kerola d2b5c8c4fb ipcs: add /proc and /sys path definitions
The necessary proc and sysfs files are tested to be present.  When
information files are missing the ipcs will use obsolted system calls,
and data structures, as fallback.

[kzak@redhat.com: - fix #define _PATH_PROC_IPC_MSG "/proc/sys/kernel/sem" typo]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-11-23 14:47:14 +01:00
Karel Zak 1ef28920f8 lib/ttyutils: add get_terminal_name()
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-11-22 14:40:14 +01:00
Karel Zak 4e76adb0e1 lib/ttyutils: create .c file
Well, now all tty stuff are incline functions in include/ttyutils.h.
It's seems more elegant to create regular lib/ttyutils.c for libcommon
and write test program.

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-11-22 14:26:41 +01:00
Karel Zak cf987d0aa7 lib/consoles: remove global variable consoles
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-11-09 10:06:23 +01:00
Werner Fink 3a08f74f1d lib/consoles: add code to detect all system consoles
Signed-off-by: Werner Fink <werner@suse.de>
2012-11-08 15:55:48 +01:00
Karel Zak f308ec19a7 libmount: add private mnt_get_kernel_cmdline_option()
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-11-08 11:59:36 +01:00
Karel Zak e21e6d265d build-sys: cleanup cpu_set_t usage
- make taskset depend on cpu_set_t
 - make cpuset.c optional for libcommon and lib/path.c

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-11-02 12:07:36 +01:00
Karel Zak a5dc4d2d95 lib/sysfs: add SCSI link functions
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-10-23 12:21:23 +02:00
Karel Zak 23a11c74a6 lib/sysfs: add functions for SCSI host attributes
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-10-23 12:18:57 +02:00
Karel Zak d0f7e5b4a0 include/sysfs: add SCSI host:channel:target:lun support
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-10-23 12:15:58 +02:00
Karel Zak 2a31396a9c include/c: move usleep() fallback to c.h
To make it available everywhere in code.

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-10-22 11:03:09 +02:00
Karel Zak 4ca5163aa4 include/c: remove MAXHOSTNAMELEN macro
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-10-19 16:58:11 +02:00
Karel Zak 1b2aa6293d include/xalloc: add xgethostname()
The new function allocates memory by xalloc() for hostname and
fill in the buffer by gethostname().

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-10-19 16:23:54 +02:00
Sami Kerola e0b6ab5687 include/env: unify indentation
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-10-19 15:07:44 +02:00
Sami Kerola 1ee4dff724 include/c: add get_hostname_max() inline function
Using sysconf(_SC_HOST_NAME_MAX) does not work everywhere.  At such even
header values for hostname length should be preferred, and if nothing
else works guess the maxium being 64 bytes.

Based-on-code-by: Karel Zak <kzak@redhat.com>
CC: Mike Frysinger <vapier@gentoo.org>
References: http://www.spinics.net/lists/util-linux-ng/msg07050.html
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-10-19 14:50:27 +02:00
Ondrej Oprala dfa68ad183 lib/color: add module for work with terminal colors
[kzak@redhat.com: - split from dmesg patch
                  - add more colors]

Signed-off-by: Ondrej Oprala <ooprala@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-10-16 16:39:00 +02:00
Ludwig Nussel 5cf05c7147 mount: losetup: remove obsolete encryption support
kernel cryptoloop is deprecated since ages and support for cryptoloop
in util-linux is incomplete/broken.
- no password hashing
- last 8 bit of key are always set to zero
- no binary keys possible (stops reading key at \n and \0)

In the past some Distros added the above features with patches. So
remove cryptoloop support from util-linux completely to make sure
people won't try using it.

Signed-off-by: Ludwig Nussel <ludwig.nussel@suse.de>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-09-11 10:46:11 +02:00
Karel Zak 778ad369f6 lib/sysfs; add sysfs_partno_to_devno()
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-08-13 22:06:18 +02:00
Milan Broz f5077b5180 lib/strutils: add string_add_to_idarray() - parse and add to id list
Signed-off-by: Milan Broz <mbroz@redhat.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-07-26 16:26:27 +02:00
Sami Kerola d0aa8a446d include: define format to be constant in xasprintf()
Add also format function attribute to add robustness.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-07-26 13:51:24 +02:00
Karel Zak f69b4c5b62 include/optutils: remove unnecessary exclusive_option()
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-07-26 09:27:42 +02:00
Karel Zak 217d20a73c include/optutils: add err_exclusive_options()
This is improved implementation of exclusive_option(). The new
implementation:

  - uses regular struct option to compose error messages
  - relationships between options are described in one const static array
  - the current status is stored in one int array

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-07-26 09:22:35 +02:00
Karel Zak 9199f5cd0a dmesg: add fileback for SEEK_DATA
Reported-by: Bernhard Voelker <mail@bernhard-voelker.de>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-07-24 14:06:25 +02:00
Sami Kerola 01c5b78794 agetty: use configured run state directory
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-07-10 13:00:20 +02:00
Karel Zak 8d398470c0 build-sys: add pager.h to Makemodule.am
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-06-26 20:57:45 +02:00
Karel Zak 8365ed42ac build-sys: convert include/ to module
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-06-26 17:08:57 +02:00
Karel Zak defa0710b6 lib/loopdev: use warn_unused_result forimportant functions
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-06-21 10:40:43 +02:00
Karel Zak 1aae31c048 lib/sysfs: use warn_unused_result for sysfs_init()
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-06-21 08:28:49 +02:00
Sami Kerola 8f77d454a9 include [optutils]: add exclusive_option() inline function
The exclusive_option() will unify how exclusive options are
determined.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-06-17 17:59:58 +02:00
Karel Zak 2fc4a256ce lib/blkdev: return static strings by blkdev_scsi_type_to_name()
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-06-15 13:14:30 +02:00
Karel Zak aa323539cf include/blkdev: cleanup up
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-06-15 13:01:51 +02:00
Karel Zak d5f9b6e5fb Merge branch '2012wk23' of git://github.com/kerolasa/lelux-utiliteetit
* '2012wk23' of git://github.com/kerolasa/lelux-utiliteetit:
  lsblk: use blkdev_scsi_type_to_name()
  blkdev: add blkdev_scsi_type_to_name()
  wipefs: use symbolic value for markup mode
  eject: inform if CD-ROM drive is not ready
  docs: clean up partx.8 manual
  include: fix void pointer arithmetics warnings
  sysfs: fix printf format warnings
  build: fix unused parameter warnings
  build: fix redundant redeclaration warnings
  include: fix spurious list.h warnings
  uuidd: use output redirection which works [checkbashisms]
  blkid: fix realloc memory leak [cppcheck]
  setarch: do not use -1 as array index [cppcheck]
2012-06-15 12:44:17 +02:00
Karel Zak e4062c72d1 losetup: improve -a to report loopdevs < 512 bytes
# ll ~/xxx2
  -rw-r--r-- 1 root root 500 Jun 12 14:30 /root/xxx2

 old version:
  # losetup -a

 new version:
  # losetup -a
  /dev/loop0: [2052]:535312 (/root/xxx2)

The new version scans /sys/block/loopN, kernel >= 2.6.37 is required
otherwise fallback to the original not-so-smart /proc/partitions scan.

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=730266
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-06-12 15:41:47 +02:00
Sami Kerola ba32a9465a blkdev: add blkdev_scsi_type_to_name()
Add a function, and necessary symbols, to convert scsi type id's
to name strings.

Reference: http://permalink.gmane.org/gmane.linux.utilities.util-linux-ng/5994
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-06-11 22:06:06 +02:00
Sami Kerola 667d375ea8 include: fix void pointer arithmetics warnings
all-io.h:18:9: warning: pointer of type 'void *' used in arithmetic [-pedantic]
all-io.h:38:9: warning: pointer of type 'void *' used in arithmetic [-pedantic]

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-06-11 19:51:35 +02:00
Sami Kerola c42206e4a7 include: fix spurious list.h warnings
include/list.h:224:17: warning: ISO C forbids omitting the middle term of a ?: expression [-pedantic]
include/list.h:255:19: warning: ISO C forbids omitting the middle term of a ?: expression [-pedantic]

Compilation warned about that at least 110 times.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-06-11 19:51:35 +02:00
Karel Zak abb53be5cb Merge branch '2012wk22' of git://github.com/kerolasa/lelux-utiliteetit
* '2012wk22' of git://github.com/kerolasa/lelux-utiliteetit:
  docs: clean up getopt.1 manual
  docs: clean up dmesg.1 manual
  docs: clean up chcpu.8 manual
  fileutils: xmkstemp() interface change
  docs: fix all man page groff warnings
  tools: add checkmans.sh
  docs: clean up wdctl.8 manual
  docs: clean up login.1 manual
  login: allow TTYGROUP name begin by number
  build-sys: add su executable to .gitignore
  logindefs: change getlogindefs_num() to return unsigned long

Conflicts:
	login-utils/su.c
	sys-utils/dmesg.1
2012-06-05 16:57:01 +02:00
Karel Zak 90af3fe39b inclide/env: innclude c.h, remove _() macro from xsetenv()
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-06-05 15:44:12 +02:00
Ludwig Nussel e557efdedd su: introduce xsetenv globally
Signed-off-by: Ludwig Nussel <ludwig.nussel@suse.de>
2012-06-05 15:16:18 +02:00
maximilian attems ab65d635c8 lib/strutils: circumvent missing localeconv()
Add stub too nls.h, include it instead of locale.h.
Code in strutils handles already returned NULL.

Signed-off-by: maximilian attems <max@stro.at>
2012-06-05 14:54:12 +02:00
Dave Reisner 3c4fed097d fileutils: xmkstemp() interface change
We can not let the user control where TMPDIR is for this tempfile.
This will be where we write the updated passwd file, and must be
capable of being moved atomically with rename(2).  Therefore, it
cannot be on a different device, or setpwnam() and vipw/vigr programs
will invariably fail with EXDEV.

Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-06-02 20:29:12 +02:00
Karel Zak 3a9c3f3fb7 include/c: move fallback for MAXHOSTNAMELEN to c.h
Reported-by: Thomas Schwinge <thomas@codesourcery.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-05-29 10:08:25 +02:00
maximilian attems ae278c88cf include: [c.h] protect container_of
fixes lots of warning noise:
../../../include/c.h:112:0: warning: "container_of" redefined [enabled
by default]
/usr/lib/klibc/include/stddef.h:52:0: note: this is the location of the
previous definition

Signed-off-by: maximilian attems <max@stro.at>
2012-05-23 10:31:07 +02:00
Karel Zak b776c15e8a lib/tt: export tt_fputs_{quoted,nonblank} function
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-05-22 13:27:46 +02:00
Karel Zak 551dae405a lib/strutils: create type specific strtoxx_or_err()
We need [un]signed int ([u]int32_t) on many places. It's also more
readable and robust to use uintXX_t types than for example "long long".

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-05-15 17:40:03 +02:00
Karel Zak 7e9a9af14f include/ttyutils: more robust get_terminal_width()
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-05-15 11:58:20 +02:00
Petr Uzel e872e32064 include: move get_terminal_width() to ttyutils.h
Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2012-05-15 11:32:53 +02:00
Petr Uzel f80e9bc30a libuuid: move read_all to include/all-io.h
Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2012-05-15 11:32:36 +02:00
Petr Uzel e12c9866b5 include: rename writeall.h to all-io.h
Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2012-05-15 11:32:27 +02:00
Petr Uzel c544aa2c25 libuuid: avoid double open and leaking fd (reworked)
This reverts commit 6126f7a53c
and fixes the double open and leaking descriptor in a different way,
that is by using newly introduced function 'have_random_source()'
to check whether good random source is available while deciding
which uuid type to generate (random/time).

This is better than calling random_get_fd() twice, passing the file
descriptor down the stack and reusing it in next call to
random_get_fd().

Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2012-05-10 11:43:49 +02:00
Petr Uzel 6126f7a53c libuuid: avoid double open and leaking descriptor
We are opening /dev/urandom twice in uuid_generate(): first to check if
the file is available and then later __uuid_generate_random() again to
actually get the random data. Moreover, descriptor from the first open
is leaking.

Fix by passign the descriptor down the stack and reusing it there.

References: http://marc.info/?l=util-linux-ng&m=133406051131131&w=2

Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2012-05-04 15:14:24 +02:00
Karel Zak 5ef167714e lib/strutils: add string_to_bitmask()
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-05-03 17:28:44 +02:00
Karel Zak 4a695b1a8b include/tt: remove obsolete stuff
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-05-03 15:25:23 +02:00
Sami Kerola 33a0de92e9 wdctl: align with other util-linux commands
* Add watchdog device path to pathnames.h
* Check output stream status at exit.
* Adjust usage() notation to follow howto file.
* Retire numeric return value.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-05-03 15:00:07 +02:00
Karel Zak 1f13d6fcd0 Merge branch '2012wk17' of https://github.com/kerolasa/lelux-utiliteetit
* '2012wk17' of https://github.com/kerolasa/lelux-utiliteetit:
  build-sys: determine availability of __fpending()
2012-05-02 09:34:39 +02:00
Petr Uzel 7f64f9bde7 build-sys: add ttyutils.h to dist
Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2012-04-27 12:30:37 +02:00
Petr Uzel 95c46edd67 build-sys: add randutils.h to dist
Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2012-04-27 12:30:34 +02:00
Karel Zak 95387b6696 lib/mangle: cleanup, add unhexmangle
* use strchr() rather than for()
 * small refactoring in mangle code
 * add un-hex-mangle

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-04-26 09:17:44 +02:00
Sami Kerola 78288764e4 build-sys: determine availability of __fpending()
Needed to for making Cygwin more possible.

Reference: http://comments.gmane.org/gmane.linux.utilities.util-linux-ng/5656
Reported-by: Bernhard Voelker <bernhard.voelker@siemens-enterprise.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-04-23 14:26:23 +02:00
Karel Zak be92327e71 lib/fileutils: add get_fd_tabsize()
as a fallback for the function getdtablesize()

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-04-23 13:58:39 +02:00
Davidlohr Bueso 35717a57ac lib: add pager functionality
When some program' output exceeds the terminal's dimensions, it is a nice
feature to call a pager that acts as calling 'less' to allow better user
navigation. This patch adds this functionality, based on what perf and git
have (ie: git log).

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
2012-04-23 11:52:39 +02:00
Karel Zak fc387ee14c libblkid: add support for PARTUUID= and PARTLABEL=
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-04-19 14:33:49 +02:00
Karel Zak 6259c257d8 Merge branch 'close_stream' of git://github.com/kerolasa/lelux-utiliteetit
* 'close_stream' of git://github.com/kerolasa/lelux-utiliteetit:
  disk-utils: verify writing to streams was successful
  fdisk: verify writing to streams was successful
  getopt: verify writing to streams was successful
  hwclock: verify writing to streams was successful
  login-utils: verify writing to streams was successful
  misc-utils: verify writing to streams was successful
  mount: verify writing to streams was successful
  partx: verify writing to streams was successful
  schedutils: verify writing to streams was successful
  sys-utils: verify writing to streams was successful
  term-utils: verify writing to streams was successful
  text-utils: verify writing to streams was successful
  include: add stream error checking facility

Conflicts:
	fdisk/fdisk.c
2012-04-11 12:37:59 +02:00
Davidlohr Bueso fe72459e41 lib: random utilities
Add a random number(s) generator specific file. The intial functions are based
on what libuuid provide. I did some modifications like avoid WIN32 checks - this
is util-LINUX.

[kzak@redhat.com: - move jrand_seed to lib/randutils.c
                  - use TLS for jrand_seed (like original code from libuuid)
                  - use size_t for buffer sizes
                  - add close() to random_get_bytes]

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-04-10 13:12:43 +02:00
Davidlohr Bueso 64128b705c fdisk: move kernel geometry into blkdev
This is a more generic place for this ioctl.

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
2012-04-10 12:21:16 +02:00
Karel Zak 4f469e588d Merge branch 'eject'
* eject: (47 commits)
  tests: use eject --force
  eject: use BUILD_EJECT, move to sys-utils
  eject: clean up usage()
  eject: clean up man page
  eject: add --force option
  eject: check for hotplug/removable attribute
  eject: remove obsolete code, use EXIT_* macros
  tests: add umount-by-eject tests
  eject: improve work with partitioned devices
  lib/sysfs: improve sysfs_is_partition_dirent()
  eject: call umount <mountpoint> rather than <device>
  eject: use libmount to detect if cdrom is mounted
  eject: make the code robust
  eject: use SG_IO ioctl for scsi
  eject: support CDIOCEJECT ioctl
  eject: new close_tray code from Fedora
  eject: new auto_eject code from Fedora
  eject: add -X from Fedora
  eject: add --manualeject from fedora
  eject: clean up devname usage
  ...
2012-04-05 15:58:28 +02:00
Sami Kerola 302e423dc1 include: add stream error checking facility
The close_stream() is copied from GNU lib.  Inspiration to do this is
talk by Jim Meyering - Goodbye World! The perils of relying on output
streams in C.

Reference: http://www.irill.org/events/ghm-gnu-hackers-meeting/videos/jim-meyering-goodbye-world-the-perils-of-relying-on-output-streams-in-c
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-04-04 19:45:37 +02:00
Karel Zak 6219c25ecb lib/loopdev: more robust initialization
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-04-02 17:33:41 +02:00
Sami Kerola 16d8a9c967 raw: use pathnames.h for file locations
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-03-30 16:48:12 +02:00
Karel Zak a99c913091 lib/strutils: add strtosize_or_err, clean up
* add strtosize_or_err(), we use strtosize() + err() on many places

 * add STRTOXX_EXIT_CODE to overwrite the default EXIT_FAILURE

 * remove else-after-noreturn (e.g. if (foo) err(...); else err(...))

 * clean up indent...

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-03-30 16:11:31 +02:00
Karel Zak 1abc33266f eject: add -X from Fedora
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-03-27 17:38:28 +02:00
Michal Luscon 3b66f48e23 sysfs: move blkid_devno_to_wholedisk to sysfs_devno_to_wholedisk
Signed-off-by: Michal Luscon <mluscon@redhat.com>
2012-03-27 13:16:19 +02:00
Karel Zak a36e9a9408 build-sys: move obsolete lib/fsprobe to mount/
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-03-27 12:23:07 +02:00
Karel Zak 70b604b827 include/exitcodes: clean up names, add _EX_ suffix
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-03-20 11:22:08 +01:00
Karel Zak e50ad21838 include/exitcodes: add FSCK_DESTRUCT alias
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-03-20 11:22:08 +01:00
Dave Reisner 0b6198ec07 include/ttyutils.h: add include guards
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
2012-03-20 09:53:48 +01:00
Sami Kerola 7961acce46 fileutils: differentiate xmkstemp and xfmkstemp
Let developer to choose, case by case, what sort of return value is
best in her code.  The xmkstemp() is for users who want file
descriptor as return value of the function, xfmkstemp() will return
FILE pointer.

Proposed-By: Karel Zak <kzak@redhat.com>
CC: Davidlohr Bueso <dave@gnu.org>
Reference: http://marc.info/?l=util-linux-ng&m=133129570124003&w=2
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-03-18 14:29:38 +01:00
Sami Kerola eeb31db9b9 include: add asprintf wrapper
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-03-18 14:28:05 +01:00
Sami Kerola 6a91958bf8 pathnames: clean up various user database paths
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-03-18 14:28:05 +01:00
Sami Kerola 6b79eb38ba lib: add fileutils function collection
The fileutils contains xmkstemp function will create temporary file
safe and reusable manner.

Reference: http://www.dwheeler.com/secure-programs/Secure-Programs-HOWTO.html#TEMPORARY-FILES
CC: Davidlohr Bueso <dave@gnu.org>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-03-18 14:28:04 +01:00
Sami Kerola c900336d8b chsh: use pathnames.h for paths
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-03-18 14:28:04 +01:00
Karel Zak 879a7ab470 agetty: move vc initialization to ttyutils.h
... to make the code usable for sulogin.

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-03-12 14:39:32 +01:00
Karel Zak 7293e97a42 libmount: fix "already mounted" detection on systems with mtab
For systems with regular mtab the fs->root should be ignored in
"already mounted" heuristic.

Reported-by: Matt Burgess <matthew@linuxfromscratch.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-03-09 13:11:24 +01:00
Karel Zak 4c5bbc5d7e libblkid: fix sysfs context usage
Reported-by: Elan Ruusamäe <glen@delfi.ee>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-03-06 11:24:54 +01:00
Davidlohr Bueso 79b1280725 include: add /proc/locks path to pathnames
Signed-off-by: Davidlohr Bueso <dave@gnu.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-02-29 12:27:41 +01:00
Sami Kerola f06b43285d build-sys: enhance readability of the autotools files
Several horizontal lists are turned to vertical, and sorted to
alphabetical order. Additionally spaces are converted to tabs where
ever possible.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-02-28 13:29:35 +01:00
Karel Zak bb4f071520 lib/fsprobe: mar this internal API as deprecated
The fsprobe has been added many years ago to provide unified API for

	- built-in libblkid
	- e2fsprogs libblkid
	- udev libvolume_id

these all is unnecessary as we strictly depends on built-in libblkid.

Signed-off-by: Karel Zak <kzak@redhat.com>
2012-02-13 15:10:55 +01:00
Karel Zak 497d2ce7ea mount: (new) share exit codes by include/exitcodes.h
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-01-23 10:55:35 +01:00
Karel Zak aa1f95c3d0 losetup: make xgetpass more robust
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-01-17 17:02:34 +01:00
Karel Zak 6c503d5916 losetup: move xgetpass() to lib/xgetpass.c
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-01-11 15:17:06 +01:00
Karel Zak 916bf85e62 losetup: add --partscan option
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-01-09 23:28:50 +01:00
Karel Zak 59d749c331 loopdev: support LO_FLAGS_PARTSCAN flag (kernel 3.2)
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-01-09 23:28:43 +01:00
Davidlohr Bueso 8150beac7c blkdev: add is_blkdev function
We should have the most basic of checks in this library to see whether or not a block device is being used.

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
2012-01-05 17:09:27 +01:00
Davidlohr Bueso 3b622ddd72 fdisk: use CDROM_GET_CAPABILITY ioctl
And replace the current archaic logic of is_ide_cdrom_or_tape().

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
2012-01-02 13:43:06 +01:00
Karel Zak c7e0925def losetup: rewrite loop setup
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-12-22 12:19:38 +01:00
Karel Zak 6c224de18b lib,loopdev: add missing functions
- improve loop_info usage (don't call ioctl more than once)
 - add functions to get devno and inode of the backing file
 - add function for compare any file with backing file by devno + inode
   or by filename

Signed-off-by: Karel Zak <kzak@redhat.com>
2011-12-22 12:19:38 +01:00
Davidlohr Bueso 5b9df0280a lists: add list sorting routine
We need a list sorting function, just to mention one example user that could
benefit is the lib/tt code to sort columns.

This patch adds list_sort() which uses the Merge Sort algorithm, behaving
nicely in O(nlog(n)), heavily based on the kernel's implementation[1].  The
private data (void *priv) passed to the comparison function as been removed to
adopt a qsort(3)-like syntax, and IMHO we don't really need it anyways.

[1]: http://git.kernel.org/?p=linux/kernel/git/torvalds/linux.git;a=blob;f=lib/list_sort.c;h=d7325c6b103f0be078ff3672c35c468ed35738f1;hb=HEAD

[kzak@redhat.com: - use size_t in list_sort()]

Signed-off-by: Davidlohr Bueso <dave@gnu.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-12-16 12:37:07 +01:00
Sami Kerola fbc333fec0 build-sys: check HAVE_ definitions with #ifdef [smatch scan]
Fix to `warning: undefined preprocessor identifier' messages.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-12-02 18:21:46 +01:00
Sami Kerola 8a3f94862c build-sys: add missing headers to dist
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-12-02 18:21:42 +01:00
Karel Zak 914c8b7102 Merge branch 'login-utils' of https://github.com/kerolasa/lelux-utiliteetit
* 'login-utils' of https://github.com/kerolasa/lelux-utiliteetit: (23 commits)
  last: fix few compiler warnings
  setpwnam: remove non-ANSI definitions [smatch scan]
  last: possible buffer overflow fixed [smatch scan]
  vipw: fix coding style
  setpwnam: fix coding style
  selinux_utils: fix coding style
  newgrp: fix coding style
  logindefs: fix coding style
  islocal: fix coding style
  chsh: fix coding style
  chfn: fix coding style
  chfn, setpwnam: let config.h be in control of extensions in use
  chfn, chsh: new file pamfail.h for error printing
  chsh: build bug: do not override config.h definition
  chfn, chsh, setpwnam: get true/false from stdbool.h
  login: add version printing option
  newgrp: add version and help options
  vipw: stop printing non-sense version string
  vipw: use libc error printing facilities
  chsh: use libc error printing facilities
  ...
2011-11-29 19:02:42 +01:00
Karel Zak 732a631126 include,optutils: add option_to_longopt()
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-11-29 18:21:49 +01:00
Sami Kerola 57b35f3ba7 chfn, chsh: new file pamfail.h for error printing
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-11-29 17:57:39 +01:00
Karel Zak 1208915521 lib,match: split match_fstype() from libmount
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-11-15 15:17:19 +01:00
Karel Zak 7aa69cf2e3 lib,tt: add TT_FL_NOEXTREMES
If you mark a column with TT_FL_NOEXTREMES flag then extremely
large fields will no have effect to column width. Foe example:

 without the TT_FL_NOEXTREMES flag for the 'AAA' column:

	 AAA         BBB CCC  DDD
	 aa          bbb ccc  ddd
	 aaaaaaaaaaa  bb ccc  ddd
	 aa           bb ccc  ddd
	 aa           bb ccc  ddd

 with the flags:

	 AAA  BBB CCC  DDD
	 aa   bbb ccc  dddddddddd
	 aaaaaaaaaaa
	       bb ccc  dddddddd
	 aa    bb ccc  dddddd
	 aa    bb ccc  ddddddddd

Signed-off-by: Karel Zak <kzak@redhat.com>
2011-11-10 12:39:02 +01:00
Petr Uzel b106d05238 libmount: ignore tailing slash in netfs source paths
Addresses: https://bugzilla.novell.com/show_bug.cgi?id=728480
Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-11-08 16:25:01 +01:00
Karel Zak 0b14bf7af1 lib,loopdev: add LOOP_CTL_GET_FREE support
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-11-07 16:45:11 +01:00
Karel Zak c82d9c977c login: add login.defs code and tests
The new logindefs.c file contains /etc/login.defs parser and functions
for searching in the list of the login default variables. The patch
also contains a new regression test for the code.

Based on pam_login-4.0 from Suse.

Signed-off-by: Karel Zak <kzak@redhat.com>
2011-10-26 23:17:17 +02:00