ruby-changes:21344
From: drbrain <ko1@a...>
Date: Tue, 4 Oct 2011 08:34:08 +0900 (JST)
Subject: [ruby-changes:21344] drbrain:r33393 (trunk): * ext/etc/etc.c: Document Etc, Etc.sysconfdir, Etc.systmpdir. Patch
drbrain 2011-10-04 08:33:57 +0900 (Tue, 04 Oct 2011) New Revision: 33393 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=33393 Log: * ext/etc/etc.c: Document Etc, Etc.sysconfdir, Etc.systmpdir. Patch by mathew murphy. [Ruby 1.9 - Bug #5396] Modified files: trunk/ChangeLog trunk/ext/etc/etc.c Index: ChangeLog =================================================================== --- ChangeLog (revision 33392) +++ ChangeLog (revision 33393) @@ -1,3 +1,8 @@ +Tue Oct 4 08:33:41 2011 Eric Hodel <drbrain@s...> + + * ext/etc/etc.c: Document Etc, Etc.sysconfdir, Etc.systmpdir. Patch + by mathew murphy. [Ruby 1.9 - Bug #5396] + Tue Oct 4 08:21:51 2011 Eric Hodel <drbrain@s...> * lib/shellwords.rb: Update toplevel comment with an example. Patch Index: ext/etc/etc.c =================================================================== --- ext/etc/etc.c (revision 33392) +++ ext/etc/etc.c (revision 33393) @@ -566,7 +566,9 @@ #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 @@ } /* - * Returns system temporary directory. + * Returns system temporary directory; typically "/tmp". */ static VALUE etc_systmpdir(void) @@ -598,9 +600,25 @@ } /* - * 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 <meta@p...>. + * 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) -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/