1998-01-16 07:13:05 -05:00
|
|
|
/************************************************
|
|
|
|
|
|
|
|
etc.c -
|
|
|
|
|
|
|
|
$Author$
|
|
|
|
created at: Tue Mar 22 18:39:19 JST 1994
|
|
|
|
|
|
|
|
************************************************/
|
|
|
|
|
|
|
|
#include "ruby.h"
|
2010-05-07 23:25:17 -04:00
|
|
|
#include "ruby/encoding.h"
|
2014-05-17 21:48:47 -04:00
|
|
|
#include "ruby/io.h"
|
1998-01-16 07:13:05 -05:00
|
|
|
|
2000-05-12 05:07:57 -04:00
|
|
|
#include <sys/types.h>
|
|
|
|
#ifdef HAVE_UNISTD_H
|
|
|
|
#include <unistd.h>
|
|
|
|
#endif
|
|
|
|
|
1998-01-16 07:13:05 -05:00
|
|
|
#ifdef HAVE_GETPWENT
|
|
|
|
#include <pwd.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_GETGRENT
|
|
|
|
#include <grp.h>
|
|
|
|
#endif
|
|
|
|
|
2014-05-17 21:48:47 -04:00
|
|
|
#include <errno.h>
|
|
|
|
|
2014-05-17 20:58:34 -04:00
|
|
|
#ifdef HAVE_SYS_UTSNAME_H
|
|
|
|
#include <sys/utsname.h>
|
|
|
|
#endif
|
|
|
|
|
2014-10-15 05:41:25 -04:00
|
|
|
#ifdef HAVE_SCHED_GETAFFINITY
|
|
|
|
#include <sched.h>
|
|
|
|
#endif
|
|
|
|
|
2008-10-26 05:07:37 -04:00
|
|
|
static VALUE sPasswd;
|
|
|
|
#ifdef HAVE_GETGRENT
|
|
|
|
static VALUE sGroup;
|
|
|
|
#endif
|
1998-01-16 07:13:05 -05:00
|
|
|
|
2010-05-07 23:25:17 -04:00
|
|
|
#ifdef _WIN32
|
|
|
|
#include <shlobj.h>
|
|
|
|
#ifndef CSIDL_COMMON_APPDATA
|
|
|
|
#define CSIDL_COMMON_APPDATA 35
|
|
|
|
#endif
|
2014-05-19 03:54:25 -04:00
|
|
|
#define HAVE_UNAME 1
|
2010-05-07 23:25:17 -04:00
|
|
|
#endif
|
|
|
|
|
2003-07-31 10:03:34 -04:00
|
|
|
#ifndef _WIN32
|
|
|
|
char *getenv();
|
|
|
|
#endif
|
2002-05-29 01:20:39 -04:00
|
|
|
char *getlogin();
|
|
|
|
|
2021-10-19 07:51:17 -04:00
|
|
|
#define RUBY_ETC_VERSION "1.3.0"
|
2019-07-09 23:33:29 -04:00
|
|
|
|
2020-04-01 02:18:00 -04:00
|
|
|
#ifdef HAVE_RB_DEPRECATE_CONSTANT
|
|
|
|
void rb_deprecate_constant(VALUE mod, const char *name);
|
|
|
|
#else
|
|
|
|
# define rb_deprecate_constant(mod,name) ((void)(mod),(void)(name))
|
|
|
|
#endif
|
|
|
|
|
2014-05-17 21:48:47 -04:00
|
|
|
#include "constdefs.h"
|
|
|
|
|
2020-12-23 02:30:16 -05:00
|
|
|
#ifdef HAVE_RUBY_ATOMIC_H
|
|
|
|
# include "ruby/atomic.h"
|
2020-12-21 23:31:11 -05:00
|
|
|
#else
|
2020-12-23 02:30:16 -05:00
|
|
|
typedef int rb_atomic_t;
|
|
|
|
# define RUBY_ATOMIC_CAS(var, oldval, newval) \
|
|
|
|
((var) == (oldval) ? ((var) = (newval), (oldval)) : (var))
|
2021-01-10 21:31:52 -05:00
|
|
|
# define RUBY_ATOMIC_EXCHANGE(var, newval) \
|
|
|
|
atomic_exchange(&var, newval)
|
|
|
|
static inline rb_atomic_t
|
|
|
|
atomic_exchange(volatile rb_atomic_t *var, rb_atomic_t newval)
|
|
|
|
{
|
|
|
|
rb_atomic_t oldval = *var;
|
|
|
|
*var = newval;
|
|
|
|
return oldval;
|
|
|
|
}
|
2020-12-21 23:31:11 -05:00
|
|
|
#endif
|
2020-12-22 00:02:45 -05:00
|
|
|
|
2012-12-07 02:08:06 -05:00
|
|
|
/* call-seq:
|
|
|
|
* getlogin -> String
|
|
|
|
*
|
|
|
|
* Returns the short user name of the currently logged in user.
|
|
|
|
* Unfortunately, it is often rather easy to fool ::getlogin.
|
|
|
|
*
|
|
|
|
* Avoid ::getlogin for security-related purposes.
|
|
|
|
*
|
|
|
|
* If ::getlogin fails, try ::getpwuid.
|
|
|
|
*
|
|
|
|
* See the unix manpage for <code>getpwuid(3)</code> for more detail.
|
2005-11-01 08:04:35 -05:00
|
|
|
*
|
|
|
|
* e.g.
|
|
|
|
* Etc.getlogin -> 'guest'
|
|
|
|
*/
|
1998-01-16 07:13:05 -05:00
|
|
|
static VALUE
|
2006-06-20 14:02:17 -04:00
|
|
|
etc_getlogin(VALUE obj)
|
1998-01-16 07:13:05 -05:00
|
|
|
{
|
|
|
|
char *login;
|
|
|
|
|
|
|
|
#ifdef HAVE_GETLOGIN
|
|
|
|
login = getlogin();
|
|
|
|
if (!login) login = getenv("USER");
|
|
|
|
#else
|
|
|
|
login = getenv("USER");
|
|
|
|
#endif
|
|
|
|
|
2014-11-10 03:24:36 -05:00
|
|
|
if (login) {
|
|
|
|
#ifdef _WIN32
|
|
|
|
rb_encoding *extenc = rb_utf8_encoding();
|
|
|
|
#else
|
|
|
|
rb_encoding *extenc = rb_locale_encoding();
|
|
|
|
#endif
|
|
|
|
return rb_external_str_new_with_enc(login, strlen(login), extenc);
|
|
|
|
}
|
|
|
|
|
1998-01-16 07:13:05 -05:00
|
|
|
return Qnil;
|
|
|
|
}
|
|
|
|
|
* gc.c (Init_stack): stack region is far smaller than usual if
pthread is used.
* marshal.c (w_extended): singleton methods should not be checked
when dumping via marshal_dump() or _dump(). [ruby-talk:85909]
* file.c (getcwdofdrv): avoid using getcwd() directly, use
my_getcwd() instead.
* merged NeXT, OpenStep, Rhapsody ports patch from Eric Sunshine
<sunshine@sunshineco.com>. [ruby-core:01596]
* marshal.c (w_object): LINK check earlier than anything else,
i.e. do not dump TYPE_IVAR for already dumped objects.
(ruby-bugs PR#1220)
* eval.c (rb_eval): call "inherited" only when a new class is
generated; not on reopening.
* eval.c (eval): prepend error position in evaluating string to
* configure.in: revived NextStep, OpenStep, and Rhapsody ports which
had become unbuildable; enhanced --enable-fat-binary option so that
it accepts a list of desired architectures (rather than assuming a
fixed list), or defaults to a platform-appropriate list if user does
not provide an explicit list; made the default list of architectures
for MAB (fat binary) more comprehensive; now uses -fno-common even
when building the interpreter (in addition to using it for
extensions), thus allowing the interpreter to be embedded into a
plugin module of an external project (in addition to allowing
embedding directly into an application); added checks for
<netinet/in_systm.h> (needed by `socket' extension) and getcwd(); now
ensures that -I/usr/local/include is employed when extensions'
extconf.rb scripts invoke have_header() since extension checks on
NextStep and OpenStep will fail without it if the desired resource
resides in the /usr/local tree; fixed formatting of --help message.
* Makefile.in: $(LIBRUBY_A) rule now deletes the archive before
invoking $(AR) since `ar' on Apple/NeXT can not "update" MAB archives
(see configure's --enable-fat-binary option); added rule for new
missing/getcwd.c.
* defines.h: fixed endian handling during MAB build (see configure's
--enable-fat-binary option) to ensure that all portions of the
project see the correct WORDS_BIGENDIAN value (some extension modules
were getting the wrong endian setting); added missing constants
GETPGRP_VOID, WNOHANG, WUNTRACED, X_OK, and type pid_t for NextStep
and OpenStep; removed unnecessary and problematic HAVE_SYS_WAIT_H
define in NeXT section.
* dir.c: do not allow NAMLEN() macro to trust dirent::d_namlen on
NextStep since, on some installations, this value always resolves
uselessly to zero.
* dln.c: added error reporting to NextStep extension loader since the
previous behavior of failing silently was not useful; now ensures
that NSLINKMODULE_OPTION_BINDNOW compatibility constant is defined
for OpenStep and Rhapsody; no longer includes <mach-o/dyld.h> twice
on Rhapsody since this header lacks multiple-include protection,
which resulted in "redefinition" compilation errors.
* main.c: also create hard reference to objc_msgSend() on NeXT
platforms (in addition to Apple platforms).
* lib/mkmf.rb: now exports XCFLAGS from configure script to extension
makefiles so that extensions can be built MAB (see configure's
--enable-fat-binary option); also utilize XCFLAGS in cc_command()
(but not cpp_command() because MAB flags are incompatible with
direct invocation of `cpp').
* ext/curses/extconf.rb: now additionally checks for presence of these
curses functions which are not present on NextStep or Openstep:
bkgd(), bkgdset(), color(), curs(), getbkgd(), init(), scrl(), set(),
setscrreg(), wattroff(), wattron(), wattrset(), wbkgd(), wbkgdset(),
wscrl(), wsetscrreg()
* ext/curses/curses.c: added appropriate #ifdef's for additional set of
curses functions now checked by extconf.rb; fixed curses_bkgd() and
window_bkgd() to correctly return boolean result rather than numeric
result; fixed window_getbkgd() to correctly signal an error by
returning nil rather than -1.
* ext/etc/etc.c: setup_passwd() and setup_group() now check for null
pointers before invoking rb_tainted_str_new2() upon fields extracted
from `struct passwd' and `struct group' since null pointers in some
fields are common on NextStep/OpenStep (especially so for the
`pw_comment' field) and rb_tainted_str_new2() throws an exception
when it receives a null pointer.
* ext/pty/pty.c: include "util.h" for strdup()/ruby_strdup() for
platforms such as NextStep and OpenStep which lack strdup().
* ext/socket/getaddrinfo.c: cast first argument of getservbyname(),
gethostbyaddr(), and gethostbyname() from (const char*) to non-const
(char*) for older platforms such as NextStep and OpenStep.
* ext/socket/socket.c: include "util.h" for strdup()/ruby_strdup() for
platforms such as NextStep and OpenStep which lack strdup(); include
<netinet/in_systm.h> if present for NextStep and OpenStep; cast first
argument of gethostbyaddr() and getservbyname() from (const char*) to
non-const (char*) for older platforms.
* ext/syslog/syslog.c: include "util.h" for strdup()/ruby_strdup() for
platforms such as NextStep and OpenStep which lack strdup().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5002 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-11-21 23:00:03 -05:00
|
|
|
#if defined(HAVE_GETPWENT) || defined(HAVE_GETGRENT)
|
|
|
|
static VALUE
|
2006-06-20 14:02:17 -04:00
|
|
|
safe_setup_str(const char *str)
|
* gc.c (Init_stack): stack region is far smaller than usual if
pthread is used.
* marshal.c (w_extended): singleton methods should not be checked
when dumping via marshal_dump() or _dump(). [ruby-talk:85909]
* file.c (getcwdofdrv): avoid using getcwd() directly, use
my_getcwd() instead.
* merged NeXT, OpenStep, Rhapsody ports patch from Eric Sunshine
<sunshine@sunshineco.com>. [ruby-core:01596]
* marshal.c (w_object): LINK check earlier than anything else,
i.e. do not dump TYPE_IVAR for already dumped objects.
(ruby-bugs PR#1220)
* eval.c (rb_eval): call "inherited" only when a new class is
generated; not on reopening.
* eval.c (eval): prepend error position in evaluating string to
* configure.in: revived NextStep, OpenStep, and Rhapsody ports which
had become unbuildable; enhanced --enable-fat-binary option so that
it accepts a list of desired architectures (rather than assuming a
fixed list), or defaults to a platform-appropriate list if user does
not provide an explicit list; made the default list of architectures
for MAB (fat binary) more comprehensive; now uses -fno-common even
when building the interpreter (in addition to using it for
extensions), thus allowing the interpreter to be embedded into a
plugin module of an external project (in addition to allowing
embedding directly into an application); added checks for
<netinet/in_systm.h> (needed by `socket' extension) and getcwd(); now
ensures that -I/usr/local/include is employed when extensions'
extconf.rb scripts invoke have_header() since extension checks on
NextStep and OpenStep will fail without it if the desired resource
resides in the /usr/local tree; fixed formatting of --help message.
* Makefile.in: $(LIBRUBY_A) rule now deletes the archive before
invoking $(AR) since `ar' on Apple/NeXT can not "update" MAB archives
(see configure's --enable-fat-binary option); added rule for new
missing/getcwd.c.
* defines.h: fixed endian handling during MAB build (see configure's
--enable-fat-binary option) to ensure that all portions of the
project see the correct WORDS_BIGENDIAN value (some extension modules
were getting the wrong endian setting); added missing constants
GETPGRP_VOID, WNOHANG, WUNTRACED, X_OK, and type pid_t for NextStep
and OpenStep; removed unnecessary and problematic HAVE_SYS_WAIT_H
define in NeXT section.
* dir.c: do not allow NAMLEN() macro to trust dirent::d_namlen on
NextStep since, on some installations, this value always resolves
uselessly to zero.
* dln.c: added error reporting to NextStep extension loader since the
previous behavior of failing silently was not useful; now ensures
that NSLINKMODULE_OPTION_BINDNOW compatibility constant is defined
for OpenStep and Rhapsody; no longer includes <mach-o/dyld.h> twice
on Rhapsody since this header lacks multiple-include protection,
which resulted in "redefinition" compilation errors.
* main.c: also create hard reference to objc_msgSend() on NeXT
platforms (in addition to Apple platforms).
* lib/mkmf.rb: now exports XCFLAGS from configure script to extension
makefiles so that extensions can be built MAB (see configure's
--enable-fat-binary option); also utilize XCFLAGS in cc_command()
(but not cpp_command() because MAB flags are incompatible with
direct invocation of `cpp').
* ext/curses/extconf.rb: now additionally checks for presence of these
curses functions which are not present on NextStep or Openstep:
bkgd(), bkgdset(), color(), curs(), getbkgd(), init(), scrl(), set(),
setscrreg(), wattroff(), wattron(), wattrset(), wbkgd(), wbkgdset(),
wscrl(), wsetscrreg()
* ext/curses/curses.c: added appropriate #ifdef's for additional set of
curses functions now checked by extconf.rb; fixed curses_bkgd() and
window_bkgd() to correctly return boolean result rather than numeric
result; fixed window_getbkgd() to correctly signal an error by
returning nil rather than -1.
* ext/etc/etc.c: setup_passwd() and setup_group() now check for null
pointers before invoking rb_tainted_str_new2() upon fields extracted
from `struct passwd' and `struct group' since null pointers in some
fields are common on NextStep/OpenStep (especially so for the
`pw_comment' field) and rb_tainted_str_new2() throws an exception
when it receives a null pointer.
* ext/pty/pty.c: include "util.h" for strdup()/ruby_strdup() for
platforms such as NextStep and OpenStep which lack strdup().
* ext/socket/getaddrinfo.c: cast first argument of getservbyname(),
gethostbyaddr(), and gethostbyname() from (const char*) to non-const
(char*) for older platforms such as NextStep and OpenStep.
* ext/socket/socket.c: include "util.h" for strdup()/ruby_strdup() for
platforms such as NextStep and OpenStep which lack strdup(); include
<netinet/in_systm.h> if present for NextStep and OpenStep; cast first
argument of gethostbyaddr() and getservbyname() from (const char*) to
non-const (char*) for older platforms.
* ext/syslog/syslog.c: include "util.h" for strdup()/ruby_strdup() for
platforms such as NextStep and OpenStep which lack strdup().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5002 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-11-21 23:00:03 -05:00
|
|
|
{
|
|
|
|
if (str == 0) str = "";
|
2019-10-18 15:10:03 -04:00
|
|
|
return rb_str_new2(str);
|
* gc.c (Init_stack): stack region is far smaller than usual if
pthread is used.
* marshal.c (w_extended): singleton methods should not be checked
when dumping via marshal_dump() or _dump(). [ruby-talk:85909]
* file.c (getcwdofdrv): avoid using getcwd() directly, use
my_getcwd() instead.
* merged NeXT, OpenStep, Rhapsody ports patch from Eric Sunshine
<sunshine@sunshineco.com>. [ruby-core:01596]
* marshal.c (w_object): LINK check earlier than anything else,
i.e. do not dump TYPE_IVAR for already dumped objects.
(ruby-bugs PR#1220)
* eval.c (rb_eval): call "inherited" only when a new class is
generated; not on reopening.
* eval.c (eval): prepend error position in evaluating string to
* configure.in: revived NextStep, OpenStep, and Rhapsody ports which
had become unbuildable; enhanced --enable-fat-binary option so that
it accepts a list of desired architectures (rather than assuming a
fixed list), or defaults to a platform-appropriate list if user does
not provide an explicit list; made the default list of architectures
for MAB (fat binary) more comprehensive; now uses -fno-common even
when building the interpreter (in addition to using it for
extensions), thus allowing the interpreter to be embedded into a
plugin module of an external project (in addition to allowing
embedding directly into an application); added checks for
<netinet/in_systm.h> (needed by `socket' extension) and getcwd(); now
ensures that -I/usr/local/include is employed when extensions'
extconf.rb scripts invoke have_header() since extension checks on
NextStep and OpenStep will fail without it if the desired resource
resides in the /usr/local tree; fixed formatting of --help message.
* Makefile.in: $(LIBRUBY_A) rule now deletes the archive before
invoking $(AR) since `ar' on Apple/NeXT can not "update" MAB archives
(see configure's --enable-fat-binary option); added rule for new
missing/getcwd.c.
* defines.h: fixed endian handling during MAB build (see configure's
--enable-fat-binary option) to ensure that all portions of the
project see the correct WORDS_BIGENDIAN value (some extension modules
were getting the wrong endian setting); added missing constants
GETPGRP_VOID, WNOHANG, WUNTRACED, X_OK, and type pid_t for NextStep
and OpenStep; removed unnecessary and problematic HAVE_SYS_WAIT_H
define in NeXT section.
* dir.c: do not allow NAMLEN() macro to trust dirent::d_namlen on
NextStep since, on some installations, this value always resolves
uselessly to zero.
* dln.c: added error reporting to NextStep extension loader since the
previous behavior of failing silently was not useful; now ensures
that NSLINKMODULE_OPTION_BINDNOW compatibility constant is defined
for OpenStep and Rhapsody; no longer includes <mach-o/dyld.h> twice
on Rhapsody since this header lacks multiple-include protection,
which resulted in "redefinition" compilation errors.
* main.c: also create hard reference to objc_msgSend() on NeXT
platforms (in addition to Apple platforms).
* lib/mkmf.rb: now exports XCFLAGS from configure script to extension
makefiles so that extensions can be built MAB (see configure's
--enable-fat-binary option); also utilize XCFLAGS in cc_command()
(but not cpp_command() because MAB flags are incompatible with
direct invocation of `cpp').
* ext/curses/extconf.rb: now additionally checks for presence of these
curses functions which are not present on NextStep or Openstep:
bkgd(), bkgdset(), color(), curs(), getbkgd(), init(), scrl(), set(),
setscrreg(), wattroff(), wattron(), wattrset(), wbkgd(), wbkgdset(),
wscrl(), wsetscrreg()
* ext/curses/curses.c: added appropriate #ifdef's for additional set of
curses functions now checked by extconf.rb; fixed curses_bkgd() and
window_bkgd() to correctly return boolean result rather than numeric
result; fixed window_getbkgd() to correctly signal an error by
returning nil rather than -1.
* ext/etc/etc.c: setup_passwd() and setup_group() now check for null
pointers before invoking rb_tainted_str_new2() upon fields extracted
from `struct passwd' and `struct group' since null pointers in some
fields are common on NextStep/OpenStep (especially so for the
`pw_comment' field) and rb_tainted_str_new2() throws an exception
when it receives a null pointer.
* ext/pty/pty.c: include "util.h" for strdup()/ruby_strdup() for
platforms such as NextStep and OpenStep which lack strdup().
* ext/socket/getaddrinfo.c: cast first argument of getservbyname(),
gethostbyaddr(), and gethostbyname() from (const char*) to non-const
(char*) for older platforms such as NextStep and OpenStep.
* ext/socket/socket.c: include "util.h" for strdup()/ruby_strdup() for
platforms such as NextStep and OpenStep which lack strdup(); include
<netinet/in_systm.h> if present for NextStep and OpenStep; cast first
argument of gethostbyaddr() and getservbyname() from (const char*) to
non-const (char*) for older platforms.
* ext/syslog/syslog.c: include "util.h" for strdup()/ruby_strdup() for
platforms such as NextStep and OpenStep which lack strdup().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5002 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-11-21 23:00:03 -05:00
|
|
|
}
|
2013-08-02 20:46:10 -04:00
|
|
|
|
|
|
|
static VALUE
|
|
|
|
safe_setup_locale_str(const char *str)
|
|
|
|
{
|
|
|
|
if (str == 0) str = "";
|
|
|
|
return rb_locale_str_new_cstr(str);
|
|
|
|
}
|
|
|
|
|
|
|
|
static VALUE
|
|
|
|
safe_setup_filesystem_str(const char *str)
|
|
|
|
{
|
|
|
|
if (str == 0) str = "";
|
|
|
|
return rb_filesystem_str_new_cstr(str);
|
|
|
|
}
|
* gc.c (Init_stack): stack region is far smaller than usual if
pthread is used.
* marshal.c (w_extended): singleton methods should not be checked
when dumping via marshal_dump() or _dump(). [ruby-talk:85909]
* file.c (getcwdofdrv): avoid using getcwd() directly, use
my_getcwd() instead.
* merged NeXT, OpenStep, Rhapsody ports patch from Eric Sunshine
<sunshine@sunshineco.com>. [ruby-core:01596]
* marshal.c (w_object): LINK check earlier than anything else,
i.e. do not dump TYPE_IVAR for already dumped objects.
(ruby-bugs PR#1220)
* eval.c (rb_eval): call "inherited" only when a new class is
generated; not on reopening.
* eval.c (eval): prepend error position in evaluating string to
* configure.in: revived NextStep, OpenStep, and Rhapsody ports which
had become unbuildable; enhanced --enable-fat-binary option so that
it accepts a list of desired architectures (rather than assuming a
fixed list), or defaults to a platform-appropriate list if user does
not provide an explicit list; made the default list of architectures
for MAB (fat binary) more comprehensive; now uses -fno-common even
when building the interpreter (in addition to using it for
extensions), thus allowing the interpreter to be embedded into a
plugin module of an external project (in addition to allowing
embedding directly into an application); added checks for
<netinet/in_systm.h> (needed by `socket' extension) and getcwd(); now
ensures that -I/usr/local/include is employed when extensions'
extconf.rb scripts invoke have_header() since extension checks on
NextStep and OpenStep will fail without it if the desired resource
resides in the /usr/local tree; fixed formatting of --help message.
* Makefile.in: $(LIBRUBY_A) rule now deletes the archive before
invoking $(AR) since `ar' on Apple/NeXT can not "update" MAB archives
(see configure's --enable-fat-binary option); added rule for new
missing/getcwd.c.
* defines.h: fixed endian handling during MAB build (see configure's
--enable-fat-binary option) to ensure that all portions of the
project see the correct WORDS_BIGENDIAN value (some extension modules
were getting the wrong endian setting); added missing constants
GETPGRP_VOID, WNOHANG, WUNTRACED, X_OK, and type pid_t for NextStep
and OpenStep; removed unnecessary and problematic HAVE_SYS_WAIT_H
define in NeXT section.
* dir.c: do not allow NAMLEN() macro to trust dirent::d_namlen on
NextStep since, on some installations, this value always resolves
uselessly to zero.
* dln.c: added error reporting to NextStep extension loader since the
previous behavior of failing silently was not useful; now ensures
that NSLINKMODULE_OPTION_BINDNOW compatibility constant is defined
for OpenStep and Rhapsody; no longer includes <mach-o/dyld.h> twice
on Rhapsody since this header lacks multiple-include protection,
which resulted in "redefinition" compilation errors.
* main.c: also create hard reference to objc_msgSend() on NeXT
platforms (in addition to Apple platforms).
* lib/mkmf.rb: now exports XCFLAGS from configure script to extension
makefiles so that extensions can be built MAB (see configure's
--enable-fat-binary option); also utilize XCFLAGS in cc_command()
(but not cpp_command() because MAB flags are incompatible with
direct invocation of `cpp').
* ext/curses/extconf.rb: now additionally checks for presence of these
curses functions which are not present on NextStep or Openstep:
bkgd(), bkgdset(), color(), curs(), getbkgd(), init(), scrl(), set(),
setscrreg(), wattroff(), wattron(), wattrset(), wbkgd(), wbkgdset(),
wscrl(), wsetscrreg()
* ext/curses/curses.c: added appropriate #ifdef's for additional set of
curses functions now checked by extconf.rb; fixed curses_bkgd() and
window_bkgd() to correctly return boolean result rather than numeric
result; fixed window_getbkgd() to correctly signal an error by
returning nil rather than -1.
* ext/etc/etc.c: setup_passwd() and setup_group() now check for null
pointers before invoking rb_tainted_str_new2() upon fields extracted
from `struct passwd' and `struct group' since null pointers in some
fields are common on NextStep/OpenStep (especially so for the
`pw_comment' field) and rb_tainted_str_new2() throws an exception
when it receives a null pointer.
* ext/pty/pty.c: include "util.h" for strdup()/ruby_strdup() for
platforms such as NextStep and OpenStep which lack strdup().
* ext/socket/getaddrinfo.c: cast first argument of getservbyname(),
gethostbyaddr(), and gethostbyname() from (const char*) to non-const
(char*) for older platforms such as NextStep and OpenStep.
* ext/socket/socket.c: include "util.h" for strdup()/ruby_strdup() for
platforms such as NextStep and OpenStep which lack strdup(); include
<netinet/in_systm.h> if present for NextStep and OpenStep; cast first
argument of gethostbyaddr() and getservbyname() from (const char*) to
non-const (char*) for older platforms.
* ext/syslog/syslog.c: include "util.h" for strdup()/ruby_strdup() for
platforms such as NextStep and OpenStep which lack strdup().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5002 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-11-21 23:00:03 -05:00
|
|
|
#endif
|
|
|
|
|
1998-01-16 07:13:05 -05:00
|
|
|
#ifdef HAVE_GETPWENT
|
2020-04-08 20:24:07 -04:00
|
|
|
# ifdef __APPLE__
|
2020-04-08 23:23:15 -04:00
|
|
|
# define PW_TIME2VAL(t) INT2NUM((int)(t))
|
2020-04-08 20:24:07 -04:00
|
|
|
# else
|
2020-04-08 23:23:15 -04:00
|
|
|
# define PW_TIME2VAL(t) TIMET2NUM(t)
|
2020-04-08 20:24:07 -04:00
|
|
|
# endif
|
|
|
|
|
1998-01-16 07:13:05 -05:00
|
|
|
static VALUE
|
* sprintf.c (rb_str_format): allow %c to print one character
string (e.g. ?x).
* lib/tempfile.rb (Tempfile::make_tmpname): put dot between
basename and pid. [ruby-talk:196272]
* parse.y (do_block): remove -> style block.
* parse.y (parser_yylex): remove tLAMBDA_ARG.
* eval.c (rb_call0): binding for the return event hook should have
consistent scope. [ruby-core:07928]
* eval.c (proc_invoke): return behavior should depend whether it
is surrounded by a lambda or a mere block.
* eval.c (formal_assign): handles post splat arguments.
* eval.c (rb_call0): ditto.
* st.c (strhash): use FNV-1a hash.
* parse.y (parser_yylex): removed experimental ';;' terminator.
* eval.c (rb_node_arity): should be aware of post splat arguments.
* eval.c (rb_proc_arity): ditto.
* parse.y (f_args): syntax rule enhanced to support arguments
after the splat.
* parse.y (block_param): ditto for block parameters.
* parse.y (f_post_arg): mandatory formal arguments after the splat
argument.
* parse.y (new_args_gen): generate nodes for mandatory formal
arguments after the splat argument.
* eval.c (rb_eval): dispatch mandatory formal arguments after the
splat argument.
* parse.y (args): allow more than one splat in the argument list.
* parse.y (method_call): allow aref [] to accept all kind of
method argument, including assocs, splat, and block argument.
* eval.c (SETUP_ARGS0): prepare block argument as well.
* lib/mathn.rb (Integer): remove Integer#gcd2. [ruby-core:07931]
* eval.c (error_line): print receivers true/false/nil specially.
* eval.c (rb_proc_yield): handles parameters in yield semantics.
* eval.c (nil_yield): gives LocalJumpError to denote no block
error.
* io.c (rb_io_getc): now takes one-character string.
* string.c (rb_str_hash): use FNV-1a hash from Fowler/Noll/Vo
hashing algorithm.
* string.c (rb_str_aref): str[0] now returns 1 character string,
instead of a fixnum. [Ruby2]
* parse.y (parser_yylex): ?c now returns 1 character string,
instead of a fixnum. [Ruby2]
* string.c (rb_str_aset): no longer support fixnum insertion.
* eval.c (umethod_bind): should not update original class.
[ruby-dev:28636]
* eval.c (ev_const_get): should support constant access from
within instance_eval(). [ruby-dev:28327]
* time.c (time_timeval): should round for usec floating
number. [ruby-core:07896]
* time.c (time_add): ditto.
* dir.c (sys_warning): should not call a vararg function
rb_sys_warning() indirectly. [ruby-core:07886]
* numeric.c (flo_divmod): the first element of Float#divmod should
be an integer. [ruby-dev:28589]
* test/ruby/test_float.rb: add tests for divmod, div, modulo and remainder.
* re.c (rb_reg_initialize): should not allow modifying literal
regexps. frozen check moved from rb_reg_initialize_m as well.
* re.c (rb_reg_initialize): should not modify untainted objects in
safe levels higher than 3.
* re.c (rb_memcmp): type change from char* to const void*.
* dir.c (dir_close): should not close untainted dir stream.
* dir.c (GetDIR): add tainted/frozen check for each dir operation.
* lib/rdoc/parsers/parse_rb.rb (RDoc::RubyParser::parse_symbol_arg):
typo fixed. a patch from Florian Gross <florg at florg.net>.
* eval.c (EXEC_EVENT_HOOK): trace_func may remove itself from
event_hooks. no guarantee for arbitrary hook deletion.
[ruby-dev:28632]
* util.c (ruby_strtod): differ addition to minimize error.
[ruby-dev:28619]
* util.c (ruby_strtod): should not raise ERANGE when the input
string does not have any digits. [ruby-dev:28629]
* eval.c (proc_invoke): should restore old ruby_frame->block.
thanks to ts <decoux at moulon.inra.fr>. [ruby-core:07833]
also fix [ruby-dev:28614] as well.
* signal.c (trap): sig should be less then NSIG. Coverity found
this bug. a patch from Kevin Tew <tewk at tewk.com>.
[ruby-core:07823]
* math.c (math_log2): add new method inspired by
[ruby-talk:191237].
* math.c (math_log): add optional base argument to Math::log().
[ruby-talk:191308]
* ext/syck/emitter.c (syck_scan_scalar): avoid accessing
uninitialized array element. a patch from Pat Eyler
<rubypate at gmail.com>. [ruby-core:07809]
* array.c (rb_ary_fill): initialize local variables first. a
patch from Pat Eyler <rubypate at gmail.com>. [ruby-core:07810]
* ext/syck/yaml2byte.c (syck_yaml2byte_handler): need to free
type_tag. a patch from Pat Eyler <rubypate at gmail.com>.
[ruby-core:07808]
* ext/socket/socket.c (make_hostent_internal): accept ai_family
check from Sam Roberts <sroberts at uniserve.com>.
[ruby-core:07691]
* util.c (ruby_strtod): should not cut off 18 digits for no
reason. [ruby-core:07796]
* array.c (rb_ary_fill): internalize local variable "beg" to
pacify Coverity. [ruby-core:07770]
* pack.c (pack_unpack): now supports CRLF newlines. a patch from
<tommy at tmtm.org>. [ruby-dev:28601]
* applied code clean-up patch from Stefan Huehner
<stefan at huehner.org>. [ruby-core:07764]
* lib/jcode.rb (String::tr_s): should have translated non
squeezing character sequence (i.e. a character) as well. thanks
to Hiroshi Ichikawa <gimite at gimite.ddo.jp> [ruby-list:42090]
* ext/socket/socket.c: document update patch from Sam Roberts
<sroberts at uniserve.com>. [ruby-core:07701]
* lib/mathn.rb (Integer): need not to remove gcd2. a patch from
NARUSE, Yui <naruse at airemix.com>. [ruby-dev:28570]
* parse.y (arg): too much NEW_LIST()
* eval.c (SETUP_ARGS0): remove unnecessary access to nd_alen.
* eval.c (rb_eval): use ARGSCAT for NODE_OP_ASGN1.
[ruby-dev:28585]
* parse.y (arg): use NODE_ARGSCAT for placeholder.
* lib/getoptlong.rb (GetoptLong::get): RDoc update patch from
mathew <meta at pobox.com>. [ruby-core:07738]
* variable.c (rb_const_set): raise error when no target klass is
supplied. [ruby-dev:28582]
* prec.c (prec_prec_f): documentation patch from
<gerardo.santana at gmail.com>. [ruby-core:07689]
* bignum.c (rb_big_pow): second operand may be too big even if
it's a Fixnum. [ruby-talk:187984]
* README.EXT: update symbol description. [ruby-talk:188104]
* COPYING: explicitly note GPLv2. [ruby-talk:187922]
* parse.y: remove some obsolete syntax rules (unparenthesized
method calls in argument list).
* eval.c (rb_call0): insecure calling should be checked for non
NODE_SCOPE method invocations too.
* eval.c (rb_alias): should preserve the current safe level as
well as method definition.
* process.c (rb_f_sleep): remove RDoc description about SIGALRM
which is not valid on the current implementation. [ruby-dev:28464]
Thu Mar 23 21:40:47 2006 K.Kosako <sndgk393 AT ybb.ne.jp>
* eval.c (method_missing): should support argument splat in
super. a bug in combination of super, splat and
method_missing. [ruby-talk:185438]
* configure.in: Solaris SunPro compiler -rapth patch from
<kuwa at labs.fujitsu.com>. [ruby-dev:28443]
* configure.in: remove enable_rpath=no for Solaris.
[ruby-dev:28440]
* ext/win32ole/win32ole.c (ole_val2olevariantdata): change behavior
of converting OLE Variant object with VT_ARRAY|VT_UI1 and Ruby
String object.
* ruby.1: a clarification patch from David Lutterkort
<dlutter at redhat.com>. [ruby-core:7508]
* lib/rdoc/ri/ri_paths.rb (RI::Paths): adding paths from rubygems
directories. a patch from Eric Hodel <drbrain at segment7.net>.
[ruby-core:07423]
* eval.c (rb_clear_cache_by_class): clearing wrong cache.
* ext/extmk.rb: use :remove_destination to install extension libraries
to avoid SEGV. [ruby-dev:28417]
* eval.c (rb_thread_fd_writable): should not re-schedule output
from KILLED thread (must be error printing).
* array.c (rb_ary_flatten_bang): allow specifying recursion
level. [ruby-talk:182170]
* array.c (rb_ary_flatten): ditto.
* gc.c (add_heap): a heap_slots may overflow. a patch from Stefan
Weil <weil at mail.berlios.de>.
* eval.c (rb_call): use separate cache for fcall/vcall
invocation.
* eval.c (rb_eval): NODE_FCALL, NODE_VCALL can call local
functions.
* eval.c (rb_mod_local): a new method to specify newly added
visibility "local".
* eval.c (search_method): search for local methods which are
visible only from the current class.
* class.c (rb_class_local_methods): a method to list local methods.
* object.c (Init_Object): add BasicObject class as a top level
BlankSlate class.
* ruby.h (SYM2ID): should not cast to signed long.
[ruby-core:07414]
* class.c (rb_include_module): allow module duplication.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10235 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-06-09 17:20:17 -04:00
|
|
|
setup_passwd(struct passwd *pwd)
|
1998-01-16 07:13:05 -05:00
|
|
|
{
|
|
|
|
if (pwd == 0) rb_sys_fail("/etc/passwd");
|
1999-01-19 23:59:39 -05:00
|
|
|
return rb_struct_new(sPasswd,
|
2013-08-02 20:46:10 -04:00
|
|
|
safe_setup_locale_str(pwd->pw_name),
|
2013-05-09 08:12:17 -04:00
|
|
|
#ifdef HAVE_STRUCT_PASSWD_PW_PASSWD
|
* gc.c (Init_stack): stack region is far smaller than usual if
pthread is used.
* marshal.c (w_extended): singleton methods should not be checked
when dumping via marshal_dump() or _dump(). [ruby-talk:85909]
* file.c (getcwdofdrv): avoid using getcwd() directly, use
my_getcwd() instead.
* merged NeXT, OpenStep, Rhapsody ports patch from Eric Sunshine
<sunshine@sunshineco.com>. [ruby-core:01596]
* marshal.c (w_object): LINK check earlier than anything else,
i.e. do not dump TYPE_IVAR for already dumped objects.
(ruby-bugs PR#1220)
* eval.c (rb_eval): call "inherited" only when a new class is
generated; not on reopening.
* eval.c (eval): prepend error position in evaluating string to
* configure.in: revived NextStep, OpenStep, and Rhapsody ports which
had become unbuildable; enhanced --enable-fat-binary option so that
it accepts a list of desired architectures (rather than assuming a
fixed list), or defaults to a platform-appropriate list if user does
not provide an explicit list; made the default list of architectures
for MAB (fat binary) more comprehensive; now uses -fno-common even
when building the interpreter (in addition to using it for
extensions), thus allowing the interpreter to be embedded into a
plugin module of an external project (in addition to allowing
embedding directly into an application); added checks for
<netinet/in_systm.h> (needed by `socket' extension) and getcwd(); now
ensures that -I/usr/local/include is employed when extensions'
extconf.rb scripts invoke have_header() since extension checks on
NextStep and OpenStep will fail without it if the desired resource
resides in the /usr/local tree; fixed formatting of --help message.
* Makefile.in: $(LIBRUBY_A) rule now deletes the archive before
invoking $(AR) since `ar' on Apple/NeXT can not "update" MAB archives
(see configure's --enable-fat-binary option); added rule for new
missing/getcwd.c.
* defines.h: fixed endian handling during MAB build (see configure's
--enable-fat-binary option) to ensure that all portions of the
project see the correct WORDS_BIGENDIAN value (some extension modules
were getting the wrong endian setting); added missing constants
GETPGRP_VOID, WNOHANG, WUNTRACED, X_OK, and type pid_t for NextStep
and OpenStep; removed unnecessary and problematic HAVE_SYS_WAIT_H
define in NeXT section.
* dir.c: do not allow NAMLEN() macro to trust dirent::d_namlen on
NextStep since, on some installations, this value always resolves
uselessly to zero.
* dln.c: added error reporting to NextStep extension loader since the
previous behavior of failing silently was not useful; now ensures
that NSLINKMODULE_OPTION_BINDNOW compatibility constant is defined
for OpenStep and Rhapsody; no longer includes <mach-o/dyld.h> twice
on Rhapsody since this header lacks multiple-include protection,
which resulted in "redefinition" compilation errors.
* main.c: also create hard reference to objc_msgSend() on NeXT
platforms (in addition to Apple platforms).
* lib/mkmf.rb: now exports XCFLAGS from configure script to extension
makefiles so that extensions can be built MAB (see configure's
--enable-fat-binary option); also utilize XCFLAGS in cc_command()
(but not cpp_command() because MAB flags are incompatible with
direct invocation of `cpp').
* ext/curses/extconf.rb: now additionally checks for presence of these
curses functions which are not present on NextStep or Openstep:
bkgd(), bkgdset(), color(), curs(), getbkgd(), init(), scrl(), set(),
setscrreg(), wattroff(), wattron(), wattrset(), wbkgd(), wbkgdset(),
wscrl(), wsetscrreg()
* ext/curses/curses.c: added appropriate #ifdef's for additional set of
curses functions now checked by extconf.rb; fixed curses_bkgd() and
window_bkgd() to correctly return boolean result rather than numeric
result; fixed window_getbkgd() to correctly signal an error by
returning nil rather than -1.
* ext/etc/etc.c: setup_passwd() and setup_group() now check for null
pointers before invoking rb_tainted_str_new2() upon fields extracted
from `struct passwd' and `struct group' since null pointers in some
fields are common on NextStep/OpenStep (especially so for the
`pw_comment' field) and rb_tainted_str_new2() throws an exception
when it receives a null pointer.
* ext/pty/pty.c: include "util.h" for strdup()/ruby_strdup() for
platforms such as NextStep and OpenStep which lack strdup().
* ext/socket/getaddrinfo.c: cast first argument of getservbyname(),
gethostbyaddr(), and gethostbyname() from (const char*) to non-const
(char*) for older platforms such as NextStep and OpenStep.
* ext/socket/socket.c: include "util.h" for strdup()/ruby_strdup() for
platforms such as NextStep and OpenStep which lack strdup(); include
<netinet/in_systm.h> if present for NextStep and OpenStep; cast first
argument of gethostbyaddr() and getservbyname() from (const char*) to
non-const (char*) for older platforms.
* ext/syslog/syslog.c: include "util.h" for strdup()/ruby_strdup() for
platforms such as NextStep and OpenStep which lack strdup().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5002 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-11-21 23:00:03 -05:00
|
|
|
safe_setup_str(pwd->pw_passwd),
|
2003-11-24 05:42:17 -05:00
|
|
|
#endif
|
* configure.in (pid_t, uid_t, gid_t): check if defined.
* intern.h, process.c, rubyio.h, ext/etc/etc.c, ext/pty/pty.c: use
rb_{pid,uid,gid}_t instead of plain int. [ruby-dev:30376]
* ext/etc/extconf.rb (PIDT2NUM, NUM2PIDT, UIDT2NUM, NUM2UIDT, GIDT2NUM,
NUM2GIDT): moved to configure.in.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11770 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-17 23:13:09 -05:00
|
|
|
UIDT2NUM(pwd->pw_uid),
|
|
|
|
GIDT2NUM(pwd->pw_gid),
|
2013-05-09 08:12:17 -04:00
|
|
|
#ifdef HAVE_STRUCT_PASSWD_PW_GECOS
|
2013-08-02 20:46:10 -04:00
|
|
|
safe_setup_locale_str(pwd->pw_gecos),
|
1999-01-19 23:59:39 -05:00
|
|
|
#endif
|
2013-08-02 20:46:10 -04:00
|
|
|
safe_setup_filesystem_str(pwd->pw_dir),
|
|
|
|
safe_setup_filesystem_str(pwd->pw_shell),
|
2013-05-09 08:12:17 -04:00
|
|
|
#ifdef HAVE_STRUCT_PASSWD_PW_CHANGE
|
2020-04-08 23:23:15 -04:00
|
|
|
PW_TIME2VAL(pwd->pw_change),
|
1998-01-16 07:13:05 -05:00
|
|
|
#endif
|
2013-05-09 08:12:17 -04:00
|
|
|
#ifdef HAVE_STRUCT_PASSWD_PW_QUOTA
|
2006-06-26 22:37:01 -04:00
|
|
|
INT2NUM(pwd->pw_quota),
|
1998-01-16 07:13:05 -05:00
|
|
|
#endif
|
2013-05-09 08:12:17 -04:00
|
|
|
#ifdef HAVE_STRUCT_PASSWD_PW_AGE
|
2005-09-06 19:35:31 -04:00
|
|
|
PW_AGE2VAL(pwd->pw_age),
|
1998-01-16 07:13:05 -05:00
|
|
|
#endif
|
2013-05-09 08:12:17 -04:00
|
|
|
#ifdef HAVE_STRUCT_PASSWD_PW_CLASS
|
2013-08-02 20:46:10 -04:00
|
|
|
safe_setup_locale_str(pwd->pw_class),
|
1998-01-16 07:13:05 -05:00
|
|
|
#endif
|
2013-05-09 08:12:17 -04:00
|
|
|
#ifdef HAVE_STRUCT_PASSWD_PW_COMMENT
|
2013-08-02 20:46:10 -04:00
|
|
|
safe_setup_locale_str(pwd->pw_comment),
|
1998-01-16 07:13:05 -05:00
|
|
|
#endif
|
2013-05-09 08:12:17 -04:00
|
|
|
#ifdef HAVE_STRUCT_PASSWD_PW_EXPIRE
|
2020-04-08 23:23:15 -04:00
|
|
|
PW_TIME2VAL(pwd->pw_expire),
|
1998-01-16 07:13:05 -05:00
|
|
|
#endif
|
2013-06-22 02:26:32 -04:00
|
|
|
0 /*dummy*/
|
1999-01-19 23:59:39 -05:00
|
|
|
);
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-12-07 02:08:06 -05:00
|
|
|
/* call-seq:
|
|
|
|
* getpwuid(uid) -> Passwd
|
|
|
|
*
|
|
|
|
* Returns the /etc/passwd information for the user with the given integer +uid+.
|
2005-11-01 08:04:35 -05:00
|
|
|
*
|
2012-12-07 02:08:06 -05:00
|
|
|
* The information is returned as a Passwd struct.
|
2005-11-01 08:04:35 -05:00
|
|
|
*
|
2012-12-07 02:08:06 -05:00
|
|
|
* If +uid+ is omitted, the value from <code>Passwd[:uid]</code> is returned
|
|
|
|
* instead.
|
|
|
|
*
|
|
|
|
* See the unix manpage for <code>getpwuid(3)</code> for more detail.
|
|
|
|
*
|
|
|
|
* === Example:
|
|
|
|
*
|
|
|
|
* Etc.getpwuid(0)
|
2013-04-12 11:16:00 -04:00
|
|
|
* #=> #<struct Etc::Passwd name="root", passwd="x", uid=0, gid=0, gecos="root",dir="/root", shell="/bin/bash">
|
2005-11-01 08:04:35 -05:00
|
|
|
*/
|
1998-01-16 07:13:05 -05:00
|
|
|
static VALUE
|
* sprintf.c (rb_str_format): allow %c to print one character
string (e.g. ?x).
* lib/tempfile.rb (Tempfile::make_tmpname): put dot between
basename and pid. [ruby-talk:196272]
* parse.y (do_block): remove -> style block.
* parse.y (parser_yylex): remove tLAMBDA_ARG.
* eval.c (rb_call0): binding for the return event hook should have
consistent scope. [ruby-core:07928]
* eval.c (proc_invoke): return behavior should depend whether it
is surrounded by a lambda or a mere block.
* eval.c (formal_assign): handles post splat arguments.
* eval.c (rb_call0): ditto.
* st.c (strhash): use FNV-1a hash.
* parse.y (parser_yylex): removed experimental ';;' terminator.
* eval.c (rb_node_arity): should be aware of post splat arguments.
* eval.c (rb_proc_arity): ditto.
* parse.y (f_args): syntax rule enhanced to support arguments
after the splat.
* parse.y (block_param): ditto for block parameters.
* parse.y (f_post_arg): mandatory formal arguments after the splat
argument.
* parse.y (new_args_gen): generate nodes for mandatory formal
arguments after the splat argument.
* eval.c (rb_eval): dispatch mandatory formal arguments after the
splat argument.
* parse.y (args): allow more than one splat in the argument list.
* parse.y (method_call): allow aref [] to accept all kind of
method argument, including assocs, splat, and block argument.
* eval.c (SETUP_ARGS0): prepare block argument as well.
* lib/mathn.rb (Integer): remove Integer#gcd2. [ruby-core:07931]
* eval.c (error_line): print receivers true/false/nil specially.
* eval.c (rb_proc_yield): handles parameters in yield semantics.
* eval.c (nil_yield): gives LocalJumpError to denote no block
error.
* io.c (rb_io_getc): now takes one-character string.
* string.c (rb_str_hash): use FNV-1a hash from Fowler/Noll/Vo
hashing algorithm.
* string.c (rb_str_aref): str[0] now returns 1 character string,
instead of a fixnum. [Ruby2]
* parse.y (parser_yylex): ?c now returns 1 character string,
instead of a fixnum. [Ruby2]
* string.c (rb_str_aset): no longer support fixnum insertion.
* eval.c (umethod_bind): should not update original class.
[ruby-dev:28636]
* eval.c (ev_const_get): should support constant access from
within instance_eval(). [ruby-dev:28327]
* time.c (time_timeval): should round for usec floating
number. [ruby-core:07896]
* time.c (time_add): ditto.
* dir.c (sys_warning): should not call a vararg function
rb_sys_warning() indirectly. [ruby-core:07886]
* numeric.c (flo_divmod): the first element of Float#divmod should
be an integer. [ruby-dev:28589]
* test/ruby/test_float.rb: add tests for divmod, div, modulo and remainder.
* re.c (rb_reg_initialize): should not allow modifying literal
regexps. frozen check moved from rb_reg_initialize_m as well.
* re.c (rb_reg_initialize): should not modify untainted objects in
safe levels higher than 3.
* re.c (rb_memcmp): type change from char* to const void*.
* dir.c (dir_close): should not close untainted dir stream.
* dir.c (GetDIR): add tainted/frozen check for each dir operation.
* lib/rdoc/parsers/parse_rb.rb (RDoc::RubyParser::parse_symbol_arg):
typo fixed. a patch from Florian Gross <florg at florg.net>.
* eval.c (EXEC_EVENT_HOOK): trace_func may remove itself from
event_hooks. no guarantee for arbitrary hook deletion.
[ruby-dev:28632]
* util.c (ruby_strtod): differ addition to minimize error.
[ruby-dev:28619]
* util.c (ruby_strtod): should not raise ERANGE when the input
string does not have any digits. [ruby-dev:28629]
* eval.c (proc_invoke): should restore old ruby_frame->block.
thanks to ts <decoux at moulon.inra.fr>. [ruby-core:07833]
also fix [ruby-dev:28614] as well.
* signal.c (trap): sig should be less then NSIG. Coverity found
this bug. a patch from Kevin Tew <tewk at tewk.com>.
[ruby-core:07823]
* math.c (math_log2): add new method inspired by
[ruby-talk:191237].
* math.c (math_log): add optional base argument to Math::log().
[ruby-talk:191308]
* ext/syck/emitter.c (syck_scan_scalar): avoid accessing
uninitialized array element. a patch from Pat Eyler
<rubypate at gmail.com>. [ruby-core:07809]
* array.c (rb_ary_fill): initialize local variables first. a
patch from Pat Eyler <rubypate at gmail.com>. [ruby-core:07810]
* ext/syck/yaml2byte.c (syck_yaml2byte_handler): need to free
type_tag. a patch from Pat Eyler <rubypate at gmail.com>.
[ruby-core:07808]
* ext/socket/socket.c (make_hostent_internal): accept ai_family
check from Sam Roberts <sroberts at uniserve.com>.
[ruby-core:07691]
* util.c (ruby_strtod): should not cut off 18 digits for no
reason. [ruby-core:07796]
* array.c (rb_ary_fill): internalize local variable "beg" to
pacify Coverity. [ruby-core:07770]
* pack.c (pack_unpack): now supports CRLF newlines. a patch from
<tommy at tmtm.org>. [ruby-dev:28601]
* applied code clean-up patch from Stefan Huehner
<stefan at huehner.org>. [ruby-core:07764]
* lib/jcode.rb (String::tr_s): should have translated non
squeezing character sequence (i.e. a character) as well. thanks
to Hiroshi Ichikawa <gimite at gimite.ddo.jp> [ruby-list:42090]
* ext/socket/socket.c: document update patch from Sam Roberts
<sroberts at uniserve.com>. [ruby-core:07701]
* lib/mathn.rb (Integer): need not to remove gcd2. a patch from
NARUSE, Yui <naruse at airemix.com>. [ruby-dev:28570]
* parse.y (arg): too much NEW_LIST()
* eval.c (SETUP_ARGS0): remove unnecessary access to nd_alen.
* eval.c (rb_eval): use ARGSCAT for NODE_OP_ASGN1.
[ruby-dev:28585]
* parse.y (arg): use NODE_ARGSCAT for placeholder.
* lib/getoptlong.rb (GetoptLong::get): RDoc update patch from
mathew <meta at pobox.com>. [ruby-core:07738]
* variable.c (rb_const_set): raise error when no target klass is
supplied. [ruby-dev:28582]
* prec.c (prec_prec_f): documentation patch from
<gerardo.santana at gmail.com>. [ruby-core:07689]
* bignum.c (rb_big_pow): second operand may be too big even if
it's a Fixnum. [ruby-talk:187984]
* README.EXT: update symbol description. [ruby-talk:188104]
* COPYING: explicitly note GPLv2. [ruby-talk:187922]
* parse.y: remove some obsolete syntax rules (unparenthesized
method calls in argument list).
* eval.c (rb_call0): insecure calling should be checked for non
NODE_SCOPE method invocations too.
* eval.c (rb_alias): should preserve the current safe level as
well as method definition.
* process.c (rb_f_sleep): remove RDoc description about SIGALRM
which is not valid on the current implementation. [ruby-dev:28464]
Thu Mar 23 21:40:47 2006 K.Kosako <sndgk393 AT ybb.ne.jp>
* eval.c (method_missing): should support argument splat in
super. a bug in combination of super, splat and
method_missing. [ruby-talk:185438]
* configure.in: Solaris SunPro compiler -rapth patch from
<kuwa at labs.fujitsu.com>. [ruby-dev:28443]
* configure.in: remove enable_rpath=no for Solaris.
[ruby-dev:28440]
* ext/win32ole/win32ole.c (ole_val2olevariantdata): change behavior
of converting OLE Variant object with VT_ARRAY|VT_UI1 and Ruby
String object.
* ruby.1: a clarification patch from David Lutterkort
<dlutter at redhat.com>. [ruby-core:7508]
* lib/rdoc/ri/ri_paths.rb (RI::Paths): adding paths from rubygems
directories. a patch from Eric Hodel <drbrain at segment7.net>.
[ruby-core:07423]
* eval.c (rb_clear_cache_by_class): clearing wrong cache.
* ext/extmk.rb: use :remove_destination to install extension libraries
to avoid SEGV. [ruby-dev:28417]
* eval.c (rb_thread_fd_writable): should not re-schedule output
from KILLED thread (must be error printing).
* array.c (rb_ary_flatten_bang): allow specifying recursion
level. [ruby-talk:182170]
* array.c (rb_ary_flatten): ditto.
* gc.c (add_heap): a heap_slots may overflow. a patch from Stefan
Weil <weil at mail.berlios.de>.
* eval.c (rb_call): use separate cache for fcall/vcall
invocation.
* eval.c (rb_eval): NODE_FCALL, NODE_VCALL can call local
functions.
* eval.c (rb_mod_local): a new method to specify newly added
visibility "local".
* eval.c (search_method): search for local methods which are
visible only from the current class.
* class.c (rb_class_local_methods): a method to list local methods.
* object.c (Init_Object): add BasicObject class as a top level
BlankSlate class.
* ruby.h (SYM2ID): should not cast to signed long.
[ruby-core:07414]
* class.c (rb_include_module): allow module duplication.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10235 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-06-09 17:20:17 -04:00
|
|
|
etc_getpwuid(int argc, VALUE *argv, VALUE obj)
|
1998-01-16 07:13:05 -05:00
|
|
|
{
|
2002-05-29 01:20:39 -04:00
|
|
|
#if defined(HAVE_GETPWENT)
|
2003-01-16 02:38:40 -05:00
|
|
|
VALUE id;
|
2009-05-14 03:13:40 -04:00
|
|
|
rb_uid_t uid;
|
1998-01-16 07:13:05 -05:00
|
|
|
struct passwd *pwd;
|
|
|
|
|
|
|
|
if (rb_scan_args(argc, argv, "01", &id) == 1) {
|
* configure.in (pid_t, uid_t, gid_t): check if defined.
* intern.h, process.c, rubyio.h, ext/etc/etc.c, ext/pty/pty.c: use
rb_{pid,uid,gid}_t instead of plain int. [ruby-dev:30376]
* ext/etc/extconf.rb (PIDT2NUM, NUM2PIDT, UIDT2NUM, NUM2UIDT, GIDT2NUM,
NUM2GIDT): moved to configure.in.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11770 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-17 23:13:09 -05:00
|
|
|
uid = NUM2UIDT(id);
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
uid = getuid();
|
|
|
|
}
|
|
|
|
pwd = getpwuid(uid);
|
2008-10-26 05:07:37 -04:00
|
|
|
if (pwd == 0) rb_raise(rb_eArgError, "can't find user for %d", (int)uid);
|
1998-01-16 07:13:05 -05:00
|
|
|
return setup_passwd(pwd);
|
2010-04-22 04:04:13 -04:00
|
|
|
#else
|
1998-01-16 07:13:05 -05:00
|
|
|
return Qnil;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2012-12-07 02:08:06 -05:00
|
|
|
/* call-seq:
|
|
|
|
* getpwnam(name) -> Passwd
|
|
|
|
*
|
|
|
|
* Returns the /etc/passwd information for the user with specified login
|
|
|
|
* +name+.
|
|
|
|
*
|
|
|
|
* The information is returned as a Passwd struct.
|
2005-11-01 08:04:35 -05:00
|
|
|
*
|
2012-12-07 02:08:06 -05:00
|
|
|
* See the unix manpage for <code>getpwnam(3)</code> for more detail.
|
2005-11-01 08:04:35 -05:00
|
|
|
*
|
2012-12-07 02:08:06 -05:00
|
|
|
* === Example:
|
|
|
|
*
|
|
|
|
* Etc.getpwnam('root')
|
2013-04-12 11:16:00 -04:00
|
|
|
* #=> #<struct Etc::Passwd name="root", passwd="x", uid=0, gid=0, gecos="root",dir="/root", shell="/bin/bash">
|
2005-11-01 08:04:35 -05:00
|
|
|
*/
|
1998-01-16 07:13:05 -05:00
|
|
|
static VALUE
|
* sprintf.c (rb_str_format): allow %c to print one character
string (e.g. ?x).
* lib/tempfile.rb (Tempfile::make_tmpname): put dot between
basename and pid. [ruby-talk:196272]
* parse.y (do_block): remove -> style block.
* parse.y (parser_yylex): remove tLAMBDA_ARG.
* eval.c (rb_call0): binding for the return event hook should have
consistent scope. [ruby-core:07928]
* eval.c (proc_invoke): return behavior should depend whether it
is surrounded by a lambda or a mere block.
* eval.c (formal_assign): handles post splat arguments.
* eval.c (rb_call0): ditto.
* st.c (strhash): use FNV-1a hash.
* parse.y (parser_yylex): removed experimental ';;' terminator.
* eval.c (rb_node_arity): should be aware of post splat arguments.
* eval.c (rb_proc_arity): ditto.
* parse.y (f_args): syntax rule enhanced to support arguments
after the splat.
* parse.y (block_param): ditto for block parameters.
* parse.y (f_post_arg): mandatory formal arguments after the splat
argument.
* parse.y (new_args_gen): generate nodes for mandatory formal
arguments after the splat argument.
* eval.c (rb_eval): dispatch mandatory formal arguments after the
splat argument.
* parse.y (args): allow more than one splat in the argument list.
* parse.y (method_call): allow aref [] to accept all kind of
method argument, including assocs, splat, and block argument.
* eval.c (SETUP_ARGS0): prepare block argument as well.
* lib/mathn.rb (Integer): remove Integer#gcd2. [ruby-core:07931]
* eval.c (error_line): print receivers true/false/nil specially.
* eval.c (rb_proc_yield): handles parameters in yield semantics.
* eval.c (nil_yield): gives LocalJumpError to denote no block
error.
* io.c (rb_io_getc): now takes one-character string.
* string.c (rb_str_hash): use FNV-1a hash from Fowler/Noll/Vo
hashing algorithm.
* string.c (rb_str_aref): str[0] now returns 1 character string,
instead of a fixnum. [Ruby2]
* parse.y (parser_yylex): ?c now returns 1 character string,
instead of a fixnum. [Ruby2]
* string.c (rb_str_aset): no longer support fixnum insertion.
* eval.c (umethod_bind): should not update original class.
[ruby-dev:28636]
* eval.c (ev_const_get): should support constant access from
within instance_eval(). [ruby-dev:28327]
* time.c (time_timeval): should round for usec floating
number. [ruby-core:07896]
* time.c (time_add): ditto.
* dir.c (sys_warning): should not call a vararg function
rb_sys_warning() indirectly. [ruby-core:07886]
* numeric.c (flo_divmod): the first element of Float#divmod should
be an integer. [ruby-dev:28589]
* test/ruby/test_float.rb: add tests for divmod, div, modulo and remainder.
* re.c (rb_reg_initialize): should not allow modifying literal
regexps. frozen check moved from rb_reg_initialize_m as well.
* re.c (rb_reg_initialize): should not modify untainted objects in
safe levels higher than 3.
* re.c (rb_memcmp): type change from char* to const void*.
* dir.c (dir_close): should not close untainted dir stream.
* dir.c (GetDIR): add tainted/frozen check for each dir operation.
* lib/rdoc/parsers/parse_rb.rb (RDoc::RubyParser::parse_symbol_arg):
typo fixed. a patch from Florian Gross <florg at florg.net>.
* eval.c (EXEC_EVENT_HOOK): trace_func may remove itself from
event_hooks. no guarantee for arbitrary hook deletion.
[ruby-dev:28632]
* util.c (ruby_strtod): differ addition to minimize error.
[ruby-dev:28619]
* util.c (ruby_strtod): should not raise ERANGE when the input
string does not have any digits. [ruby-dev:28629]
* eval.c (proc_invoke): should restore old ruby_frame->block.
thanks to ts <decoux at moulon.inra.fr>. [ruby-core:07833]
also fix [ruby-dev:28614] as well.
* signal.c (trap): sig should be less then NSIG. Coverity found
this bug. a patch from Kevin Tew <tewk at tewk.com>.
[ruby-core:07823]
* math.c (math_log2): add new method inspired by
[ruby-talk:191237].
* math.c (math_log): add optional base argument to Math::log().
[ruby-talk:191308]
* ext/syck/emitter.c (syck_scan_scalar): avoid accessing
uninitialized array element. a patch from Pat Eyler
<rubypate at gmail.com>. [ruby-core:07809]
* array.c (rb_ary_fill): initialize local variables first. a
patch from Pat Eyler <rubypate at gmail.com>. [ruby-core:07810]
* ext/syck/yaml2byte.c (syck_yaml2byte_handler): need to free
type_tag. a patch from Pat Eyler <rubypate at gmail.com>.
[ruby-core:07808]
* ext/socket/socket.c (make_hostent_internal): accept ai_family
check from Sam Roberts <sroberts at uniserve.com>.
[ruby-core:07691]
* util.c (ruby_strtod): should not cut off 18 digits for no
reason. [ruby-core:07796]
* array.c (rb_ary_fill): internalize local variable "beg" to
pacify Coverity. [ruby-core:07770]
* pack.c (pack_unpack): now supports CRLF newlines. a patch from
<tommy at tmtm.org>. [ruby-dev:28601]
* applied code clean-up patch from Stefan Huehner
<stefan at huehner.org>. [ruby-core:07764]
* lib/jcode.rb (String::tr_s): should have translated non
squeezing character sequence (i.e. a character) as well. thanks
to Hiroshi Ichikawa <gimite at gimite.ddo.jp> [ruby-list:42090]
* ext/socket/socket.c: document update patch from Sam Roberts
<sroberts at uniserve.com>. [ruby-core:07701]
* lib/mathn.rb (Integer): need not to remove gcd2. a patch from
NARUSE, Yui <naruse at airemix.com>. [ruby-dev:28570]
* parse.y (arg): too much NEW_LIST()
* eval.c (SETUP_ARGS0): remove unnecessary access to nd_alen.
* eval.c (rb_eval): use ARGSCAT for NODE_OP_ASGN1.
[ruby-dev:28585]
* parse.y (arg): use NODE_ARGSCAT for placeholder.
* lib/getoptlong.rb (GetoptLong::get): RDoc update patch from
mathew <meta at pobox.com>. [ruby-core:07738]
* variable.c (rb_const_set): raise error when no target klass is
supplied. [ruby-dev:28582]
* prec.c (prec_prec_f): documentation patch from
<gerardo.santana at gmail.com>. [ruby-core:07689]
* bignum.c (rb_big_pow): second operand may be too big even if
it's a Fixnum. [ruby-talk:187984]
* README.EXT: update symbol description. [ruby-talk:188104]
* COPYING: explicitly note GPLv2. [ruby-talk:187922]
* parse.y: remove some obsolete syntax rules (unparenthesized
method calls in argument list).
* eval.c (rb_call0): insecure calling should be checked for non
NODE_SCOPE method invocations too.
* eval.c (rb_alias): should preserve the current safe level as
well as method definition.
* process.c (rb_f_sleep): remove RDoc description about SIGALRM
which is not valid on the current implementation. [ruby-dev:28464]
Thu Mar 23 21:40:47 2006 K.Kosako <sndgk393 AT ybb.ne.jp>
* eval.c (method_missing): should support argument splat in
super. a bug in combination of super, splat and
method_missing. [ruby-talk:185438]
* configure.in: Solaris SunPro compiler -rapth patch from
<kuwa at labs.fujitsu.com>. [ruby-dev:28443]
* configure.in: remove enable_rpath=no for Solaris.
[ruby-dev:28440]
* ext/win32ole/win32ole.c (ole_val2olevariantdata): change behavior
of converting OLE Variant object with VT_ARRAY|VT_UI1 and Ruby
String object.
* ruby.1: a clarification patch from David Lutterkort
<dlutter at redhat.com>. [ruby-core:7508]
* lib/rdoc/ri/ri_paths.rb (RI::Paths): adding paths from rubygems
directories. a patch from Eric Hodel <drbrain at segment7.net>.
[ruby-core:07423]
* eval.c (rb_clear_cache_by_class): clearing wrong cache.
* ext/extmk.rb: use :remove_destination to install extension libraries
to avoid SEGV. [ruby-dev:28417]
* eval.c (rb_thread_fd_writable): should not re-schedule output
from KILLED thread (must be error printing).
* array.c (rb_ary_flatten_bang): allow specifying recursion
level. [ruby-talk:182170]
* array.c (rb_ary_flatten): ditto.
* gc.c (add_heap): a heap_slots may overflow. a patch from Stefan
Weil <weil at mail.berlios.de>.
* eval.c (rb_call): use separate cache for fcall/vcall
invocation.
* eval.c (rb_eval): NODE_FCALL, NODE_VCALL can call local
functions.
* eval.c (rb_mod_local): a new method to specify newly added
visibility "local".
* eval.c (search_method): search for local methods which are
visible only from the current class.
* class.c (rb_class_local_methods): a method to list local methods.
* object.c (Init_Object): add BasicObject class as a top level
BlankSlate class.
* ruby.h (SYM2ID): should not cast to signed long.
[ruby-core:07414]
* class.c (rb_include_module): allow module duplication.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10235 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-06-09 17:20:17 -04:00
|
|
|
etc_getpwnam(VALUE obj, VALUE nam)
|
1998-01-16 07:13:05 -05:00
|
|
|
{
|
|
|
|
#ifdef HAVE_GETPWENT
|
|
|
|
struct passwd *pwd;
|
2017-09-30 04:35:23 -04:00
|
|
|
const char *p = StringValueCStr(nam);
|
1998-01-16 07:13:05 -05:00
|
|
|
|
2017-09-30 04:35:23 -04:00
|
|
|
pwd = getpwnam(p);
|
2013-06-22 00:46:47 -04:00
|
|
|
if (pwd == 0) rb_raise(rb_eArgError, "can't find user for %"PRIsVALUE, nam);
|
1998-01-16 07:13:05 -05:00
|
|
|
return setup_passwd(pwd);
|
2010-04-22 04:04:13 -04:00
|
|
|
#else
|
1998-01-16 07:13:05 -05:00
|
|
|
return Qnil;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2002-05-29 01:20:39 -04:00
|
|
|
#ifdef HAVE_GETPWENT
|
2020-12-23 02:30:16 -05:00
|
|
|
static rb_atomic_t passwd_blocking;
|
2002-05-29 01:20:39 -04:00
|
|
|
static VALUE
|
2019-08-26 02:20:15 -04:00
|
|
|
passwd_ensure(VALUE _)
|
2002-05-29 01:20:39 -04:00
|
|
|
{
|
2012-05-13 10:00:16 -04:00
|
|
|
endpwent();
|
2021-01-10 21:14:28 -05:00
|
|
|
if (RUBY_ATOMIC_EXCHANGE(passwd_blocking, 0) != 1) {
|
|
|
|
rb_raise(rb_eRuntimeError, "unexpected passwd_blocking");
|
|
|
|
}
|
2002-05-29 01:20:39 -04:00
|
|
|
return Qnil;
|
|
|
|
}
|
|
|
|
|
|
|
|
static VALUE
|
2019-08-26 02:20:15 -04:00
|
|
|
passwd_iterate(VALUE _)
|
2002-05-29 01:20:39 -04:00
|
|
|
{
|
|
|
|
struct passwd *pw;
|
|
|
|
|
|
|
|
setpwent();
|
2015-04-18 23:19:20 -04:00
|
|
|
while ((pw = getpwent()) != 0) {
|
2002-05-29 01:20:39 -04:00
|
|
|
rb_yield(setup_passwd(pw));
|
|
|
|
}
|
|
|
|
return Qnil;
|
|
|
|
}
|
2009-02-17 10:55:49 -05:00
|
|
|
|
|
|
|
static void
|
|
|
|
each_passwd(void)
|
|
|
|
{
|
2020-12-23 02:30:16 -05:00
|
|
|
if (RUBY_ATOMIC_CAS(passwd_blocking, 0, 1)) {
|
2009-02-17 10:55:49 -05:00
|
|
|
rb_raise(rb_eRuntimeError, "parallel passwd iteration");
|
|
|
|
}
|
|
|
|
rb_ensure(passwd_iterate, 0, passwd_ensure, 0);
|
|
|
|
}
|
2002-05-29 01:20:39 -04:00
|
|
|
#endif
|
|
|
|
|
2012-12-07 02:08:06 -05:00
|
|
|
/* call-seq:
|
|
|
|
* Etc.passwd { |struct| block } -> Passwd
|
|
|
|
* Etc.passwd -> Passwd
|
|
|
|
*
|
|
|
|
* Provides a convenient Ruby iterator which executes a block for each entry
|
2005-11-01 08:04:35 -05:00
|
|
|
* in the /etc/passwd file.
|
|
|
|
*
|
2012-12-07 02:08:06 -05:00
|
|
|
* The code block is passed an Passwd struct.
|
|
|
|
*
|
|
|
|
* See ::getpwent above for details.
|
2005-11-01 08:04:35 -05:00
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
*
|
|
|
|
* require 'etc'
|
|
|
|
*
|
|
|
|
* Etc.passwd {|u|
|
|
|
|
* puts u.name + " = " + u.gecos
|
|
|
|
* }
|
|
|
|
*
|
|
|
|
*/
|
1998-01-16 07:13:05 -05:00
|
|
|
static VALUE
|
* sprintf.c (rb_str_format): allow %c to print one character
string (e.g. ?x).
* lib/tempfile.rb (Tempfile::make_tmpname): put dot between
basename and pid. [ruby-talk:196272]
* parse.y (do_block): remove -> style block.
* parse.y (parser_yylex): remove tLAMBDA_ARG.
* eval.c (rb_call0): binding for the return event hook should have
consistent scope. [ruby-core:07928]
* eval.c (proc_invoke): return behavior should depend whether it
is surrounded by a lambda or a mere block.
* eval.c (formal_assign): handles post splat arguments.
* eval.c (rb_call0): ditto.
* st.c (strhash): use FNV-1a hash.
* parse.y (parser_yylex): removed experimental ';;' terminator.
* eval.c (rb_node_arity): should be aware of post splat arguments.
* eval.c (rb_proc_arity): ditto.
* parse.y (f_args): syntax rule enhanced to support arguments
after the splat.
* parse.y (block_param): ditto for block parameters.
* parse.y (f_post_arg): mandatory formal arguments after the splat
argument.
* parse.y (new_args_gen): generate nodes for mandatory formal
arguments after the splat argument.
* eval.c (rb_eval): dispatch mandatory formal arguments after the
splat argument.
* parse.y (args): allow more than one splat in the argument list.
* parse.y (method_call): allow aref [] to accept all kind of
method argument, including assocs, splat, and block argument.
* eval.c (SETUP_ARGS0): prepare block argument as well.
* lib/mathn.rb (Integer): remove Integer#gcd2. [ruby-core:07931]
* eval.c (error_line): print receivers true/false/nil specially.
* eval.c (rb_proc_yield): handles parameters in yield semantics.
* eval.c (nil_yield): gives LocalJumpError to denote no block
error.
* io.c (rb_io_getc): now takes one-character string.
* string.c (rb_str_hash): use FNV-1a hash from Fowler/Noll/Vo
hashing algorithm.
* string.c (rb_str_aref): str[0] now returns 1 character string,
instead of a fixnum. [Ruby2]
* parse.y (parser_yylex): ?c now returns 1 character string,
instead of a fixnum. [Ruby2]
* string.c (rb_str_aset): no longer support fixnum insertion.
* eval.c (umethod_bind): should not update original class.
[ruby-dev:28636]
* eval.c (ev_const_get): should support constant access from
within instance_eval(). [ruby-dev:28327]
* time.c (time_timeval): should round for usec floating
number. [ruby-core:07896]
* time.c (time_add): ditto.
* dir.c (sys_warning): should not call a vararg function
rb_sys_warning() indirectly. [ruby-core:07886]
* numeric.c (flo_divmod): the first element of Float#divmod should
be an integer. [ruby-dev:28589]
* test/ruby/test_float.rb: add tests for divmod, div, modulo and remainder.
* re.c (rb_reg_initialize): should not allow modifying literal
regexps. frozen check moved from rb_reg_initialize_m as well.
* re.c (rb_reg_initialize): should not modify untainted objects in
safe levels higher than 3.
* re.c (rb_memcmp): type change from char* to const void*.
* dir.c (dir_close): should not close untainted dir stream.
* dir.c (GetDIR): add tainted/frozen check for each dir operation.
* lib/rdoc/parsers/parse_rb.rb (RDoc::RubyParser::parse_symbol_arg):
typo fixed. a patch from Florian Gross <florg at florg.net>.
* eval.c (EXEC_EVENT_HOOK): trace_func may remove itself from
event_hooks. no guarantee for arbitrary hook deletion.
[ruby-dev:28632]
* util.c (ruby_strtod): differ addition to minimize error.
[ruby-dev:28619]
* util.c (ruby_strtod): should not raise ERANGE when the input
string does not have any digits. [ruby-dev:28629]
* eval.c (proc_invoke): should restore old ruby_frame->block.
thanks to ts <decoux at moulon.inra.fr>. [ruby-core:07833]
also fix [ruby-dev:28614] as well.
* signal.c (trap): sig should be less then NSIG. Coverity found
this bug. a patch from Kevin Tew <tewk at tewk.com>.
[ruby-core:07823]
* math.c (math_log2): add new method inspired by
[ruby-talk:191237].
* math.c (math_log): add optional base argument to Math::log().
[ruby-talk:191308]
* ext/syck/emitter.c (syck_scan_scalar): avoid accessing
uninitialized array element. a patch from Pat Eyler
<rubypate at gmail.com>. [ruby-core:07809]
* array.c (rb_ary_fill): initialize local variables first. a
patch from Pat Eyler <rubypate at gmail.com>. [ruby-core:07810]
* ext/syck/yaml2byte.c (syck_yaml2byte_handler): need to free
type_tag. a patch from Pat Eyler <rubypate at gmail.com>.
[ruby-core:07808]
* ext/socket/socket.c (make_hostent_internal): accept ai_family
check from Sam Roberts <sroberts at uniserve.com>.
[ruby-core:07691]
* util.c (ruby_strtod): should not cut off 18 digits for no
reason. [ruby-core:07796]
* array.c (rb_ary_fill): internalize local variable "beg" to
pacify Coverity. [ruby-core:07770]
* pack.c (pack_unpack): now supports CRLF newlines. a patch from
<tommy at tmtm.org>. [ruby-dev:28601]
* applied code clean-up patch from Stefan Huehner
<stefan at huehner.org>. [ruby-core:07764]
* lib/jcode.rb (String::tr_s): should have translated non
squeezing character sequence (i.e. a character) as well. thanks
to Hiroshi Ichikawa <gimite at gimite.ddo.jp> [ruby-list:42090]
* ext/socket/socket.c: document update patch from Sam Roberts
<sroberts at uniserve.com>. [ruby-core:07701]
* lib/mathn.rb (Integer): need not to remove gcd2. a patch from
NARUSE, Yui <naruse at airemix.com>. [ruby-dev:28570]
* parse.y (arg): too much NEW_LIST()
* eval.c (SETUP_ARGS0): remove unnecessary access to nd_alen.
* eval.c (rb_eval): use ARGSCAT for NODE_OP_ASGN1.
[ruby-dev:28585]
* parse.y (arg): use NODE_ARGSCAT for placeholder.
* lib/getoptlong.rb (GetoptLong::get): RDoc update patch from
mathew <meta at pobox.com>. [ruby-core:07738]
* variable.c (rb_const_set): raise error when no target klass is
supplied. [ruby-dev:28582]
* prec.c (prec_prec_f): documentation patch from
<gerardo.santana at gmail.com>. [ruby-core:07689]
* bignum.c (rb_big_pow): second operand may be too big even if
it's a Fixnum. [ruby-talk:187984]
* README.EXT: update symbol description. [ruby-talk:188104]
* COPYING: explicitly note GPLv2. [ruby-talk:187922]
* parse.y: remove some obsolete syntax rules (unparenthesized
method calls in argument list).
* eval.c (rb_call0): insecure calling should be checked for non
NODE_SCOPE method invocations too.
* eval.c (rb_alias): should preserve the current safe level as
well as method definition.
* process.c (rb_f_sleep): remove RDoc description about SIGALRM
which is not valid on the current implementation. [ruby-dev:28464]
Thu Mar 23 21:40:47 2006 K.Kosako <sndgk393 AT ybb.ne.jp>
* eval.c (method_missing): should support argument splat in
super. a bug in combination of super, splat and
method_missing. [ruby-talk:185438]
* configure.in: Solaris SunPro compiler -rapth patch from
<kuwa at labs.fujitsu.com>. [ruby-dev:28443]
* configure.in: remove enable_rpath=no for Solaris.
[ruby-dev:28440]
* ext/win32ole/win32ole.c (ole_val2olevariantdata): change behavior
of converting OLE Variant object with VT_ARRAY|VT_UI1 and Ruby
String object.
* ruby.1: a clarification patch from David Lutterkort
<dlutter at redhat.com>. [ruby-core:7508]
* lib/rdoc/ri/ri_paths.rb (RI::Paths): adding paths from rubygems
directories. a patch from Eric Hodel <drbrain at segment7.net>.
[ruby-core:07423]
* eval.c (rb_clear_cache_by_class): clearing wrong cache.
* ext/extmk.rb: use :remove_destination to install extension libraries
to avoid SEGV. [ruby-dev:28417]
* eval.c (rb_thread_fd_writable): should not re-schedule output
from KILLED thread (must be error printing).
* array.c (rb_ary_flatten_bang): allow specifying recursion
level. [ruby-talk:182170]
* array.c (rb_ary_flatten): ditto.
* gc.c (add_heap): a heap_slots may overflow. a patch from Stefan
Weil <weil at mail.berlios.de>.
* eval.c (rb_call): use separate cache for fcall/vcall
invocation.
* eval.c (rb_eval): NODE_FCALL, NODE_VCALL can call local
functions.
* eval.c (rb_mod_local): a new method to specify newly added
visibility "local".
* eval.c (search_method): search for local methods which are
visible only from the current class.
* class.c (rb_class_local_methods): a method to list local methods.
* object.c (Init_Object): add BasicObject class as a top level
BlankSlate class.
* ruby.h (SYM2ID): should not cast to signed long.
[ruby-core:07414]
* class.c (rb_include_module): allow module duplication.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10235 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-06-09 17:20:17 -04:00
|
|
|
etc_passwd(VALUE obj)
|
1998-01-16 07:13:05 -05:00
|
|
|
{
|
1999-08-13 01:37:52 -04:00
|
|
|
#ifdef HAVE_GETPWENT
|
1998-01-16 07:13:05 -05:00
|
|
|
struct passwd *pw;
|
|
|
|
|
2000-05-24 00:34:26 -04:00
|
|
|
if (rb_block_given_p()) {
|
2009-02-17 10:55:49 -05:00
|
|
|
each_passwd();
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
2015-04-18 23:19:20 -04:00
|
|
|
else if ((pw = getpwent()) != 0) {
|
1999-08-13 01:37:52 -04:00
|
|
|
return setup_passwd(pw);
|
|
|
|
}
|
1998-01-16 07:13:05 -05:00
|
|
|
#endif
|
1999-08-13 01:37:52 -04:00
|
|
|
return Qnil;
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
|
|
|
|
2012-12-07 02:08:06 -05:00
|
|
|
/* call-seq:
|
|
|
|
* Etc::Passwd.each { |struct| block } -> Passwd
|
|
|
|
* Etc::Passwd.each -> Enumerator
|
|
|
|
*
|
|
|
|
* Iterates for each entry in the /etc/passwd file if a block is given.
|
2009-02-17 10:55:49 -05:00
|
|
|
*
|
2012-12-07 02:08:06 -05:00
|
|
|
* If no block is given, returns the Enumerator.
|
|
|
|
*
|
|
|
|
* The code block is passed an Passwd struct.
|
|
|
|
*
|
|
|
|
* See ::getpwent above for details.
|
2009-02-17 10:55:49 -05:00
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
*
|
|
|
|
* require 'etc'
|
|
|
|
*
|
|
|
|
* Etc::Passwd.each {|u|
|
|
|
|
* puts u.name + " = " + u.gecos
|
|
|
|
* }
|
|
|
|
*
|
|
|
|
* Etc::Passwd.collect {|u| u.gecos}
|
|
|
|
* Etc::Passwd.collect {|u| u.gecos}
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
static VALUE
|
|
|
|
etc_each_passwd(VALUE obj)
|
|
|
|
{
|
|
|
|
#ifdef HAVE_GETPWENT
|
|
|
|
RETURN_ENUMERATOR(obj, 0, 0);
|
|
|
|
each_passwd();
|
|
|
|
#endif
|
|
|
|
return obj;
|
|
|
|
}
|
|
|
|
|
2005-11-01 08:04:35 -05:00
|
|
|
/* Resets the process of reading the /etc/passwd file, so that the next call
|
2012-12-07 02:08:06 -05:00
|
|
|
* to ::getpwent will return the first entry again.
|
2005-11-01 08:04:35 -05:00
|
|
|
*/
|
2003-10-01 09:41:35 -04:00
|
|
|
static VALUE
|
* sprintf.c (rb_str_format): allow %c to print one character
string (e.g. ?x).
* lib/tempfile.rb (Tempfile::make_tmpname): put dot between
basename and pid. [ruby-talk:196272]
* parse.y (do_block): remove -> style block.
* parse.y (parser_yylex): remove tLAMBDA_ARG.
* eval.c (rb_call0): binding for the return event hook should have
consistent scope. [ruby-core:07928]
* eval.c (proc_invoke): return behavior should depend whether it
is surrounded by a lambda or a mere block.
* eval.c (formal_assign): handles post splat arguments.
* eval.c (rb_call0): ditto.
* st.c (strhash): use FNV-1a hash.
* parse.y (parser_yylex): removed experimental ';;' terminator.
* eval.c (rb_node_arity): should be aware of post splat arguments.
* eval.c (rb_proc_arity): ditto.
* parse.y (f_args): syntax rule enhanced to support arguments
after the splat.
* parse.y (block_param): ditto for block parameters.
* parse.y (f_post_arg): mandatory formal arguments after the splat
argument.
* parse.y (new_args_gen): generate nodes for mandatory formal
arguments after the splat argument.
* eval.c (rb_eval): dispatch mandatory formal arguments after the
splat argument.
* parse.y (args): allow more than one splat in the argument list.
* parse.y (method_call): allow aref [] to accept all kind of
method argument, including assocs, splat, and block argument.
* eval.c (SETUP_ARGS0): prepare block argument as well.
* lib/mathn.rb (Integer): remove Integer#gcd2. [ruby-core:07931]
* eval.c (error_line): print receivers true/false/nil specially.
* eval.c (rb_proc_yield): handles parameters in yield semantics.
* eval.c (nil_yield): gives LocalJumpError to denote no block
error.
* io.c (rb_io_getc): now takes one-character string.
* string.c (rb_str_hash): use FNV-1a hash from Fowler/Noll/Vo
hashing algorithm.
* string.c (rb_str_aref): str[0] now returns 1 character string,
instead of a fixnum. [Ruby2]
* parse.y (parser_yylex): ?c now returns 1 character string,
instead of a fixnum. [Ruby2]
* string.c (rb_str_aset): no longer support fixnum insertion.
* eval.c (umethod_bind): should not update original class.
[ruby-dev:28636]
* eval.c (ev_const_get): should support constant access from
within instance_eval(). [ruby-dev:28327]
* time.c (time_timeval): should round for usec floating
number. [ruby-core:07896]
* time.c (time_add): ditto.
* dir.c (sys_warning): should not call a vararg function
rb_sys_warning() indirectly. [ruby-core:07886]
* numeric.c (flo_divmod): the first element of Float#divmod should
be an integer. [ruby-dev:28589]
* test/ruby/test_float.rb: add tests for divmod, div, modulo and remainder.
* re.c (rb_reg_initialize): should not allow modifying literal
regexps. frozen check moved from rb_reg_initialize_m as well.
* re.c (rb_reg_initialize): should not modify untainted objects in
safe levels higher than 3.
* re.c (rb_memcmp): type change from char* to const void*.
* dir.c (dir_close): should not close untainted dir stream.
* dir.c (GetDIR): add tainted/frozen check for each dir operation.
* lib/rdoc/parsers/parse_rb.rb (RDoc::RubyParser::parse_symbol_arg):
typo fixed. a patch from Florian Gross <florg at florg.net>.
* eval.c (EXEC_EVENT_HOOK): trace_func may remove itself from
event_hooks. no guarantee for arbitrary hook deletion.
[ruby-dev:28632]
* util.c (ruby_strtod): differ addition to minimize error.
[ruby-dev:28619]
* util.c (ruby_strtod): should not raise ERANGE when the input
string does not have any digits. [ruby-dev:28629]
* eval.c (proc_invoke): should restore old ruby_frame->block.
thanks to ts <decoux at moulon.inra.fr>. [ruby-core:07833]
also fix [ruby-dev:28614] as well.
* signal.c (trap): sig should be less then NSIG. Coverity found
this bug. a patch from Kevin Tew <tewk at tewk.com>.
[ruby-core:07823]
* math.c (math_log2): add new method inspired by
[ruby-talk:191237].
* math.c (math_log): add optional base argument to Math::log().
[ruby-talk:191308]
* ext/syck/emitter.c (syck_scan_scalar): avoid accessing
uninitialized array element. a patch from Pat Eyler
<rubypate at gmail.com>. [ruby-core:07809]
* array.c (rb_ary_fill): initialize local variables first. a
patch from Pat Eyler <rubypate at gmail.com>. [ruby-core:07810]
* ext/syck/yaml2byte.c (syck_yaml2byte_handler): need to free
type_tag. a patch from Pat Eyler <rubypate at gmail.com>.
[ruby-core:07808]
* ext/socket/socket.c (make_hostent_internal): accept ai_family
check from Sam Roberts <sroberts at uniserve.com>.
[ruby-core:07691]
* util.c (ruby_strtod): should not cut off 18 digits for no
reason. [ruby-core:07796]
* array.c (rb_ary_fill): internalize local variable "beg" to
pacify Coverity. [ruby-core:07770]
* pack.c (pack_unpack): now supports CRLF newlines. a patch from
<tommy at tmtm.org>. [ruby-dev:28601]
* applied code clean-up patch from Stefan Huehner
<stefan at huehner.org>. [ruby-core:07764]
* lib/jcode.rb (String::tr_s): should have translated non
squeezing character sequence (i.e. a character) as well. thanks
to Hiroshi Ichikawa <gimite at gimite.ddo.jp> [ruby-list:42090]
* ext/socket/socket.c: document update patch from Sam Roberts
<sroberts at uniserve.com>. [ruby-core:07701]
* lib/mathn.rb (Integer): need not to remove gcd2. a patch from
NARUSE, Yui <naruse at airemix.com>. [ruby-dev:28570]
* parse.y (arg): too much NEW_LIST()
* eval.c (SETUP_ARGS0): remove unnecessary access to nd_alen.
* eval.c (rb_eval): use ARGSCAT for NODE_OP_ASGN1.
[ruby-dev:28585]
* parse.y (arg): use NODE_ARGSCAT for placeholder.
* lib/getoptlong.rb (GetoptLong::get): RDoc update patch from
mathew <meta at pobox.com>. [ruby-core:07738]
* variable.c (rb_const_set): raise error when no target klass is
supplied. [ruby-dev:28582]
* prec.c (prec_prec_f): documentation patch from
<gerardo.santana at gmail.com>. [ruby-core:07689]
* bignum.c (rb_big_pow): second operand may be too big even if
it's a Fixnum. [ruby-talk:187984]
* README.EXT: update symbol description. [ruby-talk:188104]
* COPYING: explicitly note GPLv2. [ruby-talk:187922]
* parse.y: remove some obsolete syntax rules (unparenthesized
method calls in argument list).
* eval.c (rb_call0): insecure calling should be checked for non
NODE_SCOPE method invocations too.
* eval.c (rb_alias): should preserve the current safe level as
well as method definition.
* process.c (rb_f_sleep): remove RDoc description about SIGALRM
which is not valid on the current implementation. [ruby-dev:28464]
Thu Mar 23 21:40:47 2006 K.Kosako <sndgk393 AT ybb.ne.jp>
* eval.c (method_missing): should support argument splat in
super. a bug in combination of super, splat and
method_missing. [ruby-talk:185438]
* configure.in: Solaris SunPro compiler -rapth patch from
<kuwa at labs.fujitsu.com>. [ruby-dev:28443]
* configure.in: remove enable_rpath=no for Solaris.
[ruby-dev:28440]
* ext/win32ole/win32ole.c (ole_val2olevariantdata): change behavior
of converting OLE Variant object with VT_ARRAY|VT_UI1 and Ruby
String object.
* ruby.1: a clarification patch from David Lutterkort
<dlutter at redhat.com>. [ruby-core:7508]
* lib/rdoc/ri/ri_paths.rb (RI::Paths): adding paths from rubygems
directories. a patch from Eric Hodel <drbrain at segment7.net>.
[ruby-core:07423]
* eval.c (rb_clear_cache_by_class): clearing wrong cache.
* ext/extmk.rb: use :remove_destination to install extension libraries
to avoid SEGV. [ruby-dev:28417]
* eval.c (rb_thread_fd_writable): should not re-schedule output
from KILLED thread (must be error printing).
* array.c (rb_ary_flatten_bang): allow specifying recursion
level. [ruby-talk:182170]
* array.c (rb_ary_flatten): ditto.
* gc.c (add_heap): a heap_slots may overflow. a patch from Stefan
Weil <weil at mail.berlios.de>.
* eval.c (rb_call): use separate cache for fcall/vcall
invocation.
* eval.c (rb_eval): NODE_FCALL, NODE_VCALL can call local
functions.
* eval.c (rb_mod_local): a new method to specify newly added
visibility "local".
* eval.c (search_method): search for local methods which are
visible only from the current class.
* class.c (rb_class_local_methods): a method to list local methods.
* object.c (Init_Object): add BasicObject class as a top level
BlankSlate class.
* ruby.h (SYM2ID): should not cast to signed long.
[ruby-core:07414]
* class.c (rb_include_module): allow module duplication.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10235 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-06-09 17:20:17 -04:00
|
|
|
etc_setpwent(VALUE obj)
|
2003-10-01 09:41:35 -04:00
|
|
|
{
|
|
|
|
#ifdef HAVE_GETPWENT
|
|
|
|
setpwent();
|
|
|
|
#endif
|
|
|
|
return Qnil;
|
|
|
|
}
|
|
|
|
|
2005-11-01 08:04:35 -05:00
|
|
|
/* Ends the process of scanning through the /etc/passwd file begun with
|
2012-12-07 02:08:06 -05:00
|
|
|
* ::getpwent, and closes the file.
|
2005-11-01 08:04:35 -05:00
|
|
|
*/
|
2003-10-01 09:41:35 -04:00
|
|
|
static VALUE
|
* sprintf.c (rb_str_format): allow %c to print one character
string (e.g. ?x).
* lib/tempfile.rb (Tempfile::make_tmpname): put dot between
basename and pid. [ruby-talk:196272]
* parse.y (do_block): remove -> style block.
* parse.y (parser_yylex): remove tLAMBDA_ARG.
* eval.c (rb_call0): binding for the return event hook should have
consistent scope. [ruby-core:07928]
* eval.c (proc_invoke): return behavior should depend whether it
is surrounded by a lambda or a mere block.
* eval.c (formal_assign): handles post splat arguments.
* eval.c (rb_call0): ditto.
* st.c (strhash): use FNV-1a hash.
* parse.y (parser_yylex): removed experimental ';;' terminator.
* eval.c (rb_node_arity): should be aware of post splat arguments.
* eval.c (rb_proc_arity): ditto.
* parse.y (f_args): syntax rule enhanced to support arguments
after the splat.
* parse.y (block_param): ditto for block parameters.
* parse.y (f_post_arg): mandatory formal arguments after the splat
argument.
* parse.y (new_args_gen): generate nodes for mandatory formal
arguments after the splat argument.
* eval.c (rb_eval): dispatch mandatory formal arguments after the
splat argument.
* parse.y (args): allow more than one splat in the argument list.
* parse.y (method_call): allow aref [] to accept all kind of
method argument, including assocs, splat, and block argument.
* eval.c (SETUP_ARGS0): prepare block argument as well.
* lib/mathn.rb (Integer): remove Integer#gcd2. [ruby-core:07931]
* eval.c (error_line): print receivers true/false/nil specially.
* eval.c (rb_proc_yield): handles parameters in yield semantics.
* eval.c (nil_yield): gives LocalJumpError to denote no block
error.
* io.c (rb_io_getc): now takes one-character string.
* string.c (rb_str_hash): use FNV-1a hash from Fowler/Noll/Vo
hashing algorithm.
* string.c (rb_str_aref): str[0] now returns 1 character string,
instead of a fixnum. [Ruby2]
* parse.y (parser_yylex): ?c now returns 1 character string,
instead of a fixnum. [Ruby2]
* string.c (rb_str_aset): no longer support fixnum insertion.
* eval.c (umethod_bind): should not update original class.
[ruby-dev:28636]
* eval.c (ev_const_get): should support constant access from
within instance_eval(). [ruby-dev:28327]
* time.c (time_timeval): should round for usec floating
number. [ruby-core:07896]
* time.c (time_add): ditto.
* dir.c (sys_warning): should not call a vararg function
rb_sys_warning() indirectly. [ruby-core:07886]
* numeric.c (flo_divmod): the first element of Float#divmod should
be an integer. [ruby-dev:28589]
* test/ruby/test_float.rb: add tests for divmod, div, modulo and remainder.
* re.c (rb_reg_initialize): should not allow modifying literal
regexps. frozen check moved from rb_reg_initialize_m as well.
* re.c (rb_reg_initialize): should not modify untainted objects in
safe levels higher than 3.
* re.c (rb_memcmp): type change from char* to const void*.
* dir.c (dir_close): should not close untainted dir stream.
* dir.c (GetDIR): add tainted/frozen check for each dir operation.
* lib/rdoc/parsers/parse_rb.rb (RDoc::RubyParser::parse_symbol_arg):
typo fixed. a patch from Florian Gross <florg at florg.net>.
* eval.c (EXEC_EVENT_HOOK): trace_func may remove itself from
event_hooks. no guarantee for arbitrary hook deletion.
[ruby-dev:28632]
* util.c (ruby_strtod): differ addition to minimize error.
[ruby-dev:28619]
* util.c (ruby_strtod): should not raise ERANGE when the input
string does not have any digits. [ruby-dev:28629]
* eval.c (proc_invoke): should restore old ruby_frame->block.
thanks to ts <decoux at moulon.inra.fr>. [ruby-core:07833]
also fix [ruby-dev:28614] as well.
* signal.c (trap): sig should be less then NSIG. Coverity found
this bug. a patch from Kevin Tew <tewk at tewk.com>.
[ruby-core:07823]
* math.c (math_log2): add new method inspired by
[ruby-talk:191237].
* math.c (math_log): add optional base argument to Math::log().
[ruby-talk:191308]
* ext/syck/emitter.c (syck_scan_scalar): avoid accessing
uninitialized array element. a patch from Pat Eyler
<rubypate at gmail.com>. [ruby-core:07809]
* array.c (rb_ary_fill): initialize local variables first. a
patch from Pat Eyler <rubypate at gmail.com>. [ruby-core:07810]
* ext/syck/yaml2byte.c (syck_yaml2byte_handler): need to free
type_tag. a patch from Pat Eyler <rubypate at gmail.com>.
[ruby-core:07808]
* ext/socket/socket.c (make_hostent_internal): accept ai_family
check from Sam Roberts <sroberts at uniserve.com>.
[ruby-core:07691]
* util.c (ruby_strtod): should not cut off 18 digits for no
reason. [ruby-core:07796]
* array.c (rb_ary_fill): internalize local variable "beg" to
pacify Coverity. [ruby-core:07770]
* pack.c (pack_unpack): now supports CRLF newlines. a patch from
<tommy at tmtm.org>. [ruby-dev:28601]
* applied code clean-up patch from Stefan Huehner
<stefan at huehner.org>. [ruby-core:07764]
* lib/jcode.rb (String::tr_s): should have translated non
squeezing character sequence (i.e. a character) as well. thanks
to Hiroshi Ichikawa <gimite at gimite.ddo.jp> [ruby-list:42090]
* ext/socket/socket.c: document update patch from Sam Roberts
<sroberts at uniserve.com>. [ruby-core:07701]
* lib/mathn.rb (Integer): need not to remove gcd2. a patch from
NARUSE, Yui <naruse at airemix.com>. [ruby-dev:28570]
* parse.y (arg): too much NEW_LIST()
* eval.c (SETUP_ARGS0): remove unnecessary access to nd_alen.
* eval.c (rb_eval): use ARGSCAT for NODE_OP_ASGN1.
[ruby-dev:28585]
* parse.y (arg): use NODE_ARGSCAT for placeholder.
* lib/getoptlong.rb (GetoptLong::get): RDoc update patch from
mathew <meta at pobox.com>. [ruby-core:07738]
* variable.c (rb_const_set): raise error when no target klass is
supplied. [ruby-dev:28582]
* prec.c (prec_prec_f): documentation patch from
<gerardo.santana at gmail.com>. [ruby-core:07689]
* bignum.c (rb_big_pow): second operand may be too big even if
it's a Fixnum. [ruby-talk:187984]
* README.EXT: update symbol description. [ruby-talk:188104]
* COPYING: explicitly note GPLv2. [ruby-talk:187922]
* parse.y: remove some obsolete syntax rules (unparenthesized
method calls in argument list).
* eval.c (rb_call0): insecure calling should be checked for non
NODE_SCOPE method invocations too.
* eval.c (rb_alias): should preserve the current safe level as
well as method definition.
* process.c (rb_f_sleep): remove RDoc description about SIGALRM
which is not valid on the current implementation. [ruby-dev:28464]
Thu Mar 23 21:40:47 2006 K.Kosako <sndgk393 AT ybb.ne.jp>
* eval.c (method_missing): should support argument splat in
super. a bug in combination of super, splat and
method_missing. [ruby-talk:185438]
* configure.in: Solaris SunPro compiler -rapth patch from
<kuwa at labs.fujitsu.com>. [ruby-dev:28443]
* configure.in: remove enable_rpath=no for Solaris.
[ruby-dev:28440]
* ext/win32ole/win32ole.c (ole_val2olevariantdata): change behavior
of converting OLE Variant object with VT_ARRAY|VT_UI1 and Ruby
String object.
* ruby.1: a clarification patch from David Lutterkort
<dlutter at redhat.com>. [ruby-core:7508]
* lib/rdoc/ri/ri_paths.rb (RI::Paths): adding paths from rubygems
directories. a patch from Eric Hodel <drbrain at segment7.net>.
[ruby-core:07423]
* eval.c (rb_clear_cache_by_class): clearing wrong cache.
* ext/extmk.rb: use :remove_destination to install extension libraries
to avoid SEGV. [ruby-dev:28417]
* eval.c (rb_thread_fd_writable): should not re-schedule output
from KILLED thread (must be error printing).
* array.c (rb_ary_flatten_bang): allow specifying recursion
level. [ruby-talk:182170]
* array.c (rb_ary_flatten): ditto.
* gc.c (add_heap): a heap_slots may overflow. a patch from Stefan
Weil <weil at mail.berlios.de>.
* eval.c (rb_call): use separate cache for fcall/vcall
invocation.
* eval.c (rb_eval): NODE_FCALL, NODE_VCALL can call local
functions.
* eval.c (rb_mod_local): a new method to specify newly added
visibility "local".
* eval.c (search_method): search for local methods which are
visible only from the current class.
* class.c (rb_class_local_methods): a method to list local methods.
* object.c (Init_Object): add BasicObject class as a top level
BlankSlate class.
* ruby.h (SYM2ID): should not cast to signed long.
[ruby-core:07414]
* class.c (rb_include_module): allow module duplication.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10235 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-06-09 17:20:17 -04:00
|
|
|
etc_endpwent(VALUE obj)
|
2003-10-01 09:41:35 -04:00
|
|
|
{
|
|
|
|
#ifdef HAVE_GETPWENT
|
|
|
|
endpwent();
|
|
|
|
#endif
|
|
|
|
return Qnil;
|
|
|
|
}
|
|
|
|
|
2012-12-07 02:08:06 -05:00
|
|
|
/* Returns an entry from the /etc/passwd file.
|
2005-11-01 08:04:35 -05:00
|
|
|
*
|
2012-12-07 02:08:06 -05:00
|
|
|
* The first time it is called it opens the file and returns the first entry;
|
|
|
|
* each successive call returns the next entry, or +nil+ if the end of the file
|
|
|
|
* has been reached.
|
2005-11-01 08:04:35 -05:00
|
|
|
*
|
2012-12-07 02:08:06 -05:00
|
|
|
* To close the file when processing is complete, call ::endpwent.
|
2005-11-01 08:04:35 -05:00
|
|
|
*
|
2012-12-07 02:08:06 -05:00
|
|
|
* Each entry is returned as a Passwd struct.
|
2005-11-01 08:04:35 -05:00
|
|
|
*
|
|
|
|
*/
|
2003-10-01 09:41:35 -04:00
|
|
|
static VALUE
|
* sprintf.c (rb_str_format): allow %c to print one character
string (e.g. ?x).
* lib/tempfile.rb (Tempfile::make_tmpname): put dot between
basename and pid. [ruby-talk:196272]
* parse.y (do_block): remove -> style block.
* parse.y (parser_yylex): remove tLAMBDA_ARG.
* eval.c (rb_call0): binding for the return event hook should have
consistent scope. [ruby-core:07928]
* eval.c (proc_invoke): return behavior should depend whether it
is surrounded by a lambda or a mere block.
* eval.c (formal_assign): handles post splat arguments.
* eval.c (rb_call0): ditto.
* st.c (strhash): use FNV-1a hash.
* parse.y (parser_yylex): removed experimental ';;' terminator.
* eval.c (rb_node_arity): should be aware of post splat arguments.
* eval.c (rb_proc_arity): ditto.
* parse.y (f_args): syntax rule enhanced to support arguments
after the splat.
* parse.y (block_param): ditto for block parameters.
* parse.y (f_post_arg): mandatory formal arguments after the splat
argument.
* parse.y (new_args_gen): generate nodes for mandatory formal
arguments after the splat argument.
* eval.c (rb_eval): dispatch mandatory formal arguments after the
splat argument.
* parse.y (args): allow more than one splat in the argument list.
* parse.y (method_call): allow aref [] to accept all kind of
method argument, including assocs, splat, and block argument.
* eval.c (SETUP_ARGS0): prepare block argument as well.
* lib/mathn.rb (Integer): remove Integer#gcd2. [ruby-core:07931]
* eval.c (error_line): print receivers true/false/nil specially.
* eval.c (rb_proc_yield): handles parameters in yield semantics.
* eval.c (nil_yield): gives LocalJumpError to denote no block
error.
* io.c (rb_io_getc): now takes one-character string.
* string.c (rb_str_hash): use FNV-1a hash from Fowler/Noll/Vo
hashing algorithm.
* string.c (rb_str_aref): str[0] now returns 1 character string,
instead of a fixnum. [Ruby2]
* parse.y (parser_yylex): ?c now returns 1 character string,
instead of a fixnum. [Ruby2]
* string.c (rb_str_aset): no longer support fixnum insertion.
* eval.c (umethod_bind): should not update original class.
[ruby-dev:28636]
* eval.c (ev_const_get): should support constant access from
within instance_eval(). [ruby-dev:28327]
* time.c (time_timeval): should round for usec floating
number. [ruby-core:07896]
* time.c (time_add): ditto.
* dir.c (sys_warning): should not call a vararg function
rb_sys_warning() indirectly. [ruby-core:07886]
* numeric.c (flo_divmod): the first element of Float#divmod should
be an integer. [ruby-dev:28589]
* test/ruby/test_float.rb: add tests for divmod, div, modulo and remainder.
* re.c (rb_reg_initialize): should not allow modifying literal
regexps. frozen check moved from rb_reg_initialize_m as well.
* re.c (rb_reg_initialize): should not modify untainted objects in
safe levels higher than 3.
* re.c (rb_memcmp): type change from char* to const void*.
* dir.c (dir_close): should not close untainted dir stream.
* dir.c (GetDIR): add tainted/frozen check for each dir operation.
* lib/rdoc/parsers/parse_rb.rb (RDoc::RubyParser::parse_symbol_arg):
typo fixed. a patch from Florian Gross <florg at florg.net>.
* eval.c (EXEC_EVENT_HOOK): trace_func may remove itself from
event_hooks. no guarantee for arbitrary hook deletion.
[ruby-dev:28632]
* util.c (ruby_strtod): differ addition to minimize error.
[ruby-dev:28619]
* util.c (ruby_strtod): should not raise ERANGE when the input
string does not have any digits. [ruby-dev:28629]
* eval.c (proc_invoke): should restore old ruby_frame->block.
thanks to ts <decoux at moulon.inra.fr>. [ruby-core:07833]
also fix [ruby-dev:28614] as well.
* signal.c (trap): sig should be less then NSIG. Coverity found
this bug. a patch from Kevin Tew <tewk at tewk.com>.
[ruby-core:07823]
* math.c (math_log2): add new method inspired by
[ruby-talk:191237].
* math.c (math_log): add optional base argument to Math::log().
[ruby-talk:191308]
* ext/syck/emitter.c (syck_scan_scalar): avoid accessing
uninitialized array element. a patch from Pat Eyler
<rubypate at gmail.com>. [ruby-core:07809]
* array.c (rb_ary_fill): initialize local variables first. a
patch from Pat Eyler <rubypate at gmail.com>. [ruby-core:07810]
* ext/syck/yaml2byte.c (syck_yaml2byte_handler): need to free
type_tag. a patch from Pat Eyler <rubypate at gmail.com>.
[ruby-core:07808]
* ext/socket/socket.c (make_hostent_internal): accept ai_family
check from Sam Roberts <sroberts at uniserve.com>.
[ruby-core:07691]
* util.c (ruby_strtod): should not cut off 18 digits for no
reason. [ruby-core:07796]
* array.c (rb_ary_fill): internalize local variable "beg" to
pacify Coverity. [ruby-core:07770]
* pack.c (pack_unpack): now supports CRLF newlines. a patch from
<tommy at tmtm.org>. [ruby-dev:28601]
* applied code clean-up patch from Stefan Huehner
<stefan at huehner.org>. [ruby-core:07764]
* lib/jcode.rb (String::tr_s): should have translated non
squeezing character sequence (i.e. a character) as well. thanks
to Hiroshi Ichikawa <gimite at gimite.ddo.jp> [ruby-list:42090]
* ext/socket/socket.c: document update patch from Sam Roberts
<sroberts at uniserve.com>. [ruby-core:07701]
* lib/mathn.rb (Integer): need not to remove gcd2. a patch from
NARUSE, Yui <naruse at airemix.com>. [ruby-dev:28570]
* parse.y (arg): too much NEW_LIST()
* eval.c (SETUP_ARGS0): remove unnecessary access to nd_alen.
* eval.c (rb_eval): use ARGSCAT for NODE_OP_ASGN1.
[ruby-dev:28585]
* parse.y (arg): use NODE_ARGSCAT for placeholder.
* lib/getoptlong.rb (GetoptLong::get): RDoc update patch from
mathew <meta at pobox.com>. [ruby-core:07738]
* variable.c (rb_const_set): raise error when no target klass is
supplied. [ruby-dev:28582]
* prec.c (prec_prec_f): documentation patch from
<gerardo.santana at gmail.com>. [ruby-core:07689]
* bignum.c (rb_big_pow): second operand may be too big even if
it's a Fixnum. [ruby-talk:187984]
* README.EXT: update symbol description. [ruby-talk:188104]
* COPYING: explicitly note GPLv2. [ruby-talk:187922]
* parse.y: remove some obsolete syntax rules (unparenthesized
method calls in argument list).
* eval.c (rb_call0): insecure calling should be checked for non
NODE_SCOPE method invocations too.
* eval.c (rb_alias): should preserve the current safe level as
well as method definition.
* process.c (rb_f_sleep): remove RDoc description about SIGALRM
which is not valid on the current implementation. [ruby-dev:28464]
Thu Mar 23 21:40:47 2006 K.Kosako <sndgk393 AT ybb.ne.jp>
* eval.c (method_missing): should support argument splat in
super. a bug in combination of super, splat and
method_missing. [ruby-talk:185438]
* configure.in: Solaris SunPro compiler -rapth patch from
<kuwa at labs.fujitsu.com>. [ruby-dev:28443]
* configure.in: remove enable_rpath=no for Solaris.
[ruby-dev:28440]
* ext/win32ole/win32ole.c (ole_val2olevariantdata): change behavior
of converting OLE Variant object with VT_ARRAY|VT_UI1 and Ruby
String object.
* ruby.1: a clarification patch from David Lutterkort
<dlutter at redhat.com>. [ruby-core:7508]
* lib/rdoc/ri/ri_paths.rb (RI::Paths): adding paths from rubygems
directories. a patch from Eric Hodel <drbrain at segment7.net>.
[ruby-core:07423]
* eval.c (rb_clear_cache_by_class): clearing wrong cache.
* ext/extmk.rb: use :remove_destination to install extension libraries
to avoid SEGV. [ruby-dev:28417]
* eval.c (rb_thread_fd_writable): should not re-schedule output
from KILLED thread (must be error printing).
* array.c (rb_ary_flatten_bang): allow specifying recursion
level. [ruby-talk:182170]
* array.c (rb_ary_flatten): ditto.
* gc.c (add_heap): a heap_slots may overflow. a patch from Stefan
Weil <weil at mail.berlios.de>.
* eval.c (rb_call): use separate cache for fcall/vcall
invocation.
* eval.c (rb_eval): NODE_FCALL, NODE_VCALL can call local
functions.
* eval.c (rb_mod_local): a new method to specify newly added
visibility "local".
* eval.c (search_method): search for local methods which are
visible only from the current class.
* class.c (rb_class_local_methods): a method to list local methods.
* object.c (Init_Object): add BasicObject class as a top level
BlankSlate class.
* ruby.h (SYM2ID): should not cast to signed long.
[ruby-core:07414]
* class.c (rb_include_module): allow module duplication.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10235 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-06-09 17:20:17 -04:00
|
|
|
etc_getpwent(VALUE obj)
|
2003-10-01 09:41:35 -04:00
|
|
|
{
|
|
|
|
#ifdef HAVE_GETPWENT
|
|
|
|
struct passwd *pw;
|
|
|
|
|
2015-04-18 23:19:20 -04:00
|
|
|
if ((pw = getpwent()) != 0) {
|
2003-10-01 09:41:35 -04:00
|
|
|
return setup_passwd(pw);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
return Qnil;
|
|
|
|
}
|
|
|
|
|
1998-01-16 07:13:05 -05:00
|
|
|
#ifdef HAVE_GETGRENT
|
|
|
|
static VALUE
|
* sprintf.c (rb_str_format): allow %c to print one character
string (e.g. ?x).
* lib/tempfile.rb (Tempfile::make_tmpname): put dot between
basename and pid. [ruby-talk:196272]
* parse.y (do_block): remove -> style block.
* parse.y (parser_yylex): remove tLAMBDA_ARG.
* eval.c (rb_call0): binding for the return event hook should have
consistent scope. [ruby-core:07928]
* eval.c (proc_invoke): return behavior should depend whether it
is surrounded by a lambda or a mere block.
* eval.c (formal_assign): handles post splat arguments.
* eval.c (rb_call0): ditto.
* st.c (strhash): use FNV-1a hash.
* parse.y (parser_yylex): removed experimental ';;' terminator.
* eval.c (rb_node_arity): should be aware of post splat arguments.
* eval.c (rb_proc_arity): ditto.
* parse.y (f_args): syntax rule enhanced to support arguments
after the splat.
* parse.y (block_param): ditto for block parameters.
* parse.y (f_post_arg): mandatory formal arguments after the splat
argument.
* parse.y (new_args_gen): generate nodes for mandatory formal
arguments after the splat argument.
* eval.c (rb_eval): dispatch mandatory formal arguments after the
splat argument.
* parse.y (args): allow more than one splat in the argument list.
* parse.y (method_call): allow aref [] to accept all kind of
method argument, including assocs, splat, and block argument.
* eval.c (SETUP_ARGS0): prepare block argument as well.
* lib/mathn.rb (Integer): remove Integer#gcd2. [ruby-core:07931]
* eval.c (error_line): print receivers true/false/nil specially.
* eval.c (rb_proc_yield): handles parameters in yield semantics.
* eval.c (nil_yield): gives LocalJumpError to denote no block
error.
* io.c (rb_io_getc): now takes one-character string.
* string.c (rb_str_hash): use FNV-1a hash from Fowler/Noll/Vo
hashing algorithm.
* string.c (rb_str_aref): str[0] now returns 1 character string,
instead of a fixnum. [Ruby2]
* parse.y (parser_yylex): ?c now returns 1 character string,
instead of a fixnum. [Ruby2]
* string.c (rb_str_aset): no longer support fixnum insertion.
* eval.c (umethod_bind): should not update original class.
[ruby-dev:28636]
* eval.c (ev_const_get): should support constant access from
within instance_eval(). [ruby-dev:28327]
* time.c (time_timeval): should round for usec floating
number. [ruby-core:07896]
* time.c (time_add): ditto.
* dir.c (sys_warning): should not call a vararg function
rb_sys_warning() indirectly. [ruby-core:07886]
* numeric.c (flo_divmod): the first element of Float#divmod should
be an integer. [ruby-dev:28589]
* test/ruby/test_float.rb: add tests for divmod, div, modulo and remainder.
* re.c (rb_reg_initialize): should not allow modifying literal
regexps. frozen check moved from rb_reg_initialize_m as well.
* re.c (rb_reg_initialize): should not modify untainted objects in
safe levels higher than 3.
* re.c (rb_memcmp): type change from char* to const void*.
* dir.c (dir_close): should not close untainted dir stream.
* dir.c (GetDIR): add tainted/frozen check for each dir operation.
* lib/rdoc/parsers/parse_rb.rb (RDoc::RubyParser::parse_symbol_arg):
typo fixed. a patch from Florian Gross <florg at florg.net>.
* eval.c (EXEC_EVENT_HOOK): trace_func may remove itself from
event_hooks. no guarantee for arbitrary hook deletion.
[ruby-dev:28632]
* util.c (ruby_strtod): differ addition to minimize error.
[ruby-dev:28619]
* util.c (ruby_strtod): should not raise ERANGE when the input
string does not have any digits. [ruby-dev:28629]
* eval.c (proc_invoke): should restore old ruby_frame->block.
thanks to ts <decoux at moulon.inra.fr>. [ruby-core:07833]
also fix [ruby-dev:28614] as well.
* signal.c (trap): sig should be less then NSIG. Coverity found
this bug. a patch from Kevin Tew <tewk at tewk.com>.
[ruby-core:07823]
* math.c (math_log2): add new method inspired by
[ruby-talk:191237].
* math.c (math_log): add optional base argument to Math::log().
[ruby-talk:191308]
* ext/syck/emitter.c (syck_scan_scalar): avoid accessing
uninitialized array element. a patch from Pat Eyler
<rubypate at gmail.com>. [ruby-core:07809]
* array.c (rb_ary_fill): initialize local variables first. a
patch from Pat Eyler <rubypate at gmail.com>. [ruby-core:07810]
* ext/syck/yaml2byte.c (syck_yaml2byte_handler): need to free
type_tag. a patch from Pat Eyler <rubypate at gmail.com>.
[ruby-core:07808]
* ext/socket/socket.c (make_hostent_internal): accept ai_family
check from Sam Roberts <sroberts at uniserve.com>.
[ruby-core:07691]
* util.c (ruby_strtod): should not cut off 18 digits for no
reason. [ruby-core:07796]
* array.c (rb_ary_fill): internalize local variable "beg" to
pacify Coverity. [ruby-core:07770]
* pack.c (pack_unpack): now supports CRLF newlines. a patch from
<tommy at tmtm.org>. [ruby-dev:28601]
* applied code clean-up patch from Stefan Huehner
<stefan at huehner.org>. [ruby-core:07764]
* lib/jcode.rb (String::tr_s): should have translated non
squeezing character sequence (i.e. a character) as well. thanks
to Hiroshi Ichikawa <gimite at gimite.ddo.jp> [ruby-list:42090]
* ext/socket/socket.c: document update patch from Sam Roberts
<sroberts at uniserve.com>. [ruby-core:07701]
* lib/mathn.rb (Integer): need not to remove gcd2. a patch from
NARUSE, Yui <naruse at airemix.com>. [ruby-dev:28570]
* parse.y (arg): too much NEW_LIST()
* eval.c (SETUP_ARGS0): remove unnecessary access to nd_alen.
* eval.c (rb_eval): use ARGSCAT for NODE_OP_ASGN1.
[ruby-dev:28585]
* parse.y (arg): use NODE_ARGSCAT for placeholder.
* lib/getoptlong.rb (GetoptLong::get): RDoc update patch from
mathew <meta at pobox.com>. [ruby-core:07738]
* variable.c (rb_const_set): raise error when no target klass is
supplied. [ruby-dev:28582]
* prec.c (prec_prec_f): documentation patch from
<gerardo.santana at gmail.com>. [ruby-core:07689]
* bignum.c (rb_big_pow): second operand may be too big even if
it's a Fixnum. [ruby-talk:187984]
* README.EXT: update symbol description. [ruby-talk:188104]
* COPYING: explicitly note GPLv2. [ruby-talk:187922]
* parse.y: remove some obsolete syntax rules (unparenthesized
method calls in argument list).
* eval.c (rb_call0): insecure calling should be checked for non
NODE_SCOPE method invocations too.
* eval.c (rb_alias): should preserve the current safe level as
well as method definition.
* process.c (rb_f_sleep): remove RDoc description about SIGALRM
which is not valid on the current implementation. [ruby-dev:28464]
Thu Mar 23 21:40:47 2006 K.Kosako <sndgk393 AT ybb.ne.jp>
* eval.c (method_missing): should support argument splat in
super. a bug in combination of super, splat and
method_missing. [ruby-talk:185438]
* configure.in: Solaris SunPro compiler -rapth patch from
<kuwa at labs.fujitsu.com>. [ruby-dev:28443]
* configure.in: remove enable_rpath=no for Solaris.
[ruby-dev:28440]
* ext/win32ole/win32ole.c (ole_val2olevariantdata): change behavior
of converting OLE Variant object with VT_ARRAY|VT_UI1 and Ruby
String object.
* ruby.1: a clarification patch from David Lutterkort
<dlutter at redhat.com>. [ruby-core:7508]
* lib/rdoc/ri/ri_paths.rb (RI::Paths): adding paths from rubygems
directories. a patch from Eric Hodel <drbrain at segment7.net>.
[ruby-core:07423]
* eval.c (rb_clear_cache_by_class): clearing wrong cache.
* ext/extmk.rb: use :remove_destination to install extension libraries
to avoid SEGV. [ruby-dev:28417]
* eval.c (rb_thread_fd_writable): should not re-schedule output
from KILLED thread (must be error printing).
* array.c (rb_ary_flatten_bang): allow specifying recursion
level. [ruby-talk:182170]
* array.c (rb_ary_flatten): ditto.
* gc.c (add_heap): a heap_slots may overflow. a patch from Stefan
Weil <weil at mail.berlios.de>.
* eval.c (rb_call): use separate cache for fcall/vcall
invocation.
* eval.c (rb_eval): NODE_FCALL, NODE_VCALL can call local
functions.
* eval.c (rb_mod_local): a new method to specify newly added
visibility "local".
* eval.c (search_method): search for local methods which are
visible only from the current class.
* class.c (rb_class_local_methods): a method to list local methods.
* object.c (Init_Object): add BasicObject class as a top level
BlankSlate class.
* ruby.h (SYM2ID): should not cast to signed long.
[ruby-core:07414]
* class.c (rb_include_module): allow module duplication.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10235 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-06-09 17:20:17 -04:00
|
|
|
setup_group(struct group *grp)
|
1998-01-16 07:13:05 -05:00
|
|
|
{
|
|
|
|
VALUE mem;
|
|
|
|
char **tbl;
|
|
|
|
|
1999-01-19 23:59:39 -05:00
|
|
|
mem = rb_ary_new();
|
1998-01-16 07:13:05 -05:00
|
|
|
tbl = grp->gr_mem;
|
|
|
|
while (*tbl) {
|
2013-08-02 20:46:10 -04:00
|
|
|
rb_ary_push(mem, safe_setup_locale_str(*tbl));
|
1998-01-16 07:13:05 -05:00
|
|
|
tbl++;
|
|
|
|
}
|
1999-01-19 23:59:39 -05:00
|
|
|
return rb_struct_new(sGroup,
|
2013-08-02 20:46:10 -04:00
|
|
|
safe_setup_locale_str(grp->gr_name),
|
2013-05-09 08:12:17 -04:00
|
|
|
#ifdef HAVE_STRUCT_GROUP_GR_PASSWD
|
* gc.c (Init_stack): stack region is far smaller than usual if
pthread is used.
* marshal.c (w_extended): singleton methods should not be checked
when dumping via marshal_dump() or _dump(). [ruby-talk:85909]
* file.c (getcwdofdrv): avoid using getcwd() directly, use
my_getcwd() instead.
* merged NeXT, OpenStep, Rhapsody ports patch from Eric Sunshine
<sunshine@sunshineco.com>. [ruby-core:01596]
* marshal.c (w_object): LINK check earlier than anything else,
i.e. do not dump TYPE_IVAR for already dumped objects.
(ruby-bugs PR#1220)
* eval.c (rb_eval): call "inherited" only when a new class is
generated; not on reopening.
* eval.c (eval): prepend error position in evaluating string to
* configure.in: revived NextStep, OpenStep, and Rhapsody ports which
had become unbuildable; enhanced --enable-fat-binary option so that
it accepts a list of desired architectures (rather than assuming a
fixed list), or defaults to a platform-appropriate list if user does
not provide an explicit list; made the default list of architectures
for MAB (fat binary) more comprehensive; now uses -fno-common even
when building the interpreter (in addition to using it for
extensions), thus allowing the interpreter to be embedded into a
plugin module of an external project (in addition to allowing
embedding directly into an application); added checks for
<netinet/in_systm.h> (needed by `socket' extension) and getcwd(); now
ensures that -I/usr/local/include is employed when extensions'
extconf.rb scripts invoke have_header() since extension checks on
NextStep and OpenStep will fail without it if the desired resource
resides in the /usr/local tree; fixed formatting of --help message.
* Makefile.in: $(LIBRUBY_A) rule now deletes the archive before
invoking $(AR) since `ar' on Apple/NeXT can not "update" MAB archives
(see configure's --enable-fat-binary option); added rule for new
missing/getcwd.c.
* defines.h: fixed endian handling during MAB build (see configure's
--enable-fat-binary option) to ensure that all portions of the
project see the correct WORDS_BIGENDIAN value (some extension modules
were getting the wrong endian setting); added missing constants
GETPGRP_VOID, WNOHANG, WUNTRACED, X_OK, and type pid_t for NextStep
and OpenStep; removed unnecessary and problematic HAVE_SYS_WAIT_H
define in NeXT section.
* dir.c: do not allow NAMLEN() macro to trust dirent::d_namlen on
NextStep since, on some installations, this value always resolves
uselessly to zero.
* dln.c: added error reporting to NextStep extension loader since the
previous behavior of failing silently was not useful; now ensures
that NSLINKMODULE_OPTION_BINDNOW compatibility constant is defined
for OpenStep and Rhapsody; no longer includes <mach-o/dyld.h> twice
on Rhapsody since this header lacks multiple-include protection,
which resulted in "redefinition" compilation errors.
* main.c: also create hard reference to objc_msgSend() on NeXT
platforms (in addition to Apple platforms).
* lib/mkmf.rb: now exports XCFLAGS from configure script to extension
makefiles so that extensions can be built MAB (see configure's
--enable-fat-binary option); also utilize XCFLAGS in cc_command()
(but not cpp_command() because MAB flags are incompatible with
direct invocation of `cpp').
* ext/curses/extconf.rb: now additionally checks for presence of these
curses functions which are not present on NextStep or Openstep:
bkgd(), bkgdset(), color(), curs(), getbkgd(), init(), scrl(), set(),
setscrreg(), wattroff(), wattron(), wattrset(), wbkgd(), wbkgdset(),
wscrl(), wsetscrreg()
* ext/curses/curses.c: added appropriate #ifdef's for additional set of
curses functions now checked by extconf.rb; fixed curses_bkgd() and
window_bkgd() to correctly return boolean result rather than numeric
result; fixed window_getbkgd() to correctly signal an error by
returning nil rather than -1.
* ext/etc/etc.c: setup_passwd() and setup_group() now check for null
pointers before invoking rb_tainted_str_new2() upon fields extracted
from `struct passwd' and `struct group' since null pointers in some
fields are common on NextStep/OpenStep (especially so for the
`pw_comment' field) and rb_tainted_str_new2() throws an exception
when it receives a null pointer.
* ext/pty/pty.c: include "util.h" for strdup()/ruby_strdup() for
platforms such as NextStep and OpenStep which lack strdup().
* ext/socket/getaddrinfo.c: cast first argument of getservbyname(),
gethostbyaddr(), and gethostbyname() from (const char*) to non-const
(char*) for older platforms such as NextStep and OpenStep.
* ext/socket/socket.c: include "util.h" for strdup()/ruby_strdup() for
platforms such as NextStep and OpenStep which lack strdup(); include
<netinet/in_systm.h> if present for NextStep and OpenStep; cast first
argument of gethostbyaddr() and getservbyname() from (const char*) to
non-const (char*) for older platforms.
* ext/syslog/syslog.c: include "util.h" for strdup()/ruby_strdup() for
platforms such as NextStep and OpenStep which lack strdup().
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@5002 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2003-11-21 23:00:03 -05:00
|
|
|
safe_setup_str(grp->gr_passwd),
|
2003-11-24 05:42:17 -05:00
|
|
|
#endif
|
* configure.in (pid_t, uid_t, gid_t): check if defined.
* intern.h, process.c, rubyio.h, ext/etc/etc.c, ext/pty/pty.c: use
rb_{pid,uid,gid}_t instead of plain int. [ruby-dev:30376]
* ext/etc/extconf.rb (PIDT2NUM, NUM2PIDT, UIDT2NUM, NUM2UIDT, GIDT2NUM,
NUM2GIDT): moved to configure.in.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@11770 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2007-02-17 23:13:09 -05:00
|
|
|
GIDT2NUM(grp->gr_gid),
|
1999-01-19 23:59:39 -05:00
|
|
|
mem);
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2012-12-07 02:08:06 -05:00
|
|
|
/* call-seq:
|
|
|
|
* getgrgid(group_id) -> Group
|
|
|
|
*
|
|
|
|
* Returns information about the group with specified integer +group_id+,
|
2005-11-01 08:04:35 -05:00
|
|
|
* as found in /etc/group.
|
|
|
|
*
|
2012-12-07 02:08:06 -05:00
|
|
|
* The information is returned as a Group struct.
|
|
|
|
*
|
|
|
|
* See the unix manpage for <code>getgrgid(3)</code> for more detail.
|
2005-11-01 08:04:35 -05:00
|
|
|
*
|
2012-12-07 02:08:06 -05:00
|
|
|
* === Example:
|
|
|
|
*
|
|
|
|
* Etc.getgrgid(100)
|
2013-04-12 11:16:00 -04:00
|
|
|
* #=> #<struct Etc::Group name="users", passwd="x", gid=100, mem=["meta", "root"]>
|
2005-11-01 08:04:35 -05:00
|
|
|
*
|
|
|
|
*/
|
1998-01-16 07:13:05 -05:00
|
|
|
static VALUE
|
2007-01-09 06:52:26 -05:00
|
|
|
etc_getgrgid(int argc, VALUE *argv, VALUE obj)
|
1998-01-16 07:13:05 -05:00
|
|
|
{
|
|
|
|
#ifdef HAVE_GETGRENT
|
2007-01-09 06:52:26 -05:00
|
|
|
VALUE id;
|
|
|
|
gid_t gid;
|
1998-01-16 07:13:05 -05:00
|
|
|
struct group *grp;
|
|
|
|
|
2007-01-09 06:52:26 -05:00
|
|
|
if (rb_scan_args(argc, argv, "01", &id) == 1) {
|
2007-02-18 08:56:15 -05:00
|
|
|
gid = NUM2GIDT(id);
|
2007-01-09 06:52:26 -05:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
gid = getgid();
|
|
|
|
}
|
1998-01-16 07:13:05 -05:00
|
|
|
grp = getgrgid(gid);
|
2008-10-26 05:07:37 -04:00
|
|
|
if (grp == 0) rb_raise(rb_eArgError, "can't find group for %d", (int)gid);
|
1998-01-16 07:13:05 -05:00
|
|
|
return setup_group(grp);
|
|
|
|
#else
|
|
|
|
return Qnil;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2012-12-07 02:08:06 -05:00
|
|
|
/* call-seq:
|
|
|
|
* getgrnam(name) -> Group
|
|
|
|
*
|
|
|
|
* Returns information about the group with specified +name+, as found in
|
|
|
|
* /etc/group.
|
|
|
|
*
|
|
|
|
* The information is returned as a Group struct.
|
2005-11-01 08:04:35 -05:00
|
|
|
*
|
2012-12-07 02:08:06 -05:00
|
|
|
* See the unix manpage for <code>getgrnam(3)</code> for more detail.
|
2005-11-01 08:04:35 -05:00
|
|
|
*
|
2012-12-07 02:08:06 -05:00
|
|
|
* === Example:
|
|
|
|
*
|
|
|
|
* Etc.getgrnam('users')
|
2013-04-12 11:16:00 -04:00
|
|
|
* #=> #<struct Etc::Group name="users", passwd="x", gid=100, mem=["meta", "root"]>
|
2005-11-01 08:04:35 -05:00
|
|
|
*
|
|
|
|
*/
|
1998-01-16 07:13:05 -05:00
|
|
|
static VALUE
|
* sprintf.c (rb_str_format): allow %c to print one character
string (e.g. ?x).
* lib/tempfile.rb (Tempfile::make_tmpname): put dot between
basename and pid. [ruby-talk:196272]
* parse.y (do_block): remove -> style block.
* parse.y (parser_yylex): remove tLAMBDA_ARG.
* eval.c (rb_call0): binding for the return event hook should have
consistent scope. [ruby-core:07928]
* eval.c (proc_invoke): return behavior should depend whether it
is surrounded by a lambda or a mere block.
* eval.c (formal_assign): handles post splat arguments.
* eval.c (rb_call0): ditto.
* st.c (strhash): use FNV-1a hash.
* parse.y (parser_yylex): removed experimental ';;' terminator.
* eval.c (rb_node_arity): should be aware of post splat arguments.
* eval.c (rb_proc_arity): ditto.
* parse.y (f_args): syntax rule enhanced to support arguments
after the splat.
* parse.y (block_param): ditto for block parameters.
* parse.y (f_post_arg): mandatory formal arguments after the splat
argument.
* parse.y (new_args_gen): generate nodes for mandatory formal
arguments after the splat argument.
* eval.c (rb_eval): dispatch mandatory formal arguments after the
splat argument.
* parse.y (args): allow more than one splat in the argument list.
* parse.y (method_call): allow aref [] to accept all kind of
method argument, including assocs, splat, and block argument.
* eval.c (SETUP_ARGS0): prepare block argument as well.
* lib/mathn.rb (Integer): remove Integer#gcd2. [ruby-core:07931]
* eval.c (error_line): print receivers true/false/nil specially.
* eval.c (rb_proc_yield): handles parameters in yield semantics.
* eval.c (nil_yield): gives LocalJumpError to denote no block
error.
* io.c (rb_io_getc): now takes one-character string.
* string.c (rb_str_hash): use FNV-1a hash from Fowler/Noll/Vo
hashing algorithm.
* string.c (rb_str_aref): str[0] now returns 1 character string,
instead of a fixnum. [Ruby2]
* parse.y (parser_yylex): ?c now returns 1 character string,
instead of a fixnum. [Ruby2]
* string.c (rb_str_aset): no longer support fixnum insertion.
* eval.c (umethod_bind): should not update original class.
[ruby-dev:28636]
* eval.c (ev_const_get): should support constant access from
within instance_eval(). [ruby-dev:28327]
* time.c (time_timeval): should round for usec floating
number. [ruby-core:07896]
* time.c (time_add): ditto.
* dir.c (sys_warning): should not call a vararg function
rb_sys_warning() indirectly. [ruby-core:07886]
* numeric.c (flo_divmod): the first element of Float#divmod should
be an integer. [ruby-dev:28589]
* test/ruby/test_float.rb: add tests for divmod, div, modulo and remainder.
* re.c (rb_reg_initialize): should not allow modifying literal
regexps. frozen check moved from rb_reg_initialize_m as well.
* re.c (rb_reg_initialize): should not modify untainted objects in
safe levels higher than 3.
* re.c (rb_memcmp): type change from char* to const void*.
* dir.c (dir_close): should not close untainted dir stream.
* dir.c (GetDIR): add tainted/frozen check for each dir operation.
* lib/rdoc/parsers/parse_rb.rb (RDoc::RubyParser::parse_symbol_arg):
typo fixed. a patch from Florian Gross <florg at florg.net>.
* eval.c (EXEC_EVENT_HOOK): trace_func may remove itself from
event_hooks. no guarantee for arbitrary hook deletion.
[ruby-dev:28632]
* util.c (ruby_strtod): differ addition to minimize error.
[ruby-dev:28619]
* util.c (ruby_strtod): should not raise ERANGE when the input
string does not have any digits. [ruby-dev:28629]
* eval.c (proc_invoke): should restore old ruby_frame->block.
thanks to ts <decoux at moulon.inra.fr>. [ruby-core:07833]
also fix [ruby-dev:28614] as well.
* signal.c (trap): sig should be less then NSIG. Coverity found
this bug. a patch from Kevin Tew <tewk at tewk.com>.
[ruby-core:07823]
* math.c (math_log2): add new method inspired by
[ruby-talk:191237].
* math.c (math_log): add optional base argument to Math::log().
[ruby-talk:191308]
* ext/syck/emitter.c (syck_scan_scalar): avoid accessing
uninitialized array element. a patch from Pat Eyler
<rubypate at gmail.com>. [ruby-core:07809]
* array.c (rb_ary_fill): initialize local variables first. a
patch from Pat Eyler <rubypate at gmail.com>. [ruby-core:07810]
* ext/syck/yaml2byte.c (syck_yaml2byte_handler): need to free
type_tag. a patch from Pat Eyler <rubypate at gmail.com>.
[ruby-core:07808]
* ext/socket/socket.c (make_hostent_internal): accept ai_family
check from Sam Roberts <sroberts at uniserve.com>.
[ruby-core:07691]
* util.c (ruby_strtod): should not cut off 18 digits for no
reason. [ruby-core:07796]
* array.c (rb_ary_fill): internalize local variable "beg" to
pacify Coverity. [ruby-core:07770]
* pack.c (pack_unpack): now supports CRLF newlines. a patch from
<tommy at tmtm.org>. [ruby-dev:28601]
* applied code clean-up patch from Stefan Huehner
<stefan at huehner.org>. [ruby-core:07764]
* lib/jcode.rb (String::tr_s): should have translated non
squeezing character sequence (i.e. a character) as well. thanks
to Hiroshi Ichikawa <gimite at gimite.ddo.jp> [ruby-list:42090]
* ext/socket/socket.c: document update patch from Sam Roberts
<sroberts at uniserve.com>. [ruby-core:07701]
* lib/mathn.rb (Integer): need not to remove gcd2. a patch from
NARUSE, Yui <naruse at airemix.com>. [ruby-dev:28570]
* parse.y (arg): too much NEW_LIST()
* eval.c (SETUP_ARGS0): remove unnecessary access to nd_alen.
* eval.c (rb_eval): use ARGSCAT for NODE_OP_ASGN1.
[ruby-dev:28585]
* parse.y (arg): use NODE_ARGSCAT for placeholder.
* lib/getoptlong.rb (GetoptLong::get): RDoc update patch from
mathew <meta at pobox.com>. [ruby-core:07738]
* variable.c (rb_const_set): raise error when no target klass is
supplied. [ruby-dev:28582]
* prec.c (prec_prec_f): documentation patch from
<gerardo.santana at gmail.com>. [ruby-core:07689]
* bignum.c (rb_big_pow): second operand may be too big even if
it's a Fixnum. [ruby-talk:187984]
* README.EXT: update symbol description. [ruby-talk:188104]
* COPYING: explicitly note GPLv2. [ruby-talk:187922]
* parse.y: remove some obsolete syntax rules (unparenthesized
method calls in argument list).
* eval.c (rb_call0): insecure calling should be checked for non
NODE_SCOPE method invocations too.
* eval.c (rb_alias): should preserve the current safe level as
well as method definition.
* process.c (rb_f_sleep): remove RDoc description about SIGALRM
which is not valid on the current implementation. [ruby-dev:28464]
Thu Mar 23 21:40:47 2006 K.Kosako <sndgk393 AT ybb.ne.jp>
* eval.c (method_missing): should support argument splat in
super. a bug in combination of super, splat and
method_missing. [ruby-talk:185438]
* configure.in: Solaris SunPro compiler -rapth patch from
<kuwa at labs.fujitsu.com>. [ruby-dev:28443]
* configure.in: remove enable_rpath=no for Solaris.
[ruby-dev:28440]
* ext/win32ole/win32ole.c (ole_val2olevariantdata): change behavior
of converting OLE Variant object with VT_ARRAY|VT_UI1 and Ruby
String object.
* ruby.1: a clarification patch from David Lutterkort
<dlutter at redhat.com>. [ruby-core:7508]
* lib/rdoc/ri/ri_paths.rb (RI::Paths): adding paths from rubygems
directories. a patch from Eric Hodel <drbrain at segment7.net>.
[ruby-core:07423]
* eval.c (rb_clear_cache_by_class): clearing wrong cache.
* ext/extmk.rb: use :remove_destination to install extension libraries
to avoid SEGV. [ruby-dev:28417]
* eval.c (rb_thread_fd_writable): should not re-schedule output
from KILLED thread (must be error printing).
* array.c (rb_ary_flatten_bang): allow specifying recursion
level. [ruby-talk:182170]
* array.c (rb_ary_flatten): ditto.
* gc.c (add_heap): a heap_slots may overflow. a patch from Stefan
Weil <weil at mail.berlios.de>.
* eval.c (rb_call): use separate cache for fcall/vcall
invocation.
* eval.c (rb_eval): NODE_FCALL, NODE_VCALL can call local
functions.
* eval.c (rb_mod_local): a new method to specify newly added
visibility "local".
* eval.c (search_method): search for local methods which are
visible only from the current class.
* class.c (rb_class_local_methods): a method to list local methods.
* object.c (Init_Object): add BasicObject class as a top level
BlankSlate class.
* ruby.h (SYM2ID): should not cast to signed long.
[ruby-core:07414]
* class.c (rb_include_module): allow module duplication.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10235 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-06-09 17:20:17 -04:00
|
|
|
etc_getgrnam(VALUE obj, VALUE nam)
|
1998-01-16 07:13:05 -05:00
|
|
|
{
|
|
|
|
#ifdef HAVE_GETGRENT
|
|
|
|
struct group *grp;
|
2017-09-30 04:35:23 -04:00
|
|
|
const char *p = StringValueCStr(nam);
|
1998-01-16 07:13:05 -05:00
|
|
|
|
2017-09-30 04:35:23 -04:00
|
|
|
grp = getgrnam(p);
|
2013-06-22 00:46:47 -04:00
|
|
|
if (grp == 0) rb_raise(rb_eArgError, "can't find group for %"PRIsVALUE, nam);
|
1998-01-16 07:13:05 -05:00
|
|
|
return setup_group(grp);
|
|
|
|
#else
|
|
|
|
return Qnil;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2002-05-29 01:20:39 -04:00
|
|
|
#ifdef HAVE_GETGRENT
|
2020-12-23 02:30:16 -05:00
|
|
|
static rb_atomic_t group_blocking;
|
2002-05-29 01:20:39 -04:00
|
|
|
static VALUE
|
2019-08-26 02:20:15 -04:00
|
|
|
group_ensure(VALUE _)
|
2002-05-29 01:20:39 -04:00
|
|
|
{
|
2012-05-13 10:00:16 -04:00
|
|
|
endgrent();
|
2021-01-10 21:14:28 -05:00
|
|
|
if (RUBY_ATOMIC_EXCHANGE(group_blocking, 0) != 1) {
|
|
|
|
rb_raise(rb_eRuntimeError, "unexpected group_blocking");
|
|
|
|
}
|
2002-05-29 01:20:39 -04:00
|
|
|
return Qnil;
|
|
|
|
}
|
|
|
|
|
2012-12-07 02:08:06 -05:00
|
|
|
|
2002-05-29 01:20:39 -04:00
|
|
|
static VALUE
|
2019-08-26 02:20:15 -04:00
|
|
|
group_iterate(VALUE _)
|
2002-05-29 01:20:39 -04:00
|
|
|
{
|
|
|
|
struct group *pw;
|
|
|
|
|
2003-10-01 09:41:35 -04:00
|
|
|
setgrent();
|
2015-04-18 23:19:20 -04:00
|
|
|
while ((pw = getgrent()) != 0) {
|
2002-05-29 01:20:39 -04:00
|
|
|
rb_yield(setup_group(pw));
|
|
|
|
}
|
|
|
|
return Qnil;
|
|
|
|
}
|
2009-02-17 10:55:49 -05:00
|
|
|
|
|
|
|
static void
|
|
|
|
each_group(void)
|
|
|
|
{
|
2020-12-23 02:30:16 -05:00
|
|
|
if (RUBY_ATOMIC_CAS(group_blocking, 0, 1)) {
|
2009-02-17 10:55:49 -05:00
|
|
|
rb_raise(rb_eRuntimeError, "parallel group iteration");
|
|
|
|
}
|
|
|
|
rb_ensure(group_iterate, 0, group_ensure, 0);
|
|
|
|
}
|
2002-05-29 01:20:39 -04:00
|
|
|
#endif
|
|
|
|
|
2010-04-22 04:04:13 -04:00
|
|
|
/* Provides a convenient Ruby iterator which executes a block for each entry
|
2005-11-01 08:04:35 -05:00
|
|
|
* in the /etc/group file.
|
|
|
|
*
|
2012-12-07 02:08:06 -05:00
|
|
|
* The code block is passed an Group struct.
|
|
|
|
*
|
|
|
|
* See ::getgrent above for details.
|
2005-11-01 08:04:35 -05:00
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
*
|
|
|
|
* require 'etc'
|
|
|
|
*
|
|
|
|
* Etc.group {|g|
|
|
|
|
* puts g.name + ": " + g.mem.join(', ')
|
|
|
|
* }
|
|
|
|
*
|
|
|
|
*/
|
1998-01-16 07:13:05 -05:00
|
|
|
static VALUE
|
* sprintf.c (rb_str_format): allow %c to print one character
string (e.g. ?x).
* lib/tempfile.rb (Tempfile::make_tmpname): put dot between
basename and pid. [ruby-talk:196272]
* parse.y (do_block): remove -> style block.
* parse.y (parser_yylex): remove tLAMBDA_ARG.
* eval.c (rb_call0): binding for the return event hook should have
consistent scope. [ruby-core:07928]
* eval.c (proc_invoke): return behavior should depend whether it
is surrounded by a lambda or a mere block.
* eval.c (formal_assign): handles post splat arguments.
* eval.c (rb_call0): ditto.
* st.c (strhash): use FNV-1a hash.
* parse.y (parser_yylex): removed experimental ';;' terminator.
* eval.c (rb_node_arity): should be aware of post splat arguments.
* eval.c (rb_proc_arity): ditto.
* parse.y (f_args): syntax rule enhanced to support arguments
after the splat.
* parse.y (block_param): ditto for block parameters.
* parse.y (f_post_arg): mandatory formal arguments after the splat
argument.
* parse.y (new_args_gen): generate nodes for mandatory formal
arguments after the splat argument.
* eval.c (rb_eval): dispatch mandatory formal arguments after the
splat argument.
* parse.y (args): allow more than one splat in the argument list.
* parse.y (method_call): allow aref [] to accept all kind of
method argument, including assocs, splat, and block argument.
* eval.c (SETUP_ARGS0): prepare block argument as well.
* lib/mathn.rb (Integer): remove Integer#gcd2. [ruby-core:07931]
* eval.c (error_line): print receivers true/false/nil specially.
* eval.c (rb_proc_yield): handles parameters in yield semantics.
* eval.c (nil_yield): gives LocalJumpError to denote no block
error.
* io.c (rb_io_getc): now takes one-character string.
* string.c (rb_str_hash): use FNV-1a hash from Fowler/Noll/Vo
hashing algorithm.
* string.c (rb_str_aref): str[0] now returns 1 character string,
instead of a fixnum. [Ruby2]
* parse.y (parser_yylex): ?c now returns 1 character string,
instead of a fixnum. [Ruby2]
* string.c (rb_str_aset): no longer support fixnum insertion.
* eval.c (umethod_bind): should not update original class.
[ruby-dev:28636]
* eval.c (ev_const_get): should support constant access from
within instance_eval(). [ruby-dev:28327]
* time.c (time_timeval): should round for usec floating
number. [ruby-core:07896]
* time.c (time_add): ditto.
* dir.c (sys_warning): should not call a vararg function
rb_sys_warning() indirectly. [ruby-core:07886]
* numeric.c (flo_divmod): the first element of Float#divmod should
be an integer. [ruby-dev:28589]
* test/ruby/test_float.rb: add tests for divmod, div, modulo and remainder.
* re.c (rb_reg_initialize): should not allow modifying literal
regexps. frozen check moved from rb_reg_initialize_m as well.
* re.c (rb_reg_initialize): should not modify untainted objects in
safe levels higher than 3.
* re.c (rb_memcmp): type change from char* to const void*.
* dir.c (dir_close): should not close untainted dir stream.
* dir.c (GetDIR): add tainted/frozen check for each dir operation.
* lib/rdoc/parsers/parse_rb.rb (RDoc::RubyParser::parse_symbol_arg):
typo fixed. a patch from Florian Gross <florg at florg.net>.
* eval.c (EXEC_EVENT_HOOK): trace_func may remove itself from
event_hooks. no guarantee for arbitrary hook deletion.
[ruby-dev:28632]
* util.c (ruby_strtod): differ addition to minimize error.
[ruby-dev:28619]
* util.c (ruby_strtod): should not raise ERANGE when the input
string does not have any digits. [ruby-dev:28629]
* eval.c (proc_invoke): should restore old ruby_frame->block.
thanks to ts <decoux at moulon.inra.fr>. [ruby-core:07833]
also fix [ruby-dev:28614] as well.
* signal.c (trap): sig should be less then NSIG. Coverity found
this bug. a patch from Kevin Tew <tewk at tewk.com>.
[ruby-core:07823]
* math.c (math_log2): add new method inspired by
[ruby-talk:191237].
* math.c (math_log): add optional base argument to Math::log().
[ruby-talk:191308]
* ext/syck/emitter.c (syck_scan_scalar): avoid accessing
uninitialized array element. a patch from Pat Eyler
<rubypate at gmail.com>. [ruby-core:07809]
* array.c (rb_ary_fill): initialize local variables first. a
patch from Pat Eyler <rubypate at gmail.com>. [ruby-core:07810]
* ext/syck/yaml2byte.c (syck_yaml2byte_handler): need to free
type_tag. a patch from Pat Eyler <rubypate at gmail.com>.
[ruby-core:07808]
* ext/socket/socket.c (make_hostent_internal): accept ai_family
check from Sam Roberts <sroberts at uniserve.com>.
[ruby-core:07691]
* util.c (ruby_strtod): should not cut off 18 digits for no
reason. [ruby-core:07796]
* array.c (rb_ary_fill): internalize local variable "beg" to
pacify Coverity. [ruby-core:07770]
* pack.c (pack_unpack): now supports CRLF newlines. a patch from
<tommy at tmtm.org>. [ruby-dev:28601]
* applied code clean-up patch from Stefan Huehner
<stefan at huehner.org>. [ruby-core:07764]
* lib/jcode.rb (String::tr_s): should have translated non
squeezing character sequence (i.e. a character) as well. thanks
to Hiroshi Ichikawa <gimite at gimite.ddo.jp> [ruby-list:42090]
* ext/socket/socket.c: document update patch from Sam Roberts
<sroberts at uniserve.com>. [ruby-core:07701]
* lib/mathn.rb (Integer): need not to remove gcd2. a patch from
NARUSE, Yui <naruse at airemix.com>. [ruby-dev:28570]
* parse.y (arg): too much NEW_LIST()
* eval.c (SETUP_ARGS0): remove unnecessary access to nd_alen.
* eval.c (rb_eval): use ARGSCAT for NODE_OP_ASGN1.
[ruby-dev:28585]
* parse.y (arg): use NODE_ARGSCAT for placeholder.
* lib/getoptlong.rb (GetoptLong::get): RDoc update patch from
mathew <meta at pobox.com>. [ruby-core:07738]
* variable.c (rb_const_set): raise error when no target klass is
supplied. [ruby-dev:28582]
* prec.c (prec_prec_f): documentation patch from
<gerardo.santana at gmail.com>. [ruby-core:07689]
* bignum.c (rb_big_pow): second operand may be too big even if
it's a Fixnum. [ruby-talk:187984]
* README.EXT: update symbol description. [ruby-talk:188104]
* COPYING: explicitly note GPLv2. [ruby-talk:187922]
* parse.y: remove some obsolete syntax rules (unparenthesized
method calls in argument list).
* eval.c (rb_call0): insecure calling should be checked for non
NODE_SCOPE method invocations too.
* eval.c (rb_alias): should preserve the current safe level as
well as method definition.
* process.c (rb_f_sleep): remove RDoc description about SIGALRM
which is not valid on the current implementation. [ruby-dev:28464]
Thu Mar 23 21:40:47 2006 K.Kosako <sndgk393 AT ybb.ne.jp>
* eval.c (method_missing): should support argument splat in
super. a bug in combination of super, splat and
method_missing. [ruby-talk:185438]
* configure.in: Solaris SunPro compiler -rapth patch from
<kuwa at labs.fujitsu.com>. [ruby-dev:28443]
* configure.in: remove enable_rpath=no for Solaris.
[ruby-dev:28440]
* ext/win32ole/win32ole.c (ole_val2olevariantdata): change behavior
of converting OLE Variant object with VT_ARRAY|VT_UI1 and Ruby
String object.
* ruby.1: a clarification patch from David Lutterkort
<dlutter at redhat.com>. [ruby-core:7508]
* lib/rdoc/ri/ri_paths.rb (RI::Paths): adding paths from rubygems
directories. a patch from Eric Hodel <drbrain at segment7.net>.
[ruby-core:07423]
* eval.c (rb_clear_cache_by_class): clearing wrong cache.
* ext/extmk.rb: use :remove_destination to install extension libraries
to avoid SEGV. [ruby-dev:28417]
* eval.c (rb_thread_fd_writable): should not re-schedule output
from KILLED thread (must be error printing).
* array.c (rb_ary_flatten_bang): allow specifying recursion
level. [ruby-talk:182170]
* array.c (rb_ary_flatten): ditto.
* gc.c (add_heap): a heap_slots may overflow. a patch from Stefan
Weil <weil at mail.berlios.de>.
* eval.c (rb_call): use separate cache for fcall/vcall
invocation.
* eval.c (rb_eval): NODE_FCALL, NODE_VCALL can call local
functions.
* eval.c (rb_mod_local): a new method to specify newly added
visibility "local".
* eval.c (search_method): search for local methods which are
visible only from the current class.
* class.c (rb_class_local_methods): a method to list local methods.
* object.c (Init_Object): add BasicObject class as a top level
BlankSlate class.
* ruby.h (SYM2ID): should not cast to signed long.
[ruby-core:07414]
* class.c (rb_include_module): allow module duplication.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10235 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-06-09 17:20:17 -04:00
|
|
|
etc_group(VALUE obj)
|
1998-01-16 07:13:05 -05:00
|
|
|
{
|
|
|
|
#ifdef HAVE_GETGRENT
|
|
|
|
struct group *grp;
|
|
|
|
|
2000-05-24 00:34:26 -04:00
|
|
|
if (rb_block_given_p()) {
|
2009-02-17 10:55:49 -05:00
|
|
|
each_group();
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
2015-04-18 23:19:20 -04:00
|
|
|
else if ((grp = getgrent()) != 0) {
|
1999-08-13 01:37:52 -04:00
|
|
|
return setup_group(grp);
|
|
|
|
}
|
1998-01-16 07:13:05 -05:00
|
|
|
#endif
|
1999-08-13 01:37:52 -04:00
|
|
|
return Qnil;
|
1998-01-16 07:13:05 -05:00
|
|
|
}
|
|
|
|
|
2009-10-28 01:51:33 -04:00
|
|
|
#ifdef HAVE_GETGRENT
|
2012-12-07 02:08:06 -05:00
|
|
|
/* call-seq:
|
|
|
|
* Etc::Group.each { |group| block } -> obj
|
|
|
|
* Etc::Group.each -> Enumerator
|
|
|
|
*
|
|
|
|
* Iterates for each entry in the /etc/group file if a block is given.
|
|
|
|
*
|
|
|
|
* If no block is given, returns the Enumerator.
|
2009-02-17 10:55:49 -05:00
|
|
|
*
|
2012-12-07 02:08:06 -05:00
|
|
|
* The code block is passed a Group struct.
|
2009-02-17 10:55:49 -05:00
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
*
|
|
|
|
* require 'etc'
|
|
|
|
*
|
|
|
|
* Etc::Group.each {|g|
|
|
|
|
* puts g.name + ": " + g.mem.join(', ')
|
|
|
|
* }
|
|
|
|
*
|
|
|
|
* Etc::Group.collect {|g| g.name}
|
|
|
|
* Etc::Group.select {|g| !g.mem.empty?}
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
static VALUE
|
|
|
|
etc_each_group(VALUE obj)
|
|
|
|
{
|
|
|
|
RETURN_ENUMERATOR(obj, 0, 0);
|
|
|
|
each_group();
|
|
|
|
return obj;
|
|
|
|
}
|
2009-02-19 01:14:27 -05:00
|
|
|
#endif
|
2009-02-17 10:55:49 -05:00
|
|
|
|
2005-11-01 08:04:35 -05:00
|
|
|
/* Resets the process of reading the /etc/group file, so that the next call
|
2012-12-07 02:08:06 -05:00
|
|
|
* to ::getgrent will return the first entry again.
|
2005-11-01 08:04:35 -05:00
|
|
|
*/
|
2003-10-01 09:41:35 -04:00
|
|
|
static VALUE
|
* sprintf.c (rb_str_format): allow %c to print one character
string (e.g. ?x).
* lib/tempfile.rb (Tempfile::make_tmpname): put dot between
basename and pid. [ruby-talk:196272]
* parse.y (do_block): remove -> style block.
* parse.y (parser_yylex): remove tLAMBDA_ARG.
* eval.c (rb_call0): binding for the return event hook should have
consistent scope. [ruby-core:07928]
* eval.c (proc_invoke): return behavior should depend whether it
is surrounded by a lambda or a mere block.
* eval.c (formal_assign): handles post splat arguments.
* eval.c (rb_call0): ditto.
* st.c (strhash): use FNV-1a hash.
* parse.y (parser_yylex): removed experimental ';;' terminator.
* eval.c (rb_node_arity): should be aware of post splat arguments.
* eval.c (rb_proc_arity): ditto.
* parse.y (f_args): syntax rule enhanced to support arguments
after the splat.
* parse.y (block_param): ditto for block parameters.
* parse.y (f_post_arg): mandatory formal arguments after the splat
argument.
* parse.y (new_args_gen): generate nodes for mandatory formal
arguments after the splat argument.
* eval.c (rb_eval): dispatch mandatory formal arguments after the
splat argument.
* parse.y (args): allow more than one splat in the argument list.
* parse.y (method_call): allow aref [] to accept all kind of
method argument, including assocs, splat, and block argument.
* eval.c (SETUP_ARGS0): prepare block argument as well.
* lib/mathn.rb (Integer): remove Integer#gcd2. [ruby-core:07931]
* eval.c (error_line): print receivers true/false/nil specially.
* eval.c (rb_proc_yield): handles parameters in yield semantics.
* eval.c (nil_yield): gives LocalJumpError to denote no block
error.
* io.c (rb_io_getc): now takes one-character string.
* string.c (rb_str_hash): use FNV-1a hash from Fowler/Noll/Vo
hashing algorithm.
* string.c (rb_str_aref): str[0] now returns 1 character string,
instead of a fixnum. [Ruby2]
* parse.y (parser_yylex): ?c now returns 1 character string,
instead of a fixnum. [Ruby2]
* string.c (rb_str_aset): no longer support fixnum insertion.
* eval.c (umethod_bind): should not update original class.
[ruby-dev:28636]
* eval.c (ev_const_get): should support constant access from
within instance_eval(). [ruby-dev:28327]
* time.c (time_timeval): should round for usec floating
number. [ruby-core:07896]
* time.c (time_add): ditto.
* dir.c (sys_warning): should not call a vararg function
rb_sys_warning() indirectly. [ruby-core:07886]
* numeric.c (flo_divmod): the first element of Float#divmod should
be an integer. [ruby-dev:28589]
* test/ruby/test_float.rb: add tests for divmod, div, modulo and remainder.
* re.c (rb_reg_initialize): should not allow modifying literal
regexps. frozen check moved from rb_reg_initialize_m as well.
* re.c (rb_reg_initialize): should not modify untainted objects in
safe levels higher than 3.
* re.c (rb_memcmp): type change from char* to const void*.
* dir.c (dir_close): should not close untainted dir stream.
* dir.c (GetDIR): add tainted/frozen check for each dir operation.
* lib/rdoc/parsers/parse_rb.rb (RDoc::RubyParser::parse_symbol_arg):
typo fixed. a patch from Florian Gross <florg at florg.net>.
* eval.c (EXEC_EVENT_HOOK): trace_func may remove itself from
event_hooks. no guarantee for arbitrary hook deletion.
[ruby-dev:28632]
* util.c (ruby_strtod): differ addition to minimize error.
[ruby-dev:28619]
* util.c (ruby_strtod): should not raise ERANGE when the input
string does not have any digits. [ruby-dev:28629]
* eval.c (proc_invoke): should restore old ruby_frame->block.
thanks to ts <decoux at moulon.inra.fr>. [ruby-core:07833]
also fix [ruby-dev:28614] as well.
* signal.c (trap): sig should be less then NSIG. Coverity found
this bug. a patch from Kevin Tew <tewk at tewk.com>.
[ruby-core:07823]
* math.c (math_log2): add new method inspired by
[ruby-talk:191237].
* math.c (math_log): add optional base argument to Math::log().
[ruby-talk:191308]
* ext/syck/emitter.c (syck_scan_scalar): avoid accessing
uninitialized array element. a patch from Pat Eyler
<rubypate at gmail.com>. [ruby-core:07809]
* array.c (rb_ary_fill): initialize local variables first. a
patch from Pat Eyler <rubypate at gmail.com>. [ruby-core:07810]
* ext/syck/yaml2byte.c (syck_yaml2byte_handler): need to free
type_tag. a patch from Pat Eyler <rubypate at gmail.com>.
[ruby-core:07808]
* ext/socket/socket.c (make_hostent_internal): accept ai_family
check from Sam Roberts <sroberts at uniserve.com>.
[ruby-core:07691]
* util.c (ruby_strtod): should not cut off 18 digits for no
reason. [ruby-core:07796]
* array.c (rb_ary_fill): internalize local variable "beg" to
pacify Coverity. [ruby-core:07770]
* pack.c (pack_unpack): now supports CRLF newlines. a patch from
<tommy at tmtm.org>. [ruby-dev:28601]
* applied code clean-up patch from Stefan Huehner
<stefan at huehner.org>. [ruby-core:07764]
* lib/jcode.rb (String::tr_s): should have translated non
squeezing character sequence (i.e. a character) as well. thanks
to Hiroshi Ichikawa <gimite at gimite.ddo.jp> [ruby-list:42090]
* ext/socket/socket.c: document update patch from Sam Roberts
<sroberts at uniserve.com>. [ruby-core:07701]
* lib/mathn.rb (Integer): need not to remove gcd2. a patch from
NARUSE, Yui <naruse at airemix.com>. [ruby-dev:28570]
* parse.y (arg): too much NEW_LIST()
* eval.c (SETUP_ARGS0): remove unnecessary access to nd_alen.
* eval.c (rb_eval): use ARGSCAT for NODE_OP_ASGN1.
[ruby-dev:28585]
* parse.y (arg): use NODE_ARGSCAT for placeholder.
* lib/getoptlong.rb (GetoptLong::get): RDoc update patch from
mathew <meta at pobox.com>. [ruby-core:07738]
* variable.c (rb_const_set): raise error when no target klass is
supplied. [ruby-dev:28582]
* prec.c (prec_prec_f): documentation patch from
<gerardo.santana at gmail.com>. [ruby-core:07689]
* bignum.c (rb_big_pow): second operand may be too big even if
it's a Fixnum. [ruby-talk:187984]
* README.EXT: update symbol description. [ruby-talk:188104]
* COPYING: explicitly note GPLv2. [ruby-talk:187922]
* parse.y: remove some obsolete syntax rules (unparenthesized
method calls in argument list).
* eval.c (rb_call0): insecure calling should be checked for non
NODE_SCOPE method invocations too.
* eval.c (rb_alias): should preserve the current safe level as
well as method definition.
* process.c (rb_f_sleep): remove RDoc description about SIGALRM
which is not valid on the current implementation. [ruby-dev:28464]
Thu Mar 23 21:40:47 2006 K.Kosako <sndgk393 AT ybb.ne.jp>
* eval.c (method_missing): should support argument splat in
super. a bug in combination of super, splat and
method_missing. [ruby-talk:185438]
* configure.in: Solaris SunPro compiler -rapth patch from
<kuwa at labs.fujitsu.com>. [ruby-dev:28443]
* configure.in: remove enable_rpath=no for Solaris.
[ruby-dev:28440]
* ext/win32ole/win32ole.c (ole_val2olevariantdata): change behavior
of converting OLE Variant object with VT_ARRAY|VT_UI1 and Ruby
String object.
* ruby.1: a clarification patch from David Lutterkort
<dlutter at redhat.com>. [ruby-core:7508]
* lib/rdoc/ri/ri_paths.rb (RI::Paths): adding paths from rubygems
directories. a patch from Eric Hodel <drbrain at segment7.net>.
[ruby-core:07423]
* eval.c (rb_clear_cache_by_class): clearing wrong cache.
* ext/extmk.rb: use :remove_destination to install extension libraries
to avoid SEGV. [ruby-dev:28417]
* eval.c (rb_thread_fd_writable): should not re-schedule output
from KILLED thread (must be error printing).
* array.c (rb_ary_flatten_bang): allow specifying recursion
level. [ruby-talk:182170]
* array.c (rb_ary_flatten): ditto.
* gc.c (add_heap): a heap_slots may overflow. a patch from Stefan
Weil <weil at mail.berlios.de>.
* eval.c (rb_call): use separate cache for fcall/vcall
invocation.
* eval.c (rb_eval): NODE_FCALL, NODE_VCALL can call local
functions.
* eval.c (rb_mod_local): a new method to specify newly added
visibility "local".
* eval.c (search_method): search for local methods which are
visible only from the current class.
* class.c (rb_class_local_methods): a method to list local methods.
* object.c (Init_Object): add BasicObject class as a top level
BlankSlate class.
* ruby.h (SYM2ID): should not cast to signed long.
[ruby-core:07414]
* class.c (rb_include_module): allow module duplication.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10235 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-06-09 17:20:17 -04:00
|
|
|
etc_setgrent(VALUE obj)
|
2003-10-01 09:41:35 -04:00
|
|
|
{
|
|
|
|
#ifdef HAVE_GETGRENT
|
|
|
|
setgrent();
|
|
|
|
#endif
|
|
|
|
return Qnil;
|
|
|
|
}
|
|
|
|
|
2010-04-22 04:04:13 -04:00
|
|
|
/* Ends the process of scanning through the /etc/group file begun by
|
2012-12-07 02:08:06 -05:00
|
|
|
* ::getgrent, and closes the file.
|
2005-11-01 08:04:35 -05:00
|
|
|
*/
|
2003-10-01 09:41:35 -04:00
|
|
|
static VALUE
|
* sprintf.c (rb_str_format): allow %c to print one character
string (e.g. ?x).
* lib/tempfile.rb (Tempfile::make_tmpname): put dot between
basename and pid. [ruby-talk:196272]
* parse.y (do_block): remove -> style block.
* parse.y (parser_yylex): remove tLAMBDA_ARG.
* eval.c (rb_call0): binding for the return event hook should have
consistent scope. [ruby-core:07928]
* eval.c (proc_invoke): return behavior should depend whether it
is surrounded by a lambda or a mere block.
* eval.c (formal_assign): handles post splat arguments.
* eval.c (rb_call0): ditto.
* st.c (strhash): use FNV-1a hash.
* parse.y (parser_yylex): removed experimental ';;' terminator.
* eval.c (rb_node_arity): should be aware of post splat arguments.
* eval.c (rb_proc_arity): ditto.
* parse.y (f_args): syntax rule enhanced to support arguments
after the splat.
* parse.y (block_param): ditto for block parameters.
* parse.y (f_post_arg): mandatory formal arguments after the splat
argument.
* parse.y (new_args_gen): generate nodes for mandatory formal
arguments after the splat argument.
* eval.c (rb_eval): dispatch mandatory formal arguments after the
splat argument.
* parse.y (args): allow more than one splat in the argument list.
* parse.y (method_call): allow aref [] to accept all kind of
method argument, including assocs, splat, and block argument.
* eval.c (SETUP_ARGS0): prepare block argument as well.
* lib/mathn.rb (Integer): remove Integer#gcd2. [ruby-core:07931]
* eval.c (error_line): print receivers true/false/nil specially.
* eval.c (rb_proc_yield): handles parameters in yield semantics.
* eval.c (nil_yield): gives LocalJumpError to denote no block
error.
* io.c (rb_io_getc): now takes one-character string.
* string.c (rb_str_hash): use FNV-1a hash from Fowler/Noll/Vo
hashing algorithm.
* string.c (rb_str_aref): str[0] now returns 1 character string,
instead of a fixnum. [Ruby2]
* parse.y (parser_yylex): ?c now returns 1 character string,
instead of a fixnum. [Ruby2]
* string.c (rb_str_aset): no longer support fixnum insertion.
* eval.c (umethod_bind): should not update original class.
[ruby-dev:28636]
* eval.c (ev_const_get): should support constant access from
within instance_eval(). [ruby-dev:28327]
* time.c (time_timeval): should round for usec floating
number. [ruby-core:07896]
* time.c (time_add): ditto.
* dir.c (sys_warning): should not call a vararg function
rb_sys_warning() indirectly. [ruby-core:07886]
* numeric.c (flo_divmod): the first element of Float#divmod should
be an integer. [ruby-dev:28589]
* test/ruby/test_float.rb: add tests for divmod, div, modulo and remainder.
* re.c (rb_reg_initialize): should not allow modifying literal
regexps. frozen check moved from rb_reg_initialize_m as well.
* re.c (rb_reg_initialize): should not modify untainted objects in
safe levels higher than 3.
* re.c (rb_memcmp): type change from char* to const void*.
* dir.c (dir_close): should not close untainted dir stream.
* dir.c (GetDIR): add tainted/frozen check for each dir operation.
* lib/rdoc/parsers/parse_rb.rb (RDoc::RubyParser::parse_symbol_arg):
typo fixed. a patch from Florian Gross <florg at florg.net>.
* eval.c (EXEC_EVENT_HOOK): trace_func may remove itself from
event_hooks. no guarantee for arbitrary hook deletion.
[ruby-dev:28632]
* util.c (ruby_strtod): differ addition to minimize error.
[ruby-dev:28619]
* util.c (ruby_strtod): should not raise ERANGE when the input
string does not have any digits. [ruby-dev:28629]
* eval.c (proc_invoke): should restore old ruby_frame->block.
thanks to ts <decoux at moulon.inra.fr>. [ruby-core:07833]
also fix [ruby-dev:28614] as well.
* signal.c (trap): sig should be less then NSIG. Coverity found
this bug. a patch from Kevin Tew <tewk at tewk.com>.
[ruby-core:07823]
* math.c (math_log2): add new method inspired by
[ruby-talk:191237].
* math.c (math_log): add optional base argument to Math::log().
[ruby-talk:191308]
* ext/syck/emitter.c (syck_scan_scalar): avoid accessing
uninitialized array element. a patch from Pat Eyler
<rubypate at gmail.com>. [ruby-core:07809]
* array.c (rb_ary_fill): initialize local variables first. a
patch from Pat Eyler <rubypate at gmail.com>. [ruby-core:07810]
* ext/syck/yaml2byte.c (syck_yaml2byte_handler): need to free
type_tag. a patch from Pat Eyler <rubypate at gmail.com>.
[ruby-core:07808]
* ext/socket/socket.c (make_hostent_internal): accept ai_family
check from Sam Roberts <sroberts at uniserve.com>.
[ruby-core:07691]
* util.c (ruby_strtod): should not cut off 18 digits for no
reason. [ruby-core:07796]
* array.c (rb_ary_fill): internalize local variable "beg" to
pacify Coverity. [ruby-core:07770]
* pack.c (pack_unpack): now supports CRLF newlines. a patch from
<tommy at tmtm.org>. [ruby-dev:28601]
* applied code clean-up patch from Stefan Huehner
<stefan at huehner.org>. [ruby-core:07764]
* lib/jcode.rb (String::tr_s): should have translated non
squeezing character sequence (i.e. a character) as well. thanks
to Hiroshi Ichikawa <gimite at gimite.ddo.jp> [ruby-list:42090]
* ext/socket/socket.c: document update patch from Sam Roberts
<sroberts at uniserve.com>. [ruby-core:07701]
* lib/mathn.rb (Integer): need not to remove gcd2. a patch from
NARUSE, Yui <naruse at airemix.com>. [ruby-dev:28570]
* parse.y (arg): too much NEW_LIST()
* eval.c (SETUP_ARGS0): remove unnecessary access to nd_alen.
* eval.c (rb_eval): use ARGSCAT for NODE_OP_ASGN1.
[ruby-dev:28585]
* parse.y (arg): use NODE_ARGSCAT for placeholder.
* lib/getoptlong.rb (GetoptLong::get): RDoc update patch from
mathew <meta at pobox.com>. [ruby-core:07738]
* variable.c (rb_const_set): raise error when no target klass is
supplied. [ruby-dev:28582]
* prec.c (prec_prec_f): documentation patch from
<gerardo.santana at gmail.com>. [ruby-core:07689]
* bignum.c (rb_big_pow): second operand may be too big even if
it's a Fixnum. [ruby-talk:187984]
* README.EXT: update symbol description. [ruby-talk:188104]
* COPYING: explicitly note GPLv2. [ruby-talk:187922]
* parse.y: remove some obsolete syntax rules (unparenthesized
method calls in argument list).
* eval.c (rb_call0): insecure calling should be checked for non
NODE_SCOPE method invocations too.
* eval.c (rb_alias): should preserve the current safe level as
well as method definition.
* process.c (rb_f_sleep): remove RDoc description about SIGALRM
which is not valid on the current implementation. [ruby-dev:28464]
Thu Mar 23 21:40:47 2006 K.Kosako <sndgk393 AT ybb.ne.jp>
* eval.c (method_missing): should support argument splat in
super. a bug in combination of super, splat and
method_missing. [ruby-talk:185438]
* configure.in: Solaris SunPro compiler -rapth patch from
<kuwa at labs.fujitsu.com>. [ruby-dev:28443]
* configure.in: remove enable_rpath=no for Solaris.
[ruby-dev:28440]
* ext/win32ole/win32ole.c (ole_val2olevariantdata): change behavior
of converting OLE Variant object with VT_ARRAY|VT_UI1 and Ruby
String object.
* ruby.1: a clarification patch from David Lutterkort
<dlutter at redhat.com>. [ruby-core:7508]
* lib/rdoc/ri/ri_paths.rb (RI::Paths): adding paths from rubygems
directories. a patch from Eric Hodel <drbrain at segment7.net>.
[ruby-core:07423]
* eval.c (rb_clear_cache_by_class): clearing wrong cache.
* ext/extmk.rb: use :remove_destination to install extension libraries
to avoid SEGV. [ruby-dev:28417]
* eval.c (rb_thread_fd_writable): should not re-schedule output
from KILLED thread (must be error printing).
* array.c (rb_ary_flatten_bang): allow specifying recursion
level. [ruby-talk:182170]
* array.c (rb_ary_flatten): ditto.
* gc.c (add_heap): a heap_slots may overflow. a patch from Stefan
Weil <weil at mail.berlios.de>.
* eval.c (rb_call): use separate cache for fcall/vcall
invocation.
* eval.c (rb_eval): NODE_FCALL, NODE_VCALL can call local
functions.
* eval.c (rb_mod_local): a new method to specify newly added
visibility "local".
* eval.c (search_method): search for local methods which are
visible only from the current class.
* class.c (rb_class_local_methods): a method to list local methods.
* object.c (Init_Object): add BasicObject class as a top level
BlankSlate class.
* ruby.h (SYM2ID): should not cast to signed long.
[ruby-core:07414]
* class.c (rb_include_module): allow module duplication.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10235 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-06-09 17:20:17 -04:00
|
|
|
etc_endgrent(VALUE obj)
|
2003-10-01 09:41:35 -04:00
|
|
|
{
|
|
|
|
#ifdef HAVE_GETGRENT
|
|
|
|
endgrent();
|
|
|
|
#endif
|
|
|
|
return Qnil;
|
|
|
|
}
|
|
|
|
|
2012-12-07 02:08:06 -05:00
|
|
|
/* Returns an entry from the /etc/group file.
|
2005-11-01 08:04:35 -05:00
|
|
|
*
|
2012-12-07 02:08:06 -05:00
|
|
|
* The first time it is called it opens the file and returns the first entry;
|
|
|
|
* each successive call returns the next entry, or +nil+ if the end of the file
|
|
|
|
* has been reached.
|
2005-11-01 08:04:35 -05:00
|
|
|
*
|
2012-12-07 02:08:06 -05:00
|
|
|
* To close the file when processing is complete, call ::endgrent.
|
2005-11-01 08:04:35 -05:00
|
|
|
*
|
2012-12-07 02:08:06 -05:00
|
|
|
* Each entry is returned as a Group struct
|
2005-11-01 08:04:35 -05:00
|
|
|
*/
|
2003-10-01 09:41:35 -04:00
|
|
|
static VALUE
|
* sprintf.c (rb_str_format): allow %c to print one character
string (e.g. ?x).
* lib/tempfile.rb (Tempfile::make_tmpname): put dot between
basename and pid. [ruby-talk:196272]
* parse.y (do_block): remove -> style block.
* parse.y (parser_yylex): remove tLAMBDA_ARG.
* eval.c (rb_call0): binding for the return event hook should have
consistent scope. [ruby-core:07928]
* eval.c (proc_invoke): return behavior should depend whether it
is surrounded by a lambda or a mere block.
* eval.c (formal_assign): handles post splat arguments.
* eval.c (rb_call0): ditto.
* st.c (strhash): use FNV-1a hash.
* parse.y (parser_yylex): removed experimental ';;' terminator.
* eval.c (rb_node_arity): should be aware of post splat arguments.
* eval.c (rb_proc_arity): ditto.
* parse.y (f_args): syntax rule enhanced to support arguments
after the splat.
* parse.y (block_param): ditto for block parameters.
* parse.y (f_post_arg): mandatory formal arguments after the splat
argument.
* parse.y (new_args_gen): generate nodes for mandatory formal
arguments after the splat argument.
* eval.c (rb_eval): dispatch mandatory formal arguments after the
splat argument.
* parse.y (args): allow more than one splat in the argument list.
* parse.y (method_call): allow aref [] to accept all kind of
method argument, including assocs, splat, and block argument.
* eval.c (SETUP_ARGS0): prepare block argument as well.
* lib/mathn.rb (Integer): remove Integer#gcd2. [ruby-core:07931]
* eval.c (error_line): print receivers true/false/nil specially.
* eval.c (rb_proc_yield): handles parameters in yield semantics.
* eval.c (nil_yield): gives LocalJumpError to denote no block
error.
* io.c (rb_io_getc): now takes one-character string.
* string.c (rb_str_hash): use FNV-1a hash from Fowler/Noll/Vo
hashing algorithm.
* string.c (rb_str_aref): str[0] now returns 1 character string,
instead of a fixnum. [Ruby2]
* parse.y (parser_yylex): ?c now returns 1 character string,
instead of a fixnum. [Ruby2]
* string.c (rb_str_aset): no longer support fixnum insertion.
* eval.c (umethod_bind): should not update original class.
[ruby-dev:28636]
* eval.c (ev_const_get): should support constant access from
within instance_eval(). [ruby-dev:28327]
* time.c (time_timeval): should round for usec floating
number. [ruby-core:07896]
* time.c (time_add): ditto.
* dir.c (sys_warning): should not call a vararg function
rb_sys_warning() indirectly. [ruby-core:07886]
* numeric.c (flo_divmod): the first element of Float#divmod should
be an integer. [ruby-dev:28589]
* test/ruby/test_float.rb: add tests for divmod, div, modulo and remainder.
* re.c (rb_reg_initialize): should not allow modifying literal
regexps. frozen check moved from rb_reg_initialize_m as well.
* re.c (rb_reg_initialize): should not modify untainted objects in
safe levels higher than 3.
* re.c (rb_memcmp): type change from char* to const void*.
* dir.c (dir_close): should not close untainted dir stream.
* dir.c (GetDIR): add tainted/frozen check for each dir operation.
* lib/rdoc/parsers/parse_rb.rb (RDoc::RubyParser::parse_symbol_arg):
typo fixed. a patch from Florian Gross <florg at florg.net>.
* eval.c (EXEC_EVENT_HOOK): trace_func may remove itself from
event_hooks. no guarantee for arbitrary hook deletion.
[ruby-dev:28632]
* util.c (ruby_strtod): differ addition to minimize error.
[ruby-dev:28619]
* util.c (ruby_strtod): should not raise ERANGE when the input
string does not have any digits. [ruby-dev:28629]
* eval.c (proc_invoke): should restore old ruby_frame->block.
thanks to ts <decoux at moulon.inra.fr>. [ruby-core:07833]
also fix [ruby-dev:28614] as well.
* signal.c (trap): sig should be less then NSIG. Coverity found
this bug. a patch from Kevin Tew <tewk at tewk.com>.
[ruby-core:07823]
* math.c (math_log2): add new method inspired by
[ruby-talk:191237].
* math.c (math_log): add optional base argument to Math::log().
[ruby-talk:191308]
* ext/syck/emitter.c (syck_scan_scalar): avoid accessing
uninitialized array element. a patch from Pat Eyler
<rubypate at gmail.com>. [ruby-core:07809]
* array.c (rb_ary_fill): initialize local variables first. a
patch from Pat Eyler <rubypate at gmail.com>. [ruby-core:07810]
* ext/syck/yaml2byte.c (syck_yaml2byte_handler): need to free
type_tag. a patch from Pat Eyler <rubypate at gmail.com>.
[ruby-core:07808]
* ext/socket/socket.c (make_hostent_internal): accept ai_family
check from Sam Roberts <sroberts at uniserve.com>.
[ruby-core:07691]
* util.c (ruby_strtod): should not cut off 18 digits for no
reason. [ruby-core:07796]
* array.c (rb_ary_fill): internalize local variable "beg" to
pacify Coverity. [ruby-core:07770]
* pack.c (pack_unpack): now supports CRLF newlines. a patch from
<tommy at tmtm.org>. [ruby-dev:28601]
* applied code clean-up patch from Stefan Huehner
<stefan at huehner.org>. [ruby-core:07764]
* lib/jcode.rb (String::tr_s): should have translated non
squeezing character sequence (i.e. a character) as well. thanks
to Hiroshi Ichikawa <gimite at gimite.ddo.jp> [ruby-list:42090]
* ext/socket/socket.c: document update patch from Sam Roberts
<sroberts at uniserve.com>. [ruby-core:07701]
* lib/mathn.rb (Integer): need not to remove gcd2. a patch from
NARUSE, Yui <naruse at airemix.com>. [ruby-dev:28570]
* parse.y (arg): too much NEW_LIST()
* eval.c (SETUP_ARGS0): remove unnecessary access to nd_alen.
* eval.c (rb_eval): use ARGSCAT for NODE_OP_ASGN1.
[ruby-dev:28585]
* parse.y (arg): use NODE_ARGSCAT for placeholder.
* lib/getoptlong.rb (GetoptLong::get): RDoc update patch from
mathew <meta at pobox.com>. [ruby-core:07738]
* variable.c (rb_const_set): raise error when no target klass is
supplied. [ruby-dev:28582]
* prec.c (prec_prec_f): documentation patch from
<gerardo.santana at gmail.com>. [ruby-core:07689]
* bignum.c (rb_big_pow): second operand may be too big even if
it's a Fixnum. [ruby-talk:187984]
* README.EXT: update symbol description. [ruby-talk:188104]
* COPYING: explicitly note GPLv2. [ruby-talk:187922]
* parse.y: remove some obsolete syntax rules (unparenthesized
method calls in argument list).
* eval.c (rb_call0): insecure calling should be checked for non
NODE_SCOPE method invocations too.
* eval.c (rb_alias): should preserve the current safe level as
well as method definition.
* process.c (rb_f_sleep): remove RDoc description about SIGALRM
which is not valid on the current implementation. [ruby-dev:28464]
Thu Mar 23 21:40:47 2006 K.Kosako <sndgk393 AT ybb.ne.jp>
* eval.c (method_missing): should support argument splat in
super. a bug in combination of super, splat and
method_missing. [ruby-talk:185438]
* configure.in: Solaris SunPro compiler -rapth patch from
<kuwa at labs.fujitsu.com>. [ruby-dev:28443]
* configure.in: remove enable_rpath=no for Solaris.
[ruby-dev:28440]
* ext/win32ole/win32ole.c (ole_val2olevariantdata): change behavior
of converting OLE Variant object with VT_ARRAY|VT_UI1 and Ruby
String object.
* ruby.1: a clarification patch from David Lutterkort
<dlutter at redhat.com>. [ruby-core:7508]
* lib/rdoc/ri/ri_paths.rb (RI::Paths): adding paths from rubygems
directories. a patch from Eric Hodel <drbrain at segment7.net>.
[ruby-core:07423]
* eval.c (rb_clear_cache_by_class): clearing wrong cache.
* ext/extmk.rb: use :remove_destination to install extension libraries
to avoid SEGV. [ruby-dev:28417]
* eval.c (rb_thread_fd_writable): should not re-schedule output
from KILLED thread (must be error printing).
* array.c (rb_ary_flatten_bang): allow specifying recursion
level. [ruby-talk:182170]
* array.c (rb_ary_flatten): ditto.
* gc.c (add_heap): a heap_slots may overflow. a patch from Stefan
Weil <weil at mail.berlios.de>.
* eval.c (rb_call): use separate cache for fcall/vcall
invocation.
* eval.c (rb_eval): NODE_FCALL, NODE_VCALL can call local
functions.
* eval.c (rb_mod_local): a new method to specify newly added
visibility "local".
* eval.c (search_method): search for local methods which are
visible only from the current class.
* class.c (rb_class_local_methods): a method to list local methods.
* object.c (Init_Object): add BasicObject class as a top level
BlankSlate class.
* ruby.h (SYM2ID): should not cast to signed long.
[ruby-core:07414]
* class.c (rb_include_module): allow module duplication.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@10235 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2006-06-09 17:20:17 -04:00
|
|
|
etc_getgrent(VALUE obj)
|
2003-10-01 09:41:35 -04:00
|
|
|
{
|
|
|
|
#ifdef HAVE_GETGRENT
|
|
|
|
struct group *gr;
|
|
|
|
|
2015-04-18 23:19:20 -04:00
|
|
|
if ((gr = getgrent()) != 0) {
|
2003-10-01 11:26:06 -04:00
|
|
|
return setup_group(gr);
|
2003-10-01 09:41:35 -04:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
return Qnil;
|
|
|
|
}
|
|
|
|
|
2011-02-08 10:47:52 -05:00
|
|
|
#define numberof(array) (sizeof(array) / sizeof(*(array)))
|
2010-05-07 23:25:17 -04:00
|
|
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
VALUE rb_w32_special_folder(int type);
|
|
|
|
UINT rb_w32_system_tmpdir(WCHAR *path, UINT len);
|
|
|
|
VALUE rb_w32_conv_from_wchar(const WCHAR *wstr, rb_encoding *enc);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
2012-12-07 02:08:06 -05:00
|
|
|
* Returns system configuration directory.
|
|
|
|
*
|
|
|
|
* This is typically "/etc", but is modified by the prefix used when Ruby was
|
2017-11-07 15:08:34 -05:00
|
|
|
* compiled. For example, if Ruby is built and installed in /usr/local,
|
|
|
|
* returns "/usr/local/etc" on other platforms than Windows.
|
|
|
|
* On Windows, this always returns the directory provided by the system.
|
2010-05-07 23:25:17 -04:00
|
|
|
*/
|
|
|
|
static VALUE
|
|
|
|
etc_sysconfdir(VALUE obj)
|
|
|
|
{
|
|
|
|
#ifdef _WIN32
|
|
|
|
return rb_w32_special_folder(CSIDL_COMMON_APPDATA);
|
|
|
|
#else
|
|
|
|
return rb_filesystem_str_new_cstr(SYSCONFDIR);
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2011-10-03 19:33:57 -04:00
|
|
|
* Returns system temporary directory; typically "/tmp".
|
2010-05-07 23:25:17 -04:00
|
|
|
*/
|
|
|
|
static VALUE
|
2019-08-28 04:48:48 -04:00
|
|
|
etc_systmpdir(VALUE _)
|
2010-05-07 23:25:17 -04:00
|
|
|
{
|
2010-09-09 18:29:16 -04:00
|
|
|
VALUE tmpdir;
|
2010-05-07 23:25:17 -04:00
|
|
|
#ifdef _WIN32
|
|
|
|
WCHAR path[_MAX_PATH];
|
|
|
|
UINT len = rb_w32_system_tmpdir(path, numberof(path));
|
|
|
|
if (!len) return Qnil;
|
2010-09-09 18:29:16 -04:00
|
|
|
tmpdir = rb_w32_conv_from_wchar(path, rb_filesystem_encoding());
|
2010-05-07 23:25:17 -04:00
|
|
|
#else
|
2014-10-06 22:17:10 -04:00
|
|
|
const char default_tmp[] = "/tmp";
|
|
|
|
const char *tmpstr = default_tmp;
|
2014-10-07 16:25:07 -04:00
|
|
|
size_t tmplen = strlen(default_tmp);
|
2014-10-06 22:17:10 -04:00
|
|
|
# if defined _CS_DARWIN_USER_TEMP_DIR
|
|
|
|
#ifndef MAXPATHLEN
|
|
|
|
#define MAXPATHLEN 1024
|
|
|
|
#endif
|
|
|
|
char path[MAXPATHLEN];
|
|
|
|
size_t len;
|
|
|
|
len = confstr(_CS_DARWIN_USER_TEMP_DIR, path, sizeof(path));
|
|
|
|
if (len > 0) {
|
|
|
|
tmpstr = path;
|
|
|
|
tmplen = len - 1;
|
2016-06-02 08:21:42 -04:00
|
|
|
if (len > sizeof(path)) tmpstr = 0;
|
2014-10-06 22:17:10 -04:00
|
|
|
}
|
|
|
|
# endif
|
|
|
|
tmpdir = rb_filesystem_str_new(tmpstr, tmplen);
|
2016-06-02 08:21:42 -04:00
|
|
|
# if defined _CS_DARWIN_USER_TEMP_DIR
|
|
|
|
if (!tmpstr) {
|
|
|
|
confstr(_CS_DARWIN_USER_TEMP_DIR, RSTRING_PTR(tmpdir), len);
|
|
|
|
}
|
|
|
|
# endif
|
2010-05-07 23:25:17 -04:00
|
|
|
#endif
|
2019-10-18 15:10:03 -04:00
|
|
|
#ifndef RB_PASS_KEYWORDS
|
|
|
|
/* untaint on Ruby < 2.7 */
|
* safe.c (rb_set_safe_level, safe_setter): raise an ArgumentError
when $SAFE is set to 4. $SAFE=4 is now obsolete.
[ruby-core:55222] [Feature #8468]
* object.c (rb_obj_untrusted, rb_obj_untrust, rb_obj_trust):
Kernel#untrusted?, untrust, and trust are now deprecated.
Their behavior is same as tainted?, taint, and untaint,
respectively.
* include/ruby/ruby.h (OBJ_UNTRUSTED, OBJ_UNTRUST): OBJ_UNTRUSTED()
and OBJ_UNTRUST() are aliases of OBJ_TAINTED() and OBJ_TAINT(),
respectively.
* array.c, class.c, debug.c, dir.c, encoding.c, error.c, eval.c,
ext/curses/curses.c, ext/dbm/dbm.c, ext/dl/cfunc.c,
ext/dl/cptr.c, ext/dl/dl.c, ext/etc/etc.c, ext/fiddle/fiddle.c,
ext/fiddle/pointer.c, ext/gdbm/gdbm.c, ext/readline/readline.c,
ext/sdbm/init.c, ext/socket/ancdata.c, ext/socket/basicsocket.c,
ext/socket/socket.c, ext/socket/udpsocket.c,
ext/stringio/stringio.c, ext/syslog/syslog.c, ext/tk/tcltklib.c,
ext/win32ole/win32ole.c, file.c, gc.c, hash.c, io.c, iseq.c,
load.c, marshal.c, object.c, proc.c, process.c, random.c, re.c,
safe.c, string.c, thread.c, transcode.c, variable.c,
vm_insnhelper.c, vm_method.c, vm_trace.c: remove code for
$SAFE=4.
* test/dl/test_dl2.rb, test/erb/test_erb.rb,
test/readline/test_readline.rb,
test/readline/test_readline_history.rb, test/ruby/test_alias.rb,
test/ruby/test_array.rb, test/ruby/test_dir.rb,
test/ruby/test_encoding.rb, test/ruby/test_env.rb,
test/ruby/test_eval.rb, test/ruby/test_exception.rb,
test/ruby/test_file_exhaustive.rb, test/ruby/test_hash.rb,
test/ruby/test_io.rb, test/ruby/test_method.rb,
test/ruby/test_module.rb, test/ruby/test_object.rb,
test/ruby/test_pack.rb, test/ruby/test_rand.rb,
test/ruby/test_regexp.rb, test/ruby/test_settracefunc.rb,
test/ruby/test_struct.rb, test/ruby/test_thread.rb,
test/ruby/test_time.rb: remove tests for $SAFE=4.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41259 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2013-06-12 10:20:51 -04:00
|
|
|
FL_UNSET(tmpdir, FL_TAINT);
|
2019-10-18 15:10:03 -04:00
|
|
|
#endif
|
2010-09-09 18:29:16 -04:00
|
|
|
return tmpdir;
|
2010-05-07 23:25:17 -04:00
|
|
|
}
|
|
|
|
|
2014-05-17 20:58:34 -04:00
|
|
|
#ifdef HAVE_UNAME
|
|
|
|
/*
|
|
|
|
* Returns the system information obtained by uname system call.
|
|
|
|
*
|
|
|
|
* The return value is a hash which has 5 keys at least:
|
|
|
|
* :sysname, :nodename, :release, :version, :machine
|
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
*
|
|
|
|
* require 'etc'
|
|
|
|
* require 'pp'
|
|
|
|
*
|
|
|
|
* pp Etc.uname
|
|
|
|
* #=> {:sysname=>"Linux",
|
|
|
|
* # :nodename=>"boron",
|
|
|
|
* # :release=>"2.6.18-6-xen-686",
|
|
|
|
* # :version=>"#1 SMP Thu Nov 5 19:54:42 UTC 2009",
|
|
|
|
* # :machine=>"i686"}
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
static VALUE
|
|
|
|
etc_uname(VALUE obj)
|
|
|
|
{
|
2014-05-19 03:54:25 -04:00
|
|
|
#ifdef _WIN32
|
|
|
|
OSVERSIONINFOW v;
|
|
|
|
SYSTEM_INFO s;
|
|
|
|
const char *sysname, *mach;
|
|
|
|
VALUE result, release, version;
|
|
|
|
VALUE vbuf, nodename = Qnil;
|
|
|
|
DWORD len = 0;
|
|
|
|
WCHAR *buf;
|
|
|
|
|
|
|
|
v.dwOSVersionInfoSize = sizeof(v);
|
|
|
|
if (!GetVersionExW(&v))
|
|
|
|
rb_sys_fail("GetVersionEx");
|
|
|
|
|
|
|
|
result = rb_hash_new();
|
|
|
|
switch (v.dwPlatformId) {
|
|
|
|
case VER_PLATFORM_WIN32s:
|
|
|
|
sysname = "Win32s";
|
|
|
|
break;
|
|
|
|
case VER_PLATFORM_WIN32_NT:
|
|
|
|
sysname = "Windows_NT";
|
|
|
|
break;
|
|
|
|
case VER_PLATFORM_WIN32_WINDOWS:
|
|
|
|
default:
|
|
|
|
sysname = "Windows";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
rb_hash_aset(result, ID2SYM(rb_intern("sysname")), rb_str_new_cstr(sysname));
|
|
|
|
release = rb_sprintf("%lu.%lu.%lu", v.dwMajorVersion, v.dwMinorVersion, v.dwBuildNumber);
|
|
|
|
rb_hash_aset(result, ID2SYM(rb_intern("release")), release);
|
|
|
|
version = rb_sprintf("%s Version %"PRIsVALUE": %"PRIsVALUE, sysname, release,
|
|
|
|
rb_w32_conv_from_wchar(v.szCSDVersion, rb_utf8_encoding()));
|
|
|
|
rb_hash_aset(result, ID2SYM(rb_intern("version")), version);
|
|
|
|
|
2014-05-19 08:32:25 -04:00
|
|
|
# if defined _MSC_VER && _MSC_VER < 1300
|
|
|
|
# define GET_COMPUTER_NAME(ptr, plen) GetComputerNameW(ptr, plen)
|
|
|
|
# else
|
2014-05-19 08:35:22 -04:00
|
|
|
# define GET_COMPUTER_NAME(ptr, plen) GetComputerNameExW(ComputerNameDnsFullyQualified, ptr, plen)
|
2014-05-19 08:32:25 -04:00
|
|
|
# endif
|
2014-05-19 08:32:14 -04:00
|
|
|
GET_COMPUTER_NAME(NULL, &len);
|
2014-05-19 03:54:25 -04:00
|
|
|
buf = ALLOCV_N(WCHAR, vbuf, len);
|
2014-05-19 08:32:14 -04:00
|
|
|
if (GET_COMPUTER_NAME(buf, &len)) {
|
2014-05-19 03:54:25 -04:00
|
|
|
nodename = rb_w32_conv_from_wchar(buf, rb_utf8_encoding());
|
|
|
|
}
|
|
|
|
ALLOCV_END(vbuf);
|
|
|
|
if (NIL_P(nodename)) nodename = rb_str_new(0, 0);
|
|
|
|
rb_hash_aset(result, ID2SYM(rb_intern("nodename")), nodename);
|
|
|
|
|
2014-05-19 08:32:25 -04:00
|
|
|
# ifndef PROCESSOR_ARCHITECTURE_AMD64
|
|
|
|
# define PROCESSOR_ARCHITECTURE_AMD64 9
|
|
|
|
# endif
|
|
|
|
# ifndef PROCESSOR_ARCHITECTURE_INTEL
|
|
|
|
# define PROCESSOR_ARCHITECTURE_INTEL 0
|
|
|
|
# endif
|
2014-05-19 03:54:25 -04:00
|
|
|
GetSystemInfo(&s);
|
|
|
|
switch (s.wProcessorArchitecture) {
|
|
|
|
case PROCESSOR_ARCHITECTURE_AMD64:
|
|
|
|
mach = "x64";
|
|
|
|
break;
|
|
|
|
case PROCESSOR_ARCHITECTURE_ARM:
|
|
|
|
mach = "ARM";
|
|
|
|
break;
|
|
|
|
case PROCESSOR_ARCHITECTURE_INTEL:
|
|
|
|
mach = "x86";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
mach = "unknown";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
rb_hash_aset(result, ID2SYM(rb_intern("machine")), rb_str_new_cstr(mach));
|
|
|
|
#else
|
2014-05-17 20:58:34 -04:00
|
|
|
struct utsname u;
|
|
|
|
int ret;
|
|
|
|
VALUE result;
|
|
|
|
|
|
|
|
ret = uname(&u);
|
|
|
|
if (ret == -1)
|
|
|
|
rb_sys_fail("uname");
|
|
|
|
|
|
|
|
result = rb_hash_new();
|
|
|
|
rb_hash_aset(result, ID2SYM(rb_intern("sysname")), rb_str_new_cstr(u.sysname));
|
|
|
|
rb_hash_aset(result, ID2SYM(rb_intern("nodename")), rb_str_new_cstr(u.nodename));
|
|
|
|
rb_hash_aset(result, ID2SYM(rb_intern("release")), rb_str_new_cstr(u.release));
|
|
|
|
rb_hash_aset(result, ID2SYM(rb_intern("version")), rb_str_new_cstr(u.version));
|
|
|
|
rb_hash_aset(result, ID2SYM(rb_intern("machine")), rb_str_new_cstr(u.machine));
|
2014-05-19 03:54:25 -04:00
|
|
|
#endif
|
2014-05-17 20:58:34 -04:00
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
#define etc_uname rb_f_notimplement
|
|
|
|
#endif
|
|
|
|
|
2014-05-17 21:48:47 -04:00
|
|
|
#ifdef HAVE_SYSCONF
|
|
|
|
/*
|
|
|
|
* Returns system configuration variable using sysconf().
|
|
|
|
*
|
2014-05-18 04:45:07 -04:00
|
|
|
* _name_ should be a constant under <code>Etc</code> which begins with <code>SC_</code>.
|
2014-05-17 21:48:47 -04:00
|
|
|
*
|
|
|
|
* The return value is an integer or nil.
|
|
|
|
* nil means indefinite limit. (sysconf() returns -1 but errno is not set.)
|
|
|
|
*
|
|
|
|
* Etc.sysconf(Etc::SC_ARG_MAX) #=> 2097152
|
2014-10-05 10:44:18 -04:00
|
|
|
* Etc.sysconf(Etc::SC_LOGIN_NAME_MAX) #=> 256
|
2014-05-17 21:48:47 -04:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
static VALUE
|
|
|
|
etc_sysconf(VALUE obj, VALUE arg)
|
|
|
|
{
|
|
|
|
int name;
|
|
|
|
long ret;
|
|
|
|
|
|
|
|
name = NUM2INT(arg);
|
|
|
|
|
|
|
|
errno = 0;
|
|
|
|
ret = sysconf(name);
|
|
|
|
if (ret == -1) {
|
|
|
|
if (errno == 0) /* no limit */
|
|
|
|
return Qnil;
|
|
|
|
rb_sys_fail("sysconf");
|
|
|
|
}
|
|
|
|
return LONG2NUM(ret);
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
#define etc_sysconf rb_f_notimplement
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFSTR
|
|
|
|
/*
|
|
|
|
* Returns system configuration variable using confstr().
|
|
|
|
*
|
2014-05-18 04:45:07 -04:00
|
|
|
* _name_ should be a constant under <code>Etc</code> which begins with <code>CS_</code>.
|
2014-05-17 21:48:47 -04:00
|
|
|
*
|
|
|
|
* The return value is a string or nil.
|
|
|
|
* nil means no configuration-defined value. (confstr() returns 0 but errno is not set.)
|
|
|
|
*
|
|
|
|
* Etc.confstr(Etc::CS_PATH) #=> "/bin:/usr/bin"
|
|
|
|
*
|
|
|
|
* # GNU/Linux
|
|
|
|
* Etc.confstr(Etc::CS_GNU_LIBC_VERSION) #=> "glibc 2.18"
|
|
|
|
* Etc.confstr(Etc::CS_GNU_LIBPTHREAD_VERSION) #=> "NPTL 2.18"
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
static VALUE
|
|
|
|
etc_confstr(VALUE obj, VALUE arg)
|
|
|
|
{
|
|
|
|
int name;
|
|
|
|
char localbuf[128], *buf = localbuf;
|
|
|
|
size_t bufsize = sizeof(localbuf), ret;
|
|
|
|
VALUE tmp;
|
|
|
|
|
|
|
|
name = NUM2INT(arg);
|
|
|
|
|
|
|
|
errno = 0;
|
|
|
|
ret = confstr(name, buf, bufsize);
|
|
|
|
if (bufsize < ret) {
|
|
|
|
bufsize = ret;
|
|
|
|
buf = ALLOCV_N(char, tmp, bufsize);
|
|
|
|
errno = 0;
|
|
|
|
ret = confstr(name, buf, bufsize);
|
|
|
|
}
|
|
|
|
if (bufsize < ret)
|
|
|
|
rb_bug("required buffer size for confstr() changed dynamically.");
|
|
|
|
if (ret == 0) {
|
|
|
|
if (errno == 0) /* no configuration-defined value */
|
|
|
|
return Qnil;
|
|
|
|
rb_sys_fail("confstr");
|
|
|
|
}
|
|
|
|
return rb_str_new_cstr(buf);
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
#define etc_confstr rb_f_notimplement
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef HAVE_FPATHCONF
|
|
|
|
/*
|
|
|
|
* Returns pathname configuration variable using fpathconf().
|
|
|
|
*
|
2014-05-18 04:45:07 -04:00
|
|
|
* _name_ should be a constant under <code>Etc</code> which begins with <code>PC_</code>.
|
2014-05-17 21:48:47 -04:00
|
|
|
*
|
|
|
|
* The return value is an integer or nil.
|
|
|
|
* nil means indefinite limit. (fpathconf() returns -1 but errno is not set.)
|
|
|
|
*
|
2014-05-18 04:45:07 -04:00
|
|
|
* require 'etc'
|
2014-05-17 22:06:15 -04:00
|
|
|
* IO.pipe {|r, w|
|
|
|
|
* p w.pathconf(Etc::PC_PIPE_BUF) #=> 4096
|
|
|
|
* }
|
2014-05-17 21:48:47 -04:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
static VALUE
|
|
|
|
io_pathconf(VALUE io, VALUE arg)
|
|
|
|
{
|
|
|
|
int name;
|
|
|
|
long ret;
|
|
|
|
rb_io_t *fptr;
|
|
|
|
|
|
|
|
name = NUM2INT(arg);
|
|
|
|
|
|
|
|
GetOpenFile(io, fptr);
|
|
|
|
|
|
|
|
errno = 0;
|
|
|
|
ret = fpathconf(fptr->fd, name);
|
|
|
|
if (ret == -1) {
|
|
|
|
if (errno == 0) /* no limit */
|
|
|
|
return Qnil;
|
|
|
|
rb_sys_fail("fpathconf");
|
|
|
|
}
|
|
|
|
return LONG2NUM(ret);
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
#define io_pathconf rb_f_notimplement
|
|
|
|
#endif
|
|
|
|
|
2014-10-02 05:42:23 -04:00
|
|
|
#if (defined(HAVE_SYSCONF) && defined(_SC_NPROCESSORS_ONLN)) || defined(_WIN32)
|
2014-10-15 05:41:25 -04:00
|
|
|
|
2014-10-15 09:09:23 -04:00
|
|
|
#if defined(HAVE_SCHED_GETAFFINITY) && defined(CPU_ALLOC)
|
2014-10-15 05:41:25 -04:00
|
|
|
static int
|
|
|
|
etc_nprocessors_affin(void)
|
|
|
|
{
|
2021-10-14 00:17:13 -04:00
|
|
|
cpu_set_t *cpuset, cpuset_buff[1024 / sizeof(cpu_set_t)];
|
2014-10-15 05:41:25 -04:00
|
|
|
size_t size;
|
|
|
|
int ret;
|
2014-10-21 14:46:33 -04:00
|
|
|
int n;
|
2014-10-15 05:41:25 -04:00
|
|
|
|
2021-10-14 00:17:13 -04:00
|
|
|
CPU_ZERO_S(sizeof(cpuset_buff), cpuset_buff);
|
|
|
|
|
2014-10-15 05:41:25 -04:00
|
|
|
/*
|
|
|
|
* XXX:
|
|
|
|
* man page says CPU_ALLOC takes number of cpus. But it is not accurate
|
|
|
|
* explanation. sched_getaffinity() returns EINVAL if cpuset bitmap is
|
|
|
|
* smaller than kernel internal bitmap.
|
|
|
|
* That said, sched_getaffinity() can fail when a kernel have sparse bitmap
|
|
|
|
* even if cpuset bitmap is larger than number of cpus.
|
|
|
|
* The precious way is to use /sys/devices/system/cpu/online. But there are
|
|
|
|
* two problems,
|
|
|
|
* - Costly calculation
|
2014-10-21 14:46:46 -04:00
|
|
|
* It is a minor issue, but possibly kill a benefit of a parallel processing.
|
2014-10-15 05:41:25 -04:00
|
|
|
* - No guarantee to exist /sys/devices/system/cpu/online
|
2014-10-21 14:46:46 -04:00
|
|
|
* This is an issue especially when using Linux containers.
|
|
|
|
* So, we use hardcode number for a workaround. Current linux kernel
|
|
|
|
* (Linux 3.17) support 8192 cpus at maximum. Then 16384 must be enough.
|
2014-10-15 05:41:25 -04:00
|
|
|
*/
|
2014-10-21 14:48:03 -04:00
|
|
|
for (n=64; n <= 16384; n *= 2) {
|
2014-10-21 14:46:33 -04:00
|
|
|
size = CPU_ALLOC_SIZE(n);
|
2021-10-14 00:17:13 -04:00
|
|
|
if (size >= sizeof(cpuset_buff)) {
|
2014-10-21 14:46:33 -04:00
|
|
|
cpuset = xcalloc(1, size);
|
|
|
|
if (!cpuset)
|
|
|
|
return -1;
|
|
|
|
} else {
|
2021-10-14 00:17:13 -04:00
|
|
|
cpuset = cpuset_buff;
|
2014-10-21 14:46:33 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
ret = sched_getaffinity(0, size, cpuset);
|
|
|
|
if (ret == 0) {
|
|
|
|
/* On success, count number of cpus. */
|
|
|
|
ret = CPU_COUNT_S(size, cpuset);
|
|
|
|
}
|
|
|
|
|
2021-10-14 00:17:13 -04:00
|
|
|
if (size >= sizeof(cpuset_buff)) {
|
2014-10-21 14:46:33 -04:00
|
|
|
xfree(cpuset);
|
|
|
|
}
|
2021-10-14 00:17:13 -04:00
|
|
|
if (ret > 0 || errno != EINVAL) {
|
2014-10-21 14:46:33 -04:00
|
|
|
return ret;
|
|
|
|
}
|
2014-10-15 05:41:25 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2014-10-01 23:23:26 -04:00
|
|
|
/*
|
|
|
|
* Returns the number of online processors.
|
|
|
|
*
|
|
|
|
* The result is intended as the number of processes to
|
|
|
|
* use all available processors.
|
|
|
|
*
|
2014-10-15 19:12:21 -04:00
|
|
|
* This method is implemented using:
|
2014-10-15 05:41:25 -04:00
|
|
|
* - sched_getaffinity(): Linux
|
2014-10-15 19:12:21 -04:00
|
|
|
* - sysconf(_SC_NPROCESSORS_ONLN): GNU/Linux, NetBSD, FreeBSD, OpenBSD, DragonFly BSD, OpenIndiana, Mac OS X, AIX
|
2014-10-01 23:23:26 -04:00
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
*
|
|
|
|
* require 'etc'
|
|
|
|
* p Etc.nprocessors #=> 4
|
|
|
|
*
|
2014-10-15 05:41:25 -04:00
|
|
|
* The result might be smaller number than physical cpus especially when ruby
|
|
|
|
* process is bound to specific cpus. This is intended for getting better
|
|
|
|
* parallel processing.
|
|
|
|
*
|
|
|
|
* Example: (Linux)
|
|
|
|
*
|
2014-10-15 19:12:21 -04:00
|
|
|
* linux$ taskset 0x3 ./ruby -retc -e "p Etc.nprocessors" #=> 2
|
2014-10-15 05:41:25 -04:00
|
|
|
*
|
2014-10-01 23:23:26 -04:00
|
|
|
*/
|
|
|
|
static VALUE
|
|
|
|
etc_nprocessors(VALUE obj)
|
|
|
|
{
|
|
|
|
long ret;
|
|
|
|
|
2014-10-02 05:42:23 -04:00
|
|
|
#if !defined(_WIN32)
|
2014-10-15 05:41:25 -04:00
|
|
|
|
2014-10-15 09:09:23 -04:00
|
|
|
#if defined(HAVE_SCHED_GETAFFINITY) && defined(CPU_ALLOC)
|
2014-10-15 05:41:25 -04:00
|
|
|
int ncpus;
|
|
|
|
|
|
|
|
ncpus = etc_nprocessors_affin();
|
|
|
|
if (ncpus != -1) {
|
2017-09-27 01:08:53 -04:00
|
|
|
return INT2NUM(ncpus);
|
2014-10-15 05:41:25 -04:00
|
|
|
}
|
|
|
|
/* fallback to _SC_NPROCESSORS_ONLN */
|
|
|
|
#endif
|
|
|
|
|
2014-10-01 23:23:26 -04:00
|
|
|
errno = 0;
|
|
|
|
ret = sysconf(_SC_NPROCESSORS_ONLN);
|
|
|
|
if (ret == -1) {
|
|
|
|
rb_sys_fail("sysconf(_SC_NPROCESSORS_ONLN)");
|
|
|
|
}
|
2014-10-02 05:42:23 -04:00
|
|
|
#else
|
|
|
|
SYSTEM_INFO si;
|
|
|
|
GetSystemInfo(&si);
|
|
|
|
ret = (long)si.dwNumberOfProcessors;
|
|
|
|
#endif
|
2014-10-01 23:23:26 -04:00
|
|
|
return LONG2NUM(ret);
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
#define etc_nprocessors rb_f_notimplement
|
|
|
|
#endif
|
|
|
|
|
2010-04-23 01:07:38 -04:00
|
|
|
/*
|
2011-10-03 19:33:57 -04:00
|
|
|
* The Etc module provides access to information typically stored in
|
|
|
|
* files in the /etc directory on Unix systems.
|
2005-11-01 08:04:35 -05:00
|
|
|
*
|
2011-10-03 19:33:57 -04:00
|
|
|
* 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
|
2012-12-07 02:08:06 -05:00
|
|
|
* the logged in user than environment variables such as +$USER+.
|
|
|
|
*
|
|
|
|
* == Example:
|
2011-10-03 19:33:57 -04:00
|
|
|
*
|
|
|
|
* require 'etc'
|
2011-11-04 03:19:23 -04:00
|
|
|
*
|
2011-10-03 19:33:57 -04:00
|
|
|
* login = Etc.getlogin
|
|
|
|
* info = Etc.getpwnam(login)
|
|
|
|
* username = info.gecos.split(/,/).first
|
|
|
|
* puts "Hello #{username}, I see your login name is #{login}"
|
|
|
|
*
|
2011-11-04 03:19:23 -04:00
|
|
|
* Note that the methods provided by this module are not always secure.
|
2011-10-03 19:33:57 -04:00
|
|
|
* It should be used for informational purposes, and not for security.
|
2012-12-07 02:08:06 -05:00
|
|
|
*
|
|
|
|
* All operations defined in this module are class methods, so that you can
|
|
|
|
* include the Etc module into your class.
|
2005-11-01 08:04:35 -05:00
|
|
|
*/
|
1998-01-16 07:13:05 -05:00
|
|
|
void
|
2006-07-03 01:42:35 -04:00
|
|
|
Init_etc(void)
|
1998-01-16 07:13:05 -05:00
|
|
|
{
|
2008-06-19 04:45:25 -04:00
|
|
|
VALUE mEtc;
|
1998-01-16 07:13:05 -05:00
|
|
|
|
2020-12-21 23:31:11 -05:00
|
|
|
#ifdef HAVE_RB_EXT_RACTOR_SAFE
|
|
|
|
RB_EXT_RACTOR_SAFE(true);
|
|
|
|
#endif
|
2008-06-19 04:45:25 -04:00
|
|
|
mEtc = rb_define_module("Etc");
|
2019-07-09 23:33:29 -04:00
|
|
|
rb_define_const(mEtc, "VERSION", rb_str_new_cstr(RUBY_ETC_VERSION));
|
2014-05-17 21:48:47 -04:00
|
|
|
init_constants(mEtc);
|
|
|
|
|
1998-01-16 07:13:05 -05:00
|
|
|
rb_define_module_function(mEtc, "getlogin", etc_getlogin, 0);
|
|
|
|
|
|
|
|
rb_define_module_function(mEtc, "getpwuid", etc_getpwuid, -1);
|
|
|
|
rb_define_module_function(mEtc, "getpwnam", etc_getpwnam, 1);
|
2003-10-01 09:41:35 -04:00
|
|
|
rb_define_module_function(mEtc, "setpwent", etc_setpwent, 0);
|
|
|
|
rb_define_module_function(mEtc, "endpwent", etc_endpwent, 0);
|
|
|
|
rb_define_module_function(mEtc, "getpwent", etc_getpwent, 0);
|
1998-01-16 07:13:05 -05:00
|
|
|
rb_define_module_function(mEtc, "passwd", etc_passwd, 0);
|
|
|
|
|
2007-01-09 06:52:26 -05:00
|
|
|
rb_define_module_function(mEtc, "getgrgid", etc_getgrgid, -1);
|
1998-01-16 07:13:05 -05:00
|
|
|
rb_define_module_function(mEtc, "getgrnam", etc_getgrnam, 1);
|
|
|
|
rb_define_module_function(mEtc, "group", etc_group, 0);
|
2003-10-01 09:41:35 -04:00
|
|
|
rb_define_module_function(mEtc, "setgrent", etc_setgrent, 0);
|
|
|
|
rb_define_module_function(mEtc, "endgrent", etc_endgrent, 0);
|
2003-10-01 11:14:23 -04:00
|
|
|
rb_define_module_function(mEtc, "getgrent", etc_getgrent, 0);
|
2010-05-07 23:25:17 -04:00
|
|
|
rb_define_module_function(mEtc, "sysconfdir", etc_sysconfdir, 0);
|
|
|
|
rb_define_module_function(mEtc, "systmpdir", etc_systmpdir, 0);
|
2014-05-17 20:58:34 -04:00
|
|
|
rb_define_module_function(mEtc, "uname", etc_uname, 0);
|
2014-05-17 21:48:47 -04:00
|
|
|
rb_define_module_function(mEtc, "sysconf", etc_sysconf, 1);
|
|
|
|
rb_define_module_function(mEtc, "confstr", etc_confstr, 1);
|
|
|
|
rb_define_method(rb_cIO, "pathconf", io_pathconf, 1);
|
2014-10-01 23:23:26 -04:00
|
|
|
rb_define_module_function(mEtc, "nprocessors", etc_nprocessors, 0);
|
1998-01-16 07:13:05 -05:00
|
|
|
|
2013-08-02 20:31:02 -04:00
|
|
|
sPasswd = rb_struct_define_under(mEtc, "Passwd",
|
|
|
|
"name",
|
2013-06-22 01:43:08 -04:00
|
|
|
#ifdef HAVE_STRUCT_PASSWD_PW_PASSWD
|
2013-08-02 20:31:02 -04:00
|
|
|
"passwd",
|
2013-06-22 01:43:08 -04:00
|
|
|
#endif
|
2013-08-02 20:31:02 -04:00
|
|
|
"uid",
|
|
|
|
"gid",
|
2013-05-09 08:12:17 -04:00
|
|
|
#ifdef HAVE_STRUCT_PASSWD_PW_GECOS
|
2013-08-02 20:31:02 -04:00
|
|
|
"gecos",
|
1999-01-19 23:59:39 -05:00
|
|
|
#endif
|
2013-08-02 20:31:02 -04:00
|
|
|
"dir",
|
|
|
|
"shell",
|
2013-05-09 08:12:17 -04:00
|
|
|
#ifdef HAVE_STRUCT_PASSWD_PW_CHANGE
|
2013-08-02 20:31:02 -04:00
|
|
|
"change",
|
1998-01-16 07:13:05 -05:00
|
|
|
#endif
|
2013-05-09 08:12:17 -04:00
|
|
|
#ifdef HAVE_STRUCT_PASSWD_PW_QUOTA
|
2013-08-02 20:31:02 -04:00
|
|
|
"quota",
|
1998-01-16 07:13:05 -05:00
|
|
|
#endif
|
2013-05-09 08:12:17 -04:00
|
|
|
#ifdef HAVE_STRUCT_PASSWD_PW_AGE
|
2013-08-02 20:31:02 -04:00
|
|
|
"age",
|
1998-01-16 07:13:05 -05:00
|
|
|
#endif
|
2013-05-09 08:12:17 -04:00
|
|
|
#ifdef HAVE_STRUCT_PASSWD_PW_CLASS
|
2013-08-02 20:31:02 -04:00
|
|
|
"uclass",
|
1998-01-16 07:13:05 -05:00
|
|
|
#endif
|
2013-05-09 08:12:17 -04:00
|
|
|
#ifdef HAVE_STRUCT_PASSWD_PW_COMMENT
|
2013-08-02 20:31:02 -04:00
|
|
|
"comment",
|
1998-01-16 07:13:05 -05:00
|
|
|
#endif
|
2013-05-09 08:12:17 -04:00
|
|
|
#ifdef HAVE_STRUCT_PASSWD_PW_EXPIRE
|
2013-08-02 20:31:02 -04:00
|
|
|
"expire",
|
1998-01-16 07:13:05 -05:00
|
|
|
#endif
|
2013-08-02 20:31:02 -04:00
|
|
|
NULL);
|
|
|
|
#if 0
|
2012-12-07 02:08:06 -05:00
|
|
|
/* Define-const: Passwd
|
|
|
|
*
|
|
|
|
* Passwd is a Struct that contains the following members:
|
|
|
|
*
|
|
|
|
* name::
|
|
|
|
* contains the short login name of the user as a String.
|
|
|
|
* passwd::
|
|
|
|
* contains the encrypted password of the user as a String.
|
|
|
|
* an 'x' is returned if shadow passwords are in use. An '*' is returned
|
|
|
|
* if the user cannot log in using a password.
|
|
|
|
* uid::
|
|
|
|
* contains the integer user ID (uid) of the user.
|
|
|
|
* gid::
|
|
|
|
* contains the integer group ID (gid) of the user's primary group.
|
|
|
|
* dir::
|
|
|
|
* contains the path to the home directory of the user as a String.
|
|
|
|
* shell::
|
|
|
|
* contains the path to the login shell of the user as a String.
|
|
|
|
*
|
|
|
|
* === The following members below are optional, and must be compiled with special flags:
|
|
|
|
*
|
|
|
|
* gecos::
|
|
|
|
* contains a longer String description of the user, such as
|
|
|
|
* a full name. Some Unix systems provide structured information in the
|
|
|
|
* gecos field, but this is system-dependent.
|
2013-05-09 08:12:17 -04:00
|
|
|
* must be compiled with +HAVE_STRUCT_PASSWD_PW_GECOS+
|
2012-12-07 02:08:06 -05:00
|
|
|
* change::
|
2013-05-09 08:12:17 -04:00
|
|
|
* password change time(integer) must be compiled with +HAVE_STRUCT_PASSWD_PW_CHANGE+
|
2012-12-07 02:08:06 -05:00
|
|
|
* quota::
|
2013-05-09 08:12:17 -04:00
|
|
|
* quota value(integer) must be compiled with +HAVE_STRUCT_PASSWD_PW_QUOTA+
|
2012-12-07 02:08:06 -05:00
|
|
|
* age::
|
2013-05-09 08:12:17 -04:00
|
|
|
* password age(integer) must be compiled with +HAVE_STRUCT_PASSWD_PW_AGE+
|
2012-12-07 02:08:06 -05:00
|
|
|
* class::
|
2013-05-09 08:12:17 -04:00
|
|
|
* user access class(string) must be compiled with +HAVE_STRUCT_PASSWD_PW_CLASS+
|
2012-12-07 02:08:06 -05:00
|
|
|
* comment::
|
2013-05-09 08:12:17 -04:00
|
|
|
* comment(string) must be compiled with +HAVE_STRUCT_PASSWD_PW_COMMENT+
|
2012-12-07 02:08:06 -05:00
|
|
|
* expire::
|
2013-05-09 08:12:17 -04:00
|
|
|
* account expiration time(integer) must be compiled with +HAVE_STRUCT_PASSWD_PW_EXPIRE+
|
2012-12-07 02:08:06 -05:00
|
|
|
*/
|
2008-06-19 04:45:25 -04:00
|
|
|
rb_define_const(mEtc, "Passwd", sPasswd);
|
2013-08-02 20:31:02 -04:00
|
|
|
#endif
|
2013-04-12 11:16:00 -04:00
|
|
|
rb_define_const(rb_cStruct, "Passwd", sPasswd); /* deprecated name */
|
2020-04-01 02:18:00 -04:00
|
|
|
rb_deprecate_constant(rb_cStruct, "Passwd");
|
2009-02-17 10:55:49 -05:00
|
|
|
rb_extend_object(sPasswd, rb_mEnumerable);
|
|
|
|
rb_define_singleton_method(sPasswd, "each", etc_each_passwd, 0);
|
1998-01-16 07:13:05 -05:00
|
|
|
#ifdef HAVE_GETGRENT
|
2013-08-02 20:31:02 -04:00
|
|
|
sGroup = rb_struct_define_under(mEtc, "Group", "name",
|
2013-05-09 08:12:17 -04:00
|
|
|
#ifdef HAVE_STRUCT_GROUP_GR_PASSWD
|
2013-08-02 20:31:02 -04:00
|
|
|
"passwd",
|
* array.c: replace rb_protect_inspect() and rb_inspecting_p() by
rb_exec_recursive() in eval.c.
* eval.c (rb_exec_recursive): new function.
* array.c (rb_ary_join): use rb_exec_recursive().
* array.c (rb_ary_inspect, rb_ary_hash): ditto.
* file.c (rb_file_join): ditto.
* hash.c (rb_hash_inspect, rb_hash_to_s, rb_hash_hash): ditto.
* io.c (rb_io_puts): ditto.
* object.c (rb_obj_inspect): ditto
* struct.c (rb_struct_inspect): ditto.
* lib/set.rb (SortedSet::setup): a hack to shut up warning.
[ruby-talk:132866]
* lib/time.rb (Time::strptime): add new function. inspired by
[ruby-talk:132815].
* lib/parsedate.rb (ParseDate::strptime): ditto.
* regparse.c: move st_*_strend() functions from st.c. fixed some
potential memory leaks.
* exception error messages updated. [ruby-core:04497]
* ext/socket/socket.c (Init_socket): add bunch of Socket
constants. Patch from Sam Roberts <sroberts@uniserve.com>.
[ruby-core:04409]
* array.c (rb_ary_s_create): no need for negative argc check.
[ruby-core:04463]
* array.c (rb_ary_unshift_m): ditto.
* lib/xmlrpc/parser.rb (XMLRPC::FaultException): make it subclass
of StandardError class, not Exception class. [ruby-core:04429]
* parse.y (fcall_gen): lvar(arg) will be evaluated as
lvar.call(arg) when lvar is a defined local variable. [new]
* object.c (rb_class_initialize): call inherited method before
calling initializing block.
* eval.c (rb_thread_start_1): initialize newly pushed frame.
* lib/open3.rb (Open3::popen3): $? should not be EXIT_FAILURE.
fixed: [ruby-core:04444]
* eval.c (is_defined): NODE_IASGN is an assignment.
* ext/readline/readline.c (Readline.readline): use rl_outstream
and rl_instream. [ruby-dev:25699]
* ext/etc/etc.c (Init_etc): sGroup needs HAVE_ST_GR_PASSWD check
[ruby-dev:25675]
* misc/ruby-mode.el: [ruby-core:04415]
* lib/rdoc/generators/html_generator.rb: [ruby-core:04412]
* lib/rdoc/generators/ri_generator.rb: ditto.
* struct.c (make_struct): fixed: [ruby-core:04402]
* ext/curses/curses.c (window_color_set): [ruby-core:04393]
* ext/socket/socket.c (Init_socket): SO_REUSEPORT added.
[ruby-talk:130092]
* object.c: [ruby-doc:818]
* parse.y (open_args): fix too verbose warnings for the space
before argument parentheses. [ruby-dev:25492]
* parse.y (parser_yylex): ditto.
* parse.y (parser_yylex): the first expression in the parentheses
should not be a command. [ruby-dev:25492]
* lib/irb/context.rb (IRB::Context::initialize): [ruby-core:04330]
* object.c (Init_Object): remove Object#type. [ruby-core:04335]
* st.c (st_foreach): report success/failure by return value.
[ruby-Bugs-1396]
* parse.y: forgot to initialize parser struct. [ruby-dev:25492]
* parse.y (parser_yylex): no tLABEL on EXPR_BEG.
[ruby-talk:127711]
* document updates - [ruby-core:04296], [ruby-core:04301],
[ruby-core:04302], [ruby-core:04307]
* dir.c (rb_push_glob): should work for NUL delimited patterns.
* dir.c (rb_glob2): should aware of offset in the pattern.
* string.c (rb_str_new4): should propagate taintedness.
* env.h: rename member names in struct FRAME; last_func -> callee,
orig_func -> this_func, last_class -> this_class.
* struct.c (rb_struct_set): use original method name, not callee
name, to retrieve member slot. [ruby-core:04268]
* time.c (time_strftime): protect from format modification from GC
finalizers.
* object.c (Init_Object): remove rb_obj_id_obsolete()
* eval.c (rb_mod_define_method): incomplete subclass check.
[ruby-dev:25464]
* gc.c (rb_data_object_alloc): klass may be NULL.
[ruby-list:40498]
* bignum.c (rb_big_rand): should return positive random number.
[ruby-dev:25401]
* bignum.c (rb_big_rand): do not use rb_big_modulo to generate
random bignums. [ruby-dev:25396]
* variable.c (rb_autoload): [ruby-dev:25373]
* eval.c (svalue_to_avalue): [ruby-dev:25366]
* string.c (rb_str_justify): [ruby-dev:25367]
* io.c (rb_f_select): [ruby-dev:25312]
* ext/socket/socket.c (sock_s_getservbyport): [ruby-talk:124072]
* struct.c (make_struct): [ruby-dev:25249]
* dir.c (dir_open_dir): new function. [ruby-dev:25242]
* io.c (rb_f_open): add type check for return value from to_open.
* lib/pstore.rb (PStore#transaction): Use the empty content when a
file is not found. [ruby-dev:24561]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@8068 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
2005-03-04 01:47:45 -05:00
|
|
|
#endif
|
2013-08-02 20:31:02 -04:00
|
|
|
"gid", "mem", NULL);
|
2006-12-31 10:02:22 -05:00
|
|
|
|
2013-08-02 20:31:02 -04:00
|
|
|
#if 0
|
2012-12-07 02:08:06 -05:00
|
|
|
/* Define-const: Group
|
|
|
|
*
|
|
|
|
* Group is a Struct that is only available when compiled with +HAVE_GETGRENT+.
|
|
|
|
*
|
|
|
|
* The struct contains the following members:
|
|
|
|
*
|
|
|
|
* name::
|
|
|
|
* contains the name of the group as a String.
|
|
|
|
* passwd::
|
|
|
|
* contains the encrypted password as a String. An 'x' is
|
|
|
|
* returned if password access to the group is not available; an empty
|
|
|
|
* string is returned if no password is needed to obtain membership of
|
|
|
|
* the group.
|
|
|
|
*
|
2013-05-09 08:12:17 -04:00
|
|
|
* Must be compiled with +HAVE_STRUCT_GROUP_GR_PASSWD+.
|
2012-12-07 02:08:06 -05:00
|
|
|
* gid::
|
|
|
|
* contains the group's numeric ID as an integer.
|
|
|
|
* mem::
|
|
|
|
* is an Array of Strings containing the short login names of the
|
|
|
|
* members of the group.
|
|
|
|
*/
|
2008-06-19 04:45:25 -04:00
|
|
|
rb_define_const(mEtc, "Group", sGroup);
|
2013-08-02 20:31:02 -04:00
|
|
|
#endif
|
2013-04-12 11:16:00 -04:00
|
|
|
rb_define_const(rb_cStruct, "Group", sGroup); /* deprecated name */
|
2020-04-01 02:18:00 -04:00
|
|
|
rb_deprecate_constant(rb_cStruct, "Group");
|
2009-02-17 10:55:49 -05:00
|
|
|
rb_extend_object(sGroup, rb_mEnumerable);
|
|
|
|
rb_define_singleton_method(sGroup, "each", etc_each_group, 0);
|
1998-01-16 07:13:05 -05:00
|
|
|
#endif
|
|
|
|
}
|