Changeset 632

Show
Ignore:
Timestamp:
10/05/08 16:09:24 (3 months ago)
Author:
ftx
Message:

fixe for segfault in case of missing /proc/modules
Closes: #227

Location:
trunk/daemon/src
Files:
4 modified

Legend:

Unmodified
Added
Removed
  • trunk/daemon/src/bandwidth.c

    r576 r632  
    1818 
    1919 
     20#include <string.h> 
     21 
    2022#include "main.h" 
    2123#include "misc.h" 
     
    2325#include "request.h" 
    2426#include "error.h" 
     27 
     28#include "fs.h" 
    2529 
    2630 
     
    321325 
    322326 
    323  
     327int ifb_kernel_support() 
     328{ 
     329        char *devsfile = file_read("/proc/net/dev"); 
     330        int ret = 0; 
     331         
     332        if(devsfile != NULL) 
     333        { 
     334                if(strstr(devsfile, "ifb") != NULL) 
     335                        ret = 1; 
     336        } 
     337         
     338        free(devsfile); 
     339         
     340        return ret; 
     341} 
  • trunk/daemon/src/bandwidth.h

    r525 r632  
    3030        struct ovcp_response_st *del_bandwidth(struct ovcp_request_st *request); 
    3131         
     32        int ifb_kernel_support(); 
     33         
    3234#endif 
  • trunk/daemon/src/misc.c

    r631 r632  
    747747 
    748748        modfile = fopen("/proc/modules", "r"); 
    749  
     749        if(modfile == NULL) 
     750                return 0; 
     751                 
    750752        while(!feof(modfile)) 
    751753        { 
  • trunk/daemon/src/traffic.c

    r576 r632  
    530530        sqlite3_exec(openvcp_db, "CREATE TABLE vserver_trafficlimit ('id' INTEGER PRIMARY KEY AUTOINCREMENT, 'name', 'total', 'notify', 'type', 'notified', UNIQUE(name, type))", NULL, 0, NULL); 
    531531 
    532         system("modprobe ifb 2>/dev/null");      
    533          
    534         system("modprobe ip_tables 2>/dev/null"); 
    535         if(kernelmodule_loaded("ip_tables")) 
    536         { 
    537                 ovcp_create_chains(); 
    538                 ovcp_create_tables(openvcp_db); 
    539         } 
    540         else  ovcp_log(OVCP_WARNING, "ip_tables Kernel Module not found"); 
    541          
    542         system("modprobe nf_conntrack_ftp 2>/dev/null"); 
     532        execb_cmd("modprobe", "modprobe", "ifb", NULL);  
     533         
     534        execb_cmd("modprobe", "modprobe", "ip_tables", NULL); 
     535 
     536        ovcp_create_chains(); 
     537        ovcp_create_tables(openvcp_db); 
     538 
     539        execb_cmd("modprobe", "modprobe", "nf_conntrack_ftp", NULL); 
     540 
    543541         
    544542        ifaces = split_string(global_settings.ifaces, ' ', &iface_count); 
     
    604602                }                
    605603                 
    606                 if(kernelmodule_loaded("ifb")) 
     604                if(ifb_kernel_support()) 
    607605                        ovcp_setup_trafficthrottling(openvcp_db); 
    608606                else  ovcp_log(OVCP_WARNING, "ifb Kernel Module not found");