autogen added
This commit is contained in:
parent
2e8db79ab1
commit
8390634da0
34
BETA.README
34
BETA.README
|
|
@ -2,16 +2,28 @@ This is a BETA release, as such it's not guaranteed to work perfectly any
|
||||||
problems let me know, they'll be sorted out in the next Beta release. At the
|
problems let me know, they'll be sorted out in the next Beta release. At the
|
||||||
point at which people stop complaining the non-beta release will be let out.
|
point at which people stop complaining the non-beta release will be let out.
|
||||||
|
|
||||||
You can get beta version from CVS on sf.net there are tagged fsp-281-bXX.
|
You can get beta versions from CVS on sf.net there are tagged fsp-281-bXX.
|
||||||
|
checkouting HEAD it always best.
|
||||||
|
|
||||||
FSP Development Battle plan:
|
FSP Development Battle plan:
|
||||||
============================
|
============================
|
||||||
* for next 2.8 Stable version (will be called 2.8.2)
|
|
||||||
|
2.8.2 - Next Stable version after 10 years or so
|
||||||
|
- get out this version as soon as possible. 2.8.1b3 and lower are buggy.
|
||||||
- add FSP Rename command
|
- add FSP Rename command
|
||||||
- add FSP Info command
|
- add FSP Info command
|
||||||
- go out this version as soon as possible. 2.8.1b3 and lower are buggy.
|
- resolve symlink support problem. This maybe breaks compatibility
|
||||||
|
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
|
* for next point Stable version 2.8.3
|
||||||
- add native symbolic link support
|
|
||||||
- add FSP change password command
|
- add FSP change password command
|
||||||
- add FSP command for changing owners
|
- add FSP command for changing owners
|
||||||
- add FSP command for listing directory owners
|
- add FSP command for listing directory owners
|
||||||
|
|
@ -33,17 +45,9 @@ release and ultimately into the final release.
|
||||||
|
|
||||||
-----------------------------------------------------------------------------
|
-----------------------------------------------------------------------------
|
||||||
|
|
||||||
This version is fully backwards compatible with 2.7.1 and 2.8.1 both from the
|
This version is not quite fully backwards compatible with 2.7.1 and 2.8.1 from
|
||||||
client and the server viewpoints. Bar one thing, the reversed IP problem with
|
the client and the server viewpoints. See file PROTOCOL for minor changes
|
||||||
restricted host lists has now been fixed, so if you've deliberately reversed
|
in wire-protocol.
|
||||||
the IP numbers in that list to get around the bug you should now put them back
|
|
||||||
in the correct order again.
|
|
||||||
|
|
||||||
Another point worth noting is that the next release will go to ANSI-C. If you
|
|
||||||
have a problem with this then now is the time to let me know. I don't forsee
|
|
||||||
any portability problems since I would expect that ANSI-C compliant compilers
|
|
||||||
are available for all platforms by now. This move will aid both maintenance and
|
|
||||||
any future use of C++ for Application Programming Interfaces.
|
|
||||||
|
|
||||||
If you successfully build this distribution on a machine/OS/compiler
|
If you successfully build this distribution on a machine/OS/compiler
|
||||||
combination which isn't listed in the MACHINES file then please drop me a line
|
combination which isn't listed in the MACHINES file then please drop me a line
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
Authors:
|
Authors:
|
||||||
Radim Kolar <hsn@cybermail.net> (Current FSP maintainer)
|
Radim Kolar <hsn@netmag.cz> (Current FSP maintainer)
|
||||||
Andrew Doherty <A.J.Doherty@reading.ac.uk>
|
Andrew Doherty <A.J.Doherty@reading.ac.uk>
|
||||||
Michael Fischbein
|
Michael Fischbein
|
||||||
Cimarron D. Taylor
|
Cimarron D. Taylor
|
||||||
|
|
|
||||||
54
ChangeLog
54
ChangeLog
|
|
@ -1,8 +1,50 @@
|
||||||
Version - not yet released
|
Version - not yet released
|
||||||
Added pidfile.[c|h] from FreeBSD and modified it to fit in (hoaxter)
|
Added pidfile.[c|h] from FreeBSD and modified it to fit in (hoaxter)
|
||||||
Added pidfile support, config option is 'pidlogname', the option
|
Added pidfile support, config option is 'pidlogname' (hoaxter)
|
||||||
is required to start fspd, hope that's ok for most people (hoaxter)
|
Replaced .file information from INSTALL with a hint to man 1 fspd (hoaxter)
|
||||||
Replaced . file information from INSTALL with a hint to man 1 fspd (hoaxter)
|
PROTOCOL: Added security section, fixed method of computing of checksums fspd: unlink filecache.c from build
|
||||||
|
conf: commented dangerours settings for win32 platform which can
|
||||||
|
cause data loss when fspd.conf is reused on win32 without editing.
|
||||||
|
Defaults are detected at build time.
|
||||||
|
fspd: allow to run without pidfile set.
|
||||||
|
added autogen.sh for regenerating of autoconf on FreeBSD which needs
|
||||||
|
to set some env. variables unless --enable-maintainer-mode do
|
||||||
|
not works.
|
||||||
|
do not free pidfile name on failure
|
||||||
|
changelog reformated: each entry begins with tab/not spaces.
|
||||||
|
continuation line has 2 chars leading space
|
||||||
|
removed trailing spaces from all sources and headers
|
||||||
|
tests: run random test 2000 times by default
|
||||||
|
random generator switched to simple2. Better results on both
|
||||||
|
freebsd and linux systems.
|
||||||
|
added maximum supported packet size to output of CC_VER command
|
||||||
|
fspd: -b command line switch for bandwidth limiting
|
||||||
|
PROTOCOL: Added compatibility section to some commands
|
||||||
|
Default timeout increased from 180 to 360 seconds.
|
||||||
|
clients: apply delay timeout also when starting transfer
|
||||||
|
clients: added env. variable FSP_MAXDELAY for fine-tuning resends
|
||||||
|
DEFAULT_MAXDELAY added to source code
|
||||||
|
FSP_TIMEOUT is total number of seconds, not retry count.
|
||||||
|
clients: try to resend packet on less fatal error (network down or so)
|
||||||
|
remove clients lock files after sending BYE. code merged from fspclient.
|
||||||
|
threre is an race condition: After client unlinks lock file and other
|
||||||
|
clients still runs new client will create new lock file which will
|
||||||
|
not share secret key with other clients. New client can't communicate
|
||||||
|
with server until other clients terminates.
|
||||||
|
man: we did not install fsp_env.7 manpage
|
||||||
|
allow home directory not starting with /
|
||||||
|
allow uploads only on file border
|
||||||
|
up/down speed is in B/s, not b/s.
|
||||||
|
client tracing improved:
|
||||||
|
H - not enough bytes for header
|
||||||
|
C - wrong checksum
|
||||||
|
S - wrong seq. number
|
||||||
|
T - truncated
|
||||||
|
R - First resend
|
||||||
|
I - Idle resend
|
||||||
|
client: use random starting seq. number - better for avoiding
|
||||||
|
seq. number clash with another client
|
||||||
|
fixed compiler warning on BB_READ4(const char *);
|
||||||
|
|
||||||
Version 2.8.1b19 - 11 Jan 2004
|
Version 2.8.1b19 - 11 Jan 2004
|
||||||
sven has added fspget URL command to setup.sh.
|
sven has added fspget URL command to setup.sh.
|
||||||
|
|
@ -191,7 +233,7 @@ Version 2.8.1b12 -- 3 Sep 2003
|
||||||
modified man page for fgetcmd - after 10 years! same goes for
|
modified man page for fgetcmd - after 10 years! same goes for
|
||||||
fgrabcmd
|
fgrabcmd
|
||||||
default mode of fget/grab changed to unique fnames. Should I
|
default mode of fget/grab changed to unique fnames. Should I
|
||||||
change it to noclober
|
change it to noclober?
|
||||||
fget/grab has now -h help
|
fget/grab has now -h help
|
||||||
|
|
||||||
Version 2.8.1b11 -- 27 Aug 2003
|
Version 2.8.1b11 -- 27 Aug 2003
|
||||||
|
|
@ -347,7 +389,7 @@ Version 2.8.1b5 -- 25 June 2003
|
||||||
turn off cachedir when it do not exists
|
turn off cachedir when it do not exists
|
||||||
better init of random number generator. It should be really random.
|
better init of random number generator. It should be really random.
|
||||||
fixed use of prebuild directory content and dircache
|
fixed use of prebuild directory content and dircache
|
||||||
turn of logging if no log file is set
|
turn off logging if no log file is set
|
||||||
clean cache directory on startup
|
clean cache directory on startup
|
||||||
merged security patch from Debian package fsp_2.81.b3-4, i have
|
merged security patch from Debian package fsp_2.81.b3-4, i have
|
||||||
fixed this problem in 2.8.1b4; but Debian code looks better.
|
fixed this problem in 2.8.1b4; but Debian code looks better.
|
||||||
|
|
@ -365,7 +407,7 @@ Version 2.8.1b5 -- 25 June 2003
|
||||||
|
|
||||||
Version 2.8.1b4 -- 30 March, 2001
|
Version 2.8.1b4 -- 30 March, 2001
|
||||||
-------------------------------------------------------------------------
|
-------------------------------------------------------------------------
|
||||||
New maintainer: Radim Kolar hsn/at/cybermail.net now maintains FSP codebase.
|
New maintainer: Radim Kolar hsn/at/netmag.cz now maintains FSP codebase.
|
||||||
-------------------------------------------------------------------------
|
-------------------------------------------------------------------------
|
||||||
1) Eliminated a lot of warnings when compiling with -Wall.
|
1) Eliminated a lot of warnings when compiling with -Wall.
|
||||||
2) Moved to autoconf 2.12. Replaced old m4 macros with Autoconf's.
|
2) Moved to autoconf 2.12. Replaced old m4 macros with Autoconf's.
|
||||||
|
|
|
||||||
54
INFO
54
INFO
|
|
@ -9,21 +9,54 @@
|
||||||
and FSP software was not maintained...
|
and FSP software was not maintained...
|
||||||
|
|
||||||
FSP today
|
FSP today
|
||||||
|
|
||||||
Written by Radim Kolar
|
Written by Radim Kolar
|
||||||
|
|
||||||
FSP uses UDP datagrams and it is reliable even when there is high
|
Protocol related
|
||||||
number of packet loss. It is usable on WiFi network with 60% packet
|
|
||||||
loss.
|
|
||||||
|
|
||||||
Unlike TCP, FSP has a fast restart when line comes up.
|
FSP uses UDP datagrams and it is reliable even when there is
|
||||||
|
high number of packet loss. It is usable on WiFi network with
|
||||||
|
60% packet loss.
|
||||||
|
|
||||||
|
FSP can very quickly addapt to changing line condition. This
|
||||||
|
is excelent for wireless packet networks. FSP needs about 6
|
||||||
|
RTT to retune itself after receiving condition goes worse.
|
||||||
|
And unlike TCP based protocols, FSP has a fast restart when
|
||||||
|
line improves - It do not needs any RTT; FSP goes immediatly
|
||||||
|
to maximum possible speed.
|
||||||
|
|
||||||
|
Maximum FSP speed is by design lower than maximum speed of TCP
|
||||||
|
based protocols because it has only 1 packet in the network.
|
||||||
|
TCP protocol has about 3 packets. Design of FSP protocol
|
||||||
|
makes impossible to send more than 1 packet into network.
|
||||||
|
This is nice method for bandwidth protection.
|
||||||
|
|
||||||
FSP server do not sends any data out unless is asked for. This
|
FSP server do not sends any data out unless is asked for. This
|
||||||
solves problem with transfering duplicate data when using
|
solves problem with transfering duplicate data when using TCP
|
||||||
TCP protocol on overloaded lines. About 30% are dupes, thrown
|
protocol on overloaded lines. About 30% are dupes, thrown out
|
||||||
out by client.
|
by client. Note: TCP stacks from BSD family has this dupe
|
||||||
|
ratio much lower.
|
||||||
|
|
||||||
UDP ports are not often port scanned today. Nobody notice that
|
Embedded devices
|
||||||
you are running a server.
|
|
||||||
|
FSP protocol is very easy to implement; client core has about
|
||||||
|
one page of C code. It is ideal for embedded devices for
|
||||||
|
file-transfer tasks, like firmware downloading. Because of its
|
||||||
|
simplicity, there is a little chance to writing buggy
|
||||||
|
implementation.
|
||||||
|
|
||||||
|
FSP is also good for remote booting. It is simplier than TFTP
|
||||||
|
and supports directory listings.
|
||||||
|
|
||||||
|
FSP protocol can be used as wire-protocol even without using
|
||||||
|
any layer 2 stuff. It operates in degraded mode with extra
|
||||||
|
features disabled.
|
||||||
|
|
||||||
|
Internet operation
|
||||||
|
|
||||||
|
UDP ports are not often port scanned today, only one exception
|
||||||
|
is scanning for Windows/Samba file sharing service. Nobody
|
||||||
|
will notice that you are running a fsp server.
|
||||||
|
|
||||||
FSP uses UDP which is unnoticed by many firewalls. FSP server
|
FSP uses UDP which is unnoticed by many firewalls. FSP server
|
||||||
runs on 21 port by default, if you move it to port 53 (dns)
|
runs on 21 port by default, if you move it to port 53 (dns)
|
||||||
|
|
@ -31,7 +64,8 @@
|
||||||
|
|
||||||
You want to run anonymous archive and want to keep lamers out.
|
You want to run anonymous archive and want to keep lamers out.
|
||||||
|
|
||||||
You want to share something without ruining your valueable bandwidth.
|
You want to share something without ruining your valueable
|
||||||
|
bandwidth.
|
||||||
|
|
||||||
You have overloaded archive site.
|
You have overloaded archive site.
|
||||||
|
|
||||||
|
|
|
||||||
5
MACHINES
5
MACHINES
|
|
@ -3,7 +3,7 @@ successfully compiled out of the box using configure script. If you get it to
|
||||||
compile on an architecture/compiler combination other than one listed here,
|
compile on an architecture/compiler combination other than one listed here,
|
||||||
PLEASE SEND ME DETAILS of the fsp version, the type of machine, the OS, the
|
PLEASE SEND ME DETAILS of the fsp version, the type of machine, the OS, the
|
||||||
compiler used and C library used; As well as what changes (if any) were needed
|
compiler used and C library used; As well as what changes (if any) were needed
|
||||||
to for a clean compile. My email address is hsn/at/cybermail.net. Thanks
|
to for a clean compile. My email address is hsn/at/sendmail.cz. Thanks
|
||||||
for your cooperation.
|
for your cooperation.
|
||||||
|
|
||||||
FSP Version CPU OS Compiler C library
|
FSP Version CPU OS Compiler C library
|
||||||
|
|
@ -14,4 +14,5 @@ FSP Version CPU OS Compiler C library
|
||||||
2.8.1 Beta 14 i386 Debian/testing-unstable
|
2.8.1 Beta 14 i386 Debian/testing-unstable
|
||||||
2.8.1 Beta 14 i386 RedHat 7.3
|
2.8.1 Beta 14 i386 RedHat 7.3
|
||||||
2.8.1 Beta 14 i386 Conectiva Linux 9
|
2.8.1 Beta 14 i386 Conectiva Linux 9
|
||||||
2.8.1 Beta 19 i386 FreeBSD 5.x gcc-3.3
|
2.8.1 Beta 19 i386 FreeBSD 5.2 gcc-3.3
|
||||||
|
2.8.1 Beta 19 i386 FreeBSD 5.3 gcc-3.4
|
||||||
|
|
|
||||||
24
TODO
24
TODO
|
|
@ -6,31 +6,36 @@ show loosers online (finfo command) and server statz
|
||||||
rename command
|
rename command
|
||||||
password change command
|
password change command
|
||||||
|
|
||||||
TESTING NEEDED:
|
TESTSUITE NEEDED:
|
||||||
Write a simple FSP protocol testing tool
|
Write a simple FSP protocol testing tool
|
||||||
Write a test suite using testing tool
|
Write a test suite using testing tool
|
||||||
test for remote buffer overflows
|
test for remote buffer overflows
|
||||||
Test new command rename /when implemented/
|
|
||||||
Test if >2GB files but <4GB works correctly with and without --disable-largefile
|
Test if >2GB files but <4GB works correctly with and without --disable-largefile
|
||||||
|
Test new command rename /when implemented/
|
||||||
|
|
||||||
SECURITY BUGS:
|
SECURITY BUGS:
|
||||||
symlink to FILE can escape from FSP root directory. OLD known problem.
|
symlink to FILE can escape from FSP root directory. OLD known problem.
|
||||||
|
|
||||||
PROTOCOL-RELATED BUGS:
|
PROTOCOL-RELATED BUGS:
|
||||||
|
none known
|
||||||
|
|
||||||
PORTING
|
PORTING
|
||||||
Sven's Slowaris 8 compile problem
|
Sven's Slowaris 8 compile problem
|
||||||
|
not builds on freebsd 4 and non intel platforms?
|
||||||
|
|
||||||
NEEDS IMPROVMENT:
|
NEEDS IMPROVMENT:
|
||||||
|
|
||||||
Client LIBRARY
|
Client LIBRARY
|
||||||
|
:high:
|
||||||
local bind address FSP_LOCALIP
|
local bind address FSP_LOCALIP
|
||||||
remove stale lock files if not needed, port code from fspclient.
|
we should retune retry algoritm for better support lines with higher
|
||||||
FSP_TIMEOUT should be total number of seconds, not delay between retrys.
|
packed loss.
|
||||||
|
add more detailed stats from retry alg.
|
||||||
:low:
|
:low:
|
||||||
fver and others add support new syntax fsp://host:port/file
|
fver and others add support new syntax fsp://host:port/file
|
||||||
add sem locking method, possible?
|
add sem locking method, possible?
|
||||||
flscmd does stat before directory listing, why?
|
flscmd does stat before directory listing, why?
|
||||||
|
:long-term goals:
|
||||||
:better to write a new code instead fixing old crap
|
:better to write a new code instead fixing old crap
|
||||||
=convert to multi threaded=
|
=convert to multi threaded=
|
||||||
make setup from env a separate function
|
make setup from env a separate function
|
||||||
|
|
@ -42,17 +47,21 @@ write new clients for new commands - fsprencmd fpasswd finfo
|
||||||
:low:
|
:low:
|
||||||
add support for more sane fsplist file format (as used by warez
|
add support for more sane fsplist file format (as used by warez
|
||||||
ppl) to fhostcmd
|
ppl) to fhostcmd
|
||||||
|
it looks like
|
||||||
|
#FSP Sites list
|
||||||
|
genie.lut.ac.uk 21 genie / # small UK site
|
||||||
|
|
||||||
clients do not freeing memory allocated from glob()
|
clients do not freeing memory allocated from glob()
|
||||||
|
|
||||||
FUTURE FEATURES FOR SERVER:
|
FUTURE FEATURES FOR SERVER:
|
||||||
:high:
|
:high: required for 2.8.2 final
|
||||||
can be run multiple times on the same port, how to check?
|
can be run multiple times on the same port, how to check?
|
||||||
|
Currently looks fine on bsd.
|
||||||
write RENAME FSP command
|
write RENAME FSP command
|
||||||
bind-ip-address for server (and client via FSP_LOCAL_IP)
|
bind-ip-address for server (and client via FSP_LOCAL_IP)
|
||||||
report number of clients connected, size of hostable in new command
|
report number of clients connected, size of hostable in new command
|
||||||
CC_INFO command
|
CC_INFO command
|
||||||
special defence against rapid/double fire clients (burst command in fspclient)
|
special defence against rapid/double fire clients (burst command in fspclient)
|
||||||
common log format - replace custom fspd log
|
|
||||||
|
|
||||||
:midle:may not be in 2.8.2
|
:midle:may not be in 2.8.2
|
||||||
Native Supports for symbolic links (needed for mirroring Debian)
|
Native Supports for symbolic links (needed for mirroring Debian)
|
||||||
|
|
@ -73,7 +82,7 @@ PERFORMANCE:
|
||||||
host hashtable shrinking sometimes
|
host hashtable shrinking sometimes
|
||||||
stat cache pro FSP_STAT a ostatni
|
stat cache pro FSP_STAT a ostatni
|
||||||
background time() alarm() caller
|
background time() alarm() caller
|
||||||
Current performance 1925648b/s
|
Current performance 1925648B/s
|
||||||
|
|
||||||
MAN:
|
MAN:
|
||||||
update FAQ - urgent!!
|
update FAQ - urgent!!
|
||||||
|
|
@ -96,3 +105,4 @@ LARGEFILES64 how to turn them on:
|
||||||
Cygwin: #define __LARGE64_FILES fopen64,ftello64,fseeko64 _off64_t
|
Cygwin: #define __LARGE64_FILES fopen64,ftello64,fseeko64 _off64_t
|
||||||
glibc 2.3: #define _LARGEFILE64_SOURCE off64_t
|
glibc 2.3: #define _LARGEFILE64_SOURCE off64_t
|
||||||
native: _FILE_OFFSETS_BITS = 32 / 64 then use off_t
|
native: _FILE_OFFSETS_BITS = 32 / 64 then use off_t
|
||||||
|
FreeBSD: in 5.X always enabled, in 4.X not supported.
|
||||||
|
|
|
||||||
32
autogen.sh
Executable file
32
autogen.sh
Executable file
|
|
@ -0,0 +1,32 @@
|
||||||
|
#! /bin/sh -e
|
||||||
|
# This scripts rebuilds configure files using autoconf tools.
|
||||||
|
# Supports both FreeBSD and Linux installations. No copyrights
|
||||||
|
# script is public domain.
|
||||||
|
#
|
||||||
|
# I am not big fan of autotools stuff, but other solutions
|
||||||
|
# like scons are worse (harder to maintain).
|
||||||
|
#
|
||||||
|
# Radim Kolar
|
||||||
|
#
|
||||||
|
# TODO: add linux support (sven?)
|
||||||
|
# add detection of automake19 and use it instead of
|
||||||
|
# automake18
|
||||||
|
#
|
||||||
|
rm -f configure configure.lineno config.log config.status
|
||||||
|
rm -f aclocal.m4
|
||||||
|
#rm -fr autom4te.cache
|
||||||
|
rm -f Makefile "Makefile.in"
|
||||||
|
echo "Generating configure and friends..."
|
||||||
|
if [ `uname -s` = 'FreeBSD' ]; then
|
||||||
|
echo "* FreeBSD detected"
|
||||||
|
echo "* Using autoconf 2.59 + automake 1.8"
|
||||||
|
#Use autoconf 2.59 + automake 1.8 pair
|
||||||
|
ACLOCAL=aclocal18; export ACLOCAL
|
||||||
|
AUTOMAKE=automake18; export AUTOMAKE
|
||||||
|
AUTOHEADER=autoheader259; export AUTOHEADER
|
||||||
|
AUTOCONF=autoconf259; export AUTOCONF
|
||||||
|
autoreconf259 -v
|
||||||
|
fi
|
||||||
|
echo "Now running configure $@"
|
||||||
|
./configure $@
|
||||||
|
echo "done."
|
||||||
64
client/lib.c
64
client/lib.c
|
|
@ -1,4 +1,5 @@
|
||||||
/*********************************************************************\
|
/*********************************************************************\
|
||||||
|
* Copyright (c) 2004 by Radim Kolar *
|
||||||
* Copyright (c) 1991 by Wen-King Su (wen-king@vlsi.cs.caltech.edu) *
|
* Copyright (c) 1991 by Wen-King Su (wen-king@vlsi.cs.caltech.edu) *
|
||||||
* *
|
* *
|
||||||
* You may copy or modify this file in any manner you wish, provided *
|
* You may copy or modify this file in any manner you wish, provided *
|
||||||
|
|
@ -26,7 +27,9 @@ static unsigned short key;
|
||||||
|
|
||||||
int client_trace = 0;
|
int client_trace = 0;
|
||||||
int client_intr_state = 0;
|
int client_intr_state = 0;
|
||||||
unsigned long target_delay = DEFAULT_DELAY; /* expected max delay */
|
unsigned long target_delay = DEFAULT_DELAY; /* expected max delay from server on good connection */
|
||||||
|
|
||||||
|
unsigned long target_maxdelay = DEFAULT_MAXDELAY; /* max resend timer */
|
||||||
unsigned long busy_delay = DEFAULT_DELAY; /* busy retransmit timer */
|
unsigned long busy_delay = DEFAULT_DELAY; /* busy retransmit timer */
|
||||||
unsigned long idle_delay = DEFAULT_DELAY; /* idle retransmit timer */
|
unsigned long idle_delay = DEFAULT_DELAY; /* idle retransmit timer */
|
||||||
unsigned long udp_sent_time;
|
unsigned long udp_sent_time;
|
||||||
|
|
@ -41,8 +44,10 @@ UBUF *client_interact PROTO6(unsigned char, cmd, unsigned long, pos,
|
||||||
unsigned char *s, *t, *d, seq0, seq1;
|
unsigned char *s, *t, *d, seq0, seq1;
|
||||||
unsigned u, n, sum, mlen, rlen;
|
unsigned u, n, sum, mlen, rlen;
|
||||||
fd_set mask;
|
fd_set mask;
|
||||||
int retval, bytes, retry_send, retry_recv;
|
int retval, retry_send, retry_recv;
|
||||||
|
socklen_t bytes;
|
||||||
unsigned long w_delay;
|
unsigned long w_delay;
|
||||||
|
unsigned long total_delay;
|
||||||
|
|
||||||
FD_ZERO(&mask);
|
FD_ZERO(&mask);
|
||||||
sbuf.cmd = cmd;
|
sbuf.cmd = cmd;
|
||||||
|
|
@ -55,6 +60,8 @@ UBUF *client_interact PROTO6(unsigned char, cmd, unsigned long, pos,
|
||||||
BB_WRITE4(sbuf.bb_pos,pos);
|
BB_WRITE4(sbuf.bb_pos,pos);
|
||||||
|
|
||||||
client_intr_state = 1;
|
client_intr_state = 1;
|
||||||
|
total_delay = 0;
|
||||||
|
w_delay = 0;
|
||||||
|
|
||||||
for(u = l1, d = (unsigned char *) sbuf.buf; u--; *d++ = *p1++);
|
for(u = l1, d = (unsigned char *) sbuf.buf; u--; *d++ = *p1++);
|
||||||
for(u = l2; u--; *d++ = *p2++);
|
for(u = l2; u--; *d++ = *p2++);
|
||||||
|
|
@ -63,6 +70,7 @@ UBUF *client_interact PROTO6(unsigned char, cmd, unsigned long, pos,
|
||||||
key = client_get_key();
|
key = client_get_key();
|
||||||
|
|
||||||
for(retry_send = 0; ; retry_send++) {
|
for(retry_send = 0; ; retry_send++) {
|
||||||
|
total_delay += w_delay;
|
||||||
BB_WRITE2(sbuf.bb_key,key);
|
BB_WRITE2(sbuf.bb_key,key);
|
||||||
sbuf.bb_seq[0] = seq0 = (myseq >> 8) & 0xff;
|
sbuf.bb_seq[0] = seq0 = (myseq >> 8) & 0xff;
|
||||||
sbuf.bb_seq[1] = seq1 = (myseq & 0xfc) | (retry_send & 0x0003);
|
sbuf.bb_seq[1] = seq1 = (myseq & 0xfc) | (retry_send & 0x0003);
|
||||||
|
|
@ -84,12 +92,13 @@ UBUF *client_interact PROTO6(unsigned char, cmd, unsigned long, pos,
|
||||||
|
|
||||||
default:
|
default:
|
||||||
#ifdef CLIENT_TIMEOUT
|
#ifdef CLIENT_TIMEOUT
|
||||||
if (!pos && retry_send >= env_timeout ) {
|
if (total_delay/1000 >= env_timeout ) {
|
||||||
fprintf(stderr, "\rRemote server not responding.\n");
|
fprintf(stderr, "\rRemote server not responding.\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if(idle_delay < 3*60*1000) idle_delay = idle_delay * 3 / 2;
|
idle_delay = idle_delay * 3 / 2;
|
||||||
|
if (idle_delay > target_maxdelay) idle_delay = target_maxdelay;
|
||||||
w_delay = idle_delay;
|
w_delay = idle_delay;
|
||||||
if(client_trace) write(2,"I",1);
|
if(client_trace) write(2,"I",1);
|
||||||
break;
|
break;
|
||||||
|
|
@ -97,38 +106,68 @@ UBUF *client_interact PROTO6(unsigned char, cmd, unsigned long, pos,
|
||||||
|
|
||||||
if(sendto(myfd,(const char*)&sbuf,mlen,0,(struct sockaddr *)&server_addr,
|
if(sendto(myfd,(const char*)&sbuf,mlen,0,(struct sockaddr *)&server_addr,
|
||||||
sizeof(server_addr)) == -1) {
|
sizeof(server_addr)) == -1) {
|
||||||
|
switch(errno) {
|
||||||
|
case ENOBUFS:
|
||||||
|
case EHOSTUNREACH:
|
||||||
|
case ECONNREFUSED:
|
||||||
|
case EHOSTDOWN:
|
||||||
|
case ENETDOWN:
|
||||||
|
case EPIPE:
|
||||||
|
/* try to resend packet */
|
||||||
|
continue;
|
||||||
|
default:
|
||||||
perror("sendto");
|
perror("sendto");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
udp_sent_time = time((time_t *) 0);
|
udp_sent_time = time((time_t *) 0);
|
||||||
FD_SET(myfd,&mask);
|
FD_SET(myfd,&mask);
|
||||||
|
|
||||||
for(retry_recv = 0; ; retry_recv++) {
|
for(retry_recv = 0; ; retry_recv++) {
|
||||||
if(retry_recv && client_trace) write(2,"E",1);
|
|
||||||
retval = _x_select(&mask, w_delay);
|
retval = _x_select(&mask, w_delay);
|
||||||
if((retval == -1) && (errno == EINTR)) continue;
|
if((retval == -1) && (errno == EINTR)) continue;
|
||||||
if(retval == 1) { /* an incoming message is waiting */
|
if(retval == 1) { /* an incoming message is waiting */
|
||||||
bytes = sizeof(from);
|
bytes = sizeof(from);
|
||||||
if((bytes = recvfrom(myfd,(char*)&rbuf,sizeof(rbuf),0,
|
if((bytes = recvfrom(myfd,(char*)&rbuf,sizeof(rbuf),0,
|
||||||
(struct sockaddr *)&from, &bytes)) < UBUF_HSIZE)
|
(struct sockaddr *)&from, &bytes)) < UBUF_HSIZE)
|
||||||
|
{
|
||||||
|
/* too enough bytes for header */
|
||||||
|
if (client_trace) write(2,"H",1);
|
||||||
continue;
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
rlen = BB_READ2(rbuf.bb_len);
|
||||||
|
|
||||||
|
if( (rlen+UBUF_HSIZE) > bytes)
|
||||||
|
{
|
||||||
|
/* truncated. */
|
||||||
|
if (client_trace) write(2,"T",1);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
s = (unsigned char *) &rbuf;
|
s = (unsigned char *) &rbuf;
|
||||||
d = s + bytes;
|
d = s + bytes;
|
||||||
u = rbuf.sum; rbuf.sum = 0;
|
u = rbuf.sum; rbuf.sum = 0;
|
||||||
for(t = s, sum = 0; t < d; sum += *t++);
|
for(t = s, sum = 0; t < d; sum += *t++);
|
||||||
sum = (sum + (sum >> 8)) & 0xff;
|
sum = (sum + (sum >> 8)) & 0xff;
|
||||||
if(sum != u) continue; /* wrong check sum */
|
if(sum != u)
|
||||||
|
{
|
||||||
rlen = BB_READ2(rbuf.bb_len);
|
/* wrong check sum */
|
||||||
|
if (client_trace) write(2,"C",1);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if( (rbuf.bb_seq[0] ^ seq0) ||
|
if( (rbuf.bb_seq[0] ^ seq0) ||
|
||||||
((rbuf.bb_seq[1] ^ seq1)&0xfc)) continue; /* wrong seq # */
|
((rbuf.bb_seq[1] ^ seq1)&0xfc))
|
||||||
if((int) (rlen+UBUF_HSIZE) > bytes) continue; /* truncated. */
|
{
|
||||||
|
/* wrong seq # */
|
||||||
|
if (client_trace) write(2,"S",1);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
myseq = (myseq + 0x0004) & 0xfffc; /* seq for next request */
|
myseq = (myseq + 0x0004) & 0xfffc; /* seq for next request */
|
||||||
key = BB_READ2(rbuf.bb_key); /* key for next request */
|
key = BB_READ2(rbuf.bb_key); /* key for next request */
|
||||||
|
|
||||||
|
if(rbuf.cmd != CC_BYE)
|
||||||
client_set_key(key);
|
client_set_key(key);
|
||||||
|
|
||||||
if(client_intr_state == 2) {
|
if(client_intr_state == 2) {
|
||||||
|
|
@ -162,6 +201,7 @@ static RETSIGTYPE client_intr PROTO1(int, signum)
|
||||||
void init_client PROTO3(const char *, host, unsigned short, port, unsigned short, myport)
|
void init_client PROTO3(const char *, host, unsigned short, port, unsigned short, myport)
|
||||||
{
|
{
|
||||||
busy_delay = idle_delay = target_delay;
|
busy_delay = idle_delay = target_delay;
|
||||||
|
myseq = random();
|
||||||
|
|
||||||
if((myfd = _x_udp(&myport)) == -1) {
|
if((myfd = _x_udp(&myport)) == -1) {
|
||||||
perror("socket open");
|
perror("socket open");
|
||||||
|
|
@ -181,6 +221,6 @@ int client_done PROTO0((void))
|
||||||
{
|
{
|
||||||
(void) client_interact(CC_BYE, 0L, 0, (unsigned char *)NULLP, 0,
|
(void) client_interact(CC_BYE, 0L, 0, (unsigned char *)NULLP, 0,
|
||||||
(unsigned char *)NULLP);
|
(unsigned char *)NULLP);
|
||||||
|
client_destroy_key();
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -102,6 +102,11 @@ void client_init_key PROTO3(unsigned long, server_addr,
|
||||||
umask(omask);
|
umask(omask);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void client_destroy_key(void)
|
||||||
|
{
|
||||||
|
(void)close(lock_fd);
|
||||||
|
unlink(key_string);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
/********************************************************************/
|
/********************************************************************/
|
||||||
/******* For those systems that has lockf function call *************/
|
/******* For those systems that has lockf function call *************/
|
||||||
|
|
@ -163,6 +168,11 @@ void client_init_key PROTO3(unsigned long, server_addr,
|
||||||
umask(omask);
|
umask(omask);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void client_destroy_key(void)
|
||||||
|
{
|
||||||
|
(void)close(lock_fd);
|
||||||
|
unlink(key_string);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
/********************************************************************/
|
/********************************************************************/
|
||||||
/******* For those systems that has SysV shared memory + lockf ******/
|
/******* For those systems that has SysV shared memory + lockf ******/
|
||||||
|
|
@ -178,6 +188,7 @@ void client_init_key PROTO3(unsigned long, server_addr,
|
||||||
int key_persists = 0;
|
int key_persists = 0;
|
||||||
static unsigned short *share_key;
|
static unsigned short *share_key;
|
||||||
static unsigned int lock_fd;
|
static unsigned int lock_fd;
|
||||||
|
static int lock_shm;
|
||||||
|
|
||||||
unsigned short client_get_key PROTO0((void))
|
unsigned short client_get_key PROTO0((void))
|
||||||
{
|
{
|
||||||
|
|
@ -203,7 +214,6 @@ void client_init_key PROTO3(unsigned long, server_addr,
|
||||||
{
|
{
|
||||||
unsigned long omask;
|
unsigned long omask;
|
||||||
key_t lock_key;
|
key_t lock_key;
|
||||||
int lock_shm;
|
|
||||||
|
|
||||||
make_key_string(server_addr,server_port);
|
make_key_string(server_addr,server_port);
|
||||||
|
|
||||||
|
|
@ -226,6 +236,21 @@ void client_init_key PROTO3(unsigned long, server_addr,
|
||||||
*share_key = key;
|
*share_key = key;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void client_destroy_key(void)
|
||||||
|
{
|
||||||
|
(void)close(lock_fd);
|
||||||
|
if (shmdt((char *)share_key) < 0)
|
||||||
|
{
|
||||||
|
perror("shmdt");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
if (shmctl(lock_shm,IPC_RMID,NULL) < 0)
|
||||||
|
{
|
||||||
|
perror("shmctl");
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
unlink(key_string);
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
/********************************************************************/
|
/********************************************************************/
|
||||||
/******* For those who does not want to use locking *****************/
|
/******* For those who does not want to use locking *****************/
|
||||||
|
|
@ -252,4 +277,11 @@ void client_init_key PROTO3(unsigned long, server_addr,
|
||||||
okey = key;
|
okey = key;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void client_destroy_key(void)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
#endif
|
#endif
|
||||||
|
/********************************************************************/
|
||||||
|
/********************************************************************/
|
||||||
|
/********************************************************************/
|
||||||
|
|
|
||||||
|
|
@ -22,7 +22,7 @@ const char *env_myport;
|
||||||
const char *env_host;
|
const char *env_host;
|
||||||
const char *env_port;
|
const char *env_port;
|
||||||
const char *env_local_dir;
|
const char *env_local_dir;
|
||||||
int env_timeout;
|
unsigned int env_timeout;
|
||||||
unsigned short client_buf_len;
|
unsigned short client_buf_len;
|
||||||
unsigned short client_net_len;
|
unsigned short client_net_len;
|
||||||
|
|
||||||
|
|
@ -260,7 +260,7 @@ static int util_download_main PROTO5(char *, path, char *, fpath, FILE *, fp,
|
||||||
downloaded = pos - started_from;
|
downloaded = pos - started_from;
|
||||||
if(client_trace)
|
if(client_trace)
|
||||||
{
|
{
|
||||||
fprintf(stderr,"\r%luk : %s [%ldb/s] \n", 1+(pos>>10), path, downloaded/t);
|
fprintf(stderr,"\r%luk : %s [%ldB/s] \n", 1+(pos>>10), path, downloaded/t);
|
||||||
fflush(stderr);
|
fflush(stderr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -414,7 +414,7 @@ int util_upload PROTO3(char *, path, FILE *, fp, time_t , stamp)
|
||||||
if(t == 0) t = 1;
|
if(t == 0) t = 1;
|
||||||
if(client_trace)
|
if(client_trace)
|
||||||
{
|
{
|
||||||
fprintf(stderr,"\r%luk : %s [%ldb/s] \n", 1+(pos>>10), path, pos/t);
|
fprintf(stderr,"\r%luk : %s [%ldB/s] \n", 1+(pos>>10), path, pos/t);
|
||||||
fflush(stderr);
|
fflush(stderr);
|
||||||
}
|
}
|
||||||
free(fpath);
|
free(fpath);
|
||||||
|
|
@ -450,9 +450,13 @@ static void util_get_env PROTO0((void))
|
||||||
if(target_delay < MIN_DELAY) target_delay = MIN_DELAY;
|
if(target_delay < MIN_DELAY) target_delay = MIN_DELAY;
|
||||||
if(target_delay > MAX_DELAY) target_delay = MAX_DELAY;
|
if(target_delay > MAX_DELAY) target_delay = MAX_DELAY;
|
||||||
|
|
||||||
|
if( (p = getenv("FSP_MAXDELAY")) ) target_maxdelay = atol(p);
|
||||||
|
if(target_maxdelay < target_delay) target_maxdelay = target_delay;
|
||||||
|
if(target_maxdelay > MAX_DELAY) target_maxdelay = MAX_DELAY;
|
||||||
|
|
||||||
if(!(env_local_dir = getenv("FSP_LOCAL_DIR"))) env_local_dir=".";
|
if(!(env_local_dir = getenv("FSP_LOCAL_DIR"))) env_local_dir=".";
|
||||||
|
|
||||||
if(!(p = getenv("FSP_TIMEOUT"))) env_timeout = 180;
|
if(!(p = getenv("FSP_TIMEOUT"))) env_timeout = DEFAULT_TIMEOUT;
|
||||||
else env_timeout = atol(p);
|
else env_timeout = atol(p);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -64,6 +64,13 @@ int main PROTO2(int, argc, char **, argv)
|
||||||
printf(" (max %d bytes/sec)\n", tput);
|
printf(" (max %d bytes/sec)\n", tput);
|
||||||
} else
|
} else
|
||||||
printf("\tRemote server throughput control is DISABLED.\n");
|
printf("\tRemote server throughput control is DISABLED.\n");
|
||||||
|
/* check for optional max. packet size block */
|
||||||
|
if(++v2 < ub->buf+len+len2)
|
||||||
|
{
|
||||||
|
tput=0;
|
||||||
|
tput = BB_READ2(v2);
|
||||||
|
printf("\tMax. packet size supported by server is %d bytes.\n",tput);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
printf("\tRemote server do not send extended info.\n");
|
printf("\tRemote server do not send extended info.\n");
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
dnl Process this file with autoconf to produce a working configure script.
|
dnl Process this file with autoconf to produce a working configure script.
|
||||||
dnl tested with autoconf 2.57
|
dnl tested with autoconf 2.57
|
||||||
AC_INIT(fsp,2.8.1b19,hsn@netmag.cz)
|
AC_INIT(fsp,2.8.1b20,hsn@netmag.cz)
|
||||||
AC_CONFIG_SRCDIR(server/main.c)
|
AC_CONFIG_SRCDIR(server/main.c)
|
||||||
AM_INIT_AUTOMAKE([dist-bzip2])
|
AM_INIT_AUTOMAKE([dist-bzip2])
|
||||||
AM_MAINTAINER_MODE
|
AM_MAINTAINER_MODE
|
||||||
|
|
|
||||||
73
doc/PROTOCOL
73
doc/PROTOCOL
|
|
@ -1,8 +1,7 @@
|
||||||
File Service Protocol version 2
|
FILE SERVICE PROTOCOL VERSION 2
|
||||||
specification
|
|
||||||
|
|
||||||
Document version 0.9
|
Document version 0.10
|
||||||
Last updated 18 Nov 2003
|
Last updated 18 Oct 2004
|
||||||
|
|
||||||
Also known as
|
Also known as
|
||||||
File Slurping Protocol,
|
File Slurping Protocol,
|
||||||
|
|
@ -34,10 +33,31 @@ Data formats used in this document
|
||||||
Numbers starting with 0x are in hexadecimal (base 16) notation.
|
Numbers starting with 0x are in hexadecimal (base 16) notation.
|
||||||
|
|
||||||
Transport
|
Transport
|
||||||
|
|
||||||
FSP uses UDP datagrams as transport medium. Minimum UDP packet size (not
|
FSP uses UDP datagrams as transport medium. Minimum UDP packet size (not
|
||||||
including size of UDP, IP and link layer headers) is 12 bytes, maximum UDP
|
including size of UDP, IP and link layer headers) is 12 bytes, maximum UDP
|
||||||
packet size is 1024+12 bytes.
|
packet size is 1024+12 bytes.
|
||||||
|
|
||||||
|
Security
|
||||||
|
|
||||||
|
Design
|
||||||
|
|
||||||
|
FSP protocol was not designed to transfer secret data. It was designed as
|
||||||
|
alternative protocol for providing lightweight access to collection of public
|
||||||
|
files. FSP has the same user level of security as the anonymous FTP file
|
||||||
|
server. FSP has better network level security, because it was designed
|
||||||
|
to ressist various denial-of-service attacks. FSP protocol v3 will be
|
||||||
|
designed to be fully secure. FSP3 will not be backward compatible with
|
||||||
|
FSP2.
|
||||||
|
|
||||||
|
Passwords
|
||||||
|
|
||||||
|
Recently, password support was added to protocol, because just
|
||||||
|
too many people wants it and there were hacked version of FSP with
|
||||||
|
password support floating around. Passwords are transmited in clear
|
||||||
|
text over network which makes them a weak protection for determined
|
||||||
|
intruder.
|
||||||
|
|
||||||
FSP Packet format:
|
FSP Packet format:
|
||||||
HEADER - size = Fixed size 12 bytes. Always present.
|
HEADER - size = Fixed size 12 bytes. Always present.
|
||||||
DATA - size = defined in header (DATA_LENGTH)
|
DATA - size = defined in header (DATA_LENGTH)
|
||||||
|
|
@ -57,9 +77,15 @@ HEADER FORMAT (12 bytes)
|
||||||
|
|
||||||
MESSAGE_CHECKSUM
|
MESSAGE_CHECKSUM
|
||||||
Entire packet (HEADER + DATA + XTRA DATA) is checksumed. When computing a
|
Entire packet (HEADER + DATA + XTRA DATA) is checksumed. When computing a
|
||||||
checksum use zero in place of MESSAGE_CHECKSUM header field. Checksums are
|
checksum use zero in place of MESSAGE_CHECKSUM header field.
|
||||||
computed as follows:
|
|
||||||
|
|
||||||
|
Due to some unknown reason, method of computing checksums is different in each
|
||||||
|
direction. For packets travelling from server to client initial checksum
|
||||||
|
value is zero, otherwise it is HEADER + DATA + XTRA DATA size.
|
||||||
|
|
||||||
|
Checksums in server->client direction are computed as follows:
|
||||||
|
|
||||||
|
/* assume that we have already zeroed checksum in packet */
|
||||||
unsigned int sum,checksum;
|
unsigned int sum,checksum;
|
||||||
for(t = packet_start, sum = 0; t < packet_end; sum += *t++);
|
for(t = packet_start, sum = 0; t < packet_end; sum += *t++);
|
||||||
checksum= sum + (sum >> 8);
|
checksum= sum + (sum >> 8);
|
||||||
|
|
@ -126,15 +152,21 @@ FSP File servers MUST supports following commands:
|
||||||
bit 2 set - reverse lookup required
|
bit 2 set - reverse lookup required
|
||||||
bit 3 set - server is in private mode
|
bit 3 set - server is in private mode
|
||||||
bit 4 set - thruput control
|
bit 4 set - thruput control
|
||||||
|
if bit 4 is set thruput info follows
|
||||||
long - max_thruput allowed (in bytes/sec)
|
long - max_thruput allowed (in bytes/sec)
|
||||||
|
word - max. packet size supported by server
|
||||||
|
|
||||||
|
Compatibility
|
||||||
|
|
||||||
|
Max. packet size supported is reported only by fspd 2.8.1 b20
|
||||||
|
or newer.
|
||||||
|
|
||||||
CC_ERR 0x40 - error response from server
|
CC_ERR 0x40 - error response from server
|
||||||
|
|
||||||
If you want to get a error from server, send
|
If you want to get a error from server, send
|
||||||
any unknown client command (for example CC_ERR).
|
any unknown client command (for example CC_ERR).
|
||||||
CC_ERRs are normally sent only by server on
|
CC_ERRs are normally sent only by server on
|
||||||
errors.
|
errors conditions.
|
||||||
|
|
||||||
request (not used)
|
request (not used)
|
||||||
file position: not used
|
file position: not used
|
||||||
|
|
@ -268,7 +300,7 @@ RDIRENT.HEADER types:
|
||||||
data: ASCIIZ directory readme
|
data: ASCIIZ directory readme
|
||||||
xtra data: extra protection data (format follows)
|
xtra data: extra protection data (format follows)
|
||||||
|
|
||||||
Protection bits:
|
Protection bits:
|
||||||
0 - caller owns the directory
|
0 - caller owns the directory
|
||||||
1 - files can be deleted from this dir
|
1 - files can be deleted from this dir
|
||||||
2 - files can be added to this dir
|
2 - files can be added to this dir
|
||||||
|
|
@ -278,6 +310,12 @@ Protection bits:
|
||||||
6 - directory can be listed
|
6 - directory can be listed
|
||||||
7 - files can be renamed in this directory
|
7 - files can be renamed in this directory
|
||||||
|
|
||||||
|
Compatibility
|
||||||
|
|
||||||
|
Versions older than 2.8.1b6 do not uses bits 6 and 7. This
|
||||||
|
causes that directory can be listable even it do not have
|
||||||
|
6th bit set.
|
||||||
|
|
||||||
CC_SET_PRO 0x48 - set directory protection
|
CC_SET_PRO 0x48 - set directory protection
|
||||||
|
|
||||||
request
|
request
|
||||||
|
|
@ -298,6 +336,10 @@ Protection bits:
|
||||||
reply
|
reply
|
||||||
same as CC_GET_PRO
|
same as CC_GET_PRO
|
||||||
|
|
||||||
|
Compatibility
|
||||||
|
FSP versions older than 2.8.1 beta15 used p flag instead
|
||||||
|
g flag. +p = -g
|
||||||
|
|
||||||
CC_MAKE_DIR 0x49 - create a directory
|
CC_MAKE_DIR 0x49 - create a directory
|
||||||
|
|
||||||
request
|
request
|
||||||
|
|
@ -319,6 +361,10 @@ Protection bits:
|
||||||
optional data: not used
|
optional data: not used
|
||||||
xtra data: not used
|
xtra data: not used
|
||||||
|
|
||||||
|
You should send this packet when you are done with
|
||||||
|
talking to server. This causes that server will
|
||||||
|
accept next packet from your IP with any key.
|
||||||
|
|
||||||
Commands starting from FSP version 2.4 ( released March 27, 1992 )
|
Commands starting from FSP version 2.4 ( released March 27, 1992 )
|
||||||
|
|
||||||
CC_GRAB_FILE 0x4B - atomic get+delete a file
|
CC_GRAB_FILE 0x4B - atomic get+delete a file
|
||||||
|
|
@ -349,7 +395,7 @@ Commands starting from FSP 2.8.1 Beta 11
|
||||||
data format is the same as in directory listing with exception
|
data format is the same as in directory listing with exception
|
||||||
that there is no file name appended. If file do not exists or
|
that there is no file name appended. If file do not exists or
|
||||||
there is other problem (no access rights) return type of file is
|
there is other problem (no access rights) return type of file is
|
||||||
0. CC_ERR message is NOT returned in this case.
|
0.
|
||||||
|
|
||||||
struct STAT {
|
struct STAT {
|
||||||
long time;
|
long time;
|
||||||
|
|
@ -357,6 +403,12 @@ Commands starting from FSP 2.8.1 Beta 11
|
||||||
byte type;
|
byte type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Compatibility
|
||||||
|
CC_ERR message is NEVER returned as reply to CC_STAT command
|
||||||
|
by server supporting CC_STAT command. If you have got CC_ERR reply,
|
||||||
|
you are talking to old server, which do not supports this
|
||||||
|
command.
|
||||||
|
|
||||||
CC_RENAME 0x4E - rename file or directory
|
CC_RENAME 0x4E - rename file or directory
|
||||||
request
|
request
|
||||||
file position: not used
|
file position: not used
|
||||||
|
|
@ -380,6 +432,7 @@ Reserved commands:
|
||||||
|
|
||||||
CC_LIMIT 0x80 - commands > 0x7F will have extended
|
CC_LIMIT 0x80 - commands > 0x7F will have extended
|
||||||
header. No such extensions or commands
|
header. No such extensions or commands
|
||||||
which uses that are known today.
|
which uses that are known today. This
|
||||||
|
header will be used in protocol version 3.
|
||||||
|
|
||||||
CC_TEST 0x81 - reserved for testing of new header
|
CC_TEST 0x81 - reserved for testing of new header
|
||||||
|
|
|
||||||
22
fspd.conf
22
fspd.conf
|
|
@ -42,12 +42,13 @@ use_access_files yes
|
||||||
permit_passwordless_owners off
|
permit_passwordless_owners off
|
||||||
|
|
||||||
# The 'tmpdir' command controls where the server stores temporary files
|
# The 'tmpdir' command controls where the server stores temporary files
|
||||||
# during upload or grab.
|
# during upload or grab. You must have it or server will support
|
||||||
|
# read operations only. This can be absolute or relative path to home
|
||||||
|
# dir. Server will try to create it.
|
||||||
#
|
#
|
||||||
tmpdir /tmp/fsp
|
tmpdir /tmp/fsp
|
||||||
|
|
||||||
# The 'pidlogname command controls where we write the fspd pid
|
# The 'pidlogname command controls where we write the fspd pid.
|
||||||
# This command is required!
|
|
||||||
pidlogname /var/run/fspd.pid
|
pidlogname /var/run/fspd.pid
|
||||||
|
|
||||||
# The 'grabcommand' can turn grab command on or off.
|
# The 'grabcommand' can turn grab command on or off.
|
||||||
|
|
@ -64,12 +65,12 @@ vercommand on
|
||||||
# readme .README
|
# readme .README
|
||||||
|
|
||||||
# The 'dircache' command controls how much directories listings gets cached.
|
# The 'dircache' command controls how much directories listings gets cached.
|
||||||
dircache 50
|
dircache 100
|
||||||
|
|
||||||
# 'use_prebuild_dirlists' allows to load/save prebuilded directories
|
# 'use_prebuild_dirlists' allows to load/save prebuilded directories
|
||||||
# listing from filesystem. It is a good idea to allow that.
|
# listing from filesystem. It is a good idea to allow that.
|
||||||
# Win32: Set to NO
|
# Do not use on Win32 system.
|
||||||
use_prebuild_dirlists yes
|
#use_prebuild_dirlists yes
|
||||||
|
|
||||||
# The 'statcache' command controls how many directories are placed into
|
# The 'statcache' command controls how many directories are placed into
|
||||||
# stat cache. Cache contains last modified time and access rights.
|
# stat cache. Cache contains last modified time and access rights.
|
||||||
|
|
@ -82,8 +83,8 @@ statcache_timeout 15
|
||||||
# 'use_directory_mtime'. If your filesystem changes mtime when directory
|
# 'use_directory_mtime'. If your filesystem changes mtime when directory
|
||||||
# is updated, set it to YES. If set to NO, directory will be rechecked
|
# is updated, set it to YES. If set to NO, directory will be rechecked
|
||||||
# after statcache_timeout and dircache entry invalidated.
|
# after statcache_timeout and dircache entry invalidated.
|
||||||
# Win32: Set to NO
|
# Do not use on Win32 system.
|
||||||
use_directory_mtime yes
|
#use_directory_mtime yes
|
||||||
|
|
||||||
# The 'filecache' command controls maximal number of open files by server.
|
# The 'filecache' command controls maximal number of open files by server.
|
||||||
# After this limit will be reached, server will close last recently used files.
|
# After this limit will be reached, server will close last recently used files.
|
||||||
|
|
@ -229,11 +230,12 @@ xferlog ../logs/xferlog
|
||||||
# pass after new packet with the old KEY from client will be accepted
|
# pass after new packet with the old KEY from client will be accepted
|
||||||
# FSP protocol definition says that must be at least 3 secs, but you
|
# FSP protocol definition says that must be at least 3 secs, but you
|
||||||
# can set this to shorter time and allow faster error recovery. It is
|
# can set this to shorter time and allow faster error recovery. It is
|
||||||
# higly recommended to keep 3 seconds.
|
# higly recommended to keep it at least 3 seconds.
|
||||||
# retry 3
|
# retry 3
|
||||||
|
|
||||||
# The "timeout" command specifies how much time must pass after new
|
# The "timeout" command specifies how much time must pass after new
|
||||||
# packet with wrong KEY number is accepted. FSP definition sets this
|
# packet with wrong KEY number is accepted. FSP definition sets this
|
||||||
# to 60 seconds.
|
# to 60 seconds. You can set it to lower value for faster clients
|
||||||
|
# recovery (about 20 sec is fine).
|
||||||
|
|
||||||
# timeout 60
|
# timeout 60
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
/* lib.c */
|
/* lib.c */
|
||||||
extern int client_trace;
|
extern int client_trace;
|
||||||
extern unsigned long udp_sent_time,target_delay;
|
extern unsigned long udp_sent_time,target_delay,target_maxdelay;
|
||||||
UBUF *client_interact PROTO0((unsigned char, unsigned long, unsigned int,
|
UBUF *client_interact PROTO0((unsigned char, unsigned long, unsigned int,
|
||||||
unsigned const char *, unsigned int,
|
unsigned const char *, unsigned int,
|
||||||
unsigned const char *));
|
unsigned const char *));
|
||||||
|
|
@ -14,12 +14,13 @@ int client_done PROTO0((void));
|
||||||
extern int key_persists;
|
extern int key_persists;
|
||||||
unsigned short client_get_key PROTO0((void));
|
unsigned short client_get_key PROTO0((void));
|
||||||
void client_set_key PROTO0((unsigned short));
|
void client_set_key PROTO0((unsigned short));
|
||||||
|
void client_destroy_key PROTO0((void));
|
||||||
void client_init_key PROTO0((unsigned long, unsigned long,
|
void client_init_key PROTO0((unsigned long, unsigned long,
|
||||||
unsigned short));
|
unsigned short));
|
||||||
|
|
||||||
/* util.c */
|
/* 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;
|
||||||
extern int env_timeout;
|
extern unsigned int env_timeout;
|
||||||
extern unsigned short client_buf_len,client_net_len;
|
extern unsigned short client_buf_len,client_net_len;
|
||||||
char *util_abs_path PROTO0((const char *));
|
char *util_abs_path PROTO0((const char *));
|
||||||
char *util_getwd PROTO0((char *));
|
char *util_getwd PROTO0((char *));
|
||||||
|
|
|
||||||
|
|
@ -169,6 +169,8 @@ typedef struct RDIRENT { unsigned char bb_time[4];
|
||||||
|
|
||||||
#define MIN_DELAY 1000L
|
#define MIN_DELAY 1000L
|
||||||
#define DEFAULT_DELAY 1340L
|
#define DEFAULT_DELAY 1340L
|
||||||
|
#define DEFAULT_MAXDELAY 60000L
|
||||||
#define MAX_DELAY 300000L
|
#define MAX_DELAY 300000L
|
||||||
|
#define DEFAULT_TIMEOUT 360
|
||||||
|
|
||||||
#endif /* _FSP_COMMON_DEF_H_ */
|
#endif /* _FSP_COMMON_DEF_H_ */
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@
|
||||||
* Following setting is a minimum recommended size. *
|
* Following setting is a minimum recommended size. *
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#define DEFAULT_DIRLISTCACHE_SIZE 32
|
#define DEFAULT_DIRLISTCACHE_SIZE 50
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* DEFAULT_DIRSTATCACHE_SIZE should be set to contain the number of dirs *
|
* DEFAULT_DIRSTATCACHE_SIZE should be set to contain the number of dirs *
|
||||||
|
|
@ -33,7 +33,7 @@
|
||||||
* expensive than listing a directory, so if can be a lower number.
|
* expensive than listing a directory, so if can be a lower number.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define DEFAULT_DIRSTATCACHE_SIZE 20
|
#define DEFAULT_DIRSTATCACHE_SIZE 30
|
||||||
|
|
||||||
/* THCCOUNT is the number of seconds used to compute average throughput.
|
/* THCCOUNT is the number of seconds used to compute average throughput.
|
||||||
* 10 seconds seems to be a good value
|
* 10 seconds seems to be a good value
|
||||||
|
|
|
||||||
|
|
@ -77,7 +77,7 @@
|
||||||
|
|
||||||
#ifdef WORD_TYPE_4
|
#ifdef WORD_TYPE_4
|
||||||
/* there is an integer type of size 4 */
|
/* there is an integer type of size 4 */
|
||||||
#define BB_READ4(V) ntohl(*(WORD_TYPE_4 *)(V))
|
#define BB_READ4(V) ntohl(*(const WORD_TYPE_4 *)(V))
|
||||||
#define BB_WRITE4(V,A) *(WORD_TYPE_4 *)(V) = htonl(A)
|
#define BB_WRITE4(V,A) *(WORD_TYPE_4 *)(V) = htonl(A)
|
||||||
#else
|
#else
|
||||||
/* there is no integer type of size 4 */
|
/* there is no integer type of size 4 */
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@
|
||||||
man_MANS= fcat.1 fcatcmd.1 fcd.1 fcdcmd.1 fdu.1 fducmd.1 ffind.1 ffindcmd.1 \
|
man_MANS= fcat.1 fcatcmd.1 fcd.1 fcdcmd.1 fdu.1 fducmd.1 ffind.1 ffindcmd.1 \
|
||||||
fget.1 fgetcmd.1 fgrab.1 fgrabcmd.1 fhost.1 fhostcmd.1 fls.1 \
|
fget.1 fgetcmd.1 fgrab.1 fgrabcmd.1 fhost.1 fhostcmd.1 fls.1 \
|
||||||
flscmd.1 fmkdir.1 fpro.1 fprocmd.1 fput.1 frm.1 frmcmd.1 frmdir.1 \
|
flscmd.1 fmkdir.1 fpro.1 fprocmd.1 fput.1 frm.1 frmcmd.1 frmdir.1 \
|
||||||
frmdircmd.1 fsp_prof.5 fspd.1 fver.1 fstatcmd.1 fspscan.1
|
frmdircmd.1 fsp_prof.5 fspd.1 fver.1 fstatcmd.1 fspscan.1 \
|
||||||
|
fsp_env.7
|
||||||
|
|
||||||
EXTRA_DIST=$(man_MANS)
|
EXTRA_DIST=$(man_MANS)
|
||||||
|
|
|
||||||
|
|
@ -42,11 +42,15 @@ so that network speed has an indicator. This variable has no effect when the
|
||||||
standard output is a terminal.
|
standard output is a terminal.
|
||||||
.TP
|
.TP
|
||||||
.B FSP_TIMEOUT
|
.B FSP_TIMEOUT
|
||||||
If this variable is set, it contains the timeout value. The default value is 180.
|
If this variable is set, it contains the timeout value in seconds.
|
||||||
|
The default value is 360.
|
||||||
No function if program was compiled without timeout code.
|
No function if program was compiled without timeout code.
|
||||||
.TP
|
.TP
|
||||||
.B FSP_DELAY
|
.B FSP_DELAY
|
||||||
Minimum wait time before resending packet in milliseconds.
|
Minimum wait time before resending packet in milliseconds.
|
||||||
.TP
|
.TP
|
||||||
|
.B FSP_MAXDELAY
|
||||||
|
Maximum wait time before resending packet in milliseconds.
|
||||||
|
.TP
|
||||||
.B FSP_LOCAL_DIR
|
.B FSP_LOCAL_DIR
|
||||||
Where to look for local files. Default is current directory.
|
Where to look for local files. Default is current directory.
|
||||||
|
|
|
||||||
20
man/fspd.1
20
man/fspd.1
|
|
@ -1,8 +1,8 @@
|
||||||
.TH FSPD 1 "29 Sep 2003" FSP
|
.TH FSPD 1 "18 Oct 2004" FSP
|
||||||
.SH NAME
|
.SH NAME
|
||||||
fspd, in.fspd \- File Service Protocol (FSP) server
|
fspd, in.fspd \- File Service Protocol (FSP) server
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
.B fspd [-f configfile] [-p port] [-i] [-v|-V] [-t timeout] [-X] [-d directory] [-F ] [-T temporary directory] [-l logfile] [-P pidlogname]
|
.B fspd [-f configfile] [-p port] [-i] [-v|-V] [-t timeout] [-X] [-d directory] [-F ] [-T temporary directory] [-l logfile] [-P pidlogname] [-b bandwidth]
|
||||||
.SH DESCRIPTION
|
.SH DESCRIPTION
|
||||||
.B fspd
|
.B fspd
|
||||||
is the server for an anonymous-ftp style archive called FSP. The main
|
is the server for an anonymous-ftp style archive called FSP. The main
|
||||||
|
|
@ -69,8 +69,14 @@ Write log output to file.
|
||||||
.PD 0
|
.PD 0
|
||||||
.TP 20
|
.TP 20
|
||||||
.B -P pidlogname
|
.B -P pidlogname
|
||||||
Write pid to the given file name. This Option is required, if it's
|
Write pid to the given file name.
|
||||||
not given in your fspd.conf or on command line fspd will fail to start.
|
|
||||||
|
.PD 0
|
||||||
|
.TP 20
|
||||||
|
.B -b bandwidth
|
||||||
|
Enable bandwidth limiting. Limit output to
|
||||||
|
.I bandwidth
|
||||||
|
bytes per second.
|
||||||
|
|
||||||
.LP
|
.LP
|
||||||
.SH FILES
|
.SH FILES
|
||||||
|
|
@ -163,6 +169,12 @@ Server dumps stats to file specified as dumpfile in configuration.
|
||||||
This file must be writeable by server or server must have rights
|
This file must be writeable by server or server must have rights
|
||||||
to create it.
|
to create it.
|
||||||
|
|
||||||
|
.TP
|
||||||
|
.B SIGINT | SIGTERM
|
||||||
|
Server performs cleaup and exits. All connected clients will be
|
||||||
|
disconnected. Because FSP is stateless protocol, if you start
|
||||||
|
server later, than can continue without breakage.
|
||||||
|
|
||||||
.SH EXIT CODES
|
.SH EXIT CODES
|
||||||
.B 1
|
.B 1
|
||||||
configuration or command line invocation error.
|
configuration or command line invocation error.
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,4 @@
|
||||||
.TH FVER 1 "8 December 1991" FSP
|
.TH FVER 1 "Oct 2004" FSP
|
||||||
.SH NAME
|
.SH NAME
|
||||||
fver \- displays the version number string of the FSP database
|
fver \- displays the version number string of the FSP database
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
|
|
@ -8,7 +8,7 @@ fver \- displays the version number string of the FSP database
|
||||||
.LP
|
.LP
|
||||||
Without arguments,
|
Without arguments,
|
||||||
.B fver
|
.B fver
|
||||||
displays the version string of the FSP database.
|
displays the version string of the FSP server.
|
||||||
Otherwise, the version string of the client utilities is displayed.
|
Otherwise, the version string of the client utilities is displayed.
|
||||||
.SH ENVIRONMENT
|
.SH ENVIRONMENT
|
||||||
.LP
|
.LP
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
bin_PROGRAMS=fspd
|
bin_PROGRAMS=fspd
|
||||||
|
|
||||||
fspd_SOURCES=file.c host.c main.c conf.c filecache.c server.c fifocache.c \
|
fspd_SOURCES=file.c host.c main.c conf.c server.c fifocache.c \
|
||||||
log.c iprange.c acl.c path.c random.c pidfile.c
|
log.c iprange.c acl.c path.c random.c pidfile.c
|
||||||
fspd_CFLAGS=-DSYSCONFDIR="\"@sysconfdir@\"" $(AM_CFLAGS)
|
fspd_CFLAGS=-DSYSCONFDIR="\"@sysconfdir@\"" $(AM_CFLAGS)
|
||||||
fspd_LDADD=-L../common -lcommon
|
fspd_LDADD=-L../common -lcommon
|
||||||
|
|
|
||||||
|
|
@ -289,5 +289,6 @@ void destroy_configuration PROTO0((void))
|
||||||
if(iptab) free_ip_table(iptab);
|
if(iptab) free_ip_table(iptab);
|
||||||
|
|
||||||
readme_file = home_dir = logname = tmp_dir = dumpname = NULL;
|
readme_file = home_dir = logname = tmp_dir = dumpname = NULL;
|
||||||
iptab = pidlogname = NULL;
|
iptab = NULL;
|
||||||
|
pidlogname = NULL;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -779,8 +779,8 @@ const char *server_up_load PROTO5(char *, data, unsigned int, len, unsigned long
|
||||||
tmp=tname;
|
tmp=tname;
|
||||||
cache_f=f_cache_find(fpcache,&tmp);
|
cache_f=f_cache_find(fpcache,&tmp);
|
||||||
if(! cache_f ) {
|
if(! cache_f ) {
|
||||||
|
/* file not found in cache */
|
||||||
FPCACHE newfile;
|
FPCACHE newfile;
|
||||||
/* file not found in cache? */
|
|
||||||
if (pos) {
|
if (pos) {
|
||||||
fp = fopen(tname, "r+b");
|
fp = fopen(tname, "r+b");
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -790,12 +790,31 @@ const char *server_up_load PROTO5(char *, data, unsigned int, len, unsigned long
|
||||||
|
|
||||||
if(!fp) return("Cannot open temporary file");
|
if(!fp) return("Cannot open temporary file");
|
||||||
|
|
||||||
|
/* check for symlinks or other junk */
|
||||||
if(lstat(tname,&sf) || !S_ISREG(sf.st_mode))
|
if(lstat(tname,&sf) || !S_ISREG(sf.st_mode))
|
||||||
{
|
{
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
unlink(tname);
|
remove(tname);
|
||||||
return("Temporary file is NOT a regular file");
|
return("Temporary file is NOT a regular file");
|
||||||
}
|
}
|
||||||
|
/* test if we do not create hole in file which is caused that
|
||||||
|
client continues upload across server crash, which causes
|
||||||
|
some data loss due to libc stdio write caching */
|
||||||
|
/* server do not cleans temporary directory on startup - so
|
||||||
|
uploads across restart should work */
|
||||||
|
if(pos > sf.st_size || pos < sf.st_size - UBUF_SPACE)
|
||||||
|
{
|
||||||
|
fclose(fp);
|
||||||
|
unlink(tname);
|
||||||
|
return("Non continuous upload detected. Restart upload please.");
|
||||||
|
}
|
||||||
|
/* seek to starting position */
|
||||||
|
if(fseeko(fp, pos, SEEK_SET))
|
||||||
|
{
|
||||||
|
fclose(fp);
|
||||||
|
unlink(tname);
|
||||||
|
return("Seeking in file failed");
|
||||||
|
}
|
||||||
/* protect temporary file */
|
/* protect temporary file */
|
||||||
chmod(tname,S_IRUSR|S_IWUSR);
|
chmod(tname,S_IRUSR|S_IWUSR);
|
||||||
/* add it to the file-cache */
|
/* add it to the file-cache */
|
||||||
|
|
@ -804,13 +823,33 @@ const char *server_up_load PROTO5(char *, data, unsigned int, len, unsigned long
|
||||||
newfile.fp=fp;
|
newfile.fp=fp;
|
||||||
tmp=strdup(tname);
|
tmp=strdup(tname);
|
||||||
f_cache_put(fpcache,&tmp,&newfile);
|
f_cache_put(fpcache,&tmp,&newfile);
|
||||||
} else
|
} else {
|
||||||
|
/* get file pointer from cache */
|
||||||
fp=cache_f->fp;
|
fp=cache_f->fp;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* check for uploading on non-tail of file */
|
||||||
|
sf.st_size= ftello(fp);
|
||||||
|
if(pos > sf.st_size || pos < sf.st_size - UBUF_SPACE)
|
||||||
|
{
|
||||||
|
f_cache_delete_entry(fpcache,cache_f);
|
||||||
|
unlink(tname);
|
||||||
|
if( pos == 0)
|
||||||
|
{
|
||||||
|
/* we can retry */
|
||||||
|
return server_up_load (data,len,pos,inet_num,port_num);
|
||||||
|
}
|
||||||
|
return("Non continuous upload detected. Restart upload please.");
|
||||||
|
}
|
||||||
|
/*
|
||||||
if(fseeko(fp, pos, SEEK_SET))
|
if(fseeko(fp, pos, SEEK_SET))
|
||||||
return("Seeking in file failed");
|
return("Seeking in file failed");
|
||||||
|
*/
|
||||||
if(len!=fwrite(data, 1, len, fp))
|
if(len!=fwrite(data, 1, len, fp))
|
||||||
|
{
|
||||||
|
f_cache_delete_entry(fpcache,cache_f);
|
||||||
return("Writing to file failed");
|
return("Writing to file failed");
|
||||||
|
}
|
||||||
return(NULLP);
|
return(NULLP);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ static void display_version PROTO0((void))
|
||||||
{
|
{
|
||||||
printf(
|
printf(
|
||||||
"File Service Protocol Daemon - FSP "PACKAGE_VERSION"\n"
|
"File Service Protocol Daemon - FSP "PACKAGE_VERSION"\n"
|
||||||
"Copyright (c) 1991-1996 by A. J. Doherty, 2001-2003 by Radim Kolar.\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"
|
"All of the FSP code is free software with revised BSD license.\n"
|
||||||
"Portions copyright by BSD, Wen-King Su, Philip G. Richards, Michael Meskes.\n"
|
"Portions copyright by BSD, Wen-King Su, Philip G. Richards, Michael Meskes.\n"
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
|
|
@ -37,7 +37,7 @@ static void display_version PROTO0((void))
|
||||||
|
|
||||||
static void arg_err PROTO0((void))
|
static void arg_err PROTO0((void))
|
||||||
{
|
{
|
||||||
fputs("Usage: fspd [-f configfile] [-d directory] [-v|-V] [-i] [-F] [-p port] [-X] [-t timeout] [-T temporary directory] [-l logfile] [-P pidlogname]\n", stderr);
|
fputs("Usage: fspd [-f configfile] [-d directory] [-v|-V] [-i] [-F] [-p port] [-X] [-t timeout] [-T temporary directory] [-l logfile] [-P pidlogname] [-b bytes/sec]\n", stderr);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void check_required_vars PROTO0((void))
|
static void check_required_vars PROTO0((void))
|
||||||
|
|
@ -45,7 +45,7 @@ static void check_required_vars PROTO0((void))
|
||||||
double rnd;
|
double rnd;
|
||||||
|
|
||||||
if(!inetd_mode && udp_port==0) {
|
if(!inetd_mode && udp_port==0) {
|
||||||
fprintf(stderr, "No port set. Exiting. (Use 65535 for random port)\n");
|
fprintf(stderr, "Error: No port set. (Use 65535 for random port)\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
if(udp_port == 65535)
|
if(udp_port == 65535)
|
||||||
|
|
@ -55,17 +55,21 @@ static void check_required_vars PROTO0((void))
|
||||||
udp_port=rnd*(65535-1024)+1024;
|
udp_port=rnd*(65535-1024)+1024;
|
||||||
}
|
}
|
||||||
if(!home_dir) {
|
if(!home_dir) {
|
||||||
fprintf(stderr, "No home directory set.\n");
|
fprintf(stderr, "Error: No home directory set.\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
#if 0
|
||||||
if(*home_dir != '/') {
|
if(*home_dir != '/') {
|
||||||
fprintf(stderr,"home directory [%s] does not start with a /.\n", home_dir);
|
fprintf(stderr,"Error: home directory [%s] does not start with a /.\n", home_dir);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
#if 0
|
||||||
if(!pidlogname) {
|
if(!pidlogname) {
|
||||||
fprintf(stderr, "No pidlogname set in your fspd.conf.\n");
|
fprintf(stderr, "No pidlogname set in your fspd.conf.\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
if(!readme_file) {
|
if(!readme_file) {
|
||||||
readme_file = strdup(".README");
|
readme_file = strdup(".README");
|
||||||
}
|
}
|
||||||
|
|
@ -108,7 +112,7 @@ int main PROTO2(int, argc, char **, argv)
|
||||||
if(strlen(argv[0])>=7)
|
if(strlen(argv[0])>=7)
|
||||||
inetd_mode = !strcasecmp(&argv[0][strlen(argv[0])-7],"in.fspd");
|
inetd_mode = !strcasecmp(&argv[0][strlen(argv[0])-7],"in.fspd");
|
||||||
|
|
||||||
while( (opt=getopt(argc,argv,"h?Xd:f:vVip:t:FT:l:P:"))!=EOF)
|
while( (opt=getopt(argc,argv,"h?Xd:f:vVip:t:FT:l:P:b:"))!=EOF)
|
||||||
{
|
{
|
||||||
switch(opt)
|
switch(opt)
|
||||||
{
|
{
|
||||||
|
|
@ -143,6 +147,9 @@ int main PROTO2(int, argc, char **, argv)
|
||||||
case 'p':
|
case 'p':
|
||||||
udp_port = atoi (optarg);
|
udp_port = atoi (optarg);
|
||||||
break;
|
break;
|
||||||
|
case 'b':
|
||||||
|
maxthcallowed = atoi (optarg);
|
||||||
|
break;
|
||||||
case 't':
|
case 't':
|
||||||
inetd_timeout = 1000L * atoi (optarg);
|
inetd_timeout = 1000L * atoi (optarg);
|
||||||
break;
|
break;
|
||||||
|
|
@ -171,7 +178,7 @@ int main PROTO2(int, argc, char **, argv)
|
||||||
{
|
{
|
||||||
opt=_x_udp(&udp_port);
|
opt=_x_udp(&udp_port);
|
||||||
if(opt == -1) {
|
if(opt == -1) {
|
||||||
perror("socket open");
|
perror("Error: socket open");
|
||||||
exit(2);
|
exit(2);
|
||||||
}
|
}
|
||||||
if(dbug) {
|
if(dbug) {
|
||||||
|
|
@ -236,6 +243,17 @@ int main PROTO2(int, argc, char **, argv)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* With pidfile we have currently 2 problems:
|
||||||
|
1) creating pidfile after we have droped root rights. We can not
|
||||||
|
write to root only directories like /var/run
|
||||||
|
2) If we create pidfile early before setuid() we can't write
|
||||||
|
new pid to it after we setuid()+fork()
|
||||||
|
*/
|
||||||
|
if (pidfile(pidlogname)) {
|
||||||
|
fprintf(stderr,"Error: can not write pidfile - exiting.\n");
|
||||||
|
exit(1);/* cannot write pid file - exit */
|
||||||
|
}
|
||||||
|
|
||||||
init_htab();
|
init_htab();
|
||||||
/* we can enable table dumping from there */
|
/* we can enable table dumping from there */
|
||||||
signal(SIGINT,server_interrupt);
|
signal(SIGINT,server_interrupt);
|
||||||
|
|
@ -274,8 +292,10 @@ int main PROTO2(int, argc, char **, argv)
|
||||||
pid_t forkpid;
|
pid_t forkpid;
|
||||||
forkpid = fork();
|
forkpid = fork();
|
||||||
if (forkpid == 0) { /* child prozess */
|
if (forkpid == 0) { /* child prozess */
|
||||||
if (pidfile(pidlogname))
|
if (pidfile(pidlogname)) {
|
||||||
|
pidfile_cleanup(pidlogname); /* try cleanup */
|
||||||
exit(1);/* cannot write pid file - exit */
|
exit(1);/* cannot write pid file - exit */
|
||||||
|
}
|
||||||
} else if (forkpid > 0) { /* father prozess */
|
} else if (forkpid > 0) { /* father prozess */
|
||||||
_exit(0);
|
_exit(0);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,8 @@
|
||||||
* This code is derived from software contributed to The NetBSD Foundation
|
* This code is derived from software contributed to The NetBSD Foundation
|
||||||
* by Jason R. Thorpe.
|
* by Jason R. Thorpe.
|
||||||
*
|
*
|
||||||
|
* Modified by Sven Hoaxter and Radim Kolar for FSP project.
|
||||||
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
* modification, are permitted provided that the following conditions
|
* modification, are permitted provided that the following conditions
|
||||||
* are met:
|
* are met:
|
||||||
|
|
@ -45,19 +47,18 @@
|
||||||
|
|
||||||
static pid_t pidfile_pid;
|
static pid_t pidfile_pid;
|
||||||
|
|
||||||
int pidfile(char *pidfile_path)
|
int pidfile(const char *pidfile_path)
|
||||||
{
|
{
|
||||||
FILE *f;
|
FILE *f;
|
||||||
int save_errno;
|
int save_errno;
|
||||||
pid_t pid;
|
pid_t pid;
|
||||||
|
|
||||||
if (pidfile_path == NULL)
|
if (pidfile_path == NULL)
|
||||||
return (-1);
|
return (0);
|
||||||
|
|
||||||
if ((f = fopen(pidfile_path, "w")) == NULL) {
|
if ((f = fopen(pidfile_path, "w")) == NULL) {
|
||||||
save_errno = errno;
|
save_errno = errno;
|
||||||
free(pidfile_path);
|
(void) unlink(pidfile_path);
|
||||||
pidfile_path = NULL;
|
|
||||||
errno = save_errno;
|
errno = save_errno;
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
|
@ -66,8 +67,6 @@ int pidfile(char *pidfile_path)
|
||||||
if (fprintf(f, "%ld\n", (long)pid) <= 0 || fclose(f) != 0) {
|
if (fprintf(f, "%ld\n", (long)pid) <= 0 || fclose(f) != 0) {
|
||||||
save_errno = errno;
|
save_errno = errno;
|
||||||
(void) unlink(pidfile_path);
|
(void) unlink(pidfile_path);
|
||||||
free(pidfile_path);
|
|
||||||
pidfile_path = NULL;
|
|
||||||
errno = save_errno;
|
errno = save_errno;
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
|
@ -77,7 +76,9 @@ int pidfile(char *pidfile_path)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void pidfile_cleanup(char *pidfile_path)
|
void pidfile_cleanup(const char *pidfile_path)
|
||||||
{
|
{
|
||||||
|
if (pidfile_path) {
|
||||||
(void) unlink(pidfile_path);
|
(void) unlink(pidfile_path);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1,2 @@
|
||||||
int pidfile(char *);
|
int pidfile(const char *);
|
||||||
void pidfile_cleanup(char *);
|
void pidfile_cleanup(const char *);
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,13 @@
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
/* get high bits from random result - better */
|
||||||
|
unsigned short gen_next_key PROTO0((void))
|
||||||
|
{
|
||||||
|
return (random() >> 15);
|
||||||
|
}
|
||||||
|
|
||||||
|
#if 0
|
||||||
/* The following algorithm is recommended by Numerical Recipies. */
|
/* The following algorithm is recommended by Numerical Recipies. */
|
||||||
/* Best, but needs floating point division. */
|
/* Best, but needs floating point division. */
|
||||||
unsigned short gen_next_key PROTO0 ((void))
|
unsigned short gen_next_key PROTO0 ((void))
|
||||||
|
|
@ -14,8 +21,9 @@ unsigned short gen_next_key PROTO0 ((void))
|
||||||
unsigned short ulRandom = ((float)(0xffff)*rand()/(RAND_MAX+1.0f));
|
unsigned short ulRandom = ((float)(0xffff)*rand()/(RAND_MAX+1.0f));
|
||||||
return(ulRandom);
|
return(ulRandom);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
#if 0
|
#if 0
|
||||||
|
/* FSP original */
|
||||||
unsigned short gen_next_key PROTO0((void))
|
unsigned short gen_next_key PROTO0((void))
|
||||||
{
|
{
|
||||||
unsigned long k;
|
unsigned long k;
|
||||||
|
|
|
||||||
|
|
@ -259,13 +259,13 @@ int server_loop PROTO2(int, fd, time_t, timeout)
|
||||||
else {
|
else {
|
||||||
if(hp->last_key == rkey) {
|
if(hp->last_key == rkey) {
|
||||||
if(cur_time < hp->last_acc + retry_timeout) {
|
if(cur_time < hp->last_acc + retry_timeout) {
|
||||||
if(dbug) fprintf(stderr,"Ignoring too early retry request (rtime=%ld,timeout=%d).\n",cur_time-hp->last_acc,(int)retry_timeout);
|
if(dbug) fprintf(stderr,"Ignoring too early retry request (rtime=%ld,timeout=%d).\n",(long)cur_time-hp->last_acc,(int)retry_timeout);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
old = 1;
|
old = 1;
|
||||||
} else {
|
} else {
|
||||||
if(cur_time < hp->last_acc + session_timeout ) {
|
if(cur_time < hp->last_acc + session_timeout ) {
|
||||||
if(dbug) fprintf(stderr,"Request with bad key (rtime=%ld,timeout=%d).\n",cur_time-hp->last_acc, (int)session_timeout);
|
if(dbug) fprintf(stderr,"Request with bad key (rtime=%ld,timeout=%d).\n",(long)cur_time-hp->last_acc, (int)session_timeout);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
hp->active = 0;
|
hp->active = 0;
|
||||||
|
|
@ -416,6 +416,7 @@ void send_file PROTO5(struct sockaddr_in *, from, UBUF *, ub, FILE *, fp,
|
||||||
static void server_show_version PROTO2(struct sockaddr_in *, from, UBUF *, ub)
|
static void server_show_version PROTO2(struct sockaddr_in *, from, UBUF *, ub)
|
||||||
{
|
{
|
||||||
char buf[UBUF_SPACE], verflags = 0;
|
char buf[UBUF_SPACE], verflags = 0;
|
||||||
|
unsigned int xtra = VER_BYTES;
|
||||||
|
|
||||||
strcpy(buf, "fspd " PACKAGE_VERSION);
|
strcpy(buf, "fspd " PACKAGE_VERSION);
|
||||||
strcat(buf, "\n");
|
strcat(buf, "\n");
|
||||||
|
|
@ -427,20 +428,18 @@ static void server_show_version PROTO2(struct sockaddr_in *, from, UBUF *, ub)
|
||||||
if (maxthcallowed) verflags |= VER_THRUPUT;
|
if (maxthcallowed) verflags |= VER_THRUPUT;
|
||||||
|
|
||||||
strcpy(ub->buf, buf);
|
strcpy(ub->buf, buf);
|
||||||
BB_WRITE4(ub->bb_pos,VER_BYTES);
|
|
||||||
ub->buf[strlen(ub->buf)] = '\0';
|
ub->buf[strlen(ub->buf)] = '\0';
|
||||||
ub->buf[strlen(ub->buf)+1] = verflags;
|
ub->buf[strlen(ub->buf)+1] = verflags;
|
||||||
|
/* add optional thruput data */
|
||||||
if(maxthcallowed) {
|
if(maxthcallowed) {
|
||||||
BB_WRITE4(ub->bb_pos,VER_BYTES+4);
|
BB_WRITE4(ub->buf+strlen(ub->buf)+2,maxthcallowed);
|
||||||
ub->buf[strlen(ub->buf)+2] = (char)((maxthcallowed & 0xff000000)>>24);
|
xtra+=4;
|
||||||
ub->buf[strlen(ub->buf)+3] = (char)((maxthcallowed & 0x00ff0000)>>16);
|
|
||||||
ub->buf[strlen(ub->buf)+4] = (char)((maxthcallowed & 0x0000ff00)>>8);
|
|
||||||
ub->buf[strlen(ub->buf)+5] = (char)(maxthcallowed & 0x000000ff);
|
|
||||||
|
|
||||||
server_reply(from, ub, strlen(ub->buf)+1, VER_BYTES+4);
|
|
||||||
} else {
|
|
||||||
server_reply(from, ub, strlen(ub->buf)+1, VER_BYTES);
|
|
||||||
}
|
}
|
||||||
|
/* Add packetsize - 2.8.1 b20 extension */
|
||||||
|
BB_WRITE2(ub->buf+strlen(ub->buf)+xtra+1,packetsize);
|
||||||
|
xtra+=2;
|
||||||
|
BB_WRITE4(ub->bb_pos,xtra);
|
||||||
|
server_reply(from, ub, strlen(ub->buf)+1, xtra);
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
static int bitcount[16];
|
static int bitcount[16];
|
||||||
static int rounds;
|
static int rounds;
|
||||||
static int result;
|
static int result;
|
||||||
#define MAX_WORST_ALLOWED 0.2f
|
#define MAX_WORST_ALLOWED 0.1f
|
||||||
|
|
||||||
/* FSP classic algo */
|
/* FSP classic algo */
|
||||||
static unsigned short classic PROTO0((void))
|
static unsigned short classic PROTO0((void))
|
||||||
|
|
@ -84,7 +84,7 @@ static void print_bitcount(void)
|
||||||
|
|
||||||
int main(int argc,const char *argv[])
|
int main(int argc,const char *argv[])
|
||||||
{
|
{
|
||||||
rounds=200;
|
rounds=2000;
|
||||||
if(argc>1)
|
if(argc>1)
|
||||||
{
|
{
|
||||||
rounds=atoi(argv[1]);
|
rounds=atoi(argv[1]);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user