diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2005-06-14 23:55:24 +0000 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2005-06-14 23:55:24 +0000 |
commit | 3f47e8458ac87c5af5a32001177c1b153a16a8bc (patch) | |
tree | 313d6781dbbcc3f4afe6789326fd7b8260e3bc55 | |
parent | d203fc19aed3486cd594cffa58175a4f0abf79d3 (diff) | |
download | coreutils-3f47e8458ac87c5af5a32001177c1b153a16a8bc.tar.xz |
(main): Standardize on a diagnostic for
restore_cwd failure, and report errno.
(install_file_in_file_parents): Fail if restore_cwd fails and
one of the files is relative. This fixes a bug (albeit unlikely).
-rw-r--r-- | src/install.c | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/src/install.c b/src/install.c index 5567f1f65..0fa08a25b 100644 --- a/src/install.c +++ b/src/install.c @@ -357,23 +357,19 @@ main (int argc, char **argv) if (dir_arg) { int i; - bool cwd_not_restored = false; + int cwd_errno = 0; for (i = 0; i < n_files; i++) { - if (cwd_not_restored && IS_RELATIVE_FILE_NAME (argv[optind])) + if (cwd_errno != 0 && IS_RELATIVE_FILE_NAME (argv[optind])) { - error (0, 0, - _("unable to create relative-named directory, %s," - " due to prior failure to return to working directory"), - quote (argv[optind])); - ok = false;; - continue; + error (0, cwd_errno, _("cannot return to working directory")); + ok = false; } - - ok &= - make_dir_parents (file[i], mode, mode, owner_id, group_id, false, - (x.verbose ? _("creating directory %s") : NULL), - &cwd_not_restored); + else + ok &= + make_dir_parents (file[i], mode, mode, owner_id, group_id, false, + (x.verbose ? _("creating directory %s") : NULL), + &cwd_errno); } } else @@ -421,12 +417,17 @@ install_file_in_file_parents (char const *from, char const *to, that this option is intended mainly to help installers when the distribution doesn't provide proper install rules. */ mode_t dir_mode = S_IRWXU | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH; - bool different_cwd; + int cwd_errno = 0; ok = make_dir_parents (dest_dir, dir_mode, dir_mode, owner_id, group_id, true, (x->verbose ? _("creating directory %s") : NULL), - &different_cwd); - /* Ignore different_cwd, since this function is called at most once. */ + &cwd_errno); + if (ok && cwd_errno != 0 + && (IS_RELATIVE_FILE_NAME (from) || IS_RELATIVE_FILE_NAME (to))) + { + error (0, cwd_errno, _("cannot return to current directory")); + ok = false; + } } free (dest_dir); |