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:



97
98
99
# File 'lib/sys/admin/common.rb', line 97

def initialize
  yield self if block_given?
end

Instance Attribute Details

#access_classObject

The user’s access class.



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

def access_class
  @access_class
end

#ageObject

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



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

def age
  @age
end

#changeObject

Next date a password change will be needed.



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

def change
  @change
end

#commentObject

Another comment field.



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

def comment
  @comment
end

#dirObject

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



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

def dir
  @dir
end

#expireObject

The account’s expiration date



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

def expire
  @expire
end

#fieldsObject

TODO: Forgot what this is.



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

def fields
  @fields
end

#gecosObject

A comment field. Rarely used now.



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

def gecos
  @gecos
end

#gidObject

The user’s group ID.



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

def gid
  @gid
end

#login_deviceObject

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



90
91
92
# File 'lib/sys/admin/common.rb', line 90

def 
  @login_device
end

#login_hostObject

The host name from which the user last logged in.



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

def 
  @login_host
end

#login_timeObject

The last time the user logged in.



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

def 
  @login_time
end

#nameObject

The user name associated with the account.



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

def name
  @name
end

#passwdObject

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



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

def passwd
  @passwd
end

#quotaObject

The user’s alloted amount of disk space.



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

def quota
  @quota
end

#shellObject

The user’s login shell.



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

def shell
  @shell
end

#uidObject

The user’s user ID.



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

def uid
  @uid
end

Instance Method Details

#groupsObject

An array of groups to which the user belongs.



102
103
104
105
106
107
108
109
110
# File 'lib/sys/admin/common.rb', line 102

def groups
  array = []

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

  array
end