[Server-devel] Intitial port of idmgr to Debian
For some reason, the cover letter of the previous patch series was not sent even though I had the --cover option in git-send-email (I blame Perl). ---cut--- The following patch series makes idmgr work on the Plan Ceibal schoolserver out of the box, after configuring a different network address. [PATCH] create_registration: Directly create a v3 format database [PATCH] Use LSB functions for initscript [PATCH] Make users home directory configurable In order to get this accepted in Debian (and in Fedora), we'll have to relocate the package home from /home/idmgr to /var/lib/idmgr and probably also rename the package to olpc-idmgr or schoolserver-idmgr. -- // Bernie Innocenti - http://codewiz.org/ \X/ Sugar Labs - http://sugarlabs.org/ ___ Server-devel mailing list Server-devel@lists.laptop.org http://lists.laptop.org/listinfo/server-devel
[Server-devel] [PATCH] Use LSB functions for initscript
This should be compatible with all LSB-compliant distributions, including Fedora 9. Signed-off-by: Bernie Innocenti --- conf.schoolserver/idmgr | 25 ++--- idmgr.spec.in |1 + 2 files changed, 11 insertions(+), 15 deletions(-) diff --git a/conf.schoolserver/idmgr b/conf.schoolserver/idmgr index e4a212f..65d2a6e 100755 --- a/conf.schoolserver/idmgr +++ b/conf.schoolserver/idmgr @@ -24,7 +24,7 @@ # description: provides the OLPC laptop identity service # Source function library -. /etc/rc.d/init.d/functions +. /lib/lsb/init-functions PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin PID_FILE="/var/run/idmgr.pid" @@ -35,35 +35,30 @@ RETVAL=0 SYS_DOMAIN_FILE=/etc/sysconfig/xs_domain_name check_domain_configured() { -if [ ! -e $SYS_DOMAIN_FILE ]; then - echo "Domain not configured yet" > /dev/stderr - exit 1; -fi +hostname="`hostname --fqdn`" -domain=`cat "$SYS_DOMAIN_FILE" ` -if [ "$domain" == "random.xs.laptop.org" ]; then +if [ -z "$hostname" -o "$hostname" = "random.xs.laptop.org" ]; then echo "Domain not configured yet" > /dev/stderr - exit 1; + exit 1 fi } start() { # Start daemons. - echo -n "Starting $prog: " + echo "Starting $prog: " check_domain_configured -daemon --pidfile=${PID_FILE} $SERVER $OPTS +start_daemon -p $PID_FILE $SERVER $OPTS RETVAL=$? return $RETVAL } stop() { # Stop daemons. - echo -n "Shutting down $prog: " - killproc -p ${PID_FILE} -d 10 $prog + echo "Shutting down $prog: " + killproc -p $PID_FILE $prog RETVAL=$? - echo - [ $RETVAL = 0 ] && rm -f ${PID_FILE} + [ $RETVAL = 0 ] && rm -f $PID_FILE return $RETVAL } @@ -88,7 +83,7 @@ case "$1" in fi ;; status) -status idmgr $PID_FILE +pidofproc -p $PID_FILE idmgr RETVAL=$? ;; *) diff --git a/idmgr.spec.in b/idmgr.spec.in index 9f8d09e..586d661 100644 --- a/idmgr.spec.in +++ b/idmgr.spec.in @@ -18,6 +18,7 @@ Requires: python python-sqlalchemy Requires(pre): /usr/bin/sqlite3, /usr/sbin/useradd Requires(post): /sbin/chkconfig, /sbin/service Requires: rssh +Requires: redhat-lsb BuildRequires: python-devel -- 1.5.6.5 ___ Server-devel mailing list Server-devel@lists.laptop.org http://lists.laptop.org/listinfo/server-devel
[Server-devel] [PATCH] Make users home directory configurable
The default is still /library/users, of course. This patch also adds an explicit "-m" argument to createuser, which seems to be required on Debian and quotes around $username, just in case. Signed-off-by: Bernie Innocenti --- conf.schoolserver/idmgr.conf |5 - scripts/create_user | 18 +++--- 2 files changed, 15 insertions(+), 8 deletions(-) diff --git a/conf.schoolserver/idmgr.conf b/conf.schoolserver/idmgr.conf index 04b71e8..a8d8fd6 100644 --- a/conf.schoolserver/idmgr.conf +++ b/conf.schoolserver/idmgr.conf @@ -29,4 +29,7 @@ #WORKDIR = '/home/idmgr' ##How many registrations before we switch to day-based clumping. -#USE_GROUPS_THRESHOLD = 40 \ No newline at end of file +#USE_GROUPS_THRESHOLD = 40 + +## Where to create home directories for registered laptops +#XO_USERS_DIR=/library/users diff --git a/scripts/create_user b/scripts/create_user index 96cd522..bc46fc4 100755 --- a/scripts/create_user +++ b/scripts/create_user @@ -28,6 +28,12 @@ if [ `whoami` != "root" ]; then exec sudo -S $0 fi +# Set defaults and read configuration +XO_USERS_DIR=/library/users +XO_USERS_GROUP=xousers +RSSH_USERS_GROUP=rsshusers +. /etc/idmgr.conf + log() { echo "$1" | logger -t $LOG_TAG -s -p $LOG_LEVEL } @@ -58,10 +64,8 @@ if [ "$PASSWD_ONLY" == '0' ]; then echo "$pubkey" | grep -s -E '^[A-Za-z0-9+/=]+$' &> /dev/null || die "bad public key" fi -homedir=/library/users/$username -XO_USERS_GROUP=xousers -RSSH_USERS_GROUP=rsshusers - +mkdir -p "$XO_USERS_DIR" +homedir="$XO_USERS_DIR/$username" #make sure the xousers and rsshusers groups exist getent group $XO_USERS_GROUP > /dev/null 2>&1 || groupadd $XO_USERS_GROUP @@ -72,7 +76,7 @@ if getent passwd "$username" > /dev/null 2>&1; then /usr/sbin/usermod -c "$full_name" "$username" || die "unable to change full name" NEW_USER=0 else -/usr/sbin/useradd -c "$full_name" -d "$homedir" \ +/usr/sbin/useradd -c "$full_name" -m -d "$homedir" \ -G $XO_USERS_GROUP,$RSSH_USERS_GROUP -s /usr/bin/rssh "$username" \ || die "Unable to create user" NEW_USER=1 @@ -95,11 +99,11 @@ clean_up_and_die(){ userhome=`getent passwd "$username" | awk -F: '{print $6}'` -cd $userhome || clean_up_and_die "Couldn't cd into user's home directory" +cd "$userhome" || clean_up_and_die "Couldn't cd into user's home directory" mkdir -p --mode=700 .ssh || clean_up_and_die "Unable to mkdir .ssh" echo "ssh-dss $pubkey" >> .ssh/authorized_keys || clean_up_and_die "Unable to set up authorized_keys" chmod 600 .ssh/authorized_keys || clean_up_and_die "Unable to chmod authorized_keys" -chown -R $username .ssh || clean_up_and_die "Unable to chown .ssh" +chown -R "$username" .ssh || clean_up_and_die "Unable to chown .ssh" #clean_up_and_die goodbye -- 1.5.6.5 ___ Server-devel mailing list Server-devel@lists.laptop.org http://lists.laptop.org/listinfo/server-devel
[Server-devel] [PATCH] create_registration: Directly create a v3 format database
Signed-off-by: Bernie Innocenti --- idmgr.spec.in |2 +- scripts/create_registration |4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/idmgr.spec.in b/idmgr.spec.in index bbdbcd5..9f8d09e 100644 --- a/idmgr.spec.in +++ b/idmgr.spec.in @@ -52,7 +52,7 @@ getent group xousers > /dev/null 2>&1 || groupadd xousers # Create the identity database, if there is no pre-existing one # and set the current rev number if [ ! -r /home/idmgr/identity.db ] ; then - # creates a v2 format file + # creates a v3 format file /home/idmgr/create_registration fi diff --git a/scripts/create_registration b/scripts/create_registration index b72a950..190b0f9 100755 --- a/scripts/create_registration +++ b/scripts/create_registration @@ -20,6 +20,6 @@ # create_registration # This script creates a new database for the registration server # -sqlite3 /home/idmgr/identity.db "CREATE TABLE laptops ( serial VARCHAR(20) NOT NULL, nickname VARCHAR(200) NOT NULL, full_name VARCHAR(100) NOT NULL, pubkey TEXT NOT NULL, uuid VARCHAR(100), lastmodified TEXT DEFAULT '1970-11-12 12:34:56', PRIMARY KEY (serial) )" +sqlite3 /home/idmgr/identity.db "CREATE TABLE laptops ( serial VARCHAR(20) NOT NULL, nickname VARCHAR(200) NOT NULL, full_name VARCHAR(100) NOT NULL, pubkey TEXT NOT NULL, uuid VARCHAR(100), lastmodified TEXT DEFAULT '1970-11-12 12:34:56', class_group INTEGER, PRIMARY KEY (serial) )" -[ -x /home/idmgr/storage_format_version ] || echo 2 > /home/idmgr/storage_format_version \ No newline at end of file +[ -x /home/idmgr/storage_format_version ] || echo 3 > /home/idmgr/storage_format_version -- 1.5.6.5 ___ Server-devel mailing list Server-devel@lists.laptop.org http://lists.laptop.org/listinfo/server-devel
[Server-devel] Initial port of idmgr to Debian
The following patch series makes idmgr work on the Plan Ceibal schoolserver out of the box, after configuring a different network address. [PATCH] create_registration: Directly create a v3 format database [PATCH] Use LSB functions for initscript [PATCH] Make users home directory configurable In order to get this accepted in Debian (and in Fedora), we'll have to relocate the package home from /home/idmgr to /var/lib/idmgr and probably also rename the package to olpc-idmgr or schoolserver-idmgr. ___ Server-devel mailing list Server-devel@lists.laptop.org http://lists.laptop.org/listinfo/server-devel