Commit Graph

10449 Commits

Author SHA1 Message Date
Sami Kerola cf582a2e86
build-sys: test functions does not return void
Found using scan-build.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2016-04-19 21:27:54 +01:00
Karel Zak 1bd62f72d8 libblkid: fix mistake in debug message
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-04-19 12:45:00 +02:00
Karel Zak bfebe74e3b libblkid: reduce probing area for crazy CDROMs
Linux kernel reports devices greater than area readable by read(2).
The readable area is usually 2-3 CD blocks smaller (CD block is
2048-bytes) than size returned by BLKGETSIZE. This patch checks for
this issues to avoid I/O errors in probing functions.

Reported-by: Thomas Schmitt <scdbackup@gmx.net>
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-04-19 12:39:05 +02:00
Petr Uzel 445e6b1ec8 libblkid: make blkid_do_wipe() work with probes with offset
When a probe is created with an offset, e.g. via
blkid_probe_set_device(), this offset is correctly used when looking for
the signatures, but is not respected by blkid_do_wipe() function.
Therefore the signature is removed from an invalid location.

Usecase: Wiping signatures from an area on the block device where
partition is to be created (but as it does not exist yet, there's no
device node for it and probe on the whole block device has to be used
with correct offset and length).

Reproducer:
======================== wiper.c ===========================

const char *dev;
unsigned long offset;
unsigned long size;

int main(int argc, char** argv) {

        if (argc != 4) {
                printf("usage: wiper dev offset size\n");
                exit(1);
        }

        dev = argv[1];
        offset = strtoull(argv[2], NULL, 10);
        size = strtoull(argv[3], NULL, 10);

        printf("dev=%s, off=%llu, size=%llu\n", dev, offset, size);

        int fd = open (dev, O_RDWR);
        if (fd == -1) {
                perror("open");
                exit(1);
        }

        blkid_loff_t wipe_offset = offset * SECTOR_SIZE;
        blkid_loff_t wipe_size = size * SECTOR_SIZE;

        int ret;

        blkid_probe pr;
        pr = blkid_new_probe();
        if (!pr)
                return 0;
        ret = blkid_probe_set_device(pr, fd, wipe_offset, wipe_size);
        ret = blkid_probe_enable_superblocks(pr, 1);
        ret = blkid_probe_set_superblocks_flags(pr, BLKID_SUBLKS_MAGIC);

        while (blkid_do_probe(pr) == 0) {
                ret = blkid_do_wipe(pr, 0);
        }

        blkid_free_probe(pr);
        close(fd);
}
======================== wiper.c ===========================

Steps to reproduce:
modprobe scsi_debug
parted -s /dev/sdX mklabel gpt
parted -s /dev/sdX mkpart first 2048s 4095s
mkfs.ext2 /dev/sdX1

wipefs -np /dev/sdX1

./wiper /dev/sdX1 2048 2048

Actual result: wiper gets into endless loop, because
blkid_do_wipe() wipes at wrong location (1080), leaving the signature
on /dev/sdc1. So it is again found by blkid_do_probe(), and so on.

Expected result: wiper clears the ext2 signature at offset 1049656(=1080+2048*512).

Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2016-04-18 19:53:51 +02:00
Karel Zak 7997468484 pylibmount: include c.h
... for sys/sysmacros.h and major() and minor() macros.

Reported-by: Mike Frysinger <vapier@gentoo.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-04-18 13:19:12 +02:00
Yuriy M. Kaminskiy c79657ca85 losetup: fix outdated comment
From abb2a420924c792be33aa3ed825b1348ea7d51a9 Mon Sep 17 00:00:00 2001
From: "Yuriy M. Kaminskiy" <yumkam@gmail.com>
Date: Wed, 13 Apr 2016 17:30:10 +0300
Subject: [PATCH] losetup: fix outdated comment

--direct-io argument was made optional by
f98d9641a3, but this comment was not
updated accordingly

Signed-off-by: Yuriy M. Kaminskiy <yumkam@gmail.com>
2016-04-18 11:04:16 +02:00
Karel Zak 71d5088f05 Merge branch '2016wk15' of git://github.com/kerolasa/lelux-utiliteetit
* '2016wk15' of git://github.com/kerolasa/lelux-utiliteetit:
  mount: try to tell what mount was doing when it failed
  dmesg: --notime should not suppress --show-delta
  script: check status of writes when closing outputs
  script: avoid trying fclose(NULL)
  sulogin: make fopen O_CLOEXEC specifier usage portable
  script: close file descriptors on exec
  docs: optinal option arguments should be long-only
2016-04-18 11:01:26 +02:00
Lubomir Rintel d97dc0ee25 mkswap: tolerate ENOTSUP when failing to relabel
It might be that the underlying filesystem just doesn't support SELinux
labeling. This fixes creating swap on vfat live media:

  # livecd-iso-to-disk.sh --msdos --swap-size-mb 666 ...

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
2016-04-18 10:51:28 +02:00
Sami Kerola 592fe0175f
mount: try to tell what mount was doing when it failed
Earlier output did not give enough information to system admin to fix an
issue in /etc/fstab effectively.

$ sudo mount -a
mount: mount(2) failed: No such file or directory

Addresses: https://bugs.launchpad.net/bugs/1557145
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2016-04-16 23:09:27 +01:00
Sami Kerola fdba1750fc
dmesg: --notime should not suppress --show-delta
The --show-delta is off by default, which means it can be only on when user
has requested to see these time stamps.  The --notime option should not turn
the delta outputing off, because then option order matters and no-one wants
that.  Example of the old output:

$ dmesg --notime --show-delta | sed -n 's/ version.*//p; q'
[<    0.000000>] Linux
$ dmesg --show-delta --notime | sed -n 's/ version.*//p; q'
Linux

Addresses: https://bugs.launchpad.net/bugs/1544595
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2016-04-16 23:09:26 +01:00
Sami Kerola 22d5cc87e6
script: check status of writes when closing outputs
This should make possible output issues more obvious, for example when a
disk will get full.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2016-04-16 23:09:26 +01:00
Sami Kerola 4b0b416acb
script: avoid trying fclose(NULL)
Here is a one-liner to reproduce the issue.

$ mkdir example && cd example && chmod 0500 . && script
Script started, file is typescript
script: cannot open typescript: Permission denied
                                                 Script done, file is typescript
Segmentation fault (core dumped)

Addresses: https://bugs.launchpad.net/bugs/1537518
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2016-04-16 23:09:26 +01:00
Sami Kerola 400423824a
sulogin: make fopen O_CLOEXEC specifier usage portable
The close at exit specifier "e" is glibc extension, so use it only if when
the extension is available.

Proposed-by: Ruediger Meier <sweet_f_a@gmx.de>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2016-04-16 23:09:26 +01:00
Sami Kerola 760e5e682d
script: close file descriptors on exec
The commands spawned from script(1) will never need access various file
descriptors the script(1) is using.

Reviewed-by: Ruediger Meier <sweet_f_a@gmx.de>
Reviewed-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2016-04-16 23:09:26 +01:00
Sami Kerola 326c5c93b9
docs: optinal option arguments should be long-only
Deprecate adding new short optional option arguments.  They are problematic.

Proposed-by: Ruediger Meier <sweet_f_a@gmx.de>
Acked-by: Karel Zak <kzak@redhat.com>
Reviewed-by: Benno Schulenberg <bensberg@justemail.net>
Reference: https://lists.gnu.org/archive/html/coreutils/2012-11/msg00004.html
Reference: http://marc.info/?l=util-linux-ng&m=146062997618853&w=2
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2016-04-16 23:08:18 +01:00
Karel Zak a772281dff libmount: make kernel_fs_postparse() more robust
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-04-15 14:48:29 +02:00
Karel Zak 4b85aef355 libmount: fix mnt_table_parse_stream() logic
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-04-15 14:30:43 +02:00
Karel Zak edeb6223fe tests: make tests more portable due to mtab
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-04-15 14:10:23 +02:00
Karel Zak b529694f61 libmount: fix mnt_table_parse_mtab() logic
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-04-15 12:05:55 +02:00
Karel Zak 3904d87636 tests: remove USE_LIBMOUNT_FORCE_MOUNTINFO
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-04-15 11:29:22 +02:00
Karel Zak 6c820514f9 umount: add note about FS names differences to the man page
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1327209
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-04-15 10:47:12 +02:00
Karel Zak e778642a9e libmount: don't support /etc/mtab by default
The file mtab is evil and already unused by mainstream distributions.

Now libmount is able to detect mtab->/proc/mounts and use
/proc/self/mountinfo if necessary. This heuristic seems overkill in
many cases. It's also dangerous on systems where mountinfo is strongly
required (systemd based distros).

This patch #ifdefs mtab code and forces libmount to always use
/proc/self/mountinfo.

The new configure option --enable-libmount-support-mtab is necessary
to enable old behavior to support mtab.

Signed-off-by: Karel Zak <kzak@redhat.com>
2016-04-14 14:26:54 +02:00
Ruediger Meier 3e584e8576 build-sys: add --enable-libuuid-force-uuidd
To build libuuid with uuidd support even though the daemon is
disabled (--disable-uuidd).

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-04-14 12:56:12 +02:00
Karel Zak 949e5c9600 wipefs: force GPT detection
The library libblkid (as well as fdisks) requires protective MBR when
probe for GPT by default.  This is unnecessary for wipefs where we're
more promiscuous and we want to delete as much as possible. This patch
enables BLKID_PARTS_FORCE_GPT for wipefs.

Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1326474
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-04-13 14:41:47 +02:00
Karel Zak b6abdc22f4 build-sys: remove obsolete comment
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-04-13 12:29:16 +02:00
Ruediger Meier c3f323cb2c tests: don't depend on GNU md5sum
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-04-13 12:29:16 +02:00
Ruediger Meier c8d211478f tests: test_md5 prints md5sum only
We want to to use it for other tests without depending on
gnu md5sum and without cut or awk.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-04-13 12:29:16 +02:00
Sami Kerola 2e31d1c3a5 chrt: validate priority before trying to use it
Earlier message:

$ chrt -i 1 ls
chrt: failed to set pid 0's policy: Invalid argument

basically told 'something failed', while the new one tries to be more
helpful.

$ chrt -i 1 ls
chrt: unsupported priority value for the policy: 1: see --max for valid range

Addresses: https://bugs.debian.org/791707
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2016-04-13 12:29:16 +02:00
Sami Kerola 962a7dc3b0 colcrt: avoid the command getting hung [afl]
Some inputs make getwc(3) not to progress file descriptor and neither to
report EILSEQ.  Detect such situation and skip the bad input.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2016-04-13 12:29:16 +02:00
Karel Zak 2238214ddc libmount: try absolute target before canonicalize
The path canonicalization is expensive and in many cases unwanted due
to problems with readlink() on unreachable NFS and automounters.

This patch add a possibility to search also by $(CWD)/<path> if the
<path> is relative to reduce number of situation when we convert the
path to the canonical absolute path.

The common use-case:

	# cd /some/long/path
	# umount ./mountpoint

old version:

15543: libmount:      TAB: [0x560a99a54230]: lookup TARGET: './test'
15543: libmount:    CACHE: [0x560a99a54290]: canonicalize path ./test
15543: libmount:    CACHE: [0x560a99a54290]: add entry [ 1] (path): /mnt/test: ./test
15543: libmount:      TAB: [0x560a99a54230]: lookup canonical TARGET: '/mnt/test'
15543: libmount:      CXT: [0x560a99a54050]: umount fs: /mnt/test

new version:

15597: libmount:      TAB: [0xabf230]: lookup TARGET: './test'
15597: libmount:      TAB: [0xabf230]: lookup absolute TARGET: '/mnt/test'
15597: libmount:      CXT: [0xabf050]: umount fs: /mnt/test

Signed-off-by: Karel Zak <kzak@redhat.com>
2016-04-13 12:29:16 +02:00
Karel Zak b2bff06661 script: use empty-slave heuristic more carefully
script(1) waits for empty slave FD (shell stdin) before it writes to
master. This feature has been intorduiced by 54c6611d6f
to avoid misbehavior when we need to send EOF to the shell.

Unfortunately, this feature has been used all time for all messages.
This is wrong because command in the session (or shell) may ignore
stdin at all and wait forever in busy loop is really bad idea. Test
case:

 script /dev/null
 tailf /etc/passwd
 <enter>
 <enter>

... script process taking 100% CPU.

This patch forces script to use empty-stave detection only when we
need to write EOF. The busy loop has been modified to use nanosleep
and it does not wait forever...

Addresses: http://bugs.debian.org/820843
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-04-13 11:52:43 +02:00
Karel Zak 44338f7fe6 build-sys: release++ (v2.28)
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-04-12 12:33:03 +02:00
Karel Zak 6ac8cab4ce docs: update v2.28-ReleaseNotes
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-04-12 12:31:56 +02:00
Karel Zak ac920791f3 docs: update AUTHORS file
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-04-12 12:30:40 +02:00
Karel Zak 98db6bb539 po: merge changes
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-04-12 12:29:25 +02:00
Yuri Chornoivan de61006a13 po: update uk.po (from translationproject.org) 2016-04-12 12:13:51 +02:00
Sebastian Rasmussen bca082fa25 po: update sv.po (from translationproject.org) 2016-04-12 12:13:51 +02:00
Rafael Fontenelle c9c2e8c473 po: update pt_BR.po (from translationproject.org) 2016-04-12 12:13:51 +02:00
Jakub Bogusz aee73e18ad po: update pl.po (from translationproject.org) 2016-04-12 12:13:51 +02:00
Benno Schulenberg c19b269666 po: update nl.po (from translationproject.org) 2016-04-12 12:13:51 +02:00
Takeshi Hamasaki 98ea3d6c0a po: update ja.po (from translationproject.org) 2016-04-12 12:13:51 +02:00
Antonio Ceballos Roa 167b0f8625 po: update es.po (from translationproject.org) 2016-04-12 12:13:51 +02:00
Philipp Thomas d044dd791c po: update de.po (from translationproject.org) 2016-04-12 12:13:50 +02:00
Petr Písař 65650eca4d po: update cs.po (from translationproject.org) 2016-04-12 12:13:50 +02:00
Mike Frysinger 801afcb09b build-sys: fix cap-ng configure flag handling
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
2016-04-12 11:33:15 +02:00
Ruediger Meier 50e6f15bb3 build-sys: add --disable-logger and --disable-lslogins
Now we are able to disable all programs which have systemd/journald
support. This feature is needed by openSUSE packagers who are building
util-linux in 2 stages to avoid build cycles.

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-04-06 13:46:34 +02:00
Ruediger Meier bedd731163 tests: remove deprecated md5sum based fdisk/bsd test
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-04-06 13:46:34 +02:00
Ruediger Meier 1b7be556e5 tests: fix fdisk/bsd for hppa
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-04-06 13:46:34 +02:00
Ruediger Meier 2635b49721 tests: add fdisk/bsd hexdump for alpha
Taken from Debian build logs:
https://buildd.debian.org/status/fetch.php?pkg=util-linux&arch=alpha&ver=2.28~rc2-1&stamp=1459443555

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-04-06 13:46:34 +02:00
Kaligule 7d85a7e966 rename: add example to the man page
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-04-06 13:43:57 +02:00