Commit graph

329 commits

Author SHA1 Message Date
Lennart Poettering 4015ac5c32 journal-upload: allow the tool to start 2014-08-20 00:18:14 +02:00
Lennart Poettering dad29dff19 cmdline: for new tools avoid introduce new negative switches, and properly align --help texts
Negative switches are a bad un-normalized thing. We alerady have some,
but we should try harder to avoid intrdoucing new ones.

Hence, instead of adding two switches:

        --foobar
        --no-foobar

Let's instead use the syntax

        --foobar
        --foobar=yes
        --foobar=no

Where the first two are equivalent. The boolean argument is parsed
following the usual rules.

Change all new negative switches this way.

This patch also properly aligns the --help table, so that single char
switches always get a column separate of the long switches.
2014-08-20 00:18:14 +02:00
Lennart Poettering d7bf74d9cc journal-remote: fix parsing of fd command line argument 2014-08-11 18:24:43 +02:00
Zbigniew Jędrzejewski-Szmek 601185b43d Unify parse_argv style
getopt is usually good at printing out a nice error message when
commandline options are invalid. It distinguishes between an unknown
option and a known option with a missing arg. It is better to let it
do its job and not use opterr=0 unless we actually want to suppress
messages. So remove opterr=0 in the few places where it wasn't really
useful.

When an error in options is encountered, we should not print a lengthy
help() and overwhelm the user, when we know precisely what is wrong
with the commandline. In addition, since help() prints to stdout, it
should not be used except when requested with -h or --help.

Also, simplify things here and there.
2014-08-03 21:46:07 -04:00
Zbigniew Jędrzejewski-Szmek 799a8f39d8 journal-remote: rename KEY_FILE to avoid confict with <linux/input.h> 2014-08-03 01:12:30 -04:00
Zbigniew Jędrzejewski-Szmek b2fadec604 Properly report invalid quoted strings
$ systemd-analyze verify trailing-g.service
[./trailing-g.service:2] Trailing garbage, ignoring.
trailing-g.service lacks ExecStart setting. Refusing.
Error: org.freedesktop.systemd1.LoadFailed: Unit trailing-g.service failed to load: Invalid argument.
Failed to create trailing-g.service/start: Invalid argument
2014-07-31 08:56:03 -04:00
Zbigniew Jędrzejewski-Szmek a2a5291b3f Reject invalid quoted strings
String which ended in an unfinished quote were accepted, potentially
with bad memory accesses.

Reject anything which ends in a unfished quote, or contains
non-whitespace characters right after the closing quote.

_FOREACH_WORD now returns the invalid character in *state. But this return
value is not checked anywhere yet.

Also, make 'word' and 'state' variables const pointers, and rename 'w'
to 'word' in various places. Things are easier to read if the same name
is used consistently.

mbiebl_> am I correct that something like this doesn't work
mbiebl_> ExecStart=/usr/bin/encfs --extpass='/bin/systemd-ask-passwd "Unlock EncFS"'
mbiebl_> systemd seems to strip of the quotes
mbiebl_> systemctl status shows
mbiebl_> ExecStart=/usr/bin/encfs --extpass='/bin/systemd-ask-password Unlock EncFS  $RootDir $MountPoint
mbiebl_> which is pretty weird
2014-07-31 04:00:31 -04:00
Zbigniew Jędrzejewski-Szmek 36f822c4bd Let config_parse open file where applicable
Special care is needed so that we get an error message if the
file failed to parse, but not when it is missing. To avoid duplicating
the same error check in every caller, add an additional 'warn' boolean
to tell config_parse whether a message should be issued.
This makes things both shorter and more robust wrt. to error reporting.
2014-07-16 18:47:20 -04:00
Zbigniew Jędrzejewski-Szmek 40780a626d journal-remote: remove obsolete variable 2014-07-16 07:53:02 -04:00
Zbigniew Jędrzejewski-Szmek a812a8816c journal-remote: fix double typedef and add missing header 2014-07-16 07:53:02 -04:00
Zbigniew Jędrzejewski-Szmek 92b10cbccd journal-remote: avoid copying input data
Instead of copying fields into new memory allocations, simply keep pointers
into the receive buffer. Data in this buffer is only copied when there is not
enough space for new data and a large chunk of the buffer contains old data.
2014-07-15 22:34:42 -04:00
Zbigniew Jędrzejewski-Szmek 93c0969cf9 µhttp-util: fix compilation without gnutls 2014-07-15 22:34:42 -04:00
Zbigniew Jędrzejewski-Szmek 29fc0ddcd7 journal-upload: add config file 2014-07-15 22:34:41 -04:00
Zbigniew Jędrzejewski-Szmek 5bc891206d journal-remote: let user specify just the main part of the url
We can append /upload ourselves.
2014-07-15 22:34:41 -04:00
Zbigniew Jędrzejewski-Szmek 9ff48d0982 journal-remote: rework fd and writer reference handling 2014-07-15 22:34:41 -04:00
Zbigniew Jędrzejewski-Szmek a83f403760 journal-remote: improve some messages 2014-07-15 22:34:41 -04:00
Zbigniew Jędrzejewski-Szmek 4a0a6ac038 Fix problem with allocating large buffers and log leftovers 2014-07-15 22:34:40 -04:00
Zbigniew Jędrzejewski-Szmek 8201af08fa journal-remote: allow splitting incoming logs by source host
Previously existing scheme where the file name would be based on
the source was just too ugly and unpredicatable. Now there are
only two options:
  1. just one file (until rotation),
  2. one file per source host, using the hostname as filename part.
For the cases where the source is specified by the user, only
option one is allowed, and the full of the file must be specified.
2014-07-15 22:31:41 -04:00
Zbigniew Jędrzejewski-Szmek 24739b7b75 Allow addresses to be specified for --listen-... args
Hostnames still aren't accepted.
2014-07-15 22:31:40 -04:00
Zbigniew Jędrzejewski-Szmek d3b7fd541b Add simple generator of fake journal export stream 2014-07-15 22:31:40 -04:00
Zbigniew Jędrzejewski-Szmek ad95fd1d2b journal-remote: add units and read certs from default locations 2014-07-15 22:23:49 -04:00
Zbigniew Jędrzejewski-Szmek a3152e7655 journal-upload: add watchdog support 2014-07-15 22:23:48 -04:00
Zbigniew Jędrzejewski-Szmek 722b679565 journal-upload: make state persistent 2014-07-15 22:23:48 -04:00
Zbigniew Jędrzejewski-Szmek eacbb4d33e journal-upload: use journal as the source 2014-07-15 22:23:48 -04:00
Zbigniew Jędrzejewski-Szmek 7449bc1f34 journal-upload: HTTPS support 2014-07-15 22:23:48 -04:00
Zbigniew Jędrzejewski-Szmek 3d090cc6f3 journal-upload: a tool to push messages to systemd-journal-remote 2014-07-15 22:23:48 -04:00
Zbigniew Jędrzejewski-Szmek 851d4e2a67 journal-remote: reject fields above maximum size
Also fix an infinite loop on E2BIG.

Remember what range we already scanned for '\n', to avoid
quadratic behaviour on long "text" fields.
2014-07-15 22:23:47 -04:00
Zbigniew Jędrzejewski-Szmek 5c879495ea journal-remote: small fixes 2014-07-15 22:23:47 -04:00
Zbigniew Jędrzejewski-Szmek 1e4e7b71e1 Move network-related journal programs to src/journal-remote/
Directory src/journal has become one of the largest directories,
and since systemd-journal-gatewayd, systemd-journal-remote, and
forthcoming systemd-journal-upload are all closely related, create
a separate directory for them.
2014-07-15 22:23:47 -04:00