</listitem>
</varlistentry>
+ <varlistentry>
+ <term><option>--pty</option></term>
+ <term><option>--pipe</option></term>
+
+ <listitem><para>Request allocation of a pseudo TTY for the <command>run0</command> session (in case
+ of <option>--pty</option>), or request passing the caller's STDIO file descriptors directly through
+ (in case of <option>--pipe</option>). If neither switch is specified, or if both switches are
+ specified, the mode will be picked automatically: if standard input, standard output and standard
+ error output are all connected to a TTY then a pseudo TTY is allocated, otherwise the relevant file
+ descriptors are passed through directly.</para>
+
+ <xi:include href="version-info.xml" xpointer="v257"/>
+ </listitem>
+ </varlistentry>
+
<varlistentry>
<term><option>--machine=</option></term>
if (r < 0)
return log_oom();
+ /* NB: Let's not go overboard with short options: we try to keep a modicum of compatibility with
+ * sudo's short switches, hence please do not introduce new short switches unless they have a roughly
+ * equivalent purpose on sudo. Use long options for everything private to run0. */
+
printf("%s [OPTIONS...] COMMAND [ARGUMENTS...]\n"
"\n%sElevate privileges interactively.%s\n\n"
" -h --help Show this help\n"
" -D --chdir=PATH Set working directory\n"
" --setenv=NAME[=VALUE] Set environment variable\n"
" --background=COLOR Set ANSI color for background\n"
+ " --pty Request allocation of a pseudo TTY for stdio\n"
+ " --pipe Request direct pipe for stdio\n"
"\nSee the %s for details.\n",
program_invocation_short_name,
ansi_highlight(),
ARG_NICE,
ARG_SETENV,
ARG_BACKGROUND,
+ ARG_PTY,
+ ARG_PIPE,
};
/* If invoked as "run0" binary, let's expose a more sudo-like interface. We add various extensions
{ "chdir", required_argument, NULL, 'D' },
{ "setenv", required_argument, NULL, ARG_SETENV },
{ "background", required_argument, NULL, ARG_BACKGROUND },
+ { "pty", no_argument, NULL, ARG_PTY },
+ { "pipe", no_argument, NULL, ARG_PIPE },
{},
};
break;
+ case ARG_PTY:
+ if (IN_SET(arg_stdio, ARG_STDIO_DIRECT, ARG_STDIO_AUTO)) /* if --pipe is already used, upgrade to auto mode */
+ arg_stdio = ARG_STDIO_AUTO;
+ else
+ arg_stdio = ARG_STDIO_PTY;
+ break;
+
+ case ARG_PIPE:
+ if (IN_SET(arg_stdio, ARG_STDIO_PTY, ARG_STDIO_AUTO)) /* If --pty is already used, upgrade to auto mode */
+ arg_stdio = ARG_STDIO_AUTO;
+ else
+ arg_stdio = ARG_STDIO_DIRECT;
+ break;
+
case '?':
return -EINVAL;
arg_wait = true;
arg_aggressive_gc = true;
- arg_stdio = isatty_safe(STDIN_FILENO) && isatty_safe(STDOUT_FILENO) && isatty_safe(STDERR_FILENO) ? ARG_STDIO_PTY : ARG_STDIO_DIRECT;
+ if (IN_SET(arg_stdio, ARG_STDIO_NONE, ARG_STDIO_AUTO))
+ arg_stdio = isatty_safe(STDIN_FILENO) && isatty_safe(STDOUT_FILENO) && isatty_safe(STDERR_FILENO) ? ARG_STDIO_PTY : ARG_STDIO_DIRECT;
+
arg_expand_environment = false;
arg_send_sighup = true;