[libuser] Don't default commonName to gecos if it is empty
Miloslav Trmac
mitr at fedoraproject.org
Thu Jan 20 13:37:28 UTC 2011
commit f1b8dca5024f7db213bf3f45480b2682db7cfe49
Author: Miloslav Trmač <mitr at redhat.com>
Date: Thu Jan 20 14:36:47 2011 +0100
Don't default commonName to gecos if it is empty
* Thu Jan 20 2011 Miloslav Trmač <mitr at redhat.com> - 0.57.1-2
- Don't default commonName to gecos if it is empty
Resolves: #670151
libuser-0.57.1-commonName.patch | 73 +++++++++++++++++++++++++++++++++++++++
libuser.spec | 9 ++++-
2 files changed, 81 insertions(+), 1 deletions(-)
---
diff --git a/libuser-0.57.1-commonName.patch b/libuser-0.57.1-commonName.patch
new file mode 100644
index 0000000..06822e6
--- /dev/null
+++ b/libuser-0.57.1-commonName.patch
@@ -0,0 +1,73 @@
+2011-01-20 Miloslav Trmač <mitr at redhat.com>
+
+ * modules/ldap.c (get_ent_adds): Don't use empty gecos as a commonName
+ value.
+ * tests/ldap_test.py (Tests.testUserAdd7): New test.
+
+diff -r d5daa92a0e78 -r 44c92c5eef75 modules/ldap.c
+--- a/modules/ldap.c Thu Jan 20 13:05:59 2011 +0000
++++ b/modules/ldap.c Thu Jan 20 14:21:20 2011 +0100
+@@ -1026,6 +1026,7 @@
+ && lu_ent_get(ent, LU_COMMONNAME) == NULL) {
+ char *cn;
+
++ cn = NULL;
+ vals = lu_ent_get(ent, LU_GECOS);
+ if (vals != NULL) {
+ char *p;
+@@ -1035,7 +1036,11 @@
+ p = strchr(cn, ',');
+ if (p != NULL)
+ *p = 0;
+- } else {
++ /* Note that gecos may be empty, but
++ commonName (as a DirectoryString) is not
++ allowed to be empty. */
++ }
++ if (cn == NULL || *cn == 0) {
+ vals = lu_ent_get(ent, LU_USERNAME);
+ /* Guaranteed by lu_ldap_set() */
+ g_assert (vals != NULL);
+diff -r d5daa92a0e78 -r 44c92c5eef75 tests/ldap_test.py
+--- a/tests/ldap_test.py Thu Jan 20 13:05:59 2011 +0000
++++ b/tests/ldap_test.py Thu Jan 20 14:21:20 2011 +0100
+@@ -169,6 +169,39 @@
+ e = self.a.initUser('user6_6')
+ self.assertRaises(RuntimeError, self.a.addUser, e, False, False)
+
++ def testUserAdd7(self):
++ # Adding commonName if it is not defined:
++ # - Explicitly set
++ e = self.a.initUser('user6_7')
++ e[libuser.COMMONNAME] = 'Common Name'
++ self.a.addUser(e, False, False)
++ del e
++ e = self.a.lookupUserByName('user6_7')
++ self.assertEqual(e[libuser.COMMONNAME], ['Common Name'])
++ # - Defaulted from GECOS
++ e = self.a.initUser('user6_8')
++ e[libuser.GECOS] = 'Full Name,Office,1234,4321'
++ self.a.addUser(e, False, False)
++ del e
++ e = self.a.lookupUserByName('user6_8')
++ self.assertEqual(e[libuser.COMMONNAME], ['Full Name'])
++ # Defaulted from user name
++ e = self.a.initUser('user6_9')
++ self.assertEqual(e[libuser.GECOS], ['user6_9'])
++ e.clear(libuser.GECOS)
++ self.assertRaises(KeyError, lambda x: x[libuser.GECOS], e)
++ self.a.addUser(e, False, False)
++ del e
++ e = self.a.lookupUserByName('user6_9')
++ self.assertEqual(e[libuser.COMMONNAME], ['user6_9'])
++ # Defaulted from user name if GECOS is empty
++ e = self.a.initUser('user6_10')
++ e[libuser.GECOS] = ''
++ self.a.addUser(e, False, False)
++ del e
++ e = self.a.lookupUserByName('user6_10')
++ self.assertEqual(e[libuser.COMMONNAME], ['user6_10'])
++
+ def testUserMod1(self):
+ # A minimal case
+ e = self.a.initUser('user7_1')
diff --git a/libuser.spec b/libuser.spec
index fe91c73..24ac297 100644
--- a/libuser.spec
+++ b/libuser.spec
@@ -2,11 +2,13 @@
Name: libuser
Version: 0.57.1
-Release: 1%{?dist}
+Release: 2%{?dist}
Group: System Environment/Base
License: LGPLv2+
URL: https://fedorahosted.org/libuser/
Source: https://fedorahosted.org/releases/l/i/libuser/libuser-%{version}.tar.xz
+# Upstream commit 44c92c5eef75eadb71f14f2c8834dfc7ca5b0adb
+Patch0: libuser-0.57.1-commonName.patch
BuildRequires: glib2-devel, linuxdoc-tools, pam-devel, popt-devel, python2-devel
BuildRequires: cyrus-sasl-devel, libselinux-devel, openldap-devel
# To make sure the configure script can find it
@@ -45,6 +47,7 @@ administering user and group accounts.
%prep
%setup -q
+%patch0 -p1 -b .commonName
%build
%configure --with-selinux --with-ldap --with-html-dir=%{_datadir}/gtk-doc/html
@@ -102,6 +105,10 @@ python -c "import libuser"
%{_datadir}/gtk-doc/html/*
%changelog
+* Thu Jan 20 2011 Miloslav Trmač <mitr at redhat.com> - 0.57.1-2
+- Don't default commonName to gecos if it is empty
+ Resolves: #670151
+
* Fri Jan 14 2011 Miloslav Trmač <mitr at redhat.com> - 0.57.1-1
- Update to libuser-0.57.1
Resolves: #668855
More information about the scm-commits
mailing list