2007-10-07 17:14:02 +05:30
|
|
|
/*
|
2021-12-05 21:05:27 +05:30
|
|
|
* SPDX-FileCopyrightText: 1989 - 1994, Julianne Frances Haugh
|
|
|
|
* SPDX-FileCopyrightText: 1996 - 1999, Marek Michałkiewicz
|
|
|
|
* SPDX-FileCopyrightText: 2003 - 2005, Tomasz Kłoczko
|
|
|
|
* SPDX-FileCopyrightText: 2007 - 2008, Nicolas François
|
2007-10-07 17:14:02 +05:30
|
|
|
*
|
2021-12-05 21:05:27 +05:30
|
|
|
* SPDX-License-Identifier: BSD-3-Clause
|
2007-10-07 17:14:02 +05:30
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#ifdef RLOGIN
|
|
|
|
|
2007-11-11 05:16:11 +05:30
|
|
|
#ident "$Id$"
|
2007-10-07 17:17:01 +05:30
|
|
|
|
2007-10-07 17:14:02 +05:30
|
|
|
#include "prototypes.h"
|
|
|
|
#include "defines.h"
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <pwd.h>
|
2007-10-07 17:16:07 +05:30
|
|
|
#include <netdb.h>
|
2007-10-07 17:14:02 +05:30
|
|
|
static struct {
|
2007-10-07 17:15:23 +05:30
|
|
|
int spd_name;
|
|
|
|
int spd_baud;
|
|
|
|
} speed_table[] =
|
|
|
|
{
|
2022-12-03 03:37:56 +05:30
|
|
|
{ B50, 50},
|
|
|
|
{ B75, 75},
|
|
|
|
{ B110, 110},
|
|
|
|
{ B134, 134},
|
|
|
|
{ B150, 150},
|
|
|
|
{ B200, 200},
|
|
|
|
{ B300, 300},
|
|
|
|
{ B600, 600},
|
|
|
|
{ B1200, 1200},
|
|
|
|
{ B1800, 1800},
|
|
|
|
{ B2400, 2400},
|
|
|
|
{ B4800, 4800},
|
|
|
|
{ B9600, 9600},
|
|
|
|
{ B19200, 19200},
|
|
|
|
{ B38400, 38400},
|
|
|
|
{ -1, -1}
|
2007-10-07 17:14:02 +05:30
|
|
|
};
|
|
|
|
|
2008-06-14 00:04:27 +05:30
|
|
|
static void get_remote_string (char *buf, size_t size)
|
2007-10-07 17:14:02 +05:30
|
|
|
{
|
|
|
|
for (;;) {
|
2008-06-14 00:04:27 +05:30
|
|
|
if (read (0, buf, 1) != 1) {
|
* lib/exitcodes.h: Define E_SUCCESS as EXIT_SUCCESS. Added FIXMEs.
* libmisc/chowntty.c, libmisc/rlogin.c, libmisc/sub.c,
src/newusers.c, libmisc/sulog.c, libmisc/system.c, src/logoutd.c,
src/groups.c, src/id.c, lib/encrypt.c, libmisc/audit_help.c,
libmisc/limits.c: Return EXIT_FAILURE instead of 1, and
EXIT_SUCCESS instead of 0.
* libmisc/audit_help.c: Replace an fprintf() by fputs().
* libmisc/audit_help.c: Remove documentation of the audit_logger
returned values. The function returns void.
* libmisc/system.c: Only return status if waitpid succeeded.
Return -1 otherwise.
2009-05-01 02:38:49 +05:30
|
|
|
exit (EXIT_FAILURE);
|
2008-06-14 00:04:27 +05:30
|
|
|
}
|
|
|
|
if ('\0' == *buf) {
|
2007-10-07 17:14:02 +05:30
|
|
|
return;
|
2008-06-14 00:04:27 +05:30
|
|
|
}
|
|
|
|
--size;
|
|
|
|
if (size > 0) {
|
2007-10-07 17:14:02 +05:30
|
|
|
++buf;
|
2008-06-14 00:04:27 +05:30
|
|
|
}
|
2007-10-07 17:14:02 +05:30
|
|
|
}
|
2007-10-07 17:15:23 +05:30
|
|
|
/*NOTREACHED*/}
|
2007-10-07 17:14:02 +05:30
|
|
|
|
|
|
|
int
|
2008-06-14 00:04:27 +05:30
|
|
|
do_rlogin (const char *remote_host, char *name, size_t namelen, char *term,
|
|
|
|
size_t termlen)
|
2007-10-07 17:14:02 +05:30
|
|
|
{
|
2007-10-07 17:15:23 +05:30
|
|
|
struct passwd *pwd;
|
|
|
|
char remote_name[32];
|
|
|
|
char *cp;
|
2009-04-29 00:47:21 +05:30
|
|
|
unsigned long remote_speed = 9600;
|
2007-10-07 17:15:23 +05:30
|
|
|
int speed_name = B9600;
|
|
|
|
int i;
|
|
|
|
TERMIO termio;
|
2007-10-07 17:14:02 +05:30
|
|
|
|
|
|
|
get_remote_string (remote_name, sizeof remote_name);
|
|
|
|
get_remote_string (name, namelen);
|
|
|
|
get_remote_string (term, termlen);
|
|
|
|
|
2008-06-14 00:04:27 +05:30
|
|
|
cp = strchr (term, '/');
|
|
|
|
if (NULL != cp) {
|
|
|
|
*cp = '\0';
|
|
|
|
cp++;
|
2007-10-07 17:14:02 +05:30
|
|
|
|
2009-04-29 00:47:21 +05:30
|
|
|
if (getulong (cp, &remote_speed) == 0) {
|
2007-10-07 17:14:02 +05:30
|
|
|
remote_speed = 9600;
|
2008-05-26 04:19:41 +05:30
|
|
|
}
|
2007-10-07 17:14:02 +05:30
|
|
|
}
|
2008-06-14 00:04:27 +05:30
|
|
|
for (i = 0;
|
|
|
|
( (speed_table[i].spd_baud != remote_speed)
|
|
|
|
&& (speed_table[i].spd_name != -1));
|
|
|
|
i++);
|
2007-10-07 17:14:02 +05:30
|
|
|
|
2008-06-14 00:04:27 +05:30
|
|
|
if (-1 != speed_table[i].spd_name) {
|
2007-10-07 17:14:02 +05:30
|
|
|
speed_name = speed_table[i].spd_name;
|
2008-06-14 00:04:27 +05:30
|
|
|
}
|
2007-10-07 17:14:02 +05:30
|
|
|
|
|
|
|
/*
|
|
|
|
* Put the terminal in cooked mode with echo turned on.
|
|
|
|
*/
|
|
|
|
|
2007-10-07 17:15:23 +05:30
|
|
|
GTTY (0, &termio);
|
|
|
|
termio.c_iflag |= ICRNL | IXON;
|
|
|
|
termio.c_oflag |= OPOST | ONLCR;
|
|
|
|
termio.c_lflag |= ICANON | ECHO | ECHOE;
|
2007-10-07 17:14:08 +05:30
|
|
|
#ifdef CBAUD
|
2007-10-07 17:14:02 +05:30
|
|
|
termio.c_cflag = (termio.c_cflag & ~CBAUD) | speed_name;
|
|
|
|
#else
|
2007-10-07 17:14:08 +05:30
|
|
|
termio.c_cflag = (termio.c_cflag) | speed_name;
|
2007-10-07 17:14:02 +05:30
|
|
|
#endif
|
2007-10-07 17:15:23 +05:30
|
|
|
STTY (0, &termio);
|
2007-10-07 17:14:02 +05:30
|
|
|
|
2008-05-26 04:19:41 +05:30
|
|
|
pwd = getpwnam (name); /* local, no need for xgetpwnam */
|
|
|
|
if (NULL == pwd) {
|
2007-10-07 17:14:02 +05:30
|
|
|
return 0;
|
2008-05-26 04:19:41 +05:30
|
|
|
}
|
2007-10-07 17:14:02 +05:30
|
|
|
|
|
|
|
/*
|
|
|
|
* ruserok() returns 0 for success on modern systems, and 1 on
|
|
|
|
* older ones. If you are having trouble with people logging
|
|
|
|
* in without giving a required password, THIS is the culprit -
|
|
|
|
* go fix the #define in config.h.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef RUSEROK
|
|
|
|
return 0;
|
|
|
|
#else
|
|
|
|
return ruserok (remote_host, pwd->pw_uid == 0,
|
2007-10-07 17:15:23 +05:30
|
|
|
remote_name, name) == RUSEROK;
|
2007-10-07 17:14:02 +05:30
|
|
|
#endif
|
|
|
|
}
|
2007-10-07 17:15:23 +05:30
|
|
|
#endif /* RLOGIN */
|
2008-04-27 06:10:09 +05:30
|
|
|
|