libcompat_minix-centric cleanup
remove some old minix-userland-specific stuff . /etc/ttytab as a file, and minix-compat function (fftyslot()), replaced by /etc/ttys and new libc functions . also remove minix-specific nlist(), cuserid(), fttyslot(), v8 regex functions and <compat/regex.h> . and remaining minix-only utilities that use them . also unused <compat/pwd.h> and <compat/syslog.h> and redundant <sys/sigcontext.h>
This commit is contained in:
parent
9290237811
commit
6af9856d4a
42 changed files with 15 additions and 3014 deletions
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
SUBDIR= add_route arp ash at awk \
|
SUBDIR= add_route arp ash at awk \
|
||||||
backup badblocks banner basename \
|
backup badblocks banner basename \
|
||||||
btrace cal calendar \
|
btrace cal \
|
||||||
cawf cd cdprobe checkhier cpp \
|
cawf cd cdprobe checkhier cpp \
|
||||||
chmod chown chroot ci cksum cleantmp clear cmp co \
|
chmod chown chroot ci cksum cleantmp clear cmp co \
|
||||||
comm compress cp crc cron crontab cut \
|
comm compress cp crc cron crontab cut \
|
||||||
|
@ -14,16 +14,16 @@ SUBDIR= add_route arp ash at awk \
|
||||||
find finger fingerd fix fold format fortune fsck.mfs \
|
find finger fingerd fix fold format fortune fsck.mfs \
|
||||||
ftp101 gcore gcov-pull getty grep head hexdump host \
|
ftp101 gcore gcov-pull getty grep head hexdump host \
|
||||||
hostaddr id ifconfig ifdef install \
|
hostaddr id ifconfig ifdef install \
|
||||||
intr ipcrm ipcs irdpd isoread join kill last leave \
|
intr ipcrm ipcs irdpd isoread join kill last \
|
||||||
less lex loadkeys loadramdisk logger login look lp \
|
less lex loadkeys loadramdisk logger login look lp \
|
||||||
lpd ls lspci mail make MAKEDEV \
|
lpd ls lspci mail make MAKEDEV \
|
||||||
mdb mesg mined mkfifo mkfs.mfs mknod \
|
mdb mesg mined mkfifo mkfs.mfs mknod \
|
||||||
mkproto modem mount mt netconf newroot nice acknm nohup \
|
mkproto mount mt netconf newroot nice acknm nohup \
|
||||||
nonamed od paste patch pax \
|
nonamed od paste patch pax \
|
||||||
ping postinstall poweroff pr prep printf printroot \
|
ping postinstall poweroff pr prep printf printroot \
|
||||||
profile progressbar proto pr_routes ps pwd pwdauth \
|
profile progressbar proto pr_routes ps pwd pwdauth \
|
||||||
ramdisk rarpd rawspeed rcp rdate readall readclock \
|
ramdisk rarpd rawspeed rcp rdate readall readclock \
|
||||||
reboot remsync rev rget rlogin rlogind \
|
reboot remsync rev rget rlogin \
|
||||||
rotate rsh rshd sed service setup shar acksize \
|
rotate rsh rshd sed service setup shar acksize \
|
||||||
sleep slip sort spell split srccrc \
|
sleep slip sort spell split srccrc \
|
||||||
stty su sum svclog swifi sync synctree sysenv \
|
stty su sum svclog swifi sync synctree sysenv \
|
||||||
|
|
|
@ -1,4 +0,0 @@
|
||||||
PROG= calendar
|
|
||||||
MAN=
|
|
||||||
|
|
||||||
.include <bsd.prog.mk>
|
|
|
@ -1,236 +0,0 @@
|
||||||
/* calendar - reminder service Authors: S. & K. Hirabayashi */
|
|
||||||
|
|
||||||
/* Permission is hereby granted for nonprofit use. */
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <time.h>
|
|
||||||
#ifdef __NBSD_LIBC
|
|
||||||
#include <compat/regexp.h>
|
|
||||||
#else
|
|
||||||
#include <regexp.h>
|
|
||||||
#endif
|
|
||||||
#include <limits.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <termcap.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <utime.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
/* Change these two lines for your system needs. */
|
|
||||||
#define MAIL1 "/usr/bin/mail"
|
|
||||||
#define MAIL2 "/bin/mail"
|
|
||||||
#define PASSWD "/etc/passwd" /* system password file */
|
|
||||||
#define MAX_EXP 4 /* see date_exp() function */
|
|
||||||
|
|
||||||
char *mail; /* mail command path ("/bin/mail" etc) */
|
|
||||||
regexp *exp[MAX_EXP]; /* date expressions */
|
|
||||||
int nexp; /* # of the date expressions */
|
|
||||||
char calfile[PATH_MAX]; /* calendar file for the user */
|
|
||||||
|
|
||||||
int rflg; /* consult aged 'calendar' file and touch */
|
|
||||||
int mflg; /* mail (multi user) service */
|
|
||||||
char *cmd; /* the name of this command */
|
|
||||||
char buf[BUFSIZ];
|
|
||||||
|
|
||||||
_PROTOTYPE(int main, (int argc, char **argv));
|
|
||||||
_PROTOTYPE(void calendar, (void));
|
|
||||||
_PROTOTYPE(char *getstr, (char *s, int n));
|
|
||||||
_PROTOTYPE(int newaccess, (char *file));
|
|
||||||
_PROTOTYPE(void grep, (char *file, char *user));
|
|
||||||
_PROTOTYPE(int date_exp, (void));
|
|
||||||
_PROTOTYPE(char *date_pat, (time_t t));
|
|
||||||
/*
|
|
||||||
_PROTOTYPE(void regerror, (char *s));
|
|
||||||
*/
|
|
||||||
_PROTOTYPE(void error, (char *s, char *t));
|
|
||||||
|
|
||||||
int main(argc, argv)
|
|
||||||
int argc;
|
|
||||||
char **argv;
|
|
||||||
{
|
|
||||||
char *s;
|
|
||||||
|
|
||||||
cmd = *argv;
|
|
||||||
while (--argc > 0 && (*++argv)[0] == '-') {
|
|
||||||
s = argv[0] + 1;
|
|
||||||
if (*s == '\0')
|
|
||||||
mflg++; /* mail service */
|
|
||||||
else if (strcmp(s, "r") == 0)
|
|
||||||
rflg++, mflg++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mflg) { /* check mailing agent */
|
|
||||||
if (access(MAIL1, X_OK) == 0)
|
|
||||||
mail = MAIL1;
|
|
||||||
else if (access(MAIL2, X_OK) == 0)
|
|
||||||
mail = MAIL2;
|
|
||||||
else
|
|
||||||
error("cannot find %s", MAIL1);
|
|
||||||
}
|
|
||||||
nexp = date_exp();
|
|
||||||
calendar();
|
|
||||||
exit(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void calendar()
|
|
||||||
{
|
|
||||||
int i;
|
|
||||||
char *s;
|
|
||||||
FILE *fp;
|
|
||||||
|
|
||||||
if (!mflg) {
|
|
||||||
grep("calendar", "");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Mail sevice */
|
|
||||||
if ((fp = fopen(PASSWD, "r")) == (FILE *) NULL)
|
|
||||||
error("cannot open %s", PASSWD);
|
|
||||||
|
|
||||||
while (fgets(buf, BUFSIZ, fp) != (char *) NULL) {
|
|
||||||
for (i = 0, s = buf; *s && *s != '\n'; s++)
|
|
||||||
if (*s == ':') i++;
|
|
||||||
*s = '\0';
|
|
||||||
if (i != 6) error("illegal '/etc/passwd' format: %s", buf);
|
|
||||||
|
|
||||||
/* Calendar file = ${HOME}/calendar */
|
|
||||||
sprintf(calfile, "%s/%s", getstr(buf, 5), "calendar");
|
|
||||||
|
|
||||||
if ((access(calfile, R_OK) != 0) || (rflg && !newaccess(calfile)))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
grep(calfile, getstr(buf, 0));
|
|
||||||
}
|
|
||||||
|
|
||||||
fclose(fp);
|
|
||||||
}
|
|
||||||
|
|
||||||
char *getstr(s, n)
|
|
||||||
char *s;
|
|
||||||
int n;
|
|
||||||
{
|
|
||||||
/* Returns the string value of the n-th field in the record (s) */
|
|
||||||
int i;
|
|
||||||
char *t;
|
|
||||||
static char str[512];
|
|
||||||
|
|
||||||
for (i = 0; i < n && *s; s++)
|
|
||||||
if (*s == ':') i++; /* field separator */
|
|
||||||
for (i = 0, t = str; *s && *s != ':' && i < 511; i++) *t++ = *s++;
|
|
||||||
*t = '\0';
|
|
||||||
return str;
|
|
||||||
}
|
|
||||||
|
|
||||||
int newaccess(file)
|
|
||||||
char *file; /* file name */
|
|
||||||
{
|
|
||||||
/* Check whether the file has been touched today. */
|
|
||||||
|
|
||||||
int r = 0;
|
|
||||||
struct tm *tm;
|
|
||||||
struct stat stbuf;
|
|
||||||
time_t clk;
|
|
||||||
char newdate[8], olddate[8];
|
|
||||||
|
|
||||||
time(&clk);
|
|
||||||
tm = localtime(&clk);
|
|
||||||
sprintf(newdate, "%02d%02d%02d", tm->tm_year, tm->tm_mon + 1, tm->tm_mday);
|
|
||||||
|
|
||||||
if (stat(file, &stbuf) == -1) error("cannot stat %s", file);
|
|
||||||
tm = localtime(&stbuf.st_mtime);
|
|
||||||
sprintf(olddate, "%02d%02d%02d", tm->tm_year, tm->tm_mon + 1, tm->tm_mday);
|
|
||||||
|
|
||||||
if (strcmp(newdate, olddate) != 0) {
|
|
||||||
utime(file, NULL); /* touch */
|
|
||||||
r++;
|
|
||||||
}
|
|
||||||
return r;
|
|
||||||
}
|
|
||||||
|
|
||||||
void grep(file, user)
|
|
||||||
char *file, *user;
|
|
||||||
{ /* grep 'exp[]' [| mail user] */
|
|
||||||
int i;
|
|
||||||
char command[128]; /* mail command */
|
|
||||||
FILE *ifp, *ofp;
|
|
||||||
|
|
||||||
if ((ifp = fopen(file, "r")) == (FILE *) NULL)
|
|
||||||
error("cannot open %s", file);
|
|
||||||
if (*user != '\0') {
|
|
||||||
sprintf(command, "%s %s", mail, user);
|
|
||||||
ofp = (FILE *) NULL;
|
|
||||||
} else {
|
|
||||||
ofp = stdout;
|
|
||||||
}
|
|
||||||
|
|
||||||
while (fgets(buf, BUFSIZ, ifp) != (char *) NULL) {
|
|
||||||
for (i = 0; i < nexp; i++) {
|
|
||||||
if (regexec(exp[i], buf, 1)) {
|
|
||||||
if ((ofp == (FILE *) NULL) &&
|
|
||||||
(ofp = popen(command, "w")) == (FILE *) NULL)
|
|
||||||
error("cannot popen %s", mail);
|
|
||||||
fputs(buf, ofp);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fclose(ifp);
|
|
||||||
if (ofp == stdout)
|
|
||||||
fflush(ofp);
|
|
||||||
else if (ofp != (FILE *) NULL)
|
|
||||||
pclose(ofp);
|
|
||||||
}
|
|
||||||
|
|
||||||
int date_exp()
|
|
||||||
{
|
|
||||||
/* Set compiled regular expressions into the exp[] array. */
|
|
||||||
static int n[] = {2, 2, 2, 2, 2, 4, 3};
|
|
||||||
int i, r, wday;
|
|
||||||
time_t clk;
|
|
||||||
|
|
||||||
time(&clk);
|
|
||||||
wday = localtime(&clk)->tm_wday;
|
|
||||||
r = n[wday];
|
|
||||||
if (r > MAX_EXP) error("too many date expressions", "");
|
|
||||||
for (i = 0; i < r; i++) {
|
|
||||||
exp[i] = regcomp(date_pat(clk));
|
|
||||||
clk += 60 * 60 * 24L; /* 24 hours */
|
|
||||||
}
|
|
||||||
return(r);
|
|
||||||
}
|
|
||||||
|
|
||||||
char *date_pat(t)
|
|
||||||
time_t t;
|
|
||||||
{ /* returns date expression for the time (t) */
|
|
||||||
static char *month[] = {
|
|
||||||
"[Jj]an", "[Ff]eb", "[Mm]ar", "[Aa]pr", "[Mm]ay", "[Jj]un",
|
|
||||||
"[Jj]ul", "[Aa]ug", "[Ss]ep", "[Oo]ct", "[Nn]ov", "[Dd]ec"
|
|
||||||
};
|
|
||||||
static char str[512];
|
|
||||||
struct tm *tm;
|
|
||||||
|
|
||||||
tm = localtime(&t);
|
|
||||||
sprintf(str,
|
|
||||||
"(^|[ \t(,;])(((%s[^ \t]*[ \t])|0*%d/|\\*/)(0*%d|\\*))([^0123456789]|$)",
|
|
||||||
month[tm->tm_mon], tm->tm_mon + 1, tm->tm_mday);
|
|
||||||
|
|
||||||
return str;
|
|
||||||
}
|
|
||||||
|
|
||||||
void regerror(s)
|
|
||||||
const char *s;
|
|
||||||
{ /* regcomp() needs this */
|
|
||||||
error("REGULAR EXPRESSION ERROR (%s)", (char *) s);
|
|
||||||
}
|
|
||||||
|
|
||||||
void error(s, t)
|
|
||||||
char *s, *t;
|
|
||||||
{
|
|
||||||
fprintf(stderr, "%s: ", cmd);
|
|
||||||
fprintf(stderr, s, t);
|
|
||||||
fprintf(stderr, "\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
|
@ -1,4 +0,0 @@
|
||||||
PROG= leave
|
|
||||||
MAN=
|
|
||||||
|
|
||||||
.include <bsd.prog.mk>
|
|
|
@ -1,210 +0,0 @@
|
||||||
/* Usage: leave [ [+] hh[:]mm ]
|
|
||||||
*
|
|
||||||
* Author: Terrence W. Holm
|
|
||||||
*
|
|
||||||
* Revision:
|
|
||||||
* Fred van Kempen, MINIX User Group Holland
|
|
||||||
* -adapted to MSS
|
|
||||||
* -adapted to new utmp database
|
|
||||||
* -adapted to POSIX (MINIX 1.5)
|
|
||||||
* Michael Temari, <temari@ix.netcom.com>
|
|
||||||
* -use localtime/mktime to fix bug with DST
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <signal.h>
|
|
||||||
#include <time.h>
|
|
||||||
#include <utmp.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
|
|
||||||
#define Min(a,b) ((a<b) ? a : b)
|
|
||||||
|
|
||||||
#define STRING 80 /* lots of room for an argument */
|
|
||||||
#define MIN 60L /* seconds per minute */
|
|
||||||
#define HOUR (60L*60L) /* seconds per hour */
|
|
||||||
|
|
||||||
/* Set the following to your personal preferences for the
|
|
||||||
* time and contents of warnings.
|
|
||||||
*/
|
|
||||||
#define INTERVALS 13 /* size of intervals[] */
|
|
||||||
#define WARNINGS 4 /* size of warnings[] */
|
|
||||||
|
|
||||||
|
|
||||||
static char *Version = "@(#) LEAVE 1.4 (01/09/90)";
|
|
||||||
static int intervals[INTERVALS] = {
|
|
||||||
-5 * MIN,
|
|
||||||
-1 * MIN,
|
|
||||||
0,
|
|
||||||
MIN,
|
|
||||||
2 * MIN,
|
|
||||||
3 * MIN,
|
|
||||||
4 * MIN,
|
|
||||||
5 * MIN,
|
|
||||||
6 * MIN,
|
|
||||||
7 * MIN,
|
|
||||||
8 * MIN,
|
|
||||||
9 * MIN,
|
|
||||||
10 * MIN
|
|
||||||
};
|
|
||||||
static char *warnings[WARNINGS] = {
|
|
||||||
"You have to leave within 5 minutes",
|
|
||||||
"Just one more minute!",
|
|
||||||
"Time to leave!",
|
|
||||||
"You're going to be late!" /* for all subsequent warnings */
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
_PROTOTYPE(int main, (int argc, char **argv));
|
|
||||||
_PROTOTYPE(void Usage, (void));
|
|
||||||
_PROTOTYPE(void Get_Hour_Min, (char *when, int *hour, int *min));
|
|
||||||
_PROTOTYPE(int Still_Logged_On, (char *user, char *tty));
|
|
||||||
|
|
||||||
void Usage()
|
|
||||||
{
|
|
||||||
fprintf(stderr, "Usage: leave [[+]hh[:]mm]\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void Get_Hour_Min(when, hour, min)
|
|
||||||
char *when;
|
|
||||||
int *hour;
|
|
||||||
int *min;
|
|
||||||
{
|
|
||||||
int hour_min;
|
|
||||||
int just_min = 0;
|
|
||||||
|
|
||||||
switch (sscanf(when, "%d:%d", &hour_min, &just_min)) {
|
|
||||||
case 1:
|
|
||||||
*hour = hour_min / 100;
|
|
||||||
*min = hour_min % 100;
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
*hour = hour_min;
|
|
||||||
*min = just_min;
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
Usage();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (hour_min < 0 || just_min < 0 || *min > 59) Usage();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int Still_Logged_On(user, tty)
|
|
||||||
char *user;
|
|
||||||
char *tty;
|
|
||||||
{
|
|
||||||
FILE *f;
|
|
||||||
struct utmp login;
|
|
||||||
|
|
||||||
if ((f = fopen(UTMP, "r")) == NULL)
|
|
||||||
/* no login/logout records kept */
|
|
||||||
return(1);
|
|
||||||
|
|
||||||
while (fread(&login, sizeof(struct utmp), (size_t)1, f) == 1) {
|
|
||||||
if (!strncmp(login.ut_line, tty, (size_t)8))
|
|
||||||
if (!strncmp(login.ut_name, user, (size_t)8)) {
|
|
||||||
fclose(f);
|
|
||||||
return(1);
|
|
||||||
} else {
|
|
||||||
fclose(f);
|
|
||||||
return(0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fclose(f);
|
|
||||||
return(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
int main(argc, argv)
|
|
||||||
int argc;
|
|
||||||
char *argv[];
|
|
||||||
{
|
|
||||||
char when[STRING];
|
|
||||||
time_t now = time((time_t *)0);
|
|
||||||
time_t leave, delta;
|
|
||||||
struct tm *tm;
|
|
||||||
int hour, min;
|
|
||||||
int pid, i;
|
|
||||||
char *user = cuserid( (char *)NULL);
|
|
||||||
char *tty = ttyname(0) + 5;
|
|
||||||
|
|
||||||
/* get the argument string "when" either from stdin, or argv */
|
|
||||||
if (argc <= 1) {
|
|
||||||
printf("When do you have to leave? ");
|
|
||||||
fflush(stdout);
|
|
||||||
if (fgets(when, STRING, stdin) == NULL || when[0] == '\n') exit(0);
|
|
||||||
} else {
|
|
||||||
strcpy(when, argv[1]);
|
|
||||||
if (argc > 2) strcat(when, argv[2]);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* determine the leave time from the current time and "when" */
|
|
||||||
tm = localtime(&now);
|
|
||||||
if (when[0] == '+') {
|
|
||||||
Get_Hour_Min(&when[1], &hour, &min);
|
|
||||||
tm->tm_hour += hour;
|
|
||||||
tm->tm_min += min;
|
|
||||||
leave = mktime(tm);
|
|
||||||
} else {
|
|
||||||
/* user entered an absolute time */
|
|
||||||
Get_Hour_Min(&when[0], &hour, &min);
|
|
||||||
tm->tm_hour = hour;
|
|
||||||
tm->tm_min = min;
|
|
||||||
leave = mktime(tm);
|
|
||||||
if (leave < now) {
|
|
||||||
printf("That time has already passed!\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
printf("Alarm set for %s", ctime(&leave));
|
|
||||||
|
|
||||||
if ((pid = fork()) == -1) {
|
|
||||||
fprintf(stderr, "leave: can not fork\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
if (pid != 0) exit(0);
|
|
||||||
|
|
||||||
/* only the child continues on */
|
|
||||||
if (user == NULL || tty == NULL) {
|
|
||||||
fprintf(stderr, "leave: Can not determine user and terminal name\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
signal(SIGINT, SIG_IGN);
|
|
||||||
signal(SIGQUIT, SIG_IGN);
|
|
||||||
signal(SIGTERM, SIG_IGN);
|
|
||||||
|
|
||||||
for (;;) {
|
|
||||||
if (!Still_Logged_On(user, tty)) exit(0);
|
|
||||||
|
|
||||||
/* how much longer until the leave time? */
|
|
||||||
/* XXX - use difftime all over. */
|
|
||||||
delta = leave - time((time_t *)0);
|
|
||||||
|
|
||||||
/* which interval are we currently in? */
|
|
||||||
for (i = 0; i < INTERVALS; ++i)
|
|
||||||
if (delta + intervals[i] > 0) break;
|
|
||||||
|
|
||||||
/* if we are within intervals[0] then print a warning If
|
|
||||||
* there are more intervals than messages, then use/
|
|
||||||
* warnings[WARNINGS-1] for all subsequent messages. */
|
|
||||||
if (i > 0)
|
|
||||||
printf("\007\r%s\r\n",
|
|
||||||
warnings[i > WARNINGS ? WARNINGS - 1 : i - 1]);
|
|
||||||
|
|
||||||
if (i == INTERVALS) {
|
|
||||||
printf("That was the last time I'll tell you. Bye.\r\n");
|
|
||||||
exit(0);
|
|
||||||
}
|
|
||||||
/* Sleep until the next interval. For long periods, wake up
|
|
||||||
* every hour to check if the user is still on (also required
|
|
||||||
* because 16 bit ints don't allow long waits). */
|
|
||||||
sleep((unsigned) Min(delta + intervals[i], HOUR));
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,4 +0,0 @@
|
||||||
PROG= modem
|
|
||||||
MAN=
|
|
||||||
|
|
||||||
.include <bsd.prog.mk>
|
|
|
@ -1,253 +0,0 @@
|
||||||
/* modem - Put modem into DIALIN or DIALOUT mode. Author: F. van Kempen */
|
|
||||||
|
|
||||||
/* Exit: 0 OK, suspended/restarted GETTY
|
|
||||||
* 1 UNIX error
|
|
||||||
* 2 Process busy
|
|
||||||
* Version: 1.3 12/30/89
|
|
||||||
*
|
|
||||||
* Author: F. van Kempen, MicroWalt Corporation
|
|
||||||
*
|
|
||||||
* All fancy stuff removed, see getty.c. Kees J. Bot.
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <sys/wait.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <signal.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <utmp.h>
|
|
||||||
#include <errno.h>
|
|
||||||
|
|
||||||
#include <paths.h>
|
|
||||||
|
|
||||||
char PATH_UTMP[] = _PATH_UTMP; /* current logins */
|
|
||||||
|
|
||||||
_PROTOTYPE(void usage , (void));
|
|
||||||
_PROTOTYPE(int main , (int argc , char *argv []));
|
|
||||||
_PROTOTYPE(void sendcodes , (char *tty, char *codes));
|
|
||||||
|
|
||||||
|
|
||||||
void usage()
|
|
||||||
{
|
|
||||||
fprintf(stderr,
|
|
||||||
"Usage: modem [-sio] [-I in-codes] [-O out-codes] line [command args ...]\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
main(argc, argv)
|
|
||||||
int argc;
|
|
||||||
char *argv[];
|
|
||||||
{
|
|
||||||
struct utmp entry;
|
|
||||||
char devtty[1024], *tty;
|
|
||||||
char **command;
|
|
||||||
int ex_code = 0;
|
|
||||||
int fd, i, slot, getty;
|
|
||||||
struct stat st;
|
|
||||||
enum { TOGGLE, DIALIN, DIALOUT } mode= TOGGLE;
|
|
||||||
int silent = 0;
|
|
||||||
_PROTOTYPE(void (*hsig), (int));
|
|
||||||
_PROTOTYPE(void (*isig), (int));
|
|
||||||
_PROTOTYPE(void (*qsig), (int));
|
|
||||||
_PROTOTYPE(void (*tsig), (int));
|
|
||||||
pid_t pid;
|
|
||||||
int r, status;
|
|
||||||
uid_t uid = getuid();
|
|
||||||
gid_t gid = getgid();
|
|
||||||
char *in_codes, *out_codes;
|
|
||||||
|
|
||||||
i = 1;
|
|
||||||
while (i < argc && argv[i][0] == '-') {
|
|
||||||
char *opt = argv[i++] + 1;
|
|
||||||
|
|
||||||
if (opt[0] == '-' && opt[1] == 0) break;
|
|
||||||
|
|
||||||
while (*opt != 0) {
|
|
||||||
switch (*opt++) {
|
|
||||||
case 's': /* silent mode */
|
|
||||||
silent = 1;
|
|
||||||
break;
|
|
||||||
case 'i': /* DIAL-IN mode: suspend GETTY */
|
|
||||||
mode = DIALIN;
|
|
||||||
break;
|
|
||||||
case 'o': /* DIAL-OUT mode: restart GETTY */
|
|
||||||
mode = DIALOUT;
|
|
||||||
break;
|
|
||||||
case 'I': /* code to switch modem to dial-in */
|
|
||||||
if (*opt == 0) {
|
|
||||||
if (i == argc) usage();
|
|
||||||
opt = argv[i++];
|
|
||||||
}
|
|
||||||
in_codes = opt;
|
|
||||||
opt = "";
|
|
||||||
break;
|
|
||||||
case 'O': /* code to switch modem to dial-out */
|
|
||||||
if (*opt == 0) {
|
|
||||||
if (i == argc) usage();
|
|
||||||
opt = argv[i++];
|
|
||||||
}
|
|
||||||
out_codes = opt;
|
|
||||||
opt = "";
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
usage();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (i == argc) usage();
|
|
||||||
tty = argv[i++]; /* Modem line */
|
|
||||||
|
|
||||||
if (mode != TOGGLE && i != argc) usage();
|
|
||||||
command = argv + i; /* Command to execute (if any). */
|
|
||||||
|
|
||||||
if (strchr(tty, '/') == NULL) {
|
|
||||||
strcpy(devtty, "/dev/");
|
|
||||||
strncat(devtty, tty, 1024 - 6);
|
|
||||||
tty = devtty;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (stat(tty, &st) < 0) {
|
|
||||||
fprintf(stderr, "modem: %s: %s\n", tty, strerror(errno));
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!S_ISCHR(st.st_mode)) {
|
|
||||||
fprintf(stderr, "%s is not a tty\n", tty);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Find the utmp slot number for the line. */
|
|
||||||
if ((fd= open(tty, O_RDONLY)) < 0 || (slot= fttyslot(fd)) == 0) {
|
|
||||||
fprintf(stderr, "modem: %s: %s\n", tty, strerror(errno));
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
close(fd);
|
|
||||||
|
|
||||||
/* Read the UTMP file to find out the PID and STATUS of the GETTY. */
|
|
||||||
entry.ut_type= 0;
|
|
||||||
if ((fd = open(PATH_UTMP, O_RDONLY)) < 0
|
|
||||||
|| lseek(fd, (off_t) slot * sizeof(entry), SEEK_SET) < 0
|
|
||||||
|| read(fd, &entry, sizeof(entry)) < 0
|
|
||||||
) {
|
|
||||||
fprintf(stderr, "modem: cannot read UTMP !\n");
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
close(fd);
|
|
||||||
|
|
||||||
hsig= signal(SIGHUP, SIG_IGN);
|
|
||||||
isig= signal(SIGINT, SIG_IGN);
|
|
||||||
qsig= signal(SIGQUIT, SIG_IGN);
|
|
||||||
tsig= signal(SIGTERM, SIG_IGN);
|
|
||||||
|
|
||||||
/* Process the terminal entry if we got one. */
|
|
||||||
switch (entry.ut_type) {
|
|
||||||
case LOGIN_PROCESS: /* getty waiting for a call */
|
|
||||||
getty = 1;
|
|
||||||
break;
|
|
||||||
case USER_PROCESS: /* login or user-shell */
|
|
||||||
if (!silent) fprintf(stderr, "modem: line is busy.\n");
|
|
||||||
exit(2);
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
getty = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = (mode == TOGGLE) ? 0 : 1; i < 2; i++) {
|
|
||||||
/* Now perform the desired action (DIALIN or DIALOUT). */
|
|
||||||
switch (mode) {
|
|
||||||
case DIALOUT:
|
|
||||||
case TOGGLE:
|
|
||||||
if (getty) kill(entry.ut_pid, SIGUSR1); /* suspend getty */
|
|
||||||
chown(tty, uid, st.st_gid); /* give line to user */
|
|
||||||
chmod(tty, 0600);
|
|
||||||
if (out_codes != NULL) sendcodes(tty, out_codes);
|
|
||||||
if (!silent) printf("modem on %s set for dialout.\n", tty);
|
|
||||||
break;
|
|
||||||
case DIALIN:
|
|
||||||
if (in_codes != NULL) sendcodes(tty, in_codes);
|
|
||||||
chown(tty, 0, st.st_gid); /* revoke access */
|
|
||||||
chmod(tty, 0600);
|
|
||||||
if (getty) kill(entry.ut_pid, SIGUSR2); /* restart getty */
|
|
||||||
if (!silent) printf("modem on %s set for dialin.\n", tty);
|
|
||||||
}
|
|
||||||
if (mode == TOGGLE) {
|
|
||||||
/* Start the command to run */
|
|
||||||
pid_t pid;
|
|
||||||
int status;
|
|
||||||
|
|
||||||
switch ((pid = fork())) {
|
|
||||||
case -1:
|
|
||||||
fprintf(stderr, "modem: fork(): %s\n", strerror(errno));
|
|
||||||
ex_code= 1;
|
|
||||||
break;
|
|
||||||
case 0:
|
|
||||||
setgid(gid);
|
|
||||||
setuid(uid);
|
|
||||||
(void) signal(SIGHUP, hsig);
|
|
||||||
(void) signal(SIGINT, isig);
|
|
||||||
(void) signal(SIGQUIT, qsig);
|
|
||||||
(void) signal(SIGTERM, tsig);
|
|
||||||
execvp(command[0], command);
|
|
||||||
fprintf(stderr, "modem: %s: %s\n",
|
|
||||||
command[0], strerror(errno));
|
|
||||||
_exit(127);
|
|
||||||
default:
|
|
||||||
while ((r= wait(&status)) != pid) {
|
|
||||||
if (r == -1 && errno != EINTR) break;
|
|
||||||
}
|
|
||||||
if (r == -1 || status != 0) ex_code = 1;
|
|
||||||
}
|
|
||||||
mode = DIALIN;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
exit(ex_code);
|
|
||||||
}
|
|
||||||
|
|
||||||
void sendcodes(tty, codes)
|
|
||||||
char *tty, *codes;
|
|
||||||
{
|
|
||||||
int fd;
|
|
||||||
int c;
|
|
||||||
char buf[1024], *bp = buf;
|
|
||||||
|
|
||||||
if ((fd = open(tty, O_RDWR|O_NONBLOCK)) < 0) {
|
|
||||||
fprintf(stderr, "modem: can't send codes to %s: %s\n",
|
|
||||||
tty, strerror(errno));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
while ((c = *codes++) != 0) {
|
|
||||||
fprintf(stderr, "%d\n", __LINE__);
|
|
||||||
if (c == '\\') {
|
|
||||||
if ((c = *codes++) == 0) break;
|
|
||||||
if (c == 'r') c= '\r';
|
|
||||||
if (c == 'n') c= '\n';
|
|
||||||
}
|
|
||||||
*bp++ = c;
|
|
||||||
if (bp == buf + sizeof(buf) || c == '\r' || c == '\n') {
|
|
||||||
fprintf(stderr, "%d\n", __LINE__);
|
|
||||||
write(fd, buf, bp - buf);
|
|
||||||
fprintf(stderr, "%d\n", __LINE__);
|
|
||||||
do {sleep(1);
|
|
||||||
fprintf(stderr, "%d\n", __LINE__);
|
|
||||||
fprintf(stderr, "%d\n", read(fd, buf, sizeof(buf)));
|
|
||||||
}while (read(fd, buf, sizeof(buf)) > 0);
|
|
||||||
fprintf(stderr, "%d\n", __LINE__);
|
|
||||||
bp = buf;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (bp > buf) {
|
|
||||||
fprintf(stderr, "%d\n", __LINE__);
|
|
||||||
write(fd, buf, bp - buf);
|
|
||||||
fprintf(stderr, "%d\n", __LINE__);
|
|
||||||
do sleep(1); while (read(fd, buf, sizeof(buf)) > 0);
|
|
||||||
fprintf(stderr, "%d\n", __LINE__);
|
|
||||||
}
|
|
||||||
close(fd);
|
|
||||||
}
|
|
|
@ -1,7 +0,0 @@
|
||||||
# Makefile for rlogind.
|
|
||||||
|
|
||||||
PROG= in.rlogind
|
|
||||||
SRCS= rlogind.c setup.c
|
|
||||||
MAN=
|
|
||||||
|
|
||||||
.include <bsd.prog.mk>
|
|
|
@ -1,455 +0,0 @@
|
||||||
/*
|
|
||||||
rlogind.c
|
|
||||||
|
|
||||||
Created: by Philip Homburg <philip@cs.vu.nl>
|
|
||||||
Log: Utmp improvement by Kees Bot <kjb@cs.vu.nl>
|
|
||||||
Split to compile easier on i86 by kjb
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/stat.h>
|
|
||||||
#include <sys/ioctl.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <signal.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <termios.h>
|
|
||||||
#include <time.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <utmp.h>
|
|
||||||
#include <net/hton.h>
|
|
||||||
#define EXTERN
|
|
||||||
#include "rlogind.h"
|
|
||||||
|
|
||||||
char pty_str[]= "/dev/ptyXX";
|
|
||||||
char tty_str[]= "/dev/ttyXX";
|
|
||||||
char hex_str[16]= "0123456789abcdef";
|
|
||||||
|
|
||||||
char PATH_UTMP[] = "/etc/utmp"; /* current logins */
|
|
||||||
char PATH_WTMP[] = "/usr/adm/wtmp"; /* login/logout history */
|
|
||||||
|
|
||||||
char term[64]= "TERM=";
|
|
||||||
#define ENVSIZE (sizeof("TERM=")-1) /* skip null for concatenation. */
|
|
||||||
int confirmed= 0;
|
|
||||||
char *env[2];
|
|
||||||
char *args[10];
|
|
||||||
|
|
||||||
static void do_child(int tty_fd, char *tty_str);
|
|
||||||
static void dealloc_term(int slot, char *tty_str, int pid);
|
|
||||||
static void wtmp(char *user, char *id, char *line, int pid, int type, int slot);
|
|
||||||
static void setup_term(int fd);
|
|
||||||
static speed_t num2speed(int num);
|
|
||||||
static int do_control(char *buf, int cnt);
|
|
||||||
static void readall(char *buf, int cnt);
|
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
|
||||||
{
|
|
||||||
int error;
|
|
||||||
int i, j= 0;
|
|
||||||
int tty_fd, pty_fd;
|
|
||||||
int login_pid, write_pid;
|
|
||||||
int count, bytes, tmp_count;
|
|
||||||
char *lp= 0, *cp;
|
|
||||||
struct stat struct_stat;
|
|
||||||
int slot;
|
|
||||||
|
|
||||||
prog_name= argv[0];
|
|
||||||
|
|
||||||
/* Check if the remote user is allowed in. */
|
|
||||||
authenticate();
|
|
||||||
|
|
||||||
write(1, "", 1); /* Send the '\0' */
|
|
||||||
confirmed= 1;
|
|
||||||
|
|
||||||
/* We try to convince the other side not the do ^S/^Q, the rlogin
|
|
||||||
* protocol indicates the we only send this when XOFF is turned off
|
|
||||||
* but we don't know when this happens so we tell the other side that
|
|
||||||
* it is turned off.
|
|
||||||
*/
|
|
||||||
tcp_urg(1, 1);
|
|
||||||
|
|
||||||
write(1, "\220", 1);
|
|
||||||
|
|
||||||
tcp_urg(1, 0);
|
|
||||||
|
|
||||||
/* Let's look for a pty. */
|
|
||||||
pty_fd= -1;
|
|
||||||
for (i= 'p'; i <= 'z'; i++)
|
|
||||||
{
|
|
||||||
pty_str[sizeof(pty_str)-3]= i;
|
|
||||||
pty_str[sizeof(pty_str)-2]= '0';
|
|
||||||
error= stat(pty_str, &struct_stat);
|
|
||||||
if (error == -1)
|
|
||||||
continue;
|
|
||||||
for (j= 0; j < 16; j++)
|
|
||||||
{
|
|
||||||
pty_str[sizeof(pty_str)-2]= hex_str[j];
|
|
||||||
pty_fd= open(pty_str, O_RDWR);
|
|
||||||
if (pty_fd != -1)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (pty_fd != -1)
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (pty_fd == -1)
|
|
||||||
{
|
|
||||||
printf("%s: out of ptys\r\n", prog_name);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
tty_str[sizeof(pty_str)-3]= i;
|
|
||||||
tty_str[sizeof(pty_str)-2]= hex_str[j];
|
|
||||||
|
|
||||||
tty_fd= open(tty_str, O_RDWR);
|
|
||||||
if (tty_fd == -1)
|
|
||||||
{
|
|
||||||
printf("%s: unable to open '%s': %s\r\n", prog_name, tty_str,
|
|
||||||
strerror(errno));
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
slot= fttyslot(tty_fd);
|
|
||||||
|
|
||||||
login_pid= fork();
|
|
||||||
if (login_pid == -1)
|
|
||||||
{
|
|
||||||
printf("%s: unable to fork: %s\r\n", prog_name,
|
|
||||||
strerror(errno));
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
if (login_pid == 0)
|
|
||||||
{
|
|
||||||
close(pty_fd);
|
|
||||||
wtmp("", "", tty_str, login_pid, LOGIN_PROCESS, slot);
|
|
||||||
do_child(tty_fd, tty_str);
|
|
||||||
}
|
|
||||||
close(tty_fd);
|
|
||||||
|
|
||||||
write_pid= fork();
|
|
||||||
if (write_pid == -1)
|
|
||||||
{
|
|
||||||
printf("%s: unable to fork: %s\r\n", prog_name,
|
|
||||||
strerror(errno));
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
if (write_pid == 0)
|
|
||||||
{
|
|
||||||
dup2(pty_fd, 0);
|
|
||||||
count= 0;
|
|
||||||
for (;;)
|
|
||||||
{
|
|
||||||
if (!count)
|
|
||||||
{
|
|
||||||
count= read(0, line, sizeof(line));
|
|
||||||
if (count <= 0)
|
|
||||||
break;
|
|
||||||
lp= line;
|
|
||||||
}
|
|
||||||
bytes= write(1, lp, count);
|
|
||||||
if (bytes <= 0 || bytes > count)
|
|
||||||
break;
|
|
||||||
lp += bytes;
|
|
||||||
count -= bytes;
|
|
||||||
}
|
|
||||||
kill(getppid(), SIGKILL);
|
|
||||||
dealloc_term(slot, tty_str, login_pid);
|
|
||||||
_exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
dup2(pty_fd, 1);
|
|
||||||
count= 0;
|
|
||||||
for (;;)
|
|
||||||
{
|
|
||||||
if (!count)
|
|
||||||
{
|
|
||||||
count= read(0, line, sizeof(line));
|
|
||||||
if (count <= 0)
|
|
||||||
break;
|
|
||||||
lp= line;
|
|
||||||
}
|
|
||||||
tmp_count= count;
|
|
||||||
cp= memchr(lp, 255, count);
|
|
||||||
if (cp)
|
|
||||||
{
|
|
||||||
tmp_count= cp-lp;
|
|
||||||
if (tmp_count == 0)
|
|
||||||
{
|
|
||||||
tmp_count= do_control(lp, count);
|
|
||||||
if (tmp_count)
|
|
||||||
{
|
|
||||||
lp += tmp_count;
|
|
||||||
count -= tmp_count;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
bytes= write(1, lp, tmp_count);
|
|
||||||
if (bytes <= 0 || bytes > count)
|
|
||||||
break;
|
|
||||||
lp += bytes;
|
|
||||||
count -= bytes;
|
|
||||||
}
|
|
||||||
kill(write_pid, SIGKILL);
|
|
||||||
dealloc_term(slot, tty_str, login_pid);
|
|
||||||
return(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void do_child(int tty_fd, char *tty_str)
|
|
||||||
{
|
|
||||||
int ctty_fd, tst_fd;
|
|
||||||
FILE *tty_file;
|
|
||||||
int sav_errno;
|
|
||||||
char **argp;
|
|
||||||
|
|
||||||
/* Set up the terminal attributes. */
|
|
||||||
setup_term(tty_fd);
|
|
||||||
|
|
||||||
/* Let's start the new session. */
|
|
||||||
setsid();
|
|
||||||
ctty_fd= open(tty_str, O_RDWR);
|
|
||||||
if (ctty_fd == -1)
|
|
||||||
{
|
|
||||||
printf("%s(do_child): unable to open '%s': %s\r\n",
|
|
||||||
prog_name, tty_str, strerror(errno));
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
/* Test if we really got a controlling tty. */
|
|
||||||
tst_fd= open("/dev/tty", O_RDWR);
|
|
||||||
if (tst_fd == -1)
|
|
||||||
{
|
|
||||||
printf(
|
|
||||||
"%s(do_child): '%s' didn't result in a controlling tty (%s)\r\n",
|
|
||||||
prog_name, tty_str, strerror(errno));
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
argp= args;
|
|
||||||
*argp++= "login";
|
|
||||||
*argp++= "-p";
|
|
||||||
*argp++= "-h";
|
|
||||||
*argp++= hostname;
|
|
||||||
if (authenticated)
|
|
||||||
*argp++= "-f";
|
|
||||||
if (lusername[0] != '\0')
|
|
||||||
*argp++= lusername;
|
|
||||||
|
|
||||||
/* We reached the point of no return. */
|
|
||||||
close(tst_fd);
|
|
||||||
close(tty_fd);
|
|
||||||
|
|
||||||
if (ctty_fd != 0)
|
|
||||||
{
|
|
||||||
dup2(ctty_fd, 0);
|
|
||||||
close(ctty_fd);
|
|
||||||
ctty_fd= 0;
|
|
||||||
}
|
|
||||||
dup2(ctty_fd, 1);
|
|
||||||
#if DEBUG
|
|
||||||
fprintf(stderr, "execing login\r\n");
|
|
||||||
#endif
|
|
||||||
dup2(ctty_fd, 2);
|
|
||||||
execve("/bin/login", args, env);
|
|
||||||
if (errno == ENOENT) execve("/usr/bin/login", args, env);
|
|
||||||
sav_errno= errno;
|
|
||||||
tty_file= fdopen(2, "w");
|
|
||||||
if (tty_file)
|
|
||||||
{
|
|
||||||
fprintf(tty_file, "%s(do_child): unable to exec login: %s\r\n",
|
|
||||||
prog_name, strerror(sav_errno));
|
|
||||||
fflush(tty_file);
|
|
||||||
}
|
|
||||||
_exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void dealloc_term(int slot, char *tty_str, int pid)
|
|
||||||
{
|
|
||||||
wtmp("", "", tty_str, pid, DEAD_PROCESS, slot);
|
|
||||||
|
|
||||||
/* Finally we reset the owner and mode of the terminal. */
|
|
||||||
chown(tty_str, 0, 0);
|
|
||||||
chmod(tty_str, 0666);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void wtmp(
|
|
||||||
char *user, /* name of user */
|
|
||||||
char *id, /* inittab ID */
|
|
||||||
char *line, /* TTY name */
|
|
||||||
int pid, /* PID of process */
|
|
||||||
int type, /* TYPE of entry */
|
|
||||||
int slot) /* slot number in UTMP */
|
|
||||||
{
|
|
||||||
/* Log an event into the UTMP and WTMP files. */
|
|
||||||
|
|
||||||
struct utmp utmp; /* UTMP/WTMP User Accounting */
|
|
||||||
int fd= -1;
|
|
||||||
int log = 1; /* log in wtmp */
|
|
||||||
char *p;
|
|
||||||
|
|
||||||
/* Strip the /dev part of the TTY name. */
|
|
||||||
p = strrchr(line, '/');
|
|
||||||
if (p != 0)
|
|
||||||
line= p+1;
|
|
||||||
|
|
||||||
if (type == DEAD_PROCESS) {
|
|
||||||
/* Don't add a logout entry for just a dying login. */
|
|
||||||
if ((fd = open(PATH_UTMP, O_RDONLY)) < 0) return;
|
|
||||||
if (lseek(fd, (off_t) slot * sizeof(utmp), SEEK_SET) != -1
|
|
||||||
&& read(fd, (void *) &utmp, sizeof(utmp)) == sizeof(utmp))
|
|
||||||
{
|
|
||||||
if (utmp.ut_type != INIT_PROCESS
|
|
||||||
&& utmp.ut_type != USER_PROCESS)
|
|
||||||
log= 0;
|
|
||||||
}
|
|
||||||
close(fd);
|
|
||||||
}
|
|
||||||
if (type == LOGIN_PROCESS) log= 0; /* and don't log this one */
|
|
||||||
|
|
||||||
/* Clear the utmp record. */
|
|
||||||
memset((void *) &utmp, 0, sizeof(utmp));
|
|
||||||
|
|
||||||
/* Enter new values. */
|
|
||||||
strncpy(utmp.ut_name, user, sizeof(utmp.ut_name));
|
|
||||||
strncpy(utmp.ut_id, id, sizeof(utmp.ut_id));
|
|
||||||
strncpy(utmp.ut_line, line, sizeof(utmp.ut_line));
|
|
||||||
strncpy(utmp.ut_host, hostname, sizeof(utmp.ut_host));
|
|
||||||
utmp.ut_pid = pid;
|
|
||||||
utmp.ut_type = type;
|
|
||||||
utmp.ut_time = time((time_t *)0);
|
|
||||||
|
|
||||||
if (log) {
|
|
||||||
if ((fd = open(PATH_WTMP, O_WRONLY | O_APPEND)) < 0) return;
|
|
||||||
write(fd, (char *) &utmp, sizeof(struct utmp));
|
|
||||||
close(fd);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* write entry to utmp */
|
|
||||||
if ((fd = open(PATH_UTMP, O_WRONLY)) < 0) return;
|
|
||||||
if (lseek(fd, (off_t) slot * sizeof(utmp), SEEK_SET) != -1)
|
|
||||||
write(fd, (char *) &utmp, sizeof(struct utmp));
|
|
||||||
close(fd);
|
|
||||||
}
|
|
||||||
|
|
||||||
void fatal(int fd, char *msg, int err)
|
|
||||||
{
|
|
||||||
int len;
|
|
||||||
char buf[80], *bp;
|
|
||||||
|
|
||||||
bp= buf;
|
|
||||||
if (!confirmed)
|
|
||||||
*bp++= '\1';
|
|
||||||
if (err)
|
|
||||||
len= sprintf(bp, "rlogind: %s: %s.\r\n", msg, strerror(err));
|
|
||||||
else
|
|
||||||
len= sprintf(bp, "rlogind: %s.\r\n", msg);
|
|
||||||
write(fd, buf, bp+len-buf);
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void setup_term(int fd)
|
|
||||||
{
|
|
||||||
char *cp, *speed;
|
|
||||||
struct termios tt;
|
|
||||||
speed_t spd;
|
|
||||||
int num;
|
|
||||||
char *check;
|
|
||||||
|
|
||||||
cp= strchr(term, '/');
|
|
||||||
if (cp)
|
|
||||||
{
|
|
||||||
tcgetattr(fd, &tt);
|
|
||||||
*cp++= '\0';
|
|
||||||
speed= cp;
|
|
||||||
cp= strchr(speed, '/');
|
|
||||||
if (cp)
|
|
||||||
*cp++= '\0';
|
|
||||||
num= strtol(speed, &check, 0);
|
|
||||||
spd= num2speed(num);
|
|
||||||
if (spd != B0 && check[0] == '\0')
|
|
||||||
{
|
|
||||||
cfsetospeed(&tt, spd);
|
|
||||||
cfsetispeed(&tt, spd);
|
|
||||||
}
|
|
||||||
tcsetattr(fd, TCSANOW, &tt);
|
|
||||||
}
|
|
||||||
env[0]= term;
|
|
||||||
env[1]= 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static speed_t num2speed(int num)
|
|
||||||
{
|
|
||||||
static struct
|
|
||||||
{
|
|
||||||
int num;
|
|
||||||
speed_t value;
|
|
||||||
} speed_table[]=
|
|
||||||
{
|
|
||||||
{ 0, B0, }, { 50, B50, }, { 75, B75, }, { 110, B110, },
|
|
||||||
{ 134, B134, }, { 150, B150, }, { 200, B200, }, { 300, B300, },
|
|
||||||
{ 600, B600, }, { 1200, B1200, }, { 1800, B1800, },
|
|
||||||
{ 2400, B2400, }, { 4800, B4800, }, { 9600, B9600, },
|
|
||||||
{ 19200, B19200, }, { 38400, B38400, },
|
|
||||||
{ -1, -1 },
|
|
||||||
};
|
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i= 0; speed_table[i].num != -1; i++)
|
|
||||||
{
|
|
||||||
if (speed_table[i].num == num)
|
|
||||||
return (speed_table[i].value);
|
|
||||||
}
|
|
||||||
return B0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int do_control(char *cp, int cnt)
|
|
||||||
{
|
|
||||||
char buf[20];
|
|
||||||
struct winsize winsize;
|
|
||||||
|
|
||||||
if (cnt > sizeof(buf))
|
|
||||||
cnt= sizeof(buf);
|
|
||||||
|
|
||||||
memcpy(buf, cp, cnt);
|
|
||||||
|
|
||||||
/* Let's fetch the first 2 bytes. */
|
|
||||||
if (cnt < 2)
|
|
||||||
readall(buf+cnt, 2-cnt);
|
|
||||||
if ((unsigned char)buf[1] != 255)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
/* Let's fetch the first 4 bytes. */
|
|
||||||
if (cnt < 4)
|
|
||||||
readall(buf+cnt, 4-cnt);
|
|
||||||
if (buf[2] != 's' || buf[3] != 's')
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
/* Let's fetch a winsize structure. */
|
|
||||||
if (cnt < 4 + sizeof(winsize))
|
|
||||||
readall(buf+cnt, 4 + sizeof(winsize) - cnt);
|
|
||||||
|
|
||||||
memcpy(&winsize, buf+4, sizeof(winsize));
|
|
||||||
winsize.ws_row= ntohs(winsize.ws_row);
|
|
||||||
winsize.ws_col= ntohs(winsize.ws_col);
|
|
||||||
winsize.ws_xpixel= ntohs(winsize.ws_xpixel);
|
|
||||||
winsize.ws_ypixel= ntohs(winsize.ws_ypixel);
|
|
||||||
#if DEBUG
|
|
||||||
fprintf(stderr, "setting window size to %d, %d\r\n", winsize.ws_row,
|
|
||||||
winsize.ws_col);
|
|
||||||
#endif
|
|
||||||
ioctl(1, TIOCSWINSZ, &winsize);
|
|
||||||
return 4 + sizeof(winsize);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void readall(char *buf, int cnt)
|
|
||||||
{
|
|
||||||
int res;
|
|
||||||
|
|
||||||
while(cnt)
|
|
||||||
{
|
|
||||||
res= read(0, buf, cnt);
|
|
||||||
if (res <= 0)
|
|
||||||
return;
|
|
||||||
buf += cnt;
|
|
||||||
cnt -= res;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,24 +0,0 @@
|
||||||
/*
|
|
||||||
in.rld.h
|
|
||||||
*/
|
|
||||||
|
|
||||||
#define NMAX 30
|
|
||||||
|
|
||||||
#ifndef EXTERN
|
|
||||||
#define EXTERN extern
|
|
||||||
#endif
|
|
||||||
|
|
||||||
EXTERN char *prog_name;
|
|
||||||
EXTERN char hostname[256+1];
|
|
||||||
EXTERN char line[1024];
|
|
||||||
EXTERN char lusername[NMAX+1], rusername[NMAX+1];
|
|
||||||
EXTERN char term[64];
|
|
||||||
EXTERN int authenticated;
|
|
||||||
|
|
||||||
/* in.rld.c: */
|
|
||||||
void fatal(int fd, char *msg, int err);
|
|
||||||
|
|
||||||
/* setup.c: */
|
|
||||||
void authenticate(void);
|
|
||||||
int do_rlogin(void);
|
|
||||||
void tcp_urg(int fd, int on);
|
|
|
@ -1,92 +0,0 @@
|
||||||
/*
|
|
||||||
setup.c
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <sys/ioctl.h>
|
|
||||||
#include <errno.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <net/netlib.h>
|
|
||||||
#include <net/gen/in.h>
|
|
||||||
#include <net/gen/inet.h>
|
|
||||||
#include <net/gen/tcp.h>
|
|
||||||
#include <net/gen/tcp_io.h>
|
|
||||||
#include <net/gen/netdb.h>
|
|
||||||
#include <net/gen/socket.h>
|
|
||||||
#include "rlogind.h"
|
|
||||||
|
|
||||||
static void getstr(char *buf, int cnt, char *errmsg);
|
|
||||||
|
|
||||||
void authenticate(void)
|
|
||||||
{
|
|
||||||
int result;
|
|
||||||
struct nwio_tcpconf tcpconf;
|
|
||||||
struct hostent *hostent;
|
|
||||||
char c;
|
|
||||||
|
|
||||||
/* Let's lookup the hostname for the connection. */
|
|
||||||
result= ioctl (0, NWIOGTCPCONF, &tcpconf);
|
|
||||||
if (result<0)
|
|
||||||
{
|
|
||||||
fprintf(stderr, "%s: ioctl(NWIOTCPCONF): %s\r\n",
|
|
||||||
prog_name, strerror(errno));
|
|
||||||
exit(1);
|
|
||||||
}
|
|
||||||
hostent= gethostbyaddr((char *)&tcpconf.nwtc_remaddr,
|
|
||||||
sizeof(tcpconf.nwtc_remaddr), AF_INET);
|
|
||||||
if (hostent)
|
|
||||||
{
|
|
||||||
strncpy(hostname, hostent->h_name, sizeof(hostname)-1);
|
|
||||||
hostname[sizeof(hostname)-1]= '\0';
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
strcpy(hostname, inet_ntoa(tcpconf.nwtc_remaddr));
|
|
||||||
}
|
|
||||||
|
|
||||||
authenticated = 0;
|
|
||||||
|
|
||||||
getstr(&c, 1, "protocol violation");
|
|
||||||
getstr(rusername, sizeof(rusername), "remuser too long");
|
|
||||||
getstr(lusername, sizeof(lusername), "locuser too long");
|
|
||||||
strcpy(term, "TERM=");
|
|
||||||
getstr(term+5, sizeof(term)-5, "Terminal type too long");
|
|
||||||
|
|
||||||
#if DEBUG
|
|
||||||
fprintf(stderr, "got lu= %s, ru= %s, te= %s\r\n", lusername, rusername,
|
|
||||||
term);
|
|
||||||
#endif
|
|
||||||
if (iruserok(tcpconf.nwtc_remaddr, 0, rusername, lusername) == 0)
|
|
||||||
authenticated = 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void getstr(char *buf, int cnt, char *errmsg)
|
|
||||||
{
|
|
||||||
char c;
|
|
||||||
|
|
||||||
errno= 0;
|
|
||||||
do
|
|
||||||
{
|
|
||||||
if (read(0, &c, 1) != 1)
|
|
||||||
fatal(1, "read failed", errno);
|
|
||||||
cnt--;
|
|
||||||
if (cnt < 0)
|
|
||||||
fatal(1, errmsg, 0);
|
|
||||||
*buf++= c;
|
|
||||||
} while(c != 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
void tcp_urg(int fd, int on)
|
|
||||||
{
|
|
||||||
struct nwio_tcpopt tcpopt;
|
|
||||||
|
|
||||||
tcpopt.nwto_flags= on ? (NWTO_BSD_URG | NWTO_SND_URG) : NWTO_SND_NOTURG;
|
|
||||||
if (ioctl(1, NWIOSTCPOPT, &tcpopt) == -1)
|
|
||||||
{
|
|
||||||
fprintf(stderr, "rlogind: NWIOSTCPOPT failed: %s\r\n",
|
|
||||||
strerror(errno));
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -3,7 +3,7 @@ USR=/usr/
|
||||||
USRETC=/usr/etc/
|
USRETC=/usr/etc/
|
||||||
DEFAULTS=/etc/defaults
|
DEFAULTS=/etc/defaults
|
||||||
FILES1=group hostname.file inet.conf motd.install mtab profile \
|
FILES1=group hostname.file inet.conf motd.install mtab profile \
|
||||||
protocols rc services termcap ttytab utmp rc.cd \
|
protocols rc services termcap utmp rc.cd \
|
||||||
syslog.conf rc.daemons.dist \
|
syslog.conf rc.daemons.dist \
|
||||||
rs.inet rs.single make.conf system.conf ttys resolv.conf rc.conf \
|
rs.inet rs.single make.conf system.conf ttys resolv.conf rc.conf \
|
||||||
rc.subr rc.subr.minix man.conf shells boot.cfg.default
|
rc.subr rc.subr.minix man.conf shells boot.cfg.default
|
||||||
|
|
|
@ -1,5 +1,4 @@
|
||||||
daemonize talkd
|
daemonize talkd
|
||||||
daemonize tcpd shell in.rshd
|
daemonize tcpd shell in.rshd
|
||||||
daemonize tcpd login in.rlogind
|
|
||||||
daemonize tcpd telnet in.telnetd
|
daemonize tcpd telnet in.telnetd
|
||||||
daemonize tcpd ftp in.ftpd
|
daemonize tcpd ftp in.ftpd
|
||||||
|
|
41
etc/ttytab
41
etc/ttytab
|
@ -1,41 +0,0 @@
|
||||||
# ttytab - terminals
|
|
||||||
#
|
|
||||||
# Device Type Program Init
|
|
||||||
console minix getty
|
|
||||||
ttyc1 minix getty
|
|
||||||
ttyc2 minix getty
|
|
||||||
ttyc3 minix getty
|
|
||||||
tty00 unknown
|
|
||||||
tty01 unknown
|
|
||||||
ttyp0 network
|
|
||||||
ttyp1 network
|
|
||||||
ttyp2 network
|
|
||||||
ttyp3 network
|
|
||||||
ttyp4 network
|
|
||||||
ttyp5 network
|
|
||||||
ttyp6 network
|
|
||||||
ttyp7 network
|
|
||||||
ttyp8 network
|
|
||||||
ttyp9 network
|
|
||||||
ttypa network
|
|
||||||
ttypb network
|
|
||||||
ttypc network
|
|
||||||
ttypd network
|
|
||||||
ttype network
|
|
||||||
ttypf network
|
|
||||||
ttyq0 network
|
|
||||||
ttyq1 network
|
|
||||||
ttyq2 network
|
|
||||||
ttyq3 network
|
|
||||||
ttyq4 network
|
|
||||||
ttyq5 network
|
|
||||||
ttyq6 network
|
|
||||||
ttyq7 network
|
|
||||||
ttyq8 network
|
|
||||||
ttyq9 network
|
|
||||||
ttyqa network
|
|
||||||
ttyqb network
|
|
||||||
ttyqc network
|
|
||||||
ttyqd network
|
|
||||||
ttyqe network
|
|
||||||
ttyqf network
|
|
|
@ -13,7 +13,6 @@
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <machine/vm.h>
|
#include <machine/vm.h>
|
||||||
|
|
||||||
#include <sys/sigcontext.h>
|
|
||||||
#include <minix/u64.h>
|
#include <minix/u64.h>
|
||||||
|
|
||||||
#include "archconst.h"
|
#include "archconst.h"
|
||||||
|
|
|
@ -8,7 +8,6 @@
|
||||||
|
|
||||||
#include <minix/safecopies.h>
|
#include <minix/safecopies.h>
|
||||||
#include <machine/archtypes.h>
|
#include <machine/archtypes.h>
|
||||||
#include <sys/sigcontext.h>
|
|
||||||
#include <a.out.h>
|
#include <a.out.h>
|
||||||
|
|
||||||
/* Struct declarations. */
|
/* Struct declarations. */
|
||||||
|
|
|
@ -42,7 +42,6 @@
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <sys/sigcontext.h>
|
|
||||||
#include <minix/endpoint.h>
|
#include <minix/endpoint.h>
|
||||||
#include <minix/safecopies.h>
|
#include <minix/safecopies.h>
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,6 @@
|
||||||
#include "kernel/system.h"
|
#include "kernel/system.h"
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <machine/cpu.h>
|
#include <machine/cpu.h>
|
||||||
#include <sys/sigcontext.h>
|
|
||||||
|
|
||||||
#if USE_SIGRETURN
|
#if USE_SIGRETURN
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
#include "kernel/system.h"
|
#include "kernel/system.h"
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/sigcontext.h>
|
|
||||||
|
|
||||||
#if USE_SIGSEND
|
#if USE_SIGSEND
|
||||||
|
|
||||||
|
|
|
@ -9,28 +9,15 @@ MACHINE_ARCH= ${ARCH}
|
||||||
# std_err()
|
# std_err()
|
||||||
SRCS+= stderr.c
|
SRCS+= stderr.c
|
||||||
|
|
||||||
# V8 regexp (incompatible with BSD regexp)
|
|
||||||
SRCS+= v8regerror.c v8regexp.c v8regsub.c
|
|
||||||
|
|
||||||
# Configfile Library.
|
# Configfile Library.
|
||||||
SRCS+= configfile.c
|
SRCS+= configfile.c
|
||||||
|
|
||||||
# ACK a.out format.
|
|
||||||
SRCS+= nlist.c
|
|
||||||
|
|
||||||
# Minix 'mtab' handling functions.
|
# Minix 'mtab' handling functions.
|
||||||
#
|
#
|
||||||
# These should be changed when we switch to
|
# These should be changed when we switch to
|
||||||
# NetBSD's 'mtab' format.
|
# NetBSD's 'mtab' format.
|
||||||
SRCS+= mtab.c
|
SRCS+= mtab.c
|
||||||
|
|
||||||
# fttyslot(fd), a Minix-specific extension
|
|
||||||
SRCS+= fttyslot.c
|
|
||||||
|
|
||||||
# cuserid()
|
|
||||||
# Now considered "compat" feature in NetBSD.
|
|
||||||
SRCS+= cuserid.c
|
|
||||||
|
|
||||||
.include "include/Makefile.inc"
|
.include "include/Makefile.inc"
|
||||||
|
|
||||||
.include <bsd.own.mk>
|
.include <bsd.own.mk>
|
||||||
|
|
|
@ -1,33 +0,0 @@
|
||||||
/* cuserid(3)
|
|
||||||
*
|
|
||||||
* Author: Terrence W. Holm Sept. 1987
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <lib.h>
|
|
||||||
#include <pwd.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#ifndef L_cuserid
|
|
||||||
#define L_cuserid 9
|
|
||||||
#endif
|
|
||||||
|
|
||||||
char *cuserid(user_name)
|
|
||||||
char *user_name;
|
|
||||||
{
|
|
||||||
PRIVATE char userid[L_cuserid];
|
|
||||||
struct passwd *pw_entry;
|
|
||||||
|
|
||||||
if (user_name == (char *)NULL) user_name = userid;
|
|
||||||
|
|
||||||
pw_entry = getpwuid(geteuid());
|
|
||||||
|
|
||||||
if (pw_entry == (struct passwd *)NULL) {
|
|
||||||
*user_name = '\0';
|
|
||||||
return((char *)NULL);
|
|
||||||
}
|
|
||||||
strcpy(user_name, pw_entry->pw_name);
|
|
||||||
|
|
||||||
return(user_name);
|
|
||||||
}
|
|
|
@ -1,50 +0,0 @@
|
||||||
/*
|
|
||||||
ttyslot.c
|
|
||||||
|
|
||||||
Return the index in the utmp file for the current user's terminal. The
|
|
||||||
current user's terminal is the first file descriptor in the range 0..2
|
|
||||||
for which ttyname() returns a name. The index is the line number in the
|
|
||||||
/etc/ttytab file. 0 will be returned in case of an error.
|
|
||||||
|
|
||||||
Created: Oct 11, 1992 by Philip Homburg
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <ttyent.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
|
|
||||||
int fttyslot(fd)
|
|
||||||
int fd;
|
|
||||||
{
|
|
||||||
char *tname;
|
|
||||||
int lineno;
|
|
||||||
struct ttyent *ttyp;
|
|
||||||
|
|
||||||
tname= ttyname(fd);
|
|
||||||
if (tname == NULL) return 0;
|
|
||||||
|
|
||||||
/* Assume that tty devices are in /dev */
|
|
||||||
if (strncmp(tname, "/dev/", 5) != 0)
|
|
||||||
return 0; /* Malformed tty name. */
|
|
||||||
tname += 5;
|
|
||||||
|
|
||||||
/* Scan /etc/ttytab. */
|
|
||||||
lineno= 1;
|
|
||||||
while ((ttyp= getttyent()) != NULL)
|
|
||||||
{
|
|
||||||
if (strcmp(tname, ttyp->ty_name) == 0)
|
|
||||||
{
|
|
||||||
endttyent();
|
|
||||||
return lineno;
|
|
||||||
}
|
|
||||||
lineno++;
|
|
||||||
}
|
|
||||||
/* No match */
|
|
||||||
endttyent();
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* $PchHeader: /mount/hd2/minix/lib/misc/RCS/ttyslot.c,v 1.3 1994/12/22 13:49:12 philip Exp $
|
|
||||||
*/
|
|
|
@ -3,8 +3,6 @@
|
||||||
INCSDIR= /usr/include
|
INCSDIR= /usr/include
|
||||||
|
|
||||||
INCS+= configfile.h
|
INCS+= configfile.h
|
||||||
INCS+= compat/a.out.h compat/regexp.h compat/syslog.h \
|
INCS+= compat/a.out.h
|
||||||
compat/pwd.h
|
|
||||||
INCS+= net/gen/netdb.h net/gen/resolv.h net/gen/nameser.h
|
INCS+= net/gen/netdb.h net/gen/resolv.h net/gen/nameser.h
|
||||||
INCS+= sys/jmp_buf.h ${MACHINE_ARCH}/compat_jmp_buf.h
|
INCS+= sys/jmp_buf.h ${MACHINE_ARCH}/compat_jmp_buf.h
|
||||||
INCS+= sys/sigcontext.h
|
|
||||||
|
|
|
@ -1,34 +0,0 @@
|
||||||
/* The <pwd.h> header defines the items in the password file. */
|
|
||||||
|
|
||||||
#ifndef _PWD_H
|
|
||||||
#define _PWD_H
|
|
||||||
|
|
||||||
#ifndef _TYPES_H
|
|
||||||
#include <minix/types.h>
|
|
||||||
#endif
|
|
||||||
|
|
||||||
struct passwd {
|
|
||||||
char *pw_name; /* login name */
|
|
||||||
uid_t pw_uid; /* uid corresponding to the name */
|
|
||||||
gid_t pw_gid; /* gid corresponding to the name */
|
|
||||||
char *pw_dir; /* user's home directory */
|
|
||||||
char *pw_shell; /* name of the user's shell */
|
|
||||||
|
|
||||||
/* The following members are not defined by POSIX. */
|
|
||||||
char *pw_passwd; /* password information */
|
|
||||||
char *pw_gecos; /* just in case you have a GE 645 around */
|
|
||||||
};
|
|
||||||
|
|
||||||
/* Function Prototypes. */
|
|
||||||
_PROTOTYPE( struct passwd *getpwnam, (const char *_name) );
|
|
||||||
_PROTOTYPE( struct passwd *getpwuid, (uid_t _uid) );
|
|
||||||
|
|
||||||
#ifdef _MINIX
|
|
||||||
_PROTOTYPE( void endpwent, (void) );
|
|
||||||
_PROTOTYPE( struct passwd *getpwent, (void) );
|
|
||||||
_PROTOTYPE( int setpwent, (void) );
|
|
||||||
_PROTOTYPE( void setpwfile, (const char *_file) );
|
|
||||||
_PROTOTYPE( const char *user_from_uid, (uid_t, int) );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif /* _PWD_H */
|
|
|
@ -1,37 +0,0 @@
|
||||||
/* The <regexp.h> header is used by the (V8-compatible) regexp(3) routines. */
|
|
||||||
/* NOTE: Obsoleted by the POSIX regex(3) library. */
|
|
||||||
|
|
||||||
#ifndef _REGEXP_H
|
|
||||||
#define _REGEXP_H
|
|
||||||
|
|
||||||
#include <sys/cdefs.h>
|
|
||||||
|
|
||||||
#define CHARBITS 0377
|
|
||||||
#define NSUBEXP 10
|
|
||||||
typedef struct regexp {
|
|
||||||
const char *startp[NSUBEXP];
|
|
||||||
const char *endp[NSUBEXP];
|
|
||||||
char regstart; /* Internal use only. */
|
|
||||||
char reganch; /* Internal use only. */
|
|
||||||
char *regmust; /* Internal use only. */
|
|
||||||
int regmlen; /* Internal use only. */
|
|
||||||
char program[1]; /* Unwarranted chumminess with compiler. */
|
|
||||||
} regexp;
|
|
||||||
|
|
||||||
/* Keep these functions away from the POSIX versions. */
|
|
||||||
#define regcomp _v8_regcomp
|
|
||||||
#define regexec _v8_regexec
|
|
||||||
#define regsub _v8_regsub
|
|
||||||
#define regerror _v8_regerror
|
|
||||||
|
|
||||||
/* Function Prototypes. */
|
|
||||||
regexp *regcomp(const char *_exp);
|
|
||||||
int regexec(regexp *_prog, const char *_string, int _bolflag);
|
|
||||||
void regsub(regexp *_prog, char *_source, char *_dest);
|
|
||||||
void regerror(const char *_message) ;
|
|
||||||
|
|
||||||
#endif /* _REGEXP_H */
|
|
||||||
|
|
||||||
/*
|
|
||||||
* $PchId: regexp.h,v 1.4 1996/04/10 21:43:17 philip Exp $
|
|
||||||
*/
|
|
|
@ -1,8 +0,0 @@
|
||||||
#ifndef _COMPAT_SYSLOG_H
|
|
||||||
#define _COMPAT_SYSLOG_H
|
|
||||||
|
|
||||||
#include <syslog.h>
|
|
||||||
#define FacNames facilitynames
|
|
||||||
#define PriNames prioritynames
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,8 +0,0 @@
|
||||||
#ifndef COMPAT_SYS_SIGCONTEXT_H
|
|
||||||
#define COMPAT_SYS_SIGCONTEXT_H
|
|
||||||
|
|
||||||
/* Minix legacy compatibility header. */
|
|
||||||
#include <sys/signal.h>
|
|
||||||
#include <sys/siginfo.h>
|
|
||||||
|
|
||||||
#endif
|
|
|
@ -1,71 +0,0 @@
|
||||||
/*
|
|
||||||
* "nlist.c", Peter Valkenburg, january 1989.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <lib.h>
|
|
||||||
#include <string.h>
|
|
||||||
#include <a.out.h>
|
|
||||||
#include <sys/types.h>
|
|
||||||
#include <fcntl.h>
|
|
||||||
#include <unistd.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#define fail(fp) (fclose(fp), -1) /* ret. exp. when nlist fails */
|
|
||||||
|
|
||||||
_PROTOTYPE( int nlist, (char *file, struct nlist nl[]));
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Nlist fills fields n_sclass and n_value of array nl with values found in
|
|
||||||
* non-stripped executable file. Entries that are not found have their
|
|
||||||
* n_value/n_sclass fields set to 0. Nl ends with a 0 or nul string n_name.
|
|
||||||
* The return value is -1 on failure, else the number of entries not found.
|
|
||||||
*/
|
|
||||||
int nlist(file, nl)
|
|
||||||
char *file;
|
|
||||||
struct nlist nl[];
|
|
||||||
{
|
|
||||||
int nents, nsrch, nfound, i;
|
|
||||||
struct nlist nlent;
|
|
||||||
FILE *fp;
|
|
||||||
struct exec hd;
|
|
||||||
|
|
||||||
/* open executable with namelist */
|
|
||||||
if ((fp = fopen(file, "r")) == NULL)
|
|
||||||
return -1;
|
|
||||||
|
|
||||||
/* get header and seek to start of namelist */
|
|
||||||
if (fread((char *) &hd, sizeof(struct exec), 1, fp) != 1 ||
|
|
||||||
BADMAG(hd) || fseek(fp, A_SYMPOS(hd), SEEK_SET) != 0)
|
|
||||||
return fail(fp);
|
|
||||||
|
|
||||||
/* determine number of entries searched for & reset fields */
|
|
||||||
nsrch = 0;
|
|
||||||
while (nl[nsrch].n_name != NULL && *(nl[nsrch].n_name) != '\0') {
|
|
||||||
nl[nsrch].n_sclass = 0;
|
|
||||||
nl[nsrch].n_value = 0;
|
|
||||||
nl[nsrch].n_type = 0; /* for compatability */
|
|
||||||
nsrch++;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* loop through namelist & fill in user array */
|
|
||||||
nfound = 0;
|
|
||||||
for (nents = (hd.a_syms & 0xFFFF) / sizeof(struct nlist);
|
|
||||||
nents > 0; nents--) {
|
|
||||||
if (nsrch == nfound)
|
|
||||||
break; /* no need to look further */
|
|
||||||
if (fread((char *) &nlent, sizeof(struct nlist), 1, fp) != 1)
|
|
||||||
return fail(fp);
|
|
||||||
for (i = 0; i < nsrch; i++)
|
|
||||||
if (nl[i].n_sclass == 0 &&
|
|
||||||
strncmp(nl[i].n_name, nlent.n_name,
|
|
||||||
sizeof(nlent.n_name)) == 0) {
|
|
||||||
nl[i] = nlent;
|
|
||||||
nfound++;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
(void) fclose(fp);
|
|
||||||
|
|
||||||
return nsrch - nfound;
|
|
||||||
}
|
|
|
@ -1,15 +0,0 @@
|
||||||
/* regerror() - Default regexp error report Author: Kees J. Bot
|
|
||||||
* 12 Jun 1999
|
|
||||||
*
|
|
||||||
* A better version of this routine should be supplied by the user in
|
|
||||||
* the program using regexps.
|
|
||||||
*/
|
|
||||||
#include <stdio.h>
|
|
||||||
#define const /* avoid "const poisoning" */
|
|
||||||
#include <compat/regexp.h>
|
|
||||||
#undef const
|
|
||||||
|
|
||||||
void regerror(char *message)
|
|
||||||
{
|
|
||||||
fprintf(stderr, "regexp error: %s\n", message);
|
|
||||||
}
|
|
File diff suppressed because it is too large
Load diff
|
@ -1,90 +0,0 @@
|
||||||
/* regsub
|
|
||||||
*
|
|
||||||
* Copyright (c) 1986 by University of Toronto.
|
|
||||||
* Written by Henry Spencer. Not derived from licensed software.
|
|
||||||
*
|
|
||||||
* Permission is granted to anyone to use this software for any
|
|
||||||
* purpose on any computer system, and to redistribute it freely,
|
|
||||||
* subject to the following restrictions:
|
|
||||||
*
|
|
||||||
* 1. The author is not responsible for the consequences of use of
|
|
||||||
* this software, no matter how awful, even if they arise
|
|
||||||
* from defects in it.
|
|
||||||
*
|
|
||||||
* 2. The origin of this software must not be misrepresented, either
|
|
||||||
* by explicit claim or by omission.
|
|
||||||
*
|
|
||||||
* 3. Altered versions must be plainly marked as such, and must not
|
|
||||||
* be misrepresented as being the original software.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include <string.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
#define const /* avoid "const poisoning" */
|
|
||||||
#include <compat/regexp.h>
|
|
||||||
#undef const
|
|
||||||
|
|
||||||
/* The first byte of the regexp internal "program" is actually this magic
|
|
||||||
* number; the start node begins in the second byte.
|
|
||||||
*/
|
|
||||||
#define MAGIC 0234
|
|
||||||
|
|
||||||
#define CHARBITS 0377
|
|
||||||
#ifndef CHARBITS
|
|
||||||
#define UCHARAT(p) ((int)*(unsigned char *)(p))
|
|
||||||
#else
|
|
||||||
#define UCHARAT(p) ((int)*(p)&CHARBITS)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/*
|
|
||||||
- regsub - perform substitutions after a regexp match
|
|
||||||
*/
|
|
||||||
void regsub(prog, source, dest)
|
|
||||||
regexp *prog;
|
|
||||||
char *source;
|
|
||||||
char *dest;
|
|
||||||
{
|
|
||||||
register char *src;
|
|
||||||
register char *dst;
|
|
||||||
register char c;
|
|
||||||
register int no;
|
|
||||||
register int len;
|
|
||||||
|
|
||||||
if (prog == (regexp *)NULL || source == (char *)NULL || dest == (char *)NULL) {
|
|
||||||
regerror("NULL parm to regsub");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (UCHARAT(prog->program) != MAGIC) {
|
|
||||||
regerror("damaged regexp fed to regsub");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
src = source;
|
|
||||||
dst = dest;
|
|
||||||
while ((c = *src++) != '\0') {
|
|
||||||
if (c == '&')
|
|
||||||
no = 0;
|
|
||||||
else if (c == '\\' && '0' <= *src && *src <= '9')
|
|
||||||
no = *src++ - '0';
|
|
||||||
else
|
|
||||||
no = -1;
|
|
||||||
|
|
||||||
if (no < 0) { /* Ordinary character. */
|
|
||||||
if (c == '\\' && (*src == '\\' || *src == '&')) c = *src++;
|
|
||||||
*dst++ = c;
|
|
||||||
} else
|
|
||||||
if (prog->startp[no] != (char *)NULL && prog->endp[no] != (char *)NULL) {
|
|
||||||
len = (int) (prog->endp[no] - prog->startp[no]);
|
|
||||||
strncpy(dst, prog->startp[no], len);
|
|
||||||
dst += len;
|
|
||||||
if (len != 0 && *(dst - 1) == '\0') { /* strncpy hit NUL. */
|
|
||||||
regerror("damaged match string");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*dst++ = '\0';
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* $PchId: regsub.c,v 1.3 1995/11/27 20:18:16 philip Exp $
|
|
||||||
*/
|
|
|
@ -1,6 +1,5 @@
|
||||||
MAN= ash.1 at.1 banner.1 basename.1 \
|
MAN= ash.1 at.1 banner.1 basename.1 \
|
||||||
bsfilt.1 cal.1 \
|
bsfilt.1 cal.1 cawf.1 chgrp.1 \
|
||||||
calendar.1 cawf.1 chgrp.1 \
|
|
||||||
chmod.1 cksum.1 clear.1 cmp.1 comm.1 compress.1 \
|
chmod.1 cksum.1 clear.1 cmp.1 comm.1 compress.1 \
|
||||||
cp.1 crc.1 crontab.1 ctags.1 dd.1 dev2name.1 \
|
cp.1 crc.1 crontab.1 ctags.1 dd.1 dev2name.1 \
|
||||||
df.1 dhrystone.1 dosdir.1 dosread.1 doswrite.1 \
|
df.1 dhrystone.1 dosdir.1 dosread.1 doswrite.1 \
|
||||||
|
@ -9,10 +8,10 @@ MAN= ash.1 at.1 banner.1 basename.1 \
|
||||||
finger.1 flexdoc.1 fmt.1 fold.1 format.1 fortune.1 \
|
finger.1 flexdoc.1 fmt.1 fold.1 format.1 fortune.1 \
|
||||||
fsck.mfs.1 head.1 host.1 hostaddr.1 ifdef.1 \
|
fsck.mfs.1 head.1 host.1 hostaddr.1 ifdef.1 \
|
||||||
install.1 isodir.1 isoinfo.1 isoread.1 join.1 kill.1 \
|
install.1 isodir.1 isoinfo.1 isoread.1 join.1 kill.1 \
|
||||||
last.1 leave.1 loadfont.1 loadkeys.1 logger.1 login.1 \
|
last.1 loadfont.1 loadkeys.1 logger.1 login.1 \
|
||||||
look.1 lp.1 ls.1 lspci.1 mail.1 \
|
look.1 lp.1 ls.1 lspci.1 mail.1 \
|
||||||
mesg.1 mixer.1 mkfs.1 \
|
mesg.1 mixer.1 mkfs.1 \
|
||||||
mkproto.1 modem.1 mount.1 mt.1 nice.1 nm.1 nohup.1 od.1 \
|
mkproto.1 mount.1 mt.1 nice.1 nm.1 nohup.1 od.1 \
|
||||||
paste.1 ping.1 playwave.1 pr.1 prep.1 \
|
paste.1 ping.1 playwave.1 pr.1 prep.1 \
|
||||||
profile.1 ps.1 pwd.1 rcp.1 readall.1 recwave.1 \
|
profile.1 ps.1 pwd.1 rcp.1 readall.1 recwave.1 \
|
||||||
ref.1 remsync.1 rget.1 rlogin.1 rsh.1 rz.1 \
|
ref.1 remsync.1 rget.1 rlogin.1 rsh.1 rz.1 \
|
||||||
|
|
|
@ -1,44 +0,0 @@
|
||||||
.TH CALENDAR 1
|
|
||||||
.SH NAME
|
|
||||||
calendar \- reminder service
|
|
||||||
.SH SYNOPSIS
|
|
||||||
\fBcalendar [\fB\-\fR] [\fB\-r\fR]\fR
|
|
||||||
.br
|
|
||||||
.de FL
|
|
||||||
.TP
|
|
||||||
\\fB\\$1\\fR
|
|
||||||
\\$2
|
|
||||||
..
|
|
||||||
.de EX
|
|
||||||
.TP 20
|
|
||||||
\\fB\\$1\\fR
|
|
||||||
# \\$2
|
|
||||||
..
|
|
||||||
.SH OPTIONS
|
|
||||||
.FL "\-" "Work for every user and send mail to him"
|
|
||||||
.FL "\-r" "Restrict multiple execution on the same day"
|
|
||||||
.SH EXAMPLES
|
|
||||||
.EX "calendar" "Check \fIcalendar\fR file in current directory"
|
|
||||||
.EX "calendar" "Normary used under the control of cron(8)"
|
|
||||||
.EX "calendar \-r" " Normary used in /etc/rc file"
|
|
||||||
.SH DESCRIPTION
|
|
||||||
.PP
|
|
||||||
Basically \fIcalendar\fR program consults the file \fIcalendar\fR in the
|
|
||||||
current directory and display lines which contain today's or tomorrow's date.
|
|
||||||
Month-day formats such
|
|
||||||
as '12/25', 'Dec. 25', 'december 25', '*/25', '12/*', '*/*' are
|
|
||||||
recognized. The asterisk
|
|
||||||
means 'all' days or 'all' months. On weekends 'tomorrow' extends through
|
|
||||||
next Monday without any consideration about holidays.
|
|
||||||
To prevent ambiguity, the formats '25 Dec.' and '25/12' are not recognized.
|
|
||||||
.PP
|
|
||||||
When an argument \fB\-\fR is present, \fIcalendar\fR works for all users
|
|
||||||
with a file \fIcalendar\fR in their login directories and sends them mail.
|
|
||||||
Normally this is done daily under the control of \fIcron\fR.
|
|
||||||
.PP
|
|
||||||
The \fB\-r\fR option does its the same job as \fB\-\fR option, but touches
|
|
||||||
the \fIcalendar\fR to prevents further access on the same day.
|
|
||||||
Normally this is done in the \fI/etc/rc\fR file on a machine which may be
|
|
||||||
booted several times in one day.
|
|
||||||
.SH "SEE ALSO"
|
|
||||||
.BR cron (8).
|
|
|
@ -1,26 +0,0 @@
|
||||||
.TH LEAVE 1
|
|
||||||
.SH NAME
|
|
||||||
leave \- warn when it is time to go home
|
|
||||||
.SH SYNOPSIS
|
|
||||||
\fBleave\fR [\fR [\fB+\fR] \fIhh\fR[\fB:\fR]\fImm\fR]\fR
|
|
||||||
.br
|
|
||||||
.de FL
|
|
||||||
.TP
|
|
||||||
\\fB\\$1\\fR
|
|
||||||
\\$2
|
|
||||||
..
|
|
||||||
.de EX
|
|
||||||
.TP 20
|
|
||||||
\\fB\\$1\\fR
|
|
||||||
# \\$2
|
|
||||||
..
|
|
||||||
.SH EXAMPLES
|
|
||||||
.EX "leave 1500" "Issue a warning at 2:55 p.m."
|
|
||||||
.EX "leave 10:00" "Issue a warning at 9:55 a.m."
|
|
||||||
.EX "leave + 30" "Issue a warning in 25 minutes"
|
|
||||||
.SH DESCRIPTION
|
|
||||||
.PP
|
|
||||||
\fILeave\fR sets an alarm clock to a specified time and issues a warning
|
|
||||||
5 minutes before, 1 minute before, and at the time to leave.
|
|
||||||
It then keeps issuing warnings every minute for 10 minutes, then quits.
|
|
||||||
If no time is provided, the program prompts for one.
|
|
|
@ -1,39 +0,0 @@
|
||||||
.TH MODEM 1
|
|
||||||
.SH NAME
|
|
||||||
modem \- switch the modem and getty state
|
|
||||||
.SH SYNOPSIS
|
|
||||||
\fBmodem \fR[\fB\-o\fR] [\fB\-i \fInum\fR] \fBtty\fIn\fR\fR
|
|
||||||
.br
|
|
||||||
.de FL
|
|
||||||
.TP
|
|
||||||
\\fB\\$1\\fR
|
|
||||||
\\$2
|
|
||||||
..
|
|
||||||
.de EX
|
|
||||||
.TP 20
|
|
||||||
\\fB\\$1\\fR
|
|
||||||
# \\$2
|
|
||||||
..
|
|
||||||
.SH OPTIONS
|
|
||||||
.FL "\-o" "Turn getty off and set modem to dialout"
|
|
||||||
.FL "\-i" "Set line to dialin"
|
|
||||||
.SH EXAMPLES
|
|
||||||
.EX "modem \-o tty00" "Set tty00 to dialout"
|
|
||||||
.EX "modem \-i2 tty00" "Set tty00 to dialin (2 rings)"
|
|
||||||
.SH DESCRIPTION
|
|
||||||
.PP
|
|
||||||
The \fIgetty\fR program allows a terminal port to be used for both dialin and
|
|
||||||
dialout.
|
|
||||||
This little program switches the getty state, and also sends
|
|
||||||
some commands to the modem attached to the specified line.
|
|
||||||
If the \fB\-o\fR flag is presnt, \fImodem\fR will put the
|
|
||||||
getty process (if any) connected to the specified line into
|
|
||||||
SUSPEND state, which means that it
|
|
||||||
will not pay attention to that line until it is reset to RESTART state.
|
|
||||||
Also, \fImodem\fR will send some (Hayes)
|
|
||||||
commands to the attached modem to disable the auto-nanswer mode.
|
|
||||||
The \fB\-i\fR flag specifies the number of times the telephone has to
|
|
||||||
ring before the modem may answer the call (to give the operator a chance).
|
|
||||||
.SH "SEE ALSO"
|
|
||||||
.BR term (1),
|
|
||||||
.BR getty (8).
|
|
|
@ -6,7 +6,7 @@ MAN= add_route.8 backup.8 badblocks.8 boot.8 btrace.8 \
|
||||||
mknod.8 netconf.8 newroot.8 nonamed.8 \
|
mknod.8 netconf.8 newroot.8 nonamed.8 \
|
||||||
ossdevlinks.8 part.8 partition.8 \
|
ossdevlinks.8 part.8 partition.8 \
|
||||||
poweroff.8 printroot.8 pr_routes.8 pwdauth.8 rarpd.8 \
|
poweroff.8 printroot.8 pr_routes.8 pwdauth.8 rarpd.8 \
|
||||||
rdate.8 readclock.8 reboot.8 repartition.8 rlogind.8 \
|
rdate.8 readclock.8 reboot.8 repartition.8 \
|
||||||
rshd.8 screendump.8 serial-ip.8 service.8 \
|
rshd.8 screendump.8 serial-ip.8 service.8 \
|
||||||
setup.8 shutdown.8 slip.8 srccrc.8 sync.8 syslogd.8 tcpd.8 \
|
setup.8 shutdown.8 slip.8 srccrc.8 sync.8 syslogd.8 tcpd.8 \
|
||||||
unix.8 update.8 usage.8
|
unix.8 update.8 usage.8
|
||||||
|
|
|
@ -1,103 +0,0 @@
|
||||||
.\" Copyright (c) 1983 Regents of the University of California.
|
|
||||||
.\" All rights reserved. The Berkeley software License Agreement
|
|
||||||
.\" specifies the terms and conditions for redistribution.
|
|
||||||
.\"
|
|
||||||
.\" @(#)rlogind.8c 6.3 (Berkeley) 5/24/86
|
|
||||||
.\"
|
|
||||||
.TH RLOGIND 8 "May 24, 1986"
|
|
||||||
.UC 5
|
|
||||||
.SH NAME
|
|
||||||
rlogind, in.rlogind \- remote login server
|
|
||||||
.SH SYNOPSIS
|
|
||||||
.B "login stream tcp nowait root /usr/sbin/in.rlogind in.rlogind"
|
|
||||||
.br
|
|
||||||
.B "tcpd login /usr/sbin/in.rlogind"
|
|
||||||
.SH DESCRIPTION
|
|
||||||
.B Rlogind
|
|
||||||
is the server for the
|
|
||||||
.BR rlogin (1)
|
|
||||||
program. The server provides a remote login facility
|
|
||||||
with authentication based on privileged port numbers from trusted hosts.
|
|
||||||
.PP
|
|
||||||
.B Rlogind
|
|
||||||
listens for service requests at the port indicated in
|
|
||||||
the ``login'' service specification; see
|
|
||||||
.BR services (5).
|
|
||||||
When a service request is received the following protocol
|
|
||||||
is initiated:
|
|
||||||
.IP 1)
|
|
||||||
The server checks the client's source port.
|
|
||||||
If the port is not in the range 0-1023, the server
|
|
||||||
aborts the connection.
|
|
||||||
.IP 2)
|
|
||||||
The server checks the client's source address
|
|
||||||
and requests the corresponding host name (see
|
|
||||||
.BR gethostbyaddr (3),
|
|
||||||
.BR hosts (5)
|
|
||||||
and
|
|
||||||
.BR named (8)).
|
|
||||||
If the hostname cannot be determined,
|
|
||||||
the dot-notation representation of the host address is used.
|
|
||||||
.PP
|
|
||||||
Once the source port and address have been checked,
|
|
||||||
.B rlogind
|
|
||||||
allocates a pseudo terminal (see
|
|
||||||
.BR tty (4)),
|
|
||||||
and manipulates file descriptors so that the slave
|
|
||||||
half of the pseudo terminal becomes the
|
|
||||||
.B stdin ,
|
|
||||||
.B stdout ,
|
|
||||||
and
|
|
||||||
.B stderr
|
|
||||||
for a login process.
|
|
||||||
The login process is an instance of the
|
|
||||||
.BR login (1)
|
|
||||||
program, invoked with the
|
|
||||||
.B \-r
|
|
||||||
option. The login process then proceeds with the authentication
|
|
||||||
process as described in
|
|
||||||
.BR rshd (8),
|
|
||||||
but if automatic authentication fails, it reprompts the user
|
|
||||||
to login as one finds on a standard terminal line.
|
|
||||||
.PP
|
|
||||||
The parent of the login process manipulates the master side of
|
|
||||||
the pseduo terminal, operating as an intermediary
|
|
||||||
between the login process and the client instance of the
|
|
||||||
.B rlogin
|
|
||||||
program. In normal operation, the packet protocol described
|
|
||||||
in
|
|
||||||
.BR tty (4)
|
|
||||||
is invoked to provide ^S/^Q type facilities and propagate
|
|
||||||
interrupt signals to the remote programs. The login process
|
|
||||||
propagates the client terminal's baud rate and terminal type,
|
|
||||||
as found in the environment variable, ``TERM''; see
|
|
||||||
.BR environ (7).
|
|
||||||
The screen or window size of the terminal is requested from the client,
|
|
||||||
and window size changes from the client are propagated to the pseudo terminal.
|
|
||||||
.SH "SEE ALSO"
|
|
||||||
.BR rlogin (1).
|
|
||||||
.SH DIAGNOSTICS
|
|
||||||
All diagnostic messages are returned on the connection
|
|
||||||
associated with the
|
|
||||||
.BR stderr ,
|
|
||||||
after which any network connections are closed.
|
|
||||||
An error is indicated by a leading byte with a value of 1.
|
|
||||||
.PP
|
|
||||||
.B ``Try again.''
|
|
||||||
.br
|
|
||||||
A
|
|
||||||
.B fork
|
|
||||||
by the server failed.
|
|
||||||
.PP
|
|
||||||
.B ``/bin/sh: ...''
|
|
||||||
.br
|
|
||||||
The user's login shell could not be started.
|
|
||||||
.SH BUGS
|
|
||||||
The authentication procedure used here assumes the integrity
|
|
||||||
of each client machine and the connecting medium. This is
|
|
||||||
insecure, but is useful in an ``open'' environment.
|
|
||||||
.PP
|
|
||||||
A facility to allow all data exchanges to be encrypted should be
|
|
||||||
present.
|
|
||||||
.PP
|
|
||||||
A more extensible protocol should be used.
|
|
|
@ -28,7 +28,6 @@
|
||||||
#include <minix/vm.h>
|
#include <minix/vm.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <sys/resource.h>
|
#include <sys/resource.h>
|
||||||
#include <sys/sigcontext.h>
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "mproc.h"
|
#include "mproc.h"
|
||||||
#include "param.h"
|
#include "param.h"
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
#include <minix/sysutil.h>
|
#include <minix/sysutil.h>
|
||||||
#include <minix/syslib.h>
|
#include <minix/syslib.h>
|
||||||
#include <minix/bitmap.h>
|
#include <minix/bitmap.h>
|
||||||
#include <sys/sigcontext.h>
|
#include <sys/signal.h>
|
||||||
|
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <env.h>
|
#include <env.h>
|
||||||
|
|
|
@ -132,37 +132,28 @@ void test11b()
|
||||||
|
|
||||||
void test11c()
|
void test11c()
|
||||||
{
|
{
|
||||||
/* Test getlogin() and cuserid(). This test MUST run setuid root. */
|
/* Test getlogin(). This test MUST run setuid root. */
|
||||||
|
|
||||||
int n, etc_uid;
|
int n, etc_uid;
|
||||||
uid_t ruid, euid;
|
uid_t ruid, euid;
|
||||||
char *lnamep, *cnamep, *p;
|
char *lnamep, *p;
|
||||||
#define MAXLINELEN 200
|
#define MAXLINELEN 200
|
||||||
char array[MAXLINELEN], save[L_cuserid], save2[L_cuserid];
|
char array[MAXLINELEN], save[L_cuserid];
|
||||||
FILE *stream;
|
FILE *stream;
|
||||||
|
|
||||||
subtest = 3;
|
subtest = 3;
|
||||||
errno = -2000; /* None of these calls set errno. */
|
errno = -2000; /* None of these calls set errno. */
|
||||||
array[0] = '@';
|
|
||||||
array[1] = '0';
|
|
||||||
save[0] = '#';
|
save[0] = '#';
|
||||||
save[1] = '0';
|
save[1] = '0';
|
||||||
ruid = getuid();
|
ruid = getuid();
|
||||||
euid = geteuid();
|
euid = geteuid();
|
||||||
lnamep = getlogin();
|
lnamep = getlogin();
|
||||||
strcpy(save, lnamep);
|
strcpy(save, lnamep);
|
||||||
cnamep = cuserid(array);
|
|
||||||
strcpy(save2, cnamep);
|
|
||||||
|
|
||||||
/* Because we are setuid root, cuser == array == 'root'; login != 'root' */
|
/* Because we are setuid, login != 'root' */
|
||||||
if (euid != 0) e(1);
|
if (euid != 0) e(1);
|
||||||
if (ruid == 0) e(2);
|
if (ruid == 0) e(2);
|
||||||
if (strcmp(cnamep, "root") != 0) e(3);
|
|
||||||
if (strcmp(array, "root") != 0) e(4);
|
|
||||||
if ( (n = strlen(save)) == 0) e(5);
|
if ( (n = strlen(save)) == 0) e(5);
|
||||||
if (strcmp(save, cnamep) == 0) e(6); /* they must be different */
|
|
||||||
cnamep = cuserid(NULL);
|
|
||||||
if (strcmp(cnamep, save2) != 0) e(7);
|
|
||||||
|
|
||||||
/* Check login against passwd file. First lookup login in /etc/passwd. */
|
/* Check login against passwd file. First lookup login in /etc/passwd. */
|
||||||
if (n == 0) return; /* if login not found, don't look it up */
|
if (n == 0) return; /* if login not found, don't look it up */
|
||||||
|
|
|
@ -2,9 +2,6 @@
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <sys/times.h>
|
#include <sys/times.h>
|
||||||
#ifdef _MINIX
|
|
||||||
#include <sys/sigcontext.h>
|
|
||||||
#endif
|
|
||||||
#include <sys/wait.h>
|
#include <sys/wait.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
|
|
|
@ -5,7 +5,6 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <sys/sigcontext.h>
|
|
||||||
|
|
||||||
#define MAX_ERROR 4
|
#define MAX_ERROR 4
|
||||||
#include "common.c"
|
#include "common.c"
|
||||||
|
|
Loading…
Reference in a new issue