mirror of
https://github.com/systemd/systemd.git
synced 2025-02-23 13:57:33 +03:00
main: replace --running-as= by --session and --system do mimic related tools and D-Bus
This commit is contained in:
parent
eee4b05fab
commit
edb9aaa8b2
@ -10,7 +10,8 @@ HOWTO:
|
|||||||
you need to add/change things.
|
you need to add/change things.
|
||||||
|
|
||||||
1) Patch src/hostname-setup.c so that systemd knows where to
|
1) Patch src/hostname-setup.c so that systemd knows where to
|
||||||
read your host name from.
|
read your host name from. You might also want to update
|
||||||
|
status_welcome() in util.c.
|
||||||
|
|
||||||
2) Check the unit files in units/ if they match your
|
2) Check the unit files in units/ if they match your
|
||||||
distribution. Most likely you will have to make additions to
|
distribution. Most likely you will have to make additions to
|
||||||
@ -23,11 +24,11 @@ HOWTO:
|
|||||||
and you should be able to find the places where you need to
|
and you should be able to find the places where you need to
|
||||||
add/change things.
|
add/change things.
|
||||||
|
|
||||||
4) Try it out. Play around with 'systemd --test
|
4) Try it out. Play around with 'systemd --test --system' for
|
||||||
--running-as=init' for a test run of systemd without
|
a test run of systemd without booting. This will read the unit
|
||||||
booting. This will read the unit files and print the initial
|
files and print the initial transaction it would execute
|
||||||
transaction it would execute during boot-up. This will also
|
during boot-up. This will also inform you about ordering loops
|
||||||
inform you about ordering loops and suchlike.
|
and suchlike.
|
||||||
|
|
||||||
CONTRIBUTING UPSTREAM:
|
CONTRIBUTING UPSTREAM:
|
||||||
We are interested in merging your changes upstream, if they
|
We are interested in merging your changes upstream, if they
|
||||||
|
@ -135,17 +135,19 @@
|
|||||||
<filename>default.target</filename>.</para></listitem>
|
<filename>default.target</filename>.</para></listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term><option>--running-as=</option></term>
|
<term><option>--system</option></term>
|
||||||
|
<term><option>--session</option></term>
|
||||||
|
|
||||||
<listitem><para>Tell systemd to run in
|
<listitem><para>Tell systemd to run a
|
||||||
a particular mode. Argument is one of
|
system instance (resp. session
|
||||||
<option>system</option>,
|
instance), even if the process ID is
|
||||||
<option>session</option>. Normally it
|
not 1 (resp. is 1), i.e. system is not
|
||||||
should not be necessary to pass this
|
(resp. is) run as init process.
|
||||||
option, as systemd automatically
|
Normally it should not be necessary to
|
||||||
detects the mode it is started
|
pass these options, as systemd
|
||||||
in. This call is hence of little use
|
automatically detects the mode it is
|
||||||
except for
|
started in. These options are hence of
|
||||||
|
little use except for
|
||||||
debugging.</para></listitem>
|
debugging.</para></listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
@ -466,7 +468,7 @@
|
|||||||
when figuring out whether a service
|
when figuring out whether a service
|
||||||
shall be enabled. Note that a service
|
shall be enabled. Note that a service
|
||||||
unit with a native unit configuration
|
unit with a native unit configuration
|
||||||
file can be started by activating it
|
file cannot be started by activating it
|
||||||
in the SysV runlevel link
|
in the SysV runlevel link
|
||||||
farm.</para></listitem>
|
farm.</para></listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
48
src/main.c
48
src/main.c
@ -545,7 +545,8 @@ static int parse_argv(int argc, char *argv[]) {
|
|||||||
ARG_LOG_COLOR,
|
ARG_LOG_COLOR,
|
||||||
ARG_LOG_LOCATION,
|
ARG_LOG_LOCATION,
|
||||||
ARG_UNIT,
|
ARG_UNIT,
|
||||||
ARG_RUNNING_AS,
|
ARG_SYSTEM,
|
||||||
|
ARG_SESSION,
|
||||||
ARG_TEST,
|
ARG_TEST,
|
||||||
ARG_DUMP_CONFIGURATION_ITEMS,
|
ARG_DUMP_CONFIGURATION_ITEMS,
|
||||||
ARG_DUMP_CORE,
|
ARG_DUMP_CORE,
|
||||||
@ -562,7 +563,8 @@ static int parse_argv(int argc, char *argv[]) {
|
|||||||
{ "log-color", optional_argument, NULL, ARG_LOG_COLOR },
|
{ "log-color", optional_argument, NULL, ARG_LOG_COLOR },
|
||||||
{ "log-location", optional_argument, NULL, ARG_LOG_LOCATION },
|
{ "log-location", optional_argument, NULL, ARG_LOG_LOCATION },
|
||||||
{ "unit", required_argument, NULL, ARG_UNIT },
|
{ "unit", required_argument, NULL, ARG_UNIT },
|
||||||
{ "running-as", required_argument, NULL, ARG_RUNNING_AS },
|
{ "system", no_argument, NULL, ARG_SYSTEM },
|
||||||
|
{ "session", no_argument, NULL, ARG_SESSION },
|
||||||
{ "test", no_argument, NULL, ARG_TEST },
|
{ "test", no_argument, NULL, ARG_TEST },
|
||||||
{ "help", no_argument, NULL, 'h' },
|
{ "help", no_argument, NULL, 'h' },
|
||||||
{ "dump-configuration-items", no_argument, NULL, ARG_DUMP_CONFIGURATION_ITEMS },
|
{ "dump-configuration-items", no_argument, NULL, ARG_DUMP_CONFIGURATION_ITEMS },
|
||||||
@ -634,17 +636,13 @@ static int parse_argv(int argc, char *argv[]) {
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case ARG_RUNNING_AS: {
|
case ARG_SYSTEM:
|
||||||
ManagerRunningAs as;
|
arg_running_as = MANAGER_SYSTEM;
|
||||||
|
break;
|
||||||
if ((as = manager_running_as_from_string(optarg)) < 0) {
|
|
||||||
log_error("Failed to parse running as value %s", optarg);
|
case ARG_SESSION:
|
||||||
return -EINVAL;
|
arg_running_as = MANAGER_SESSION;
|
||||||
}
|
|
||||||
|
|
||||||
arg_running_as = as;
|
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
case ARG_TEST:
|
case ARG_TEST:
|
||||||
arg_action = ACTION_TEST;
|
arg_action = ACTION_TEST;
|
||||||
@ -746,7 +744,8 @@ static int help(void) {
|
|||||||
" --dump-configuration-items Dump understood unit configuration items\n"
|
" --dump-configuration-items Dump understood unit configuration items\n"
|
||||||
" --introspect[=INTERFACE] Extract D-Bus interface data\n"
|
" --introspect[=INTERFACE] Extract D-Bus interface data\n"
|
||||||
" --unit=UNIT Set default unit\n"
|
" --unit=UNIT Set default unit\n"
|
||||||
" --running-as=AS Set running as (system, session)\n"
|
" --system Run a system instance, even if PID != 1\n"
|
||||||
|
" --session Run a session instance\n"
|
||||||
" --dump-core Dump core on crash\n"
|
" --dump-core Dump core on crash\n"
|
||||||
" --crash-shell Run shell on crash\n"
|
" --crash-shell Run shell on crash\n"
|
||||||
" --confirm-spawn Ask for confirmation when spawning processes\n"
|
" --confirm-spawn Ask for confirmation when spawning processes\n"
|
||||||
@ -1042,7 +1041,7 @@ finish:
|
|||||||
dbus_shutdown();
|
dbus_shutdown();
|
||||||
|
|
||||||
if (reexecute) {
|
if (reexecute) {
|
||||||
const char *args[11];
|
const char *args[14];
|
||||||
unsigned i = 0;
|
unsigned i = 0;
|
||||||
char sfd[16];
|
char sfd[16];
|
||||||
|
|
||||||
@ -1057,8 +1056,22 @@ finish:
|
|||||||
args[i++] = "--log-target";
|
args[i++] = "--log-target";
|
||||||
args[i++] = log_target_to_string(log_get_target());
|
args[i++] = log_target_to_string(log_get_target());
|
||||||
|
|
||||||
args[i++] = "--running-as";
|
if (arg_running_as == MANAGER_SYSTEM)
|
||||||
args[i++] = manager_running_as_to_string(arg_running_as);
|
args[i++] = "--system";
|
||||||
|
else
|
||||||
|
args[i++] = "--session";
|
||||||
|
|
||||||
|
if (arg_dump_core)
|
||||||
|
args[i++] = "--dump-core";
|
||||||
|
|
||||||
|
if (arg_crash_shell)
|
||||||
|
args[i++] = "--crash-shell";
|
||||||
|
|
||||||
|
if (arg_confirm_spawn)
|
||||||
|
args[i++] = "--confirm-spawn";
|
||||||
|
|
||||||
|
if (arg_show_status)
|
||||||
|
args[i++] = "--show-status";
|
||||||
|
|
||||||
snprintf(sfd, sizeof(sfd), "%i", fileno(serialization));
|
snprintf(sfd, sizeof(sfd), "%i", fileno(serialization));
|
||||||
char_array_0(sfd);
|
char_array_0(sfd);
|
||||||
@ -1066,9 +1079,6 @@ finish:
|
|||||||
args[i++] = "--deserialize";
|
args[i++] = "--deserialize";
|
||||||
args[i++] = sfd;
|
args[i++] = sfd;
|
||||||
|
|
||||||
if (arg_confirm_spawn)
|
|
||||||
args[i++] = "--confirm-spawn";
|
|
||||||
|
|
||||||
args[i++] = NULL;
|
args[i++] = NULL;
|
||||||
|
|
||||||
assert(i <= ELEMENTSOF(args));
|
assert(i <= ELEMENTSOF(args));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user