Skip to content

Commit

Permalink
Merge remote-tracking branch 'remotes/berrange-gitlab/tags/misc-fixes…
Browse files Browse the repository at this point in the history
…-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]>
  • Loading branch information
pm215 committed Jan 29, 2021
2 parents 9df52f5 + ecb98f5 commit 74208cd
Show file tree
Hide file tree
Showing 25 changed files with 161 additions and 147 deletions.
24 changes: 2 additions & 22 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -47,30 +47,10 @@ git-submodule-update:
Makefile: .git-submodule-status

.PHONY: git-submodule-update

git_module_status := $(shell \
cd '$(SRC_PATH)' && \
GIT="$(GIT)" ./scripts/git-submodule.sh status $(GIT_SUBMODULES); \
echo $$?; \
)

ifeq (1,$(git_module_status))
ifeq (no,$(GIT_UPDATE))
git-submodule-update:
$(call quiet-command, \
echo && \
echo "GIT submodule checkout is out of date. Please run" && \
echo " scripts/git-submodule.sh update $(GIT_SUBMODULES)" && \
echo "from the source directory checkout $(SRC_PATH)" && \
echo && \
exit 1)
else
git-submodule-update:
$(call quiet-command, \
(cd $(SRC_PATH) && GIT="$(GIT)" ./scripts/git-submodule.sh update $(GIT_SUBMODULES)), \
"GIT","$(GIT_SUBMODULES)")
endif
endif
(GIT="$(GIT)" "$(SRC_PATH)/scripts/git-submodule.sh" $(GIT_SUBMODULES_ACTION) $(GIT_SUBMODULES)), \
"GIT","$(GIT_SUBMODULES)")

# 0. ensure the build tree is okay

Expand Down
51 changes: 38 additions & 13 deletions configure
Original file line number Diff line number Diff line change
Expand Up @@ -255,12 +255,12 @@ gdb_bin=$(command -v "gdb-multiarch" || command -v "gdb")

if test -e "$source_path/.git"
then
git_update=yes
git_submodules_action="update"
git_submodules="ui/keycodemapdb"
git_submodules="$git_submodules tests/fp/berkeley-testfloat-3"
git_submodules="$git_submodules tests/fp/berkeley-softfloat-3"
else
git_update=no
git_submodules_action="ignore"
git_submodules=""

if ! test -f "$source_path/ui/keycodemapdb/README"
Expand Down Expand Up @@ -1499,9 +1499,16 @@ for opt do
;;
--with-git=*) git="$optarg"
;;
--enable-git-update) git_update=yes
--enable-git-update)
git_submodules_action="update"
echo "--enable-git-update deprecated, use --with-git-submodules=update"
;;
--disable-git-update) git_update=no
--disable-git-update)
git_submodules_action="validate"
echo "--disable-git-update deprecated, use --with-git-submodules=validate"
;;
--with-git-submodules=*)
git_submodules_action="$optarg"
;;
--enable-debug-mutex) debug_mutex=yes
;;
Expand Down Expand Up @@ -1557,6 +1564,21 @@ for opt do
esac
done

case $git_submodules_action in
update|validate)
if test ! -e "$source_path/.git"; then
echo "ERROR: cannot $git_submodules_action git submodules without .git"
exit 1
fi
;;
ignore)
;;
*)
echo "ERROR: invalid --with-git-submodules= value '$git_submodules_action'"
exit 1
;;
esac

libdir="${libdir:-$prefix/lib}"
libexecdir="${libexecdir:-$prefix/libexec}"
includedir="${includedir:-$prefix/include}"
Expand Down Expand Up @@ -1701,6 +1723,9 @@ Advanced options (experts only):
--ninja=NINJA use specified ninja [$ninja]
--smbd=SMBD use specified smbd [$smbd]
--with-git=GIT use specified git [$git]
--with-git-submodules=update update git submodules (default if .git dir exists)
--with-git-submodules=validate fail if git submodules are not up to date
--with-git-submodules=ignore do not update or check git submodules (default if no .git dir)
--static enable static build [$static]
--mandir=PATH install man pages in PATH
--datadir=PATH install firmware in PATH/$qemu_suffix
Expand Down Expand Up @@ -1917,7 +1942,7 @@ python="$python -B"
if test -z "$meson"; then
if test "$explicit_python" = no && has meson && version_ge "$(meson --version)" 0.55.3; then
meson=meson
elif test -e "${source_path}/.git" && test $git_update = 'yes' ; then
elif test $git_submodules_action != 'ignore' ; then
meson=git
elif test -e "${source_path}/meson/meson.py" ; then
meson=internal
Expand Down Expand Up @@ -1985,7 +2010,7 @@ fi
# Consult white-list to determine whether to enable werror
# by default. Only enable by default for git builds
if test -z "$werror" ; then
if test -e "$source_path/.git" && \
if test "$git_submodules_action" != "ignore" && \
{ test "$linux" = "yes" || test "$mingw32" = "yes"; }; then
werror="yes"
else
Expand Down Expand Up @@ -3558,7 +3583,7 @@ fi
case "$fdt" in
auto | enabled | internal)
# Simpler to always update submodule, even if not needed.
if test -e "${source_path}/.git" && test $git_update = 'yes' ; then
if test "$git_submodules_action" != "ignore"; then
git_submodules="${git_submodules} dtc"
fi
;;
Expand Down Expand Up @@ -4272,7 +4297,7 @@ fi
case "$capstone" in
auto | enabled | internal)
# Simpler to always update submodule, even if not needed.
if test -e "${source_path}/.git" && test $git_update = 'yes' ; then
if test "$git_submodules_action" != "ignore"; then
git_submodules="${git_submodules} capstone"
fi
;;
Expand Down Expand Up @@ -5219,7 +5244,7 @@ fi
case "$slirp" in
auto | enabled | internal)
# Simpler to always update submodule, even if not needed.
if test -e "${source_path}/.git" && test $git_update = 'yes' ; then
if test "$git_submodules_action" != "ignore"; then
git_submodules="${git_submodules} slirp"
fi
;;
Expand Down Expand Up @@ -5393,7 +5418,7 @@ if test "$cpu" = "s390x" ; then
roms="$roms s390-ccw"
# SLOF is required for building the s390-ccw firmware on s390x,
# since it is using the libnet code from SLOF for network booting.
if test -e "${source_path}/.git" ; then
if test "$git_submodules_action" != "ignore"; then
git_submodules="${git_submodules} roms/SLOF"
fi
fi
Expand Down Expand Up @@ -5431,8 +5456,8 @@ else
cxx=
fi

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

config_host_mak="config-host.mak"
Expand All @@ -5443,7 +5468,7 @@ echo >> $config_host_mak
echo all: >> $config_host_mak
echo "GIT=$git" >> $config_host_mak
echo "GIT_SUBMODULES=$git_submodules" >> $config_host_mak
echo "GIT_UPDATE=$git_update" >> $config_host_mak
echo "GIT_SUBMODULES_ACTION=$git_submodules_action" >> $config_host_mak

echo "ARCH=$ARCH" >> $config_host_mak

Expand Down
6 changes: 3 additions & 3 deletions crypto/aes.c
Original file line number Diff line number Diff line change
Expand Up @@ -1080,9 +1080,9 @@ int AES_set_encrypt_key(const unsigned char *userKey, const int bits,

rk = key->rd_key;

if (bits==128)
if (bits == 128)
key->rounds = 10;
else if (bits==192)
else if (bits == 192)
key->rounds = 12;
else
key->rounds = 14;
Expand Down Expand Up @@ -1182,7 +1182,7 @@ int AES_set_decrypt_key(const unsigned char *userKey, const int bits,
rk = key->rd_key;

/* invert the order of the round keys: */
for (i = 0, j = 4*(key->rounds); i < j; i += 4, j -= 4) {
for (i = 0, j = 4 * (key->rounds); i < j; i += 4, j -= 4) {
temp = rk[i ]; rk[i ] = rk[j ]; rk[j ] = temp;
temp = rk[i + 1]; rk[i + 1] = rk[j + 1]; rk[j + 1] = temp;
temp = rk[i + 2]; rk[i + 2] = rk[j + 2]; rk[j + 2] = temp;
Expand Down
4 changes: 2 additions & 2 deletions crypto/desrfb.c
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ static const unsigned char pc1[56] = {
13, 5, 60, 52, 44, 36, 28, 20, 12, 4, 27, 19, 11, 3 };

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

static const unsigned char pc2[48] = {
13, 16, 10, 23, 0, 4, 2, 27, 14, 5, 20, 9,
Expand Down Expand Up @@ -93,7 +93,7 @@ void deskey(unsigned char *key, int edf)
}
for( j = 0; j < 24; j++ ) {
if( pcr[pc2[j]] ) kn[m] |= bigbyte[j];
if( pcr[pc2[j+24]] ) kn[n] |= bigbyte[j];
if( pcr[pc2[j + 24]] ) kn[n] |= bigbyte[j];
}
}
cookey(kn);
Expand Down
14 changes: 0 additions & 14 deletions crypto/secret.c
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,6 @@ qcrypto_secret_prop_get_file(Object *obj,
}


static void
qcrypto_secret_complete(UserCreatable *uc, Error **errp)
{
object_property_set_bool(OBJECT(uc), "loaded", true, errp);
}


static void
qcrypto_secret_finalize(Object *obj)
{
Expand All @@ -129,9 +122,6 @@ qcrypto_secret_class_init(ObjectClass *oc, void *data)
QCryptoSecretCommonClass *sic = QCRYPTO_SECRET_COMMON_CLASS(oc);
sic->load_data = qcrypto_secret_load_data;

UserCreatableClass *ucc = USER_CREATABLE_CLASS(oc);
ucc->complete = qcrypto_secret_complete;

object_class_property_add_str(oc, "data",
qcrypto_secret_prop_get_data,
qcrypto_secret_prop_set_data);
Expand All @@ -148,10 +138,6 @@ static const TypeInfo qcrypto_secret_info = {
.instance_finalize = qcrypto_secret_finalize,
.class_size = sizeof(QCryptoSecretClass),
.class_init = qcrypto_secret_class_init,
.interfaces = (InterfaceInfo[]) {
{ TYPE_USER_CREATABLE },
{ }
}
};


Expand Down
21 changes: 18 additions & 3 deletions crypto/secret_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -191,9 +191,9 @@ qcrypto_secret_prop_set_loaded(Object *obj,

secret->rawdata = input;
secret->rawlen = inputlen;
} else {
g_free(secret->rawdata);
secret->rawlen = 0;
} else if (secret->rawdata) {
error_setg(errp, "Cannot unload secret");
return;
}
}

Expand Down Expand Up @@ -268,6 +268,13 @@ qcrypto_secret_prop_get_keyid(Object *obj,
}


static void
qcrypto_secret_complete(UserCreatable *uc, Error **errp)
{
object_property_set_bool(OBJECT(uc), "loaded", true, errp);
}


static void
qcrypto_secret_finalize(Object *obj)
{
Expand All @@ -281,6 +288,10 @@ qcrypto_secret_finalize(Object *obj)
static void
qcrypto_secret_class_init(ObjectClass *oc, void *data)
{
UserCreatableClass *ucc = USER_CREATABLE_CLASS(oc);

ucc->complete = qcrypto_secret_complete;

object_class_property_add_bool(oc, "loaded",
qcrypto_secret_prop_get_loaded,
qcrypto_secret_prop_set_loaded);
Expand Down Expand Up @@ -390,6 +401,10 @@ static const TypeInfo qcrypto_secret_info = {
.class_size = sizeof(QCryptoSecretCommonClass),
.class_init = qcrypto_secret_class_init,
.abstract = true,
.interfaces = (InterfaceInfo[]) {
{ TYPE_USER_CREATABLE },
{ }
}
};


Expand Down
14 changes: 0 additions & 14 deletions crypto/secret_keyring.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,22 +102,12 @@ qcrypto_secret_prop_get_key(Object *obj, Visitor *v,
}


static void
qcrypto_secret_keyring_complete(UserCreatable *uc, Error **errp)
{
object_property_set_bool(OBJECT(uc), "loaded", true, errp);
}


static void
qcrypto_secret_keyring_class_init(ObjectClass *oc, void *data)
{
QCryptoSecretCommonClass *sic = QCRYPTO_SECRET_COMMON_CLASS(oc);
sic->load_data = qcrypto_secret_keyring_load_data;

UserCreatableClass *ucc = USER_CREATABLE_CLASS(oc);
ucc->complete = qcrypto_secret_keyring_complete;

object_class_property_add(oc, "serial", "int32_t",
qcrypto_secret_prop_get_key,
qcrypto_secret_prop_set_key,
Expand All @@ -130,10 +120,6 @@ static const TypeInfo qcrypto_secret_info = {
.name = TYPE_QCRYPTO_SECRET_KEYRING,
.instance_size = sizeof(QCryptoSecretKeyring),
.class_init = qcrypto_secret_keyring_class_init,
.interfaces = (InterfaceInfo[]) {
{ TYPE_USER_CREATABLE },
{ }
}
};


Expand Down
3 changes: 1 addition & 2 deletions crypto/tlscredsanon.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,10 +123,9 @@ qcrypto_tls_creds_anon_prop_set_loaded(Object *obj,
{
QCryptoTLSCredsAnon *creds = QCRYPTO_TLS_CREDS_ANON(obj);

qcrypto_tls_creds_anon_unload(creds);
if (value) {
qcrypto_tls_creds_anon_load(creds, errp);
} else {
qcrypto_tls_creds_anon_unload(creds);
}
}

Expand Down
3 changes: 1 addition & 2 deletions crypto/tlscredspsk.c
Original file line number Diff line number Diff line change
Expand Up @@ -192,10 +192,9 @@ qcrypto_tls_creds_psk_prop_set_loaded(Object *obj,
{
QCryptoTLSCredsPSK *creds = QCRYPTO_TLS_CREDS_PSK(obj);

qcrypto_tls_creds_psk_unload(creds);
if (value) {
qcrypto_tls_creds_psk_load(creds, errp);
} else {
qcrypto_tls_creds_psk_unload(creds);
}
}

Expand Down
5 changes: 2 additions & 3 deletions crypto/tlscredsx509.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ qcrypto_tls_creds_check_cert_key_usage(QCryptoTLSCredsX509 *creds,
if (status < 0) {
if (status == GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE) {
usage = isCA ? GNUTLS_KEY_KEY_CERT_SIGN :
GNUTLS_KEY_DIGITAL_SIGNATURE|GNUTLS_KEY_KEY_ENCIPHERMENT;
GNUTLS_KEY_DIGITAL_SIGNATURE | GNUTLS_KEY_KEY_ENCIPHERMENT;
} else {
error_setg(errp,
"Unable to query certificate %s key usage: %s",
Expand Down Expand Up @@ -694,10 +694,9 @@ qcrypto_tls_creds_x509_prop_set_loaded(Object *obj,
{
QCryptoTLSCredsX509 *creds = QCRYPTO_TLS_CREDS_X509(obj);

qcrypto_tls_creds_x509_unload(creds);
if (value) {
qcrypto_tls_creds_x509_load(creds, errp);
} else {
qcrypto_tls_creds_x509_unload(creds);
}
}

Expand Down
Loading

0 comments on commit 74208cd

Please sign in to comment.