X-Git-Url: http://ftp.carnet.hr/carnet-debian/scm?p=ossec-hids.git;a=blobdiff_plain;f=src%2Fwin32%2Fui%2Fos_win32ui.c;fp=src%2Fwin32%2Fui%2Fos_win32ui.c;h=8b26954339f33034f45ffb2b8dfe1beb213e8c38;hp=e19b9690e1c1ad536c3b11c0031d8da19f397f97;hb=789cbc8e52da68eba3517b920ef22e000cf3c9fd;hpb=ef70704f0b31b59bb719b884d6a99cb9e3e2044a diff --git a/src/win32/ui/os_win32ui.c b/src/win32/ui/os_win32ui.c index e19b969..8b26954 100644 --- a/src/win32/ui/os_win32ui.c +++ b/src/win32/ui/os_win32ui.c @@ -99,7 +99,7 @@ BOOL CALLBACK DlgProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) hStatus = CreateWindowEx(0, STATUSCLASSNAME, NULL, - WS_CHILD|WS_VISIBLE|SBARS_SIZEGRIP, + WS_CHILD|WS_VISIBLE, 0, 0, 0, 0, hwnd, (HMENU)IDC_MAIN_STATUS, GetModuleHandle(NULL), NULL); @@ -109,7 +109,6 @@ BOOL CALLBACK DlgProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) (LPARAM)statwidths); SendMessage(hStatus, SB_SETTEXT, 0, (LPARAM)"http://www.ossec.net"); - /* Initializing config */ config_read(hwnd); @@ -128,7 +127,7 @@ BOOL CALLBACK DlgProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) { MessageBox(hwnd, "Admin access required. Some features may not work properly. \n\n" "**If on Vista (or Server 2008), choose the \"Run as administrator\" option.", - "Admin access required.", MB_OK); + "Admin Access Required", MB_OK); break; } @@ -153,10 +152,6 @@ BOOL CALLBACK DlgProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) break; } - /** Getting values from the user (if chosen save) - * We should probably create another function for it... - **/ - /* Getting server ip */ len = GetWindowTextLength(GetDlgItem(hwnd, UI_SERVER_TEXT)); if(len > 0) @@ -214,7 +209,6 @@ BOOL CALLBACK DlgProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) char *name = NULL; char *ip = NULL; - /* Getting new fields */ decd_buf = decode_base64(buf); if(decd_buf) @@ -250,8 +244,8 @@ BOOL CALLBACK DlgProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) if(!ip) { MessageBox(hwnd, "Unable to import " - "authentication key. Invalid.", - "Error Saving.", MB_OK); + "authentication key because it was invalid.", + "Error -- Failure Saving Auth Key", MB_OK); } else { @@ -265,20 +259,14 @@ BOOL CALLBACK DlgProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) id, name, ip); ret = MessageBox(hwnd, mbox_msg, - "Confirm Importing Key", MB_OKCANCEL); + "Confirm Importing Key", MB_OKCANCEL); if(ret == IDOK) { - FILE *fp; - fp = fopen(AUTH_FILE, "w"); - if(fp) + if(set_ossec_key(decd_to_write, hwnd)) { - chd+=2; - fprintf(fp, "%s", decd_to_write); - fclose(fp); + chd += 2; } } - - } /* Free used memory */ @@ -311,18 +299,18 @@ BOOL CALLBACK DlgProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) if(chd == 1) { SendMessage(hStatus, SB_SETTEXT, 0, - (LPARAM)"Server IP Saved .."); + (LPARAM)"Server IP saved"); } else if(chd == 2) { SendMessage(hStatus, SB_SETTEXT, 0, - (LPARAM)"Auth key imported .."); + (LPARAM)"Auth key imported"); } else { SendMessage(hStatus, SB_SETTEXT, 0, - (LPARAM)"Auth key and server ip saved .."); + (LPARAM)"Auth key and IP saved"); } } @@ -368,23 +356,23 @@ BOOL CALLBACK DlgProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) if(ret_code == 0) { - MessageBox(hwnd, "Unable to start OSSEC (check config).", - "Error -- Unable to start", MB_OK); + MessageBox(hwnd, "Unable to start agent (check config)", + "Error -- Unable to Start Agent", MB_OK); } else if(ret_code == 1) { config_read(hwnd); gen_server_info(hwnd); - SendMessage(hStatus, SB_SETTEXT, 0, (LPARAM)"Started.."); + SendMessage(hStatus, SB_SETTEXT, 0, (LPARAM)"Started"); - MessageBox(hwnd, "OSSEC Agent Started.", - "Started..", MB_OK); + MessageBox(hwnd, "Agent started", + "Agent Started", MB_OK); } else { - MessageBox(hwnd, "Agent already running (try restart).", - "Already running..", MB_OK); + MessageBox(hwnd, "Agent already running (try restart)", + "Agent Running", MB_OK); } break; case UI_MENU_MANAGE_STOP: @@ -396,27 +384,27 @@ BOOL CALLBACK DlgProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) config_read(hwnd); gen_server_info(hwnd); - SendMessage(hStatus, SB_SETTEXT, 0, (LPARAM)"Stopped.."); - MessageBox(hwnd, "OSSEC Agent Stopped.", - "Stopped..", MB_OK); + SendMessage(hStatus, SB_SETTEXT, 0, (LPARAM)"Stopped"); + MessageBox(hwnd, "Agent stopped", + "Agent Stopped", MB_OK); } else { - MessageBox(hwnd, "Agent already stopped.", - "Already stopped..", MB_OK); + MessageBox(hwnd, "Agent already stopped", + "Agent Stopped", MB_OK); } break; case UI_MENU_MANAGE_STATUS: if(CheckServiceRunning()) { - MessageBox(hwnd, "OSSEC Agent running.", - "Agent running..", MB_OK); + MessageBox(hwnd, "Agent running", + "Agent Running", MB_OK); } else { - MessageBox(hwnd, "OSSEC Agent stopped.", - "Agent stopped.", MB_OK); + MessageBox(hwnd, "Agent stopped", + "Agent Stopped", MB_OK); } break; case UI_MENU_MANAGE_RESTART: @@ -424,8 +412,8 @@ BOOL CALLBACK DlgProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) if((strcmp(config_inst.key, FL_NOKEY) == 0) || (strcmp(config_inst.server, FL_NOSERVER) == 0)) { - MessageBox(hwnd, "Unable to restart OSSEC (check config).", - "Error -- Unable to restart", MB_OK); + MessageBox(hwnd, "Unable to restart agent (check config)", + "Error -- Unable to Restart Agent", MB_OK); break; } @@ -436,17 +424,17 @@ BOOL CALLBACK DlgProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) ret_code = os_start_service(); if(ret_code == 0) { - MessageBox(hwnd, "Unable to restart OSSEC (check config).", - "Error -- Unable to restart", MB_OK); + MessageBox(hwnd, "Unable to restart agent (check config)", + "Error -- Unable to Restart Agent", MB_OK); } else { config_read(hwnd); gen_server_info(hwnd); - SendMessage(hStatus, SB_SETTEXT, 0, (LPARAM)"Restarted.."); - MessageBox(hwnd, "OSSEC Agent Restarted.", - "Restarted..", MB_OK); + SendMessage(hStatus, SB_SETTEXT, 0, (LPARAM)"Restarted"); + MessageBox(hwnd, "Agent restarted", + "Agent Restarted", MB_OK); } break; } @@ -468,14 +456,11 @@ BOOL CALLBACK DlgProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { - int ret; WSADATA wsaData; - /* Starting Winsock -- for name resolution. */ WSAStartup(MAKEWORD(2, 0), &wsaData); - /* Initializing config */ init_config(); @@ -485,23 +470,6 @@ int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, /* Creating main dialogbox */ DialogBox(hInstance, MAKEINTRESOURCE(IDD_MAIN), NULL, DlgProc); - - /* Check if service is running and try to start it */ - if((strcmp(config_inst.key, FL_NOKEY) != 0)&& - (strcmp(config_inst.server, FL_NOSERVER) != 0) && - !CheckServiceRunning() && - (config_inst.admin_access != 0)) - { - ret = MessageBox(NULL, "OSSEC Agent not running. " - "Do you wish to start it?", - "Wish to start the agent?", MB_OKCANCEL); - if(ret == IDOK) - { - /* Starting the service */ - os_start_service(); - } - } - return(0); }