added my Recipes

This commit is contained in:
2024-07-11 14:16:35 +02:00
parent 38bc4f53ac
commit 09b621d929
7118 changed files with 525762 additions and 3 deletions

View File

@@ -0,0 +1,56 @@
From 4848b9e4d516a9203c08432901a7b40419e8f43c Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Wed, 19 Jul 2017 15:54:35 -0700
Subject: [PATCH 1/3] Respect flags from env
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
Makefile | 4 ++--
cli/Makefile | 2 +-
pppd/Makefile | 2 +-
3 files changed, 4 insertions(+), 4 deletions(-)
diff --git a/Makefile b/Makefile
index a05a000..439a978 100644
--- a/Makefile
+++ b/Makefile
@@ -81,8 +81,8 @@ LIBS.dmalloc= -ldmalloc
export USE_DMALLOC
endif
-CPPFLAGS= $(CPPFLAGS.ippooltest)
-CFLAGS= -I. -Iusl -Icli -MMD -Wall -g $(CPPFLAGS) $(CPPFLAGS.dmalloc)
+CPPFLAGS+= $(CPPFLAGS.ippooltest)
+CFLAGS+= -I. -Iusl -Icli -MMD -Wall -g $(CPPFLAGS) $(CPPFLAGS.dmalloc)
LDFLAGS.ippoold= $(LDFLAGS) -Wl,-E -L. -Lusl -lusl -lnsl -ldl $(LIBS.dmalloc) -lc
LDFLAGS.ippoolconfig= $(LDFLAGS) -Lcli -lcli -lreadline -lcurses -lnsl $(LIBS.dmalloc) -lc
diff --git a/cli/Makefile b/cli/Makefile
index 4b5dd59..56fbf2f 100644
--- a/cli/Makefile
+++ b/cli/Makefile
@@ -7,7 +7,7 @@ CLI_SRCS_TEST.o= $(CLI_SRCS_TEST.c:%.c=%.o)
LDFLAGS.cli_test= -L.. -L. $(READLINE_LDFLAGS) -lcli -lusl -lreadline -lcurses -lc
-CFLAGS= $(CFLAGS.optimize) -MMD -Wall -Werror -I.. $(READLINE_CFLAGS)
+CFLAGS= $(CFLAGS.optimize) -MMD -Wall -Werror -I.. $(READLINE_CFLAGS) $(CPPFLAGS)
.PHONY: all test clean
diff --git a/pppd/Makefile b/pppd/Makefile
index 106deca..7fd815f 100644
--- a/pppd/Makefile
+++ b/pppd/Makefile
@@ -10,7 +10,7 @@ endif
# END CONFIGURABLE SETTINGS
-CFLAGS += -g -I.. -I/usr/include/pppd $(CFLAGS.pppd) -fPIC
+CFLAGS += -g -I.. -I=/usr/include/pppd $(CFLAGS.pppd) -fPIC
LDFLAGS += -shared
all: ippool.so
--
2.13.3

View File

@@ -0,0 +1,42 @@
From 4788ce6ec602f6441970e1095572c4ff0e90c7c5 Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Tue, 17 Jan 2023 22:33:52 -0800
Subject: [PATCH] Use unsigned int type for 1-bit integer bitfield
In C++, signed integers are represented in two's complement. This also applies to signed bitfields.
A signed bitfield composed of one bit can therefore store a value in the range -1 to 0.
Assigning a value of 1 to such a bitfield should produce a warning since it is out of range of representable values.
Therefore fix this case by using unsigned int instead of signed int
Upstream-Status: Pending
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
usl/usl_signal.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/usl/usl_signal.c b/usl/usl_signal.c
index 45ddd94..8c1d4d0 100644
--- a/usl/usl_signal.c
+++ b/usl/usl_signal.c
@@ -39,12 +39,12 @@ struct usl_notifier {
};
typedef struct {
- volatile int sighup:1;
- volatile int sigterm:1;
- volatile int sigchld:1;
- volatile int sigusr1:1;
- volatile int sigusr2:1;
- volatile int running:1;
+ volatile unsigned int sighup:1;
+ volatile unsigned int sigterm:1;
+ volatile unsigned int sigchld:1;
+ volatile unsigned int sigusr1:1;
+ volatile unsigned int sigusr2:1;
+ volatile unsigned int running:1;
sig_atomic_t waiting;
sigjmp_buf sigjmp;
} usl_signal_data_t;
--
2.39.1

View File

@@ -0,0 +1,72 @@
From da67444994bde603c7ff1483a6803bdab24e1f14 Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Mon, 29 Aug 2022 09:36:55 -0700
Subject: [PATCH 1/2] pppd/ippool.c: Fix type casting issues between in_addr
and ippool_api_ip_addr
Also remove unused variabled
Upstream-Status: Inappropriate [No upstream]
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
pppd/ippool.c | 13 ++++++-------
1 file changed, 6 insertions(+), 7 deletions(-)
--- a/pppd/ippool.c
+++ b/pppd/ippool.c
@@ -16,6 +16,7 @@
#include <sys/ioctl.h>
#include <sys/socket.h>
#include <netinet/in.h>
+#include <arpa/inet.h>
#include <signal.h>
#include <linux/types.h>
@@ -24,7 +25,6 @@
const char pppd_version[] = VERSION;
-static int ippool_fd = -1;
static char *ippool_pool_name = NULL;
static char *ippool_pool_name2 = NULL;
static char *ippool_server = "localhost";
@@ -64,9 +64,9 @@ static int ippool_addr_alloc(CLIENT *cl,
}
*addr = clnt_res.addr.s_addr;
-
+ struct in_addr temp_addr = {*addr};
if (ippool_debug) {
- dbglog("Allocated address %s from pool %s", inet_ntoa(clnt_res.addr.s_addr), pool_name);
+ dbglog("Allocated address %s from pool %s", inet_ntoa(temp_addr), pool_name);
}
out:
return result;
@@ -85,14 +85,16 @@ static void ippool_addr_free(CLIENT *cl,
}
if (clnt_res < 0) {
if (ippool_debug) {
+ struct in_addr temp_addr = {free_addr.s_addr};
warn("IP address %s free to pool %s failed: %s",
- inet_ntoa(free_addr), pool_name, strerror(-clnt_res));
+ inet_ntoa(temp_addr), pool_name, strerror(-clnt_res));
}
goto out;
}
if (ippool_debug) {
- dbglog("Freed address %s to pool %s", inet_ntoa(free_addr), pool_name);
+ struct in_addr temp_addr = {free_addr.s_addr};
+ dbglog("Freed address %s to pool %s", inet_ntoa(temp_addr), pool_name);
}
out:
return;
@@ -138,8 +140,6 @@ static void ippool_choose_ip(u_int32_t *
{
ipcp_options *wo = &ipcp_wantoptions[0];
ipcp_options *go = &ipcp_gotoptions[0];
- ipcp_options *ao = &ipcp_allowoptions[0];
- ipcp_options *ho = &ipcp_hisoptions[0];
CLIENT *cl;
int result = 0;

View File

@@ -0,0 +1,31 @@
From e4e0aae139b6489dc582fd14e54e562126482ce2 Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Sat, 26 Aug 2017 07:23:53 -0700
Subject: [PATCH 1/3] read() returns ssize_t
Fixes
usl_fd.c:284:10: error: comparison of unsigned expression < 0 is always false [-Werror,-Wtautological-compare]
if (nb < 0) {
~~ ^ ~
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
usl/usl_fd.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/usl/usl_fd.c b/usl/usl_fd.c
index 3b7a813..04ba48c 100644
--- a/usl/usl_fd.c
+++ b/usl/usl_fd.c
@@ -280,7 +280,7 @@ size_t usl_fd_read(int fd, void *buf, size_t count)
char *ptr = buf;
for (chars_read = 0; chars_read < count; ) {
- size_t nb = read(fd, ptr, count - chars_read);
+ ssize_t nb = read(fd, ptr, count - chars_read);
if (nb < 0) {
if (errno == EINTR)
continue;
--
2.14.1

View File

@@ -0,0 +1,28 @@
From 5d7f20c045b3c74dad2c53d65e30bd4840250082 Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Tue, 27 Jun 2017 15:17:19 -0700
Subject: [PATCH] usl_timer: Check for return value of write() API
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
usl/usl_timer.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/usl/usl_timer.c b/usl/usl_timer.c
index fda752b..d8414a6 100644
--- a/usl/usl_timer.c
+++ b/usl/usl_timer.c
@@ -94,7 +94,9 @@ void usl_timer_tick(void)
if (!usl_tick_pending) {
usl_tick_pending = 1;
- write(usl_tick_pipe[1], &msg, sizeof(msg));
+ if (write(usl_tick_pipe[1], &msg, sizeof(msg)) != sizeof(msg)) {
+ fprintf(stderr, "write to fd %i failed: %s\n", usl_tick_pipe[1], strerror(errno));
+ }
}
}
--
2.13.2

View File

@@ -0,0 +1,31 @@
From cf25576428903168cd41b183fb1ca9c2b7e2666e Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Sat, 26 Aug 2017 07:28:10 -0700
Subject: [PATCH 2/3] Mark first element of a string as null
Fixes
cli_lib.c:427:20: error: expression which evaluates to zero treated as a null pointer constant of type 'char *' [-Werror,-Wnon-literal-null-conversion]
values[arg] = '\0';
^~~~
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
cli/cli_lib.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/cli/cli_lib.c b/cli/cli_lib.c
index 41a0b06..e4d2fd5 100644
--- a/cli/cli_lib.c
+++ b/cli/cli_lib.c
@@ -424,7 +424,7 @@ int cli_find_args(int argc, char *argv[], struct cli_node *cmd, struct cli_node
if (arg_string[1] == '\0') {
/* no arg value - only allowed for string args */
if (node->arg->parser == cli_arg_parse_string) {
- values[arg] = '\0';
+ *values[arg] = '\0';
} else {
result = -EINVAL;
break;
--
2.14.1

View File

@@ -0,0 +1,22 @@
From f9ea91771f0d3c984e7d5fe9e15962db1ee686ad Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Mon, 29 Aug 2022 09:39:16 -0700
Subject: [PATCH 2/2] ippool_rpc_server.c: Add missing prototype for
ippool_api_rpc_check_request
Upstream-Status: Inappropriate [no upstream]
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
ippool_rpc_server.c | 2 ++
1 file changed, 2 insertions(+)
--- a/Makefile
+++ b/Makefile
@@ -123,6 +123,7 @@ $(IPPOOL_RPC_STEM)_server.c: $(IPPOOL_RP
-$(RM) $@ $@.tmp
rpcgen $(RPCGENFLAGS) -m -o $@.tmp $<
cat $@.tmp | sed -e 's/switch (rqstp->rq_proc) {/if (ippool_api_rpc_check_request(transp) < 0) return; switch (rqstp->rq_proc) {/' > $@
+ sed -i '20i int ippool_api_rpc_check_request(SVCXPRT *xprt);' $@
$(IPPOOL_RPC_STEM)_client.c: $(IPPOOL_RPC_STEM).x
-$(RM) $@

View File

@@ -0,0 +1,30 @@
From 47aef26198431f7ad568c2277dded158bda3e36f Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Wed, 19 Jul 2017 16:00:35 -0700
Subject: [PATCH 2/3] link with libtirpc
musl needs it
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
Makefile | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/Makefile b/Makefile
index 439a978..ea821eb 100644
--- a/Makefile
+++ b/Makefile
@@ -83,8 +83,8 @@ endif
CPPFLAGS+= $(CPPFLAGS.ippooltest)
CFLAGS+= -I. -Iusl -Icli -MMD -Wall -g $(CPPFLAGS) $(CPPFLAGS.dmalloc)
-LDFLAGS.ippoold= $(LDFLAGS) -Wl,-E -L. -Lusl -lusl -lnsl -ldl $(LIBS.dmalloc) -lc
-LDFLAGS.ippoolconfig= $(LDFLAGS) -Lcli -lcli -lreadline -lcurses -lnsl $(LIBS.dmalloc) -lc
+LDFLAGS.ippoold= $(LDFLAGS) -Wl,-E -L. -Lusl -lusl -ldl $(LIBS.dmalloc) -lc -ltirpc
+LDFLAGS.ippoolconfig= $(LDFLAGS) -Lcli -lcli -lreadline -lcurses $(LIBS.dmalloc) -lc -ltirpc
OPT_CFLAGS?= -O
--
2.13.3

View File

@@ -0,0 +1,58 @@
From 994d9575374d3cdb34b1b0f70c3c53ae76fe578e Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Sat, 26 Aug 2017 07:41:05 -0700
Subject: [PATCH 3/3] cli: Mark return of strtol as long int
strtol does not return unsigned long
error: taking the absolute value of unsigned type 'unsigned long' has no effect [-Werror,-Wabsolute-value]
if ((*endp == '\0') && (labs(tmp) < 32768)) {
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
cli/cli_lib.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/cli/cli_lib.c b/cli/cli_lib.c
index e4d2fd5..5f487dc 100644
--- a/cli/cli_lib.c
+++ b/cli/cli_lib.c
@@ -522,7 +522,7 @@ int cli_arg_parse_int32(struct cli_node *arg, const char *val, void *result)
int cli_arg_parse_int16(struct cli_node *arg, const char *val, void *result)
{
int16_t *intval = result;
- unsigned long tmp;
+ long tmp;
char *endp;
int ret = 0;
@@ -539,7 +539,7 @@ int cli_arg_parse_int16(struct cli_node *arg, const char *val, void *result)
int cli_arg_parse_int8(struct cli_node *arg, const char *val, void *result)
{
int8_t *intval = result;
- unsigned long tmp;
+ long tmp;
char *endp;
int ret = 0;
@@ -573,7 +573,7 @@ int cli_arg_parse_uint32(struct cli_node *arg, const char *val, void *result)
int cli_arg_parse_uint16(struct cli_node *arg, const char *val, void *result)
{
uint16_t *intval = result;
- unsigned long tmp;
+ long tmp;
char *endp;
int ret = 0;
@@ -590,7 +590,7 @@ int cli_arg_parse_uint16(struct cli_node *arg, const char *val, void *result)
int cli_arg_parse_uint8(struct cli_node *arg, const char *val, void *result)
{
uint8_t *intval = result;
- unsigned long tmp;
+ long tmp;
char *endp;
int ret = 0;
--
2.14.1

View File

@@ -0,0 +1,80 @@
From eb345047decba665e3f39908336a83f039e1ece2 Mon Sep 17 00:00:00 2001
From: Khem Raj <raj.khem@gmail.com>
Date: Wed, 19 Jul 2017 16:01:32 -0700
Subject: [PATCH 3/3] musl fixes
Signed-off-by: Khem Raj <raj.khem@gmail.com>
---
cli/cli_readline.c | 7 +-
ippool_api.c | 9 ++-
net/ppp_defs.h | 194 +++++++++++++++++++++++++++++++++++++++++++++++++++++
usl/usl.h | 4 ++
4 files changed, 208 insertions(+), 6 deletions(-)
create mode 100644 net/ppp_defs.h
Index: ippool-1.3/cli/cli_readline.c
===================================================================
--- ippool-1.3.orig/cli/cli_readline.c
+++ ippool-1.3/cli/cli_readline.c
@@ -17,13 +17,14 @@
* Boston, MA 02110-1301 USA
*
*****************************************************************************/
-
+#define _GNU_SOURCE
#include <stdio.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/file.h>
#include <sys/stat.h>
-#include <sys/errno.h>
+#include <fcntl.h>
+#include <errno.h>
#include <signal.h>
#include <readline/readline.h>
@@ -630,7 +631,7 @@ static void cli_rl_uninstall_signal_hand
static int cli_rl_install_signal_handlers(void)
{
- __sighandler_t handler;
+ sighandler_t handler;
rl_catch_signals = 0;
rl_clear_signals();
Index: ippool-1.3/ippool_api.c
===================================================================
--- ippool-1.3.orig/ippool_api.c
+++ ippool-1.3/ippool_api.c
@@ -181,10 +181,13 @@ int ippool_api_rpc_check_request(SVCXPRT
* non-loopback interface, reject the request.
*/
if ((!ippool_opt_remote_rpc) &&
- ((xprt->xp_raddr.sin_addr.s_addr != htonl(INADDR_LOOPBACK)) &&
- (xprt->xp_raddr.sin_addr.s_addr != htonl(INADDR_ANY)))) {
+ ((xprt->xp_raddr.sin6_addr.s6_addr != htonl(INADDR_LOOPBACK)) &&
+ (xprt->xp_raddr.sin6_addr.s6_addr != htonl(INADDR_ANY)))) {
+ char straddr[INET6_ADDRSTRLEN];
+ inet_ntop(AF_INET6, &xprt->xp_raddr.sin6_addr, straddr, sizeof(straddr));
+
if (ippool_opt_debug) {
- ippool_log(LOG_ERR, "Rejecting RPC request from %s", inet_ntoa(xprt->xp_raddr.sin_addr));
+ ippool_log(LOG_ERR, "Rejecting RPC request from %s", straddr);
}
svcerr_auth(xprt, AUTH_TOOWEAK);
return -EPERM;
Index: ippool-1.3/usl/usl.h
===================================================================
--- ippool-1.3.orig/usl/usl.h
+++ ippool-1.3/usl/usl.h
@@ -38,6 +38,10 @@
#include "usl_fsm.h"
#include "usl_list.h"
+#ifndef WAIT_ANY
+#define WAIT_ANY (-1)
+#endif
+
#define USL_VERSION "0.6"
#ifdef DEBUG

View File

@@ -0,0 +1,22 @@
ippool: always log to syslog
Even when running in the foreground, send log messages to syslog.
Upstream-Status: Inappropriate [embedded specific]
Signed-off-by: Joe Slater <jslater@windriver.com>
--- a/ippool_main.c
+++ b/ippool_main.c
@@ -251,9 +251,8 @@ void ippool_vlog(int level, const char *
if (ippool_opt_nodaemon) {
vprintf(fmt, ap);
printf("\n");
- } else {
- vsyslog(level, fmt, ap);
}
+ vsyslog(level, fmt, ap);
DMALLOC_VMESSAGE(fmt, ap);
}

View File

@@ -0,0 +1,18 @@
[Unit]
Description=ip address pool allocator
Requires=rpcbind.service
After=rpcbind.service
[Service]
Type=simple
# Start ippoold in the foreground!
ExecStart=@SBINDIR@/ippoold -f
# Normal output will go to syslog, so suppress stdout.
StandardOutput=null
# ExecStop is not needed. systemd will send SIGTERM
# and ippoold will exit status 1.
SuccessExitStatus=1
[Install]
WantedBy=multi-user.target

View File

@@ -0,0 +1,65 @@
Fix start error if lsb init-functions doesn't exist
Upstream-Status: Inappropriate [embedded specific]
Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
diff --git a/debian/init.d b/debian/init.d
index 363ba89..0327fec 100644
--- a/debian/init.d
+++ b/debian/init.d
@@ -10,6 +10,9 @@
# Description: Start ippool daemon
### END INIT INFO
+# Source function library.
+. /etc/init.d/functions
+
DAEMON=/usr/sbin/ippoold
NAME=ippoold
MODULE=pppol2tp
@@ -18,7 +21,23 @@ MODULE=pppol2tp
test -x $DAEMON || exit 0
# Get lsb functions
-. /lib/lsb/init-functions
+if [ -f /lib/lsb/init-functions ]
+then
+ . /lib/lsb/init-functions
+else
+ log_begin_msg() {
+ echo -n $*
+ }
+
+ log_end_msg() {
+ if [ $1 -eq 0 ]; then
+ echo "done"
+ else
+ echo "failed"
+ fi
+ }
+fi
+
. /etc/default/rcS
case "$1" in
@@ -35,6 +54,10 @@ case "$1" in
fi
log_end_msg $?
;;
+ status)
+ status /usr/sbin/ippoold;
+ exit $?
+ ;;
restart)
$0 stop
sleep 1
@@ -46,7 +69,7 @@ case "$1" in
log_end_msg $?
;;
*)
- log_success_msg "Usage: /etc/init.d/ippoold {start|stop|restart|reload|force-reload}"
+ log_success_msg "Usage: /etc/init.d/ippoold {start|stop|status|restart|reload|force-reload}"
exit 1
esac

View File

@@ -0,0 +1,89 @@
1)add -fPIC for $(IPPOOL_RPC_STEM)_xdr.o, $(IPPOOL_RPC_STEM)_client.o
2)add sub target for subdirs-all, and those dependencies below
pppd plugin directory build depends on $(IPPOOL_RPC_STEM)_xdr.o
$(IPPOOL_RPC_STEM)_client.o ippool_rpc.h
ippoold depends on libusl
ippoolconfig depends on libcli
$(IPPOOL_RPC_STEM)_xdr.o, $(IPPOOL_RPC_STEM)_client.o
$(IPPOOL_RPC_STEM)_server.o *.o in main directory depends on ippool_rpc.h
as those all directly or indirectly include ippool_rpc.h which is
dynamically generated by rpcgen
to make parallel make working.
3)include dependency files for pppd.
Upstream-Status: Pending
Signed-off-by: Yao Zhao <yao.zhao@windriver.com>
---
diff --git a/Makefile b/Makefile
index 73aa72f..4f7af1d 100644
--- a/Makefile
+++ b/Makefile
@@ -106,14 +106,14 @@ all: generated-files $(IPPOOL_RPC_STEM)_xdr.o $(IPPOOL_RPC_STEM)_client.o \
subdirs-all $(PROGS.sbin) $(PROGS.bin)
# Compile without -Wall because rpcgen-generated code is full of warnings
-$(IPPOOL_RPC_STEM)_xdr.o: $(IPPOOL_RPC_STEM)_xdr.c
- $(CC) -I. -MMD -g -c -w $(CPPFLAGS) $(CFLAGS.optimize) $<
+$(IPPOOL_RPC_STEM)_xdr.o: $(IPPOOL_RPC_STEM)_xdr.c $(IPPOOL_RPC_STEM).h
+ $(CC) -I. -MMD -g -c -w $(CPPFLAGS) $(CFLAGS.optimize) $< -fPIC
-$(IPPOOL_RPC_STEM)_client.o: $(IPPOOL_RPC_STEM)_client.c
- $(CC) -I. -MMD -g -c -w $(CPPFLAGS) $(CFLAGS.optimize) $<
+$(IPPOOL_RPC_STEM)_client.o: $(IPPOOL_RPC_STEM)_client.c $(IPPOOL_RPC_STEM).h
+ $(CC) -I. -MMD -g -c -w $(CPPFLAGS) $(CFLAGS.optimize) $< -fPIC
-$(IPPOOL_RPC_STEM)_server.o: $(IPPOOL_RPC_STEM)_server.c
- $(CC) -I. -MMD -g -c -w $(CPPFLAGS) $(CFLAGS.optimize) $<
+$(IPPOOL_RPC_STEM)_server.o: $(IPPOOL_RPC_STEM)_server.c $(IPPOOL_RPC_STEM).h
+ $(CC) -I. -MMD -g -c -w $(CPPFLAGS) $(CFLAGS.optimize) $< -fPIC
$(IPPOOL_RPC_STEM)_xdr.c: $(IPPOOL_RPC_STEM).x
-$(RM) $@
@@ -136,8 +136,12 @@ $(IPPOOL_RPC_STEM).h: $(IPPOOL_RPC_STEM).x
generated-files: $(RPC_FILES)
-subdirs-all:
- @for d in $(SUBDIRS); do $(MAKE) -C $$d $(MFLAGS) EXTRA_CFLAGS="$(CPPFLAGS)" all; if [ $$? -ne 0 ]; then exit 1; fi; done
+subdirs-all: $(patsubst %,%-dir, $(SUBDIRS))
+
+pppd-dir: $(IPPOOL_RPC_STEM)_xdr.o $(IPPOOL_RPC_STEM)_client.o $(IPPOOL_RPC_STEM).h
+
+$(patsubst %,%-dir,$(SUBDIRS)):
+ @for d in $(patsubst %-dir,%,$@); do $(MAKE) -C $$d $(MFLAGS) EXTRA_CFLAGS="$(CPPFLAGS)" all; if [ $$? -ne 0 ]; then exit 1; fi; done
clean:
@for d in $(SUBDIRS); do $(MAKE) -C $$d $(MFLAGS) $@; if [ $$? -ne 0 ]; then exit 1; fi; done
@@ -151,13 +155,13 @@ TAGS:
@for d in $(SUBDIRS); do $(MAKE) -C $$d $(MFLAGS) $@; done
etags -t $(wildcard *.c) $(wildcard *.h)
-ippoold: $(IPPOOLD_SRCS.o)
- $(CC) -o $@ $^ $(LDFLAGS.ippoold)
+ippoold: $(IPPOOLD_SRCS.o) usl-dir
+ $(CC) -o $@ $(IPPOOLD_SRCS.o) $(LDFLAGS.ippoold)
-ippoolconfig: $(IPPOOLCONFIG_SRCS.o)
- $(CC) -o $@ $^ $(LDFLAGS.ippoolconfig)
+ippoolconfig: $(IPPOOLCONFIG_SRCS.o) cli-dir
+ $(CC) -o $@ $(IPPOOLCONFIG_SRCS.o) $(LDFLAGS.ippoolconfig)
-%.o: %.c
+%.o: %.c $(IPPOOL_RPC_STEM).h
$(CC) -c $(CFLAGS) $< -o $@
install: all
diff --git a/pppd/Makefile b/pppd/Makefile
index 78d9b33..106deca 100644
--- a/pppd/Makefile
+++ b/pppd/Makefile
@@ -24,3 +24,5 @@ install: ippool.so
clean:
-rm -rf *.o *.so
+
+include $(wildcard *.d /dev/null)

View File

@@ -0,0 +1,49 @@
include limits.h to avoid UINT_MAX undefined compiling error.
remove the unused assign which caused compiling error with -Werror.
Upstream-Status: Pending
Signed-off-by: Yao Zhao <yao.zhao@windriver.com>
---
diff --git a/usl/usl_timer.c b/usl/usl_timer.c
index 734b820..fda752b 100644
--- a/usl/usl_timer.c
+++ b/usl/usl_timer.c
@@ -42,6 +42,7 @@
#include <signal.h>
#include <string.h>
#include <sys/time.h>
+#include <limits.h>
#include "usl.h"
@@ -87,14 +88,13 @@ void (*usl_timer_tick_hook)(void);
*/
void usl_timer_tick(void)
{
- int result;
char msg = '\0';
usl_tick++;
if (!usl_tick_pending) {
usl_tick_pending = 1;
- result = write(usl_tick_pipe[1], &msg, sizeof(msg));
+ write(usl_tick_pipe[1], &msg, sizeof(msg));
}
}
@@ -111,11 +111,10 @@ static void usl_timer_tick_handler(int fd, void *arg)
struct usl_ord_list_head *tmp;
struct usl_list_head *iwalk;
struct usl_list_head *itmp;
- int result;
char msg;
USL_LIST_HEAD(expire_list);
- result = usl_fd_read(usl_tick_pipe[0], &msg, sizeof(msg));
+ usl_fd_read(usl_tick_pipe[0], &msg, sizeof(msg));
usl_tick_pending = 0;
usl_list_for_each(walk, tmp, &usl_timer_list) {

View File

@@ -0,0 +1,21 @@
Add LDFLAGS variable to Makefile so that extra linker flags can be sent via this variable.
Upstream-Status: Pending
Signed-off-by: Yi Zhao <yi.zhao@windriver.com>
diff --git a/Makefile b/Makefile
index 4f7af1d..a05a000 100644
--- a/Makefile
+++ b/Makefile
@@ -83,8 +83,8 @@ endif
CPPFLAGS= $(CPPFLAGS.ippooltest)
CFLAGS= -I. -Iusl -Icli -MMD -Wall -g $(CPPFLAGS) $(CPPFLAGS.dmalloc)
-LDFLAGS.ippoold= -Wl,-E -L. -Lusl -lusl -lnsl -ldl $(LIBS.dmalloc) -lc
-LDFLAGS.ippoolconfig= -Lcli -lcli -lreadline -lcurses -lnsl $(LIBS.dmalloc) -lc
+LDFLAGS.ippoold= $(LDFLAGS) -Wl,-E -L. -Lusl -lusl -lnsl -ldl $(LIBS.dmalloc) -lc
+LDFLAGS.ippoolconfig= $(LDFLAGS) -Lcli -lcli -lreadline -lcurses -lnsl $(LIBS.dmalloc) -lc
OPT_CFLAGS?= -O

View File

@@ -0,0 +1,26 @@
#!/bin/sh
BANNER="----------------------------------------------------------------------------"
TCLSH="tclsh all.tcl -preservecore 3 -verbose bps -tmpdir ./results -outfile test-ippool.result"
test_setup() {
if [ -d ./results ]; then rm -fr ./results; fi
mkdir ./results
}
test_ippool() {
echo "${BANNER}"
eval $TCLSH -constraints "ipPool"
}
test_postprocess() {
echo "${BANNER}"
(failed=`grep FAILED results/*.result | wc -l`; \
let failed2=failed/2 ;\
passed=`grep PASSED results/*.result | wc -l`; \
echo "TEST SUMMARY: $passed tests PASSED, $failed2 tests FAILED" ;\
exit $failed2)
}
test_setup
test_ippool
test_postprocess

View File

@@ -0,0 +1,39 @@
Replace strncpy with memcpy
since the length of data to
be copied has already been determined with strlen(). Replace strncpy()
with memcpy() to address the warning and optimize the code a little.
| ippool_config.c:112:2: note: 'snprintf' output between 8 and 55 bytes into a destination of size 48
| 112 | snprintf(prompt, sizeof(prompt), "ippool-%s", server_name);
| | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Upstream-Status: Pending
Signed-off-by: Khem Raj <raj.khem@gmail.com>
--- a/cli/cli_readline.c
+++ b/cli/cli_readline.c
@@ -257,10 +257,15 @@ static void cli_rl_display_wrapped_text(
int pos;
int in_ws;
int i;
+ int bufsize = sizeof(text_buf)/sizeof(text_buf[0]);
if (left_margin == 0) {
left_margin = 3;
}
+ if (left_margin > bufsize) {
+ left_margin = bufsize;
+ }
+
if (right_margin == 0) {
right_margin = 78;;
}
@@ -271,7 +276,7 @@ static void cli_rl_display_wrapped_text(
/* First copy the text heading to the buffer and add a "-", accounting for
* the specified left margin.
*/
- strncpy(&text_buf[0], text1, left_margin - 3);
+ memcpy(&text_buf[0], text1, left_margin - 3);
for (pos = strlen(text1); pos < left_margin - 3; pos++) {
text_buf[pos] = ' ';
}

View File

@@ -0,0 +1,113 @@
SUMMARY = "An IP address pool manager"
DESCRIPTION = "IpPool is implemented as a separate server daemon \
to allow any application to use its address pools. This makes it possible \
to define address pools that are shared by PPP, L2TP, PPTP etc. It may be \
useful in some VPN server setups. IpPool comes with a command line \
management application, ippoolconfig to manage and query address pool \
status. A pppd plugin is supplied which allows pppd to request IP \
addresses from ippoold. \
"
HOMEPAGE = "http://www.openl2tp.org/"
SECTION = "console/network"
LICENSE = "GPL-2.0-or-later"
SRC_URI = "https://sourceforge.net/projects/openl2tp/files/${BPN}/${PV}/${BPN}-${PV}.tar.gz \
file://runtest.sh \
file://ippool.service \
file://ippool_usl_timer.patch \
file://ippool_parallel_make_and_pic.patch \
file://ippool_init.d.patch \
file://always_syslog.patch \
file://makefile-add-ldflags.patch \
file://0001-usl_timer-Check-for-return-value-of-write-API.patch \
file://0001-Respect-flags-from-env.patch \
file://0001-read-returns-ssize_t.patch \
file://0002-Mark-first-element-of-a-string-as-null.patch \
file://0003-cli-Mark-return-of-strtol-as-long-int.patch \
file://0002-link-with-libtirpc.patch \
file://0003-musl-fixes.patch \
file://strncpy-truncation.patch \
file://0001-pppd-ippool.c-Fix-type-casting-issues-between-in_add.patch \
file://0002-ippool_rpc_server.c-Add-missing-prototype-for-ippool.patch \
file://0001-Use-unsigned-int-type-for-1-bit-integer-bitfield.patch \
"
LIC_FILES_CHKSUM = "file://LICENSE;md5=4c59283b82fc2b166455e0fc23c71c6f"
SRC_URI[md5sum] = "e2401e65db26a3764585b97212888fae"
SRC_URI[sha256sum] = "d3eab7d6cad5da8ccc9d1e31d5303e27a39622c07bdb8fa3618eea314412075b"
inherit systemd
DEPENDS = "readline ppp ncurses gzip-native rpcsvc-proto-native libtirpc"
RDEPENDS:${PN} = "rpcbind"
EXTRA_OEMAKE = "CC='${CC}' AS='${AS}' LD='${LD}' AR='${AR}' NM='${NM}' STRIP='${STRIP}'"
EXTRA_OEMAKE += "PPPD_VERSION=${PPPD_VERSION} SYS_LIBDIR=${libdir}"
# enable self tests
EXTRA_OEMAKE += "IPPOOL_TEST=y"
CPPFLAGS += "${SELECTED_OPTIMIZATION} -I${STAGING_INCDIR}/tirpc"
SYSTEMD_SERVICE:${PN} = "ippool.service"
SYSTEMD_AUTO_ENABLE = "disable"
do_compile:prepend() {
# fix the CFLAGS= and CPPFLAGS= in main Makefile, to have the extra CFLAGS in env
sed -i -e "s/^CFLAGS=/CFLAGS+=/" ${S}/Makefile
sed -i -e "s/^CPPFLAGS=/CPPFLAGS+=/" ${S}/Makefile
sed -i -e "s:-I/usr/include/pppd:-I=/usr/include/pppd:" ${S}/pppd/Makefile
}
do_install() {
oe_runmake DESTDIR=${D} install
install -D -m 0755 ${S}/debian/init.d ${D}${sysconfdir}/init.d/ippoold
install -D -m 0644 ${WORKDIR}/ippool.service ${D}${systemd_system_unitdir}/ippool.service
sed -i -e 's:@SBINDIR@:${sbindir}:g' ${D}${systemd_system_unitdir}/ippool.service
# install self test
install -d ${D}/opt/${BPN}
install ${S}/test/all.tcl ${S}/test/ippool.test \
${S}/test/test_procs.tcl ${D}/opt/${BPN}
install ${WORKDIR}/runtest.sh ${D}/opt/${BPN}
# fix the ../ippoolconfig in test_procs.tcl
sed -i -e "s:../ippoolconfig:ippoolconfig:" \
${D}/opt/${BPN}/test_procs.tcl
}
PACKAGES =+ "${PN}-test"
FILES:${PN} += "${libdir}/pppd/${PPPD_VERSION}/ippool.so"
FILES:${PN}-dbg += "${libdir}/pppd/${PPPD_VERSION}/.debug/ippool.so"
FILES:${PN}-test = "/opt/${BPN}"
# needs tcl to run tests
RDEPENDS:${PN}-test += "tcl ${BPN}"
PPPD_VERSION="${@get_ppp_version(d)}"
def get_ppp_version(d):
import re
pppd_plugin = d.expand('${STAGING_LIBDIR}/pppd')
if not os.path.isdir(pppd_plugin):
return None
bb.debug(1, "pppd plugin dir %s" % pppd_plugin)
r = re.compile(r"\d*\.\d*\.\d*")
for f in os.listdir(pppd_plugin):
if os.path.isdir(os.path.join(pppd_plugin, f)):
ma = r.match(f)
if ma:
bb.debug(1, "pppd version dir %s" % f)
return f
else:
bb.debug(1, "under pppd plugin dir %s" % f)
return None