Commit graph

312 commits

Author SHA1 Message Date
Lennart Poettering 7410616cd9 core: rework unit name validation and manipulation logic
A variety of changes:

- Make sure all our calls distuingish OOM from other errors if OOM is
  not the only error possible.

- Be much stricter when parsing escaped paths, do not accept trailing or
  leading escaped slashes.

- Change unit validation to take a bit mask for allowing plain names,
  instance names or template names or an combination thereof.

- Refuse manipulating invalid unit name
2015-05-05 15:06:42 -07:00
Ronny Chevalier 0d67448869 shared: fix memleak
path was used for 2 purposes but it was not freed before being reused.
2015-04-10 15:44:02 +02:00
Harald Hoyer a7f7d1bde4 fix gcc warnings about uninitialized variables
like:

src/shared/install.c: In function ‘unit_file_lookup_state’:
src/shared/install.c:1861:16: warning: ‘r’ may be used uninitialized in
this function [-Wmaybe-uninitialized]
         return r < 0 ? r : state;
                ^
src/shared/install.c:1796:13: note: ‘r’ was declared here
         int r;
             ^
2015-03-27 14:57:38 +01:00
Zbigniew Jędrzejewski-Szmek a8ffe6fbcb sysv-generator: initialize LookupPaths just once
With debugging on, sysv-generator would print the full set of
lookup paths for *every* sysv script.

While at it, pass LookupPaths as a pointer in sysv-generator,
and constify it everywhere.
2015-03-14 23:03:21 -04:00
David Herrmann 15411c0cb1 tree-wide: there is no ENOTSUP on linux
Replace ENOTSUP by EOPNOTSUPP as this is what linux actually uses.
2015-03-13 14:10:39 +01:00
Thomas Hindoe Paaboel Andersen 2eec67acbb remove unused includes
This patch removes includes that are not used. The removals were found with
include-what-you-use which checks if any of the symbols from a header is
in use.
2015-02-23 23:53:42 +01:00
Lennart Poettering 63c372cb9d util: rework strappenda(), and rename it strjoina()
After all it is now much more like strjoin() than strappend(). At the
same time, add support for NULL sentinels, even if they are normally not
necessary.
2015-02-03 02:05:59 +01:00
Ivan Shapovalov 60d27f1916 path-lookup, systemctl: export lookup_paths_init_from_scope() from shared/install.c and use it 2015-01-05 11:13:30 -05:00
Lennart Poettering a34bf9db5d util: rename ignore_file() to hidden_file()
hidden_file() is a bit more precise, since dot files usually shouldn't
be ignored, but certainly be considered hidden.
2014-12-19 20:03:36 +01:00
Lennart Poettering 764458325e core: properly pass unit file state to clients via the bus 2014-12-10 19:58:50 +01:00
Tom Gundersen 56e73b34ce shared: install - report error if mask symlink can not be marked for removal 2014-11-29 11:14:48 +01:00
Michal Schmidt f647962d64 treewide: yet more log_*_errno + return simplifications
Using:
find . -name '*.[ch]' | while read f; do perl -i.mmm -e \
 'local $/;
  local $_=<>;
  s/(if\s*\([^\n]+\))\s*{\n(\s*)(log_[a-z_]*_errno\(\s*([->a-zA-Z_]+)\s*,[^;]+);\s*return\s+\g4;\s+}/\1\n\2return \3;/msg;
  print;'
 $f
done

And a couple of manual whitespace fixups.
2014-11-28 18:56:16 +01:00
Michal Schmidt da927ba997 treewide: no need to negate errno for log_*_errno()
It corrrectly handles both positive and negative errno values.
2014-11-28 13:29:21 +01:00
Michal Schmidt 0a1beeb642 treewide: auto-convert the simple cases to log_*_errno()
As a followup to 086891e5c1 "log: add an "error" parameter to all
low-level logging calls and intrdouce log_error_errno() as log calls
that take error numbers", use sed to convert the simple cases to use
the new macros:

find . -name '*.[ch]' | xargs sed -r -i -e \
's/log_(debug|info|notice|warning|error|emergency)\("(.*)%s"(.*), strerror\(-([a-zA-Z_]+)\)\);/log_\1_errno(-\4, "\2%m"\3);/'

Multi-line log_*() invocations are not covered.
And we also should add log_unit_*_errno().
2014-11-28 12:04:41 +01:00
Jan Synacek aedd4012f4 shared/install: when unit contains only Also=, report 'indirect'
If a unit contains only Also=, with no Alias= or WantedBy=, it shouldn't
be reported as static. New 'indirect' status shall be introduced.

https://bugzilla.redhat.com/show_bug.cgi?id=864298
2014-11-10 19:58:21 +01:00
Dave Reisner 0ffce503cd shared/install: avoid prematurely rejecting "missing" units
f7101b7368 copied some logic to prevent enabling masked units, but
also added a check which causes attempts to enable templated units to
fail. Since we know the logic beyond this check will properly handle
units which truly do not exist, we can rely on the unit file state
comparison to suffice for expressing the intent of f7101b7368.

ref: https://bugs.archlinux.org/task/42616
2014-10-31 08:19:26 -04:00
Zbigniew Jędrzejewski-Szmek e95c98378a systemctl: do not ignore errors in symlink removal
On an ro fs, systemctl disable ... would fail silently.
2014-10-25 15:34:48 -04:00
Michal Schmidt 2d5c93c7af install, cgtop: adjust hashmap_move_one() callers for -ENOMEM possibility
That hashmap_move_one() currently cannot fail with -ENOMEM is an
implementation detail, which is not possible to guarantee in general.
Hashmap implementations based on anything else than chaining of
individual entries may have to allocate.

hashmap_move_one will not fail with -ENOMEM if a proper reservation has
been made beforehand. Use reservations in install.c.

In cgtop.c simply propagate the error instead of asserting.
2014-10-23 17:38:02 +02:00
Michal Schmidt 9f03ee51a2 install: make InstallContext::{will_install,have_installed} OrderedHashmaps
It appears order may matter here. Use OrderedHashmaps to be safe.
2014-10-23 17:38:02 +02:00
Lukas Nykryn e94937df95 systemctl: add add-wants and add-requires verbs 2014-10-08 12:44:00 +02:00
Jan Synacek f7101b7368 core: don't allow enabling if unit is masked 2014-10-07 17:08:18 -04:00
Zbigniew Jędrzejewski-Szmek 4d5dec2389 Rename user_runtime to user_runtime_dir
This makes this function name similar to user_config_home() and makes
it match the name of the environment variable.
2014-10-02 11:10:35 -04:00
Steven Allen 718880ba0d add a transient user unit directory
This patch adds a transient user unit directory under
`$XDG_RUNTIME_DIR/systemd/user/` and stores transient user-instance
units (such as those created by `systemd-run --user`) under there
instead of putting them in $XDG_CONFIG_HOME/systemd/user/.

Fixes https://bugs.freedesktop.org/show_bug.cgi?id=67331
2014-10-02 10:37:30 -04:00
Andreas Henriksson d9ab174bd7 shared: fix resource leak in config_parse_default_instance
The recently allocated "printed" is not freed on error path.

Found by coverity. Fixes: CID#1237745
2014-09-16 21:49:56 +02:00
Michal Schmidt d5099efc47 hashmap: introduce hash_ops to make struct Hashmap smaller
It is redundant to store 'hash' and 'compare' function pointers in
struct Hashmap separately. The functions always comprise a pair.
Store a single pointer to struct hash_ops instead.

systemd keeps hundreds of hashmaps, so this saves a little bit of
memory.
2014-09-15 16:08:50 +02:00
Lukas Nykryn 81fc054dc7 systemctl: fix broken list-unit-files with --root 2014-08-27 11:48:48 +02:00
Lennart Poettering 4fc13f521a Revert "systemctl: fix broken list-unit-files with --root"
This reverts commit 41a451cc29.

This breaks checks for masking of units file, since we invoke
null_or_empty_path() on the resulting path.
2014-08-26 04:09:22 +02:00
Lukas Nykryn 41a451cc29 systemctl: fix broken list-unit-files with --root
This patch modifies unit_file_get_list which will now return
hashmap of structures where f->path is *without* root_dir prefix.

This change should be ok, because current code either does not use
root_dir at all or calls basename() on the f->path.
2014-08-25 15:51:55 +02:00
Lennart Poettering 59ccf93d97 install: simplify usage of _cleanup_ macros 2014-08-21 19:08:30 +02:00
Lukas Nykryn fdbdf6ec29 systemctl: fail in the case that no unit files were found
Previously systemctl died with message

-bash-4.2# systemctl --root /rawhi list-unit-files
(src/systemctl/systemctl.c:868) Out of memory.

in the case that no unit files were found in the --root
or the directory did not exist.

So lets return ENOENT in the case that --root does not exist
and empty list in the case that there are no unit files.
2014-08-20 10:45:18 +02:00
Dave Reisner 8085f163c5 util: allow strappenda to take any number of args
This makes strappenda3 redundant, so we remove its usage and
definition. Add a few tests along the way for sanity.
2014-08-13 20:41:41 -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 0c6ea3a4e2 Add utility function to append root to path 2014-07-26 15:08:42 -04:00
Karel Zak 7de80bfe2e Always check asprintf return code
There is a small number of the places in sources where we don't check
asprintf() return code and assume that after error the function
returns NULL pointer via the first argument. That's wrong, after
error the content of pointer is undefined.
2014-07-26 15:08:41 -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 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 e9f3d2d508 Constify ConfigTableItem tables 2014-07-15 22:34:40 -04:00
Michael Marineau cba2ef0272 conf-files: include root in returned file paths
This restores the original root handling logic that was present prior to
112cfb18 when path expansion moved to path_strv_canonicalize_absolute.
That behavior partially went away in 12ed81d9.

Alternatively all users of conf_files_list* could be updated to
concatenate the paths themselves as unit_file_query_preset did but since
no user needs the un-concatenated form that is pointless duplication.
2014-06-20 00:10:47 -04:00
Thomas Hindoe Paaboel Andersen de228aabc8 install: remove unused variable 2014-06-17 21:22:01 +02:00
Lennart Poettering ac78d81a35 install: improve paths we show the user when enabling/disabling 2014-06-17 02:43:44 +02:00
Lennart Poettering 278fa5758c install: simplify symlink --root= logic 2014-06-17 02:43:44 +02:00
Lennart Poettering 0a327d753f install: "systemctl enable" should be a nop for template units lacking a DefaultInstance= setting 2014-06-17 02:43:44 +02:00
Lennart Poettering 8f294b45cb install: make sure that --root= mode doesn't make us consider all units outside of search path 2014-06-17 02:43:43 +02:00
Lennart Poettering 559367add5 install: make sure "systemctl disable foobar@.service" actually removes all instances 2014-06-17 02:43:43 +02:00
Lennart Poettering d54c499369 install: introduce new DefaultInstance= field for [Install] sections
The DefaultInstance= name is used when enabling template units when only
specifying the template name, but no instance.

Add DefaultInstance=tty1 to getty@.service, so that when the template
itself is enabled an instance for tty1 is created.

This is useful so that we "systemctl preset-all" can work properly,
because we can operate on getty@.service after finding it, and the right
instance is created.
2014-06-17 02:43:43 +02:00
Lennart Poettering e50bd77516 install: when looking for a unit file for enabling, search for templates only after traversing all search directories
Let's always make sure to look in all search directories for the full
unit names first, before looking for templates for them.
2014-06-17 02:43:43 +02:00
Lennart Poettering 1f8c46040e install: use symlink_atomic() instead of unlink()+symlink() when force creating a symlink 2014-06-17 02:43:43 +02:00
Lennart Poettering 1dacfd2ad6 install: various modernizations 2014-06-17 02:43:43 +02:00
Lennart Poettering c2a8d7b05c install: teach preset query logic --root= support 2014-06-17 02:43:43 +02:00
Lennart Poettering d309c1c364 install: beef up preset logic to limit to only enable or only disable, and do all-unit preset operations
The new "systemctl preset-all" command may now be used to put all
installed units back into the enable/disable state the vendor/admin
encoded in preset files.

Also, introduce "systemctl --preset-mode=enable-only" and "systemctl
--preset-mode=disable-only" to only apply the enable or only the disable
operations of a "systemctl preset" or "systemctl preset-all" operation.

"systemctl preset-all" implements this RFE:

https://bugzilla.redhat.com/show_bug.cgi?id=630174
2014-06-17 02:43:17 +02:00
Lennart Poettering bcafe923a7 install: simplify and clarify disabling logic for instanced units 2014-06-17 01:24:04 +02:00
Lennart Poettering da39f6a63e install: various modernizations 2014-06-17 01:24:04 +02:00
Andreas Henriksson 223217749e install: fix invalid free() in unit_file_mask()
int unit_file_mask(...) in ./src/shared/install.c calls
get_config_path(...) which can in 4 error cases return without setting
"ret", and thus "prefix" can be uninitialized when unit_file_mask(...)
finishes (which it does directly after the error is returned from
get_config_path(...)).
2014-06-13 19:01:07 +02:00
Zbigniew Jędrzejewski-Szmek 12ed81d9c8 Make systemctl --root look for files in the proper places
Running systemctl enable/disable/set-default/... with the --root
option under strace reveals that it accessed various files and
directories in the main fs, and not underneath the specified root.
This can lead to correct results only when the layout and
configuration in the container are identical, which often is not the
case. Fix this by adding the specified root to all file access
operations.

This patch does not handle some corner cases: symlinks which point
outside of the specified root might be interpreted differently than
they would be by the kernel if the specified root was the real root.
But systemctl does not create such symlinks by itself, and I think
this is enough of a corner case not to be worth the additional
complexity of reimplementing link chasing in systemd.

Also, simplify the code in a few places and remove an hypothetical
memory leak on error.
2014-05-15 15:29:58 +02:00
Zbigniew Jędrzejewski-Szmek 62b0023377 shared/install: do not prefix created symlink with root path
Before: /var/tmp/inst1//etc/systemd/system/default.target -> /var/tmp/inst1//usr/lib/systemd/system/graphical.target
After: /var/tmp/inst1/etc/systemd/system/default.target -> /usr/lib/systemd/system/graphical.target
2014-05-15 15:29:57 +02:00
Lennart Poettering ead349509e replace more dup() by F_DUPFD_CLOEXEC 2014-05-13 16:40:53 +02:00
Lennart Poettering b91a3b02f3 install: simplification 2014-04-23 19:06:38 +02:00
Djalal Harouni af7fce1cdb install: create_symlink() check unlink() return value
create_symlink() do not check the return value of unlink(), this may
confuse the user.

Before the unlink() call we check the 'force' argument. If it is not set
we fail with -EEXIST, otherwise we unlink() the file, therefore the next
symlink() should not fail with -EEXIST (do not count races...).

However since callers may not have appropriate privileges to unlink()
the file we lose the -EPERM or any other errno code of unlink(), and
return the -EEXIST of the next symlink(). Fix this by checking unlink()
results.

Before:
$ systemctl --force --root=~/container-03 set-default multi-user.target
Failed to set default target: File exists

After:
$ systemctl --force --root=~/container-03 set-default multi-user.target
Failed to set default target: Permission denied
2014-04-16 23:13:22 -04:00
Lennart Poettering 03e334a1c7 util: replace close_nointr_nofail() by a more useful safe_close()
safe_close() automatically becomes a NOP when a negative fd is passed,
and returns -1 unconditionally. This makes it easy to write lines like
this:

        fd = safe_close(fd);

Which will close an fd if it is open, and reset the fd variable
correctly.

By making use of this new scheme we can drop a > 200 lines of code that
was required to test for non-negative fds or to reset the closed fd
variable afterwards.
2014-03-18 19:31:34 +01:00
Zbigniew Jędrzejewski-Szmek bdd13f6be4 Remove dead lines in various places
As pointed-out by clang -Wunreachable-code.

No behaviour changes.
2014-02-24 19:24:14 -05:00
Zbigniew Jędrzejewski-Szmek 7195aa42e3 shared/install: use char** convention for strvs 2014-01-05 09:16:15 -05:00
Zbigniew Jędrzejewski-Szmek f78e6385dc Use enums to make it obvious what boolean params mean
Suggested-by: Russ Allbery <rra@debian.org>
2013-12-26 15:49:54 -05:00
Lennart Poettering 693eb9a2d4 bus: rename message "serial" to "cookie"
Even if the lower-leveld dbus1 protocol calls it "serial", let's expose
the word "cookie" for this instead, as this is what kdbus uses and since
it doesn't imply monotonicity the same way "serial" does.
2013-12-25 18:04:04 +01:00
Florian Weimer 4d993c8cb7 install: replace readdir_r with readdir
The old code incorrectly assumed that readdir_r updates errno.
2013-12-21 18:35:55 -05: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
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
Lennart Poettering 718db96199 core: convert PID 1 to libsystemd-bus
This patch converts PID 1 to libsystemd-bus and thus drops the
dependency on libdbus. The only remaining code using libdbus is a test
case that validates our bus marshalling against libdbus' marshalling,
and this dependency can be turned off.

This patch also adds a couple of things to libsystem-bus, that are
necessary to make the port work:

- Synthesizing of "Disconnected" messages when bus connections are
  severed.

- Support for attaching multiple vtables for the same interface on the
  same path.

This patch also fixes the SetDefaultTarget() and GetDefaultTarget() bus
calls which used an inappropriate signature.

As a side effect we will now generate PropertiesChanged messages which
carry property contents, rather than just invalidation information.
2013-11-20 20:52:36 +01:00
Lennart Poettering e8372f7e3e install: when determining where default.target points to, accept a file instead of a symlink, too 2013-11-20 19:37:02 +01:00
Lennart Poettering 16ed0233a5 install: use const where we can 2013-11-20 19:36:13 +01:00
Lennart Poettering 97137ecce6 install: don't override caller's parameter 2013-11-08 14:07:27 +01:00
Daniel Buch fb15be8395 path_lookup: moved _cleanup_lookup_paths_free_ from install.c to path-lookup.h 2013-10-27 11:51:22 -04:00
Zbigniew Jędrzejewski-Szmek 1ca208fb4f Introduce udev object cleanup functions 2013-10-13 17:56:55 -04:00
Zbigniew Jędrzejewski-Szmek b47d419c25 Modernization
Fixes minor leak in error path in device.c.
2013-10-13 17:56:54 -04:00
Lennart Poettering 19f6d71077 specifier: rework specifier calls to return proper error message
Previously the specifier calls could only indicate OOM by returning
NULL. With this change they will return negative errno-style error codes
like everything else.
2013-09-17 10:06:50 -05:00
Zbigniew Jędrzejewski-Szmek 6c5a28255b systemd: fix NULL dereference when disabling a nonexistent instance
Assertion 'p' failed at src/shared/path-util.c:51, function path_get_file_name(). Aborting.

The unit file could not be found, and i->path would not be set.
In 02b9e969 a code path was added which attempts to remove symlinks
to a nonexistent (removed) unit file. This worked OK in case of
non-instance services, but broke in the case of instance services.

Behaviour wrt. to instance units is changed in the way that 02b9e969
changed it for non-instance units: it is now possible to remove
instance symlinks to a template unit that has been removed.

This patch isn't a full fix, because the behaviour wrt. to enabling
and disabling instance units is still broken: e.g it is possible to
start autovt@tty5.service, but it is not possible to enable it,
because autovt@.service is a symlink, and on the other hand, disabling
getty@tty5.service removes all symlinks to getty@.service, which is
wrong too. But segfaults make bad pr, so let's add at least this
partial fix for now.
2013-07-14 23:53:45 -04:00
Ross Lagerwall 92d430a9e0 install: make "reenable" work with templated units
Before, "systemctl reenable getty@tty1.service" would fail with:
Failed to issue method call: File exists
To fix this, reimplement "reenable" explicitly as a disable followed by
an enable.
This is shorter and is how the man page documents its behavior.
2013-07-13 07:56:11 -04:00
Zbigniew Jędrzejewski-Szmek d7b478b448 shared/install: fix trivial memleak
We lost the reference when setting path second time.
2013-07-12 13:24:06 -04:00
Zbigniew Jędrzejewski-Szmek 02b9e969a6 systemctl,core: allow nuking of symlinks to removed units
Before, one the unit file was deleted, install_context_for_removal()
would refuse to look for symlinks. But we can remove dangling symlinks
anyway.

In principle, package installation/deinstallation scripts should do
that before the unit is uninstalled, but they don't always do. Also,
a user might have added additional symlinks manually.

https://bugs.freedesktop.org/show_bug.cgi?id=62395
2013-06-03 13:55:17 -04:00
Václav Pavlín 99504dd4c1 systemctl: add commands set-default and get-default
systemctl set-default NAME links the default.target to the given unit,
get-default prints out the path to the currently set default target.
2013-05-30 20:44:41 -04:00
Michael Tremer 67820a0cbd systemctl: make systemctl is-enabled work for templated units
Patch resolves the problem that 'systemctl is-enabled' does
not work for templated units.

Without this patch, systemctl is-enabled something@abc.service
returned "No such file or directory", because it first checked
if /usr/lib/systemd/system/something@abc.service, etc. exists.
If systemctl is-enabled is called for templated units, this
check should be omitted and it should search for symlinks in
the .wants dirs right away.

This patch fixes the broken behaviour and resolves
  https://bugs.freedesktop.org/show_bug.cgi?id=55318.

[zj: fixed the patch to still check for broken symlinks and
     masked instances. Also removed untrue assumptions from
     the patch description.]
2013-05-21 09:23:51 -04:00
Lennart Poettering db5c012285 conf-parser: restrict .include usage
Disallow recursive .include, and make it unavailable in anything but
unit files.
2013-04-25 00:05:14 -03:00
Zbigniew Jędrzejewski-Szmek ef42202ac8 Add set_consume which always takes ownership
Freeing in error path is the common pattern with set_put().
2013-04-24 00:25:04 -04:00
Harald Hoyer 7fd1b19bc9 move _cleanup_ attribute in front of the type
http://lists.freedesktop.org/archives/systemd-devel/2013-April/010510.html
2013-04-18 09:11:22 +02:00
Zbigniew Jędrzejewski-Szmek e8e581bf25 Report about syntax errors with metadata
The information about the unit for which files are being parsed
is passed all the way down. This way messages land in the journal
with proper UNIT=... or USER_UNIT=... attribution.

'systemctl status' and 'journalctl -u' not displaying those messages
has been a source of confusion for users, since the journal entry for
a misspelt setting was often logged quite a bit earlier than the
failure to start a unit.

Based-on-a-patch-by: Oleksii Shevchuk <alxchk@gmail.com>
2013-04-17 00:09:16 -04:00
Zbigniew Jędrzejewski-Szmek d3b6d0c21e fileio: in envfiles, do not skip lines following empty lines
https://bugs.freedesktop.org/show_bug.cgi?id=63477
2013-04-13 20:24:39 -04:00
Zbigniew Jędrzejewski-Szmek 7914d6bba4 Remove a few NULLs
Just {} is used in a lot of places now, and there's nothing
special abose those few.
2013-04-13 20:24:39 -04:00
Zbigniew Jędrzejewski-Szmek bcb161b023 errno is positive
Make sure we compare errno against positive error codes.
The ones in hwclock.c and install.c can have an impact, the
rest are unlikely to be hit or in code that isn't widely
used.

Also check that errno > 0, to help gcc know that we are
returning a negative error code.
2013-04-11 19:13:18 -04:00
Zbigniew Jędrzejewski-Szmek b92bea5d2a Use initalization instead of explicit zeroing
Before, we would initialize many fields twice: first
by filling the structure with zeros, and then a second
time with the real values. We can let the compiler do
the job for us, avoiding one copy.

A downside of this patch is that text gets slightly
bigger. This is because all zero() calls are effectively
inlined:

$ size build/.libs/systemd
         text    data     bss     dec     hex filename
before 897737  107300    2560 1007597   f5fed build/.libs/systemd
after  897873  107300    2560 1007733   f6075 build/.libs/systemd

… actually less than 1‰.

A few asserts that the parameter is not null had to be removed. I
don't think this changes much, because first, it is quite unlikely
for the assert to fail, and second, an immediate SEGV is almost as
good as an assert.
2013-04-05 19:50:57 -04:00
Kay Sievers 7850b3b837 shared: conf-files - add root parameter 2013-02-08 10:23:04 +01:00
Zbigniew Jędrzejewski-Szmek 3f0b2f0f45 install: allow %u an and %U specifiers in WantedBy/RequiredBy/Alias 2013-01-29 19:01:41 -05:00
Zbigniew Jędrzejewski-Szmek 7584d236ea install: allow specifiers in WantedBy/RequiredBy/Alias
This allows one templated unit to refer to another templated unit
at installation time.

Examples:

> grep WantedBy ~/.config/systemd/user/mpop@.timer
WantedBy=services@%i.target

> srv disable mpop@iit.timer
rm '/home/alxchk/.config/systemd/user/services@iit.target.wants/mpop@iit.timer'
> srv enable mpop@iit.timer
ln -s '/home/alxchk/.config/systemd/user/mpop@.timer' '/home/alxchk/.config/systemd/user/services@iit.target.wants/mpop@iit.timer'

Based-on-patch-by: Oleksii Shevchuk <alxchk@gmail.com>
2013-01-29 19:01:41 -05:00
Zbigniew Jędrzejewski-Szmek d9e5e694ea install: automatic cleanup using local cleanup functions 2013-01-29 19:01:41 -05:00
Zbigniew Jędrzejewski-Szmek ea55addcb7 install: use automatic cleanup in find_symlinks_fd() 2013-01-29 19:01:41 -05:00
Christian Hesse 20f59e42cd shared/install: fix typo in comment 2012-10-19 17:34:38 +02:00
Lennart Poettering 7d5e9c0f60 util: define union dirent_storage and make use of it everywhere
Make sure to allocate enough space for readdir_r().

https://bugzilla.redhat.com/show_bug.cgi?id=858754
2012-09-19 22:21:09 +02:00
Zbigniew Jędrzejewski-Szmek 67445f4e22 core: move ManagerRunningAs to shared
Note: I did s/MANAGER/SYSTEMD/ everywhere, even though it makes the
patch quite verbose. Nevertheless, keeping MANAGER prefix in some
places, and SYSTEMD prefix in others would just lead to confusion down
the road. Better to rip off the band-aid now.
2012-09-18 19:53:34 +02:00
Zbigniew Jędrzejewski-Szmek d8831ed554 install: use automatic cleanup 2012-09-16 16:20:06 +02:00
Zbigniew Jędrzejewski-Szmek d5891fdacf install: treat non-existent directory as empty
When looking for symlinks, it doesn't make sense to error-out if
the directory is missing. The user might delete an empty directory.

This check caused test-unit-file to fail when run before installation.
2012-09-16 14:00:25 +02:00
Lennart Poettering b5b46d5995 when determining unit file list, include invalid unit names in an "invalid" state 2012-09-11 01:14:25 +02:00
Michal Sekletar 29283ea4cf systemd: enable/disable instances of template
https://bugzilla.redhat.com/show_bug.cgi?id=752774
2012-07-26 10:02:10 +02:00
Lennart Poettering 5f73969991 unit-name: remove unit_name_is_valid_no_type() and move unit_name_is_valid() to unit-name.h 2012-07-10 17:07:32 +02:00
Lennart Poettering a7480dbad2 core: rename system.preset to system-presets to follow naming scheme of other dirs in /usr/lib/systemd/
Thankfully nobody is using this yet, and presets aren't documented yet,
hence take the liberty to rename this.
2012-06-27 14:34:24 +02:00
Lennart Poettering b4bdfefac3 preset: don't look for preset files in /lib unless /usr is split off 2012-06-21 23:22:53 +02:00
Kay Sievers d2e54fae5c mkdir: append _label to all mkdir() calls that explicitly set the selinux context 2012-05-31 12:40:20 +02:00
Lennart Poettering 07719a21b6 manager: rework generator logic
Previously generated units were always placed at the end of the search
path. With this change there will be three unit dirs instead of one, to
place generated entries at the beginning, in the middle and at the end
of the search path:

beginning: for units that need to override all configuration, regardless
of user or vendor. Example use: system-update-generator uses this to
temporarily redirect default.target.

middle: for units that need to override vendor configuration, but not
vendor configuration. Example use: /etc/fstab should override vendor
supplied configuration (think /tmp), but should not override native user
configuration.

end: does not override anything but is available as well. Possible usage
might be to convert D-Bus bus service files to native units but allowing
vendor supplied native units to win.
2012-05-23 03:43:29 +02:00
Lennart Poettering 78d54bd42b unit: introduce RequiredBy= setting in [Install], to complement WantedBy= 2012-05-21 15:27:26 +02:00
Michal Schmidt ba49b4a1a2 install: fix inverted meaning of '--force' in systemctl enable 2012-05-15 08:13:29 +02:00
Kay Sievers 9eb977db5b util: split-out path-util.[ch] 2012-05-08 02:33:10 +02:00
Kay Sievers 2c21044f05 util: split-out conf-file.[ch] 2012-05-07 19:01:24 +02:00
Sven Anders 771faa9ae6 fix typo in src/shared/install.c 2012-04-19 12:03:28 +02:00
Kay Sievers f33d3ec1d7 move more common files to shared/ and add them to shared.la 2012-04-12 02:39:37 +02:00
Renamed from src/install.c (Browse further)