Changeset 1742


Ignore:
Timestamp:
Feb 28, 2010, 10:12:45 AM (10 years ago)
Author:
alno
Message:

reworked "setuser" command in monitor module. Syntax setuser <username> <parameter>=<value>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/module-monitor.c

    r1732 r1742  
    512512    int argidx, i, found;
    513513    char *argarray[3];
    514     char *token[]={"au", "sleep", "uniq", "monlevel", "group", "services", "betatunnel", "ident", "caid", "chid", "class", "hostname", "refresh"};
     514    char *token[]={"au", "sleep", "uniq", "monlevel", "group", "services", "betatunnel", "ident", "caid", "chid", "class", "hostname"};
    515515    int tokencnt = sizeof(token)/sizeof(char *);
    516     char buf[256];
     516    char buf[256], tmp[64];
    517517
    518518    argidx = 0;
    519519    found = 0;
     520
     521    sprintf(tmp, "%s",args);
     522    sprintf(buf, "[S-0000]setuser: %s check\n", tmp);
     523    monitor_send_info(buf, 0);
    520524
    521525    ptr = strtok(args, delimiter);
     
    528532    }
    529533
    530     if(!strcmp(argarray[1], "refresh")){
    531         kill(client[0].pid, SIGHUP);
    532     }else{
    533         if(argidx != 3) {
    534             sprintf(buf, "[S-0000]setuser failed - wrong number of parameters (%d)\n", argidx);
    535             monitor_send_info(buf, 1);
    536             return;
    537         }
     534    if(argidx != 3) {
     535        sprintf(buf, "[S-0000]setuser: %s failed - wrong number of parameters (%d)\n",tmp,  argidx);
     536        monitor_send_info(buf, 0);
     537        sprintf(buf, "[S-0000]setuser: %s end\n", tmp);
     538        monitor_send_info(buf, 1);
     539        return;
    538540    }
    539541
     
    547549
    548550    if (found != 1){
    549         sprintf(buf, "[S-0000]setuser failed - user %s not found\n", argarray[0]);
     551        sprintf(buf, "[S-0000]setuser: %s failed - user %s not found\n",tmp , argarray[0]);
     552        monitor_send_info(buf, 0);
     553        sprintf(buf, "[S-0000]setuser: %s end\n", tmp);
    550554        monitor_send_info(buf, 1);
    551555        return;
     
    561565
    562566            case    8: clear_caidtab(&account->ctab); break;    //Caid
    563 
    564 
    565 
    566 
    567567            }
    568568            found = i;
     
    571571
    572572    if (!found){
    573         sprintf(buf, "[S-0000]setuser failed - parameter %s not exist", argarray[1]);
     573        sprintf(buf, "[S-0000]setuser: %s failed - parameter %s not exist",tmp , argarray[1]);
     574        monitor_send_info(buf, 0);
     575        sprintf(buf, "[S-0000]setuser: %s end\n", tmp);
    574576        monitor_send_info(buf, 1);
    575577        return;
     
    578580    }
    579581
    580     cs_reinit_clients();
    581 
    582     sprintf(buf, "[S-0000]setuser %s done - param %s set to %s\n", argarray[0], argarray[1], argarray[2]);
     582    if (write_userdb()==0)
     583        kill(client[0].pid, SIGHUP);
     584
     585    sprintf(buf, "[S-0000]setuser: %s done - param %s set to %s\n", tmp, argarray[1], argarray[2]);
     586    monitor_send_info(buf, 0);
     587
     588    sprintf(buf, "[S-0000]setuser: %s end\n", tmp);
    583589    monitor_send_info(buf, 1);
    584590}
Note: See TracChangeset for help on using the changeset viewer.