The trailing comma made code to compile without issues, but meant all_done()
was called only when --debug was in defined in command-line.
Fixes: 3d6250e96b
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Limiting random query to 1000 uuid's was pointless when the next line will
further restrict upper limit to 63 entries. The 63 entries is what fits to
the uuidd communication buffer with the header.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Use a typedef for types that are sensitive what comes to uuidd protocol
field widths, read write sizes, and related checks.
Proposed-by: Karel Zak <kzak@redhat.com>
Reference: https://github.com/karelzak/util-linux/pull/1196#discussion_r528595794
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Write the data and response length values in same close to order they appear
in protocol. This should make code a little easier to read.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Seeing what can be expected should make it easier to understand what the
code does.
Notice that simply writing down the resposes one can start wondering deeper
questions, such as, why does the time bulk response reply only one uuid
followed by number how many were requested? Was that a some type of TODO
note?
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Relying to single vs bulk requests to be exactly two steps away from each
other was an unnecessary dirty trick.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Moving the option parsing to a separate function will allow moving some
variables from main() heap to be in scope that free them later. That should
make the uuidd to have a little bit smaller runtime memory allocation.
The static long options is changed to be local variable. That should make
it to be part of heap for a bit, until removed. Earlier the variable was in
data segment and permanently in runtime memory. Whether this makes any
impact either way is not entirely clear, but hope is the runtime memory
allocation is tiny bit smaller.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
The struct will help seeing where the variable values are coming from. This
will also help upcoming refactoring.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Earlier use of a variable that holds switch enabling boolean to hold process
id was a little bit strange, and not exactly correct. An int should be good
enough to hold any pid, but it is better to be precise and use the type that
is meant for the job.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
This change fixes "warning: variable 'var' may be uninitialized when used
here [-Wconditional-uninitialized]" warnings reported in various files.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* add struct ul_timer as API abstraction to hide differences between
timer_create() and setitimer()
* add setitimer() detection to ./configure.ac
* add fallback code to use setitimer() if timer_create() not available
(for example on OSX)
Addresses: https://github.com/karelzak/util-linux/issues/584
Signed-off-by: Karel Zak <kzak@redhat.com>
This was the error
uuidd: couldn't bind unix socket /var/tmp/portage/sys-apps/util-linux-2.31.1/work/util-linux-2.31.1-abi_x86_64.amd64/tests/output/uuid/uuiddkOcTUuoZ7kaP3: Address already in use
because the socket path was truncated to 108 chars which was luckily
an existing directory.
Now we abort early with "uuidd: socket name too long: ... "
Reported-by: Thomas Deutschmann <whissi@gentoo.org>
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
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>
This patch is trivial and changes nothing, because
we were always using usage(stdout)
Now all our usage() functions look very similar. If wanted we
could auto-generate another big cosmetical patch to remove all
the useless "FILE *out" constants and use printf and puts
rather than their f* friends. Such patch could be automatically
synchronized with the translation project (newlines!) to not
make the translators sick.
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
Fix various typos in error messages, warnings, debug strings,
comments and names of static functions.
Signed-off-by: Sebastian Rasmussen <sebras@gmail.com>
misc-utils/uuidd.c:384:13: warning: declaration of 'ret' shadows a previous
local [-Wshadow]
misc-utils/uuidd.c:327:6: note: shadowed declaration is here
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Point of this change is to replace use of signal() and alarm() system calls
using newer interfaces. Nice side effect is that the point where timer was
earlier used cannot be distracted by sending rogue SIGALRM.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
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>
Earlier for example this 'uuidd --pid /dev/full' worked, now error is
printed about truncating not being possible for character device and
assuming someone would write pid to full disk it should not be go by
unnoticed.
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
* systemd (since v209) uses only one library (when compiled
without --enable-compat-libs)
* all systemd build-sys stuff is merged into HAVE_SYSTEMD
(automake) and HAVE_LIBSYSTEMD (C macro) now
* all is controlled by --with-systemd, default is to automatically
check for systemd libs
* no more --enable-socket-activation and --enable-journald
Signed-off-by: Karel Zak <kzak@redhat.com>
[kzak@redhat.com: - remove USE_SOCKET_ACTIVATION and use
HAVE_* as we use for another libs]
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
This reverts commit 6126f7a53c
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().
Signed-off-by: Petr Uzel <petr.uzel@suse.cz>