Created
January 8, 2017 06:23
-
-
Save tbaschak/1320ab62b64b85813c735d46716bdc93 to your computer and use it in GitHub Desktop.
diff -u bgplg.c bgplgapi.c
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- bgplg.c 2017-01-08 00:08:36.000000000 -0600 | |
+++ bgplgapi.c 2017-01-08 00:18:27.000000000 -0600 | |
@@ -2,6 +2,7 @@ | |
/* | |
* Copyright (c) 2005, 2006 Reyk Floeter <reyk@openbsd.org> | |
+ * Copyright (c) 2017 Theodore Baschak <theodore@ciscodude.net>> | |
* | |
* Permission to use, copy, modify, and distribute this software for any | |
* purpose with or without fee is hereby granted, provided that the above | |
@@ -32,17 +33,13 @@ | |
#include "bgplg.h" | |
-#define INC_STYLE "/conf/bgplg.css" | |
-#define INC_HEAD "/conf/bgplg.head" | |
-#define INC_FOOT "/conf/bgplg.foot" | |
- | |
#define BGPDSOCK "/run/bgpd.rsock" | |
#define BGPCTL "/bin/bgpctl", "-s", BGPDSOCK | |
#define PING "/bin/ping" | |
#define TRACEROUTE "/bin/traceroute" | |
#define PING6 "/bin/ping6" | |
#define TRACEROUTE6 "/bin/traceroute6" | |
-#define CONTENT_TYPE "text/html" | |
+#define CONTENT_TYPE "text/plain" | |
static struct cmd cmds[] = CMDS; | |
@@ -248,7 +245,6 @@ | |
char *query, *myname, *self, *cmd = NULL, *req; | |
char **argv = NULL; | |
int ret = 1, argc = 0, query_length = 0; | |
- struct stat st; | |
u_int i; | |
struct cmd *cmdp = NULL; | |
@@ -259,26 +255,8 @@ | |
return (1); | |
printf("Content-Type: %s\n" | |
- "Cache-Control: no-cache\n\n" | |
- "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n" | |
- "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" " | |
- "\"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">\n" | |
- "<html xmlns=\"http://www.w3.org/1999/xhtml\">\n" | |
- "<head>\n" | |
- "<title>%s: %s</title>\n", | |
- CONTENT_TYPE, NAME, myname); | |
- if (stat(INC_STYLE, &st) == 0) { | |
- printf("<style type='text/css'><!--\n"); | |
- lg_incl(INC_STYLE); | |
- printf("--></style>\n"); | |
- } | |
- if (stat(INC_HEAD, &st) != 0 || lg_incl(INC_HEAD) != 0) { | |
- printf("</head>\n" | |
- "<body>\n"); | |
- } | |
- | |
- printf("<h1>%s: %s</h1>\n", NAME, myname); | |
- printf("<h2>%s</h2>\n", BRIEF); | |
+ "Cache-Control: no-cache\n\n", | |
+ CONTENT_TYPE); | |
/* print a form with possible options */ | |
if ((self = lg_getenv("SCRIPT_NAME", NULL)) == NULL) { | |
@@ -287,29 +265,6 @@ | |
} | |
if ((query = lg_getenv("QUERY_STRING", &query_length)) != NULL) | |
cmd = lg_getarg("cmd=", query, query_length); | |
- printf( | |
- "<form action='%s'>\n" | |
- "<div class=\"command\">\n" | |
- "<select name='cmd'>\n", | |
- self); | |
- for (i = 0; cmds[i].name != NULL; i++) { | |
- if (!lg_checkperm(&cmds[i])) | |
- continue; | |
- | |
- if (cmd != NULL && strcmp(cmd, cmds[i].name) == 0) | |
- printf("<option value='%s' selected='selected'>%s" | |
- "</option>\n", | |
- cmds[i].name, cmds[i].name); | |
- else | |
- printf("<option value='%s'>%s</option>\n", | |
- cmds[i].name, cmds[i].name); | |
- } | |
- printf("</select>\n" | |
- "<input type='text' name='req'/>\n" | |
- "<input type='submit' value='submit'/>\n" | |
- "</div>\n" | |
- "</form>\n" | |
- "<pre>\n"); | |
fflush(stdout); | |
#ifdef DEBUG | |
@@ -371,16 +326,5 @@ | |
free(argv); | |
- printf("</pre>\n"); | |
- | |
- if (stat(INC_FOOT, &st) != 0 || lg_incl(INC_FOOT) != 0) | |
- printf("<hr/>\n"); | |
- | |
- printf("<div class='footer'>\n" | |
- "<small>%s - %s<br/>Copyright (c) %s</small>\n" | |
- "</div>\n" | |
- "</body>\n" | |
- "</html>\n", NAME, BRIEF, COPYRIGHT); | |
- | |
return (ret); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment