Age | Commit message (Collapse) | Author |
|
Remove some garbage code inherited from `systemd`
|
|
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
|
|
Make sure to extract the log-priority when comparing against
max-log-level, otherwise, we will always drop those messages.
This fixes bus-proxyd to properly send warnings on policy blocks.
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
|
|
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
|
|
|
|
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
|
|
We originally only supported the BMP (i.e., we treated UTF-16 as UCS-2).
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
|
|
Originally we only supported ucs2, so move the ucs4 version from libsystemd-terminal to shared
and use that everywhere.
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
|
|
There is alot of cleanup that will have to happen to turn on
-fstrict-aliasing, but I think our code should be "correct" to the rule.
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
|
|
hidden_file() is a bit more precise, since dot files usually shouldn't
be ignored, but certainly be considered hidden.
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
|
|
extra "#" to the name
That way, we have a simple, somewhat reliable way to detect such
temporary files, by simply checking if they start with ".#".
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
|
|
Commit a2a5291b3f5 changed the parser to reject unfinished quoted
strings. Unfortunately it introduced an error where a trailing
backslash would case an infinite loop. Of course this must fixed, but
the question is what to to instead. Allowing trailing backslashes and
treating them as normal characters would be one option, but this seems
suboptimal. First, there would be inconsistency between handling of
quoting and of backslashes. Second, a trailing backslash is most
likely an error, at it seems better to point it out to the user than
to try to continue.
Updated rules:
ExecStart=/bin/echo \\ → OK, prints a backslash
ExecStart=/bin/echo \ → error
ExecStart=/bin/echo "x → error
ExecStart=/bin/echo "x"y → error
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
|
|
This fixes 2 problems introduced by 6feeeab0bc:
1) If name_to_handle_at returns ENOSYS for the child, we'll wrongly
return -ENOSYS when it returns the same for the parent. Immediately
jump to the fallback logic when we get ENOSYS.
2) If name_to_handle_at returns EOPNOTSUPP for the child but suceeds
for the parent, we'll be comparing an uninitialized value (mount_id) to
an initialized value (mount_id_parent). Initialize the mount_id
variables to invalid mount_ids to avoid this.
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
|
|
If child supports, but the parent does not, or when the child does
not support, but the parent does, assume the child is a mount point.
Only if neither supports use the fallback.
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
|
|
c0e57ba9e22ee937722958d8b912ade2a37f206d fixed the fallback path.
We should do the same for name_to_handle_at().
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
|
|
[zj: When we lstat the target path, symlinks above the last component
will be followed by both stat and lstat. So when we look at the
parent, we should follow symlinks.]
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
|
|
This frees the elements of the strv without freeing the strv itself.
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
|
|
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
|
|
src/shared/utf8.c:268:13: warning: unused variable 'd'
[-Wunused-variable]
int d;
|
|
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
|
|
There will be more debugging options later.
--enable-debug will enable them all.
--enable-debug=hashmap will enable only hashmap debugging.
Also rename the C #define to ENABLE_DEBUG_* pattern.
NOTE: We add the debugging code to hashmap.{c,h} but do not
add the option in configure.ac. We may do so at a later time.
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
|
|
This is part of upstream's e7eebcfc42f00aa481ef31abc8e7e243c16f5b2c
in which they add a minimal JSON tokenizer. We don't add that but
update utf8 stuff from that commit to follow upstream more closely.
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
|
|
An early version used underscore prefixes for internal functions, but
the current version uses the prefix "internal_".
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
|
|
Upstream change the behaviour of tempfn_xxxxxx() to make
the following work:
# systemd-nspawn -xb -D / -M foobar
in commit c4e34a612c81266773cf8358cb38a43d2e43474e. We
have no reason not to follow that change even though
eudev has nothing to do with nspawn.
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
|
|
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
|
|
resulting name is actually valid
Also, rename filename_is_safe() to filename_is_valid(), since it
actually does a full validation for what the kernel will accept as file
name, it's not just a heuristic.
NOTE: eudev doesn't have filename_is_safe() -- AGB
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
|
|
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
|
|
Let's add some syntactic sugar for iterating through inotify events, and
use it everywhere.
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
|
|
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
|
|
We need original socket_fd around otherwise mac_selinux_get_child_mls_label
fails with -EINVAL return code. Also don't call setexeccon twice but rather pass
context value of SELinuxContext option as an extra argument.
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
|
|
environ is already defined in unistd.h
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
|
|
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
|
|
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
|
|
Using the same scripts as in f647962d64e "treewide: yet more log_*_errno
+ return simplifications".
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
|
|
If the format string contains %m, clearly errno must have a meaningful
value, so we might as well use log_*_errno to have ERRNO= logged.
Using:
find . -name '*.[ch]' | xargs sed -r -i -e \
's/log_(debug|info|notice|warning|error|emergency)\((".*%m.*")/log_\1_errno(errno, \2/'
Plus some whitespace, linewrap, and indent adjustments.
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
|
|
On the contrary of env, the added function returns all characters
cescaped, because it improves reproducibility.
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
|
|
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
|
|
- Rename log_meta() → log_internal(), to follow naming scheme of most
other log functions that are usually invoked through macros, but never
directly.
- Rename log_info_object() to log_object_info(), simply because the
object should be before any other parameters, to follow OO-style
programming style.
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
|
|
log_error_errno() as log calls that take error numbers
This change has two benefits:
- The format string %m will now resolve to the specified error (or to
errno if the specified error is 0. This allows getting rid of a ton of
strerror() invocations, a function that is not thread-safe.
- The specified error can be passed to the journal in the ERRNO= field.
Now of course, we just need somebody to convert all cases of this:
log_error("Something happened: %s", strerror(-r));
into thus:
log_error_errno(-r, "Something happened: %m");
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
|
|
In service file, if the file has some of special SMACK label in
ExecStart= and systemd has no permission for the special SMACK label
then permission error will occurred. To resolve this, systemd should
be able to set its SMACK label to something accessible of ExecStart=.
So introduce new SmackProcessLabel. If label is specified with
SmackProcessLabel= then the child systemd will set its label to
that. To successfully execute the ExecStart=, accessible label should
be specified with SmackProcessLabel=.
Additionally, by SMACK policy, if the file in ExecStart= has no
SMACK64EXEC then the executed process will have given label by
SmackProcessLabel=. But if the file has SMACK64EXEC then the
SMACK64EXEC label will be overridden.
[zj: reword man page]
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
|
|
already is in the set
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
|
|
fix 1237557 Unchecked return value from library
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
|
|
|
|
utf8_is_printable_newline()
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
|
|
Also, make all parsing of the kernel cmdline non-fatal.
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
|
|
The SELinux policy defines no context for some files. E.g.:
$ matchpathcon /run/lock/subsys /dev/mqueue
/run/lock/subsys <<none>>
/dev/mqueue <<none>>
We still need to be able to create them.
In this case selabel_lookup_raw() returns ENOENT. We should then skip
setfscreatecon(), but still return success.
It was broken since c34255bdb2 ("label: unify code to make directories,
symlinks").
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
|
|
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
|
|
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
|
|
We reintroduce hashmap.{h,c}, list.h and set.h verbatim from upstream,
before we punt dead code. The following is the upstream message:
This is a rewrite of the hashmap implementation. Its advantage is lower
memory usage.
It uses open addressing (entries are stored in an array, as opposed to
linked lists). Hash collisions are resolved with linear probing and
Robin Hood displacement policy. See the references in hashmap.c.
Some fun empirical findings about hashmap usage in systemd on my laptop:
- 98 % of allocated hashmaps are Sets.
- Sets contain 78 % of all entries, plain Hashmaps 17 %, and
OrderedHashmaps 5 %.
- 60 % of allocated hashmaps contain only 1 entry.
- 90 % of allocated hashmaps contain 5 or fewer entries.
- 75 % of all entries are in hashmaps that use trivial_hash_ops.
Clearly it makes sense to:
- store entries in distinct entry types. Especially for Sets - their
entries are the most numerous and they require the least information
to store an entry.
- have a way to store small numbers of entries directly in the hashmap
structs, and only allocate the usual entry arrays when the direct
storage is full.
The implementation has an optional debugging feature (enabled by
defining the ENABLE_HASHMAP_DEBUG macro), where it:
- tracks all allocated hashmaps in a linked list so that one can
easily find them in gdb,
- tracks which function/line allocated a given hashmap, and
- checks for invalid mixing of hashmap iteration and modification.
Since entries are not allocated one-by-one anymore, mempools are not
used for entries. Originally I meant to drop mempools entirely, but it's
still worth it to use them for the hashmap structs. My testing indicates
that it makes loading of units about 5 % faster (a test with 10000 units
where more than 200000 hashmaps are allocated - pure malloc: 449±4 ms,
mempools: 427±7 ms).
Here are some memory usage numbers, taken on my laptop with a more or
less normal Fedora setup after booting with SELinux disabled (SELinux
increases systemd's memory usage significantly):
systemd (PID 1) Original New Change
dirty memory (from pmap -x 1) [KiB] 2152 1264 -41 %
total heap allocations (from gdb-heap) [KiB] 1623 756 -53 %
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
|
|
Add mempool_alloc0_tile(). It's like mempool_alloc_tile(), but it
initializes the allocated tile's memory to zero.
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
|