mirror of
https://github.com/dreamlayers/netbsd-mopd.git
synced 2026-02-27 17:02:37 +00:00
Application of mopd-2.5.3-vax-linux.patch:
* Fri Oct 26 2001 Maciej W. Rozycki <macro@ds2.pg.gda.pl> - added a few more updates from the VAX/Linux version of mopd-linux; mostly security fixes (vax-linux) Downloaded from: ftp://ftp.linux-mips.org/pub/linux/mips/people/macro/mopd/mopd-2.5.3-vax-linux.patch.gz .patch SHA256 = a76757c7dcd4befbcdbe9e3a386c2f2ede26c0394d4a56de1e1750e76e23f524 Patch history copied from: ftp://ftp.linux-mips.org/pub/linux/mips/people/macro/mopd/mopd-2.5.3-15.spec
This commit is contained in:
committed by
Boris Gjenero
parent
8cabaa5ecb
commit
2a42d24d4f
20
README
Normal file
20
README
Normal file
@@ -0,0 +1,20 @@
|
||||
mopd-linux-20000808
|
||||
|
||||
This is the Linux version of Mats Jansens' Mopd.
|
||||
|
||||
The sources here are taken from the NetBSD version of mopd 2.5.3/4
|
||||
in CVS, plus some bits from the OpenBSD port, and the security
|
||||
fixes reported on BUGTRAQ on 08 Aug 2000.
|
||||
|
||||
I had to rewrite the Makefiles, and hack things about a bit to compile
|
||||
under Linux, So if this version doesnt work for you, send email to the
|
||||
Linux/VAX list detailing the problem.
|
||||
|
||||
The mopa.out program does not work. The a.out structures have different
|
||||
names under NetBSD and Linux (see /usr/include/a.out.h), and so the
|
||||
code needs re-writing.
|
||||
|
||||
atp@pergamentum.com 8/Aug/2000
|
||||
|
||||
Patches from John Nall added for Alpha/Linux
|
||||
|
||||
@@ -38,6 +38,10 @@
|
||||
#define BUFSIZE 1600 /* main receive buffer size */
|
||||
#define HDRSIZ 22 /* room for 803.2 header */
|
||||
|
||||
#ifndef DEFAULT_HOSTNAME
|
||||
#define DEFAULT_HOSTNAME "ipc"
|
||||
#endif
|
||||
|
||||
#ifndef MOP_FILE_PATH
|
||||
#define MOP_FILE_PATH "/tftpboot/mop"
|
||||
#endif
|
||||
|
||||
@@ -82,6 +82,7 @@ deviceEthAddr(ifname, eaddr)
|
||||
if (ioctl(fd, SIOCGIFCONF, (caddr_t)&ifc) < 0 ||
|
||||
ifc.ifc_len < sizeof(struct ifreq)) {
|
||||
syslog(LOG_ERR, "deviceEthAddr: SIOGIFCONF: %m");
|
||||
(void) close(fd);
|
||||
exit(1);
|
||||
}
|
||||
ifr = ifc.ifc_req;
|
||||
@@ -94,11 +95,13 @@ deviceEthAddr(ifname, eaddr)
|
||||
continue;
|
||||
if (!strncmp(ifr->ifr_name, ifname, sizeof(ifr->ifr_name))) {
|
||||
bcopy((caddr_t)LLADDR(sdl), (caddr_t)eaddr, 6);
|
||||
(void) close(fd);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
syslog(LOG_ERR, "deviceEthAddr: Never saw interface `%s'!", ifname);
|
||||
(void) close(fd);
|
||||
exit(1);
|
||||
}
|
||||
#endif /* DEV_NEW_CONF */
|
||||
@@ -213,11 +216,7 @@ deviceInitOne(ifname)
|
||||
|
||||
/* Ok, get transport information */
|
||||
|
||||
#ifdef __linux__
|
||||
trans = TRANS_ETHER+TRANS_8023+TRANS_AND;
|
||||
#else
|
||||
trans = pfTrans(interface);
|
||||
#endif
|
||||
|
||||
#ifndef NORC
|
||||
/* Start with MOP Remote Console */
|
||||
|
||||
@@ -44,8 +44,8 @@ mopDumpDL(fd, pkt, trans)
|
||||
{
|
||||
int i,index = 0;
|
||||
long tmpl;
|
||||
u_char tmpc,c,program[17],code,*ucp;
|
||||
u_short len,tmps,moplen;
|
||||
u_char tmpc,c,program[257],code,*ucp;
|
||||
int len,tmps,moplen;
|
||||
|
||||
len = mopGetLength(pkt, trans);
|
||||
|
||||
@@ -58,6 +58,8 @@ mopDumpDL(fd, pkt, trans)
|
||||
index = 16;
|
||||
moplen = len;
|
||||
}
|
||||
if (moplen < 1) /* broken packet */
|
||||
return;
|
||||
code = mopGetChar(pkt,&index);
|
||||
|
||||
switch (code) {
|
||||
|
||||
@@ -34,7 +34,7 @@ static char rcsid[] = "$Id: loop-bsd.c,v 1.11 1996/08/16 22:41:28 moj Exp $";
|
||||
#include <stdlib.h>
|
||||
#include <strings.h>
|
||||
#include <unistd.h>
|
||||
#if defined(__bsdi__) || defined(__FreeBSD__)
|
||||
#if defined(__bsdi__) || defined(__FreeBSD__) || defined(__NetBSD__)
|
||||
#include <sys/time.h>
|
||||
#endif
|
||||
#if !defined(__linux__)
|
||||
|
||||
@@ -70,6 +70,9 @@
|
||||
#endif
|
||||
#include <unistd.h>
|
||||
|
||||
#include <sys/utsname.h>
|
||||
#include <sys/param.h>
|
||||
|
||||
#if defined(sun)
|
||||
typedef int ssize_t;
|
||||
#endif
|
||||
|
||||
@@ -45,6 +45,8 @@
|
||||
#include <unistd.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "mopdef.h"
|
||||
|
||||
/*
|
||||
* map compatible functions
|
||||
*
|
||||
@@ -131,7 +133,7 @@ int typ, mode;
|
||||
|
||||
{ u_short prot;
|
||||
|
||||
prot = ((typ == 2) ? htons(ETH_P_802_2) : htons(protocol));
|
||||
prot = ((typ == TRANS_8023) ? htons(ETH_P_802_2) : htons(protocol));
|
||||
if ((s = socket(AF_INET, SOCK_PACKET, prot)) < 0) {
|
||||
perror(interface);
|
||||
return(-1);
|
||||
@@ -175,7 +177,8 @@ int s;
|
||||
char *interface;
|
||||
u_char *addr;
|
||||
{
|
||||
strcpy(ifr.ifr_name, interface);
|
||||
strncpy(ifr.ifr_name, interface, sizeof (ifr.ifr_name) - 1);
|
||||
ifr.ifr_name[sizeof(ifr.ifr_name)] = 0;
|
||||
ifr.ifr_addr.sa_family = AF_INET;
|
||||
if (ioctl(s, SIOCGIFHWADDR, &ifr) < 0) {
|
||||
perror("SIOCGIFHWADDR");
|
||||
@@ -200,7 +203,8 @@ u_char *addr;
|
||||
|
||||
#ifdef USE_SADDMULTI
|
||||
|
||||
strcpy(ifr.ifr_name, interface);
|
||||
strncpy(ifr.ifr_name, interface, sizeof (ifr.ifr_name) - 1);
|
||||
ifr.ifr_name[sizeof(ifr.ifr_name)] = 0;
|
||||
|
||||
#ifdef UPFILT
|
||||
/* get the real interface name */
|
||||
@@ -248,7 +252,8 @@ u_char *addr;
|
||||
|
||||
#ifdef USE_SADDMULTI
|
||||
|
||||
strcpy(ifr.ifr_name, interface);
|
||||
strncpy(ifr.ifr_name, interface, sizeof (ifr.ifr_name) - 1);
|
||||
ifr.ifr_name[sizeof(ifr.ifr_name)] = 0;
|
||||
|
||||
ifr.ifr_addr.sa_family = AF_UNSPEC;
|
||||
bcopy((char *)addr, ifr.ifr_addr.sa_data, 6);
|
||||
@@ -354,4 +359,17 @@ u_char *buf;
|
||||
return(-1);
|
||||
}
|
||||
|
||||
/*
|
||||
* Return information to device.c how to open device.
|
||||
* In this case the driver can handle both Ethernet type II and
|
||||
* IEEE 802.3 frames (SNAP) in a single pfOpen.
|
||||
*/
|
||||
|
||||
int
|
||||
pfTrans(interface)
|
||||
char *interface;
|
||||
{
|
||||
return TRANS_ETHER+TRANS_8023;
|
||||
}
|
||||
|
||||
#endif /* __linux__ */
|
||||
|
||||
@@ -45,7 +45,7 @@ mopDumpRC(fd, pkt, trans)
|
||||
int i,index = 0;
|
||||
long tmpl;
|
||||
u_char tmpc,code,control;
|
||||
u_short len,tmps,moplen;
|
||||
int len,tmps,moplen;
|
||||
|
||||
len = mopGetLength(pkt, trans);
|
||||
|
||||
@@ -58,6 +58,8 @@ mopDumpRC(fd, pkt, trans)
|
||||
index = 16;
|
||||
moplen = len;
|
||||
}
|
||||
if (moplen < 1) /* broken packet */
|
||||
return;
|
||||
code = mopGetChar(pkt,&index);
|
||||
|
||||
switch (code) {
|
||||
|
||||
@@ -45,6 +45,10 @@ static char rcsid[] = "$Id: process.c,v 1.21 1996/08/22 17:04:07 moj Exp $";
|
||||
#include <common/file.h>
|
||||
#include "process.h"
|
||||
|
||||
#define SEND_REAL_HOSTNAME
|
||||
|
||||
#define MAX_ETH_PAYLOAD 1492
|
||||
|
||||
extern u_char buf[];
|
||||
extern int DebugFlag;
|
||||
|
||||
@@ -266,10 +270,12 @@ mopStartLoad(dst, src, dl_rpr, trans)
|
||||
dllist[slot].a_lseek = 0;
|
||||
|
||||
dllist[slot].count = 0;
|
||||
if (dllist[slot].dl_bsz >= 1492)
|
||||
dllist[slot].dl_bsz = 1492;
|
||||
if (dllist[slot].dl_bsz >= MAX_ETH_PAYLOAD)
|
||||
dllist[slot].dl_bsz = MAX_ETH_PAYLOAD;
|
||||
if (dllist[slot].dl_bsz == 1030) /* VS/uVAX 2000 needs this */
|
||||
dllist[slot].dl_bsz = 1000;
|
||||
if (dllist[slot].dl_bsz == 0) /* Needed by "big" VAXen */
|
||||
dllist[slot].dl_bsz = MAX_ETH_PAYLOAD;
|
||||
if (trans == TRANS_8023)
|
||||
dllist[slot].dl_bsz = dllist[slot].dl_bsz - 8;
|
||||
|
||||
@@ -324,6 +330,13 @@ mopNextLoad(dst, src, new_count, trans)
|
||||
u_short newlen = 0,ptype = MOP_K_PROTO_DL;
|
||||
u_char mopcode;
|
||||
|
||||
#ifdef SEND_REAL_HOSTNAME
|
||||
struct utsname uts_name;
|
||||
char hostname[MAXHOSTNAMELEN];
|
||||
#else
|
||||
char hostname[MAXHOSTNAMELEN] = DEFAULT_HOSTNAME;
|
||||
#endif
|
||||
|
||||
slot = -1;
|
||||
|
||||
for (i = 0; i < MAXDL; i++) {
|
||||
@@ -352,14 +365,14 @@ mopNextLoad(dst, src, new_count, trans)
|
||||
sprintf(line,
|
||||
"%x:%x:%x:%x:%x:%x Load completed",
|
||||
dst[0],dst[1],dst[2],dst[3],dst[4],dst[5]);
|
||||
syslog(LOG_INFO, line);
|
||||
syslog(LOG_INFO, "%s", line);
|
||||
return;
|
||||
}
|
||||
|
||||
dllist[slot].lseek = lseek(dllist[slot].ldfd,0L,SEEK_CUR);
|
||||
|
||||
if (dllist[slot].dl_bsz >= 1492)
|
||||
dllist[slot].dl_bsz = 1492;
|
||||
if (dllist[slot].dl_bsz >= MAX_ETH_PAYLOAD)
|
||||
dllist[slot].dl_bsz = MAX_ETH_PAYLOAD;
|
||||
|
||||
index = 0;
|
||||
mopPutHeader(pkt, &index, dst, src, ptype, trans);
|
||||
@@ -382,13 +395,22 @@ mopNextLoad(dst, src, new_count, trans)
|
||||
|
||||
} else {
|
||||
if (len == 0) {
|
||||
#ifdef SEND_REAL_HOSTNAME
|
||||
if (uname(&uts_name) < 0) {
|
||||
syslog(LOG_ERR,
|
||||
"uname: %m, sending `%s' as hostname",
|
||||
DEFAULT_HOSTNAME);
|
||||
sprintf(hostname, "%s", DEFAULT_HOSTNAME);
|
||||
} else
|
||||
sprintf(hostname, "%s", uts_name.nodename);
|
||||
#endif
|
||||
index = pindex;
|
||||
mopcode = MOP_K_CODE_PLT;
|
||||
mopPutChar (pkt,&index,mopcode);
|
||||
mopPutChar (pkt,&index,dllist[slot].count);
|
||||
mopPutChar (pkt,&index,MOP_K_PLTP_HSN);
|
||||
mopPutChar (pkt,&index,3);
|
||||
mopPutMulti(pkt,&index,"ipc",3);
|
||||
mopPutChar (pkt,&index,strlen(hostname));
|
||||
mopPutMulti(pkt,&index,hostname,strlen(hostname));
|
||||
mopPutChar (pkt,&index,MOP_K_PLTP_HSA);
|
||||
mopPutChar (pkt,&index,6);
|
||||
mopPutMulti(pkt,&index,src,6);
|
||||
@@ -437,7 +459,7 @@ mopProcessDL(fd, ii, pkt, index, dst, src, trans, len)
|
||||
{
|
||||
u_char tmpc;
|
||||
u_short moplen;
|
||||
u_char pfile[17], mopcode;
|
||||
u_char pfile[257], mopcode;
|
||||
char filename[FILENAME_MAX];
|
||||
char line[100];
|
||||
int i,nfd,iindex;
|
||||
@@ -527,7 +549,7 @@ mopProcessDL(fd, ii, pkt, index, dst, src, trans, len)
|
||||
src[0],src[1],src[2],
|
||||
src[3],src[4],src[5],trans,pfile);
|
||||
}
|
||||
syslog(LOG_INFO, line);
|
||||
syslog(LOG_INFO, "%s", line);
|
||||
} else {
|
||||
if ((mopCmpEAddr(dst,ii->eaddr) == 0)) {
|
||||
dl_rpr->ldfd = open(filename, O_RDONLY, 0);
|
||||
@@ -536,7 +558,7 @@ mopProcessDL(fd, ii, pkt, index, dst, src, trans, len)
|
||||
"%x:%x:%x:%x:%x:%x Send me %s",
|
||||
src[0],src[1],src[2],
|
||||
src[3],src[4],src[5],pfile);
|
||||
syslog(LOG_INFO, line);
|
||||
syslog(LOG_INFO, "%s", line);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user