From f8849e658f253e409fb28752739ab0d398f41e7c Mon Sep 17 00:00:00 2001 From: hsn <> Date: Tue, 26 Oct 2004 16:24:37 +0000 Subject: [PATCH] *** empty log message *** --- BETA.README | 4 ++-- ChangeLog | 9 +++++++++ MACHINES | 2 +- TODO | 6 +++--- client/lib.c | 2 +- client/util.c | 6 ++++-- common/udp_io.c | 19 +++++++++++-------- configure.ac | 2 ++ fspd.conf | 16 +++++++++++----- include/c_extern.h | 2 +- include/co_extern.h | 2 +- include/s_extern.h | 1 + man/fsp_env.7 | 14 ++++++++++---- server/Makefile.am | 2 +- server/conf.c | 9 +++++++++ server/file.c | 7 +++++++ server/main.c | 33 +++++++++++++++++++++++++++++++-- server/server.c | 5 ++++- 18 files changed, 109 insertions(+), 32 deletions(-) diff --git a/BETA.README b/BETA.README index 5db5adf..c1448f5 100644 --- a/BETA.README +++ b/BETA.README @@ -16,14 +16,14 @@ FSP Development Battle plan: with older software versions. - security: symlink to FILE can escape from FSP root directory. - fix Sven's Slowaris 8 compile problem -- local bind address FSP_LOCALIP for clients -- bind-ip-address for server - normalize return error codes of all clients - server can be run multiple times on the same port, how to check? on freebsd this works okay. needs re-testing on linux. - fspd: add special defence against rapid/double fire clients (burst command in fspclient) * for next point Stable version 2.8.3 +- retune alg. for links with high packet loss +- hard coded access list, do not load it from filesystem - add FSP change password command - add FSP command for changing owners - add FSP command for listing directory owners diff --git a/ChangeLog b/ChangeLog index fe71d4e..44310ad 100644 --- a/ChangeLog +++ b/ChangeLog @@ -45,6 +45,15 @@ Version - not yet released client: use random starting seq. number - better for avoiding seq. number clash with another client fixed compiler warning on BB_READ4(const char *); + PROTOCOL: Added more information about directory blocks + Add pidfile.h to distribution + default FSP_DIR to / if not set + improved Sven's fsp-faq.sgml + Added local bind port support for server + added FSP_LOCALIP env variable for clients + --enable-lamerpack == build specialy tuned fspd for lamers + lamerz guide added + text rotate tool added Version 2.8.1b19 - 11 Jan 2004 sven has added fspget URL command to setup.sh. diff --git a/MACHINES b/MACHINES index f5e7931..2f22906 100644 --- a/MACHINES +++ b/MACHINES @@ -15,4 +15,4 @@ FSP Version CPU OS Compiler C library 2.8.1 Beta 14 i386 RedHat 7.3 2.8.1 Beta 14 i386 Conectiva Linux 9 2.8.1 Beta 19 i386 FreeBSD 5.2 gcc-3.3 -2.8.1 Beta 19 i386 FreeBSD 5.3 gcc-3.4 +2.8.1 Beta 20 i386 FreeBSD 5.3 gcc-3.4 diff --git a/TODO b/TODO index 4095d67..96eac56 100644 --- a/TODO +++ b/TODO @@ -17,7 +17,9 @@ SECURITY BUGS: symlink to FILE can escape from FSP root directory. OLD known problem. PROTOCOL-RELATED BUGS: -none known +it is not clear how to generate directory items with type skip. append + \0 name to them or not? All known clients stops reading the directory + when sees skip item in block. PORTING Sven's Slowaris 8 compile problem @@ -27,7 +29,6 @@ NEEDS IMPROVMENT: Client LIBRARY :high: -local bind address FSP_LOCALIP we should retune retry algoritm for better support lines with higher packed loss. add more detailed stats from retry alg. @@ -58,7 +59,6 @@ FUTURE FEATURES FOR SERVER: can be run multiple times on the same port, how to check? Currently looks fine on bsd. write RENAME FSP command -bind-ip-address for server (and client via FSP_LOCAL_IP) report number of clients connected, size of hostable in new command CC_INFO command special defence against rapid/double fire clients (burst command in fspclient) diff --git a/client/lib.c b/client/lib.c index 2dd0e82..098801e 100644 --- a/client/lib.c +++ b/client/lib.c @@ -203,7 +203,7 @@ void init_client PROTO3(const char *, host, unsigned short, port, unsigned short busy_delay = idle_delay = target_delay; myseq = random(); - if((myfd = _x_udp(&myport)) == -1) { + if((myfd = _x_udp(env_listen_on,&myport)) == -1) { perror("socket open"); exit(1); } diff --git a/client/util.c b/client/util.c index d822023..f43f936 100644 --- a/client/util.c +++ b/client/util.c @@ -22,6 +22,7 @@ const char *env_myport; const char *env_host; const char *env_port; const char *env_local_dir; +const char *env_listen_on; unsigned int env_timeout; unsigned short client_buf_len; unsigned short client_net_len; @@ -434,10 +435,11 @@ static void util_get_env PROTO0((void)) exit(1); } if(!(env_dir = getenv("FSP_DIR"))) { - fputs("No FSP_DIR specified.\n",stderr); - exit(1); + env_dir = "/"; + env_dir_malloced = 0; } if(!(env_myport = getenv("FSP_LOCALPORT"))) env_myport = "0"; + if(!(env_listen_on = getenv("FSP_LOCALIP"))) env_listen_on = NULL; if(!(env_passwd = getenv("FSP_PASSWORD"))) env_passwd = "\0"; client_trace = !!getenv("FSP_TRACE"); if( (p = getenv("FSP_BUF_SIZE")) ) client_buf_len = atoi(p); diff --git a/common/udp_io.c b/common/udp_io.c index 26ea4ab..00a0a3c 100644 --- a/common/udp_io.c +++ b/common/udp_io.c @@ -26,7 +26,7 @@ #include #include -int _x_udp PROTO1(unsigned short *, port) +int _x_udp PROTO2(const char *, bindaddress, unsigned short *, port) { int f; socklen_t len; @@ -34,14 +34,16 @@ int _x_udp PROTO1(unsigned short *, port) struct sockaddr_in myadr; int zz=1; - memset(&me,0,sizeof(me)); - - me.sin_port = htons(*port); - me.sin_family = AF_INET; + if(bindaddress == NULL || _x_adr (bindaddress, *port,&me ) != 0) { + memset(&me,0,sizeof(me)); + me.sin_port = htons(*port); + me.sin_family = AF_INET; + }; len=sizeof(me); - - if((f=socket(AF_INET,SOCK_DGRAM,0)) == -1) return(-1); + f=socket(AF_INET,SOCK_DGRAM,0); + + if(f == -1) return(-1); if(setsockopt(f,SOL_SOCKET,SO_REUSEADDR,(char *)&zz,sizeof(zz)) < 0 || bind(f,(struct sockaddr *) &me,len) < 0 || @@ -67,8 +69,9 @@ int _x_adr PROTO3(const char *, host, int, port, struct sockaddr_in *, his) } /* if((his->sin_addr.s_addr = inet_addr(host)) != -1) */ - if(inet_aton(host,&his->sin_addr)) + if(inet_aton(host,&his->sin_addr)) { his->sin_family = AF_INET; + } else if( (H = gethostbyname(host))) { for(s = (char *)H->h_addr, d = (char *)&his->sin_addr, i = H->h_length; diff --git a/configure.ac b/configure.ac index 9d03314..d65116d 100644 --- a/configure.ac +++ b/configure.ac @@ -80,6 +80,8 @@ AC_CHECK_LIB(efence,EF_Abort) fi AC_MSG_CHECKING([if enable extra debug code]) AC_ARG_ENABLE(debug,[Enable client library debuging],AC_DEFINE(DEBUG,1,[Define if you want more debug messages]) AC_MSG_RESULT(YES),AC_MSG_RESULT(NO)) +AC_MSG_CHECKING([if we are building lamer pack]) +AC_ARG_ENABLE(lamerpack,[Build for lamers],AC_DEFINE(LAMERPACK,1,[Define if you want to build for lamer disbled ppl]) AC_MSG_RESULT(YES),AC_MSG_RESULT(NO)) AC_HEADER_STDC AC_CHECK_HEADERS(limits.h sys/syslimits.h errno.h) AC_CHECK_HEADERS(string.h memory.h strings.h unistd.h sys/resource.h utime.h) diff --git a/fspd.conf b/fspd.conf index c9cf9aa..6a47de1 100644 --- a/fspd.conf +++ b/fspd.conf @@ -11,11 +11,15 @@ # port 21 +# Server can listen only on particular network interface +#listenaddress 192.168.1.2 + # The 'packetsize' sets maximal data size which will send FSPD in one packet. # FSP definition allows up to 1024 bytes of data (default value) and it is a # recommended to use this value unless there is a reason to use a smaller one. -# If your fsp site eats too much bandwidth try smaller value. !!! If you -# change this value you must delete all .FSP_CONTENT files !!! +# If your fsp site eats too much bandwidth try smaller value. +# !!! If you change this value you must delete all prebuilded directory +# listings == .FSP_CONTENT files !!! # packetsize 768 # The 'conf' command allows a global file to read local files so that @@ -34,6 +38,8 @@ homedir_restricted yes # 'use_access_files' if server should check for special .FSP files # in directory and set access rights acording to that. +# In most installation, yes is right. Use `no` if people can uload +# files starting with .FSP into fsp server homedir. use_access_files yes # 'permit_passwordless_owners' If server allow directory owners without @@ -78,7 +84,7 @@ statcache 30 # The 'statcache_timeout' command controls how long statcache entries are # valid before directory gets re-examined by stat() -statcache_timeout 15 +statcache_timeout 20 # 'use_directory_mtime'. If your filesystem changes mtime when directory # is updated, set it to YES. If set to NO, directory will be rechecked @@ -89,7 +95,7 @@ statcache_timeout 15 # The 'filecache' command controls maximal number of open files by server. # After this limit will be reached, server will close last recently used files. # This do not prevent any number clients from downloading, but file for each -# request must be opened first. Setting this lower open/close overhead. +# request must be opened first. Setting this lowers open/close overhead. filecache 30 # The 'dumpfile' command tells the server where to log stats on SIGUSR1 @@ -123,7 +129,7 @@ logfile ../logs/logfile log all !readonly #The 'xferlog' command tells server where to use wuftpd compatible -#transfer log file. +#transfer log file. Thos logs currectly do not support partial transfers. xferlog ../logs/xferlog # The 'thruput' command is used to specify the maximum average diff --git a/include/c_extern.h b/include/c_extern.h index beef653..d976c1c 100644 --- a/include/c_extern.h +++ b/include/c_extern.h @@ -19,7 +19,7 @@ void client_init_key PROTO0((unsigned long, unsigned long, unsigned short)); /* util.c */ -extern const char *env_dir,*env_passwd,*env_local_dir,*env_port,*env_myport,*env_host; +extern const char *env_dir,*env_passwd,*env_local_dir,*env_port,*env_myport,*env_host,*env_listen_on; extern unsigned int env_timeout; extern unsigned short client_buf_len,client_net_len; char *util_abs_path PROTO0((const char *)); diff --git a/include/co_extern.h b/include/co_extern.h index 61d24dd..2e51647 100644 --- a/include/co_extern.h +++ b/include/co_extern.h @@ -15,7 +15,7 @@ long random PROTO0((void)); #endif /* udp_io.c */ -int _x_udp PROTO0((unsigned short *)); +int _x_udp PROTO0((const char *, unsigned short *)); int _x_adr PROTO0((const char *, int, struct sockaddr_in *)); int _x_select PROTO0((fd_set *, long)); diff --git a/include/s_extern.h b/include/s_extern.h index 27a648d..a03a35f 100644 --- a/include/s_extern.h +++ b/include/s_extern.h @@ -14,6 +14,7 @@ extern unsigned short udp_port,packetsize; extern time_t retry_timeout,session_timeout,stat_cache_timeout; extern char *logname,*tlogname,*readme_file,*dumpname; extern char *home_dir,*pidlogname; +extern char *listen_on; extern unsigned int dir_cache_limit, stat_cache_limit,fp_cache_limit; extern char *tmp_dir; extern mode_t upload_umask, system_umask; diff --git a/man/fsp_env.7 b/man/fsp_env.7 index 078e9ff..6716c68 100644 --- a/man/fsp_env.7 +++ b/man/fsp_env.7 @@ -1,4 +1,4 @@ -.TH "FSP ENVIRONMENT" 7 "Jul 2003" FSP "FSP Environment Variables" +.TH "FSP ENVIRONMENT" 7 "Oct 2004" FSP "FSP Environment Variables" .SH NAME Environment variables used by FSP Clients programs .SH SYNOPSIS @@ -8,10 +8,16 @@ setenv VARIABLE value | export VARIABLE=value The following variables are used for access FSP servers: .TP .B FSP_HOST -The name or internet number of the machine with the FSP server. +The name or internet number of the machine with the FSP server. Required. .TP .B FSP_PORT -The port number of the UDP socket used by the FSP server. +The port number of the UDP socket used by the FSP server. Required. +.TP +.B FSP_LOCALIP +Local Address of UDP socket used by FSP client utilities. This +IP address must be one of your local IP addresses. If not used, +TCP protocol stack sets the default. This variable is mainly +used for multi-homed hosts. .TP .B FSP_LOCALPORT The port number of the UDP socket used by FSP client utilities. @@ -32,7 +38,7 @@ packets from server. .TP .B FSP_DIR The current working directory of the client in the FSP server. -The root of the database is /. +The server's root is /. .TP .B FSP_TRACE If this variable is set to any value, program diff --git a/server/Makefile.am b/server/Makefile.am index 310f389..1a20185 100644 --- a/server/Makefile.am +++ b/server/Makefile.am @@ -7,4 +7,4 @@ fspd_SOURCES=file.c host.c main.c conf.c server.c fifocache.c \ fspd_CFLAGS=-DSYSCONFDIR="\"@sysconfdir@\"" $(AM_CFLAGS) fspd_LDADD=-L../common -lcommon -noinst_HEADERS=fifocache.h +noinst_HEADERS=fifocache.h pidfile.h diff --git a/server/conf.c b/server/conf.c index 8b3bad2..02a7e9c 100644 --- a/server/conf.c +++ b/server/conf.c @@ -56,6 +56,7 @@ char *pidlogname = NULL; char *dumpname = NULL; char *home_dir = NULL; char *tmp_dir = NULL; +char *listen_on = NULL; int homedir_restricted = 1; int permit_passwordless_owners = 0; char *readme_file = NULL; @@ -132,6 +133,9 @@ static void read_configuration PROTO1(const char *, name) } else if(strcasecmp(p, "readme") == 0) { if(readme_file) free(readme_file); readme_file = strdup(q); + } else if(strcasecmp(p, "ListenAddress") == 0) { + if(listen_on) free(listen_on); + listen_on = strdup(q); } else if(strcasecmp(p, "homedir") == 0) { if(home_dir) free(home_dir); home_dir = strdup(q); @@ -264,6 +268,9 @@ static void read_configuration PROTO1(const char *, name) void load_configuration PROTO1(const char *,config_file) { +#ifdef LAMERPACK + return; +#endif if(config_file == NULL) return; /* destroy_configuration(); */ @@ -287,8 +294,10 @@ void destroy_configuration PROTO0((void)) if(tmp_dir) free(tmp_dir); if(dumpname) free(dumpname); if(iptab) free_ip_table(iptab); + if(listen_on) free(listen_on); readme_file = home_dir = logname = tmp_dir = dumpname = NULL; iptab = NULL; pidlogname = NULL; + listen_on = NULL; } diff --git a/server/file.c b/server/file.c index 8b25024..abebac1 100644 --- a/server/file.c +++ b/server/file.c @@ -213,6 +213,9 @@ void stat_caches PROTO1(FILE *,fp) /* should init all types of caches in future */ void shutdown_caches PROTO0((void)) { +#ifdef LAMERPACK + fclose(stderr); +#endif fprintf(stderr,"DIRLISTCACHE "); f_cache_stats(dirlistcache,stderr); f_cache_clear(dirlistcache); @@ -1108,9 +1111,13 @@ void init_home_dir PROTO0((void)) chdir(home_dir); } +#ifndef LAMERPACK if(dbug) { +#endif fprintf(stderr,"home on %s\n",home_dir); if(tmp_dir) fprintf(stderr,"tmpdir on %s\n",tmp_dir); +#ifndef LAMERPACK } +#endif } diff --git a/server/main.c b/server/main.c index 73097de..c57f576 100644 --- a/server/main.c +++ b/server/main.c @@ -23,6 +23,7 @@ static const char *config_file = CONF_FILE ; static void display_version PROTO0((void)) { printf( +#ifndef LAMERPACK "File Service Protocol Daemon - FSP "PACKAGE_VERSION"\n" "Copyright (c) 1991-1996 by A. J. Doherty, 2001-2004 by Radim Kolar.\n" "All of the FSP code is free software with revised BSD license.\n" @@ -30,6 +31,10 @@ static void display_version PROTO0((void)) #ifdef __GNUC__ "Compiled "__DATE__" by GCC "__VERSION__"\n" #endif +#else + "FSP server "PACKAGE_VERSION"\n" + "For lamerZ by Elite!\n" +#endif ); } @@ -44,9 +49,20 @@ static void check_required_vars PROTO0((void)) { double rnd; +#ifdef LAMERPACK + inetd_mode = 0; + daemonize = 0; + dbug = 0; + dir_cache_limit = 500; +#endif + if(!inetd_mode && udp_port==0) { +#ifdef LAMERPACK + udp_port = 53; +#else fprintf(stderr, "Error: No port set. (Use 65535 for random port)\n"); exit(1); +#endif } if(udp_port == 65535) { @@ -55,8 +71,12 @@ static void check_required_vars PROTO0((void)) udp_port=rnd*(65535-1024)+1024; } if(!home_dir) { +#ifdef LAMERPACK + home_dir = strdup("/"); +#else fprintf(stderr, "Error: No home directory set.\n"); exit(1); +#endif } #if 0 if(*home_dir != '/') { @@ -82,8 +102,10 @@ static void check_required_vars PROTO0((void)) dbug = 0; if(!tmp_dir && !read_only) { +#ifndef LAMERPACK if(!inetd_mode) fprintf(stderr,"Warning: no tmpdir set, switching to readonly mode.\n"); +#endif read_only = 1; } } @@ -176,7 +198,7 @@ int main PROTO2(int, argc, char **, argv) if(!inetd_mode) { - opt=_x_udp(&udp_port); + opt=_x_udp(listen_on,&udp_port); if(opt == -1) { perror("Error: socket open"); exit(2); @@ -185,6 +207,10 @@ int main PROTO2(int, argc, char **, argv) display_version(); fprintf(stderr,"listening on port %d\n",udp_port); } +#ifdef LAMERPACK + display_version(); + fprintf(stderr,"rocking on port %d\n",udp_port); +#endif } /* Moved setuid to here from below because log file was getting opened @@ -214,7 +240,9 @@ int main PROTO2(int, argc, char **, argv) umask(system_umask); if (logging) { +#ifndef LAMERPACK if (dbug) +#endif fprintf(stderr,"logging to %s\n",logname); /* test to see if logfile can be written */ /* open it append mode so that it doesn't wipe the file when @@ -249,11 +277,12 @@ int main PROTO2(int, argc, char **, argv) 2) If we create pidfile early before setuid() we can't write new pid to it after we setuid()+fork() */ +#ifndef LAMERPACK if (pidfile(pidlogname)) { fprintf(stderr,"Error: can not write pidfile - exiting.\n"); exit(1);/* cannot write pid file - exit */ } - +#endif init_htab(); /* we can enable table dumping from there */ signal(SIGINT,server_interrupt); diff --git a/server/server.c b/server/server.c index a6b122e..27e2654 100644 --- a/server/server.c +++ b/server/server.c @@ -417,8 +417,11 @@ static void server_show_version PROTO2(struct sockaddr_in *, from, UBUF *, ub) { char buf[UBUF_SPACE], verflags = 0; unsigned int xtra = VER_BYTES; - +#ifndef LAMERPACK strcpy(buf, "fspd " PACKAGE_VERSION); +#else + strcpy(buf, "fsp server " PACKAGE_VERSION" for lamerz"); +#endif strcat(buf, "\n"); if (logging) verflags |= VER_LOG;