repo sync
This commit is contained in:
parent
a2786444b7
commit
2bacf3601f
|
|
@ -15,11 +15,10 @@ FSP Protocol wire changes:
|
|||
with older software versions.
|
||||
- security: symlink to FILE can escape from FSP root directory, this will
|
||||
be fixed as part of symlink support.
|
||||
- add FSP change password command (do we really need this ??)
|
||||
Code fixups:
|
||||
- fix Sven's compiling problems on various unixes
|
||||
- normalize return error codes of all clients
|
||||
- fspd: add special defence against rapid/double fire clients (burst command in fspclient)
|
||||
- add FSP change password command (do we really need this ??)
|
||||
|
||||
* for next point Stable version 2.8.3
|
||||
- hard coded access list, do not load it from filesystem
|
||||
|
|
|
|||
11
ChangeLog
11
ChangeLog
|
|
@ -45,6 +45,17 @@ Version NEXT
|
|||
FAQ: Added two section making FSP slower/faster, version bumped
|
||||
to 0.2
|
||||
do not use exit code -1 in fspscan
|
||||
LAMAH fspd: improve some error messages, run on port 80 by default
|
||||
Changed all exit() calls to use standard EX_* values. Some utilities
|
||||
still do not returns error exit when they should.
|
||||
fhostcmd: split host managing functions into fhost.c
|
||||
fhost.c: do not output partial results when dns resolving fails
|
||||
fhost.c: fallback to other display method (host/ip name) on
|
||||
resolving failure
|
||||
common lib: When doing addr resolving turn port 0 into 21.
|
||||
fhostcmd: ignore servers without port number set
|
||||
new command fsetup: C rewrite of old Perl script. This command is
|
||||
like fhostcmd but uses standard fspsites file format
|
||||
|
||||
Version 2.8.1b22 - 20 Dec 2004
|
||||
fixed sf bug 1060594: fspd: owner can't rename files
|
||||
|
|
|
|||
20
TODO
20
TODO
|
|
@ -1,11 +1,11 @@
|
|||
FSP SUITE TO DO LIST
|
||||
====================
|
||||
|
||||
/* maintained by hsn -at- netmag * cz */
|
||||
|
||||
Radim Kolar's personal wishlist from 1997
|
||||
*-high priority-*
|
||||
- show loosers online (finfo command) and server statz
|
||||
* l o w *
|
||||
- password change command !?
|
||||
|
||||
TESTSUITE NEEDED:
|
||||
Write a simple FSP protocol testing tool
|
||||
|
|
@ -38,16 +38,9 @@ LOCKING
|
|||
|
||||
CLIENTS
|
||||
:high:
|
||||
normalize return error codes of all clients
|
||||
write new clients for new commands - fpasswd finfo
|
||||
some client commands should exit with nonzero rc on failure
|
||||
|
||||
:low:
|
||||
add support for more sane fsplist file format (as used by warez
|
||||
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()
|
||||
|
||||
FUTURE FEATURES FOR SERVER:
|
||||
|
|
@ -57,7 +50,10 @@ report number of clients connected, size of hostable in new command
|
|||
special defence against rapid/double fire clients (burst command in fspclient)
|
||||
Native Supports for symbolic links (needed for mirroring Debian)
|
||||
new LSTAT COMMAND, new MAKELINK command
|
||||
|
||||
SERVER DIR LISTINGS
|
||||
Server should save .FSP_CONTENT using 1k size directory blocks
|
||||
Server should support sending different sized directory blocks
|
||||
|
||||
:midle:may not be in 2.8.2
|
||||
write FSP_CHANGE_PASSWORD command
|
||||
|
|
@ -79,14 +75,14 @@ FSP Proxy repeater - take a look at old code, but we have NAT and fspproxy
|
|||
|
||||
PERFORMANCE:
|
||||
do host hashtable shrinking/clearing sometimes
|
||||
stat cache pro FSP_STAT a other stat() calls
|
||||
stat cache for FSP_STAT a other stat() calls
|
||||
chage O(N) fifo cache to some more sane lru hashtable code.
|
||||
background time() alarm() caller
|
||||
Current performance 1925648B/s
|
||||
|
||||
MAN:
|
||||
separate manpage for 7 fsp (protocol definition) == write FSP RFC
|
||||
Register udp/21 for FSP in iana
|
||||
Register udp/21 for FSP in iana. FSP RFC needed!
|
||||
manual page for fmvcmd.1
|
||||
|
||||
libraries and support for FSP protocol
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@ static PLAN *palloc (enum ntype t, int (*f)())
|
|||
return(new);
|
||||
}
|
||||
perror("palloc");
|
||||
exit(1);
|
||||
exit(EX_OSERR);
|
||||
}
|
||||
|
||||
extern int isoutput;
|
||||
|
|
@ -154,7 +154,7 @@ static long find_parsenum (PLAN * plan, const char * option, char * str,
|
|||
if ( (!value && endchar == str) || (endchar[0] &&
|
||||
(!endch || endchar[0] != *endch))) {
|
||||
fprintf(stderr,"%s: %s", option, "illegal numeric value");
|
||||
exit(1);
|
||||
exit(EX_USAGE);
|
||||
}
|
||||
if (endch)
|
||||
*endch = endchar[0];
|
||||
|
|
@ -203,7 +203,7 @@ static void brace_subst (char * orig, char ** store, char * path, int len)
|
|||
if (!(*store = (char *)realloc(*store, len *= 2))) {
|
||||
perror("realloc");
|
||||
client_done();
|
||||
exit(1);
|
||||
exit(EX_OSERR);
|
||||
}
|
||||
bcopy(path, p, plen);
|
||||
p += plen;
|
||||
|
|
@ -279,11 +279,11 @@ static int find_exec (PLAN * plan, struct stat * sbuf, char * path)
|
|||
{
|
||||
case -1:
|
||||
perror ("fork");
|
||||
exit(1);
|
||||
exit(EX_OSERR);
|
||||
case 0:
|
||||
execvp(plan->e_argv[0], plan->e_argv);
|
||||
perror ("execvp");
|
||||
exit(1);
|
||||
exit(EX_OSERR);
|
||||
}
|
||||
pid = wait(&status);
|
||||
|
||||
|
|
@ -296,7 +296,7 @@ static char *emalloc_ffind (unsigned int len)
|
|||
|
||||
if ( (p = (char *)malloc(len))) return((char *)p);
|
||||
perror("malloc");
|
||||
exit(1);
|
||||
exit(EX_OSERR);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
@ -320,7 +320,7 @@ PLAN *c_exec (char *** argvp, int isok)
|
|||
for (ap = argv = *argvp;; ++ap) {
|
||||
if (!*ap) {
|
||||
fprintf(stderr,"%s: no terminating", isok ? "-ok" : "-exec");
|
||||
exit(1);
|
||||
exit(EX_USAGE);
|
||||
}
|
||||
if (**ap == ';') break;
|
||||
}
|
||||
|
|
@ -445,7 +445,7 @@ PLAN *c_newer (char * filename)
|
|||
|
||||
if (stat(filename, &sb)) {
|
||||
perror("stat");
|
||||
exit(1);
|
||||
exit(EX_NOINPUT);
|
||||
}
|
||||
new = palloc(N_NEWER, find_newer);
|
||||
new->t_data = sb.st_mtime;
|
||||
|
|
@ -541,7 +541,7 @@ PLAN *c_type (char * typestring)
|
|||
break;
|
||||
default:
|
||||
fprintf(stderr,"-type: unknown type");
|
||||
exit(1);
|
||||
exit(EX_USAGE);
|
||||
}
|
||||
|
||||
new = palloc(N_TYPE, find_type);
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ static char *strspl (register char * cp, register const char * dp)
|
|||
|
||||
if (ep == (char *)0) {
|
||||
perror("Out of memory 1");
|
||||
exit(1);
|
||||
exit(EX_OSERR);
|
||||
}
|
||||
(void) strcpy(ep, cp);
|
||||
(void) strcat(ep, dp);
|
||||
|
|
@ -405,7 +405,7 @@ static char **copyblk (register char ** v)
|
|||
nv = (char **)malloc((unsigned)((blklen(v) + 1) * sizeof(char **)));
|
||||
if (nv == (char **)0) {
|
||||
perror("Out of memory 2");
|
||||
exit(2);
|
||||
exit(EX_OSERR);
|
||||
}
|
||||
return (blkcpy(nv, v));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ static PLAN *yankexpr (PLAN ** planp)
|
|||
if (next->type == N_CLOSEPAREN) {
|
||||
if (subplan == NULL) {
|
||||
fprintf(stderr,"(): empty inner expression");
|
||||
exit(1);
|
||||
exit(EX_USAGE);
|
||||
}
|
||||
node->p_data[0] = subplan;
|
||||
node->type = N_EXPR;
|
||||
|
|
@ -134,7 +134,7 @@ PLAN *paren_squish (PLAN * plan)
|
|||
*/
|
||||
if (expr->type == N_CLOSEPAREN) {
|
||||
fprintf(stderr,"): no beginning '('");
|
||||
exit(1);
|
||||
exit(EX_USAGE);
|
||||
}
|
||||
|
||||
/* add the expression to our result plan */
|
||||
|
|
@ -183,11 +183,11 @@ PLAN *not_squish (PLAN * plan)
|
|||
}
|
||||
if (node == NULL) {
|
||||
fprintf(stderr,"!: no following expression");
|
||||
exit(1);
|
||||
exit(EX_USAGE);
|
||||
}
|
||||
if (node->type == N_OR) {
|
||||
fprintf(stderr,"!: nothing between ! and -o");
|
||||
exit(1);
|
||||
exit(EX_USAGE);
|
||||
}
|
||||
if (notlevel % 2 != 1) next = node;
|
||||
else next->p_data[0] = node;
|
||||
|
|
@ -234,13 +234,13 @@ PLAN *or_squish (PLAN * plan)
|
|||
if (next->type == N_OR) {
|
||||
if (result == NULL) {
|
||||
fprintf(stderr,"-o: no expression before -o");
|
||||
exit(1);
|
||||
exit(EX_USAGE);
|
||||
}
|
||||
next->p_data[0] = result;
|
||||
next->p_data[1] = or_squish(plan);
|
||||
if (next->p_data[1] == NULL) {
|
||||
fprintf(stderr,"-o: no expression after -o");
|
||||
exit(1);
|
||||
exit(EX_USAGE);
|
||||
}
|
||||
return(next);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -85,13 +85,13 @@ PLAN *find_create (char *** argvp)
|
|||
|
||||
if ((p = option(*argv)) == NULL) {
|
||||
(void)fprintf(stderr, "find: unknown option %s.\n", *argv);
|
||||
exit(1);
|
||||
exit(EX_USAGE);
|
||||
}
|
||||
++argv;
|
||||
if (p->flags & (O_ARGV|O_ARGVP) && !*argv) {
|
||||
(void)fprintf(stderr, "find: %s requires additional arguments.\n",
|
||||
*--argv);
|
||||
exit(1);
|
||||
exit(EX_USAGE);
|
||||
}
|
||||
|
||||
switch(p->flags) {
|
||||
|
|
|
|||
14
client/lib.c
14
client/lib.c
|
|
@ -104,7 +104,7 @@ UBUF *client_interact (unsigned char cmd, unsigned long pos,
|
|||
#ifdef CLIENT_TIMEOUT
|
||||
if (total_delay/1000 >= env_timeout ) {
|
||||
fprintf(stderr, "\rRemote server not responding.\n");
|
||||
exit(1);
|
||||
exit(EX_UNAVAILABLE);
|
||||
}
|
||||
#endif
|
||||
idle_delay = idle_delay * 4 / 3;
|
||||
|
|
@ -128,7 +128,7 @@ UBUF *client_interact (unsigned char cmd, unsigned long pos,
|
|||
continue;
|
||||
default:
|
||||
perror("sendto");
|
||||
exit(1);
|
||||
exit(EX_IOERR);
|
||||
}
|
||||
}
|
||||
/* Check if w_delay is within limits */
|
||||
|
|
@ -204,7 +204,7 @@ UBUF *client_interact (unsigned char cmd, unsigned long pos,
|
|||
|
||||
if(client_intr_state == 2) {
|
||||
if(!key_persists) client_done();
|
||||
exit(1);
|
||||
exit(EX_TEMPFAIL);
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
|
|
@ -221,9 +221,9 @@ UBUF *client_interact (unsigned char cmd, unsigned long pos,
|
|||
static RETSIGTYPE client_intr (int signum)
|
||||
{
|
||||
switch(client_intr_state) {
|
||||
case 0: exit(2);
|
||||
case 0: exit(EX_TEMPFAIL);
|
||||
case 1: client_intr_state = 2; break;
|
||||
case 2: exit(3);
|
||||
case 2: exit(EX_TEMPFAIL);
|
||||
}
|
||||
#ifndef RELIABLE_SIGNALS
|
||||
signal(SIGINT,client_intr);
|
||||
|
|
@ -241,12 +241,12 @@ void init_client (const char * host, unsigned short port, unsigned short myport)
|
|||
|
||||
if((myfd = _x_udp(env_listen_on,&myport)) == -1) {
|
||||
perror("socket open");
|
||||
exit(1);
|
||||
exit(EX_OSERR);
|
||||
}
|
||||
|
||||
if(_x_adr(host,port,&server_addr) == -1) {
|
||||
perror("server addr");
|
||||
exit(1);
|
||||
exit(EX_OSERR);
|
||||
}
|
||||
|
||||
client_init_key(server_addr.sin_addr.s_addr,port,getpid());
|
||||
|
|
|
|||
|
|
@ -62,14 +62,14 @@ unsigned short client_get_key (void)
|
|||
{
|
||||
if(flock(lock_fd,LOCK_EX) == -1) {
|
||||
perror("flock");
|
||||
exit(1);
|
||||
exit(EX_OSERR);
|
||||
}
|
||||
if(read(lock_fd,&okey,sizeof(okey)) == -1) {
|
||||
perror("read"); exit(1);
|
||||
perror("read"); exit(EX_OSERR);
|
||||
}
|
||||
if(lseek(lock_fd,0L,0) == -1) {
|
||||
perror("seek");
|
||||
exit(1);
|
||||
exit(EX_OSERR);
|
||||
}
|
||||
return(okey);
|
||||
}
|
||||
|
|
@ -80,15 +80,15 @@ void client_set_key (unsigned short nkey)
|
|||
key=nkey;
|
||||
if(write(lock_fd,&key,sizeof(key)) == -1) {
|
||||
perror("write");
|
||||
exit(1);
|
||||
exit(EX_OSERR);
|
||||
}
|
||||
if(lseek(lock_fd,0L,0) == -1) {
|
||||
perror("seek");
|
||||
exit(1);
|
||||
exit(EX_OSERR);
|
||||
}
|
||||
if(flock(lock_fd,LOCK_UN) == -1) {
|
||||
perror("unflock");
|
||||
exit(1);
|
||||
exit(EX_OSERR);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -129,15 +129,15 @@ unsigned short client_get_key (void)
|
|||
{
|
||||
if(lockf(lock_fd,F_LOCK,sizeof(okey)) == -1) {
|
||||
perror("lockf");
|
||||
exit(1);
|
||||
exit(EX_OSERR);
|
||||
}
|
||||
if(read(lock_fd,&okey,sizeof(okey)) == -1) {
|
||||
perror("read");
|
||||
exit(1);
|
||||
exit(EX_OSERR);
|
||||
}
|
||||
if(lseek(lock_fd,0L,0) == -1) {
|
||||
perror("seek");
|
||||
exit(1);
|
||||
exit(EX_OSERR);
|
||||
}
|
||||
return(okey);
|
||||
}
|
||||
|
|
@ -148,15 +148,15 @@ void client_set_key (unsigned short nkey)
|
|||
key=nkey;
|
||||
if(write(lock_fd,&key,sizeof(key)) == -1) {
|
||||
perror("write");
|
||||
exit(1);
|
||||
exit(EX_OSERR);
|
||||
}
|
||||
if(lseek(lock_fd,0L,0) == -1) {
|
||||
perror("seek");
|
||||
exit(1);
|
||||
exit(EX_OSERR);
|
||||
}
|
||||
if(lockf(lock_fd,F_ULOCK,sizeof(key)) == -1) {
|
||||
perror("unlockf");
|
||||
exit(1);
|
||||
exit(EX_OSERR);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -199,7 +199,7 @@ unsigned short client_get_key (void)
|
|||
{
|
||||
if(lockf(lock_fd,F_LOCK,2) == -1) {
|
||||
perror("lockf");
|
||||
exit(1);
|
||||
exit(EX_OSERR);
|
||||
}
|
||||
return(*share_key);
|
||||
}
|
||||
|
|
@ -209,7 +209,7 @@ void client_set_key (unsigned short key)
|
|||
*share_key = key;
|
||||
if(lockf(lock_fd,F_ULOCK,2) == -1) {
|
||||
perror("unlockf");
|
||||
exit(1);
|
||||
exit(EX_OSERR);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -228,15 +228,15 @@ void client_init_key (unsigned long server_addr,
|
|||
|
||||
if((lock_key = ftok(key_string,238)) == -1) {
|
||||
perror("ftok");
|
||||
exit(1);
|
||||
exit(EX_OSERR);
|
||||
}
|
||||
if((lock_shm = shmget(lock_key,2*sizeof(unsigned int),IPC_CREAT|0666)) == -1) {
|
||||
perror("shmget");
|
||||
exit(1);
|
||||
exit(EX_OSERR);
|
||||
}
|
||||
if(!(share_key = (unsigned int *) shmat(lock_shm,(char*)0,0))) {
|
||||
perror("shmat");
|
||||
exit(1);
|
||||
exit(EX_OSERR);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -317,7 +317,7 @@ unsigned short client_get_key (void)
|
|||
if(semop(lock_sem,&sem,1) == -1 )
|
||||
{
|
||||
perror("semop");
|
||||
exit(1);
|
||||
exit(EX_OSERR);
|
||||
}
|
||||
return(*share_key);
|
||||
}
|
||||
|
|
@ -333,7 +333,7 @@ void client_set_key (unsigned short key)
|
|||
*share_key = key;
|
||||
if(semop(lock_sem,&sem,1) == -1) {
|
||||
perror("semop");
|
||||
exit(1);
|
||||
exit(EX_OSERR);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -356,15 +356,15 @@ void client_init_key (unsigned long server_addr,
|
|||
|
||||
if((lock_key = ftok(key_string,238)) == -1) {
|
||||
perror("ftok");
|
||||
exit(1);
|
||||
exit(EX_OSERR);
|
||||
}
|
||||
if((lock_shm = shmget(lock_key,2*sizeof(unsigned int),IPC_CREAT|0666)) == -1) {
|
||||
perror("shmget");
|
||||
exit(1);
|
||||
exit(EX_OSERR);
|
||||
}
|
||||
if(!(share_key = (unsigned int *) shmat(lock_shm,(char*)0,0))) {
|
||||
perror("shmat");
|
||||
exit(1);
|
||||
exit(EX_OSERR);
|
||||
}
|
||||
|
||||
if((lock_sem = semget(lock_key,0,0)) == -1) {
|
||||
|
|
@ -377,7 +377,7 @@ void client_init_key (unsigned long server_addr,
|
|||
if(semctl(lock_sem,0,SETVAL,sun) == -1)
|
||||
{
|
||||
perror("semctl setval");
|
||||
exit(1);
|
||||
exit(EX_OSERR);
|
||||
}
|
||||
*share_key = key;
|
||||
}
|
||||
|
|
@ -389,7 +389,7 @@ void client_init_key (unsigned long server_addr,
|
|||
|
||||
if(semop(lock_sem,&sem,1) == -1) {
|
||||
perror("semop");
|
||||
exit(1);
|
||||
exit(EX_OSERR);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -400,14 +400,14 @@ void client_destroy_key(void)
|
|||
if (shmdt((char *)share_key) < 0)
|
||||
{
|
||||
perror("shmdt");
|
||||
exit(1);
|
||||
exit(EX_OSERR);
|
||||
}
|
||||
/* check if we are only one process holding lock */
|
||||
rc = semctl(lock_sem,1,GETVAL);
|
||||
if (rc == -1)
|
||||
{
|
||||
perror("semctl");
|
||||
exit(1);
|
||||
exit(EX_OSERR);
|
||||
}
|
||||
if (rc == 1)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -460,11 +460,11 @@ static void util_get_env (void)
|
|||
|
||||
if(!(env_host = getenv("FSP_HOST"))) {
|
||||
fputs("No FSP_HOST specified.\n",stderr);
|
||||
exit(1);
|
||||
exit(EX_CONFIG);
|
||||
}
|
||||
if(!(env_port = getenv("FSP_PORT"))) {
|
||||
fputs("No FSP_PORT specified.\n",stderr);
|
||||
exit(1);
|
||||
exit(EX_CONFIG);
|
||||
}
|
||||
if(!(env_dir = getenv("FSP_DIR"))) {
|
||||
env_dir = "/";
|
||||
|
|
|
|||
|
|
@ -19,5 +19,7 @@ fstatcmd
|
|||
fver
|
||||
.deps
|
||||
fspprof.c
|
||||
fspsites.c
|
||||
fmvcmd
|
||||
fbye
|
||||
fsetupcmd
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
bin_PROGRAMS=fcatcmd fcdcmd fducmd ffindcmd fgetcmd fgrabcmd fhostcmd \
|
||||
flscmd fmkdir fprocmd fput frmcmd frmdircmd fver fspmerge \
|
||||
fstatcmd fmvcmd fbye
|
||||
fstatcmd fmvcmd fbye fsetupcmd
|
||||
|
||||
LDADD=-L../common -L../bsd_src -L../client -lclient -lcommon -lbsdfsp $(EX_LIBS)
|
||||
|
||||
|
|
@ -10,13 +10,15 @@ fspmerge_SOURCES=merge.c printpro.c fspprof.l
|
|||
fcdcmd_SOURCES=fcdcmd.c printpro.c
|
||||
fprocmd_SOURCES=printpro.c fprocmd.c
|
||||
noinst_HEADERS=printpro.h fhost.h merge.h
|
||||
fhostcmd_SOURCES=fhostcmd.c fspprof.l
|
||||
fhostcmd_SOURCES=fhostcmd.c fspprof.l fhost.c
|
||||
fhostcmd_LDADD=$(LDADD)
|
||||
fsetupcmd_SOURCES=fsetupcmd.c fspsites.l fhost.c
|
||||
fsetupcmd_LDADD=$(LDADD)
|
||||
|
||||
fspmerge_LDADD=fcatcmd_m.o fcdcmd_m.o fducmd_m.o ffindcmd_m.o fgetcmd_m.o \
|
||||
fgrabcmd_m.o fhostcmd_m.o flscmd_m.o fmkdir_m.o fprocmd_m.o \
|
||||
fput_m.o frmcmd_m.o frmdircmd_m.o fver_m.o fmvcmd_m.o \
|
||||
fstatcmd_m.o fbye_m.o $(LDADD)
|
||||
fstatcmd_m.o fbye_m.o fhost.o $(LDADD)
|
||||
|
||||
fgetcmd_CFLAGS:=-DCOMMAND_GET
|
||||
|
||||
|
|
|
|||
|
|
@ -51,5 +51,5 @@ int main (int argc, char ** argv)
|
|||
|
||||
client_done();
|
||||
|
||||
exit(0);
|
||||
exit(EX_OK);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,5 +65,5 @@ int main (int argc, char ** argv)
|
|||
}
|
||||
}
|
||||
client_done();
|
||||
exit(0);
|
||||
exit(EX_OK);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ int main (int argc, char ** argv)
|
|||
break;
|
||||
default:
|
||||
fprintf(stderr,"Usage: du [-r|a|s] directory name.\n");
|
||||
exit(0);
|
||||
exit(EX_USAGE);
|
||||
}
|
||||
|
||||
/* special case `du' without file arguments -- becomes `du .' */
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ static RETSIGTYPE fsp_cleanup (int signum)
|
|||
char filename[20];
|
||||
sprintf(filename,".fsp.%d",getpid());
|
||||
unlink(filename);
|
||||
exit(1);
|
||||
exit(EX_TEMPFAIL);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -231,7 +231,7 @@ int main (int argc, char ** argv)
|
|||
env_client();
|
||||
if (strcmp(env_local_dir,".") && chdir(env_local_dir)) {
|
||||
perror("chdir");
|
||||
exit(1);
|
||||
exit(EX_NOINPUT);
|
||||
}
|
||||
|
||||
while ((optletter=getopt(argc, argv,"ofutnacrph?")) != EOF)
|
||||
|
|
@ -262,7 +262,7 @@ int main (int argc, char ** argv)
|
|||
case 'h':
|
||||
case '?':
|
||||
usage();
|
||||
exit(0);
|
||||
exit(EX_OK);
|
||||
}
|
||||
|
||||
if(argc > optind) {
|
||||
|
|
@ -324,5 +324,5 @@ int main (int argc, char ** argv)
|
|||
|
||||
client_done();
|
||||
|
||||
exit(0);
|
||||
exit(EX_OK);
|
||||
}
|
||||
|
|
|
|||
234
clients/fhost.c
Normal file
234
clients/fhost.c
Normal file
|
|
@ -0,0 +1,234 @@
|
|||
/*********************************************************************\
|
||||
* Copyright (c) 1993 by Michael Meskes *
|
||||
* (meskes@ulysses.informatik.rwth-aachen.de) *
|
||||
* Copyright (c) 2003-2005 by Radim Kolar (hsn@cybermail.net) *
|
||||
* *
|
||||
* You may copy or modify this file in any manner you wish, provided *
|
||||
* that this notice is always included, and that you hold the author *
|
||||
* harmless for any loss or damage resulting from the installation or *
|
||||
* use of this software. *
|
||||
\*********************************************************************/
|
||||
|
||||
#include "tweak.h"
|
||||
#include "client_def.h"
|
||||
#include "c_extern.h"
|
||||
#include <stdio.h>
|
||||
#include "my-string.h"
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#ifdef STDC_HEADERS
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
#ifdef HOST_LOOKUP
|
||||
#include <netdb.h>
|
||||
#endif
|
||||
|
||||
#include "fhost.h"
|
||||
|
||||
static struct fsp_host *host;
|
||||
static int hostsize=0;
|
||||
|
||||
/* allocate and init fsp_host structure */
|
||||
struct fsp_host * init_host(void)
|
||||
{
|
||||
struct fsp_host *h;
|
||||
|
||||
h=malloc(sizeof(struct fsp_host));
|
||||
if(h==NULL)
|
||||
{
|
||||
perror("init_host");
|
||||
exit(EX_OSERR);
|
||||
}
|
||||
|
||||
h->hostname=NULL;
|
||||
h->hostaddr=NULL;
|
||||
h->alias=calloc(1,sizeof(char *));
|
||||
h->port=-1;
|
||||
h->dir=NULL;
|
||||
h->delay=-1;
|
||||
h->local_port=-1;
|
||||
h->timeout=-1;
|
||||
h->trace=-1;
|
||||
h->local_dir=NULL;
|
||||
h->password=NULL;
|
||||
|
||||
return h;
|
||||
}
|
||||
|
||||
void add_host_alias(struct fsp_host *h, const char *name)
|
||||
{
|
||||
int i=0;
|
||||
while(h->alias[i])
|
||||
i++;
|
||||
h->alias=realloc(h->alias,sizeof(char *)*(i+2));
|
||||
h->alias[i]=strdup(name);
|
||||
h->alias[i+1]=NULL;
|
||||
}
|
||||
|
||||
void add_host(struct fsp_host *h)
|
||||
{
|
||||
if (hostsize==0)
|
||||
host=NULL;
|
||||
if(h==NULL) return;
|
||||
if(h->port<=0) return;
|
||||
host=realloc(host,sizeof(struct fsp_host)*(hostsize+1));
|
||||
if(host==NULL)
|
||||
{
|
||||
perror("host realloc");
|
||||
exit(EX_OSERR);
|
||||
}
|
||||
memcpy(host+hostsize,h,sizeof(struct fsp_host));
|
||||
hostsize++;
|
||||
return;
|
||||
}
|
||||
|
||||
struct fsp_host *find_host(const char *name)
|
||||
{
|
||||
int i,j;
|
||||
|
||||
if(name==NULL || hostsize==0 ) return NULL;
|
||||
for(i=0;i<hostsize;i++)
|
||||
{
|
||||
if(host[i].hostname)
|
||||
if(!strcmp(host[i].hostname,name)) return &host[i];
|
||||
if(host[i].hostaddr)
|
||||
if(!strcmp(host[i].hostaddr,name)) return &host[i];
|
||||
j=0;
|
||||
while(host[i].alias[j])
|
||||
{
|
||||
if(!strcmp(host[i].alias[j],name)) return &host[i];
|
||||
j++;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void list_prof_file (void) /* list resource file */
|
||||
{
|
||||
int i;
|
||||
for(i=0;i<hostsize;i++)
|
||||
{
|
||||
printf("host: %s port: %d\n",(host[i].hostname?host[i].hostname : host[i].hostaddr),(host[i].port<=0? 21 : host[i].port));
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/* lhost: type of FSP_HOST address NUMBER or NAME */
|
||||
int print_host_setup(struct fsp_host *setup,int csh,int lhost)
|
||||
{
|
||||
struct hostent *hp;
|
||||
long addr;
|
||||
register char *p;
|
||||
|
||||
if (setup->hostname || setup->hostaddr) {
|
||||
if (csh) printf("setenv FSP_HOST ");
|
||||
else printf("FSP_HOST=");
|
||||
/* kill trailing junk from hostname and hostaddr */
|
||||
if(setup->hostname) {
|
||||
for(p = setup->hostname; *p && *p!='\n' && *p!= ' '; p++);
|
||||
*p = 0;
|
||||
}
|
||||
if(setup->hostaddr) {
|
||||
for(p=setup->hostaddr;*p && *p !='\n' && *p!=' ';p++);
|
||||
*p = 0;
|
||||
}
|
||||
if(lhost==NAME && !setup->hostname) {
|
||||
/* look for name */
|
||||
#if HOST_LOOKUP
|
||||
addr=inet_addr(setup->hostaddr);
|
||||
if ( (hp=gethostbyaddr((char *) &addr, sizeof(addr), AF_INET)))
|
||||
setup->hostname= (char *)hp->h_name;
|
||||
#endif
|
||||
if (!setup->hostname) lhost=NUMBER;
|
||||
}
|
||||
if (
|
||||
(lhost==NUMBER && !setup->hostaddr)
|
||||
#if HOST_LOOKUP
|
||||
|| lhost==0
|
||||
#endif
|
||||
) {
|
||||
/* look for number */
|
||||
#if HOST_LOOKUP
|
||||
if ( (hp=gethostbyname(setup->hostname)))
|
||||
setup->hostaddr=(char *)inet_ntoa(*(struct in_addr *) * hp->h_addr_list);
|
||||
#endif
|
||||
if (!setup->hostaddr) lhost=NAME;
|
||||
}
|
||||
/* setup lhost to correct displaying type */
|
||||
if (lhost==0)
|
||||
{
|
||||
if (setup->hostaddr)
|
||||
lhost=NUMBER;
|
||||
else
|
||||
if(setup->hostname)
|
||||
lhost=NAME;
|
||||
} else
|
||||
{
|
||||
if (lhost==NUMBER && !setup->hostaddr)
|
||||
lhost=NAME;
|
||||
else
|
||||
if (lhost==NAME && !setup->hostname)
|
||||
host=NUMBER;
|
||||
}
|
||||
printf("%s", (lhost==NAME)? setup->hostname : setup->hostaddr);
|
||||
if (csh) printf(";\n");
|
||||
else printf(";\nexport FSP_HOST;\n");
|
||||
if (!setup->dir) setup->dir="/"; /* if host is set we need this */
|
||||
}
|
||||
if (setup->delay>=0) {
|
||||
if (csh) printf("setenv FSP_DELAY %d;\n",setup->delay);
|
||||
else printf("FSP_DELAY=%d;\nexport FSP_DELAY;\n",setup->delay);
|
||||
}
|
||||
if (setup->local_port>=0) {
|
||||
if (csh) printf("setenv FSP_LOCALPORT %d;\n",setup->local_port);
|
||||
else printf("FSP_LOCALPORT=%d;\nexport FSP_LOCALPORT;\n",setup->local_port);
|
||||
}
|
||||
if (setup->trace>=0) {
|
||||
if (csh) {
|
||||
if (setup->trace) printf("setenv FSP_TRACE;\n");
|
||||
else printf("unsetenv FSP_TRACE;\n");
|
||||
} else {
|
||||
if (setup->trace) printf("FSP_TRACE;\nexport FSP_TRACE;\n");
|
||||
else printf("unset FSP_TRACE;\n");
|
||||
}
|
||||
}
|
||||
if (setup->timeout>=0) {
|
||||
if (csh) printf("setenv FSP_TIMEOUT %d;\n",setup->timeout);
|
||||
else printf("FSP_TIMEOUT=%d;\nexport FSP_TIMEOUT;\n",setup->timeout);
|
||||
}
|
||||
if (setup->port>=0) {
|
||||
if (csh) printf("setenv FSP_PORT %d;\n",setup->port);
|
||||
else printf("FSP_PORT=%d;\nexport FSP_PORT;\n",setup->port);
|
||||
}
|
||||
if (setup->local_dir) {
|
||||
if (csh) printf("setenv FSP_LOCAL_DIR ");
|
||||
else printf("FSP_LOCAL_DIR=");
|
||||
for (p=setup->local_dir;*p && *p!='\n' && *p!=' ';p++) printf("%c",*p);
|
||||
if (csh) printf(";\n");
|
||||
else printf(";\nexport FSP_LOCAL_DIR;\n");
|
||||
}
|
||||
if (setup->password) {
|
||||
if (csh) printf("setenv FSP_PASSWORD ");
|
||||
else printf("FSP_PASSWORD=");
|
||||
for (p=setup->password;*p && *p!='\n' && *p!=' ';p++) printf("%c",*p);
|
||||
if (csh) printf(";\n");
|
||||
else printf(";\nexport FSP_PASSWORD;\n");
|
||||
}
|
||||
if (setup->dir) {
|
||||
if (csh) printf("setenv FSP_DIR ");
|
||||
else printf("FSP_DIR=");
|
||||
for (p=setup->dir;*p && *p!='\n' && *p!=' ';p++) printf("%c",*p);
|
||||
if (csh) printf(";\n");
|
||||
else printf(";\nexport FSP_DIR;\n");
|
||||
}
|
||||
|
||||
if (csh) printf("setenv FSP_NAME \"");
|
||||
else printf("FSP_NAME=\"");
|
||||
if (setup->hostname)
|
||||
for (p=setup->hostname;*p && *p!='\n' && *p!=' ';p++) printf("%c",*p);
|
||||
if (csh) printf("\";\n");
|
||||
else printf("\";\nexport FSP_NAME;\n");
|
||||
return (0);
|
||||
}
|
||||
|
|
@ -12,11 +12,11 @@ struct fsp_host {
|
|||
char *password;
|
||||
};
|
||||
|
||||
#define NUMBER 1
|
||||
#define NAME 2
|
||||
struct fsp_host * init_host(void);
|
||||
void add_host(struct fsp_host *h);
|
||||
void add_host_alias(struct fsp_host *h, const char *name);
|
||||
|
||||
/* lex parser */
|
||||
extern FILE *yyin;
|
||||
int yylex(void);
|
||||
int yywrap(void);
|
||||
struct fsp_host *find_host(const char *name);
|
||||
void list_prof_file (void); /* list resource file */
|
||||
int print_host_setup(struct fsp_host *setup,int csh,int lhost);
|
||||
|
|
|
|||
|
|
@ -30,90 +30,17 @@
|
|||
|
||||
#define FSP_STAT stat
|
||||
|
||||
#define NUMBER 1
|
||||
#define NAME 2
|
||||
|
||||
#include "fhost.h"
|
||||
|
||||
static const char *home="/";
|
||||
|
||||
static struct fsp_host *host;
|
||||
static int hostsize=0;
|
||||
static int tryfile=0;
|
||||
|
||||
/* allocate and init fsp_host structure */
|
||||
struct fsp_host * init_host(void)
|
||||
{
|
||||
struct fsp_host *h;
|
||||
|
||||
h=malloc(sizeof(struct fsp_host));
|
||||
if(h==NULL)
|
||||
{
|
||||
perror("init_host");
|
||||
exit(2);
|
||||
}
|
||||
|
||||
h->hostname=NULL;
|
||||
h->hostaddr=NULL;
|
||||
h->alias=calloc(1,sizeof(char *));
|
||||
h->port=-1;
|
||||
h->dir=NULL;
|
||||
h->delay=-1;
|
||||
h->local_port=-1;
|
||||
h->timeout=-1;
|
||||
h->trace=-1;
|
||||
h->local_dir=NULL;
|
||||
h->password=NULL;
|
||||
|
||||
return h;
|
||||
}
|
||||
|
||||
void add_host_alias(struct fsp_host *h, const char *name)
|
||||
{
|
||||
int i=0;
|
||||
while(h->alias[i])
|
||||
i++;
|
||||
h->alias=realloc(h->alias,sizeof(char *)*(i+2));
|
||||
h->alias[i]=strdup(name);
|
||||
h->alias[i+1]=NULL;
|
||||
}
|
||||
|
||||
void add_host(struct fsp_host *h)
|
||||
{
|
||||
if (hostsize==0)
|
||||
host=NULL;
|
||||
if(h==NULL) return;
|
||||
host=realloc(host,sizeof(struct fsp_host)*(hostsize+1));
|
||||
if(host==NULL)
|
||||
{
|
||||
perror("host realloc");
|
||||
exit(2);
|
||||
}
|
||||
memcpy(host+hostsize,h,sizeof(struct fsp_host));
|
||||
hostsize++;
|
||||
return;
|
||||
}
|
||||
|
||||
static struct fsp_host *find_host(const char *name)
|
||||
{
|
||||
int i,j;
|
||||
|
||||
if(name==NULL || hostsize==0 ) return NULL;
|
||||
for(i=0;i<hostsize;i++)
|
||||
{
|
||||
if(host[i].hostname)
|
||||
if(!strcmp(host[i].hostname,name)) return &host[i];
|
||||
if(host[i].hostaddr)
|
||||
if(!strcmp(host[i].hostaddr,name)) return &host[i];
|
||||
j=0;
|
||||
while(host[i].alias[j])
|
||||
{
|
||||
if(!strcmp(host[i].alias[j],name)) return &host[i];
|
||||
j++;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
/* generated lex parser */
|
||||
extern FILE *yyin;
|
||||
int yylex(void);
|
||||
int yywrap(void);
|
||||
|
||||
static void host_usage (void) /* print usage message */
|
||||
{
|
||||
|
|
@ -121,7 +48,7 @@ static void host_usage (void) /* print usage message */
|
|||
fprintf(stderr," [-o timeout] [-t trace] [-w password]\n");
|
||||
fprintf(stderr," [-f filename] [-h [number|name]] [-c | -b]\n");
|
||||
fprintf(stderr," [host port [directory] | abbreviation]\n");
|
||||
exit(0);
|
||||
exit(EX_OK);
|
||||
}
|
||||
|
||||
/* get data out of resource file */
|
||||
|
|
@ -150,17 +77,6 @@ static void parse_prof_file_new (const char * filename)
|
|||
fclose(input);
|
||||
}
|
||||
|
||||
static void list_prof_file (void) /* list resource file */
|
||||
{
|
||||
int i;
|
||||
for(i=0;i<hostsize;i++)
|
||||
{
|
||||
printf("host: %s port: %d\n",(host[i].hostname?host[i].hostname : host[i].hostaddr),(host[i].port<=0? 21 : host[i].port));
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
int main (int argc, char ** argv)
|
||||
{
|
||||
int optletter,csh,lhost=0;
|
||||
|
|
@ -168,8 +84,6 @@ int main (int argc, char ** argv)
|
|||
const char *filename=NULL;
|
||||
char *log;
|
||||
struct passwd *pw=0L;
|
||||
struct hostent *hp;
|
||||
long addr;
|
||||
struct fsp_host *setup=NULL;
|
||||
|
||||
log = (char *)getlogin();
|
||||
|
|
@ -249,102 +163,16 @@ int main (int argc, char ** argv)
|
|||
if (filename || argc==1) { /* list only */
|
||||
parse_prof_file_new(filename);
|
||||
list_prof_file();
|
||||
exit(0);
|
||||
exit(EX_OK);
|
||||
}
|
||||
}
|
||||
if (setup->delay>=0) {
|
||||
if (csh) printf("setenv FSP_DELAY %d;\n",setup->delay);
|
||||
else printf("FSP_DELAY=%d;\nexport FSP_DELAY;\n",setup->delay);
|
||||
if(setup->hostname==NULL && setup->hostaddr==NULL)
|
||||
{
|
||||
fprintf(stderr,"fhost: No host given!\n");
|
||||
exit(EX_USAGE);
|
||||
}
|
||||
if (setup->local_port>=0) {
|
||||
if (csh) printf("setenv FSP_LOCALPORT %d;\n",setup->local_port);
|
||||
else printf("FSP_LOCALPORT=%d;\nexport FSP_LOCALPORT;\n",setup->local_port);
|
||||
}
|
||||
if (setup->trace>=0) {
|
||||
if (csh) {
|
||||
if (setup->trace) printf("setenv FSP_TRACE;\n");
|
||||
else printf("unsetenv FSP_TRACE;\n");
|
||||
} else {
|
||||
if (setup->trace) printf("FSP_TRACE;\nexport FSP_TRACE;\n");
|
||||
else printf("unset FSP_TRACE;\n");
|
||||
}
|
||||
}
|
||||
if (setup->timeout>=0) {
|
||||
if (csh) printf("setenv FSP_TIMEOUT %d;\n",setup->timeout);
|
||||
else printf("FSP_TIMEOUT=%d;\nexport FSP_TIMEOUT;\n",setup->timeout);
|
||||
}
|
||||
if (setup->port>=0) {
|
||||
if (csh) printf("setenv FSP_PORT %d;\n",setup->port);
|
||||
else printf("FSP_PORT=%d;\nexport FSP_PORT;\n",setup->port);
|
||||
}
|
||||
if (setup->local_dir) {
|
||||
if (csh) printf("setenv FSP_LOCAL_DIR ");
|
||||
else printf("FSP_LOCAL_DIR=");
|
||||
for (p=setup->local_dir;*p && *p!='\n' && *p!=' ';p++) printf("%c",*p);
|
||||
if (csh) printf(";\n");
|
||||
else printf(";\nexport FSP_LOCAL_DIR;\n");
|
||||
}
|
||||
if (setup->password) {
|
||||
if (csh) printf("setenv FSP_PASSWORD ");
|
||||
else printf("FSP_PASSWORD=");
|
||||
for (p=setup->password;*p && *p!='\n' && *p!=' ';p++) printf("%c",*p);
|
||||
if (csh) printf(";\n");
|
||||
else printf(";\nexport FSP_PASSWORD;\n");
|
||||
}
|
||||
if (setup->hostname || setup->hostaddr) {
|
||||
if (csh) printf("setenv FSP_HOST ");
|
||||
else printf("FSP_HOST=");
|
||||
if(setup->hostname) {
|
||||
for(p = setup->hostname; *p && *p!='\n' && *p!= ' '; p++);
|
||||
*p = 0;
|
||||
}
|
||||
if(setup->hostaddr) {
|
||||
for(p=setup->hostaddr;*p && *p !='\n' && *p!=' ';p++);
|
||||
*p = 0;
|
||||
}
|
||||
if(lhost==NAME && !setup->hostname) {
|
||||
#if HOST_LOOKUP
|
||||
addr=inet_addr(setup->hostaddr);
|
||||
if ( (hp=gethostbyaddr((char *) &addr, sizeof(addr), AF_INET)))
|
||||
setup->hostname= (char *)hp->h_name;
|
||||
#endif
|
||||
if (!setup->hostname) lhost=NUMBER;
|
||||
}
|
||||
if (lhost==NUMBER && !setup->hostaddr) { /* look for number */
|
||||
#if HOST_LOOKUP
|
||||
if ( (hp=gethostbyname(setup->hostname)))
|
||||
setup->hostaddr=(char *)inet_ntoa(*(struct in_addr *) * hp->h_addr_list);
|
||||
#endif
|
||||
if (!setup->hostaddr) lhost=NAME;
|
||||
}
|
||||
if (!lhost) {
|
||||
if (setup->hostaddr) lhost=NUMBER;
|
||||
else if (setup->hostname) lhost=NAME;
|
||||
else {
|
||||
fprintf(stderr,"fhost: No host given!");
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
printf("%s", (lhost==NAME)? setup->hostname : setup->hostaddr);
|
||||
if (csh) printf(";\n");
|
||||
else printf(";\nexport FSP_HOST;\n");
|
||||
if (!setup->dir) setup->dir="/"; /* if host is set we need this */
|
||||
}
|
||||
if (setup->dir) {
|
||||
if (csh) printf("setenv FSP_DIR ");
|
||||
else printf("FSP_DIR=");
|
||||
for (p=setup->dir;*p && *p!='\n' && *p!=' ';p++) printf("%c",*p);
|
||||
if (csh) printf(";\n");
|
||||
else printf(";\nexport FSP_DIR;\n");
|
||||
}
|
||||
|
||||
if (csh) printf("setenv FSP_NAME \"");
|
||||
else printf("FSP_NAME=\"");
|
||||
if (setup->hostname)
|
||||
for (p=setup->hostname;*p && *p!='\n' && *p!=' ';p++) printf("%c",*p);
|
||||
if (csh) printf("\";\n");
|
||||
else printf("\";\nexport FSP_NAME;\n");
|
||||
exit(0);
|
||||
print_host_setup(setup,csh,lhost);
|
||||
exit(EX_OK);
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
|||
|
|
@ -34,5 +34,5 @@ int main (int argc, char ** argv)
|
|||
|
||||
client_done();
|
||||
|
||||
exit(0);
|
||||
exit(EX_OK);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,5 +47,5 @@ int main (int argc, char ** argv)
|
|||
while(*++argv) make_dir(*argv);
|
||||
client_done();
|
||||
|
||||
exit(0);
|
||||
exit(EX_OK);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -95,10 +95,10 @@ int main (int argc, char ** argv)
|
|||
else
|
||||
{
|
||||
fprintf(stderr,"%s source target\n", argv[0]);
|
||||
exit(1);
|
||||
exit(EX_USAGE);
|
||||
}
|
||||
|
||||
client_done();
|
||||
|
||||
exit(0);
|
||||
exit(EX_OK);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -94,5 +94,5 @@ int main (int argc, char ** argv)
|
|||
|
||||
client_done();
|
||||
|
||||
exit(0);
|
||||
exit(EX_OK);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ static RETSIGTYPE upload_cleanup (int signum)
|
|||
if(ub->cmd==CC_UP_LOAD)
|
||||
ub=client_interact(CC_INSTALL,0L, 1, "", 0, (unsigned char *)NULLP);
|
||||
client_done();
|
||||
exit(1);
|
||||
exit(EX_TEMPFAIL);
|
||||
}
|
||||
|
||||
int main (int argc, char ** argv)
|
||||
|
|
@ -76,7 +76,7 @@ int main (int argc, char ** argv)
|
|||
env_client();
|
||||
if (strcmp(env_local_dir,".") && chdir(env_local_dir)) {
|
||||
perror("chdir");
|
||||
exit(1);
|
||||
exit(EX_NOINPUT);
|
||||
}
|
||||
|
||||
signal(SIGHUP,SIG_IGN);
|
||||
|
|
@ -100,7 +100,7 @@ int main (int argc, char ** argv)
|
|||
case 'h':
|
||||
case '?':
|
||||
usage();
|
||||
exit(0);
|
||||
exit(EX_OK);
|
||||
case 'p':
|
||||
timestamps=1;
|
||||
}
|
||||
|
|
@ -125,5 +125,5 @@ int main (int argc, char ** argv)
|
|||
|
||||
client_done();
|
||||
|
||||
exit(0);
|
||||
exit(EX_OK);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -54,5 +54,5 @@ int main (int argc, char ** argv)
|
|||
|
||||
client_done();
|
||||
|
||||
exit(0);
|
||||
exit(EX_OK);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -55,5 +55,5 @@ int main (int argc, char **argv)
|
|||
|
||||
client_done();
|
||||
|
||||
exit(0);
|
||||
exit(EX_OK);
|
||||
}
|
||||
|
|
|
|||
192
clients/fsetupcmd.c
Normal file
192
clients/fsetupcmd.c
Normal file
|
|
@ -0,0 +1,192 @@
|
|||
/*********************************************************************\
|
||||
* Copyright (c) 1993 by Michael Meskes *
|
||||
* (meskes@ulysses.informatik.rwth-aachen.de) *
|
||||
* Copyright (c) 2003-5by Radim Kolar (hsn@cybermail.net) *
|
||||
* *
|
||||
* You may copy or modify this file in any manner you wish, provided *
|
||||
* that this notice is always included, and that you hold the author *
|
||||
* harmless for any loss or damage resulting from the installation or *
|
||||
* use of this software. *
|
||||
\*********************************************************************/
|
||||
|
||||
#include "tweak.h"
|
||||
#include "client_def.h"
|
||||
#include "c_extern.h"
|
||||
#include <stdio.h>
|
||||
#include "my-string.h"
|
||||
#include "merge.h"
|
||||
#include <pwd.h>
|
||||
#ifdef HAVE_UNISTD_H
|
||||
#include <unistd.h>
|
||||
#endif
|
||||
#ifdef STDC_HEADERS
|
||||
#include <stdlib.h>
|
||||
#endif
|
||||
#include <ctype.h>
|
||||
|
||||
#define FSP_STAT stat
|
||||
|
||||
#include "fhost.h"
|
||||
|
||||
static const char *home="/";
|
||||
static int tryfile=0;
|
||||
|
||||
|
||||
/* generated lex parser */
|
||||
extern FILE *yyin;
|
||||
int yylex(void);
|
||||
int yywrap(void);
|
||||
|
||||
static void setup_usage (void) /* print usage message */
|
||||
{
|
||||
fprintf(stderr,"Usage: fsetup [ -b | -c ] host port [directory] | abbreviation \n");
|
||||
exit(EX_OK);
|
||||
}
|
||||
|
||||
/* get data out of resource file */
|
||||
static void parse_prof_file_new (const char * filename)
|
||||
{
|
||||
|
||||
FILE *input=NULL;
|
||||
int rc;
|
||||
|
||||
if(filename)
|
||||
{
|
||||
input=fopen(filename,"r");
|
||||
}
|
||||
|
||||
if(input)
|
||||
{
|
||||
yyin=input;
|
||||
rc=0;
|
||||
} else
|
||||
rc=yywrap();
|
||||
|
||||
if(rc==0)
|
||||
yylex();
|
||||
|
||||
if(input)
|
||||
fclose(input);
|
||||
}
|
||||
|
||||
int main (int argc, char ** argv)
|
||||
{
|
||||
int optletter,csh,lhost=0;
|
||||
register char *p;
|
||||
const char *filename=NULL;
|
||||
char *log;
|
||||
struct passwd *pw=0L;
|
||||
struct fsp_host *setup=NULL;
|
||||
|
||||
log = (char *)getlogin();
|
||||
if (log) pw = getpwnam(log);
|
||||
if (!pw) pw = getpwuid(getuid());
|
||||
if (pw) {
|
||||
csh = !strcmp(pw->pw_shell + strlen(pw->pw_shell) - 3, "csh");
|
||||
home = pw->pw_dir; /* for default search for file .fsp_prof*/
|
||||
} else
|
||||
home=getenv("HOME");
|
||||
|
||||
/*
|
||||
* Figure out what shell we're using. A hack, we look for a shell
|
||||
* ending in "csh".
|
||||
*/
|
||||
log=getenv("SHELL");
|
||||
if(log)
|
||||
{
|
||||
csh = !strcmp(log + strlen(log) - 3, "csh");
|
||||
}
|
||||
|
||||
setup=init_host();
|
||||
while ((optletter=getopt(argc, argv,"hbc?")) != EOF)
|
||||
switch (optletter) {
|
||||
case '?':
|
||||
case 'h':
|
||||
setup_usage();
|
||||
case 'b':
|
||||
csh=0;
|
||||
break;
|
||||
case 'c':
|
||||
csh=1;
|
||||
break;
|
||||
default:
|
||||
setup_usage();
|
||||
break;
|
||||
}
|
||||
|
||||
if(argc > optind+1 && !filename) { /* host and port and no filename given */
|
||||
for (p=argv[optind];!setup->hostname && *p && *p!='\n';p++)
|
||||
if (!isdigit(*p) && *p!='.') setup->hostname=argv[optind];
|
||||
if (!setup->hostname) setup->hostaddr=argv[optind];
|
||||
setup->port=atol(argv[optind+1]);
|
||||
if (argc > optind + 1) setup->dir=argv[optind+2]; /* directory given, too */
|
||||
} else if (argc > optind) { /* abbreviation given */
|
||||
parse_prof_file_new(filename);
|
||||
setup=find_host(argv[optind]);
|
||||
if(!setup) setup=init_host();
|
||||
} else { /* list or set command-line options */
|
||||
if (filename || argc==1) { /* list only */
|
||||
parse_prof_file_new(filename);
|
||||
list_prof_file();
|
||||
exit(EX_OK);
|
||||
}
|
||||
}
|
||||
if(setup->hostname==NULL && setup->hostaddr==NULL)
|
||||
{
|
||||
fprintf(stderr,"fhost: No host given!\n");
|
||||
exit(EX_USAGE);
|
||||
}
|
||||
print_host_setup(setup,csh,lhost);
|
||||
exit(EX_OK);
|
||||
}
|
||||
|
||||
/*
|
||||
* search order: curdir, homedir, sysdir
|
||||
*
|
||||
* Returns: 1 for terminating scanner or 0 for switching
|
||||
*/
|
||||
|
||||
int yywrap(void)
|
||||
{
|
||||
char *f2=NULL;
|
||||
int rc;
|
||||
|
||||
if(yyin!=NULL)
|
||||
{
|
||||
fclose(yyin);
|
||||
yyin=NULL;
|
||||
}
|
||||
|
||||
switch(tryfile)
|
||||
{
|
||||
case 0:
|
||||
/* file in cur. dir */
|
||||
yyin=fopen(FSPSITES,"r");
|
||||
break;
|
||||
case 1:
|
||||
/* file in home dir */
|
||||
f2=(char *)malloc (strlen(home) + strlen(FSPSITES) + 2);
|
||||
if (!f2) {
|
||||
perror("malloc");
|
||||
return(1);
|
||||
}
|
||||
sprintf (f2,"%s/%s",home,FSPSITES);
|
||||
yyin=fopen(f2,"r");
|
||||
free(f2);
|
||||
break;
|
||||
case 2:
|
||||
yyin=fopen(FSPSITESRC,"r");
|
||||
break;
|
||||
default:
|
||||
return 1;
|
||||
}
|
||||
tryfile++;
|
||||
if(yyin==NULL)
|
||||
{
|
||||
/* try next available */
|
||||
rc=yywrap();
|
||||
return rc;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
@ -1,16 +1,7 @@
|
|||
%option nounput
|
||||
%option noyyget_lineno
|
||||
%option noyyset_lineno
|
||||
%option noyyget_debug
|
||||
%option noyyset_debug
|
||||
%option noyyget_in
|
||||
%option noyyget_out
|
||||
%option noyyget_leng
|
||||
%option noyyget_text
|
||||
%option noyyset_in
|
||||
%option noyyset_out
|
||||
%option case-insensitive
|
||||
%option never-interactive
|
||||
%option noyylineno
|
||||
|
||||
%{
|
||||
#include <string.h>
|
||||
|
|
|
|||
47
clients/fspsites.l
Normal file
47
clients/fspsites.l
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
%option nounput
|
||||
%option never-interactive
|
||||
%option noyylineno
|
||||
|
||||
%{
|
||||
#include <string.h>
|
||||
#include "fhost.h"
|
||||
|
||||
static struct fsp_host *host=NULL;
|
||||
/* The standard for the format for fspsites file is:
|
||||
|
||||
hostname port alias root-directory # comment
|
||||
*/
|
||||
%}
|
||||
DIGIT [0-9]
|
||||
NUMBER {DIGIT}+
|
||||
WHITECHAR [ \t]
|
||||
EOL [\r\n]+
|
||||
OPTWHITESPACE {WHITECHAR}*
|
||||
WHITESPACE {WHITECHAR}+
|
||||
COMMENT #[^\r\n]*
|
||||
IPADDRESS {NUMBER}\.{NUMBER}\.{NUMBER}\.{NUMBER}
|
||||
HOSTNAME [[:alpha:]][\-._[:alnum:]]+
|
||||
/* stavy */
|
||||
%s sport
|
||||
%s salias
|
||||
%s sdir
|
||||
%%
|
||||
{COMMENT} /* just ignore comments */
|
||||
{WHITESPACE} /* eat me too */
|
||||
<INITIAL>{HOSTNAME} {
|
||||
host=init_host();
|
||||
/* printf("host %s!\n",yytext); */
|
||||
host->hostname=strdup(yytext);
|
||||
BEGIN(sport);
|
||||
}
|
||||
<INITIAL>{IPADDRESS} {
|
||||
host=init_host();
|
||||
/* printf("ihost %s!\n",yytext); */
|
||||
host->hostaddr=strdup(yytext);
|
||||
BEGIN(sport);
|
||||
}
|
||||
<sport>{NUMBER} host->port=atoi(yytext);BEGIN(salias);
|
||||
<salias>{HOSTNAME} add_host_alias(host,yytext);BEGIN(sdir);
|
||||
<sdir,salias>\/[[:graph:]]* host->dir=strdup(yytext);BEGIN(INITIAL);
|
||||
{EOL} add_host(host);host=NULL;BEGIN(INITIAL);
|
||||
<<EOF>> add_host(host);host=NULL;BEGIN(INITIAL);yyterminate();
|
||||
|
|
@ -94,5 +94,5 @@ int main (int argc, char ** argv)
|
|||
|
||||
client_done();
|
||||
|
||||
exit(0);
|
||||
exit(EX_OK);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -134,5 +134,5 @@ int main (int argc, char ** argv)
|
|||
printf("no\n");
|
||||
#endif
|
||||
}
|
||||
exit(0);
|
||||
exit(EX_OK);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ int main (int argc, char ** argv)
|
|||
else if(!strcmp(q,"fmvcmd")) fmvcmd_main(argc,argv);
|
||||
else {
|
||||
fprintf(stderr,"Unknown FSP client command: %s\n",q);
|
||||
exit(1);
|
||||
exit(EX_USAGE);
|
||||
}
|
||||
exit(0);
|
||||
exit(EX_OK);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ char *strdup PROTO1(char *, str)
|
|||
|
||||
if (nstr == (char*)0) {
|
||||
fprintf(stderr, "strdup(): not enough memory to duplicate `%s'\n", str);
|
||||
exit(1);
|
||||
exit(EX_OSERR);
|
||||
}
|
||||
|
||||
strcpy(nstr, str);
|
||||
|
|
|
|||
|
|
@ -71,6 +71,9 @@ int _x_adr (const char *host, int port, struct sockaddr_in * his)
|
|||
host=myhost;
|
||||
}
|
||||
|
||||
if(port <= 0)
|
||||
port=21;
|
||||
|
||||
/* if((his->sin_addr.s_addr = inet_addr(host)) != -1) */
|
||||
if(inet_aton(host,&his->sin_addr)) {
|
||||
his->sin_family = AF_INET;
|
||||
|
|
|
|||
|
|
@ -237,7 +237,7 @@ elif test "x$ac_cv_func_semop" = "xyes" -a "x$ac_cv_func_shmget" = "xyes"; then
|
|||
elif test "x$ac_cv_func_shmget" = "xyes" -a "x$ac_cv_func_lockf" = "xyes"; then
|
||||
AC_DEFINE(FSP_USE_SHAREMEM_AND_LOCKF,1)
|
||||
elif test "x$ac_cv_func_lockf" = "xyes"; then AC_DEFINE(FSP_USE_LOCKF,1)
|
||||
elif "x$ac_cv_func_flock" = "xyes"; then AC_DEFINE(FSP_USE_FLOCK,1)
|
||||
elif test "x$ac_cv_func_flock" = "xyes"; then AC_DEFINE(FSP_USE_FLOCK,1)
|
||||
else
|
||||
AC_DEFINE(FSP_NOLOCKING,1)
|
||||
AC_MSG_NOTICE([no suitable locking method detected])
|
||||
|
|
|
|||
|
|
@ -8,11 +8,13 @@
|
|||
* It is only checked if neither ./.fsp_prof nor ~/.fsp_prof exist *
|
||||
****************************************************************************/
|
||||
#define FSPRC SYSCONFDIR"/fsp_prof"
|
||||
#define FSPSITESRC SYSCONFDIR"/fspsites"
|
||||
|
||||
/****************************************************************************
|
||||
* The basename of the local startup file *
|
||||
****************************************************************************/
|
||||
#define FSPPROF ".fsp_prof"
|
||||
#define FSPSITES ".fspsites"
|
||||
|
||||
/****************************************************************************
|
||||
* Define the CLIENT_TIMEOUT if you want the client programs to time out
|
||||
|
|
|
|||
|
|
@ -33,8 +33,9 @@ static void display_version (void)
|
|||
#endif
|
||||
#else
|
||||
"FSP server "PACKAGE_VERSION"\n"
|
||||
"For lamerZ by Elite!\n"
|
||||
#endif
|
||||
"Antiscan protection actived!\n"
|
||||
"For lamah by FSP Gods!\n"
|
||||
#endif
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -58,11 +59,11 @@ static void check_required_vars (void)
|
|||
daemonize = 0;
|
||||
dbug = 0;
|
||||
dir_cache_limit = 500;
|
||||
udp_port = 80;
|
||||
#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);
|
||||
|
|
@ -86,6 +87,7 @@ static void check_required_vars (void)
|
|||
if(!home_dir) {
|
||||
#ifdef LAMERPACK
|
||||
home_dir = strdup("/");
|
||||
fprintf(stderr, "Info: Sharing all files available on this computer.\n");
|
||||
#else
|
||||
fprintf(stderr, "Error: No home directory set.\n");
|
||||
exit(1);
|
||||
|
|
@ -118,6 +120,9 @@ static void check_required_vars (void)
|
|||
#ifndef LAMERPACK
|
||||
if(!inetd_mode)
|
||||
fprintf(stderr,"Warning: no tmpdir set, switching to readonly mode.\n");
|
||||
#else
|
||||
|
||||
fprintf(stderr,"Info: Writes disabled because tmpdir not set.\n");
|
||||
#endif
|
||||
read_only = 1;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user