summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
Diffstat (limited to 'ext')
-rw-r--r--ext/etc/etc.c26
1 files changed, 22 insertions, 4 deletions
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 <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)