Skip to content

Commit b8ed3fa

Browse files
committed
feat: Delete of OSSECHIDS conditional directives.
1 parent 604667d commit b8ed3fa

File tree

9 files changed

+0
-431
lines changed

9 files changed

+0
-431
lines changed

src/modules/rootcheck/include/rootcheck.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,6 @@ void check_rc_pids(void);
126126
int check_rc_readproc(int pid);
127127

128128
void check_rc_ports(void);
129-
void check_open_ports(void);
130129
void check_rc_if(void);
131130

132131
/*Checks if the path or file is user-ignored */

src/modules/rootcheck/src/check_open_ports.c

Lines changed: 0 additions & 122 deletions
This file was deleted.

src/modules/rootcheck/src/check_rc_pids.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,14 +168,11 @@ static void loop_all_pids(const char *ps, pid_t max_pid, int *_errors, int *_tot
168168
}
169169
}
170170

171-
/* If we are run in the context of OSSEC-HIDS, sleep here (no rush) */
172-
#ifdef OSSECHIDS
173171
#ifdef WIN32
174172
Sleep(rootcheck.tsleep);
175173
#else
176174
struct timeval timeout = {0, rootcheck.tsleep * 1000};
177175
select(0, NULL, NULL, NULL, &timeout);
178-
#endif
179176
#endif
180177

181178
/* Everything fine, move on */

src/modules/rootcheck/src/check_rc_ports.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,14 +105,11 @@ static void test_ports(int proto, int *_errors, int *_total)
105105
continue;
106106
}
107107

108-
#ifdef OSSECHIDS
109-
/* If we are in the context of OSSEC-HIDS, sleep here (no rush) */
110108
#ifdef WIN32
111109
Sleep(rootcheck.tsleep);
112110
#else
113111
struct timeval timeout = {0, rootcheck.tsleep * 1000};
114112
select(0, NULL, NULL, NULL, &timeout);
115-
#endif
116113
#endif
117114

118115
if (!run_netstat(proto, i) && conn_port(proto, i)) {

src/modules/rootcheck/src/check_rc_sys.c

Lines changed: 0 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,6 @@ static int read_sys_file(const char *file_name, int do_read)
142142

143143
if (statbuf.st_uid == 0) {
144144
char op_msg[OS_SIZE_1024 + 1];
145-
#ifdef OSSECHIDS
146145
const char op_msg_fmt[] = "File '%*s' is owned by root and has written permissions to anyone.";
147146

148147
const int size = snprintf(NULL, 0, op_msg_fmt, (int)strlen(file_name), file_name);
@@ -161,27 +160,6 @@ static int read_sys_file(const char *file_name, int do_read)
161160
}
162161

163162
_sys_errors++;
164-
165-
#else
166-
const char op_msg_fmt[] = "File '%*s' is: \n - owned by root,\n - has write permissions to anyone.";
167-
168-
const int size = snprintf(NULL, 0, op_msg_fmt, (int)strlen(file_name), file_name);
169-
170-
if (size >= 0) {
171-
if ((size_t)size < sizeof(op_msg)) {
172-
snprintf(op_msg, sizeof(op_msg), op_msg_fmt, (int)strlen(file_name), file_name);
173-
} else {
174-
const unsigned int surplus = size - sizeof(op_msg) + 1;
175-
snprintf(op_msg, sizeof(op_msg), op_msg_fmt, (int)(strlen(file_name) - surplus), file_name);
176-
}
177-
178-
notify_rk(ALERT_SYSTEM_CRIT, op_msg);
179-
} else {
180-
mtdebug2(ARGV0, "Error %d (%s) with snprintf with file %s", errno, strerror(errno), file_name);
181-
}
182-
183-
_sys_errors++;
184-
#endif
185163
}
186164
} else if ((statbuf.st_mode & S_ISUID) == S_ISUID) {
187165
if (_suid) {

src/modules/rootcheck/src/config.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
* Foundation
99
*/
1010

11-
#ifdef OSSECHIDS
1211
#include "shared.h"
1312
#include "rootcheck.h"
1413
#include "config/config.h"
@@ -104,5 +103,3 @@ cJSON *getRootcheckConfig(void) {
104103

105104
return root;
106105
}
107-
108-
#endif /* OSSECHIDS */

src/modules/rootcheck/src/rootcheck.c

Lines changed: 0 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -28,50 +28,12 @@ char total_ports_tcp[65535 + 1];
2828
#define ARGV0 "rootcheck"
2929
#endif
3030

31-
#ifndef OSSECHIDS
32-
33-
/* Print help statement */
34-
void help_rootcheck(char * home_path)
35-
{
36-
print_header();
37-
print_out(" %s: -[Vhdtsr] [-c config] [-D dir]", ARGV0);
38-
print_out(" -V Version and license message");
39-
print_out(" -h Print this help message");
40-
print_out(" -d Execute in debug mode. This parameter");
41-
print_out(" can be specified multiple times");
42-
print_out(" to increase the debug level.");
43-
print_out(" -t Test configuration");
44-
print_out(" -s Scan the whole system");
45-
print_out(" -r Read all the files for kernel-based detection");
46-
print_out(" -c <config> Configuration file to use");
47-
print_out(" -D <dir> Directory to chroot into (default: %s)", home_path);
48-
print_out(" ");
49-
os_free(home_path);
50-
exit(1);
51-
}
52-
53-
int main(int argc, char **argv)
54-
{
55-
int test_config = 0;
56-
const char *cfg = "./rootcheck.conf";
57-
char * home_path = w_homedir(argv[0]);
58-
59-
#else
60-
6131
int rootcheck_init(int test_config)
6232
{
6333
const char *cfg = OSSECCONF;
6434

65-
#endif /* OSSECHIDS */
66-
6735
int c;
6836

69-
#ifndef OSSECHIDS
70-
if (chdir(home_path) == -1) {
71-
merror_exit(CHDIR_ERROR, home_path, errno, strerror(errno));
72-
}
73-
#endif /* OSSECHIDS */
74-
7537
/* Zero the structure, initialize default values */
7638
rootcheck.workdir = NULL;
7739
rootcheck.basedir = NULL;
@@ -115,58 +77,6 @@ int rootcheck_init(int test_config)
11577
c++;
11678
}
11779

118-
#ifndef OSSECHIDS
119-
rootcheck.notify = SYSLOG_RK;
120-
rootcheck.daemon = 0;
121-
while ((c = getopt(argc, argv, "VstrdhD:c:")) != -1) {
122-
switch (c) {
123-
case 'V':
124-
print_version();
125-
break;
126-
case 'h':
127-
help_rootcheck(home_path);
128-
break;
129-
case 'd':
130-
nowDebug();
131-
break;
132-
case 'D':
133-
if (!optarg) {
134-
mterror_exit(ARGV0, "-D needs an argument");
135-
}
136-
rootcheck.workdir = optarg;
137-
break;
138-
case 'c':
139-
if (!optarg) {
140-
mterror_exit(ARGV0, "-c needs an argument");
141-
}
142-
cfg = optarg;
143-
break;
144-
case 's':
145-
rootcheck.scanall = 1;
146-
break;
147-
case 't':
148-
test_config = 1;
149-
break;
150-
case 'r':
151-
rootcheck.readall = 1;
152-
break;
153-
default:
154-
help_rootcheck(home_path);
155-
break;
156-
}
157-
}
158-
#ifdef WIN32
159-
/* Start Winsock */
160-
{
161-
WSADATA wsaData;
162-
if (WSAStartup(MAKEWORD(2, 0), &wsaData) != 0) {
163-
mterror_exit(ARGV0, "WSAStartup() failed");
164-
}
165-
}
166-
#endif /* WIN32 */
167-
168-
#endif /* OSSECHIDS */
169-
17080
/* Check if the configuration is present */
17181
if (File_DateofChange(cfg) < 0) {
17282
mterror(ARGV0, "Configuration file '%s' not found", cfg);
@@ -211,22 +121,11 @@ int rootcheck_init(int test_config)
211121
}
212122
#endif
213123

214-
/* Set default values */
215-
#ifndef OSSECHIDS
216-
mdebug1(WAZUH_HOMEDIR, home_path);
217-
if (rootcheck.workdir == NULL) {
218-
rootcheck.workdir = home_path;
219-
}
220-
#endif
221-
222-
#ifdef OSSECHIDS
223124
/* Start up message */
224125
#ifdef WIN32
225126
mtinfo(ARGV0, STARTUP_MSG, getpid());
226127
#endif /* WIN32 */
227128

228-
#endif /* OSSECHIDS */
229-
230129
/* Initialize rk list */
231130
rk_sys_name = (char **) calloc(MAX_RK_SYS + 2, sizeof(char *));
232131
rk_sys_file = (char **) calloc(MAX_RK_SYS + 2, sizeof(char *));
@@ -236,18 +135,6 @@ int rootcheck_init(int test_config)
236135
rk_sys_name[0] = NULL;
237136
rk_sys_file[0] = NULL;
238137

239-
#ifndef OSSECHIDS
240-
#ifndef WIN32
241-
/* Start signal handling */
242-
StartSIG(ARGV0);
243-
rootcheck_connect();
244-
#endif
245-
mtdebug1(ARGV0, "Running run_rk_check");
246-
run_rk_check();
247-
248-
mtdebug1(ARGV0, "Leaving...");
249-
os_free(home_path);
250-
#endif /* OSSECHIDS */
251138
return (0);
252139
}
253140

0 commit comments

Comments
 (0)