changed in include/c.h and applied via sed:
sed -i 's/fprintf.*\(USAGE_MAN_TAIL.*\)/printf(\1/' $(git ls-files -- "*.c")
sed -i 's/print_usage_help_options\(.*\);/printf(USAGE_HELP_OPTIONS\1);/' $(git ls-files -- "*.c")
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
Consolidate --help and --version descriptions. We are
now able to align them to the other options.
We changed include/c.h. The rest of this patch was
generated by sed, plus manually setting the right
alignment numbers. We do not change anything but
white spaces in the --help output.
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
Now the build will fail on many non-Linux systems because
utmpx.h is available everywhere but we still use non-POSIX
features. We'll fix this next commit.
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
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>
Fix various typos in error messages, warnings, debug strings,
comments and names of static functions.
Signed-off-by: Sebastian Rasmussen <sebras@gmail.com>
The write(1) is commonly a setuid binary, because common users cannot by
default write to each others terminals. Since the commit in reference, that
is part of releases v2.24 to v2.28, the write(1) has used access(2) to check
capability to write to a destination terminal. The catch is that access(2)
uses real UID and GID to when performing the accessibility. The obvious
correction is to avoid access(2) when in context of setuid binaries.
As a smaller fix, but equally important fix, ensure the 'msgsok' variable is
initialized to indicate no access. Uninitialized variable will almost
certainly do wrong thing at the time of check.
Breaking-commit: 0233a8ea18
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Wayne Pollock <profwaynepollock@gmail.com>
This adds a concise description of a tool to its usage text.
A first form of this patch was proposed by Steven Honeyman
(see http://www.spinics.net/lists/util-linux-ng/msg09994.html).
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
Translating these text elements should happen only once, which is
more likely when the text macros are used properly.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
In include/bits/utmp.h the ut_user and ut_time macros are marked with
comment they are backwards compatibility hacks. It is probably best to
avoid use of these macros where ever possible.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Earlier test failed when user had write permission, but was not in
special group that owns terminal devices, usually tty.
This made write(1) to fail for root, if the root did not happen to be in
tty group. In this commit root is granted ot write to anyone, even if
they have mesg(1) turned off. For an user who is trying to write to own
other session the group write bit is significant only for whether mesg(1)
are enabled.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Use libc error printing facilities, remove void casting, clean up
unused headers and alignt coding style with README.devel.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>