summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJason Woodward2011-04-27 19:31:37 +0000
committerJason Woodward2011-04-27 19:31:37 +0000
commit9dbda58d2d6a94b03617103cafe3bd51ccb8030f (patch)
tree6d7af2496f129e1c95e077c03bec44c7e9367c01 /src
parentfde0eeea3557bd40c398fa6f7e47b1377b72bd34 (diff)
downloadslapt-get-9dbda58d2d6a94b03617103cafe3bd51ccb8030f.tar.gz
update working direction creation to account for N path depth
Diffstat (limited to 'src')
-rw-r--r--src/configuration.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/configuration.c b/src/configuration.c
index ead156d..a0b209e 100644
--- a/src/configuration.c
+++ b/src/configuration.c
@@ -143,21 +143,24 @@ void slapt_working_dir_init(const slapt_rc_config *global_config)
{
DIR *working_dir;
int mode = W_OK;
+ char *cwd = NULL;
if ( (working_dir = opendir(global_config->working_dir)) == NULL ) {
- if ( mkdir(global_config->working_dir,
- S_IRUSR|S_IWUSR|S_IXUSR|S_IRGRP|S_IXGRP|S_IROTH|S_IXOTH) == -1
- ) {
- printf(gettext("Failed to build working directory [%s]\n"),
- global_config->working_dir);
-
- if ( errno )
- perror(global_config->working_dir);
+ cwd = getcwd (NULL, 0);
+ if (cwd != NULL) {
+ chdir ("/");
+ slapt_create_dir_structure (global_config->working_dir);
+ chdir (cwd);
+ free (cwd);
+ } else {
+ printf (gettext ("Failed to build working directory [%s]\n"),
+ global_config->working_dir);
+ exit (EXIT_FAILURE);
- exit(EXIT_FAILURE);
}
}
- closedir(working_dir);
+ if (working_dir != NULL)
+ closedir(working_dir);
/* allow read access if we are simulating */
if (global_config->simulate)