aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Woodward2008-11-23 20:31:33 +0000
committerJason Woodward2008-11-23 20:31:33 +0000
commit8d31622d3a7d3d6dc6fd109756baf56b56a7c799 (patch)
treedd1f7d1e34efdf93e94131fa4d39b286c1e91ffb
parentd1724dbc6d0b321a218d21d8f538b6a3545eb538 (diff)
downloadslapt-get-8d31622d3a7d3d6dc6fd109756baf56b56a7c799.tar.gz
check return value from chdir
-rw-r--r--src/main.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/main.c b/src/main.c
index cb56967..48927be 100644
--- a/src/main.c
+++ b/src/main.c
@@ -282,7 +282,10 @@ int main( int argc, char *argv[] )
/* create the working directory if needed */
slapt_working_dir_init(global_config);
- chdir(global_config->working_dir);
+ if ((chdir(global_config->working_dir)) == -1) {
+ fprintf(stderr,gettext("Failed to chdir: %s\n"),global_config->working_dir);
+ exit(EXIT_FAILURE);
+ }
switch(do_action) {
case UPDATE:
@@ -372,7 +375,10 @@ int main( int argc, char *argv[] )
case CLEAN:
/* clean out local cache */
slapt_clean_pkg_dir(global_config->working_dir);
- chdir(global_config->working_dir);
+ if ((chdir(global_config->working_dir)) == -1) {
+ fprintf(stderr,gettext("Failed to chdir: %s\n"),global_config->working_dir);
+ exit(EXIT_FAILURE);
+ }
break;
case AUTOCLEAN:
slapt_purge_old_cached_pkgs(global_config, NULL, NULL);