Skip to content

Commit d0d34f4

Browse files
lneelyLevi Neely
andauthored
Resolve #394: Replace Boost.Program_options with CLI11 (#396)
* Replace Boost.Program_options with CLI11 to resolve version pinning (#394) - Replace boost::program_options with header-only CLI11 in main.cpp - Remove boost dependency from Makefile, default.nix, and flake.nix - Update documentation in doc/BUILD.md - Add CMakeLists.txt as an alternative build system This fixes the issue where the binary would fail to find specific libboost_program_options.so versions (e.g., 1.90.0) on systems with newer/older Boost versions. Since CLI11 is header-only, there is no longer a runtime dependency on Boost for pcloudcc. * Update build configuration and dev scripts to remove remaining Boost references - Remove Boost from dev scripts and container build configs - Add -std=c++11 to Makefile CXXFLAGS - Explicitly add -I. to Makefile CFLAGS for CLI11.hpp include * Address build review feedback and fix security/bug issues - Fix passascrypto logic and type (now a flag) in main.cpp - Fix typo in daemon process name - Add secret wiping (putil_wipe) for tfa_code and singleton passwords - Remove redundant App setup in control_tools.cpp - Use CLI11 envname for PCLOUD_USER - Fix C++11 compatibility for putil_wipe and App initialization in control_tools.cpp * Remove phantom CMakeLists.txt and ensure Makefile is the source of truth --------- Co-authored-by: Levi Neely <lkn@darkstar.example.net>
1 parent 89cd7b1 commit d0d34f4

11 files changed

Lines changed: 82 additions & 90 deletions

Makefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@ else
3131
endif
3232

3333
COMMONFLAGS = -fsanitize=address
34-
CFLAGS = -fPIC $(COMMONFLAGS) -I./pclsync -I/usr/include $(FUSE_CFLAGS) $(shell pkg-config --cflags $$(pkg-config --list-all | grep -o 'mbedtls[0-9.]*\s' | head -1) 2>/dev/null || pkg-config --cflags mbedtls 2>/dev/null || echo "-I/usr/local/include")
34+
CFLAGS = -fPIC $(COMMONFLAGS) -I. -I./pclsync -I/usr/include $(FUSE_CFLAGS) $(shell pkg-config --cflags $$(pkg-config --list-all | grep -o 'mbedtls[0-9.]*\s' | head -1) 2>/dev/null || pkg-config --cflags mbedtls 2>/dev/null || echo "-I/usr/local/include")
3535
ifneq (,$(filter clang%,$(CC)))
3636
CFLAGS += -Wthread-safety
3737
endif
38-
CXXFLAGS = $(CFLAGS)
38+
CXXFLAGS = $(CFLAGS) -std=c++11
3939
LIBLDFLAGS = $(COMMONFLAGS) -lreadline -lpthread -ludev -lsqlite3 -lz $(shell \
4040
MBEDTLS_PKG=$$(pkg-config --list-all 2>/dev/null | grep -o 'mbedtls[0-9.]*\s' | head -1 | tr -d ' '); \
4141
if [ -n "$$MBEDTLS_PKG" ]; then \
@@ -45,7 +45,7 @@ LIBLDFLAGS = $(COMMONFLAGS) -lreadline -lpthread -ludev -lsqlite3 -lz $(shell \
4545
else \
4646
pkg-config --libs mbedtls mbedx509 mbedcrypto 2>/dev/null || echo "-L/usr/local/lib -lmbedtls -lmbedx509 -lmbedcrypto"; \
4747
fi)
48-
EXECLDFLAGS = $(COMMONFLAGS) -lboost_program_options $(FUSE_LIBS)
48+
EXECLDFLAGS = $(COMMONFLAGS) $(FUSE_LIBS)
4949

5050
SCAN := 0
5151
SRCDIR := .

control_tools.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,9 @@ void setup_app(CLI::App *app) {
198198
size_t errm_size = 0;
199199
RpcClient *rpc = new RpcClient();
200200
int result = rpc->Call(SENDAUTH, auth_pass_input.c_str(), &errm, &errm_size);
201-
putil_wipe(auth_pass_input.data(), auth_pass_input.size());
201+
if (!auth_pass_input.empty()) {
202+
putil_wipe(&auth_pass_input[0], auth_pass_input.size());
203+
}
202204
auth_pass_input.clear();
203205
if (result != 0) {
204206
std::cerr << "Failed to send auth: " << (errm ? errm : "no message") << std::endl;
@@ -221,7 +223,9 @@ void setup_app(CLI::App *app) {
221223
size_t errm_size = 0;
222224
RpcClient *rpc = new RpcClient();
223225
int result = rpc->Call(SENDAUTHSAVE, authsave_pass_input.c_str(), &errm, &errm_size);
224-
putil_wipe(authsave_pass_input.data(), authsave_pass_input.size());
226+
if (!authsave_pass_input.empty()) {
227+
putil_wipe(&authsave_pass_input[0], authsave_pass_input.size());
228+
}
225229
authsave_pass_input.clear();
226230
if (result != 0) {
227231
std::cerr << "Failed to send auth: " << (errm ? errm : "no message") << std::endl;
@@ -440,7 +444,7 @@ void setup_app(CLI::App *app) {
440444
}
441445

442446
int process_command(const std::string &command) {
443-
CLI::App app = CLI::App{"pcloudcc-lneely"};
447+
CLI::App app{"pcloudcc-lneely"};
444448
setup_app(&app);
445449
try {
446450
app.parse(command);
@@ -480,9 +484,6 @@ int process_command(const std::string &command) {
480484
}
481485

482486
void process_commands() {
483-
CLI::App app = CLI::App{"pcloudcc-lneely"};
484-
setup_app(&app);
485-
486487
using_history();
487488
rl_attempted_completion_function = command_completion;
488489

default.nix

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ pkgs.mkShell {
55
buildInputs = with pkgs; [
66
zlib
77
sqlite
8-
boost
98
libudev-zero
109
readline
1110
fuse
@@ -15,15 +14,13 @@ pkgs.mkShell {
1514
CFLAGS = [
1615
"-I${pkgs.zlib.dev}/include"
1716
"-I${pkgs.sqlite.dev}/include"
18-
"-I${pkgs.boost.dev}/include"
1917
"-I${pkgs.readline.dev}/include"
2018
"-I${pkgs.fuse.dev}/include"
2119
"-I${pkgs.mbedtls}/include"
2220
];
2321
CXXFLAGS = [
2422
"-I${pkgs.zlib.dev}/include"
2523
"-I${pkgs.sqlite.dev}/include"
26-
"-I${pkgs.boost.dev}/include"
2724
"-I${pkgs.readline.dev}/include"
2825
"-I${pkgs.fuse.dev}/include"
2926
"-I${pkgs.mbedtls}/include"

dev/container-build.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,26 +93,26 @@ case $IMAGE in
9393
echo "Setting up Debian/Ubuntu-based container..."
9494
ctrid=$(buildah from "$FULL_IMAGE")
9595
buildah run "$ctrid" -- apt update
96-
buildah run "$ctrid" -- apt install -y build-essential git libfuse-dev libudev-dev libsqlite3-dev libmbedtls-dev zlib1g-dev libboost-system-dev libboost-program-options-dev fuse llvm gdb
96+
buildah run "$ctrid" -- apt install -y build-essential git libfuse-dev libudev-dev libsqlite3-dev libmbedtls-dev zlib1g-dev fuse llvm gdb
9797
;;
9898
fedora)
9999
echo "Setting up Fedora-based container..."
100100
ctrid=$(buildah from "$FULL_IMAGE")
101101
buildah run "$ctrid" -- dnf update -y
102102
buildah run "$ctrid" -- dnf group install -y "C Development Tools and Libraries"
103-
buildah run "$ctrid" -- dnf install -y git fuse-devel systemd-devel sqlite-devel mbedtls-devel zlib-devel boost-devel boost-program-options fuse llvm gdb fuse udev libasan
103+
buildah run "$ctrid" -- dnf install -y git fuse-devel systemd-devel sqlite-devel mbedtls-devel zlib-devel fuse llvm gdb fuse udev libasan
104104
;;
105105
archlinux|arch)
106106
echo "Setting up Arch Linux-based container..."
107107
ctrid=$(buildah from "$FULL_IMAGE")
108108
buildah run "$ctrid" -- pacman -Syu --noconfirm
109-
buildah run "$ctrid" -- pacman -S --noconfirm base-devel git fuse2 systemd sqlite mbedtls2 zlib boost boost-libs llvm gdb udev gcc make
109+
buildah run "$ctrid" -- pacman -S --noconfirm base-devel git fuse2 systemd sqlite mbedtls2 zlib llvm gdb udev gcc make
110110
;;
111111
opensuse/tumbleweed|opensuse/leap)
112112
echo "Setting up openSUSE-based container..."
113113
ctrid=$(buildah from "$FULL_IMAGE")
114114
buildah run "$ctrid" -- zypper refresh
115-
buildah run "$ctrid" -- zypper install -y gcc gcc-c++ make git fuse-devel systemd-devel sqlite3-devel zlib-devel libboost_system-devel libboost_program_options-devel fuse llvm gdb udev mbedtls-2-devel
115+
buildah run "$ctrid" -- zypper install -y gcc gcc-c++ make git fuse-devel systemd-devel sqlite3-devel zlib-devel fuse llvm gdb udev mbedtls-2-devel
116116
;;
117117
*)
118118
echo "Unsupported image: $IMAGE"

dev/devhost-arch-arm64.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ build_container() {
103103
sudo vim nano curl wget git htop tmux man-db \
104104
bash-completion ca-certificates openssh \
105105
base-devel gcc gcc-libs make fuse2 systemd sqlite3 \
106-
mbedtls zlib boost llvm gdb iproute \
106+
mbedtls zlib llvm gdb iproute \
107107
rsync readline
108108

109109
# verify fuse

dev/devhost-arch.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ build_container() {
103103
sudo vim nano curl wget git htop tmux man-db \
104104
bash-completion ca-certificates openssh \
105105
base-devel gcc gcc-libs make fuse2 systemd sqlite3 \
106-
mbedtls zlib boost llvm gdb iproute \
106+
mbedtls zlib llvm gdb iproute \
107107
rsync readline
108108

109109
# verify fuse

dev/devhost-debian.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,7 @@ build_container() {
106106
sudo vim nano curl wget git htop tmux man-db locales \
107107
bash-completion ca-certificates ssh systemd systemd-sysv \
108108
build-essential libfuse-dev libudev-dev libsqlite3-dev \
109-
libmbedtls-dev zlib1g-dev libboost-system-dev \
110-
libboost-program-options-dev fuse llvm gdb iproute2 \
109+
libmbedtls-dev zlib1g-dev fuse llvm gdb iproute2 \
111110
openssh-server rsync libreadline-dev
112111

113112
# verify fuse

dev/devhost-fedora.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ build_container() {
103103
sudo vim nano curl wget git htop tmux man-db \
104104
bash-completion ca-certificates openssh-server \
105105
gcc gcc-c++ make fuse-devel systemd-devel sqlite-devel \
106-
mbedtls-devel zlib-devel boost-devel fuse llvm gdb iproute \
106+
mbedtls-devel zlib-devel fuse llvm gdb iproute \
107107
rsync readline-devel
108108

109109
# verify fuse

doc/BUILD.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Dependencies
22
- zlib (-lz)
3-
- boost (-lboost_system, -lboost_program_options)
3+
- CLI11 (included as CLI11.hpp)
44
- pthread (lpthread)
55
- udev (-ludev)
66
- fuse (-lfuse)

flake.nix

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
clang-tools
1717
zlib
1818
sqlite
19-
boost
2019
libudev-zero
2120
readline
2221
fuse
@@ -27,7 +26,6 @@
2726
CFLAGS = [
2827
"-I${pkgs.zlib.dev}/include"
2928
"-I${pkgs.sqlite.dev}/include"
30-
"-I${pkgs.boost.dev}/include"
3129
"-I${pkgs.readline.dev}/include"
3230
"-I${pkgs.fuse.dev}/include"
3331
"-I${pkgs.mbedtls}/include"
@@ -36,7 +34,6 @@
3634
CXXFLAGS = [
3735
"-I${pkgs.zlib.dev}/include"
3836
"-I${pkgs.sqlite.dev}/include"
39-
"-I${pkgs.boost.dev}/include"
4037
"-I${pkgs.readline.dev}/include"
4138
"-I${pkgs.fuse.dev}/include"
4239
"-I${pkgs.mbedtls}/include"

0 commit comments

Comments
 (0)