2012-02-28 10:45:10 -06:00
|
|
|
/*
|
2012-03-12 05:29:09 -05:00
|
|
|
* sulogin
|
2012-02-28 10:45:10 -06:00
|
|
|
*
|
2012-03-12 05:29:09 -05:00
|
|
|
* This program gives Linux machines a reasonable secure way to boot single
|
|
|
|
* user. It forces the user to supply the root password before a shell is
|
|
|
|
* started. If there is a shadow password file and the encrypted root password
|
|
|
|
* is "x" the shadow password will be used.
|
2012-02-28 10:45:10 -06:00
|
|
|
*
|
|
|
|
* Copyright (C) 1998-2003 Miquel van Smoorenburg.
|
2012-03-12 06:55:26 -05:00
|
|
|
* Copyright (C) 2012 Karel Zak <kzak@redhat.com>
|
2012-12-07 02:00:56 -06:00
|
|
|
* Copyright (C) 2012 Werner Fink <werner@suse.de>
|
2012-02-28 10:45:10 -06:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
2012-12-10 06:27:11 -06:00
|
|
|
#include <sys/mman.h>
|
2012-02-28 10:45:10 -06:00
|
|
|
#include <sys/types.h>
|
|
|
|
#include <sys/stat.h>
|
2012-12-10 06:27:11 -06:00
|
|
|
#include <sys/wait.h>
|
2012-02-28 10:45:10 -06:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
#include <fcntl.h>
|
|
|
|
#include <signal.h>
|
|
|
|
#include <pwd.h>
|
|
|
|
#include <shadow.h>
|
|
|
|
#include <termios.h>
|
|
|
|
#include <errno.h>
|
2012-03-12 06:23:29 -05:00
|
|
|
#include <getopt.h>
|
2012-02-28 10:45:10 -06:00
|
|
|
#include <sys/ioctl.h>
|
2012-02-28 10:45:19 -06:00
|
|
|
#ifdef HAVE_CRYPT_H
|
2012-03-12 05:29:09 -05:00
|
|
|
# include <crypt.h>
|
2012-02-28 10:45:10 -06:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_LIBSELINUX
|
2012-03-12 05:29:09 -05:00
|
|
|
# include <selinux/selinux.h>
|
|
|
|
# include <selinux/get_context_list.h>
|
2012-02-28 10:45:10 -06:00
|
|
|
#endif
|
|
|
|
|
2014-05-08 05:09:25 -05:00
|
|
|
#ifdef __linux__
|
|
|
|
# include <sys/kd.h>
|
|
|
|
# include <sys/param.h>
|
2021-05-17 10:20:32 -05:00
|
|
|
# include <linux/serial.h>
|
2014-05-08 05:09:25 -05:00
|
|
|
#endif
|
|
|
|
|
2012-02-28 10:45:20 -06:00
|
|
|
#include "c.h"
|
2012-04-04 12:58:34 -05:00
|
|
|
#include "closestream.h"
|
2016-08-07 01:27:21 -05:00
|
|
|
#include "env.h"
|
2012-02-28 10:45:20 -06:00
|
|
|
#include "nls.h"
|
2012-02-28 10:45:18 -06:00
|
|
|
#include "pathnames.h"
|
2016-05-26 08:05:14 -05:00
|
|
|
#ifdef USE_PLYMOUTH_SUPPORT
|
|
|
|
# include "plymouth-ctrl.h"
|
|
|
|
#endif
|
2012-03-12 06:43:53 -05:00
|
|
|
#include "strutils.h"
|
2012-03-12 08:41:00 -05:00
|
|
|
#include "ttyutils.h"
|
2012-12-23 15:14:21 -06:00
|
|
|
#include "sulogin-consoles.h"
|
2012-12-10 06:27:11 -06:00
|
|
|
#define CONMAX 16
|
|
|
|
|
2012-03-12 06:43:53 -05:00
|
|
|
static unsigned int timeout;
|
2012-02-28 10:45:10 -06:00
|
|
|
static int profile;
|
2012-12-10 06:27:11 -06:00
|
|
|
static volatile uint32_t openfd; /* Remember higher file descriptors */
|
2012-02-28 10:45:10 -06:00
|
|
|
|
2017-02-11 18:19:33 -06:00
|
|
|
static struct sigaction saved_sigint;
|
|
|
|
static struct sigaction saved_sigtstp;
|
|
|
|
static struct sigaction saved_sigquit;
|
|
|
|
static struct sigaction saved_sighup;
|
|
|
|
static struct sigaction saved_sigchld;
|
2012-02-28 10:45:10 -06:00
|
|
|
|
2012-12-07 02:00:56 -06:00
|
|
|
static volatile sig_atomic_t alarm_rised;
|
2012-12-10 06:27:11 -06:00
|
|
|
static volatile sig_atomic_t sigchild;
|
|
|
|
|
|
|
|
#ifndef IUCLC
|
|
|
|
# define IUCLC 0
|
|
|
|
#endif
|
|
|
|
|
2016-03-21 08:04:43 -05:00
|
|
|
#ifndef WEXITED
|
|
|
|
# warning "WEXITED is missing, sulogin may not work as expected"
|
|
|
|
# define WEXITED 0
|
|
|
|
#endif
|
|
|
|
|
2017-04-15 15:46:38 -05:00
|
|
|
static int locked_account_password(const char * const passwd)
|
2015-05-25 08:30:52 -05:00
|
|
|
{
|
|
|
|
if (passwd && (*passwd == '*' || *passwd == '!'))
|
|
|
|
return 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2012-12-10 06:27:11 -06:00
|
|
|
/*
|
|
|
|
* Fix the tty modes and set reasonable defaults.
|
|
|
|
*/
|
|
|
|
static void tcinit(struct console *con)
|
|
|
|
{
|
2017-04-15 15:46:38 -05:00
|
|
|
int flags = 0, mode = 0;
|
2012-12-10 06:27:11 -06:00
|
|
|
struct termios *tio = &con->tio;
|
2017-05-09 04:59:53 -05:00
|
|
|
const int fd = con->fd;
|
2021-05-17 10:20:32 -05:00
|
|
|
#if defined(TIOCGSERIAL)
|
|
|
|
struct serial_struct serinfo;
|
|
|
|
#endif
|
2016-05-26 08:05:14 -05:00
|
|
|
#ifdef USE_PLYMOUTH_SUPPORT
|
|
|
|
struct termios lock;
|
2016-04-22 05:16:04 -05:00
|
|
|
int i = (plymouth_command(MAGIC_PING)) ? PLYMOUTH_TERMIOS_FLAGS_DELAY : 0;
|
|
|
|
if (i)
|
|
|
|
plymouth_command(MAGIC_QUIT);
|
2014-05-08 05:09:22 -05:00
|
|
|
while (i-- > 0) {
|
|
|
|
/*
|
|
|
|
* With plymouth the termios flags become changed after this
|
|
|
|
* function had changed the termios.
|
|
|
|
*/
|
|
|
|
memset(&lock, 0, sizeof(struct termios));
|
|
|
|
if (ioctl(fd, TIOCGLCKTRMIOS, &lock) < 0)
|
|
|
|
break;
|
|
|
|
if (!lock.c_iflag && !lock.c_oflag && !lock.c_cflag && !lock.c_lflag)
|
|
|
|
break;
|
|
|
|
sleep(1);
|
|
|
|
}
|
|
|
|
memset(&lock, 0, sizeof(struct termios));
|
|
|
|
ioctl(fd, TIOCSLCKTRMIOS, &lock);
|
2021-05-17 10:20:32 -05:00
|
|
|
errno = 0;
|
2014-06-19 03:35:23 -05:00
|
|
|
#endif
|
2021-05-17 10:20:32 -05:00
|
|
|
|
|
|
|
#if defined(TIOCGSERIAL)
|
|
|
|
if (ioctl(fd, TIOCGSERIAL, &serinfo) >= 0)
|
|
|
|
con->flags |= CON_SERIAL;
|
|
|
|
errno = 0;
|
|
|
|
#else
|
|
|
|
# if defined(KDGKBMODE)
|
|
|
|
if (ioctl(fd, KDGKBMODE, &mode) < 0)
|
|
|
|
con->flags |= CON_SERIAL;
|
2012-12-10 06:27:11 -06:00
|
|
|
errno = 0;
|
2021-05-17 10:20:32 -05:00
|
|
|
# endif
|
|
|
|
#endif
|
2012-12-10 06:27:11 -06:00
|
|
|
|
|
|
|
if (tcgetattr(fd, tio) < 0) {
|
2021-05-17 10:20:32 -05:00
|
|
|
int saveno = errno;
|
|
|
|
#if defined(KDGKBMODE) || defined(TIOCGSERIAL)
|
|
|
|
if (con->flags & CON_SERIAL) { /* Try to recover this */
|
|
|
|
|
|
|
|
# if defined(TIOCGSERIAL)
|
|
|
|
serinfo.flags |= ASYNC_SKIP_TEST; /* Skip test of UART */
|
|
|
|
|
|
|
|
if (ioctl(fd, TIOCSSERIAL, &serinfo) < 0)
|
|
|
|
goto tcgeterr;
|
|
|
|
if (ioctl(fd, TIOCSERCONFIG) < 0) /* Try to autoconfigure */
|
|
|
|
goto tcgeterr;
|
|
|
|
if (ioctl(fd, TIOCGSERIAL, &serinfo) < 0)
|
|
|
|
goto tcgeterr; /* Ouch */
|
|
|
|
# endif
|
|
|
|
if (tcgetattr(fd, tio) < 0) /* Retry to get tty attributes */
|
|
|
|
saveno = errno;
|
|
|
|
}
|
|
|
|
# if defined(TIOCGSERIAL)
|
|
|
|
tcgeterr:
|
|
|
|
# endif
|
|
|
|
if (saveno)
|
|
|
|
#endif
|
|
|
|
{
|
|
|
|
FILE *fcerr = fdopen(fd, "w");
|
|
|
|
if (fcerr) {
|
|
|
|
fprintf(fcerr, _("tcgetattr failed"));
|
|
|
|
fclose(fcerr);
|
|
|
|
}
|
|
|
|
warn(_("tcgetattr failed"));
|
|
|
|
|
|
|
|
con->flags &= ~CON_SERIAL;
|
|
|
|
if (saveno != EIO)
|
|
|
|
con->flags |= CON_NOTTY;
|
|
|
|
else
|
|
|
|
con->flags |= CON_EIO;
|
|
|
|
|
|
|
|
errno = 0;
|
|
|
|
return;
|
|
|
|
}
|
2012-12-10 06:27:11 -06:00
|
|
|
}
|
|
|
|
|
2014-05-08 05:09:25 -05:00
|
|
|
/* Handle lines other than virtual consoles here */
|
2021-05-17 10:20:32 -05:00
|
|
|
#if defined(KDGKBMODE) || defined(TIOCGSERIAL)
|
|
|
|
if (con->flags & CON_SERIAL)
|
2014-05-08 05:09:25 -05:00
|
|
|
#endif
|
|
|
|
{
|
2012-12-10 06:27:11 -06:00
|
|
|
speed_t ispeed, ospeed;
|
|
|
|
struct winsize ws;
|
2014-05-08 05:09:25 -05:00
|
|
|
errno = 0;
|
2012-12-10 06:27:11 -06:00
|
|
|
|
|
|
|
/* Flush input and output queues on modem lines */
|
2012-12-18 09:03:02 -06:00
|
|
|
tcflush(fd, TCIOFLUSH);
|
2012-12-10 06:27:11 -06:00
|
|
|
|
|
|
|
ispeed = cfgetispeed(tio);
|
|
|
|
ospeed = cfgetospeed(tio);
|
|
|
|
|
|
|
|
if (!ispeed) ispeed = TTYDEF_SPEED;
|
|
|
|
if (!ospeed) ospeed = TTYDEF_SPEED;
|
|
|
|
|
|
|
|
tio->c_cflag = CREAD | CS8 | HUPCL | (tio->c_cflag & CLOCAL);
|
2012-12-19 03:24:23 -06:00
|
|
|
tio->c_iflag = 0;
|
|
|
|
tio->c_lflag = 0;
|
|
|
|
tio->c_oflag &= OPOST | ONLCR;
|
2012-12-10 06:27:11 -06:00
|
|
|
|
|
|
|
cfsetispeed(tio, ispeed);
|
|
|
|
cfsetospeed(tio, ospeed);
|
|
|
|
|
2013-03-22 08:41:47 -05:00
|
|
|
#ifdef HAVE_STRUCT_TERMIOS_C_LINE
|
2012-12-10 06:27:11 -06:00
|
|
|
tio->c_line = 0;
|
2013-03-22 08:41:47 -05:00
|
|
|
#endif
|
2012-12-10 06:27:11 -06:00
|
|
|
tio->c_cc[VTIME] = 0;
|
|
|
|
tio->c_cc[VMIN] = 1;
|
|
|
|
|
|
|
|
if (ioctl(fd, TIOCGWINSZ, &ws) == 0) {
|
2019-05-18 16:36:44 -05:00
|
|
|
int update = 0;
|
|
|
|
|
2012-12-10 06:27:11 -06:00
|
|
|
if (ws.ws_row == 0) {
|
|
|
|
ws.ws_row = 24;
|
2019-05-18 16:36:44 -05:00
|
|
|
update++;
|
2012-12-10 06:27:11 -06:00
|
|
|
}
|
|
|
|
if (ws.ws_col == 0) {
|
|
|
|
ws.ws_col = 80;
|
2019-05-18 16:36:44 -05:00
|
|
|
update++;
|
2012-12-10 06:27:11 -06:00
|
|
|
}
|
2019-05-18 16:36:44 -05:00
|
|
|
if (update)
|
2012-12-18 09:03:02 -06:00
|
|
|
ignore_result( ioctl(fd, TIOCSWINSZ, &ws) );
|
2012-12-10 06:27:11 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
setlocale(LC_CTYPE, "POSIX");
|
|
|
|
goto setattr;
|
|
|
|
}
|
|
|
|
#if defined(IUTF8) && defined(KDGKBMODE)
|
2014-05-08 05:09:25 -05:00
|
|
|
/* Handle mode of current keyboard setup, e.g. for UTF-8 */
|
2012-12-10 06:27:11 -06:00
|
|
|
switch(mode) {
|
|
|
|
case K_UNICODE:
|
|
|
|
setlocale(LC_CTYPE, "C.UTF-8");
|
|
|
|
flags |= UL_TTY_UTF8;
|
|
|
|
break;
|
|
|
|
case K_RAW:
|
|
|
|
case K_MEDIUMRAW:
|
|
|
|
case K_XLATE:
|
|
|
|
default:
|
|
|
|
setlocale(LC_CTYPE, "POSIX");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
setlocale(LC_CTYPE, "POSIX");
|
|
|
|
#endif
|
|
|
|
reset_virtual_console(tio, flags);
|
|
|
|
setattr:
|
|
|
|
if (tcsetattr(fd, TCSANOW, tio))
|
|
|
|
warn(_("tcsetattr failed"));
|
|
|
|
|
|
|
|
/* Enable blocking mode for read and write */
|
|
|
|
if ((flags = fcntl(fd, F_GETFL, 0)) != -1)
|
2012-12-18 09:03:02 -06:00
|
|
|
ignore_result( fcntl(fd, F_SETFL, flags & ~O_NONBLOCK) );
|
2012-12-10 06:27:11 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Finalize the tty modes on modem lines.
|
|
|
|
*/
|
|
|
|
static void tcfinal(struct console *con)
|
|
|
|
{
|
2017-04-15 15:46:38 -05:00
|
|
|
struct termios *tio = &con->tio;
|
|
|
|
const int fd = con->fd;
|
2012-12-10 06:27:11 -06:00
|
|
|
|
2021-05-17 10:20:32 -05:00
|
|
|
if (con->flags & CON_EIO)
|
|
|
|
return;
|
2012-12-10 06:27:11 -06:00
|
|
|
if ((con->flags & CON_SERIAL) == 0) {
|
2016-08-07 01:27:21 -05:00
|
|
|
xsetenv("TERM", "linux", 1);
|
2012-12-10 06:27:11 -06:00
|
|
|
return;
|
|
|
|
}
|
2014-05-08 05:09:24 -05:00
|
|
|
if (con->flags & CON_NOTTY) {
|
2016-08-07 01:27:21 -05:00
|
|
|
xsetenv("TERM", "dumb", 1);
|
2012-12-10 06:27:11 -06:00
|
|
|
return;
|
2014-05-08 05:09:24 -05:00
|
|
|
}
|
2012-12-10 06:27:11 -06:00
|
|
|
|
2014-05-08 05:09:24 -05:00
|
|
|
#if defined (__s390__) || defined (__s390x__)
|
2016-08-07 01:27:21 -05:00
|
|
|
xsetenv("TERM", "dumb", 1);
|
2014-05-08 05:09:24 -05:00
|
|
|
#else
|
2016-08-07 01:27:21 -05:00
|
|
|
xsetenv("TERM", "vt102", 1);
|
2014-05-08 05:09:24 -05:00
|
|
|
#endif
|
2012-12-10 06:27:11 -06:00
|
|
|
tio->c_iflag |= (IXON | IXOFF);
|
|
|
|
tio->c_lflag |= (ICANON | ISIG | ECHO|ECHOE|ECHOK|ECHOKE);
|
|
|
|
tio->c_oflag |= OPOST;
|
|
|
|
|
|
|
|
tio->c_cc[VINTR] = CINTR;
|
|
|
|
tio->c_cc[VQUIT] = CQUIT;
|
|
|
|
tio->c_cc[VERASE] = con->cp.erase;
|
|
|
|
tio->c_cc[VKILL] = con->cp.kill;
|
|
|
|
tio->c_cc[VEOF] = CEOF;
|
|
|
|
#ifdef VSWTC
|
|
|
|
tio->c_cc[VSWTC] = _POSIX_VDISABLE;
|
2013-03-22 08:41:47 -05:00
|
|
|
#elif defined(VSWTCH)
|
2012-12-10 06:27:11 -06:00
|
|
|
tio->c_cc[VSWTCH] = _POSIX_VDISABLE;
|
|
|
|
#endif
|
|
|
|
tio->c_cc[VSTART] = CSTART;
|
|
|
|
tio->c_cc[VSTOP] = CSTOP;
|
|
|
|
tio->c_cc[VSUSP] = CSUSP;
|
|
|
|
tio->c_cc[VEOL] = _POSIX_VDISABLE;
|
|
|
|
|
|
|
|
if (con->cp.eol == CR) {
|
|
|
|
tio->c_iflag |= ICRNL;
|
|
|
|
tio->c_iflag &= ~(INLCR|IGNCR);
|
|
|
|
tio->c_oflag |= ONLCR;
|
|
|
|
tio->c_oflag &= ~(OCRNL|ONLRET);
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (con->cp.parity) {
|
|
|
|
default:
|
|
|
|
case 0:
|
|
|
|
tio->c_cflag &= ~(PARODD | PARENB);
|
|
|
|
tio->c_iflag &= ~(INPCK | ISTRIP);
|
|
|
|
break;
|
|
|
|
case 1: /* odd parity */
|
|
|
|
tio->c_cflag |= PARODD;
|
2017-05-16 03:18:24 -05:00
|
|
|
/* fallthrough */
|
2012-12-10 06:27:11 -06:00
|
|
|
case 2: /* even parity */
|
|
|
|
tio->c_cflag |= PARENB;
|
|
|
|
tio->c_iflag |= (INPCK | ISTRIP);
|
2017-05-16 03:18:24 -05:00
|
|
|
/* fallthrough */
|
2012-12-10 06:27:11 -06:00
|
|
|
case (1 | 2): /* no parity bit */
|
|
|
|
tio->c_cflag &= ~CSIZE;
|
|
|
|
tio->c_cflag |= CS7;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Set line attributes */
|
2012-12-18 09:03:02 -06:00
|
|
|
tcsetattr(fd, TCSANOW, tio);
|
2012-12-10 06:27:11 -06:00
|
|
|
}
|
2012-12-07 02:00:56 -06:00
|
|
|
|
2012-02-28 10:45:10 -06:00
|
|
|
/*
|
2012-03-12 05:29:09 -05:00
|
|
|
* Called at timeout.
|
2012-02-28 10:45:10 -06:00
|
|
|
*/
|
2012-02-28 10:45:13 -06:00
|
|
|
static void alrm_handler(int sig __attribute__((unused)))
|
2012-02-28 10:45:10 -06:00
|
|
|
{
|
2012-12-07 02:00:56 -06:00
|
|
|
/* Timeout expired */
|
|
|
|
alarm_rised++;
|
2012-02-28 10:45:13 -06:00
|
|
|
}
|
|
|
|
|
2012-12-10 06:27:11 -06:00
|
|
|
static void chld_handler(int sig __attribute__((unused)))
|
|
|
|
{
|
|
|
|
sigchild++;
|
|
|
|
}
|
|
|
|
|
2012-02-28 10:45:13 -06:00
|
|
|
static void mask_signal(int signal, void (*handler)(int),
|
|
|
|
struct sigaction *origaction)
|
|
|
|
{
|
|
|
|
struct sigaction newaction;
|
|
|
|
|
|
|
|
newaction.sa_handler = handler;
|
|
|
|
sigemptyset(&newaction.sa_mask);
|
|
|
|
newaction.sa_flags = 0;
|
|
|
|
|
2012-12-10 06:27:11 -06:00
|
|
|
sigaction(signal, &newaction, origaction);
|
2012-02-28 10:45:13 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
static void unmask_signal(int signal, struct sigaction *sa)
|
|
|
|
{
|
|
|
|
sigaction(signal, sa, NULL);
|
2012-02-28 10:45:10 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2012-03-12 05:29:09 -05:00
|
|
|
* See if an encrypted password is valid. The encrypted password is checked for
|
|
|
|
* traditional-style DES and FreeBSD-style MD5 encryption.
|
2012-02-28 10:45:10 -06:00
|
|
|
*/
|
2012-02-28 10:45:12 -06:00
|
|
|
static int valid(const char *pass)
|
2012-02-28 10:45:10 -06:00
|
|
|
{
|
|
|
|
const char *s;
|
|
|
|
char id[5];
|
|
|
|
size_t len;
|
|
|
|
off_t off;
|
|
|
|
|
2012-02-28 10:45:12 -06:00
|
|
|
if (pass[0] == 0)
|
|
|
|
return 1;
|
|
|
|
if (pass[0] != '$')
|
|
|
|
goto check_des;
|
2012-02-28 10:45:10 -06:00
|
|
|
|
|
|
|
/*
|
2012-03-12 05:29:09 -05:00
|
|
|
* up to 4 bytes for the signature e.g. $1$
|
2012-02-28 10:45:10 -06:00
|
|
|
*/
|
2012-02-28 10:45:12 -06:00
|
|
|
for (s = pass+1; *s && *s != '$'; s++);
|
|
|
|
|
|
|
|
if (*s++ != '$')
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if ((off = (off_t)(s-pass)) > 4 || off < 3)
|
|
|
|
return 0;
|
2012-02-28 10:45:10 -06:00
|
|
|
|
|
|
|
memset(id, '\0', sizeof(id));
|
|
|
|
strncpy(id, pass, off);
|
|
|
|
|
|
|
|
/*
|
2012-03-12 05:29:09 -05:00
|
|
|
* up to 16 bytes for the salt
|
2012-02-28 10:45:10 -06:00
|
|
|
*/
|
2012-02-28 10:45:12 -06:00
|
|
|
for (; *s && *s != '$'; s++);
|
|
|
|
|
|
|
|
if (*s++ != '$')
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
if ((off_t)(s-pass) > 16)
|
|
|
|
return 0;
|
|
|
|
|
2012-02-28 10:45:10 -06:00
|
|
|
len = strlen(s);
|
|
|
|
|
|
|
|
/*
|
2012-03-12 05:29:09 -05:00
|
|
|
* the MD5 hash (128 bits or 16 bytes) encoded in base64 = 22 bytes
|
2012-02-28 10:45:10 -06:00
|
|
|
*/
|
2012-02-28 10:45:12 -06:00
|
|
|
if ((strcmp(id, "$1$") == 0) && (len < 22 || len > 24))
|
|
|
|
return 0;
|
2012-02-28 10:45:10 -06:00
|
|
|
|
|
|
|
/*
|
2012-03-12 05:29:09 -05:00
|
|
|
* the SHA-256 hash 43 bytes
|
2012-02-28 10:45:10 -06:00
|
|
|
*/
|
2012-02-28 10:45:12 -06:00
|
|
|
if ((strcmp(id, "$5$") == 0) && (len < 42 || len > 44))
|
|
|
|
return 0;
|
2012-02-28 10:45:10 -06:00
|
|
|
|
|
|
|
/*
|
2012-03-12 05:29:09 -05:00
|
|
|
* the SHA-512 hash 86 bytes
|
2012-02-28 10:45:10 -06:00
|
|
|
*/
|
2012-02-28 10:45:12 -06:00
|
|
|
if ((strcmp(id, "$6$") == 0) && (len < 85 || len > 87))
|
|
|
|
return 0;
|
2012-02-28 10:45:10 -06:00
|
|
|
|
|
|
|
/*
|
2012-03-12 05:29:09 -05:00
|
|
|
* e.g. Blowfish hash
|
2012-02-28 10:45:10 -06:00
|
|
|
*/
|
|
|
|
return 1;
|
|
|
|
check_des:
|
2012-02-28 10:45:12 -06:00
|
|
|
if (strlen(pass) != 13)
|
|
|
|
return 0;
|
|
|
|
|
2012-02-28 10:45:10 -06:00
|
|
|
for (s = pass; *s; s++) {
|
|
|
|
if ((*s < '0' || *s > '9') &&
|
|
|
|
(*s < 'a' || *s > 'z') &&
|
|
|
|
(*s < 'A' || *s > 'Z') &&
|
2012-02-28 10:45:12 -06:00
|
|
|
*s != '.' && *s != '/')
|
|
|
|
return 0;
|
2012-02-28 10:45:10 -06:00
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2012-03-12 05:29:09 -05:00
|
|
|
* Set a variable if the value is not NULL.
|
2012-02-28 10:45:10 -06:00
|
|
|
*/
|
2012-03-12 06:36:39 -05:00
|
|
|
static inline void set(char **var, char *val)
|
2012-02-28 10:45:10 -06:00
|
|
|
{
|
2012-02-28 10:45:12 -06:00
|
|
|
if (val)
|
|
|
|
*var = val;
|
2012-02-28 10:45:10 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2012-03-12 05:29:09 -05:00
|
|
|
* Get the root password entry.
|
2012-02-28 10:45:10 -06:00
|
|
|
*/
|
2012-02-28 10:45:12 -06:00
|
|
|
static struct passwd *getrootpwent(int try_manually)
|
2012-02-28 10:45:10 -06:00
|
|
|
{
|
|
|
|
static struct passwd pwd;
|
|
|
|
struct passwd *pw;
|
|
|
|
struct spwd *spw;
|
|
|
|
FILE *fp;
|
2015-05-25 08:24:13 -05:00
|
|
|
static char line[2 * BUFSIZ];
|
|
|
|
static char sline[2 * BUFSIZ];
|
2012-02-28 10:45:10 -06:00
|
|
|
char *p;
|
|
|
|
|
|
|
|
/*
|
2012-03-12 05:29:09 -05:00
|
|
|
* First, we try to get the password the standard way using normal
|
|
|
|
* library calls.
|
2012-02-28 10:45:10 -06:00
|
|
|
*/
|
|
|
|
if ((pw = getpwnam("root")) &&
|
|
|
|
!strcmp(pw->pw_passwd, "x") &&
|
|
|
|
(spw = getspnam("root")))
|
|
|
|
pw->pw_passwd = spw->sp_pwdp;
|
2012-03-12 05:29:09 -05:00
|
|
|
|
2012-02-28 10:45:12 -06:00
|
|
|
if (pw || !try_manually)
|
|
|
|
return pw;
|
2012-02-28 10:45:10 -06:00
|
|
|
|
|
|
|
/*
|
2012-03-12 05:29:09 -05:00
|
|
|
* If we come here, we could not retrieve the root password through
|
|
|
|
* library calls and we try to read the password and shadow files
|
|
|
|
* manually.
|
2012-02-28 10:45:10 -06:00
|
|
|
*/
|
|
|
|
pwd.pw_name = "root";
|
|
|
|
pwd.pw_passwd = "";
|
|
|
|
pwd.pw_gecos = "Super User";
|
|
|
|
pwd.pw_dir = "/";
|
|
|
|
pwd.pw_shell = "";
|
|
|
|
pwd.pw_uid = 0;
|
|
|
|
pwd.pw_gid = 0;
|
|
|
|
|
2012-02-28 10:45:18 -06:00
|
|
|
if ((fp = fopen(_PATH_PASSWD, "r")) == NULL) {
|
2012-07-15 03:39:57 -05:00
|
|
|
warn(_("cannot open %s"), _PATH_PASSWD);
|
2012-02-28 10:45:10 -06:00
|
|
|
return &pwd;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2012-03-12 05:29:09 -05:00
|
|
|
* Find root in the password file.
|
2012-02-28 10:45:10 -06:00
|
|
|
*/
|
2015-05-25 08:24:13 -05:00
|
|
|
while ((p = fgets(line, sizeof(line), fp)) != NULL) {
|
2012-02-28 10:45:10 -06:00
|
|
|
if (strncmp(line, "root:", 5) != 0)
|
|
|
|
continue;
|
|
|
|
p += 5;
|
|
|
|
set(&pwd.pw_passwd, strsep(&p, ":"));
|
2012-02-28 10:45:12 -06:00
|
|
|
strsep(&p, ":");
|
|
|
|
strsep(&p, ":");
|
2012-02-28 10:45:10 -06:00
|
|
|
set(&pwd.pw_gecos, strsep(&p, ":"));
|
|
|
|
set(&pwd.pw_dir, strsep(&p, ":"));
|
|
|
|
set(&pwd.pw_shell, strsep(&p, "\n"));
|
|
|
|
p = line;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
fclose(fp);
|
|
|
|
|
|
|
|
/*
|
2012-03-12 05:29:09 -05:00
|
|
|
* If the encrypted password is valid or not found, return.
|
2012-02-28 10:45:10 -06:00
|
|
|
*/
|
|
|
|
if (p == NULL) {
|
2012-03-12 05:38:12 -05:00
|
|
|
warnx(_("%s: no entry for root\n"), _PATH_PASSWD);
|
2012-02-28 10:45:10 -06:00
|
|
|
return &pwd;
|
|
|
|
}
|
2012-02-28 10:45:12 -06:00
|
|
|
if (valid(pwd.pw_passwd))
|
|
|
|
return &pwd;
|
2012-02-28 10:45:10 -06:00
|
|
|
|
|
|
|
/*
|
2012-03-12 05:29:09 -05:00
|
|
|
* The password is invalid. If there is a shadow password, try it.
|
2012-02-28 10:45:10 -06:00
|
|
|
*/
|
2015-05-25 08:24:13 -05:00
|
|
|
*pwd.pw_passwd = '\0';
|
2012-02-28 10:45:18 -06:00
|
|
|
if ((fp = fopen(_PATH_SHADOW_PASSWD, "r")) == NULL) {
|
2012-07-15 03:39:57 -05:00
|
|
|
warn(_("cannot open %s"), _PATH_PASSWD);
|
2012-02-28 10:45:10 -06:00
|
|
|
return &pwd;
|
|
|
|
}
|
2015-05-25 08:24:13 -05:00
|
|
|
while ((p = fgets(sline, sizeof(sline), fp)) != NULL) {
|
2012-02-28 10:45:10 -06:00
|
|
|
if (strncmp(sline, "root:", 5) != 0)
|
|
|
|
continue;
|
|
|
|
p += 5;
|
|
|
|
set(&pwd.pw_passwd, strsep(&p, ":"));
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
fclose(fp);
|
|
|
|
|
|
|
|
/*
|
2012-03-12 05:29:09 -05:00
|
|
|
* If the password is still invalid, NULL it, and return.
|
2012-02-28 10:45:10 -06:00
|
|
|
*/
|
|
|
|
if (p == NULL) {
|
2012-03-12 05:48:33 -05:00
|
|
|
warnx(_("%s: no entry for root"), _PATH_SHADOW_PASSWD);
|
2015-05-25 08:24:13 -05:00
|
|
|
*pwd.pw_passwd = '\0';
|
2012-02-28 10:45:10 -06:00
|
|
|
}
|
2016-05-29 16:11:53 -05:00
|
|
|
/* locked account passwords are valid too */
|
2015-05-25 08:30:52 -05:00
|
|
|
if (!locked_account_password(pwd.pw_passwd) && !valid(pwd.pw_passwd)) {
|
2012-03-12 05:48:33 -05:00
|
|
|
warnx(_("%s: root password garbled"), _PATH_SHADOW_PASSWD);
|
2015-05-25 08:24:13 -05:00
|
|
|
*pwd.pw_passwd = '\0';
|
2012-02-28 10:45:12 -06:00
|
|
|
}
|
2012-02-28 10:45:10 -06:00
|
|
|
return &pwd;
|
|
|
|
}
|
|
|
|
|
2012-12-10 06:27:11 -06:00
|
|
|
/*
|
|
|
|
* Ask by prompt for the password.
|
|
|
|
*/
|
2015-05-25 08:30:52 -05:00
|
|
|
static void doprompt(const char *crypted, struct console *con, int deny)
|
2012-12-10 06:27:11 -06:00
|
|
|
{
|
|
|
|
struct termios tty;
|
|
|
|
|
|
|
|
if (con->flags & CON_SERIAL) {
|
|
|
|
tty = con->tio;
|
|
|
|
/*
|
|
|
|
* For prompting: map NL in output to CR-NL
|
|
|
|
* otherwise we may see stairs in the output.
|
|
|
|
*/
|
|
|
|
tty.c_oflag |= (ONLCR | OPOST);
|
2012-12-18 09:03:02 -06:00
|
|
|
tcsetattr(con->fd, TCSADRAIN, &tty);
|
2012-12-10 06:27:11 -06:00
|
|
|
}
|
2018-08-16 08:58:20 -05:00
|
|
|
if (!con->file) {
|
|
|
|
con->file = fdopen(con->fd, "r+");
|
|
|
|
if (!con->file)
|
2012-12-10 06:27:11 -06:00
|
|
|
goto err;
|
|
|
|
}
|
2015-05-25 08:30:52 -05:00
|
|
|
|
|
|
|
if (deny)
|
|
|
|
fprintf(con->file, _("\nCannot open access to console, the root account is locked.\n"
|
|
|
|
"See sulogin(8) man page for more details.\n\n"
|
|
|
|
"Press Enter to continue.\n"));
|
|
|
|
else {
|
2012-12-10 06:27:11 -06:00
|
|
|
#if defined(USE_ONELINE)
|
2015-05-25 08:30:52 -05:00
|
|
|
if (crypted[0] && !locked_account_password(crypted))
|
|
|
|
fprintf(con->file, _("Give root password for login: "));
|
|
|
|
else
|
|
|
|
fprintf(con->file, _("Press Enter for login: "));
|
2012-12-10 06:27:11 -06:00
|
|
|
#else
|
2015-05-25 08:30:52 -05:00
|
|
|
if (crypted[0] && !locked_account_password(crypted))
|
|
|
|
fprintf(con->file, _("Give root password for maintenance\n"));
|
|
|
|
else
|
|
|
|
fprintf(con->file, _("Press Enter for maintenance\n"));
|
|
|
|
fprintf(con->file, _("(or press Control-D to continue): "));
|
2012-12-10 06:27:11 -06:00
|
|
|
#endif
|
2015-05-25 08:30:52 -05:00
|
|
|
}
|
2012-12-10 06:27:11 -06:00
|
|
|
fflush(con->file);
|
|
|
|
err:
|
|
|
|
if (con->flags & CON_SERIAL)
|
2012-12-18 09:03:02 -06:00
|
|
|
tcsetattr(con->fd, TCSADRAIN, &con->tio);
|
2012-12-10 06:27:11 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Make sure to have an own session and controlling terminal
|
|
|
|
*/
|
|
|
|
static void setup(struct console *con)
|
|
|
|
{
|
2017-04-15 15:46:38 -05:00
|
|
|
int fd = con->fd;
|
2021-05-17 10:20:32 -05:00
|
|
|
const pid_t pid = getpid(), pgrp = getpgid(0), ppgrp = getpgid(getppid());
|
|
|
|
pid_t ttypgrp;
|
2012-12-10 06:27:11 -06:00
|
|
|
|
|
|
|
if (con->flags & CON_NOTTY)
|
2021-05-17 10:20:32 -05:00
|
|
|
goto notty;
|
|
|
|
if (con->flags & CON_EIO)
|
2012-12-10 06:27:11 -06:00
|
|
|
return;
|
|
|
|
|
2021-05-17 10:20:32 -05:00
|
|
|
ttypgrp = tcgetpgrp(fd);
|
|
|
|
|
2012-12-10 06:27:11 -06:00
|
|
|
/*
|
|
|
|
* Only go through this trouble if the new
|
|
|
|
* tty doesn't fall in this process group.
|
|
|
|
*/
|
|
|
|
if (pgrp != ttypgrp && ppgrp != ttypgrp) {
|
|
|
|
if (pid != getsid(0)) {
|
|
|
|
if (pid == getpgid(0))
|
|
|
|
setpgid(0, getpgid(getppid()));
|
|
|
|
setsid();
|
|
|
|
}
|
|
|
|
|
|
|
|
mask_signal(SIGHUP, SIG_IGN, &saved_sighup);
|
|
|
|
if (ttypgrp > 0)
|
|
|
|
ioctl(STDIN_FILENO, TIOCNOTTY, (char *)1);
|
|
|
|
unmask_signal(SIGHUP, &saved_sighup);
|
|
|
|
if (fd > STDIN_FILENO) close(STDIN_FILENO);
|
|
|
|
if (fd > STDOUT_FILENO) close(STDOUT_FILENO);
|
|
|
|
if (fd > STDERR_FILENO) close(STDERR_FILENO);
|
|
|
|
|
|
|
|
ioctl(fd, TIOCSCTTY, (char *)1);
|
|
|
|
tcsetpgrp(fd, ppgrp);
|
|
|
|
}
|
2021-05-17 10:20:32 -05:00
|
|
|
notty:
|
2012-12-10 06:27:11 -06:00
|
|
|
dup2(fd, STDIN_FILENO);
|
|
|
|
dup2(fd, STDOUT_FILENO);
|
|
|
|
dup2(fd, STDERR_FILENO);
|
|
|
|
con->fd = STDIN_FILENO;
|
|
|
|
|
|
|
|
for (fd = STDERR_FILENO+1; fd < 32; fd++) {
|
|
|
|
if (openfd & (1<<fd)) {
|
|
|
|
close(fd);
|
|
|
|
openfd &= ~(1<<fd);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-02-28 10:45:10 -06:00
|
|
|
/*
|
2012-03-12 05:29:09 -05:00
|
|
|
* Ask for the password. Note that there is no default timeout as we normally
|
|
|
|
* skip this during boot.
|
2012-02-28 10:45:10 -06:00
|
|
|
*/
|
2017-04-15 15:46:38 -05:00
|
|
|
static const char *getpasswd(struct console *con)
|
2012-02-28 10:45:10 -06:00
|
|
|
{
|
|
|
|
struct sigaction sa;
|
2012-12-10 06:27:11 -06:00
|
|
|
struct termios tty;
|
|
|
|
static char pass[128], *ptr;
|
|
|
|
struct chardata *cp;
|
2021-05-17 10:20:32 -05:00
|
|
|
const char *ret = NULL;
|
2012-12-10 06:27:11 -06:00
|
|
|
unsigned char tc;
|
|
|
|
char c, ascval;
|
|
|
|
int eightbit;
|
2017-04-15 15:46:38 -05:00
|
|
|
const int fd = con->fd;
|
2012-02-28 10:45:15 -06:00
|
|
|
|
2021-05-17 10:20:32 -05:00
|
|
|
if (con->flags & CON_EIO)
|
2012-12-10 06:27:11 -06:00
|
|
|
goto out;
|
2021-05-17 10:20:32 -05:00
|
|
|
|
2012-12-10 06:27:11 -06:00
|
|
|
cp = &con->cp;
|
|
|
|
tty = con->tio;
|
2021-05-17 10:20:32 -05:00
|
|
|
tc = 0;
|
|
|
|
ret = pass;
|
2012-02-28 10:45:10 -06:00
|
|
|
|
|
|
|
tty.c_iflag &= ~(IUCLC|IXON|IXOFF|IXANY);
|
2012-12-10 06:27:11 -06:00
|
|
|
tty.c_lflag &= ~(ECHO|ECHOE|ECHOK|ECHONL|TOSTOP|ISIG);
|
2021-05-17 10:20:32 -05:00
|
|
|
|
|
|
|
if ((con->flags & CON_NOTTY) == 0)
|
|
|
|
tc = (tcsetattr(fd, TCSAFLUSH, &tty) == 0);
|
2012-02-28 10:45:10 -06:00
|
|
|
|
2014-07-17 07:47:20 -05:00
|
|
|
sigemptyset(&sa.sa_mask);
|
2012-02-28 10:45:10 -06:00
|
|
|
sa.sa_handler = alrm_handler;
|
|
|
|
sa.sa_flags = 0;
|
|
|
|
sigaction(SIGALRM, &sa, NULL);
|
2012-12-18 09:03:02 -06:00
|
|
|
|
|
|
|
if (timeout)
|
|
|
|
alarm(timeout);
|
2012-02-28 10:45:10 -06:00
|
|
|
|
2012-12-10 06:27:11 -06:00
|
|
|
ptr = &pass[0];
|
|
|
|
cp->eol = *ptr = '\0';
|
|
|
|
|
|
|
|
eightbit = ((con->flags & CON_SERIAL) == 0 || (tty.c_cflag & (PARODD|PARENB)) == 0);
|
|
|
|
while (cp->eol == '\0') {
|
|
|
|
if (read(fd, &c, 1) < 1) {
|
|
|
|
if (errno == EINTR || errno == EAGAIN) {
|
2016-11-28 10:24:50 -06:00
|
|
|
if (alarm_rised) {
|
|
|
|
ret = NULL;
|
|
|
|
goto quit;
|
|
|
|
}
|
2014-01-24 06:04:14 -06:00
|
|
|
xusleep(250000);
|
2012-12-10 06:27:11 -06:00
|
|
|
continue;
|
|
|
|
}
|
2018-08-16 08:58:20 -05:00
|
|
|
ret = NULL;
|
2012-12-10 06:27:11 -06:00
|
|
|
switch (errno) {
|
|
|
|
case EIO:
|
2021-05-17 10:20:32 -05:00
|
|
|
con->flags |= CON_EIO;
|
2012-12-10 06:27:11 -06:00
|
|
|
case ESRCH:
|
|
|
|
case EINVAL:
|
|
|
|
case ENOENT:
|
2021-05-17 10:20:32 -05:00
|
|
|
case 0:
|
2012-02-28 10:45:10 -06:00
|
|
|
break;
|
2012-12-10 06:27:11 -06:00
|
|
|
default:
|
2013-10-08 10:04:22 -05:00
|
|
|
warn(_("cannot read %s"), con->tty);
|
2012-12-10 06:27:11 -06:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
goto quit;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (eightbit)
|
|
|
|
ascval = c;
|
|
|
|
else if (c != (ascval = (c & 0177))) {
|
|
|
|
uint32_t bits, mask;
|
|
|
|
for (bits = 1, mask = 1; mask & 0177; mask <<= 1) {
|
|
|
|
if (mask & ascval)
|
|
|
|
bits++;
|
|
|
|
}
|
|
|
|
cp->parity |= ((bits & 1) ? 1 : 2);
|
|
|
|
}
|
|
|
|
|
|
|
|
switch (ascval) {
|
|
|
|
case 0:
|
|
|
|
*ptr = '\0';
|
|
|
|
goto quit;
|
|
|
|
case CR:
|
|
|
|
case NL:
|
|
|
|
*ptr = '\0';
|
|
|
|
cp->eol = ascval;
|
|
|
|
break;
|
|
|
|
case BS:
|
|
|
|
case CERASE:
|
|
|
|
cp->erase = ascval;
|
|
|
|
if (ptr > &pass[0])
|
|
|
|
ptr--;
|
|
|
|
break;
|
|
|
|
case CKILL:
|
|
|
|
cp->kill = ascval;
|
|
|
|
while (ptr > &pass[0])
|
|
|
|
ptr--;
|
|
|
|
break;
|
|
|
|
case CEOF:
|
2016-11-28 10:24:49 -06:00
|
|
|
ret = NULL;
|
2012-12-10 06:27:11 -06:00
|
|
|
goto quit;
|
|
|
|
default:
|
|
|
|
if ((size_t)(ptr - &pass[0]) >= (sizeof(pass) -1 )) {
|
|
|
|
fprintf(stderr, "sulogin: input overrun at %s\n\r", con->tty);
|
2018-08-16 08:58:20 -05:00
|
|
|
ret = NULL;
|
2012-12-10 06:27:11 -06:00
|
|
|
goto quit;
|
2012-02-28 10:45:10 -06:00
|
|
|
}
|
2012-12-10 06:27:11 -06:00
|
|
|
*ptr++ = ascval;
|
|
|
|
break;
|
|
|
|
}
|
2012-02-28 10:45:10 -06:00
|
|
|
}
|
2012-12-10 06:27:11 -06:00
|
|
|
quit:
|
2012-02-28 10:45:10 -06:00
|
|
|
alarm(0);
|
2012-12-10 06:27:11 -06:00
|
|
|
if (tc)
|
2012-12-18 09:03:02 -06:00
|
|
|
tcsetattr(fd, TCSAFLUSH, &con->tio);
|
2016-03-22 04:38:59 -05:00
|
|
|
tcfinal(con);
|
2012-12-10 06:27:11 -06:00
|
|
|
printf("\r\n");
|
|
|
|
out:
|
2012-02-28 10:45:10 -06:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2012-03-12 05:29:09 -05:00
|
|
|
* Password was OK, execute a shell.
|
2012-02-28 10:45:10 -06:00
|
|
|
*/
|
2012-02-28 10:45:12 -06:00
|
|
|
static void sushell(struct passwd *pwd)
|
2012-02-28 10:45:10 -06:00
|
|
|
{
|
2012-03-12 06:32:03 -05:00
|
|
|
char shell[PATH_MAX];
|
|
|
|
char home[PATH_MAX];
|
2017-04-15 15:46:38 -05:00
|
|
|
char const *p;
|
|
|
|
char const *su_shell;
|
2012-02-28 10:45:10 -06:00
|
|
|
|
|
|
|
/*
|
2012-03-12 05:29:09 -05:00
|
|
|
* Set directory and shell.
|
2012-02-28 10:45:10 -06:00
|
|
|
*/
|
2012-03-12 06:32:03 -05:00
|
|
|
if (chdir(pwd->pw_dir) != 0) {
|
|
|
|
warn(_("%s: change directory failed"), pwd->pw_dir);
|
|
|
|
printf(_("Logging in with home = \"/\".\n"));
|
|
|
|
|
|
|
|
if (chdir("/") != 0)
|
|
|
|
warn(_("change directory to system root failed"));
|
|
|
|
}
|
|
|
|
|
2012-02-28 10:45:10 -06:00
|
|
|
if ((p = getenv("SUSHELL")) != NULL)
|
2012-07-25 14:15:24 -05:00
|
|
|
su_shell = p;
|
2012-02-28 10:45:10 -06:00
|
|
|
else if ((p = getenv("sushell")) != NULL)
|
2012-07-25 14:15:24 -05:00
|
|
|
su_shell = p;
|
2012-02-28 10:45:10 -06:00
|
|
|
else {
|
|
|
|
if (pwd->pw_shell[0])
|
2012-07-25 14:15:24 -05:00
|
|
|
su_shell = pwd->pw_shell;
|
2012-02-28 10:45:10 -06:00
|
|
|
else
|
2012-07-25 14:15:24 -05:00
|
|
|
su_shell = "/bin/sh";
|
2012-02-28 10:45:10 -06:00
|
|
|
}
|
2012-07-25 14:15:24 -05:00
|
|
|
if ((p = strrchr(su_shell, '/')) == NULL)
|
|
|
|
p = su_shell;
|
2012-02-28 10:45:10 -06:00
|
|
|
else
|
|
|
|
p++;
|
2012-03-12 05:29:09 -05:00
|
|
|
|
2012-02-28 10:45:10 -06:00
|
|
|
snprintf(shell, sizeof(shell), profile ? "-%s" : "%s", p);
|
|
|
|
|
|
|
|
/*
|
2012-03-12 05:29:09 -05:00
|
|
|
* Set some important environment variables.
|
2012-02-28 10:45:10 -06:00
|
|
|
*/
|
2012-12-10 06:27:11 -06:00
|
|
|
if (getcwd(home, sizeof(home)) == NULL)
|
|
|
|
strcpy(home, "/");
|
2012-03-12 06:32:03 -05:00
|
|
|
|
2016-08-07 01:27:21 -05:00
|
|
|
xsetenv("HOME", home, 1);
|
|
|
|
xsetenv("LOGNAME", "root", 1);
|
|
|
|
xsetenv("USER", "root", 1);
|
2012-02-28 10:45:10 -06:00
|
|
|
if (!profile)
|
2016-08-07 01:27:21 -05:00
|
|
|
xsetenv("SHLVL","0",1);
|
2012-02-28 10:45:10 -06:00
|
|
|
|
|
|
|
/*
|
2012-03-12 05:29:09 -05:00
|
|
|
* Try to execute a shell.
|
2012-02-28 10:45:10 -06:00
|
|
|
*/
|
2016-08-07 01:27:21 -05:00
|
|
|
xsetenv("SHELL", su_shell, 1);
|
2012-02-28 10:45:13 -06:00
|
|
|
unmask_signal(SIGINT, &saved_sigint);
|
|
|
|
unmask_signal(SIGTSTP, &saved_sigtstp);
|
|
|
|
unmask_signal(SIGQUIT, &saved_sigquit);
|
2012-12-10 06:27:11 -06:00
|
|
|
mask_signal(SIGHUP, SIG_DFL, NULL);
|
2012-03-12 06:47:37 -05:00
|
|
|
|
|
|
|
#ifdef HAVE_LIBSELINUX
|
2012-02-28 10:45:10 -06:00
|
|
|
if (is_selinux_enabled() > 0) {
|
2021-01-13 06:12:19 -06:00
|
|
|
char *scon = NULL;
|
|
|
|
char *seuser = NULL;
|
|
|
|
char *level = NULL;
|
2020-12-14 08:44:59 -06:00
|
|
|
|
2012-02-28 10:45:12 -06:00
|
|
|
if (getseuserbyname("root", &seuser, &level) == 0) {
|
|
|
|
if (get_default_context_with_level(seuser, level, 0, &scon) == 0) {
|
|
|
|
if (setexeccon(scon) != 0)
|
2012-03-12 05:48:33 -05:00
|
|
|
warnx(_("setexeccon failed"));
|
2012-02-28 10:45:12 -06:00
|
|
|
freecon(scon);
|
|
|
|
}
|
|
|
|
}
|
2012-02-28 10:45:10 -06:00
|
|
|
free(seuser);
|
|
|
|
free(level);
|
|
|
|
}
|
|
|
|
#endif
|
2020-10-29 12:49:07 -05:00
|
|
|
execl(su_shell, shell, (char *)NULL);
|
2013-01-30 14:33:24 -06:00
|
|
|
warn(_("failed to execute %s"), su_shell);
|
2012-02-28 10:45:10 -06:00
|
|
|
|
2016-08-07 01:27:21 -05:00
|
|
|
xsetenv("SHELL", "/bin/sh", 1);
|
2020-10-29 12:49:07 -05:00
|
|
|
execl("/bin/sh", profile ? "-sh" : "sh", (char *)NULL);
|
2013-01-30 14:33:24 -06:00
|
|
|
warn(_("failed to execute %s"), "/bin/sh");
|
2012-02-28 10:45:10 -06:00
|
|
|
}
|
|
|
|
|
2017-06-19 02:24:10 -05:00
|
|
|
static void usage(void)
|
2012-02-28 10:45:10 -06:00
|
|
|
{
|
2017-06-19 02:24:10 -05:00
|
|
|
FILE *out = stdout;
|
2012-03-12 06:23:29 -05:00
|
|
|
fputs(USAGE_HEADER, out);
|
2012-02-28 10:45:20 -06:00
|
|
|
fprintf(out, _(
|
2012-03-12 06:23:29 -05:00
|
|
|
" %s [options] [tty device]\n"), program_invocation_short_name);
|
|
|
|
|
2014-12-22 15:57:17 -06:00
|
|
|
fputs(USAGE_SEPARATOR, out);
|
|
|
|
fputs(_("Single-user login.\n"), out);
|
|
|
|
|
2012-03-12 06:23:29 -05:00
|
|
|
fputs(USAGE_OPTIONS, out);
|
|
|
|
fputs(_(" -p, --login-shell start a login shell\n"
|
|
|
|
" -t, --timeout <seconds> max time to wait for a password (default: no limit)\n"
|
|
|
|
" -e, --force examine password files directly if getpwnam(3) fails\n"),
|
|
|
|
out);
|
|
|
|
|
|
|
|
fputs(USAGE_SEPARATOR, out);
|
2017-06-29 08:52:16 -05:00
|
|
|
printf(USAGE_HELP_OPTIONS(26));
|
|
|
|
printf(USAGE_MAN_TAIL("sulogin(8)"));
|
2019-04-16 08:14:13 -05:00
|
|
|
|
|
|
|
exit(EXIT_SUCCESS);
|
2012-02-28 10:45:10 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
int main(int argc, char **argv)
|
|
|
|
{
|
2017-01-05 04:54:59 -06:00
|
|
|
struct list_head *ptr, consoles;
|
2012-12-10 06:27:11 -06:00
|
|
|
struct console *con;
|
2012-02-28 10:45:10 -06:00
|
|
|
char *tty = NULL;
|
|
|
|
struct passwd *pwd;
|
2017-04-15 15:46:38 -05:00
|
|
|
const struct timespec sigwait = { .tv_sec = 0, .tv_nsec = 50000000 };
|
|
|
|
siginfo_t status = { 0 };
|
2016-03-14 07:21:27 -05:00
|
|
|
sigset_t set;
|
2016-02-11 06:35:26 -06:00
|
|
|
int c, reconnect = 0;
|
2012-02-28 10:45:10 -06:00
|
|
|
int opt_e = 0;
|
2016-02-11 06:35:26 -06:00
|
|
|
int wait = 0;
|
2012-12-10 06:27:11 -06:00
|
|
|
pid_t pid;
|
2012-02-28 10:45:10 -06:00
|
|
|
|
2012-03-12 06:23:29 -05:00
|
|
|
static const struct option longopts[] = {
|
2017-02-11 14:23:26 -06:00
|
|
|
{ "login-shell", no_argument, NULL, 'p' },
|
|
|
|
{ "timeout", required_argument, NULL, 't' },
|
|
|
|
{ "force", no_argument, NULL, 'e' },
|
|
|
|
{ "help", no_argument, NULL, 'h' },
|
|
|
|
{ "version", no_argument, NULL, 'V' },
|
|
|
|
{ NULL, 0, NULL, 0 }
|
2012-03-12 06:23:29 -05:00
|
|
|
};
|
|
|
|
|
2017-01-05 04:54:59 -06:00
|
|
|
INIT_LIST_HEAD(&consoles);
|
|
|
|
|
2012-12-10 06:27:11 -06:00
|
|
|
/*
|
2020-12-17 15:39:05 -06:00
|
|
|
* If we are init we need to set up an own session.
|
2012-12-10 06:27:11 -06:00
|
|
|
*/
|
|
|
|
if ((pid = getpid()) == 1) {
|
|
|
|
setsid();
|
2012-12-18 09:03:02 -06:00
|
|
|
ignore_result( ioctl(STDIN_FILENO, TIOCSCTTY, (char *) 1) );
|
2012-12-10 06:27:11 -06:00
|
|
|
}
|
|
|
|
|
2012-03-12 06:36:39 -05:00
|
|
|
setlocale(LC_ALL, "");
|
|
|
|
bindtextdomain(PACKAGE, LOCALEDIR);
|
|
|
|
textdomain(PACKAGE);
|
2019-04-16 08:14:13 -05:00
|
|
|
close_stdout_atexit();
|
2012-03-12 06:36:39 -05:00
|
|
|
|
2012-02-28 10:45:10 -06:00
|
|
|
/*
|
2012-03-12 05:29:09 -05:00
|
|
|
* See if we have a timeout flag.
|
2012-02-28 10:45:10 -06:00
|
|
|
*/
|
2012-03-12 06:23:29 -05:00
|
|
|
while ((c = getopt_long(argc, argv, "ehpt:V", longopts, NULL)) != -1) {
|
2012-02-28 10:45:12 -06:00
|
|
|
switch(c) {
|
2012-02-28 10:45:10 -06:00
|
|
|
case 't':
|
2012-05-15 10:44:19 -05:00
|
|
|
timeout = strtou32_or_err(optarg, _("invalid timeout argument"));
|
2012-02-28 10:45:10 -06:00
|
|
|
break;
|
|
|
|
case 'p':
|
|
|
|
profile = 1;
|
|
|
|
break;
|
|
|
|
case 'e':
|
|
|
|
opt_e = 1;
|
|
|
|
break;
|
2012-03-12 06:23:29 -05:00
|
|
|
case 'V':
|
2019-04-16 08:14:13 -05:00
|
|
|
print_version(EXIT_SUCCESS);
|
2012-02-28 10:45:20 -06:00
|
|
|
case 'h':
|
2017-06-19 02:24:10 -05:00
|
|
|
usage();
|
2012-02-28 10:45:10 -06:00
|
|
|
default:
|
2017-06-19 02:24:10 -05:00
|
|
|
/* Do not exit! getopt prints a warning. */
|
2012-02-28 10:45:10 -06:00
|
|
|
break;
|
2012-02-28 10:45:12 -06:00
|
|
|
}
|
2012-02-28 10:45:10 -06:00
|
|
|
}
|
|
|
|
|
2012-03-12 05:48:33 -05:00
|
|
|
if (geteuid() != 0)
|
2014-08-06 15:35:06 -05:00
|
|
|
errx(EXIT_FAILURE, _("only superuser can run this program"));
|
2012-02-28 10:45:10 -06:00
|
|
|
|
2012-02-28 10:45:13 -06:00
|
|
|
mask_signal(SIGQUIT, SIG_IGN, &saved_sigquit);
|
|
|
|
mask_signal(SIGTSTP, SIG_IGN, &saved_sigtstp);
|
|
|
|
mask_signal(SIGINT, SIG_IGN, &saved_sigint);
|
2012-12-10 06:27:11 -06:00
|
|
|
mask_signal(SIGHUP, SIG_IGN, &saved_sighup);
|
|
|
|
|
2012-12-23 15:44:05 -06:00
|
|
|
|
|
|
|
emergency_do_mounts();
|
|
|
|
atexit( emergency_do_umounts );
|
|
|
|
|
2012-12-10 06:27:11 -06:00
|
|
|
/*
|
|
|
|
* See if we need to open an other tty device.
|
|
|
|
*/
|
2012-02-28 10:45:12 -06:00
|
|
|
if (optind < argc)
|
|
|
|
tty = argv[optind];
|
2012-02-28 10:45:10 -06:00
|
|
|
|
2012-12-10 06:27:11 -06:00
|
|
|
if (!tty || *tty == '\0')
|
|
|
|
tty = getenv("CONSOLE");
|
2012-02-28 10:45:10 -06:00
|
|
|
|
2012-12-10 06:27:11 -06:00
|
|
|
/*
|
|
|
|
* Detect possible consoles, use stdin as fallback.
|
|
|
|
* If an optional tty is given, reconnect it to stdin.
|
|
|
|
*/
|
|
|
|
reconnect = detect_consoles(tty, STDIN_FILENO, &consoles);
|
2012-02-28 10:45:10 -06:00
|
|
|
|
2012-12-10 06:27:11 -06:00
|
|
|
/*
|
2016-05-29 16:11:53 -05:00
|
|
|
* If previous stdin was not the specified tty and therefore reconnected
|
2012-12-10 06:27:11 -06:00
|
|
|
* to the specified tty also reconnect stdout and stderr.
|
|
|
|
*/
|
|
|
|
if (reconnect) {
|
|
|
|
if (isatty(STDOUT_FILENO) == 0)
|
|
|
|
dup2(STDOUT_FILENO, STDIN_FILENO);
|
|
|
|
if (isatty(STDERR_FILENO) == 0)
|
|
|
|
dup2(STDOUT_FILENO, STDERR_FILENO);
|
2012-02-28 10:45:10 -06:00
|
|
|
}
|
|
|
|
|
2012-12-10 06:27:11 -06:00
|
|
|
/*
|
|
|
|
* Should not happen
|
|
|
|
*/
|
|
|
|
if (list_empty(&consoles)) {
|
|
|
|
if (!errno)
|
|
|
|
errno = ENOENT;
|
2013-05-14 16:29:09 -05:00
|
|
|
err(EXIT_FAILURE, _("cannot open console"));
|
2012-12-10 06:27:11 -06:00
|
|
|
}
|
2012-03-12 08:41:00 -05:00
|
|
|
|
2012-02-28 10:45:10 -06:00
|
|
|
/*
|
2012-03-12 05:29:09 -05:00
|
|
|
* Get the root password.
|
2012-02-28 10:45:10 -06:00
|
|
|
*/
|
|
|
|
if ((pwd = getrootpwent(opt_e)) == NULL) {
|
2014-08-06 15:35:06 -05:00
|
|
|
warnx(_("cannot open password database"));
|
2012-02-28 10:45:10 -06:00
|
|
|
sleep(2);
|
2013-03-27 08:50:52 -05:00
|
|
|
return EXIT_FAILURE;
|
2012-02-28 10:45:10 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2012-12-10 06:27:11 -06:00
|
|
|
* Ask for the password on the consoles.
|
2012-02-28 10:45:10 -06:00
|
|
|
*/
|
2012-12-10 06:27:11 -06:00
|
|
|
list_for_each(ptr, &consoles) {
|
|
|
|
con = list_entry(ptr, struct console, entry);
|
|
|
|
if (con->id >= CONMAX)
|
2012-02-28 10:45:12 -06:00
|
|
|
break;
|
2012-12-10 06:27:11 -06:00
|
|
|
if (con->fd >= 0) {
|
2012-12-18 09:03:02 -06:00
|
|
|
openfd |= (1 << con->fd);
|
2012-12-10 06:27:11 -06:00
|
|
|
tcinit(con);
|
|
|
|
continue;
|
2012-12-07 02:00:56 -06:00
|
|
|
}
|
2012-12-10 06:27:11 -06:00
|
|
|
if ((con->fd = open(con->tty, O_RDWR | O_NOCTTY | O_NONBLOCK)) < 0)
|
|
|
|
continue;
|
2012-12-18 09:03:02 -06:00
|
|
|
openfd |= (1 << con->fd);
|
2012-12-10 06:27:11 -06:00
|
|
|
tcinit(con);
|
2012-02-28 10:45:10 -06:00
|
|
|
}
|
2012-12-10 06:27:11 -06:00
|
|
|
ptr = (&consoles)->next;
|
2012-02-28 10:45:10 -06:00
|
|
|
|
2012-12-10 06:27:11 -06:00
|
|
|
if (ptr->next == &consoles) {
|
|
|
|
con = list_entry(ptr, struct console, entry);
|
|
|
|
goto nofork;
|
|
|
|
}
|
2012-12-07 02:00:56 -06:00
|
|
|
|
2015-05-25 08:30:52 -05:00
|
|
|
|
2012-12-10 06:27:11 -06:00
|
|
|
mask_signal(SIGCHLD, chld_handler, &saved_sigchld);
|
|
|
|
do {
|
|
|
|
con = list_entry(ptr, struct console, entry);
|
|
|
|
if (con->id >= CONMAX)
|
|
|
|
break;
|
2021-05-17 10:20:32 -05:00
|
|
|
if (con->flags & CON_EIO)
|
|
|
|
goto next;
|
2012-12-10 06:27:11 -06:00
|
|
|
|
|
|
|
switch ((con->pid = fork())) {
|
|
|
|
case 0:
|
|
|
|
mask_signal(SIGCHLD, SIG_DFL, NULL);
|
2021-05-17 10:20:32 -05:00
|
|
|
dup2(con->fd, STDERR_FILENO);
|
2012-12-10 06:27:11 -06:00
|
|
|
nofork:
|
|
|
|
setup(con);
|
|
|
|
while (1) {
|
|
|
|
const char *passwd = pwd->pw_passwd;
|
|
|
|
const char *answer;
|
2018-08-16 09:16:40 -05:00
|
|
|
int doshell = 0;
|
2015-05-25 08:30:52 -05:00
|
|
|
int deny = !opt_e && locked_account_password(pwd->pw_passwd);
|
|
|
|
|
|
|
|
doprompt(passwd, con, deny);
|
2012-12-10 06:27:11 -06:00
|
|
|
|
|
|
|
if ((answer = getpasswd(con)) == NULL)
|
|
|
|
break;
|
2015-05-25 08:30:52 -05:00
|
|
|
if (deny)
|
|
|
|
exit(EXIT_FAILURE);
|
2012-12-10 06:27:11 -06:00
|
|
|
|
2015-05-25 08:30:52 -05:00
|
|
|
/* no password or locked account */
|
|
|
|
if (!passwd[0] || locked_account_password(passwd))
|
2012-12-10 06:27:11 -06:00
|
|
|
doshell++;
|
|
|
|
else {
|
|
|
|
const char *cryptbuf;
|
|
|
|
cryptbuf = crypt(answer, passwd);
|
|
|
|
if (cryptbuf == NULL)
|
2013-05-14 16:29:09 -05:00
|
|
|
warn(_("crypt failed"));
|
2012-12-10 06:27:11 -06:00
|
|
|
else if (strcmp(cryptbuf, pwd->pw_passwd) == 0)
|
|
|
|
doshell++;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (doshell) {
|
2018-08-16 09:16:40 -05:00
|
|
|
/* sushell() unmask signals */
|
2012-12-10 06:27:11 -06:00
|
|
|
sushell(pwd);
|
|
|
|
|
2018-08-16 09:16:40 -05:00
|
|
|
mask_signal(SIGQUIT, SIG_IGN, &saved_sigquit);
|
|
|
|
mask_signal(SIGTSTP, SIG_IGN, &saved_sigtstp);
|
|
|
|
mask_signal(SIGINT, SIG_IGN, &saved_sigint);
|
2012-12-10 06:27:11 -06:00
|
|
|
|
2016-11-01 13:40:33 -05:00
|
|
|
fprintf(stderr, _("cannot execute su shell\n\n"));
|
2012-12-10 06:27:11 -06:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
fprintf(stderr, _("Login incorrect\n\n"));
|
|
|
|
}
|
|
|
|
if (alarm_rised) {
|
|
|
|
tcfinal(con);
|
|
|
|
warnx(_("Timed out\n\n"));
|
|
|
|
}
|
|
|
|
/*
|
|
|
|
* User pressed Control-D.
|
|
|
|
*/
|
|
|
|
exit(0);
|
|
|
|
case -1:
|
2013-05-14 16:29:09 -05:00
|
|
|
warn(_("fork failed"));
|
2017-05-16 03:18:24 -05:00
|
|
|
/* fallthrough */
|
2012-12-10 06:27:11 -06:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2021-05-17 10:20:32 -05:00
|
|
|
next:
|
2012-12-10 06:27:11 -06:00
|
|
|
ptr = ptr->next;
|
|
|
|
|
|
|
|
} while (ptr != &consoles);
|
|
|
|
|
2016-02-11 06:35:26 -06:00
|
|
|
do {
|
|
|
|
int ret;
|
|
|
|
|
|
|
|
status.si_pid = 0;
|
|
|
|
ret = waitid(P_ALL, 0, &status, WEXITED);
|
|
|
|
|
|
|
|
if (ret == 0)
|
2012-12-10 06:27:11 -06:00
|
|
|
break;
|
2016-02-11 06:35:26 -06:00
|
|
|
if (ret < 0) {
|
|
|
|
if (errno == ECHILD)
|
|
|
|
break;
|
|
|
|
if (errno == EINTR)
|
2012-12-10 06:27:11 -06:00
|
|
|
continue;
|
2016-02-11 06:35:26 -06:00
|
|
|
}
|
|
|
|
|
2016-11-01 13:40:33 -05:00
|
|
|
errx(EXIT_FAILURE, _("cannot wait on su shell\n\n"));
|
2016-02-11 06:35:26 -06:00
|
|
|
|
|
|
|
} while (1);
|
|
|
|
|
|
|
|
list_for_each(ptr, &consoles) {
|
|
|
|
con = list_entry(ptr, struct console, entry);
|
|
|
|
|
|
|
|
if (con->fd < 0)
|
|
|
|
continue;
|
|
|
|
if (con->pid < 0)
|
|
|
|
continue;
|
|
|
|
if (con->pid == status.si_pid)
|
|
|
|
con->pid = -1;
|
|
|
|
else {
|
|
|
|
kill(con->pid, SIGTERM);
|
|
|
|
wait++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
sigemptyset(&set);
|
|
|
|
sigaddset(&set, SIGCHLD);
|
|
|
|
|
|
|
|
do {
|
|
|
|
int signum, ret;
|
|
|
|
|
|
|
|
if (!wait)
|
|
|
|
break;
|
|
|
|
|
|
|
|
status.si_pid = 0;
|
|
|
|
ret = waitid(P_ALL, 0, &status, WEXITED|WNOHANG);
|
|
|
|
|
|
|
|
if (ret < 0) {
|
|
|
|
if (errno == ECHILD)
|
|
|
|
break;
|
|
|
|
if (errno == EINTR)
|
2012-12-10 06:27:11 -06:00
|
|
|
continue;
|
2016-02-11 06:35:26 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!ret && status.si_pid > 0) {
|
|
|
|
list_for_each(ptr, &consoles) {
|
|
|
|
con = list_entry(ptr, struct console, entry);
|
|
|
|
|
|
|
|
if (con->fd < 0)
|
|
|
|
continue;
|
|
|
|
if (con->pid < 0)
|
|
|
|
continue;
|
|
|
|
if (con->pid == status.si_pid) {
|
|
|
|
con->pid = -1;
|
|
|
|
wait--;
|
|
|
|
}
|
2012-12-10 06:27:11 -06:00
|
|
|
}
|
2016-02-11 06:35:26 -06:00
|
|
|
continue;
|
2012-12-10 06:27:11 -06:00
|
|
|
}
|
2016-02-11 06:35:26 -06:00
|
|
|
|
|
|
|
signum = sigtimedwait(&set, NULL, &sigwait);
|
2016-07-04 16:09:10 -05:00
|
|
|
if (signum != SIGCHLD && signum < 0 && errno == EAGAIN)
|
|
|
|
break;
|
2016-02-11 06:35:26 -06:00
|
|
|
|
|
|
|
} while (1);
|
2012-12-10 06:27:11 -06:00
|
|
|
|
|
|
|
mask_signal(SIGCHLD, SIG_DFL, NULL);
|
2012-03-12 05:51:19 -05:00
|
|
|
return EXIT_SUCCESS;
|
2012-02-28 10:45:10 -06:00
|
|
|
}
|