jcrodriguez-dis / vpl-jail-system

Execution/jail server for VPL
GNU General Public License v3.0
23 stars 22 forks source link

bug with TASK_ONLY_FROM #50

Closed jkeltz closed 1 year ago

jkeltz commented 2 years ago

Our local moodle installation is moving to the cloud. TASK_ONLY_FROM was working perfectly for the local installation which lists only 2 IP ranges. In the cloud, it doesn't work. It turns out this is because when I list the 6 possible IPs that can submit tasks, only the first few work. I believe, in particular, the first 3 work but everything else fails. Can you look into this for me please? Running on CentOS 7 with latest Jail server 2.7.1.

jkeltz commented 2 years ago

in configuration.cpp this code isn't working quite right... i inserted some debug syslog lines...

        string dir;
        size_t pos=0;
        while((pos=tof.find(" ", pos)) != string::npos){
                dir=tof.substr(0, pos);
                Util::trimAndRemoveQuotes(dir);
                if(dir.length() > 0) {
                        taskOnlyFrom.push_back(dir);
                        syslog(LOG_INFO, "in readconfigfile and IP is %s",dir.c_str());
                }
                tof.erase(0, pos);
        }
        dir=tof.substr(0, pos);

        Util::trimAndRemoveQuotes(dir);
        if(dir.size() > 0) {
                taskOnlyFrom.push_back(dir);
                syslog(LOG_INFO, "after while loop dir contains  %s",dir.c_str());
        }

(IPs changed for privacy)

The result in syslog was..

Dec 17 16:05:42 vpl1 vpl-jail-system[26544]: in readconfigfile and IP is 1.2.3.4
Dec 17 16:05:42 vpl1 vpl-jail-system[26544]: in readconfigfile and IP is 5.6.7.8
Dec 17 16:05:42 vpl1 vpl-jail-system[26544]: in readconfigfile and IP is 9.10.11.12 13.14.15.16
Dec 17 16:05:42 vpl1 vpl-jail-system[26544]: after while loop dir contains  17.18.19.20 21.22.23.24

... which messes with the IP blocking in the further addresses...

I replaced the above code with this simpler use:


        std::istringstream iss (tof);
        for (string s; iss >> s; ) {
          taskOnlyFrom.push_back(s);
          syslog(LOG_INFO,"found IP %s",s.c_str());
        }

It picks out all the IPs properly.

I had to also define at the top:

#include <sstream>

jcrodriguez-dis commented 2 years ago

Dear keltz. Thank you for the bug report. I will review the problem and your code to solve the issue as soon as possible.

Juan Carlos.