* libmisc/copydir.c: Added warning for relative symlinks.

* libmisc/copydir.c (remove_tree): There is no need to check if
	the root argument exist. opendir() will report this.
This commit is contained in:
nekral-guest 2009-05-22 10:16:12 +00:00
parent 8dfd253b9c
commit 738ebc04b9
2 changed files with 8 additions and 9 deletions

View File

@ -1,3 +1,9 @@
2009-05-21 Nicolas François <nicolas.francois@centraliens.net>
* libmisc/copydir.c: Added warning for relative symlinks.
* libmisc/copydir.c (remove_tree): There is no need to check if
the root argument exist. opendir() will report this.
2009-05-21 Nicolas François <nicolas.francois@centraliens.net> 2009-05-21 Nicolas François <nicolas.francois@centraliens.net>
* man/faillog.8.xml: Minor updates. * man/faillog.8.xml: Minor updates.

View File

@ -494,6 +494,7 @@ static int copy_symlink (const char *src, const char *dst,
/* If src was a link to an entry of the src_orig directory itself, /* If src was a link to an entry of the src_orig directory itself,
* create a link to the corresponding entry in the dst_orig * create a link to the corresponding entry in the dst_orig
* directory. * directory.
* FIXME: This may change a relative link to an absolute link
*/ */
if (strncmp (oldlink, src_orig, strlen (src_orig)) == 0) { if (strncmp (oldlink, src_orig, strlen (src_orig)) == 0) {
size_t len = strlen (dst_orig) + strlen (oldlink) - strlen (src_orig) + 1; size_t len = strlen (dst_orig) + strlen (oldlink) - strlen (src_orig) + 1;
@ -546,7 +547,7 @@ static int copy_hardlink (const char *src, const char *dst,
return -1; return -1;
} }
/* FIXME: why is it unlinked? This is a copy, not a move*/ /* FIXME: why is it unlinked? This is a copy, not a move */
if (unlink (src) != 0) { if (unlink (src) != 0) {
return -1; return -1;
} }
@ -674,14 +675,6 @@ int remove_tree (const char *root)
struct stat sb; struct stat sb;
DIR *dir; DIR *dir;
/*
* Make certain the directory exists.
*/
if (access (root, F_OK) != 0) {
return -1;
}
/* /*
* Open the source directory and read each entry. Every file * Open the source directory and read each entry. Every file
* entry in the directory is copied with the UID and GID set * entry in the directory is copied with the UID and GID set