Part of Slepp's ProjectsPastebinTURLImagebinFilebin
Feedback -- English French German Japanese
Create Upload Newest Tools Donate
Sign In | Create Account

Miscellany
Wednesday, December 6th, 2006 at 2:18:04pm UTC 

  1. --- posix.c.old 2006-12-06 13:48:21.021525232 +0000
  2. +++ posix.c     2006-12-06 13:52:01.364028080 +0000
  3. @@ -554,6 +554,9 @@
  4.  {
  5.         zval **z_fd;
  6.         char *p;
  7. +#if HAVE_TTYNAME_R
  8. +       int buflen;
  9. +#endif
  10.         int fd;
  11.  
  12.         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "Z", &z_fd) == FAILURE) {
  13. @@ -571,12 +574,26 @@
  14.                       fd = Z_LVAL_PP(z_fd);
  15.         }
  16.  
  17. +#if HAVE_TTYNAME_R
  18. +       buflen = sysconf(_SC_TTY_NAME_MAX);
  19. +       p = emalloc(buflen);
  20. +
  21. +       if (ttyname_r(fd, p, buflen) != 0 ) {
  22. +       POSIX_G(last_error) = errno;
  23. +              efree(p);
  24. +              RETURN_FALSE;
  25. +       }
  26. +    RETVAL_STRING(p, 1);
  27. +       efree(p);
  28. +       return;
  29. +#else
  30.         if (NULL == (p = ttyname(fd))) {
  31.                POSIX_G(last_error) = errno;
  32.                RETURN_FALSE;
  33.         }
  34.         
  35.         RETURN_STRING(p, 1);
  36. +#endif
  37.  }
  38.  /* }}} */
  39.  
  40. @@ -810,18 +827,40 @@
  41.         struct group *g;
  42.         int name_len;
  43.         
  44. +       int ret;
  45. +#if HAVE_GETGRNAM_R
  46. +       struct group gbuf;
  47. +       int buflen;
  48. +       char *buf;
  49. +#endif
  50. +       
  51.         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name, &name_len) == FAILURE) {
  52.                RETURN_FALSE;
  53.         }
  54.  
  55. +#if HAVE_GETGRNAM_R
  56. +       buflen = sysconf(_SC_GETGR_R_SIZE_MAX);
  57. +       buf = emalloc(buflen);
  58. +       g = &gbuf;
  59. +
  60. +       if (getgrnam_r(name, g, buf, buflen, &g) != 0 || g == NULL) {
  61. +       POSIX_G(last_error) = errno;
  62. +              efree(buf);
  63. +              RETURN_FALSE;
  64. +       }
  65. +#else
  66.         if (NULL == (g = getgrnam(name))) {
  67.                POSIX_G(last_error) = errno;
  68.                RETURN_FALSE;
  69.         }
  70. +#endif
  71.         
  72.         array_init(return_value);
  73. -
  74. -       if (!php_posix_group_to_array(g, return_value)) {
  75. +       ret = php_posix_group_to_array(g, return_value);
  76. +#if HAVE_GETGRNAM_R
  77. +       efree(buf);
  78. +#endif
  79. +       if (0 == ret) {
  80.                php_error_docref(NULL TSRMLS_CC, E_WARNING, "unable to convert posix group to array");
  81.                RETURN_FALSE;
  82.         }
  83. @@ -892,23 +931,44 @@
  84.         struct passwd *pw;
  85.         char *name;
  86.         int name_len;
  87. +       int ret;
  88. +
  89. +#ifdef HAVE_GETPWNAM_R
  90. +       struct passwd pwbuf;
  91. +       int buflen;
  92. +       char *buf;
  93. +#endif
  94.         
  95.         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &name, &name_len) == FAILURE) {
  96.                RETURN_FALSE;
  97.         }
  98. -
  99. +   
  100. +#ifdef HAVE_GETPWNAM_R
  101. +       buflen = sysconf(_SC_GETPW_R_SIZE_MAX);
  102. +       buf = emalloc(buflen);
  103. +       pw = &pwbuf;
  104. +
  105. +       if (getpwnam_r(name, pw, buf, buflen, &pw) != 0 || pw == NULL) {
  106. +              efree(buf);
  107. +       POSIX_G(last_error) = errno;
  108. +              RETURN_FALSE;
  109. +       }
  110. +#else
  111.         if (NULL == (pw = getpwnam(name))) {
  112.                POSIX_G(last_error) = errno;
  113.                RETURN_FALSE;
  114.         }
  115. -       
  116. -       array_init(return_value);
  117. +#endif
  118.  
  119. -       if (!php_posix_passwd_to_array(pw, return_value)) {
  120. +       array_init(return_value);
  121. +       ret = php_posix_passwd_to_array(pw, return_value);
  122. +#ifdef HAVE_GETPWNAM_R
  123. +       efree(buf);
  124. +#endif
  125. +       if (0 == ret) {
  126.                php_error_docref(NULL TSRMLS_CC, E_WARNING, "unable to convert posix passwd struct to array");
  127.                RETURN_FALSE;
  128.         }
  129. -
  130.  }
  131.  /* }}} */
  132.  

Update the Post

Either update this post and resubmit it with changes, or make a new post.

You may also comment on this post.

update paste below
details of the post (optional)

Note: Only the paste content is required, though the following information can be useful to others.

Save name / title?

(space separated, optional)



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.

comments powered by Disqus
worth-right
worth-right