[gnome-initial-setup/wip/pwithnall/misc-fixes: 5/70] account-local: limit full name to 80 characters




commit e240ffbd2c271535fb0391a953146eb946dc5755
Author: Alessandro Puccetti <alessandro kinvolk io>
Date:   Fri May 5 11:49:59 2017 +0200

    account-local: limit full name to 80 characters
    
    Debian/Ubuntu ship a patch to accountsservice that makes it use adduser
    instead of the default useradd when adding an user to the system.
    One of the differences between adduser and useradd is that the former
    calls into chfn to set the user full name. That has a limitation of 80
    characters, and user creation will then fail when a longer full name is
    provided.
    
    Instead of reverting the accountsservice patch (which might have
    unforeseen consequences) at this point the safest thing to do is to
    limit the number of characters that can be entered in the FBE
    to match the limit of chfn - i.e. 80 characters.
    
    TODO: This patch is wrong. The limit is 80 bytes, not 80 characters, as
    confirmed by Will's testing in https://phabricator.endlessm.com/T25360.
    There is a ticket open, and if it is addressed before a following
    rebase, then it should be squashed into this commit:
    https://phabricator.endlessm.com/T25444
    
    (Rebase 3.38: Squash in a later fix from Matthew Leeds to also check the
    size in code.)
    
    https://phabricator.endlessm.com/T2903
    https://phabricator.endlessm.com/T25444

 gnome-initial-setup/pages/account/gis-account-page-local.ui | 2 +-
 gnome-initial-setup/pages/account/um-utils.c                | 4 +++-
 2 files changed, 4 insertions(+), 2 deletions(-)
---
diff --git a/gnome-initial-setup/pages/account/gis-account-page-local.ui 
b/gnome-initial-setup/pages/account/gis-account-page-local.ui
index ccfd7e14..6b9e1bc6 100644
--- a/gnome-initial-setup/pages/account/gis-account-page-local.ui
+++ b/gnome-initial-setup/pages/account/gis-account-page-local.ui
@@ -63,7 +63,7 @@
             </child>
             <child>
               <object class="GtkEntry" id="fullname_entry">
-                <property name="max_length">255</property>
+                <property name="max_length">80</property>
                 <property name="width-chars">25</property>
                 <property name="visible">True</property>
                 <property name="invisible_char">●</property>
diff --git a/gnome-initial-setup/pages/account/um-utils.c b/gnome-initial-setup/pages/account/um-utils.c
index 524b45ed..c2567fa9 100644
--- a/gnome-initial-setup/pages/account/um-utils.c
+++ b/gnome-initial-setup/pages/account/um-utils.c
@@ -184,6 +184,7 @@ is_valid_name (const gchar *name)
         /* Valid names must contain:
          *   1) at least one character.
          *   2) at least one non-"space" character.
+         *   3) no more than 80 bytes (see https://phabricator.endlessm.com/T25444).
          */
         for (c = name; *c; c++) {
                 gunichar unichar;
@@ -201,7 +202,8 @@ is_valid_name (const gchar *name)
                 }
         }
 
-        return !is_empty;
+        /* Here we check the number of bytes not characters */
+        return !is_empty && strlen (name) < 80;
 }
 
 gboolean


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