[gnome-control-center] user-accounts: use POSIX for max login name length
- From: Ryan Lortie <desrt src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-control-center] user-accounts: use POSIX for max login name length
- Date: Wed, 12 Feb 2014 18:15:38 +0000 (UTC)
commit 07d24bbdab3d6dc37f685ae22c741ead8b8221c1
Author: Ryan Lortie <desrt desrt ca>
Date: Wed Feb 12 12:07:34 2014 -0500
user-accounts: use POSIX for max login name length
Use the POSIX-specified way of determining the maximum length of a valid
username on this system.
https://bugzilla.gnome.org/show_bug.cgi?id=724193
panels/user-accounts/um-utils.c | 21 +++++++++++++++++++--
1 files changed, 19 insertions(+), 2 deletions(-)
---
diff --git a/panels/user-accounts/um-utils.c b/panels/user-accounts/um-utils.c
index f721c26..b1b67ba 100644
--- a/panels/user-accounts/um-utils.c
+++ b/panels/user-accounts/um-utils.c
@@ -23,8 +23,9 @@
#include <math.h>
#include <stdlib.h>
#include <sys/types.h>
+#include <limits.h>
+#include <unistd.h>
#include <pwd.h>
-#include <utmp.h>
#include <gio/gio.h>
#include <gio/gunixoutputstream.h>
@@ -463,8 +464,24 @@ down_arrow (GtkStyleContext *context,
cairo_restore (cr);
}
+static guint
+get_login_name_max (void)
+{
+#ifdef LOGIN_NAME_MAX
+ return LOGIN_NAME_MAX
+#else
+ static gint length;
+
+ if (!length) {
+ length = sysconf (_SC_LOGIN_NAME_MAX);
+ g_assert_cmpint (length, >=, 0);
+ }
+
+ return length;
+#endif
+}
-#define MAXNAMELEN (UT_NAMESIZE - 1)
+#define MAXNAMELEN get_login_name_max ()
static gboolean
is_username_used (const gchar *username)
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]