Changeset 3153 for trunk/module-monitor.c
- Timestamp:
- 09/22/10 12:02:21 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/module-monitor.c
r2988 r3153 8 8 extern struct s_reader *reader; 9 9 10 static int auth = 0;11 12 10 static void monitor_check_ip() 13 11 { … … 15 13 struct s_ip *p_ip; 16 14 17 if ( auth) return;15 if (client[cs_idx].auth) return; 18 16 for (p_ip=cfg->mon_allowed; (p_ip) && (!ok); p_ip=p_ip->next) 19 17 ok=((client[cs_idx].ip>=p_ip->ip[0]) && (client[cs_idx].ip<=p_ip->ip[1])); … … 29 27 struct s_auth *account; 30 28 31 if ( auth) return;29 if (client[cs_idx].auth) return; 32 30 if ((!usr) || (!pwd)) 33 31 { … … 35 33 cs_exit(0); 36 34 } 37 for (account=cfg->account, auth=0; (account) && (!auth);)35 for (account=cfg->account, client[cs_idx].auth=0; (account) && (!client[cs_idx].auth);) 38 36 { 39 37 if (account->monlvl) 40 auth=!(strcmp(usr, account->usr) | strcmp(pwd, account->pwd));41 if (! auth)38 client[cs_idx].auth=!(strcmp(usr, account->usr) | strcmp(pwd, account->pwd)); 39 if (!client[cs_idx].auth) 42 40 account=account->next; 43 41 } 44 if (! auth)42 if (!client[cs_idx].auth) 45 43 { 46 44 cs_auth_client((struct s_auth *)0, "invalid account"); … … 56 54 struct s_auth *account; 57 55 58 if ( auth)56 if (client[cs_idx].auth) 59 57 { 60 58 int s=memcmp(client[cs_idx].ucrc, ucrc, 4); … … 65 63 client[cs_idx].crypted=1; 66 64 crc=(ucrc[0]<<24) | (ucrc[1]<<16) | (ucrc[2]<<8) | ucrc[3]; 67 for (account=cfg->account; (account) && (! auth); account=account->next)65 for (account=cfg->account; (account) && (!client[cs_idx].auth); account=account->next) 68 66 if ((account->monlvl) && 69 67 (crc==crc32(0L, MD5((unsigned char *)account->usr, strlen(account->usr), NULL), 16))) … … 73 71 if (cs_auth_client(account, NULL)) 74 72 cs_exit(0); 75 auth=1;76 } 77 if (! auth)73 client[cs_idx].auth=1; 74 } 75 if (!client[cs_idx].auth) 78 76 { 79 77 cs_auth_client((struct s_auth *)0, "invalid user"); 80 78 cs_exit(0); 81 79 } 82 return( auth);80 return(client[cs_idx].auth); 83 81 } 84 82 … … 236 234 int cs_idx2ridx(int idx){ 237 235 int i; 236 238 237 for (i = 0; i < CS_MAXREADER; i++) 239 if (reader[i].c s_idx==idx)238 if (reader[i].cidx==idx) 240 239 return(i); 241 240 return(-1); … … 460 459 char filename[32]; 461 460 char buffer[128]; 462 sprintf(filename, "%s/reader%d", get_tmp_dir(), reader[ridx].ridx);461 sprintf(filename, "%s/reader%d", get_tmp_dir(), client[cs_idx].ridx); 463 462 fp = fopen(filename, "r"); 464 463 … … 502 501 static void monitor_send_login(void){ 503 502 char buf[64]; 504 if ( auth)503 if (client[cs_idx].auth) 505 504 sprintf(buf, "[A-0000]1|%s logged in\n", client[cs_idx].usr); 506 505 else … … 737 736 if( (arg = strchr(req, ' ')) ) { *arg++ = 0; trim(arg); } 738 737 //trim(req); 739 if ((! auth) && (strcmp(req, cmd[0]))) monitor_login(NULL);738 if ((!client[cs_idx].auth) && (strcmp(req, cmd[0]))) monitor_login(NULL); 740 739 741 740 for (rc=1, i = 0; i < cmdcnt; i++) … … 764 763 } 765 764 766 static void monitor_server( ){765 static void monitor_server(void *idx){ 767 766 int n; 767 768 int cidx=(int)idx; 769 client[cidx].thread=pthread_self(); 768 770 client[cs_idx].typ='m'; 769 while (((n = process_input( mbuf, sizeof(mbuf), cfg->cmaxidle)) >= 0) && monitor_process_request((char *)mbuf));771 while (((n = process_input(client[cs_idx].mbuf, sizeof(client[cs_idx].mbuf), cfg->cmaxidle)) >= 0) && monitor_process_request((char *)client[cs_idx].mbuf)); 770 772 cs_disconnect_client(); 771 773 }
Note:
See TracChangeset
for help on using the changeset viewer.