Sami Kerola [Sat, 6 Jun 2015 21:41:51 +0000 (22:41 +0100)]
rtcwake: fix valgrind warning
==3445== Syscall param ioctl(generic) points to uninitialised byte(s)
==3445== at 0x4F16477: ioctl (in /usr/lib/libc-2.21.so)
==3445== by 0x402785: setup_alarm (rtcwake.c:231)
==3445== by 0x403302: main (rtcwake.c:520)
Sami Kerola [Sun, 11 Jan 2015 09:37:59 +0000 (09:37 +0000)]
rtcwake: read accepted mode strings from /sys/power/state
The rtcwake has various mode names that are internal to the command,
listed in rtcwake_mode_string array, while some modes are dynamicaly
listed in /sys/power/state. Together these form the allowed modes.
[kzak@redhat.com: - cleanup strv usage]
Reviewed-by: Karel Zak <kzak@redhat.com> Signed-off-by: Sami Kerola <kerolasa@iki.fi> Signed-off-by: Karel Zak <kzak@redhat.com>
Sami Kerola [Sat, 10 Jan 2015 20:07:08 +0000 (20:07 +0000)]
rtcwake: add --list-modes
Commit ece44f19f423408f576f348fed2845c876d72c6e missed freeze mode, which
to a simple patch adding the missing argument but Karel pointed out it
would be better to make the rtcwake to tell what arguments are supported
so that possible changes end up to be automatically correct in bash
completion.
Proposed-by: Karel Zak <kzak@redhat.com> Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Sami Kerola [Sat, 10 Jan 2015 17:07:09 +0000 (17:07 +0000)]
rtcwake: remove RTC_ALM_READ and RTC_ALM_SET compatibility
The RTC_WKALM_RD and RTC_WKALM_SET have been available since 2.6.17, and
preferred way since 2007. Keeping the fallbacks to the old interface is
no longer needed.
Sami Kerola [Fri, 12 Jun 2015 20:25:08 +0000 (21:25 +0100)]
reset: deprecate the script, and remove reset.033c
Most distributions probably ship reset from ncurses, which means
util-linux reset(1) is unlikely to be in use anywhere. Assuming the
previous being true it is almost unimaginable anyone one would be using
the alternative script, so remove it and mark the script deprecated.
Sami Kerola [Tue, 2 Jun 2015 09:18:25 +0000 (10:18 +0100)]
last-deprecated: remove from source tree
The last/lastb(1) from sysvinit has been around for about two years,
and the better implementation is already part of releases 2.24 to 2.26.
It should be safe to remove the unused last code from the source tree.
Karel Zak [Mon, 25 May 2015 13:30:52 +0000 (15:30 +0200)]
sulogin: improve support for locked root account
Some installations and distributions don't use a root account password
for security reasons and use sudo instead. In that case, asking for the
password makes no sense, and it is not even considered as valid as it's just
"*" or "!".
In these cases --force is required to just start a root shell and no
ask for password.
I don't think it's a good idea to automatically start root shell when
locked account is detected. It's possible that the machine is on
public place and for example Ubuntu uses root account disabled by
default (and also Fedora when installed by yum/dnf without anaconda).
The --force option forces admins to think about it...
The distro maintainers can also use --force in their initscripts or
systemd emergency.service if they believe that promiscuous setting is
the right thing for the distro.
Addresses: https://bugs.debian.org/326678 Signed-off-by: Karel Zak <kzak@redhat.com>
Boris Egorov [Fri, 19 Jun 2015 19:41:01 +0000 (01:41 +0600)]
cfdisk: fix condition logic [cppcheck]
[disk-utils/cfdisk.c:1181] -> [disk-utils/cfdisk.c:1181]: (warning)
Possible null pointer dereference: data - otherwise it is redundant to
check it against null.
Boris Egorov [Fri, 19 Jun 2015 19:41:00 +0000 (01:41 +0600)]
libblkid/whereis: simplify some conditions [cppcheck]
[misc-utils/whereis.c:466]: (style) Redundant condition: uflag.
'A && (!A || B)' is equivalent to 'A || B'
[libblkid/src/tag.c:373]: (style) Redundant condition: dev.
'A && (!A || B)' is equivalent to 'A || B'
Karel Zak [Thu, 25 Jun 2015 09:56:02 +0000 (11:56 +0200)]
Merge branch 'script'
* script: (25 commits)
script: add note to BUGS man page section
script: fix EOF problems
script: improve poll debugging
script: cleanup signals usage
script: debug poll() results
script: add support for SCRIPT_DEBUG=
script: remove magic constants from poll code
script: rename control struct members
script: close timingfp also when -e
tests: add scriptreplay test
script: move timing file opening close to use of it
script: add noreturn function attributes
script: use gettime_monotonic() to get timing file timestamps
script: use correct input type, move comment, and so on
script: replace strftime() workaround with CFLAGS = -Wno-format-y2k
script: move do_io() content to small functions
script: add 'Script started' line always to capture file
script: remove io vs signal race
script: merge doinput() and output() functions to do_io()
script: use poll() rather than select()
...
Karel Zak [Fri, 19 Jun 2015 10:17:45 +0000 (12:17 +0200)]
libmount: improve monitor to be usable for non-root users
The current implementation calls mkdir and open(O_CREATE) to
initialize /run/mount/utab.lock before it starts to monitor the file.
Unfortunately it makes the monitor useless for non-root processes
(e.g. systemd --user).
The new implementation adds inotify watch for the last existing
component in the path (/run/mount/utab.lock) and re-initialize
after a change. It makes the monitor robust enough for mkdir/rmdir
when monitor is already active.
Romain Bouvier [Wed, 17 Jun 2015 15:59:18 +0000 (15:59 +0000)]
libuuid: return correct value for uuid_generate_time_safe
Make return value consistent for consecutive calls. If you call
uuid_generate_time_safe, it should always return -1 if it can't guarantee
uniqueness. Without this patch, on consecutive calls where it can't guarantee
uniqueness, the first call returns -1, but later calls return 0.
Reported-by: Romain Bouvier <skunnyk@alteroot.org> Signed-off-by: Andreas Henriksson <andreas@fatal.se>
Karel Zak [Wed, 17 Jun 2015 11:25:46 +0000 (13:25 +0200)]
script: cleanup signals usage
* don't call anything from assert()
* fork() block cleanup to make it more readable
* restore original signal mask in child (do_shell())
* close signal FD in child (do_shell())
Karel Zak [Tue, 16 Jun 2015 09:53:18 +0000 (11:53 +0200)]
Merge branch 'script3' of git://github.com/kerolasa/lelux-utiliteetit into script
* 'script3' of git://github.com/kerolasa/lelux-utiliteetit:
tests: add scriptreplay test
script: move timing file opening close to use of it
script: add noreturn function attributes
script: use gettime_monotonic() to get timing file timestamps
script: use correct input type, move comment, and so on
script: replace strftime() workaround with CFLAGS = -Wno-format-y2k
script: move do_io() content to small functions
script: add 'Script started' line always to capture file
script: remove io vs signal race
script: merge doinput() and output() functions to do_io()
script: use poll() rather than select()
script: use signalfd() to catch signals
script: add struct script_control and remove global variables
script: remove function prototypes
tests: check script options work as expected
tests: add script output buffering race check
Karel Zak [Wed, 10 Jun 2015 12:19:45 +0000 (14:19 +0200)]
fstrim: de-duplicate by mount source too
Now fstrim de-duplicates by target (mountpoint). This patch adds
de-duplication according to mount source (device) to avoid bind mounts
or devices mounted more than once. Note that the patch also check FS
root, the different FS roots of the same multi-root FS (e.g. btrfs)
maybe mounted on different places.
# mount --bind /home/wine /mnt/test
old version:
# fstrim -av
/mnt/test: 0 B (0 bytes) trimmed <---
/home/wine: 0 B (0 bytes) trimmed <---
/boot: 0 B (0 bytes) trimmed
/home: 0 B (0 bytes) trimmed
/: 0 B (0 bytes) trimmed
new version:
# fstrim -av
/mnt/test: 0 B (0 bytes) trimmed <---
/boot: 0 B (0 bytes) trimmed
/home: 171.8 MiB (180113408 bytes) trimmed
/: 0 B (0 bytes) trimmed
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1162213 Signed-off-by: Karel Zak <kzak@redhat.com>
Karel Zak [Tue, 9 Jun 2015 13:53:20 +0000 (15:53 +0200)]
libblkid: (nilfs2) check size for backup superblock only
The size of the device seems irrelevant for the primary superblock.
The primary superblock is stored on fixed offset, possible collision
between last partition and whole-disk is possible only for backup
superblock only.
Karel Zak [Tue, 9 Jun 2015 08:37:11 +0000 (10:37 +0200)]
libblkid: (nilfs2) check devise size
Unfortunately, nilfs2 have the same problem like many RAIDs. It uses
the end of the device to store (backup) superblock. The end of the
last partition is the same location as the end of the whole-disk. It
means that the superblock seems valid for the last partitions as well
as for whole-device.
Fortunately, nilfs2 superblock contains size of the device, so we can
distinguish between whole-disk and partition device.
Reported-by: Heinz Diehl <htd+ml@fritha.org> Signed-off-by: Karel Zak <kzak@redhat.com>
Sami Kerola [Tue, 30 Dec 2014 23:03:32 +0000 (23:03 +0000)]
script: use gettime_monotonic() to get timing file timestamps
This moves the previous time to script control structure, and does
timeval calculation with timersub() that is more appropriate than
making a timeval to a double.
Sami Kerola [Fri, 26 Dec 2014 17:57:46 +0000 (17:57 +0000)]
script: add 'Script started' line always to capture file
The scriptreplay(1) will expect capture file always to have header.
Before this change the --quiet option together with timing caused
following replay error.
$ script --quiet --timing=timing
[...]
$ scriptreplay timing typescript
[...]
scriptreplay: unexpected end of file on typescript
The patch also improves fdisk_align_lba_in_range() to not align sizes
smaller than grain (default 1MiB) to make it possible to create really
small partitions.
Reported-by: Tom Yan <tom.ty89@gmail.com> Signed-off-by: Karel Zak <kzak@redhat.com>
Guillem Jover [Sat, 6 Jun 2015 04:19:05 +0000 (06:19 +0200)]
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.
Boris Egorov [Tue, 2 Jun 2015 17:59:01 +0000 (23:59 +0600)]
bash-completion: handle comma-separated options
This solution can become messy when you have too many options listed,
because it repeats all of them. For example, after invoking completion
with this input:
Nevertheless, it works even with numbers (listed options properly
excluded from completion). Try to invoke completion after
'chcpu --disable ' or 'lsblk --exclude ' to see it in action.
Few issues remained:
* completion interrupts after encountering ':' in listed option,
like in 'MAJ:MIN' in lsblk, losetup.
* lscpu completion is broken: it inserts space after '--extended',
but lscpu assumes there is no space after this option. It also
doesn't complete '--parse' option.
* some completion options are outdated (for example, lscpu MMHZ). We
need to sync them with code. Fix for lscpu follows.