]> git.sesse.net Git - betaftpd/blobdiff - cmds.c
Contact section changes: Changed homepage URL, added some information about the new...
[betaftpd] / cmds.c
diff --git a/cmds.c b/cmds.c
index 0af47825ef0aaadc3e153aae4db930209ba2c055..3af02a354c25f39f893b21b5d9b568a0154a77f5 100644 (file)
--- a/cmds.c
+++ b/cmds.c
@@ -936,11 +936,19 @@ int cmd_stat(struct conn * const c)
                            "     BetaFTPD version " VERSION " (http://members.xoom.com/sneeze/betaftpd.html)\r\n"
                            "     Connected to %s\r\n"
                            "     Control connection state: %s\r\n"
+#if WANT_ASCII
+                           "     TYPE: %s; STRUcture: File; transfer MODE: Stream\r\n"
+#else
                            "     TYPE: Image; STRUcture: File; transfer MODE: Stream\r\n"
+#endif
                            "     Data connection state: %s\r\n"
                            "211 End of status\r\n",
                                inet_ntoa(((struct sockaddr_in *)(&(c->addr)))->sin_addr),
-                               conn_state[c->auth], (f) ? ftran_state[f->state] : ftran_state[0]);
+                               conn_state[c->auth],
+#if WANT_ASCII
+                               (c->ascii_mode == 1) ? "ASCII, FORM: Nonprint" : "Image",
+#endif
+                               (f) ? ftran_state[f->state] : ftran_state[0]);
 
        i = strlen(buf);
 
@@ -1044,7 +1052,7 @@ int long_listing(char * const retbuf, const char * const pathname, const int do_
 #if WANT_NONROOT
                char rights[16];
 
-               if (nr_check_permission(0, pathname, 0, (buf.st_mode & S_IFDIR), rights) == -1) {
+               if (nr_check_permission(0, pathname, 0, (S_ISDIR(buf.st_mode)), rights) == -1) {
                        /* no permission to even see this file */
                        return 0;
                }
@@ -1656,13 +1664,13 @@ void prepare_for_transfer(struct ftran *f)
  *             The most common cases are put first, for speed :-)
  */
 char decode_mode(mode_t mode) {
-       if (mode & S_IFREG)  return '-';
-       if (mode & S_IFDIR)  return 'd';
-       if (mode & S_IFLNK)  return 'l';
-       if (mode & S_IFBLK)  return 'b';
-       if (mode & S_IFCHR)  return 'c';
-       if (mode & S_IFSOCK) return 's';
-       if (mode & S_IFIFO)  return 'f';
+       if (S_ISREG(mode))  return '-';
+       if (S_ISDIR(mode))  return 'd';
+       if (S_ISLNK(mode))  return 'l';
+       if (S_ISBLK(mode))  return 'b';
+       if (S_ISCHR(mode))  return 'c';
+       if (S_ISSOCK(mode)) return 's';
+       if (S_ISFIFO(mode))  return 'f';
 
        return '-';
 }
@@ -1737,9 +1745,9 @@ int do_openfile(struct conn * const c, char * const path,
 #if WANT_UPLOAD
        if ((flags & O_CREAT) == 0) {
 #endif
-               stat(ptr, &buf);
+               TRAP_ERROR(stat(ptr, &buf) == -1, 550, return -2);
                if (!S_ISREG(buf.st_mode)) {
-                       numeric(c, 550, "%s: Not a plain file.", ptr);
+                       numeric(c, 550, "Not a plain file.", ptr);
                        return -2;
                }
 #if WANT_UPLOAD