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

[Freeipa-devel] [PATCH] Improve error messages



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Jenny found several cases where our error messages were not very
descriptive. This patch adds a ERROR() call for those cases.

The error message for adding a user with existing UID and name is the
same, since the error code from sysdb is EEXIST in both cases..I hope
this is OK.

Also fixes one typo where useradd would say it cannot "modify user"
instead of "add user".

Jakub

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
Comment: Using GnuPG with Fedora - http://enigmail.mozdev.org/

iEYEARECAAYFAkpu9d8ACgkQHsardTLnvCV1fgCdFJLJ/oOvtpwrOn+Qv9Dkf0Uf
LAwAoIjHB/KlgR4tAvN8QvOeAZkIHQWs
=n3Jt
-----END PGP SIGNATURE-----
>From 2964e61f5ee3a2770bbd322dfb387e66e4e7cb6b Mon Sep 17 00:00:00 2001
From: Jakub Hrozek <jhrozek redhat com>
Date: Tue, 28 Jul 2009 14:02:01 +0200
Subject: [PATCH] Improve error messages

Fixes:
* RHBZ 513282 - Error Message Incorrect when Trying to add Group with GID
already in use
* RHBZ 513284 -  Error Message Incorrect when Trying to add User with
UID already in use
* RHBZ 513242 - Better error Message when modifying a user that doesn't exist
* RHBZ 513244 - Better error Message when adding a user to a group that doesn't
exist
---
 server/tools/sss_groupadd.c |    2 +-
 server/tools/sss_groupmod.c |   15 ++++++++++++++-
 server/tools/sss_useradd.c  |    4 ++--
 server/tools/sss_usermod.c  |   16 +++++++++++++++-
 4 files changed, 32 insertions(+), 5 deletions(-)

diff --git a/server/tools/sss_groupadd.c b/server/tools/sss_groupadd.c
index e9c81b8..b799408 100644
--- a/server/tools/sss_groupadd.c
+++ b/server/tools/sss_groupadd.c
@@ -255,7 +255,7 @@ int main(int argc, const char **argv)
         ret = data->error;
         switch (ret) {
             case EEXIST:
-                ERROR("The group %s already exists\n", data->name);
+                ERROR("A group with the same name or UID already exists\n");
                 break;
 
             default:
diff --git a/server/tools/sss_groupmod.c b/server/tools/sss_groupmod.c
index 2fc6f9d..d91e377 100644
--- a/server/tools/sss_groupmod.c
+++ b/server/tools/sss_groupmod.c
@@ -448,7 +448,20 @@ int main(int argc, const char **argv)
     if (data->error) {
         ret = data->error;
         DEBUG(1, ("sysdb operation failed (%d)[%s]\n", ret, strerror(ret)));
-        ERROR("Transaction error. Could not modify group.\n");
+        switch (ret) {
+            case ENOENT:
+                ERROR("Could not modify group - check if member group names are correct\n");
+                break;
+
+            case EFAULT:
+                ERROR("Could not modify group - check if groupname is correct\n");
+                break;
+
+            default:
+                ERROR("Transaction error. Could not modify group.\n");
+                break;
+        }
+
         ret = EXIT_FAILURE;
         goto fini;
     }
diff --git a/server/tools/sss_useradd.c b/server/tools/sss_useradd.c
index 2880182..b284179 100644
--- a/server/tools/sss_useradd.c
+++ b/server/tools/sss_useradd.c
@@ -516,13 +516,13 @@ int main(int argc, const char **argv)
         ret = data->error;
         switch (ret) {
             case EEXIST:
-                ERROR("The user %s already exists\n", data->name);
+                ERROR("A user with the same name or UID already exists\n");
                 break;
 
             default:
                 DEBUG(1, ("sysdb operation failed (%d)[%s]\n",
                           ret, strerror(ret)));
-                ERROR("Transaction error. Could not modify user.\n");
+                ERROR("Transaction error. Could not add user.\n");
                 break;
         }
         ret = EXIT_FAILURE;
diff --git a/server/tools/sss_usermod.c b/server/tools/sss_usermod.c
index 6ef873b..65e9497 100644
--- a/server/tools/sss_usermod.c
+++ b/server/tools/sss_usermod.c
@@ -580,8 +580,22 @@ int main(int argc, const char **argv)
 
     if (data->error) {
         ret = data->error;
+
         DEBUG(1, ("sysdb operation failed (%d)[%s]\n", ret, strerror(ret)));
-        ERROR("Transaction error. Could not modify user.\n");
+        switch (ret) {
+            case ENOENT:
+                ERROR("Could not modify user - check if group names are correct\n");
+                break;
+
+            case EFAULT:
+                ERROR("Could not modify user - check if username is correct\n");
+                break;
+
+            default:
+                ERROR("Transaction error. Could not modify user.\n");
+                break;
+        }
+
         ret = EXIT_FAILURE;
         goto fini;
     }
-- 
1.6.2.5



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