aboutsummaryrefslogtreecommitdiffstats
path: root/community/tpm2-tss/0001-configure-Check-system-with-busybox.patch
blob: 4099c2ff0184aa0c45e98c97a88f9b486bf1d2e5 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
From 7fde604383c62fc764a1e060dff48fc06f79860b Mon Sep 17 00:00:00 2001
From: Juergen Repp <juergen.repp@sit.fraunhofer.de>
Date: Wed, 1 Dec 2021 12:54:03 +0100
Subject: [PATCH] configure: Check system with busybox.

Busybox does not support useradd and groupadd. If useradd and groupadd are
not available adduser and addgroup will be used during FAPI installation.

Signed-off-by: Juergen Repp <juergen.repp@sit.fraunhofer.de>
---
 Makefile.am  | 17 +++++++++++++++--
 configure.ac | 16 +++++++++-------
 2 files changed, 24 insertions(+), 9 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index 521dcee9..049be206 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -636,8 +636,21 @@ define make_parent_dir
 endef
 
 define make_tss_user_and_group
-    (id -g tss 2>/dev/null || groupadd -r tss) && \
-    (id -u tss 2>/dev/null || useradd -r -g tss tss)
+    if type -p groupadd > /dev/null; then \
+        id -g tss 2>/dev/null || groupadd --system tss; \
+    else \
+        id -g tss 2>/dev/null || \
+        addgroup --system tss; \
+    fi && \
+    if type -p useradd > /dev/null; then \
+        id -u tss 2>/dev/null || \
+        useradd --system --home-dir / --shell `type -p nologin` \
+                         --no-create-home -g tss tss; \
+    else \
+        id -u tss 2>/dev/null || \
+        adduser --system --home / --shell `type -p nologin` \
+                --no-create-home --ingroup tss tss; \
+    fi
 endef
 
 define make_tss_dir
diff --git a/configure.ac b/configure.ac
index 1b7ce126..5a8c5f74 100644
--- a/configure.ac
+++ b/configure.ac
@@ -487,15 +487,17 @@ AC_CHECK_PROG(systemd_sysusers, systemd-sysusers, yes)
 AM_CONDITIONAL(SYSD_SYSUSERS, test "x$systemd_sysusers" = "xyes")
 AC_CHECK_PROG(systemd_tmpfiles, systemd-tmpfiles, yes)
 AM_CONDITIONAL(SYSD_TMPFILES, test "x$systemd_tmpfiles" = "xyes")
+
 # Check all tools used by make install
 AS_IF([test "$HOSTOS" = "Linux"],
-      [ERROR_IF_NO_PROG([groupadd])
-       ERROR_IF_NO_PROG([useradd])
-       ERROR_IF_NO_PROG([id])
-       ERROR_IF_NO_PROG([chown])
-       ERROR_IF_NO_PROG([chmod])
-       ERROR_IF_NO_PROG([mkdir])
-       ERROR_IF_NO_PROG([setfacl])])
+    [ AC_CHECK_PROG(useradd, useradd, yes)
+      AC_CHECK_PROG(groupadd, groupadd, yes)
+      AC_CHECK_PROG(adduser, adduser, yes)
+      AC_CHECK_PROG(addgroup, addgroup, yes)
+      AS_IF([test "x$addgroup" != "xyes" && test "x$groupadd" != "xyes" ],
+         [AC_MSG_ERROR([addgroup or groupadd are needed.])])
+      AS_IF([test "x$adduser" != "xyes" && test "x$useradd" != "xyes" ],
+         [AC_MSG_ERROR([adduser or useradd are needed.])])])
 
 AC_SUBST([PATH])
 
-- 
2.34.1