Commit Graph

235 Commits

Author SHA1 Message Date
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)