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);
(LPARAM)statwidths);
SendMessage(hStatus, SB_SETTEXT, 0, (LPARAM)"http://www.ossec.net");
-
/* Initializing config */
config_read(hwnd);
{
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;
}
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)
char *name = NULL;
char *ip = NULL;
-
/* Getting new fields */
decd_buf = decode_base64(buf);
if(decd_buf)
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
{
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 */
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");
}
}
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:
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:
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;
}
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;
}
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();
/* 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);
}