Skip to content

Commit 46ba8d4

Browse files
committed
mod_uuid: Move uuid.c out of core into separate module.
Move uuid out of the core and into a separate module. This library was only used for one function in the core, which was only used by one caller in net_nntp. Support for this library is not universal (e.g. lacking on BSD), so moving this out of the core allows the core to build successfully on more platforms.
1 parent 684c113 commit 46ba8d4

File tree

10 files changed

+96
-37
lines changed

10 files changed

+96
-37
lines changed

.github/workflows/main.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,6 @@ jobs:
252252
- name: Run basic tests
253253
run: |
254254
tests/test -ttest_menus -ddddddddd -DDDDDDDDDD -x
255-
# Binary fails to link due to uuid library missing in CI, but it will make all specified targets, so enumerate those
256255
freebsd-14:
257256
runs-on: ubuntu-24.04
258257
name: FreeBSD
@@ -266,7 +265,7 @@ jobs:
266265
./scripts/install_prereq.sh
267266
gmake modcheck
268267
gmake modconfig
269-
gmake main
268+
gmake bbs
270269
gmake doors
271270
gmake io
272271
gmake modules

bbs/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ INC = -I..
1111
LIBS = -lrt -lm -ldl
1212

1313
# -lcrypto needed for SHA1_Init in hash.c
14-
LIBS += -lcrypt -lcrypto -luuid -rdynamic
14+
LIBS += -lcrypt -lcrypto -rdynamic
1515

1616
# -lbfd and friends
1717
# On SUSE, the remaining libraries are needed to link successfully

bbs/utils.c

Lines changed: 0 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
#include <limits.h> /* use PATH_MAX */
3535

3636
#ifdef __linux__
37-
#include <uuid/uuid.h> /* use uuid_generate, uuid_unparse */
3837
#include <syscall.h>
3938
#endif
4039

@@ -44,25 +43,6 @@
4443
#include "include/base64.h"
4544
#include "include/system.h"
4645

47-
char *bbs_uuid(void)
48-
{
49-
#ifdef UUID_STR_LEN
50-
char *uuid;
51-
uuid_t binary_uuid;
52-
53-
uuid_generate_random(binary_uuid);
54-
uuid = malloc(UUID_STR_LEN + 1);
55-
if (ALLOC_FAILURE(uuid)) {
56-
return NULL;
57-
}
58-
uuid_unparse_lower(binary_uuid, uuid);
59-
return uuid;
60-
#else
61-
bbs_error("uuid not supported on this platform\n");
62-
return NULL;
63-
#endif
64-
}
65-
6646
void dyn_str_reset(struct dyn_str *dynstr)
6747
{
6848
free_if(dynstr->buf);

configs/modules.conf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ load = mod_node_callbacks.so
4444
load = mod_history.so ; A dependency of mod_sysop, for keeping track of command history.
4545
load = mod_sysop.so ; You probably don't want to forget this one if autoload=no. require will force the module to load or abort startup on failure.
4646
load = mod_curl.so ; cURL support
47+
load = mod_uuid.so ; UUID support
4748
load = mod_version.so
4849
load = mod_ip_blocker.so
4950

include/mod_uuid.h

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
/*
2+
* LBBS -- The Lightweight Bulletin Board System
3+
*
4+
* Copyright (C) 2025, Naveen Albert
5+
*
6+
* Naveen Albert <bbs@phreaknet.org>
7+
*
8+
*/
9+
10+
/*! \file
11+
*
12+
* \brief UUID support
13+
*
14+
* \author Naveen Albert <bbs@phreaknet.org>
15+
*/
16+
17+
/*!
18+
* \brief Generate a UUID (universally unique identifier), all lowercase
19+
* \return UUID on success, NULL on failure
20+
*/
21+
char *bbs_uuid(void);

include/utils.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,6 @@ struct sockaddr_in;
3333
struct bbs_user;
3434
struct dirent;
3535

36-
/*!
37-
* \brief Generate a UUID (universally unique identifier), all lowercase
38-
* \return UUID on success, NULL on failure
39-
*/
40-
char *bbs_uuid(void);
41-
4236
/*! \note This really should be opaque, but it's declared here so that callers can stack allocate it */
4337
struct dyn_str {
4438
char *buf;

modules/Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,10 @@ mod_systemd.so : mod_systemd.o
137137
@echo " [LD] $^ -> $@"
138138
$(CC) -shared -fPIC -o $(basename $^).so $^ -lsystemd
139139

140+
mod_uuid.so : mod_uuid.o
141+
@echo " [LD] $^ -> $@"
142+
$(CC) -shared -fPIC -o $(basename $^).so $^ -luuid
143+
140144
mod_webmail.so : mod_webmail.o
141145
@echo " [LD] $^ -> $@"
142146
$(CC) -shared -fPIC -o $(basename $^).so $^ $(MOD_WEBMAIL_LIBS) -L/usr/local/lib -Wl,-rpath=/usr/local/lib/ -letpan

modules/mod_uuid.c

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*
2+
* LBBS -- The Lightweight Bulletin Board System
3+
*
4+
* Copyright (C) 2025, Naveen Albert
5+
*
6+
* Naveen Albert <bbs@phreaknet.org>
7+
*
8+
* This program is free software, distributed under the terms of
9+
* the GNU General Public License Version 2. See the LICENSE file
10+
* at the top of the source tree.
11+
*/
12+
13+
/*! \file
14+
*
15+
* \brief UUID support
16+
*
17+
* \author Naveen Albert <bbs@phreaknet.org>
18+
*/
19+
20+
#include "include/bbs.h"
21+
22+
#ifdef __linux__
23+
#include <uuid/uuid.h> /* use uuid_generate, uuid_unparse */
24+
#endif
25+
26+
#include "include/module.h"
27+
28+
#include "include/mod_uuid.h"
29+
30+
char *bbs_uuid(void)
31+
{
32+
#ifdef UUID_STR_LEN
33+
char *uuid;
34+
uuid_t binary_uuid;
35+
36+
uuid_generate_random(binary_uuid);
37+
uuid = malloc(UUID_STR_LEN + 1);
38+
if (ALLOC_FAILURE(uuid)) {
39+
return NULL;
40+
}
41+
uuid_unparse_lower(binary_uuid, uuid);
42+
return uuid;
43+
#else
44+
bbs_error("uuid not supported on this platform\n");
45+
return NULL;
46+
#endif
47+
}
48+
49+
static int unload_module(void)
50+
{
51+
return 0;
52+
}
53+
54+
static int load_module(void)
55+
{
56+
return 0;
57+
}
58+
59+
BBS_MODULE_INFO_FLAGS("UUID Support", MODFLAG_GLOBAL_SYMBOLS);

nets/net_nntp.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
#include "include/user.h"
4040

4141
#include "include/mod_mail.h"
42+
#include "include/mod_uuid.h"
4243

4344
/* NNTP ports */
4445
/* Reading server */
@@ -1398,4 +1399,4 @@ static int unload_module(void)
13981399
return 0;
13991400
}
14001401

1401-
BBS_MODULE_INFO_STANDARD("RFC3977 NNTP/NNSP");
1402+
BBS_MODULE_INFO_DEPENDENT("RFC3977 NNTP/NNSP", "mod_uuid.so");

scripts/install_prereq.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,6 @@ PACKAGES_SUSE="$PACKAGES_SUSE libcap-devel"
4646
PACKAGES_ARCH="$PACKAGES_ARCH libcap"
4747
PACKAGES_ALPINE="$PACKAGES_ALPINE libcap-dev"
4848

49-
# <uuid/uuid.h>
50-
PACKAGES_DEBIAN="$PACKAGES_DEBIAN libuuid1 uuid-dev"
51-
PACKAGES_FEDORA="$PACKAGES_FEDORA libuuid-devel"
52-
PACKAGES_SUSE="$PACKAGES_SUSE libuuid-devel"
53-
PACKAGES_ARCH="$PACKAGES_ARCH util-linux-libs"
54-
PACKAGES_ALPINE="$PACKAGES_ALPINE util-linux-dev"
55-
5649
# sz, rz programs for ZMODEM transfers
5750
PACKAGES_DEBIAN="$PACKAGES_DEBIAN lrzsz"
5851
PACKAGES_FEDORA="$PACKAGES_FEDORA lrzsz"
@@ -88,6 +81,13 @@ PACKAGES_ARCH="$PACKAGES_ARCH systemd-libs"
8881
# Alpine Linux doesn't use systemd, so no need for that here!
8982
# No systemd on FreeBSD, or other Unices
9083

84+
# <uuid/uuid.h> (mod_uuid)
85+
PACKAGES_DEBIAN="$PACKAGES_DEBIAN libuuid1 uuid-dev"
86+
PACKAGES_FEDORA="$PACKAGES_FEDORA libuuid-devel"
87+
PACKAGES_SUSE="$PACKAGES_SUSE libuuid-devel"
88+
PACKAGES_ARCH="$PACKAGES_ARCH util-linux-libs"
89+
PACKAGES_ALPINE="$PACKAGES_ALPINE util-linux-dev"
90+
9191
# libssh (net_ssh)
9292
PACKAGES_DEBIAN="$PACKAGES_DEBIAN libssh-dev"
9393
# net_ssh, which requires objdump to test for symbol existence... thanks a lot, libssh

0 commit comments

Comments
 (0)