From 14f878aed60a62b24535983c136a8eb5e59030b8 Mon Sep 17 00:00:00 2001 From: drbrain Date: Mon, 3 Oct 2011 23:33:57 +0000 Subject: * ext/etc/etc.c: Document Etc, Etc.sysconfdir, Etc.systmpdir. Patch by mathew murphy. [Ruby 1.9 - Bug #5396] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@33393 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ext/etc/etc.c | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) (limited to 'ext/etc/etc.c') diff --git a/ext/etc/etc.c b/ext/etc/etc.c index 2bd2e30747..f8dc368d35 100644 --- a/ext/etc/etc.c +++ b/ext/etc/etc.c @@ -566,7 +566,9 @@ VALUE rb_w32_conv_from_wchar(const WCHAR *wstr, rb_encoding *enc); #endif /* - * Returns system configuration directory. + * Returns system configuration directory. This is typically "/etc", but + * is modified by the prefix used when Ruby was compiled. For example, + * if Ruby is built and installed in /usr/local, returns "/usr/local/etc". */ static VALUE etc_sysconfdir(VALUE obj) @@ -579,7 +581,7 @@ etc_sysconfdir(VALUE obj) } /* - * Returns system temporary directory. + * Returns system temporary directory; typically "/tmp". */ static VALUE etc_systmpdir(void) @@ -598,9 +600,25 @@ etc_systmpdir(void) } /* - * The etc module provides access to information from the running OS. + * The Etc module provides access to information typically stored in + * files in the /etc directory on Unix systems. * - * Documented by mathew . + * The information accessible consists of the information found in the + * /etc/passwd and /etc/group files, plus information about the system's + * temporary directory (/tmp) and configuration directory (/etc). + * + * The Etc module provides a more reliable way to access information about + * the logged in user than environment variables such as $USER. For example: + * + * require 'etc' + * + * login = Etc.getlogin + * info = Etc.getpwnam(login) + * username = info.gecos.split(/,/).first + * puts "Hello #{username}, I see your login name is #{login}" + * + * Note that the methods provided by this module are not always secure. + * It should be used for informational purposes, and not for security. */ void Init_etc(void) -- cgit v1.2.3