Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,19 @@ OpenRC NEWS
This file will contain a list of notable changes for each release. Note
the information in this file is in reverse order.

## OpenRC 0.64

librc: rc_runlevel_get() now returns NULL when no runlevel has been set,
instead of falling back to "sysinit".

rc-update now adds/deletes services in the default runlevel when invoked
without a runlevel if none is set (for example in a chroot).

rc-status -r now prints an empty line when no runlevel has been set.

The RC_DEFAULTLEVEL environment variable now honours the
rc_default_runlevel setting from rc.conf.

## OpenRC 0.62

User services are no longer considered experimental.
Expand Down
3 changes: 2 additions & 1 deletion man/rc-status.8
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ List all defined runlevels.
.It Fl m , -manual
Show all manually started services.
.It Fl r , -runlevel
Print the current runlevel name.
Print the current runlevel name, or an empty line if no runlevel has
been set.
.It Fl S , -supervised
Show all supervised services.
.It Fl s , -servicelist
Expand Down
2 changes: 1 addition & 1 deletion src/librc/librc.c
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ rc_runlevel_get(void)

if (!runlevel || !*runlevel) {
free(runlevel);
runlevel = xstrdup(RC_LEVEL_SYSINIT);
runlevel = NULL;
}

return runlevel;
Expand Down
2 changes: 1 addition & 1 deletion src/librc/rc.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ const char *rc_runleveldir(void);
const char *rc_svcdir(void);

/*! Return the current runlevel.
* @return the current runlevel */
* @return the current runlevel, or NULL if no runlevel has been set */
char *rc_runlevel_get(void);

/*! Checks if the runlevel exists or not
Expand Down
2 changes: 1 addition & 1 deletion src/openrc-run/openrc-run.c
Original file line number Diff line number Diff line change
Expand Up @@ -1290,7 +1290,7 @@ int main(int argc, char **argv)
if ((runlevel = xstrdup(getenv("RC_RUNLEVEL"))) == NULL) {
env_filter();
env_config();
runlevel = rc_runlevel_get();
runlevel = effective_runlevel();
}

setenv("EINFO_LOG", applet, 1);
Expand Down
4 changes: 2 additions & 2 deletions src/openrc/rc.c
Original file line number Diff line number Diff line change
Expand Up @@ -875,7 +875,7 @@ int main(int argc, char **argv)
* won't actually be starting them all.
*/
bootlevel = getenv("RC_BOOTLEVEL");
runlevel = rc_runlevel_get();
runlevel = effective_runlevel();

rc_logger_open(newlevel ? newlevel : runlevel);

Expand All @@ -890,7 +890,7 @@ int main(int argc, char **argv)
if (newlevel && strcmp(newlevel, RC_LEVEL_SYSINIT) == 0) {
do_sysinit();
free(runlevel);
runlevel = rc_runlevel_get();
runlevel = effective_runlevel();
}

rc_plugin_load();
Expand Down
2 changes: 1 addition & 1 deletion src/rc-depend/rc-depend.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ int main(int argc, char **argv)
}

if (!runlevel)
runlevel = rc_runlevel_get();
runlevel = effective_runlevel();

services = rc_stringlist_new();
while (optind < argc) {
Expand Down
8 changes: 4 additions & 4 deletions src/rc-status/rc-status.c
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@ static void print_services_in_state(const char *runlevel, RC_STRINGLIST *svcs,
rc_stringlist_add(types, "iafter");
}
if (!runlevel)
r = rc_runlevel_get();
r = effective_runlevel();
l = rc_deptree_depends(deptree, types, svcs, r ? r : runlevel,
RC_DEP_STRICT | RC_DEP_TRACE | RC_DEP_START);
free(r);
Expand Down Expand Up @@ -377,7 +377,7 @@ int main(int argc, char **argv)
/* NOTREACHED */
case 'r':
runlevel = rc_runlevel_get();
printf("%s\n", runlevel);
printf("%s\n", runlevel ? runlevel : "");
goto exit;
/* NOTREACHED */
case 'S':
Expand Down Expand Up @@ -432,7 +432,7 @@ int main(int argc, char **argv)
if (opt == 0)
exit(EXIT_FAILURE);
if (!TAILQ_FIRST(levels)) {
runlevel = rc_runlevel_get();
runlevel = effective_runlevel();
rc_stringlist_add(levels, runlevel);
}

Expand Down Expand Up @@ -463,7 +463,7 @@ int main(int argc, char **argv)
rc_stringlist_free(levels);
levels = rc_stringlist_new();
if (!runlevel)
runlevel = rc_runlevel_get();
runlevel = effective_runlevel();
rc_stringlist_add(levels, runlevel);
}
rc_stringlist_add(levels, RC_LEVEL_SYSINIT);
Expand Down
3 changes: 2 additions & 1 deletion src/rc-update/rc-update.c
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,8 @@ int main(int argc, char **argv)
runlevels = rc_runlevel_list();
} else {
p = rc_runlevel_get();
rc_stringlist_add(runlevels, p);
rc_stringlist_add(runlevels,
p ? p : default_runlevel());
free(p);
}
}
Expand Down
29 changes: 26 additions & 3 deletions src/shared/misc.c
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,25 @@ env_filter(void)
rc_stringlist_free(profile);
}

const char *
default_runlevel(void)
{
const char *runlevel = rc_conf_value("rc_default_runlevel");

return runlevel ? runlevel : RC_LEVEL_DEFAULT;
}

char *
effective_runlevel(void)
{
char *runlevel = rc_runlevel_get();

if (!runlevel)
runlevel = xstrdup(rc_is_user() ? default_runlevel() : RC_LEVEL_SYSINIT);

return runlevel;
}

void
env_config(void)
{
Expand Down Expand Up @@ -218,7 +237,7 @@ env_config(void)
}

xasprintf(&tmpdir, "%s/tmp", svcdir);
e = rc_runlevel_get();
e = effective_runlevel();

setenv("RC_VERSION", VERSION, 1);
setenv("RC_LIBEXECDIR", RC_LIBEXECDIR, 1);
Expand All @@ -240,13 +259,17 @@ env_config(void)
free(e);
free(tmpdir);

if ((fp = fopen(RC_KRUNLEVEL, "r"))) {
/* krunlevel is a system-wide override; it never applies to
* user sessions. */
if (!rc_is_user() && (fp = fopen(RC_KRUNLEVEL, "r"))) {
if (xgetline(&buffer, &size, fp) != -1)
setenv("RC_DEFAULTLEVEL", buffer, 1);
else
setenv("RC_DEFAULTLEVEL", default_runlevel(), 1);
free(buffer);
fclose(fp);
} else {
setenv("RC_DEFAULTLEVEL", RC_LEVEL_DEFAULT, 1);
setenv("RC_DEFAULTLEVEL", default_runlevel(), 1);
}

if (sys)
Expand Down
2 changes: 2 additions & 0 deletions src/shared/misc.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@

char *rc_conf_value(const char *var);
bool rc_conf_yesno(const char *var);
const char *default_runlevel(void);
char *effective_runlevel(void);
void env_filter(void);
void env_config(void);
int signal_setup(int sig, void (*handler)(int));
Expand Down
Loading