source: patches/sysvinit-2.86-fixes-1.patch@ af4d05c

clfs-1.2 clfs-2.1 clfs-3.0.0-systemd clfs-3.0.0-sysvinit systemd sysvinit
Last change on this file since af4d05c was de28452, checked in by Jim Gifford <clfs@…>, 16 years ago

Added patch to fix issues with Sysvinit

  • Property mode set to 100644
File size: 20.5 KB
  • sysvinit-2.86

    Submitted By: Jim Gifford (jim at cross-lfs dot org)
    Date: 01-07-2008
    Initial Package Version: 2.86
    Origin: Various
    Upstream Status: Unknown
    Description: Fixes to Major issues in Sysvinit -- listed Below
    	IPV6 Displayed Incorrectly
    	On 64bit which have 32bit multilib support, the utmp struct is the same
    	Fix bug where proc names are truncated
    	Fixed support for POSIX capabilite
    	All halt/reboot to handle being called by login correctly
    	Preserve waiting state across re-exec
    	Allow failed console opens some time to resolve themselves
    	
    	New:
    	Added kexec support
    
    diff -Naur sysvinit-2.86.orig/man/halt.8 sysvinit-2.86/man/halt.8
    old new  
    2323.RB [ \-d ]
    2424.RB [ \-f ]
    2525.RB [ \-i ]
     26.RB [ \-k ]
    2627.br
    2728.B /sbin/poweroff
    2829.RB [ \-n ]
     
    6566.IP \fB\-p\fP
    6667When halting the system, do a poweroff. This is the default when halt is
    6768called as \fBpoweroff\fP.
     69.IP \fB\-k\fP
     70Try to reboot using \fBkexec\fP, if kernel supports it.
    6871.\"}}}
    6972.\"{{{  Diagnostics
    7073.SH DIAGNOSTICS
  • sysvinit-2.86

    diff -Naur sysvinit-2.86.orig/man/init.8 sysvinit-2.86/man/init.8
    old new  
    6464.PP
    6565Runlevel \fBS\fP or \fBs\fP bring the system to single user mode
    6666and do not require an \fB/etc/inittab\fP file.  In single user mode,
    67 \fB/sbin/sulogin\fP is invoked on \fB/dev/console\fP.
     67a root shell is opened on \fB/dev/console\fP.
    6868.PP
    6969When entering single user mode, \fBinit\fP initializes the consoles
    7070\fBstty\fP settings to sane values. Clocal mode is set. Hardware
  • sysvinit-2.86

    diff -Naur sysvinit-2.86.orig/man/last.1 sysvinit-2.86/man/last.1
    old new  
    6060useful, e.g., to determine easily who was logged in at a particular
    6161time -- specify that time with \fB\-t\fP and look for "still logged
    6262in".
     63.IP "\fB\-f\fP \fIfile\fP"
     64Specifies a file to search other than \fB/var/log/wtmp\fP.
    6365.IP \fB\-R\fP
    6466Suppresses the display of the hostname field.
    6567.IP \fB\-a\fP
  • sysvinit-2.86

    diff -Naur sysvinit-2.86.orig/man/pidof.8 sysvinit-2.86/man/pidof.8
    old new  
    44.SH SYNOPSIS
    55.B pidof
    66.RB [ \-s ]
     7.RB [ \-c ]
    78.RB [ \-x ]
    89.RB [ \-o
    910.IR omitpid ]
     
    2425.SH OPTIONS
    2526.IP -s
    2627Single shot - this instructs the program to only return one \fIpid\fP.
     28.IP -c
     29Only return process ids that are running with the same root directory.
     30This option is ignored for non-root users, as they will be unable to check
     31the current root directory of processes they do not own.
    2732.IP -x
    2833Scripts too - this causes the program to also return process id's of
    2934shells running the named scripts.
  • man/shutdown.8

    diff -Naur sysvinit-2.86.orig/man/shutdown.8 sysvinit-2.86/man/shutdown.8
    old new  
    99.\"{{{  Synopsis
    1010.SH SYNOPSIS
    1111.B /sbin/shutdown
     12.RB [ \-akrhPHfFnc ]
    1213.RB [ \-t
    1314.IR sec ]
    14 .RB [ \-arkhncfFHP ]
    1515.I time
    16 .RI [ warning-message ]
     16.RI [ "warning message" ]
    1717.\"}}}
    1818.\"{{{  Description
    1919.SH DESCRIPTION
     
    3939.IP "\fB\-a\fP
    4040Use \fB/etc/shutdown.allow\fP.
    4141.\"}}}
    42 .\"{{{  -t sec
    43 .IP "\fB\-t\fP \fIsec\fP"
    44 Tell \fBinit\fP(8) to wait \fIsec\fP seconds between sending processes the
    45 warning and the kill signal, before changing to another runlevel.
    46 .\"}}}
    4742.\"{{{  -k
    4843.IP \fB\-k\fP
    4944Don't really shutdown; only send the warning messages to everybody.
     
    5651.IP \fB\-h\fP
    5752Halt or poweroff after shutdown.
    5853.\"}}}
    59 .\"{{{  -H
    60 .IP \fB\-H\fP
    61 Halt action is to halt or drop into boot monitor on systems that
    62 support it.
    63 .\"}}}
    6454.\"{{{  -P
    6555.IP \fB\-P\fP
    6656Halt action is to turn off the power.
    6757.\"}}}
    68 .\"{{{  -n
    69 .IP \fB\-n\fP
    70 [DEPRECATED] Don't call \fBinit\fP(8) to do the shutdown but do it ourself.
    71 The use of this option is discouraged, and its results are not always what
    72 you'd expect.
     58.\"{{{  -H
     59.IP \fB\-H\fP
     60Halt action is to halt or drop into boot monitor on systems that
     61support it.
    7362.\"}}}
    7463.\"{{{  -f
    7564.IP \fB\-f\fP
     
    7968.IP \fB\-F\fP
    8069Force fsck on reboot.
    8170.\"}}}
     71.\"{{{  -n
     72.IP \fB\-n\fP
     73[DEPRECATED] Don't call \fBinit\fP(8) to do the shutdown but do it ourself.
     74The use of this option is discouraged, and its results are not always what
     75you'd expect.
     76.\"}}}
    8277.\"{{{  -c
    8378.IP \fB\-c\fP
    8479Cancel an already running shutdown. With this option it is of course
    8580not possible to give the \fBtime\fP argument, but you can enter a
    8681explanatory message on the command line that will be sent to all users.
    8782.\"}}}
     83.\"{{{  -t sec
     84.IP "\fB\-t\fP \fIsec\fP"
     85Tell \fBinit\fP(8) to wait \fIsec\fP seconds between sending processes the
     86warning and the kill signal, before changing to another runlevel.
     87.\"}}}
    8888.\"{{{  time
    8989.IP \fItime\fP
    9090When to shutdown.
    9191.\"}}}
    9292.\"{{{  warning-message
    93 .IP \fIwarning-message\fP
     93.IP "\fIwarning message\fP"
    9494Message to send to all users.
    9595.\"}}}
    9696.PP
  • man/sulogin.8

    diff -Naur sysvinit-2.86.orig/man/sulogin.8 sysvinit-2.86/man/sulogin.8
    old new  
    99.RB [ " tty-device " ]
    1010.SH DESCRIPTION
    1111.I sulogin
    12 is invoked by \fBinit(8)\fP when the system goes into single user mode
     12can be invoked by \fBinit(8)\fP when the system goes into single user mode
    1313(this is done through an entry in \fIinittab(5)\fP). \fBInit\fP also
    1414tries to execute \fIsulogin\fP when it is passed the \fB-b\fP flag
    1515from the bootmonitor (eg, LILO).
  • src/bootlogd.c

    diff -Naur sysvinit-2.86.orig/src/bootlogd.c sysvinit-2.86/src/bootlogd.c
    old new  
    609609                else
    610610                        todo = endptr - outptr;
    611611                if (fp && todo)
    612                         writelog(fp, outptr, todo);
     612                        writelog(fp, (unsigned char *)outptr, todo);
    613613        }
    614614
    615615        if (fp) {
  • sysvinit-2.86

    diff -Naur sysvinit-2.86.orig/src/halt.c sysvinit-2.86/src/halt.c
    old new  
    88 *              execute an "shutdown -r". This is for compatibility with
    99 *              sysvinit 2.4.
    1010 *
    11  * Usage:       halt [-n] [-w] [-d] [-f] [-h] [-i] [-p]
     11 * Usage:       halt [-n] [-w] [-d] [-f] [-h] [-i] [-p] [-k]
    1212 *              -n: don't sync before halting the system
    1313 *              -w: only write a wtmp reboot record and exit.
    1414 *              -d: don't write a wtmp record.
     
    1616 *              -h: put harddisks in standby mode
    1717 *              -i: shut down all network interfaces.
    1818 *              -p: power down the system (if possible, otherwise halt).
     19 *              -k: reboot the system using kexec.
    1920 *
    2021 *              Reboot and halt are both this program. Reboot
    2122 *              is just a link to halt. Invoking the program
     
    6465 */
    6566void usage(void)
    6667{
    67         fprintf(stderr, "usage: %s [-n] [-w] [-d] [-f] [-h] [-i]%s\n",
    68                 progname, strcmp(progname, "halt") ? "" : " [-p]");
     68        fprintf(stderr, "usage: %s [-n] [-w] [-d] [-f] [-h] [-i]%s%s\n",
     69                progname,
     70                strcmp(progname, "halt") ? "" : " [-p]",
     71                strcmp(progname, "reboot") ? "" : " [-k]");
    6972        fprintf(stderr, "\t-n: don't sync before halting the system\n");
    7073        fprintf(stderr, "\t-w: only write a wtmp reboot record and exit.\n");
    7174        fprintf(stderr, "\t-d: don't write a wtmp record.\n");
     
    7477        fprintf(stderr, "\t-i: shut down all network interfaces.\n");
    7578        if (!strcmp(progname, "halt"))
    7679                fprintf(stderr, "\t-p: power down the system (if possible, otherwise halt).\n");
     80        if (!strcmp(progname, "reboot"))
     81                fprintf(stderr, "\t-k: reboot the system using kexec.\n");
    7782        exit(1);
    7883}
    7984
     
    172177        int do_ifdown = 0;
    173178        int do_hddown = 0;
    174179        int do_poweroff = 0;
     180        int do_kexec = 0;
    175181        int c;
    176182        char *tm = NULL;
    177183
    178184        /*
    179185         *      Find out who we are
    180186         */
     187        if (argv[0][0] == '-') argv[0]++;
    181188        if ((progname = strrchr(argv[0], '/')) != NULL)
    182189                progname++;
    183190        else
     
    189196        /*
    190197         *      Get flags
    191198         */
    192         while((c = getopt(argc, argv, ":ihdfnpwt:")) != EOF) {
     199        while((c = getopt(argc, argv, ":ihdfnpwkt:")) != EOF) {
    193200                switch(c) {
    194201                        case 'n':
    195202                                do_sync = 0;
     
    213220                        case 'p':
    214221                                do_poweroff = 1;
    215222                                break;
     223                        case 'k':
     224                                do_kexec = 1;
     225                                break;
    216226                        case 't':
    217227                                tm = optarg;
    218228                                break;
     
    230240        (void)chdir("/");
    231241
    232242        if (!do_hard && !do_nothing) {
     243                c = get_runlevel();
     244
     245                /*
     246                 *       We can't reboot using kexec through this path.
     247                 */
     248                if (c != '6' && do_reboot && do_kexec) {
     249                        fprintf(stderr, "ERROR: using -k at this"
     250                                " runlevel requires also -f\n"
     251                                "  (You probably want instead to reboot"
     252                                " normally and let your reboot\n"
     253                                "   script, usually /etc/init.d/reboot,"
     254                                " specify -k)\n");
     255                        exit(1);
     256                }
     257               
    233258                /*
    234259                 *      See if we are in runlevel 0 or 6.
    235260                 */
    236                 c = get_runlevel();
    237                 if (c != '0' && c != '6')
    238                         do_shutdown(do_reboot ? "-r" : "-h", tm);
     261               if (c != '0' && c != '6') {
     262                       char *file;
     263
     264                       if (do_poweroff) {
     265                               file = strdup("/poweroff");
     266                       } else {
     267                               file = strdup("/halt");
     268                       }
     269                       close(open(file, O_CREAT|O_RDWR, 0644));
     270                       free(file);
     271
     272                        do_shutdown(do_reboot ? "-r" : "-h", tm);
     273               }
    239274        }
    240275
    241276        /*
     
    263298        if (do_nothing) exit(0);
    264299
    265300        if (do_reboot) {
     301                /*
     302                 *      kexec or reboot
     303                 */
     304                if (do_kexec) {
     305                        init_reboot(BMAGIC_KEXEC);
     306                }
     307
     308                /*
     309                 *      Fall through if failed
     310                 */
    266311                init_reboot(BMAGIC_REBOOT);
    267312        } else {
    268313                /*
  • sysvinit-2.86

    diff -Naur sysvinit-2.86.orig/src/init.c sysvinit-2.86/src/init.c
    old new  
    185185        {"RU",RUNNING},
    186186        {"DE",DEMAND},
    187187        {"XD",XECUTED},
     188        {"WT",WAITING},
    188189        {NULL,0}
    189190};
    190191
     
    466467
    467468        if (maxproclen > 2) {
    468469                memset(argv0, 0, maxproclen);
    469                 strncpy(argv0, buf, maxproclen - 2);
     470                strncpy(argv0, buf, maxproclen - 1);
    470471        }
    471472
    472473        return len;
     
    527528        /*
    528529         *      Retry the open five times.
    529530         */
    530         for(f = 0; f < 5; f++)
     531        for(f = 0; f < 5; f++) {
    531532                if ((fd = open(console_dev, m)) >= 0) break;
     533                usleep(100);
     534        }
    532535
    533536        if (fd < 0) return fd;
    534537
     
    949952                sigprocmask(SIG_SETMASK, &omask, NULL);
    950953
    951954                /*
     955                 * Update utmp/wtmp file prior to starting
     956                 * any child.  This MUST be done right here in
     957                 * the child process in order to prevent a race
     958                 * condition that occurs when the child
     959                 * process' time slice executes before the
     960                 * parent (can and does happen in a uniprocessor
     961                 * environment).  If the child is a getty and
     962                 * the race condition happens, then init's utmp
     963                 * update will happen AFTER the getty runs
     964                 * and expects utmp to be updated already!
     965                 *
     966                 * Do NOT log if process field starts with '+'
     967                 * FIXME: that's for compatibility with *very*
     968                 * old getties - probably it can be taken out.
     969                 */
     970                if (ch->action == RESPAWN && ch->process[0] != '+')
     971                        write_utmp_wtmp("", ch->id, getpid(), INIT_PROCESS, "");
     972
     973                /*
    952974                 *      In sysinit, boot, bootwait or single user mode:
    953975                 *      for any wait-type subprocess we _force_ the console
    954976                 *      to be its controlling tty.
    955977                 */
    956                 if (strchr("*#sS", runlevel) && ch->flags & WAITING) {
     978                if ((strchr("*#sS", runlevel) || (ch->id[0] == 'l' && isdigit(ch->id[1]))) && ch->flags & WAITING) {
    957979                        /*
    958980                         *      We fork once extra. This is so that we can
    959981                         *      wait and change the process group and session
     
    10881110                case ONDEMAND:
    10891111                case RESPAWN:
    10901112                        ch->flags |= RUNNING;
    1091                         if (spawn(ch, &(ch->pid)) < 0) break;
    1092                         /*
    1093                          *      Do NOT log if process field starts with '+'
    1094                          *      FIXME: that's for compatibility with *very*
    1095                          *      old getties - probably it can be taken out.
    1096                          */
    1097                         if (ch->process[0] != '+')
    1098                                 write_utmp_wtmp("", ch->id, ch->pid,
    1099                                         INIT_PROCESS, "");
     1113                        (void)spawn(ch, &(ch->pid));
    11001114                        break;
    11011115        }
    11021116}
     
    13731387                case 0: /* Send TERM signal */
    13741388                        if (talk)
    13751389                                initlog(L_CO,
    1376                                         "Sending processes the TERM signal");
     1390                                        "Sending processes started by init the TERM signal");
    13771391                        kill(-(ch->pid), SIGTERM);
    13781392                        foundOne = 1;
    13791393                        break;
    13801394                case 1: /* Send KILL signal and collect status */
    13811395                        if (talk)
    13821396                                initlog(L_CO,
    1383                                         "Sending processes the KILL signal");
     1397                                        "Sending processes started by init the KILL signal");
    13841398                        kill(-(ch->pid), SIGKILL);
    13851399                        break;
    13861400        }
     
    18841898         *      The existing init process execs a new init binary.
    18851899         */
    18861900        env = init_buildenv(0);
    1887         execl(myname, myname, "--init", NULL, env);
     1901        execle(myname, myname, "--init", NULL, env);
    18881902
    18891903        /*
    18901904         *      We shouldn't be here, something failed.
  • src/killall5.c

    diff -Naur sysvinit-2.86.orig/src/killall5.c sysvinit-2.86/src/killall5.c
    old new  
    5151        char *argv0base;        /* `basename argv[1]`             */
    5252        char *argv1;            /* Name as found out from argv[1] */
    5353        char *argv1base;        /* `basename argv[1]`             */
     54        char *pathname;         /* full path to executable        */
    5455        char *statname;         /* the statname without braces    */
    55         ino_t ino;              /* Inode number                   */
    56         dev_t dev;              /* Device it is on                */
    5756        pid_t pid;              /* Process ID.                    */
    5857        int sid;                /* Session ID.                    */
    5958        int kernel;             /* Kernel thread or zombie.       */
     
    172171        FILE            *fp;
    173172        PROC            *p, *n;
    174173        struct dirent   *d;
    175         struct stat     st;
    176174        char            path[256];
    177175        char            buf[256];
    178176        char            *s, *q;
     
    191189                n = p->next;
    192190                if (p->argv0) free(p->argv0);
    193191                if (p->argv1) free(p->argv1);
     192                if (p->pathname) free(p->pathname);
     193                if (p->statname) free(p->statname);
    194194                free(p);
    195195        }
    196196        plist = NULL;
     
    248248                                p->sid = 0;
    249249                                nsyslog(LOG_ERR, "can't read sid from %s\n",
    250250                                        path);
     251                                if (p->statname) free(p->statname);
    251252                                free(p);
    252253                                continue;
    253254                        }
     
    300301
    301302                } else {
    302303                        /* Process disappeared.. */
     304                        if (p->statname) free(p->statname);
    303305                        free(p);
    304306                        continue;
    305307                }
    306308
    307309                /* Try to stat the executable. */
    308310                snprintf(path, sizeof(path), "/proc/%s/exe", d->d_name);
    309                 if (stat(path, &st) == 0) {
    310                         p->dev = st.st_dev;
    311                         p->ino = st.st_ino;
     311                p->pathname = (char *)xmalloc(PATH_MAX);
     312                if (readlink(path, p->pathname, PATH_MAX) == -1) {
     313                        p->pathname = NULL;
     314                } else {
     315                        p->pathname[PATH_MAX-1] = '\0';
    312316                }
    313317
    314318                /* Link it into the list. */
     
    372376{
    373377        PROC            *p;
    374378        PIDQ_HEAD       *q;
    375         struct stat     st;
    376379        char            *s;
    377380        int             dostat = 0;
    378381        int             foundone = 0;
    379382        int             ok = 0;
     383        char            *real_path;
    380384
    381385        /* Try to stat the executable. */
    382         if (prog[0] == '/' && stat(prog, &st) == 0) dostat++;
     386        if (prog[0] == '/' && (real_path = canonicalize_file_name(prog))) dostat++;
    383387
    384388        /* Get basename of program. */
    385389        if ((s = strrchr(prog, '/')) == NULL)
     
    390394        q = (PIDQ_HEAD *)xmalloc(sizeof(PIDQ_HEAD));
    391395        q = init_pid_q(q);
    392396
    393         /* First try to find a match based on dev/ino pair. */
     397        /* First try to find a match based on pathname. */
    394398        if (dostat) {
    395399                for (p = plist; p; p = p->next) {
    396                         if (p->dev == st.st_dev && p->ino == st.st_ino) {
     400                        if (p->pathname && strcmp(real_path, p->pathname) == 0) {
    397401                                add_pid_to_q(q, p);
    398402                                foundone++;
    399403                        }
     
    408412                ok += (p->argv0 && strcmp(p->argv0, prog) == 0);
    409413                ok += (p->argv0 && strcmp(p->argv0base, s) == 0);
    410414
     415                if (prog[0] == '/' && p->pathname && strcmp(prog, p->pathname))
     416                        ok = 0;
     417               
    411418                /* For scripts, compare argv[1] as well. */
    412419                if (scripts_too && p->argv1 &&
    413420                    !strncmp(p->statname, p->argv1base, STATNAMELEN)) {
    414421                        ok += (strcmp(p->argv1, prog) == 0);
    415                         ok += (strcmp(p->argv1base, s) == 0);
     422                        if (prog[0] != '/') ok += (strcmp(p->argv1base, s) == 0);
    416423                }
    417424
    418425                /*
     
    476483        int             f;
    477484        int             first = 1;
    478485        int             i, oind, opt, flags = 0;
     486        int             chroot_check = 0;
     487        struct stat     st;
     488        char            tmp[512];
    479489
    480490        for (oind = PIDOF_OMITSZ-1; oind > 0; oind--)
    481491                opid[oind] = 0;
    482492        opterr = 0;
    483493
    484         while ((opt = getopt(argc,argv,"ho:sx")) != EOF) switch (opt) {
     494        while ((opt = getopt(argc,argv,"hco:sx")) != EOF) switch (opt) {
    485495                case '?':
    486496                        nsyslog(LOG_ERR,"invalid options on command line!\n");
    487497                        closelog();
    488498                        exit(1);
     499                case 'c':
     500                        if (geteuid() == 0) chroot_check = 1;
     501                        break;
    489502                case 'o':
    490503                        if (oind >= PIDOF_OMITSZ -1) {
    491504                                nsyslog(LOG_ERR,"omit pid buffer size %d "
     
    518531        argc -= optind;
    519532        argv += optind;
    520533
     534        /* Check if we are in a chroot */
     535        if (chroot_check) {
     536                snprintf(tmp, 512, "/proc/%d/root", getpid());
     537                if (stat(tmp, &st) < 0) {
     538                        nsyslog(LOG_ERR, "stat failed for %s!\n", tmp);
     539                        closelog();
     540                        exit(1);
     541                }
     542        }
     543
    521544        /* Print out process-ID's one by one. */
    522545        readproc();
    523546        for(f = 0; f < argc; f++) {
     
    541564                                        else
    542565                                                spid = 1;
    543566                                }
     567                                if (chroot_check) {
     568                                        struct stat st2;
     569                                        snprintf(tmp, 512, "/proc/%d/root",
     570                                                 p->pid);
     571                                        if (stat(tmp, &st2) < 0 ||
     572                                            st.st_dev != st2.st_dev ||
     573                                            st.st_ino != st2.st_ino) {
     574                                                continue;
     575                                        }
     576                                }
    544577                                if (!first)
    545578                                        printf(" ");
    546579                                printf("%d", p->pid);
  • sysvinit-2.86

    diff -Naur sysvinit-2.86.orig/src/last.c sysvinit-2.86/src/last.c
    old new  
    307307        struct sockaddr         *sa;
    308308        int                     salen, flags;
    309309        unsigned int            topnibble;
     310        unsigned int            azero = 0, sitelocal = 0;
    310311        int                     mapped = 0;
    311312
    312313        flags = useip ? NI_NUMERICHOST : 0;
    313314
    314315        /*
    315316         *      IPv4 or IPv6 ? We use 2 heuristics:
    316          *      1. Current IPv6 range uses 2000-3fff. Outside of
    317          *         that is illegal and must be IPv4.
     317         *      1. Current IPv6 range uses 2000-3fff or fec0-feff.
     318         *         Outside of that is illegal and must be IPv4.
    318319         *      2. If last 3 bytes are 0, must be IPv4
    319320         *      3. If IPv6 in IPv4, handle as IPv4
    320321         *
     
    323324        if (a[0] == 0 && a[1] == 0 && a[2] == htonl (0xffff))
    324325                mapped = 1;
    325326        topnibble = ntohl((unsigned int)a[0]) >> 28;
    326         if (topnibble < 2 || topnibble > 3 || mapped ||
     327
     328        azero = ntohl((unsigned int)a[0]) >> 16;
     329        sitelocal = (azero >= 0xfec0 && azero <= 0xfeff) ? 1 : 0;
     330       
     331        if (((topnibble < 2 || topnibble > 3) && (!sitelocal)) || mapped ||
    327332            (a[1] == 0 && a[2] == 0 && a[3] == 0)) {
    328333                /* IPv4 */
    329334                sin.sin_family = AF_INET;
  • src/reboot.h

    diff -Naur sysvinit-2.86.orig/src/reboot.h sysvinit-2.86/src/reboot.h
    old new  
    3232#  define BMAGIC_POWEROFF       BMAGIC_HALT
    3333#endif
    3434
     35/* for kexec support */
     36#define BMAGIC_KEXEC  0x45584543
     37
    3538#define init_reboot(magic)      reboot(magic)
    3639
  • src/shutdown.c

    diff -Naur sysvinit-2.86.orig/src/shutdown.c sysvinit-2.86/src/shutdown.c
    old new  
    102102void usage(void)
    103103{
    104104        fprintf(stderr,
    105         "Usage:\t  shutdown [-akrhHPfnc] [-t secs] time [warning message]\n"
     105        "Usage:\t  shutdown [-akrhPHfFnc] [-t sec] time [warning message]\n"
    106106        "\t\t  -a:      use /etc/shutdown.allow\n"
    107107        "\t\t  -k:      don't really shutdown, only warn.\n"
    108108        "\t\t  -r:      reboot after shutdown.\n"
     
    460460
    461461        if (getuid() != 0) {
    462462                fprintf(stderr, "shutdown: you must be root to do that!\n");
     463                usage();
    463464                exit(1);
    464465        }
    465466        strcpy(down_level, "1");
  • sysvinit-2.86

    diff -Naur sysvinit-2.86.orig/src/utmp.c sysvinit-2.86/src/utmp.c
    old new  
    4747        int fd;
    4848        struct utmp utmp;
    4949        struct utsname uname_buf;
     50        struct timeval tv;
    5051
    5152        /*
    5253         *      Try to open the wtmp file. Note that we even try
     
    7677         */
    7778        memset(&utmp, 0, sizeof(utmp));
    7879#if defined(__GLIBC__)
    79         gettimeofday(&utmp.ut_tv, NULL);
     80        gettimeofday(&tv, NULL);
     81        utmp.ut_tv.tv_sec = tv.tv_sec;
     82        utmp.ut_tv.tv_usec = tv.tv_usec;
    8083#else
    8184        time(&utmp.ut_time);
    8285#endif
     
    113116        struct utmp utmp;
    114117        struct utmp tmp;
    115118        struct utmp *utmptr;
     119        struct timeval tv;
    116120
    117121        /*
    118122         *      Can't do much if UTMP_FILE is not present.
     
    144148        utmp.ut_pid = pid;
    145149        strncpy(utmp.ut_id, id, sizeof(utmp.ut_id));
    146150#if defined(__GLIBC__)
    147         gettimeofday(&utmp.ut_tv, NULL);
     151        gettimeofday(&tv, NULL);
     152        utmp.ut_tv.tv_sec = tv.tv_sec;
     153        utmp.ut_tv.tv_usec = tv.tv_usec;
    148154#else
    149155        time(&utmp.ut_time);
    150156#endif
Note: See TracBrowser for help on using the repository browser.