Committer: Diego Biurrun <diego@xxxxxxxxxx> Date: 22/05/2010 at 20:35:13 Revision: 4573 Revision-id: diego@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx Branch nick: trunk Log: Clean up system configuration directory definitions. Introduce more suitable names for the directory creation mask definition and move it to a sensible place in the codebase. Modified: M firewall/firewall.c M firewall/rule_management.c M hipd/hipd.c M hipd/init.c M lib/core/crypto.h M lib/core/filemanip.h M lib/core/hostid.c M test/dh_performance.c === modified file 'firewall/firewall.c' --- firewall/firewall.c 2010-05-22 12:40:19 +0000 +++ firewall/firewall.c 2010-05-22 17:33:20 +0000 @@ -2113,7 +2113,7 @@ HIP_DEBUG("Creating perf set\n"); perf_set = hip_perf_create(PERF_MAX_FIREWALL); - check_and_create_dir("results", DEFAULT_CONFIG_DIR_MODE); + check_and_create_dir("results", HIP_DIR_MODE); /* To keep things simple, we use a subset of the performance set originally * created for the HIP daemon. */ === modified file 'firewall/rule_management.c' --- firewall/rule_management.c 2010-05-22 12:40:19 +0000 +++ firewall/rule_management.c 2010-05-22 17:33:20 +0000 @@ -105,10 +105,10 @@ /* Firewall depends on hipd to create /etc/hip */ for (i = 0; i < 5; i++) { - if (stat(DEFAULT_CONFIG_DIR, &status) && + if (stat(HIPL_SYSCONFDIR, &status) && errno == ENOENT) { HIP_INFO("%s does not exist. Waiting for hipd to start...\n", - DEFAULT_CONFIG_DIR); + HIPL_SYSCONFDIR); sleep(2); } else { break; === modified file 'hipd/hipd.c' --- hipd/hipd.c 2010-05-22 12:37:40 +0000 +++ hipd/hipd.c 2010-05-22 17:33:20 +0000 @@ -266,7 +266,7 @@ HIP_DEBUG("Creating perf set\n"); perf_set = hip_perf_create(PERF_MAX); - check_and_create_dir("results", DEFAULT_CONFIG_DIR_MODE); + check_and_create_dir("results", HIP_DIR_MODE); hip_perf_set_name(perf_set, PERF_STARTUP, "results/PERF_STARTUP.csv"); hip_perf_set_name(perf_set, PERF_I1_SEND, "results/PERF_I1_SEND.csv"); === modified file 'hipd/init.c' --- hipd/init.c 2010-05-22 12:37:40 +0000 +++ hipd/init.c 2010-05-22 17:33:20 +0000 @@ -443,11 +443,11 @@ /* Create default keys if necessary. */ - if (stat(DEFAULT_CONFIG_DIR "/" DEFAULT_HOST_RSA_KEY_FILE_BASE DEFAULT_PUB_HI_FILE_NAME_SUFFIX, &status) && errno == ENOENT) { + if (stat(HIPL_SYSCONFDIR "/" DEFAULT_HOST_RSA_KEY_FILE_BASE DEFAULT_PUB_HI_FILE_NAME_SUFFIX, &status) && errno == ENOENT) { HIP_IFEL(hip_serialize_host_id_action(user_msg, ACTION_NEW, 0, 1, NULL, NULL, RSA_KEY_DEFAULT_BITS, DSA_KEY_DEFAULT_BITS), - 1, "Failed to create keys to %s\n", DEFAULT_CONFIG_DIR); + 1, "Failed to create keys to %s\n", HIPL_SYSCONFDIR); } /* Retrieve the keys to hipd */ === modified file 'lib/core/crypto.h' --- lib/core/crypto.h 2010-05-17 16:55:10 +0000 +++ lib/core/crypto.h 2010-05-22 17:33:20 +0000 @@ -57,9 +57,6 @@ #define DSA_KEY_DEFAULT_BITS 1024 #define RSA_KEY_DEFAULT_BITS 1024 -#define DEFAULT_CONFIG_DIR HIPL_SYSCONFDIR - -#define DEFAULT_CONFIG_DIR_MODE 0755 #define DEFAULT_HOST_DSA_KEY_FILE_BASE "hip_host_dsa_key" #define DEFAULT_HOST_RSA_KEY_FILE_BASE "hip_host_rsa_key" #define DEFAULT_PUB_FILE_SUFFIX ".pub" === modified file 'lib/core/filemanip.h' --- lib/core/filemanip.h 2010-05-22 17:20:42 +0000 +++ lib/core/filemanip.h 2010-05-22 17:33:20 +0000 @@ -10,8 +10,8 @@ #include <fcntl.h> #include <sys/types.h> -#define HIP_CREATE_FILE(x) open((x), O_RDWR | O_CREAT, 0644) - +#define HIP_CREATE_FILE(x) open((x), O_RDWR | O_CREAT, 0644) +#define HIP_DIR_MODE 0755 #define HIP_DEFAULT_EXEC_PATH "/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/sbin:/usr/local/bin" int hip_create_lock_file(const char *filename, int killold); === modified file 'lib/core/hostid.c' --- lib/core/hostid.c 2010-05-22 12:37:40 +0000 +++ lib/core/hostid.c 2010-05-22 17:33:20 +0000 @@ -578,7 +578,7 @@ * adding is called separately for DSA, RSA anon and RSA pub */ if (hi_fmt == NULL || !strcmp(hi_fmt, "dsa")) { dsa_filenamebase_len = - strlen(DEFAULT_CONFIG_DIR) + strlen("/") + + strlen(HIPL_SYSCONFDIR) + strlen("/") + strlen(DEFAULT_HOST_DSA_KEY_FILE_BASE) + 1; dsa_filenamebase = malloc(HOST_ID_FILENAME_MAX_LEN); HIP_IFEL(!dsa_filenamebase, -ENOMEM, @@ -588,7 +588,7 @@ dsa_filenamebase_len + strlen(DEFAULT_ANON_HI_FILE_NAME_SUFFIX), "%s/%s%s", - DEFAULT_CONFIG_DIR, + HIPL_SYSCONFDIR, DEFAULT_HOST_DSA_KEY_FILE_BASE, DEFAULT_ANON_HI_FILE_NAME_SUFFIX); @@ -600,7 +600,7 @@ ret = snprintf(dsa_filenamebase_pub, HOST_ID_FILENAME_MAX_LEN, "%s/%s%s", - DEFAULT_CONFIG_DIR, + HIPL_SYSCONFDIR, DEFAULT_HOST_DSA_KEY_FILE_BASE, DEFAULT_PUB_HI_FILE_NAME_SUFFIX); @@ -614,7 +614,7 @@ if (hi_fmt == NULL || !strcmp(hi_fmt, "rsa")) { rsa_filenamebase_len = - strlen(DEFAULT_CONFIG_DIR) + strlen("/") + + strlen(HIPL_SYSCONFDIR) + strlen("/") + strlen(DEFAULT_HOST_RSA_KEY_FILE_BASE) + 1; if (anon || hi_fmt == NULL) { @@ -626,7 +626,7 @@ ret = snprintf( rsa_filenamebase, HOST_ID_FILENAME_MAX_LEN, "%s/%s%s", - DEFAULT_CONFIG_DIR, + HIPL_SYSCONFDIR, DEFAULT_HOST_RSA_KEY_FILE_BASE, DEFAULT_ANON_HI_FILE_NAME_SUFFIX); @@ -647,7 +647,7 @@ rsa_filenamebase_pub, rsa_filenamebase_len + strlen(DEFAULT_PUB_HI_FILE_NAME_SUFFIX), - "%s/%s%s", DEFAULT_CONFIG_DIR, + "%s/%s%s", HIPL_SYSCONFDIR, DEFAULT_HOST_RSA_KEY_FILE_BASE, DEFAULT_PUB_HI_FILE_NAME_SUFFIX); @@ -663,8 +663,8 @@ case ACTION_NEW: /* Default directory is created only in "hipconf new default hi" */ if (use_default) { - if ((err = check_and_create_dir(DEFAULT_CONFIG_DIR, - DEFAULT_CONFIG_DIR_MODE))) { + if ((err = check_and_create_dir(HIPL_SYSCONFDIR, + HIP_DIR_MODE))) { HIP_ERROR("Could not create default directory.\n"); goto out_err; } === modified file 'test/dh_performance.c' --- test/dh_performance.c 2010-05-18 19:46:13 +0000 +++ test/dh_performance.c 2010-05-22 17:33:20 +0000 @@ -370,7 +370,7 @@ if (sw_file_output) { perfset = hip_perf_create(PS_MAX); - check_and_create_dir("results", DEFAULT_CONFIG_DIR_MODE); + check_and_create_dir("results", HIP_DIR_MODE); hip_perf_set_name(perfset, PS_DH_CREATE, "PS_DH_CREATE.csv"); hip_perf_set_name(perfset, PS_DH_SHARE, "PS_DH_SHARE.csv");