summaryrefslogtreecommitdiff
path: root/src/shared/path-lookup.c
AgeCommit message (Collapse)Author
2017-02-21Merge pull request #5131 from keszybz/environment-generatorsLennart Poettering
Environment generators
2017-02-20environment-generator: new generator to peruse environment.dZbigniew Jędrzejewski-Szmek
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-10path-lookup: if $HOME can be determined but $XDG_RUNTIME_DIR can't, is itLennart Poettering
So far, if either $HOME or $XDG_RUNTIME_DIR is not set we wouldn't use either, and fail acquire_config_dirs() and acquire_control_dirs() in their entireties. With this change, let's make use of the variables we can acquire, and don't bother with the other. Specifically this means: in both acquire_config_dirs() and acquire_control_dirs() handle ENXIO from user_config_dir() and user_runtime_dir() directly, instead of propagating it up and handling it in the caller.
2017-02-10path-lookup: drop redundant strv_isempty() checkLennart Poettering
If the strv is empty, then strv_extend_strv_concat() is a NOP anyway, and hence there is no reason to guard for this explicitly.
2017-02-10path-lookup: try harder acquiring them $HOME of a userLennart Poettering
Let's use get_home_dir() for figuring out the home directory, so that there's a good chance we succeed figuring out unit locations even if $HOME isn't set. Fixes: #5260
2017-01-03path-lookup: use correct cleanup function for strv (#5007)Thomas H. P. Andersen
2016-10-23tree-wide: drop NULL sentinel from strjoinZbigniew Jędrzejewski-Szmek
This makes strjoin and strjoina more similar and avoids the useless final argument. spatch -I . -I ./src -I ./src/basic -I ./src/basic -I ./src/shared -I ./src/shared -I ./src/network -I ./src/locale -I ./src/login -I ./src/journal -I ./src/journal -I ./src/timedate -I ./src/timesync -I ./src/nspawn -I ./src/resolve -I ./src/resolve -I ./src/systemd -I ./src/core -I ./src/core -I ./src/libudev -I ./src/udev -I ./src/udev/net -I ./src/udev -I ./src/libsystemd/sd-bus -I ./src/libsystemd/sd-event -I ./src/libsystemd/sd-login -I ./src/libsystemd/sd-netlink -I ./src/libsystemd/sd-network -I ./src/libsystemd/sd-hwdb -I ./src/libsystemd/sd-device -I ./src/libsystemd/sd-id128 -I ./src/libsystemd-network --sp-file coccinelle/strjoin.cocci --in-place $(git ls-files src/*.c) git grep -e '\bstrjoin\b.*NULL' -l|xargs sed -i -r 's/strjoin\((.*), NULL\)/strjoin(\1)/' This might have missed a few cases (spatch has a really hard time dealing with _cleanup_ macros), but that's no big issue, they can always be fixed later.
2016-07-11treewide: fix typos and remove accidental repetition of wordsTorstein Husebø
2016-04-22path-lookup: optimize a common strv copy operation awayLennart Poettering
Follow-up for: https://github.com/systemd/systemd/pull/3033#discussion_r59689398
2016-04-13shared/path-lookup: fix leakZbigniew Jędrzejewski-Szmek
CID #1354671: char **l would be leaked. Also rename l to paths, to make the code easier to read, and do strv deduplication immediately when extending. No need to allocate strings to remove them a few lines down.
2016-04-13tree-wide: remove useless NULLs from strjoinaZbigniew Jędrzejewski-Szmek
The coccinelle patch didn't work in some places, I have no idea why.
2016-04-12systemctl: don't confuse sysv code with generated unitsLennart Poettering
The SysV compat code checks whether there's a native unit file before looking for a SysV init script. Since the newest rework generated units will show up in the unit path, and hence the checks ended up assuming that there always was a native unit file for each init script: the generated one. With this change the generated unit file directory is suppressed from the search path when this check is done, to avoid the confusion.
2016-04-12path-lookup: move generator_binary_paths() to end of fileLennart Poettering
Let's keep the code that manipulates LookupPaths together, and move generator_binary_paths() to the end of the .h and .c files, since it is not strictly related to that.
2016-04-12core: introduce a "control" unit file directoryLennart Poettering
This patch adds a concept of a "control" unit file directory, which is supposed to be used as place for unit file drop-ins created by "systemctl set-property" (note that this directory is not actually hooked up to "systemctl set-property" yet, that's coming in a later patch). The rationale for this: previously changes made by the user and by "systemctl set-property" were done in the same directory, which made semantics very unclear: the changes made by "systemctl set-property" were applied instantly, and their drop-ins only written to not lose settings on a later "systemctl daemon-reload", while drop-ins made by the user would only be in effect after "systemctl daemon-reload". This is particular problematic as the changes made by "systemctl set-property" would really apply immediately without any respect for the unit search path. This meant that using "set-property" could have an effect that is lsot as soon as "daemon-reload" is issued, in case there was a "later" drop-in already in place. With this change the directories are seperated, and the "control" directory always takes the highest priority of all, to avoid any confusion.
2016-04-12install: rename generator_paths() → generator_binary_paths()Lennart Poettering
This is too confusing, as this funciton returns the paths to the generator binaries, while usually when we refer to the just the "generator path" we mean the generated unit files. Let's clean this up.
2016-04-12core: move flushing of generated unit files to path-lookup.cLennart Poettering
It's very similar to the mkdir and trim operations for the generator dirs, hence let's unify this at a single place.
2016-04-12path-lookup: make user_runtime_dir() more genericLennart Poettering
Let's make the suffix it appends configurable. This way we can reuse it at a second place.
2016-04-12path-lookup: clean up user_config_home() and user_runtime_dir()Lennart Poettering
Let's modernize these calls a bit. Also, don't call them from user_dirs() anymore, as we already have both dirs in the list a second time via the persistent_config and runtime_config function parameters.
2016-04-12path-lookup: stop exporting two functionsLennart Poettering
user_runtime_dir() and user_config_home() are not used externally anymore, hence let's not export them anymore.
2016-04-12core: rework logic to drop duplicate and non-existing items from search pathLennart Poettering
Move this into a function of its own, so that we can run it after we ran the generators, so that it takes into account removed generator dirs.
2016-04-12path-lookup: split out logic for mkdir/rmdir of generator dirs in their own ↵Lennart Poettering
functions
2016-04-12core: add a separate unit directory for transient unitsLennart Poettering
Previously, transient units were created below the normal runtime directory /run/systemd/system. With this change they are created in a special transient directory /run/systemd/transient, which only contains data for transient units. This clarifies the life-cycle of transient units, and makes clear they are distinct from user-provided runtime units. In particular, users may now extend transient units via /run/systemd/system, without systemd interfering with the life-cycle of these files. This change also adds code so that when a transient unit exits only the drop-ins in this new directory are removed, but nothing else. Fixes: #2139
2016-04-12path-lookup: add configured unit paths back into search pathLennart Poettering
After all, for test builds they might differ from /etc/systemd/{user|system}, hence they should be included.
2016-04-12install: add root directory to LookupPaths structureLennart Poettering
We use the root directory parameter while putting together the LookupPaths structure, hence let's also store it in the structure as-is. That way we can drop a parameter from half of the functions in install.c Also, let's move the validation of the root paths into lookup_paths_init() so that we can drop even more code from install.c
2016-04-12core: remove ManagerRunningAs enumLennart Poettering
Previously, we had two enums ManagerRunningAs and UnitFileScope, that were mostly identical and converted from one to the other all the time. The latter had one more value UNIT_FILE_GLOBAL however. Let's simplify things, and remove ManagerRunningAs and replace it by UnitFileScope everywhere, thus making the translation unnecessary. Introduce two new macros MANAGER_IS_SYSTEM() and MANAGER_IS_USER() to simplify checking if we are running in one or the user context.
2016-04-12core: add configuration directories to LookupPathsLennart Poettering
Let's add a seperate fields for the directories where we place runtime and persistent configuration, so that we can use this in install.c (to be added in a later commit), and we store path information in the same place everywhere.
2016-04-12core: rework generator dir logic, move the dirs into LookupPaths structureLennart Poettering
A long time ago – when generators where first introduced – the directories for them were randomly created via mkdtemp(). This was changed later so that they use fixed name directories now. Let's make use of this, and add the genrator dirs to the LookupPaths structure and into the unit file search path maintained in it. This has the benefit that the generator dirs are now normal part of the search path for all tools, and thus are shown in "systemctl list-unit-files" too.
2016-04-12core: drop SysV paths from path-lookup logicLennart Poettering
We don't need it anymore, give that sysv-generator can determine the path on its own now.
2016-02-10tree-wide: remove Emacs lines from all filesDaniel Mack
This should be handled fine now by .dir-locals.el, so need to carry that stuff in every file.
2015-12-06shared: include what we useThomas Hindoe Paaboel Andersen
The next step of a general cleanup of our includes. This one mostly adds missing includes but there are a few removals as well.
2015-11-16tree-wide: sort includesThomas Hindoe Paaboel Andersen
Sort the includes accoding to the new coding style.
2015-10-27util-lib: split out allocation calls into alloc-util.[ch]Lennart Poettering
2015-10-24util-lib: split our string related calls from util.[ch] into its own file ↵Lennart Poettering
string-util.[ch] There are more than enough calls doing string manipulations to deserve its own files, hence do something about it. This patch also sorts the #include blocks of all files that needed to be updated, according to the sorting suggestions from CODING_STYLE. Since pretty much every file needs our string manipulation functions this effectively means that most files have sorted #include blocks now. Also touches a few unrelated include files.
2015-10-24util-lib: get_current_dir_name() can return errors other than ENOMEMLennart Poettering
get_current_dir_name() can return a variety of errors, not just ENOMEM, hence don't blindly turn its errors to ENOMEM, but return correct errors in path_make_absolute_cwd(). This trickles down into a couple of other functions, some of which receive unrelated minor fixes too with this commit.
2015-10-07ask-password: add support for caching passwords in the kernel keyringLennart Poettering
This adds support for caching harddisk passwords in the kernel keyring if it is available, thus supporting caching without Plymouth being around. This is also useful for hooking up "gdm-auto-login" with the collected boot-time harddisk password, in order to support gnome keyring passphrase unlocking via the HDD password, if it is the same. Any passwords added to the kernel keyring this way have a timeout of 2.5min at which time they are purged from the kernel.
2015-09-09tree-wide: make use of the fact that strv_free() returns NULLLennart Poettering
Another Coccinelle patch.
2015-05-11core: rename SystemdRunningAs to ManagerRunningAsLennart Poettering
It's primarily just a property of the Manager object after all, and we try to refer to PID 1 as "manager" instead of "systemd", hence let's to stick to this here too.
2015-03-14sysv-generator: initialize LookupPaths just onceZbigniew Jędrzejewski-Szmek
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-02-23remove unused includesThomas Hindoe Paaboel Andersen
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-01-11path-lookup: allow /run to override /etc in generator searchZbigniew Jędrzejewski-Szmek
Generators are different than unit files: they are never automatically generated, so there's no point in allowing /etc to override /run. On the other hand, overriding /etc might be useful in some cases.
2015-01-11Implement masking and overriding of generatorsZbigniew Jędrzejewski-Szmek
Sometimes it is necessary to stop a generator from running. Either because of a bug, or for testing, or some other reason. The only way to do that would be to rename or chmod the generator binary, which is inconvenient and does not survive upgrades. Allow masking and overriding generators similarly to units and other configuration files. For the systemd instance, masking would be more common, rather than overriding generators. For the user instances, it may also be useful for users to have generators in $XDG_CONFIG_HOME to augment or override system-wide generators. Directories are searched according to the usual scheme (/usr/lib, /usr/local/lib, /run, /etc), and files with the same name in higher priority directories override files with the same name in lower priority directories. Empty files and links to /dev/null mask a given name. https://bugs.freedesktop.org/show_bug.cgi?id=87230
2015-01-05path-lookup, systemctl: export lookup_paths_init_from_scope() from ↵Ivan Shapovalov
shared/install.c and use it
2014-10-02Fix order and document user unit dirsZbigniew Jędrzejewski-Szmek
Fixup for 718880ba0d 'add a transient user unit directory'.
2014-10-02Rename user_runtime to user_runtime_dirZbigniew Jędrzejewski-Szmek
This makes this function name similar to user_config_home() and makes it match the name of the environment variable.
2014-10-02add a transient user unit directorySteven Allen
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-07-21Merge systemd-verify with systemd-analyzeZbigniew Jędrzejewski-Szmek
2014-07-20path-lookup: make SYSTEMD_UNIT_PATH more flexibleZbigniew Jędrzejewski-Szmek
It can now contain more than one directory, and can be used to only prepend, not totally override, the normal load path.
2014-07-19core: remove systemd_running_as lookup functionsZbigniew Jędrzejewski-Szmek
They are unused and unlikely to ever be.
2014-07-13path-lookup: don't make ~/.local/share/systemd/user a symlinkTanu Kaskinen
We already encourage upstreams to keep the default configuration separate from user customizations for software that is installed in the system location. Let's allow that separation also for software that is installed in the home directory. Some discussion: http://thread.gmane.org/gmane.comp.sysutils.systemd.devel/19627
2014-06-20shared: rename path_strv_canonicalize_absolute functionsMichael Marineau
Since 12ed81d9 path_strv_canonicalize_absolute leaves the search list relative to the given root directory instead of resolving paths to their true location as the name implies. To better reflect this behavior rename to the less strongly worded path_strv_resolve.