1
0
mirror of https://github.com/systemd/systemd.git synced 2024-11-07 09:56:51 +03:00
Commit Graph

728 Commits

Author SHA1 Message Date
Lennart Poettering
9bfa2c029d bus: _printf_ attributes should be on prototypes not function definitions for non-static functions 2013-12-15 23:43:47 +01:00
Thomas Hindoe Paaboel Andersen
899839b9f8 test-journal-syslog: use streq_ptr since we pass in NULL 2013-12-15 02:31:01 +01:00
Thomas Hindoe Paaboel Andersen
9091e686f4 Add more _printf_'s for format-nonliterals
Clang is a bit more strict wrt format-nonliterals:
http://clang.llvm.org/docs/LanguageExtensions.html#format-string-checking

Adding these extra printf attributes also makes gcc able to find more
problems. E.g. this patch uncovers a format issue in udev-builtin-path_id.c

Some parts looked intetional about breaking the format-nonliteral check.
I added some supression for warnings there.
2013-12-14 13:32:22 +01:00
Lennart Poettering
7b77ed8cf3 event: be more conservative when returning errors from event handler callbacks
We really should return errors from event handlers if we have a
continous problem and don't know any other solution.
2013-12-13 04:06:43 +01:00
Lennart Poettering
6203e07a83 event: rework sd-event exit logic
With this change a failing event source handler will not cause the
entire event loop to fail. Instead, we just disable the specific event
source, log a message at debug level and go on.

This also introduces a new concept of "exit code" which can be stored in
the event loop and is returned by sd_event_loop(). We also rename "quit"
to "exit" everywhere else.

Altogether this should make things more robus and keep errors local
while still providing a way to return event loop errors in a clear way.
2013-12-13 04:06:43 +01:00
Djalal Harouni
faf5077f89 journal: pipe journalctl help output into a pager
journalctl help output might run off the screen, so be consistent
as other systemd tools do and pipe it into a pager.
2013-12-11 22:26:55 -05:00
Lennart Poettering
21c6dc33a6 journald: make sure the stdout/stderr stream fd is removed from epoll before we close it 2013-12-11 23:36:59 +01:00
Lennart Poettering
e9174f29c7 journald: cache cgroup root path, instead of querying it on every incoming log message 2013-12-11 23:31:07 +01:00
Lennart Poettering
897395791f journal: when listing logs of a container make sure we don't accidentally show messages from host too 2013-12-11 23:10:36 +01:00
Lennart Poettering
0c24bb2346 journald: cache hostname, boot_id and machine_id fields instead of generating them fresh for each log entry 2013-12-11 22:55:57 +01:00
Lennart Poettering
91bf3b3e12 journal: don't go belly up when an stdout/stderr client terminates the connection 2013-12-11 22:17:15 +01:00
Lennart Poettering
b6741478e7 journal: add ability to browse journals of running OS containers
This adds the new library call sd_journal_open_container() and a new
"-M" switch to journalctl. Particular care is taken that journalctl's
"-b" switch resolves to the current boot ID of the container, not the
host.
2013-12-11 22:04:03 +01:00
Lennart Poettering
f9a810beda journald: port to sd-event and enable watchdog support 2013-12-11 20:55:09 +01:00
Zbigniew Jędrzejewski-Szmek
e3bfb7be07 journald: malloc less when streaming messages 2013-12-10 20:38:33 -05:00
Lennart Poettering
14c1025934 journald: use a bit more cleanup magic! 2013-12-10 19:51:47 +00:00
Dan McGee
2d43b19090 Ensure unit is journaled for short-lived or oneshot processes
In the time it takes to process incoming log messages, the process we
are logging details for may exit. This means the cgroup data is no
longer available from '/proc'. Unfortunately, the way the code was
structured before, we never log _SYSTEMD_UNIT if we don't have this
cgroup information.

Add an else if case that allows the passed in unit_id to be logged even
if we couldn't capture cgroup information. This ensures a command like
`journalctl -u run-XXX` will return all log messages from a oneshot
process.
2013-12-10 07:40:55 -05:00
Dan McGee
f92ae4968f Fix memory leak in stdout journal streams
Just as 'identifier' is strdup-ed and freed, we need to do the same for
unit_id.
2013-12-08 13:15:59 -08:00
Zbigniew Jędrzejewski-Szmek
2b6bf07dd2 Get rid of our reimplementation of basename
The only problem is that libgen.h #defines basename to point to it's
own broken implementation instead of the GNU one. This can be fixed
by #undefining basename.
2013-12-06 21:29:55 -05:00
Thomas Hindoe Paaboel Andersen
f168c27313 trivial coding style clean ups
- Add space between if/for and the opening parentheses
- Place the opening brace on same line as the function (not for  udev)

From the CODING_STYLE
Try to use this:
    void foo() {
    }
instead of this:
    void foo()
    {
    }
2013-12-03 22:27:45 +01:00
Zbigniew Jędrzejewski-Szmek
6c045c0b4c journal: fail silently in sd_j_sendv() if journal is unavailable
"syslog(3) and sd_journal_print() may largely be used interchangeably
functionality-wise" according to sd_journal_print(3). This socket
should be always available except in rare circumstatances, and we
don't random applications to fail on logging, so let's do what syslog
did. The alternative of forcing all callers to do error handling for
this rare case doesn't really have any benefits, since if they can't
log there isn't much they can do anyway.

https://bugzilla.redhat.com/show_bug.cgi?id=1023041
2013-12-03 12:11:18 -05:00
Zbigniew Jędrzejewski-Szmek
c7332b0844 catalog: determine language from the filename 2013-12-02 22:12:02 -05:00
Thomas Hindoe Paaboel Andersen
1ae464e093 Use assert_return in more of the public API 2013-12-02 23:13:58 +01:00
Lennart Poettering
fbb634117d journald: mention how long we needed to flush to /var in the logs 2013-11-27 02:39:19 +01:00
Lennart Poettering
eda4b58b50 journal: simplify pre-allocation logic
let's just do a single fallocate() as far as possible, and don't
distuingish between allocated space and file size.

This way we can save a syscall for each append, which makes quite some
benefits.
2013-11-27 01:50:36 +01:00
Lennart Poettering
d0767ffd08 journal: add a test case for flushing messages out of a series of journal files into a single new one 2013-11-27 01:01:53 +01:00
Lennart Poettering
248c78c79c journal: allow journal_file_copy_entry() to work on non-local files 2013-11-27 00:59:07 +01:00
Lennart Poettering
e5462cd80e journal: fix iteration when we go backwards from the beginning of an array chain element 2013-11-27 00:58:39 +01:00
Lennart Poettering
f268980d2c journal: optimize bisection logic a bit by caching the last position
This way we can do a quick restart limiting a bit how wildly we need to
jump around during the bisection process.
2013-11-26 20:37:53 +01:00
Lennart Poettering
bf807d4dbf journald: keep statistics on how of we hit/miss the mmap cache 2013-11-26 18:58:44 +01:00
Lennart Poettering
b8e891e699 journal: make table const 2013-11-26 18:46:03 +01:00
Lennart Poettering
a676e66535 journal: when appending to journal file, allocate larger blocks at once 2013-11-26 18:46:03 +01:00
Daniel Buch
f5f6d0e255 tree-wide usage of %m specifier instead of strerror(errno)
Also for log_error() except where a specific error is specified

e.g. errno ? strerror(errno) : "Some user specified message"
2013-11-26 21:07:46 +10:00
Tom Gundersen
71a6151083 conf-parser: distinguish between multiple sections with the same name
Pass on the line on which a section was decleared to the parsers, so they
can distinguish between multiple sections (if they chose to). Currently
no parsers take advantage of this, but a follow-up patch will do that
to distinguish

[Address]
Address=192.168.0.1/24
Label=one

[Address]
Address=192.168.0.2/24
Label=two

from

[Address]
Address=192.168.0.1/24
Label=one
Address=192.168.0.2/24
Label=two
2013-11-25 19:35:44 +01:00
Karel Zak
4561be3a64 Remove duplicate includes 2013-11-18 20:28:55 -05:00
Umut Tezduyar Lindskog
ad79565d6b journal: timestamp support on console messages
journald mimics the kernel here: timestamps will be printed if
/sys/module/printk/parameters/time contains "Y".
2013-11-13 22:44:37 -05:00
Lennart Poettering
76b543756e bus: introduce concept of a default bus for each thread and make use of it everywhere
We want to emphasize bus connections as per-thread communication
primitives, hence introduce a concept of a per-thread default bus, and
make use of it everywhere.
2013-11-12 00:12:43 +01:00
Lennart Poettering
9588bc3209 Remove dead code and unexport some calls
"make check-api-unused" informs us about code that is not used anymore
or that is exported but only used internally. Fix these all over the
place.
2013-11-08 18:12:45 +01:00
Lennart Poettering
baabc09191 journal: fix minor memory leak 2013-11-08 14:07:27 +01:00
Lennart Poettering
47c649b5de bus: use new property retrieval calls everywhere 2013-11-07 22:17:19 +01:00
Lennart Poettering
eb9da376d7 clients: unify how we invoke getopt_long()
Among other things this makes sure we always expose a --version command
and show it in the help texts.
2013-11-06 18:28:39 +01:00
Lennart Poettering
74df0fca09 util: unify reading of /proc/cmdline
Instead of individually checking for containers in each user do this
once in a new call proc_cmdline() that read the file only if we are not
in a container.
2013-11-06 03:15:16 +01:00
Zbigniew Jędrzejewski-Szmek
f11880744c journalctl: add --list-boots to show boot IDs and times
Suggested by David Wilkins <dwilkins@maths.tcd.ie> in
https://bugzilla.redhat.com/show_bug.cgi?id=967521:

> [Specific boot ID is a] bit of a palaver to obtain.  I consulted the
> verbose dump of the journal to discover the _BOOT_ID for the
> timestamp, and then generated the journal dump for that boot using
> journalctl _BOOT_ID=foo -o short-monotonic.
2013-10-28 23:43:57 -04:00
Lennart Poettering
40ca29a137 timedated: use libsystemd-bus instead of libdbus for bus communication
Among other things this also adds a few things necessary for the change:

- Considerably more powerful error returning APIs in libsystemd-bus

- Adapter for connecting an sd_bus to an sd_event

- As I reworked the PolicyKit logic to the new library I also made it
  asynchronous, so that PolicyKit requests of one user cannot block out
  another user anymore.

- We always use the macro names for common bus error. That way it is
  harder to mistype them since the compiler will notice
2013-10-16 06:15:02 +02:00
Lennart Poettering
44b601bc79 macro: clean up usage of gcc attributes
Always use our own macros, and name all our own macros the same style.
2013-10-16 06:14:59 +02:00
Lennart Poettering
71fda00f32 list: make our list macros a bit easier to use by not requring type spec on each invocation
We can determine the list entry type via the typeof() gcc construct, and
so we should to make the macros much shorter to use.
2013-10-14 06:11:19 +02:00
Lennart Poettering
14bf2c9d37 util: allow trailing semicolons on define_trivial_cleanup_func lines
Emacs C indenting really gets confused by these lines if they carry no
trailing semicolon, hence let's make this nicer for good old emacs. The
other macros which define functions already do this too, so let's copy
the scheme here.

Also, let's use an uppercase name for the macro. So far our rough rule
was that macros that are totally not function-like (like this ones,
which define a function) are uppercase. (Well, admittedly it is a rough
rule only, for example function and variable decorators are all
lower-case SINCE THE CONSTANT YELLING IN THE SOURCES WOULD SUCK, and
also they at least got underscore prefixes.) Also, the macros that
define functions that we already have are all uppercase, so let's do the
same here...
2013-10-14 06:11:19 +02:00
Zbigniew Jędrzejewski-Szmek
1ca208fb4f Introduce udev object cleanup functions 2013-10-13 17:56:55 -04:00
Zbigniew Jędrzejewski-Szmek
872c8faaf2 Fix write-only use of a few variables
Since the invention of read-only memory, write-only memory has been
considered deprecated. Where appropriate, either make use of the
value, or avoid writing it, to make it clear that it is not used.
2013-10-13 17:56:54 -04:00
Zbigniew Jędrzejewski-Szmek
7ca9dffae1 journald: use greedy_realloc in one place 2013-10-13 17:56:54 -04:00
Zbigniew Jędrzejewski-Szmek
7ff7394d9e Never call qsort on potentially NULL arrays
This extends 62678ded 'efi: never call qsort on potentially
NULL arrays' to all other places where qsort is used and it
is not obvious that the count is non-zero.
2013-10-13 17:56:54 -04:00