summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Griffin <aaron@archlinux.org>2007-03-19 04:49:28 +0000
committerAaron Griffin <aaron@archlinux.org>2007-03-19 04:49:28 +0000
commit22206d5beab9df816872a2f78280a4b35ecac34d (patch)
treee90bebebcbe7fa6c57c3309b324dba7d8fd3e0fb
parentbd55cf548c63958e6d4e8c15ccd5bed3972e0574 (diff)
Nagy Gabor <ngaba@petra.hos.u-szeged.hu>
* correct _alpm_rmrf usage with regard to symlinks and directories
-rw-r--r--lib/libalpm/util.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/lib/libalpm/util.c b/lib/libalpm/util.c
index be9eeb31..2b3847ad 100644
--- a/lib/libalpm/util.c
+++ b/lib/libalpm/util.c
@@ -310,21 +310,20 @@ int _alpm_rmrf(const char *path)
struct dirent *dp;
DIR *dirp;
char name[PATH_MAX];
- struct stat st;
+ struct stat st;
- if(stat(path, &st) == 0) {
- if(S_ISREG(st.st_mode)) {
+ if(lstat(path, &st) == 0) {
+ if(!S_ISDIR(st.st_mode)) {
if(!unlink(path)) {
return(0);
} else {
if(errno == ENOENT) {
return(0);
} else {
- /* not a directory */
return(1);
}
}
- } else if(S_ISDIR(st.st_mode)) {
+ } else {
if((dirp = opendir(path)) == (DIR *)-1) {
return(1);
}