virtual int setup() override { init_paths(); // Create test directory A. string dir_path = mnt_dir_ + "/" TEST_DIR_A; int res = mkdir(dir_path.c_str(), 0777); if (res < 0) { return -1; } //Create file foo in TEST_DIR_A const int fd_foo = open(foo_path.c_str(), O_RDWR | O_CREAT, TEST_FILE_PERMS); if (fd_foo < 0) { return -1; } const int fd_foo_backup = open(foo_backup_path.c_str(), O_RDWR | O_CREAT, TEST_FILE_PERMS); if (fd_foo_backup < 0) { return -1; } // Write some contents to the file if (WriteData(fd_foo, 0, 4096) < 0) { return -2; } // Write some contents to the backup file (for verifying md5sum in check_test) if (WriteData(fd_foo_backup, 0, 4096) < 0) { return -2; } // Sync the file and backup file if (fsync(fd_foo) < 0) { return -1; } if (fsync(fd_foo_backup) < 0) { return -1; } // write more contents in a different offset if (WriteData(fd_foo, 4096, 4096) < 0) { return -2; } if (WriteData(fd_foo_backup, 4096, 4096) < 0) { return -2; } // sync range the foo file if (sync_file_range(fd_foo, 4096, 4096, 0) < 0) { return -3; } // fsync the entire backup file if (fsync(fd_foo_backup) < 0) { return -1; } close(fd_foo); close(fd_foo_backup); return 0; }
virtual int run(int checkpoint) override { init_paths(); int local_checkpoint = 0; // Rename the foo to bar if (rename(foo_path.c_str(), bar_path.c_str()) != 0) { return -2; } const int fd_bar = open(bar_path.c_str(), O_RDWR | O_CREAT, TEST_FILE_PERMS); if (fd_bar < 0) { return -3; } if (fsync(fd_bar) < 0) { return -4; } if (Checkpoint() < 0){ return -5; } local_checkpoint += 1; if (local_checkpoint == checkpoint) { return 1; } //Close open files close(fd_bar); return 0; }
//--------------------------------------------------------------------------------------------------------------------------------------------------- int main(int argc, char *argv[]) { int r = 0; char *username = NULL; char *tty = NULL; char *ip = NULL; int paranoid = 0; if(argc < 2) usage(argv[0]); while((r = getopt(argc, argv, OPTSTRING)) != -1) { switch(r) { case 'u': username = optarg; break; case 't': tty = optarg; break; case 'i': ip = optarg; break; case 'p': paranoid = 1; break; default: return -1; } } print_banner(); if(getuid() != 0) printf("[+] You should be root\n"); printf("[*] User: %s\n", username); printf("[*] TTY: %s\n", tty); printf("[*] IP: %s\n", ip); printf("[*] Paranoid: %s\n", (paranoid == 1) ? "yes" : "no"); init_paths(); if(username && tty) { clear_system_layer(username, tty); } if(ip) { clear_application_layer(ip); } if(paranoid == 1) { clear_paranoid_layer(); } printf("\n[*] Cleaning is complete\n"); return 0; }
void load_config(){ /* * Called once at startup, loads the json config file into the proper structs and such. * If any fail, abort program, otherwise we would be in unknowable state. * */ if (init_paths() !=0){ exit(EXIT_FAILURE); } }
virtual int check_test(unsigned int last_checkpoint, DataTestResult *test_result) override { init_paths(); const int fd_bar = open(bar_path.c_str(), O_RDONLY, TEST_FILE_PERMS); const int fd_foo = open(foo_path.c_str(), O_RDONLY, TEST_FILE_PERMS); if (fd_bar >= 0 && fd_foo >= 0) { test_result->SetError(DataTestResult::kOldFilePersisted); test_result->error_description = " : Both old and new files present after crash recovery"; close(fd_bar); close(fd_foo); return 0; } if (fd_bar < 0 && fd_foo < 0) { test_result->SetError(DataTestResult::kFileMissing); test_result->error_description = " : Both old and new files are missing after crash recovery"; return 0; } if (fd_foo >= 0) { close(fd_foo); } if (fd_bar < 0 && last_checkpoint >= 1) { test_result->SetError(DataTestResult::kFileMissing); test_result->error_description = " : Unable to locate bar file after crash recovery"; return 0; } string expected_md5sum = get_md5sum(foo_backup_path); string actual_md5sum = get_md5sum(bar_path); if (expected_md5sum.compare(actual_md5sum) != 0 && last_checkpoint >= 1) { test_result->SetError(DataTestResult::kFileDataCorrupted); test_result->error_description = " : md5sum of bar does not match with expected md5sum of foo backup"; } if (fd_bar >= 0) { close(fd_bar); } return 0; }
gboolean mu_runtime_init (const char* muhome_arg, const char *name) { gchar *muhome; g_return_val_if_fail (!_initialized, FALSE); g_return_val_if_fail (name, FALSE); setlocale (LC_ALL, ""); #ifndef GLIB_VERSION_2_36 g_type_init (); #endif /*GLIB_VERSION_2_36*/ if (muhome_arg) muhome = g_strdup (muhome_arg); else muhome = mu_util_guess_mu_homedir (); if (!mu_util_create_dir_maybe (muhome, 0700, TRUE)) { g_printerr ("mu: invalid mu homedir specified;" " use --muhome=<dir>\n"); runtime_free (); return FALSE; } _data = g_new0 (MuRuntimeData, 1); _data->_str[MU_RUNTIME_PATH_MUHOME] = muhome; init_paths (muhome, _data); _data->_name = g_strdup (name); if (!init_log (muhome, name, MU_LOG_OPTIONS_BACKUP)) { runtime_free (); g_free (muhome); return FALSE; } return _initialized = TRUE; }
gboolean mu_runtime_init_from_cmdline (int *pargc, char ***pargv, const char *name) { g_return_val_if_fail (!_initialized, FALSE); g_return_val_if_fail (name, FALSE); setlocale (LC_ALL, ""); g_type_init (); _data = g_new0 (MuRuntimeData, 1); _data->_config = mu_config_init (pargc, pargv); if (!_data->_config) { runtime_free (); return FALSE; } if (!mu_util_create_dir_maybe (_data->_config->muhome, 0700, TRUE)) { g_printerr ("mu: invalid mu homedir specified;" " use --muhome=<dir>\n"); runtime_free (); return FALSE; } _data->_name = g_strdup (name); _data->_str[MU_RUNTIME_PATH_MUHOME] = g_strdup (_data->_config->muhome); init_paths (_data->_str[MU_RUNTIME_PATH_MUHOME], _data); if (!init_log (runtime_path(MU_RUNTIME_PATH_MUHOME), name, _data->_config->log_stderr, _data->_config->quiet, _data->_config->debug)) { runtime_free (); return FALSE; } return _initialized = TRUE; }
static unsigned int do_test(void) { if (mkdir("/tmp/qemu-test_path", 0700) != 0) return __LINE__; if (mkdir("/tmp/qemu-test_path/DIR1", 0700) != 0) return __LINE__; if (mkdir("/tmp/qemu-test_path/DIR1/DIR2", 0700) != 0) return __LINE__; if (mkdir("/tmp/qemu-test_path/DIR1/DIR3", 0700) != 0) return __LINE__; if (close(creat("/tmp/qemu-test_path/DIR1/DIR2/FILE", 0600)) != 0) return __LINE__; if (close(creat("/tmp/qemu-test_path/DIR1/DIR2/FILE2", 0600)) != 0) return __LINE__; if (close(creat("/tmp/qemu-test_path/DIR1/DIR2/FILE3", 0600)) != 0) return __LINE__; if (close(creat("/tmp/qemu-test_path/DIR1/DIR2/FILE4", 0600)) != 0) return __LINE__; if (close(creat("/tmp/qemu-test_path/DIR1/DIR2/FILE5", 0600)) != 0) return __LINE__; init_paths("/tmp/qemu-test_path"); NO_CHANGE("/tmp"); NO_CHANGE("/tmp/"); NO_CHANGE("/tmp/qemu-test_path"); NO_CHANGE("/tmp/qemu-test_path/"); NO_CHANGE("/tmp/qemu-test_path/D"); NO_CHANGE("/tmp/qemu-test_path/DI"); NO_CHANGE("/tmp/qemu-test_path/DIR"); NO_CHANGE("/tmp/qemu-test_path/DIR1"); NO_CHANGE("/tmp/qemu-test_path/DIR1/"); NO_CHANGE("/D"); NO_CHANGE("/DI"); NO_CHANGE("/DIR"); NO_CHANGE("/DIR2"); NO_CHANGE("/DIR1."); CHANGE_TO("/DIR1", "/tmp/qemu-test_path/DIR1"); CHANGE_TO("/DIR1/", "/tmp/qemu-test_path/DIR1"); NO_CHANGE("/DIR1/D"); NO_CHANGE("/DIR1/DI"); NO_CHANGE("/DIR1/DIR"); NO_CHANGE("/DIR1/DIR1"); CHANGE_TO("/DIR1/DIR2", "/tmp/qemu-test_path/DIR1/DIR2"); CHANGE_TO("/DIR1/DIR2/", "/tmp/qemu-test_path/DIR1/DIR2"); CHANGE_TO("/DIR1/DIR3", "/tmp/qemu-test_path/DIR1/DIR3"); CHANGE_TO("/DIR1/DIR3/", "/tmp/qemu-test_path/DIR1/DIR3"); NO_CHANGE("/DIR1/DIR2/F"); NO_CHANGE("/DIR1/DIR2/FI"); NO_CHANGE("/DIR1/DIR2/FIL"); NO_CHANGE("/DIR1/DIR2/FIL."); CHANGE_TO("/DIR1/DIR2/FILE", "/tmp/qemu-test_path/DIR1/DIR2/FILE"); CHANGE_TO("/DIR1/DIR2/FILE2", "/tmp/qemu-test_path/DIR1/DIR2/FILE2"); CHANGE_TO("/DIR1/DIR2/FILE3", "/tmp/qemu-test_path/DIR1/DIR2/FILE3"); CHANGE_TO("/DIR1/DIR2/FILE4", "/tmp/qemu-test_path/DIR1/DIR2/FILE4"); CHANGE_TO("/DIR1/DIR2/FILE5", "/tmp/qemu-test_path/DIR1/DIR2/FILE5"); NO_CHANGE("/DIR1/DIR2/FILE6"); NO_CHANGE("/DIR1/DIR2/FILE/X"); CHANGE_TO("/DIR1/../DIR1", "/tmp/qemu-test_path/DIR1"); CHANGE_TO("/DIR1/../DIR1/", "/tmp/qemu-test_path/DIR1"); CHANGE_TO("/../DIR1", "/tmp/qemu-test_path/DIR1"); CHANGE_TO("/../DIR1/", "/tmp/qemu-test_path/DIR1"); CHANGE_TO("/DIR1/DIR2/../DIR2", "/tmp/qemu-test_path/DIR1/DIR2"); CHANGE_TO("/DIR1/DIR2/../DIR2/../../DIR1/DIR2/FILE", "/tmp/qemu-test_path/DIR1/DIR2/FILE"); CHANGE_TO("/DIR1/DIR2/../DIR2/FILE", "/tmp/qemu-test_path/DIR1/DIR2/FILE"); NO_CHANGE("/DIR1/DIR2/../DIR1"); NO_CHANGE("/DIR1/DIR2/../FILE"); CHANGE_TO("/./DIR1/DIR2/FILE", "/tmp/qemu-test_path/DIR1/DIR2/FILE"); CHANGE_TO("/././DIR1/DIR2/FILE", "/tmp/qemu-test_path/DIR1/DIR2/FILE"); CHANGE_TO("/DIR1/./DIR2/FILE", "/tmp/qemu-test_path/DIR1/DIR2/FILE"); CHANGE_TO("/DIR1/././DIR2/FILE", "/tmp/qemu-test_path/DIR1/DIR2/FILE"); CHANGE_TO("/DIR1/DIR2/./FILE", "/tmp/qemu-test_path/DIR1/DIR2/FILE"); CHANGE_TO("/DIR1/DIR2/././FILE", "/tmp/qemu-test_path/DIR1/DIR2/FILE"); CHANGE_TO("/./DIR1/./DIR2/./FILE", "/tmp/qemu-test_path/DIR1/DIR2/FILE"); return 0; }
void parse(char *country_input, char *path_input, char *domain_input, char *ipaddress_input, char *http_status_input, char *referer_input, char *bird, char *db_path, int minimum_field_count) { // GENERIC VARIABLES char *fields[MAX_FIELD_CNT]; // number of fields we expect in a single line int num_filters = 0; // total number of filters we detect from the command line int num_domain_filters = 0; // total number of domain filters int num_path_filters = 0; // total number of path filters int num_ipaddress_filters = 0; // total number of ipaddress filter int num_countries_filters = 0; // total number countries we want to restrict the filtering int num_http_status_filters = 0; // total number of http status we want to restrict the filtering. int num_referer_filters = 0; int required_hits = 0; int bird_int = 0; int i; int field_count_this_line=0; // number of fields found in the current line char line[ LINE_BUF_SIZE ]; char *ipaddr; char *url; char *http_status; char *referer; // DETERMINE NUMBER OF FILTERS if(params[DOMAIN_FILTER]){ num_domain_filters = determine_num_obs(domain_input,comma_delimiter); required_hits+=1; } if(params[PATH_FILTER]){ num_path_filters = determine_num_obs(path_input,comma_delimiter); required_hits+=1; } if(params[IP_FILTER]){ num_ipaddress_filters = determine_num_obs(ipaddress_input, comma_delimiter); required_hits+=1; } if(params[GEO_FILTER]){ if(country_input != NULL && strlen(country_input) >1){ num_countries_filters = determine_num_obs(country_input, comma_delimiter); required_hits+=1; } } if(params[REFERER_FILTER]){ num_referer_filters = determine_num_obs(referer_input, comma_delimiter); required_hits+=1; } if(params[HTTP_STATUS_FILTER]){ if(http_status_input != NULL && strlen(http_status_input) >1){ num_http_status_filters = determine_num_obs(http_status_input, comma_delimiter); required_hits+=1; } } num_filters = num_path_filters + num_domain_filters + num_ipaddress_filters + num_countries_filters + num_http_status_filters + num_referer_filters; Filter filters[num_filters]; // GEO_FILTER INITIALIZATION GeoIP *gi = NULL; // initialize to suppress compiler warning char *countries[num_countries_filters]; char *area; // FILTER INITIALIZATION if(params[DOMAIN_FILTER]){ init_domains(filters, domain_input, comma_delimiter); } else { domain_input=NULL; } if(params[PATH_FILTER]){ init_paths(filters, path_input, comma_delimiter); } else { path_input = NULL; } if(params[IP_FILTER]){ init_ip_addresses(filters, ipaddress_input, comma_delimiter); } else { ipaddress_input = NULL; } if (params[REFERER_FILTER]){ init_domains(filters, referer_input, comma_delimiter); } else { referer_input = NULL; } if( ! (params[GEO_FILTER] || (recode & GEO)) ) { country_input = NULL; } else { init_countries(countries, country_input, num_countries_filters, comma_delimiter); bird_int = init_bird_level(bird); /* * Before changing the type of cache, have a look at this benchmark: * http://www.maxmind.com/app/benchmark * and choose wisely. */ switch(bird_int){ case COUNTRY: if(db_path!=NULL){ db_country_path=db_path; } gi = GeoIP_open(db_country_path, GEOIP_MEMORY_CACHE); break; case REGION: if(db_path!=NULL){ db_region_path=db_path; } gi = GeoIP_open(db_region_path, GEOIP_MEMORY_CACHE); break; case CITY: if(db_path!=NULL){ db_city_path=db_path; } gi = GeoIP_open(db_city_path, GEOIP_MEMORY_CACHE); break; case LAT_LON: if(db_path!=NULL){ db_city_path=db_path; } gi = GeoIP_open(db_city_path, GEOIP_MEMORY_CACHE); break; case EVERYTHING: if(db_path!=NULL){ db_city_path=db_path; } gi = GeoIP_open(db_city_path, GEOIP_MEMORY_CACHE); break; } if (gi == NULL) { fprintf(stderr, "Error opening MaxMind Geo database.\n"); fprintf(stderr, "Path used for country database:%s\n", db_country_path); fprintf(stderr, "Path used for region database:%s\n", db_region_path); fprintf(stderr, "Path used for city database:%s\n", db_city_path); exit(EXIT_FAILURE); } else { if(verbose_flag){ char *db_info =GeoIP_database_info(gi); unsigned char db_edition = GeoIP_database_edition(gi); GeoIPDBTypes geodbtype = (GeoIPDBTypes)db_info; fprintf(stderr,"Maxmind database: %i; version: %i\n", db_edition, geodbtype); } } } if(params[HTTP_STATUS_FILTER]){ init_http_status(filters, http_status_input, comma_delimiter); } else { http_status_input = NULL; } if (verbose_flag){ fprintf(stderr, "num_path_filters:%d\tnum_domain_filters:%d" "\tnum_http_status_filters:%d\tip_address_count:%d" "\tcountries_count:%d\treferer_count:%d\n", num_path_filters, num_domain_filters, num_http_status_filters, num_ipaddress_filters, num_countries_filters, num_referer_filters); } // Now that we have initilaized all the filters, // do the actual filtering and conversion of the // incoming data. while ( true ) { int found =0; area = NULL; char *r; r=fgets(line, LINE_BUF_SIZE, stdin); if(!r) { break; } i = 0; char *p; do { fields[i] = r; //strsep(&r, ws_delimiter); p = strchr( r, *ws_delimiter ); i++; if ( NULL == p ) break; *p = 0; r = p + 1; } while (i < MAX_FIELD_CNT); if (i < minimum_field_count || i == MAX_FIELD_CNT){ continue; // ignore line since field count is outside expected range } // we found i fields in this line. field_count_this_line = i; ipaddr = fields[4]; http_status = fields[5]; url = fields[8]; referer = fields[11]; //ua = fields[13]; // necessary for bot detection if (url != NULL) { if (params[DOMAIN_FILTER]){ found += match_domain(url, filters, num_domain_filters,verbose_flag); } if (params[PATH_FILTER]){ found += match_path(url, filters, num_path_filters,verbose_flag); } if (params[HTTP_STATUS_FILTER]){ found += match_http_status(http_status, filters, num_http_status_filters,verbose_flag); } if (params[IP_FILTER]){ found += match_ip_address(ipaddr, filters, num_ipaddress_filters,verbose_flag); } if (params[REFERER_FILTER]){ found += match_domain(referer, filters, num_referer_filters,verbose_flag); } if (params[GEO_FILTER]){ area = geo_lookup(gi, ipaddr, bird_int); found += geo_check(area, countries, num_countries_filters,verbose_flag); if (verbose_flag){ fprintf(stderr, "IP address: %s was geocoded as: %s\n", ipaddr, area); } } } // required_hits will equal the number of filters // given. These include ip, domain, path, status, // and country filtering. If no filters were given, // then found will be 0 AND require_hits will be 0, // allowing the line to pass through. if (found >= required_hits) { // if we need to replace the IP addr // because recode is GEO or ANONYMIZE or both if (recode) { // geocode if we haven't already geocoded and // we'll be needing the geocoded string when // replacing the IP. if (area == NULL && (recode & GEO)) { area = geo_lookup(gi, ipaddr, bird_int); } // replace the ip address in fields. // if area is not null, it will be appended // to the ip address. If (recode & ANONYMIZE) is // true, then the IP will be replaced. replace_ip_addr(fields, area, (recode & ANONYMIZE)); } // print output to stdout for (i=0;i<field_count_this_line;++i){ if (i!=0){ FPUTS(ws_delimiter, stdout); } FPUTS(fields[i], stdout); } } if (verbose_flag) { fprintf(stderr, "ipaddr: '%s', url: '%s, status: %s'\n", ipaddr, url, http_status); } } free_memory(filters, path_input, domain_input,num_filters, gi, countries, num_countries_filters); }
int main(int argc, char** argv) { int ch; boolean priority_mode = TRUE; boolean test_mode = FALSE; boolean disable_partial_commit = FALSE; boolean full_commit_check = FALSE; boolean break_priority = FALSE; int break_priority_node = -1; boolean disable_hook = FALSE; char *commit_comment = NULL; /* this is needed before calling certain glib functions */ g_type_init(); //grab inputs while ((ch = getopt(argc, argv, "xdpthsecoafb:rlC:")) != -1) { switch (ch) { case 'x': g_old_print_output = TRUE; break; case 'd': g_debug = TRUE; break; case 'h': usage(); exit(0); break; case 'p': priority_mode = FALSE; break; case 't': test_mode = TRUE; break; case 's': g_dump_trans = TRUE; break; case 'e': g_display_error_node = TRUE; break; case 'c': g_coverage = TRUE; break; case 'o': disable_partial_commit = TRUE; break; case 'a': g_dump_actions = TRUE; break; case 'f': full_commit_check = TRUE; break; case 'b': break_priority_node = strtoul(optarg,NULL,10); break_priority = TRUE; break; case 'r': disable_hook = TRUE; break; case 'C': commit_comment = strdup(optarg); break; case 'l': release_config_lock(); break; default: usage(); exit(0); } } //can also be set via environment variable if (getenv("VYATTA_OUTPUT_ERROR_LOCATION") != NULL) { g_print_error_location_all = TRUE; } if (disable_hook == FALSE) { execute_hook(PRE_COMMIT_HOOK_DIR,commit_comment); } initialize_output("Commit"); init_paths(TRUE); d_dplog("commit2: starting up"); if (get_config_lock() != 0) { fprintf(out_stream, "Configuration system temporarily locked " "due to another commit in progress\n"); exit(1); } //get local session data plus configuration data GNode *config_data = common_get_local_session_data(); if (g_node_n_children(config_data) == 0) { common_commit_clean_temp_config(NULL, test_mode); fprintf(out_stream, "No configuration changes to commit\n"); return 0; } GNode *orig_node_tree = g_node_copy(config_data); // Get collection of transactions, i.e. trans nodes that have been activated. GNode *trans_coll = get_transactions(config_data, priority_mode); if (trans_coll == NULL) { printf("commit2: transactions collection is empty, exiting\n"); exit(0); } if (g_debug == TRUE || g_dump_trans == TRUE) { if (g_dump_trans == TRUE) { fprintf(out_stream,"Dumping transactions\n"); syslog(LOG_DEBUG,"Dumping transactions"); } //iterate over config_data and dump... g_node_traverse(trans_coll, G_PRE_ORDER, G_TRAVERSE_ALL, -1, (GNodeTraverseFunc)dump_func, (gpointer)NULL); if (g_dump_trans == TRUE) { exit(0); } } set_in_commit(TRUE); GNode *trans_child_node = (GNode*)g_node_first_child(trans_coll); if (trans_child_node == NULL) { printf("commit2: No child nodes to process, exiting\n"); exit(0); } //open the changes file and clear FILE *fp_changes = fopen(COMMIT_CHANGES_FILE,"w"); if (fp_changes == NULL) { cond_plog(true, LOG_ERR, "commit2: Cannot access changes file, exiting"); exit(0); } GSList *completed_root_node_coll = NULL; GSList *nodes_visited_coll = NULL; int errors = 0; int i = 0; do { boolean success = FALSE; d_dplog("commit2: Starting new transaction processing pass on root: [%s]", ((trans_child_node && trans_child_node->data && ((struct VyattaNode*)(trans_child_node->data))->_data._name) ? ((struct VyattaNode*)(trans_child_node->data))->_data._name : "")); if (break_priority) { gpointer gp = ((GNode*)trans_child_node)->data; long p = (long) ((struct VyattaNode*)gp)->_config._priority; if (p >= break_priority_node) { g_dump_trans = TRUE; g_node_traverse(trans_child_node, G_PRE_ORDER, G_TRAVERSE_ALL, -1, (GNodeTraverseFunc)dump_func, (gpointer)NULL); g_dump_trans = FALSE; fprintf(out_stream,"Press any key to commit...\n"); // Wait for single character char input = getchar(); input = input; //to fix stupid compilier warning } } //complete() now requires a undisturbed copy of the trans_child_node tree GNode *comp_cp_node = g_node_copy(trans_child_node); if (g_dump_actions == TRUE) { fprintf(out_stream,"\n"); //add an extra line here } //on each priority node now execute actions nodes_visited_coll = NULL; if (validate_configuration(trans_child_node, full_commit_check, &nodes_visited_coll) == TRUE && (success = process_priority_node(trans_child_node)) == TRUE) { //this below copies the node directory from the local to active location //if this is true root skip if (trans_child_node != NULL && trans_child_node->data != NULL && strcmp(((struct VyattaNode*)(trans_child_node->data)) ->_data._path, "/") == 0) { //no op, need better way to define true root } else { if (disable_partial_commit == FALSE && g_dump_actions == FALSE) { completed_root_node_coll = g_slist_append(completed_root_node_coll, comp_cp_node); } } } if (g_dump_actions == TRUE) { success = TRUE; //FORCE SUCCESS ON DISPLAY MODE OF ACTIONS } if (success == FALSE) { errors |= 1; d_dplog("commit2: Failed in processing node"); } else { errors |= 2; } //now update the changes file update_change_file(fp_changes,nodes_visited_coll); fflush(fp_changes); ++i; } while ((trans_child_node = (GNode*) g_node_nth_child((GNode*) trans_coll, (guint) i)) != NULL); if (errors == 2) { /* * Need to add to the following func below to clean up dangling .wh. files */ if (g_dump_actions == FALSE) { common_commit_copy_to_live_config(orig_node_tree, TRUE, test_mode); common_commit_clean_temp_config(orig_node_tree, test_mode); } d_dplog("commit2: successful commit, now cleaning up temp directories"); } else { fprintf(out_stream,"Commit failed\n"); complete(completed_root_node_coll, test_mode); } set_in_commit(FALSE); d_dplog("DONE"); if (fp_changes != NULL) { fclose(fp_changes); } restore_output(); if (disable_hook == FALSE) { if (errors == 2) { setenv(ENV_COMMIT_STATUS,"SUCCESS",1); } else if (errors == 3) { setenv(ENV_COMMIT_STATUS,"PARTIAL",1); } else { setenv(ENV_COMMIT_STATUS,"FAILURE",1); } execute_hook(POST_COMMIT_HOOK_DIR,commit_comment); unsetenv(ENV_COMMIT_STATUS); } //remove tmp changes file as all the work is now done unlink(COMMIT_CHANGES_FILE); exit (errors == 2 ? 0 : 1); }