Imported Upstream version 2.7
[ossec-hids.git] / src / addagent / manage_agents.h
1 /* @(#) $Id: ./src/addagent/manage_agents.h, 2011/09/08 dcid Exp $
2  */
3
4 /* Copyright (C) 2009 Trend Micro Inc.
5  * All rights reserved.
6  *
7  * This program is a free software; you can redistribute it
8  * and/or modify it under the terms of the GNU General Public
9  * License (version 2) as published by the FSF - Free Software
10  * Foundation.
11  *
12  * License details at the LICENSE file included with OSSEC or
13  * online at: http://www.ossec.net/en/licensing.html
14  */
15
16
17 #include "shared.h"
18 #include "sec.h"
19
20
21 /** Prototypes **/
22
23 /* Read any input from the user (stdin) */
24 char *read_from_user();
25
26 /* Add or remove an agent */
27 int add_agent();
28 int remove_agent();
29
30 /* Extract or import a key */
31 int k_extract(char *cmdextract);
32 int k_import(char *cmdimport);
33 int k_bulkload(char *cmdbulk);
34
35 /* Validation functions */
36 int OS_IsValidName(char *u_name);
37 int OS_IsValidID(char *id);
38 int IDExist(char *id);
39 int NameExist(char *u_name);
40 char *getFullnameById(char *id);
41 char *OS_AddNewAgent(char *name, char *ip, char *id, char *key);
42
43
44
45 /* Print available agents */
46 int print_agents(int print_status, int active_only, int csv_output);
47 int list_agents(int cmdlist);
48
49 /* clear a line */
50 char *chomp(char *str);
51
52
53 /* Shared variables */
54 int restart_necessary;
55 int time1;
56 int time2;
57 int time3;
58 int rand1;
59 int rand2;
60 fpos_t fp_pos;
61
62
63 /* Internal defines */
64 #define USER_SIZE       514
65 #define FILE_SIZE       257
66 #define STR_SIZE        66
67
68 /* Internal strings */
69 #define QUIT                "\\q"
70
71 /* Print agents */
72 #define PRINT_AVAILABLE     "\nAvailable agents: \n"
73 #define PRINT_AGENT         "   ID: %s, Name: %s, IP: %s\n"
74 #define PRINT_AGENT_STATUS  "   ID: %s, Name: %s, IP: %s, %s\n"
75
76
77 /* Add new agent */
78 #define ADD_NEW         "\n- Adding a new agent"\
79                         " (use '\\q' to return to the main menu).\n"\
80                         "  Please provide the following:\n"
81 #define ADD_NAME        "   * A name for the new agent: "
82 #define ADD_IP          "   * The IP Address of the new agent: "
83 #define ADD_ID          "   * An ID for the new agent[%s]: "
84 #define AGENT_INFO      "Agent information:\n   ID:%s\n   Name:%s\n   " \
85                         "IP Address:%s\n\n"
86 #define ADD_CONFIRM     "Confirm adding it?(y/n): "
87 #define AGENT_ADD       "Agent added.\n"
88 #define ADDED           "Added.\n"
89 #define ADD_NOT         "Not Adding ..\n"
90 #define PRESS_ENTER     "** Press ENTER to return to the main menu.\n"
91 #define MUST_RESTART    "\n** You must restart OSSEC for your changes" \
92                         " to take effect.\n\n"
93
94 /* Add errors */
95 #define ADD_ERROR_ID    "\n** ID '%s' already present. They must be unique.\n\n"
96 #define ADD_ERROR_NAME  "\n** Name '%s' already present. Please enter a new name.\n\n"
97 #define IP_ERROR        "\n** Invalid IP '%s'. Please enter a valid IP Address.\n\n"
98 #define NO_AGENT        "\n** No agent available. You need to add one first.\n"
99 #define NO_ID           "\n** Invalid ID '%s' given. ID is not present.\n"
100 #define NO_KEY          "\n** Invalid authentication key. Starting over again.\n"
101 #define INVALID_ID      "\n** Invalid ID '%s' given. ID must be numeric (max 8 digits).\n\n"
102 #define INVALID_NAME    "\n** Invalid name '%s' given. Name must contain only alphanumeric characters (min=2, max=32).\n\n"
103
104 /* Remove agent */
105 #define REMOVE_ID       "Provide the ID of the agent to be removed (or '\\q' to quit): "
106 #define REMOVE_CONFIRM  "Confirm deleting it?(y/n): "
107 #define REMOVE_DONE     "Agent '%s' removed.\n"
108 #define REMOVE_NOT      "Not removing ..\n"
109
110 /* Import agent */
111 #define IMPORT_KEY      "\n* Provide the Key generated by the server.\n" \
112                         "* The best approach is to cut and paste it.\n" \
113                         "*** OBS: Do not include spaces or new lines.\n\n" \
114                         "Paste it here (or '\\q' to quit): "
115
116 /* extract key */
117 #define EXTRACT_KEY     "Provide the ID of the agent to extract " \
118                         "the key (or '\\q' to quit): "
119 #define EXTRACT_MSG     "\nAgent key information for '%s' is: \n%s\n"
120
121
122 /* Commom errors */
123 #define ERROR_KEYS      "Unable to handle keys file. Exiting.\n"
124 #define EXTRACT_ERROR   "Unable to extract agent key.\n"
125 #define INPUT_LARGE     ARGV0 ": Input too large. Not adding it.\n"
126 #define EXIT            ARGV0 ": Exiting ..\n"
127
128 #define BANNER          "\n****************************************" \
129                         "\n* %s %s Agent manager.     *" \
130                         "\n* The following options are available: *" \
131                         "\n****************************************\n"
132
133 #define BANNER_OPT      "   (A)dd an agent (A).\n" \
134                         "   (E)xtract key for an agent (E).\n" \
135                         "   (L)ist already added agents (L).\n" \
136                         "   (R)emove an agent (R).\n" \
137                         "   (Q)uit.\n" \
138                         "Choose your action: A,E,L,R or Q: "
139
140 #define BANNER_CLIENT   "   (I)mport key from the server (I).\n" \
141                         "   (Q)uit.\n" \
142                         "Choose your action: I or Q: "
143
144 /* EOF */