[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Re: Setting the Live User uid



Thanks for the quick reply,

Since Saturday, I've successfully tried a usermod hook script to change cruisecontrol's uid within the system range with the following script.

$ cat 05-moduser.chroot.sh
#!/bin/sh

PASSWD_FILE="/etc/passwd"
CRUISE_USERNAME="cruise"

LAST_SYSTEM_UID=$(cut -d':' -f3 "${PASSWD_FILE}" | egrep "^[0-9]{1,3}$" | sort -run | head -1)
NEXT_SYSTEM_UID=$((${LAST_SYSTEM_UID} + 1))

grep "${CRUISE_USERNAME}" "${PASSWD_FILE}" 1> /dev/null 2>&1 && usermod -u "${NEXT_SYSTEM_UID}" ${CRUISE_USERNAME}
RC=$?
echo "Code retour usermod : ${RC}"

---------

When booting from the generated image, live-initramfs successfully created the Live User with uid 1000. This is just a workaround but that will let me get on with the rest of the packages I have to include in this demo CD.

A better workaround might be to repackage cruisecontrol and change the way their user is create. For reference, here's the extract from the postinst file within the cruisecontrol package that creates the user.

$ head -6 postinst
#!/bin/bash
set -e

# Create the user and group if the don't exist
grep -q "^cruise:" /etc/group || groupadd cruise
grep -q "^cruise:" /etc/passwd || useradd -d /var/spool/cruisecontrol -g cruise -s /bin/bash cruise

---------

A couple --system switches will probably do the trick.

Now, as David said, this doesn't change the problem with live-initramfs. Here's the an extract from the 10adduser script handling the Live User creation :

$cat /usr/share/initramfs-tools/scripts/live-bottom/10adduser

[...]
user_crypted="8Ab05sVQ4LLps" # as in $(echo "live" | mkpasswd -s)

# U6aMy0wojraho is just a blank password
chroot /root debconf-communicate -fnoninteractive live-initramfs > /dev/null << EOF
set passwd/make-user true
set passwd/root-password-crypted *
set passwd/user-password-crypted ${user_crypted}
set passwd/user-fullname ${USERFULLNAME}
set passwd/username ${USERNAME}
set passwd/user-uid 1000
EOF

chroot /root /usr/bin/env -i HOME="/root" \
   TERM="${TERM}" PATH="/usr/sbin:/usr/bin:/sbin:/bin" \
   /usr/lib/user-setup/user-setup-apply 2>&1 \
       | grep -v "Shadow passwords are now on"

[...]
---------

Even if I change the 1000 uid value to 1666 with a hook during live-helper's chroot stage, live-initramfs creates the Live User with 1000 as uid.

Does anybody see any blatant error in initramfs-tools' script ?

Thanks for your help,
Séb.


Reply to: