lib/bsd/sys/admin.rb in sys-admin-1.7.5 vs lib/bsd/sys/admin.rb in sys-admin-1.7.6

- old
+ new

@@ -4,14 +4,13 @@ # The BSD specific code. module Sys class Admin - private - # :no-doc: BUF_MAX = 65536 # Max buffer for retry + private_constant :BUF_MAX # I'm making some aliases here to prevent potential conflicts attach_function :open_c, :open, [:string, :int], :int attach_function :pread_c, :pread, [:int, :pointer, :size_t, :off_t], :size_t attach_function :close_c, :close, [:int], :int @@ -20,12 +19,11 @@ attach_function :getpwnam_r, [:string, :pointer, :pointer, :size_t, :pointer], :int attach_function :getpwuid_r, [:long, :pointer, :pointer, :size_t, :pointer], :int attach_function :getgrnam_r, [:string, :pointer, :pointer, :size_t, :pointer], :int attach_function :getgrgid_r, [:long, :pointer, :pointer, :size_t, :pointer], :int - private_class_method :getlogin_r, :getpwnam_r, :getpwuid_r, :getgrnam_r - private_class_method :getgrgid_r + private_class_method :getlogin_r, :getpwnam_r, :getpwuid_r, :getgrnam_r, :getgrgid_r private_class_method :open_c, :pread_c, :close_c # struct passwd from /usr/include/pwd.h class PasswdStruct < FFI::Struct fields = [ @@ -46,30 +44,34 @@ end layout(*fields) end + private_constant :PasswdStruct + # struct group from /usr/include/grp.h class GroupStruct < FFI::Struct layout( :gr_name, :string, :gr_passwd, :string, :gr_gid, :uint, :gr_mem, :pointer ) end + private_constant :GroupStruct + # I'm blending the timeval struct in directly here class LastlogStruct < FFI::Struct layout( :ll_time, :int32, :ll_line, [:char, 32], :ll_host, [:char, 256] ) end - public + private_constant :LastlogStruct # Returns the login for the current process. # def self.get_login buf = FFI::MemoryPointer.new(:char, 256) @@ -190,22 +192,22 @@ end groups end - private - # Takes a GroupStruct and converts it to a Group object. def self.get_group_from_struct(grp) Group.new do |g| g.name = grp[:gr_name] g.passwd = grp[:gr_passwd] g.gid = grp[:gr_gid] g.members = grp[:gr_mem].read_array_of_string end end + private_class_method :get_group_from_struct + # Takes a UserStruct and converts it to a User object. def self.get_user_from_struct(pwd) user = User.new do |u| u.name = pwd[:pw_name] u.passwd = pwd[:pw_passwd] @@ -228,10 +230,12 @@ end user end + private_class_method :get_user_from_struct + # Get lastlog information for the given user. def self.get_lastlog_info(uid) logfile = '/var/log/lastlog' lastlog = LastlogStruct.new @@ -250,7 +254,9 @@ close_c(fd) if fd && fd >= 0 end lastlog end + + private_class_method :get_lastlog_info end end