Commit graph

1555 commits

Author SHA1 Message Date
Lennart Poettering 4a4d89b682 util: make creation time xattr logic more generic 2014-12-24 16:53:04 +01:00
Shawn Paul Landden 0254e9448f util: fix strict aliasing violations in use of struct inotify_event v5
There is alot of cleanup that will have to happen to turn on
-fstrict-aliasing, but I think our code should be "correct" to the rule.
2014-12-24 16:53:04 +01:00
Lennart Poettering 8b169c0fc2 build-sys: move core/build.h → shared/build.h
After all, pretty much all our tools include it, and it should hence be
shared.

Also move sysfs-show.h from core/ to login/, since it has no point to
exist in core.
2014-12-23 21:05:28 +01:00
Lennart Poettering 5f8cc96a03 machined: add new call OpenMachineLogin() that starts a getty in a container on a pty and returns the pty master fd to the client
This is a one-stop solution for "machinectl login", and should simplify
getting logins in containers.
2014-12-23 19:15:27 +01:00
Lennart Poettering 080bfdbb8e condition: don't include files from src/core 2014-12-23 19:15:27 +01:00
Lennart Poettering 039f0e70a0 env-util: don't include files from src/core/ 2014-12-23 19:15:27 +01:00
Lennart Poettering 9d8c4979c0 util: add allocation loop to gettyname_malloc() 2014-12-23 03:26:24 +01:00
Lennart Poettering 611b312b7d nspawn,pty: port over to new ptsname_malloc() helper 2014-12-23 03:26:24 +01:00
Lennart Poettering ee451d766a systemd-run: support -t mode when combined with -M
For that, ask machined for a container PTY and use that.
2014-12-23 03:26:24 +01:00
Lennart Poettering 9b15b7846d run: add a new "-t" mode for invoking a binary on an allocated TTY 2014-12-23 03:26:24 +01:00
Tom Gundersen 9bae67d49b shared: json - support escaping utf16 surrogate pairs
We originally only supported escaping ucs2 encoded characters (as \uxxxx). This
only covers the BMP. Support escaping also utf16 surrogate pairs (on the form
\uxxxx\uyyyy) to cover all of unicode.
2014-12-22 20:27:20 +01:00
Tom Gundersen 04166cb7dd shared: utf8 - support decoding the full utf16
We originally only supported the BMP (i.e., we treated UTF-16 as UCS-2).
2014-12-22 20:26:53 +01:00
Tom Gundersen 2bb4c7e384 shared: utf8 - support ucs4 -> utf8
Originally we only supported ucs2, so move the ucs4 version from libsystemd-terminal to shared
and use that everywhere.
2014-12-22 20:26:53 +01:00
Dave Reisner 540d858183 verbs: fix typo in error message 2014-12-22 08:21:50 -05:00
Lennart Poettering c2ce6a3d82 machined: add new GetImage() bus call for retrieving the bus path for an image 2014-12-19 20:07:23 +01: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 43343ee7c2 verbs: when invoking the default verb, pass a faked argv array, with just the verb in it
That way the dispatcher calls know how they got called.
2014-12-19 19:19:29 +01:00
Lennart Poettering cd61c3bfd7 machined/machinectl: add logic to show list of available images
This adds a new bus call to machined that enumerates /var/lib/container
and returns all trees stored in it, distuingishing three types:

        - GPT disk images, which are files suffixed with ".gpt"
        - directory trees
        - btrfs subvolumes
2014-12-19 19:19:29 +01:00
Lennart Poettering 8eebf6ad55 util: when creating temporary filename for atomic creation of files, add an extra "#" to the name
That way, we have a simple, somewhat reliable way to detect such
temporary files, by simply checking if they start with ".#".
2014-12-19 19:19:29 +01:00
Lennart Poettering 72648326ea import: add new minimal tool "systemd-import" for pulling down foreign containers and install them locally
This adds a simply but powerful tool for downloading container images
from the most popular container solution used today. Use it like
this:

       # systemd-import pull-dck mattdm/fedora
       # systemd-nspawn -M fedora

This will donwload the layers for "mattdm/fedora", and make them
available locally as /var/lib/container/fedora.

The tool is pretty complete, as long as it's only about pulling down
images, or updating them. Pushing or searching is not supported yet.
2014-12-19 02:08:14 +01:00
Lennart Poettering dca59f6266 util: add generalization of verb parsing for command line tools
We should move loginctl, timedatectl, machinectl over to use this new
API instead of a manual one.
2014-12-19 02:07:42 +01:00
Lennart Poettering e02d225b1e util: make sure rm_rf() can be called on symlinks (with the effect of deleting it) 2014-12-19 02:07:42 +01:00
Lennart Poettering e1dd6790e4 strv: ass new strv_is_uniq() and strv_reverse() calls 2014-12-19 02:07:42 +01:00
Zbigniew Jędrzejewski-Szmek ba774317ac Treat a trailing backslash as an error
Commit a2a5291b3f changed the parser to reject unfinished quoted
strings. Unfortunately it introduced an error where a trailing
backslash would case an infinite loop. Of course this must fixed, but
the question is what to to instead. Allowing trailing backslashes and
treating them as normal characters would be one option, but this seems
suboptimal. First, there would be inconsistency between handling of
quoting and of backslashes. Second, a trailing backslash is most
likely an error, at it seems better to point it out to the user than
to try to continue.

Updated rules:
ExecStart=/bin/echo \\ → OK, prints a backslash
ExecStart=/bin/echo \ → error
ExecStart=/bin/echo "x → error
ExecStart=/bin/echo "x"y → error
2014-12-18 19:26:21 -05:00
Zbigniew Jędrzejewski-Szmek 447021aafd tree-wide: make condition_free_list return NULL 2014-12-18 19:26:21 -05:00
Dave Reisner e40872fc53 path-util: fix breakage in path_is_mount_point
This fixes 2 problems introduced by 6feeeab0bc:

1) If name_to_handle_at returns ENOSYS for the child, we'll wrongly
return -ENOSYS when it returns the same for the parent. Immediately
jump to the fallback logic when we get ENOSYS.

2) If name_to_handle_at returns EOPNOTSUPP for the child but suceeds
for the parent, we'll be comparing an uninitialized value (mount_id) to
an initialized value (mount_id_parent). Initialize the mount_id
variables to invalid mount_ids to avoid this.
2014-12-18 18:34:12 -05:00
Zbigniew Jędrzejewski-Szmek ee05e7795b core: use raw_clone instead of fork in signal handler
fork() is not async-signal-safe and calling it from the signal handler
could result in a deadlock when at_fork() handlers are called. Using
the raw clone() syscall sidesteps that problem.

The tricky part is that raise() does not work, since getpid() does not
work. Add raw_getpid() to get the real pid, and use kill() instead of
raise().

https://bugs.freedesktop.org/show_bug.cgi?id=86604
2014-12-18 00:52:41 -05:00
Zbigniew Jędrzejewski-Szmek 6feeeab0bc path: make the check for unsupported name_to_handle_at symmetric
If child supports, but the parent does not, or when the child does
not support, but the parent does, assume the child is a mount point.

Only if neither supports use the fallback.
2014-12-17 21:08:16 -05:00
Umut Tezduyar Lindskog b890bf6a81 path: follow symbolic link for parent path (2)
c0e57ba9e2 fixed the fallback path.
We should do the same for name_to_handle_at().
2014-12-17 21:08:16 -05:00
Lennart Poettering f2cbe59e11 machinectl: add new commands for copying files from/to containers 2014-12-18 01:36:28 +01:00
Lennart Poettering 20b63d12b5 util: in make_stdio() use dup2() rather than dup3()
dup3() allows setting O_CLOEXEC which we are not interested in. However,
it also fails if called with the same fd as input and output, which is
something we don't want. Hence use dup2().

Also, we need to explicitly turn off O_CLOEXEC for the fds, in case the
input fd was O_CLOEXEC and < 3.
2014-12-18 01:36:28 +01:00
Ken Werner 60e1651a31 nspawn: fix invocation of the raw clone() system call on s390 and cris
Since the order of the first and second arguments of the raw clone() system
call is reversed on s390 and cris it needs to be invoked differently.
2014-12-17 00:20:56 -05:00
Umut Tezduyar Lindskog c0e57ba9e2 path: follow symbolic link for parent path
[zj: When we lstat the target path, symlinks above the last component
     will be followed by both stat and lstat. So when we look at the
     parent, we should follow symlinks.]
2014-12-16 21:19:19 -05:00
Tom Gundersen dd9c7723fa shared: strv - add strv_clear()
This frees the elements of the strv without freeing the strv itself.
2014-12-17 01:09:16 +01:00
Tom Gundersen 3542eac7f9 shared: path-util - memory leak 2014-12-16 22:54:04 +01:00
Susant Sahani b0ceb53a7d fix compiler warning
src/shared/utf8.c:268:13: warning: unused variable 'd'
[-Wunused-variable]
         int d;
2014-12-16 00:30:34 -05:00
Zbigniew Jędrzejewski-Szmek bc854dc7cd systemctl: refuse to edit runtime dropins when they already exist in /etc
The check for existing unit files and dropins is unified.

path_join() is updated to not insert duplicate separators.
2014-12-16 00:30:34 -05:00
Zbigniew Jędrzejewski-Szmek 1a7f1b385c Move dropin listing to shared
No functional change. This is in preparation for using this in
systemctl in the future.
2014-12-16 00:30:33 -05:00
Lennart Poettering e7eebcfc42 shared: add minimal JSON tokenizer 2014-12-15 22:27:15 +01:00
Tom Gundersen c532d8a00c udev: builtin-hwdb - port to sd-hwdb 2014-12-15 20:40:09 +01:00
Martin Pitt e17fb3c1dd shared: time-dst: Avoid buffer overflow
Commit 681f9718 introduced an additional null terminator for the zone names.
Increase the allocation of "transitions" to actually make room for this.
2014-12-15 13:50:11 +01:00
Michal Schmidt fc86aa0ed2 configure.ac: add a generic --enable-debug, replace --enable-hashmap-debug
There will be more debugging options later.
 --enable-debug will enable them all.
 --enable-debug=hashmap will enable only hashmap debugging.

Also rename the C #define to ENABLE_DEBUG_* pattern.
2014-12-13 00:46:16 +01:00
Michal Schmidt 90df619ef5 shared/hashmap.h: fix comment
An early version used underscore prefixes for internal functions, but
the current version uses the prefix "internal_".
2014-12-13 00:46:16 +01:00
Lennart Poettering c4e34a612c nspawn: allow spawning ephemeral nspawn containers based on the root file system of the OS
This works now:

        # systemd-nspawn -xb -D / -M foobar

Which boots up an ephemeral container, based on the host's root file
system. Or in other words: you can now run the very same host OS you
booted your system with also in a container, on top of it, without
having it interfere. Great for testing whether the init system you are
hacking on still boots without reboot the system!
2014-12-12 17:30:25 +01:00
Lennart Poettering 7430ec6ac0 copy: use btrfs reflinking only whe we know we copy full files 2014-12-12 17:30:25 +01:00
Lennart Poettering ec16945ebf nspawn: beef up nspawn with some btrfs magic
This adds --template= to duplicate an OS tree as btrfs snpashot and run
it

This also adds --ephemeral or -x to create a snapshot of an OS tree and
boot that, removing it after exit.
2014-12-12 13:35:32 +01:00
Lennart Poettering 0254b455e9 copy: teach copy_bytes() btrfs reflink magic 2014-12-12 13:35:32 +01:00
Lennart Poettering d7c7c334f5 shared: add new btrfs-util.[ch] helpers for doing common btrfs operation 2014-12-12 13:35:32 +01:00
Lennart Poettering 700c6087eb shared: missing.h should include btrfs.h, before redefining some of its definitions 2014-12-12 13:35:32 +01:00
Lennart Poettering 6ce830fa61 util: minor simplification for loop_write() and loop_read() 2014-12-12 13:35:32 +01:00