lib: intro `user_exists` and `group_exists`
authorAlexis Laferrière <alexis.laf@xymus.net>
Fri, 1 Aug 2014 23:19:08 +0000 (19:19 -0400)
committerAlexis Laferrière <alexis.laf@xymus.net>
Tue, 19 Aug 2014 13:58:50 +0000 (09:58 -0400)
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

lib/privileges.nit

index e3e1220..d91a9a6 100644 (file)
@@ -22,6 +22,22 @@ module privileges
 
 import opts
 
+redef class Text
+       # Does the operating system know the user named `self`?
+       fun user_exists: Bool
+       do
+               var passwd = new Passwd.from_name(to_s)
+               return not passwd.address_is_null
+       end
+
+       # Does the operating system know the group named `self`?
+       fun group_exists: Bool
+       do
+               var passwd = new Group.from_name(to_s)
+               return not passwd.address_is_null
+       end
+end
+
 # Class to manage user groups
 class UserGroup