Applied MINIX 2.0.4 pathes provides by Al Woodhull.

This commit is contained in:
Jorrit Herder 2005-06-17 13:00:04 +00:00
parent 330d7eba56
commit 7279bb68ef
34 changed files with 2790 additions and 56 deletions

View file

@ -189,6 +189,9 @@ int main(int argc, char **argv)
pflag= 1;
}
/* Initialize current Time */
time(&now);
if (cflag) {
int fd1, fd2;

View file

@ -158,6 +158,7 @@ void tab_reschedule(cronjob_t *job)
job->rtime= NEVER;
return;
}
tmptm= *localtime(&job->rtime);
if (tmptm.tm_hour != nexttm.tm_hour ||
tmptm.tm_min != nexttm.tm_min)
{
@ -182,6 +183,7 @@ void tab_reschedule(cronjob_t *job)
job->rtime= NEVER;
return;
}
tmptm= *localtime(&job->rtime);
if (tmptm.tm_hour != nexttm.tm_hour ||
tmptm.tm_min != nexttm.tm_min)
{

42
commands/ftpd200/Makefile Normal file
View file

@ -0,0 +1,42 @@
# Makefile for ftpd
#
# 01/25/96 Initial Release Michael Temari, <Michael@TemWare.Com>
# 2005-02-25 version 2.00
CFLAGS= -O -D_MINIX -D_POSIX_SOURCE -m
LDFLAGS=-i
BINDIR= /usr/bin
PROG= in.ftpd
MANDIR= /usr/man/man8
MANPAGE=ftpd.8
OBJS= ftpd.o access.o file.o net.o
all: $(PROG)
$(PROG): $(OBJS)
$(CC) $(LDFLAGS) -o $@ $(OBJS)
install -S 8kw $@
clean:
rm -f $(PROG) $(OBJS)
install: $(BINDIR)/$(PROG) $(BINDIR)/setup.anonftp $(BINDIR)/ftpdsh
$(BINDIR)/$(PROG): $(PROG)
install -cs -o bin $? $@
$(BINDIR)/setup.anonftp: setup.anonftp
install -c -o bin $? $@
$(BINDIR)/ftpdsh: ftpdsh
install -c -o bin $? $@
ftpd.o: ftpd.c ftpd.h access.h file.h net.h
access.o: access.c ftpd.h access.h
file.o: file.c ftpd.h access.h file.h net.h
net.o: net.c ftpd.h net.h
installman: $(MANDIR)/$(MANPAGE)
cp $(MANPAGE) $(MANDIR)
echo "You may need to run makewhatis to update man page index"

35
commands/ftpd200/README Normal file
View file

@ -0,0 +1,35 @@
ftpd200 --- FTP server program for Minix 2.0
written by Michael Temari <Michael@TemWare.Com> release 2.00 2005-02-25
Full download: <a href="/pub/contrib/ftpd200.tar.Z">ftpd200.tar.Z</a>
Ftpd is the File Transfer Protocol (FTP) server.
Important: Release 2.00 incorporates an improved mechanism to restrict
execution of commands on the server. This is done through use of a
shell script, ftpdsh. Any earlier ftpd version in use on a system
accessible from the Internet should be upgraded at least to version 1.01,
version 2.00 is preferable.
Installation: unpack the tarball in /usr/local/src or another directory
of your choice:
zcat < ftpd200.tar.Z | tar xvfp -
The ftpd200 directory will be created. Read the Makefile to see how
the program is compiled and installed:
make (or make ftpd) -- compiles the binary
make install -- installs /usr/bin/in.ftpd, and ftpdsh. Also installs
setup.anonftp script.
make installman -- installs new ftpd.8 man page in /usr/local/man/man8
The shell script setup.anonftp sets up and verifies configuration for
anonymous ftp. If you provide anonymous ftp you are letting anyone in
the whole wide world execute a program on your computer. You want to
make sure it's set up correctly so outsiders can't mess with things
they shouldn't.
This file is included as README in the source directory. For more
notes on compiling and installing, also please see the file README2.
notes updated by asw 2005-02-25

34
commands/ftpd200/README2 Normal file
View file

@ -0,0 +1,34 @@
README2: additional notes on compiling and installing ftpd.
Note that the Makefile install options will replace files in /usr/bin
and /usr/man that were installed with the Minix distribution. If you
are not sure you want to do this you can either rename the original
in.ftpd binary, the anonftp.* scripts, and the ftpd.8 man page to
prevent them from being replaced, or you can edit the Makefile to
change the directory values:
BINDIR= /usr/local/bin
MANDIR= /usr/local/man/man8
ASW's practice is to rename binaries with a suffix that indicates the
original distribution from which they were obtained, i.e., in.ftpd.203
for the version distributed with Minix 2.0.3, or with a date code or a
version number.
If you are sure you want to replace the original ftpd provided with your
distribution you may want to copy the contents of the unpacked tarball
to the main directory tree, in this case /usr/src/commands/ftpd, so that
a new version will be compiled if you do a general recompilation of all
commands using "make all" or "make compile" in /usr/src. ASW's practice
is generally to make a directory in /usr/local/src for new versions of
major programs.
Also note that if you create a new man page where one did not exist
previously you will need to run makewhatis to rebuild the whatis
database, i.e.:
makewhatis /usr/man
or
makewhatis /usr/local/man
Important: the scripts for setting up and maintaining an anonymous ftp
installation haven't been checked for a long time, I would appreciate
comments.
ASW 2005-02-06

134
commands/ftpd200/access.c Normal file
View file

@ -0,0 +1,134 @@
/* access.c Copyright 1992-2000 by Michael Temari All Rights Reserved
*
* This file is part of ftpd.
*
* This file handles:
*
* USER PASS QUIT
*
*
* 01/25/96 Initial Release Michael Temari, <Michael@TemWare.Com>
*/
#include <sys/types.h>
#include <stdio.h>
#include <string.h>
#include <pwd.h>
#include <stdlib.h>
#include <unistd.h>
#include <net/gen/in.h>
#include <net/gen/tcp.h>
#include "ftpd.h"
#include "access.h"
_PROTOTYPE(static int AreWeIn, (char *name, struct passwd *pwd));
static char *msg530 = "530 Not logged in.\r\n";
/* Returns -1 = not logged in, 0 = loggedin */
int ChkLoggedIn()
{
if(!loggedin) {
printf(msg530);
return(-1);
} else
return(0);
}
/* what a USER! */
int doUSER(buff)
char *buff;
{
loggedin = 0;
gotuser = 0;
strncpy(username, buff, sizeof(username));
username[sizeof(username)-1] = '\0';
if(*username == '\0') {
printf("501 Bad user name.\r\n");
return(GOOD);
}
gotuser = 1;
printf("331 Password required for %s.\r\n", username);
return(GOOD);
}
/* secret, secret, secret */
int doPASS(buff)
char *buff;
{
char *name;
struct passwd *pwd;
int bad=0;
name = username;
if(!strcmp(name, "anonymous"))
name = "ftp";
if(!gotuser || ((pwd = getpwnam(name)) == (struct passwd *)0))
bad = 1;
else
if(strcmp(name, "ftp")) {
if(!strcmp(pwd->pw_passwd, crypt("", pwd->pw_passwd)))
bad = 1;
if(strcmp(pwd->pw_passwd, crypt(buff, pwd->pw_passwd)))
bad = 1;
} else {
strncpy(anonpass, buff, sizeof(anonpass));
anonpass[sizeof(anonpass)-1] = '\0';
}
if(bad) {
logit("LOGIN", "FAIL");
printf(msg530);
return(GOOD);
}
return(AreWeIn(name, pwd));
}
/* bye, bye don't let the door hit you in the butt on the way out */
int doQUIT(buff)
char *buff;
{
printf("221 Service closing, don't be a stranger.\r\n");
return(BAD);
}
/* see if this user is okay */
static int AreWeIn(name, pwd)
char *name;
struct passwd *pwd;
{
if(!strcmp(name, "ftp")) {
if(chroot(pwd->pw_dir)) {
logit("LOGIN", "FAIL");
printf("530 Not logged in, could not chroot.\r\n");
return(GOOD);
}
strncpy(newroot, pwd->pw_dir, sizeof(newroot));
newroot[sizeof(newroot)-1] = '\0';
anonymous = 1;
strcpy(pwd->pw_dir, "/");
}
if(setgid(pwd->pw_gid) || setuid(pwd->pw_uid) || chdir(pwd->pw_dir)) {
logit("LOGIN", "FAIL");
printf(msg530);
anonymous = 0;
} else {
logit("LOGIN", "PASS");
showmsg("230", (char *)NULL);
printf("230 User %s logged in, directory %s.\r\n",
username, pwd->pw_dir);
loggedin = 1;
}
return(GOOD);
}

12
commands/ftpd200/access.h Normal file
View file

@ -0,0 +1,12 @@
/* ftpd.h
*
* This file is part of ftpd.
*
*
* 01/25/96 Initial Release Michael Temari, <Michael@TemWare.Com>
*/
_PROTOTYPE(int ChkLoggedIn, (void));
_PROTOTYPE(int doUSER, (char *buff));
_PROTOTYPE(int doPASS, (char *buff));
_PROTOTYPE(int doQUIT, (char *buff));

1252
commands/ftpd200/file.c Normal file

File diff suppressed because it is too large Load diff

32
commands/ftpd200/file.h Normal file
View file

@ -0,0 +1,32 @@
/* file.h Copyright 1992-2000 by Michael Temari All Rights Reserved
*
* This file is part of ftpd.
*
*
* 01/25/96 Initial Release Michael Temari, <Michael@TemWare.Com>
*/
_PROTOTYPE(int doALLO, (char *buff));
_PROTOTYPE(int doAPPE, (char *buff));
_PROTOTYPE(int doCDUP, (char *buff));
_PROTOTYPE(int doCWD, (char *buff));
_PROTOTYPE(int doDELE, (char *buff));
_PROTOTYPE(int doLIST, (char *buff));
_PROTOTYPE(int doMDTM, (char *buff));
_PROTOTYPE(int doMODE, (char *buff));
_PROTOTYPE(int doMKD, (char *buff));
_PROTOTYPE(int doNLST, (char *buff));
_PROTOTYPE(int doPWD, (char *buff));
_PROTOTYPE(int doREST, (char *buff));
_PROTOTYPE(int doRETR, (char *buff));
_PROTOTYPE(int doRMD, (char *buff));
_PROTOTYPE(int doRNFR, (char *buff));
_PROTOTYPE(int doRNTO, (char *buff));
_PROTOTYPE(int doSITE, (char *buff));
_PROTOTYPE(int doSIZE, (char *buff));
_PROTOTYPE(int doSTAT, (char *buff));
_PROTOTYPE(int doSTOR, (char *buff));
_PROTOTYPE(int doSTOU, (char *buff));
_PROTOTYPE(int doSTRU, (char *buff));
_PROTOTYPE(int doSYST, (char *buff));
_PROTOTYPE(int doTYPE, (char *buff));

161
commands/ftpd200/ftpd.8 Normal file
View file

@ -0,0 +1,161 @@
.\" Copyright (c) 1985 Regents of the University of California.
.\" All rights reserved. The Berkeley software License Agreement
.\" specifies the terms and conditions for redistribution.
.\"
.\" @(#)ftpd.8c 6.4 (Berkeley) 5/28/86
.\"
.TH FTPD 8
.SH NAME
ftpd, in.ftpd, ftpdsh, setup.anonftp \- DARPA Internet File Transfer Protocol server
.SH SYNOPSIS
.B "ftp stream tcp nowait root /usr/bin/in.ftpd in.ftpd"
.br
.B "tcpd ftp /usr/bin/in.ftpd"
.SH DESCRIPTION
.B Ftpd
is the DARPA Internet File Transfer Prototocol
server process. The server uses the TCP protocol
and listens at the port specified in the ``ftp''
service specification; see
.BR services (5).
.PP
The ftp server currently supports the following ftp
requests; case is not distinguished.
.PP
.nf
.ta \w'Request 'u
\fBRequest Description\fP
ABOR abort previous command
ACCT specify account (ignored)
ALLO allocate storage (vacuously)
APPE append to a file
CDUP change to parent of current working directory
CWD change working directory
DELE delete a file
HELP give help information
LIST give list files in a directory (``ls -lA'')
MKD make a directory
MODE specify data transfer \fImode\fP
NLST give name list of files in directory (``ls'')
NOOP do nothing
PASS specify password
PASV prepare for server-to-server transfer
PORT specify data connection port
PWD print the current working directory
QUIT terminate session
RETR retrieve a file
RMD remove a directory
RNFR specify rename-from file name
RNTO specify rename-to file name
STOR store a file
STOU store a file with a unique name
STRU specify data transfer \fIstructure\fP
TYPE specify data transfer \fItype\fP
USER specify user name
XCUP change to parent of current working directory
XCWD change working directory
XMKD make a directory
XPWD print the current working directory
XRMD remove a directory
.fi
.PP
The remaining ftp requests specified in Internet RFC 959 are
recognized, but not implemented.
.PP
The ftp server will abort an active file transfer only when the
ABOR command is preceded by a Telnet "Interrupt Process" (IP)
signal and a Telnet "Synch" signal in the command Telnet stream,
as described in Internet RFC 959.
.PP
.B Ftpd
interprets file names according to the ``globbing''
conventions used by
.BR csh (1).
This allows users to utilize the metacharacters ``*?[]{}~''.
.PP
.B Ftpd
authenticates users according to two rules.
.IP 1)
The user name must be in the password data base,
.BR /etc/passwd ,
and not have a null password. In this case a password
must be provided by the client before any file operations
may be performed.
.IP 2)
If the user name is ``anonymous'' or ``ftp'', an
anonymous ftp account must be present in the password
file (user ``ftp''). In this case the user is allowed
to log in by specifying any password (by convention this
is given as the client host's name).
.PP
In the last case,
.B ftpd
takes special measures to restrict the client's access privileges.
The server performs a
.BR chroot (2)
command to the home directory of the ``ftp'' user.
In order that system security is not breached, it is recommended
that the ``ftp'' subtree be constructed with care; the following
rules are recommended.
.IP ~ftp)
Make the home directory owned by ``ftp'' and unwritable by anyone.
.IP ~ftp/bin)
Make this directory owned by the super-user and unwritable by
anyone. The program
.BR ls (1)
must be present to support the list commands.
Also,
.BR crc (1)
must be present to support generating crcs using the site command,
.BR tar (1)
and
.BR compress (1)
must be present to support on-the-fly generation of .tar and .tar.Z archives,
.BR gzip (1)
must be present to support gzip compression, and
.BR sh (1)
must be present to support
.BR ftpdsh (8)
which also must be present.
.BR ftpdsh controls which binaries can be used.
These programs should all have mode 111.
.IP ~ftp/etc)
Make this directory owned by the super-user and unwritable by
anyone. The files
.BR passwd (5)
and
.BR group (5)
must be present for the
.B ls
command to work properly. These files should be mode 444. They can (and
should) be stripped down versions so as not to reveal names of users who
are not owners of files in the ~ftp/pub directory tree.
.IP ~ftp/pub)
Make this directory mode 755 and owned by the super-user. Create
directories in it owned by users if those users want to manage an
anonymous ftp directory.
.IP ~ftp/pub/incoming)
Optionally create this directory for anonymous uploads. Make it mode
777. The FTP daemon will create files with mode 266, so remote users
can write a file, but only local users can do something with it.
.PP
The script
.B setup.anonftp
can be used to create or check an anonymous FTP tree.
.SH "SEE ALSO"
.BR ftp (1).
.SH BUGS
The anonymous account is inherently dangerous and should
avoided when possible.
.ig \" Minix doesn't have privileged port numbers (yet?)
.PP
The server must run as the super-user
to create sockets with privileged port numbers. It maintains
an effective user id of the logged in user, reverting to
the super-user only when binding addresses to sockets. The
possible security holes have been extensively
scrutinized, but are possibly incomplete.
..
.\" man page updated by Al Woodhull 2005-02-25

405
commands/ftpd200/ftpd.c Normal file
View file

@ -0,0 +1,405 @@
/* ftpd.c Copyright 1992-2000 by Michael Temari All Rights Reserved
*
* ftpd An FTP server program for use with Minix.
*
* Usage: Minix usage: tcpd ftp ftpd
*
* 06/14/92 Tnet Release Michael Temari
* 01/15/96 0.30 Michael Temari
* 01/25/96 0.90 Michael Temari
* 03/17/96 0.91 Michael Temari
* 06/27/96 0.92 Michael Temari
* 07/02/96 0.93 Michael Temari
* 07/15/96 0.94 Michael Temari
* 08/27/96 0.95 Michael Temari
* 02/09/97 0.96 Michael Temari
* 02/10/97 0.97 Michael Temari
* 09/25/97 0.98 Michael Temari
* 03/10/00 0.99 Michael Temari, <Michael@TemWare.Com>
* 12/12/03 1.00 Michael Temari, <Michael@TemWare.Com>
* 02/06/05 1.01 Michael Temari, <Michael@TemWare.Com>
* 02/12/05 2.00 Michael Temari, <Michael@TemWare.Com>
*/
char *FtpdVersion = "2.00";
#include <sys/types.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <net/gen/in.h>
#include <net/gen/tcp.h>
#include "ftpd.h"
#include "access.h"
#include "file.h"
#include "net.h"
_PROTOTYPE(static void init, (void));
_PROTOTYPE(static int doHELP, (char *buff));
_PROTOTYPE(static int doNOOP, (char *buff));
_PROTOTYPE(static int doUNIMP, (char *buff));
_PROTOTYPE(static int getline, (char *line, int len));
FILE *msgfile = (FILE *)NULL;
/* The following defines the inactivity timeout in seconds */
#define INACTIVITY_TIMEOUT 60*5
char *days[] = {"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"};
char *months[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun",
"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"};
char line[512];
int type, format, mode, structure;
int ftpdata_fd = -1;
int loggedin, gotuser, anonymous;
char username[80];
char anonpass[128];
char newroot[128];
ipaddr_t myipaddr, rmtipaddr, dataaddr;
tcpport_t myport, rmtport, dataport;
char myhostname[256], rmthostname[256];
#define FTPD_LOG "/usr/adm/ftpd.log"
#define FTPD_MSG "/etc/ftpd_msg"
FILE *logfile;
int timeout = 0;
_PROTOTYPE(static int doHELP, (char *buff));
_PROTOTYPE(int readline, (char **args));
_PROTOTYPE(void Timeout, (int sig));
_PROTOTYPE(int main, (int argc, char *argv[]));
struct commands {
char *name;
_PROTOTYPE(int (*func), (char *buff));
};
struct commands commands[] = {
"ABOR", doUNIMP,
"ACCT", doUNIMP,
"ALLO", doALLO,
"APPE", doAPPE,
"CDUP", doCDUP,
"CWD", doCWD,
"DELE", doDELE,
"HELP", doHELP,
"LIST", doLIST,
"MDTM", doMDTM,
"MKD", doMKD,
"MODE", doMODE,
"NLST", doNLST,
"NOOP", doNOOP,
"PASS", doPASS,
"PASV", doPASV,
"PORT", doPORT,
"PWD", doPWD,
"QUIT", doQUIT,
"REIN", doUNIMP,
"REST", doREST,
"RETR", doRETR,
"RMD", doRMD,
"RNFR", doRNFR,
"RNTO", doRNTO,
"SITE", doSITE,
"SIZE", doSIZE,
"SMNT", doUNIMP,
"STAT", doSTAT,
"STOR", doSTOR,
"STOU", doSTOU,
"STRU", doSTRU,
"SYST", doSYST,
"TYPE", doTYPE,
"USER", doUSER,
"XCUP", doCDUP,
"XCWD", doCWD,
"XMKD", doMKD,
"XPWD", doPWD,
"XRMD", doRMD,
"", (int (*)())0
};
static void init()
{
loggedin = 0;
gotuser = 0;
anonymous = 0;
newroot[0] = '\0';
type = TYPE_A;
format = 0;
mode = MODE_S;
structure = 0;
ftpdata_fd = -1;
username[0] = '\0';
anonpass[0] = '\0';
}
/* nothing, nada, zilch... */
static int doNOOP(buff)
char *buff;
{
printf("200 NOOP to you too!\r\n");
return(GOOD);
}
/* giv'em help, what a USER! */
static int doHELP(buff)
char *buff;
{
struct commands *cmd;
char star;
int i;
char *space = " ";
printf("214-Here is a list of available ftp commands\r\n");
printf(" Those with '*' are not yet implemented.\r\n");
i = 0;
for(cmd = commands; *cmd->name != '\0'; cmd++) {
if(cmd->func == doUNIMP)
star = '*';
else
star = ' ';
printf(" %s%c%s", cmd->name, star, space + strlen(cmd->name));
if(++i == 6) {
printf("\r\n");
i = 0;
}
}
if(i)
printf("\r\n");
printf("214 That's all the help you get.\r\n");
return(GOOD);
}
/* not implemented */
static int doUNIMP(buff)
char *buff;
{
printf("502 Command \"%s\" not implemented!\r\n", line);
return(GOOD);
}
/* convert line for use */
void cvtline(args)
char **args;
{
char *p;
p = line + strlen(line);
while(--p >= line)
if(*p == '\r' || *p == '\n' || isspace(*p))
*p = '\0';
else
break;
p = line;
#ifdef DEBUG
logit("COMMAND", line);
#endif
while(*p && !isspace(*p)) {
*p = toupper(*p);
p++;
}
if(*p) {
*p = '\0';
p++;
while(*p && isspace(*p))
p++;
}
*args = p;
return;
}
static int getline(line, len)
char *line;
int len;
{
int s;
int gotcr;
/* leave room for at end for null */
len--;
/* got to be able to put in at least 1 character */
if(len < 1)
return(-1);
gotcr = 0;
while(len-- > 0) {
s = read(0, line, 1);
if(s != 1)
return(-1);
if(*line == '\n')
break;
gotcr = (*line == '\r');
line++;
}
if(gotcr)
--line;
*line = '\0';
return(0);
}
int readline(args)
char **args;
{
if(getline(line, sizeof(line)))
return(BAD);
cvtline(args);
return(GOOD);
}
/* signal handler for inactivity timeout */
void Timeout(sig)
int sig;
{
timeout = 1;
printf("421 Inactivity timer expired.\r\n");
}
/* logit */
void logit(type, parm)
char *type;
char *parm;
{
time_t now;
struct tm *tm;
if(logfile == (FILE *)NULL)
return;
time(&now);
tm = localtime(&now);
fprintf(logfile, "%4d%02d%02d%02d%02d%02d ",
1900+tm->tm_year,
tm->tm_mon + 1,
tm->tm_mday,
tm->tm_hour, tm->tm_min, tm->tm_sec);
fprintf(logfile, "%s %s %s %s %s\n",
rmthostname, username, anonymous ? anonpass : username, type, parm);
fflush(logfile);
}
void showmsg(reply, filename)
char *reply;
char *filename;
{
FILE *mfp;
char *pe;
static char mline[256];
if(filename == (char *)NULL)
mfp = msgfile;
else
mfp = fopen(filename, "r");
if(mfp == (FILE *)NULL)
return;
while(fgets(mline, sizeof(mline), mfp) != (char *)NULL) {
pe = mline + strlen(mline);
while(--pe >= mline)
if(*pe == '\r' || *pe == '\n')
*pe = '\0';
else
break;
printf("%s- %s\r\n", reply, mline);
}
if(filename != (char *)NULL)
fclose(mfp);
}
int main(argc, argv)
int argc;
char *argv[];
{
struct commands *cmd;
char *args;
int status;
time_t now;
struct tm *tm;
int s;
GetNetInfo();
/* open transfer log file if it exists */
if((logfile = fopen(FTPD_LOG, "r")) != (FILE *)NULL) {
fclose(logfile);
logfile = fopen(FTPD_LOG, "a");
}
/* open login msg file */
msgfile = fopen(FTPD_MSG, "r");
/* Let's initialize some stuff */
init();
/* Log the connection */
logit("CONNECT", "");
/* Tell 'em we are ready */
time(&now);
tm = localtime(&now);
printf("220 FTP service (Ftpd %s) ready on %s at ",
FtpdVersion, myhostname);
printf("%s, %02d %s %d %02d:%02d:%02d %s\r\n", days[tm->tm_wday],
tm->tm_mday, months[tm->tm_mon], 1900+tm->tm_year,
tm->tm_hour, tm->tm_min, tm->tm_sec,
tzname[tm->tm_isdst]);
fflush(stdout);
/* Loop here getting commands */
while(1) {
signal(SIGALRM, Timeout);
alarm(INACTIVITY_TIMEOUT);
if(readline(&args) != GOOD) {
if(!timeout)
printf("221 Control connection closing (EOF).\r\n");
break;
}
alarm(0);
for(cmd = commands; *cmd->name != '\0'; cmd++)
if(!strcmp(line, cmd->name))
break;
if(*cmd->name != '\0')
status = (*cmd->func)(args);
else {
printf("500 Command \"%s\" not recognized.\r\n", line);
status = GOOD;
}
fflush(stdout);
if(status != GOOD)
break;
}
CleanUpPasv();
return(-1);
}

37
commands/ftpd200/ftpd.h Normal file
View file

@ -0,0 +1,37 @@
/* ftpd.h Copyright 1992-2000 by Michael Temari All Rights Reserved
*
* This file is part of ftpd.
*
*
* 01/25/96 Initial Release Michael Temari, <Michael@TemWare.Com>
*/
#define GOOD 0
#define BAD 1
#define TYPE_A 0
#define TYPE_I 1
#define MODE_S 0
#define MODE_B 1
#define MODE_B_EOF 64
extern char *FtpdVersion;
extern int type, format, mode, structure;
extern ipaddr_t myipaddr, rmtipaddr, dataaddr;
extern tcpport_t myport, rmtport, dataport;
extern int ftpdata_fd;
extern int loggedin, gotuser, anonymous;
extern char newroot[128];
extern char *days[], *months[];
extern char username[80];
extern char anonpass[128];
extern char myhostname[256], rmthostname[256];
extern char line[512];
extern FILE *logfile;
_PROTOTYPE(void cvtline, (char **args));
_PROTOTYPE(void logit, (char *type, char *parm));
_PROTOTYPE(void showmsg, (char *reply, char *filename));

14
commands/ftpd200/ftpdsh Executable file
View file

@ -0,0 +1,14 @@
#!/bin/sh
case $1 in
1) ls -A $2 ;;
2) ls -la $2 ;;
3) crc $2 ;;
12) tar cf - $2 ;;
13) tar cf - $2 | compress -q ;;
14) compress -cq $2 ;;
15) tar cf - $2 | gzip ;;
16) tar -c $2 ;;
17) compress -dcq $2 ;;
esac
exit

431
commands/ftpd200/net.c Normal file
View file

@ -0,0 +1,431 @@
/* net.c Copyright 1992-2000 by Michael Temari All Rights Reserved
*
* This file is part of ftpd.
*
* This file handles:
*
* PASV PORT
*
*
* 01/25/1995 Initial Release Michael Temari, <Michael@TemWare.Com>
* 02/09/2005 Initial Release Michael Temari, <Michael@TemWare.Com>
*/
#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/wait.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <errno.h>
#include <fcntl.h>
#include <signal.h>
#include <unistd.h>
#include <time.h>
#include <net/netlib.h>
#include <net/hton.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/socket.h>
#include <net/gen/netdb.h>
#include "ftpd.h"
#include "access.h"
#include "net.h"
_PROTOTYPE(static void timeout, (int sig));
static char *msg425 = "425-Could not open data connection.\r\n";
static char *msg501 = "501 Syntax error in parameters.\r\n";
static int gottimeout = 0;
static int lpid = -1;
static int didpassive = 0;
/* they must be behind a firewall or using a web browser */
int doPASV(buff)
char *buff;
{
nwio_tcpconf_t tcpconf;
nwio_tcpcl_t tcplopt;
char *tcp_device;
ipaddr_t ipaddr;
tcpport_t lport;
int s;
time_t starttime;
int retry;
if(ChkLoggedIn())
return(GOOD);
CleanUpPasv();
/* here we set up a connection to listen on */
if((tcp_device = getenv("TCP_DEVICE")) == NULL)
tcp_device = TCP_DEVICE;
if(ftpdata_fd >= 0) {
close(ftpdata_fd);
ftpdata_fd = -1;
}
if((ftpdata_fd = open(tcp_device, O_RDWR)) < 0) {
printf(msg425);
printf("425 Could not open tcp_device. Error %s\r\n", strerror(errno));
return(GOOD);
}
tcpconf.nwtc_flags = NWTC_LP_SEL | NWTC_SET_RA | NWTC_UNSET_RP;
tcpconf.nwtc_remaddr = rmtipaddr;
tcpconf.nwtc_remport = htons(0);
tcpconf.nwtc_locport = htons(0);
s = ioctl(ftpdata_fd, NWIOSTCPCONF, &tcpconf);
if(s < 0) {
printf(msg425);
printf("425 Could not ioctl NWIOSTCPCONF. Error %s\r\n", strerror(errno));
close(ftpdata_fd);
ftpdata_fd = -1;
return(GOOD);
}
s = ioctl(ftpdata_fd, NWIOGTCPCONF, &tcpconf);
if(s < 0) {
printf(msg425);
printf("425 Could not NWIOGTCPCONF. Error %s\r\n", strerror(errno));
close(ftpdata_fd);
ftpdata_fd = -1;
return(GOOD);
}
ipaddr = tcpconf.nwtc_locaddr;
lport = tcpconf.nwtc_locport;
/* Now lets fork a child to do the listening :-( */
tcplopt.nwtcl_flags = 0;
lpid = fork();
if(lpid < 0) {
printf(msg425);
printf("425 Could not fork listener. Error %s\r\n", strerror(errno));
close(ftpdata_fd);
ftpdata_fd = -1;
return(GOOD);
} else if(lpid == 0) {
retry = 0;
while(1) {
#ifdef DEBUG
fprintf(logfile, "ftpd: child %d parent %d listen try %d\n", getpid(), getppid(), retry);
fflush(logfile);
#endif
s = ioctl(ftpdata_fd, NWIOTCPLISTEN, &tcplopt);
if(!(s == -1 && errno == EAGAIN)) break;
if(retry++ > 10) break;
sleep(1);
}
#ifdef DEBUG
fprintf(logfile, "ftpd: child %d s %d errno %d\n", getpid(), s, errno);
fflush(logfile);
#endif
if(s < 0)
exit(errno); /* tells parent listen failed */
else
exit(0); /* tells parent listen okay */
}
#ifdef DEBUG
fprintf(logfile, "ftpd: parent %d wait for %d\n", getpid(), lpid);
fflush(logfile);
#endif
/* wait for child to be listening, no more than serveral seconds */
(void) time(&starttime);
while(1) {
if(time((time_t *)NULL) > (starttime + 15)) break;
signal(SIGALRM, timeout);
alarm(1);
s = ioctl(ftpdata_fd, NWIOGTCPCONF, &tcpconf);
#ifdef DEBUG
fprintf(logfile, "ftpd: parent %d child %d s %d errno %d start %ld now %ld\n",
getpid(), lpid, s, errno, starttime, time((time_t *)NULL));
fflush(logfile);
#endif
alarm(0);
if(s == -1) break;
sleep(1);
}
#define hiword(x) ((u16_t)((x) >> 16))
#define loword(x) ((u16_t)(x & 0xffff))
#define hibyte(x) (((x) >> 8) & 0xff)
#define lobyte(x) ((x) & 0xff)
printf("227 Entering Passive Mode (%u,%u,%u,%u,%u,%u).\r\n",
hibyte(hiword(htonl(ipaddr))), lobyte(hiword(htonl(ipaddr))),
hibyte(loword(htonl(ipaddr))), lobyte(loword(htonl(ipaddr))),
hibyte(htons(lport)), lobyte(htons(lport)));
#ifdef DEBUG
fprintf(logfile, "ftpd: parent %d child %d send 227\n", getpid(), lpid);
fflush(logfile);
#endif
didpassive = -1;
return(GOOD);
}
/* they want us to connect here */
int doPORT(buff)
char *buff;
{
u32_t ipaddr;
u16_t port;
int i;
if(ftpdata_fd >= 0) {
close(ftpdata_fd);
ftpdata_fd = -1;
}
ipaddr = (u32_t)0;
for(i = 0; i < 4; i++) {
ipaddr = (ipaddr << 8) + (u32_t)atoi(buff);
if((buff = strchr(buff, ',')) == (char *)0) {
printf(msg501);
return(GOOD);
}
buff++;
}
port = (u16_t)atoi(buff);
if((buff = strchr(buff, ',')) == (char *)0) {
printf(msg501);
return(0);
}
buff++;
port = (port << 8) + (u16_t)atoi(buff);
dataaddr = htonl(ipaddr);
dataport = htons(port);
if(dataaddr != rmtipaddr) {
printf(msg501);
return(GOOD);
}
printf("200 Port command okay.\r\n");
return(GOOD);
}
/* connect, huh? */
int DataConnect()
{
nwio_tcpconf_t tcpconf;
nwio_tcpcl_t tcpcopt;
nwio_tcpcl_t tcplopt;
char *tcp_device;
int s, cs;
int retry;
if(didpassive && ftpdata_fd >= 0) {
didpassive = 0;
gottimeout = 0;
signal(SIGALRM, timeout);
alarm(10);
while(!gottimeout) {
s = waitpid(lpid, &cs, 0);
if((s == lpid) || (s < 0 && errno == ECHILD)) break;
#ifdef DEBUG
fprintf(logfile, "ftpd: parent %d child %d waitpid s %d cs %04x errno %d\n", getpid(), lpid, s, cs, errno);
fflush(logfile);
#endif
}
alarm(0);
#ifdef DEBUG
fprintf(logfile, "ftpd: parent %d child %d waitpid s %d cs %04x errno %d\n", getpid(), lpid, s, cs, errno);
fflush(logfile);
#endif
if(gottimeout) {
#ifdef DEBUG
fprintf(logfile, "ftpd: parent %d child %d got timeout\n", getpid(), lpid);
fflush(logfile);
#endif
kill(lpid, SIGKILL);
s = waitpid(lpid, &cs, 0);
}
#ifdef DEBUG
fprintf(logfile, "ftpd: parent %d child %d continuing\n", getpid(), lpid);
fflush(logfile);
#endif
lpid = -1;
if(gottimeout) {
printf(msg425);
printf("425 Child listener timeout.\r\n");
close(ftpdata_fd);
ftpdata_fd = -1;
return(BAD);
}
if(s < 0) {
printf(msg425);
printf("425 Child listener vanished.\r\n");
close(ftpdata_fd);
ftpdata_fd = -1;
return(BAD);
}
if((cs & 0x00ff)) {
printf(msg425);
printf("425 Child listener failed %04x\r\n", cs);
close(ftpdata_fd);
ftpdata_fd = -1;
return(BAD);
}
cs = (cs >> 8) & 0x00ff;
if(cs) {
printf(msg425);
printf("425 Child listener error %s\r\n", strerror(cs));
close(ftpdata_fd);
ftpdata_fd = -1;
return(BAD);
}
#ifdef DEBUG
fprintf(logfile, "ftpd: parent %d child %d pasv done\n", getpid(), lpid);
fflush(logfile);
#endif
return(GOOD);
}
if(ftpdata_fd >= 0)
return(GOOD);
if((tcp_device = getenv("TCP_DEVICE")) == NULL)
tcp_device = TCP_DEVICE;
if((ftpdata_fd = open(tcp_device, O_RDWR)) < 0) {
printf(msg425);
printf("425 Could not open tcp_device. Error %s\r\n", strerror(errno));
return(BAD);
}
tcpconf.nwtc_flags = NWTC_LP_SET | NWTC_SET_RA | NWTC_SET_RP;
tcpconf.nwtc_remaddr = dataaddr;
tcpconf.nwtc_remport = dataport;
tcpconf.nwtc_locport = htons(20);
s = ioctl(ftpdata_fd, NWIOSTCPCONF, &tcpconf);
if(s < 0) {
printf(msg425);
printf("425 Could not ioctl NWIOSTCPCONF. Error %s\r\n", strerror(errno));
close(ftpdata_fd);
ftpdata_fd = -1;
return(BAD);
}
s = ioctl(ftpdata_fd, NWIOGTCPCONF, &tcpconf);
if(s < 0) {
printf(msg425);
printf("425 Could not ioctl NWIOGTCPCONF. Error %s\r\n", strerror(errno));
close(ftpdata_fd);
ftpdata_fd = -1;
return(BAD);
}
tcpcopt.nwtcl_flags = 0;
retry = 0;
do {
#ifdef DEBUG
fprintf(logfile, "try connect\n"); fflush(logfile);
fflush(logfile);
#endif
sleep(2);
s = ioctl(ftpdata_fd, NWIOTCPCONN, &tcpcopt);
#ifdef DEBUG
fprintf(logfile, "after connect %d %d\n", s, errno);
fflush(logfile);
#endif
if(!(s == -1 && errno == EAGAIN)) break;
if(retry++ > 10) break;
sleep(1);
} while(1);
if(s < 0) {
printf(msg425);
printf("425 Could not ioctl NWIOTCPCONN. Error %s\r\n", strerror(errno));
close(ftpdata_fd);
ftpdata_fd = -1;
return(BAD);
}
s = ioctl(ftpdata_fd, NWIOGTCPCONF, &tcpconf);
if(s < 0) {
printf(msg425);
printf("425 Could not ioctl NWIOGTCPCONF. Error %s\r\n", strerror(errno));
close(ftpdata_fd);
ftpdata_fd = -1;
return(BAD);
}
return(GOOD);
}
/* Clean up stuff we did to get a Pasv connection going */
int CleanUpPasv()
{
int s, cs;
if(lpid >= 0) {
kill(lpid, SIGKILL);
while(1) {
s = waitpid(lpid, &cs, 0);
if(s == lpid || (s == -1 && errno == ECHILD))
break;
}
}
lpid = -1;
didpassive = 0;
return(GOOD);
}
void GetNetInfo()
{
nwio_tcpconf_t tcpconf;
int s;
struct hostent *hostent;
/* Ask the system what our hostname is. */
if(gethostname(myhostname, sizeof(myhostname)) < 0)
strcpy(myhostname, "unknown");
/* lets get our ip address and the clients ip address */
s = ioctl(0, NWIOGTCPCONF, &tcpconf);
if(s < 0) {
printf("421 FTP service unable to get remote ip address. Closing.\r\n");
fflush(stdout);
exit(1);
}
myipaddr = tcpconf.nwtc_locaddr;
myport = tcpconf.nwtc_locport;
rmtipaddr = tcpconf.nwtc_remaddr;
rmtport = tcpconf.nwtc_remport;
/* Look up the host name of the remote host. */
hostent = gethostbyaddr((char *) &rmtipaddr, sizeof(rmtipaddr), AF_INET);
if(!hostent)
strcpy(rmthostname, inet_ntoa(rmtipaddr));
else {
strncpy(rmthostname, hostent->h_name, sizeof(rmthostname)-1);
rmthostname[sizeof(rmthostname)-1] = '\0';
}
}
static void timeout(sig)
int sig;
{
gottimeout = 1;
}

13
commands/ftpd200/net.h Normal file
View file

@ -0,0 +1,13 @@
/* net.h Copyright 1992-2000 by Michael Temari All Rights Reserved
*
* This file is part of ftpd.
*
*
* 01/25/96 Initial Release Michael Temari, <Michael@TemWare.Com>
*/
_PROTOTYPE(int doPASV, (char *buff));
_PROTOTYPE(int doPORT, (char *buff));
_PROTOTYPE(int DataConnect, (void));
_PROTOTYPE(int CleanUpPasv, (void));
_PROTOTYPE(void GetNetInfo, (void));

75
commands/ftpd200/setup.anonftp Executable file
View file

@ -0,0 +1,75 @@
#!/bin/sh
# setup.anonftp - Anonymous FTP setup and maintenance.
#
# 01/22/96 Initial Release Al Woodhul, <asw@hampshire.edu>
# 01/25/96 Michael Temari, <temari@ix.netcom.com>
#
# What is needed for anon ftp
# ref: Hunt TCP/IP Net Admin pp. 338++
# ref: Nemeth et al UNIX System Admin Handbook p. 295
# ref: mail from M. Temari 18.01.96
# programs possibly used by ftpd
PROGS="sh ls crc tar compress gzip"
echo Checking /etc/passwd
if grep '^ftp:[^:]*:[1-9][0-9]*:[1-9][0-9]*:[^:]*:/[^:]*:[^:]*$' \
/etc/passwd >/dev/null
then
echo -n "OK, ftp entry found: "
grep '^ftp:' /etc/passwd
else
echo "Found no entry for ftp in /etc/passwd, please add one with the"
echo "home directory pointing to the anonymous FTP directory"
exit 1
fi
# ftp directory
FTPDIR="`sed '/^ftp:/!d; s/^.*:\\([^:]*\\):[^:]*/\\1/' /etc/passwd`"
if [ `whoami` != root ]
then
echo You must be root to do this
exit 1
fi
echo Setting up for anonymous ftp
echo Making $FTPDIR and subdirectories
install -d -m 755 -o root -g operator $FTPDIR
install -d -m 751 -o root -g operator $FTPDIR/bin
install -d -m 751 -o root -g operator $FTPDIR/dev
install -d -m 751 -o root -g operator $FTPDIR/etc
install -d -m 755 -o root -g operator $FTPDIR/pub
incoming=
if [ -d $FTPDIR/pub/incoming ]
then
incoming=t
elif [ -t 0 ]
then
echo -n "Create \"incoming\" directory? [n] "; read yn
case "$yn" in
[yY]*|ok|sure) incoming=t
esac
fi
test "$incoming" && install -d -m 777 -o root -g operator $FTPDIR/pub/incoming
echo Copying files
for PROG in $PROGS
do
test -f /usr/bin/$PROG && install -lcs /usr/bin/$PROG $FTPDIR/bin
done
cp -rp /dev/tcp $FTPDIR/dev/tcp
install -lcs ftpdsh $FTPDIR/bin
echo Copying a minimum of the password and group files
sed 's/^\([^:]*\):[^:]*:\([^:]*:[^:]*\):.*$/\1:*:\2:::/' \
/etc/passwd >$FTPDIR/etc/passwd
sed 's/^\([^:]*\):[^:]*:\([^:]*\):.*$/\1:*:\2:/' \
/etc/group >$FTPDIR/etc/group
chown root:operator $FTPDIR/etc/*
chmod 444 $FTPDIR/etc/*
echo "Anonymous ftp setup complete"

View file

@ -7,9 +7,12 @@
* If you want to compile this for non-IBM PC architectures, the header files
* require that you have your CHIP, MACHINE etc. defined.
* Full syntax:
* ps [-][alx]
* ps [-][aeflx]
* Option `a' gives all processes, `l' for detailed info, `x' includes even
* processes without a terminal.
* The `f' and `e' options were added by Kees Bot for the convenience of
* Solaris users accustomed to these options. The `e' option is equivalent to
* `a' and `f' is equivalent to -l. These do not appear in the usage message.
*
* VERY IMPORTANT NOTE:
* To compile ps, the kernel/, fs/ and pm/ source directories must be in
@ -549,7 +552,7 @@ int nbytes;
void usage(pname)
char *pname;
{
fprintf(stderr, "Usage: %s [-][alx]\n", pname);
fprintf(stderr, "Usage: %s [-][aeflx]\n", pname);
exit(1);
}

View file

@ -55,6 +55,7 @@ struct pci_device pci_device_table[]=
{ 0x100B, 0xD001, "Nat. Semi. 87410" },
{ 0x1013, 0x00B8, "Cirrus Logic GD 5446" },
{ 0x1013, 0x6003, "Cirrus Logic CS4614/22/24 CrystalClear" },
{ 0x1022, 0x2000, "AMD Lance/PCI" },
{ 0x1022, 0x700C, "AMD-762 CPU to PCI Bridge (SMP chipset)" },
{ 0x1022, 0x700D, "AMD-762 CPU to PCI Bridge (AGP 4x)" },
{ 0x1022, 0x7410, "AMD-766 PCI to ISA/LPC Bridge" },
@ -100,20 +101,27 @@ struct pci_device pci_device_table[]=
{ 0x5333, 0x88d0, "S3 Vision 964 vers 0" },
{ 0x5333, 0x8a01, "S3 Virge/DX or /GX" },
{ 0x8086, 0x1004, "Intel 82543GC Gigabit Ethernet Controller" },
{ 0x8086, 0x1229, "Intel 82557" },
{ 0x8086, 0x1029, "Intel EtherExpressPro100 ID1029" },
{ 0x8086, 0x1030, "Intel Corporation 82559 InBusiness 10/100" },
{ 0x8086, 0x1209, "Intel EtherExpressPro100 82559ER" },
{ 0x8086, 0x1229, "Intel EtherExpressPro100 82557/8/9" },
{ 0x8086, 0x122D, "Intel 82437FX" },
{ 0x8086, 0x122E, "Intel 82371FB (PIIX)" },
{ 0x8086, 0x1230, "Intel 82371FB (IDE)" },
{ 0x8086, 0x1237, "Intel 82441FX (440FX)" },
{ 0x8086, 0x1250, "Intel 82439HX" },
{ 0x8086, 0x2449, "Intel EtherExpressPro100 82562EM" },
{ 0x8086, 0x7000, "Intel 82371SB" },
{ 0x8086, 0x7010, "Intel 82371SB (IDE)" },
{ 0x8086, 0x7020, "Intel 82371SB (USB)" },
{ 0x8086, 0x7030, "Intel 82437VX" }, /* asw 2005-03-02 */
{ 0x8086, 0x7100, "Intel 82371AB" }, /* asw 2004-07-31 */
{ 0x8086, 0x7100, "Intel 82371AB" },
{ 0x8086, 0x7110, "Intel 82371AB (PIIX4)" },
{ 0x8086, 0x7111, "Intel 82371AB (IDE)" },
{ 0x8086, 0x7112, "Intel 82371AB (USB)" },
{ 0x8086, 0x7113, "Intel 82371AB (Power)" },
{ 0x8086, 0x7124, "Intel 82801AA" }, /* asw 2004-11-09 */
{ 0x8086, 0x7190, "Intel 82443BX" },
{ 0x8086, 0x7191, "Intel 82443BX (AGP bridge)" },
{ 0x9004, 0x8178, "Adaptec AHA-2940U/2940UW Ultra/Ultra-Wide SCSI Ctrlr" },
@ -216,7 +224,9 @@ struct pci_intel_ctrl pci_intel_ctrl[]=
{ 0x8086, 0x122D, }, /* Intel 82437FX */
{ 0x8086, 0x1237, }, /* Intel 82441FX */
{ 0x8086, 0x1250, }, /* Intel 82439HX */
{ 0x8086, 0x7100, }, /* Intel 82371AB */
{ 0x8086, 0x7030, }, /* Intel 82437VX (asw 2005-03-02) */
{ 0x8086, 0x7100, }, /* Intel 82371AB (asw 2004-07-31) */
{ 0x8086, 0x7124, }, /* Intel 82801AA (asw 2004-11-09) */
{ 0x8086, 0x7190, }, /* Intel 82443BX */
{ 0x0000, 0x0000, },
};
@ -231,8 +241,10 @@ struct pci_isabridge pci_isabridge[]=
{ 0x1106, 0x3227, 1, PCI_IB_VIA, }, /* VIA */
{ 0x8086, 0x122E, 1, PCI_IB_PIIX, }, /* Intel 82371FB */
{ 0x8086, 0x7000, 1, PCI_IB_PIIX, }, /* Intel 82371SB */
{ 0x8086, 0x7100, 1, PCI_IB_PIIX, }, /* Intel 82371AB */
{ 0x8086, 0x7110, 1, PCI_IB_PIIX, }, /* Intel PIIX4 */
{ 0x8086, 0x7030, 1, PCI_IB_PIIX, }, /* Intel 82437VX (asw 2005-03-02) */
{ 0x8086, 0x7100, 1, PCI_IB_PIIX, }, /* Intel 82371AB (asw 2004-07-31) */
{ 0x8086, 0x7110, 1, PCI_IB_PIIX, }, /* Intel PIIX4 */
{ 0x8086, 0x7124, 1, PCI_IB_PIIX, }, /* Intel 82801AA (asw 2004-11-09) */
{ 0x0000, 0x0000, 0, 0, },
};

View file

@ -267,7 +267,7 @@ irq_hook_t *hook;
&& rdy_head[PPRI_USER] != NIL_PROC))
{
m.NOTIFY_TYPE = HARD_INT;
int_notify(CLOCK, &m);
lock_notify(CLOCK, &m);
}
else if (--sched_ticks <= 0) {
sched_ticks = SCHED_RATE; /* reset the quantum */

View file

@ -10,10 +10,9 @@
*
* As well as several entry points used from the interrupt and task level:
*
* lock_notify: send a notification to inform a process of a system event
* int_notify: same as above, but from an interrupt handler (no locking)
* lock_notify: notify a process of a system event
* lock_send: send a message to a process
* lock_ready: put a process on one of the ready queues so it can be run
* lock_ready: put a process on one of the ready queues
* lock_unready: remove a process from the ready queues
* lock_sched: a process has run too long; schedule another one
*
@ -438,36 +437,28 @@ PUBLIC int lock_notify(dst, m_ptr)
int dst; /* to whom is message being sent? */
message *m_ptr; /* pointer to message buffer */
{
/* Safe gateway to mini_notify() for tasks. Don't use this function from the
* interrupt level, as it will reenable interrupts (because of the unlock()
* call). For interrupt handlers, int_notify() is available.
/* Safe gateway to mini_notify() for tasks and interrupt handlers. MINIX
* kernel is not reentrant, which means to interrupts are disabled after
* the first kernel entry (hardware interrupt, trap, or exception). Locking
* work is done by temporarily disabling interrupts.
*/
int result;
register struct proc *caller_ptr;
lock(0, "notify");
caller_ptr = (k_reenter >= 0) ? proc_addr(HARDWARE) : proc_ptr;
result = mini_notify(caller_ptr, dst, m_ptr);
unlock(0);
/* Exception or interrupt occurred, thus already locked. */
if (k_reenter >= 0) {
result = mini_notify(proc_addr(HARDWARE), dst, m_ptr);
}
/* Call from task level, locking is required. */
else {
lock(0, "notify");
result = mini_notify(proc_ptr, dst, m_ptr);
unlock(0);
}
return(result);
}
/*==========================================================================*
* int_notify *
*==========================================================================*/
PUBLIC int int_notify(dst, m_ptr)
int dst; /* to whom is message being sent? */
message *m_ptr; /* pointer to message buffer */
{
/* Gateway to mini_notify() for interrupt handlers. This function doesn't
* use lock() and unlock() because interrupts are already disabled.
*/
int result;
register struct proc *caller_ptr = proc_addr(HARDWARE);
result = mini_notify(caller_ptr, dst, m_ptr);
return(result);
}
/*===========================================================================*
* pick_proc *

View file

@ -41,7 +41,6 @@ _PROTOTYPE( void free_bit, (bit_t nr, bitchunk_t *map, bit_t nr_bits) );
/* proc.c */
_PROTOTYPE( int sys_call, (int function, int src_dest, message *m_ptr) );
_PROTOTYPE( int lock_notify, (int dst, message *m_ptr) );
_PROTOTYPE( int int_notify, (int dst, message *m_ptr) );
_PROTOTYPE( int lock_send, (int dst, message *m_ptr) );
_PROTOTYPE( void lock_ready, (struct proc *rp) );
_PROTOTYPE( void lock_sched, (int queue) );

View file

@ -296,7 +296,7 @@ irq_hook_t *hook;
/* Build notification message and return. */
m.NOTIFY_TYPE = HARD_INT;
m.NOTIFY_ARG = hook->irq;
int_notify(hook->proc_nr, &m);
lock_notify(hook->proc_nr, &m);
return(hook->policy & IRQ_REENABLE);
}

View file

@ -352,7 +352,7 @@ date_of(register struct dsttype *dst, struct tm *timep)
tmpday = day;
day += (dst->ds_date[2] - firstday + 7) % 7
+ 7 * (dst->ds_date[1] - 1);
if (day >= tmpday + _ytab[leap][month]) day -= 7;
if (day >= tmpday + _ytab[leap][month-1]) day -= 7;
return day;
}

View file

@ -323,7 +323,7 @@ declared inside
not to the global variable named
.BR x .
.PP
The only special parameter than can be made local is ``\fB-\fR''.
The only special parameter that can be made local is ``\fB-\fR''.
Making ``\fB-\fR'' local any shell options that are changed via the
.I set
command inside the function to be restored to their original values
@ -1103,7 +1103,7 @@ echo(1), expr(1), line(1), pwd(1), true(1).
.SH BUGS
When command substitution occurs inside a here document, the commands inside
the here document are run with their standard input closed. For example,
the following will not word because the standard input of the
the following will not work because the standard input of the
.I line
command will be closed when the command is run:
.d
@ -1121,3 +1121,4 @@ as well as by a line containing the terminator word which follows the ``<<''.
What this means is that if you mistype the terminator line, the shell
will silently swallow up the rest of your shell script and stick it
in the here document.
.\" several minor typos corrected -- ASW 2005-01-15

View file

@ -18,7 +18,13 @@ Tapes can't be unloaded with this command, use
instead.
.SH "SEE ALSO"
.BR mt (1),
.BR hd (4),
.BR sd (4).
.BR disk (4),
.BR tape (4).
.SH AUTHOR
Kees J. Bot (kjb@cs.vu.nl)
.\" hd, sd changed to disk, tape -- ASW 2004-12-13

View file

@ -75,7 +75,7 @@ there, the initialization file is called "elvis.rc" instead.
.SH "SEE ALSO"
.BR ctags (1),
.BR ref (1),
.BR virec (1),
.BR elvrec (1),
.BR elvis (9).
.PP
\fIElvis - A Clone of Vi/Ex\fP, the complete \fBelvis\fP documentation.
@ -98,3 +98,4 @@ kirkenda@cs.pdx.edu
Many other people have worked to port \fBelvis\fP to various operating systems.
To see who deserves credit, run the \fB:version\fP command from within \fBelvis\fP,
or look in the system-specific section of the complete documentation.
.\" ref to virec chnaged to elvrec -- ASW 2004-12-13

View file

@ -631,7 +631,7 @@ on some systems).
library with which to link the scanners.
.SH "SEE ALSO"
.LP
flexdoc(1), lex(1), yacc(1), sed(1), awk(1).
flexdoc(1), lex(1), yacc(1), sed(1), awk(9).
.LP
M. E. Lesk and E. Schmidt,
.I LEX - Lexical Analyzer Generator
@ -777,3 +777,4 @@ required for POSIX-compliance.
The
.I flex
internal algorithms need documentation.
.\" ref. to awk(9) man page corrected -- ASW 2005-01-15

View file

@ -2380,7 +2380,7 @@ requires that at least one of the classes share characters.
See flex(1).
.SH "SEE ALSO"
.LP
flex(1), lex(1), yacc(1), sed(1), awk(1).
flex(1), lex(1), yacc(1), sed(1), awk(9).
.LP
M. E. Lesk and E. Schmidt,
.I LEX - Lexical Analyzer Generator
@ -2439,3 +2439,4 @@ Send comments to:
decvax!cornell!vern
.fi
.\" ref. to awk(9) man page corrected -- ASW 2005-01-15

View file

@ -21,10 +21,10 @@ fsck, fsck1 \- perform file system consistency check
.FL "\-r" "Prompt user for repairs if inconsistencies are found
.FL "\-s" "List the superblock of the file system"
.SH EXAMPLES
.EX "fsck /dev/hd4" "Check file system on \fI/dev/hd4\fR"
.EX "fsck /dev/c0d0p3" "Check file system on \fI/dev/c0d0p3\fR"
.EX "fsck \-a /dev/at0" "Automatically fix errors on \fI/dev/at0\fR"
.EX "fsck \-l /dev/fd0" "List the contents of \fI/dev/fd0\fR"
.EX "fsck \-c 2 3 /dev/hd3" "Check and list \fI/dev/hd3\fR i-nodes 2 & 3"
.EX "fsck \-c 2 3 /dev/c0d0p2" "Check and list \fI/dev/c0d0p2\fR i-nodes 2 & 3"
.SH DESCRIPTION
.PP
\fIFsck\fR performs consistency checks on the file systems which reside
@ -49,3 +49,4 @@ simply be unmounted before it is checked.
.SH "SEE ALSO"
.BR mkfs (1),
.BR mount (1).
.\" disk name refs corrected, i.e., old hd1 now c0d0p0 -- ASW 2005-01-15

View file

@ -98,7 +98,7 @@ in a line is significant.
.SH "SEE ALSO"
.BR sort (1),
.BR comm (1),
.BR awk (1).
.BR awk (9).
.SH BUGS
With default field separation,
the collating sequence is that of
@ -114,5 +114,6 @@ The conventions of
.BR uniq ,
.BR look
and
.BR awk (1)
.BR awk (9)
are wildly incongruous.
.\" ref. to awk(9) man page corrected -- ASW 2005-01-15

View file

@ -14,7 +14,7 @@ to map titles to manual page names and by
.BR whatis (1)
to give one line descriptions. See
.BR whatis (5)
for a desciption of what a whatis database should look like and the
for a description of what a whatis database should look like and the
restrictions that are placed on the NAME sections so that
.B makewhatis
can make whatis lines out of the manual pages.
@ -25,3 +25,4 @@ Removing only font and size changes from the NAME section is often not
enough.
.SH AUTHOR
Kees J. Bot (kjb@cs.vu.nl)
.\" minor correction -- ASW 2005-01-15

View file

@ -2,7 +2,7 @@
.SH NAME
ps \- process status
.SH SYNOPSIS
\fBps \fR[\fB\-alxU\fR] [\fBkernel mm fs\fR]\fR
\fBps \fR[\fR[\fB\-\fR]\fBalx\fR]
.br
.de FL
.TP
@ -19,7 +19,9 @@ ps \- process status
.FL "\-l" "Give long listing"
.FL "\-x" "Include processes without a terminal"
.SH EXAMPLES
.EX "ps " "Show user's own processes in short format"
.EX "ps \-axl" "Print all processes and tasks in long format"
.EX "ps \axl" "Same -- the '\-' is optional"
.SH DESCRIPTION
.PP
\fIPs\fR prints the status of active processes. Normally only the caller's own
@ -66,3 +68,16 @@ The files \fI/dev/{mem,kmem}\fR are used to read the system tables and command
line arguments from. Terminal names in \fI/dev\fR are used to generate the
mnemonic names in the TTY column, so \fIps\fR is independent of terminal naming
conventions.
.SH NOTES
The '\-' option prefix is not required.
For marginal compatibility with System V usage, the hidden option
.B \-e
means the same as
.BR \-ax ,
and
.B \-f
is the same as
.BR \-l .
.\" edited by ASW 2004-12-14

View file

@ -27,7 +27,7 @@ tar \- tape archiver
.SH EXAMPLES
.EX "tar c /dev/fd1 ." "Back up current directory to \fI/dev/fd1\fR"
.EX "tar xv /dev/fd1 file1 file2" "Extract two files from the archive"
.EX "tar cf \- | (cd dest; tar xf \-)" "Copy current directory to \fIdest\fR"
.EX "tar cf \- . | (cd dest; tar xf \-)" "Copy current directory to \fIdest\fR"
.SH DESCRIPTION
.PP
\fITar\fR is a POSIX-compatible archiver, except that it does not use tape.
@ -47,3 +47,4 @@ try
.SH "SEE ALSO"
.BR compress (1),
.BR vol (1).
.\" minor correction ASW 2005-01-15

View file

@ -1,8 +1,8 @@
.TH TOUCH 1
.SH NAME
touch \- update a file's time of last modification
touch \- change file access and modification times
.SH SYNOPSIS
\fBtouch\fR [\fB\-c\fR] \fIfile\fR ...\fR
\fBtouch\fR [\fB\-c\fR] [\fB\-a\fR] [\fB\-m\fR] [\fB\-r\fR file] [\fB\-t\fR [CC[YY]]MMDDhhmm[.ss]] [MMDDhhmm[YY]] \fIfile\fR ...\fR
.br
.de FL
.TP
@ -15,17 +15,35 @@ touch \- update a file's time of last modification
# \\$2
..
.SH OPTIONS
.FL "\-c" "Do not create the file"
.FL "\-c" "Do not create the file if it doesn't already exist"
.FL "\-a" "Change access time"
.FL "\-m" "Change modification time"
.FL "\-r file" "Apply time of specified file"
.FL "\-t [CC[YY]]MMDDhhmm[.ss]]" "Apply time specified"
.FL "\-t [MMDDhhmm[YY]]" "Apply time specified (alternate form)"
.SH EXAMPLES
.EX "touch *.h" "Make the \fI.h\fP files look recent"
.EX "touch -t 199610010000 *" "Change date and time of all files in current directory to midnight Oct 1, 1996"
.SH DESCRIPTION
############ NEXT ENTRY HAS NOT BEEN CHECKED #############
.PP
The time of last modification is set to the current time.
With no options specified, the times of last modification and last access
are set to the current time.
This command is mostly used to trick
.I make
into thinking that a file is more recent than it really is.
If the file being touched does not exist, it is created, unless the \fB\-c\fR
flag is present.
.PP
The \fB\-a\fR or \fB\-m\fR flag may be used to change only the access or
modification time. The \fB\-r\fR or \fB\-t\fR flag may be used to change
the times to match the times of another file or to a specified time.
.SH "SEE ALSO"
.BR utime (2).
.SH "AUTHOR"
.PP
Original author unknown. Rewritten for POSIX by Peter Holzer
(hp@vmars.tuwien.ac.at).
.\" man page updated by A. S. Woodhull 2005-01-15