Commit 1079cc2f authored by Ophélie Gagnard's avatar Ophélie Gagnard

Same WIP.

main.pyx: Replace fprintf(file, var) with fputs(var, file).
Makefile: Copy main.pyx and Cython+ directories if copying main.cpp fails.
installation/metadata-collect-agent/Makefile: Add the right CPPFLAGS.
Note: Maybe it should be CXXFLAGS?
parent 77542b18
......@@ -17,7 +17,7 @@ bin/metadata-collect-agent:
mkdir -p build/ ;\
cp -r installation/metadata-collect-agent/ build/ ;\
mkdir -p build/metadata-collect-agent/logs ;\
cp src/main.cpp build/metadata-collect-agent/ || cp src/main.pyx build/metadata-collect-agent/
cp src/main.cpp build/metadata-collect-agent/ || (cp -r src/main.pyx build/metadata-collect-agent/ && cp -r src/runtime/ build/metadata-collect-agent && cp -r src/stdlib/ build/metadata-collect-agent)
cd build/metadata-collect-agent ;\
make
install -m 744 build/metadata-collect-agent/metadata-collect-agent bin/
......
......@@ -37,7 +37,8 @@ RUNPATHS = $(RUNPATH_FMTLIB) $(RUNPATH_OPENSSL)
#EXE = main
#CXX = g++
#CPPFLAGS = -O2 -g -Wno-unused-result -Wsign-compare -pthread $(INCLUDE_DIRS) $(LDLIBS) $(LIBRARY_DIRS) $(RUNPATHS)
CPPFLAGS = -pthread -Wall -Wextra -Werror
CPPFLAGS = -pthread -Wformat -Werror=format-security
#-Wall -Wextra -Werror -Wno-unused-parameter
#LDFLAGS += -Wl,--unresolved-symbols=ignore-all
LDFLAGS = $(LIBRARY_DIRS) $(RUNPATHS)
LDLIBS = -lcrypto -lfmt
......@@ -45,7 +46,7 @@ EXT_SUFFIX := $(shell python3 -c "import sysconfig; print(sysconfig.get_config_v
EXT = $(EXE)$(EXT_SUFFIX)
# Build without Python runtime
all: metadata-collect-agent dev
all: dev metadata-collect-agent
dev:
echo dev:
......
......@@ -6547,32 +6547,32 @@ static int __pyx_f_4main_start(char const *__pyx_v_path_to_scan, char const *__p
* dev_whitelist.append(p_dev)
*
* realpath(path_to_scan, resolved_scan_path) # <<<<<<<<<<<<<<
* fprintf(stderr, resolved_scan_path) # DEBUG
* fprintf(stderr, "\n") # DEBUG
* fputs(resolved_scan_path, stderr) # DEBUG
* fputs("\n", stderr) # DEBUG
*/
(void)(realpath(__pyx_v_path_to_scan, __pyx_v_resolved_scan_path));
/* "main.pyx":319
*
* realpath(path_to_scan, resolved_scan_path)
* fprintf(stderr, resolved_scan_path) # DEBUG # <<<<<<<<<<<<<<
* fprintf(stderr, "\n") # DEBUG
* fputs(resolved_scan_path, stderr) # DEBUG # <<<<<<<<<<<<<<
* fputs("\n", stderr) # DEBUG
* fflush(stderr) # DEBUG
*/
(void)(fprintf(stderr, __pyx_v_resolved_scan_path));
(void)(fputs(__pyx_v_resolved_scan_path, stderr));
/* "main.pyx":320
* realpath(path_to_scan, resolved_scan_path)
* fprintf(stderr, resolved_scan_path) # DEBUG
* fprintf(stderr, "\n") # DEBUG # <<<<<<<<<<<<<<
* fputs(resolved_scan_path, stderr) # DEBUG
* fputs("\n", stderr) # DEBUG # <<<<<<<<<<<<<<
* fflush(stderr) # DEBUG
* node = make_node(resolved_scan_path, resolved_scan_path)
*/
(void)(fprintf(stderr, ((char const *)"\n")));
(void)(fputs(((char const *)"\n"), stderr));
/* "main.pyx":321
* fprintf(stderr, resolved_scan_path) # DEBUG
* fprintf(stderr, "\n") # DEBUG
* fputs(resolved_scan_path, stderr) # DEBUG
* fputs("\n", stderr) # DEBUG
* fflush(stderr) # DEBUG # <<<<<<<<<<<<<<
* node = make_node(resolved_scan_path, resolved_scan_path)
* if node is NULL:
......@@ -6580,7 +6580,7 @@ static int __pyx_f_4main_start(char const *__pyx_v_path_to_scan, char const *__p
(void)(fflush(stderr));
/* "main.pyx":322
* fprintf(stderr, "\n") # DEBUG
* fputs("\n", stderr) # DEBUG
* fflush(stderr) # DEBUG
* node = make_node(resolved_scan_path, resolved_scan_path) # <<<<<<<<<<<<<<
* if node is NULL:
......@@ -6717,32 +6717,32 @@ static int __pyx_f_4main_start(char const *__pyx_v_path_to_scan, char const *__p
*
* #""" # DEBUG
* realpath(log_path, resolved_log_path) # <<<<<<<<<<<<<<
* fprintf(stderr, resolved_log_path) # DEBUG
* fprintf(stderr, "\n") # DEBUG
* fputs(resolved_log_path, stderr) # DEBUG
* fputs("\n", stderr) # DEBUG
*/
(void)(realpath(__pyx_v_log_path, __pyx_v_resolved_log_path));
/* "main.pyx":333
* #""" # DEBUG
* realpath(log_path, resolved_log_path)
* fprintf(stderr, resolved_log_path) # DEBUG # <<<<<<<<<<<<<<
* fprintf(stderr, "\n") # DEBUG
* fputs(resolved_log_path, stderr) # DEBUG # <<<<<<<<<<<<<<
* fputs("\n", stderr) # DEBUG
* fflush(stderr) # DEBUG
*/
(void)(fprintf(stderr, __pyx_v_resolved_log_path));
(void)(fputs(__pyx_v_resolved_log_path, stderr));
/* "main.pyx":334
* realpath(log_path, resolved_log_path)
* fprintf(stderr, resolved_log_path) # DEBUG
* fprintf(stderr, "\n") # DEBUG # <<<<<<<<<<<<<<
* fputs(resolved_log_path, stderr) # DEBUG
* fputs("\n", stderr) # DEBUG # <<<<<<<<<<<<<<
* fflush(stderr) # DEBUG
* result = fopen(resolved_log_path, 'w')
*/
(void)(fprintf(stderr, ((char const *)"\n")));
(void)(fputs(((char const *)"\n"), stderr));
/* "main.pyx":335
* fprintf(stderr, resolved_log_path) # DEBUG
* fprintf(stderr, "\n") # DEBUG
* fputs(resolved_log_path, stderr) # DEBUG
* fputs("\n", stderr) # DEBUG
* fflush(stderr) # DEBUG # <<<<<<<<<<<<<<
* result = fopen(resolved_log_path, 'w')
* if result is NULL:
......@@ -6750,7 +6750,7 @@ static int __pyx_f_4main_start(char const *__pyx_v_path_to_scan, char const *__p
(void)(fflush(stderr));
/* "main.pyx":336
* fprintf(stderr, "\n") # DEBUG
* fputs("\n", stderr) # DEBUG
* fflush(stderr) # DEBUG
* result = fopen(resolved_log_path, 'w') # <<<<<<<<<<<<<<
* if result is NULL:
......@@ -7127,7 +7127,7 @@ int main(int __pyx_v_argc, char **__pyx_v_argv) {
* fb_conf_path = <char*>argv[4]
* if argc >=6: # <<<<<<<<<<<<<<
* log_path = <char*>argv[5]
* return start(<char*>path_to_scan, <char*>fb_exec_path, <char*>fb_lib_path, <char*>fb_conf_path, <char*>log_path)
* fputs(path_to_scan, stderr)
*/
__pyx_t_1 = ((__pyx_v_argc >= 6) != 0);
if (__pyx_t_1) {
......@@ -7136,8 +7136,8 @@ int main(int __pyx_v_argc, char **__pyx_v_argv) {
* fb_conf_path = <char*>argv[4]
* if argc >=6:
* log_path = <char*>argv[5] # <<<<<<<<<<<<<<
* fputs(path_to_scan, stderr)
* return start(<char*>path_to_scan, <char*>fb_exec_path, <char*>fb_lib_path, <char*>fb_conf_path, <char*>log_path)
*
*/
__pyx_v_log_path = ((char *)(__pyx_v_argv[5]));
......@@ -7146,13 +7146,22 @@ int main(int __pyx_v_argc, char **__pyx_v_argv) {
* fb_conf_path = <char*>argv[4]
* if argc >=6: # <<<<<<<<<<<<<<
* log_path = <char*>argv[5]
* return start(<char*>path_to_scan, <char*>fb_exec_path, <char*>fb_lib_path, <char*>fb_conf_path, <char*>log_path)
* fputs(path_to_scan, stderr)
*/
}
/* "main.pyx":381
* if argc >=6:
* log_path = <char*>argv[5]
* fputs(path_to_scan, stderr) # <<<<<<<<<<<<<<
* return start(<char*>path_to_scan, <char*>fb_exec_path, <char*>fb_lib_path, <char*>fb_conf_path, <char*>log_path)
*
*/
(void)(fputs(__pyx_v_path_to_scan, stderr));
/* "main.pyx":382
* log_path = <char*>argv[5]
* fputs(path_to_scan, stderr)
* return start(<char*>path_to_scan, <char*>fb_exec_path, <char*>fb_lib_path, <char*>fb_conf_path, <char*>log_path) # <<<<<<<<<<<<<<
*
* #def python_main():
......
......@@ -5,7 +5,7 @@
from libcythonplus.list cimport cyplist
from libc.stdio cimport fprintf, fopen, fclose, fread, fwrite, FILE, stdout, stderr, printf, ferror, fscanf, fflush
from libc.stdio cimport fprintf, fopen, fclose, fread, fwrite, FILE, stdout, stderr, printf, ferror, fscanf, fflush, fputs
from runtime.runtime cimport SequentialMailBox, BatchMailBox, NullResult, Scheduler
from runtime.unistd cimport pid_t, execlp, fork, sleep
......@@ -316,8 +316,8 @@ cdef int start(const char *path_to_scan, const char *fb_exec_path, const char *f
dev_whitelist.append(p_dev)
realpath(path_to_scan, resolved_scan_path)
fprintf(stderr, resolved_scan_path) # DEBUG
fprintf(stderr, "\n") # DEBUG
fputs(resolved_scan_path, stderr) # DEBUG
fputs("\n", stderr) # DEBUG
fflush(stderr) # DEBUG
node = make_node(resolved_scan_path, resolved_scan_path)
if node is NULL:
......@@ -330,8 +330,8 @@ cdef int start(const char *path_to_scan, const char *fb_exec_path, const char *f
#""" # DEBUG
realpath(log_path, resolved_log_path)
fprintf(stderr, resolved_log_path) # DEBUG
fprintf(stderr, "\n") # DEBUG
fputs(resolved_log_path, stderr) # DEBUG
fputs("\n", stderr) # DEBUG
fflush(stderr) # DEBUG
result = fopen(resolved_log_path, 'w')
if result is NULL:
......@@ -378,6 +378,7 @@ cdef public int main(int argc, char* argv[]) nogil:
fb_conf_path = <char*>argv[4]
if argc >=6:
log_path = <char*>argv[5]
fputs(path_to_scan, stderr)
return start(<char*>path_to_scan, <char*>fb_exec_path, <char*>fb_lib_path, <char*>fb_conf_path, <char*>log_path)
#def python_main():
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment