[system-tools-backends-clone] Return new user struct when creating user



commit f61fd89844316c9569427b2f0f09d71d3ff1ce07
Author: Milan Bouchet-Valat <nalimilan club fr>
Date:   Mon Jan 11 16:50:38 2010 +0100

    Return new user struct when creating user
    
    Clients need to know what values were chosen for fields left blank. This also allows us to return NULL in case of failure, which provides error checking.

 UserConfig.pm  |    4 ++--
 Users/Users.pm |    4 ++++
 2 files changed, 6 insertions(+), 2 deletions(-)
---
diff --git a/UserConfig.pm b/UserConfig.pm
index 0a4b7de..a50f10e 100644
--- a/UserConfig.pm
+++ b/UserConfig.pm
@@ -48,7 +48,7 @@ sub new
 
 dbus_method ("get", [ "string" ], [ $USER_FORMAT ]);
 dbus_method ("set", [ $USER_FORMAT ], []);
-dbus_method ("add", [ $USER_FORMAT ], []);
+dbus_method ("add", [ $USER_FORMAT ], [ $USER_FORMAT ]);
 dbus_method ("del", [ $USER_FORMAT ], []);
 
 sub get
@@ -69,7 +69,7 @@ sub add
 {
   my ($self, @config) = @_;
 
-  Users::Users::add_user (@config);
+  return Users::Users::add_user (@config);
 }
 
 sub del
diff --git a/Users/Users.pm b/Users/Users.pm
index f924d83..ff5726c 100644
--- a/Users/Users.pm
+++ b/Users/Users.pm
@@ -625,6 +625,10 @@ sub add_user
 
   &change_user_chfn ($$user[$LOGIN], undef, $$user[$COMMENT]);
   &set_passwd ($$user[$LOGIN], $$user[$PASSWD]);
+
+  # Return the new user with default values filled.
+  # Returns NULL if user doesn't exist, which means failure.
+  return &get_user ($$user[$LOGIN]);
 }
 
 sub change_user



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