Commit graph

28490 commits

Author SHA1 Message Date
AsciiWolf f628d6d750 catalog: use https:// in URLs 2017-02-21 18:21:13 +01:00
AsciiWolf 83d69666a3 docs: use https:// in URLs 2017-02-21 18:18:24 +01:00
Zbigniew Jędrzejewski-Szmek 2e98288b15 Merge pull request #5410 from AsciiWolf/https-urls
Use https:// in URLs when possible.
2017-02-21 11:27:10 -05:00
AsciiWolf 28a0ad81ee man: use https:// in URLs 2017-02-21 16:28:04 +01:00
AsciiWolf 56cadcb6e3 NEWS: use https:// in URLs 2017-02-21 16:03:04 +01:00
AsciiWolf 19d9372b60 README, README.md: use https:// in URLs 2017-02-21 15:56:04 +01:00
AsciiWolf ca78304fce configure.am: use https:// in URLs 2017-02-21 15:44:13 +01:00
Martin Pitt baf327864a NEWS: fix typos, grammar, and small errors (#5407) 2017-02-21 09:41:44 -05:00
Martin Pitt d0c7baa871 Merge pull request #5406 from poettering/v233-prep
V233 preparation
2017-02-21 15:04:02 +01:00
Lennart Poettering e7034ee0ad build-sys: bump package version 2017-02-21 14:01:09 +01:00
Lennart Poettering d08ee7cbea start putting together a NEWS entry for 233 2017-02-21 13:59:23 +01:00
Lennart Poettering 10ab1831de systemctl: suffix cmdline options that take arguments with =
Just to clarify, that these options expect arguments, following our
usual style.
2017-02-21 11:17:24 +01:00
Lennart Poettering a4dde27d73 Merge pull request #5131 from keszybz/environment-generators
Environment generators
2017-02-21 11:11:44 +01:00
Zbigniew Jędrzejewski-Szmek 012f2b7de7 coredumpctl: print a hint if any coredumps are in flight (#5393)
Fixes #4685.
2017-02-21 11:08:35 +01:00
Lennart Poettering 1ebfd03bd9 Merge pull request #5390 from keszybz/coverity
Clarifications to make coverity happy
2017-02-21 10:49:49 +01:00
Zbigniew Jędrzejewski-Szmek f50ce8fc4b test-env-util: add more tests for "extended syntax"
This is only the tip of the iceberg. It would be great to test all kinds of nesting, handling
of invalid syntax, etc., but I'm leaving that for later.
2017-02-20 23:35:19 -05:00
Ray Strode b82f58bfe3 basic: support default and alternate values for env expansion
Sometimes it's useful to provide a default value during an environment
expansion, if the environment variable isn't already set.

For instance $XDG_DATA_DIRS is suppose to default to:

/usr/local/share/:/usr/share/

if it's not yet set. That means callers wishing to augment
XDG_DATA_DIRS need to manually add those two values.

This commit changes replace_env to support the following shell
compatible default value syntax:

XDG_DATA_DIRS=/foo:${XDG_DATA_DIRS:-/usr/local/share/:/usr/share}

Likewise, it's useful to provide an alternate value during an
environment expansion, if the environment variable isn't already set.

For instance, $LD_LIBRARY_PATH will inadvertently search the current
working directory if it starts or ends with a colon, so the following
is usually wrong:

LD_LIBRARY_PATH=/foo/lib:${LD_LIBRARY_PATH}

To address that, this changes replace_env to support the following
shell compatible alternate value syntax:

LD_LIBRARY_PATH=/foo/lib${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}

[zj: gate the new syntax under REPLACE_ENV_ALLOW_EXTENDED switch, so
existing callers are not modified.]
2017-02-20 23:32:53 -05:00
Ray Strode 4bed076c5f basic: add replace_env_n function
It's like replace_env, but lets you pass in a substring.
2017-02-20 23:32:53 -05:00
Zbigniew Jędrzejewski-Szmek 51e76f7cd1 build-sys: make environment.d support conditional
We have ./configure switches for various parts of non-essential functionality,
let's add one for this new stuff too. Support for environment generators is
not conditional — if you don't want them, just don't install any.
2017-02-20 23:32:53 -05:00
Zbigniew Jędrzejewski-Szmek 184d190473 Tighten checking for variable validity
In the future we might want to allow additional syntax (for example
"unset VAR". But let's check that the data we're getting does not contain
anything unexpected.
2017-02-20 23:32:53 -05:00
Zbigniew Jędrzejewski-Szmek ccad1fd07c Allow braceless variables to be expanded
(Only in environment.d files.)

We have only basic compatibility with shell syntax, but specifying variables
without using braces is probably more common, and I think a lot of people would
be surprised if this didn't work.
2017-02-20 23:30:50 -05:00
Zbigniew Jędrzejewski-Szmek cb4499d005 basic/env-util: use _cleanup_ in replace_env() 2017-02-20 18:49:14 -05:00
Ray Strode 79d615d56c build-sys,man: load /etc/environment and describe the new environment.d syntax
Add support for /etc/environment and document the changes to the user manager
to automatically import environment *.conf files from:

        ~/.config/environment.d/
        /etc/environment.d/
        /run/environment.d/
        /usr/local/lib/environment.d/
        /usr/lib/environment.d/
        /etc/environment
2017-02-20 18:49:14 -05:00
Zbigniew Jędrzejewski-Szmek f63c4aabb2 environment-generator: new generator to peruse environment.d
Why the strange name: the prefix is necessary to follow our own advice that
environment generators should have numerical prefixes. I also put -d- in the
name because otherwise the name was very easy to mistake with
systemd.environment-generator. This additional letter clarifies that this
on special generator that supports environment.d files.
2017-02-20 18:49:14 -05:00
Ray Strode 37f3ffca27 basic: add new merge_env_file function
merge_env_file is a new function, that's like load_env_file, but takes a
pre-existing environment as an input argument. New environment entries are
merged. Variable expansion is performed.

Falling back to the process environment is supported (when a flag is set).
Alternatively this could be implemented as passing an additional fallback
environment array, but later on we're adding another flag to allow braceless
expansion, and the two flags can be combined in one arg, so there's less
stuff to pass around.
2017-02-20 18:49:14 -05:00
Ray Strode d8ad241f54 basic: drop unnecessary strempty() call in replace_env
strempty() converts a NULL value to empty string, so
that it can be passed on to functions that don't support NULL.

replace_env calls strempty before passing its value on to strappend.

strappend supports NULL just fine, though, so this commit drops the
strempty call.
2017-02-20 18:49:14 -05:00
Ray Strode 6162512cde basic: fix strv_env_get_n for unclean arrays
If an environment array has duplicates, strv_env_get_n returns
the results for the first match. This is wrong, because later
entries in the environment are supposed to replace earlier
entries.
2017-02-20 18:49:14 -05:00
Zbigniew Jędrzejewski-Szmek 1bd2d4e31b man: add systemd.environment-generator(7) with two examples
v2:
  - add example files to EXTRA_DIST
v3:
  - rework for the new scheme where nothing is written to disk
v4:
  - use separate dirs for system and user env generators
2017-02-20 18:49:14 -05:00
Zbigniew Jędrzejewski-Szmek 64691d2024 manager: run environment generators
Environment file generators are a lot like unit file generators, but not
exactly:

1. environment file generators are run for each manager instance, and their
   output is (or at least can be) individualized.

   The generators themselves are system-wide, the same for all users.

2. environment file generators are run sequentially, in priority order.

Thus, the lifetime of those files is tied to lifecycle of the manager
instance. Because generators are run sequentially, later generators can use or
modify the output of earlier generators.

Each generator is run with no arguments, and the whole state is stored in the
environment variables. The generator can echo a set of variable assignments to
standard output:

  VAR_A=something
  VAR_B=something else

This output is parsed, and the next and subsequent generators run with those
updated variables in the environment. After the last generator is done, the
environment that the manager itself exports is updated.

Each generator must return 0, otherwise the output is ignored.

The generators in */user-env-generator are for the user session managers,
including root, and the ones in */system-env-generator are for pid1.
2017-02-20 18:49:14 -05:00
Zbigniew Jędrzejewski-Szmek 3303d1b2dc exec-util: implement a set of callbacks to pass variables around
Only tests are added, otherwise the new code is unused.
2017-02-20 18:49:14 -05:00
Zbigniew Jędrzejewski-Szmek c8cebc36b0 basic/env-util: drop _pure_ from static function 2017-02-20 18:49:14 -05:00
Zbigniew Jędrzejewski-Szmek 99003e01b6 env-util,fileio: immediately replace variables in load_env_file_push()
strv_env_replace was calling env_match(), which in effect allowed multiple
values for the same key to be inserted into the environment block. That's
pointless, because APIs to access variables only return a single value (the
latest entry), so it's better to keep the block clean, i.e. with just a single
entry for each key.

Add a new helper function that simply tests if the part before '=' is equal in
two strings and use that in strv_env_replace.

In load_env_file_push, use strv_env_replace to immediately replace the previous
assignment with a matching name.

Afaict, none of the callers are materially affected by this change, but it
seems like some pointless work was being done, if the same value was set
multiple times. We'd go through parsing and assigning the value for each
entry. With this change, we handle just the last one.
2017-02-20 18:49:14 -05:00
Zbigniew Jędrzejewski-Szmek ac46681881 basic/fileio: add helper function for a set of two common checks 2017-02-20 18:49:14 -05:00
Zbigniew Jędrzejewski-Szmek fe902fa496 core/manager: move environment serialization out to basic/env-util.c
This protocol is generally useful, we might just as well reuse it for the
env. generators.

The implementation is changed a bit: instead of making a new strv and freeing
the old one, just mutate the original. This is much faster with larger arrays,
while in fact atomicity is preserved, since we only either insert the new
entry or not, without being in inconsistent state.

v2:
- fix confusion with return value
2017-02-20 18:49:14 -05:00
Zbigniew Jędrzejewski-Szmek 71cb7d306a core/manager: fix grammar in comment 2017-02-20 18:49:14 -05:00
Zbigniew Jędrzejewski-Szmek c6e47247a7 basic/exec-util: add support for synchronous (ordered) execution
The output of processes can be gathered, and passed back to the callee.
(This commit just implements the basic functionality and tests.)

After the preparation in previous commits, the change in functionality is
relatively simple. For coding convenience, alarm is prepared *before* any
children are executed, and not before. This shouldn't matter usually, since
just forking of the children should be pretty quick. One could also argue that
this is more correct, because we will also catch the case when (for whatever
reason), forking itself is slow.

Three callback functions and three levels of serialization are used:
- from individual generator processes to the generator forker
- from the forker back to the main process
- deserialization in the main process

v2:
- replace an structure with an indexed array of callbacks
2017-02-20 18:49:13 -05:00
Zbigniew Jędrzejewski-Szmek 504afd7c34 core/manager: split out creation of serialization fd out to a helper
There is a slight change in behaviour: the user manager for root will create a
temporary file in /run/systemd, not /tmp. I don't think this matters, but
simplifies implementation.
2017-02-20 18:49:09 -05:00
Lucas Werkmeister cc7de2ba32 tree-wide: add man: to manpage references (#5402)
Found with:

    git grep '"[^"]*[a-z0-9]([0-9]\+p\?)' src/ | grep -vF man:
2017-02-20 18:45:35 -05:00
pyBlob aa32885055 Syntax for defines that is also unterstood by the GNU C/C++ compilers. (#5397) 2017-02-20 16:24:45 -05:00
Benjamin Robin 5955df2c40 systemctl: Fix condition in start_special() (#5399) 2017-02-20 16:11:34 -05:00
Zbigniew Jędrzejewski-Szmek 2fa4861ad5 sd-device: replace lstat() + open() with open(O_NOFOLLOW)
Coverity was complaining about TOCTOU (CID #745806). Indeed, it seems better
to open the file and avoid the stat altogether:

- O_NOFOLLOW means we'll get ELOOP, which we can translate to EINVAL as before,
- similarly, open(O_WRONLY) on a directory will fail with EISDIR,
- and finally, it makes no sense to check access mode ourselves: just let
  the kernel do it and propagate the error.

v2:
- fix memleak, don't clober input arg
2017-02-20 16:03:42 -05:00
Zbigniew Jędrzejewski-Szmek 0357fa0dce shared/pager: abort if we cannot set environment variables
This most likely means oom, it's better to exit than to run less with
incomplete settings.

CID #714383.
2017-02-20 16:02:18 -05:00
Zbigniew Jędrzejewski-Szmek 643f4706b0 core/execute: add (void)
CID #778045.
2017-02-20 16:02:18 -05:00
Zbigniew Jędrzejewski-Szmek e8f3e7a707 logind: check return value from lseek
In practice this doesn't matter much because the read that follows will
likely fail, but we'll get a better error message.

CID #1368233.
2017-02-20 16:02:18 -05:00
Zbigniew Jędrzejewski-Szmek df8067ef6d importd: check setenv return value
CID #1368235.
2017-02-20 16:02:18 -05:00
Zbigniew Jędrzejewski-Szmek 5c5d9f26d6 core/killall: add (void)
CID #1368238.
2017-02-20 16:02:18 -05:00
Zbigniew Jędrzejewski-Szmek f28501279d firewall-util: add an assert that we're not overwriting a buffer
Check for CID #1368267.
2017-02-20 16:02:15 -05:00
Lennart Poettering 04a0891038 Merge pull request #5392 from keszybz/systemctl-edit
systemctl edit & reboot fixlets
2017-02-20 16:30:58 +01:00
Alexander Galanin 5153494f1d Include 'vendor class identifier option' into DHCPREQUEST message (#5380) 2017-02-20 10:15:58 +01:00
Zbigniew Jędrzejewski-Szmek 2b0f4e6f21 systemctl: give a hint about --force --force when communication with manager fails
The hint is not too explicit, and just refers to the man page, because this
option is slightly dangereous. This was we don't have to discuss the limitation
in the hint itself.

Fixes #4002.
2017-02-19 18:56:02 -05:00