projects
/
ossec-hids.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Imported Upstream version 2.7
[ossec-hids.git]
/
src
/
rootcheck
/
check_rc_readproc.c
diff --git
a/src/rootcheck/check_rc_readproc.c
b/src/rootcheck/check_rc_readproc.c
index
d136d6e
..
6cc763e
100755
(executable)
--- a/
src/rootcheck/check_rc_readproc.c
+++ b/
src/rootcheck/check_rc_readproc.c
@@
-1,4
+1,5
@@
-/* @(#) $Id$ */
+/* @(#) $Id: ./src/rootcheck/check_rc_readproc.c, 2011/09/08 dcid Exp $
+ */
/* Copyright (C) 2009 Trend Micro Inc.
* All right reserved.
/* Copyright (C) 2009 Trend Micro Inc.
* All right reserved.
@@
-9,7
+10,7
@@
* Foundation
*/
* Foundation
*/
-
+
#ifndef WIN32
#include "shared.h"
#include "rootcheck.h"
#ifndef WIN32
#include "shared.h"
#include "rootcheck.h"
@@
-28,18
+29,18
@@
int read_proc_dir(char *dir_name, char *pid, int position);
int read_proc_file(char *file_name, char *pid, int position)
{
struct stat statbuf;
int read_proc_file(char *file_name, char *pid, int position)
{
struct stat statbuf;
-
+
if(lstat(file_name, &statbuf) < 0)
{
return(-1);
}
if(lstat(file_name, &statbuf) < 0)
{
return(-1);
}
-
+
/* If directory, read the directory */
else if(S_ISDIR(statbuf.st_mode))
{
return(read_proc_dir(file_name, pid, position));
}
/* If directory, read the directory */
else if(S_ISDIR(statbuf.st_mode))
{
return(read_proc_dir(file_name, pid, position));
}
-
+
return(0);
}
return(0);
}
@@
-49,16
+50,16
@@
int read_proc_file(char *file_name, char *pid, int position)
int read_proc_dir(char *dir_name, char *pid, int position)
{
DIR *dp;
int read_proc_dir(char *dir_name, char *pid, int position)
{
DIR *dp;
-
+
struct dirent *entry;
struct dirent *entry;
-
+
if((dir_name == NULL)||(strlen(dir_name) > PATH_MAX))
{
merror("%s: Invalid directory given",ARGV0);
return(-1);
}
if((dir_name == NULL)||(strlen(dir_name) > PATH_MAX))
{
merror("%s: Invalid directory given",ARGV0);
return(-1);
}
-
+
/* Opening the directory given */
dp = opendir(dir_name);
if(!dp)
/* Opening the directory given */
dp = opendir(dir_name);
if(!dp)
@@
-72,7
+73,7
@@
int read_proc_dir(char *dir_name, char *pid, int position)
/* Just ignore . and .. */
if((strcmp(entry->d_name,".") == 0) ||
/* Just ignore . and .. */
if((strcmp(entry->d_name,".") == 0) ||
- (strcmp(entry->d_name,"..") == 0))
+ (strcmp(entry->d_name,"..") == 0))
continue;
if(position == PROC)
continue;
if(position == PROC)
@@
-90,8
+91,8
@@
int read_proc_dir(char *dir_name, char *pid, int position)
if(*tmp_str != '\0')
continue;
if(*tmp_str != '\0')
continue;
-
-
+
+
snprintf(f_name, PATH_MAX +1, "%s/%s",dir_name, entry->d_name);
read_proc_file(f_name, pid, position+1);
snprintf(f_name, PATH_MAX +1, "%s/%s",dir_name, entry->d_name);
read_proc_file(f_name, pid, position+1);
@@
-122,7
+123,7
@@
int read_proc_dir(char *dir_name, char *pid, int position)
}
closedir(dp);
}
closedir(dp);
-
+
return(0);
}
return(0);
}
@@
-136,17
+137,17
@@
int check_rc_readproc(int pid)
char char_pid[32];
proc_pid_found = 0;
char char_pid[32];
proc_pid_found = 0;
-
- /* NL threads */
+
+ /* NL threads */
snprintf(char_pid, 31, "/proc/.%d", pid);
if(is_file(char_pid))
return(1);
snprintf(char_pid, 31, "/proc/.%d", pid);
if(is_file(char_pid))
return(1);
-
-
+
+
snprintf(char_pid, 31, "%d", pid);
snprintf(char_pid, 31, "%d", pid);
-
+
read_proc_dir("/proc", char_pid, PROC);
read_proc_dir("/proc", char_pid, PROC);
-
+
return(proc_pid_found);
}
return(proc_pid_found);
}