rc --override foo will override the runlevel to load after boot or single user runlevels to avoid rc recursion, #196338
This commit is contained in:
parent
8c85fa399f
commit
c9fe3ade4c
@ -3,6 +3,9 @@
|
|||||||
|
|
||||||
29 Oct 2007; Roy Marples <uberlord@gentoo.org>:
|
29 Oct 2007; Roy Marples <uberlord@gentoo.org>:
|
||||||
|
|
||||||
|
rc --override foo will override the runlevel to load after boot
|
||||||
|
or single user runlevels to avoid rc recursion, #196338
|
||||||
|
|
||||||
/etc/mtab is now a true reflection on /proc/mounts.
|
/etc/mtab is now a true reflection on /proc/mounts.
|
||||||
The only exception is that we punt any / on tmpfs entry, #194615.
|
The only exception is that we punt any / on tmpfs entry, #194615.
|
||||||
|
|
||||||
|
11
src/_usage.c
11
src/_usage.c
@ -20,9 +20,18 @@ static void usage (int exit_status)
|
|||||||
for (i = 0; longopts[i].name; ++i) {
|
for (i = 0; longopts[i].name; ++i) {
|
||||||
int len = printf (" -%c, --%s %s", longopts[i].val, longopts[i].name,
|
int len = printf (" -%c, --%s %s", longopts[i].val, longopts[i].name,
|
||||||
has_arg[longopts[i].has_arg]);
|
has_arg[longopts[i].has_arg]);
|
||||||
|
|
||||||
|
char *lo = xstrdup (longopts_help[i]);
|
||||||
|
char *p = lo;
|
||||||
|
char *token;
|
||||||
|
|
||||||
|
while ((token = strsep (&p, "\n"))) {
|
||||||
while (++len < 37)
|
while (++len < 37)
|
||||||
printf (" ");
|
printf (" ");
|
||||||
puts (longopts_help[i]);
|
puts (token);
|
||||||
|
len = 0;
|
||||||
|
}
|
||||||
|
free (lo);
|
||||||
}
|
}
|
||||||
exit (exit_status);
|
exit (exit_status);
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
|
|
||||||
#include "builtins.h"
|
#include "builtins.h"
|
||||||
#include "einfo.h"
|
#include "einfo.h"
|
||||||
|
#include "rc-misc.h"
|
||||||
|
|
||||||
static char *applet = NULL;
|
static char *applet = NULL;
|
||||||
|
|
||||||
|
@ -46,6 +46,7 @@
|
|||||||
#include "builtins.h"
|
#include "builtins.h"
|
||||||
#include "einfo.h"
|
#include "einfo.h"
|
||||||
#include "rc.h"
|
#include "rc.h"
|
||||||
|
#include "rc-misc.h"
|
||||||
#include "strlist.h"
|
#include "strlist.h"
|
||||||
|
|
||||||
#ifdef HAVE_GETMNTENT
|
#ifdef HAVE_GETMNTENT
|
||||||
|
15
src/rc.c
15
src/rc.c
@ -544,7 +544,7 @@ static void single_user (void)
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
static void set_ksoftlevel (const char *level)
|
static bool set_ksoftlevel (const char *level)
|
||||||
{
|
{
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
|
|
||||||
@ -556,16 +556,17 @@ static void set_ksoftlevel (const char *level)
|
|||||||
if (exists (RC_KSOFTLEVEL) &&
|
if (exists (RC_KSOFTLEVEL) &&
|
||||||
unlink (RC_KSOFTLEVEL) != 0)
|
unlink (RC_KSOFTLEVEL) != 0)
|
||||||
eerror ("unlink `%s': %s", RC_KSOFTLEVEL, strerror (errno));
|
eerror ("unlink `%s': %s", RC_KSOFTLEVEL, strerror (errno));
|
||||||
return;
|
return (false);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! (fp = fopen (RC_KSOFTLEVEL, "w"))) {
|
if (! (fp = fopen (RC_KSOFTLEVEL, "w"))) {
|
||||||
eerror ("fopen `%s': %s", RC_KSOFTLEVEL, strerror (errno));
|
eerror ("fopen `%s': %s", RC_KSOFTLEVEL, strerror (errno));
|
||||||
return;
|
return (false);
|
||||||
}
|
}
|
||||||
|
|
||||||
fprintf (fp, "%s", level);
|
fprintf (fp, "%s", level);
|
||||||
fclose (fp);
|
fclose (fp);
|
||||||
|
return (true);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int get_ksoftlevel (char *buffer, int buffer_len)
|
static int get_ksoftlevel (char *buffer, int buffer_len)
|
||||||
@ -718,11 +719,13 @@ static void run_script (const char *script) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#include "_usage.h"
|
#include "_usage.h"
|
||||||
#define getoptstring getoptstring_COMMON
|
#define getoptstring "o:" getoptstring_COMMON
|
||||||
static struct option longopts[] = {
|
static struct option longopts[] = {
|
||||||
|
{ "override", 1, NULL, 'o' },
|
||||||
longopts_COMMON
|
longopts_COMMON
|
||||||
};
|
};
|
||||||
static const char * const longopts_help[] = {
|
static const char * const longopts_help[] = {
|
||||||
|
"override the next runlevel to change into\nwhen leaving single user or boot runlevels",
|
||||||
longopts_help_COMMON
|
longopts_help_COMMON
|
||||||
};
|
};
|
||||||
#include "_usage.c"
|
#include "_usage.c"
|
||||||
@ -870,6 +873,10 @@ int main (int argc, char **argv)
|
|||||||
longopts, (int *) 0)) != -1)
|
longopts, (int *) 0)) != -1)
|
||||||
{
|
{
|
||||||
switch (opt) {
|
switch (opt) {
|
||||||
|
case 'o':
|
||||||
|
if (strlen (optarg) == 0)
|
||||||
|
optarg = NULL;
|
||||||
|
exit (set_ksoftlevel (optarg) ? EXIT_SUCCESS : EXIT_FAILURE);
|
||||||
case_RC_COMMON_GETOPT
|
case_RC_COMMON_GETOPT
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user