Class: Sys::Admin::User

Inherits:
Object
  • Object
show all
Defined in:
lib/sys/admin/common.rb

Overview

The User class encapsulates the information found in /etc/passwd.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize {|_self| ... } ⇒ User

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.

Yields:

  • (_self)

Yield Parameters:



94
95
96
# File 'lib/sys/admin/common.rb', line 94

def initialize
  yield self if block_given?
end

Instance Attribute Details

#access_classObject

The user’s access class.



72
73
74
# File 'lib/sys/admin/common.rb', line 72

def access_class
  @access_class
end

#ageObject

Used in the past for password aging. Deprecated by /etc/shadow.



78
79
80
# File 'lib/sys/admin/common.rb', line 78

def age
  @age
end

#changeObject

Next date a password change will be needed.



51
52
53
# File 'lib/sys/admin/common.rb', line 51

def change
  @change
end

#commentObject

Another comment field.



75
76
77
# File 'lib/sys/admin/common.rb', line 75

def comment
  @comment
end

#dirObject

The absolute path name of the user’s home directory.



60
61
62
# File 'lib/sys/admin/common.rb', line 60

def dir
  @dir
end

#expireObject

The account’s expiration date



66
67
68
# File 'lib/sys/admin/common.rb', line 66

def expire
  @expire
end

#fieldsObject

TODO: Forgot what this is.



69
70
71
# File 'lib/sys/admin/common.rb', line 69

def fields
  @fields
end

#gecosObject

A comment field. Rarely used now.



54
55
56
# File 'lib/sys/admin/common.rb', line 54

def gecos
  @gecos
end

#gidObject

The user’s group ID.



48
49
50
# File 'lib/sys/admin/common.rb', line 48

def gid
  @gid
end

#login_deviceObject

The name of the terminal device the user last logged on with.



87
88
89
# File 'lib/sys/admin/common.rb', line 87

def 
  @login_device
end

#login_hostObject

The host name from which the user last logged in.



84
85
86
# File 'lib/sys/admin/common.rb', line 84

def 
  @login_host
end

#login_timeObject

The last time the user logged in.



81
82
83
# File 'lib/sys/admin/common.rb', line 81

def 
  @login_time
end

#nameObject

The user name associated with the account.



39
40
41
# File 'lib/sys/admin/common.rb', line 39

def name
  @name
end

#passwdObject

The user’s encrypted password. Deprecated by /etc/shadow.



42
43
44
# File 'lib/sys/admin/common.rb', line 42

def passwd
  @passwd
end

#quotaObject

The user’s alloted amount of disk space.



57
58
59
# File 'lib/sys/admin/common.rb', line 57

def quota
  @quota
end

#shellObject

The user’s login shell.



63
64
65
# File 'lib/sys/admin/common.rb', line 63

def shell
  @shell
end

#uidObject

The user’s user ID.



45
46
47
# File 'lib/sys/admin/common.rb', line 45

def uid
  @uid
end

Instance Method Details

#groupsObject

An array of groups to which the user belongs.



99
100
101
102
103
104
105
106
107
# File 'lib/sys/admin/common.rb', line 99

def groups
  array = []

  Sys::Admin.groups.each{ |grp|
    array << grp.name if grp.members.include?(self.name)
  }

  array
end