Skip to content

Commit 5c7c2d0

Browse files
committed
[linux] fix packages to work with podman/docker properly.
also don't run container test if the podman/docker were not found. Signed-off-by: Vitalii Koshura <[email protected]>
1 parent 5f3e2ee commit 5c7c2d0

File tree

5 files changed

+69
-23
lines changed

5 files changed

+69
-23
lines changed

.github/workflows/linux-package.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This file is part of BOINC.
2-
# http://boinc.berkeley.edu
3-
# Copyright (C) 2024 University of California
2+
# https://boinc.berkeley.edu
3+
# Copyright (C) 2025 University of California
44
#
55
# BOINC is free software; you can redistribute it and/or modify it
66
# under the terms of the GNU Lesser General Public License
@@ -396,12 +396,18 @@ jobs:
396396
fi
397397
done
398398
}
399+
if [ -x /bin/systemctl ] ; then
400+
if systemctl is-active --quiet boinc-client.service; then
401+
systemctl stop boinc-client.service
402+
fi
403+
fi
399404
if ! getent group ${BOINCGROUP} >/dev/null; then
400405
groupadd -r ${BOINCGROUP}
401406
fi
402407
if ! getent passwd ${BOINCUSER} >/dev/null; then
403408
useradd -r -g ${BOINCGROUP} -d ${BOINCDIR} -s /usr/sbin/nologin -c \"BOINC user\" ${BOINCUSER}
404409
fi
410+
usermod -d ${BOINCDIR} ${BOINCUSER}
405411
if ! getent group ${BOINCGROUP} | grep -q ${BOINCUSER}; then
406412
usermod -a -G ${BOINCGROUP} ${BOINCUSER}
407413
fi
@@ -425,6 +431,7 @@ jobs:
425431
usermod -a -G ${BOINCGROUP} \"\$SUDO_USER\"
426432
fi
427433
fi
434+
usermod --add-subuids 100000-165535 --add-subgids 100000-165535 ${BOINCUSER}
428435
if [ ! -d /etc/boinc-client ] ; then
429436
mkdir -p /etc/boinc-client
430437
fi

client/hostinfo_unix.cpp

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// This file is part of BOINC.
22
// https://boinc.berkeley.edu
3-
// Copyright (C) 2024 University of California
3+
// Copyright (C) 2025 University of California
44
//
55
// BOINC is free software; you can redistribute it and/or modify it
66
// under the terms of the GNU Lesser General Public License
@@ -1268,24 +1268,26 @@ bool HOST_INFO::get_docker_version_aux(DOCKER_TYPE type){
12681268
//
12691269
// Since we do this every time on startup, don't delete the image.
12701270
//
1271-
cmd = string(docker_cli_prog(type)) + " run hello-world 2>/dev/null";
1272-
bool found = false;
1273-
f = popen(cmd.c_str(), "r");
1274-
if (f) {
1275-
while (fgets(buf, 256, f)) {
1276-
if (strstr(buf, "Hello")) {
1277-
found = true;
1278-
break;
1271+
if (ret) {
1272+
cmd = string(docker_cli_prog(type)) + " run hello-world 2>/dev/null";
1273+
bool found = false;
1274+
f = popen(cmd.c_str(), "r");
1275+
if (f) {
1276+
while (fgets(buf, 256, f)) {
1277+
if (strstr(buf, "Hello")) {
1278+
found = true;
1279+
break;
1280+
}
12791281
}
1282+
pclose(f);
1283+
}
1284+
if (!found) {
1285+
msg_printf(NULL, MSG_INFO,
1286+
"%s found but 'hello-world' test failed",
1287+
docker_type_str(type)
1288+
);
1289+
docker_version[0] = 0;
12801290
}
1281-
pclose(f);
1282-
}
1283-
if (!found) {
1284-
msg_printf(NULL, MSG_INFO,
1285-
"%s found but 'hello-world' test failed",
1286-
docker_type_str(type)
1287-
);
1288-
docker_version[0] = 0;
12891291
}
12901292
#endif
12911293
return ret;

client/scripts/boinc-client.service.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Type=simple
99
ProtectHome=true
1010
ProtectSystem=strict
1111
ProtectControlGroups=true
12-
ReadWritePaths=-/var/lib/boinc -/etc/boinc-client -/tmp
12+
ReadWritePaths=-/var/lib/boinc -/etc/boinc-client -/tmp -/var/tmp
1313
Nice=10
1414
User=boinc
1515
WorkingDirectory=/var/lib/boinc

packages/deb/postinst

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# This file is part of BOINC.
44
# https://boinc.berkeley.edu
5-
# Copyright (C) 2024 University of California
5+
# Copyright (C) 2025 University of California
66
#
77
# BOINC is free software; you can redistribute it and/or modify it
88
# under the terms of the GNU Lesser General Public License
@@ -52,13 +52,20 @@ update_nested_dirs() {
5252
done
5353
}
5454

55+
if [ -x /bin/systemctl ] ; then
56+
if systemctl is-active --quiet boinc-client.service; then
57+
systemctl stop boinc-client.service
58+
fi
59+
fi
60+
5561
if ! getent group ${BOINCGROUP} >/dev/null; then
5662
groupadd -r ${BOINCGROUP}
5763
fi
5864

5965
if ! getent passwd ${BOINCUSER} >/dev/null; then
6066
useradd -r -g ${BOINCGROUP} -d ${BOINCDIR} -s /usr/sbin/nologin -c "BOINC user" ${BOINCUSER}
6167
fi
68+
usermod -d "$BOINCDIR" "$BOINCUSER"
6269

6370
if ! getent group ${BOINCGROUP} | grep -q ${BOINCUSER}; then
6471
usermod -a -G ${BOINCGROUP} ${BOINCUSER}
@@ -88,6 +95,8 @@ if [ -n "$SUDO_USER" ]; then
8895
fi
8996
fi
9097

98+
usermod --add-subuids 100000-165535 --add-subgids 100000-165535 ${BOINCUSER}
99+
91100
if [ ! -d /etc/boinc-client ] ; then
92101
mkdir -p /etc/boinc-client
93102
fi

tests/linux_package_integration_tests.py

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This file is part of BOINC.
22
# https://boinc.berkeley.edu
3-
# Copyright (C) 2024 University of California
3+
# Copyright (C) 2025 University of California
44
#
55
# BOINC is free software; you can redistribute it and/or modify it
66
# under the terms of the GNU Lesser General Public License
@@ -50,6 +50,31 @@ def _get_group_exists(self, groupname):
5050
def _get_user_in_group(self, username, groupname):
5151
return os.popen("id -Gn {username}".format(username=username)).read().strip().find(groupname) != -1
5252

53+
def _get_user_home_directory(self, username):
54+
return os.popen("getent passwd {username}".format(username=username)).read().strip().split(":")[5]
55+
56+
def _get_uid_range(self, username):
57+
result = os.popen("cat /etc/subuid | grep {username}".format(username=username)).read().strip()
58+
if (result == ""):
59+
return ""
60+
result = result.split(":")
61+
if (len(result) != 3):
62+
return ""
63+
start = int(result[1])
64+
count = int(result[2])
65+
return "{start}:{count}".format(start=start, count=count)
66+
67+
def _get_gid_range(self, groupname):
68+
result = os.popen("cat /etc/subgid | grep {groupname}".format(groupname=groupname)).read().strip()
69+
if (result == ""):
70+
return ""
71+
result = result.split(":")
72+
if (len(result) != 3):
73+
return ""
74+
start = int(result[1])
75+
count = int(result[2])
76+
return "{start}:{count}".format(start=start, count=count)
77+
5378
def _get_key_value_pairs_from_file(self, filename):
5479
result = {}
5580
with open(filename, "r") as f:
@@ -143,13 +168,16 @@ def test_user(self):
143168
ts.expect_true(self._get_user_in_group("boinc", "video"), "Test 'boinc' user is in 'video' group")
144169
if (self._get_group_exists("render")):
145170
ts.expect_true(self._get_user_in_group("boinc", "render"), "Test 'boinc' user is in 'render' group")
171+
ts.expect_equal("/var/lib/boinc", self._get_user_home_directory("boinc"), "Test 'boinc' user home directory is '/var/lib/boinc'")
172+
ts.expect_equal("100000:65536", self._get_uid_range("boinc"), "Test 'boinc' user UID range is '100000:65536'")
173+
ts.expect_equal("100000:65536", self._get_gid_range("boinc"), "Test 'boinc' group GID range is '100000:65536'")
146174
return ts.result()
147175

148176
def test_selected_values_from_boinc_client_service_file(self):
149177
ts = testset.TestSet("Test selected values from the '/usr/lib/systemd/system/boinc-client.service' file")
150178
data = self._get_key_value_pairs_from_file("/usr/lib/systemd/system/boinc-client.service")
151179
ts.expect_equal(data["ProtectSystem"], "strict", "Test 'ProtectSystem' is correctly set")
152-
ts.expect_equal(data["ReadWritePaths"], "-/var/lib/boinc -/etc/boinc-client -/tmp", "Test 'ReadWritePaths' is correctly set")
180+
ts.expect_equal(data["ReadWritePaths"], "-/var/lib/boinc -/etc/boinc-client -/tmp -/var/tmp", "Test 'ReadWritePaths' is correctly set")
153181
ts.expect_equal(data["User"], "boinc", "Test 'User' is correctly set")
154182
ts.expect_equal(data["WorkingDirectory"], "/var/lib/boinc", "Test 'WorkingDirectory' is correctly set")
155183
ts.expect_equal(data["ExecStart"], "/usr/local/bin/boinc", "Test 'ExecStart' is correctly set")

0 commit comments

Comments
 (0)