When writing tests for: http://drupal.org/node/256152 I needed to check something which validates against ip_address() (which is pretty much a wrapper for $_SERVER['REMOTE_ADDR'])

debian etch: libcurl3 (>= 7.15.5-1) - fails
ubuntu gutsy: - libcurl3 (>= 7.16.2-1) - passes
MAMP on OSX: fails (not sure of curl version).

Another option might be to try to fake $_SERVER['REMOTE_ADDR'] within the simpletest browser to something consistent - then test against that for any similar tests, bit nasty but for what it's worth.

Comments

boombatower’s picture

The IP could be set to something in a similar manor to the db prefix. What should it be set to?

boombatower’s picture

Status: Active » Postponed (maintainer needs more info)

Marking accordingly.

catch’s picture

Status: Postponed (maintainer needs more info) » Active

Not sure really, 127.0.0.1 maybe?

chx’s picture

just pass on the real ip_address

boombatower’s picture

This would be very simple to fix, just check for SimpleTest user-agent then set IP to x if it doesn't come through.

I can't test this because it passes on my machine.

boombatower’s picture

Status: Active » Postponed (maintainer needs more info)

Bump, we need to pick an IP address and get this fixed. I would second 127.0.0.1.

catch’s picture

Status: Postponed (maintainer needs more info) » Active

@boombatower - do you mean in the test itself or somewhere more central?

boombatower’s picture

More central, but if this is the only place where it occurs perhaps just in the test would be fine.

For consistency and to ensure this doesn't come up again it should probably be more central.

catch’s picture

Status: Active » Needs review
StatusFileSize
new867 bytes

Since this appears to be a curl bug, here's a patch to simply roll back that part of the test - we can then mark this postponed against a curl issue (which I believe chx is arranging).

General consensus has been to keep test passes at 100% (once they all pass), and not commit tests that we know are going to fail - this one kinda breaks that rule so I think it's acceptable to remove.

catch’s picture

Status: Needs review » Closed (won't fix)

Since I can't reproduce this anymore myself, marking as won't fix. Can re-open if someone else does.

catch’s picture

Status: Closed (won't fix) » Needs review

Sorry, I can indeed reproduce this.

boombatower’s picture

Status: Needs review » Reviewed & tested by the community

This patch makes sense, but I think we need to contact the cURL developers and inform them of this issue.

Once resolved this needs to be reverted.

Once this is committed lets mark this as postponed.

Otherwise we can just ignore the environments that this doesn't pass on. :)

catch’s picture

Ideally we want all tests passing on any environments they can be run on - otherwise we'll get bogus test failures while people are trying to write patches or just showing up in the bug queue over and over again. Another option might be to wrap that part of the tests in an if, to ensure ip_address() returns something before doing the assertion - but ideally it can be dealt with on the cURL end.

dries’s picture

Status: Reviewed & tested by the community » Needs work

I've decided to comment out this test instead of deleting it. I've also added a note to explain why it was commented out.

I'm marking this issue 'code needs work'. I think we should mark it 'fixed' once we have reported this bug to the cURL maintainers.

wim leers’s picture

curl version info on Mac OS X Leopard:

curl 7.16.3 (powerpc-apple-darwin9.0) libcurl/7.16.3 OpenSSL/0.9.7l zlib/1.2.3

(Note that I did NOT check if tests are working or failing for me.)

damien tournoud’s picture

Isn't this probably a PHP and/or Apache bug rather than a cURL bug?

I can't understand why the client (here cURL) could have any impact on the server's ability to detect it's IP address. After all, this is done at the TCP layer, not at the HTTP one. We need more information on this.

damien tournoud’s picture

What is the return of $_SERVER['REMOTE_ADDR'] in the case it fails?

damien tournoud’s picture

Title: internal browser and ip_address() inconsistent » Internal browser and ip_address() inconsistent
StatusFileSize
new1.37 KB

Ok, here is a fix for that.

Tested in the both cases I could think of (the hostname specified in $base_url points to 127.0.0.1 and that hostname points to the IP of an external interface), tests pass.

About the debate on whether we should "teach" ip_address() to fake it's return when we are in a test request: I think we shouldn't, because there are no needs to at that point.

damien tournoud’s picture

Status: Needs work » Needs review
catch’s picture

Status: Needs review » Reviewed & tested by the community

Works for me :)

dries’s picture

Doesn't work for me yet.

In the test, $parsed['host'] is 'localhost' and the IP in $edit['ip'] is '127.0.0.1'.

Given that, I've put the following two lines in system_ip_blocking_form_validate():

  file_put_contents('/tmp/drupal.log', "$ip -- ". ip_address() ."\n", FILE_APPEND);
  flush();

This is what ends up in the log file when running the tests:

$ tail -f /tmp/drupal.log
192.168.1.1 -- ::1
192.168.1.1 -- ::1
255.255.255.255 -- ::1
test.example.com -- ::1
 -- ::1
127.0.0.1 -- ::1

It looks like ip_address() doesn't return a proper IP address (when running simpletest)?

catch’s picture

Status: Reviewed & tested by the community » Needs work

Hmm. I'll try again on my system where it seemed to fix the problem, but looks like we might have to leave this postponed against cURL still.

damien tournoud’s picture

@Dries#21: ip_address() can't be wrong, it just report the IP address of the client as seen by the server. Except that here it's the address of the IPv6 loopback interface.

What's wrong is my code that tries to guess what the IP address of the client *as seen by the server* could possibly be if we call the server from the same box as the client.

Can you paste your /etc/hosts? I guess there is a localhost ::1 there.

dries’s picture

Damien, you're right! Here is my /etc/hosts:

127.0.0.1	localhost
255.255.255.255	broadcasthost
::1             localhost 
192.168.2.2     metis

I checked on both my Macs and they both have that line.

dave reid’s picture

Status: Needs work » Needs review

So this sounds like it's a configuration problem then? We should probably add this test back in.

Status: Needs review » Needs work

The last submitted patch failed testing.

  • Dries committed 1d97b23 on 8.3.x
    - Patch #256886 by catch et al: comment out a test that fails due to a...

  • Dries committed 1d97b23 on 8.3.x
    - Patch #256886 by catch et al: comment out a test that fails due to a...

  • Dries committed 1d97b23 on 8.4.x
    - Patch #256886 by catch et al: comment out a test that fails due to a...

  • Dries committed 1d97b23 on 8.4.x
    - Patch #256886 by catch et al: comment out a test that fails due to a...

  • Dries committed 1d97b23 on 9.1.x
    - Patch #256886 by catch et al: comment out a test that fails due to a...

Status: Needs work » Closed (outdated)

Automatically closed because Drupal 7 security and bugfix support has ended as of 5 January 2025. If the issue verifiably applies to later versions, please reopen with details and update the version.