From 763594c26cd9a5df4f1860c43664f51a86b6aa3c Mon Sep 17 00:00:00 2001 From: "Sergey V. Lobanov" Date: Wed, 28 Aug 2024 20:06:28 +0000 Subject: [PATCH 01/15] pcre --- CMakeLists.txt | 10 ++++++++++ README | 2 +- accel-pppd/CMakeLists.txt | 4 ++-- accel-pppd/cli/show_sessions.c | 19 ++++++++++++------- 4 files changed, 25 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 128b75a9..3363f649 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -33,6 +33,16 @@ IF(NOT PCRE_LIBRARY) message(FATAL_ERROR "${Esc}[31mRequired libpcre not found.\n Install libpcre3-dev and run cmake again${Esc}[m") ENDIF(NOT PCRE_LIBRARY) +#Check libpcre2 +find_library(PCRE2_LIBRARY pcre2-8 + HINTS ${CMAKE_SOURCE_DIR}/lib/linux/gcc/${BIT}/lib + PATHS ${CMAKE_SOURCE_DIR}/lib/linux/gcc/${BIT}/lib +) + +IF(NOT PCRE2_LIBRARY) + message(FATAL_ERROR "${Esc}[31mRequired libpcre not found.\n Install libpcre2-dev and run cmake again${Esc}[m") +ENDIF(NOT PCRE2_LIBRARY) + IF (EXISTS ${CMAKE_HOME_DIRECTORY}/.git AND NOT IGNORE_GIT) EXECUTE_PROCESS( diff --git a/README b/README index 143c5e13..4977d647 100644 --- a/README +++ b/README @@ -34,7 +34,7 @@ Requirment 4. cmake-2.6 or later 5. libnl-2.0 or probably later (required for builtin shaper) 6. libcrypto-0.9.8 or probably later (openssl-0.9.8) -7. libpcre +7. libpcre2 8. net-snmp-5.x 9. libssl-0.9.8 or probably later (openssl-0.9.8) diff --git a/accel-pppd/CMakeLists.txt b/accel-pppd/CMakeLists.txt index cd7186ba..61e106c8 100644 --- a/accel-pppd/CMakeLists.txt +++ b/accel-pppd/CMakeLists.txt @@ -163,9 +163,9 @@ CHECK_FUNCTION_EXISTS(getcontext HAVE_GETCONTEXT) CHECK_FUNCTION_EXISTS(setcontext HAVE_SETCONTEXT) IF (HAVE_GETCONTEXT AND HAVE_SETCONTEXT) - TARGET_LINK_LIBRARIES(accel-pppd triton rt pthread ${crypto_lib} pcre) + TARGET_LINK_LIBRARIES(accel-pppd triton rt pthread ${crypto_lib} pcre pcre2-8) ELSE (HAVE_GETCONTEXT AND HAVE_SETCONTEXT) - TARGET_LINK_LIBRARIES(accel-pppd triton rt pthread ${crypto_lib} pcre ucontext) + TARGET_LINK_LIBRARIES(accel-pppd triton rt pthread ${crypto_lib} pcre pcre2-8 ucontext) ENDIF (HAVE_GETCONTEXT AND HAVE_SETCONTEXT) set_property(TARGET accel-pppd PROPERTY CMAKE_SKIP_BUILD_RPATH FALSE) diff --git a/accel-pppd/cli/show_sessions.c b/accel-pppd/cli/show_sessions.c index 22f5318a..2c0d1f28 100644 --- a/accel-pppd/cli/show_sessions.c +++ b/accel-pppd/cli/show_sessions.c @@ -6,6 +6,8 @@ #include #include #include +#define PCRE2_CODE_UNIT_WIDTH 8 +#include #include "triton.h" #include "events.h" @@ -128,9 +130,9 @@ static int show_ses_exec(const char *cmd, char * const *f, int f_cnt, void *cli) struct column_t *match_key = NULL; char *match_pattern = NULL; struct column_t *order_key = NULL; - pcre *re = NULL; - const char *pcre_err; - int pcre_offset; + pcre2_code *re = NULL; + int pcre_err; + PCRE2_SIZE pcre_offset; struct column_t *column; struct col_t *col; struct row_t *row; @@ -169,9 +171,12 @@ static int show_ses_exec(const char *cmd, char * const *f, int f_cnt, void *cli) } if (match_key) { - re = pcre_compile2(match_pattern, 0, NULL, &pcre_err, &pcre_offset, NULL); + re = pcre2_compile((PCRE2_SPTR)match_pattern, PCRE2_ZERO_TERMINATED, 0, &pcre_err, &pcre_offset, NULL); if (!re) { - cli_sendv(cli, "match: %s at %i\r\n", pcre_err, pcre_offset); + PCRE2_UCHAR err_msg[64]; + pcre2_get_error_message(pcre_err, err_msg, sizeof(err_msg)); + + cli_sendv(cli, "match: %s at %i\r\n", err_msg, (int)pcre_offset); return CLI_CMD_OK; } } @@ -262,7 +267,7 @@ static int show_ses_exec(const char *cmd, char * const *f, int f_cnt, void *cli) row = list_entry(t_list.next, typeof(*row), entry); list_del(&row->entry); if (match_key) { - if (pcre_exec(re, NULL, row->match_key, strlen(row->match_key), 0, 0, NULL, 0) < 0) { + if (pcre2_match(re, (PCRE2_SPTR)row->match_key, strlen(row->match_key), 0, 0, NULL, NULL) < 0) { free_row(row); continue; } @@ -362,7 +367,7 @@ static int show_ses_exec(const char *cmd, char * const *f, int f_cnt, void *cli) } if (re) - pcre_free(re); + pcre2_code_free(re); return CLI_CMD_OK; From 9d65db67f3741c0dcef12394752dae8a8f8cdb8f Mon Sep 17 00:00:00 2001 From: "Sergey V. Lobanov" Date: Wed, 28 Aug 2024 20:09:09 +0000 Subject: [PATCH 02/15] pcre ci --- .github/workflows/build-and-run.yml | 10 +++++----- .github/workflows/run-tests.yml | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build-and-run.yml b/.github/workflows/build-and-run.yml index 591d8cbf..a40ff4ea 100644 --- a/.github/workflows/build-and-run.yml +++ b/.github/workflows/build-and-run.yml @@ -34,7 +34,7 @@ jobs: sudo apt update && NEEDRESTART_SUSPEND=1 DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true sudo -E apt -y install git build-essential cmake gcc linux-headers-`uname -r` - libpcre3-dev libssl-dev liblua5.1-0-dev kmod + libpcre3-dev libpcre2-dev libssl-dev liblua5.1-0-dev kmod - name: Check out repository code uses: actions/checkout@v3 with: @@ -118,7 +118,7 @@ jobs: apt update && apt -y upgrade && apt -y dist-upgrade && NEEDRESTART_SUSPEND=1 DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true apt -y install git build-essential cmake gcc linux-headers-${{ env.HEADERS_SUFFIX }} - libpcre3-dev libssl-dev liblua5.1-0-dev kmod + libpcre3-dev libpcre2-dev libssl-dev liblua5.1-0-dev kmod - name: Get kernel name from headers run: > echo KERNEL_NAME=`ls -1 /usr/src/ | grep 'linux-headers.*${{ env.HEADERS_SUFFIX }}' | @@ -177,7 +177,7 @@ jobs: run: > apt update && apt -y upgrade && apt -y dist-upgrade && DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true apt -y install git build-essential cmake gcc - linux-headers-generic libpcre3-dev libssl-dev liblua5.1-0-dev kmod software-properties-common + linux-headers-generic libpcre3-dev libpcre2-dev libssl-dev liblua5.1-0-dev kmod software-properties-common pkexec dbus linux-base && add-apt-repository -y ppa:cappelikan/ppa && apt update && service dbus start && @@ -222,7 +222,7 @@ jobs: steps: - name: Install build tools run: > - apk update && apk add --no-cache git cmake make g++ pcre-dev libressl-dev linux-headers libucontext-dev lua5.1-dev + apk update && apk add --no-cache git cmake make g++ pcre-dev pcre2-dev libressl-dev linux-headers libucontext-dev lua5.1-dev - name: Check out repository code uses: actions/checkout@v3 with: @@ -259,7 +259,7 @@ jobs: - name: Install build tools run: | emerge -g --autounmask-write sys-kernel/gentoo-kernel-bin || (etc-update --verbose --automode -5 && emerge -g sys-kernel/gentoo-kernel-bin) - emerge -g dev-vcs/git dev-libs/libpcre dev-build/cmake dev-lang/lua:5.1 + emerge -g dev-vcs/git dev-libs/libpcre dev-libs/libpcre2 dev-build/cmake dev-lang/lua:5.1 - name: Check out repository code uses: actions/checkout@v4 with: diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index a50a7a53..704de526 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -117,7 +117,7 @@ jobs: run: > ssh -i ssh-key -p2222 user@localhost "sudo apt -y install git build-essential cmake gcc linux-headers-\`uname -r\` - libpcre3-dev libssl-dev liblua5.1-0-dev kmod python3-pip + libpcre3-dev libpcre2-dev libssl-dev liblua5.1-0-dev kmod python3-pip libxml2-dev libxslt1-dev zlib1g-dev iproute2 ppp pppoe isc-dhcp-client timelimit && (sudo pip3 install pytest pytest-dependency pytest-order || sudo pip3 install --break-system-packages pytest pytest-dependency pytest-order)" @@ -195,7 +195,7 @@ jobs: sudo apt update && NEEDRESTART_SUSPEND=1 DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true sudo -E apt -y install git build-essential cmake gcc linux-headers-`uname -r` - libpcre3-dev libssl-dev liblua5.1-0-dev kmod python3-pip + libpcre3-dev libpcre2-dev libssl-dev liblua5.1-0-dev kmod python3-pip iproute2 ppp pppoe isc-dhcp-client - name: Install testing tools (using pip) @@ -248,7 +248,7 @@ jobs: sudo apt update && NEEDRESTART_SUSPEND=1 DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true sudo -E apt -y install git build-essential cmake gcc linux-headers-`uname -r` - libpcre3-dev libssl-dev liblua5.1-0-dev kmod python3-pip + libpcre3-dev libpcre2-dev libssl-dev liblua5.1-0-dev kmod python3-pip iproute2 ppp pppoe isc-dhcp-client - name: Install testing tools (using pip) From f78ce684ed1502d3ae877faf99b9d40bce4ec90e Mon Sep 17 00:00:00 2001 From: "Sergey V. Lobanov" Date: Wed, 28 Aug 2024 20:26:00 +0000 Subject: [PATCH 03/15] pcre --- accel-pppd/cli/show_sessions.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/accel-pppd/cli/show_sessions.c b/accel-pppd/cli/show_sessions.c index 2c0d1f28..759b85a5 100644 --- a/accel-pppd/cli/show_sessions.c +++ b/accel-pppd/cli/show_sessions.c @@ -267,10 +267,13 @@ static int show_ses_exec(const char *cmd, char * const *f, int f_cnt, void *cli) row = list_entry(t_list.next, typeof(*row), entry); list_del(&row->entry); if (match_key) { - if (pcre2_match(re, (PCRE2_SPTR)row->match_key, strlen(row->match_key), 0, 0, NULL, NULL) < 0) { + pcre2_match_data *match_data = pcre2_match_data_create(0, NULL); + if (pcre2_match(re, (PCRE2_SPTR)row->match_key, strlen(row->match_key), 0, 0, match_data, NULL) < 0) { free_row(row); + pcre2_match_data_free(match_data); continue; } + pcre2_match_data_free(match_data); } if (order_key) insert_row(&r_list, row); From e31e12fde83df60917d4d791ac913a01f8855894 Mon Sep 17 00:00:00 2001 From: "Sergey V. Lobanov" Date: Wed, 28 Aug 2024 20:45:43 +0000 Subject: [PATCH 04/15] cli (remove unused func) --- accel-pppd/cli/cli.c | 45 -------------------------------------------- accel-pppd/cli/cli.h | 1 - 2 files changed, 46 deletions(-) diff --git a/accel-pppd/cli/cli.c b/accel-pppd/cli/cli.c index 7d440727..0df984f8 100644 --- a/accel-pppd/cli/cli.c +++ b/accel-pppd/cli/cli.c @@ -63,51 +63,6 @@ void __export cli_register_simple_cmd2( va_end(ap); } -void __export cli_register_regexp_cmd(struct cli_regexp_cmd_t *cmd) -{ - int err; - int erroffset; - const char *errptr; - - if (cmd->exec == NULL) { - log_emerg("cli: impossible to register regexp command" - " without an execution callback function\n"); - _exit(EXIT_FAILURE); - } - if (cmd->pattern == NULL) { - log_emerg("cli: impossible to register regexp command" - " without pattern\n"); - _exit(EXIT_FAILURE); - } - cmd->re = pcre_compile2(cmd->pattern, cmd->options, &err, - &errptr, &erroffset, NULL); - if (!cmd->re) { - log_emerg("cli: failed to compile regexp \"%s\": %s (error %i)" - " at positon %i (unprocessed characters: \"%s\")\n", - cmd->pattern, errptr, err, erroffset, - cmd->pattern + erroffset); - _exit(EXIT_FAILURE); - } - - if (cmd->h_pattern) { - cmd->h_re = pcre_compile2(cmd->h_pattern, cmd->h_options, &err, - &errptr, &erroffset, NULL); - if (!cmd->h_re) { - log_emerg("cli: failed to compile help regexp \"%s\":" - " %s (error %i) at position %i (unprocessed" - " characters: \"%s\")\n", - cmd->h_pattern, errptr, err, erroffset, - cmd->h_pattern + erroffset); - _exit(EXIT_FAILURE); - } - } else { - cmd->h_re = NULL; - cmd->h_pattern = NULL; - } - - list_add_tail(&cmd->entry, ®exp_cmd_list); -} - int __export cli_send(void *client, const char *data) { struct cli_client_t *cln = (struct cli_client_t *)client; diff --git a/accel-pppd/cli/cli.h b/accel-pppd/cli/cli.h index 6eda5d3f..4ae5d1af 100644 --- a/accel-pppd/cli/cli.h +++ b/accel-pppd/cli/cli.h @@ -42,7 +42,6 @@ void cli_register_simple_cmd2( int hdr_len, ... ); -void cli_register_regexp_cmd(struct cli_regexp_cmd_t *cmd); void cli_show_ses_register(const char *name, const char *desc, void (*print)(struct ap_session *ses, char *buf)); int cli_send(void *client, const char *data); From b8678b171c0efaba97263b104cda2e95c0c6f619 Mon Sep 17 00:00:00 2001 From: "Sergey V. Lobanov" Date: Wed, 28 Aug 2024 21:03:59 +0000 Subject: [PATCH 05/15] pcre (cli, std_cmd, show_session changes) --- accel-pppd/cli/cli.h | 2 ++ accel-pppd/cli/show_sessions.c | 13 +++++-------- accel-pppd/cli/std_cmd.c | 18 ++++++++++++------ 3 files changed, 19 insertions(+), 14 deletions(-) diff --git a/accel-pppd/cli/cli.h b/accel-pppd/cli/cli.h index 4ae5d1af..d9129fe4 100644 --- a/accel-pppd/cli/cli.h +++ b/accel-pppd/cli/cli.h @@ -2,6 +2,8 @@ #define __CLI_H #include +#define PCRE2_CODE_UNIT_WIDTH 8 +#include #include "list.h" diff --git a/accel-pppd/cli/show_sessions.c b/accel-pppd/cli/show_sessions.c index 759b85a5..ca2ec68d 100644 --- a/accel-pppd/cli/show_sessions.c +++ b/accel-pppd/cli/show_sessions.c @@ -6,8 +6,6 @@ #include #include #include -#define PCRE2_CODE_UNIT_WIDTH 8 -#include #include "triton.h" #include "events.h" @@ -173,9 +171,8 @@ static int show_ses_exec(const char *cmd, char * const *f, int f_cnt, void *cli) if (match_key) { re = pcre2_compile((PCRE2_SPTR)match_pattern, PCRE2_ZERO_TERMINATED, 0, &pcre_err, &pcre_offset, NULL); if (!re) { - PCRE2_UCHAR err_msg[64]; - pcre2_get_error_message(pcre_err, err_msg, sizeof(err_msg)); - + PCRE2_UCHAR err_msg[64]; + pcre2_get_error_message(pcre_err, err_msg, sizeof(err_msg)); cli_sendv(cli, "match: %s at %i\r\n", err_msg, (int)pcre_offset); return CLI_CMD_OK; } @@ -267,13 +264,13 @@ static int show_ses_exec(const char *cmd, char * const *f, int f_cnt, void *cli) row = list_entry(t_list.next, typeof(*row), entry); list_del(&row->entry); if (match_key) { - pcre2_match_data *match_data = pcre2_match_data_create(0, NULL); + pcre2_match_data *match_data = pcre2_match_data_create(0, NULL); if (pcre2_match(re, (PCRE2_SPTR)row->match_key, strlen(row->match_key), 0, 0, match_data, NULL) < 0) { free_row(row); - pcre2_match_data_free(match_data); + pcre2_match_data_free(match_data); continue; } - pcre2_match_data_free(match_data); + pcre2_match_data_free(match_data); } if (order_key) insert_row(&r_list, row); diff --git a/accel-pppd/cli/std_cmd.c b/accel-pppd/cli/std_cmd.c index fc073526..695a843d 100644 --- a/accel-pppd/cli/std_cmd.c +++ b/accel-pppd/cli/std_cmd.c @@ -123,9 +123,9 @@ static int terminate_exec1(char * const *f, int f_cnt, void *cli) { struct ap_session *ses; int hard = 0; - pcre *re; - const char *pcre_err; - int pcre_offset; + pcre2_code *re; + int pcre_err; + PCRE2_SIZE pcre_offset; if (f_cnt == 5) { if (!strcmp(f[4], "hard")) @@ -135,8 +135,10 @@ static int terminate_exec1(char * const *f, int f_cnt, void *cli) } else if (f_cnt != 4) return CLI_CMD_SYNTAX; - re = pcre_compile2(f[3], 0, NULL, &pcre_err, &pcre_offset, NULL); + re = pcre2_compile((PCRE2_SPTR)f[3], PCRE2_ZERO_TERMINATED, 0, &pcre_err, &pcre_offset, NULL); if (!re) { + PCRE2_UCHAR err_msg[64]; + pcre2_get_error_message(pcre_err, err_msg, sizeof(err_msg)); cli_sendv(cli, "match: %s at %i\r\n", pcre_err, pcre_offset); return CLI_CMD_OK; } @@ -145,8 +147,12 @@ static int terminate_exec1(char * const *f, int f_cnt, void *cli) list_for_each_entry(ses, &ses_list, entry) { if (!ses->username) continue; - if (pcre_exec(re, NULL, ses->username, strlen(ses->username), 0, 0, NULL, 0) < 0) + pcre2_match_data *match_data = pcre2_match_data_create(0, NULL); + if (pcre2_match(re, (PCRE2_SPTR)ses->username, strlen(ses->username), 0, 0, match_data, NULL) < 0) { + pcre2_match_data_free(match_data); continue; + } + pcre2_match_data_free(match_data); if (hard) triton_context_call(ses->ctrl->ctx, (triton_event_func)__terminate_hard, ses); else @@ -154,7 +160,7 @@ static int terminate_exec1(char * const *f, int f_cnt, void *cli) } pthread_rwlock_unlock(&ses_lock); - pcre_free(re); + pcre2_code_free(re); return CLI_CMD_OK; } From 015fadc022e378bf23b3103881b4acc7923b73f3 Mon Sep 17 00:00:00 2001 From: "Sergey V. Lobanov" Date: Wed, 28 Aug 2024 21:11:30 +0000 Subject: [PATCH 06/15] pcre --- accel-pppd/cli/std_cmd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/accel-pppd/cli/std_cmd.c b/accel-pppd/cli/std_cmd.c index 695a843d..ace48391 100644 --- a/accel-pppd/cli/std_cmd.c +++ b/accel-pppd/cli/std_cmd.c @@ -139,7 +139,7 @@ static int terminate_exec1(char * const *f, int f_cnt, void *cli) if (!re) { PCRE2_UCHAR err_msg[64]; pcre2_get_error_message(pcre_err, err_msg, sizeof(err_msg)); - cli_sendv(cli, "match: %s at %i\r\n", pcre_err, pcre_offset); + cli_sendv(cli, "match: %s at %i\r\n", err_msg, (int)pcre_offset); return CLI_CMD_OK; } From a27d67fcb4686dc63556c31c9c45ec41b8084d6e Mon Sep 17 00:00:00 2001 From: "Sergey V. Lobanov" Date: Wed, 28 Aug 2024 21:24:01 +0000 Subject: [PATCH 07/15] pcre --- accel-pppd/cli/cli.c | 39 +-------------------------------------- accel-pppd/cli/cli.h | 13 ------------- 2 files changed, 1 insertion(+), 51 deletions(-) diff --git a/accel-pppd/cli/cli.c b/accel-pppd/cli/cli.c index 0df984f8..0dd002c9 100644 --- a/accel-pppd/cli/cli.c +++ b/accel-pppd/cli/cli.c @@ -27,7 +27,6 @@ static const char *def_cli_prompt = "accel-ppp"; char *conf_cli_prompt; static LIST_HEAD(simple_cmd_list); -static LIST_HEAD(regexp_cmd_list); void __export cli_register_simple_cmd(struct cli_simple_cmd_t *cmd) { @@ -123,7 +122,6 @@ static int split(char *buf, char **ptr) static int cli_process_help_cmd(struct cli_client_t *cln) { - struct cli_regexp_cmd_t *recmd = NULL; struct cli_simple_cmd_t *sicmd = NULL; char *cmd = (char *)cln->cmdline; char *items[MAX_CMD_ITEMS] = { 0 }; @@ -143,16 +141,6 @@ static int cli_process_help_cmd(struct cli_client_t *cln) /* "help" with no argument always succeeds */ cmd_found = 1; - list_for_each_entry(recmd, ®exp_cmd_list, entry) { - if (cmd[0] == '\0' - || pcre_exec(recmd->h_re, NULL, cmd, strlen(cmd), - 0, 0, NULL, 0) >= 0) { - cmd_found = 1; - if (recmd->help) - recmd->help(cmd, cln); - } - } - nb_items = split(cmd, items); list_for_each_entry(sicmd, &simple_cmd_list, entry) { int indx = 0; @@ -177,28 +165,6 @@ static int cli_process_help_cmd(struct cli_client_t *cln) return 1; } -static int cli_process_regexp_cmd(struct cli_client_t *cln, int *err) -{ - struct cli_regexp_cmd_t *recmd = NULL; - char *cmd = (char *)cln->cmdline; - int found = 0; - int res; - - cmd = skip_space(cmd); - list_for_each_entry(recmd, ®exp_cmd_list, entry) - if (pcre_exec(recmd->re, NULL, cmd, strlen(cmd), - 0, 0, NULL, 0) >= 0) { - found = 1; - res = recmd->exec(cmd, cln); - if (res != CLI_CMD_OK) - break; - } - if (found) - *err = res; - - return found; -} - static int cli_process_simple_cmd(struct cli_client_t *cln, int *err) { struct cli_simple_cmd_t *sicmd = NULL; @@ -238,10 +204,7 @@ int __export cli_process_cmd(struct cli_client_t *cln) if (cli_process_help_cmd(cln)) return 0; - found = cli_process_regexp_cmd(cln, &err); - if (found && err != CLI_CMD_OK) - goto out_found; - + found = 0; found |= cli_process_simple_cmd(cln, &err); if (found) goto out_found; diff --git a/accel-pppd/cli/cli.h b/accel-pppd/cli/cli.h index d9129fe4..778d94eb 100644 --- a/accel-pppd/cli/cli.h +++ b/accel-pppd/cli/cli.h @@ -22,19 +22,6 @@ struct cli_simple_cmd_t void (*help)(char * const *fields, int field_cnt, void *client); }; -struct cli_regexp_cmd_t -{ - struct list_head entry; - pcre *re; - const char *pattern; - int options; - int (*exec)(const char *cmd, void *client); - pcre *h_re; - const char *h_pattern; - int h_options; - int (*help)(const char *cmd, void *client); -}; - struct ap_session; void cli_register_simple_cmd(struct cli_simple_cmd_t *cmd); From d673b3578b07f4d6a1cd87ea350b652f3af6dfe7 Mon Sep 17 00:00:00 2001 From: "Sergey V. Lobanov" Date: Wed, 28 Aug 2024 21:29:08 +0000 Subject: [PATCH 08/15] Revert "pcre" This reverts commit a27d67fcb4686dc63556c31c9c45ec41b8084d6e. --- accel-pppd/cli/cli.c | 39 ++++++++++++++++++++++++++++++++++++++- accel-pppd/cli/cli.h | 13 +++++++++++++ 2 files changed, 51 insertions(+), 1 deletion(-) diff --git a/accel-pppd/cli/cli.c b/accel-pppd/cli/cli.c index 0dd002c9..0df984f8 100644 --- a/accel-pppd/cli/cli.c +++ b/accel-pppd/cli/cli.c @@ -27,6 +27,7 @@ static const char *def_cli_prompt = "accel-ppp"; char *conf_cli_prompt; static LIST_HEAD(simple_cmd_list); +static LIST_HEAD(regexp_cmd_list); void __export cli_register_simple_cmd(struct cli_simple_cmd_t *cmd) { @@ -122,6 +123,7 @@ static int split(char *buf, char **ptr) static int cli_process_help_cmd(struct cli_client_t *cln) { + struct cli_regexp_cmd_t *recmd = NULL; struct cli_simple_cmd_t *sicmd = NULL; char *cmd = (char *)cln->cmdline; char *items[MAX_CMD_ITEMS] = { 0 }; @@ -141,6 +143,16 @@ static int cli_process_help_cmd(struct cli_client_t *cln) /* "help" with no argument always succeeds */ cmd_found = 1; + list_for_each_entry(recmd, ®exp_cmd_list, entry) { + if (cmd[0] == '\0' + || pcre_exec(recmd->h_re, NULL, cmd, strlen(cmd), + 0, 0, NULL, 0) >= 0) { + cmd_found = 1; + if (recmd->help) + recmd->help(cmd, cln); + } + } + nb_items = split(cmd, items); list_for_each_entry(sicmd, &simple_cmd_list, entry) { int indx = 0; @@ -165,6 +177,28 @@ static int cli_process_help_cmd(struct cli_client_t *cln) return 1; } +static int cli_process_regexp_cmd(struct cli_client_t *cln, int *err) +{ + struct cli_regexp_cmd_t *recmd = NULL; + char *cmd = (char *)cln->cmdline; + int found = 0; + int res; + + cmd = skip_space(cmd); + list_for_each_entry(recmd, ®exp_cmd_list, entry) + if (pcre_exec(recmd->re, NULL, cmd, strlen(cmd), + 0, 0, NULL, 0) >= 0) { + found = 1; + res = recmd->exec(cmd, cln); + if (res != CLI_CMD_OK) + break; + } + if (found) + *err = res; + + return found; +} + static int cli_process_simple_cmd(struct cli_client_t *cln, int *err) { struct cli_simple_cmd_t *sicmd = NULL; @@ -204,7 +238,10 @@ int __export cli_process_cmd(struct cli_client_t *cln) if (cli_process_help_cmd(cln)) return 0; - found = 0; + found = cli_process_regexp_cmd(cln, &err); + if (found && err != CLI_CMD_OK) + goto out_found; + found |= cli_process_simple_cmd(cln, &err); if (found) goto out_found; diff --git a/accel-pppd/cli/cli.h b/accel-pppd/cli/cli.h index 778d94eb..d9129fe4 100644 --- a/accel-pppd/cli/cli.h +++ b/accel-pppd/cli/cli.h @@ -22,6 +22,19 @@ struct cli_simple_cmd_t void (*help)(char * const *fields, int field_cnt, void *client); }; +struct cli_regexp_cmd_t +{ + struct list_head entry; + pcre *re; + const char *pattern; + int options; + int (*exec)(const char *cmd, void *client); + pcre *h_re; + const char *h_pattern; + int h_options; + int (*help)(const char *cmd, void *client); +}; + struct ap_session; void cli_register_simple_cmd(struct cli_simple_cmd_t *cmd); From 3f354b57b2037b2dfc779d7d4ade20c5e05eb5cd Mon Sep 17 00:00:00 2001 From: "Sergey V. Lobanov" Date: Sat, 31 Aug 2024 17:47:03 +0000 Subject: [PATCH 09/15] pcre2 pppoe --- accel-pppd/ctrl/pppoe/pppoe.c | 60 +++++++++++++++++++++-------------- 1 file changed, 37 insertions(+), 23 deletions(-) diff --git a/accel-pppd/ctrl/pppoe/pppoe.c b/accel-pppd/ctrl/pppoe/pppoe.c index 8678db80..c8007414 100644 --- a/accel-pppd/ctrl/pppoe/pppoe.c +++ b/accel-pppd/ctrl/pppoe/pppoe.c @@ -83,7 +83,7 @@ struct padi_t }; struct iplink_arg { - pcre *re; + pcre2_code *re; const char *opt; void *cli; long *arg1; @@ -1368,8 +1368,12 @@ static int parse_server(const char *opt, int *padi_limit, struct ap_net **net) static int __pppoe_add_interface_re(int index, int flags, const char *name, int iflink, int vid, struct iplink_arg *arg) { - if (pcre_exec(arg->re, NULL, name, strlen(name), 0, 0, NULL, 0) < 0) + pcre2_match_data *match_data = pcre2_match_data_create(0, NULL); + if (pcre2_match(arg->re, (PCRE2_SPTR)name, strlen(name), 0, 0, match_data, NULL) < 0) { + pcre2_match_data_free(match_data); return 0; + } + pcre2_match_data_free(match_data); __pppoe_server_start(name, arg->opt, arg->cli, iflink, vid, 0); @@ -1378,11 +1382,11 @@ static int __pppoe_add_interface_re(int index, int flags, const char *name, int static void pppoe_add_interface_re(const char *opt, void *cli) { - pcre *re = NULL; - const char *pcre_err; + pcre2_code *re = NULL; + int pcre_err; char *pattern; const char *ptr; - int pcre_offset; + PCRE2_SIZE pcre_offset; struct iplink_arg arg; for (ptr = opt; *ptr && *ptr != ','; ptr++); @@ -1391,12 +1395,14 @@ static void pppoe_add_interface_re(const char *opt, void *cli) memcpy(pattern, opt + 3, ptr - (opt + 3)); pattern[ptr - (opt + 3)] = 0; - re = pcre_compile2(pattern, 0, NULL, &pcre_err, &pcre_offset, NULL); + re = pcre2_compile((PCRE2_SPTR)pattern, PCRE2_ZERO_TERMINATED, 0, &pcre_err, &pcre_offset, NULL); if (!re) { - if (cli) - cli_sendv(cli, "pppoe: %s at %i\r\n", pcre_err, pcre_offset); - log_error("pppoe: %s at %i\r\n", pcre_err, pcre_offset); + PCRE2_UCHAR err_msg[64]; + pcre2_get_error_message(pcre_err, err_msg, sizeof(err_msg)); + if (cli) + cli_sendv(cli, "pppoe: %s at %i\r\n", err_msg, (int)pcre_offset); + log_error("pppoe: %s at %i\r\n", err_msg, (int)pcre_offset); return; } @@ -1406,7 +1412,7 @@ static void pppoe_add_interface_re(const char *opt, void *cli) iplink_list((iplink_list_func)__pppoe_add_interface_re, &arg); - pcre_free(re); + pcre2_code_free(re); _free(pattern); } @@ -1678,10 +1684,10 @@ void pppoe_vlan_mon_notify(int ifindex, int vid, int vlan_ifindex) struct ifreq ifr; char *ptr; int len, r, svid; - pcre *re = NULL; - const char *pcre_err; + pcre2_code *re = NULL; + int pcre_err; char *pattern; - int pcre_offset; + PCRE2_SIZE pcre_offset; char ifname[IFNAMSIZ]; if (!sect) @@ -1779,15 +1785,17 @@ void pppoe_vlan_mon_notify(int ifindex, int vid, int vlan_ifindex) memcpy(pattern, opt->val + 3, ptr - (opt->val + 3)); pattern[ptr - (opt->val + 3)] = 0; - re = pcre_compile2(pattern, 0, NULL, &pcre_err, &pcre_offset, NULL); + re = pcre2_compile((PCRE2_SPTR)pattern, PCRE2_ZERO_TERMINATED, 0, &pcre_err, &pcre_offset, NULL); _free(pattern); if (!re) continue; - r = pcre_exec(re, NULL, ifr.ifr_name, len, 0, 0, NULL, 0); - pcre_free(re); + pcre2_match_data *match_data = pcre2_match_data_create(0, NULL); + r = pcre2_match(re, (PCRE2_SPTR)ifr.ifr_name, len, 0, 0, match_data, NULL); + pcre2_match_data_free(match_data); + pcre2_code_free(re); if (r < 0) continue; @@ -1862,8 +1870,12 @@ static int __load_vlan_mon_re(int index, int flags, const char *name, int iflink long mask1[4096/8/sizeof(long)]; struct pppoe_serv_t *serv; - if (pcre_exec(arg->re, NULL, name, strlen(name), 0, 0, NULL, 0) < 0) + pcre2_match_data *match_data = pcre2_match_data_create(0, NULL); + if (pcre2_match(arg->re, (PCRE2_SPTR)name, strlen(name), 0, 0, match_data, NULL) < 0) { + pcre2_match_data_free(match_data); return 0; + } + pcre2_match_data_free(match_data); memset(&ifr, 0, sizeof(ifr)); strcpy(ifr.ifr_name, name); @@ -1896,11 +1908,11 @@ static int __load_vlan_mon_re(int index, int flags, const char *name, int iflink static void load_vlan_mon_re(const char *opt, long *mask, int len) { - pcre *re = NULL; - const char *pcre_err; + pcre2_code *re = NULL; + int pcre_err; char *pattern; const char *ptr; - int pcre_offset; + PCRE2_SIZE pcre_offset; struct iplink_arg arg; for (ptr = opt; *ptr && *ptr != ','; ptr++); @@ -1909,10 +1921,12 @@ static void load_vlan_mon_re(const char *opt, long *mask, int len) memcpy(pattern, opt + 3, ptr - (opt + 3)); pattern[ptr - (opt + 3)] = 0; - re = pcre_compile2(pattern, 0, NULL, &pcre_err, &pcre_offset, NULL); + re = pcre2_compile((PCRE2_SPTR)pattern, PCRE2_ZERO_TERMINATED, 0, &pcre_err, &pcre_offset, NULL); if (!re) { - log_error("pppoe: '%s': %s at %i\r\n", pattern, pcre_err, pcre_offset); + PCRE2_UCHAR err_msg[64]; + pcre2_get_error_message(pcre_err, err_msg, sizeof(err_msg)); + log_error("pppoe: '%s': %s at %i\r\n", pattern, err_msg, (int)pcre_offset); return; } @@ -1922,7 +1936,7 @@ static void load_vlan_mon_re(const char *opt, long *mask, int len) iplink_list((iplink_list_func)__load_vlan_mon_re, &arg); - pcre_free(re); + pcre2_code_free(re); _free(pattern); } From b35a4cda7900eee1dbfdc4fafcbe773d56f38adf Mon Sep 17 00:00:00 2001 From: "Sergey V. Lobanov" Date: Sat, 31 Aug 2024 19:05:26 +0000 Subject: [PATCH 10/15] pcre2 cli, ipoe --- accel-pppd/cli/cli.c | 19 ++++++++---- accel-pppd/cli/cli.h | 4 +-- accel-pppd/ctrl/ipoe/ipoe.c | 62 +++++++++++++++++++++++-------------- 3 files changed, 53 insertions(+), 32 deletions(-) diff --git a/accel-pppd/cli/cli.c b/accel-pppd/cli/cli.c index 0df984f8..6b71cb04 100644 --- a/accel-pppd/cli/cli.c +++ b/accel-pppd/cli/cli.c @@ -144,13 +144,15 @@ static int cli_process_help_cmd(struct cli_client_t *cln) cmd_found = 1; list_for_each_entry(recmd, ®exp_cmd_list, entry) { + pcre2_match_data *match_data = pcre2_match_data_create(0, NULL); if (cmd[0] == '\0' - || pcre_exec(recmd->h_re, NULL, cmd, strlen(cmd), - 0, 0, NULL, 0) >= 0) { + || pcre2_match(recmd->h_re, (PCRE2_SPTR)cmd, strlen(cmd), + 0, 0, match_data, NULL) >= 0) { cmd_found = 1; if (recmd->help) recmd->help(cmd, cln); } + pcre2_match_data_free(match_data); } nb_items = split(cmd, items); @@ -185,14 +187,19 @@ static int cli_process_regexp_cmd(struct cli_client_t *cln, int *err) int res; cmd = skip_space(cmd); - list_for_each_entry(recmd, ®exp_cmd_list, entry) - if (pcre_exec(recmd->re, NULL, cmd, strlen(cmd), - 0, 0, NULL, 0) >= 0) { + list_for_each_entry(recmd, ®exp_cmd_list, entry) { + pcre2_match_data *match_data = pcre2_match_data_create(0, NULL); + if (pcre2_match(recmd->re, (PCRE2_SPTR)cmd, strlen(cmd), + 0, 0, match_data, NULL) >= 0) { found = 1; res = recmd->exec(cmd, cln); - if (res != CLI_CMD_OK) + if (res != CLI_CMD_OK) { + pcre2_match_data_free(match_data); break; + } } + pcre2_match_data_free(match_data); + } if (found) *err = res; diff --git a/accel-pppd/cli/cli.h b/accel-pppd/cli/cli.h index d9129fe4..c0851eb7 100644 --- a/accel-pppd/cli/cli.h +++ b/accel-pppd/cli/cli.h @@ -25,11 +25,11 @@ struct cli_simple_cmd_t struct cli_regexp_cmd_t { struct list_head entry; - pcre *re; + pcre2_code *re; const char *pattern; int options; int (*exec)(const char *cmd, void *client); - pcre *h_re; + pcre2_code *h_re; const char *h_pattern; int h_options; int (*help)(const char *cmd, void *client); diff --git a/accel-pppd/ctrl/ipoe/ipoe.c b/accel-pppd/ctrl/ipoe/ipoe.c index 95ff8568..6139d24e 100644 --- a/accel-pppd/ctrl/ipoe/ipoe.c +++ b/accel-pppd/ctrl/ipoe/ipoe.c @@ -20,8 +20,6 @@ #endif #include -#include - #include "events.h" #include "list.h" #include "triton.h" @@ -56,7 +54,7 @@ #define SESSION_TERMINATED "Session was terminated" struct iplink_arg { - pcre *re; + pcre2_code *re; const char *opt; long *arg1; }; @@ -2804,10 +2802,10 @@ void ipoe_vlan_mon_notify(int ifindex, int vid, int vlan_ifindex) struct ifreq ifr; char *ptr; int len, r, svid; - pcre *re = NULL; - const char *pcre_err; + pcre2_code *re = NULL; + int pcre_err; char *pattern; - int pcre_offset; + PCRE2_SIZE pcre_offset; char ifname[IFNAMSIZ]; if (!sect) @@ -2905,15 +2903,17 @@ void ipoe_vlan_mon_notify(int ifindex, int vid, int vlan_ifindex) memcpy(pattern, opt->val + 3, ptr - (opt->val + 3)); pattern[ptr - (opt->val + 3)] = 0; - re = pcre_compile2(pattern, 0, NULL, &pcre_err, &pcre_offset, NULL); + re = pcre2_compile((PCRE2_SPTR)pattern, PCRE2_ZERO_TERMINATED, 0, &pcre_err, &pcre_offset, NULL); _free(pattern); if (!re) continue; - r = pcre_exec(re, NULL, ifname, len, 0, 0, NULL, 0); - pcre_free(re); + pcre2_match_data *match_data = pcre2_match_data_create(0, NULL); + r = pcre2_match(re, (PCRE2_SPTR)ifname, len, 0, 0, match_data, NULL); + pcre2_match_data_free(match_data); + pcre2_code_free(re); if (r < 0) continue; @@ -3358,8 +3358,12 @@ static void load_interface(const char *opt) static int __load_interface_re(int index, int flags, const char *name, int iflink, int vid, struct iplink_arg *arg) { - if (pcre_exec(arg->re, NULL, name, strlen(name), 0, 0, NULL, 0) < 0) + pcre2_match_data *match_data = pcre2_match_data_create(0, NULL); + if (pcre2_match(arg->re, (PCRE2_SPTR)name, strlen(name), 0, 0, match_data, NULL) < 0) { + pcre2_match_data_free(match_data); return 0; + } + pcre2_match_data_free(match_data); add_interface(name, index, arg->opt, iflink, vid, 0); @@ -3368,11 +3372,11 @@ static int __load_interface_re(int index, int flags, const char *name, int iflin static void load_interface_re(const char *opt) { - pcre *re = NULL; - const char *pcre_err; + pcre2_code *re = NULL; + int pcre_err; char *pattern; const char *ptr; - int pcre_offset; + PCRE2_SIZE pcre_offset; struct iplink_arg arg; struct ipoe_serv *serv; @@ -3382,10 +3386,12 @@ static void load_interface_re(const char *opt) memcpy(pattern, opt + 3, ptr - (opt + 3)); pattern[ptr - (opt + 3)] = 0; - re = pcre_compile2(pattern, 0, NULL, &pcre_err, &pcre_offset, NULL); + re = pcre2_compile((PCRE2_SPTR)pattern, PCRE2_ZERO_TERMINATED, 0, &pcre_err, &pcre_offset, NULL); if (!re) { - log_error("ipoe: '%s': %s at %i\r\n", pattern, pcre_err, pcre_offset); + PCRE2_UCHAR err_msg[64]; + pcre2_get_error_message(pcre_err, err_msg, sizeof(err_msg)); + log_error("ipoe: '%s': %s at %i\r\n", pattern, err_msg, (int)pcre_offset); return; } @@ -3398,11 +3404,13 @@ static void load_interface_re(const char *opt) if (serv->active) continue; - if (pcre_exec(re, NULL, serv->ifname, strlen(serv->ifname), 0, 0, NULL, 0) >= 0) + pcre2_match_data *match_data = pcre2_match_data_create(0, NULL); + if (pcre2_match(re, (PCRE2_SPTR)serv->ifname, strlen(serv->ifname), 0, 0, match_data, NULL) >= 0) add_interface(serv->ifname, serv->ifindex, opt, 0, 0, 0); + pcre2_match_data_free(match_data); } - pcre_free(re); + pcre2_code_free(re); _free(pattern); } @@ -3670,8 +3678,12 @@ static int __load_vlan_mon_re(int index, int flags, const char *name, int iflink long mask1[4096/8/sizeof(long)]; struct ipoe_serv *serv; - if (pcre_exec(arg->re, NULL, name, strlen(name), 0, 0, NULL, 0) < 0) + pcre2_match_data *match_data = pcre2_match_data_create(0, NULL); + if (pcre2_match(arg->re, (PCRE2_SPTR)name, strlen(name), 0, 0, match_data, NULL) < 0) { + pcre2_match_data_free(match_data); return 0; + } + pcre2_match_data_free(match_data); if (!(flags & IFF_UP)) { memset(&ifr, 0, sizeof(ifr)); @@ -3701,11 +3713,11 @@ static int __load_vlan_mon_re(int index, int flags, const char *name, int iflink static void load_vlan_mon_re(const char *opt, long *mask, int len) { - pcre *re = NULL; - const char *pcre_err; + pcre2_code *re = NULL; + int pcre_err; char *pattern; const char *ptr; - int pcre_offset; + PCRE2_SIZE pcre_offset; struct iplink_arg arg; for (ptr = opt; *ptr && *ptr != ','; ptr++); @@ -3714,10 +3726,12 @@ static void load_vlan_mon_re(const char *opt, long *mask, int len) memcpy(pattern, opt + 3, ptr - (opt + 3)); pattern[ptr - (opt + 3)] = 0; - re = pcre_compile2(pattern, 0, NULL, &pcre_err, &pcre_offset, NULL); + re = pcre2_compile((PCRE2_SPTR)pattern, PCRE2_ZERO_TERMINATED, 0, &pcre_err, &pcre_offset, NULL); if (!re) { - log_error("ipoe: '%s': %s at %i\r\n", pattern, pcre_err, pcre_offset); + PCRE2_UCHAR err_msg[64]; + pcre2_get_error_message(pcre_err, err_msg, sizeof(err_msg)); + log_error("ipoe: '%s': %s at %i\r\n", pattern, err_msg, (int)pcre_offset); return; } @@ -3727,7 +3741,7 @@ static void load_vlan_mon_re(const char *opt, long *mask, int len) iplink_list((iplink_list_func)__load_vlan_mon_re, &arg); - pcre_free(re); + pcre2_code_free(re); _free(pattern); } From f5633c6a627c693b878ba92e5b9a73bf9e0b1136 Mon Sep 17 00:00:00 2001 From: "Sergey V. Lobanov" Date: Sat, 31 Aug 2024 19:17:07 +0000 Subject: [PATCH 11/15] pcre cmake --- CMakeLists.txt | 10 ---------- accel-pppd/CMakeLists.txt | 4 ++-- 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3363f649..b606898a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,16 +23,6 @@ ENDIF (NOT DEFINED LIB_SUFFIX) #color console example message(FATAL_ERROR "${Esc}[31m Red Text ${Esc}[m Restore Normal Text") string(ASCII 27 Esc) -#Check libpcre -find_library(PCRE_LIBRARY pcre - HINTS ${CMAKE_SOURCE_DIR}/lib/linux/gcc/${BIT}/lib - PATHS ${CMAKE_SOURCE_DIR}/lib/linux/gcc/${BIT}/lib -) - -IF(NOT PCRE_LIBRARY) - message(FATAL_ERROR "${Esc}[31mRequired libpcre not found.\n Install libpcre3-dev and run cmake again${Esc}[m") -ENDIF(NOT PCRE_LIBRARY) - #Check libpcre2 find_library(PCRE2_LIBRARY pcre2-8 HINTS ${CMAKE_SOURCE_DIR}/lib/linux/gcc/${BIT}/lib diff --git a/accel-pppd/CMakeLists.txt b/accel-pppd/CMakeLists.txt index 61e106c8..a1161ddd 100644 --- a/accel-pppd/CMakeLists.txt +++ b/accel-pppd/CMakeLists.txt @@ -163,9 +163,9 @@ CHECK_FUNCTION_EXISTS(getcontext HAVE_GETCONTEXT) CHECK_FUNCTION_EXISTS(setcontext HAVE_SETCONTEXT) IF (HAVE_GETCONTEXT AND HAVE_SETCONTEXT) - TARGET_LINK_LIBRARIES(accel-pppd triton rt pthread ${crypto_lib} pcre pcre2-8) + TARGET_LINK_LIBRARIES(accel-pppd triton rt pthread ${crypto_lib} pcre2-8) ELSE (HAVE_GETCONTEXT AND HAVE_SETCONTEXT) - TARGET_LINK_LIBRARIES(accel-pppd triton rt pthread ${crypto_lib} pcre pcre2-8 ucontext) + TARGET_LINK_LIBRARIES(accel-pppd triton rt pthread ${crypto_lib} pcre2-8 ucontext) ENDIF (HAVE_GETCONTEXT AND HAVE_SETCONTEXT) set_property(TARGET accel-pppd PROPERTY CMAKE_SKIP_BUILD_RPATH FALSE) From c513209f2a179ab4b751cc03fc48bb95a7812507 Mon Sep 17 00:00:00 2001 From: "Sergey V. Lobanov" Date: Sat, 31 Aug 2024 20:10:31 +0000 Subject: [PATCH 12/15] pcre2 cpack --- cmake/cpack.cmake | 46 +++++++++++++--------------------------------- 1 file changed, 13 insertions(+), 33 deletions(-) diff --git a/cmake/cpack.cmake b/cmake/cpack.cmake index 3dfc2750..c004075c 100644 --- a/cmake/cpack.cmake +++ b/cmake/cpack.cmake @@ -20,73 +20,53 @@ SET(CPACK_PACKAGE_VENDOR "Dmitry Kozlov") SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README") SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/COPYING") -IF(CPACK_TYPE STREQUAL Debian5) - SET(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6 (>= 2.7), libssl0.9.8 (>= 0.9.8), libpcre3 (>= 7.6)") - INCLUDE(${CMAKE_HOME_DIRECTORY}/cmake/debian/debian.cmake) -ENDIF(CPACK_TYPE STREQUAL Debian5) - -IF(CPACK_TYPE STREQUAL Debian6) - SET(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6 (>= 2.11.2), libssl0.9.8 (>= 0.9.8), libpcre3 (>= 8.02)") - INCLUDE(${CMAKE_HOME_DIRECTORY}/cmake/debian/debian.cmake) -ENDIF(CPACK_TYPE STREQUAL Debian6) - -IF(CPACK_TYPE STREQUAL Debian7) - SET(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6 (>= 2.13), libssl1.0.0 (>= 1.0.0), libpcre3 (>= 8.30)") - INCLUDE(${CMAKE_HOME_DIRECTORY}/cmake/debian/debian.cmake) -ENDIF(CPACK_TYPE STREQUAL Debian7) - -IF(CPACK_TYPE STREQUAL Debian8) - SET(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6 (>= 2.19), libssl1.0.0 (>= 1.0.1k), libpcre3 (>= 8.35)") - INCLUDE(${CMAKE_HOME_DIRECTORY}/cmake/debian/debian.cmake) -ENDIF(CPACK_TYPE STREQUAL Debian8) - IF(CPACK_TYPE STREQUAL Debian9) - SET(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6 (>= 2.24), libssl1.0.2 (>= 1.0.2l), libpcre3 (>= 8.39)") + SET(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6 (>= 2.24), libssl1.0.2 (>= 1.0.2l), libpcre2-8-0 (>= 10.22)") INCLUDE(${CMAKE_HOME_DIRECTORY}/cmake/debian/debian.cmake) ENDIF(CPACK_TYPE STREQUAL Debian9) IF(CPACK_TYPE STREQUAL Debian10) - SET(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6 (>= 2.28), libssl1.1 (>= 1.1.1c), libpcre3 (>= 8.39)") + SET(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6 (>= 2.28), libssl1.1 (>= 1.1.1c), libpcre2-8-0 (>= 10.32)") INCLUDE(${CMAKE_HOME_DIRECTORY}/cmake/debian/debian.cmake) ENDIF(CPACK_TYPE STREQUAL Debian10) IF(CPACK_TYPE STREQUAL Debian11) - SET(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6 (>= 2.31), libssl1.1 (>= 1.1.1k), libpcre3 (>= 8.39)") + SET(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6 (>= 2.31), libssl1.1 (>= 1.1.1k), libpcre2-8-0 (>= 10.36)") INCLUDE(${CMAKE_HOME_DIRECTORY}/cmake/debian/debian.cmake) ENDIF(CPACK_TYPE STREQUAL Debian11) IF(CPACK_TYPE STREQUAL Debian12) - SET(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6 (>= 2.34), libssl3 (>= 3.0.5), libpcre3 (>= 8.39)") + SET(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6 (>= 2.34), libssl3 (>= 3.0.5), libpcre2-8-0 (>= 10.42)") INCLUDE(${CMAKE_HOME_DIRECTORY}/cmake/debian/debian.cmake) ENDIF(CPACK_TYPE STREQUAL Debian12) IF(CPACK_TYPE STREQUAL Debian13) - SET(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6 (>= 2.37), libssl3 (>= 3.0.9), libpcre3 (>= 8.39)") + SET(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6 (>= 2.37), libssl3 (>= 3.0.9), libpcre2-8-0 (>= 10.42)") INCLUDE(${CMAKE_HOME_DIRECTORY}/cmake/debian/debian.cmake) ENDIF(CPACK_TYPE STREQUAL Debian13) IF(CPACK_TYPE STREQUAL Ubuntu16) - SET(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6 (>= 2.23), libssl1.0.0 (>= 1.0.0), libpcre3 (>= 8.39)") + SET(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6 (>= 2.23), libssl1.0.0 (>= 1.0.0), libpcre2-8-0 (>= 10.21)") INCLUDE(${CMAKE_HOME_DIRECTORY}/cmake/debian/debian.cmake) ENDIF(CPACK_TYPE STREQUAL Ubuntu16) IF(CPACK_TYPE STREQUAL Ubuntu18) - SET(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6 (>= 2.24), libssl1.0.0 (>= 1.0.2n), libpcre3 (>= 8.39)") + SET(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6 (>= 2.24), libssl1.0.0 (>= 1.0.2n), libpcre2-8-0 (>= 10.31)") INCLUDE(${CMAKE_HOME_DIRECTORY}/cmake/debian/debian.cmake) ENDIF(CPACK_TYPE STREQUAL Ubuntu18) IF(CPACK_TYPE STREQUAL Ubuntu20) - SET(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6 (>= 2.31), libssl1.1 (>= 1.1.1d), libpcre3 (>= 8.39)") + SET(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6 (>= 2.31), libssl1.1 (>= 1.1.1d), libpcre2-8-0 (>= 10.34)") INCLUDE(${CMAKE_HOME_DIRECTORY}/cmake/debian/debian.cmake) ENDIF(CPACK_TYPE STREQUAL Ubuntu20) IF(CPACK_TYPE STREQUAL Ubuntu22) - SET(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6 (>= 2.35), libssl3 (>= 3.0.2), libpcre3 (>= 8.39)") + SET(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6 (>= 2.35), libssl3 (>= 3.0.2), libpcre2-8-0 (>= 10.39)") INCLUDE(${CMAKE_HOME_DIRECTORY}/cmake/debian/debian.cmake) ENDIF(CPACK_TYPE STREQUAL Ubuntu22) IF(CPACK_TYPE STREQUAL Ubuntu24) - SET(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6 (>= 2.35), libssl3 (>= 3.0.2), libpcre3 (>= 8.39)") + SET(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6 (>= 2.35), libssl3 (>= 3.0.2), libpcre2-8-0 (>= 10.42)") INCLUDE(${CMAKE_HOME_DIRECTORY}/cmake/debian/debian.cmake) ENDIF(CPACK_TYPE STREQUAL Ubuntu24) @@ -94,7 +74,7 @@ IF(CPACK_TYPE STREQUAL Centos7) SET(CPACK_RPM_PACKAGE_LICENSE "GPL") SET(CPACK_RPM_PACKAGE_URL "http://accel-ppp.org") SET(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "/usr/sbin") - SET(CPACK_RPM_PACKAGE_REQUIRES "glibc >= 2.17, openssl-libs >= 1.0.2k, pcre >= 8.32") + SET(CPACK_RPM_PACKAGE_REQUIRES "glibc >= 2.17, openssl-libs >= 1.0.2k, pcre2 >= 10.23") INCLUDE(${CMAKE_HOME_DIRECTORY}/cmake/centos/centos.cmake) ENDIF() @@ -102,7 +82,7 @@ IF(CPACK_TYPE STREQUAL Centos8) SET(CPACK_RPM_PACKAGE_LICENSE "GPL") SET(CPACK_RPM_PACKAGE_URL "http://accel-ppp.org") SET(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "/usr/sbin") - SET(CPACK_RPM_PACKAGE_REQUIRES "glibc >= 2.28, openssl-libs >= 1.1.1, pcre >= 8.42") + SET(CPACK_RPM_PACKAGE_REQUIRES "glibc >= 2.28, openssl-libs >= 1.1.1, pcre2 >= 10.32") INCLUDE(${CMAKE_HOME_DIRECTORY}/cmake/centos/centos.cmake) ENDIF() @@ -110,7 +90,7 @@ IF(CPACK_TYPE STREQUAL Centos9) SET(CPACK_RPM_PACKAGE_LICENSE "GPL") SET(CPACK_RPM_PACKAGE_URL "http://accel-ppp.org") SET(CPACK_RPM_EXCLUDE_FROM_AUTO_FILELIST_ADDITION "/usr/sbin") - SET(CPACK_RPM_PACKAGE_REQUIRES "glibc >= 2.34, openssl-libs >= 3.0.1, pcre >= 8.44") + SET(CPACK_RPM_PACKAGE_REQUIRES "glibc >= 2.34, openssl-libs >= 3.0.1, pcre2 >= 10.40") INCLUDE(${CMAKE_HOME_DIRECTORY}/cmake/centos/centos.cmake) ENDIF() From 6ee1a8a95f05e92939cff0704bda125e503ff43f Mon Sep 17 00:00:00 2001 From: "Sergey V. Lobanov" Date: Sat, 31 Aug 2024 20:11:40 +0000 Subject: [PATCH 13/15] pcre2 ci2 --- .github/workflows/build-and-run.yml | 6 +++--- .github/workflows/run-tests.yml | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build-and-run.yml b/.github/workflows/build-and-run.yml index a40ff4ea..1d073dfd 100644 --- a/.github/workflows/build-and-run.yml +++ b/.github/workflows/build-and-run.yml @@ -34,7 +34,7 @@ jobs: sudo apt update && NEEDRESTART_SUSPEND=1 DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true sudo -E apt -y install git build-essential cmake gcc linux-headers-`uname -r` - libpcre3-dev libpcre2-dev libssl-dev liblua5.1-0-dev kmod + libpcre2-dev libssl-dev liblua5.1-0-dev kmod - name: Check out repository code uses: actions/checkout@v3 with: @@ -118,7 +118,7 @@ jobs: apt update && apt -y upgrade && apt -y dist-upgrade && NEEDRESTART_SUSPEND=1 DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true apt -y install git build-essential cmake gcc linux-headers-${{ env.HEADERS_SUFFIX }} - libpcre3-dev libpcre2-dev libssl-dev liblua5.1-0-dev kmod + libpcre2-dev libssl-dev liblua5.1-0-dev kmod - name: Get kernel name from headers run: > echo KERNEL_NAME=`ls -1 /usr/src/ | grep 'linux-headers.*${{ env.HEADERS_SUFFIX }}' | @@ -177,7 +177,7 @@ jobs: run: > apt update && apt -y upgrade && apt -y dist-upgrade && DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true apt -y install git build-essential cmake gcc - linux-headers-generic libpcre3-dev libpcre2-dev libssl-dev liblua5.1-0-dev kmod software-properties-common + linux-headers-generic libpcre2-dev libssl-dev liblua5.1-0-dev kmod software-properties-common pkexec dbus linux-base && add-apt-repository -y ppa:cappelikan/ppa && apt update && service dbus start && diff --git a/.github/workflows/run-tests.yml b/.github/workflows/run-tests.yml index 704de526..2d23b419 100644 --- a/.github/workflows/run-tests.yml +++ b/.github/workflows/run-tests.yml @@ -117,7 +117,7 @@ jobs: run: > ssh -i ssh-key -p2222 user@localhost "sudo apt -y install git build-essential cmake gcc linux-headers-\`uname -r\` - libpcre3-dev libpcre2-dev libssl-dev liblua5.1-0-dev kmod python3-pip + libpcre2-dev libssl-dev liblua5.1-0-dev kmod python3-pip libxml2-dev libxslt1-dev zlib1g-dev iproute2 ppp pppoe isc-dhcp-client timelimit && (sudo pip3 install pytest pytest-dependency pytest-order || sudo pip3 install --break-system-packages pytest pytest-dependency pytest-order)" @@ -195,7 +195,7 @@ jobs: sudo apt update && NEEDRESTART_SUSPEND=1 DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true sudo -E apt -y install git build-essential cmake gcc linux-headers-`uname -r` - libpcre3-dev libpcre2-dev libssl-dev liblua5.1-0-dev kmod python3-pip + libpcre2-dev libssl-dev liblua5.1-0-dev kmod python3-pip iproute2 ppp pppoe isc-dhcp-client - name: Install testing tools (using pip) @@ -248,7 +248,7 @@ jobs: sudo apt update && NEEDRESTART_SUSPEND=1 DEBIAN_FRONTEND=noninteractive DEBCONF_NONINTERACTIVE_SEEN=true sudo -E apt -y install git build-essential cmake gcc linux-headers-`uname -r` - libpcre3-dev libpcre2-dev libssl-dev liblua5.1-0-dev kmod python3-pip + libpcre2-dev libssl-dev liblua5.1-0-dev kmod python3-pip iproute2 ppp pppoe isc-dhcp-client - name: Install testing tools (using pip) From c65363b3d673d17188ba232965a275e2d3e4d597 Mon Sep 17 00:00:00 2001 From: "Sergey V. Lobanov" Date: Sat, 31 Aug 2024 20:41:17 +0000 Subject: [PATCH 14/15] pcre2 remove pcre.h --- accel-pppd/cli/cli.h | 1 - 1 file changed, 1 deletion(-) diff --git a/accel-pppd/cli/cli.h b/accel-pppd/cli/cli.h index c0851eb7..3d8069b3 100644 --- a/accel-pppd/cli/cli.h +++ b/accel-pppd/cli/cli.h @@ -1,7 +1,6 @@ #ifndef __CLI_H #define __CLI_H -#include #define PCRE2_CODE_UNIT_WIDTH 8 #include From 652c9199722879b008e7494df546f97e1da24258 Mon Sep 17 00:00:00 2001 From: "Sergey V. Lobanov" Date: Sat, 31 Aug 2024 20:48:54 +0000 Subject: [PATCH 15/15] ci remove libpcre3 --- .github/workflows/build-and-run.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-and-run.yml b/.github/workflows/build-and-run.yml index 1d073dfd..99db25f1 100644 --- a/.github/workflows/build-and-run.yml +++ b/.github/workflows/build-and-run.yml @@ -222,7 +222,7 @@ jobs: steps: - name: Install build tools run: > - apk update && apk add --no-cache git cmake make g++ pcre-dev pcre2-dev libressl-dev linux-headers libucontext-dev lua5.1-dev + apk update && apk add --no-cache git cmake make g++ pcre2-dev libressl-dev linux-headers libucontext-dev lua5.1-dev - name: Check out repository code uses: actions/checkout@v3 with: @@ -259,7 +259,7 @@ jobs: - name: Install build tools run: | emerge -g --autounmask-write sys-kernel/gentoo-kernel-bin || (etc-update --verbose --automode -5 && emerge -g sys-kernel/gentoo-kernel-bin) - emerge -g dev-vcs/git dev-libs/libpcre dev-libs/libpcre2 dev-build/cmake dev-lang/lua:5.1 + emerge -g dev-vcs/git dev-libs/libpcre2 dev-build/cmake dev-lang/lua:5.1 - name: Check out repository code uses: actions/checkout@v4 with: