[oe-commits] org.oe.dev ppp: added a nylon-specific patch for a cli program allowing to read the ppp database /var/run/pppd.tdb.

MartinDietze commit openembedded-commits at lists.openembedded.org
Fri Sep 15 09:11:34 UTC 2006


ppp: added a nylon-specific patch for a cli program allowing to read the ppp database /var/run/pppd.tdb.

Author: MartinDietze at openembedded.org
Branch: org.openembedded.dev
Revision: 67163c625b15951f2b396aedcd5ff10c5d106b2b
ViewMTN: http://monotone.openembedded.org/revision.psp?id=67163c625b15951f2b396aedcd5ff10c5d106b2b
Files:
1
packages/ppp/ppp-2.4.1/ppp-tdbread.patch
packages/ppp/ppp-2.4.3/ppp-tdbread.patch
packages/ppp/ppp_2.4.1.bb
packages/ppp/ppp_2.4.3.bb
Diffs:

#
# mt diff -rb0736f8ec7ea965eeb533a6872e86157d94c76f8 -r67163c625b15951f2b396aedcd5ff10c5d106b2b
#
# 
# 
# add_file "packages/ppp/ppp-2.4.1/ppp-tdbread.patch"
#  content [61f91aff2ff5a23705cc92efd6868b1c7c1481ec]
# 
# add_file "packages/ppp/ppp-2.4.3/ppp-tdbread.patch"
#  content [658022073c18fc7c6ec4e3c03adaeeda07264574]
# 
# patch "packages/ppp/ppp_2.4.1.bb"
#  from [dd30a652eb1c563d66b1ebf10f144d5a94a789a4]
#    to [b594d35a559e4695363f9fac922fab97a708d9f0]
# 
# patch "packages/ppp/ppp_2.4.3.bb"
#  from [7f84ccdc3eeb261cbc1edd5d9133517b69804a5f]
#    to [3dadae43796249078a70971e3b72c78fb78eb54c]
# 
============================================================
--- packages/ppp/ppp-2.4.1/ppp-tdbread.patch	61f91aff2ff5a23705cc92efd6868b1c7c1481ec
+++ packages/ppp/ppp-2.4.1/ppp-tdbread.patch	61f91aff2ff5a23705cc92efd6868b1c7c1481ec
@@ -0,0 +1,194 @@
+diff -Nur ppp-2.4.1/pppd/Makefile.linux myppp/ppp-2.4.1/pppd/Makefile.linux
+--- ppp-2.4.1/pppd/Makefile.linux	2006-09-14 14:52:54.000000000 +0200
++++ ppp-2.4.1/pppd/Makefile.linux	2006-09-14 14:55:44.000000000 +0200
+@@ -17,7 +17,7 @@
+ 	   auth.o options.o demand.o utils.o sys-linux.o ipxcp.o multilink.o \
+ 	   tdb.o tty.o
+ 
+-all: pppd
++all: pppd tdbread
+ 
+ #
+ # include dependancies if present and backup if as a header file
+@@ -114,9 +114,10 @@
+ 
+ INSTALL= install
+ 
+-install: pppd
++install: pppd tdbread
+ 	mkdir -p $(BINDIR) $(MANDIR)
+ 	$(INSTALL) -c -m 555 pppd $(BINDIR)/pppd
++	$(INSTALL) -c -m 555 tdbread $(BINDIR)/tdbread
+ 	if chgrp pppusers $(BINDIR)/pppd 2>/dev/null; then \
+ 	  chmod o-rx,u+s $(BINDIR)/pppd; fi
+ 	$(INSTALL) -c -m 444 pppd.8 $(MANDIR)/man8
+@@ -124,8 +125,11 @@
+ pppd: $(PPPDOBJS)
+ 	$(CC) $(CFLAGS) $(LDFLAGS) -o pppd $(PPPDOBJS) $(LIBS)
+ 
++tdbread: tdbread.o tdb.o
++	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ 
++
+ clean:
+-	rm -f $(PPPDOBJS) pppd *~ #* core
++	rm -f $(PPPDOBJS) tdbread.o tdbread pppd *~ #* core
+ 
+ depend:
+ 	$(CPP) -M $(CFLAGS) $(PPPDSRCS) >.depend
+diff -Nur ppp-2.4.1/pppd/tdbread.c myppp/ppp-2.4.1/pppd/tdbread.c
+--- ppp-2.4.1/pppd/tdbread.c	1970-01-01 01:00:00.000000000 +0100
++++ ppp-2.4.1/pppd/tdbread.c	2006-09-14 14:52:32.000000000 +0200
+@@ -0,0 +1,153 @@
++/**
++ * @file    tdbread.c
++ * @author  Thomas Geffert <geffert at 4g-systems.com>
++ * @date    Thu Sep 14 10:28:31 2006
++ *
++ * @brief  Small program to extract information from pppd.tbd database.
++ *         You can get information about a specific ppp process with its pid
++ *         or view all keys available in the database.
++ */
++
++/*
++ * (c) COPYRIGHT 2006 by 4G Systems GmbH Germany
++ *
++ * Redistribution and use in source and binary forms are permitted
++ * provided that the above copyright notice and this paragraph are
++ * duplicated in all such forms AND provided that this software or
++ * any derived work is only used as part of the PPP daemon (pppd)
++ * and related utilities.
++ * The name of the author may not be used to endorse or promote products
++ * derived from this software without specific prior written permission.
++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
++ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
++ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
++ *
++ * Note: this software is also available under the Gnu Public License
++ * version 2 or later.
++ */
++
++#include <stdio.h>
++#include <stdlib.h>
++#include <string.h>
++#include <fcntl.h>
++#include <getopt.h>
++#include <signal.h>				/* needed for tdb.h starting with ppp-2.4.3 */
++
++#include "tdb.h"
++#include "pppd.h"
++#include "pathnames.h"
++
++/**
++ * Callback function for tdb_traverse: show a key and its associated data
++ *
++ * @param tdb pointer to database
++ * @param key hash key
++ * @param dbuf data belonging to key
++ * @param state unused data pointer
++ *
++ * @return 0 if success, 1 to stop calling function
++ */
++static int show(TDB_CONTEXT *tdb, TDB_DATA key, TDB_DATA dbuf, void *state)
++{
++	printf("%.*s: \"%.*s\"\n", key.dsize, key.dptr, dbuf.dsize, dbuf.dptr);
++	return 0;
++}
++
++/**
++ * Parse command line option. Option is used to sepcify for which ppp process
++ * information should be shown.
++ *
++ * @param argc  number of options
++ * @param argv  pointer to array with options
++ *
++ * @return empty key if no valid option found, or key selected by config option
++ */
++TDB_DATA parse_options(int argc, char **argv)
++{
++	TDB_DATA key = { NULL, 0 };
++	static char keyname[32] = { 0 };
++	int c;
++	while (1) {
++		int option_index = 0;
++		static struct option long_options[] = {
++			{"pid", 1, 0, 'p'}, {"device", 1, 0, 'd'}, {"ifname", 1, 0, 'i'},
++			{"ipremote", 1, 0, 'r'}, {"help", 0, 0, 'h'}, {0, 0, 0, 0}
++		};
++
++		c = getopt_long (argc, argv, "p:d:i:r:h", long_options, &option_index);
++		if (c == -1) {
++			if ( optind<argc ) {
++				c = '?'; // force display of usage
++			} else {
++				break;
++			}
++		}
++
++		switch (c) {
++		case 'p':
++			snprintf(keyname, sizeof(keyname), "PPPD_PID=%s", optarg);
++			break;
++		case 'i':
++			snprintf(keyname, sizeof(keyname), "IFNAME=%s", optarg);
++			break;
++		case 'd':
++			snprintf(keyname, sizeof(keyname), "DEVICE=%s", optarg);
++			break;
++		case 'r':
++			snprintf(keyname, sizeof(keyname), "IPREMOTE=%s", optarg);
++			break;
++		case '?':
++		case 'h':
++			fprintf(stderr, "Usage: tdbread [--pid pid|--device devname|--ifname ifname|--ipremote ipremote]\n"
++					" If several options are given, only the last one is used.\n");
++			exit(1);
++			break;
++		}
++	}
++
++	if ( *keyname != 0 ) {
++		key.dptr = (char *) keyname;
++		key.dsize = strlen(keyname);
++	}
++
++	return key;
++}
++
++
++int main(int argc, char **argv) {
++	TDB_CONTEXT *pppdb;
++	int rc=1;
++
++	/* open database */
++	pppdb = tdb_open(_PATH_PPPDB, 0, 0, O_RDWR, 0644);
++	if (pppdb == NULL) {
++		fprintf(stderr, "Cannot open DB %s\n", _PATH_PPPDB);
++		return 1;
++	}
++
++	TDB_DATA key = parse_options(argc, argv);
++
++	if (key.dsize==0) {
++		tdb_traverse(pppdb, show, NULL);
++	} else {
++		if (tdb_exists(pppdb, key)) {
++			TDB_DATA key2;
++			/* value of pppd_pid entry points to entry with real info */
++			key2 = tdb_fetch(pppdb, key);
++			if (tdb_exists(pppdb, key2)) {
++				TDB_DATA data;
++				data = tdb_fetch(pppdb, key2);
++				printf("%.*s\n", data.dsize, data.dptr);
++				rc=0;
++			} else {
++				fprintf(stderr, "No data found for %.*s\n", key2.dsize, key2.dptr);
++			}
++		} else {
++			fprintf(stderr, "Key %.*s not found\n", key.dsize, key.dptr);
++		}
++	}
++
++	tdb_close(pppdb);
++
++	return rc;
++}
============================================================
--- packages/ppp/ppp-2.4.3/ppp-tdbread.patch	658022073c18fc7c6ec4e3c03adaeeda07264574
+++ packages/ppp/ppp-2.4.3/ppp-tdbread.patch	658022073c18fc7c6ec4e3c03adaeeda07264574
@@ -0,0 +1,196 @@
+diff -Nur ppp-2.4.3/pppd/Makefile.linux myppp/ppp-2.4.3/pppd/Makefile.linux
+--- ppp-2.4.3/pppd/Makefile.linux	2006-09-14 14:52:54.000000000 +0200
++++ ppp-2.4.3/pppd/Makefile.linux	2006-09-14 14:55:44.000000000 +0200
+@@ -9,7 +9,7 @@
+ MANDIR = $(DESTDIR)/share/man/man8
+ INCDIR = $(DESTDIR)/include
+ 
+-TARGETS = pppd
++TARGETS = pppd tdbread
+ 
+ PPPDSRCS = main.c magic.c fsm.c lcp.c ipcp.c upap.c chap-new.c md5.c ccp.c \
+ 	   ecp.c ipxcp.c auth.c options.c sys-linux.c md4.c chap_ms.c \
+@@ -199,10 +199,11 @@
+ 
+ all: $(TARGETS)
+ 
+-install: pppd
++install: pppd tdbread
+ 	mkdir -p $(BINDIR) $(MANDIR)
+ 	$(EXTRAINSTALL)
+ 	$(INSTALL) -c -m 555 pppd $(BINDIR)/pppd
++	$(INSTALL) -c -m 555 tdbread $(BINDIR)/tdbread
+ 	if chgrp pppusers $(BINDIR)/pppd 2>/dev/null; then \
+ 	  chmod o-rx,u+s $(BINDIR)/pppd; fi
+ 	$(INSTALL) -c -m 444 pppd.8 $(MANDIR)
+@@ -217,8 +218,12 @@
+ 	mkdir -p $(INCDIR)/pppd
+ 	$(INSTALL) -c -m 644 $(HEADERS) $(INCDIR)/pppd
+ 
+-clean:
+-	rm -f $(PPPDOBJS) $(EXTRACLEAN) $(TARGETS) *~ #* core
++tdbread: tdbread.o tdb.o spinlock.o
++	$(CC) $(CFLAGS) $(LDFLAGS) -o $@ $^ 
+ 
++ clean:
++	rm -f $(PPPDOBJS) tdbread.o tdbread pppd *~ #* core
++	rm -f $(PPPDOBJS) $(EXTRACLEAN) $(TARGETS) *~ #* core
++ 
+ depend:
+ 	$(CPP) -M $(CFLAGS) $(PPPDSRCS) >.depend
+--- ppp-2.4.3/pppd/tdbread.c	1970-01-01 01:00:00.000000000 +0100
++++ ppp-2.4.3/pppd/tdbread.c	2006-09-14 14:52:32.000000000 +0200
+@@ -0,0 +1,153 @@
++/**
++ * @file    tdbread.c
++ * @author  Thomas Geffert <geffert at 4g-systems.com>
++ * @date    Thu Sep 14 10:28:31 2006
++ *
++ * @brief  Small program to extract information from pppd.tbd database.
++ *         You can get information about a specific ppp process with its pid
++ *         or view all keys available in the database.
++ */
++
++/*
++ * (c) COPYRIGHT 2006 by 4G Systems GmbH Germany
++ *
++ * Redistribution and use in source and binary forms are permitted
++ * provided that the above copyright notice and this paragraph are
++ * duplicated in all such forms AND provided that this software or
++ * any derived work is only used as part of the PPP daemon (pppd)
++ * and related utilities.
++ * The name of the author may not be used to endorse or promote products
++ * derived from this software without specific prior written permission.
++ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
++ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
++ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
++ *
++ * Note: this software is also available under the Gnu Public License
++ * version 2 or later.
++ */
++
++#include <stdio.h>
++#include <stdlib.h>
++#include <string.h>
++#include <fcntl.h>
++#include <getopt.h>
++#include <signal.h>				/* needed for tdb.h starting with ppp-2.4.3 */
++
++#include "tdb.h"
++#include "pppd.h"
++#include "pathnames.h"
++
++/**
++ * Callback function for tdb_traverse: show a key and its associated data
++ *
++ * @param tdb pointer to database
++ * @param key hash key
++ * @param dbuf data belonging to key
++ * @param state unused data pointer
++ *
++ * @return 0 if success, 1 to stop calling function
++ */
++static int show(TDB_CONTEXT *tdb, TDB_DATA key, TDB_DATA dbuf, void *state)
++{
++	printf("%.*s: \"%.*s\"\n", key.dsize, key.dptr, dbuf.dsize, dbuf.dptr);
++	return 0;
++}
++
++/**
++ * Parse command line option. Option is used to sepcify for which ppp process
++ * information should be shown.
++ *
++ * @param argc  number of options
++ * @param argv  pointer to array with options
++ *
++ * @return empty key if no valid option found, or key selected by config option
++ */
++TDB_DATA parse_options(int argc, char **argv)
++{
++	TDB_DATA key = { NULL, 0 };
++	static char keyname[32] = { 0 };
++	int c;
++	while (1) {
++		int option_index = 0;
++		static struct option long_options[] = {
++			{"pid", 1, 0, 'p'}, {"device", 1, 0, 'd'}, {"ifname", 1, 0, 'i'},
++			{"ipremote", 1, 0, 'r'}, {"help", 0, 0, 'h'}, {0, 0, 0, 0}
++		};
++
++		c = getopt_long (argc, argv, "p:d:i:r:h", long_options, &option_index);
++		if (c == -1) {
++			if ( optind<argc ) {
++				c = '?'; // force display of usage
++			} else {
++				break;
++			}
++		}
++
++		switch (c) {
++		case 'p':
++			snprintf(keyname, sizeof(keyname), "PPPD_PID=%s", optarg);
++			break;
++		case 'i':
++			snprintf(keyname, sizeof(keyname), "IFNAME=%s", optarg);
++			break;
++		case 'd':
++			snprintf(keyname, sizeof(keyname), "DEVICE=%s", optarg);
++			break;
++		case 'r':
++			snprintf(keyname, sizeof(keyname), "IPREMOTE=%s", optarg);
++			break;
++		case '?':
++		case 'h':
++			fprintf(stderr, "Usage: tdbread [--pid pid|--device devname|--ifname ifname|--ipremote ipremote]\n"
++					" If several options are given, only the last one is used.\n");
++			exit(1);
++			break;
++		}
++	}
++
++	if ( *keyname != 0 ) {
++		key.dptr = (char *) keyname;
++		key.dsize = strlen(keyname);
++	}
++
++	return key;
++}
++
++
++int main(int argc, char **argv) {
++	TDB_CONTEXT *pppdb;
++	int rc=1;
++
++	/* open database */
++	pppdb = tdb_open(_PATH_PPPDB, 0, 0, O_RDWR, 0644);
++	if (pppdb == NULL) {
++		fprintf(stderr, "Cannot open DB %s\n", _PATH_PPPDB);
++		return 1;
++	}
++
++	TDB_DATA key = parse_options(argc, argv);
++
++	if (key.dsize==0) {
++		tdb_traverse(pppdb, show, NULL);
++	} else {
++		if (tdb_exists(pppdb, key)) {
++			TDB_DATA key2;
++			/* value of pppd_pid entry points to entry with real info */
++			key2 = tdb_fetch(pppdb, key);
++			if (tdb_exists(pppdb, key2)) {
++				TDB_DATA data;
++				data = tdb_fetch(pppdb, key2);
++				printf("%.*s\n", data.dsize, data.dptr);
++				rc=0;
++			} else {
++				fprintf(stderr, "No data found for %.*s\n", key2.dsize, key2.dptr);
++			}
++		} else {
++			fprintf(stderr, "Key %.*s not found\n", key.dsize, key.dptr);
++		}
++	}
++
++	tdb_close(pppdb);
++
++	return rc;
++}
============================================================
--- packages/ppp/ppp_2.4.1.bb	dd30a652eb1c563d66b1ebf10f144d5a94a789a4
+++ packages/ppp/ppp_2.4.1.bb	b594d35a559e4695363f9fac922fab97a708d9f0
@@ -16,7 +16,9 @@ SRC_URI = "ftp://ftp.samba.org/pub/ppp/p
 	file://ip-down \
 	file://08setupdns \
 	file://92removedns"
-	
+
+SRC_URI_append_nylon = " file://ppp-tdbread.patch;patch=1"
+
 inherit autotools
 
 EXTRA_OEMAKE = "STRIPPROG=${STRIP}"
============================================================
--- packages/ppp/ppp_2.4.3.bb	7f84ccdc3eeb261cbc1edd5d9133517b69804a5f
+++ packages/ppp/ppp_2.4.3.bb	3dadae43796249078a70971e3b72c78fb78eb54c
@@ -21,6 +21,7 @@ SRC_URI = "ftp://ftp.samba.org/pub/ppp/p
 	file://08setupdns \
 	file://92removedns"
 	
+SRC_URI_append_nylon = " file://ppp-tdbread.patch;patch=1"
 
 inherit autotools
 
@@ -45,6 +46,7 @@ FILES_${PN}        = "/etc /usr/bin /usr
 CONFFILES_${PN} = "${sysconfdir}/ppp/pap-secrets ${sysconfdir}/ppp/chap-secrets ${sysconfdir}/ppp/options"
 PACKAGES += "ppp-oa ppp-oe ppp-radius ppp-winbind ppp-minconn ppp-password ppp-tools"
 FILES_${PN}        = "/etc /usr/bin /usr/sbin/chat /usr/sbin/pppd"
+FILES_${PN}_nylon  = "/etc /usr/bin /usr/sbin/chat /usr/sbin/pppd /usr/sbin/tdbread"
 FILES_ppp-oa       = "/usr/lib/pppd/2.4.3/pppoatm.so"
 FILES_ppp-oe       = "/usr/sbin/pppoe-discovery /usr/lib/pppd/2.4.3/rp-pppoe.so"
 FILES_ppp-radius   = "/usr/lib/pppd/2.4.3/radius.so /usr/lib/pppd/2.4.3/radattr.so /usr/lib/pppd/2.4.3/radrealms.so"






More information about the Openembedded-commits mailing list