From: Alexis Laferrière Date: Fri, 1 Aug 2014 23:19:08 +0000 (-0400) Subject: lib: intro `user_exists` and `group_exists` X-Git-Tag: v0.6.8~14^2~2 X-Git-Url: http://nitlanguage.org lib: intro `user_exists` and `group_exists` Signed-off-by: Alexis Laferrière --- diff --git a/lib/privileges.nit b/lib/privileges.nit index e3e1220..d91a9a6 100644 --- a/lib/privileges.nit +++ b/lib/privileges.nit @@ -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