Skip to content

Commit 74208cd

Browse files
committed
Merge remote-tracking branch 'remotes/berrange-gitlab/tags/misc-fixes-pull-request' into staging
* Replace --enable/disable-git-update with --with-git-submodules to allow improved control over use of git submodules * Deprecate the -enable-fips option * Ensure docs use prefer format for bool options * Clarify platform support rules * Misc fixes to keymap conversions * Fix misc problems on macOS # gpg: Signature made Fri 29 Jan 2021 17:10:13 GMT # gpg: using RSA key DAF3A6FDB26B62912D0E8E3FBE86EBB415104FDF # gpg: Good signature from "Daniel P. Berrange <[email protected]>" [full] # gpg: aka "Daniel P. Berrange <[email protected]>" [full] # Primary key fingerprint: DAF3 A6FD B26B 6291 2D0E 8E3F BE86 EBB4 1510 4FDF * remotes/berrange-gitlab/tags/misc-fixes-pull-request: tests: Replace deprecated ASN1 code tests: Fix runtime error in test-authz-pam ui: update keycodemapdb submodule commit crypto: Add spaces around operator configure: replace --enable/disable-git-update with --with-git-submodules docs: fix missing backslash in certtool shell example docs: simplify and clarify the platform support rules Prefer 'on' | 'off' over 'yes' | 'no' for bool options os: deprecate the -enable-fips option and QEMU's FIPS enforcement crypto: Fix memory leaks in set_loaded for tls-* crypto: Forbid broken unloading of secrets crypto: Move USER_CREATABLE to secret_common base class crypto: Fix some code style problems, add spaces around operator Signed-off-by: Peter Maydell <[email protected]>
2 parents 9df52f5 + ecb98f5 commit 74208cd

25 files changed

+161
-147
lines changed

Makefile

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -47,30 +47,10 @@ git-submodule-update:
4747
Makefile: .git-submodule-status
4848

4949
.PHONY: git-submodule-update
50-
51-
git_module_status := $(shell \
52-
cd '$(SRC_PATH)' && \
53-
GIT="$(GIT)" ./scripts/git-submodule.sh status $(GIT_SUBMODULES); \
54-
echo $$?; \
55-
)
56-
57-
ifeq (1,$(git_module_status))
58-
ifeq (no,$(GIT_UPDATE))
5950
git-submodule-update:
6051
$(call quiet-command, \
61-
echo && \
62-
echo "GIT submodule checkout is out of date. Please run" && \
63-
echo " scripts/git-submodule.sh update $(GIT_SUBMODULES)" && \
64-
echo "from the source directory checkout $(SRC_PATH)" && \
65-
echo && \
66-
exit 1)
67-
else
68-
git-submodule-update:
69-
$(call quiet-command, \
70-
(cd $(SRC_PATH) && GIT="$(GIT)" ./scripts/git-submodule.sh update $(GIT_SUBMODULES)), \
71-
"GIT","$(GIT_SUBMODULES)")
72-
endif
73-
endif
52+
(GIT="$(GIT)" "$(SRC_PATH)/scripts/git-submodule.sh" $(GIT_SUBMODULES_ACTION) $(GIT_SUBMODULES)), \
53+
"GIT","$(GIT_SUBMODULES)")
7454

7555
# 0. ensure the build tree is okay
7656

configure

Lines changed: 38 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -255,12 +255,12 @@ gdb_bin=$(command -v "gdb-multiarch" || command -v "gdb")
255255

256256
if test -e "$source_path/.git"
257257
then
258-
git_update=yes
258+
git_submodules_action="update"
259259
git_submodules="ui/keycodemapdb"
260260
git_submodules="$git_submodules tests/fp/berkeley-testfloat-3"
261261
git_submodules="$git_submodules tests/fp/berkeley-softfloat-3"
262262
else
263-
git_update=no
263+
git_submodules_action="ignore"
264264
git_submodules=""
265265

266266
if ! test -f "$source_path/ui/keycodemapdb/README"
@@ -1499,9 +1499,16 @@ for opt do
14991499
;;
15001500
--with-git=*) git="$optarg"
15011501
;;
1502-
--enable-git-update) git_update=yes
1502+
--enable-git-update)
1503+
git_submodules_action="update"
1504+
echo "--enable-git-update deprecated, use --with-git-submodules=update"
15031505
;;
1504-
--disable-git-update) git_update=no
1506+
--disable-git-update)
1507+
git_submodules_action="validate"
1508+
echo "--disable-git-update deprecated, use --with-git-submodules=validate"
1509+
;;
1510+
--with-git-submodules=*)
1511+
git_submodules_action="$optarg"
15051512
;;
15061513
--enable-debug-mutex) debug_mutex=yes
15071514
;;
@@ -1557,6 +1564,21 @@ for opt do
15571564
esac
15581565
done
15591566

1567+
case $git_submodules_action in
1568+
update|validate)
1569+
if test ! -e "$source_path/.git"; then
1570+
echo "ERROR: cannot $git_submodules_action git submodules without .git"
1571+
exit 1
1572+
fi
1573+
;;
1574+
ignore)
1575+
;;
1576+
*)
1577+
echo "ERROR: invalid --with-git-submodules= value '$git_submodules_action'"
1578+
exit 1
1579+
;;
1580+
esac
1581+
15601582
libdir="${libdir:-$prefix/lib}"
15611583
libexecdir="${libexecdir:-$prefix/libexec}"
15621584
includedir="${includedir:-$prefix/include}"
@@ -1701,6 +1723,9 @@ Advanced options (experts only):
17011723
--ninja=NINJA use specified ninja [$ninja]
17021724
--smbd=SMBD use specified smbd [$smbd]
17031725
--with-git=GIT use specified git [$git]
1726+
--with-git-submodules=update update git submodules (default if .git dir exists)
1727+
--with-git-submodules=validate fail if git submodules are not up to date
1728+
--with-git-submodules=ignore do not update or check git submodules (default if no .git dir)
17041729
--static enable static build [$static]
17051730
--mandir=PATH install man pages in PATH
17061731
--datadir=PATH install firmware in PATH/$qemu_suffix
@@ -1917,7 +1942,7 @@ python="$python -B"
19171942
if test -z "$meson"; then
19181943
if test "$explicit_python" = no && has meson && version_ge "$(meson --version)" 0.55.3; then
19191944
meson=meson
1920-
elif test -e "${source_path}/.git" && test $git_update = 'yes' ; then
1945+
elif test $git_submodules_action != 'ignore' ; then
19211946
meson=git
19221947
elif test -e "${source_path}/meson/meson.py" ; then
19231948
meson=internal
@@ -1985,7 +2010,7 @@ fi
19852010
# Consult white-list to determine whether to enable werror
19862011
# by default. Only enable by default for git builds
19872012
if test -z "$werror" ; then
1988-
if test -e "$source_path/.git" && \
2013+
if test "$git_submodules_action" != "ignore" && \
19892014
{ test "$linux" = "yes" || test "$mingw32" = "yes"; }; then
19902015
werror="yes"
19912016
else
@@ -3558,7 +3583,7 @@ fi
35583583
case "$fdt" in
35593584
auto | enabled | internal)
35603585
# Simpler to always update submodule, even if not needed.
3561-
if test -e "${source_path}/.git" && test $git_update = 'yes' ; then
3586+
if test "$git_submodules_action" != "ignore"; then
35623587
git_submodules="${git_submodules} dtc"
35633588
fi
35643589
;;
@@ -4272,7 +4297,7 @@ fi
42724297
case "$capstone" in
42734298
auto | enabled | internal)
42744299
# Simpler to always update submodule, even if not needed.
4275-
if test -e "${source_path}/.git" && test $git_update = 'yes' ; then
4300+
if test "$git_submodules_action" != "ignore"; then
42764301
git_submodules="${git_submodules} capstone"
42774302
fi
42784303
;;
@@ -5219,7 +5244,7 @@ fi
52195244
case "$slirp" in
52205245
auto | enabled | internal)
52215246
# Simpler to always update submodule, even if not needed.
5222-
if test -e "${source_path}/.git" && test $git_update = 'yes' ; then
5247+
if test "$git_submodules_action" != "ignore"; then
52235248
git_submodules="${git_submodules} slirp"
52245249
fi
52255250
;;
@@ -5393,7 +5418,7 @@ if test "$cpu" = "s390x" ; then
53935418
roms="$roms s390-ccw"
53945419
# SLOF is required for building the s390-ccw firmware on s390x,
53955420
# since it is using the libnet code from SLOF for network booting.
5396-
if test -e "${source_path}/.git" ; then
5421+
if test "$git_submodules_action" != "ignore"; then
53975422
git_submodules="${git_submodules} roms/SLOF"
53985423
fi
53995424
fi
@@ -5431,8 +5456,8 @@ else
54315456
cxx=
54325457
fi
54335458

5434-
if test $git_update = 'yes' ; then
5435-
(cd "${source_path}" && GIT="$git" "./scripts/git-submodule.sh" update "$git_submodules")
5459+
if !(GIT="$git" "$source_path/scripts/git-submodule.sh" "$git_submodules_action" "$git_submodules"); then
5460+
exit 1
54365461
fi
54375462

54385463
config_host_mak="config-host.mak"
@@ -5443,7 +5468,7 @@ echo >> $config_host_mak
54435468
echo all: >> $config_host_mak
54445469
echo "GIT=$git" >> $config_host_mak
54455470
echo "GIT_SUBMODULES=$git_submodules" >> $config_host_mak
5446-
echo "GIT_UPDATE=$git_update" >> $config_host_mak
5471+
echo "GIT_SUBMODULES_ACTION=$git_submodules_action" >> $config_host_mak
54475472

54485473
echo "ARCH=$ARCH" >> $config_host_mak
54495474

crypto/aes.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1080,9 +1080,9 @@ int AES_set_encrypt_key(const unsigned char *userKey, const int bits,
10801080

10811081
rk = key->rd_key;
10821082

1083-
if (bits==128)
1083+
if (bits == 128)
10841084
key->rounds = 10;
1085-
else if (bits==192)
1085+
else if (bits == 192)
10861086
key->rounds = 12;
10871087
else
10881088
key->rounds = 14;
@@ -1182,7 +1182,7 @@ int AES_set_decrypt_key(const unsigned char *userKey, const int bits,
11821182
rk = key->rd_key;
11831183

11841184
/* invert the order of the round keys: */
1185-
for (i = 0, j = 4*(key->rounds); i < j; i += 4, j -= 4) {
1185+
for (i = 0, j = 4 * (key->rounds); i < j; i += 4, j -= 4) {
11861186
temp = rk[i ]; rk[i ] = rk[j ]; rk[j ] = temp;
11871187
temp = rk[i + 1]; rk[i + 1] = rk[j + 1]; rk[j + 1] = temp;
11881188
temp = rk[i + 2]; rk[i + 2] = rk[j + 2]; rk[j + 2] = temp;

crypto/desrfb.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ static const unsigned char pc1[56] = {
5656
13, 5, 60, 52, 44, 36, 28, 20, 12, 4, 27, 19, 11, 3 };
5757

5858
static const unsigned char totrot[16] = {
59-
1,2,4,6,8,10,12,14,15,17,19,21,23,25,27,28 };
59+
1, 2, 4, 6, 8, 10, 12, 14, 15, 17, 19, 21, 23, 25, 27, 28 };
6060

6161
static const unsigned char pc2[48] = {
6262
13, 16, 10, 23, 0, 4, 2, 27, 14, 5, 20, 9,
@@ -93,7 +93,7 @@ void deskey(unsigned char *key, int edf)
9393
}
9494
for( j = 0; j < 24; j++ ) {
9595
if( pcr[pc2[j]] ) kn[m] |= bigbyte[j];
96-
if( pcr[pc2[j+24]] ) kn[n] |= bigbyte[j];
96+
if( pcr[pc2[j + 24]] ) kn[n] |= bigbyte[j];
9797
}
9898
}
9999
cookey(kn);

crypto/secret.c

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -107,13 +107,6 @@ qcrypto_secret_prop_get_file(Object *obj,
107107
}
108108

109109

110-
static void
111-
qcrypto_secret_complete(UserCreatable *uc, Error **errp)
112-
{
113-
object_property_set_bool(OBJECT(uc), "loaded", true, errp);
114-
}
115-
116-
117110
static void
118111
qcrypto_secret_finalize(Object *obj)
119112
{
@@ -129,9 +122,6 @@ qcrypto_secret_class_init(ObjectClass *oc, void *data)
129122
QCryptoSecretCommonClass *sic = QCRYPTO_SECRET_COMMON_CLASS(oc);
130123
sic->load_data = qcrypto_secret_load_data;
131124

132-
UserCreatableClass *ucc = USER_CREATABLE_CLASS(oc);
133-
ucc->complete = qcrypto_secret_complete;
134-
135125
object_class_property_add_str(oc, "data",
136126
qcrypto_secret_prop_get_data,
137127
qcrypto_secret_prop_set_data);
@@ -148,10 +138,6 @@ static const TypeInfo qcrypto_secret_info = {
148138
.instance_finalize = qcrypto_secret_finalize,
149139
.class_size = sizeof(QCryptoSecretClass),
150140
.class_init = qcrypto_secret_class_init,
151-
.interfaces = (InterfaceInfo[]) {
152-
{ TYPE_USER_CREATABLE },
153-
{ }
154-
}
155141
};
156142

157143

crypto/secret_common.c

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -191,9 +191,9 @@ qcrypto_secret_prop_set_loaded(Object *obj,
191191

192192
secret->rawdata = input;
193193
secret->rawlen = inputlen;
194-
} else {
195-
g_free(secret->rawdata);
196-
secret->rawlen = 0;
194+
} else if (secret->rawdata) {
195+
error_setg(errp, "Cannot unload secret");
196+
return;
197197
}
198198
}
199199

@@ -268,6 +268,13 @@ qcrypto_secret_prop_get_keyid(Object *obj,
268268
}
269269

270270

271+
static void
272+
qcrypto_secret_complete(UserCreatable *uc, Error **errp)
273+
{
274+
object_property_set_bool(OBJECT(uc), "loaded", true, errp);
275+
}
276+
277+
271278
static void
272279
qcrypto_secret_finalize(Object *obj)
273280
{
@@ -281,6 +288,10 @@ qcrypto_secret_finalize(Object *obj)
281288
static void
282289
qcrypto_secret_class_init(ObjectClass *oc, void *data)
283290
{
291+
UserCreatableClass *ucc = USER_CREATABLE_CLASS(oc);
292+
293+
ucc->complete = qcrypto_secret_complete;
294+
284295
object_class_property_add_bool(oc, "loaded",
285296
qcrypto_secret_prop_get_loaded,
286297
qcrypto_secret_prop_set_loaded);
@@ -390,6 +401,10 @@ static const TypeInfo qcrypto_secret_info = {
390401
.class_size = sizeof(QCryptoSecretCommonClass),
391402
.class_init = qcrypto_secret_class_init,
392403
.abstract = true,
404+
.interfaces = (InterfaceInfo[]) {
405+
{ TYPE_USER_CREATABLE },
406+
{ }
407+
}
393408
};
394409

395410

crypto/secret_keyring.c

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -102,22 +102,12 @@ qcrypto_secret_prop_get_key(Object *obj, Visitor *v,
102102
}
103103

104104

105-
static void
106-
qcrypto_secret_keyring_complete(UserCreatable *uc, Error **errp)
107-
{
108-
object_property_set_bool(OBJECT(uc), "loaded", true, errp);
109-
}
110-
111-
112105
static void
113106
qcrypto_secret_keyring_class_init(ObjectClass *oc, void *data)
114107
{
115108
QCryptoSecretCommonClass *sic = QCRYPTO_SECRET_COMMON_CLASS(oc);
116109
sic->load_data = qcrypto_secret_keyring_load_data;
117110

118-
UserCreatableClass *ucc = USER_CREATABLE_CLASS(oc);
119-
ucc->complete = qcrypto_secret_keyring_complete;
120-
121111
object_class_property_add(oc, "serial", "int32_t",
122112
qcrypto_secret_prop_get_key,
123113
qcrypto_secret_prop_set_key,
@@ -130,10 +120,6 @@ static const TypeInfo qcrypto_secret_info = {
130120
.name = TYPE_QCRYPTO_SECRET_KEYRING,
131121
.instance_size = sizeof(QCryptoSecretKeyring),
132122
.class_init = qcrypto_secret_keyring_class_init,
133-
.interfaces = (InterfaceInfo[]) {
134-
{ TYPE_USER_CREATABLE },
135-
{ }
136-
}
137123
};
138124

139125

crypto/tlscredsanon.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,10 +123,9 @@ qcrypto_tls_creds_anon_prop_set_loaded(Object *obj,
123123
{
124124
QCryptoTLSCredsAnon *creds = QCRYPTO_TLS_CREDS_ANON(obj);
125125

126+
qcrypto_tls_creds_anon_unload(creds);
126127
if (value) {
127128
qcrypto_tls_creds_anon_load(creds, errp);
128-
} else {
129-
qcrypto_tls_creds_anon_unload(creds);
130129
}
131130
}
132131

crypto/tlscredspsk.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,10 +192,9 @@ qcrypto_tls_creds_psk_prop_set_loaded(Object *obj,
192192
{
193193
QCryptoTLSCredsPSK *creds = QCRYPTO_TLS_CREDS_PSK(obj);
194194

195+
qcrypto_tls_creds_psk_unload(creds);
195196
if (value) {
196197
qcrypto_tls_creds_psk_load(creds, errp);
197-
} else {
198-
qcrypto_tls_creds_psk_unload(creds);
199198
}
200199
}
201200

crypto/tlscredsx509.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ qcrypto_tls_creds_check_cert_key_usage(QCryptoTLSCredsX509 *creds,
143143
if (status < 0) {
144144
if (status == GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE) {
145145
usage = isCA ? GNUTLS_KEY_KEY_CERT_SIGN :
146-
GNUTLS_KEY_DIGITAL_SIGNATURE|GNUTLS_KEY_KEY_ENCIPHERMENT;
146+
GNUTLS_KEY_DIGITAL_SIGNATURE | GNUTLS_KEY_KEY_ENCIPHERMENT;
147147
} else {
148148
error_setg(errp,
149149
"Unable to query certificate %s key usage: %s",
@@ -694,10 +694,9 @@ qcrypto_tls_creds_x509_prop_set_loaded(Object *obj,
694694
{
695695
QCryptoTLSCredsX509 *creds = QCRYPTO_TLS_CREDS_X509(obj);
696696

697+
qcrypto_tls_creds_x509_unload(creds);
697698
if (value) {
698699
qcrypto_tls_creds_x509_load(creds, errp);
699-
} else {
700-
qcrypto_tls_creds_x509_unload(creds);
701700
}
702701
}
703702

0 commit comments

Comments
 (0)