diff options
author | Luke Shumaker <lukeshu@lukeshu.com> | 2017-10-25 22:56:07 -0400 |
---|---|---|
committer | Luke Shumaker <lukeshu@lukeshu.com> | 2017-10-25 22:56:07 -0400 |
commit | ad2f606b03dbfbd3f7c0320825edb2e877b211f8 (patch) | |
tree | e660731b4da03d71bb6c6b37e79b967dce228f9d | |
parent | 9565f024ddd08b12dee916a9e9a2806d833e51c5 (diff) |
a
-rw-r--r-- | src/nspawn/nspawn.c | 72 |
1 files changed, 12 insertions, 60 deletions
diff --git a/src/nspawn/nspawn.c b/src/nspawn/nspawn.c index 994347c6de..ac8656b597 100644 --- a/src/nspawn/nspawn.c +++ b/src/nspawn/nspawn.c @@ -143,7 +143,6 @@ static const char *arg_selinux_apifs_context = NULL; static const char *arg_slice = NULL; static bool arg_read_only = false; static StartMode arg_start_mode = START_PID1; -static bool arg_ephemeral = false; static LinkJournal arg_link_journal = LINK_AUTO; static bool arg_link_journal_try = false; static uint64_t arg_caps_retain = @@ -425,10 +424,6 @@ static int parse_argv(int argc, char *argv[]) { return r; break; - case 'x': - arg_ephemeral = true; - break; - case 'u': r = free_and_strdup(&arg_user, optarg); if (r < 0) @@ -849,31 +844,11 @@ static int parse_argv(int argc, char *argv[]) { if (arg_userns_mode == USER_NAMESPACE_PICK) arg_userns_chown = true; - if (arg_ephemeral && arg_template && !arg_directory) { - /* User asked for ephemeral execution but specified --template= instead of --directory=. Semantically - * such an invocation makes some sense, see https://github.com/systemd/systemd/issues/3667. Let's - * accept this here, and silently make "--ephemeral --template=" equivalent to "--ephemeral - * --directory=". */ - - arg_directory = arg_template; - arg_template = NULL; - } - if (arg_template && !(arg_directory || arg_machine)) { log_error("--template= needs --directory= or --machine=."); return -EINVAL; } - if (arg_ephemeral && arg_template) { - log_error("--ephemeral and --template= may not be combined."); - return -EINVAL; - } - - if (arg_ephemeral && !IN_SET(arg_link_journal, LINK_NO, LINK_AUTO)) { - log_error("--ephemeral and --link-journal= may not be combined."); - return -EINVAL; - } - if (arg_userns_mode != USER_NAMESPACE_NO && !userns_supported()) { log_error("--private-users= is not supported, kernel compiled without user namespace support."); return -EOPNOTSUPP; @@ -1384,10 +1359,6 @@ static int setup_journal(const char *directory) { char id[33]; int r; - /* Don't link journals in ephemeral mode */ - if (arg_ephemeral) - return 0; - if (arg_link_journal == LINK_NO) return 0; @@ -1768,21 +1739,6 @@ static int determine_names(void) { log_error("Failed to determine machine name automatically, please use -M."); return -EINVAL; } - - if (arg_ephemeral) { - char *b; - - /* Add a random suffix when this is an - * ephemeral machine, so that we can run many - * instances at once without manually having - * to specify -M each time. */ - - if (asprintf(&b, "%s-%016" PRIx64, arg_machine, random_u64()) < 0) - return log_oom(); - - free(arg_machine); - arg_machine = b; - } } return 0; @@ -2945,28 +2901,24 @@ int main(int argc, char *argv[]) { goto finish; if (arg_directory) { - if (path_equal(arg_directory, "/") && !arg_ephemeral) { + if (path_equal(arg_directory, "/")) { log_error("Spawning container on root directory is not supported. Consider using --ephemeral."); r = -EINVAL; goto finish; } - if (arg_ephemeral) { - } else { - r = chase_symlinks_and_update(&arg_directory, arg_template ? CHASE_NONEXISTENT : 0); - if (r < 0) - goto finish; - - r = image_path_lock(arg_directory, (arg_read_only ? LOCK_SH : LOCK_EX) | LOCK_NB, &tree_global_lock, &tree_local_lock); - if (r == -EBUSY) { - log_error_errno(r, "Directory tree %s is currently busy.", arg_directory); - goto finish; - } - if (r < 0) { - log_error_errno(r, "Failed to lock %s: %m", arg_directory); - goto finish; - } + r = chase_symlinks_and_update(&arg_directory, arg_template ? CHASE_NONEXISTENT : 0); + if (r < 0) + goto finish; + r = image_path_lock(arg_directory, (arg_read_only ? LOCK_SH : LOCK_EX) | LOCK_NB, &tree_global_lock, &tree_local_lock); + if (r == -EBUSY) { + log_error_errno(r, "Directory tree %s is currently busy.", arg_directory); + goto finish; + } + if (r < 0) { + log_error_errno(r, "Failed to lock %s: %m", arg_directory); + goto finish; } if (arg_start_mode == START_BOOT) { |