Commit Graph

79 Commits

Author SHA1 Message Date
Rosen Penev 042f62dfc5
[clang-tidy] do not use else after return
Found with readability-else-after-return

Signed-off-by: Rosen Penev <rosenp@gmail.com>
2020-04-20 13:20:59 -07:00
Karel Zak 2c308875a7 misc: consolidate version printing and close_stdout()
Signed-off-by: Karel Zak <kzak@redhat.com>
2019-04-16 15:14:13 +02:00
Sami Kerola 4813a5210f various: fix 'uninitialized when used' warnings [clang]
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>
2019-02-18 13:19:24 +01:00
Karel Zak 6df5acf970 lib/timer: add fallback if timer_create() not available
* 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>
2018-12-03 11:23:33 +01:00
Karel Zak 2446d0487f uuidd: cosmetic coding style change
Signed-off-by: Karel Zak <kzak@redhat.com>
2018-03-07 11:53:15 +01:00
Ruediger Meier eb10dbc159 uuidd: don't truncate long socket paths
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>
2018-03-07 11:50:05 +01:00
Philip Prindeville b443c1779e misc: replace magic number 37 with UUID_STR_LEN
Signed-off-by: Philip Prindeville <philipp@redfish-solutions.com>
2017-09-05 11:49:21 +02:00
Ruediger Meier f45f3ec34a misc: consolidate macro style USAGE_HELP_OPTIONS
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>
2017-06-29 16:54:33 +02:00
Ruediger Meier b1a294c448 misc: introduce print_usage_help_options()
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>
2017-06-27 12:26:19 +02:00
Ruediger Meier 86be6a32d3 misc: cosmetics, remove argument from usage(FILE*)
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>
2017-06-26 14:38:24 +02:00
Ruediger Meier 619081cdab uuidd: remove unused define
Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2017-06-22 02:56:57 +02:00
Karel Zak 677ec86cef Use --help suggestion on invalid option
The current default is to print all usage() output. This is overkill
in many case.

Addresses: https://github.com/karelzak/util-linux/issues/338
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-12-19 13:13:34 +01:00
Sami Kerola b7a245e27a uuidd: remove unnecessary pidpile path variable
Signed-off-by: Karel Zak <kzak@redhat.com>
2016-08-08 12:33:16 +02:00
Sami Kerola 74ce680a3e
misc: simplify if clauses [oclint]
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2016-07-21 21:14:33 +01:00
Sebastian Rasmussen 9e93004171 misc: Fix various typos
Fix various typos in error messages, warnings, debug strings,
comments and names of static functions.

Signed-off-by: Sebastian Rasmussen <sebras@gmail.com>
2016-05-31 23:40:21 +02:00
Benno Schulenberg 9e708d01f3 uuidd: correct the wording of an error message
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2016-03-16 10:39:38 +01:00
Ruediger Meier 3fd1f7711e docs: fix typos found by codespell
Using "codespell" from https://github.com/lucasdemarchi/codespell

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2016-02-03 15:10:08 +01:00
Karel Zak 3d6250e96b uuidd: add debug message for timeout
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-10-09 11:46:49 +02:00
Karel Zak b85df4b738 uuidd: use cxt->quiet
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-10-09 11:26:28 +02:00
Karel Zak 4b09b1c253 uuidd: fix compiler warning [-Wsign-compare]
Signed-off-by: Karel Zak <kzak@redhat.com>
2015-10-09 11:23:16 +02:00
Sami Kerola fd346daf89 uuidd: fix shadow declaration
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>
2015-10-09 11:17:12 +02:00
Sami Kerola 25d66b4e32 uuidd: use signalfd() and setup_timer()
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>
2015-10-09 11:17:11 +02:00
Sami Kerola 67791b7787 blkid, uuidd, uuidgen: assume getopt.h and getopt.h are available
These headers are in use allover this project without issues.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-10-09 11:17:09 +02:00
Sami Kerola 61b6427638 uuidd: slice up the usage text and normalize its layout
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-10-09 11:17:08 +02:00
Sami Kerola fa8945db4a uuidd: improve socket activation error messaging
Tell more exactly what is wrong and how, and give hint how to recover
when possible.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2015-10-02 12:38:30 +02:00
Benno Schulenberg 451dbcfae1 textual: add a docstring to most of the utilities
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>
2015-01-06 11:27:38 +01:00
Sami Kerola db433bf737 textual: use usage() text element macros
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>
2014-10-01 12:33:26 +02:00
Sami Kerola d8bb8a033f uuidd: do not mix signed type and unsigned code
Both the strtou32_or_err() and alarm() expect timeout to be unsigned.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-05-26 16:42:49 +01:00
Sami Kerola e4faf64847 uuidd: set options to be mutually exclusive
--pid     || --no-pid
--debug   || --quiet
--random  || --time

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-05-26 16:42:40 +01:00
Sami Kerola caac206429 uuidd: ensure pid file is wrote when it is requested
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>
2014-05-26 16:37:54 +01:00
Karel Zak ebff016a19 build-sys: consolidate systemd support
* 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>
2014-04-09 12:23:30 +02:00
Sami Kerola ea45d34c7c uuidd: use pkg-config to find systemd-deamon support
[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>
2014-01-07 12:17:37 +01:00
Karel Zak 57a24292ff uuidd: add missing initializer [clang-analyzer]
Reported-by: Sami Kerola <kerolasa@iki.fi>
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-07-09 14:45:41 +02:00
Benno Schulenberg 0012e33c2c textual: fix typo in error message and uniformize their use of period
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2013-05-28 15:08:44 +02:00
Karel Zak bcb693de80 uuidd: clean up error messages
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-05-15 00:18:27 +02:00
Karel Zak e421313dc2 textual: use UTIL_LINUX_VERSION everywhere
Signed-off-by: Karel Zak <kzak@redhat.com>
2013-01-25 12:05:26 +01:00
Petr Uzel f80e9bc30a libuuid: move read_all to include/all-io.h
Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2012-05-15 11:32:36 +02:00
Petr Uzel e12c9866b5 include: rename writeall.h to all-io.h
Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2012-05-15 11:32:27 +02:00
Petr Uzel c544aa2c25 libuuid: avoid double open and leaking fd (reworked)
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>
2012-05-10 11:43:49 +02:00
Karel Zak 4b1cf29d23 uuidd: remove unnecessary variables
Signed-off-by: Karel Zak <kzak@redhat.com>
2012-05-04 16:20:37 +02:00
Petr Uzel 6126f7a53c libuuid: avoid double open and leaking descriptor
We are opening /dev/urandom twice in uuid_generate(): first to check if
the file is available and then later __uuid_generate_random() again to
actually get the random data. Moreover, descriptor from the first open
is leaking.

Fix by passign the descriptor down the stack and reusing it there.

References: http://marc.info/?l=util-linux-ng&m=133406051131131&w=2

Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2012-05-04 15:14:24 +02:00
Petr Uzel 881a0f6b28 uuidd: introduce uuidd_cxt to pass arguments to server loop
Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2012-05-04 15:14:21 +02:00
Petr Uzel cb20279fb0 uuidd: do not drop privileges
libuuid can (for now) spawn uuidd on-demand. To support this scenario,
uuidd should be installed setuid/setgid to have access to
/var/lib/libuuid/clock.txt. Therefore, dropping the privileges is
not functional, so removing this ability.

Moreover, the ability to spawn uuidd on-demand will be removed anyway.

References: http://www.spinics.net/lists/util-linux-ng/msg05934.html

Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2012-05-04 15:14:11 +02:00
Petr Uzel 18c68d70ee uuidd: print all debugging information to stderr
Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2012-05-04 15:14:07 +02:00
Petr Uzel bbe289c489 uuidd: implement --socket-activation option
Implement --socket-activation option, which is supposed to be used
with systemd (or equivalent init system) socket activation mechanism.
With this option, the UUID daemon does not create the socket on its own,
but instead expect the connection fd to be provided by the calling
process.

This option is only available if util-linux is configured with
--enable-socket-activation option. With this configure
option, the uuidd is compiled with sd-daemon.c.

Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2012-05-04 15:14:04 +02:00
Petr Uzel 75a94e8b36 uuidd: factor out socket creation into separate function
Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2012-05-04 15:13:46 +02:00
Petr Uzel e1cf3ebed5 uuidd: implement --no-fork option
With this option, uuidd does not daemonize itself but stays
in the foreground.

Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2012-05-04 15:13:45 +02:00
Petr Uzel f6f3dc7811 uuidd: use ignore_result helper
Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2012-05-04 15:13:43 +02:00
Petr Uzel 0abfbd9ce6 uuidd: implement --no-pid option
With this option, uuidd does not create the PID file.

Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2012-05-04 15:13:40 +02:00
Petr Uzel c453635572 uuidd: factor out pidfile creation into separate function
Introduce create_pidfile() function.

Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2012-05-04 15:13:34 +02:00