Class: Sys::User
- Inherits:
-
Object
- Object
- Sys::User
- Defined in:
- ext/sys/admin.c
Instance Attribute Summary collapse
-
#access_class ⇒ Object
The user’s access class.
-
#age ⇒ Object
Used in the past for password aging.
-
#change ⇒ Object
Next date a password change will be needed.
-
#comment ⇒ Object
Another comment field.
-
#dir ⇒ Object
The absolute pathname of the user’s home directory.
-
#expire ⇒ Object
Account expiration date.
-
#gecos ⇒ Object
A comment field.
-
#gid ⇒ Object
The user’s primary group ID.
-
#login_device ⇒ Object
readonly
The name of the terminal device the user last logged on with.
-
#login_host ⇒ Object
readonly
The hostname from which the user last logged in.
-
#login_time ⇒ Object
readonly
The last time the user logged in.
-
#name ⇒ Object
The user name associated with the account.
-
#passwd ⇒ Object
The user’s encrypted password.
-
#quota ⇒ Object
The user’s alloted amount of disk space.
-
#shell ⇒ Object
The user’s login shell.
-
#uid ⇒ Object
The user’s user ID.
Instance Method Summary collapse
-
#groups ⇒ Object
Returns an array of groups the user belongs to.
-
#initialize ⇒ Object
constructor
Creates and returns a User object, which encapsulates the information typically found within an /etc/passwd entry, i.e.
Constructor Details
#new ⇒ Object #new {|user| ... } ⇒ Object
Creates and returns a User object, which encapsulates the information typically found within an /etc/passwd entry, i.e. a struct passwd.
If a block is provided, yields the object back to the block.
24 25 26 27 28 29 |
# File 'ext/sys/admin.c', line 24 static VALUE user_init(VALUE self){ if(rb_block_given_p()) rb_yield(self); return self; } |
Instance Attribute Details
#access_class ⇒ Object
The user’s access class
#age ⇒ Object
Used in the past for password aging. Deprecated in favor of /etc/shadow
#change ⇒ Object
Next date a password change will be needed
#comment ⇒ Object
Another comment field. Rarely used.
#dir ⇒ Object
The absolute pathname of the user’s home directory
#expire ⇒ Object
Account expiration date
#gecos ⇒ Object
A comment field. Rarely used.
#gid ⇒ Object
The user’s primary group ID
#login_device ⇒ Object (readonly)
The name of the terminal device the user last logged on with
#login_host ⇒ Object (readonly)
The hostname from which the user last logged in
#login_time ⇒ Object (readonly)
The last time the user logged in
#name ⇒ Object
The user name associated with the account
#passwd ⇒ Object
The user’s encrypted password. Deprecated in favor of /etc/shadow
#quota ⇒ Object
The user’s alloted amount of disk space
#shell ⇒ Object
The user’s login shell
#uid ⇒ Object
The user’s user ID
Instance Method Details
#groups ⇒ Object
Returns an array of groups the user belongs to.
291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 |
# File 'ext/sys/admin.c', line 291 static VALUE user_groups(VALUE self){ VALUE v_groups, v_group, v_users, v_group_name, v_name, v_result; int i; v_name = rb_funcall(self, rb_intern("name"), 0, 0); v_result = rb_ary_new(); v_groups = admin_groups(self); /* Iterate over each group, checking its members. If the members includes * the user name, we have a match. */ if(!NIL_P(v_groups)){ for(i = 0; i < RARRAY_LEN(v_groups); i++){ v_group = RARRAY_PTR(v_groups)[i]; v_users = rb_funcall(v_group, rb_intern("members"), 0, 0); if(RTEST(rb_funcall(v_users, rb_intern("include?"), 1, v_name))){ v_group_name = rb_funcall(v_group, rb_intern("name"), 0, 0); rb_ary_push(v_result, v_group_name); } } } return v_result; } |