Skip to content

Commit 6d01fc1

Browse files
devopsecroot
authored andcommitted
Fix Libjwt / Libstirshaken Builds
- fix build for debian-based systems - pin libjwt to 2.1.1
1 parent 59a7452 commit 6d01fc1

7 files changed

Lines changed: 373 additions & 40 deletions

File tree

kamailio/debian/10.sh

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -181,8 +181,9 @@ EOF
181181
# setup STIR/SHAKEN module for kamailio
182182
## compile and install libjwt (version in repos is too old)
183183
if [[ ! -d ${SRC_DIR}/libjwt ]]; then
184-
git clone --depth 1 -c advice.detachedHead=false https://github.com/benmcollins/libjwt.git ${SRC_DIR}/libjwt
184+
git clone --depth 1 -c advice.detachedHead=false -b v2.1.1 https://github.com/devopsec/libjwt.git ${SRC_DIR}/libjwt
185185
fi
186+
186187
(
187188
cd ${SRC_DIR}/libjwt &&
188189
autoreconf -i &&
@@ -213,9 +214,10 @@ EOF
213214
git clone --depth 1 -c advice.detachedHead=false https://github.com/signalwire/libstirshaken ${SRC_DIR}/libstirshaken
214215
fi
215216
(
217+
# TODO: commit updates to upstream to fix EVP_PKEY_cmp being deprecated
216218
cd ${SRC_DIR}/libstirshaken &&
217219
./bootstrap.sh &&
218-
./configure --prefix=/usr &&
220+
./configure --prefix=/usr CFLAGS='-Wno-deprecated-declarations' LDFLAGS='-L/usr/lib' &&
219221
make -j $NPROC &&
220222
make -j $NPROC install &&
221223
ldconfig

kamailio/debian/11.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ EOF
158158
# setup STIR/SHAKEN module for kamailio
159159
## compile and install libjwt (version in repos is too old)
160160
if [[ ! -d ${SRC_DIR}/libjwt ]]; then
161-
git clone --depth 1 -c advice.detachedHead=false https://github.com/benmcollins/libjwt.git ${SRC_DIR}/libjwt
161+
git clone --depth 1 -c advice.detachedHead=false -b v2.1.1 https://github.com/devopsec/libjwt.git ${SRC_DIR}/libjwt
162162
fi
163163
(
164164
cd ${SRC_DIR}/libjwt &&
@@ -190,9 +190,10 @@ EOF
190190
git clone --depth 1 -c advice.detachedHead=false https://github.com/signalwire/libstirshaken ${SRC_DIR}/libstirshaken
191191
fi
192192
(
193+
# TODO: commit updates to upstream to fix EVP_PKEY_cmp being deprecated
193194
cd ${SRC_DIR}/libstirshaken &&
194195
./bootstrap.sh &&
195-
./configure --prefix=/usr &&
196+
./configure --prefix=/usr CFLAGS='-Wno-deprecated-declarations' LDFLAGS='-L/usr/lib' &&
196197
make -j $NPROC &&
197198
make -j $NPROC install &&
198199
ldconfig

kamailio/debian/12.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ EOF
166166
# setup STIR/SHAKEN module for kamailio
167167
## compile and install libjwt (version in repos is too old)
168168
if [[ ! -d ${SRC_DIR}/libjwt ]]; then
169-
git clone --depth 1 -c advice.detachedHead=false https://github.com/benmcollins/libjwt.git ${SRC_DIR}/libjwt
169+
git clone --depth 1 -c advice.detachedHead=false -b v2.1.1 https://github.com/devopsec/libjwt.git ${SRC_DIR}/libjwt
170170
fi
171171
(
172172
cd ${SRC_DIR}/libjwt &&
@@ -201,8 +201,8 @@ EOF
201201
# TODO: commit updates to upstream to fix EVP_PKEY_cmp being deprecated
202202
cd ${SRC_DIR}/libstirshaken &&
203203
./bootstrap.sh &&
204-
./configure --prefix=/usr &&
205-
make -j $NPROC CFLAGS='-Wno-deprecated-declarations' &&
204+
./configure --prefix=/usr CFLAGS='-Wno-deprecated-declarations' LDFLAGS='-L/usr/lib' &&
205+
make -j $NPROC &&
206206
make -j $NPROC install &&
207207
ldconfig
208208
) || {

kamailio/debian/9.sh

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,10 +177,19 @@ EOF
177177
# setup STIR/SHAKEN module for kamailio
178178
## compile and install libjwt
179179
if [[ ! -d ${SRC_DIR}/libjwt ]]; then
180-
git clone --depth 1 -c advice.detachedHead=false https://github.com/benmcollins/libjwt.git ${SRC_DIR}/libjwt
180+
git clone --depth 1 -c advice.detachedHead=false -b v2.1.1 https://github.com/devopsec/libjwt.git ${SRC_DIR}/libjwt
181181
fi
182-
( cd ${SRC_DIR}/libjwt && autoreconf -i && ./configure --prefix=/usr && make && make install; exit $?; ) ||
183-
{ printerr 'Failed to compile and install libjwt'; return 1; }
182+
183+
(
184+
cd ${SRC_DIR}/libjwt &&
185+
autoreconf -i &&
186+
./configure --prefix=/usr &&
187+
make -j $NPROC &&
188+
make -j $NPROC install
189+
) || {
190+
printerr 'Failed to compile and install libjwt'
191+
return 1
192+
}
184193

185194
## compile and install libks
186195
if [[ ! -d ${SRC_DIR}/libks ]]; then

kamailio/ubuntu/20.sh

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ fi
1111
function install() {
1212
local KAM_SOURCES_LIST="/etc/apt/sources.list.d/kamailio.list"
1313
local KAM_PREFS_CONF="/etc/apt/preferences.d/kamailio.pref"
14+
local NPROC=$(nproc)
1415

1516
# nf_tables is the default fw on ubuntu but it has too many bugs at this time
1617
# instead we will use legacy iptables until these issues are ironed out
@@ -176,10 +177,19 @@ EOF
176177
# setup STIR/SHAKEN module for kamailio
177178
## compile and install libjwt
178179
if [[ ! -d ${SRC_DIR}/libjwt ]]; then
179-
git clone --depth 1 -c advice.detachedHead=false https://github.com/benmcollins/libjwt.git ${SRC_DIR}/libjwt
180+
git clone --depth 1 -c advice.detachedHead=false -b v2.1.1 https://github.com/devopsec/libjwt.git ${SRC_DIR}/libjwt
180181
fi
181-
( cd ${SRC_DIR}/libjwt && autoreconf -i && ./configure --prefix=/usr && make && make install; exit $?; ) ||
182-
{ printerr 'Failed to compile and install libjwt'; return 1; }
182+
183+
(
184+
cd ${SRC_DIR}/libjwt &&
185+
autoreconf -i &&
186+
./configure --prefix=/usr &&
187+
make -j $NPROC &&
188+
make -j $NPROC install
189+
) || {
190+
printerr 'Failed to compile and install libjwt'
191+
return 1
192+
}
183193

184194
## compile and install libks
185195
if [[ ! -d ${SRC_DIR}/libks ]]; then

kamailio/ubuntu/22.sh

Lines changed: 37 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ fi
1111
function install() {
1212
local KAM_SOURCES_LIST="/etc/apt/sources.list.d/kamailio.list"
1313
local KAM_PREFS_CONF="/etc/apt/preferences.d/kamailio.pref"
14+
local NPROC=$(nproc)
1415

1516
# nf_tables is the default fw on ubuntu but it has too many bugs at this time
1617
# instead we will use legacy iptables until these issues are ironed out
@@ -21,6 +22,30 @@ function install() {
2122
apt-get install -y curl wget sed gawk vim perl uuid-dev libssl-dev logrotate rsyslog \
2223
libcurl4-openssl-dev libjansson-dev cmake firewalld python3 python3-venv
2324

25+
if (( $? != 0 )); then
26+
printerr 'Failed installing required packages'
27+
exit 1
28+
fi
29+
30+
## compile and install openssl v1.1.1 (workaround for amazon linux repo conflicts)
31+
## we must overwrite system packages (openssl/openssl-devel) otherwise python's openssl package is not supported
32+
if [[ "$(openssl version 2>/dev/null | awk '{print $2}')" != "1.1.1w" ]]; then
33+
if [[ ! -d ${SRC_DIR}/openssl ]]; then
34+
( cd ${SRC_DIR} &&
35+
curl -sL https://www.openssl.org/source/openssl-1.1.1w.tar.gz 2>/dev/null |
36+
tar -xzf - --transform 's%openssl-1.1.1w%openssl%'; )
37+
fi
38+
(
39+
cd ${SRC_DIR}/openssl &&
40+
./Configure --prefix=/usr linux-$(uname -m) &&
41+
make -j $NPROC &&
42+
make -j $NPROC install
43+
) || {
44+
printerr 'Failed to compile openssl'
45+
return 1
46+
}
47+
fi
48+
2449
# we need a newer version of certbot than the distro repos offer
2550
apt-get remove -y *certbot*
2651
python3 -m venv /opt/certbot/
@@ -37,26 +62,25 @@ function install() {
3762
chown -R kamailio:kamailio /var/run/kamailio
3863

3964
# add repo sources to apt
40-
# TODO: note that kamailio has only published a DEB for bookworm (debian upstream), not jammmy (ubuntu downstream)
4165
mkdir -p /etc/apt/sources.list.d
4266
(cat << EOF
4367
# kamailio repo's
44-
deb http://deb.kamailio.org/kamailio${KAM_VERSION} bookworm main
45-
#deb-src http://deb.kamailio.org/kamailio${KAM_VERSION} bookworm main
68+
deb https://deb-archive.kamailio.org/repos/kamailio-${KAM_VERSION} jammy main
69+
#deb-src https://deb-archive.kamailio.org/repos/kamailio-${KAM_VERSION} jammy main
4670
EOF
4771
) > ${KAM_SOURCES_LIST}
4872

4973
# give higher precedence to packages from kamailio repo
5074
mkdir -p /etc/apt/preferences.d
5175
(cat << 'EOF'
5276
Package: *
53-
Pin: origin deb.kamailio.org
77+
Pin: origin deb-archive.kamailio.org
5478
Pin-Priority: 1000
5579
EOF
5680
) > ${KAM_PREFS_CONF}
5781

5882
# Add Key for Kamailio Repo
59-
wget -O- http://deb.kamailio.org/kamailiodebkey.gpg | apt-key add -
83+
wget -O- https://deb-archive.kamailio.org/kamailiodebkey.gpg | apt-key add -
6084

6185
# Update repo sources cache
6286
apt-get update -y
@@ -66,7 +90,6 @@ EOF
6690
kamailio-websocket-modules kamailio-presence-modules kamailio-json-modules kamailio-sctp-modules
6791

6892
# get info about the kamailio install for later use in script
69-
KAM_VERSION_FULL=$(kamailio -v 2>/dev/null | grep '^version:' | awk '{print $3}')
7093
KAM_MODULES_DIR=$(find /usr/lib{32,64,}/{i386*/*,i386*/kamailio/*,x86_64*/*,x86_64*/kamailio/*,*} -name drouting.so -printf '%h' -quit 2>/dev/null)
7194

7295
# create kamailio defaults config
@@ -96,28 +119,14 @@ DBRWPW="${KAM_DB_PASS}"
96119
DBROOTUSER="${ROOT_DB_USER}"
97120
${ROOTPW_SETTING}
98121
CHARSET=utf8
122+
EXTRA_MODULES="imc cpl siptrace domainpolicy carrierroute drouting userblocklist htable purple uac pipelimit mtree sca mohqueue rtpproxy rtpengine secfilter"
99123
INSTALL_EXTRA_TABLES=yes
100124
INSTALL_PRESENCE_TABLES=yes
101125
INSTALL_DBUID_TABLES=yes
102126
#STORE_PLAINTEXT_PW=0
103127
EOF
104128
) > ${SYSTEM_KAMAILIO_CONFIG_DIR}/kamctlrc
105129

106-
# fix bug in kamilio v5.3.4 installer
107-
if [[ "$KAM_VERSION_FULL" == "5.3.4" ]]; then
108-
(cat << 'EOF'
109-
CREATE TABLE `secfilter` (
110-
`id` INT(10) UNSIGNED AUTO_INCREMENT PRIMARY KEY NOT NULL,
111-
`action` SMALLINT DEFAULT 0 NOT NULL,
112-
`type` SMALLINT DEFAULT 0 NOT NULL,
113-
`data` VARCHAR(64) DEFAULT "" NOT NULL
114-
);
115-
CREATE INDEX secfilter_idx ON secfilter (`action`, `type`, `data`);
116-
INSERT INTO version (table_name, table_version) values ("secfilter","1");
117-
EOF
118-
) > /usr/share/kamailio/mysql/secfilter-create.sql
119-
fi
120-
121130
# Execute 'kamdbctl create' to create the Kamailio database schema
122131
kamdbctl create
123132

@@ -166,8 +175,9 @@ EOF
166175
# setup STIR/SHAKEN module for kamailio
167176
## compile and install libjwt (version in repos is too old)
168177
if [[ ! -d ${SRC_DIR}/libjwt ]]; then
169-
git clone --depth 1 -c advice.detachedHead=false https://github.com/benmcollins/libjwt.git ${SRC_DIR}/libjwt
178+
git clone --depth 1 -c advice.detachedHead=false -b v2.1.1 https://github.com/devopsec/libjwt.git ${SRC_DIR}/libjwt
170179
fi
180+
171181
(
172182
cd ${SRC_DIR}/libjwt &&
173183
autoreconf -i &&
@@ -201,8 +211,8 @@ EOF
201211
# TODO: commit updates to upstream to fix EVP_PKEY_cmp being deprecated
202212
cd ${SRC_DIR}/libstirshaken &&
203213
./bootstrap.sh &&
204-
./configure --prefix=/usr &&
205-
make -j $NPROC CFLAGS='-Wno-deprecated-declarations' &&
214+
./configure --prefix=/usr CFLAGS='-Wno-deprecated-declarations' LDFLAGS='-L/usr/lib' &&
215+
make -j $NPROC &&
206216
make -j $NPROC install &&
207217
ldconfig
208218
) || {
@@ -213,12 +223,12 @@ EOF
213223
## compile and install STIR/SHAKEN module
214224
## reuse repo if it exists and matches version we want to install
215225
if [[ -d ${SRC_DIR}/kamailio ]]; then
216-
if [[ "$(getGitTagFromShallowRepo ${SRC_DIR}/kamailio)" != "${KAM_VERSION_FULL}" ]]; then
226+
if [[ "$(getGitTagFromShallowRepo ${SRC_DIR}/kamailio)" != "${KAM_VERSION}" ]]; then
217227
rm -rf ${SRC_DIR}/kamailio
218-
git clone --depth 1 -c advice.detachedHead=false -b ${KAM_VERSION_FULL} https://github.com/kamailio/kamailio.git ${SRC_DIR}/kamailio
228+
git clone --depth 1 -c advice.detachedHead=false -b ${KAM_VERSION} https://github.com/kamailio/kamailio.git ${SRC_DIR}/kamailio
219229
fi
220230
else
221-
git clone --depth 1 -c advice.detachedHead=false -b ${KAM_VERSION_FULL} https://github.com/kamailio/kamailio.git ${SRC_DIR}/kamailio
231+
git clone --depth 1 -c advice.detachedHead=false -b ${KAM_VERSION} https://github.com/kamailio/kamailio.git ${SRC_DIR}/kamailio
222232
fi
223233
(
224234
cd ${SRC_DIR}/kamailio/src/modules/stirshaken &&

0 commit comments

Comments
 (0)