linux-ppp.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [pppoe-server] Enable HURL and MOTD messages with custom content
@ 2017-05-16 16:15 Luca Piccirillo
  0 siblings, 0 replies; only message in thread
From: Luca Piccirillo @ 2017-05-16 16:15 UTC (permalink / raw)
  To: linux-ppp

[-- Attachment #1: Type: text/plain, Size: 2109 bytes --]

Here is a really simple patch to allow sending HURL and MOTD messages
after peer connection. It also adds command line support for both and
allow https as well as HURL content.

--- rp-pppoe-3.12/src/pppoe-server.c
+++ rp-pppoe-3.12_patch/src/pppoe-server.c
@@ -141,6 +141,9 @@

 static char *pppd_path = PPPD_PATH;
 static char *pppoe_path = PPPOE_PATH;
+
+static char *motd_string = NULL;
+static char *hurl_string = NULL;

 static int Debug = 0;
 static int CheckPoolSyntax = 0;
@@ -1082,6 +1085,11 @@
     pads.length = htons(plen);
     sendPacket(NULL, sock, &pads, (int) (plen + HDR_SIZE));

+    if(hurl_string != NULL)
+        sendHURLorMOTM(&conn, hurl_string, TAG_HURL);
+    if(motd_string != NULL)
+        sendHURLorMOTM(&conn, motd_string, TAG_MOTM);
+
     /* Close sock; don't need it any more */
     close(sock);

@@ -1200,9 +1208,9 @@
 #endif

 #ifndef HAVE_LINUX_KERNEL_PPPOE
-    char *options = "X:ix:hI:C:L:R:T:m:FN:f:O:o:sp:lrudPc:S:1q:Q:";
+    char *options = "X:ix:hI:C:L:R:T:m:FN:f:O:o:sp:lrudPc:S:1q:Q:H:M:";
 #else
-    char *options = "X:ix:hI:C:L:R:T:m:FN:f:O:o:skp:lrudPc:S:1q:Q:";
+    char *options = "X:ix:hI:C:L:R:T:m:FN:f:O:o:skp:lrudPc:S:1q:Q:H:M:";
 #endif

     if (getuid() != geteuid() ||
@@ -1270,6 +1278,22 @@
         }
         break;

+    case 'M':
+        motd_string = strdup(optarg);
+        if (!motd_string) {
+        fprintf(stderr, "Out of memory");
+        exit(1);
+        }
+        break;
+
+    case 'H':
+        hurl_string = strdup(optarg);
+        if (!hurl_string) {
+        fprintf(stderr, "Out of memory");
+        exit(1);
+        }
+        break;
+
     case 'c':
 #ifndef HAVE_LICENSE
         fprintf(stderr, "Clustering capability not available.\n");
@@ -2310,8 +2334,10 @@

     if (tag == TAG_HURL) {
     if (strncmp(url, "http://", 7)) {
-        syslog(LOG_WARNING, "sendHURL(%s): URL must begin with http://", url);
+      if (strncmp(url, "https://", 8)) {
+        syslog(LOG_WARNING, "sendHURL(%s): URL must begin with
http:// or https://", url);
         return;
+      }
     }
     } else {
     tag = TAG_MOTM;

[-- Attachment #2: hurl_motd.patch --]
[-- Type: application/octet-stream, Size: 1854 bytes --]

--- rp-pppoe-3.12/src/pppoe-server.c
+++ rp-pppoe-3.12_patch/src/pppoe-server.c
@@ -141,6 +141,9 @@
 
 static char *pppd_path = PPPD_PATH;
 static char *pppoe_path = PPPOE_PATH;
+
+static char *motd_string = NULL;
+static char *hurl_string = NULL;
 
 static int Debug = 0;
 static int CheckPoolSyntax = 0;
@@ -1082,6 +1085,11 @@
     pads.length = htons(plen);
     sendPacket(NULL, sock, &pads, (int) (plen + HDR_SIZE));
 
+    if(hurl_string != NULL)
+        sendHURLorMOTM(&conn, hurl_string, TAG_HURL);
+    if(motd_string != NULL)
+        sendHURLorMOTM(&conn, motd_string, TAG_MOTM);
+
     /* Close sock; don't need it any more */
     close(sock);
 
@@ -1200,9 +1208,9 @@
 #endif
 
 #ifndef HAVE_LINUX_KERNEL_PPPOE
-    char *options = "X:ix:hI:C:L:R:T:m:FN:f:O:o:sp:lrudPc:S:1q:Q:";
+    char *options = "X:ix:hI:C:L:R:T:m:FN:f:O:o:sp:lrudPc:S:1q:Q:H:M:";
 #else
-    char *options = "X:ix:hI:C:L:R:T:m:FN:f:O:o:skp:lrudPc:S:1q:Q:";
+    char *options = "X:ix:hI:C:L:R:T:m:FN:f:O:o:skp:lrudPc:S:1q:Q:H:M:";
 #endif
 
     if (getuid() != geteuid() ||
@@ -1270,6 +1278,22 @@
 	    }
 	    break;
 
+	case 'M':
+	    motd_string = strdup(optarg);
+	    if (!motd_string) {
+		fprintf(stderr, "Out of memory");
+		exit(1);
+	    }
+	    break;
+
+	case 'H':
+	    hurl_string = strdup(optarg);
+	    if (!hurl_string) {
+		fprintf(stderr, "Out of memory");
+		exit(1);
+	    }
+	    break;
+	    
 	case 'c':
 #ifndef HAVE_LICENSE
 	    fprintf(stderr, "Clustering capability not available.\n");
@@ -2310,8 +2334,10 @@
 
     if (tag == TAG_HURL) {
 	if (strncmp(url, "http://", 7)) {
-	    syslog(LOG_WARNING, "sendHURL(%s): URL must begin with http://", url);
+	  if (strncmp(url, "https://", 8)) {
+	    syslog(LOG_WARNING, "sendHURL(%s): URL must begin with http:// or https://", url);
 	    return;
+	  }
 	}
     } else {
 	tag = TAG_MOTM;

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2017-05-16 16:15 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-16 16:15 [pppoe-server] Enable HURL and MOTD messages with custom content Luca Piccirillo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).