summaryrefslogtreecommitdiff
path: root/src/shared/install.c
AgeCommit message (Collapse)Author
2014-08-20systemctl: fail in the case that no unit files were foundLukas Nykryn
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-13util: allow strappenda to take any number of argsDave Reisner
This makes strappenda3 redundant, so we remove its usage and definition. Add a few tests along the way for sanity.
2014-07-31Properly report invalid quoted stringsZbigniew Jędrzejewski-Szmek
$ 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-31Reject invalid quoted stringsZbigniew Jędrzejewski-Szmek
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-26Add utility function to append root to pathZbigniew Jędrzejewski-Szmek
2014-07-26Always check asprintf return codeKarel Zak
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-16test-tables: add new entriesZbigniew Jędrzejewski-Szmek
One missing string found. A few things had to be moved around to make it possible to test them.
2014-07-16Let config_parse open file where applicableZbigniew Jędrzejewski-Szmek
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-15Constify ConfigTableItem tablesZbigniew Jędrzejewski-Szmek
2014-06-20conf-files: include root in returned file pathsMichael Marineau
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-17install: remove unused variableThomas Hindoe Paaboel Andersen
2014-06-17install: improve paths we show the user when enabling/disablingLennart Poettering
2014-06-17install: simplify symlink --root= logicLennart Poettering
2014-06-17install: "systemctl enable" should be a nop for template units lacking a ↵Lennart Poettering
DefaultInstance= setting
2014-06-17install: make sure that --root= mode doesn't make us consider all units ↵Lennart Poettering
outside of search path
2014-06-17install: make sure "systemctl disable foobar@.service" actually removes all ↵Lennart Poettering
instances
2014-06-17install: introduce new DefaultInstance= field for [Install] sectionsLennart Poettering
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-17install: when looking for a unit file for enabling, search for templates ↵Lennart Poettering
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-17install: use symlink_atomic() instead of unlink()+symlink() when force ↵Lennart Poettering
creating a symlink
2014-06-17install: various modernizationsLennart Poettering
2014-06-17install: teach preset query logic --root= supportLennart Poettering
2014-06-17install: beef up preset logic to limit to only enable or only disable, and ↵Lennart Poettering
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-17install: simplify and clarify disabling logic for instanced unitsLennart Poettering
2014-06-17install: various modernizationsLennart Poettering
2014-06-13install: fix invalid free() in unit_file_mask()Andreas Henriksson
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-05-15Make systemctl --root look for files in the proper placesZbigniew Jędrzejewski-Szmek
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-15shared/install: do not prefix created symlink with root pathZbigniew Jędrzejewski-Szmek
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-13replace more dup() by F_DUPFD_CLOEXECLennart Poettering
2014-04-23install: simplificationLennart Poettering
2014-04-16install: create_symlink() check unlink() return valueDjalal Harouni
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-03-18util: replace close_nointr_nofail() by a more useful safe_close()Lennart Poettering
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-02-24Remove dead lines in various placesZbigniew Jędrzejewski-Szmek
As pointed-out by clang -Wunreachable-code. No behaviour changes.
2014-01-05shared/install: use char** convention for strvsZbigniew Jędrzejewski-Szmek
2013-12-26Use enums to make it obvious what boolean params meanZbigniew Jędrzejewski-Szmek
Suggested-by: Russ Allbery <rra@debian.org>
2013-12-25bus: rename message "serial" to "cookie"Lennart Poettering
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-21install: replace readdir_r with readdirFlorian Weimer
The old code incorrectly assumed that readdir_r updates errno.
2013-12-06Get rid of our reimplementation of basenameZbigniew Jędrzejewski-Szmek
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-11-25conf-parser: distinguish between multiple sections with the same nameTom Gundersen
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-20core: convert PID 1 to libsystemd-busLennart Poettering
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-20install: when determining where default.target points to, accept a file ↵Lennart Poettering
instead of a symlink, too
2013-11-20install: use const where we canLennart Poettering
2013-11-08install: don't override caller's parameterLennart Poettering
2013-10-27path_lookup: moved _cleanup_lookup_paths_free_ from install.c to path-lookup.hDaniel Buch
2013-10-13Introduce udev object cleanup functionsZbigniew Jędrzejewski-Szmek
2013-10-13ModernizationZbigniew Jędrzejewski-Szmek
Fixes minor leak in error path in device.c.
2013-09-17specifier: rework specifier calls to return proper error messageLennart Poettering
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-07-14systemd: fix NULL dereference when disabling a nonexistent instanceZbigniew Jędrzejewski-Szmek
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-13install: make "reenable" work with templated unitsRoss Lagerwall
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-12shared/install: fix trivial memleakZbigniew Jędrzejewski-Szmek
We lost the reference when setting path second time.
2013-06-03systemctl,core: allow nuking of symlinks to removed unitsZbigniew Jędrzejewski-Szmek
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