Skip to content

Instantly share code, notes, and snippets.

@michaelcarruthers
Created August 23, 2012 08:35
Show Gist options
  • Save michaelcarruthers/3434314 to your computer and use it in GitHub Desktop.
Save michaelcarruthers/3434314 to your computer and use it in GitHub Desktop.
Agent
action "info" do
validate :user, String
user = request[:user]
reply[:user] = user_info(user)
end
private
require 'etc'
def user_info(req_user)
users = ""
Etc.passwd do |user|
next unless user.name == req_user
user_uid = uid_name(user.uid)
user_gid = gid_name(user.gid)
users = "#{user_uid} #{user_gid}"
end
users
end
def uid_name(uid)
Etc.getpwuid(uid).name
end
def gid_name(gid)
Etc.getgrgid(gid).name
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment