Module: NexusSW::LXD::Transport::Mixins::Helpers::UsersMixin
Instance Attribute Summary collapse
-
#file_mode ⇒ Object
Returns the value of attribute file_mode.
-
#gid ⇒ Object
Returns the value of attribute gid.
-
#uid ⇒ Object
readonly
Returns the value of attribute uid.
-
#username ⇒ Object
readonly
Returns the value of attribute username.
Instance Method Summary collapse
Instance Attribute Details
#file_mode ⇒ Object
Returns the value of attribute file_mode.
21 22 23 |
# File 'lib/nexussw/lxd/transport/mixins/helpers/users.rb', line 21 def file_mode @file_mode end |
#gid ⇒ Object
Returns the value of attribute gid.
21 22 23 |
# File 'lib/nexussw/lxd/transport/mixins/helpers/users.rb', line 21 def gid @gid end |
#uid ⇒ Object (readonly)
Returns the value of attribute uid.
22 23 24 |
# File 'lib/nexussw/lxd/transport/mixins/helpers/users.rb', line 22 def uid @uid end |
#username ⇒ Object (readonly)
Returns the value of attribute username.
22 23 24 |
# File 'lib/nexussw/lxd/transport/mixins/helpers/users.rb', line 22 def username @username end |
Instance Method Details
#user(user_nameorid, options = {}) ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/nexussw/lxd/transport/mixins/helpers/users.rb', line 9 def user(user_nameorid, = {}) passwd = read_file [:passwd_file] || '/etc/passwd' # rework into .split(':') if this gets more complicated @uid = user_nameorid.is_a?(String) ? passwd[/^#{user_nameorid}:[^:]*:([^:]*):/, 1] : user_nameorid @username = user_nameorid.is_a?(String) ? user_nameorid : passwd[/^([^:]*):[^:]*:#{user_nameorid}:/, 1] # gotcha: we're always setting the default group here, but it's changeable by the user, afterwards # so if `user` gets called again, and the caller wants an alternative gid, the caller will need to re-set the gid @gid = passwd[/^[^:]*:[^:]*:#{uid}:([^:]*):/, 1] end |