1 /* @(#) $Id: manage_agents.h,v 1.20 2009/08/05 18:02:13 dcid Exp $ */
3 /* Copyright (C) 2009 Trend Micro Inc.
6 * This program is a free software; you can redistribute it
7 * and/or modify it under the terms of the GNU General Public
8 * License (version 3) as published by the FSF - Free Software
11 * License details at the LICENSE file included with OSSEC or
12 * online at: http://www.ossec.net/en/licensing.html
22 /* Read any input from the user (stdin) */
23 char *read_from_user();
25 /* Add or remove an agent */
29 /* Extract or import a key */
30 int k_extract(char *cmdextract);
31 int k_import(char *cmdimport);
33 /* Validation functions */
34 int OS_IsValidName(char *u_name);
35 int OS_IsValidID(char *id);
36 int IDExist(char *id);
37 int NameExist(char *u_name);
38 char *getFullnameById(char *id);
41 /* Print available agents */
42 int print_agents(int print_status, int active_only, int csv_output);
43 int list_agents(int cmdlist);
46 char *chomp(char *str);
49 /* Shared variables */
50 int restart_necessary;
59 /* Internal defines */
64 /* Internal strings */
68 #define PRINT_AVAILABLE "\nAvailable agents: \n"
69 #define PRINT_AGENT " ID: %s, Name: %s, IP: %s\n"
70 #define PRINT_AGENT_STATUS " ID: %s, Name: %s, IP: %s, %s\n"
74 #define ADD_NEW "\n- Adding a new agent"\
75 " (use '\\q' to return to the main menu).\n"\
76 " Please provide the following:\n"
77 #define ADD_NAME " * A name for the new agent: "
78 #define ADD_IP " * The IP Address of the new agent: "
79 #define ADD_ID " * An ID for the new agent[%s]: "
80 #define AGENT_INFO "Agent information:\n ID:%s\n Name:%s\n " \
82 #define ADD_CONFIRM "Confirm adding it?(y/n): "
83 #define AGENT_ADD "Agent added.\n"
84 #define ADDED "Added.\n"
85 #define ADD_NOT "Not Adding ..\n"
86 #define PRESS_ENTER "** Press ENTER to return to the main menu.\n"
87 #define MUST_RESTART "\n** You must restart the server for your changes" \
88 " to have effect.\n\n"
91 #define ADD_ERROR_ID "\n** ID '%s' already present. They must be unique.\n\n"
92 #define ADD_ERROR_NAME "\n** Name '%s' already present. Please enter a new name.\n\n"
93 #define IP_ERROR "\n** Invalid IP '%s'. Please enter a valid IP Address.\n\n"
94 #define NO_AGENT "\n** No agent available. You need to add one first.\n"
95 #define NO_ID "\n** Invalid ID '%s' given. ID is not present.\n"
96 #define NO_KEY "\n** Invalid authentication key. Starting over again.\n"
97 #define INVALID_ID "\n** Invalid ID '%s' given. ID must be numeric (max 5 digits).\n\n"
98 #define INVALID_NAME "\n** Invalid name '%s' given. Name must contain only alphanumeric characters (min=2, max=32).\n\n"
101 #define REMOVE_ID "Provide the ID of the agent to be removed (or '\\q' to quit): "
102 #define REMOVE_CONFIRM "Confirm deleting it?(y/n): "
103 #define REMOVE_DONE "Agent '%s' removed.\n"
104 #define REMOVE_NOT "Not removing ..\n"
107 #define IMPORT_KEY "\n* Provide the Key generated by the server.\n" \
108 "* The best approach is to cut and paste it.\n" \
109 "*** OBS: Do not include spaces or new lines.\n\n" \
110 "Paste it here (or '\\q' to quit): "
113 #define EXTRACT_KEY "Provide the ID of the agent to extract " \
114 "the key (or '\\q' to quit): "
115 #define EXTRACT_MSG "\nAgent key information for '%s' is: \n%s\n"
119 #define ERROR_KEYS "Unable to handle keys file. Exiting.\n"
120 #define EXTRACT_ERROR "Unable to extract agent key.\n"
121 #define INPUT_LARGE ARGV0 ": Input too large. Not adding it.\n"
122 #define EXIT ARGV0 ": Exiting ..\n"
124 #define BANNER "\n****************************************" \
125 "\n* %s %s Agent manager. *" \
126 "\n* The following options are available: *" \
127 "\n****************************************\n"
129 #define BANNER_OPT " (A)dd an agent (A).\n" \
130 " (E)xtract key for an agent (E).\n" \
131 " (L)ist already added agents (L).\n" \
132 " (R)emove an agent (R).\n" \
134 "Choose your action: A,E,L,R or Q: "
136 #define BANNER_CLIENT " (I)mport key from the server (I).\n" \
138 "Choose your action: I or Q: "