read and commit It_process_plimits_008.cpp

pull/2/head
Mr.NaCl 7 months ago
parent e89676cded
commit c42d4c8f9c

@ -38,13 +38,14 @@
#include <cstring> #include <cstring>
#include "It_process_plimits.h" #include "It_process_plimits.h"
//write function to get process file mode
static std::string GetFileMode(const char* filePath) static std::string GetFileMode(const char* filePath)
{ {
const int MODE_COUNT = 11; const int MODE_COUNT = 11;
char fileProperty[MODE_COUNT] = "----------"; char fileProperty[MODE_COUNT] = "----------";
char fileMode[MODE_COUNT] = "-rwxrwxrwx"; char fileMode[MODE_COUNT] = "-rwxrwxrwx";
struct stat buf; struct stat buf;
stat(filePath, &buf); stat(filePath, &buf);//get state of the file
unsigned int off = 256; unsigned int off = 256;
const int LOOP_VARY = 10; const int LOOP_VARY = 10;
for (int i = 1; i < LOOP_VARY; i++) { for (int i = 1; i < LOOP_VARY; i++) {
@ -55,6 +56,7 @@ static std::string GetFileMode(const char* filePath)
return fileProperty; return fileProperty;
} }
//check the Property
static int IsFilePropertyR1(const char* filePath) static int IsFilePropertyR1(const char* filePath)
{ {
std::string fileOrg = "-r--r--r--"; std::string fileOrg = "-r--r--r--";
@ -64,6 +66,7 @@ static int IsFilePropertyR1(const char* filePath)
void ItProcessPlimits008(void) void ItProcessPlimits008(void)
{ {
//define process function ID
std::string filePath = "/proc/plimits/"; std::string filePath = "/proc/plimits/";
std::vector<std::string> fileName; std::vector<std::string> fileName;
fileName.push_back("plimits.procs"); fileName.push_back("plimits.procs");
@ -86,3 +89,12 @@ void ItProcessPlimits008(void)
return; return;
} }
/*It is used primarily to verify access to specific files in
the /proc/plimit/directory, ensuring that these files are read-only
*/

Loading…
Cancel
Save