+ if (add_symlink("console-getty.service", "console-getty.service") < 0)
+ return EXIT_FAILURE;
+
+ /* When $container_ttys is set for PID 1, spawn
+ * gettys on all ptys named therein. Note that despite
+ * the variable name we only support ptys here. */
+
+ r = getenv_for_pid(1, "container_ttys", &container_ttys);
+ if (r > 0) {
+ const char *word, *state;
+ size_t l;
+
+ FOREACH_WORD(word, l, container_ttys, state) {
+ const char *t;
+ char tty[l + 1];
+
+ memcpy(tty, word, l);
+ tty[l] = 0;
+
+ /* First strip off /dev/ if it is specified */
+ t = path_startswith(tty, "/dev/");
+ if (!t)
+ t = tty;
+
+ /* Then, make sure it's actually a pty */
+ t = path_startswith(t, "pts/");
+ if (!t)
+ continue;
+
+ if (add_container_getty(t) < 0)
+ return EXIT_FAILURE;
+ }
+ }