Moodle

Implement getremoteaddr() in all places where $_SERVER['REMOTE_ADDR'] is used

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 1.9.4
  • Fix Version/s: 1.9.5
  • Component/s: Libraries
  • Labels:
    None
  • Difficulty:
    Easy
  • Affected Branches:
    MOODLE_19_STABLE
  • Fixed Branches:
    MOODLE_19_STABLE

Description

getremoteaddr() is designed to get the best IP for the current user, with settings so that the admin can even control the way it works.

We should be using it consistently everywhere, but currently there are still places where we are not and are accessing $_SERVER['REMOTE_ADDR'] directly

ie:

auth/cas/cas_ldap_sync_users.php
auth/db/auth_db_sync_users.php
lib/moodlelib.php
lib/form/recaptcha.php
mnet/remote_client.php
mod/resource/type/file/resource.class.php
mod/resource/type/repository/resource.class.php

Dongsheng, can you carefully fix these for 1.9.5 please?

Issue Links

Activity

Hide
Dongsheng Cai added a comment -

$_SERVER['REMOTE_ADDR'] is used to check if user is accessing from web, it is OK in this case.
phpmail and pear auth lib use $_SERVER['REMOTE_ADDR'] directly, I think we should change them.

Following files should be changed:
auth/ldap/auth.php
lib/form/recaptcha.php
mod/hotpot/view.php
mod/resource/type/file/resource.class.php
mod/resource/type/repository/resource.class.php

Show
Dongsheng Cai added a comment - $_SERVER['REMOTE_ADDR'] is used to check if user is accessing from web, it is OK in this case. phpmail and pear auth lib use $_SERVER['REMOTE_ADDR'] directly, I think we should change them. Following files should be changed: auth/ldap/auth.php lib/form/recaptcha.php mod/hotpot/view.php mod/resource/type/file/resource.class.php mod/resource/type/repository/resource.class.php
Hide
Martin Dougiamas added a comment - - edited

Thanks. Doesn't look like these are merged to 1.9.x yet ... ?

Show
Martin Dougiamas added a comment - - edited Thanks. Doesn't look like these are merged to 1.9.x yet ... ?
Hide
Dongsheng Cai added a comment -

Sorry, I forgot to comit it..

Show
Dongsheng Cai added a comment - Sorry, I forgot to comit it..
Hide
Petr Škoda (skodak) added a comment -

thanks

Show
Petr Škoda (skodak) added a comment - thanks
Hide
Chris Fryer added a comment -

May I suggest you backport this change:

http://cvs.moodle.org/moodle/mnet/remote_client.php?r1=1.7&r2=1.8

to MOODLE_19_WEEKLY? getremoteaddr() and address_in_subnet() exist in 1.9.x now.

This will fix an issue where unencrypted XML-RPC calls fail when Moodle is behind a reverse proxy.

Thanks,

Chris

Show
Chris Fryer added a comment - May I suggest you backport this change: http://cvs.moodle.org/moodle/mnet/remote_client.php?r1=1.7&r2=1.8 to MOODLE_19_WEEKLY? getremoteaddr() and address_in_subnet() exist in 1.9.x now. This will fix an issue where unencrypted XML-RPC calls fail when Moodle is behind a reverse proxy. Thanks, Chris

People

Dates

  • Created:
    Updated:
    Resolved: