[libvirt PATCH 4/7] ci: integration.sh: Replace most 'sudo' usage with running as root

Martin Kletzander mkletzan at redhat.com
Mon Jan 23 08:36:04 UTC 2023


On Fri, Jan 20, 2023 at 04:06:00PM +0100, Erik Skultety wrote:
>This is a purely cosmetic change dropping the majority of 'sudo'
>invocations which we need to do to make final preparations on the
>test environment. This patch visually divides the part where we need to
>run as root from the rest of the operations.
>
>Signed-off-by: Erik Skultety <eskultet at redhat.com>
>---
> ci/integration.sh | 22 ++++++++++++++--------
> 1 file changed, 14 insertions(+), 8 deletions(-)
>
>diff --git a/ci/integration.sh b/ci/integration.sh
>index 160aecf00d..5cee536442 100644
>--- a/ci/integration.sh
>+++ b/ci/integration.sh
>@@ -1,10 +1,13 @@
> #!/bin/sh
>
>+# BEGIN AS ROOT
>+sudo su -
>+

This won't work, it will spawn a shell and if the input is closed it
will quit again.  It will not run the rest of the script as root.
Unless there is some special setting somewhere which I don't know.

> # Avocado >98.0 fails with the nwfilter TCK tests, so stick with 98.0 for now
>-sudo pip3 install --prefix=/usr avocado-framework==98.0
>+pip3 install --prefix=/usr avocado-framework==98.0
>
>-sudo sh -c "echo DefaultLimitCORE=infinity >> /etc/systemd/system.conf" # Explicitly allow storing cores globally
>-sudo systemctl daemon-reexec # need to reexec systemd after changing config
>+echo "DefaultLimitCORE=infinity" >> /etc/systemd/system.conf # Explicitly allow storing cores globally
>+systemctl daemon-reexec # need to reexec systemd after changing config
>
> source /etc/os-release  # in order to query the vendor-provided variables
> if test "$ID" = "centos" && test "$VERSION_ID" -eq 8
>@@ -17,13 +20,16 @@ for daemon in $DAEMONS
> do
>     LOG_OUTPUTS="1:file:/var/log/libvirt/${daemon}.log"
>     LOG_FILTERS="3:remote 4:event 3:util.json 3:util.object 3:util.dbus 3:util.netlink 3:node_device 3:rpc 3:access 1:*"
>-    sudo augtool set /files/etc/libvirt/${daemon}.conf/log_filters "'$LOG_FILTERS'" &>/dev/null
>-    sudo augtool set /files/etc/libvirt/${daemon}.conf/log_outputs "'$LOG_OUTPUTS'" &>/dev/null
>-    sudo systemctl --quiet stop ${daemon}.service
>-    sudo systemctl restart ${daemon}.socket
>+    augtool set /files/etc/libvirt/${daemon}.conf/log_filters "'$LOG_FILTERS'" &>/dev/null
>+    augtool set /files/etc/libvirt/${daemon}.conf/log_outputs "'$LOG_OUTPUTS'" &>/dev/null
>+    systemctl --quiet stop ${daemon}.service
>+    systemctl restart ${daemon}.socket
> done
>
>-sudo virsh net-start default &>/dev/null || true
>+virsh net-start default &>/dev/null || true
>+
>+# END AS ROOT
>+exit
>

This would quit the whole script then.

> cd "$SCRATCH_DIR"
> git clone --depth 1 https://gitlab.com/libvirt/libvirt-tck.git
>-- 
>2.39.0
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20230123/cd143002/attachment-0001.sig>


More information about the libvir-list mailing list