Skip to content

Commit

Permalink
Use Etc.getpwuid() instead of ENV['USER'] for identifying the user.
Browse files Browse the repository at this point in the history
  • Loading branch information
clonezone committed Mar 13, 2014
1 parent 8708f4b commit 6c7ada1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
8 changes: 7 additions & 1 deletion Changes
@@ -1,10 +1,16 @@
v1.15.1.beta.2 - 2014/3/13

Miscellaneous:

- Use a different workaround for utmp files: getpwuid(3).

v1.15.1.beta.1 - 2014/3/5

Miscellaneous:

- Work around broken utmp files by looking at the LOGNAME and USER
environment variables to get the current user before falling back on
getlogin().
getlogin(3).

v1.15.0 - 2014/2/24

Expand Down
7 changes: 5 additions & 2 deletions lib/fig/repository_package_publisher.rb
Expand Up @@ -92,8 +92,11 @@ def derive_publish_metadata()
end

def derive_login()
return ENV['LOGNAME'] if ENV['LOGNAME']
return ENV['USER'] if ENV['USER']
# Etc.getpwuid() returns nil on Windows, but Etc.getlogin() will return the
# wrong result on some systems if you su(1) to a different user.
if password_entry = Etc.getpwuid() and password_entry.name
return password_entry.name
end

return Etc.getlogin()
end
Expand Down

0 comments on commit 6c7ada1

Please sign in to comment.