summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-10-03 23:33:57 +0000
committerdrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-10-03 23:33:57 +0000
commit14f878aed60a62b24535983c136a8eb5e59030b8 (patch)
tree25e1917b415cf9fbdef5ada067c9a5fe2c3f2f38
parent6be866e2621c543b710da3ece25d32ce861ece02 (diff)
* 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
-rw-r--r--ChangeLog5
-rw-r--r--ext/etc/etc.c26
2 files changed, 27 insertions, 4 deletions
diff --git a/ChangeLog b/ChangeLog
index a557a57..43faeb8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Tue Oct 4 08:33:41 2011 Eric Hodel <drbrain@segment7.net>
+
+ * 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@segment7.net>
* lib/shellwords.rb: Update toplevel comment with an example. Patch
diff --git a/ext/etc/etc.c b/ext/etc/etc.c
index 2bd2e30..f8dc368 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 <meta@pobox.com>.
+ * 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)