Dave Reisner [Sun, 13 May 2012 19:14:49 +0000 (15:14 -0400)]
lib/mangle: check for end of string on every iteration
Checking for the null byte at the end of the string only conditionally
leads to segfaults, evidenced by mount helpers crashing on writes to
/run/mount/utab. Simply check for the null on each iteration, and append
a null byte to the mangled string before breaking.
Signed-off-by: Dave Reisner <dreisner@archlinux.org>
Petr Uzel [Sun, 13 May 2012 11:57:46 +0000 (13:57 +0200)]
rev: mention tac(1) in 'SEE ALSO' man page section
Cc: James R. Van Zandt <jrv@debian.org>
From: James R. Van Zandt <jrv@debian.org>
Addresses: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=568709 Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
Petr Uzel [Sun, 13 May 2012 11:44:32 +0000 (13:44 +0200)]
mkswap: improve diagnostics message if the device is mounted
Currently, attempt to create swap on mounted partition results
with "/dev/sdXy: Device or resource busy" message being printed.
Change this to explicitly telling the user that the device is mounted.
Petr Uzel [Sun, 13 May 2012 11:44:31 +0000 (13:44 +0200)]
mkswap: allow creating swap on /dev/hd[ab]
Currently, mkswap does not allow swap to be created on /dev/hda and
/dev/hdb. There is no reason why /dev/hda and /dev/hdb should be treated
differently.
Addresses: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=491021 Cc: Russell Coker <russell@coker.com.au> Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
Jeremy Huntwork [Sun, 13 May 2012 16:31:48 +0000 (16:31 +0000)]
Remove use of __P. Its intended usage was to support pre-ANSI C compilers, but that is not even possible with the modern-day codebase. Moreover, it breaks compiling on libcs that do not define this legacy implementation-internal macro.
Petr Uzel [Sun, 6 May 2012 19:55:53 +0000 (21:55 +0200)]
libuuid: avoid double open and leaking fd (reworked)
This reverts commit 6126f7a53c57485a9a29ddd772765695f23c92e6
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().
Davidlohr Bueso [Sun, 6 May 2012 12:10:25 +0000 (14:10 +0200)]
fdisk: sgi: abort on HDIO_GETGEO failure
When the HDIO_GETGEO ioctl fails on non IRIX/MIPS platforms (ie: inappropriate
ioctl for device) the variables that describe the geometry are compromissed.
One clear example is a division by 0 bug because the cylinder size is 0 is
verify_sgi():
$> fdisk sgi.img
Welcome to fdisk (util-linux 2.21.392-4b1c).
...
Command (m for help): x
Expert command (m for help): g
Building a new SGI disklabel.
Partition 11 of type SGI volume and of size 7.9 MiB is set
Floating point exception
Fix this by simply exiting the program instead of leaving it in a vulnerable
state.
Signed-off-by: Davidlohr Bueso <dave@gnu.org> Signed-off-by: Karel Zak <kzak@redhat.com>
Davidlohr Bueso [Sun, 6 May 2012 12:10:18 +0000 (14:10 +0200)]
fdisk: move DOS new/add partition code
Since this is DOS specific logic, it belongs in its own label file.
Additionally, a dos_new_partition() function is created that asks the user for
partition type and then calls the actual dos_add_partition().
This patch passed fdisk regression tests, builds without problems and it was
locally tested against adding and removing DOS partitions.
Davidlohr Bueso [Fri, 4 May 2012 11:35:32 +0000 (13:35 +0200)]
fdisk: fix segfault on bsd label
Commit 8db8295d824cd0c8cba9385e4635d6e311d69d3f added a regression that causes the program to crash when
touching the partition structure (pte) for BSD/OSF labels. Since DOS has its own initialization function,
allow BSD labels to use it as well.
Steps to reproduce:
$> fdisk bsd.img (obtained from blkid regression test files)
Command (m for help): p
...
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Petr Uzel [Thu, 3 May 2012 19:02:01 +0000 (21:02 +0200)]
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.
Petr Uzel [Thu, 3 May 2012 19:01:59 +0000 (21:01 +0200)]
libuuid: don't exec uuidd
Executing the daemon from the shared library is not quite elegant
solution. Drop this functionality and require uuidd (should it be
needed) to be started from the initscript or by socket-activation.
Petr Uzel [Thu, 3 May 2012 19:01:58 +0000 (21:01 +0200)]
uuidd: add systemd unit files
Add systemd unit files which use the socket activation mechanism
of systemd. The uuidd deamon is started upon first request on the
socket and quits after 1 minute of inactivity.
Petr Uzel [Thu, 3 May 2012 19:01:56 +0000 (21:01 +0200)]
uuidd: do not drop privileges
libuuid can (for now) spawn uuidd on-demand. To support this scenario,
uuidd should be installed setuid/setgid to have access to
/var/lib/libuuid/clock.txt. Therefore, dropping the privileges is
not functional, so removing this ability.
Moreover, the ability to spawn uuidd on-demand will be removed anyway.
Petr Uzel [Thu, 3 May 2012 19:01:54 +0000 (21:01 +0200)]
uuidd: implement --socket-activation option
Implement --socket-activation option, which is supposed to be used
with systemd (or equivalent init system) socket activation mechanism.
With this option, the UUID daemon does not create the socket on its own,
but instead expect the connection fd to be provided by the calling
process.
This option is only available if util-linux is configured with
--enable-socket-activation option. With this configure
option, the uuidd is compiled with sd-daemon.c.
Petr Uzel [Thu, 3 May 2012 19:01:47 +0000 (21:01 +0200)]
uuidd: use UUIDD_OP_GETPID instead of magic number
Make parameters passed to call_daemon() more descriptive:
- use UUIDD_OP_GETPID instead of magic number 0
- call_daemon() takes pointer as a last argument, so pass NULL instead
of 0
libblkid: accept small blocks for NTFS and Reiserfs in blkid
libblkid is restrictive as to what it accepts as valid reiserfs or
valid NTFS. One can mkfs an NTFS with 256B sectors and it's supported
by ntfs-3g Reiserfs can have 512B blocks and it works both with
mkfs.ntfs and Linux.
DOS specific logic is currently embedded in the heart of fdisk code. This patch
separates DOS label specific code into its own file, just like the rest of the
labels, leaving a more generic fdisk.c file. Most changes are just moving code
from fdisk.c to fdisk.h and fdiskdoslabel.[c/h].
The only logical modification is calling dos_delete_partition() from
read_extended(), instead of the generic delete_partition. This is ok since
read extended is only called from a DOS context.
When the device cannot be opened, there's no point calling fatal() when we can
just use err(3). When any other kind of fatal error occurs it's Ok, in addition
we can also go ahead and close the descriptor before exiting the program as
it's currently leaking.
This patch eliminates the long/setjmp code. The current logic does not do
anything with stack jumps as it only exits from
print_partition_table_from_option() when a fatal error occurs.
Petr Uzel [Tue, 24 Apr 2012 08:21:01 +0000 (10:21 +0200)]
findmnt: fix compiler warnings [-Wuninitialized]
findmnt.c:333:29: error: ‘vfs_attr’ may be used uninitialized in this function [-Werror=uninitialized]
findmnt.c:307:11: note: ‘vfs_attr’ was declared here
Petr Uzel [Tue, 24 Apr 2012 08:21:00 +0000 (10:21 +0200)]
sfdisk: fix compiler warning [-Wunused-result]
sfdisk.c: In function ‘do_fdisk’:
sfdisk.c:3212:11: error: ignoring return value of ‘fgets’, declared with attribute warn_unused_result [-Werror=unused-result]
fsck.minix.c: In function ‘ask’:
fsck.minix.c:263:7: error: ignoring return value of ‘fgets’, declared with attribute warn_unused_result [-Werror=unused-result]
Karel Zak [Fri, 27 Apr 2012 08:30:08 +0000 (10:30 +0200)]
libmount: close device fd (to avoid mount(2) EBUSY)
libmount uses libblkid to detect filesystem type. Unfortunately, the
blkid probe struct is not freed before mount(2), it means that the
device is still open and mount(2) may return EBUSY.
We don't need persistent blkid stuff in libmount, so let's close
all immediately after device probing.
Reported-by: David Zeuthen <zeuthen@gmail.com> Signed-off-by: Karel Zak <kzak@redhat.com>
Dave Reisner [Thu, 26 Apr 2012 00:30:52 +0000 (20:30 -0400)]
findmnt: add match_by_file to do within-device matching
Use the newly exported mnt_get_mountpoint to determine the device that a
given file resides on, in case the supplied source or target is not
explicitly a mount point.