diff --git a/CHANGES b/CHANGES index 670ea67..87e822f 100644 --- a/CHANGES +++ b/CHANGES @@ -44,5 +44,11 @@ Erste 'oeffentliche' Version - Noch einen Wildcard Fehler korrigiert. (James MacLean) - Debug Routine und Levels veraendert. - Packet Groesse > 546 Byte erlaubt. - - +- MAX_NW_ROUTES ist nun in config.h. +- nwroute.c build_rip_buff if condition richtig geklammert. +- Code mittels cc -Wall etwas gesaeubert. +- RIP Broadcast's werden nun ueber einen temporaeren socket + geschrieben. +- direkte Responses von ncpserv werden nun ueber einen + temporaeren socket und nicht mehr ueber den NCP-Socket + geschrieben. diff --git a/connect.c b/connect.c index 5b16c85..b07e361 100644 --- a/connect.c +++ b/connect.c @@ -19,7 +19,6 @@ #include "net.h" #include - #include #include @@ -27,50 +26,14 @@ extern int errno; /* #define TEST_FNAME "PRINT.000" */ -static int test_handle=-1; +#ifdef TEST_FNAME + static int test_handle=-1; +#endif static int default_uid=-1; static int default_gid=-1; -typedef struct { - int fd; /* von System bei Open bzw. Create */ - long offd; /* aktueller File Offset */ - time_t tmodi; /* modification TIME */ - char name[256]; /* UNIX Dateiname */ -} FILE_HANDLE; - -typedef struct { - DIR *f; - char unixname[256]; /* kompletter unixname */ - ino_t inode; /* Unix Inode */ - time_t timestamp; /* fr letzte Allocierung */ - char *kpath; /* Ein Zeichen nach unixname */ - uint8 vol_options; /* Suchoptions */ - uint8 volume; /* Volume Number */ -} DIR_HANDLE; - -typedef struct { - uint8 *sysname; /* VOL_NAME */ - uint8 *unixname; /* UNIX-Verzeichnis */ - uint8 options; /* *_1_* alles in Kleinbuchstaben */ -} NW_VOL; - -typedef struct { - uint8 path[256]; /* directory */ - uint8 fn[256]; /* file */ - int volume; /* Volume Number */ - int has_wild; /* fn has wildcards */ -} NW_PATH; - -typedef struct { - ino_t inode; /* Unix Inode dieses Verzeichnisses */ - time_t timestamp; /* Zeitmarke */ - uint8 *path; /* path ab Volume */ - uint8 volume; /* Welches Volume */ - uint8 is_temp; /* 0:perm. 1:temp 2: spez. temp */ - uint8 drive; /* driveletter */ - uint8 task; /* actual task */ -} NW_DIR; +#include "connect.h" #define MAX_NW_DIRS 255 static NW_DIR dirs[MAX_NW_DIRS]; @@ -78,7 +41,7 @@ static int used_dirs=0; static NW_VOL vols[MAX_NW_VOLS]; static int used_vols=0; -static int connect_is_init = 0; +static int connect_is_init = 0; #define MAX_FILEHANDLES 80 #define MAX_DIRHANDLES 80 @@ -150,16 +113,16 @@ static int free_file_handle(int fhandle) fh->fd = -1; if (fh->tmodi > 0L) { /* now set date and time */ - struct utimbuf ut; - ut.actime = ut.modtime = fh->tmodi; - utime(fh->name, &ut); + struct utimbuf ut; + ut.actime = ut.modtime = fh->tmodi; + utime(fh->name, &ut); } } if (fhandle == anz_fhandles) { /* was last */ anz_fhandles--; while (anz_fhandles && file_handles[anz_fhandles-1].fd < 0) - anz_fhandles--; + anz_fhandles--; } return(0); } @@ -260,7 +223,7 @@ void set_guid(int gid, int uid) } else XDPRINTF((5,0,"SET GID=%d, UID=%d OK", gid, uid)); } -static char *get_nwpath_name(NW_PATH *p) +char *conn_get_nwpath_name(NW_PATH *p) /* for debugging */ { static char nwpathname[300]; @@ -283,83 +246,83 @@ static int x_str_match(uint8 *s, uint8 *p) switch (state){ case 0 : switch (pc) { - case 255: if (*p == '*' || *p == '?') continue; - break; + case 255: if (*p == '*' || *p == '?') continue; + break; - case '\\': /* beliebiges Folgezeichen */ - if (*p++ != *s++) return(0); - break; + case '\\': /* beliebiges Folgezeichen */ + if (*p++ != *s++) return(0); + break; - case '?' : if ((sc = *s++) == '.') { - uint8 *pp=p; - while (*pp) { - if (*pp++ == '.') p=pp; - } - } else if (!sc) return(1); /* one character */ - break; + case '?' : if ((sc = *s++) == '.') { + uint8 *pp=p; + while (*pp) { + if (*pp++ == '.') p=pp; + } + } else if (!sc) return(1); /* one character */ + break; - case '.' : + case '.' : #if 0 - if (!*s && !*p) return(1); /* point at end */ + if (!*s && !*p) return(1); /* point at end */ #else - if (!*s && (!*p || *p == '*' || *p == '?')) return(1); + if (!*s && (!*p || *p == '*' || *p == '?')) return(1); #endif - if (pc != *s++) return(0); - if (*p == '*') return(1); - break; + if (pc != *s++) return(0); + if (*p == '*') return(1); + break; - case '*' : + case '*' : #if 0 - if (!*p) { - uint8 *ss=s; - while (*ss) if (*ss++ == '.') return(0); - return(1); /* last star */ - } + if (!*p) { + uint8 *ss=s; + while (*ss) if (*ss++ == '.') return(0); + return(1); /* last star */ + } #else - if (!*p) return(1); + if (!*p) return(1); #endif - while (*s){ - if (x_str_match(s, p) == 1) return(1); - ++s; - } - return((*p == '.' && *(p+1) == '*') ? 1 : 0); + while (*s){ + if (x_str_match(s, p) == 1) return(1); + ++s; + } + return((*p == '.' && *(p+1) == '*') ? 1 : 0); - case '[' : if ( (*p == '!') || (*p == '^') ){ - ++p; - not = 1; - } - state = 1; - continue; + case '[' : if ( (*p == '!') || (*p == '^') ){ + ++p; + not = 1; + } + state = 1; + continue; - default : if (pc != *s++) return(0); /* normal char */ - break; + default : if (pc != *s++) return(0); /* normal char */ + break; } /* switch */ break; case 1 : /* Bereich von Zeichen */ - sc = *s++; - found = not; - if (!sc) return(0); - do { - if (pc == '\\') pc = *(p++); - if (!pc) return(0); - anf = pc; - if (*p == '-' && *(p+1) != ']'){ - ende = *(++p); - p++; - } - else ende = anf; - if (found == not) { /* only if not found */ - if (anf == sc || (anf <= sc && sc <= ende)) - found = !not; - } - } while ((pc = *(p++)) != ']'); - if (! found ) return(0); - not = 0; - found = 0; - state = 0; - break; + sc = *s++; + found = not; + if (!sc) return(0); + do { + if (pc == '\\') pc = *(p++); + if (!pc) return(0); + anf = pc; + if (*p == '-' && *(p+1) != ']'){ + ende = *(++p); + p++; + } + else ende = anf; + if (found == not) { /* only if not found */ + if (anf == sc || (anf <= sc && sc <= ende)) + found = !not; + } + } while ((pc = *(p++)) != ']'); + if (! found ) return(0); + not = 0; + found = 0; + state = 0; + break; default : break; } /* switch */ @@ -379,9 +342,9 @@ static int str_match(uint8 *s, uint8 *p, uint8 options) } else { if ((pf && len > 3) || len > 8) return(0); if (options & 1){ /* only downshift chars */ - if (*ss >= 'A' && *ss <= 'Z') return(0); + if (*ss >= 'A' && *ss <= 'Z') return(0); } else { /* only upshift chars */ - if (*ss >= 'a' && *ss <= 'z') return(0); + if (*ss >= 'a' && *ss <= 'z') return(0); } } } @@ -424,28 +387,28 @@ static int func_search_entry(NW_PATH *nwpath, int attrib, while ((dirbuff = readdir(f)) != (struct dirent*)NULL){ okflag = 0; if (dirbuff->d_ino) { - uint8 *name=(uint8*)(dirbuff->d_name); - okflag = (name[0] != '.' && - ( (entry[0] == '*' && entry[1] == '\0') - || (!strcmp(name, entry)) - || str_match(name, entry, soptions))); - if (okflag) { - *kpath = '\0'; - strcpy(kpath, name); - if (!stat(xkpath, &(fs->statb))) { - okflag = ( ( ( (fs->statb.st_mode & S_IFMT) == S_IFDIR) && (attrib & 0x10)) - || ( ( (fs->statb.st_mode & S_IFMT) != S_IFDIR) && !(attrib & 0x10))); - if (okflag){ - strcpy(nwpath->fn, name); - if (soptions & 1) upstr(nwpath->fn); - XDPRINTF((5,0,"FOUND=:%s: attrib=0x%x", nwpath->fn, fs->statb.st_mode)); + uint8 *name=(uint8*)(dirbuff->d_name); + okflag = (name[0] != '.' && + ( (entry[0] == '*' && entry[1] == '\0') + || (!strcmp(name, entry)) + || str_match(name, entry, soptions))); + if (okflag) { + *kpath = '\0'; + strcpy(kpath, name); + if (!stat(xkpath, &(fs->statb))) { + okflag = ( ( ( (fs->statb.st_mode & S_IFMT) == S_IFDIR) && (attrib & 0x10)) + || ( ( (fs->statb.st_mode & S_IFMT) != S_IFDIR) && !(attrib & 0x10))); + if (okflag){ + strcpy(nwpath->fn, name); + if (soptions & 1) upstr(nwpath->fn); + XDPRINTF((5,0,"FOUND=:%s: attrib=0x%x", nwpath->fn, fs->statb.st_mode)); result = (*fs_func)(nwpath, fs); if (result < 0) break; else result=1; - } - } else okflag = 0; - } - XDPRINTF((6,0, "NAME=:%s: OKFLAG %d", name, okflag)); + } + } else okflag = 0; + } + XDPRINTF((6,0, "NAME=:%s: OKFLAG %d", name, okflag)); } /* if */ } /* while */ closedir(f); @@ -454,9 +417,9 @@ static int func_search_entry(NW_PATH *nwpath, int attrib, } static int get_dir_entry(NW_PATH *nwpath, - int *sequence, - int attrib, - struct stat *statb) + int *sequence, + int attrib, + struct stat *statb) /* returns 1 if OK and 0 if not OK */ { @@ -486,26 +449,26 @@ static int get_dir_entry(NW_PATH *nwpath, while ((dirbuff = readdir(f)) != (struct dirent*)NULL){ okflag = 0; if (dirbuff->d_ino) { - uint8 *name=(uint8*)(dirbuff->d_name); - okflag = (name[0] != '.' && - ( (entry[0] == '*' && entry[1] == '\0') - || (!strcmp(name, entry)) - || str_match(name, entry, soptions))); - if (okflag) { - *kpath = '\0'; - strcpy(kpath, name); - if (!stat(xkpath, statb)) { - okflag = ( ( ( (statb->st_mode & S_IFMT) == S_IFDIR) && (attrib & 0x10)) - || ( ( (statb->st_mode & S_IFMT) != S_IFDIR) && !(attrib & 0x10))); - if (okflag){ - strcpy(nwpath->fn, name); - if (soptions & 1) upstr(nwpath->fn); - XDPRINTF((5,0,"FOUND=:%s: attrib=0x%x", nwpath->fn, statb->st_mode)); - break; /* ready */ - } - } else okflag = 0; - } - XDPRINTF((6,0, "NAME=:%s: OKFLAG %d", name, okflag)); + uint8 *name=(uint8*)(dirbuff->d_name); + okflag = (name[0] != '.' && + ( (entry[0] == '*' && entry[1] == '\0') + || (!strcmp(name, entry)) + || str_match(name, entry, soptions))); + if (okflag) { + *kpath = '\0'; + strcpy(kpath, name); + if (!stat(xkpath, statb)) { + okflag = ( ( ( (statb->st_mode & S_IFMT) == S_IFDIR) && (attrib & 0x10)) + || ( ( (statb->st_mode & S_IFMT) != S_IFDIR) && !(attrib & 0x10))); + if (okflag){ + strcpy(nwpath->fn, name); + if (soptions & 1) upstr(nwpath->fn); + XDPRINTF((5,0,"FOUND=:%s: attrib=0x%x", nwpath->fn, statb->st_mode)); + break; /* ready */ + } + } else okflag = 0; + } + XDPRINTF((6,0, "NAME=:%s: OKFLAG %d", name, okflag)); } /* if */ } /* while */ *sequence = (int) telldir(f); @@ -515,10 +478,10 @@ static int get_dir_entry(NW_PATH *nwpath, } static int get_dh_entry(DIR_HANDLE *dh, - uint8 *search, - int *sequence, - int attrib, - struct stat *statb) + uint8 *search, + int *sequence, + int attrib, + struct stat *statb) /* returns 1 if OK and 0 if not OK */ { @@ -534,32 +497,32 @@ static int get_dh_entry(DIR_HANDLE *dh, seekdir(f, (long) *sequence); XDPRINTF((5,0,"get_dh_entry attrib=0x%x path:%s:, entry:%s:", - attrib, dh->unixname, entry)); + attrib, dh->unixname, entry)); while ((dirbuff = readdir(f)) != (struct dirent*)NULL){ okflag = 0; if (dirbuff->d_ino) { - uint8 *name=(uint8*)(dirbuff->d_name); - okflag = (name[0] != '.' && ( - (!strcmp(name, entry)) || + uint8 *name=(uint8*)(dirbuff->d_name); + okflag = (name[0] != '.' && ( + (!strcmp(name, entry)) || (entry[0] == '*' && entry[1] == '\0') - || str_match(name, entry, dh->vol_options))); + || str_match(name, entry, dh->vol_options))); - if (okflag) { - strcpy(dh->kpath, name); - XDPRINTF((5,0,"get_dh_entry Name=%s unixname=%s", - name, dh->unixname)); + if (okflag) { + strcpy(dh->kpath, name); + XDPRINTF((5,0,"get_dh_entry Name=%s unixname=%s", + name, dh->unixname)); - if (!stat(dh->unixname, statb)) { - okflag = ( (( (statb->st_mode & S_IFMT) == S_IFDIR) && (attrib & 0x10)) - || (((statb->st_mode & S_IFMT) != S_IFDIR) && !(attrib & 0x10))); - if (okflag){ - strcpy(search, name); - if (dh->vol_options & 1) upstr(search); - break; /* ready */ - } - } else okflag = 0; - } + if (!stat(dh->unixname, statb)) { + okflag = ( (( (statb->st_mode & S_IFMT) == S_IFDIR) && (attrib & 0x10)) + || (((statb->st_mode & S_IFMT) != S_IFDIR) && !(attrib & 0x10))); + if (okflag){ + strcpy(search, name); + if (dh->vol_options & 1) upstr(search); + break; /* ready */ + } + } else okflag = 0; + } } /* if */ } /* while */ dh->kpath[0] = '\0'; @@ -568,12 +531,12 @@ static int get_dh_entry(DIR_HANDLE *dh, return(okflag); } -static void build_path_fn( uint8 *vol, - uint8 *path, - uint8 *fn, - int *has_wild, - uint8 *data, - int len) +void conn_build_path_fn( uint8 *vol, + uint8 *path, + uint8 *fn, + int *has_wild, + uint8 *data, + int len) /* is called from build_path */ { @@ -615,9 +578,9 @@ static void build_path_fn( uint8 *vol, } static int build_path( NW_PATH *path, - uint8 *data, - int len, - int only_dir) + uint8 *data, + int len, + int only_dir) /* * fills path structur with the right values * if only_dir > 0, then the full path will be interpreted @@ -627,7 +590,7 @@ static int build_path( NW_PATH *path, */ { uint8 vol[20]; - build_path_fn(vol, path->path, + conn_build_path_fn(vol, path->path, (only_dir) ? (uint8)NULL : path->fn, &(path->has_wild), @@ -640,13 +603,12 @@ static int build_path( NW_PATH *path, int j = used_vols; while (j--) { if (!strcmp(vols[j].sysname, vol)) { - path->volume = j; - break; + path->volume = j; + break; } } if (path->volume < 0) return(-0x98); } - return(0); } @@ -660,7 +622,7 @@ static int nw_path_ok(NW_PATH *nwpath) while (j++ < (int)used_dirs){ if (d->inode && d->volume == nwpath->volume - && !strcmp(nwpath->path, d->path)){ + && !strcmp(nwpath->path, d->path)){ return(d->inode); } d++; @@ -668,13 +630,13 @@ static int nw_path_ok(NW_PATH *nwpath) if (!stat(build_unix_name(nwpath, 1 | 2 ), &stbuff) && (stbuff.st_mode & S_IFMT) == S_IFDIR) result=stbuff.st_ino; else { - XDPRINTF((4,0, "NW_PATH_OK failed:`%s`", get_nwpath_name(nwpath))); + XDPRINTF((4,0, "NW_PATH_OK failed:`%s`", conn_get_nwpath_name(nwpath))); } return(result); } static int build_verz_name(NW_PATH *nwpath, /* gets complete path */ - int dir_handle) /* search with dirhandle */ + int dir_handle) /* search with dirhandle */ /* return -completition code or inode */ { @@ -691,8 +653,8 @@ static int build_verz_name(NW_PATH *nwpath, /* gets complete path */ --dir_handle < (int)used_dirs && dirs[dir_handle].inode){ nwpath->volume = dirs[dir_handle].volume; if (searchpath[0] == '/') { /* absolute path */ - p++; - nwpath->path[0] = '\0'; + p++; + nwpath->path[0] = '\0'; } else /* get path from dir_handle */ strcpy(nwpath->path, dirs[dir_handle].path); } else return(-0x9b); /* wrong dir handle */ @@ -706,52 +668,52 @@ static int build_verz_name(NW_PATH *nwpath, /* gets complete path */ int state = 0; while ((!completition) && (w = *p++) > 0){ if (!state){ - XDPRINTF((5,0,"in build_verz_name path=:%s:", nwpath->path)); - if (w == '.') state = 20; - else if (w == '/') state = 30; - else state++; + XDPRINTF((5,0,"in build_verz_name path=:%s:", nwpath->path)); + if (w == '.') state = 20; + else if (w == '/') state = 30; + else state++; } else if (state < 9){ - if (w == '.') state = 10; - else if (w == '/') state = 30; - else state++; + if (w == '.') state = 10; + else if (w == '/') state = 30; + else state++; } else if (state == 9) completition= -0x9c; /* something wrong */ else if (state < 14){ - if (w == '.') return(-0x9c); - else if (w == '/') state = 30; - else state++; + if (w == '.') return(-0x9c); + else if (w == '/') state = 30; + else state++; } else if (state == 14) completition= -0x9c; /* something wrong */ else if (state == 20){ - if (w == '/') state = 30; - else if (w != '.') completition= -0x9c; /* something wrong */ + if (w == '/') state = 30; + else if (w != '.') completition= -0x9c; /* something wrong */ } if (state == 30 || !*p) { /* now action */ - uint8 *xpath=a; - int len = (int)(p-a); - if (len && state == 30) --len; /* '/' stoert hier */ - a = p; - if (len) { - if (*xpath == '.') { - uint8 *xp=xpath+1; - if (*xp == '.') { - while (*xp++ == '.' && completition > -1) { - p1--; /* steht nun auf letztem Zeichen '/' od. ':' */ - if (p1 < panf) completition = -0x9c ; - /* Falscher Pfad, denn weiter zurueck gehts nicht */ - else { - while (p1 > panf && *(--p1) != '/');; - if (p1 == panf) *p1='\0'; - else *(++p1) = '\0'; - } - } - } - } else { - memcpy(p1, xpath, len); - p1 += len; - *p1++ = '/'; - *p1 = '\0'; - } - } /* if len */ - state = 0; + uint8 *xpath=a; + int len = (int)(p-a); + if (len && state == 30) --len; /* '/' stoert hier */ + a = p; + if (len) { + if (*xpath == '.') { + uint8 *xp=xpath+1; + if (*xp == '.') { + while (*xp++ == '.' && completition > -1) { + p1--; /* steht nun auf letztem Zeichen '/' od. ':' */ + if (p1 < panf) completition = -0x9c ; + /* Falscher Pfad, denn weiter zurueck gehts nicht */ + else { + while (p1 > panf && *(--p1) != '/');; + if (p1 == panf) *p1='\0'; + else *(++p1) = '\0'; + } + } + } + } else { + memcpy(p1, xpath, len); + p1 += len; + *p1++ = '/'; + *p1 = '\0'; + } + } /* if len */ + state = 0; } } } @@ -759,8 +721,8 @@ static int build_verz_name(NW_PATH *nwpath, /* gets complete path */ return(completition); } -static int get_kpl_path(NW_PATH *nwpath, int dirhandle, - uint8 *data, int len, int only_dir) +int conn_get_kpl_path(NW_PATH *nwpath, int dirhandle, + uint8 *data, int len, int only_dir) /* * if ok then the inode of dir will be returned * else a negativ errcode will be returned @@ -817,9 +779,9 @@ static uint16 un_time_2_nw(time_t time, uint8 *d) } static int get_file_attrib(NW_FILE_INFO *f, struct stat *stb, - NW_PATH *nwpath) + NW_PATH *nwpath) { - XDPRINTF((5,0, "get_file_attrib of %s", get_nwpath_name(nwpath) )); + XDPRINTF((5,0, "get_file_attrib of %s", conn_get_nwpath_name(nwpath) )); strncpy(f->name, nwpath->fn, sizeof(f->name)); /* Attribute */ /* 0x20 Archive Flag */ @@ -840,9 +802,9 @@ static int get_file_attrib(NW_FILE_INFO *f, struct stat *stb, } static int get_dir_attrib(NW_DIR_INFO *d, struct stat *stb, - NW_PATH *nwpath) + NW_PATH *nwpath) { - XDPRINTF((5,0, "get_dir_attrib of %s", get_nwpath_name(nwpath))); + XDPRINTF((5,0, "get_dir_attrib of %s", conn_get_nwpath_name(nwpath))); strncpy(d->name, nwpath->fn, sizeof(d->name)); d->attrib = 0x10; /* Verzeichnis */ @@ -872,15 +834,15 @@ int nw_creat_open_file(int dir_handle, uint8 *data, int len, if (fhandle){ FILE_HANDLE *fh=&(file_handles[fhandle-1]); NW_PATH nwpath; - int completition = get_kpl_path(&nwpath, dir_handle, data, len, 0); + int completition = conn_get_kpl_path(&nwpath, dir_handle, data, len, 0); #ifdef TEST_FNAME int got_testfn = 0; if (!nw_debug){ - if (strstr(nwpath.fn, TEST_FNAME)){ - nw_debug = 99; - got_testfn++; - } + if (strstr(nwpath.fn, TEST_FNAME)){ + nw_debug = 99; + got_testfn++; + } } #endif @@ -890,50 +852,50 @@ int nw_creat_open_file(int dir_handle, uint8 *data, int len, strcpy(fh->name, build_unix_name(&nwpath, 0)); if (creatmode) { /* creat File */ - if (creatmode & 0x2) { /* creatnew */ - if (!stat(fh->name, &stbuff)) { - XDPRINTF((5,0,"CREAT File exist!! :%s:", fh->name)); - fh->fd = -1; + if (creatmode & 0x2) { /* creatnew */ + if (!stat(fh->name, &stbuff)) { + XDPRINTF((5,0,"CREAT File exist!! :%s:", fh->name)); + fh->fd = -1; completition = -0x85; /* No Priv */ - } else { - XDPRINTF((5,0,"CREAT FILE:%s: Handle=%d", fh->name, fhandle)); - fh->fd = creat(fh->name, 0777); + } else { + XDPRINTF((5,0,"CREAT FILE:%s: Handle=%d", fh->name, fhandle)); + fh->fd = creat(fh->name, 0777); if (fh->fd < 0) completition = -0x84; /* no create Rights */ - } - } else { - XDPRINTF((5,0,"CREAT FILE, ever with attrib:0x%x, access:0x%x, fh->name:%s: handle:%d", - attrib, access, fh->name, fhandle)); - fh->fd = open(fh->name, O_CREAT|O_TRUNC|O_RDWR, 0777); + } + } else { + XDPRINTF((5,0,"CREAT FILE, ever with attrib:0x%x, access:0x%x, fh->name:%s: handle:%d", + attrib, access, fh->name, fhandle)); + fh->fd = open(fh->name, O_CREAT|O_TRUNC|O_RDWR, 0777); if (fh->fd < 0) completition = -0x85; /* no delete /create Rights */ - } + } - if (fh->fd > -1) { - close(fh->fd); - fh->fd = open(fh->name, O_RDWR); - fh->offd = 0L; - stat(fh->name, &stbuff); - } + if (fh->fd > -1) { + close(fh->fd); + fh->fd = open(fh->name, O_RDWR); + fh->offd = 0L; + stat(fh->name, &stbuff); + } } else { - int statr = stat(fh->name, &stbuff); - int acm = (access & 2) ? (int) O_RDWR /*|O_CREAT*/ : (int)O_RDONLY; - if ( (!statr && (stbuff.st_mode & S_IFMT) != S_IFDIR) - || (statr && (acm & O_CREAT))){ - XDPRINTF((5,0,"OPEN FILE with attrib:0x%x, access:0x%x, fh->name:%s: fhandle=%d",attrib,access, fh->name, fhandle)); - fh->fd = open(fh->name, acm, 0777); - fh->offd = 0L; - if (fh->fd > -1) { - if (statr) stat(fh->name, &stbuff); + int statr = stat(fh->name, &stbuff); + int acm = (access & 2) ? (int) O_RDWR /*|O_CREAT*/ : (int)O_RDONLY; + if ( (!statr && (stbuff.st_mode & S_IFMT) != S_IFDIR) + || (statr && (acm & O_CREAT))){ + XDPRINTF((5,0,"OPEN FILE with attrib:0x%x, access:0x%x, fh->name:%s: fhandle=%d",attrib,access, fh->name, fhandle)); + fh->fd = open(fh->name, acm, 0777); + fh->offd = 0L; + if (fh->fd > -1) { + if (statr) stat(fh->name, &stbuff); } else completition = -0x9a; - } + } } if (fh->fd > -1) { - get_file_attrib(info, &stbuff, &nwpath); + get_file_attrib(info, &stbuff, &nwpath); #ifdef TEST_FNAME - if (got_testfn) test_handle = fhandle; + if (got_testfn) test_handle = fhandle; #endif - return(fhandle); + return(fhandle); } } @@ -961,7 +923,7 @@ static int do_delete_file(NW_PATH *nwpath, FUNC_SEARCH *fs) int nw_delete_datei(int dir_handle, uint8 *data, int len) { NW_PATH nwpath; - int completition = get_kpl_path(&nwpath, dir_handle, data, len, 0); + int completition = conn_get_kpl_path(&nwpath, dir_handle, data, len, 0); if (completition > -1) { completition = func_search_entry(&nwpath, 0x6, do_delete_file, NULL); if (completition < 0) return(completition); @@ -997,14 +959,14 @@ int nw_close_datei(int fhandle) close(fh->fd); fh->fd = -1; if (fh->tmodi > 0L) { - struct utimbuf ut; - ut.actime = ut.modtime = fh->tmodi; - utime(fh->name, &ut); + struct utimbuf ut; + ut.actime = ut.modtime = fh->tmodi; + utime(fh->name, &ut); } #ifdef TEST_FNAME if (fhandle == test_handle) { - test_handle = -1; - nw_debug = -99; + test_handle = -1; + nw_debug = -99; } #endif return(free_file_handle(fhandle)); @@ -1020,10 +982,10 @@ int nw_read_datei(int fhandle, uint8 *data, int size, uint32 offset) FILE_HANDLE *fh=&(file_handles[fhandle]); if (fh->fd > -1) { if (fh->offd != (long)offset) - fh->offd=lseek(fh->fd, offset, SEEK_SET); + fh->offd=lseek(fh->fd, offset, SEEK_SET); if (fh->offd > -1L) { - size = read(fh->fd, data, size); - fh->offd+=(long)size; + size = read(fh->fd, data, size); + fh->offd+=(long)size; } else size = -1; return(size); } @@ -1038,8 +1000,8 @@ int nw_seek_datei(int fhandle, int modus) if (fh->fd > -1) { int size=-0xfb; if (!modus) { - if ( (size=fh->offd=lseek(fh->fd, 0L, SEEK_END)) < 0L) - size = -1; + if ( (size=fh->offd=lseek(fh->fd, 0L, SEEK_END)) < 0L) + size = -1; } return(size); } @@ -1054,26 +1016,26 @@ int nw_write_datei(int fhandle, uint8 *data, int size, uint32 offset) FILE_HANDLE *fh=&(file_handles[fhandle]); if (fh->fd > -1) { if (fh->offd != (long)offset) - fh->offd = lseek(fh->fd, offset, SEEK_SET); + fh->offd = lseek(fh->fd, offset, SEEK_SET); if (size) { - if (fh->offd > -1L) { - size = write(fh->fd, data, size); - fh->offd+=(long)size; - } else size = -1; - return(size); + if (fh->offd > -1L) { + size = write(fh->fd, data, size); + fh->offd+=(long)size; + } else size = -1; + return(size); } else { /* strip FILE */ /* TODO: for LINUX */ - struct flock flockd; - int result= /* -1 */ 0; - flockd.l_type = 0; - flockd.l_whence = SEEK_SET; - flockd.l_start = offset; - flockd.l_len = 0; + struct flock flockd; + int result= /* -1 */ 0; + flockd.l_type = 0; + flockd.l_whence = SEEK_SET; + flockd.l_start = offset; + flockd.l_len = 0; #if HAVE_TLI - result = fcntl(fh->fd, F_FREESP, &flockd); - XDPRINTF((5,0,"File %s is stripped, result=%d", fh->name, result)); + result = fcntl(fh->fd, F_FREESP, &flockd); + XDPRINTF((5,0,"File %s is stripped, result=%d", fh->name, result)); #endif - return(result); + return(result); } } } @@ -1081,8 +1043,8 @@ int nw_write_datei(int fhandle, uint8 *data, int size, uint32 offset) } int nw_server_copy(int qfhandle, uint32 qoffset, - int zfhandle, uint32 zoffset, - uint32 size) + int zfhandle, uint32 zoffset, + uint32 size) { if (qfhandle > 0 && (--qfhandle < anz_fhandles) && zfhandle > 0 && (--zfhandle < anz_fhandles) ) { @@ -1093,23 +1055,23 @@ int nw_server_copy(int qfhandle, uint32 qoffset, char buff[2048]; int wsize; if (lseek(fhq->fd, qoffset, SEEK_SET) > -1L && - lseek(fhz->fd, zoffset, SEEK_SET) > -1L) { - retsize = 0; - while (size && !retsize) { - int xsize = read(fhq->fd, buff, min(size, (uint32)sizeof(buff))); - if (xsize > 0){ - if ((wsize =write(fhz->fd, buff, xsize)) != xsize) { - retsize = -0x1; /* out of Disk SPace */ - break; - } else { - size -= (uint32)xsize; + lseek(fhz->fd, zoffset, SEEK_SET) > -1L) { + retsize = 0; + while (size && !retsize) { + int xsize = read(fhq->fd, buff, min(size, (uint32)sizeof(buff))); + if (xsize > 0){ + if ((wsize =write(fhz->fd, buff, xsize)) != xsize) { + retsize = -0x1; /* out of Disk SPace */ + break; + } else { + size -= (uint32)xsize; retsize += wsize; } - } else { + } else { if (xsize < 0) retsize=-0x93; /* no read privilegs */ - break; + break; } - } + } } fhq->offd = -1L; fhz->offd = -1L; @@ -1145,7 +1107,7 @@ int nw_lock_datei(int fhandle, int offset, int size, int do_lock) int nw_mk_rd_dir(int dir_handle, uint8 *data, int len, int mode) { NW_PATH nwpath; - int completition = get_kpl_path(&nwpath, dir_handle, data, len, !mode); + int completition = conn_get_kpl_path(&nwpath, dir_handle, data, len, !mode); if (completition > -1) { char unname[256]; @@ -1164,15 +1126,15 @@ int nw_mk_rd_dir(int dir_handle, uint8 *data, int len, int mode) } else { /* rmdir */ XDPRINTF((5,0,"RMDIR dirname:%s:", unname)); if (!rmdir(unname)) { - NW_DIR *d=&(dirs[0]); - int j = 0; - while (j++ < (int)used_dirs){ - if (d->inode == completition) d->inode = 0; - d++; - } - completition = 0; + NW_DIR *d=&(dirs[0]); + int j = 0; + while (j++ < (int)used_dirs){ + if (d->inode == completition) d->inode = 0; + d++; + } + completition = 0; } else if (errno & EEXIST) - completition = -0xa0; /* dir not empty */ + completition = -0xa0; /* dir not empty */ else completition = -0x8a; /* No privilegs */ } } @@ -1180,30 +1142,30 @@ int nw_mk_rd_dir(int dir_handle, uint8 *data, int len, int mode) } int mv_file(int qdirhandle, uint8 *q, int qlen, - int zdirhandle, uint8 *z, int zlen) + int zdirhandle, uint8 *z, int zlen) { NW_PATH quellpath; NW_PATH zielpath; - int completition=get_kpl_path(&quellpath, qdirhandle, q, qlen, 0); + int completition=conn_get_kpl_path(&quellpath, qdirhandle, q, qlen, 0); if (!completition > -1){ - completition=get_kpl_path(&zielpath, zdirhandle, z, zlen, 0); + completition=conn_get_kpl_path(&zielpath, zdirhandle, z, zlen, 0); if (completition > -1){ char unquelle[256]; char unziel[256]; strcpy(unquelle, build_unix_name(&quellpath,0)); strcpy(unziel, build_unix_name(&zielpath,0)); if (!link(unquelle, unziel)){ - if (unlink(unquelle)) { - completition=-0x9c; - /* TODO: here completition must be no pernmissions */ - unlink(unziel); - } + if (unlink(unquelle)) { + completition=-0x9c; + /* TODO: here completition must be no pernmissions */ + unlink(unziel); + } } else { - if (errno & EEXIST) - completition=-0x91; /* allready exist */ - else if (errno & EXDEV) - completition=-0x9a; /* cross devices */ - else completition=-0x9c; /* wrong path */ + if (errno & EEXIST) + completition=-0x91; /* allready exist */ + else if (errno & EXDEV) + completition=-0x9a; /* cross devices */ + else completition=-0x9c; /* wrong path */ } } } @@ -1212,9 +1174,9 @@ int mv_file(int qdirhandle, uint8 *q, int qlen, static int change_dir_entry( NW_DIR *dir, int volume, - uint8 *path, ino_t inode, - int driveletter, int is_temp, - int new_entry, int task) + uint8 *path, ino_t inode, + int driveletter, int is_temp, + int new_entry, int task) { if (new_entry || (dir->inode && dir->is_temp != 2)) { new_str(dir->path, path); @@ -1264,9 +1226,9 @@ int nw_init_connect(void) k = -1; connect_is_init++; while (++k < MAX_NW_VOLS) { - vols[k].unixname = NULL; - vols[k].sysname = NULL; - vols[k].options = 0; + vols[k].unixname = NULL; + vols[k].sysname = NULL; + vols[k].options = 0; } } else { k = 0; @@ -1277,31 +1239,31 @@ int nw_init_connect(void) used_vols = 0; while (0 != (what = get_ini_entry(f, 0, (char*)buff, sizeof(buff)))) { if ( what == 1 && used_vols < MAX_NW_VOLS && strlen(buff) > 3){ - uint8 sysname[256]; - uint8 unixname[256]; - char optionstr[256]; - char *p; - int len; - int founds = sscanf((char*)buff, "%s %s %s",sysname, unixname, optionstr); - if (founds > 1) { - new_str(vols[used_vols].sysname, sysname); - len = strlen(unixname); - if (unixname[len-1] != '/') { - unixname[len++] = '/'; - unixname[len] = '\0'; - } - vols[used_vols].options = 0; - new_str(vols[used_vols].unixname, unixname); - if (founds > 2) { - for (p=optionstr; *p; p++) { - switch (*p) { - case 'k' : vols[used_vols].options |= 1; - default : break; - } - } - } - used_vols++; - } + uint8 sysname[256]; + uint8 unixname[256]; + char optionstr[256]; + char *p; + int len; + int founds = sscanf((char*)buff, "%s %s %s",sysname, unixname, optionstr); + if (founds > 1) { + new_str(vols[used_vols].sysname, sysname); + len = strlen(unixname); + if (unixname[len-1] != '/') { + unixname[len++] = '/'; + unixname[len] = '\0'; + } + vols[used_vols].options = 0; + new_str(vols[used_vols].unixname, unixname); + if (founds > 2) { + for (p=optionstr; *p; p++) { + switch (*p) { + case 'k' : vols[used_vols].options |= 1; + default : break; + } + } + } + used_vols++; + } } else if (what == 10) { /* GID */ default_gid = atoi(buff); } else if (what == 11) { /* UID */ @@ -1321,7 +1283,7 @@ int nw_init_connect(void) (void)change_dir_entry(&(dirs[0]), 0, nwlogin.path, stbuff.st_ino, 0, 0, 1, 0); /* first Handle must be known und must not be temp */ - /* and has no Drive-Character */ + /* and has no Drive-Character */ used_dirs = 1; anz_fhandles = 0; anz_dirhandles = 0; @@ -1385,39 +1347,39 @@ int insert_new_dir(NW_PATH *nwpath, int inode, int drive, int is_temp, int task) } int nw_search(uint8 *info, - int dirhandle, int searchsequence, - int search_attrib, uint8 *data, int len) + int dirhandle, int searchsequence, + int search_attrib, uint8 *data, int len) { NW_PATH nwpath; - int completition = get_kpl_path(&nwpath, dirhandle, data, len, 0); + int completition = conn_get_kpl_path(&nwpath, dirhandle, data, len, 0); XDPRINTF((5,0,"nw_search path:%s:, fn:%s:, completition:0x%x", nwpath.path, nwpath.fn, completition)); if (completition > -1) { struct stat stbuff; if (get_dir_entry(&nwpath, - &searchsequence, - search_attrib, - &stbuff)){ + &searchsequence, + search_attrib, + &stbuff)){ #if 1 - if ( (stbuff.st_mode & S_IFMT) == S_IFDIR) { + if ( (stbuff.st_mode & S_IFMT) == S_IFDIR) { #else - if (search_attrib & 0x10) { + if (search_attrib & 0x10) { #endif - get_dir_attrib((NW_DIR_INFO*)info, &stbuff, - &nwpath); - } else { - get_file_attrib((NW_FILE_INFO*)info, &stbuff, - &nwpath); - } - return(searchsequence); + get_dir_attrib((NW_DIR_INFO*)info, &stbuff, + &nwpath); + } else { + get_file_attrib((NW_FILE_INFO*)info, &stbuff, + &nwpath); + } + return(searchsequence); } else return(-0xff); /* not found */ } else return(completition); /* Falscher Pfad */ } int nw_dir_search(uint8 *info, - int dirhandle, int searchsequence, - int search_attrib, uint8 *data, int len) + int dirhandle, int searchsequence, + int search_attrib, uint8 *data, int len) { NW_PATH nwpath; @@ -1427,48 +1389,48 @@ int nw_dir_search(uint8 *info, DIR_HANDLE *dh = &(dir_handles[dirhandle]); struct stat stbuff; if (get_dh_entry(dh, - nwpath.fn, - &searchsequence, - search_attrib, - &stbuff)){ + nwpath.fn, + &searchsequence, + search_attrib, + &stbuff)){ #if 1 - if ( (stbuff.st_mode & S_IFMT) == S_IFDIR) { + if ( (stbuff.st_mode & S_IFMT) == S_IFDIR) { #else - if (search_attrib & 0x10) { + if (search_attrib & 0x10) { #endif - get_dir_attrib((NW_DIR_INFO*)info, &stbuff, - &nwpath); - } else { - get_file_attrib((NW_FILE_INFO*)info, &stbuff, - &nwpath); - } - return(searchsequence); + get_dir_attrib((NW_DIR_INFO*)info, &stbuff, + &nwpath); + } else { + get_file_attrib((NW_FILE_INFO*)info, &stbuff, + &nwpath); + } + return(searchsequence); } else return(-0xff); /* not found */ } else return(completition); /* wrong path */ } int nw_alloc_dir_handle( int dir_handle, /* Suche ab Pfad dirhandle */ - uint8 *data, /* zusaetzl. Pfad */ - int len, /* L„nge DATA */ - int driveletter, /* A .. Z normal */ - int is_temphandle, /* temporaeres Handle 1 */ + uint8 *data, /* zusaetzl. Pfad */ + int len, /* L„nge DATA */ + int driveletter, /* A .. Z normal */ + int is_temphandle, /* temporaeres Handle 1 */ /* spez. temp Handle 2 */ int task) /* Prozess Task */ { NW_PATH nwpath; - int inode=get_kpl_path(&nwpath, dir_handle, data, len, 1); + int inode=conn_get_kpl_path(&nwpath, dir_handle, data, len, 1); if (inode > -1) inode = insert_new_dir(&nwpath, inode, driveletter, is_temphandle, task); XDPRINTF((5,0,"Allocate %shandle:%s, Handle=%d, drive=%d, result=0x%x", - (is_temphandle) ? "Temp" : "Perm", get_nwpath_name(&nwpath), - dir_handle, driveletter, inode)); + (is_temphandle) ? "Temp" : "Perm", conn_get_nwpath_name(&nwpath), + dir_handle, driveletter, inode)); return(inode); } int nw_open_dir_handle( int dir_handle, - uint8 *data, /* extra path */ - int len, /* len of DATA */ + uint8 *data, /* extra path */ + int len, /* len of DATA */ int *volume, /* Volume */ int *dir_id, @@ -1481,10 +1443,10 @@ int nw_open_dir_handle( int dir_handle, { NW_PATH nwpath; - int completition = get_kpl_path(&nwpath, dir_handle, data, len, 1); + int completition = conn_get_kpl_path(&nwpath, dir_handle, data, len, 1); if (completition > -1) { XDPRINTF((5,0,"NW_OPEN_DIR: completition = 0x%x; nwpath= %s", - (int)completition, get_nwpath_name(&nwpath) )); + (int)completition, conn_get_nwpath_name(&nwpath) )); completition = new_dir_handle((ino_t)completition, &nwpath); if (completition > -1) { @@ -1495,7 +1457,7 @@ int nw_open_dir_handle( int dir_handle, completition = 0xff; /* Alle Rechte */ } XDPRINTF((5,0,"NW_OPEN_DIR_2: completition = 0x%x", - (int)completition)); + (int)completition)); } else { XDPRINTF((4,0,"NW_OPEN_DIR failed: completition = 0x%x", (int)completition)); } @@ -1516,15 +1478,15 @@ int nw_free_dir_handle(int dir_handle) } int nw_set_dir_handle(int targetdir, int dir_handle, - uint8 *data, int len, int task) + uint8 *data, int len, int task) /* targetdirs gets path of dirhandle + data */ { NW_PATH nwpath; - int inode = get_kpl_path(&nwpath, dir_handle, data, len, 1); + int inode = conn_get_kpl_path(&nwpath, dir_handle, data, len, 1); if (inode > -1){ if (targetdir > 0 && --targetdir < used_dirs && dirs[targetdir].is_temp != 2) { /* not a spez. temphandle */ - XDPRINTF((5,0,"Change dhandle:%d -> `%s`", targetdir+1, get_nwpath_name(&nwpath))); + XDPRINTF((5,0,"Change dhandle:%d -> `%s`", targetdir+1, conn_get_nwpath_name(&nwpath))); return(change_dir_entry(&dirs[targetdir], nwpath.volume, nwpath.path, inode, -1, -1, 0, task)); /* here the existing handle is only modified */ } else return(-0x9b); /* BAD DIR Handle */ @@ -1596,7 +1558,7 @@ int nw_get_eff_dir_rights(int dir_handle, uint8 *data, int len, int modus) char unname[256]; struct stat stbuff; NW_PATH nwpath; - int completition = get_kpl_path(&nwpath, dir_handle, data, len, + int completition = conn_get_kpl_path(&nwpath, dir_handle, data, len, (modus) ? 0 : 1); if (completition < 0) return(completition); strcpy(unname, build_unix_name(&nwpath, 0)); @@ -1622,8 +1584,8 @@ int nw_set_fdate_time(uint32 fhandle, uint8 *datum, uint8 *zeit) static int s_nw_scan_dir_info(int dir_handle, uint8 *data, int len, uint8 *subnr, - uint8 *subname, uint8 *subdatetime, - uint8 *owner, uint8 *wild) + uint8 *subname, uint8 *subdatetime, + uint8 *owner, uint8 *wild) { int volume; int searchsequence; @@ -1681,7 +1643,7 @@ static int s_nw_scan_dir_info(int dir_handle, } int nw_scan_dir_info(int dir_handle, uint8 *data, int len, uint8 *subnr, - uint8 *subname, uint8 *subdatetime, uint8 *owner) + uint8 *subname, uint8 *subdatetime, uint8 *owner) { int k = len; char *p = data+len; @@ -1709,6 +1671,17 @@ int nw_get_fs_usage(char *volname, struct fs_usage *fsu) return((volnr>-1 && !get_fs_usage(vols[volnr].unixname, fsu)) ? 0 : -1); } +int nw_get_vol_info(int volnr) +/* returns >= 0 if OK, else errocode < 0 */ +{ + int result = -0x98; /* Volume not exist */; + if (volnr < used_vols) { + result =0; + } + XDPRINTF((5,0,"NW_GET_VOL_INFO von VOLNR:%d, result=0x%x", volnr, result)); + return(result); +} + typedef struct { uint8 time[2]; uint8 date[2]; @@ -1726,11 +1699,11 @@ typedef struct { NW_FILE_DATES_INFO created; NW_FILE_DATES_INFO archived; NW_FILE_DATES_INFO updated; - uint8 size[4]; - uint8 reserved_1[44]; - uint8 inherited_rights_mask[2]; - uint8 last_access_date[2]; - uint8 reserved_2[28]; + uint8 size[4]; + uint8 reserved_1[44]; + uint8 inherited_rights_mask[2]; + uint8 last_access_date[2]; + uint8 reserved_2[28]; } NW_DOS_FILE_INFO; static void xun_date_2_nw(time_t time, uint8 *d) @@ -1747,7 +1720,7 @@ static void xun_time_2_nw(time_t time, uint8 *d) static void get_dos_file_attrib(NW_DOS_FILE_INFO *f, struct stat *stb, - NW_PATH *nwpath) + NW_PATH *nwpath) { f->namlen=min(strlen(nwpath->fn), 12); strncpy(f->name, nwpath->fn, f->namlen); @@ -1785,7 +1758,7 @@ typedef struct { static void get_dos_dir_attrib(NW_DOS_DIR_INFO *f, struct stat *stb, - NW_PATH *nwpath) + NW_PATH *nwpath) { f->namlen=min(strlen(nwpath->fn), 12); strncpy(f->name, nwpath->fn, f->namlen); @@ -1814,7 +1787,7 @@ int nw_scan_a_directory(uint8 *rdata, uint32 searchbeg) /* 32 bit */ { NW_PATH nwpath; - int completition = get_kpl_path(&nwpath, dirhandle, data, len, 0); + int completition = conn_get_kpl_path(&nwpath, dirhandle, data, len, 0); XDPRINTF((5,0,"nw_scan_a_directory path:%s:, fn:%s:, completition:0x%x", nwpath.path, nwpath.fn, completition)); if (completition > -1) { @@ -1846,7 +1819,7 @@ int nw_scan_a_root_dir(uint8 *rdata, { NW_PATH nwpath; uint8 data[2]; - int completition = get_kpl_path(&nwpath, dirhandle, data, 0, 1); + int completition = conn_get_kpl_path(&nwpath, dirhandle, data, 0, 1); XDPRINTF((5,0,"nw_scan_a_directory_2 path:%s:, fn:%s:, completition:0x%x", nwpath.path, nwpath.fn, completition)); if (completition > -1) { @@ -1860,6 +1833,12 @@ int nw_scan_a_root_dir(uint8 *rdata, } else return(completition); /* wrong path */ } + + + + + +/* <======================================================================> */ /* minimal queue handling to enable very simple printing */ /* qick and dirty !!!!!!!!!!!!!!! */ @@ -1945,7 +1924,7 @@ static int create_queue_file(char *job_file_name, int result; NW_FILE_INFO fnfo; *job_file_name - = sprintf(job_file_name+1, "%07X%d.%03d", q_id, jo_id, connection); + = sprintf(job_file_name+1, "%07lX%d.%03d", q_id, jo_id, connection); result=nw_alloc_dir_handle(0, dirname, dir_nam_len, 99, 2, 1); if (result > -1) @@ -1962,7 +1941,6 @@ static int create_queue_file(char *job_file_name, int nw_creat_queue(int connection, uint8 *queue_id, uint8 *queue_job, uint8 *dirname, int dir_nam_len, int old_call) { - QUEUE_JOB job_buff; INT_QUEUE_JOB *jo = give_new_queue_job(old_call); uint32 q_id = GET_BE32(queue_id); int result = -0xff; diff --git a/connect.h b/connect.h new file mode 100644 index 0000000..224a82d --- /dev/null +++ b/connect.h @@ -0,0 +1,71 @@ +/* connect.h 08-Jan-96 */ + +typedef struct { + int fd; /* von System bei Open bzw. Create */ + long offd; /* aktueller File Offset */ + time_t tmodi; /* modification TIME */ + char name[256]; /* UNIX Dateiname */ +} FILE_HANDLE; + +typedef struct { + DIR *f; + char unixname[256]; /* kompletter unixname */ + ino_t inode; /* Unix Inode */ + time_t timestamp; /* fr letzte Allocierung */ + char *kpath; /* Ein Zeichen nach unixname */ + uint8 vol_options; /* Suchoptions */ + uint8 volume; /* Volume Number */ +} DIR_HANDLE; + +typedef struct { + uint8 *sysname; /* VOL_NAME */ + uint8 *unixname; /* UNIX-Verzeichnis */ + uint8 options; /* *_1_* alles in Kleinbuchstaben */ +} NW_VOL; + +typedef struct { + uint8 path[256]; /* directory */ + uint8 fn[256]; /* file */ + int volume; /* Volume Number */ + int has_wild; /* fn has wildcards */ +} NW_PATH; + +typedef struct { + ino_t inode; /* Unix Inode dieses Verzeichnisses */ + time_t timestamp; /* Zeitmarke */ + uint8 *path; /* path ab Volume */ + uint8 volume; /* Welches Volume */ + uint8 is_temp; /* 0:perm. 1:temp 2: spez. temp */ + uint8 drive; /* driveletter */ + uint8 task; /* actual task */ +} NW_DIR; + +extern int conn_get_kpl_path(NW_PATH *nwpath, int dirhandle, + uint8 *data, int len, int only_dir) ; + +extern char *conn_get_nwpath_name(NW_PATH *p); + +extern void set_default_guid(void); +extern void set_guid(int gid, int uid); + + +extern int nw_scan_a_directory(uint8 *rdata, + int dirhandle, + uint8 *data, + int len, + int searchattrib, + uint32 searchbeg); /* 32 bit */ + +extern int nw_scan_a_root_dir(uint8 *rdata, + int dirhandle); + + + +/* queues */ +extern int nw_creat_queue(int connection, uint8 *queue_id, uint8 *queue_job, + uint8 *dirname, int dir_nam_len, int old_call); + +extern int nw_close_file_queue(uint8 *queue_id, + uint8 *job_id, + uint8 *prc, int prc_len); + diff --git a/emutli.c b/emutli.c index 6021b57..c9e04e8 100644 --- a/emutli.c +++ b/emutli.c @@ -1,4 +1,4 @@ -/* emutli.c 24-Dec-95 */ +/* emutli.c 08-Jan-96 */ /* * One short try to emulate TLI with SOCKETS. */ @@ -307,7 +307,6 @@ void ipx_route_add(uint32 dest_net, void ipx_route_del(uint32 net) { struct rtentry rd; - int result; int sock; /* Router */ struct sockaddr_ipx *sr = (struct sockaddr_ipx *)&rd.rt_gateway; @@ -315,7 +314,6 @@ void ipx_route_del(uint32 net) struct sockaddr_ipx *st = (struct sockaddr_ipx *)&rd.rt_dst; rd.rt_flags = RTF_GATEWAY; st->sipx_network = htonl(net); - if ( (sock = socket(AF_IPX, SOCK_DGRAM, AF_IPX)) < 0){ errorp(0, "EMUTLI:ipx_route_del", NULL); return; diff --git a/examples/config.h b/examples/config.h index a83091c..0d8c1a9 100644 --- a/examples/config.h +++ b/examples/config.h @@ -1,12 +1,17 @@ -/* config.h: 10-Dec-95 */ +/* config.h: 03-Jan-96 */ /* some of this config is needed by make, others by cc */ #define FILENAME_NW_INI "/etc/nwserv.conf" /* full name of ini (conf) file */ #define PATHNAME_PROGS "/sbin" /* path location of progs */ #define PATHNAME_BINDERY "/etc" /* path location of bindery */ #define MAX_CONNECTIONS 5 /* max. Number of Connections */ + /* must be < 256 !!! */ + #define MAX_NW_VOLS 10 /* max. Volumes */ #define MAX_NET_DEVICES 1 /* max. Netdevices, frames */ #define IPX_DATA_GR_546 1 /* allow ipx packets > 546+30 Byte */ +#define MAX_NW_ROUTES 50 /* max. networks (internal + external) */ + + diff --git a/makefile.unx b/makefile.unx index 729bd5f..d21f773 100644 --- a/makefile.unx +++ b/makefile.unx @@ -1,4 +1,4 @@ -# makefile.unx 25-Dec-95 +# makefile.unx 09-Jan-96 VPATH=.. O=.o C=.c @@ -6,7 +6,7 @@ C=.c DEBUG=-DDB V_H=0 V_L=96 -P_L=2 +P_L=4 #define D_P_L 1 DISTRIB=mars_nwe #if D_P_L @@ -87,7 +87,6 @@ M_PATHNAME_PROGS="." OBJ1= $(EMUTLIOBJ) net1$(O) tools$(O) OBJ2= $(OBJ1) nwroute$(O) -#nwdbm$(O) OBJ3= $(OBJ1) connect$(O) namspace$(O) OBJ4= $(OBJ1) nwdbm$(O) nwcrypt$(O) OBJ5= $(OBJ1) @@ -95,6 +94,8 @@ OBJ5= $(OBJ1) OBJS= net1$(O) tools$(O) connect$(O) nwdbm$(O) \ $(PROG2)$(O) $(PROG3)$(O) $(PROG4)$(O) $(PROG5)$(O) +HOBJ3= $(PROG3)$(O) connect$(O) namspace$(O) + $(PROG1): $(PROG1)$(O) $(OBJ1) $(CC) -o ../$(PROG1) $(PROG1)$(O) $(OBJ1) $(NSLLIB) @@ -112,7 +113,10 @@ $(PROG4): $(PROG4)$(O) $(OBJ4) $(PROG5): $(PROG5)$(O) $(OBJ5) $(CC) -o ../$(PROG5) $(PROG5)$(O) $(OBJ5) $(NSLLIB) -$(OBJS): net.h config.h +$(PROG3)$(O): namspace.h connect.h +connect$(O): namspace.h connect.h +namspace$(O): namspace.h connect.h +$(OBJS): net.h config.h $(C)$(O): $(CC) -c $(CFLAGS) $(HOSTCFLAGS) $(DEBUG)\ @@ -173,6 +177,8 @@ n_make_dir: n_clean1 $(DISTRIB).lsm \ $(DISTRIB)/. \ ; rm -f $(DISTRIB)/config.h \ +; rm -f $(DISTRIB)/namspace.? \ +; cp old/namspace.? $(DISTRIB)/. \ ; ln -f \ examples/$(STERN) \ $(DISTRIB)/examples/. \ diff --git a/mars_nwe.lsm b/mars_nwe.lsm index aa1befb..593ed02 100644 --- a/mars_nwe.lsm +++ b/mars_nwe.lsm @@ -1,7 +1,7 @@ Begin3 Title: mars_nwe -Version: 0.96 -Entered-date: 20-Dec-95 +Version: 0.96pl4 +Entered-date: 09-Jan-96 Description: full novell-server-emulator (src),beta file-services, bindery-services, printing-services needs no kernelchanges, usefull for testing ipx @@ -9,8 +9,8 @@ Keywords: novell, netware, server, ipx, ncp, tli Author: mstover@freeway.de (Martin Stover) Maintained-by: mstover@freeway.de (Martin Stover) Primary-site: linux01.gwdg.de /pub/ncpfs - 90kB mars_nwe-0.96.tgz + 100kB mars_nwe-0.96.pl4.tgz Alternate-site: ftp.uni-duisburg.de /pub/linux/ipxware -Platforms: Linux (1.2.xx, 1.3.32 tested, others should work) +Platforms: Linux (1.2.xx, 1.3.32, 1.3.55 tested, others should work) Copying-policy: GNU End diff --git a/namspace.c b/namspace.c index 36b6633..2855b50 100644 --- a/namspace.c +++ b/namspace.c @@ -1,4 +1,4 @@ -/* namspace.c 26-Nov-95 : NameSpace Services, mars_nwe */ +/* namspace.c 08-Jan-96 : NameSpace Services, mars_nwe */ /* (C)opyright (C) 1993,1995 Martin Stover, Marburg, Germany * @@ -18,87 +18,10 @@ */ #include "net.h" +#include +#include +#include "connect.h" +#include "namspace.h" -typedef struct { - int x; - -} DIR_BASE_ENTRY; - -#define MAX_DIR_BASE 20 - -int nw_generate_dir_path(uint8 *nwpathstruct, - uint8 *ns_dir_base, uint8 *dos_dir_base) -/* returns Volume Number >=0 or errcode < 0 if error */ -{ - return(-0xfb); /* TODO: complete call */ -} - - -int handle_func_0x57(uint8 *p, uint8 *responsedata) -{ - int result = -0xfb; /* unknown request */ - int ufunc = (int) *p++; /* now p locates at 4 byte boundary */ - int namspace = (int) *p; /* for most calls */ - switch (ufunc) { - case 0x02 : /* Initialize Search */ - { - /* NW PATH STRUC */ - } - break; - case 0x07 : /* Modify File or Dir Info */ - { - - } - break; - case 0x09 : /* Set short Dir Handle*/ - { - - } - break; - case 0x15 : /* Get Path String from short dir neu*/ - { - - } - break; - case 0x16 : /* Generate Dir BASE and VolNumber */ - { - uint8 *nwpathstruct = p+3; - struct OUTPUT { - uint8 ns_dir_base[4]; /* BASEHANDLE */ - uint8 dos_dir_base[4]; /* BASEHANDLE */ - uint8 volume; /* Volumenumber*/ - } *xdata= (struct OUTPUT*)responsedata; - result = nw_generate_dir_path(nwpathstruct, - xdata->ns_dir_base, xdata->dos_dir_base); - - if (result >-1) { - xdata->volume = result; - result = sizeof(struct OUTPUT); - } - } - break; - case 0x0c : /* alloc short dir Handle */ - { - - } - break; - case 0x1a : /* Get Huge NS Info new*/ - { - - } - break; - case 0x1c : /* GetFullPathString new*/ - { - - } - break; - case 0x1d : /* GetEffDirRights new */ - { - - } - break; - - default : result = -0xfb; /* unknown request */ - } /* switch */ - return(result); -} +#if WITH_NAME_SPACE_CALLS +#endif diff --git a/namspace.h b/namspace.h new file mode 100644 index 0000000..37180a7 --- /dev/null +++ b/namspace.h @@ -0,0 +1,20 @@ +/* namspace.h 08-Jan-96 : NameSpace Services, mars_nwe */ + +/* (C)opyright (C) 1993,1995 Martin Stover, Marburg, Germany + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#define WITH_NAME_SPACE_CALLS 0 diff --git a/ncpserv.c b/ncpserv.c index 7a4c238..9febe29 100644 --- a/ncpserv.c +++ b/ncpserv.c @@ -1,5 +1,5 @@ -/* ncpserv.c, 24-Dec-95 */ - +/* ncpserv.c */ +#define REVISION_DATE "09-Jan-96" /* (C)opyright (C) 1993,1995 Martin Stover, Marburg, Germany * * This program is free software; you can redistribute it and/or modify @@ -126,7 +126,6 @@ static int anz_connect=0; /* actual anz connections */ static int new_conn_nr(void) { int j = -1; - int not_logged=-1; if (!anz_connect){ /* init all */ j = MAX_CONNECTIONS; while (j--) { @@ -293,8 +292,9 @@ static int handle_fxx(CONNECTION *c, int gelen, int func) NCPRESPONSE *ncpresponse = (NCPRESPONSE*)&ipxoutdata; uint8 *responsedata = ((uint8*)&ipxoutdata)+sizeof(NCPRESPONSE); uint8 *requestdata = ((uint8*)ncprequest)+sizeof(NCPREQUEST); - +#if 0 uint8 len = *(requestdata+1); +#endif uint8 ufunc = *(requestdata+2); uint8 *rdata = requestdata+3; uint8 completition = 0; @@ -478,7 +478,7 @@ static int handle_fxx(CONNECTION *c, int gelen, int func) if (!result) { c->object_id = obj.id; /* actuell Object ID */ c->t_login = akttime; /* u. login Time */ - get_guid(rdata+2, rdata+2+sizeof(int), obj.id); + get_guid((int*) (rdata+2), (int*) (rdata+2+sizeof(int)), obj.id); in_len=12 + 2*sizeof(int); return(-1); /* nwconn must do the rest */ } else completition = (uint8) -result; @@ -540,7 +540,7 @@ static int handle_fxx(CONNECTION *c, int gelen, int func) if (result > -1) { c->object_id = obj.id; /* actuell Object */ c->t_login = akttime; /* and login time */ - get_guid(rdata+2, rdata+2+sizeof(int), obj.id); + get_guid((int*)(rdata+2), (int*)(rdata+2+sizeof(int)), obj.id); in_len=12 + 2*sizeof(int); return(-1); /* nwconn must do the rest */ } else completition = (uint8) -result; @@ -948,7 +948,6 @@ static int handle_fxx(CONNECTION *c, int gelen, int func) case 0x49 : { /* IS CALLING STATION A MANAGER */ NETOBJ obj; - int result; obj.id = GET_BE32(rdata); /* TODO !! */ completition = 0; /* here allways Manager */ @@ -1061,10 +1060,10 @@ static int handle_fxx(CONNECTION *c, int gelen, int func) } break; case 0xc9 : { /* GET FILE SERVER DESCRIPTION STRINGs */ - char *company = "Mars :-)"; - char *revision = "Version %d.%d"; - char *revision_date= "24-Dec-95"; - char *copyright = "(C)opyright Martin Stover"; + char *company = "Mars :-)"; + char *revision = "Version %d.%d"; + char *revision_date = REVISION_DATE; + char *copyright = "(C)opyright Martin Stover"; int k=strlen(company)+1; memset(responsedata, 0, 512); @@ -1163,11 +1162,11 @@ static void ncp_response(int type, int sequence, if (nw_debug){ char comment[80]; sprintf(comment, "NCP-RESP compl=0x%x ", completition); - send_ipx_data(ncp_fd, 17, sizeof(NCPRESPONSE) + data_len, + send_ipx_data(-1, 17, sizeof(NCPRESPONSE) + data_len, (char *) ncpresponse, &from_addr, comment); } else - send_ipx_data(ncp_fd, 17, sizeof(NCPRESPONSE) + data_len, + send_ipx_data(-1, 17, sizeof(NCPRESPONSE) + data_len, (char *) ncpresponse, &from_addr, NULL); } @@ -1286,7 +1285,7 @@ static int handle_ctrl(void) data_len = read(0, (char*)&conn, sizeof(conn)); if (sizeof(int) == data_len && conn == what) sent_down_message(); - break; + break; default : break; } /* switch */ @@ -1362,6 +1361,7 @@ int main(int argc, char *argv[]) if (diff_time > 50) /* after max. 50 seconds */ nwserv_reset_wdog(connection); /* tell the wdog there's no need to look */ + if (ncprequest->sequence == c->sequence && !c->retry++) { /* perhaps nwconn is busy */ @@ -1409,7 +1409,10 @@ int main(int argc, char *argv[]) ncp_response(0x3333, ncprequest->sequence, ncprequest->connection, - 0, 0xff, 0x08, 0); + 0, + 0xff, /* completition */ + 0xff, /* conn status */ + 0); } else if (type == 0x1111) { /* GIVE CONNECTION Nr connection */ diff --git a/net.h b/net.h index 474ff86..ba61b38 100644 --- a/net.h +++ b/net.h @@ -1,4 +1,4 @@ -/* net.h 02-Jan-96 */ +/* net.h 08-Jan-96 */ /* (C)opyright (C) 1993,1995 Martin Stover, Marburg, Germany * @@ -34,6 +34,7 @@ #include "unistd.h" #include #include +#include #ifndef LINUX # include "stropts.h" @@ -107,6 +108,10 @@ # define IPX_DATA_GR_546 1 #endif +#ifndef MAX_NW_ROUTES +# define MAX_NW_ROUTES 50 +#endif + #if IPX_DATA_GR_546 # define IPX_MAX_DATA 1058 #else @@ -351,15 +356,6 @@ typedef struct { } QUEUE_PRINT_AREA; -typedef struct { - uint8 volume; - uint8 base[4]; /* Base or Handle */ - uint8 flag; /* 0=base, 1=handle, 0xff=not path nor handle */ - uint8 components; /* nmbrs of pathes, components */ - uint8 pathes[1]; /* form len+name */ -} NW_HPATH; - - extern int nw_init_connect(void); extern int nw_free_handles(int task); diff --git a/net1.c b/net1.c index 1e9749b..40d1ea5 100644 --- a/net1.c +++ b/net1.c @@ -1,4 +1,4 @@ -/* net1.c, 24-Dec-95 */ +/* net1.c, 09-Jan-96 */ /* (C)opyright (C) 1993,1995 Martin Stover, Marburg, Germany * @@ -138,13 +138,14 @@ void ipx_addr_to_adr(char *s, ipxAddr_t *p) } -int send_ipx_data(int fd, int pack_typ, +int send_ipx_data(int fdx, int pack_typ, int data_len, char *data, ipxAddr_t *to_addr, char *comment) { + int fd=fdx; + int result=0; struct t_unitdata ud; uint8 ipx_pack_typ = (uint8) pack_typ; - ud.opt.len = sizeof(ipx_pack_typ); ud.opt.maxlen = sizeof(ipx_pack_typ); ud.opt.buf = (char*)&ipx_pack_typ; @@ -156,16 +157,32 @@ int send_ipx_data(int fd, int pack_typ, ud.addr.buf = (char*)to_addr; if (comment != NULL) XDPRINTF((2,0,"%s TO: ", comment)); if (nw_debug > 1) print_ipx_addr(to_addr); - if (t_sndudata(fd, &ud) < 0){ - if (nw_debug > 1) t_error("t_sndudata !OK"); - return(-1); + if (fd < 0) { + struct t_bind bind; + ipxAddr_t addr; + fd=t_open("/dev/ipx", O_RDWR, NULL); + if (fd < 0) { + t_error("t_open !Ok"); + return(-1); + } + memset(&addr,0, sizeof(ipxAddr_t)); + bind.addr.len = sizeof(ipxAddr_t); + bind.addr.maxlen = sizeof(ipxAddr_t); + bind.addr.buf = (char*)&addr; + bind.qlen = 0; /* ever */ + if (t_bind(fd, &bind, &bind) < 0){ + t_error("t_bind in send_ipx_data"); + t_close(fd); + return(-1); + } } - return(0); + if ((result=t_sndudata(fd, &ud)) < 0){ + if (nw_debug > 1) t_error("t_sndudata !OK"); + } + if (fdx < 0 && fd > -1) { + t_unbind(fd); + t_close(fd); + } + return(result); } - - - - - - diff --git a/nwconn.c b/nwconn.c index 77df767..2e1f116 100644 --- a/nwconn.c +++ b/nwconn.c @@ -1,4 +1,4 @@ -/* nwconn.c 02-Jan-96 */ +/* nwconn.c 09-Jan-96 */ /* one process / connection */ /* (C)opyright (C) 1993,1995 Martin Stover, Marburg, Germany @@ -19,6 +19,9 @@ */ #include "net.h" +#include +#include "connect.h" +#include "namspace.h" static int father_pid = -1; static ipxAddr_t from_addr; @@ -306,21 +309,25 @@ static void handle_ncp_serv() } else if (*p == 0xa){ /* legt Verzeichnis an */ /******** Create Dir *********************/ int dir_handle = (int) *(p+1); +#if 0 int rightmask = (int) *(p+2); +#endif int pathlen = (int) *(p+3); uint8 *path = p+4; int code = nw_mk_rd_dir(dir_handle, path, pathlen, 1); if (code) completition = (uint8) -code; - } else if (*p == 0xb){ /* l”scht Verzeichnis */ + } else if (*p == 0xb){ /* deletes dir */ /******** Delete DIR *********************/ int dir_handle = (int) *(p+1); +#if 0 int reserved = (int) *(p+2); /* Res. by NOVELL */ +#endif int pathlen = (int) *(p+3); uint8 *path = p+4; int code = nw_mk_rd_dir(dir_handle, path, pathlen, 0); if (code) completition = (uint8) -code; } else if (*p == 0xd){ /* Add Trustees to DIR */ - /******** GetDirektoryPATH ***************/ + /******** AddTrustesstoDir ***************/ struct INPUT { uint8 header[7]; /* Requestheader */ uint8 div[3]; /* 0x0, dlen, typ */ @@ -1195,11 +1202,13 @@ static void handle_ncp_serv() } break; -#if 0 +#if WITH_NAME_SPACE_CALLS case 0x57 : /* some new namespace calls */ - int result = handle_func_0x57(requestdata, responsedata); - if (result > -1) data_len = result; - else completition=(uint8)-result; + { + int result = handle_func_0x57(requestdata, responsedata); + if (result > -1) data_len = result; + else completition=(uint8)-result; + } break; #endif @@ -1288,7 +1297,6 @@ static void set_sig(void) int main(int argc, char **argv) { - int completition = 0; if (argc != 4) { fprintf(stderr, "usage nwconn PID FROM_ADDR Connection\n"); exit(1); @@ -1299,7 +1307,8 @@ int main(int argc, char **argv) init_tools(NWCONN); XDPRINTF((1, 0, "FATHER PID=%d, ADDR=%s CON:%s", father_pid, *(argv+2), *(argv+3))); - adr_to_ipx_addr(&from_addr, *(argv+2)); + + adr_to_ipx_addr(&from_addr, *(argv+2)); if (nw_init_connect()) exit(1); diff --git a/nwcrypt.c b/nwcrypt.c index c2792f1..507ce54 100644 --- a/nwcrypt.c +++ b/nwcrypt.c @@ -118,7 +118,7 @@ static buf32 encryptkeys = 0x6B,0x0F,0xD5,0x70,0xAE,0xFB,0xAD,0x11, 0xF4,0x47,0xDC,0xA7,0xEC,0xCF,0x50,0xC0}; - +#include "nwcrypt.h" static void shuffle1(buf32 temp, unsigned char *target) { diff --git a/nwcrypt.h b/nwcrypt.h new file mode 100644 index 0000000..3876b0b --- /dev/null +++ b/nwcrypt.h @@ -0,0 +1,7 @@ +/* nwcrypt.h */ +extern void shuffle(unsigned char *lon, + const unsigned char *buf, int buflen, + unsigned char *target); + +extern void nw_encrypt(unsigned char *fra, + unsigned char *buf,unsigned char *til); diff --git a/nwdbm.c b/nwdbm.c index 3a8f065..3650c3d 100644 --- a/nwdbm.c +++ b/nwdbm.c @@ -1,4 +1,4 @@ -/* nwdbm.c 24-Dec-95 data base for mars_nwe */ +/* nwdbm.c 08-Jan-96 data base for mars_nwe */ /* (C)opyright (C) 1993,1995 Martin Stover, Marburg, Germany * * This program is free software; you can redistribute it and/or modify @@ -23,12 +23,14 @@ #include "net.h" #include "nwdbm.h" +#include "nwcrypt.h" #ifdef LINUX # include #else # include #endif + int tells_server_version=0; static char *fnprop = "nwprop"; @@ -1062,7 +1064,7 @@ static void add_pr_queue(uint32 q_id, } -static uint32 add_user(uint32 u_id, uint32 g_id, +static void add_user(uint32 u_id, uint32 g_id, char *name, char *unname, char *password) { uint8 buff[4]; @@ -1089,17 +1091,17 @@ static uint32 add_user(uint32 u_id, uint32 g_id, void nw_fill_standard(char *servername, ipxAddr_t *adr) /* fills the Standardproperties */ { - char serverna[50]; - uint8 buff[12]; + char serverna[MAX_SERVER_NAME+2]; uint32 su_id = 0x00000001; uint32 ge_id = 0x01000001; - - uint32 guest_id = 0x02000001; uint32 serv_id = 0x03000001; + uint32 q1_id = 0x0E000001; +#if 0 + uint32 guest_id = 0x02000001; uint32 nbo_id = 0x0B000001; uint32 ngr_id = 0x0C000001; uint32 ps1_id = 0x0D000001; - uint32 q1_id = 0x0E000001; +#endif FILE *f = open_nw_ini(); ge_id = nw_new_create_prop(ge_id, "EVERYONE", 0x2, 0x0, 0x31, @@ -1162,7 +1164,7 @@ void nw_fill_standard(char *servername, ipxAddr_t *adr) fclose(f); } if (servername && adr) { - strmaxcpy(serverna, servername, 48); + strmaxcpy(serverna, servername, MAX_SERVER_NAME); upstr(serverna); nw_new_create_prop(serv_id, serverna, 0x4, O_FL_DYNA, 0x40, "NET_ADDRESS", P_FL_ITEM | P_FL_DYNA, 0x40, diff --git a/nwdbm.h b/nwdbm.h index d460609..be69747 100644 --- a/nwdbm.h +++ b/nwdbm.h @@ -1,4 +1,4 @@ -/* nwdbm.h 11-Sep-95 */ +/* nwdbm.h 08-Jan-96 */ /* (C)opyright (C) 1993,1995 Martin Stover, Marburg, Germany * * This program is free software; you can redistribute it and/or modify @@ -168,6 +168,12 @@ extern uint32 nw_new_create_prop(uint32 wanted_id, char *propname, int propflags, int propsecurity, char *value, int valuesize); +extern int get_guid(int *gid, int *uid, uint32 obj_id); + +extern int nw_test_passwd(uint32 obj_id, uint8 *vgl_key, uint8 *akt_key); +extern int nw_get_q_dirname(uint32 q_id, uint8 *buff); +extern int nw_get_q_prcommand(uint32 q_id, uint8 *buff); + extern void nw_fill_standard(char *servername, ipxAddr_t *adr); extern void nw_init_dbm(char *servername, ipxAddr_t *adr); diff --git a/nwroute.c b/nwroute.c index bf15082..ec7c197 100644 --- a/nwroute.c +++ b/nwroute.c @@ -1,4 +1,4 @@ -/* nwroute.c 24-Dec-95 */ +/* nwroute.c 08-Jan-96 */ /* (C)opyright (C) 1993,1995 Martin Stover, Marburg, Germany * * This program is free software; you can redistribute it and/or modify @@ -19,7 +19,6 @@ #include "net.h" #include "nwserv.h" -#define MAX_NW_ROUTES 50 /* max. 1 complete RIP packet should be enough */ typedef struct { uint32 net; /* destnet */ @@ -65,7 +64,10 @@ static void insert_delete_net(uint32 destnet, if (k == anz_routes) { /* no route slot found */ if (do_delete) return; /* nothing to delete */ if (freeslot < 0) { - if (anz_routes == MAX_NW_ROUTES) return; + if (anz_routes == MAX_NW_ROUTES) { + XDPRINTF((1, 0, "too many routes=%d, increase MAX_NW_ROUTES in config.h", anz_routes)); + return; + } nw_routes[k] = (NW_ROUTES*)xmalloc(sizeof(NW_ROUTES)); anz_routes++; } else k=freeslot; @@ -153,7 +155,7 @@ static void build_rip_buff(uint32 destnet) k=-1; while (++k < anz_routes) { NW_ROUTES *nr=nw_routes[k]; - if ((is_wild || nr->net == destnet) && rmode==1 || nr->hops < 2) + if ( (is_wild || nr->net == destnet) && (rmode==1 || nr->hops < 2) ) ins_rip_buff(nr->net, (rmode==1) ? 16 : nr->hops, nr->ticks); } } @@ -178,7 +180,9 @@ static void send_rip_buff(ipxAddr_t *from_addr) (operation==1) ? "Request" : "Response", rentries)); p+=2; while (rentries--) { +#if 0 uint32 net = GET_BE32(p); +#endif uint16 hops = GET_BE16(p+4); uint16 ticks = GET_BE16(p+6); XDPRINTF((2,0, "hops=%3d, ticks %3d, network:%02x.%02x.%02x.%02x", @@ -298,7 +302,13 @@ void send_sap_broadcast(int mode) U16_TO_BE16(1, ipx_data.sip.intermediate_networks); /* I hope 1 is ok here */ } - send_ipx_data(sockfd[MY_BROADCAST_SLOT], 0, + +#ifdef MY_BROADCAST_SLOT + send_ipx_data(sockfd[MY_BROADCAST_SLOT], +#else + send_ipx_data(-1, +#endif + 0, sizeof(ipx_data.sip), (char *)&(ipx_data.sip), &wild, "SIP Broadcast"); diff --git a/nwserv.c b/nwserv.c index 3dd8a09..d8b61a5 100644 --- a/nwserv.c +++ b/nwserv.c @@ -1,4 +1,4 @@ -/* nwserv.c 20-Dec-95 */ +/* nwserv.c 09-Jan-96 */ /* (C)opyright (C) 1993,1995 Martin Stover, Marburg, Germany * * This program is free software; you can redistribute it and/or modify @@ -27,8 +27,13 @@ char my_nwname[50]; /* Name of this server */ int anz_net_devices=0; NW_NET_DEVICE *net_devices[MAX_NET_DEVICES]; -uint16 ipx_sock_nummern[]={ 0, /* auto sock */ +uint16 ipx_sock_nummern[]={ +#ifdef MY_BROADCAST_SLOT 0, /* auto sock */ +#endif +#ifdef WDOG_SLOT + 0, /* auto sock */ +#endif SOCK_SAP, SOCK_RIP, SOCK_ROUTE, @@ -578,8 +583,12 @@ static void handle_event(int fd, uint16 socknr, int slot) IPXCMPNET (source_adr.net, my_server_adr.net)) { int source_sock = (int) GET_BE16(source_adr.sock); + +#if 0 if ( source_sock == sock_nummern[MY_BROADCAST_SLOT] - || source_sock == sock_nummern[WDOG_SLOT] +#endif + + if ( source_sock == sock_nummern[WDOG_SLOT] || source_sock == SOCK_SAP || source_sock == SOCK_RIP) { XDPRINTF((2,0,"OWN Packet from sock:0x%04x, ignored", source_sock)); @@ -639,8 +648,8 @@ static void get_ini(int full) char inhalt4[500]; char dummy; int anz; - if ((anz=sscanf((char*)buff, "%s %s %s", inhalt, inhalt2, - inhalt3, inhalt4)) > 0) { + if ((anz=sscanf((char*)buff, "%s %s %s %s", inhalt, inhalt2, + inhalt3, inhalt4)) > 0) { switch (what) { case 2 : if (full) { strncpy(my_nwname, inhalt, 48); diff --git a/nwserv.h b/nwserv.h index 9a7adae..af29ed7 100644 --- a/nwserv.h +++ b/nwserv.h @@ -1,4 +1,4 @@ -/* nwserv.h 09-Dec-95 */ +/* nwserv.h 09-Jan-96 */ /* (C)opyright (C) 1993,1995 Martin Stover, Marburg, Germany * * This program is free software; you can redistribute it and/or modify @@ -33,16 +33,18 @@ extern int anz_net_devices; extern NW_NET_DEVICE *net_devices[]; /* <======== SOCKETS =========> */ -#define MY_BROADCAST_SLOT 0 /* Server Broadcast OUT */ -#define WDOG_SLOT 1 /* Watchdog send + recv */ - -#define SAP_SLOT 2 -#define RIP_SLOT 3 -#define ROUTE_SLOT 4 -#define DIAG_SLOT 5 #if 0 -#define ECHO_SLOT 6 -#define ERR_SLOT 7 +#define MY_BROADCAST_SLOT 0 /* Server Broadcast OUT */ +#endif + +#define WDOG_SLOT 0 /* Watchdog send + recv */ +#define SAP_SLOT 1 +#define RIP_SLOT (SAP_SLOT +1) +#define ROUTE_SLOT (RIP_SLOT +1) +#define DIAG_SLOT (ROUTE_SLOT +1) +#if 0 +#define ECHO_SLOT (DIAG_SLOT +1) +#define ERR_SLOT (ECHO_SLOT +1) #endif extern int sockfd[]; diff --git a/tools.c b/tools.c index a1fc502..3deb989 100644 --- a/tools.c +++ b/tools.c @@ -1,4 +1,4 @@ -/* tools.c 24-Dec-95 */ +/* tools.c 07-Jan-96 */ /* (C)opyright (C) 1993,1995 Martin Stover, Marburg, Germany * * This program is free software; you can redistribute it and/or modify @@ -45,6 +45,13 @@ char *xmalloc(uint size) return(p); } +char *xcmalloc(uint size) +{ + char *p = xmalloc(size); + if (size) memset(p, 0, size); + return(p); +} + void x_x_xfree(char **p) { if (*p != (char *)NULL){ @@ -301,7 +308,7 @@ int get_fs_usage(char *path, struct fs_usage *fsp) struct statfs fsd; if (statfs (path, &fsd) < 0) return (-1); XDPRINTF((3, 0, - "blocks=%d, bfree=%d, bavail=%d, files=%d, ffree=%d, bsize=%d\n", + "blocks=%d, bfree=%d, bavail=%d, files=%d, ffree=%d, bsize=%d", fsd.f_blocks, fsd.f_bfree, fsd.f_bavail, fsd.f_files, fsd.f_ffree, fsd.f_bsize)); #define convert_blocks(b) adjust_blocks ((b), fsd.f_bsize, 512) diff --git a/tools.h b/tools.h index 7cdbd8b..64b303e 100644 --- a/tools.h +++ b/tools.h @@ -1,4 +1,4 @@ -/* tools.h : 14-Nov-95 */ +/* tools.h : 07-Jan-96 */ /* (C)opyright (C) 1993,1995 Martin Stover, Marburg, Germany * @@ -30,6 +30,7 @@ extern int x_x_xnewstr(uint8 **p, uint8 *s); #define new_str(p, s) x_x_xnewstr((uint8 **)&(p), s) extern char *xmalloc(uint size); +extern char *xcmalloc(uint size); extern int strmaxcpy(char *dest, char *source, int len); extern void dprintf(char *p, ...); extern void xdprintf(int dlevel, int mode, char *p, ...);