Receive and scan requests
This commit is contained in:
29
src/main.cpp
29
src/main.cpp
@@ -12,12 +12,12 @@
|
|||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <signal.h>
|
#include <signal.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include "pipedata.h"
|
|
||||||
#include "locations.h"
|
#include "locations.h"
|
||||||
#include "usermanager.h"
|
#include "usermanager.h"
|
||||||
|
|
||||||
#define MAXNAMESIZE 255
|
#define MAXNAMESIZE 255
|
||||||
#define SCAN_DONE_SIG SIGRTMIN
|
#define SCAN_DONE_SIG SIGRTMIN
|
||||||
|
#define SCAN_CMD_USR "docker exec -ti --user www-data nextcloud /var/www/html/occ files:scan --path="
|
||||||
|
|
||||||
void initRunningFlag(int shmid)
|
void initRunningFlag(int shmid)
|
||||||
{
|
{
|
||||||
@@ -72,9 +72,8 @@ int main()
|
|||||||
std::string line(buffer.data());
|
std::string line(buffer.data());
|
||||||
|
|
||||||
if (line.find('|') == std::string::npos)
|
if (line.find('|') == std::string::npos)
|
||||||
{
|
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
|
|
||||||
std::vector<std::string> x = splitLogFile(line, '|');
|
std::vector<std::string> x = splitLogFile(line, '|');
|
||||||
std::string user(x.at(USER_LOG_LOCATION));
|
std::string user(x.at(USER_LOG_LOCATION));
|
||||||
@@ -83,9 +82,11 @@ int main()
|
|||||||
|
|
||||||
std::vector<std::string> users = manager.getFlaggedUsers();
|
std::vector<std::string> users = manager.getFlaggedUsers();
|
||||||
|
|
||||||
for (auto it = users.begin(); it != users.end(); ++it)
|
for (std::vector<std::string>::iterator it = users.begin(); it != users.end(); ++it)
|
||||||
{
|
{
|
||||||
write(p1[1], it->data(), it->size());
|
int size = it->size();
|
||||||
|
write(p1[1], &size, sizeof(int));
|
||||||
|
write(p1[1], it->data(), size * sizeof(char));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -96,10 +97,24 @@ int main()
|
|||||||
{
|
{
|
||||||
close(p1[1]); // write
|
close(p1[1]); // write
|
||||||
|
|
||||||
std::array<char, MAXNAMESIZE> received;
|
int size;
|
||||||
|
char *buffer = nullptr;
|
||||||
|
|
||||||
while (read(p1[0], received.data(), sizeof(char) * MAXNAMESIZE))
|
while (read(p1[0], &size, sizeof(int)))
|
||||||
{
|
{
|
||||||
|
if (buffer == nullptr)
|
||||||
|
buffer = new char[size];
|
||||||
|
|
||||||
|
read(p1[0], buffer, size * sizeof(char));
|
||||||
|
std::string name(buffer);
|
||||||
|
|
||||||
|
system((std::string(SCAN_CMD_USR) + name).data());
|
||||||
|
|
||||||
|
if (buffer != nullptr)
|
||||||
|
{
|
||||||
|
delete[] buffer;
|
||||||
|
buffer = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +0,0 @@
|
|||||||
#ifndef _PIPDATA_H
|
|
||||||
#define _PIPDATA_H
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
struct pipestruct
|
|
||||||
{
|
|
||||||
std::string user;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // _PIPDATA_H
|
|
||||||
Reference in New Issue
Block a user