Advertising
- Miscellany
- Wednesday, December 6th, 2006 at 7:18:04am MST
- --- posix.c.old 2006-12-06 13:48:21.021525232 +0000
- +++ posix.c 2006-12-06 13:52:01.364028080 +0000
- @@ -554,6 +554,9 @@
- {
- zval **z_fd;
- char *p;
- +#if HAVE_TTYNAME_R
- + int buflen;
- +#endif
- int fd;
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Z", &z_fd) == FAILURE) {
- @@ -571,12 +574,26 @@
- fd = Z_LVAL_PP(z_fd);
- }
- +#if HAVE_TTYNAME_R
- + buflen = sysconf(_SC_TTY_NAME_MAX);
- + p = emalloc(buflen);
- +
- + if (ttyname_r(fd, p, buflen) != 0 ) {
- + POSIX_G(last_error) = errno;
- + efree(p);
- + RETURN_FALSE;
- + }
- + RETVAL_STRING(p, 1);
- + efree(p);
- + return;
- +#else
- if (NULL == (p = ttyname(fd))) {
- POSIX_G(last_error) = errno;
- RETURN_FALSE;
- }
- RETURN_STRING(p, 1);
- +#endif
- }
- /* }}} */
- @@ -810,18 +827,40 @@
- struct group *g;
- int name_len;
- + int ret;
- +#if HAVE_GETGRNAM_R
- + struct group gbuf;
- + int buflen;
- + char *buf;
- +#endif
- +
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name, &name_len) == FAILURE) {
- RETURN_FALSE;
- }
- +#if HAVE_GETGRNAM_R
- + buflen = sysconf(_SC_GETGR_R_SIZE_MAX);
- + buf = emalloc(buflen);
- + g = &gbuf;
- +
- + if (getgrnam_r(name, g, buf, buflen, &g) != 0 || g == NULL) {
- + POSIX_G(last_error) = errno;
- + efree(buf);
- + RETURN_FALSE;
- + }
- +#else
- if (NULL == (g = getgrnam(name))) {
- POSIX_G(last_error) = errno;
- RETURN_FALSE;
- }
- +#endif
- array_init(return_value);
- -
- - if (!php_posix_group_to_array(g, return_value)) {
- + ret = php_posix_group_to_array(g, return_value);
- +#if HAVE_GETGRNAM_R
- + efree(buf);
- +#endif
- + if (0 == ret) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "unable to convert posix group to array");
- RETURN_FALSE;
- }
- @@ -892,23 +931,44 @@
- struct passwd *pw;
- char *name;
- int name_len;
- + int ret;
- +
- +#ifdef HAVE_GETPWNAM_R
- + struct passwd pwbuf;
- + int buflen;
- + char *buf;
- +#endif
- if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name, &name_len) == FAILURE) {
- RETURN_FALSE;
- }
- -
- +
- +#ifdef HAVE_GETPWNAM_R
- + buflen = sysconf(_SC_GETPW_R_SIZE_MAX);
- + buf = emalloc(buflen);
- + pw = &pwbuf;
- +
- + if (getpwnam_r(name, pw, buf, buflen, &pw) != 0 || pw == NULL) {
- + efree(buf);
- + POSIX_G(last_error) = errno;
- + RETURN_FALSE;
- + }
- +#else
- if (NULL == (pw = getpwnam(name))) {
- POSIX_G(last_error) = errno;
- RETURN_FALSE;
- }
- -
- - array_init(return_value);
- +#endif
- - if (!php_posix_passwd_to_array(pw, return_value)) {
- + array_init(return_value);
- + ret = php_posix_passwd_to_array(pw, return_value);
- +#ifdef HAVE_GETPWNAM_R
- + efree(buf);
- +#endif
- + if (0 == ret) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING, "unable to convert posix passwd struct to array");
- RETURN_FALSE;
- }
- -
- }
- /* }}} */
advertising
Update the Post
Either update this post and resubmit it with changes, or make a new post.
You may also comment on this post.
Please note that information posted here will expire by default in one month. If you do not want it to expire, please set the expiry time above. If it is set to expire, web search engines will not be allowed to index it prior to it expiring. Items that are not marked to expire will be indexable by search engines. Be careful with your passwords. All illegal activities will be reported and any information will be handed over to the authorities, so be good.