Commit Graph

967 Commits

Author SHA1 Message Date
Sami Kerola 4288f9f12c logger: make --stderr print remote server messages
Users wish to see the message should include also remote messages, not
only the one sent to locally via libc function.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-07-28 21:15:18 +01:00
Sami Kerola aab5b44405 logger: add process --id=parent optional argument
When scripts send several messages they will be easier to group together
when parent process id is printed rather than id of the each logger
process.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-07-28 21:15:18 +01:00
Sami Kerola d9b38f6baf docs: add logger protocol notes to manual page
Inform about rfc5424 support, how to control what it includes to
submission, and that it is the new default when sending syslog messages
to remote server without specifying protocol.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-07-28 21:15:17 +01:00
Sami Kerola 4de2e8a038 logger: add rfc5424 support
Add support the more recent syslog protocol and make it default.  The
older BSD syslog protocol can still be used with option --rfc3164.
Protocols are meaningful only when messages are sent to remote syslog
server.

Requested-by: Kodiak Firesmith <ksf@sei.cmu.edu>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-07-28 21:15:17 +01:00
Sami Kerola c68a1cb490 logger: tidy up main() by adding small functions and ctl data
Add logger_open(), logger_command_line(), logger_stdin(), and
logger_close() functions, and move all remaining option argument
assignments to control structure.

Proposed-by: Karel Zak <kzak@redhat.com>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-07-28 21:15:17 +01:00
Sami Kerola cfa77d2643 logger: add function pointer to choose how logging is done
This change paves way to adding support for both RFC 3164 and RFC 5424
syslog protocols.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-07-28 21:15:17 +01:00
Sami Kerola 4c3ac8fe52 docs: make logger.1 facilities and levels easier to read
Most people read vertical list a lot quicker than horizontal.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-07-28 21:15:17 +01:00
Sami Kerola c462a8caf2 logger: refactor long if clause
When if clause that continues throughout whole function it usually can be
shorten to immediate action, e.g., in this case return on the spot not at
end of the function.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-07-28 21:15:17 +01:00
Sami Kerola 019b97024f logger: do not rely only getlogin(3) telling who ran the command
The getlogin(3) is known not to always work, and when that happens it is
reasonable to try determine user of name by looking process owner and
passwd information.

Reference: http://man7.org/linux/man-pages/man3/getlogin.3.html
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-07-28 21:15:16 +01:00
Sami Kerola d8b616c216 logger: fix indentation issues
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-07-28 21:15:16 +01:00
Sami Kerola 633493beaf logger: ensure program writes everything to syslog file descriptor
It is fair assumption messages an user is asking to be wrote will be
attempted to be wrote as hard as possible.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-07-28 21:15:16 +01:00
Bernhard Voelker ada74f3f32 mcookie: avoid format warning
"gcc (SUSE Linux) 4.8.1 20130909 [gcc-4_8-branch revision 202388]"
issued the following warning:

  warning: format ‘%zu’ expects argument of type ‘size_t’, \
  but argument 3 has type ‘int’ [-Wformat=]

* misc-utils/mcookie.c (main): Change format from %zu to %d.
RAND_BYTES is an enum, thus of type int.

Signed-off-by: Bernhard Voelker <mail@bernhard-voelker.de>
2014-07-28 11:09:49 +02:00
Benno Schulenberg 09af3db48e textual: fix some typos and inconsistencies in various messages
Fixing plain typos, miswordings, inconsistent periods, some missing
angular brackets, and a proper pluralization (even when it involves
a constant, because for some languages the precise value matters).

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2014-07-23 08:56:00 +02:00
Karel Zak bd86cb1679 Merge branch 'rename' of git://github.com/kerolasa/lelux-utiliteetit
* 'rename' of git://github.com/kerolasa/lelux-utiliteetit:
  tests: add rename(1) return value check
  rename: use function pointer to select file or symlink operation
  rename: continue despite something failed
  tests: add rename(1) checks
  tests: use ts_cd everywhere to change direcrory
  tests: add function to change directory reliable way
  rename: allow renaming in subdirectories
2014-07-22 12:12:52 +02:00
Karel Zak ccef45168b Merge branch 'master' of https://github.com/yurchor/util-linux
* 'master' of https://github.com/yurchor/util-linux:
  Fix typos in user visible messages
2014-07-22 12:01:50 +02:00
Karel Zak 3df45c7cdc Merge branch 'ioclt' of https://github.com/lanurmi/util-linux 2014-07-22 11:58:21 +02:00
Sami Kerola 5651128abd rename: use function pointer to select file or symlink operation
Add separate functions to different functionality, and add a function for
the stuff that is in common for both.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-07-18 18:34:15 +01:00
Sami Kerola d6cf9e1669 rename: continue despite something failed
Try to do all file operations even when one or some of them fail, and
use exit value to inform what happen.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-07-18 18:34:15 +01:00
Sami Kerola bd9ced628b rename: allow renaming in subdirectories
Earlier the rename(1) considered path as possible string to be renamed,
could lead to an issue with none existing destination.  See below for
demonstration of this issue.  After this change all directory elements
are ignored when the match finding happens.

$ cd $(mktemp -d)
$ mkdir aa ab
$ touch a{a,b}/aa
$ rename -v a x */aa
rename: aa/aa: rename to xa/aa failed: No such file or directory

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-07-18 18:34:14 +01:00
Karel Zak edaf38cf8c findmnt: more robust usage of columns[]
For more details see commit dcc8dbdc8137cb3da5100158639b565565b89875.

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-07-18 13:49:40 +02:00
Karel Zak 21abf83d6d lslocks: clean up columns[] usage
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-07-18 13:48:31 +02:00
Karel Zak b6327c6fd8 lsblk: check number of used columns
The current code does not check size of the columns[] array when add
the next on command line specified column. We check the array size for
"-o <columns>" but not for another options.

Old version:

   $ for x in $(seq 0 100); do echo "-t"; done | xargs lsblk
   xargs: lsblk: terminated by signal 11

new version:

  $ for x in $(seq 0 100); do echo "-t"; done | xargs lsblk
  lsblk: too many columns specified, the limit is 83 columns.

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-07-18 13:47:53 +02:00
Karel Zak 03df0d1150 lsblk: differentiate between infos[] and columns[]
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-07-18 13:45:32 +02:00
Karel Zak 5ffe4d514c Merge branch 'patch-1' of https://github.com/bneijt/util-linux 2014-07-18 12:59:46 +02:00
Karel Zak aea3a3ba2c findmnt: fix memory leak [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-07-17 15:00:17 +02:00
A. Bram Neijt 9d2926bf12 Add missing paragraph mark before -f
the sections on -P and -f where glued together.
2014-07-16 21:07:04 +02:00
Benno Schulenberg 36a3cd56ab textual: fix the usage message of kill
Using angular brackets around each individual argument, indenting a
continuation line, not using a space before =, improving some wordings,
and the argument of --queue is a value (a piece of data), not a signal.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2014-07-14 16:13:37 +02:00
Karel Zak 2fa32bea49 Merge branch 'minor-fixes' of git://github.com/kerolasa/lelux-utiliteetit
* 'minor-fixes' of git://github.com/kerolasa/lelux-utiliteetit:
  lscpu: avoid double free
  libsmartcols: avoid variable dereference after release
  libfdisk: do not do the same thing twice in single if statement
  whereis: avoid printing uninitialized string
  setpriv: avoid alloca() use xmalloc() instead
  dmesg: avoid unnecessary variable assignment
  fdisk: avoid code duplication
  mkfs.cramfs: use defined failure name rather than magic value
  fdformat: match variable and print format types
  cfdisk: add braces to ensure operation order
  lscpu: avoid use of bzero() in favor of memset()
  setterm: remove unnecessary variable
  cal: remove unnused structure and definition
  textual: fix some typos
2014-07-14 16:03:48 +02:00
Andreas Henriksson 89c80bd25a uuidd.rc: Requires remote_fs
The Debian package checking tool lintian thinks that the script is
missing Requires on $remote_fs because it pokes at stuff under /usr
and it's probably right.

Signed-off-by: Andreas Henriksson <andreas@fatal.se>
2014-07-14 15:55:45 +02:00
Andreas Henriksson 928601e630 uuidd.rc: drop on-demand mode from script
The on-demand mode was dropped from libuuid in
commit ea4f8845f0 "libuuid: don't exec uuidd"

You now need systemd (socket activation) to use
uuidd on demand.

Signed-off-by: Andreas Henriksson <andreas@fatal.se>
2014-07-14 15:55:34 +02:00
Sami Kerola a3443c3067 kill: use --queue option argument as sigval integer value
The sigqueue(3) takes two values, signal and sigval.  Contents of the
signal can be altered with --signal option argument, so the --queue
argument should be reserved to affect sigval_int.

This is regression fix introduced by commit
9e8dffd5cd.

Reference: http://man7.org/linux/man-pages/man3/sigqueue.3.html
Reported-by: Benno Schulenberg <bensberg@justemail.net>
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-07-14 15:49:35 +02:00
Benno Schulenberg 8309826200 docs: fix many wording and some formatting issues in the man page of kill
Also, add the most-used form of '-signal' to the synopsis.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2014-07-14 15:49:30 +02:00
Andreas Henriksson 8a11218213 whereis: fix missing newline on empty results
Running "whereis foo.bar.quux" previously resulted in
printing the "foo.bar:" pattern prefix without any
newline following it.

Signed-off-by: Andreas Henriksson <andreas@fatal.se>
2014-07-14 15:49:27 +02:00
Sami Kerola 46ed183613 whereis: avoid printing uninitialized string
The patbuf[] needs to be filled before print out.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-07-13 18:35:38 +01:00
Sami Kerola 34a7e101cc cal: remove unnused structure and definition
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
2014-07-13 17:25:14 +01:00
Lauri Nurmi a5c523a0e7 Fix typo "ioclt" in various files. 2014-07-11 22:52:09 +03:00
Yuri Chornoivan b5af3ee835 Fix typos in user visible messages 2014-07-03 09:33:15 +03:00
Karel Zak 23deb5aca0 findmnt: simplify cache_set_targets()
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-07-01 10:36:40 +02:00
Eric Rannaud fb329bbc04 findmnt: use mnt_cache_set_targets() for non-kernel table
findmnt compares the user-supplied path <target> with each entry in the
parsed table. To do this comparison, libmount attempts to canonicalize
the target path of each table entry, when the entry does not originate
from the kernel (kernel supplied target paths are already
canonicalized). However, if one of these entries is an active mount
point, stat(2) or readlink(2) on the mount target path can hang (e.g.
unreachable NFS server).

If the main table is not a kernel table, we parse /proc/self/mountinfo
into a secondary table and call mnt_cache_set_targets(). This allows
libmount to check that the target path of each entry in the main table
is not an active mount point, so it can avoid canonicalizing it.

Signed-off-by: Eric Rannaud <e@nanocritical.com>
2014-07-01 10:05:16 +02:00
Benno Schulenberg ab5b4f837d findmnt: minimally improve wording of usage text
Also sort the options better and tweak whitespace.

Signed-off-by: Benno Schulenberg <bensberg@justemail.net>
2014-06-30 10:22:26 +02:00
Benno Schulenberg 9421a1a3b3 findmnt: slightly improve wording and formatting in man page
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-06-30 10:22:07 +02:00
Karel Zak 097e7f2ff4 findmnt: add --nocanonicalize to avoid realpath()
* in some cases is realpath() overkill
 * sometimes you want to search for explicitly specified paths (e.g.
   "findmnt --fstab /mnt/symlink") rather than for real paths
 * you want to avoid readlink() and stat() on NFS

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-06-16 15:47:50 +02:00
Karel Zak 7734a6e3ec rename: remove reference to mmv gtom man page
It seems better to not have a reference to the program that is not
available in many cases on usual Linux installation.

Signed-off-by: Karel Zak <kzak@redhat.com>
2014-06-12 10:28:10 +02:00
Karel Zak 710ed55dcd libsmartcols: add debug messages
Signed-off-by: Karel Zak <kzak@redhat.com>
2014-06-06 13:47:06 +02:00
Ruediger Meier 60cb2c3720 build: fix some compiler warnings
Most of them catched on 32bit gcc and icc.

disk-utils/fsck.cramfs.c:     printf format type
lib/boottime.c:               unused variables
misc-utils/cal.c:             set but never used
sys-utils/losetup.c:          set but never used
sys-utils/lscpu-dmi.c:        defined but not used
sys-utils/switch_root.c:      comparison between signed and unsigned
tests/helpers/test_sysinfo.c: printf format type
2014-05-30 01:18:09 +02:00
Karel Zak 8c19519930 Merge branch 'uuid' of git://github.com/kerolasa/lelux-utiliteetit 2014-05-27 16:15:30 +02:00
Ruediger Meier 07ac4aa9d4 cal: all output must use my_putstring
Replace all puts, fputs and printf calls by my_putstring() because
we don't want to mix different output channels (buffers).

Signed-off-by: Ruediger Meier <ruediger.meier@ga-group.nl>
2014-05-27 16:12:56 +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 6328799db1 uuidgen: use type definitions from uuid.h
There is no need to re-invent wheel.

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