]> git.sesse.net Git - betaftpd/blobdiff - cmds.c
Fixed the ls -R' seems to ignore its argument.
[betaftpd] / cmds.c
diff --git a/cmds.c b/cmds.c
index 629d11411156082cea5cad865e077f1ab67ed906..9e1edcaa80827177bb1aade3446fe9c013390dd7 100644 (file)
--- a/cmds.c
+++ b/cmds.c
@@ -1856,7 +1856,16 @@ int prepare_for_listing(struct conn * const c, char ** const ptr,
        }
 
        /* if no argument, choose all files */
-       if (fptr == NULL || fptr[0] == 0) fptr = "*";
+       if (fptr == NULL || fptr[0] == 0) {
+               fptr = "*";
+       } else {
+               /* we need to check if the last part is a directory (no -d switch) */
+               struct stat buf;
+               if (stat(fptr, &buf) == 0 && S_ISDIR(buf.st_mode)) {
+                       TRAP_ERROR(chdir(fptr) == -1, 550, return -1);
+                       fptr = "*";
+               }
+       }
        *ptr = fptr;
 
 #if WANT_NONROOT