All new accounts created on Gitlab now require administrator approval. If you invite any collaborators, please let Flux staff know so they can approve the accounts.

Commit 3f943535 authored by Leigh B. Stoller's avatar Leigh B. Stoller

Remove all trace of proxydhcp!

parent 0bc1d045
......@@ -1385,7 +1385,7 @@ outfiles="$outfiles Makeconf GNUmakefile \
os/imagezip/ffs/GNUmakefile os/imagezip/extfs/GNUmakefile \
os/frisbee.redux/GNUmakefile os/growdisk/GNUmakefile \
os/syncd/GNUmakefile \
pxe/GNUmakefile pxe/proxydhcp.restart pxe/bootinfo.restart \
pxe/GNUmakefile pxe/bootinfo.restart \
security/GNUmakefile security/paperbag security/lastlog_daemon \
security/plasticwrap \
sensors/GNUmakefile sensors/slothd/GNUmakefile \
......
......@@ -430,7 +430,7 @@ outfiles="$outfiles Makeconf GNUmakefile \
os/imagezip/ffs/GNUmakefile os/imagezip/extfs/GNUmakefile \
os/frisbee.redux/GNUmakefile os/growdisk/GNUmakefile \
os/syncd/GNUmakefile \
pxe/GNUmakefile pxe/proxydhcp.restart pxe/bootinfo.restart \
pxe/GNUmakefile pxe/bootinfo.restart \
security/GNUmakefile security/paperbag security/lastlog_daemon \
security/plasticwrap \
sensors/GNUmakefile sensors/slothd/GNUmakefile \
......
......@@ -16,7 +16,7 @@ include $(OBJDIR)/Makeconf
# Force dependencies on the scripts so that they will be rerun through
# configure if the .in file is changed.
#
all: proxydhcp bootinfo bootinfosend proxydhcp.restart bootinfo.restart
all: bootinfo bootinfosend bootinfo.restart
include $(TESTBED_SRCDIR)/GNUmakerules
......@@ -25,8 +25,6 @@ DBFLAG = -DUSE_MYSQL_DB
#DBFLAG = -DUSE_NULL_DB
BI_DBSRC = bootinfo_null.c bootinfo_cfile.c bootinfo_mysql.c
BI_DBOBJ = bootinfo_null.o bootinfo_cfile.o bootinfo_mysql.o
PR_DBSRC = proxydhcp_cfile.c proxydhcp_mysql.c
PR_DBOBJ = proxydhcp_cfile.o proxydhcp_mysql.o
INCS = -I${OBJDIR} -I/usr/local/include -I$(TESTBED_SRCDIR)/lib/libtb
......@@ -47,11 +45,6 @@ LFLAGS += $(OBJDIR)/event/lib/libevent.a ${OBJDIR}/lib/libtb/libtb.a \
`elvin-config --libs vin4c` -lcrypto
endif
proxydhcp: proxydhcp.o $(PR_DBOBJ)
cc $(CFLAGS) $(DBFLAG) $(INCS) \
-o proxydhcp proxydhcp.o $(PR_DBOBJ) \
$(LFLAGS) -L/usr/local/lib/mysql -lmysqlclient
bootinfo: bootinfo.o bootinfo.h bootinfo_version.o bootwhat.h $(BI_DBOBJ)
cc $(CFLAGS) $(DBFLAG) $(INCS) \
-o bootinfo bootinfo.o bootinfo_version.o $(BI_DBOBJ) \
......@@ -72,30 +65,16 @@ testbootinfo_mysql: bootinfo_mysql.c
testbootinfo_cfile: bootinfo_cfile.c
cc $(CFLAGS) -DUSE_CFILE_DB -DTEST $(INCS) -o testcfile $< $(LFLAGS)
testproxydhcp_mysql: proxydhcp_mysql.c
cc $(CFLAGS) -DUSE_MYSQL_DB -DTEST $(INCS) \
-o testmysql $< \
$(LFLAGS) -L/usr/local/lib/mysql -lmysqlclient
testproxydhcp_cfile: proxydhcp_cfile.c
cc $(CFLAGS) -DUSE_CFILE_DB -DTEST $(INCS) -o testcfile $< $(LFLAGS)
proxydhcp_version.c: proxydhcp.c proxydhcp_mysql.c
echo >$@ "char build_info[] = \"Built `date +%d-%b-%Y` by `id -nu`@`hostname | sed 's/\..*//'`:`pwd`\";"
bootinfo_version.c: bootinfo.c bootinfo_mysql.c
echo >$@ "char build_info[] = \"Built `date +%d-%b-%Y` by `id -nu`@`hostname | sed 's/\..*//'`:`pwd`\";"
install: all
install: $(INSTALL_SBINDIR)/proxydhcp \
$(INSTALL_SBINDIR)/proxydhcp.restart \
$(INSTALL_SBINDIR)/bootinfo \
install: $(INSTALL_SBINDIR)/bootinfo \
$(INSTALL_SBINDIR)/bootinfo.restart \
$(INSTALL_SBINDIR)/bootinfosend \
$(INSTALL_ETCDIR)/proxydhcp.conf \
$(INSTALL_ETCDIR)/bootinfo.conf
clean:
rm -f *.o core proxydhcp bootinfo *.restart testmysql
rm -f *.o core bootinfo bootinfosend *.restart testmysql
......@@ -230,4 +230,7 @@ log_bootwhat(struct in_addr ipaddr, boot_what_t *bootinfo)
info("%s: REPLY: boot from mfs %s\n", ipstr, bootinfo->what.mfs);
break;
}
if (bootinfo->cmdline[0]) {
info("%s: REPLY: command line: %s\n", ipstr, bootinfo->cmdline);
}
}
......@@ -8,7 +8,7 @@
#ifndef _OSKIT_BOOT_BOOTWHAT_H_
#define _OSKIT_BOOT_BOOTWHAT_H_
#define BOOTWHAT_DSTPORT 6969
#define BOOTWHAT_DSTPORT 6968
#define BOOTWHAT_SRCPORT 9696
#define BOOTWHAT_SENDPORT 6970
......
This diff is collapsed.
# This is a comment.
# Client IP TFTPD IP File to boot
# (paper)
#
155.101.132.101 155.101.128.70 /tftpboot/pxeboot
155.101.132.2 155.101.128.70 /tftpboot/pxeboot
155.101.132.3 155.101.128.70 /tftpboot/pxeboot
155.101.132.4 155.101.128.70 /tftpboot/pxeboot
155.101.132.5 155.101.128.70 /tftpboot/pxeboot
155.101.132.6 155.101.128.70 /tftpboot/pxeboot
155.101.132.7 155.101.128.70 /tftpboot/pxeboot
155.101.132.8 155.101.128.70 /tftpboot/pxeboot
155.101.132.9 155.101.128.70 /tftpboot/pxeboot
155.101.132.10 155.101.128.70 /tftpboot/pxeboot
155.101.132.11 155.101.128.70 /tftpboot/pxeboot
155.101.132.12 155.101.128.70 /tftpboot/pxeboot
155.101.132.13 155.101.128.70 /tftpboot/pxeboot
155.101.132.14 155.101.128.70 /tftpboot/pxeboot
155.101.132.15 155.101.128.70 /tftpboot/pxeboot
155.101.132.16 155.101.128.70 /tftpboot/pxeboot
155.101.132.17 155.101.128.70 /tftpboot/pxeboot
155.101.132.18 155.101.128.70 /tftpboot/pxeboot
155.101.132.19 155.101.128.70 /tftpboot/pxeboot
155.101.132.20 155.101.128.70 /tftpboot/pxeboot
155.101.132.21 155.101.128.70 /tftpboot/pxeboot
155.101.132.22 155.101.128.70 /tftpboot/pxeboot
155.101.132.23 155.101.128.70 /tftpboot/pxeboot
155.101.132.24 155.101.128.70 /tftpboot/pxeboot
155.101.132.25 155.101.128.70 /tftpboot/pxeboot
155.101.132.26 155.101.128.70 /tftpboot/pxeboot
155.101.132.27 155.101.128.70 /tftpboot/pxeboot
155.101.132.28 155.101.128.70 /tftpboot/pxeboot
155.101.132.29 155.101.128.70 /tftpboot/pxeboot
155.101.132.30 155.101.128.70 /tftpboot/pxeboot
155.101.132.31 155.101.128.70 /tftpboot/pxeboot
155.101.132.32 155.101.128.70 /tftpboot/pxeboot
155.101.132.33 155.101.128.70 /tftpboot/pxeboot
155.101.132.34 155.101.128.70 /tftpboot/pxeboot
155.101.132.35 155.101.128.70 /tftpboot/pxeboot
155.101.132.36 155.101.128.70 /tftpboot/pxeboot
155.101.132.37 155.101.128.70 /tftpboot/pxeboot
155.101.132.38 155.101.128.70 /tftpboot/pxeboot
155.101.132.39 155.101.128.70 /tftpboot/pxeboot
155.101.132.40 155.101.128.70 /tftpboot/pxeboot
#!/bin/sh
IDIR=@prefix@/sbin
EDIR=@prefix@/etc
killall proxydhcp
${IDIR}/proxydhcp > /dev/null 2>&1 &
/*
* EMULAB-COPYRIGHT
* Copyright (c) 2000-2002 University of Utah and the Flux Group.
* All rights reserved.
*/
#include <sys/types.h>
#include <netdb.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <netdb.h>
#include <syslog.h>
#include <fcntl.h>
#include <netinet/in.h>
#include <arpa/inet.h>
/*
* Directory containing a set of configuration files, one per host
*/
#ifdef USE_CDIR_DB
#define CDIR "proxydhcp.d"
#define DEFAULTS "defaults"
struct config {
struct in_addr client;
struct in_addr server;
char bootprog[1];
/* bootprog is variable length */
};
#define MAX_CONFIGS 1
static int numconfigs;
static struct config *parse_configs(char *filename);
static struct config *default_config;
int
open_db(void)
{
char cfile[BUFSIZ];
#ifdef TEST
strcpy(cfile, CDIR);
#else
strcpy(cfile, CONFPATH);
strcat(cfile, CDIR);
#endif
strcat(cfile,"/defaults");
default_config = parse_configs(cfile);
return (default_config == NULL);
}
int
query_db(struct in_addr ipaddr, struct in_addr *sip,
char *bootprog, int bootlen)
{
struct config *configp;
char cfile[BUFSIZ];
int fd;
/* Check for a file with this host's name */
#ifdef TEST
strcpy(cfile,CDIR);
strcat(cfile,"/");
strcat(cfile,inet_ntoa(ipaddr));
#else
strcpy(cfile, CONFPATH);
strcat(cfile,CDIR);
strcat(cfile,"/");
strcat(cfile,inet_nota(ipaddr));
#endif
configp = parse_configs(cfile);
if (configp == NULL) {
printf("No configuration file %s found, using default\n", cfile);
strcpy(bootprog, default_config->bootprog);
sip->s_addr = default_config->server.s_addr;
return 0;
}
if (configp->server.s_addr == 0xffffffff) {
#ifdef TEST
printf("Using default server\n");
#endif
sip->s_addr = default_config->server.s_addr;
} else {
sip->s_addr = configp->server.s_addr;
}
if (strcmp(configp->bootprog,"default") == 0) {
#ifdef TEST
printf("Using default bootprog\n");
#endif
strcpy(bootprog, default_config->bootprog);
} else {
strcpy(bootprog, configp->bootprog);
}
return 0;
}
static int
parse_host(char *name)
{
struct hostent *he;
if (!isdigit(name[0])) {
if (strcmp(name,"default") == 0) {
return 0xffffffff;
}
he = gethostbyname(name);
if (he == 0) {
syslog(LOG_ERR, "%s: unknown host", name);
return 0;
}
return *(int *)he->h_addr;
}
return inet_addr(name);
}
static struct config*
parse_configs(char *filename)
{
FILE *fp;
int i;
char buf[BUFSIZ], *bp, *cix;
char client[256], server[256], bootprog[256];
struct config *configp;
int ipaddr;
if ((fp = fopen(filename, "r")) == NULL) {
syslog(LOG_ERR, "%s: cannot open", filename);
return NULL;
}
while (1) {
if ((bp = fgets(buf, BUFSIZ, fp)) == NULL)
break;
if (*bp == '\n' || *bp == '#')
continue;
if (numconfigs >= MAX_CONFIGS) {
syslog(LOG_ERR, "%s: too many lines", filename);
fclose(fp);
return NULL;
}
sscanf(bp, "%s %s\n", &server, &bootprog);
configp = (struct config *)
calloc(sizeof(*configp) + strlen(bootprog), 1);
if (!configp) {
bad:
syslog(LOG_ERR, "%s: parse error", filename);
fclose(fp);
return NULL;
}
strcpy(configp->bootprog, bootprog);
if ((ipaddr = parse_host(server)) == 0)
goto bad;
configp->server.s_addr = ipaddr;
}
fclose(fp);
return configp;
}
#ifdef TEST
#include <stdarg.h>
void
syslog(int prio, const char *msg, ...)
{
va_list ap;
va_start(ap, msg);
vfprintf(stderr, msg, ap);
va_end(ap);
fprintf(stderr, "\n");
}
main(int argc, char **argv)
{
struct in_addr ipaddr, server;
char bootprog[1024];
if (open_db() != 0) {
printf("bad config file\n");
exit(1);
}
while (--argc > 0) {
if (ipaddr.s_addr = parse_host(*++argv)) {
if (query_db(ipaddr, &server, bootprog, 1024) == 0) {
printf("%s: %s %s\n", *argv,
inet_ntoa(server), bootprog);
} else
printf("failed\n");
} else
printf("bogus IP address `%s'\n", *argv);
}
exit(0);
}
#endif
#endif
/*
* EMULAB-COPYRIGHT
* Copyright (c) 2000-2002 University of Utah and the Flux Group.
* All rights reserved.
*/
#include <sys/types.h>
#include <netinet/in.h>
#include <netdb.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <netdb.h>
#include <syslog.h>
/*
* Trivial config file format.
*/
#ifdef USE_CFILE_DB
#define CFILE "proxydhcp.conf"
struct config {
struct in_addr client;
struct in_addr server;
char bootprog[1];
/* bootprog is variable length */
};
#define MAX_CONFIGS 256
static int numconfigs;
static struct config *configurations[MAX_CONFIGS];
static struct config *find_config(struct in_addr addr);
static int parse_configs(char *filename);
int
open_db(void)
{
char cfile[BUFSIZ];
#ifdef TEST
strcpy(cfile, CFILE);
#else
strcpy(cfile, CONFPATH);
strcat(cfile, CFILE);
#endif
return parse_configs(cfile);
}
int
query_db(struct in_addr ipaddr, struct in_addr *sip,
char *bootprog, int bootlen)
{
struct config *configp;
if ((configp = find_config(ipaddr)) == 0)
return 1;
if (strlen(configp->bootprog) >= bootlen)
return 1;
sip->s_addr = configp->server.s_addr;
strcpy(bootprog, configp->bootprog);
return 0;
}
int
close_db(void)
{
int i;
for (i = 0; i < numconfigs; i++)
if (configurations[i])
free(configurations[i]);
numconfigs = 0;
return 0;
}
static int
parse_host(char *name)
{
struct hostent *he;
if (!isdigit(name[0])) {
he = gethostbyname(name);
if (he == 0) {
syslog(LOG_ERR, "%s: unknown host", name);
return 0;
}
return *(int *)he->h_addr;
}
return inet_addr(name);
}
static int
parse_configs(char *filename)
{
FILE *fp;
int i;
char buf[BUFSIZ], *bp, *cix;
char client[256], server[256], bootprog[256];
struct config *configp;
int ipaddr;
if ((fp = fopen(filename, "r")) == NULL) {
syslog(LOG_ERR, "%s: cannot open", filename);
return 1;
}
while (1) {
if ((bp = fgets(buf, BUFSIZ, fp)) == NULL)
break;
if (*bp == '\n' || *bp == '#')
continue;
if (numconfigs >= MAX_CONFIGS) {
syslog(LOG_ERR, "%s: too many lines", filename);
fclose(fp);
return 1;
}
sscanf(bp, "%s %s %s\n", &client, &server, &bootprog);
configp = (struct config *)
calloc(sizeof(*configp) + strlen(bootprog), 1);
if (!configp) {
bad:
syslog(LOG_ERR, "%s: parse error", filename);
fclose(fp);
close_db();
return 1;
}
configurations[numconfigs++] = configp;
strcpy(configp->bootprog, bootprog);
if ((ipaddr = parse_host(client)) == 0)
goto bad;
configp->client.s_addr = ipaddr;
if ((ipaddr = parse_host(server)) == 0)
goto bad;
configp->server.s_addr = ipaddr;
}
fclose(fp);
return 0;
}
static struct config *
find_config(struct in_addr addr)
{
int i;
struct config *configp;
for (i = 0; i < numconfigs; i++)
if ((configp = configurations[i]) != NULL &&
addr.s_addr == configp->client.s_addr)
return configp;
return 0;
}
#ifdef TEST
#include <stdarg.h>
void
syslog(int prio, const char *msg, ...)
{
va_list ap;
va_start(ap, msg);
vfprintf(stderr, msg, ap);
va_end(ap);
fprintf(stderr, "\n");
}
main(int argc, char **argv)
{
struct in_addr ipaddr, server;
char *bootprog;
if (open_db() != 0) {
printf("bad config file\n");
exit(1);
}
while (--argc > 0) {
if (ipaddr.s_addr = parse_host(*++argv)) {
if (query_db(ipaddr, &server, &bootprog) == 0) {
printf("%s: %s %s\n", *argv,
inet_ntoa(server), bootprog);
} else
printf("failed\n");
} else
printf("bogus IP address `%s'\n", *argv);
}
close_db();
exit(0);
}
#endif
#endif
/*
* EMULAB-COPYRIGHT
* Copyright (c) 2000-2003 University of Utah and the Flux Group.
* All rights reserved.
*/
#include <sys/types.h>
#include <netinet/in.h>
#include <netdb.h>
#include <stdio.h>
#include <syslog.h>
#include <arpa/inet.h>
#include <string.h>
#ifdef USE_MYSQL_DB
#include <mysql/mysql.h>
static char dbname[] = TBDBNAME;
static int parse_pathspec(char *path, struct in_addr *sip, char **filename);
#include <stdarg.h>
int
open_db(void)
{
return 0;
}
int
query_db(struct in_addr ipaddr, struct in_addr *sip,
char *bootprog, int bootlen)
{
char querybuf[1024];
int n, nrows, ncols;
MYSQL db;
MYSQL_RES *res;
MYSQL_ROW row;
char dbquery[] =
"select pxe_boot_path,next_pxe_boot_path from interfaces as i "
"left join nodes as n on i.node_id=n.node_id "
"where i.IP = '%s'";
#define PXEBOOT_PATH 0
#define NEXT_PXEBOOT_PATH 1
n = snprintf(querybuf, sizeof querybuf, dbquery, inet_ntoa(ipaddr));
if (n > sizeof querybuf) {
syslog(LOG_ERR, "query too long for buffer");
return 1;
}
mysql_init(&db);
if (mysql_real_connect(&db, 0, "proxydhcp", 0, dbname, 0, 0, 0) == 0) {
syslog(LOG_ERR, "%s: connect failed: %s",
dbname, mysql_error(&db));
return 1;
}
/* Debug message into log:
syslog(LOG_ERR, "USING QUERY: %s", querybuf);
*/
if (mysql_real_query(&db, querybuf, n) != 0) {
syslog(LOG_ERR, "%s: query failed: %s",
dbname, mysql_error(&db));
mysql_close(&db);
return 1;
}
res = mysql_store_result(&db);
if (res == 0) {
syslog(LOG_ERR, "%s: store_result failed: %s",
dbname, mysql_error(&db));
mysql_close(&db);
return 1;
}
mysql_close(&db);
nrows = (int)mysql_num_rows(res);
switch (nrows) {
case 0:
syslog(LOG_ERR, "%s: no entry for host %s",
dbname, inet_ntoa(ipaddr));