summaryrefslogtreecommitdiff
path: root/src/shared/path-util.c
AgeCommit message (Collapse)Author
2014-08-18util: try to be a bit more NFS compatible when checking whether an FS is ↵Lennart Poettering
writable https://bugs.freedesktop.org/show_bug.cgi?id=81169
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-07Fix typoZbigniew Jędrzejewski-Szmek
2014-06-25fsck: consider a fsck implementation linked to /bin/true non-existantLennart Poettering
2014-06-24use more _cleanup_ macroRonny Chevalier
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.
2014-06-13os-release: define /usr/lib/os-release as fallback for /etc/os-releaseLennart Poettering
The file should have been in /usr/lib/ in the first place, since it describes the OS container in /usr (and not the configuration in /etc), hence, let's support os-release files in /usr/lib as fallback if no version in /etc exists, following the usual override logic. A prior commit already enabled tmpfiles to create /etc/os-release as a symlink to /usr/lib/os-release should it be missing, thus providing nice compatibility with applications only checking in /etc. While it's probably a good idea if all apps check both locations via a fallback logic, it is only necessary in the early boot process, as long as the /etc/os-release symlink has not been restored, in case we boot with an empty /etc.
2014-05-25path-util: fix missing terminating zeroTanu Kaskinen
There was this code: if (to_path_len > 0) memcpy(p, to_path, to_path_len); That didn't add the terminating zero, so the resulting string was corrupt if this code path was taken. Using strcpy() instead of memcpy() solves this issue, and also simplifies the code. Previously there was special handling for shortening "../../" to "../..", but that has now been replaced by a path_kill_slashes() call, which also makes the result prettier in case the input contains redundant slashes that would otherwise be copied to the result.
2014-05-16path-util: add path_make_relative()Tanu Kaskinen
In user_dirs() in path-lookup.c, I want to replace this: symlink("../../../.config/systemd/user", data_home); with symlink(config_home, data_home); to avoid hardcoding .config when XDG_CONFIG_HOME is set. The problem is that config_home is an absolute path, and it's better to make the symlink relative. path_make_relative() is an utility function that converts an absolute path into a relative one.
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-04-24util: make sure all our name_to_handle_at() code makes use of file_handle_unionLennart Poettering
2014-04-21condense assignment and path_kill_slashes callsDave Reisner
2014-04-12path-util: also check for existence of binary when given absolute pathZbigniew Jędrzejewski-Szmek
In contrast to a filename-only argument, find_binary() did not actually check if an path exists, allowing the code to fail later on. This was OK, but it seems nicer to treat both paths identically. Also take advantage of path_make_absolute_cwd doing strdup() by itself if necessary to simplify.
2014-04-12fsck: Search for fsck.type in PATHMike Gilbert
Modifies find_binary() to accept NULL in the second argument. fsck.type lookup logic moved to new fsck_exists() function, with a test.
2014-02-14shared: include root when canonicalizing conf pathsMichael Marineau
The conf_files_list family accepts an alternate root path to prefix all directories in the list but path_strv_canonicalize_uniq doesn't use it. This results in the suspicious behavior of resolving directory symlinks based on the contents of / instead of the alternate root. This adds a prefix argument to path_strv_canonicalize which will now prepend the prefix, if given, to every path in the list. To avoid answering what a relative path means when called with a root prefix path_strv_canonicalize is now path_strv_canonicalize_absolute and only considers absolute paths. Fortunately all users of already call path_strv_canonicalize with a list of absolute paths.
2014-01-08No need to canonicalize fixed pathsZbigniew Jędrzejewski-Szmek
2013-12-24log: log_error() and friends add a newline after each line anyway, so avoid ↵Lennart Poettering
including it in the log strings
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-06path-util: paths_check_timestamp() opimizationsLennart Poettering
2013-10-29path_check_timestamp: only keep the most recent timestampTom Gundersen
There is no point in keeping one timestamp for each directory, as we only ever care about the most recent one.
2013-10-26udev: move udev_rules_check_timestamp to sharedTom Gundersen
I want to use this from a bulitin in a subsequent patch.
2013-09-09Fix two compiler warningsZbigniew Jędrzejewski-Szmek
2013-09-09run: allow non-absolute paths as commandZbigniew Jędrzejewski-Szmek
2013-09-09path-util.c: small modernizationZbigniew Jędrzejewski-Szmek
2013-05-02time-dst: use _cleanup_Zbigniew Jędrzejewski-Szmek
2013-04-16path-util: unify code for detecting OS treesLennart Poettering
This also makes sure we always detect an OS tree the same way, by checking for /etc/os-release.
2013-02-11binfmt,tmpfiles,modules-load,sysctl: rework the various early-boot services ↵Lennart Poettering
that work on .d/ directories This unifies much of the logic behind them: - All four will now ofllow the rule that the earlier file and earlier assignment in the .d/ directories wins. Before, sysctl was the only outlier, where the later setting always won. - All four now support getopt() and --help on the command line. - All four can now handle specification of configuration file names on the command line to apply. The tools will automatically find them, and apply them. Previously only tmpfiles could do that. This is useful for %post scripts in RPMs and suchlike. - This fixes various error path issues in conf_files_list()
2013-02-11path-util: fix memory leakLennart Poettering
2013-02-06shared: remove now unused functionZbigniew Jędrzejewski-Szmek
2013-02-06systemd: do not remove empty paths from unit lookup pathZbigniew Jędrzejewski-Szmek
The ability to start a new unit with 'systemctl start ...' should not depend on whether there are other units in the directory. Previously, an additional 'systemctl daemon-reload' would be necessary to tell systemd to update the list of unit lookup paths.
2012-12-17path-util: set pointer to null after calling free()Michal Sekletar
In cases where path_strv_canonicalize() returns NULL, strv_free() is called afterwards and it will call free() on pointers which were freed already in path_strv_canonicalize()
2012-09-14timedate: assorted improvementsLennart Poettering
- Make writing/reading of /etc/timezone dependendent of HAVE_SYSV_COMPAT - Introduce symlink_atomic() after all, and use it - Use relative symlink for /etc/localtime
2012-09-10path-util: fall back to stat() if kernel does not support name_to_handle_at()Mantas Mikulėnas
Fixes instant hang on kernels that do not have CONFIG_FHANDLE enabled.
2012-09-10path-util: do not fail in path_is_mountpoint() if path doesn't existMantas Mikulėnas
This was accidentally lost in commit 1640a0b6b05b.
2012-09-04path: fix invalid variable access in path_is_mount_point()Lennart Poettering
2012-09-04path-util: in path_is_mount_point() fall back to the classic stat() test if ↵Lennart Poettering
fs does not support name_to_handle_at()
2012-09-04missing: define name_to_handle_at on our own if it is missingLennart Poettering
2012-09-03util: make path_is_mount_point() recognize bind mounts, tooLennart Poettering
2012-07-13util: rename join() to strjoin()Lennart Poettering
This is to match strappend() and the other string related functions.
2012-05-08util: split-out path-util.[ch]Kay Sievers