Commit febc2a2d authored by Ophélie Gagnard's avatar Ophélie Gagnard

src/main.*: Add the possibility to give the paths of the fluentbit files...

src/main.*: Add the possibility to give the paths of the fluentbit files (exec, lib, conf...) and the log file as an argument of the program.
parent a6ec4e5f
...@@ -3332,7 +3332,7 @@ static CYTHON_INLINE ActhonResultInterface *__pyx_f_7runtime_7runtime_NullResult ...@@ -3332,7 +3332,7 @@ static CYTHON_INLINE ActhonResultInterface *__pyx_f_7runtime_7runtime_NullResult
/* Module declarations from "main" */ /* Module declarations from "main" */
static __pyx_t_7runtime_7runtime_Scheduler *__pyx_v_4main_scheduler; static __pyx_t_7runtime_7runtime_Scheduler *__pyx_v_4main_scheduler;
static __pyx_t_4main_Node *__pyx_f_4main_make_node(std::string, std::string); /*proto*/ static __pyx_t_4main_Node *__pyx_f_4main_make_node(std::string, std::string); /*proto*/
static int __pyx_f_4main_start(char const *); /*proto*/ static int __pyx_f_4main_start(char const *, char const *, char const *, char const *, char const *); /*proto*/
__PYX_EXTERN_C int main(int, char **); /*proto*/ __PYX_EXTERN_C int main(int, char **); /*proto*/
static PyObject *__pyx_f_4main___pyx_unpickle_Node_cyp_cclass_wrapper__set_state(struct CyPyObject *, PyObject *); /*proto*/ static PyObject *__pyx_f_4main___pyx_unpickle_Node_cyp_cclass_wrapper__set_state(struct CyPyObject *, PyObject *); /*proto*/
static PyObject *__pyx_f_4main___pyx_unpickle_DirNode_cyp_cclass_wrapper__set_state(struct CyPyObject *, PyObject *); /*proto*/ static PyObject *__pyx_f_4main___pyx_unpickle_DirNode_cyp_cclass_wrapper__set_state(struct CyPyObject *, PyObject *); /*proto*/
...@@ -6141,19 +6141,16 @@ void __pyx_t_4main_SymlinkNode::write_node(FILE *__pyx_v_stream) { ...@@ -6141,19 +6141,16 @@ void __pyx_t_4main_SymlinkNode::write_node(FILE *__pyx_v_stream) {
/* "main.pyx":269 /* "main.pyx":269
* *
* *
* cdef int start(const char *path) nogil: # <<<<<<<<<<<<<< * cdef int start(const char *path_to_scan, const char *fb_exec_path, const char *fb_lib_path, const char *fb_conf_path, const char *log_path) nogil: # <<<<<<<<<<<<<<
* *
* printf("TEST TEST TEST TEST TEST\n\n") # DEBUG * printf("TEST TEST TEST TEST TEST\n\n") # DEBUG
*/ */
static int __pyx_f_4main_start(char const *__pyx_v_path) { static int __pyx_f_4main_start(char const *__pyx_v_path_to_scan, char const *__pyx_v_fb_exec_path, char const *__pyx_v_fb_lib_path, char const *__pyx_v_fb_conf_path, char const *__pyx_v_log_path) {
char __pyx_v_resolved_path[0x1000]; char __pyx_v_resolved_scan_path[0x1000];
char __pyx_v_resolved_log_path[0x1000];
CYTHON_UNUSED pid_t __pyx_v_wait_error; CYTHON_UNUSED pid_t __pyx_v_wait_error;
char *__pyx_v_program_name; char *__pyx_v_program_name;
char *__pyx_v_arg1;
char *__pyx_v_arg2;
char *__pyx_v_arg3;
char *__pyx_v_arg4;
pid_t __pyx_v_child_pid; pid_t __pyx_v_child_pid;
int __pyx_v_err; int __pyx_v_err;
__pyx_t_13libcythonplus_4list_cyplist<std::string> *__pyx_v_ignore_paths = NULL; __pyx_t_13libcythonplus_4list_cyplist<std::string> *__pyx_v_ignore_paths = NULL;
...@@ -6189,7 +6186,7 @@ static int __pyx_f_4main_start(char const *__pyx_v_path) { ...@@ -6189,7 +6186,7 @@ static int __pyx_f_4main_start(char const *__pyx_v_path) {
#endif #endif
/* "main.pyx":271 /* "main.pyx":271
* cdef int start(const char *path) nogil: * cdef int start(const char *path_to_scan, const char *fb_exec_path, const char *fb_lib_path, const char *fb_conf_path, const char *log_path) nogil:
* *
* printf("TEST TEST TEST TEST TEST\n\n") # DEBUG # <<<<<<<<<<<<<< * printf("TEST TEST TEST TEST TEST\n\n") # DEBUG # <<<<<<<<<<<<<<
* *
...@@ -6197,71 +6194,35 @@ static int __pyx_f_4main_start(char const *__pyx_v_path) { ...@@ -6197,71 +6194,35 @@ static int __pyx_f_4main_start(char const *__pyx_v_path) {
*/ */
(void)(printf(((char const *)"TEST TEST TEST TEST TEST\n\n"))); (void)(printf(((char const *)"TEST TEST TEST TEST TEST\n\n")));
/* "main.pyx":275 /* "main.pyx":276
* # TODO replace 4096 by PATH_MAX (yet it will not be perfect) * cdef char resolved_scan_path[4096]
* cdef char resolved_path[4096] * cdef char resolved_log_path[4096]
* cdef pid_t wait_error = -1 # DEBUG # <<<<<<<<<<<<<< * cdef pid_t wait_error = -1 # DEBUG # <<<<<<<<<<<<<<
* cdef char* program_name = "fluentbit" * cdef char* program_name = <char*>"fluent-bit"
* cdef char* arg1 = "-e" * cdef pid_t child_pid = -1 # DEBUG
*/ */
__pyx_v_wait_error = -1; __pyx_v_wait_error = -1;
/* "main.pyx":276
* cdef char resolved_path[4096]
* cdef pid_t wait_error = -1 # DEBUG
* cdef char* program_name = "fluentbit" # <<<<<<<<<<<<<<
* cdef char* arg1 = "-e"
* cdef char* arg2 = "/etc/fluentbit_wendelin.so"
*/
__pyx_v_program_name = ((char *)"fluentbit");
/* "main.pyx":277 /* "main.pyx":277
* cdef char resolved_log_path[4096]
* cdef pid_t wait_error = -1 # DEBUG * cdef pid_t wait_error = -1 # DEBUG
* cdef char* program_name = "fluentbit" * cdef char* program_name = <char*>"fluent-bit" # <<<<<<<<<<<<<<
* cdef char* arg1 = "-e" # <<<<<<<<<<<<<<
* cdef char* arg2 = "/etc/fluentbit_wendelin.so"
* cdef char* arg3 = "-c"
*/
__pyx_v_arg1 = ((char *)"-e");
/* "main.pyx":278
* cdef char* program_name = "fluentbit"
* cdef char* arg1 = "-e"
* cdef char* arg2 = "/etc/fluentbit_wendelin.so" # <<<<<<<<<<<<<<
* cdef char* arg3 = "-c"
* cdef char* arg4 = "/etc/flb.conf"
*/
__pyx_v_arg2 = ((char *)"/etc/fluentbit_wendelin.so");
/* "main.pyx":279
* cdef char* arg1 = "-e"
* cdef char* arg2 = "/etc/fluentbit_wendelin.so"
* cdef char* arg3 = "-c" # <<<<<<<<<<<<<<
* cdef char* arg4 = "/etc/flb.conf"
* cdef pid_t child_pid = -1 # DEBUG
*/
__pyx_v_arg3 = ((char *)"-c");
/* "main.pyx":280
* cdef char* arg2 = "/etc/fluentbit_wendelin.so"
* cdef char* arg3 = "-c"
* cdef char* arg4 = "/etc/flb.conf" # <<<<<<<<<<<<<<
* cdef pid_t child_pid = -1 # DEBUG * cdef pid_t child_pid = -1 # DEBUG
* child_pid = fork() # DEBUG * child_pid = fork() # DEBUG
*/ */
__pyx_v_arg4 = ((char *)"/etc/flb.conf"); __pyx_v_program_name = ((char *)((char *)"fluent-bit"));
/* "main.pyx":281 /* "main.pyx":278
* cdef char* arg3 = "-c" * cdef pid_t wait_error = -1 # DEBUG
* cdef char* arg4 = "/etc/flb.conf" * cdef char* program_name = <char*>"fluent-bit"
* cdef pid_t child_pid = -1 # DEBUG # <<<<<<<<<<<<<< * cdef pid_t child_pid = -1 # DEBUG # <<<<<<<<<<<<<<
* child_pid = fork() # DEBUG * child_pid = fork() # DEBUG
* cdef int err * cdef int err
*/ */
__pyx_v_child_pid = -1; __pyx_v_child_pid = -1;
/* "main.pyx":282 /* "main.pyx":279
* cdef char* arg4 = "/etc/flb.conf" * cdef char* program_name = <char*>"fluent-bit"
* cdef pid_t child_pid = -1 # DEBUG * cdef pid_t child_pid = -1 # DEBUG
* child_pid = fork() # DEBUG # <<<<<<<<<<<<<< * child_pid = fork() # DEBUG # <<<<<<<<<<<<<<
* cdef int err * cdef int err
...@@ -6269,45 +6230,45 @@ static int __pyx_f_4main_start(char const *__pyx_v_path) { ...@@ -6269,45 +6230,45 @@ static int __pyx_f_4main_start(char const *__pyx_v_path) {
*/ */
__pyx_v_child_pid = fork(); __pyx_v_child_pid = fork();
/* "main.pyx":286 /* "main.pyx":283
* #cdef char ip_address[100] * #cdef char ip_address[100]
* #cdef FILE *address_path = fopen("/sys/class/net/ens3/address", "r") * #cdef FILE *address_path = fopen("/sys/class/net/ens3/address", "r")
* if child_pid == 0: # CHILD # <<<<<<<<<<<<<< * if child_pid == 0: # CHILD # <<<<<<<<<<<<<<
* err = execlp("/sbin/fluent-bit", program_name, arg1, arg2, arg3, arg4, 0) * err = execlp(fb_exec_path, program_name, <char*>"-e", fb_lib_path, <char*>"-c", fb_conf_path, 0)
* fprintf(stderr, "ERROR with execlp() in CHILD: %d\n", err) * fprintf(stderr, "ERROR with execlp() in CHILD: %d\n", err)
*/ */
__pyx_t_1 = ((__pyx_v_child_pid == 0) != 0); __pyx_t_1 = ((__pyx_v_child_pid == 0) != 0);
if (__pyx_t_1) { if (__pyx_t_1) {
/* "main.pyx":287 /* "main.pyx":284
* #cdef FILE *address_path = fopen("/sys/class/net/ens3/address", "r") * #cdef FILE *address_path = fopen("/sys/class/net/ens3/address", "r")
* if child_pid == 0: # CHILD * if child_pid == 0: # CHILD
* err = execlp("/sbin/fluent-bit", program_name, arg1, arg2, arg3, arg4, 0) # <<<<<<<<<<<<<< * err = execlp(fb_exec_path, program_name, <char*>"-e", fb_lib_path, <char*>"-c", fb_conf_path, 0) # <<<<<<<<<<<<<<
* fprintf(stderr, "ERROR with execlp() in CHILD: %d\n", err) * fprintf(stderr, "ERROR with execlp() in CHILD: %d\n", err)
* else: # PARENT * else: # PARENT
*/ */
__pyx_v_err = execlp(((char const *)"/sbin/fluent-bit"), __pyx_v_program_name, __pyx_v_arg1, __pyx_v_arg2, __pyx_v_arg3, __pyx_v_arg4, 0); __pyx_v_err = execlp(__pyx_v_fb_exec_path, __pyx_v_program_name, ((char *)((char *)"-e")), __pyx_v_fb_lib_path, ((char *)((char *)"-c")), __pyx_v_fb_conf_path, 0);
/* "main.pyx":288 /* "main.pyx":285
* if child_pid == 0: # CHILD * if child_pid == 0: # CHILD
* err = execlp("/sbin/fluent-bit", program_name, arg1, arg2, arg3, arg4, 0) * err = execlp(fb_exec_path, program_name, <char*>"-e", fb_lib_path, <char*>"-c", fb_conf_path, 0)
* fprintf(stderr, "ERROR with execlp() in CHILD: %d\n", err) # <<<<<<<<<<<<<< * fprintf(stderr, "ERROR with execlp() in CHILD: %d\n", err) # <<<<<<<<<<<<<<
* else: # PARENT * else: # PARENT
* printf("WELCOME TO PARENT\n\n") # DEBUG * printf("WELCOME TO PARENT\n\n") # DEBUG
*/ */
(void)(fprintf(stderr, ((char const *)"ERROR with execlp() in CHILD: %d\n"), __pyx_v_err)); (void)(fprintf(stderr, ((char const *)"ERROR with execlp() in CHILD: %d\n"), __pyx_v_err));
/* "main.pyx":286 /* "main.pyx":283
* #cdef char ip_address[100] * #cdef char ip_address[100]
* #cdef FILE *address_path = fopen("/sys/class/net/ens3/address", "r") * #cdef FILE *address_path = fopen("/sys/class/net/ens3/address", "r")
* if child_pid == 0: # CHILD # <<<<<<<<<<<<<< * if child_pid == 0: # CHILD # <<<<<<<<<<<<<<
* err = execlp("/sbin/fluent-bit", program_name, arg1, arg2, arg3, arg4, 0) * err = execlp(fb_exec_path, program_name, <char*>"-e", fb_lib_path, <char*>"-c", fb_conf_path, 0)
* fprintf(stderr, "ERROR with execlp() in CHILD: %d\n", err) * fprintf(stderr, "ERROR with execlp() in CHILD: %d\n", err)
*/ */
goto __pyx_L3; goto __pyx_L3;
} }
/* "main.pyx":290 /* "main.pyx":287
* fprintf(stderr, "ERROR with execlp() in CHILD: %d\n", err) * fprintf(stderr, "ERROR with execlp() in CHILD: %d\n", err)
* else: # PARENT * else: # PARENT
* printf("WELCOME TO PARENT\n\n") # DEBUG # <<<<<<<<<<<<<< * printf("WELCOME TO PARENT\n\n") # DEBUG # <<<<<<<<<<<<<<
...@@ -6317,7 +6278,7 @@ static int __pyx_f_4main_start(char const *__pyx_v_path) { ...@@ -6317,7 +6278,7 @@ static int __pyx_f_4main_start(char const *__pyx_v_path) {
/*else*/ { /*else*/ {
(void)(printf(((char const *)"WELCOME TO PARENT\n\n"))); (void)(printf(((char const *)"WELCOME TO PARENT\n\n")));
/* "main.pyx":292 /* "main.pyx":289
* printf("WELCOME TO PARENT\n\n") # DEBUG * printf("WELCOME TO PARENT\n\n") # DEBUG
* *
* sleep(2) # TODO error handling ; check if a wait can be made to wait for the child to perform execlp() (instead of the sleep) # <<<<<<<<<<<<<< * sleep(2) # TODO error handling ; check if a wait can be made to wait for the child to perform execlp() (instead of the sleep) # <<<<<<<<<<<<<<
...@@ -6326,7 +6287,7 @@ static int __pyx_f_4main_start(char const *__pyx_v_path) { ...@@ -6326,7 +6287,7 @@ static int __pyx_f_4main_start(char const *__pyx_v_path) {
*/ */
(void)(sleep(2)); (void)(sleep(2));
/* "main.pyx":295 /* "main.pyx":292
* *
* global scheduler * global scheduler
* scheduler = Scheduler() # <<<<<<<<<<<<<< * scheduler = Scheduler() # <<<<<<<<<<<<<<
...@@ -6339,7 +6300,7 @@ static int __pyx_f_4main_start(char const *__pyx_v_path) { ...@@ -6339,7 +6300,7 @@ static int __pyx_f_4main_start(char const *__pyx_v_path) {
__pyx_v_4main_scheduler = __pyx_t_2; __pyx_v_4main_scheduler = __pyx_t_2;
__pyx_t_2 = 0; __pyx_t_2 = 0;
/* "main.pyx":297 /* "main.pyx":294
* scheduler = Scheduler() * scheduler = Scheduler()
* *
* ignore_paths = cyplist[string]() # <<<<<<<<<<<<<< * ignore_paths = cyplist[string]() # <<<<<<<<<<<<<<
...@@ -6352,7 +6313,7 @@ static int __pyx_f_4main_start(char const *__pyx_v_path) { ...@@ -6352,7 +6313,7 @@ static int __pyx_f_4main_start(char const *__pyx_v_path) {
__pyx_v_ignore_paths = __pyx_t_3; __pyx_v_ignore_paths = __pyx_t_3;
__pyx_t_3 = 0; __pyx_t_3 = 0;
/* "main.pyx":298 /* "main.pyx":295
* *
* ignore_paths = cyplist[string]() * ignore_paths = cyplist[string]()
* ignore_paths.append(b'/opt/slapgrid') # <<<<<<<<<<<<<< * ignore_paths.append(b'/opt/slapgrid') # <<<<<<<<<<<<<<
...@@ -6360,9 +6321,9 @@ static int __pyx_f_4main_start(char const *__pyx_v_path) { ...@@ -6360,9 +6321,9 @@ static int __pyx_f_4main_start(char const *__pyx_v_path) {
* *
*/ */
Cy_GOTREF(__pyx_v_ignore_paths); Cy_GOTREF(__pyx_v_ignore_paths);
__pyx_t_4 = __pyx_v_ignore_paths->append(__pyx_k_opt_slapgrid); if (unlikely(__pyx_t_4.is_error())) __PYX_ERR(0, 298, __pyx_L1_error) __pyx_t_4 = __pyx_v_ignore_paths->append(__pyx_k_opt_slapgrid); if (unlikely(__pyx_t_4.is_error())) __PYX_ERR(0, 295, __pyx_L1_error)
/* "main.pyx":299 /* "main.pyx":296
* ignore_paths = cyplist[string]() * ignore_paths = cyplist[string]()
* ignore_paths.append(b'/opt/slapgrid') * ignore_paths.append(b'/opt/slapgrid')
* ignore_paths.append(b'/srv/slapgrid') # <<<<<<<<<<<<<< * ignore_paths.append(b'/srv/slapgrid') # <<<<<<<<<<<<<<
...@@ -6370,9 +6331,9 @@ static int __pyx_f_4main_start(char const *__pyx_v_path) { ...@@ -6370,9 +6331,9 @@ static int __pyx_f_4main_start(char const *__pyx_v_path) {
* dev_whitelist_paths = cyplist[string]() * dev_whitelist_paths = cyplist[string]()
*/ */
Cy_GOTREF(__pyx_v_ignore_paths); Cy_GOTREF(__pyx_v_ignore_paths);
__pyx_t_4 = __pyx_v_ignore_paths->append(__pyx_k_srv_slapgrid); if (unlikely(__pyx_t_4.is_error())) __PYX_ERR(0, 299, __pyx_L1_error) __pyx_t_4 = __pyx_v_ignore_paths->append(__pyx_k_srv_slapgrid); if (unlikely(__pyx_t_4.is_error())) __PYX_ERR(0, 296, __pyx_L1_error)
/* "main.pyx":301 /* "main.pyx":298
* ignore_paths.append(b'/srv/slapgrid') * ignore_paths.append(b'/srv/slapgrid')
* *
* dev_whitelist_paths = cyplist[string]() # <<<<<<<<<<<<<< * dev_whitelist_paths = cyplist[string]() # <<<<<<<<<<<<<<
...@@ -6385,7 +6346,7 @@ static int __pyx_f_4main_start(char const *__pyx_v_path) { ...@@ -6385,7 +6346,7 @@ static int __pyx_f_4main_start(char const *__pyx_v_path) {
__pyx_v_dev_whitelist_paths = __pyx_t_3; __pyx_v_dev_whitelist_paths = __pyx_t_3;
__pyx_t_3 = 0; __pyx_t_3 = 0;
/* "main.pyx":302 /* "main.pyx":299
* *
* dev_whitelist_paths = cyplist[string]() * dev_whitelist_paths = cyplist[string]()
* dev_whitelist_paths.append(b'.') # <<<<<<<<<<<<<< * dev_whitelist_paths.append(b'.') # <<<<<<<<<<<<<<
...@@ -6393,9 +6354,9 @@ static int __pyx_f_4main_start(char const *__pyx_v_path) { ...@@ -6393,9 +6354,9 @@ static int __pyx_f_4main_start(char const *__pyx_v_path) {
* dev_whitelist_paths.append(b'/boot/efi') * dev_whitelist_paths.append(b'/boot/efi')
*/ */
Cy_GOTREF(__pyx_v_dev_whitelist_paths); Cy_GOTREF(__pyx_v_dev_whitelist_paths);
__pyx_t_4 = __pyx_v_dev_whitelist_paths->append(__pyx_k_); if (unlikely(__pyx_t_4.is_error())) __PYX_ERR(0, 302, __pyx_L1_error) __pyx_t_4 = __pyx_v_dev_whitelist_paths->append(__pyx_k_); if (unlikely(__pyx_t_4.is_error())) __PYX_ERR(0, 299, __pyx_L1_error)
/* "main.pyx":303 /* "main.pyx":300
* dev_whitelist_paths = cyplist[string]() * dev_whitelist_paths = cyplist[string]()
* dev_whitelist_paths.append(b'.') * dev_whitelist_paths.append(b'.')
* dev_whitelist_paths.append(b'/') # <<<<<<<<<<<<<< * dev_whitelist_paths.append(b'/') # <<<<<<<<<<<<<<
...@@ -6403,9 +6364,9 @@ static int __pyx_f_4main_start(char const *__pyx_v_path) { ...@@ -6403,9 +6364,9 @@ static int __pyx_f_4main_start(char const *__pyx_v_path) {
* dev_whitelist_paths.append(b'/root') * dev_whitelist_paths.append(b'/root')
*/ */
Cy_GOTREF(__pyx_v_dev_whitelist_paths); Cy_GOTREF(__pyx_v_dev_whitelist_paths);
__pyx_t_4 = __pyx_v_dev_whitelist_paths->append(__pyx_k__2); if (unlikely(__pyx_t_4.is_error())) __PYX_ERR(0, 303, __pyx_L1_error) __pyx_t_4 = __pyx_v_dev_whitelist_paths->append(__pyx_k__2); if (unlikely(__pyx_t_4.is_error())) __PYX_ERR(0, 300, __pyx_L1_error)
/* "main.pyx":304 /* "main.pyx":301
* dev_whitelist_paths.append(b'.') * dev_whitelist_paths.append(b'.')
* dev_whitelist_paths.append(b'/') * dev_whitelist_paths.append(b'/')
* dev_whitelist_paths.append(b'/boot/efi') # <<<<<<<<<<<<<< * dev_whitelist_paths.append(b'/boot/efi') # <<<<<<<<<<<<<<
...@@ -6413,40 +6374,40 @@ static int __pyx_f_4main_start(char const *__pyx_v_path) { ...@@ -6413,40 +6374,40 @@ static int __pyx_f_4main_start(char const *__pyx_v_path) {
* dev_whitelist_paths.append(b'/sysroot') * dev_whitelist_paths.append(b'/sysroot')
*/ */
Cy_GOTREF(__pyx_v_dev_whitelist_paths); Cy_GOTREF(__pyx_v_dev_whitelist_paths);
__pyx_t_4 = __pyx_v_dev_whitelist_paths->append(__pyx_k_boot_efi); if (unlikely(__pyx_t_4.is_error())) __PYX_ERR(0, 304, __pyx_L1_error) __pyx_t_4 = __pyx_v_dev_whitelist_paths->append(__pyx_k_boot_efi); if (unlikely(__pyx_t_4.is_error())) __PYX_ERR(0, 301, __pyx_L1_error)
/* "main.pyx":305 /* "main.pyx":302
* dev_whitelist_paths.append(b'/') * dev_whitelist_paths.append(b'/')
* dev_whitelist_paths.append(b'/boot/efi') * dev_whitelist_paths.append(b'/boot/efi')
* dev_whitelist_paths.append(b'/root') # <<<<<<<<<<<<<< * dev_whitelist_paths.append(b'/root') # <<<<<<<<<<<<<<
* dev_whitelist_paths.append(b'/sysroot') * dev_whitelist_paths.append(b'/sysroot')
* dev_whitelist_paths.append(path) * dev_whitelist_paths.append(path_to_scan)
*/ */
Cy_GOTREF(__pyx_v_dev_whitelist_paths); Cy_GOTREF(__pyx_v_dev_whitelist_paths);
__pyx_t_4 = __pyx_v_dev_whitelist_paths->append(__pyx_k_root); if (unlikely(__pyx_t_4.is_error())) __PYX_ERR(0, 305, __pyx_L1_error) __pyx_t_4 = __pyx_v_dev_whitelist_paths->append(__pyx_k_root); if (unlikely(__pyx_t_4.is_error())) __PYX_ERR(0, 302, __pyx_L1_error)
/* "main.pyx":306 /* "main.pyx":303
* dev_whitelist_paths.append(b'/boot/efi') * dev_whitelist_paths.append(b'/boot/efi')
* dev_whitelist_paths.append(b'/root') * dev_whitelist_paths.append(b'/root')
* dev_whitelist_paths.append(b'/sysroot') # <<<<<<<<<<<<<< * dev_whitelist_paths.append(b'/sysroot') # <<<<<<<<<<<<<<
* dev_whitelist_paths.append(path) * dev_whitelist_paths.append(path_to_scan)
* *
*/ */
Cy_GOTREF(__pyx_v_dev_whitelist_paths); Cy_GOTREF(__pyx_v_dev_whitelist_paths);
__pyx_t_4 = __pyx_v_dev_whitelist_paths->append(__pyx_k_sysroot); if (unlikely(__pyx_t_4.is_error())) __PYX_ERR(0, 306, __pyx_L1_error) __pyx_t_4 = __pyx_v_dev_whitelist_paths->append(__pyx_k_sysroot); if (unlikely(__pyx_t_4.is_error())) __PYX_ERR(0, 303, __pyx_L1_error)
/* "main.pyx":307 /* "main.pyx":304
* dev_whitelist_paths.append(b'/root') * dev_whitelist_paths.append(b'/root')
* dev_whitelist_paths.append(b'/sysroot') * dev_whitelist_paths.append(b'/sysroot')
* dev_whitelist_paths.append(path) # <<<<<<<<<<<<<< * dev_whitelist_paths.append(path_to_scan) # <<<<<<<<<<<<<<
* *
* dev_whitelist = cyplist[dev_t]() * dev_whitelist = cyplist[dev_t]()
*/ */
Cy_GOTREF(__pyx_v_dev_whitelist_paths); Cy_GOTREF(__pyx_v_dev_whitelist_paths);
__pyx_t_4 = __pyx_v_dev_whitelist_paths->append(__pyx_v_path); if (unlikely(__pyx_t_4.is_error())) __PYX_ERR(0, 307, __pyx_L1_error) __pyx_t_4 = __pyx_v_dev_whitelist_paths->append(__pyx_v_path_to_scan); if (unlikely(__pyx_t_4.is_error())) __PYX_ERR(0, 304, __pyx_L1_error)
/* "main.pyx":309 /* "main.pyx":306
* dev_whitelist_paths.append(path) * dev_whitelist_paths.append(path_to_scan)
* *
* dev_whitelist = cyplist[dev_t]() # <<<<<<<<<<<<<< * dev_whitelist = cyplist[dev_t]() # <<<<<<<<<<<<<<
* for p in dev_whitelist_paths: * for p in dev_whitelist_paths:
...@@ -6458,7 +6419,7 @@ static int __pyx_f_4main_start(char const *__pyx_v_path) { ...@@ -6458,7 +6419,7 @@ static int __pyx_f_4main_start(char const *__pyx_v_path) {
__pyx_v_dev_whitelist = __pyx_t_5; __pyx_v_dev_whitelist = __pyx_t_5;
__pyx_t_5 = 0; __pyx_t_5 = 0;
/* "main.pyx":310 /* "main.pyx":307
* *
* dev_whitelist = cyplist[dev_t]() * dev_whitelist = cyplist[dev_t]()
* for p in dev_whitelist_paths: # <<<<<<<<<<<<<< * for p in dev_whitelist_paths: # <<<<<<<<<<<<<<
...@@ -6473,7 +6434,7 @@ static int __pyx_f_4main_start(char const *__pyx_v_path) { ...@@ -6473,7 +6434,7 @@ static int __pyx_f_4main_start(char const *__pyx_v_path) {
++__pyx_t_6; ++__pyx_t_6;
__pyx_v_p = __PYX_STD_MOVE_IF_SUPPORTED(__pyx_t_7); __pyx_v_p = __PYX_STD_MOVE_IF_SUPPORTED(__pyx_t_7);
/* "main.pyx":311 /* "main.pyx":308
* dev_whitelist = cyplist[dev_t]() * dev_whitelist = cyplist[dev_t]()
* for p in dev_whitelist_paths: * for p in dev_whitelist_paths:
* p_stat = Stat(p) # <<<<<<<<<<<<<< * p_stat = Stat(p) # <<<<<<<<<<<<<<
...@@ -6486,7 +6447,7 @@ static int __pyx_f_4main_start(char const *__pyx_v_path) { ...@@ -6486,7 +6447,7 @@ static int __pyx_f_4main_start(char const *__pyx_v_path) {
__pyx_v_p_stat = __pyx_t_8; __pyx_v_p_stat = __pyx_t_8;
__pyx_t_8 = 0; __pyx_t_8 = 0;
/* "main.pyx":312 /* "main.pyx":309
* for p in dev_whitelist_paths: * for p in dev_whitelist_paths:
* p_stat = Stat(p) * p_stat = Stat(p)
* if p_stat is not NULL: # <<<<<<<<<<<<<< * if p_stat is not NULL: # <<<<<<<<<<<<<<
...@@ -6497,7 +6458,7 @@ static int __pyx_f_4main_start(char const *__pyx_v_path) { ...@@ -6497,7 +6458,7 @@ static int __pyx_f_4main_start(char const *__pyx_v_path) {
__pyx_t_1 = ((__pyx_v_p_stat != NULL) != 0); __pyx_t_1 = ((__pyx_v_p_stat != NULL) != 0);
if (__pyx_t_1) { if (__pyx_t_1) {
/* "main.pyx":313 /* "main.pyx":310
* p_stat = Stat(p) * p_stat = Stat(p)
* if p_stat is not NULL: * if p_stat is not NULL:
* p_dev = p_stat.st_data.st_dev # <<<<<<<<<<<<<< * p_dev = p_stat.st_data.st_dev # <<<<<<<<<<<<<<
...@@ -6508,17 +6469,17 @@ static int __pyx_f_4main_start(char const *__pyx_v_path) { ...@@ -6508,17 +6469,17 @@ static int __pyx_f_4main_start(char const *__pyx_v_path) {
__pyx_t_9 = __pyx_v_p_stat->st_data.st_dev; __pyx_t_9 = __pyx_v_p_stat->st_data.st_dev;
__pyx_v_p_dev = __pyx_t_9; __pyx_v_p_dev = __pyx_t_9;
/* "main.pyx":314 /* "main.pyx":311
* if p_stat is not NULL: * if p_stat is not NULL:
* p_dev = p_stat.st_data.st_dev * p_dev = p_stat.st_data.st_dev
* dev_whitelist.append(p_dev) # <<<<<<<<<<<<<< * dev_whitelist.append(p_dev) # <<<<<<<<<<<<<<
* *
* realpath(path, resolved_path) * realpath(path_to_scan, resolved_scan_path)
*/ */
Cy_GOTREF(__pyx_v_dev_whitelist); Cy_GOTREF(__pyx_v_dev_whitelist);
__pyx_t_10 = __pyx_v_dev_whitelist->append(__pyx_v_p_dev); if (unlikely(__pyx_t_10.is_error())) __PYX_ERR(0, 314, __pyx_L1_error) __pyx_t_10 = __pyx_v_dev_whitelist->append(__pyx_v_p_dev); if (unlikely(__pyx_t_10.is_error())) __PYX_ERR(0, 311, __pyx_L1_error)
/* "main.pyx":312 /* "main.pyx":309
* for p in dev_whitelist_paths: * for p in dev_whitelist_paths:
* p_stat = Stat(p) * p_stat = Stat(p)
* if p_stat is not NULL: # <<<<<<<<<<<<<< * if p_stat is not NULL: # <<<<<<<<<<<<<<
...@@ -6527,7 +6488,7 @@ static int __pyx_f_4main_start(char const *__pyx_v_path) { ...@@ -6527,7 +6488,7 @@ static int __pyx_f_4main_start(char const *__pyx_v_path) {
*/ */
} }
/* "main.pyx":310 /* "main.pyx":307
* *
* dev_whitelist = cyplist[dev_t]() * dev_whitelist = cyplist[dev_t]()
* for p in dev_whitelist_paths: # <<<<<<<<<<<<<< * for p in dev_whitelist_paths: # <<<<<<<<<<<<<<
...@@ -6537,58 +6498,58 @@ static int __pyx_f_4main_start(char const *__pyx_v_path) { ...@@ -6537,58 +6498,58 @@ static int __pyx_f_4main_start(char const *__pyx_v_path) {
} }
__pyx_t_6 = __pyx_v_dev_whitelist_paths->end(); __pyx_t_6 = __pyx_v_dev_whitelist_paths->end();
/* "main.pyx":316 /* "main.pyx":313
* dev_whitelist.append(p_dev) * dev_whitelist.append(p_dev)
* *
* realpath(path, resolved_path) # <<<<<<<<<<<<<< * realpath(path_to_scan, resolved_scan_path) # <<<<<<<<<<<<<<
* fprintf(stderr, resolved_path) # DEBUG * fprintf(stderr, resolved_scan_path) # DEBUG
* fprintf(stderr, "\n") # DEBUG * fprintf(stderr, "\n") # DEBUG
*/ */
(void)(realpath(__pyx_v_path, __pyx_v_resolved_path)); (void)(realpath(__pyx_v_path_to_scan, __pyx_v_resolved_scan_path));
/* "main.pyx":317 /* "main.pyx":314
* *
* realpath(path, resolved_path) * realpath(path_to_scan, resolved_scan_path)
* fprintf(stderr, resolved_path) # DEBUG # <<<<<<<<<<<<<< * fprintf(stderr, resolved_scan_path) # DEBUG # <<<<<<<<<<<<<<
* fprintf(stderr, "\n") # DEBUG * fprintf(stderr, "\n") # DEBUG
* fflush(stderr) # DEBUG * fflush(stderr) # DEBUG
*/ */
(void)(fprintf(stderr, __pyx_v_resolved_path)); (void)(fprintf(stderr, __pyx_v_resolved_scan_path));
/* "main.pyx":318 /* "main.pyx":315
* realpath(path, resolved_path) * realpath(path_to_scan, resolved_scan_path)
* fprintf(stderr, resolved_path) # DEBUG * fprintf(stderr, resolved_scan_path) # DEBUG
* fprintf(stderr, "\n") # DEBUG # <<<<<<<<<<<<<< * fprintf(stderr, "\n") # DEBUG # <<<<<<<<<<<<<<
* fflush(stderr) # DEBUG * fflush(stderr) # DEBUG
* node = make_node(resolved_path, resolved_path) * node = make_node(resolved_scan_path, resolved_scan_path)
*/ */
(void)(fprintf(stderr, ((char const *)"\n"))); (void)(fprintf(stderr, ((char const *)"\n")));
/* "main.pyx":319 /* "main.pyx":316
* fprintf(stderr, resolved_path) # DEBUG * fprintf(stderr, resolved_scan_path) # DEBUG
* fprintf(stderr, "\n") # DEBUG * fprintf(stderr, "\n") # DEBUG
* fflush(stderr) # DEBUG # <<<<<<<<<<<<<< * fflush(stderr) # DEBUG # <<<<<<<<<<<<<<
* node = make_node(resolved_path, resolved_path) * node = make_node(resolved_scan_path, resolved_scan_path)
* if node is NULL: * if node is NULL:
*/ */
(void)(fflush(stderr)); (void)(fflush(stderr));
/* "main.pyx":320 /* "main.pyx":317
* fprintf(stderr, "\n") # DEBUG * fprintf(stderr, "\n") # DEBUG
* fflush(stderr) # DEBUG * fflush(stderr) # DEBUG
* node = make_node(resolved_path, resolved_path) # <<<<<<<<<<<<<< * node = make_node(resolved_scan_path, resolved_scan_path) # <<<<<<<<<<<<<<
* if node is NULL: * if node is NULL:
* return -1 * return -1
*/ */
__pyx_t_11 = __pyx_f_4main_make_node(__pyx_v_resolved_path, __pyx_v_resolved_path); __pyx_t_11 = __pyx_f_4main_make_node(__pyx_v_resolved_scan_path, __pyx_v_resolved_scan_path);
Cy_GOTREF(__pyx_t_11); Cy_GOTREF(__pyx_t_11);
Cy_XDECREF(__pyx_v_node); Cy_XDECREF(__pyx_v_node);
__pyx_v_node = __pyx_t_11; __pyx_v_node = __pyx_t_11;
__pyx_t_11 = 0; __pyx_t_11 = 0;
/* "main.pyx":321 /* "main.pyx":318
* fflush(stderr) # DEBUG * fflush(stderr) # DEBUG
* node = make_node(resolved_path, resolved_path) * node = make_node(resolved_scan_path, resolved_scan_path)
* if node is NULL: # <<<<<<<<<<<<<< * if node is NULL: # <<<<<<<<<<<<<<
* return -1 * return -1
* *
...@@ -6597,8 +6558,8 @@ static int __pyx_f_4main_start(char const *__pyx_v_path) { ...@@ -6597,8 +6558,8 @@ static int __pyx_f_4main_start(char const *__pyx_v_path) {
__pyx_t_1 = ((__pyx_v_node == NULL) != 0); __pyx_t_1 = ((__pyx_v_node == NULL) != 0);
if (__pyx_t_1) { if (__pyx_t_1) {
/* "main.pyx":322 /* "main.pyx":319
* node = make_node(resolved_path, resolved_path) * node = make_node(resolved_scan_path, resolved_scan_path)
* if node is NULL: * if node is NULL:
* return -1 # <<<<<<<<<<<<<< * return -1 # <<<<<<<<<<<<<<
* *
...@@ -6607,16 +6568,16 @@ static int __pyx_f_4main_start(char const *__pyx_v_path) { ...@@ -6607,16 +6568,16 @@ static int __pyx_f_4main_start(char const *__pyx_v_path) {
__pyx_r = -1; __pyx_r = -1;
goto __pyx_L0; goto __pyx_L0;
/* "main.pyx":321 /* "main.pyx":318
* fflush(stderr) # DEBUG * fflush(stderr) # DEBUG
* node = make_node(resolved_path, resolved_path) * node = make_node(resolved_scan_path, resolved_scan_path)
* if node is NULL: # <<<<<<<<<<<<<< * if node is NULL: # <<<<<<<<<<<<<<
* return -1 * return -1
* *
*/ */
} }
/* "main.pyx":324 /* "main.pyx":321
* return -1 * return -1
* *
* active_node = activate(consume node) # <<<<<<<<<<<<<< * active_node = activate(consume node) # <<<<<<<<<<<<<<
...@@ -6633,7 +6594,7 @@ static int __pyx_f_4main_start(char const *__pyx_v_path) { ...@@ -6633,7 +6594,7 @@ static int __pyx_f_4main_start(char const *__pyx_v_path) {
__pyx_v_active_node = __pyx_t_12; __pyx_v_active_node = __pyx_t_12;
__pyx_t_12 = 0; __pyx_t_12 = 0;
/* "main.pyx":325 /* "main.pyx":322
* *
* active_node = activate(consume node) * active_node = activate(consume node)
* active_node.build_node(NULL, consume dev_whitelist, consume ignore_paths) # <<<<<<<<<<<<<< * active_node.build_node(NULL, consume dev_whitelist, consume ignore_paths) # <<<<<<<<<<<<<<
...@@ -6651,7 +6612,7 @@ static int __pyx_f_4main_start(char const *__pyx_v_path) { ...@@ -6651,7 +6612,7 @@ static int __pyx_f_4main_start(char const *__pyx_v_path) {
#ifdef WITH_THREAD #ifdef WITH_THREAD
PyGILState_Release(_save); PyGILState_Release(_save);
#endif #endif
__PYX_ERR(0, 325, __pyx_L1_error) __PYX_ERR(0, 322, __pyx_L1_error)
} }
__pyx_v_dev_whitelist = NULL; __pyx_v_dev_whitelist = NULL;
Cy_GOTREF(__pyx_v_ignore_paths); Cy_GOTREF(__pyx_v_ignore_paths);
...@@ -6664,7 +6625,7 @@ static int __pyx_f_4main_start(char const *__pyx_v_path) { ...@@ -6664,7 +6625,7 @@ static int __pyx_f_4main_start(char const *__pyx_v_path) {
#ifdef WITH_THREAD #ifdef WITH_THREAD
PyGILState_Release(_save); PyGILState_Release(_save);
#endif #endif
__PYX_ERR(0, 325, __pyx_L1_error) __PYX_ERR(0, 322, __pyx_L1_error)
} }
__pyx_v_ignore_paths = NULL; __pyx_v_ignore_paths = NULL;
__pyx_t_15 = __pyx_v_active_node->__pyx_f_active_build_node(NULL, __pyx_t_13, __pyx_t_14); __pyx_t_15 = __pyx_v_active_node->__pyx_f_active_build_node(NULL, __pyx_t_13, __pyx_t_14);
...@@ -6673,7 +6634,7 @@ static int __pyx_f_4main_start(char const *__pyx_v_path) { ...@@ -6673,7 +6634,7 @@ static int __pyx_f_4main_start(char const *__pyx_v_path) {
__pyx_t_14 = 0; __pyx_t_14 = 0;
Cy_XDECREF(__pyx_t_15); __pyx_t_15 = NULL; Cy_XDECREF(__pyx_t_15); __pyx_t_15 = NULL;
/* "main.pyx":326 /* "main.pyx":323
* active_node = activate(consume node) * active_node = activate(consume node)
* active_node.build_node(NULL, consume dev_whitelist, consume ignore_paths) * active_node.build_node(NULL, consume dev_whitelist, consume ignore_paths)
* scheduler.finish() # <<<<<<<<<<<<<< * scheduler.finish() # <<<<<<<<<<<<<<
...@@ -6683,7 +6644,7 @@ static int __pyx_f_4main_start(char const *__pyx_v_path) { ...@@ -6683,7 +6644,7 @@ static int __pyx_f_4main_start(char const *__pyx_v_path) {
Cy_GOTREF(__pyx_v_4main_scheduler); Cy_GOTREF(__pyx_v_4main_scheduler);
__pyx_v_4main_scheduler->finish(); __pyx_v_4main_scheduler->finish();
/* "main.pyx":327 /* "main.pyx":324
* active_node.build_node(NULL, consume dev_whitelist, consume ignore_paths) * active_node.build_node(NULL, consume dev_whitelist, consume ignore_paths)
* scheduler.finish() * scheduler.finish()
* node = consume active_node # <<<<<<<<<<<<<< * node = consume active_node # <<<<<<<<<<<<<<
...@@ -6700,25 +6661,61 @@ static int __pyx_f_4main_start(char const *__pyx_v_path) { ...@@ -6700,25 +6661,61 @@ static int __pyx_f_4main_start(char const *__pyx_v_path) {
#ifdef WITH_THREAD #ifdef WITH_THREAD
PyGILState_Release(_save); PyGILState_Release(_save);
#endif #endif
__PYX_ERR(0, 327, __pyx_L1_error) __PYX_ERR(0, 324, __pyx_L1_error)
} }
__pyx_v_active_node = NULL; __pyx_v_active_node = NULL;
Cy_XDECREF(__pyx_v_node); Cy_XDECREF(__pyx_v_node);
__pyx_v_node = __pyx_t_11; __pyx_v_node = __pyx_t_11;
__pyx_t_11 = 0; __pyx_t_11 = 0;
/* "main.pyx":330 /* "main.pyx":327
* *
* #""" # DEBUG * #""" # DEBUG
* result = fopen('/var/log/metadata_collect.log', 'w') # <<<<<<<<<<<<<< * realpath(log_path, resolved_log_path) # <<<<<<<<<<<<<<
* fprintf(stderr, resolved_log_path) # DEBUG
* fprintf(stderr, "\n") # DEBUG
*/
(void)(realpath(__pyx_v_log_path, __pyx_v_resolved_log_path));
/* "main.pyx":328
* #""" # DEBUG
* realpath(log_path, resolved_log_path)
* fprintf(stderr, resolved_log_path) # DEBUG # <<<<<<<<<<<<<<
* fprintf(stderr, "\n") # DEBUG
* fflush(stderr) # DEBUG
*/
(void)(fprintf(stderr, __pyx_v_resolved_log_path));
/* "main.pyx":329
* realpath(log_path, resolved_log_path)
* fprintf(stderr, resolved_log_path) # DEBUG
* fprintf(stderr, "\n") # DEBUG # <<<<<<<<<<<<<<
* fflush(stderr) # DEBUG
* result = fopen(resolved_log_path, 'w')
*/
(void)(fprintf(stderr, ((char const *)"\n")));
/* "main.pyx":330
* fprintf(stderr, resolved_log_path) # DEBUG
* fprintf(stderr, "\n") # DEBUG
* fflush(stderr) # DEBUG # <<<<<<<<<<<<<<
* result = fopen(resolved_log_path, 'w')
* if result is NULL: * if result is NULL:
* fprintf(stderr, 'Error creating the log file.\n') # DEBUG
*/ */
__pyx_v_result = fopen(((char const *)"/var/log/metadata_collect.log"), ((char const *)"w")); (void)(fflush(stderr));
/* "main.pyx":331 /* "main.pyx":331
* #""" # DEBUG * fprintf(stderr, "\n") # DEBUG
* result = fopen('/var/log/metadata_collect.log', 'w') * fflush(stderr) # DEBUG
* result = fopen(resolved_log_path, 'w') # <<<<<<<<<<<<<<
* if result is NULL:
* fprintf(stderr, 'Error creating the log file.\n') # DEBUG
*/
__pyx_v_result = fopen(__pyx_v_resolved_log_path, ((char const *)"w"));
/* "main.pyx":332
* fflush(stderr) # DEBUG
* result = fopen(resolved_log_path, 'w')
* if result is NULL: # <<<<<<<<<<<<<< * if result is NULL: # <<<<<<<<<<<<<<
* fprintf(stderr, 'Error creating the log file.\n') # DEBUG * fprintf(stderr, 'Error creating the log file.\n') # DEBUG
* fflush(stderr) * fflush(stderr)
...@@ -6726,8 +6723,8 @@ static int __pyx_f_4main_start(char const *__pyx_v_path) { ...@@ -6726,8 +6723,8 @@ static int __pyx_f_4main_start(char const *__pyx_v_path) {
__pyx_t_1 = ((__pyx_v_result == NULL) != 0); __pyx_t_1 = ((__pyx_v_result == NULL) != 0);
if (__pyx_t_1) { if (__pyx_t_1) {
/* "main.pyx":332 /* "main.pyx":333
* result = fopen('/var/log/metadata_collect.log', 'w') * result = fopen(resolved_log_path, 'w')
* if result is NULL: * if result is NULL:
* fprintf(stderr, 'Error creating the log file.\n') # DEBUG # <<<<<<<<<<<<<< * fprintf(stderr, 'Error creating the log file.\n') # DEBUG # <<<<<<<<<<<<<<
* fflush(stderr) * fflush(stderr)
...@@ -6735,7 +6732,7 @@ static int __pyx_f_4main_start(char const *__pyx_v_path) { ...@@ -6735,7 +6732,7 @@ static int __pyx_f_4main_start(char const *__pyx_v_path) {
*/ */
(void)(fprintf(stderr, ((char const *)"Error creating the log file.\n"))); (void)(fprintf(stderr, ((char const *)"Error creating the log file.\n")));
/* "main.pyx":333 /* "main.pyx":334
* if result is NULL: * if result is NULL:
* fprintf(stderr, 'Error creating the log file.\n') # DEBUG * fprintf(stderr, 'Error creating the log file.\n') # DEBUG
* fflush(stderr) # <<<<<<<<<<<<<< * fflush(stderr) # <<<<<<<<<<<<<<
...@@ -6744,7 +6741,7 @@ static int __pyx_f_4main_start(char const *__pyx_v_path) { ...@@ -6744,7 +6741,7 @@ static int __pyx_f_4main_start(char const *__pyx_v_path) {
*/ */
(void)(fflush(stderr)); (void)(fflush(stderr));
/* "main.pyx":334 /* "main.pyx":335
* fprintf(stderr, 'Error creating the log file.\n') # DEBUG * fprintf(stderr, 'Error creating the log file.\n') # DEBUG
* fflush(stderr) * fflush(stderr)
* return -1 # <<<<<<<<<<<<<< * return -1 # <<<<<<<<<<<<<<
...@@ -6754,16 +6751,16 @@ static int __pyx_f_4main_start(char const *__pyx_v_path) { ...@@ -6754,16 +6751,16 @@ static int __pyx_f_4main_start(char const *__pyx_v_path) {
__pyx_r = -1; __pyx_r = -1;
goto __pyx_L0; goto __pyx_L0;
/* "main.pyx":331 /* "main.pyx":332
* #""" # DEBUG * fflush(stderr) # DEBUG
* result = fopen('/var/log/metadata_collect.log', 'w') * result = fopen(resolved_log_path, 'w')
* if result is NULL: # <<<<<<<<<<<<<< * if result is NULL: # <<<<<<<<<<<<<<
* fprintf(stderr, 'Error creating the log file.\n') # DEBUG * fprintf(stderr, 'Error creating the log file.\n') # DEBUG
* fflush(stderr) * fflush(stderr)
*/ */
} }
/* "main.pyx":336 /* "main.pyx":337
* return -1 * return -1
* *
* fprintf(stderr, 'Log opened successfully.\n') # DEBUG # <<<<<<<<<<<<<< * fprintf(stderr, 'Log opened successfully.\n') # DEBUG # <<<<<<<<<<<<<<
...@@ -6772,7 +6769,7 @@ static int __pyx_f_4main_start(char const *__pyx_v_path) { ...@@ -6772,7 +6769,7 @@ static int __pyx_f_4main_start(char const *__pyx_v_path) {
*/ */
(void)(fprintf(stderr, ((char const *)"Log opened successfully.\n"))); (void)(fprintf(stderr, ((char const *)"Log opened successfully.\n")));
/* "main.pyx":338 /* "main.pyx":339
* fprintf(stderr, 'Log opened successfully.\n') # DEBUG * fprintf(stderr, 'Log opened successfully.\n') # DEBUG
* *
* fprintf(stderr, "WRITE_NOTE STAGE\n\n") # DEBUG # <<<<<<<<<<<<<< * fprintf(stderr, "WRITE_NOTE STAGE\n\n") # DEBUG # <<<<<<<<<<<<<<
...@@ -6781,7 +6778,7 @@ static int __pyx_f_4main_start(char const *__pyx_v_path) { ...@@ -6781,7 +6778,7 @@ static int __pyx_f_4main_start(char const *__pyx_v_path) {
*/ */
(void)(fprintf(stderr, ((char const *)"WRITE_NOTE STAGE\n\n"))); (void)(fprintf(stderr, ((char const *)"WRITE_NOTE STAGE\n\n")));
/* "main.pyx":343 /* "main.pyx":344
* #fclose(address_path) * #fclose(address_path)
* #fprintf(result, '{"mac_address": "%s"}\n', ip_address) * #fprintf(result, '{"mac_address": "%s"}\n', ip_address)
* node.write_node(result) # <<<<<<<<<<<<<< * node.write_node(result) # <<<<<<<<<<<<<<
...@@ -6791,7 +6788,7 @@ static int __pyx_f_4main_start(char const *__pyx_v_path) { ...@@ -6791,7 +6788,7 @@ static int __pyx_f_4main_start(char const *__pyx_v_path) {
Cy_GOTREF(__pyx_v_node); Cy_GOTREF(__pyx_v_node);
__pyx_v_node->write_node(__pyx_v_result); __pyx_v_node->write_node(__pyx_v_result);
/* "main.pyx":344 /* "main.pyx":345
* #fprintf(result, '{"mac_address": "%s"}\n', ip_address) * #fprintf(result, '{"mac_address": "%s"}\n', ip_address)
* node.write_node(result) * node.write_node(result)
* fprintf(result, '{}\n') # <<<<<<<<<<<<<< * fprintf(result, '{}\n') # <<<<<<<<<<<<<<
...@@ -6800,7 +6797,7 @@ static int __pyx_f_4main_start(char const *__pyx_v_path) { ...@@ -6800,7 +6797,7 @@ static int __pyx_f_4main_start(char const *__pyx_v_path) {
*/ */
(void)(fprintf(__pyx_v_result, ((char const *)"{}\n"))); (void)(fprintf(__pyx_v_result, ((char const *)"{}\n")));
/* "main.pyx":345 /* "main.pyx":346
* node.write_node(result) * node.write_node(result)
* fprintf(result, '{}\n') * fprintf(result, '{}\n')
* fprintf(result, 'fluentbit_end\n') # <<<<<<<<<<<<<< * fprintf(result, 'fluentbit_end\n') # <<<<<<<<<<<<<<
...@@ -6809,7 +6806,7 @@ static int __pyx_f_4main_start(char const *__pyx_v_path) { ...@@ -6809,7 +6806,7 @@ static int __pyx_f_4main_start(char const *__pyx_v_path) {
*/ */
(void)(fprintf(__pyx_v_result, ((char const *)"fluentbit_end\n"))); (void)(fprintf(__pyx_v_result, ((char const *)"fluentbit_end\n")));
/* "main.pyx":347 /* "main.pyx":348
* fprintf(result, 'fluentbit_end\n') * fprintf(result, 'fluentbit_end\n')
* *
* fclose(result) # <<<<<<<<<<<<<< * fclose(result) # <<<<<<<<<<<<<<
...@@ -6818,7 +6815,7 @@ static int __pyx_f_4main_start(char const *__pyx_v_path) { ...@@ -6818,7 +6815,7 @@ static int __pyx_f_4main_start(char const *__pyx_v_path) {
*/ */
(void)(fclose(__pyx_v_result)); (void)(fclose(__pyx_v_result));
/* "main.pyx":349 /* "main.pyx":350
* fclose(result) * fclose(result)
* #""" # DEBUG * #""" # DEBUG
* del scheduler # <<<<<<<<<<<<<< * del scheduler # <<<<<<<<<<<<<<
...@@ -6828,7 +6825,7 @@ static int __pyx_f_4main_start(char const *__pyx_v_path) { ...@@ -6828,7 +6825,7 @@ static int __pyx_f_4main_start(char const *__pyx_v_path) {
Cy_GOTREF(__pyx_v_4main_scheduler); Cy_GOTREF(__pyx_v_4main_scheduler);
Cy_XDECREF(__pyx_v_4main_scheduler); __pyx_v_4main_scheduler = NULL; Cy_XDECREF(__pyx_v_4main_scheduler); __pyx_v_4main_scheduler = NULL;
/* "main.pyx":351 /* "main.pyx":352
* del scheduler * del scheduler
* *
* fprintf(stderr, "WAITING for fluent-bit to end\n\n") # <<<<<<<<<<<<<< * fprintf(stderr, "WAITING for fluent-bit to end\n\n") # <<<<<<<<<<<<<<
...@@ -6837,7 +6834,7 @@ static int __pyx_f_4main_start(char const *__pyx_v_path) { ...@@ -6837,7 +6834,7 @@ static int __pyx_f_4main_start(char const *__pyx_v_path) {
*/ */
(void)(fprintf(stderr, ((char const *)"WAITING for fluent-bit to end\n\n"))); (void)(fprintf(stderr, ((char const *)"WAITING for fluent-bit to end\n\n")));
/* "main.pyx":352 /* "main.pyx":353
* *
* fprintf(stderr, "WAITING for fluent-bit to end\n\n") * fprintf(stderr, "WAITING for fluent-bit to end\n\n")
* wait_error = wait(NULL) # TODO improve this call (error handling, etc.) # <<<<<<<<<<<<<< * wait_error = wait(NULL) # TODO improve this call (error handling, etc.) # <<<<<<<<<<<<<<
...@@ -6846,7 +6843,7 @@ static int __pyx_f_4main_start(char const *__pyx_v_path) { ...@@ -6846,7 +6843,7 @@ static int __pyx_f_4main_start(char const *__pyx_v_path) {
*/ */
__pyx_v_wait_error = wait(NULL); __pyx_v_wait_error = wait(NULL);
/* "main.pyx":354 /* "main.pyx":355
* wait_error = wait(NULL) # TODO improve this call (error handling, etc.) * wait_error = wait(NULL) # TODO improve this call (error handling, etc.)
* #wait_error = waitpid(child_pid, NULL, 1) # TODO improve this call (error handling, etc.) * #wait_error = waitpid(child_pid, NULL, 1) # TODO improve this call (error handling, etc.)
* fprintf(stderr, "WAITING ENDS\n\n") # <<<<<<<<<<<<<< * fprintf(stderr, "WAITING ENDS\n\n") # <<<<<<<<<<<<<<
...@@ -6855,7 +6852,7 @@ static int __pyx_f_4main_start(char const *__pyx_v_path) { ...@@ -6855,7 +6852,7 @@ static int __pyx_f_4main_start(char const *__pyx_v_path) {
*/ */
(void)(fprintf(stderr, ((char const *)"WAITING ENDS\n\n"))); (void)(fprintf(stderr, ((char const *)"WAITING ENDS\n\n")));
/* "main.pyx":355 /* "main.pyx":356
* #wait_error = waitpid(child_pid, NULL, 1) # TODO improve this call (error handling, etc.) * #wait_error = waitpid(child_pid, NULL, 1) # TODO improve this call (error handling, etc.)
* fprintf(stderr, "WAITING ENDS\n\n") * fprintf(stderr, "WAITING ENDS\n\n")
* fflush(stderr) # DEBUG # <<<<<<<<<<<<<< * fflush(stderr) # DEBUG # <<<<<<<<<<<<<<
...@@ -6864,7 +6861,7 @@ static int __pyx_f_4main_start(char const *__pyx_v_path) { ...@@ -6864,7 +6861,7 @@ static int __pyx_f_4main_start(char const *__pyx_v_path) {
*/ */
(void)(fflush(stderr)); (void)(fflush(stderr));
/* "main.pyx":357 /* "main.pyx":358
* fflush(stderr) # DEBUG * fflush(stderr) # DEBUG
* *
* return 0 # <<<<<<<<<<<<<< * return 0 # <<<<<<<<<<<<<<
...@@ -6879,7 +6876,7 @@ static int __pyx_f_4main_start(char const *__pyx_v_path) { ...@@ -6879,7 +6876,7 @@ static int __pyx_f_4main_start(char const *__pyx_v_path) {
/* "main.pyx":269 /* "main.pyx":269
* *
* *
* cdef int start(const char *path) nogil: # <<<<<<<<<<<<<< * cdef int start(const char *path_to_scan, const char *fb_exec_path, const char *fb_lib_path, const char *fb_conf_path, const char *log_path) nogil: # <<<<<<<<<<<<<<
* *
* printf("TEST TEST TEST TEST TEST\n\n") # DEBUG * printf("TEST TEST TEST TEST TEST\n\n") # DEBUG
*/ */
...@@ -6906,65 +6903,168 @@ static int __pyx_f_4main_start(char const *__pyx_v_path) { ...@@ -6906,65 +6903,168 @@ static int __pyx_f_4main_start(char const *__pyx_v_path) {
return __pyx_r; return __pyx_r;
} }
/* "main.pyx":359 /* "main.pyx":360
* return 0 * return 0
* *
* cdef public int main(int argc, char* argv[]) nogil: # <<<<<<<<<<<<<< * cdef public int main(int argc, char* argv[]) nogil: # <<<<<<<<<<<<<<
* if argc >= 2: * cdef char* path_to_scan = "/"
* return start(<char*>argv[1]) * cdef char* fb_exec_path = "/sbin/fluent-bit"
*/ */
int main(int __pyx_v_argc, char **__pyx_v_argv) { int main(int __pyx_v_argc, char **__pyx_v_argv) {
char *__pyx_v_path_to_scan;
char *__pyx_v_fb_exec_path;
char *__pyx_v_fb_lib_path;
char *__pyx_v_fb_conf_path;
char *__pyx_v_log_path;
int __pyx_r; int __pyx_r;
int __pyx_t_1;
/* "main.pyx":360 /* "main.pyx":361
* *
* cdef public int main(int argc, char* argv[]) nogil: * cdef public int main(int argc, char* argv[]) nogil:
* if argc >= 2: # <<<<<<<<<<<<<< * cdef char* path_to_scan = "/" # <<<<<<<<<<<<<<
* return start(<char*>argv[1]) * cdef char* fb_exec_path = "/sbin/fluent-bit"
* else: * cdef char* fb_lib_path = "/etc/fluentbit_wendelin.so"
*/ */
__pyx_t_1 = ((__pyx_v_argc >= 2) != 0); __pyx_v_path_to_scan = ((char *)"/");
if (__pyx_t_1) {
/* "main.pyx":361 /* "main.pyx":362
* cdef public int main(int argc, char* argv[]) nogil: * cdef public int main(int argc, char* argv[]) nogil:
* if argc >= 2: * cdef char* path_to_scan = "/"
* return start(<char*>argv[1]) # <<<<<<<<<<<<<< * cdef char* fb_exec_path = "/sbin/fluent-bit" # <<<<<<<<<<<<<<
* else: * cdef char* fb_lib_path = "/etc/fluentbit_wendelin.so"
* return start(<char*>'/') * cdef char* fb_conf_path = "/etc/flb.conf"
*/ */
__pyx_r = __pyx_f_4main_start(((char *)(__pyx_v_argv[1]))); __pyx_v_fb_exec_path = ((char *)"/sbin/fluent-bit");
goto __pyx_L0;
/* "main.pyx":360 /* "main.pyx":363
* cdef char* path_to_scan = "/"
* cdef char* fb_exec_path = "/sbin/fluent-bit"
* cdef char* fb_lib_path = "/etc/fluentbit_wendelin.so" # <<<<<<<<<<<<<<
* cdef char* fb_conf_path = "/etc/flb.conf"
* cdef char* log_path = "/var/log/metadata_collect.log"
*/
__pyx_v_fb_lib_path = ((char *)"/etc/fluentbit_wendelin.so");
/* "main.pyx":364
* cdef char* fb_exec_path = "/sbin/fluent-bit"
* cdef char* fb_lib_path = "/etc/fluentbit_wendelin.so"
* cdef char* fb_conf_path = "/etc/flb.conf" # <<<<<<<<<<<<<<
* cdef char* log_path = "/var/log/metadata_collect.log"
* if argc == 2:
*/
__pyx_v_fb_conf_path = ((char *)"/etc/flb.conf");
/* "main.pyx":365
* cdef char* fb_lib_path = "/etc/fluentbit_wendelin.so"
* cdef char* fb_conf_path = "/etc/flb.conf"
* cdef char* log_path = "/var/log/metadata_collect.log" # <<<<<<<<<<<<<<
* if argc == 2:
* path_to_scan = <char*>argv[1]
*/
__pyx_v_log_path = ((char *)"/var/log/metadata_collect.log");
/* "main.pyx":366
* cdef char* fb_conf_path = "/etc/flb.conf"
* cdef char* log_path = "/var/log/metadata_collect.log"
* if argc == 2: # <<<<<<<<<<<<<<
* path_to_scan = <char*>argv[1]
* elif argc == 6:
*/
switch (__pyx_v_argc) {
case 2:
/* "main.pyx":367
* cdef char* log_path = "/var/log/metadata_collect.log"
* if argc == 2:
* path_to_scan = <char*>argv[1] # <<<<<<<<<<<<<<
* elif argc == 6:
* path_to_scan = <char*>argv[1]
*/
__pyx_v_path_to_scan = ((char *)(__pyx_v_argv[1]));
/* "main.pyx":366
* cdef char* fb_conf_path = "/etc/flb.conf"
* cdef char* log_path = "/var/log/metadata_collect.log"
* if argc == 2: # <<<<<<<<<<<<<<
* path_to_scan = <char*>argv[1]
* elif argc == 6:
*/
break;
case 6:
/* "main.pyx":369
* path_to_scan = <char*>argv[1]
* elif argc == 6:
* path_to_scan = <char*>argv[1] # <<<<<<<<<<<<<<
* fb_exec_path = <char*>argv[2]
* fb_lib_path = <char*>argv[3]
*/
__pyx_v_path_to_scan = ((char *)(__pyx_v_argv[1]));
/* "main.pyx":370
* elif argc == 6:
* path_to_scan = <char*>argv[1]
* fb_exec_path = <char*>argv[2] # <<<<<<<<<<<<<<
* fb_lib_path = <char*>argv[3]
* fb_conf_path = <char*>argv[4]
*/
__pyx_v_fb_exec_path = ((char *)(__pyx_v_argv[2]));
/* "main.pyx":371
* path_to_scan = <char*>argv[1]
* fb_exec_path = <char*>argv[2]
* fb_lib_path = <char*>argv[3] # <<<<<<<<<<<<<<
* fb_conf_path = <char*>argv[4]
* log_path = <char*>argv[5]
*/
__pyx_v_fb_lib_path = ((char *)(__pyx_v_argv[3]));
/* "main.pyx":372
* fb_exec_path = <char*>argv[2]
* fb_lib_path = <char*>argv[3]
* fb_conf_path = <char*>argv[4] # <<<<<<<<<<<<<<
* 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)
*/
__pyx_v_fb_conf_path = ((char *)(__pyx_v_argv[4]));
/* "main.pyx":373
* fb_lib_path = <char*>argv[3]
* fb_conf_path = <char*>argv[4]
* 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)
* *
* cdef public int main(int argc, char* argv[]) nogil:
* if argc >= 2: # <<<<<<<<<<<<<<
* return start(<char*>argv[1])
* else:
*/ */
__pyx_v_log_path = ((char *)(__pyx_v_argv[5]));
/* "main.pyx":368
* if argc == 2:
* path_to_scan = <char*>argv[1]
* elif argc == 6: # <<<<<<<<<<<<<<
* path_to_scan = <char*>argv[1]
* fb_exec_path = <char*>argv[2]
*/
break;
default: break;
} }
/* "main.pyx":363 /* "main.pyx":374
* return start(<char*>argv[1]) * fb_conf_path = <char*>argv[4]
* else: * log_path = <char*>argv[5]
* return start(<char*>'/') # <<<<<<<<<<<<<< * return start(<char*>path_to_scan, <char*>fb_exec_path, <char*>fb_lib_path, <char*>fb_conf_path, <char*>log_path) # <<<<<<<<<<<<<<
* *
* #def python_main(): * #def python_main():
*/ */
/*else*/ { __pyx_r = __pyx_f_4main_start(((char *)__pyx_v_path_to_scan), ((char *)__pyx_v_fb_exec_path), ((char *)__pyx_v_fb_lib_path), ((char *)__pyx_v_fb_conf_path), ((char *)__pyx_v_log_path));
__pyx_r = __pyx_f_4main_start(((char *)((char *)"/")));
goto __pyx_L0; goto __pyx_L0;
}
/* "main.pyx":359 /* "main.pyx":360
* return 0 * return 0
* *
* cdef public int main(int argc, char* argv[]) nogil: # <<<<<<<<<<<<<< * cdef public int main(int argc, char* argv[]) nogil: # <<<<<<<<<<<<<<
* if argc >= 2: * cdef char* path_to_scan = "/"
* return start(<char*>argv[1]) * cdef char* fb_exec_path = "/sbin/fluent-bit"
*/ */
/* function exit code */ /* function exit code */
......
...@@ -266,25 +266,22 @@ cdef cypclass SymlinkNode(Node): ...@@ -266,25 +266,22 @@ cdef cypclass SymlinkNode(Node):
fwrite(self.formatted.data(), 1, self.formatted.size(), stream) fwrite(self.formatted.data(), 1, self.formatted.size(), stream)
cdef int start(const char *path) nogil: cdef int start(const char *path_to_scan, const char *fb_exec_path, const char *fb_lib_path, const char *fb_conf_path, const char *log_path) nogil:
printf("TEST TEST TEST TEST TEST\n\n") # DEBUG printf("TEST TEST TEST TEST TEST\n\n") # DEBUG
# TODO replace 4096 by PATH_MAX (yet it will not be perfect) # TODO replace 4096 by PATH_MAX (yet it will not be perfect)
cdef char resolved_path[4096] cdef char resolved_scan_path[4096]
cdef char resolved_log_path[4096]
cdef pid_t wait_error = -1 # DEBUG cdef pid_t wait_error = -1 # DEBUG
cdef char* program_name = "fluentbit" cdef char* program_name = <char*>"fluent-bit"
cdef char* arg1 = "-e"
cdef char* arg2 = "/etc/fluentbit_wendelin.so"
cdef char* arg3 = "-c"
cdef char* arg4 = "/etc/flb.conf"
cdef pid_t child_pid = -1 # DEBUG cdef pid_t child_pid = -1 # DEBUG
child_pid = fork() # DEBUG child_pid = fork() # DEBUG
cdef int err cdef int err
#cdef char ip_address[100] #cdef char ip_address[100]
#cdef FILE *address_path = fopen("/sys/class/net/ens3/address", "r") #cdef FILE *address_path = fopen("/sys/class/net/ens3/address", "r")
if child_pid == 0: # CHILD if child_pid == 0: # CHILD
err = execlp("/sbin/fluent-bit", program_name, arg1, arg2, arg3, arg4, 0) err = execlp(fb_exec_path, program_name, <char*>"-e", fb_lib_path, <char*>"-c", fb_conf_path, 0)
fprintf(stderr, "ERROR with execlp() in CHILD: %d\n", err) fprintf(stderr, "ERROR with execlp() in CHILD: %d\n", err)
else: # PARENT else: # PARENT
printf("WELCOME TO PARENT\n\n") # DEBUG printf("WELCOME TO PARENT\n\n") # DEBUG
...@@ -304,7 +301,7 @@ cdef int start(const char *path) nogil: ...@@ -304,7 +301,7 @@ cdef int start(const char *path) nogil:
dev_whitelist_paths.append(b'/boot/efi') dev_whitelist_paths.append(b'/boot/efi')
dev_whitelist_paths.append(b'/root') dev_whitelist_paths.append(b'/root')
dev_whitelist_paths.append(b'/sysroot') dev_whitelist_paths.append(b'/sysroot')
dev_whitelist_paths.append(path) dev_whitelist_paths.append(path_to_scan)
dev_whitelist = cyplist[dev_t]() dev_whitelist = cyplist[dev_t]()
for p in dev_whitelist_paths: for p in dev_whitelist_paths:
...@@ -313,11 +310,11 @@ cdef int start(const char *path) nogil: ...@@ -313,11 +310,11 @@ cdef int start(const char *path) nogil:
p_dev = p_stat.st_data.st_dev p_dev = p_stat.st_data.st_dev
dev_whitelist.append(p_dev) dev_whitelist.append(p_dev)
realpath(path, resolved_path) realpath(path_to_scan, resolved_scan_path)
fprintf(stderr, resolved_path) # DEBUG fprintf(stderr, resolved_scan_path) # DEBUG
fprintf(stderr, "\n") # DEBUG fprintf(stderr, "\n") # DEBUG
fflush(stderr) # DEBUG fflush(stderr) # DEBUG
node = make_node(resolved_path, resolved_path) node = make_node(resolved_scan_path, resolved_scan_path)
if node is NULL: if node is NULL:
return -1 return -1
...@@ -327,7 +324,11 @@ cdef int start(const char *path) nogil: ...@@ -327,7 +324,11 @@ cdef int start(const char *path) nogil:
node = consume active_node node = consume active_node
#""" # DEBUG #""" # DEBUG
result = fopen('/var/log/metadata_collect.log', 'w') realpath(log_path, resolved_log_path)
fprintf(stderr, resolved_log_path) # DEBUG
fprintf(stderr, "\n") # DEBUG
fflush(stderr) # DEBUG
result = fopen(resolved_log_path, 'w')
if result is NULL: if result is NULL:
fprintf(stderr, 'Error creating the log file.\n') # DEBUG fprintf(stderr, 'Error creating the log file.\n') # DEBUG
fflush(stderr) fflush(stderr)
...@@ -357,10 +358,20 @@ cdef int start(const char *path) nogil: ...@@ -357,10 +358,20 @@ cdef int start(const char *path) nogil:
return 0 return 0
cdef public int main(int argc, char* argv[]) nogil: cdef public int main(int argc, char* argv[]) nogil:
if argc >= 2: cdef char* path_to_scan = "/"
return start(<char*>argv[1]) cdef char* fb_exec_path = "/sbin/fluent-bit"
else: cdef char* fb_lib_path = "/etc/fluentbit_wendelin.so"
return start(<char*>'/') cdef char* fb_conf_path = "/etc/flb.conf"
cdef char* log_path = "/var/log/metadata_collect.log"
if argc == 2:
path_to_scan = <char*>argv[1]
elif argc == 6:
path_to_scan = <char*>argv[1]
fb_exec_path = <char*>argv[2]
fb_lib_path = <char*>argv[3]
fb_conf_path = <char*>argv[4]
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)
#def python_main(): #def python_main():
# start(<char*>'.') # start(<char*>'.')
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