diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-05-10 23:34:33 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2017-05-10 23:34:33 +0000 |
commit | 8f9a46a3043422253b5fef27a5f350c1a14740a7 (patch) | |
tree | 7a7c24feb92c636285dde3002d3e7033dd67fbe2 /process.c | |
parent | ec70309ffa6994a01b0f1b53ff05526ef9d388b5 (diff) |
.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@58659 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'process.c')
-rw-r--r-- | process.c | 14 |
1 files changed, 12 insertions, 2 deletions
@@ -173,6 +173,11 @@ static void check_gid_switch(void); VALUE getpw_buf = 0 # define FINISH_GETPWNAM \ (getpw_buf ? (void)rb_str_resize(getpw_buf, 0) : (void)0) +# ifdef __APPLE__ +# define GETPWNAM_R_RETRY_P(e) (e == 0 || e == ERANGE) +# else +# define GETPWNAM_R_RETRY_P(e) (e == ERANGE) +# endif # define OBJ2UID1(id) obj2uid((id), &getpw_buf) # define OBJ2UID(id) obj2uid0(id) static rb_uid_t obj2uid(VALUE id, VALUE *getpw_buf); @@ -215,6 +220,11 @@ static rb_uid_t obj2uid(VALUE id); VALUE getgr_buf = 0 # define FINISH_GETGRNAM \ (getgr_buf ? (void)rb_str_resize(getgr_buf, 0) : (void)0) +# ifdef __APPLE__ +# define GETGRNAM_R_RETRY_P(e) (e == 0 || e == ERANGE) +# else +# define GETGRNAM_R_RETRY_P(e) (e == ERANGE) +# endif # define OBJ2GID1(id) obj2gid((id), &getgr_buf) # define OBJ2GID(id) obj2gid0(id) static rb_gid_t obj2gid(VALUE id, VALUE *getgr_buf); @@ -5042,7 +5052,7 @@ obj2uid(VALUE id /* gepwnam_r() on MacOS X doesn't set errno if buffer size is insufficient */ while (getpwnam_r(usrname, &pwbuf, getpw_buf, getpw_buf_len, &pwptr)) { int e = errno; - if (e != ERANGE || getpw_buf_len >= GETPW_R_SIZE_LIMIT) { + if (!GETPWNAM_R_RETRY_P(e) || getpw_buf_len >= GETPW_R_SIZE_LIMIT) { rb_str_resize(*getpw_tmp, 0); rb_syserr_fail(e, "getpwnam_r"); } @@ -5120,7 +5130,7 @@ obj2gid(VALUE id /* gegrnam_r() on MacOS X doesn't set errno if buffer size is insufficient */ while (getgrnam_r(grpname, &grbuf, getgr_buf, getgr_buf_len, &grptr)) { int e = errno; - if (e != ERANGE || getgr_buf_len >= GETGR_R_SIZE_LIMIT) { + if (!GETGRNAM_R_RETRY_P(e) || getgr_buf_len >= GETGR_R_SIZE_LIMIT) { rb_str_resize(*getgr_tmp, 0); rb_syserr_fail(e, "getgrnam_r"); } |