Skip to content

Commit f080baa

Browse files
committed
adding swtpm
1 parent fb67943 commit f080baa

15 files changed

+257
-2
lines changed

build/meta/extra-build-tools.p5m

+1
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ depend fmri=ooce/library/libogg type=require
5151
depend fmri=ooce/library/libpng type=require
5252
depend fmri=ooce/library/libsodium type=require
5353
depend fmri=ooce/library/libtasn1 type=require
54+
depend fmri=ooce/library/libtpms type=require
5455
depend fmri=ooce/library/liburcu type=require
5556
depend fmri=ooce/library/libuv type=require
5657
depend fmri=ooce/library/libvncserver type=require

build/swtpm/build.sh

+100
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
#!/usr/bin/bash
2+
#
3+
# {{{ CDDL HEADER
4+
#
5+
# This file and its contents are supplied under the terms of the
6+
# Common Development and Distribution License ("CDDL"), version 1.0.
7+
# You may only use this file in accordance with the terms of version
8+
# 1.0 of the CDDL.
9+
#
10+
# A full copy of the text of the CDDL should have accompanied this
11+
# source. A copy of the CDDL is also available via the Internet at
12+
# http://www.illumos.org/license/CDDL.
13+
# }}}
14+
15+
# Copyright 2024 OmniOS Community Edition (OmniOSce) Association.
16+
17+
. ../../lib/build.sh
18+
19+
PROG=swtpm
20+
VER=0.10.0
21+
PKG=ooce/security/swtpm
22+
SUMMARY="SWTPM - Software TPM Emulator"
23+
DESC="TPM emulators with different front-end interfaces to libtpms"
24+
25+
JSONGLIBVER=1.9.2
26+
27+
OPREFIX=$PREFIX
28+
PREFIX+="/$PROG"
29+
30+
set_arch 64
31+
set_clangver
32+
set_standard XPG6
33+
34+
XFORM_ARGS="
35+
-DPREFIX=${PREFIX#/}
36+
-DOPREFIX=${OPREFIX#/}
37+
-DPROG=$PROG
38+
-DPKGROOT=$PROG
39+
"
40+
41+
init
42+
prep_build
43+
44+
#########################################################################
45+
# Download and build static versions of dependencies
46+
47+
pre_configure() {
48+
typeset arch=$1
49+
50+
! cross_arch $arch && return
51+
52+
CONFIGURE_CMD+=" --cross-file $SRCDIR/files/aarch64-gcc.txt"
53+
}
54+
55+
save_buildenv
56+
57+
CONFIGURE_OPTS="-Ddefault_library=static"
58+
CONFIGURE_OPTS[aarch64]="
59+
--prefix=$PREFIX
60+
--libdir=$PREFIX/${LIBDIRS[aarch64]}
61+
"
62+
63+
build_dependency -meson json-glib json-glib-$JSONGLIBVER \
64+
$PROG/json-glib json-glib $JSONGLIBVER
65+
66+
restore_buildenv
67+
68+
#########################################################################
69+
70+
note -n "-- Building $PROG"
71+
72+
CONFIGURE_OPTS="
73+
--localstatedir=/var$PREFIX
74+
--disable-static
75+
--with-tss-user=root
76+
--with-tss-group=root
77+
"
78+
79+
pre_configure() {
80+
typeset arch=$1
81+
82+
subsume_arch $arch PKG_CONFIG_PATH
83+
addpath PKG_CONFIG_PATH $DEPROOT$PREFIX/${LIBDIRS[$arch]}/pkgconfig
84+
85+
CPPFLAGS+=" -DHAVE_SYS_IOCCOM_H -I$DEPROOT$PREFIX/include/json-glib-1.0"
86+
LDFLAGS[$arch]+=" -L$DEPROOT$PREFIX/${LIBDIRS[$arch]} -lsocket"
87+
LDFLAGS[$arch]+=" -Wl,-R$OPREFIX/${LIBDIRS[$arch]}"
88+
LDFLAGS[$arch]+=" -Wl,-R$PREFIX/${LIBDIRS[$arch]}/$PROG"
89+
90+
run_autoreconf -fi
91+
}
92+
93+
download_source $PROG v$VER
94+
patch_source
95+
build
96+
make_package
97+
clean_up
98+
99+
# Vim hints
100+
# vim:ts=4:sw=4:et:fdm=marker

build/swtpm/files/aarch64-gcc.txt

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[binaries]
2+
c = '/opt/cross/aarch64/bin/aarch64-unknown-solaris2.11-gcc'
3+
cpp = '/opt/cross/aarch64/bin/aarch64-unknown-solaris2.11-g++'
4+
ar = '/opt/cross/aarch64/bin/aarch64-unknown-solaris2.11-ar'
5+
pkgconfig = 'pkg-config'
6+
7+
[host_machine]
8+
system = 'sunos'
9+
cpu_family = 'aarch64'
10+
cpu = 'aarch64'
11+
endian = 'little'
12+

build/swtpm/files/ctf.ignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
seccomp_profile.c

build/swtpm/local.mog

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#
2+
# This file and its contents are supplied under the terms of the
3+
# Common Development and Distribution License ("CDDL"), version 1.0.
4+
# You may only use this file in accordance with the terms of version
5+
# 1.0 of the CDDL.
6+
#
7+
# A full copy of the text of the CDDL should have accompanied this
8+
# source. A copy of the CDDL is also available via the Internet at
9+
# http://www.illumos.org/license/CDDL.
10+
11+
# Copyright 2024 OmniOS Community Edition (OmniOSce) Association.
12+
13+
license LICENSE license=modified-BSD
14+
15+
<include binlink.mog>
16+
<include manlink.mog>
17+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
fixing: error: a label can only be part of a statement and a declaration is not a statement
2+
3+
diff -wpruN --no-dereference '--exclude=*.orig' a~/json-glib/json-scanner.c a/json-glib/json-scanner.c
4+
--- a~/json-glib/json-scanner.c 1970-01-01 00:00:00
5+
+++ a/json-glib/json-scanner.c 1970-01-01 00:00:00
6+
@@ -779,6 +779,7 @@ json_scanner_get_token_ll (JsonScanner
7+
GString *gstring = NULL;
8+
JsonTokenValue value;
9+
guchar ch;
10+
+ guint fchar;
11+
12+
config = &scanner->config;
13+
(*value_p).v_int64 = 0;
14+
@@ -889,7 +890,7 @@ json_scanner_get_token_ll (JsonScanner
15+
break;
16+
17+
case 'u':
18+
- guint fchar = json_scanner_peek_next_char (scanner);
19+
+ fchar = json_scanner_peek_next_char (scanner);
20+
if (is_hex_digit (fchar))
21+
{
22+
gunichar ucs;

build/swtpm/patches-json-glib/series

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
label-statement.patch

build/swtpm/patches/illumos.patch

+66
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
diff -wpruN --no-dereference '--exclude=*.orig' a~/include/sys_dependencies.h a/include/sys_dependencies.h
2+
--- a~/include/sys_dependencies.h 1970-01-01 00:00:00
3+
+++ a/include/sys_dependencies.h 1970-01-01 00:00:00
4+
@@ -39,7 +39,7 @@
5+
#define SWTPM_SYS_DEPENDENCIES_H
6+
7+
#if !defined __OpenBSD__ && !defined __FreeBSD__ && !defined __NetBSD__ \
8+
- && !defined __APPLE__ && !defined __DragonFly__
9+
+ && !defined __APPLE__ && !defined __DragonFly__ && !defined __illumos__
10+
#define _GNU_SOURCE
11+
#include <features.h>
12+
#endif
13+
diff -wpruN --no-dereference '--exclude=*.orig' a~/src/swtpm/check_algos.c a/src/swtpm/check_algos.c
14+
--- a~/src/swtpm/check_algos.c 1970-01-01 00:00:00
15+
+++ a/src/swtpm/check_algos.c 1970-01-01 00:00:00
16+
@@ -42,6 +42,10 @@
17+
#include <stdio.h>
18+
#include <string.h>
19+
20+
+#ifdef __illumos__
21+
+# include <strings.h>
22+
+#endif
23+
+
24+
#include "check_algos.h"
25+
#include "utils.h"
26+
#include "swtpm_utils.h"
27+
diff -wpruN --no-dereference '--exclude=*.orig' a~/src/swtpm/common.c a/src/swtpm/common.c
28+
--- a~/src/swtpm/common.c 1970-01-01 00:00:00
29+
+++ a/src/swtpm/common.c 1970-01-01 00:00:00
30+
@@ -56,6 +56,10 @@
31+
# include <seccomp.h>
32+
#endif
33+
34+
+#ifdef __illumos__
35+
+# include <strings.h>
36+
+#endif
37+
+
38+
#include <libtpms/tpm_error.h>
39+
40+
#include "common.h"
41+
diff -wpruN --no-dereference '--exclude=*.orig' a~/src/swtpm_ioctl/tpm_ioctl.c a/src/swtpm_ioctl/tpm_ioctl.c
42+
--- a~/src/swtpm_ioctl/tpm_ioctl.c 1970-01-01 00:00:00
43+
+++ a/src/swtpm_ioctl/tpm_ioctl.c 1970-01-01 00:00:00
44+
@@ -90,6 +90,11 @@
45+
# define _IOC_NRMASK 255
46+
#endif
47+
48+
+/* for illumos */
49+
+#ifndef MIN
50+
+# define MIN(a, b) ((a) < (b) ? (a) : (b))
51+
+#endif
52+
+
53+
/* poll timeout that takes into account a busy swtpm creating a key */
54+
#define DEFAULT_POLL_TIMEOUT 10000 /* ms */
55+
56+
diff -wpruN --no-dereference '--exclude=*.orig' a~/tests/sed-inplace a/tests/sed-inplace
57+
--- a~/tests/sed-inplace 1970-01-01 00:00:00
58+
+++ a/tests/sed-inplace 1970-01-01 00:00:00
59+
@@ -1,6 +1,6 @@
60+
#!/usr/bin/env bash
61+
62+
-if [[ "$(uname -s)" =~ (Linux|CYGWIN_NT-) ]]; then
63+
+if [[ "$(uname -s)" =~ (Linux|CYGWIN_NT-|SunOS) ]]; then
64+
sed -i "$1" "$2"
65+
else
66+
sed -i '' "$1" "$2"

build/swtpm/patches/series

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
illumos.patch
2+
utsname.patch

build/swtpm/patches/utsname.patch

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
fixing:
2+
3+
swtpm_setup_utils.c:96:20: error: declaration shadows a variable in the global scope [-Werror,-Wshadow]
4+
96 | struct utsname utsname;
5+
| ^
6+
/usr/include/sys/utsname.h:61:23: note: previous declaration is here
7+
61 | extern struct utsname utsname;
8+
| ^
9+
10+
diff -wpruN --no-dereference '--exclude=*.orig' a~/src/swtpm_setup/swtpm_setup_utils.c a/src/swtpm_setup/swtpm_setup_utils.c
11+
--- a~/src/swtpm_setup/swtpm_setup_utils.c 1970-01-01 00:00:00
12+
+++ a/src/swtpm_setup/swtpm_setup_utils.c 1970-01-01 00:00:00
13+
@@ -23,6 +23,8 @@
14+
#include "swtpm_utils.h"
15+
#include "swtpm_setup_utils.h"
16+
17+
+struct utsname utsname;
18+
+
19+
/* Get a configuration value given its name */
20+
gchar *get_config_value(gchar *const *config_file_lines, const gchar *configname)
21+
{
22+
@@ -93,7 +95,6 @@ int create_config_files(gboolean overwri
23+
gboolean delete_files = FALSE;
24+
g_auto(GStrv) configfiles = NULL;
25+
g_auto(GStrv) filedata = NULL;
26+
- struct utsname utsname;
27+
int ret = 1;
28+
size_t i;
29+

build/virtualbox/build.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -199,8 +199,8 @@ make_install() {
199199
bindir=out/solaris.amd64/$BUILD_TYPE
200200

201201
# Fix the runtime path for these components to include the ooce lib
202-
# in order that libpng can be found.
203-
for f in VBoxSVC components/VBoxC.so; do
202+
# in order that libpng and libtpms can be found.
203+
for f in VBoxSVC VBoxDD.so components/VBoxC.so; do
204204
logcmd elfedit -e "dyn:value -s RUNPATH $rpath" $DESTDIR$PREFIX/amd64/$f
205205
logcmd elfedit -e "dyn:value -s RPATH $rpath" $DESTDIR$PREFIX/amd64/$f
206206
done

doc/baseline

+1
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,7 @@ extra.omnios ooce/security/gnupg
248248
extra.omnios ooce/security/minisign
249249
extra.omnios ooce/security/oath-toolkit
250250
extra.omnios ooce/security/pam_radius
251+
extra.omnios ooce/security/swtpm
251252
extra.omnios ooce/server/apache-24
252253
extra.omnios ooce/server/apache-24/modules/fcgid
253254
extra.omnios ooce/server/apache-24/modules/subversion

doc/baseline.aarch64

+1
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ extra.omnios ooce/security/gnupg
8686
extra.omnios ooce/security/minisign
8787
extra.omnios ooce/security/oath-toolkit
8888
extra.omnios ooce/security/pam_radius
89+
extra.omnios ooce/security/swtpm
8990
extra.omnios ooce/system/htop
9091
extra.omnios ooce/system/mbuffer
9192
extra.omnios ooce/system/top

doc/packages.md

+1
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@
204204
| ooce/security/minisign | 0.11 | https://github.com/jedisct1/minisign/releases | [omniosorg](https://github.com/omniosorg)
205205
| ooce/security/oath-toolkit | 2.6.12 | https://download.savannah.nongnu.org/releases/oath-toolkit/ | [omniosorg](https://github.com/omniosorg)
206206
| ooce/security/pam_radius | 3.0.0 | https://github.com/FreeRADIUS/pam_radius/tags | [omniosorg](https://github.com/omniosorg)
207+
| ooce/security/swtpm | 0.10.0 | https://github.com/stefanberger/swtpm/releases | [omniosorg](https://github.com/omniosorg)
207208
| ooce/server/apache-24 | 2.4.62 | https://downloads.apache.org/httpd/ | [omniosorg](https://github.com/omniosorg)
208209
| ooce/server/apache-24/modules/fcgid | 2.3.9 | https://downloads.apache.org/httpd/mod_fcgid/ | [omniosorg](https://github.com/omniosorg)
209210
| ooce/server/apache-24/modules/wsgi | 5.0.0 | https://github.com/GrahamDumpleton/mod_wsgi/tags/ | [cgrzemba](https://github.com/cgrzemba)

doc/pkglist.aarch64

+1
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@ ooce/library/pango
116116
ooce/network/znc
117117
ooce/library/libvncserver
118118
ooce/network/smtp/postfix
119+
ooce/security/swtpm
119120
###############################################################################
120121
.SYSROOT
121122
ooce/multimedia/minidlna

0 commit comments

Comments
 (0)