Guido,

On 11/18/2016 04:24 PM, Guido Günther wrote:
I'm failing to spot how you make sure you only run on new
installations. [snip]

Oops. You're right. Not sure where my head was at. It passed
tests due to debconf again; sorry.

I thought of not doing a whole-file guard, but an early exit,
to keep it short.  Is this snippet OK with you?

# Only perform this check/warning on new installations
# (precisely: when not creating neither user nor group).
if getent passwd libvirt-qemu >/dev/null \
&& getent group  libvirt-qemu >/dev/null; then
        exit 0
fi

> +# Check if allocated UID/GID are assigned to a different user/group.
> +UID_TO_NAME="$(getent passwd $LIBVIRT_QEMU_UID | cut -d: -f1)"
> +GID_TO_NAME="$(getent group  $LIBVIRT_QEMU_GID | cut -d: -f1)"
> +
> +if ( [ -n "$UID_TO_NAME" ] && [ "$UID_TO_NAME" != 'libvirt-qemu' ] ) \
> +|| ( [ -n "$GID_TO_NAME" ] && [ "$GID_TO_NAME" != 'libvirt-qemu' ] )
> \
I think this can be shortened to:

if [ "$UID_TO_NAME" != 'libvirt-qemu' ] || [ "$GID_TO_NAME" != 'libvirt-qemu' 
]; then

Hm, but if the uid/gid is not taken, then getent output is null,
which is != 'libvirt-qemu', so the warning shows up incorrectly.

If you're OK w/ my suggestions, would you apply the guard snippet,
or would prefer a v4 of this particular patch submitted?

Thanks,

--
Mauricio Faria de Oliveira
IBM Linux Technology Center

Reply via email to