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

Re: Setting the Live User uid



Hi again,

I'm coming back to this issue after a while now but you'll find in this mail an *untested* patch for live-initramfs to set the Live User UID from boot parameter. I'm also sending a second patch for live-helper in a seperate mail to handle this parameter in lh_config.

This is my first experience with using git and modifying either live-initramfs or live-helper, so don't be shy to comment/correct the code. Just be fair.

The parameter name used for both is userid (based on the naming scheme used for username and userfullname).

I haven't been able to test this as I have little knowledge of debian packaging and am still wondering how to override live-initramfs in the generated iso (local mirror, local package in (chroot|binary)_local_package, ... ?). Any pointer on how to proceed will be greatly appreciated. I've noticed a paragraph in the manual but haven't taken the time to read it through (yet). I'm more than willing to test this further but will need more time and documentation.

Sorry for the lack of testing but I wanted to send the patch as quickly as possible to avoid merging issues.

Looking forward to reading more from you,
Sébastien.

Here's the patch for live-initramfs :

From 56d96ae7e0f52b5e0dc2c5737b706bdd7e05853b Mon Sep 17 00:00:00 2001
From: Debian Live user <user@debian.(none)>
Date: Sat, 28 Mar 2009 09:32:32 +0000
Subject: [PATCH] Added Live User UID value in live.conf, adduser script and as a boot parameter

---
bin/live-snapshot                   |    2 +-
conf/live.conf                      |    3 ++-
docs/parameters.txt                 |    1 +
manpages/live-initramfs.en.7.txt    |    2 +-
scripts/live                        |    9 ++++++++-
scripts/live-bottom/02etc_live_conf |    2 ++
scripts/live-bottom/10adduser       |    2 +-
7 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/bin/live-snapshot b/bin/live-snapshot
index d942c90..d689bf0 100755
--- a/bin/live-snapshot
+++ b/bin/live-snapshot
@@ -42,7 +42,7 @@ fi
LIVE_CONF="/etc/live.conf"
. "${LIVE_CONF}"

-export USERNAME USERFULLNAME HOSTNAME
+export USERNAME USERFULLNAME USERID HOSTNAME

EXECUTABLE="${0}"
PROGRAM=$(basename "${EXECUTABLE}")
diff --git a/conf/live.conf b/conf/live.conf
index 0de5b6c..7ed768b 100644
--- a/conf/live.conf
+++ b/conf/live.conf
@@ -2,6 +2,7 @@

USERNAME="user"
USERFULLNAME="Debian Live user"
+USERID="1000"
HOSTNAME="debian"

-export USERNAME USERFULLNAME HOSTNAME
+export USERNAME USERFULLNAME USERID HOSTNAME
diff --git a/docs/parameters.txt b/docs/parameters.txt
index 60ad650..1f3a1bf 100644
--- a/docs/parameters.txt
+++ b/docs/parameters.txt
@@ -12,6 +12,7 @@ live fetch=URL
live hostname=HOSTNAME
live username=USER
live userfullname=USERFULLNAME
+live userid=USERID
live integrity-check
live ip=[CLIENT_IP]:[SERVER_IP]:[GATEWAY_IP]:[NETMASK]:[HOSTNAME]:[DEVICE]:[AUTOCONF] [,[CLIENT_IP]:[SERVER_IP]:[GATEWAY_IP]:[NETMASK]:[HOSTNAME]:[DEVICE]:[AUTOCONF]]*
live ip[=frommedia]
diff --git a/manpages/live-initramfs.en.7.txt b/manpages/live-initramfs.en.7.txt
index c43fa5e..3ae45cb 100644
--- a/manpages/live-initramfs.en.7.txt
+++ b/manpages/live-initramfs.en.7.txt
@@ -64,7 +64,7 @@ Also note that therefore it's currently not possible to fetch an image from a namebased virtualhost of an httpd if it is sharing the ip with the main httpd
instance.

-  hostname=*HOSTNAME*, username=*USER*, userfullname=*USERFULLNAME*::
+ hostname=*HOSTNAME*, username=*USER*, userfullname=*USERFULLNAME*, userid=*USERID*::

Those parameters lets you override values read from the config file.

diff --git a/scripts/live b/scripts/live
index ef7f64d..d1cfe21 100755
--- a/scripts/live
+++ b/scripts/live
@@ -17,6 +17,7 @@ home_snapshot_label="home-sn"

USERNAME="user"
USERFULLNAME="Live user"
+USERID="1000"
HOSTNAME="host"

mkdir -p "${mountpoint}"
@@ -33,7 +34,7 @@ then
fi

[ -f /etc/live.conf ] && . /etc/live.conf
-export USERNAME USERFULLNAME HOSTNAME
+export USERNAME USERFULLNAME USERID HOSTNAME

. /scripts/live-helpers

@@ -104,6 +105,12 @@ Arguments ()
                export USERFULLNAME LIVECONF
                ;;

+            userid=*)
+                USERID="${ARGUMENT#userid=}"
+                LIVECONF="changed"
+                export USERID LIVECONF
+                ;;
+
            ignore_uuid)
                IGNORE_UUID="Yes"
                export IGNORE_UUID
diff --git a/scripts/live-bottom/02etc_live_conf b/scripts/live-bottom/02etc_live_conf
index 815e379..c09aa98 100755
--- a/scripts/live-bottom/02etc_live_conf
+++ b/scripts/live-bottom/02etc_live_conf
@@ -33,6 +33,7 @@ then
        # Updating live.conf
        sed -i -e 's/\(USERNAME="\).*"/\1'"${USERNAME}"'"/g' \
               -e 's/\(USERFULLNAME="\).*"/\1'"${USERFULLNAME}"'"/g' \
+               -e 's/\(USERID="\).*"/\1'"${USERID}"'"/g' \
               -e 's/\(HOSTNAME="\).*"/\1'"${HOSTNAME}"'"/g' \
        /etc/live.conf
    fi
@@ -43,6 +44,7 @@ else
cat > /root/etc/live.conf << EOF
export USERNAME="${USERNAME}"
export USERFULLNAME="${USERFULLNAME}"
+export USERID="${USERID}"
export HOSTNAME="${HOSTNAME}"
EOF

diff --git a/scripts/live-bottom/10adduser b/scripts/live-bottom/10adduser
index 9295070..2931e78 100755
--- a/scripts/live-bottom/10adduser
+++ b/scripts/live-bottom/10adduser
@@ -40,7 +40,7 @@ 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
+set passwd/user-uid ${USERID}
EOF

chroot /root /usr/bin/env -i HOME="/root" \
--
1.5.6.5


Reply to: