cvs: pecl /tcpwrap package.xml tcpwrap.c
| From: | Marcin Gibula | Date: | Fri, 24 Oct 2003 18:11:53 +0000 |
| Subject: | cvs: pecl /tcpwrap package.xml tcpwrap.c | ||
| Groups: | php.pecl.cvs | ||
| Request: | Send a blank email to pecl-cvs+get-502@lists.php.net to get a copy of this message | ||
mg Fri Oct 24 14:11:53 2003 EDT
Modified files:
/pecl/tcpwrap package.xml tcpwrap.c
Log:
Dns resolve failure is now not an error. Added optional parameter to tcpwrap_check to avoid dns
lookups.
Index: pecl/tcpwrap/package.xml
diff -u pecl/tcpwrap/package.xml:1.2 pecl/tcpwrap/package.xml:1.3
--- pecl/tcpwrap/package.xml:1.2 Sun Oct 19 17:34:36 2003
+++ pecl/tcpwrap/package.xml Fri Oct 24 14:11:53 2003
@@ -17,11 +17,11 @@
</maintainers>
<release>
- <version>0.1</version>
- <date>2003-10-19</date>
+ <version>1.0</version>
+ <date>2003-10-24</date>
<state>stable</state>
<notes>
- This is the first release of LZF extension.
+ This is the first release of tcpwrap extension.
</notes>
<filelist>
<dir role="src" name="/">
Index: pecl/tcpwrap/tcpwrap.c
diff -u pecl/tcpwrap/tcpwrap.c:1.1 pecl/tcpwrap/tcpwrap.c:1.2
--- pecl/tcpwrap/tcpwrap.c:1.1 Sun Oct 19 17:22:37 2003
+++ pecl/tcpwrap/tcpwrap.c Fri Oct 24 14:11:53 2003
@@ -15,7 +15,7 @@
| Author: |
+----------------------------------------------------------------------+
- $Id: tcpwrap.c,v 1.1 2003/10/19 21:22:37 mg Exp $
+ $Id: tcpwrap.c,v 1.2 2003/10/24 18:11:53 mg Exp $
*/
#ifdef HAVE_CONFIG_H
@@ -79,11 +79,11 @@
}
/* }}} */
-/* {{{ proto bool tcpwrap_check(string daemon, string address [, string user])
+/* {{{ proto bool tcpwrap_check(string daemon, string address [, string user, [int nodns]])
Check if client has access according to tcp wrappers table */
PHP_FUNCTION(tcpwrap_check)
{
- int argc, retval;
+ int argc, retval, nodns = 0;
char *daemon, *ip, *address, *user = NULL;
int daemon_l, address_l, user_l;
struct in_addr tmp;
@@ -101,6 +101,11 @@
return;
}
break;
+ case 4:
+ if (zend_parse_parameters(argc TSRMLS_CC, "sssb", &daemon, &daemon_l,
&address, &address_l, &user, &user_l, &nodns) == FAILURE) {
+ return;
+ }
+ break;
default:
WRONG_PARAM_COUNT;
}
@@ -113,13 +118,12 @@
ip = address;
address = STRING_UNKNOWN;
} else {
- if (!(host_entry = gethostbyname(address))) {
- php_error(E_WARNING, "%s Host lookup failed", get_active_function_name(TSRMLS_C));
- RETURN_FALSE;
+ if (nodns || !(host_entry = gethostbyname(address))) {
+ ip = STRING_UNKNOWN;
+ } else {
+ memcpy(&tmp.s_addr, *(host_entry->h_addr_list), sizeof(tmp.s_addr));
+ ip = inet_ntoa(tmp);
}
-
- memcpy(&tmp.s_addr, *(host_entry->h_addr_list), sizeof(tmp.s_addr));
- ip = inet_ntoa(tmp);
}
retval = hosts_ctl(daemon, address, ip, user);