]> git.sesse.net Git - betaftpd/blobdiff - ftpd.h
Fixed a security problem where the custom snprintf() would always be used. Thanks...
[betaftpd] / ftpd.h
diff --git a/ftpd.h b/ftpd.h
index 02ae127e3788146839ae3f26792edf53737e6d45..3d11bea8841e6554fdf66004c81ec5356fda1341 100644 (file)
--- a/ftpd.h
+++ b/ftpd.h
@@ -2,7 +2,7 @@
     Copyright (C) 1999-2000 Steinar H. Gunderson
 
     This program is is free software; you can redistribute it and/or modify
-    it under the terms of the GNU General Public License, version 2 if the
+    it under the terms of the GNU General Public License, version 2 of the
     License as published by the Free Software Foundation.
 
     This program is distributed in the hope that it will be useful,
     Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 */
 
+#ifndef _FTPD_H
+#define _FTPD_H 1
+
 /*
- * This is the port you want BetaFTPD to listen on. The standard
- * FTP port is 21 -- if you really want to use BetaFTPD as your
- * primary FTP server, change FTP_PORT.
+ * This is the port you want BetaFTPD to listen on.
  */
 #if WANT_NONROOT
 #define FTP_PORT 12121
  */
 #define MAX_BLOCK_SIZE 4096
 
+#if HAVE_PWD_H
+#include <pwd.h>
+#endif
+
+#if HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+
+#if HAVE_NETINET_IN_H
+#include <netinet/in.h>
+#endif
+
+#if HAVE_SYS_SOCKET_H
+#include <sys/socket.h>
+#endif
+
 #if HAVE_LINUX_SENDFILE && !HAVE_MMAP
 #warning sendfile() without mmap() is not supported -- disabling sendfile()
 #undef HAVE_LINUX_SENDFILE
@@ -59,6 +76,8 @@
 #undef WANT_DCACHE
 #endif
 
+extern char message_buf[];
+
 struct list_options {
        int recursive;
        int long_listing;
@@ -98,6 +117,8 @@ struct conn {
        char username[17];
 
        uid_t uid;
+       gid_t gid;
+
        char root_dir[256];
        char curr_dir[256];
 
@@ -109,27 +130,9 @@ struct conn {
 #endif
 
        time_t last_transfer;
+       int free_me;
 };
 
-#if WANT_DCACHE
-/* doubly linked list of cached directory listings */
-struct dcache {
-       struct dcache *prev_dcache;
-       struct dcache *next_dcache;
-
-       int use_count;
-       time_t last_used;
-       time_t generated;
-
-       char dir_name[256];
-       char pattern[256];
-       struct list_options lo;
-
-       char *dir_data;
-       int dir_size;
-};
-#endif
-
 /* doubly linked list of file transfers */
 struct ftran {
        struct ftran *prev_ftran;
@@ -177,18 +180,14 @@ void remove_from_linked_list(struct list_element * const elem);
 
 struct conn *alloc_new_conn(const int sock);
 struct ftran *alloc_new_ftran(const int sock, const struct conn * const c);
-#if WANT_DCACHE
-struct dcache *alloc_new_dcache();
-#endif
 
 int add_fd(const int fd, const int events);
 void del_fd(const int fd);
 
 void destroy_conn(struct conn * const c);
 void destroy_ftran(struct ftran * const f);
-#if WANT_DCACHE
-void destroy_dcache(struct dcache * const d);
-#endif
+
+void finish_transfer(struct ftran * const f);
 
 #if HAVE_POLL
 int process_all_clients(const int num_ac);
@@ -207,12 +206,10 @@ RETSIGTYPE handle_alarm(int signum);
 
 void accept_new_client(int * const server_sock);
 void time_out_sockets();
-#if WANT_DCACHE
-void time_out_dcache();
-#endif
 
 void remove_bytes(struct conn * const c, const int i);
 void numeric(struct conn * const c, const int numeric, const char * const format, ...);
+void flush_numeric(struct conn * const c);
 void init_file_transfer(struct ftran * const f);
 int create_server_socket();
 
@@ -220,8 +217,13 @@ int create_server_socket();
 void clear_bad_fds(int * const server_sock);
 #endif
 
+#if HAVE_BSD_SENDFILE || HAVE_LINUX_SENDFILE
+int mysendfile(int sock, int fd, off_t *offset, size_t count);
+#endif 
+
 #if WANT_MESSAGE
 void dump_file(struct conn * const c, const int num, const char * const filename);
 void list_readmes(struct conn * const c);
 #endif
 
+#endif