Commit graph

16268 commits

Author SHA1 Message Date
Thomas Hindoe Paaboel Andersen 41cb81eab9 terminal: silence warning 2014-07-18 13:32:40 +02:00
Tom Gundersen d243773263 networkd-wait-online: fix comilation warning
sd_rtnl_message_read_string() was changed to take a const argument, update the users.
2014-07-18 13:25:18 +02:00
David Herrmann a72e03749f autogen: add "t" switch with --enable-terminal
Just temporarily add a "t" switch to "./autogen t" runs with
--enable-terminal. Once it's compile-tested enough, we can add it to the
default flags.
2014-07-18 13:00:30 +02:00
David Herrmann 037ee337f0 journal: reduce test-journal-send timeout from 10s to 1s
The sleep(10) in test-journal-send is quite aggressive. We need it only
for the journal to get our cgroup information. But even that information
is not vital to the test, so a sleep(1) should be just fine.
2014-07-18 12:58:00 +02:00
David Herrmann 5ab887e98d terminal: add systemd-subterm example
The systemd-subterm example is a stacked terminal that shows how to
use sd-term. Instead of rendering images and displaying it via X11/etc.,
it uses its parent terminal to display the page (terminal-emulator inside
a terminal-emulator) (like GNU-screen and friends do).

This is only for testing and not installed system-wide!
2014-07-18 12:53:41 +02:00
David Herrmann e432f9e8f9 terminal: add screen-handling
The screen-layer represents the terminal-side (compared to the host-side).
It connects term_parser with term_page and implements all the required
control sequences.

We do not implement all available control sequences. Even though our
parser recognizes them, there is no need to handle them. Most of them are
legacy or unused. We try to be as compatible to xterm, so if we missed
something, we can implement it later. However, all the VT510 / VT440 stuff
can safely be skipped (who needs terminal macros? WTF?).

The keyboard-handling is still missing. It will be added once
systemd-console is available and we pulled in the key-definitions.
2014-07-18 12:53:41 +02:00
David Herrmann 1c9633d669 terminal: add parser state-machine
The term-parser is used to parse any input from TTY-clients. It reads CSI,
DCS, OSC and ST control sequences and normal escape sequences. It doesn't
do anything with the parsed data besides detecting the sequence and
returning it. The caller has to react to them.

The parser also comes with its own UTF-8 helpers. The reason for that is
that we don't want to assert() or hard-fail on parsing errors. Instead,
we treat any invalid UTF-8 sequences as ISO-8859-1. This allows pasting
invalid data into a terminal (which cannot be controlled through the TTY,
anyway) and we still deal with it in a proper manner.
This is _required_ for 8-bit and 7-bit DEC modes (including the g0-g3
mappings), so it's not just an ugly fallback because we can (it's still
horribly ugly but at least we have an excuse).
2014-07-18 12:53:41 +02:00
David Herrmann 28622e8f5b terminal: add page handling for terminals
The page-layer is a one-dimensional array of lines. Combined with the
one-dimensional lines, you get a two-dimensional page. However, both
implementations, lines and pages only deal with their own dimension. That
means, lines don't know anything about other lines, and pages don't know
anything about cells.

Apart from pages, this also introduces history objects. A history object
is a scroll-back buffer. As some pages like alt-buffers don't have
histories, we keep them separate.

Pages itself forward all cell-related operations to the related line. Only
line-related operations are directly handled by the page. This is mostly
scrolling and history. To support proper resizing, we also keep a
fill-state just like lines do for cells.
2014-07-18 12:53:41 +02:00
David Herrmann 952f4b5959 terminal: extend RGB attributes
There're 3 supported color-modes: term-color-codes, 256-color-code and
rgb-color. We now use the term-color as default so zero(attr) will do what
you'd expect. Furthermore, we split rgb and 256color so users can forward
them properly without requiring an internal RGB converter.

Furthermore, a "hidden" field according to VT510rm manual is added.
2014-07-18 12:53:41 +02:00
Lennart Poettering 1716f6dcf5 resolved: add LLMNR support for looking up names 2014-07-18 12:38:32 +02:00
Lennart Poettering 9d48598533 shared: rename PROTO_ADDRESS_SIZE() to FAMILY_ADDRESS_SIZE()
We mostly use "family" to refer to AF_INET, AF_INET6, etc, let's use
this terminology here, too
2014-07-18 12:38:32 +02:00
Lennart Poettering ca4e095ab9 sd-rtnl: make string returned by sd_rtnl_message_read_string() const 2014-07-18 12:38:32 +02:00
Thomas Hindoe Paaboel Andersen 0204152684 test-tables: fix build-scan 2014-07-17 23:54:12 +02:00
Tom Gundersen 6dcaa6f59a sd-network: fixup api
Do not expose link_is_loopback, people should just get this from rtnl directly.
Do not expose NTP servers as IP addresses, these must be strings.
Expose ifindex as int, not unsigned. This is what the kernel (mostly) and glibc uses.
2014-07-17 22:53:35 +02:00
Tom Gundersen 7de12ae764 networkd-wait-online: track links
Rather than refetching the link information on ever event, we liston to
rtnl to track them. Much code stolen from resolved.

This will allow us to simplify the sd-network api and don't expose
information available over rtnl.
2014-07-17 22:53:35 +02:00
Tom Gundersen 560852ced0 sd-network: expose 'unmanaged' as a regular state
This is useful to save in the consumer of the lib, unlike ENODATA/EBUSY which
means that the user should wait until a useful state is available.
2014-07-17 22:53:35 +02:00
Thomas Hindoe Paaboel Andersen 962225baa8 resolved: silence warnings
No need to write to r here since it will be overwritten as the first
step in parse_fail.
2014-07-17 21:12:39 +02:00
Thomas Hindoe Paaboel Andersen 99dfe1345c test-pty: silence a warning 2014-07-17 20:23:53 +02:00
Thomas Hindoe Paaboel Andersen f12ea7dad0 resolved: remove unused variable 2014-07-17 19:59:47 +02:00
Lennart Poettering b6b63571ae update TODO 2014-07-17 19:39:50 +02:00
Lennart Poettering 322345fdb9 resolved: add DNS cache 2014-07-17 19:39:50 +02:00
Lennart Poettering c5ed93163e resolved: don't trip up when an rtlink message does not include the MTU 2014-07-17 19:39:50 +02:00
Lennart Poettering ea30eb86e5 nss-util: be a tiny bit more compatible with glibc's lookup behaviour regarding IPv6
Check for RES_USE_INET6 before we prefer IPv6 over IPv4, for all our NSS
modules. (Not that the DNS resolver that is configured with this matters
to us, but hey, let's try to be compatible).
2014-07-17 19:39:50 +02:00
Thomas Blume a71516dfd1 detect-virt: Fix Xen domU discovery
The conditional for detection xen virtualization contained a little mistake.
It is checking for i to be empty: 'if (!i)  {', but it must check for cap instead,
because: 'cap = strsep(&i, ",")' will set cap to the discovered value and i to
the next value after the separator.
Hence, i would be empty, if there is only control_d in domcap, leading to a wrong
domU detection.

https://bugs.freedesktop.org/show_bug.cgi?id=77271
2014-07-17 08:26:35 -04:00
Zbigniew Jędrzejewski-Szmek 6eb33ab207 networkd: fix colud typo
sztanpet> if your already there, might fixing "Colud" to Could in 53af3b7
2014-07-17 08:14:15 -04:00
Zbigniew Jędrzejewski-Szmek fa8b8030a4 units: fix typo
vrutkovs> zbyszek:
http://cgit.freedesktop.org/systemd/systemd/diff/units/systemd-journal-upload.service.in?id=ad95fd1d2b9c6344864857c2ba7634fd87753f8e - typo in Group name
2014-07-17 08:08:38 -04:00
David Herrmann 84da4a3022 ui/term: add line/cell/char handling for terminal pages
This commit introduces libsystemd-ui, a systemd-internal helper library
that will contain all the UI related functionality. It is going to be used
by systemd-welcomed, systemd-consoled, systemd-greeter and systemd-er.
Further use-cases may follow.

For now, this commit only adds terminal-page handling based on lines only.
Follow-up commits will add more functionality.
2014-07-17 11:48:40 +02:00
David Herrmann 3496b9eeaf nspawn: fix barrier-destroy call
I dropped the cleanup-helper before pushing so use _cleanup_() directly.
2014-07-17 11:48:39 +02:00
David Herrmann a47d1dfd08 shared: add PTY helper
This Pty API wraps the ugliness that is POSIX PTY. It takes care of:
  - edge-triggered HUP handling (avoid heavy CPU-usage on vhangup)
  - HUP vs. input-queue draining (handle HUP _after_ draining the whole
    input queue)
  - SIGCHLD vs. HUP (HUP is no reliable way to catch PTY deaths, always
    use SIGCHLD. Otherwise, vhangup() and friends will break.)
  - Output queue buffering (async EPOLLOUT handling)
  - synchronous setup (via Barrier API)

At the same time, the PTY API does not execve(). It simply fork()s and
leaves everything else to the caller. Usually, they execve() but we
support other setups, too.

This will be needed by multiple UI binaries (systemd-console, systemd-er,
...) so it's placed in src/shared/. It's not strictly related to
libsystemd-terminal, so it's not included there.
2014-07-17 11:39:48 +02:00
David Herrmann a2da110b78 nspawn: use Barrier API instead of eventfd-util
The Barrier-API simplifies cross-fork() synchronization a lot. Replace the
hard-coded eventfd-util implementation and drop it.

Compared to the old API, Barriers also handle exit() of the remote side as
abortion. This way, segfaults will not cause the parent to deadlock.

EINTR handling is currently ignored for any barrier-waits. This can easily
be added, but it isn't needed so far so I dropped it. EINTR handling in
general is ugly, anyway. You need to deal with pselect/ppoll/... variants
and make sure not to unblock signals at the wrong times. So genrally,
there's little use in adding it.
2014-07-17 11:34:25 +02:00
David Herrmann 279da1e3f9 shared: add generic IPC barrier
The "Barrier" object is a simple inter-process barrier implementation. It
allows placing synchronization points and waiting for the other side to
reach it. Additionally, it has an abortion-mechanism as second-layer
synchronization to send abortion-events asynchronously to the other side.

The API is usually used to synchronize processes during fork(). However,
it can be extended to pass state through execve() so you could synchronize
beyond execve().

Usually, it's used like this (error-handling replaced by assert() for
simplicity):

    Barrier b;

    r = barrier_init(&b);
    assert_se(r >= 0);

    pid = fork();
    assert_se(pid >= 0);
    if (pid == 0) {
            barrier_set_role(&b, BARRIER_CHILD);

            ...do child post-setup...
            if (CHILD_SETUP_FAILED)
                       exit(1);
            ...child setup done...

            barrier_place(&b);
            if (!barrier_sync(&b)) {
                    /* parent setup failed */
                    exit(1);
            }

            barrier_destroy(&b); /* redundant as execve() and exit() imply this */

            /* parent & child setup successful */
            execve(...);
    }

    barrier_set_role(&b, BARRIER_PARENT);

    ...do parent post-setup...
    if (PARENT_SETUP_FAILED) {
            barrier_abort(&b);          /* send abortion event */
            barrier_wait_abortion(&b);  /* wait for child to abort (exit() implies abortion) */
            barrier_destroy(&b);
           ...bail out...
    }
    ...parent setup done...

    barrier_place(&b);
    if (!barrier_sync(&b)) {
            ...child setup failed... ;
            barrier_destroy(&b);
            ...bail out...
    }

    barrier_destroy(&b);

    ...child setup successfull...

This is the most basic API. Using barrier_place() to place barriers and
barrier_sync() to perform a full synchronization between both processes.
barrier_abort() places an abortion barrier which superceeds any other
barriers, exit() (or barrier_destroy()) places an abortion-barrier that
queues behind existing barriers (thus *not* replacing existing barriers
unlike barrier_abort()).

This example uses hard-synchronization with wait_abortion(), sync() and
friends. These are all optional. Barriers are highly dynamic and can be
used for one-way synchronization or even no synchronization at all
(postponing it for later). The sync() call performs a full two-way
synchronization.

The API is documented and should be fairly self-explanatory. A test-suite
shows some special semantics regarding abortion, wait_next() and exit().

Internally, barriers use two eventfds and a pipe. The pipe is used to
detect exit()s of the remote side as eventfds do not allow that. The
eventfds are used to place barriers, one for each side. Barriers itself
are numbered, but the numbers are reused once both sides reached the same
barrier, thus you cannot address barriers by the index. Moreover, the
numbering is implicit and we only store a counter. This makes the
implementation itself very lightweight, which is probably negligible
considering that we need 3 FDs for a barrier..

Last but not least: This barrier implementation is quite heavy. It's
definitely not meant for fast IPC synchronization. However, it's very easy
to use. And given the *HUGE* overhead of fork(), the barrier-overhead
should be negligible.
2014-07-17 11:34:00 +02:00
Zbigniew Jędrzejewski-Szmek 18abe7bd3e core: nicer message when inotify watches are exhausted
inotify_add_watch returns ENOSPC, which translates to
"No space left on device", which is misleading.

https://bugs.freedesktop.org/show_bug.cgi?id=73628
2014-07-16 22:53:07 -04:00
Zbigniew Jędrzejewski-Szmek 8c275eef38 man: document yearly and annually in systemd.time(7)
https://bugs.freedesktop.org/show_bug.cgi?id=81158
2014-07-16 22:18:16 -04:00
Lennart Poettering 39762fdf67 resolved: enforce limit on concurrent outstanding queries 2014-07-17 01:58:14 +02:00
Lennart Poettering 634af5665f sd-login: always use "indices" as plural of "index"
So far both "indexes" and "indices" was used. Let's clean this up, and
stick to indices, since it appears to be used more frequently.
2014-07-17 01:48:40 +02:00
Lennart Poettering d12b8cad40 sd-network: rename "index" parameter to "ifindex"
makes things a bit clearer and avoids any clashes with libc's index()
symbol.
2014-07-17 01:46:21 +02:00
Lennart Poettering 8b9652a711 sd-network: if a boolean is mising, we should just take it as false
That way, we can deprecate fields later on without problems
2014-07-17 01:42:26 +02:00
Lennart Poettering a2ba62c719 sd-network: remove redundant array size parameter from functions that return arrays
As long as the number of array entries is relatively small it's nicer to
simply return the number of entries directly, instead of using a size_t*
return parameter for it.
2014-07-17 01:42:26 +02:00
Lennart Poettering b45d9e86e4 resolved: fix check for mdns names 2014-07-17 01:41:52 +02:00
Lennart Poettering faec72d5de resolved: we are never authoritative for localhost 2014-07-17 01:41:52 +02:00
Lennart Poettering e1c959948c resolved: properly handle MTU logic 2014-07-17 01:41:52 +02:00
Lennart Poettering 76f468c8ea dns-domain: enforce maximum DNS domain name length 2014-07-17 01:41:52 +02:00
Lennart Poettering 0014a4ad50 sd-network: fix parameter order for sd_network_monitor_new()
Constructors should return the object they created as first parameter,
except when they are generated as a child/member object of some other
object in which case that should be first.
2014-07-17 01:41:52 +02:00
Daniel Korostil 260b6323cc po: add Ukrainian translation 2014-07-16 19:19:31 -04:00
Zbigniew Jędrzejewski-Szmek 54f3ff079f journal/verify: flush progress bar, print offset in more places
Before, fragments of the progress bar would remain when
errors or warnings were printed.
2014-07-16 19:00:03 -04:00
Zbigniew Jędrzejewski-Szmek 86bbe5bfbc test-tables: add new entries
One missing string found.

A few things had to be moved around to make it possible to test them.
2014-07-16 19:00:03 -04:00
Zbigniew Jędrzejewski-Szmek e46eab86cd tty-ask-password-agent: modernization 2014-07-16 19:00:03 -04:00
Zbigniew Jędrzejewski-Szmek ed88bcfb7c Be more careful when checking for empty files
If we want to avoid reading a totally empty file, it seems better
to check after we have opened the file, not before.
2014-07-16 19:00:03 -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
Kay Sievers e1bbf3d12f resolved: do not free() sd_dhcp_lease_get_dns() results 2014-07-16 23:50:45 +02:00