Guest User

Untitled

a guest
May 26th, 2018
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.35 KB | None | 0 0
  1. diff -Naur ruby-tcpwrap.orig//tcpwrap.c ruby-tcpwrap//tcpwrap.c
  2. --- ruby-tcpwrap.orig//tcpwrap.c 2003-08-20 12:30:10.000000000 +0900
  3. +++ ruby-tcpwrap//tcpwrap.c 2010-05-28 01:54:50.000000000 +0900
  4. @@ -25,7 +25,11 @@
  5. */
  6.  
  7. #include "ruby.h"
  8. +#ifdef HAVE_RUBY_IO_H
  9. +#include "ruby/io.h"
  10. +#else
  11. #include "rubyio.h"
  12. +#endif
  13. #include <sys/types.h>
  14. #include <sys/socket.h>
  15. #include <netinet/in.h>
  16. @@ -46,6 +50,10 @@
  17.  
  18. #define DEFAULT_RFC1413_QUERY_TIMEOUT 30
  19.  
  20. +#ifndef RSTRING_PTR
  21. +#define RSTRING_PTR(str) RSTRING(str)->ptr
  22. +#endif
  23. +
  24. int allow_severity = 0;
  25. int deny_severity = 0;
  26.  
  27. @@ -101,7 +109,7 @@
  28. tcp_wrapper_t *tcpd;
  29. VALUE sock;
  30. int sockfd;
  31. - OpenFile *fptr;
  32. + rb_io_t *fptr;
  33. struct sockaddr_storage addr;
  34. char client_name[NI_MAXHOST] = STRING_UNKNOWN;
  35. char client_addr[NI_MAXHOST] = STRING_UNKNOWN;
  36. @@ -113,7 +121,11 @@
  37. again:
  38. sock = rb_funcall(tcpd->server, rb_intern("accept"), 0);
  39. GetOpenFile(sock, fptr);
  40. +#ifdef HAVE_RUBY_IO_H
  41. + sockfd = fileno(fptr->stdio_file);
  42. +#else
  43. sockfd = fileno(fptr->f);
  44. +#endif
  45. if (getpeername(sockfd, (struct sockaddr*) &addr, &len) < 0)
  46. rb_sys_fail("getpeername(2)");
  47. error = getnameinfo((struct sockaddr*) &addr, len,
  48. @@ -132,7 +144,7 @@
  49. if (tcpd->ident_lookup)
  50. client_user = ident_id(sockfd, tcpd->ident_timeout);
  51. #endif
  52. - if (!hosts_ctl(RSTRING(tcpd->daemon)->ptr,
  53. + if (!hosts_ctl(RSTRING_PTR(tcpd->daemon),
  54. client_name,
  55. client_addr,
  56. (client_user == NULL) ? STRING_UNKNOWN : client_user)) {
  57. @@ -157,7 +169,7 @@
  58. static char hosts_allow[MAXPATHLEN];
  59.  
  60. Check_SafeStr(s);
  61. - snprintf(hosts_allow, sizeof(hosts_allow), "%s", RSTRING(s)->ptr);
  62. + snprintf(hosts_allow, sizeof(hosts_allow), "%s", RSTRING_PTR(s));
  63. if(access(hosts_allow, R_OK) < 0)
  64. rb_warning("cannot read %s", hosts_allow);
  65. hosts_allow_table = hosts_allow;
  66. @@ -177,7 +189,7 @@
  67. static char hosts_deny[MAXPATHLEN];
  68.  
  69. Check_SafeStr(s);
  70. - snprintf(hosts_deny, sizeof(hosts_deny), "%s", RSTRING(s)->ptr);
  71. + snprintf(hosts_deny, sizeof(hosts_deny), "%s", RSTRING_PTR(s));
  72. if(access(hosts_deny, R_OK) < 0)
  73. rb_warning("cannot read %s", hosts_deny);
  74. hosts_deny_table = hosts_deny;
  75. @@ -196,7 +208,7 @@
  76. {
  77. if(NIL_P(s)) return STRING_UNKNOWN;
  78. Check_Type(s, T_STRING);
  79. - return RSTRING(s)->ptr;
  80. + return RSTRING_PTR(s);
  81. }
  82.  
  83. static VALUE
Add Comment
Please, Sign In to add comment