ip/tftpd: remove sunkernel hack
This commit is contained in:
parent
a33d76f8c9
commit
08385e6681
|
@ -279,21 +279,7 @@ Change directory to
|
|||
The default is
|
||||
.BR /lib/tftpd .
|
||||
All requests for files with non-rooted file names are served starting at this
|
||||
directory with the exception of files of the form
|
||||
.BR xxxxxxxx.SUNyy .
|
||||
These are Sparc kernel boot files where
|
||||
.B xxxxxxxx
|
||||
is the hex IP address of the machine requesting the kernel and
|
||||
.B yy
|
||||
is an architecture identifier.
|
||||
.I Tftpd
|
||||
looks up the file in the network database using
|
||||
.I ipinfo
|
||||
(see
|
||||
.IR ndb (2))
|
||||
and responds with the boot file specified for that particular
|
||||
machine.
|
||||
If no boot file is specified, the transfer fails.
|
||||
directory.
|
||||
.I Tftpd
|
||||
supports only octet mode.
|
||||
.TP
|
||||
|
|
|
@ -6,7 +6,6 @@
|
|||
#include <auth.h>
|
||||
#include <bio.h>
|
||||
#include <ip.h>
|
||||
#include <ndb.h>
|
||||
|
||||
enum
|
||||
{
|
||||
|
@ -85,7 +84,6 @@ void nak(int, int, char*);
|
|||
void ack(int, ushort);
|
||||
void clrcon(void);
|
||||
void setuser(void);
|
||||
char* sunkernel(char*);
|
||||
void remoteaddr(char*, char*, int);
|
||||
void doserve(int);
|
||||
|
||||
|
@ -563,14 +561,8 @@ sendfile(int fd, char *name, char *mode, int opts)
|
|||
uchar buf[Maxsegsize+Hdrsize];
|
||||
char errbuf[ERRMAX];
|
||||
|
||||
file = -1;
|
||||
syslog(dbg, flog, "tftpd %d send file '%s' %s to %s",
|
||||
pid, name, mode, raddr);
|
||||
name = sunkernel(name);
|
||||
if(name == 0){
|
||||
nak(fd, 0, "not in our database");
|
||||
goto error;
|
||||
}
|
||||
|
||||
notify(catcher);
|
||||
|
||||
|
@ -755,59 +747,6 @@ setuser(void)
|
|||
sysfatal("can't build namespace: %r");
|
||||
}
|
||||
|
||||
char*
|
||||
lookup(char *sattr, char *sval, char *tattr, char *tval, int len)
|
||||
{
|
||||
static Ndb *db;
|
||||
char *attrs[1];
|
||||
Ndbtuple *t;
|
||||
|
||||
if(db == nil)
|
||||
db = ndbopen(0);
|
||||
if(db == nil)
|
||||
return nil;
|
||||
|
||||
if(sattr == nil)
|
||||
sattr = ipattr(sval);
|
||||
|
||||
attrs[0] = tattr;
|
||||
t = ndbipinfo(db, sattr, sval, attrs, 1);
|
||||
if(t == nil)
|
||||
return nil;
|
||||
strncpy(tval, t->val, len);
|
||||
tval[len-1] = 0;
|
||||
ndbfree(t);
|
||||
return tval;
|
||||
}
|
||||
|
||||
/*
|
||||
* for sun kernel boots, replace the requested file name with
|
||||
* a one from our database. If the database doesn't specify a file,
|
||||
* don't answer.
|
||||
*/
|
||||
char*
|
||||
sunkernel(char *name)
|
||||
{
|
||||
ulong addr;
|
||||
uchar v4[IPv4addrlen];
|
||||
uchar v6[IPaddrlen];
|
||||
char buf[256];
|
||||
char ipbuf[128];
|
||||
char *suffix;
|
||||
|
||||
addr = strtoul(name, &suffix, 16);
|
||||
if(suffix-name != 8 || (strcmp(suffix, "") != 0 && strcmp(suffix, ".SUN") != 0))
|
||||
return name;
|
||||
|
||||
v4[0] = addr>>24;
|
||||
v4[1] = addr>>16;
|
||||
v4[2] = addr>>8;
|
||||
v4[3] = addr;
|
||||
v4tov6(v6, v4);
|
||||
sprint(ipbuf, "%I", v6);
|
||||
return lookup("ip", ipbuf, "bootf", buf, sizeof buf);
|
||||
}
|
||||
|
||||
void
|
||||
remoteaddr(char *dir, char *raddr, int len)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue