Changeset 4245 for trunk/module-monitor.c
- Timestamp:
- 12/29/10 12:57:16 (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/module-monitor.c
r4163 r4245 12 12 int ok=0; 13 13 struct s_ip *p_ip; 14 15 if (cur_client()->auth) return; 14 struct s_client *cur_cl = cur_client(); 15 16 if (cur_cl->auth) return; 16 17 for (p_ip=cfg->mon_allowed; (p_ip) && (!ok); p_ip=p_ip->next) 17 ok=((cur_cl ient()->ip>=p_ip->ip[0]) && (cur_client()->ip<=p_ip->ip[1]));18 ok=((cur_cl->ip>=p_ip->ip[0]) && (cur_cl->ip<=p_ip->ip[1])); 18 19 if (!ok) 19 20 { 20 cs_auth_client(cur_cl ient(), (struct s_auth *)0, "invalid ip");21 cs_auth_client(cur_cl, (struct s_auth *)0, "invalid ip"); 21 22 cs_exit(0); 22 23 } … … 26 27 { 27 28 struct s_auth *account; 28 29 if (cur_client()->auth) return; 29 struct s_client *cur_cl = cur_client(); 30 31 if (cur_cl->auth) return; 30 32 if ((!usr) || (!pwd)) 31 33 { 32 cs_auth_client(cur_cl ient(), (struct s_auth *)0, NULL);34 cs_auth_client(cur_cl, (struct s_auth *)0, NULL); 33 35 cs_exit(0); 34 36 } 35 for (account=cfg->account, cur_cl ient()->auth=0; (account) && (!cur_client()->auth);)37 for (account=cfg->account, cur_cl->auth=0; (account) && (!cur_cl->auth);) 36 38 { 37 39 if (account->monlvl) 38 cur_cl ient()->auth=!(strcmp(usr, account->usr) | strcmp(pwd, account->pwd));39 if (!cur_cl ient()->auth)40 cur_cl->auth=!(strcmp(usr, account->usr) | strcmp(pwd, account->pwd)); 41 if (!cur_cl->auth) 40 42 account=account->next; 41 43 } 42 if (!cur_cl ient()->auth)43 { 44 cs_auth_client(cur_cl ient(), (struct s_auth *)0, "invalid account");44 if (!cur_cl->auth) 45 { 46 cs_auth_client(cur_cl, (struct s_auth *)0, "invalid account"); 45 47 cs_exit(0); 46 48 } 47 if (cs_auth_client(cur_cl ient(), account, NULL))49 if (cs_auth_client(cur_cl, account, NULL)) 48 50 cs_exit(0); 49 51 } … … 53 55 ulong crc; 54 56 struct s_auth *account; 55 56 if (cur_client()->auth) 57 { 58 int s=memcmp(cur_client()->ucrc, ucrc, 4); 57 struct s_client *cur_cl = cur_client(); 58 59 if (cur_cl->auth) 60 { 61 int s=memcmp(cur_cl->ucrc, ucrc, 4); 59 62 if (s) 60 63 cs_log("wrong user-crc or garbage !?"); 61 64 return(!s); 62 65 } 63 cur_cl ient()->crypted=1;66 cur_cl->crypted=1; 64 67 crc=(ucrc[0]<<24) | (ucrc[1]<<16) | (ucrc[2]<<8) | ucrc[3]; 65 for (account=cfg->account; (account) && (!cur_cl ient()->auth); account=account->next)68 for (account=cfg->account; (account) && (!cur_cl->auth); account=account->next) 66 69 if ((account->monlvl) && 67 (crc==crc32(0L, MD5((unsigned char *)account->usr, strlen(account->usr), cur_cl ient()->dump), 16)))68 { 69 memcpy(cur_cl ient()->ucrc, ucrc, 4);70 aes_set_key((char *)MD5((unsigned char *)account->pwd, strlen(account->pwd), cur_cl ient()->dump));71 if (cs_auth_client(cur_cl ient(), account, NULL))70 (crc==crc32(0L, MD5((unsigned char *)account->usr, strlen(account->usr), cur_cl->dump), 16))) 71 { 72 memcpy(cur_cl->ucrc, ucrc, 4); 73 aes_set_key((char *)MD5((unsigned char *)account->pwd, strlen(account->pwd), cur_cl->dump)); 74 if (cs_auth_client(cur_cl, account, NULL)) 72 75 cs_exit(0); 73 cur_cl ient()->auth=1;74 } 75 if (!cur_cl ient()->auth)76 { 77 cs_auth_client(cur_cl ient(), (struct s_auth *)0, "invalid user");76 cur_cl->auth=1; 77 } 78 if (!cur_cl->auth) 79 { 80 cs_auth_client(cur_cl, (struct s_auth *)0, "invalid user"); 78 81 cs_exit(0); 79 82 } 80 return(cur_cl ient()->auth);83 return(cur_cl->auth); 81 84 } 82 85 … … 250 253 lsec=now-cl->login; 251 254 isec=now-cl->last; 252 usr=cl-> usr;255 usr=cl->account->usr; 253 256 if (((cl->typ == 'r') || (cl->typ == 'p')) && (con=get_ridx(cl->reader)) >= 0) 254 257 usr=cl->reader->label; … … 291 294 time_t now = time((time_t)0); 292 295 293 struct s_client *cl; 296 struct s_client *cl, *cur_cl = cur_client(); 297 294 298 for (cl=first_client; cl ; cl=cl->next) { 295 299 if ((cfg->mon_hideclient_to <= 0) || … … 297 301 ( now-cl->lastemm < cfg->mon_hideclient_to) || 298 302 ( cl->typ != 'c')){ 299 if ((cur_cl ient()->monlvl < 2) && (cl->typ != 's')) {300 if ((strcmp(cur_client()->usr, cl->usr)) ||303 if ((cur_cl->monlvl < 2) && (cl->typ != 's')) { 304 if ((cur_cl->account && cl->account && strcmp(cur_cl->account->usr, cl->account->usr)) || 301 305 ((cl->typ != 'c') && (cl->typ != 'm'))) 302 306 continue; … … 439 443 static void monitor_send_login(void){ 440 444 char buf[64]; 441 if (cur_client()->auth) 442 sprintf(buf, "[A-0000]1|%s logged in\n", cur_client()->usr); 445 struct s_client *cur_cl = cur_client(); 446 if (cur_cl->auth && cur_cl->account) 447 sprintf(buf, "[A-0000]1|%s logged in\n", cur_cl->account->usr); 443 448 else 444 449 strcpy(buf, "[A-0000]0|not logged in\n"); … … 463 468 if (!flag) return; //no arg 464 469 470 struct s_client *cur_cl = cur_client(); 465 471 if (strcmp(flag, "on")) { 466 472 if (strcmp(flag, "onwohist")) { 467 cur_cl ient()->log=0;473 cur_cl->log=0; 468 474 return; 469 475 } 470 476 } 471 477 472 if (cur_cl ient()->log) // already on478 if (cur_cl->log) // already on 473 479 return; 474 480 #ifdef CS_LOGHISTORY … … 478 484 p_usr=(char *)(loghist+(i*CS_LOGHISTSIZE)); 479 485 p_txt = p_usr + 32; 480 if ((p_txt[0]) && ((cur_cl ient()->monlvl > 1) || (!strcmp(p_usr, cur_client()->usr)))) {486 if ((p_txt[0]) && ((cur_cl->monlvl > 1) || (cur_cl->account && !strcmp(p_usr, cur_cl->account->usr)))) { 481 487 char sbuf[8]; 482 sprintf(sbuf, "%03d", cur_cl ient()->logcounter);483 cur_cl ient()->logcounter=(cur_client()->logcounter + 1) % 1000;488 sprintf(sbuf, "%03d", cur_cl->logcounter); 489 cur_cl->logcounter=(cur_cl->logcounter + 1) % 1000; 484 490 memcpy(p_txt + 4, sbuf, 3); 485 491 monitor_send(p_txt); … … 488 494 } 489 495 #endif 490 cur_cl ient()->log=1;496 cur_cl->log=1; 491 497 } 492 498 … … 592 598 593 599 if (write_userdb(cfg->account)==0) 594 cs_reinit_clients( );600 cs_reinit_clients(cfg->account); 595 601 596 602 sprintf(buf, "[S-0000]setuser: %s done - param %s set to %s\n", tmp, argarray[1], argarray[2]); … … 675 681 int cmdcnt = sizeof(cmd)/sizeof(char *); // Calculate the amount of items in array 676 682 char *arg; 683 struct s_client *cur_cl = cur_client(); 677 684 678 685 if( (arg = strchr(req, ' ')) ) { *arg++ = 0; trim(arg); } 679 686 //trim(req); 680 if ((!cur_cl ient()->auth) && (strcmp(req, cmd[0]))) monitor_login(NULL);687 if ((!cur_cl->auth) && (strcmp(req, cmd[0]))) monitor_login(NULL); 681 688 682 689 for (rc=1, i = 0; i < cmdcnt; i++) … … 687 694 case 2: monitor_logsend(arg); break; // log 688 695 case 3: monitor_process_info(); break; // status 689 case 4: if (cur_cl ient()->monlvl > 3) cs_exit(SIGQUIT); break; // shutdown690 case 5: if (cur_cl ient()->monlvl > 2) cs_reinit_clients(); break; // reload696 case 4: if (cur_cl->monlvl > 3) cs_exit(SIGQUIT); break; // shutdown 697 case 5: if (cur_cl->monlvl > 2) cs_reinit_clients(cfg->account); break; // reload 691 698 case 6: monitor_process_details(arg); break; // details 692 699 case 7: monitor_send_details_version(); break; // version 693 case 8: if (cur_cl ient()->monlvl > 3) monitor_set_debuglevel(arg); break; // debuglevel694 case 9: if (cur_cl ient()->monlvl > 3) monitor_get_account(); break; // getuser695 case 10: if (cur_cl ient()->monlvl > 3) monitor_set_account(arg); break; // setuser696 case 11: if (cur_cl ient()->monlvl > 3) monitor_set_server(arg); break; // setserver697 case 12: if (cur_cl ient()->monlvl > 3) monitor_list_commands(cmd, cmdcnt); break; // list commands698 case 13: if (cur_cl ient()->monlvl > 3) monitor_send_keepalive_ack(); break; // keepalive700 case 8: if (cur_cl->monlvl > 3) monitor_set_debuglevel(arg); break; // debuglevel 701 case 9: if (cur_cl->monlvl > 3) monitor_get_account(); break; // getuser 702 case 10: if (cur_cl->monlvl > 3) monitor_set_account(arg); break; // setuser 703 case 11: if (cur_cl->monlvl > 3) monitor_set_server(arg); break; // setserver 704 case 12: if (cur_cl->monlvl > 3) monitor_list_commands(cmd, cmdcnt); break; // list commands 705 case 13: if (cur_cl->monlvl > 3) monitor_send_keepalive_ack(); break; // keepalive 699 706 case 14: { char buf[64];sprintf(buf, "[S-0000]reread\n");monitor_send_info(buf, 1); cs_card_info(); break; } // reread 700 707 default: continue;
Note:
See TracChangeset
for help on using the changeset viewer.