Commit Graph

49 Commits

Author SHA1 Message Date
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
Petr Uzel fcb09bf211 uuidd: remove useless initialization of cleanup_socket
Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2012-05-04 15:13:28 +02:00
Petr Uzel 2e9b39eff3 uuidd: use UUIDD_OP_GETPID instead of magic number
Make parameters passed to call_daemon() more descriptive:
- use UUIDD_OP_GETPID instead of magic number 0
- call_daemon() takes pointer as a last argument, so pass NULL instead
  of 0

Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2012-05-04 15:13:20 +02:00
Sami Kerola c05a80ca63 misc-utils: verify writing to streams was successful
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2012-04-04 19:56:48 +02:00
Petr Uzel 960cf5737e misc: use %m in format string instead of %s and strerror(errno)
Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2011-09-27 15:46:07 +02:00
Eric Sandeen b747e88698 uuidd: Add missing break to option case statement
Specifying the "-n" option to uuidd would incorrectly
fall through to the "-p" case, and assign that number to
the pidfile_path.

Signed-off-by: Eric Sandeen <sandeen@redhat.com>
2011-09-27 15:08:34 +02:00
Karel Zak c63a92b828 uuidd: cleanup usage()
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-08-16 12:48:23 +02:00
Benno Schulenberg 0149cd8468 uuidd: distinguish between singular and plural in three messages
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2011-08-02 14:13:44 +02:00
Karel Zak c3bfedc3d7 uuidd: fix compiler warnings [-Wsign-compare]
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-08-01 12:32:18 +02:00
Sami Kerola f7c297b839 uuidd: coding style fixes
Few unnecessary void casts removed, rest is about spacing.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-06-25 15:15:29 +02:00
Sami Kerola 2fb35353fd uuidd: remove goto statement
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-06-25 14:58:35 +02:00
Sami Kerola 41dc5bc097 uuidd: use symbolic exit and return values
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-06-25 14:53:50 +02:00
Sami Kerola ea091bed63 uuidd: die() function removed
The function is replaced with err().

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-06-25 14:46:47 +02:00
Sami Kerola f0ef0b58dc uuidd: long options & new usage
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2011-06-25 14:36:34 +02:00
Benno Schulenberg 3c06229414 uuidd: add "-q" to synopsis, order options alphabetically
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2011-03-08 13:14:48 +01:00
Petr Uzel 70b989c280 libuuid: rename uuid__generate_* to __uuid_generate_*
Having uuid_generate_time and uuid__generate_time at
the same time is confusing. These functions are exported,
but not part of the official API (used by uuidd only).

Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2011-02-16 16:07:15 +01:00
Petr Uzel 0ee03a2867 uuidd: correctly report number of generated subsequent UUIDs
Before this change, "uuidd -t -n 1" reported
"6fd0672e-2f9b-11e0-b9c8-000feae00cb0 and subsequent 1 UUIDs".
That is two subsequent UUIDs, which is not correct.

Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2011-02-08 15:22:07 +01:00
Petr Uzel 38cf50010f uuidd: fix -n usage
It does not make sense to request zero UUIDs - report error.

Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2011-02-08 15:21:53 +01:00
Petr Uzel 2307a2b9ea uuidd: increase connection backlog size to SOMAXCONN
Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2011-02-08 15:21:51 +01:00
Petr Uzel 386749317e uuidd: use write_all from include/writeall.h
Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2011-02-08 15:21:50 +01:00
Petr Uzel 2d16924217 uuidd: use die() where possible
Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2011-02-08 15:21:49 +01:00
Petr Uzel 83a4498d77 uuidd: use daemon(3) library function
Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2011-02-08 15:21:46 +01:00
Petr Uzel a8f131986c uuidd: use UUID_STR_LEN and UUID_LEN
Use named constants for lentgh of UUID's binary and textual
representation, instead of magic numbers.

[kzak@redhat.com: - use sizeof(uuid_t) rather than hardcoded size]

Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
Signed-off-by: Karel Zak <kzak@redhat.com>
2011-02-08 15:03:13 +01:00
Petr Uzel 783140784a uuidd: use UUIDD_OP_BULK_*_UUID named constants
Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2011-02-08 15:01:30 +01:00
Petr Uzel faab2be3f4 uuidd: fix uuidd -r -n 2
uuidd -r -n 2 failed with "Unexpected reply length from server 36".
Fixed by this patch.

Signed-off-by: Petr Uzel <petr.uzel@suse.cz>
2011-02-08 15:01:26 +01:00
Benno Schulenberg e6b0611b46 messages: gettextize a few skipped or forgotten ones
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2010-06-14 11:19:19 +02:00
Benno Schulenberg 333ec74962 uuidd: spell the plural of "UUID" consistently as "UUIDs"
Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2010-06-14 11:13:51 +02:00
Theodore Ts'o 3b90c50066 libuuid, uuidd: Avoid infinite loop while reading from the socket fd
If for some reason the uuidd daemon or the process calling uuidd
exited unexpectely, the read_all() function would end up looping
forever, either in uuidd or in libuuid.  Fix this terminating the loop
if no data can be read after five tries to read from the file
descriptor.

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-06-30 23:26:09 -04:00
Theodore Ts'o fdb3e93ce9 uuidd: Avoid closing the server socket when calling create_daemon()
In the event that file descriptors 0-2 are closed when uuidd is
started, the server socket could be created as a file descriptor that
will get closed when create_daemon() tries detaching the uuidd daemon
from its controlling tty.   Avoid this case by using dup(2).

Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
2009-06-30 23:26:09 -04:00
Karel Zak 69045d3dba uuidd: new command (UUID daemon from e2fsprogs)
Signed-off-by: Karel Zak <kzak@redhat.com>
2009-05-22 10:06:16 +02:00