Created
August 23, 2012 08:35
-
-
Save michaelcarruthers/3434314 to your computer and use it in GitHub Desktop.
Agent
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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