Move negative and positive testing of 'has' variable to top level, and test
flag bit mask on second level. This way the 'has' needs to be checked only
once.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
The if clause change is pretty trivial. Moving the macro near to where it
is used makes sense to people who want to read the code. And finally the
comment about user list was at wrong spot.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
The if statement in line 162 already ensures value of cfd to be 0 or
greater, so the later if is not needed.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
This reverts commit 14f644f386.
It seems we have mess in reread-after-write:
all old versions to v2.20 -- returns 0
from v2.20 to v2.26 -- returns 1
since v2.26 -- returns 0
I think re-read errors should not be interpreted as fatal errors,
because it's pretty common that you want to modify only one partition
(e.g. resize) and then another partitions are probably still in use
and re-read all PT does not make sense.
What we need is to improve granularity for re-read and calls it only
when really necessary (all PT modified) and otherwise call BLKPG
(add/delete/resize) ioctls.
Reported-by: Nikhil Valluru <vvnikhil@gmail.com>
Signed-off-by: Karel Zak <kzak@redhat.com>
Issues:
1. Whitespace-ish \r is not stripped, while it should be.
2. In journal \r is considered unprintable.
Lennart: "it is the duty of the client side to drop the trailing whitespace,
which "logger" doesn't do".
Reported-by: Ivan Babrou <ibobrik@gmail.com>
Explained-by: Lennart Poettering <lennart@poettering.net>
Reference: https://github.com/systemd/systemd/issues/3416
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Casting the value to be checked to size_t renders the check useless.
If st_size is SIZE_MAX+1, it will be truncated to 0 and the check
succeeds. In fact, this check can never be false because every value
stored in a size_t is smaller or equal to SIZE_MAX.
I think this adjustment was meant to fix a compiler warning for 64 bit
systems for which sizeof(off_t) is sizeof(size_t), but the signedness
differs.
Going unconditionally to the greatest possible unsigned int type if
st_size is positive (off_t is signed) will fix this issue.
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
* 'write-improvements' of git://github.com/kerolasa/lelux-utiliteetit:
lib: try to find tty in get_terminal_name()
write: stop removing and adding /dev/ in front of tty string
write: tell when effective gid and tty path group mismatch
write: improve coding style
write: remove PUTC macro
write: make timestamp to be obviously just a clock time
write: remove unnecessary utmp variables
write: improve function and variable names
write: add control structure to clarify what is going on
write: run atexit() checks at the end of execution
write: use xstrncpy() from strutils.h
write: set atime value in term_chk() only when needed
write: remove pointless fileno(3) calls
write: get rid of function prototypes
write: remove unused variable
This change fixes compiler option -Werror=nonnull option warning:
login-utils/sulogin-consoles.c: In function 'append_console':
login-utils/sulogin-consoles.c:324:14: warning: nonnull argument 'consoles'
compared to NULL [-Wnonnull-compare]
The NULL check done with list_empty() looks valid, so it is best to remove
the function attribute that allows compiler to optimize the check away.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
On Sparc, fdisk defaults to using SUN disk labels, which causes the
output from these tests to differ from non-Sparc.
Signed-off-by: James Clarke <jrtc27@jrtc27.com>
Improve the grammar and phrasing of the --verbose option and how it
interacts with the --step option.
Signed-off-by: Allon Mureinik <amureini@redhat.com>
tailf crashes with a segmentation fault when used with a file that is
exactly 4GB in size due to an integer overflow between off_t and size_t:
$ dd if=/dev/zero of=tailf.crash bs=1 count=1 seek=4294967295
$ tailf tailf.crash
Segmentation fault
$ _
Signed-off-by: Tobias Stoeckmann <tobias@stoeckmann.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
This is extension to the patch 7164a1c34d.
We also need to detect non-empty recursion in the EBR chain. It's
possible to create standard valid logical partitions and in the last one
points back to the EBR chain. In this case all offsets will be non-empty.
Unfortunately, it's valid to create logical partitions that are not in
the "disk order" (sorted by start offset). So link somewhere back is
valid, but this link cannot points to already existing partition
(otherwise we will see recursion).
This patch forces libblkid to ignore duplicate logical partitions, the
duplicate chain segment is interpreted as non-data segment, after 100
iterations with non-data segments it will break the loop -- no memory
is allocated in this case by the loop.
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1349536
References: http://seclists.org/oss-sec/2016/q3/40
Signed-off-by: Karel Zak <kzak@redhat.com>
We have fallback for compilation with/without proper glibc and kernel
headers, but it's not enough, because people can switch between
kernels with and without the syscalls. (For example RT kernels for
RHEL/CentOS).
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1353340
Signed-off-by: Karel Zak <kzak@redhat.com>
If the extended partition starts at zero LBA then MBR is interpreted
as EBR and all is recursively parsed... result is out-of-memory.
MBR --extended-partition--> EBR --> MBR --> ENB --> MBR ...
Note that such PT is not possible to create by standard partitioning
tools.
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1349536
Signed-off-by: Karel Zak <kzak@redhat.com>
Try all standard terminal input/output file descriptors when finding tty
name in get_germinal_name(). This should make all invocations of the
function as robust as they can get.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Add both path and tty name representations of tty's to control structure,
that point to same string beginning from different depths. This way there
is no need to removing and adding /dev/ in front of tty string all the time.
Secondly this change makes it possible to use of get_terminal_name() from
ttyutils.c.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Most commonly this error happens when write(1) executable does not have
correct group ownership and setgid bit. The earlier message was unclear
what exactly was wrong.
$ mesg
is y
$ write testuser
write: you have write permission turned off
Alternatively the 'getegid() == s.st_gid' could be considered unnecessary.
Afterall if to write to destination tty is denied that does not go unnoticed
at thet time when tty is opened.
Reviewed-by: Benno Schulenberg <bensberg@justemail.net>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Function like macros make following the execution flow unnecessarily
difficult, and deserves to be removed.
Requested-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
By looking the code one will had hard time knowing that a slice of ctime()
from characters 11 to 16 is HH:MM time format. Use of strftime("%H:%M")
makes this a lot less mysterious.
In same go make \007 hex printouts to be \a that is the same thing: alarm.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
glibc documentation tells getutent() calls are not thread safe, and
recommends to copy the context of the structures when information is wished
to be stored. This leads to excessive copying, that in this case is not
relevant. write(1) is single threaded program and there is no reason to
assume this would change in future.
Reference: http://www.gnu.org/software/libc/manual/html_node/Manipulating-the-Database.html
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Earlier use of _exit() caused program to terminate abnormally from atexit()
perspective and standard file descriptor close checks did not run resulting
to blindness if writes were successful, or not. Easy fix is to avoid
running _exit() altogether.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Earlier if the tty path was exactly length of the maximum ut_line then last
character of the path was overwrote by \0. This is in practise theoretical
bug, as it is unheard that a tty device path could be 32 characters long.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* add --noinaccessible to not print incomplete information
* make incomplete paths more visible (append "...")
* don't print 0B size if lock file inaccessible
Signed-off-by: Karel Zak <kzak@redhat.com>
* 'utmpdump' of git://github.com/kerolasa/lelux-utiliteetit:
docs: add file format note to utmpdump manual page
tests: utmpdump add subsecond accuracy test
tests: challenge utmpdump localization go-around
tests: fix utmpdump timestamps to be in iso format
utmpdump: use iso-8601 timestamp format with subsecond accuracy
libcommon: add ISO_8601_GMTIME that will print UTC-0 timestamps
utmpdump: use always UTC-0 timezone in textual output
Drives with 512 and 4K sectors have different offset for
metadata signature. Without signature detected on 4Kn drives
those drives will not be recognized as raid member. This
patch adds checking for IMSM signature for 4Kn drives.
Signed-off-by: Alexey Obitotskiy <aleksey.obitotskiy@intel.com>
Tell that the old textual format that does not use full utmp time precision,
and has issues with timezones. Warn also that the textual format may become
incompatible, although there are no plans in foreseeable future to do so.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
The utmpdump timestamps are unambiguous, they always use UTC-0 regardless of
localization. If thesse tests starts to fail after this change then the
timezone forcing is not working.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
The utmpdump-circle is slightly modified to use old timestamp format as
basis of conversion and to do cyclic conversion via new format. This is
better from test coverage point of view.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>