install(TARGETS ${PROJECT_NAME} DESTINATION ${TESTS_DIR})
install(FILES agent.manifest DESTINATION ${MANIFESTDIR})
+install(FILES run.sh DESTINATION ${TESTS_DIR})
message(STATUS "Configuring: " ${ProjectId})
message(STATUS "CMAKE_CXX_FLAGS: " ${CMAKE_CXX_FLAGS})
%files agent
%manifest %{_manifestdir}/agent.manifest
%attr(0755,root,root) %{_tests_dir}/agent
+%attr(0755,root,root) %{_tests_dir}/run.sh
+
+
--- /dev/null
+#!/bin/sh
+
+# run agent 1
+rm -f .fifo1
+mkfifo .fifo1
+tail -f .fifo1 | ./agent &
+
+# run agent 2
+rm -f .fifo2
+mkfifo .fifo2
+tail -f .fifo2 | ./agent &
+
+# run agent 3
+rm -f .fifo3
+mkfifo .fifo3
+tail -f .fifo3 | ./agent &
+
+sleep 0.1
+echo -e "agent1\n" > .fifo1
+sleep 0.1
+echo -e "agent2\n" > .fifo2
+sleep 0.1
+echo -e "agent3\n" > .fifo3
+sleep 0.1
+
+# agent 1
+# usb disable
+echo -e "1\n" > .fifo1
+echo -e "2\n" > .fifo1
+echo -e "q\n" > .fifo1
+sleep 0.1
+
+# agent 2
+# screen capture disable
+echo -e "2\n" > .fifo2
+echo -e "2\n" > .fifo2
+echo -e "q\n" > .fifo2
+sleep 0.1
+
+# agent 3
+# bluetooth disable
+echo -e "3\n" > .fifo3
+echo -e "2\n" > .fifo3
+echo -e "0\n" > .fifo3
+sleep 0.1
+# Iptables enable
+echo -e "4\n" > .fifo3
+echo -e "1\n" > .fifo3
+sleep 0.1
+# Iptables add to block list
+echo -e "3\n" > .fifo3
+echo -e "192.168.131.1\n" > .fifo3
+echo -e "2\n" > .fifo3
+echo -e "1234\n" > .fifo3
+echo -e "q\n" > .fifo3
+
+
void applyPolicy(const string& agend_id, const TvPolicy& policy)
{
- static AgentPolicyAdapter adapter;
-
try
{
+ static AgentPolicyAdapter adapter;
string policy_json = policy.makePolicy();
int result = adapter.enforcePolicy(agend_id, policy_json);
}
}
-void read_line(istream& is, string& out)
-{
- char c;
- out.clear();
- is.get(c);
- if (c != 'r' && c != '\n') out.push_back(c);
-
- for (;;)
- {
- is.get(c);
- if (c == '\r' || c == '\n') break;
- out.push_back(c);
- }
-}
-
vector<string> split(const string& str, const char delim)
{
vector<string> v;
cout << " Enter ports (one value, coma separated list, or range as start-end)" << endl;
cout << " Examples:" << endl << " 1234" << endl << " 80,8080,8000" << endl << " 22-1000" << endl;
- read_line(cin, ports);
+ cin >> ports;
auto pos = ports.find('-');