Package: ejabberd

--- Please enter the report below this line. ---

This is a simple patch for debconf that checks whether the admin username 
respects rfc6122. Please check the template text, because my english is not 
good enough for the Debian standards.

--- System information. ---
Architecture: amd64
Kernel:       Linux 3.16.0-4-amd64

Debian Release: jessie/sid
  650 testing         security.debian.org 
  650 testing         ftp.be.debian.org 
  600 unstable        www.deb-multimedia.org 
  600 unstable        ftp.be.debian.org 
  600 sid             linux.dropbox.com 
  500 suldr           www.bchemnet.com 
  500 stable          security.debian.org 
  500 stable          dl.google.com 
  500 experimental    www.deb-multimedia.org 
  500 experimental    ftp.be.debian.org 

--- Package information. ---
Package's Depends field is empty.

Package's Recommends field is empty.

Package's Suggests field is empty.

--
| /
| \Byte - Andrea Briganti
Blog: http://kbyte.snowpenguin.org JID:[email protected]
diff -ur ejabberd-14.07.orig/debian/config ejabberd-14.07/debian/config
--- ejabberd-14.07.orig/debian/config	2014-08-25 17:08:55.000000000 +0200
+++ ejabberd-14.07/debian/config	2014-11-16 17:30:44.670814998 +0100
@@ -30,7 +30,24 @@
   db_go || true
   db_get ejabberd/user
   if [ -n "$RET" ]; then
-    get_passwd
+    NEWUSER="$RET"
+
+    # Strip the ejabber hostname
+    STRIPDOMAIN=$(echo "$NEWUSER" | awk -v host="@$HOST" 'host{ print $0 }')
+    if [ -n "$STRIPDOMAIN" ]; then
+      NEWUSER=$(echo "$NEWUSER" | awk -v host="@$HOST" '{ sub(host, ""); print}')
+      db_set ejabberd/user "$NEWUSER"
+    fi
+
+    # Check unallowed chars
+    INVALID=$(echo "$NEWUSER" | awk '/[[:cntrl:]]|[[:space:]]|@|<|>|:|\/|&|\"|\x27/{ print $0 }')
+    if [ -n "$INVALID" ]; then
+      db_input medium ejabberd/invaliduser || true
+      db_go || true
+      get_credentials
+    else
+      get_passwd
+    fi
   fi
 }
 
diff -ur ejabberd-14.07.orig/debian/templates ejabberd-14.07/debian/templates
--- ejabberd-14.07.orig/debian/templates	2014-08-25 17:08:55.000000000 +0200
+++ ejabberd-14.07/debian/templates	2014-11-16 17:28:58.462814501 +0100
@@ -32,3 +32,10 @@
 _Description: The passwords do not match!
  The passwords you have typed do not match. Please try again.
 
+Template: ejabberd/invaliduser
+Type: error
+_Description: The username of the admin account is not valid!
+ The username you have typed contains unallowed chars. Please respect the 
+ JID syntax (http://tools.ietf.org/html/rfc6122#appendix-A.5). If you used
+ a full JID (e.g. user@hostname), you have to use the same hostname
+ you typed into the hostname configuration step.

Reply via email to