The following usages of utmpdump result in no output being flushed to the specified file because the default output buffering is fully buffered:
$ utmpdump --follow --output myOutputFile /var/log/utmp
$ utmpdump --follow /var/log/utmp > myOutputFile
This change configures line buffering for these scenarios so that output will be flushed after each log event.
Signed-off-by: Andrew Shapiro <anshapiro@gmail.com>
The function read_buffer() implements read and clear functionally, but
we do not differentiate between these actions in main() for error
messages, and one generic "dmesg: read kernel buffer failed" is used
in all cases. That's a bug.
This patch removes the "clear" action from read_buffer() and keeps it
for buffer reading only. The "clear" action is implemented in main()
by separate klogctl(SYSLOG_ACTION_CLEAR) for cases. It means also for
"dmesg --read-clear"; we do not use SYSLOG_ACTION_READ_CLEAR anymore.
Now "clear+read" is:
* syslog: SYSLOG_ACTION_READ_ALL + SYSLOG_ACTION_CLEAR
* kmsg: /dev/kmsg read() + SYSLOG_ACTION_CLEAR
In old versions "dmesg --syslog --read-clear" (syalog backed) was
implemented by logctl(SYSLOG_ACTION_READ_CLEAR) and it returns no
data for non-root users (due to EPERM), "dmesg --read-clear" (kmsg)
returns data and EPERM for the "clear" action.
Now the command "dmesg --syslog --read-clear" and "dmesg --read-clear"
behaves in the same way -- returns data and EPERM for the "clear"
action.
Fixes: https://github.com/karelzak/util-linux/issues/1255
Signed-off-by: Karel Zak <kzak@redhat.com>
The current situation:
# su --pty - kzak
$ ll $(tty)
crw--w---- 1 root tty 136, 9 Feb 23 11:53 /dev/pts/9
$ mesg
mesg: cannot open /dev/pts/9: Permission denied
the pseudo-terminal is still owned by the original user.
New version:
# su --pty - kzak
# ll $(tty)
crw--w---- 1 kzak tty 136, 9 Feb 23 11:56 /dev/pts/9
# mesg
is y
The patch follows login(1) to change the pty owner and group. It
follows "TTYPERM" and "TTYGROUP" from login.defs (or econf lib).
Signed-off-by: Karel Zak <kzak@redhat.com>
Command (m for help): t
Selected partition 1
Partition type or alias (type L to list all): linux root x86
Changed type of partition 'Linux /usr (x86)' to 'Linux root (x86)'.
Signed-off-by: Karel Zak <kzak@redhat.com>
Let's follow our policy for default directories and explicitly default
to localstatedir=/var and sysconfdir=/etc when the default $prefix is
used.
Reported-by: Bruce Dubbs <bruce.dubbs@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
>>> CID 365738: Uninitialized variables (UNINIT)
>>> Using uninitialized value "ret". Field "ret" is uninitialized.
326 return ret;
Signed-off-by: Karel Zak <kzak@redhat.com>
The original Julian's hardlink.c code is pretty readable, but for
util-linux we use a little different indention (aka Linux kernel
coding style).
Signed-off-by: Karel Zak <kzak@redhat.com>
We usually use "debug" for very detailed information. For end-user
information is better to talk about "verbose" output.
Signed-off-by: Karel Zak <kzak@redhat.com>