mars_nwe-0.98.pl07

This commit is contained in:
Mario Fetka 2011-11-13 00:38:58 +01:00
parent 1eac63223b
commit 309ae4659e
26 changed files with 492 additions and 123 deletions

View File

@ -1047,9 +1047,12 @@ int un_nw_attrib(struct stat *stb, int attrib, int mode)
} else {
/* NW access -> UNIX access */
int mode = S_IRUSR | S_IRGRP;
#if 0
/* this is sometimes very BAD */
if (attrib & FILE_ATTR_H) /* hidden */
stb->st_mode &= ~mode;
else
#endif
stb->st_mode |= mode;
mode = S_IWUSR | S_IWGRP;
@ -1284,7 +1287,7 @@ int mv_file(int qdirhandle, uint8 *q, int qlen,
NW_PATH quellpath;
NW_PATH zielpath;
int completition=conn_get_kpl_path(&quellpath, qdirhandle, q, qlen, 0);
if (!completition > -1) {
if (completition > -1) {
completition=conn_get_kpl_path(&zielpath, zdirhandle, z, zlen, 0);
if (completition > -1) {
int optq = get_volume_options(quellpath.volume, 1);
@ -1299,7 +1302,10 @@ int mv_file(int qdirhandle, uint8 *q, int qlen,
char unziel[256];
strcpy(unquelle, build_unix_name(&quellpath,0));
strcpy(unziel, build_unix_name(&zielpath,0));
completition = unx_mvfile(unquelle, unziel);
if (entry8_flags & 0x4) /* new: 20-Nov-96 */
completition = unx_mvfile_or_dir(unquelle, unziel);
else
completition = unx_mvfile(unquelle, unziel);
switch (completition) {
case 0 : break;
case EEXIST : completition = -0x92; break; /* allready exist */
@ -1318,11 +1324,17 @@ int mv_dir(int dir_handle, uint8 *q, int qlen,
NW_PATH quellpath;
NW_PATH zielpath;
int completition=conn_get_kpl_path(&quellpath, dir_handle, q, qlen, 0);
if (!completition > -1){
if (completition > -1){
#if 1
/* I do not know anymore why I did these ??? */
memcpy(&zielpath, &quellpath, sizeof(NW_PATH));
strmaxcpy(zielpath.fn, z, zlen);
/* ----------- now I know again why I did these ----- */
/* for example the novell rendir.exe does something like this
* 0x0,0xd,0xf,0x0,0x7,'T','M','P',':','\','I','I',0x2,'K','K'
* no dirhandle, qpath = fullpath, zpath = only name
*/
#else
/* and NOT these, perhaps this will also be ok ?! -- TODO -- */
completition=conn_get_kpl_path(&zielpath, dir_handle, z, zlen, 0);
@ -2018,8 +2030,8 @@ static int get_match(uint8 *unixname, uint8 *p)
uint8 *pp;
#if 0
uint8 *p1;
#endif
int inode=0;
#endif
if (!p || !*p) return(1);
*p = '\0';
pp=p+1;
@ -2044,7 +2056,11 @@ static int get_match(uint8 *unixname, uint8 *p)
int len;
if (dirbuff->d_ino) {
XDPRINTF((10, 0, "get match found d_name='%s'", dirbuff->d_name));
if ((dirbuff->d_ino ==inode) || 0 != (len=my_match(dirbuff->d_name, pp))) {
if (
#if 0
(dirbuff->d_ino ==inode) ||
#endif
0 != (len=my_match(dirbuff->d_name, pp))) {
memcpy(pp, dirbuff->d_name, len);
XDPRINTF((10, 0, "get match, match OK"));
closedir(d);

15
debmask.h Normal file
View File

@ -0,0 +1,15 @@
/* debmask.h: 30-Dec-96 */
#ifndef _DEBMASK_H_
#define _DEBMASK_H_
/*
* several debug masks.
* second paramter in debug entries 100 .. 1xx
*
*/
/* NWCONN */
#define D_FH_OPEN 1 /* file open/close */
#endif

View File

@ -1,6 +1,6 @@
Sorry, this is in German only.
User important notes are in the NEWS file.
Aenderungen in mars_nwe bis zum : 09-Nov-96
Aenderungen in mars_nwe bis zum : 15-Dec-96
--------------------------------
Erste 'oeffentliche' Version
^^^^^^^^^^ VERSION 0.94 ^^^^^^^^
@ -244,6 +244,26 @@ Erste 'oeffentliche' Version
- IPX_MAX_DATA vergroessert. IPX_DATA_GR_546 abgeaendert.
- kleinen patch ( upper/lowercase Handling ) von
Sven Norinder <snorinder@sgens.ericsson.se>
in nwconn,mv_dir eingebaut.
in connect.c,mv_dir eingebaut.
<----- ^^^^^^^^^^ pl5 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- nwrouted wieder zum Laufen gebracht. Es waren einige
defines falsch gesetzt.
<----- ^^^^^^^^^^ pl6 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- die 'rename file' Routine erlaubt nun auch das Umbenennen von
Verzeichnissen, falls section 8 flag=0x4 gesetzt ist.
- Beim file locking wird nun durch Ignorieren des Vorzeichenbits
verhindert, dass offsets > MAX_INT nicht funktionieren.
wird z.B. fuer dBase benoetigt.
( Hint from:Morio Taneda <morio@sozio.geist-soz.uni-karlsruhe.de> )
- ini Datei wird nun bei Bedarf mit uid=0 gelesen, so dass sie
ab jetzt fuer Anwender versteckt sein darf.
- Das 'hidden File' handling (Dateien wurden auf -R -W gesetzt) ausgebaut.
- 0x4b (set date of file) funktioniert nun auch bei RO geoeffneten Dateien.
- Index in der Bindery ueber die Objektnamen eingebaut.
Dadurch muessten Bindery Zugriffe ueber die Objektnamen bechleunigt
werden, z.B. beim Einloggen.
- Fehler bei der Allocierung von Filehandles beseitigt.
Es konnten nicht alle freigegebenen Filehandles wiederverwendet
werden. -> "No more free file handles"
<----- ^^^^^^^^^^ pl7 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

View File

@ -1,3 +1,4 @@
last updated: 05-Dec-96
Q: I don't exaclty understand the meaning of some ponits in nw.ini:
12,13
What will happen if I will not put PASSWORD here? Will it take it from
@ -31,3 +32,15 @@ A: Give the volume the 'O' flag.
[HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\VxD\NWREDIR]
"SupportLFN"=hex:02
Q: I have 2 Eth-devices (one for IP/IPX and one for IPX only)
and after starting mars_nwe I have strange problems with my IP-net.
A: Make sure that all Eth-devices have an assigned IP-address, even
they are only used for IPX.
Q: I have arcnet cards and I dont find the frame-typ TRXNET.
A: The correct frame typ is handled by the arcnet driver.
You should use the 'dummy frametyp' 802.3.

View File

@ -1,4 +1,6 @@
# in this files are some notes for user of mars_nwe.
------09-Nov-96--- 0.98.pl7 ----------
- section 8: new flag 0x4 added. (see examples/nw.ini).
------09-Nov-96--- 0.98.pl5 ----------
- now Novell Client32 should works.
- new config.h flag. 'HANDLE_ALL_SAP_TYPS'

View File

@ -1,7 +1,7 @@
Begin3
Title: mars_nwe
Version: 0.98.pl5
Entered-date: 11-Nov-96
Version: 0.98.pl7
Entered-date: 09-Jan-97
Description: Full netware-emulator (src), beta.
Supports file-services, bindery-services,
printing-services, routing-services.
@ -9,8 +9,8 @@ Keywords: novell, netware, server, ipx, ncp, tli
Author: mstover@stover.f.eunet.de (Martin Stover)
Maintained-by: mstover@stover.f.eunet.de (Martin Stover)
Primary-site: ftp.gwdg.de:/pub/linux/misc/ncpfs
200kB mars_nwe-0.98.pl5.tgz
Alternate-site: ftp.uni-duisburg.de /pub/linux/ipxware
200kB mars_nwe-0.98.pl7.tgz
Alternate-site: sunsite.unc.edu:/pub/Linux/system/Filesystems/ncpfs
Platforms: Linux (1.2.xx, 1.3.xx, 2.xx), UnixWare (2.xx)
Copying-policy: GNU
End

View File

@ -35,6 +35,8 @@
#define IPX_DATA_GR_546 1 /* 0 = max. IPX Packets = 546 +30 Byte ( 512 Byte RWBuff) */
/* 1 = max. IPX packets = 1058 +30 Byte (1024 Byte RWBuff) */
/* 2 = max. IPX packets = 1470 +30 Byte (1444 Byte RWBuff) */
/* 3 = max. IPX packets = 4130 +30 Byte (4096 Byte RWBuff) */
#define USE_MMAP 1 /* use mmap systen call */

BIN
examples/e.pck Normal file

Binary file not shown.

View File

@ -2,7 +2,7 @@
# This is the configuration-file for "mars_nwe", a free netware-emulator
# for Linux.
#
# last changed: 09-Nov-96
# last changed: 20-Nov-96
# This file specifies which Linux-resources (printers, users, directories)
# should be accessible to the DOS-clients via "mars_nwe". Furthermore
@ -221,6 +221,7 @@
# Examples:
# 4 0x0 * AUTO 1 # automatic setup
# 4 0x10 eth0 802.3 1 # manual setup
# 4 0xa20 arc0 802.3 1 # standard arcnet (TRXNET)
4 0x10 eth0 802.3 1
4 0x0 * AUTO 1
@ -311,11 +312,17 @@
# 0x1 allow changing dir/accessing other files than login/*
# when not logged in, if the client supports it.
# ( this was standard till mars_nwe-0.98.pl4 )
#
# 0x2 switch on strange compatibility mode for opening files.
# If an opencall do an open for writing but
# the file is readonly then this call will not fail
# but open the file readonly.
#
# 0x4 allow the rename file call (NCP function 0x45)
# renaming of directories.
# normally the rename file call returns an error if this
# routine is used for renaming directories.
#
# other flags may follow.
# value will be interpreted as hex value.
@ -590,14 +597,14 @@
# Section 401: nearest server
#
# for special handling of the 'get nearest server request'.
401 0 # 0 = ignore entry 400, get nearest response ever enabled.
401 0 # 0 = ignore entry 400, get nearest response always enabled.
# 1 = 400 are excludes, get nearest response normally enabled.
# 2 = 400 are includes, get nearest response normally disabled.
# Section 402: station connect restrictions
#
# for special handling of the 'creat connection' call.
402 0 # 0 = ignore entry 400, creat connection ever enabled.
# 1 = 400 are excludes, creat connection normally enabled.
# 2 = 400 are includes, creat connection normally disabled.
402 0 # 0 = ignore entry 400, create connection always enabled.
# 1 = 400 are excludes, create connection normally enabled.
# 2 = 400 are includes, create connection normally disabled.

View File

@ -1,5 +1,5 @@
#if 0
#makefile.unx 04-Oct-96
#makefile.unx 14-Nov-96
#endif
VPATH=$(V_VPATH)
@ -9,7 +9,7 @@ C=.c
V_H=0
V_L=98
P_L=5
P_L=7
#define D_P_L 1
DISTRIB=mars_nwe
@ -23,8 +23,10 @@ PATCHF=$(DISTRIBF).pl$(P_L)
#endif
STERN=*
#if 0
MAKEPATCH=diff -rub
DESTMAKEFILE=Makefile.o
#if 0
all: $(DESTMAKEFILE)
$(MAKE) -f $(DESTMAKEFILE) n_$@
@ -150,7 +152,7 @@ $(PROG5): $(PROG5)$(O) $(OBJ5)
$(PROG6): $(PROG6)$(O) $(OBJ6)
$(CC) -o $(VPATH)/$(PROG6) $(PROG6)$(O) $(OBJ6) $(NDBMLIB) $(CRYPTLIB) $(NSLLIB)
$(PROG7): $(PROG7)$(O) $(OBJ7) nwserv.c nwroute.c
$(PROG7): $(PROG7)$(O) $(OBJ7)
$(CC) -o $(VPATH)/$(PROG7) $(PROG7)$(O) $(OBJ7) $(NSLLIB)
$(PROG8): $(PROG8)$(O) $(OBJ8)
@ -158,6 +160,8 @@ $(PROG8): $(PROG8)$(O) $(OBJ8)
$(HOBJ3): namspace.h connect.h nwvolume.h nwfile.h
$(OBJS): net.h config.h
$(PROG7)$(O): nwserv.c nwroute.c
tools$(O): $(DESTMAKEFILE)
$(C)$(O):
$(CC) -c $(CFLAGS) $(HOSTCFLAGS)\
@ -242,7 +246,7 @@ make_dir:
n_diff: make_dir clean_d
cd $(VPATH) && ( \
makepatch org/$(DISTRIB) $(DISTRIB) > $(PATCHF) \
$(MAKEPATCH) org/$(DISTRIB) $(DISTRIB) > $(PATCHF) \
; gzip -9 -f $(PATCHF) \
; cd $(OBJDIR) )

View File

@ -1048,8 +1048,9 @@ int nw_search_file_dir(int namespace, int datastream,
{
static uint32 saved_sequence=0L;
#if 0
int max_counts = *count;
#endif
int found = 0;
int result = find_base_entry(volume, basehandle);
*perhaps_more = 0;
@ -1575,7 +1576,9 @@ int handle_func_0x57(uint8 *p, uint8 *responsedata, int task)
uint8 reserved;
} *xdata= (struct OUTPUT*)responsedata;
/* NW PATH STRUC */
#if 0
int datastream = (int) *(p+1);
#endif
int searchattrib = (int) GET_16(p+2); /* LOW-HI */
uint32 infomask = GET_32(p+4); /* LOW-HI */
int volume = *(p+8);
@ -1709,7 +1712,9 @@ static int code = 0;
uint8 more_entries; /* NW4.1 (UNIX) says 0xff here */
uint8 count[2]; /* count of entries */
} *xdata= (struct OUTPUT*)responsedata;
#if 0
int datastream = (int) *(p+1);
#endif
int searchattrib = (int) GET_16(p+2); /* LOW-HI */
uint32 infomask = GET_32(p+4); /* LOW-HI */
int count = (int)GET_16(p+8);

5
net.h
View File

@ -239,7 +239,10 @@ extern int errno;
#endif
#if IPX_DATA_GR_546
# if IPX_DATA_GR_546 == 2
# if IPX_DATA_GR_546 == 3
# define IPX_MAX_DATA 4130
# define RW_BUFFERSIZE 4096
# elif IPX_DATA_GR_546 == 2
# define IPX_MAX_DATA 1470
# define RW_BUFFERSIZE 1444
# else

5
net1.c
View File

@ -73,6 +73,7 @@ void print_ipx_addr(ipxAddr_t *p)
void print_ud_data(struct t_unitdata *ud)
{
#if DO_DEBUG
int packet_typ = *(int*)(ud->opt.buf);
int data_len = ud->udata.len;
IPX_DATA *ipxdata = (IPX_DATA *)(ud->udata.buf);
@ -86,8 +87,7 @@ void print_ud_data(struct t_unitdata *ud)
} else if (data_len > sizeof(SIP)){
SAP *sap = &(ipxdata->sap);
SAPS *saps = &(ipxdata->sap.saps);
int sap_operation = GET_BE16(sap->sap_operation);
XDPRINTF((2,0, "SAP-OPERATION %d", sap_operation));
XDPRINTF((2,0, "SAP-OPERATION %d", (int) GET_BE16(sap->sap_operation) ));
while (data_len >= sizeof(SAPS)){
XDPRINTF((2,0, "Name:%s:, typ:0x%x",saps->server_name,
GET_BE16(saps->server_type)));
@ -96,6 +96,7 @@ void print_ud_data(struct t_unitdata *ud)
data_len -= sizeof(SAPS);
}
} else print_ipx_data(ipxdata);
#endif
}
void print_ipx_data(IPX_DATA *p)

View File

@ -1,5 +1,5 @@
/* nwbind.c */
#define REVISION_DATE "01-Nov-96"
#define REVISION_DATE "02-Jan-97"
/* NCP Bindery SUB-SERVER */
/* authentification and some message handling */
@ -432,7 +432,7 @@ static void handle_fxx(int gelen, int func)
xstrmaxcpy(password, p1+1, (int) *p1);
XDPRINTF((10, 0, "LOGIN unencrypted PW NAME='%s', PASSW='%s'",
obj.name, password));
if (0 == (result = find_obj_id(&obj, 0))) {
if (0 == (result = find_obj_id(&obj))) {
if (password_scheme & PW_SCHEME_LOGIN) {
#if 0
if (obj.id == 1) {
@ -469,7 +469,7 @@ static void handle_fxx(int gelen, int func)
p+=2;
strmaxcpy((char*)obj.name, (char*)(p+1), (int) *(p));
upstr(obj.name);
result = find_obj_id(&obj, 0);
result = find_obj_id(&obj);
if (!result){
int k=-1;
int anz = 0;
@ -542,7 +542,7 @@ static void handle_fxx(int gelen, int func)
upstr(obj.name);
XDPRINTF((2, 0, "LOGIN CRYPTED PW NAME='%s'",obj.name));
if (0 == (result = find_obj_id(&obj, 0))) {
if (0 == (result = find_obj_id(&obj))) {
internal_act = 1;
result=nw_test_passwd(obj.id, act_c->crypt_key, rdata);
internal_act = 0;
@ -643,7 +643,7 @@ static void handle_fxx(int gelen, int func)
obj.type = GET_BE16(p);
strmaxcpy((char*)obj.name, (char*)(p+3), (int) *(p+2));
upstr(obj.name);
result = find_obj_id(&obj, 0);
result = find_obj_id(&obj);
if (!result){
U32_TO_BE32(obj.id, xdata->object_id);
U16_TO_BE16(obj.type, xdata->object_type);
@ -687,7 +687,7 @@ static void handle_fxx(int gelen, int func)
obj.type = GET_BE16(p);
strmaxcpy((char*)obj.name, (char*)(p+3),(int) *(p+2));
upstr(obj.name);
result = find_obj_id(&obj, last_obj_id);
result = scan_for_obj(&obj, last_obj_id);
if (!result){
U32_TO_BE32(obj.id, xdata->object_id);
U16_TO_BE16(obj.type, xdata->object_type);
@ -849,7 +849,7 @@ static void handle_fxx(int gelen, int func)
xstrmaxcpy(oldpassword, p+1, (int) *p);
p += ((*p)+1);
xstrmaxcpy(newpassword, p+1, (int) *p);
if (0 == (result = find_obj_id(&obj, 0))) {
if (0 == (result = find_obj_id(&obj))) {
XDPRINTF((6, 0, "CHPW: OLD=`%s`, NEW=`%s`", oldpassword,
newpassword));
@ -1007,7 +1007,7 @@ static void handle_fxx(int gelen, int func)
obj.type = GET_BE16(p);
strmaxcpy((char*)obj.name, (char*)(p+3), *(p+2));
upstr(obj.name);
if (0 == (result = find_obj_id(&obj, 0))) {
if (0 == (result = find_obj_id(&obj))) {
internal_act = 1;
result=nw_test_passwd(obj.id, act_c->crypt_key, rdata);
internal_act = 0;
@ -1029,7 +1029,7 @@ static void handle_fxx(int gelen, int func)
/* from Guntram Blohm */
p += (*p+1); /* here is crypted password length */
if (0 == (result = find_obj_id(&obj, 0))) {
if (0 == (result = find_obj_id(&obj))) {
internal_act=1;
result=nw_keychange_passwd(obj.id, act_c->crypt_key,
rdata, (int)*p, p+1, act_c->object_id);
@ -1093,7 +1093,11 @@ static void handle_fxx(int gelen, int func)
NETOBJ obj;
obj.id = GET_BE32(rdata);
XDPRINTF((1, 0, "TODO:GET QUEUE JOB LIST,old of Q=0x%lx", obj.id));
memset(responsedata, 0, 2);
data_len = 2;
#if 0
completition=0xd5; /* no Queue Job */
#endif
}
break;
@ -1102,6 +1106,7 @@ static void handle_fxx(int gelen, int func)
NETOBJ obj;
obj.id = GET_BE32(rdata);
XDPRINTF((1, 0, "TODO: GET QUEUE JOB ENTRY of Q=0x%lx", obj.id));
completition=0xd5; /* no Queue Job */
}
break;
@ -1148,6 +1153,7 @@ static void handle_fxx(int gelen, int func)
obj.id = GET_BE32(rdata);
XDPRINTF((2, 0, "TODO:GET QUEUE JOB List of Q=0x%lx", obj.id));
memset(xdata, 0, sizeof(struct XDATA));
data_len=sizeof(struct XDATA);
}break;
case 0xc8 : { /* CHECK CONSOLE PRIVILEGES */

View File

@ -533,25 +533,27 @@ static int handle_ncp_serv(void)
data_len = (8 * xdata->entries) + 1;
} else completition = (uint8) (-result);
} else if (*p == 0x21) {
#if DO_DEBUG
/* change Vol restrictions for Obj */
uint8 volnr = *(p+1);
uint32 id = GET_BE32(p+2);
uint32 blocks = GET_BE32(p+6);
XDPRINTF((2,0,"TODO:Change vol restriction vol=%d, id=0x%lx, Blocks=0x%lx",
(int)volnr, id, blocks));
(int)volnr, id, blocks))
#endif
;
} else if (*p == 0x22) {
#if DO_DEBUG
/* remove Vol restrictions for Obj */
uint8 volnr = *(p+1);
uint32 id = GET_BE32(p+2);
XDPRINTF((2,0, "TODO:Remove vol restriction vol=%d, id=0x%lx",
(int)volnr, id));
(int)volnr, id))
#endif
;
} else if (*p == 0x25){ /* setting FILE INFO ??*/
/* TODO !!!!!!!!!!!!!!!!!!!! */
do_druck++;
} else if (*p == 0x26) { /* Scan file or Dir for ext trustees */
int sequenz = (int)*(p+2); /* trustee sequenz */
struct XDATA {
@ -594,14 +596,18 @@ static int handle_ncp_serv(void)
do_druck++;
} else if (*p == 0x29){
/* read volume restrictions for an object */
#if DO_DEBUG
uint8 volnr = *(p+1);
uint32 id = GET_BE32(p+2);
#endif
struct XDATA {
uint8 restriction[4];
uint8 inuse[4];
} *xdata = (struct XDATA*) responsedata;
XDPRINTF((5,0, "Get vol restriction vol=%d, id=0x%lx",
(int)volnr, id));
U32_TO_32(0x40000000, xdata->restriction);
U32_TO_32(0x0, xdata->inuse);
data_len=sizeof(struct XDATA);
@ -705,14 +711,13 @@ static int handle_ncp_serv(void)
} else completition = 0xfb; /* unkwown request */
}
break;
case 0x17 : { /* FILE SERVER ENVIRONMENT */
/* uint8 len = *(requestdata+1); */
uint8 ufunc = *(requestdata+2);
#if DO_DEBUG
uint8 *rdata = requestdata+3;
#endif
switch (ufunc) {
#if FUNC_17_02_IS_DEBUG
case 0x02 : {
/* I hope this call isn't used */
@ -872,7 +877,7 @@ static int handle_ncp_serv(void)
(int) (GET_BE16((uint8*)requestdata)));
U16_TO_BE16(rw_buffer_size, getsize);
data_len = 2;
XDPRINTF((5,0, "Negotiate Buffer size = 0x%04x,(%d)",
XDPRINTF((2,0, "Negotiate Buffer size = 0x%04x,(%d)",
(int) rw_buffer_size, (int) rw_buffer_size));
}
break;
@ -887,7 +892,30 @@ static int handle_ncp_serv(void)
case 0x3d : { /* commit file, flush file buffers */
0x3d seems to be no valid/used NCP call.
#endif
case 0x3b : { /* commit file, flush file buffers */
case 0x3d : /* looks also like commit file */
/* I make no errorresult here */
{
#if 0
XDPRINTF((2,0, "don't know function: 0x3d"));
#else
struct INPUT {
uint8 header[7]; /* Requestheader */
uint8 reserve;
uint8 ext_fhandle[2]; /* all zero */
uint8 fhandle[4]; /* filehandle */
} *input = (struct INPUT *)ncprequest;
char fname[200];
int fd = (int) GET_BE32(input->fhandle);
int result=fd_2_fname(fd, fname, sizeof(fname));
XDPRINTF((1,0, "0x3d, fd=%d, fn=`%s`, r=%d",
fd, fname, result));
#endif
}
break;
case 0x3b :
#if DO_DEBUG
{ /* commit file, flush file buffers */
struct INPUT {
uint8 header[7]; /* Requestheader */
uint8 reserve;
@ -896,7 +924,9 @@ static int handle_ncp_serv(void)
} *input = (struct INPUT *)ncprequest;
uint32 fhandle = GET_BE32(input->fhandle);
XDPRINTF((5,0, "should be done some time: COMMIT FILE:fhandle=%ld", fhandle));
} break;
}
#endif
break;
case 0x3e : { /* FILE SEARCH INIT */
@ -1373,6 +1403,13 @@ static int handle_ncp_serv(void)
(int) wantsize, (int) wantsize, flags));
}
break;
#else
case 0x61 : /* Negotiate Buffer Size, Packetsize new ? */
XDPRINTF((2,0, "Function '0x61' not supportet"));
completition = 0xfb; /* unknown request */
nw_debug=0;
break;
#endif
#if 0
@ -1391,14 +1428,22 @@ static int handle_ncp_serv(void)
uint8 max_packet_size[4];
} *xdata= (struct XDATA*) responsedata;
break;
#else
case 0x65 :
XDPRINTF((2,0, "Packet Burst Connection Request not yet supportet"));
nw_debug=0;
completition = 0xfb; /* unknown request */
break;
#endif
#if 0
case 0x68 : /* NDS NCP, NDS Fragger Protokoll ?? */
#endif
XDPRINTF((2,0, "NDS Fragger Protokoll not supportet"));
nw_debug=0;
completition = 0xfb; /* unknown request */
break;
default : completition = 0xfb; /* unknown request */
break;
break;
} /* switch function */
} else if (ncp_type == 0x1111) {

175
nwdbm.c
View File

@ -1,4 +1,4 @@
/* nwdbm.c 04-Oct-96 data base for mars_nwe */
/* nwdbm.c 19-Dec-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
@ -52,10 +52,24 @@ static DBM *my_dbm=NULL;
#define FNVAL 1
#define FNOBJ 2
static char *dbm_fn[3] = { "nwprop", "nwval", "nwobj" };
#define FNIOBJ 3 /* Index for Object Names */
#define COUNT_DBM_FILES 4
static char *dbm_fn[COUNT_DBM_FILES] = {
"nwprop", "nwval", "nwobj"
#if COUNT_DBM_FILES > 3
,"nwiobj"
#endif
};
#if DBM_REMAINS_OPEN
static DBM *my_dbms[3] = { NULL, NULL, NULL };
static DBM *my_dbms[COUNT_DBM_FILES] = {
NULL, NULL, NULL
#if COUNT_DBM_FILES > 3
, NULL
#endif
};
#endif
static int x_dbminit(char *s)
@ -94,7 +108,7 @@ static int dbmclose()
void sync_dbm()
{
#if DBM_REMAINS_OPEN
int k = 3;
int k = COUNT_DBM_FILES;
while (k--) {
if (NULL != my_dbms[k]) {
dbm_close(my_dbms[k]);
@ -112,14 +126,105 @@ void sync_dbm()
#define store(key, content) dbm_store(my_dbm, key, content, DBM_REPLACE)
int find_obj_id(NETOBJ *o, uint32 last_obj_id)
static int handle_iobj(int mode, NETOBJ *o)
/* modes:
* 0 = search/read
* 1 = rewrite ( not needed yet )
* 2 = rewrite/creat
* 3 = delete
*/
{
int result=-0xff;
if (!dbminit(FNIOBJ)){
NETIOBJ iobj;
strncpy(iobj.name, o->name, sizeof(iobj.name));
iobj.type = o->type;
key.dsize = NETIOBJ_KEY_SIZE;
key.dptr = (char*)&iobj;
result = -0xfc; /* no Object */
if (mode == 3) {
if (!delete(key)) result=0;
} else {
data = fetch(key);
if (data.dptr != NULL) {
NETIOBJ *piobj=(NETIOBJ*)data.dptr;
XDPRINTF((3,0, "got index of OBJ name=%s, type=0x%x, id = 0x%x",
piobj->name, (int)piobj->type, piobj->id));
if (!mode) {
o->id = piobj->id;
result = 0;
} else { /* write back */
piobj->id = o->id;
result=(store(key, data)) ? -0xff : 0;
}
} else if (mode == 2) { /* creat */
data.dsize = sizeof(NETIOBJ);
data.dptr = (char*)&iobj;
iobj.id = o->id;
result= (store(key, data)) ? -0xff : 0;
}
}
}
dbmclose();
XDPRINTF((3, 0,"handle_iobj mode=%d, result=0x%x, OBJ=%s, type=0x%x",
mode, -result,
o->name,(int)o->type));
return(result);
}
int find_obj_id(NETOBJ *o)
/* no wildcards allowed */
{
int result;
XDPRINTF((2, 0,"findobj_id OBJ=%s, type=0x%x", o->name,(int)o->type));
if ((result=handle_iobj(0, o)) == 0) {
if (!dbminit(FNOBJ)){
key.dsize = NETOBJ_KEY_SIZE;
key.dptr = (char*)o;
data = fetch(key);
result = -0xff;
if (data.dptr != NULL){
NETOBJ *obj=(NETOBJ*)data.dptr;
XDPRINTF((3,0, "got OBJ name=%s, id = 0x%x", obj->name, (int)obj->id));
if ( (!strncmp(obj->name, o->name, sizeof(obj->name)))
&& obj->type == o->type) {
memcpy(o, data.dptr, sizeof(NETOBJ));
result=0;
} else {
XDPRINTF((1,0, "OBJ Index '%s',0x%x, clashes OBJ data '%s', 0x%x",
o->name, (int)o->type,
obj->name, (int)obj->type));
}
} else {
XDPRINTF((1,0, "OBJ Index '%s',0x%x, id=0x%x not found in OBJ data",
o->name, (int)o->type, o->id));
}
} else result = -0xff;
dbmclose();
if (!result)
return(0);
}
result=scan_for_obj(o, 0);
if (!result) { /* was ok, we will rewrite/creat iobj record */
XDPRINTF((1, 0,"findobj_id OBJ='%s', type=0x%x, id=0x%x not in Index File",
o->name,(int)o->type,o->id));
handle_iobj(2, o);
}
return(result);
}
int scan_for_obj(NETOBJ *o, uint32 last_obj_id)
/*
* scans for object,
* wildcards in objectname allowed
* wildcard (MAX_U16) in objecttype allowed
*/
{
int result = -0xfc; /* no Object */
XDPRINTF((2, 0,"findobj_id OBJ=%s, type=0x%x, lastid=0x%x",
XDPRINTF((2, 0,"scan_for_obj OBJ=%s, type=0x%x, lastid=0x%x",
o->name, (int)o->type, (int)last_obj_id));
if (!dbminit(FNOBJ)){
key = firstkey();
if (last_obj_id && (last_obj_id != MAX_U32)){
int flag = 0;
@ -128,7 +233,6 @@ int find_obj_id(NETOBJ *o, uint32 last_obj_id)
key = nextkey(key);
}
}
while (key.dptr != NULL && result) {
data = fetch(key);
if (data.dptr != NULL){
@ -145,7 +249,6 @@ int find_obj_id(NETOBJ *o, uint32 last_obj_id)
}
if (result) key = nextkey(key);
} /* while */
} else result = -0xff;
dbmclose();
return(result);
@ -298,32 +401,43 @@ static int loc_delete_obj(uint32 objid, int security)
result=-0xff;
dbmclose();
if (!result) {
NETOBJ obj;
int filled=0;
if (!dbminit(FNOBJ)){
key.dptr = (char*)&objid;
key.dsize = NETOBJ_KEY_SIZE;
data=fetch(key);
if (data.dptr) {
filled++;
memcpy(&obj, data.dptr, sizeof(NETOBJ));
}
if (delete(key)) result = -0xff;
} else result = -0xff;
dbmclose();
if (filled)
handle_iobj(3, &obj); /* now delete iobj */;
}
return(result);
}
int nw_delete_obj(NETOBJ *obj)
{
int result = find_obj_id(obj, 0);
int result = find_obj_id(obj);
XDPRINTF((2,0, "nw_delete_obj obj_id=%d, obj_name=%s", obj->id, obj->name));
if (!result) result=loc_delete_obj(obj->id, obj->security);
if (!result)
result=loc_delete_obj(obj->id, obj->security);
return(result);
}
int nw_rename_obj(NETOBJ *o, uint8 *newname)
/* rename object */
{
int result = find_obj_id(o, 0);
int result = find_obj_id(o);
if (!result) {
result = b_acc(0, 0x33, 0x04); /* only supervisor */
if (result) return(result); /* no obj rename priv */
else result=-0xff;
handle_iobj(3, o); /* delete old iobj */
if (!dbminit(FNOBJ)){
key.dsize = NETOBJ_KEY_SIZE;
key.dptr = (char*)o;
@ -332,11 +446,14 @@ int nw_rename_obj(NETOBJ *o, uint8 *newname)
NETOBJ *obj=(NETOBJ*)data.dptr;
XDPRINTF((2,0, "rename_obj:got OBJ name=%s, id = 0x%x", obj->name, (int)obj->id));
strncpy(obj->name, newname, 48);
if (!store(key, data)) result=0;
if (!store(key, data)) {
memcpy(o, obj, sizeof(NETOBJ)); /* for handle_iobj */
result=0;
}
}
}
dbmclose();
handle_iobj(2, o); /* creat new iobj */
}
return(result);
}
@ -344,7 +461,7 @@ int nw_rename_obj(NETOBJ *o, uint8 *newname)
int nw_change_obj_security(NETOBJ *o, int newsecurity)
/* change Security of Object */
{
int result = find_obj_id(o, 0);
int result = find_obj_id(o);
if (!result) {
result = b_acc(o->id, o->security, 0x05);
if (result) return(result);
@ -621,7 +738,7 @@ int nw_get_prop_val(int object_type,
int result=-0xff;
strmaxcpy((char*)obj.name, (char*)object_name, object_namlen);
obj.type = (uint16) object_type;
if ((result = find_obj_id(&obj, 0)) == 0){
if ((result = find_obj_id(&obj)) == 0){
result = nw_get_prop_val_by_obj_id(obj.id,
segment_nr,
prop_name, prop_namlen,
@ -644,7 +761,7 @@ int nw_delete_property(int object_type,
XDPRINTF((2,0, "nw_delete_property obj=%s, prop=%s, type=0x%x",
obj.name, prop_name_x, object_type));
obj.type = (uint16) object_type;
if ((result = find_obj_id(&obj, 0)) == 0){
if ((result = find_obj_id(&obj)) == 0){
result = loc_delete_property(obj.id, prop_name_x, 0, 0);
}
return(result);
@ -667,10 +784,10 @@ int nw_is_obj_in_set(int object_type,
obj.name, object_type, mobj.name, member_type, prop.name));
obj.type = (uint16) object_type;
mobj.type = (uint16) member_type;
if ((result = find_obj_id(&obj, 0)) == 0){
if ((result = find_obj_id(&obj)) == 0){
result=find_first_prop_id(&prop, obj.id);
if (!result)
result = find_obj_id(&mobj, 0);
result = find_obj_id(&mobj);
if (!result)
result = prop_find_member(obj.id, (int)prop.id, mobj.id);
}
@ -694,10 +811,10 @@ int nw_add_obj_to_set(int object_type,
obj.name, object_type, mobj.name, member_type, prop.name));
obj.type = (uint16) object_type;
mobj.type = (uint16) member_type;
if ((result = find_obj_id(&obj, 0)) == 0){
if ((result = find_obj_id(&obj)) == 0){
result=find_first_prop_id(&prop, obj.id);
if (!result)
result = find_obj_id(&mobj, 0);
result = find_obj_id(&mobj);
if (!result)
result = prop_add_member(obj.id, (int)prop.id, mobj.id);
}
@ -721,10 +838,10 @@ int nw_delete_obj_from_set(int object_type,
obj.name, object_type, mobj.name, member_type, prop.name));
obj.type = (uint16) object_type;
mobj.type = (uint16) member_type;
if ((result = find_obj_id(&obj, 0)) == 0){
if ((result = find_obj_id(&obj)) == 0){
result=find_first_prop_id(&prop, obj.id);
if (!result)
result = find_obj_id(&mobj, 0);
result = find_obj_id(&mobj);
if (!result)
result = prop_delete_member(obj.id, (int)prop.id, mobj.id);
}
@ -747,7 +864,7 @@ int nw_write_prop_value(int object_type,
obj.name, prop.name, object_type, segment_nr));
obj.type = (uint16) object_type;
if ((result = find_obj_id(&obj, 0)) == 0){
if ((result = find_obj_id(&obj)) == 0){
if ((result=find_first_prop_id(&prop, obj.id))==0){
result=ins_prop_val(obj.id, &prop, segment_nr,
property_value, erase_segments);
@ -772,7 +889,7 @@ int nw_change_prop_security(int object_type,
XDPRINTF((2,0, "nw_change_prop_security obj=%s,0x%x, prop=%s",
obj.name, object_type, prop.name));
obj.type = (uint16) object_type;
if ((result = find_obj_id(&obj, 0)) == 0)
if ((result = find_obj_id(&obj)) == 0)
return(loc_change_prop_security(&prop, obj.id));
return(-0xff);
}
@ -793,7 +910,7 @@ int nw_scan_property(NETPROP *prop,
obj.name, prop->name, object_type, (int)*last_scan));
obj.type = (uint16) object_type;
if ((result = find_obj_id(&obj, 0)) == 0){
if ((result = find_obj_id(&obj)) == 0){
int last_prop_id;
if (*last_scan == MAX_U32) *last_scan = 0;
last_prop_id = *last_scan;
@ -865,6 +982,8 @@ int nw_create_obj(NETOBJ *obj, uint32 wanted_id)
}
} else result = -0xff;
dbmclose();
if (!result)
handle_iobj(2, obj);
return(result);
}
@ -935,7 +1054,7 @@ int nw_create_prop(int object_type,
strmaxcpy((char*)obj.name, (char*)object_name, object_namlen);
strmaxcpy((char*)prop.name, (char*)prop_name, prop_namlen);
obj.type = (uint16) object_type;
if ( 0 == (result = find_obj_id(&obj, 0))
if ( 0 == (result = find_obj_id(&obj))
&& 0 == (result = b_acc(obj.id, obj.security, 0x12)) ) {
prop.flags = (uint8)prop_flags;
prop.security = (uint8)prop_security;
@ -1723,6 +1842,8 @@ int nw_init_dbm(char *servername, ipxAddr_t *adr)
create_nw_db(dbm_fn[FNPROP], 0);
create_nw_db(dbm_fn[FNVAL], 0);
create_nw_db(dbm_fn[FNIOBJ], 0);
if (!dbminit(FNOBJ)){
for (key = firstkey(); key.dptr != NULL; key = nextkey(key)) {
data = fetch(key);

21
nwdbm.h
View File

@ -1,4 +1,4 @@
/* nwdbm.h 04-Oct-96 */
/* nwdbm.h 18-Dec-96 */
/* (C)opyright (C) 1993,1995 Martin Stover, Marburg, Germany
*
* This program is free software; you can redistribute it and/or modify
@ -29,6 +29,14 @@ typedef struct {
uint8 security;
} NETOBJ;
#define NETIOBJ_KEY_SIZE 50
typedef struct {
uint8 name[48];
uint16 type;
/* --------------- */
uint32 id; /* Objekt ID */
} NETIOBJ;
#define NETPROP_KEY_SIZE 5
typedef struct {
uint32 obj_id; /* ID OBJECT */
@ -82,8 +90,8 @@ extern int nw_get_prop(int object_type,
uint8 *property_flags);
extern int find_obj_id(NETOBJ *o, uint32 last_obj_id);
extern int find_obj_id(NETOBJ *o);
extern int scan_for_obj(NETOBJ *o, uint32 last_obj_id);
extern int nw_delete_obj(NETOBJ *obj);
extern int nw_rename_obj(NETOBJ *o, uint8 *newname);
@ -191,6 +199,9 @@ extern int nw_get_q_prcommand(uint32 q_id, uint8 *buff);
extern void test_ins_unx_user(uint32 id);
extern int nw_fill_standard(char *servername, ipxAddr_t *adr);
extern int nw_init_dbm(char *servername, ipxAddr_t *adr);
extern int nw_fill_standard(char *servername, ipxAddr_t *adr);
extern int nw_init_dbm(char *servername, ipxAddr_t *adr);
extern int do_export_dbm(char *path);
extern int do_import_dbm(char *path);
#endif

View File

@ -1,4 +1,4 @@
/* nwfile.c 04-Nov-96 */
/* nwfile.c 31-Dec-96 */
/* (C)opyright (C) 1993,1996 Martin Stover, Marburg, Germany
*
* This program is free software; you can redistribute it and/or modify
@ -47,7 +47,7 @@ static int new_file_handle(uint8 *unixname, int task)
int rethandle = HOFFS -1;
FILE_HANDLE *fh=NULL;
while (++rethandle < anz_fhandles) {
FILE_HANDLE *fh=&(file_handles[rethandle]);
fh=&(file_handles[rethandle]);
if (fh->fd == -1 && !(fh->fh_flags & FH_DO_NOT_REUSE)) { /* empty slot */
rethandle++;
break;
@ -279,7 +279,6 @@ int file_creat_open(int volume, uint8 *unixname, struct stat *stbuff,
if (S_ISFIFO(stbuff->st_mode)){
fh->fd = open(fh->fname,
O_NONBLOCK | dowrite ? O_RDWR : O_RDONLY);
} else {
fh->fh_flags |= FH_IS_PIPE_COMMAND;
fh->fd=-3;
@ -293,7 +292,7 @@ int file_creat_open(int volume, uint8 *unixname, struct stat *stbuff,
fh->fh_flags |= FH_DO_NOT_REUSE;
if (did_grpchange)
xsetegid(act_gid);
return(fhandle);
goto file_creat_open_ret;
}
} else {
/* <========= this is NOT a PIPE Volume ====================> */
@ -371,7 +370,8 @@ int file_creat_open(int volume, uint8 *unixname, struct stat *stbuff,
flockd.l_start = 0;
flockd.l_len = 0;
result = fcntl(fh->fd, F_SETLK, &flockd);
XDPRINTF((5, 0, "open shared lock:result=%d", result));
XDPRINTF(((result==-1)?2:5, 0, "open shared lock:result=%d,fn='%s'",
result, fh->fname));
if (result == -1) {
close(fh->fd);
fh->fd = -1;
@ -397,21 +397,34 @@ int file_creat_open(int volume, uint8 *unixname, struct stat *stbuff,
}
}
if (fh->fd > -1) {
if (!dowrite) fh->fh_flags |= FH_IS_READONLY;
if (creatmode & 4) fh->fh_flags |= FH_DO_NOT_REUSE;
if (!dowrite)
fh->fh_flags |= FH_OPENED_RO;
if (voloptions & VOL_OPTION_READONLY)
fh->fh_flags |= FH_IS_READONLY;
if (creatmode & 4)
fh->fh_flags |= FH_DO_NOT_REUSE;
if (did_grpchange)
xsetegid(act_gid);
return(fhandle);
goto file_creat_open_ret;
}
} /* else (NOT DEVICE) */
} /* else (note pipecommand) */
} /* if !completition */
if (did_grpchange)
xsetegid(act_gid);
XDPRINTF((5,0,"OPEN FILE not OK (-0x%x), fh->name:%s: fhandle=%d",
-completition, fh->fname, fhandle));
free_file_handle(fhandle);
return(completition);
} else return(-0x81); /* no more File Handles */
fhandle=completition;
} else fhandle=-0x81; /* no more File Handles */
file_creat_open_ret:
MDEBUG(D_FH_OPEN, {
char fname[200];
if (!fd_2_fname(fhandle, fname, sizeof(fname))){
dprintf("Open/creat fd=%d, fn=`%s`", fhandle, fname);
}
})
return(fhandle);
}
int nw_set_fdate_time(uint32 fhandle, uint8 *datum, uint8 *zeit)
@ -432,6 +445,13 @@ int nw_close_datei(int fhandle, int reset_reuse)
{
XDPRINTF((5, 0, "nw_close_datei handle=%d, anz_fhandles",
fhandle, anz_fhandles));
MDEBUG(D_FH_OPEN, {
char fname[200];
int r=fd_2_fname(fhandle, fname, sizeof(fname));
dprintf("nw_close_datei: fd=%d, fn=`%s`,r=%d", fhandle, fname, r);
})
if (fhandle > HOFFS && (fhandle <= anz_fhandles)) {
FILE_HANDLE *fh=&(file_handles[fhandle-1]);
if (reset_reuse) fh->fh_flags &= (~FH_DO_NOT_REUSE);
@ -589,7 +609,7 @@ int nw_write_datei(int fhandle, uint8 *data, int size, uint32 offset)
if (fh->fh_flags & FH_IS_PIPE_COMMAND)
open_pipe_command(fh, 1);
if (fh->fd > -1) {
if (fh->fh_flags & FH_IS_READONLY) return(-0x94);
if (fh->fh_flags & FH_OPENED_RO) return(-0x94);
if (fh->fh_flags & FH_IS_PIPE) { /* PIPE */
return(size ? write(fh->fd, data, size) : 0);
} else {
@ -635,7 +655,7 @@ int nw_server_copy(int qfhandle, uint32 qoffset,
if (fhq->fd > -1 && fhz->fd > -1) {
char buff[4096];
int wsize;
if (fhz->fh_flags & FH_IS_READONLY) return(-0x94);
if (fhz->fh_flags & FH_OPENED_RO) return(-0x94);
if (lseek(fhq->fd, qoffset, SEEK_SET) > -1L &&
lseek(fhz->fd, zoffset, SEEK_SET) > -1L) {
retsize = 0;
@ -673,11 +693,19 @@ int nw_lock_datei(int fhandle, int offset, int size, int do_lock)
int result;
if (fh->fh_flags & FH_IS_PIPE) return(0);
flockd.l_type = (do_lock)
? ((fh->fh_flags & FH_IS_READONLY) ? F_RDLCK
: F_WRLCK)
? ((fh->fh_flags & FH_OPENED_RO) ? F_RDLCK
: F_WRLCK)
: F_UNLCK;
flockd.l_whence = SEEK_SET;
#if 0
flockd.l_start = offset;
#else
/* Hint from:Morio Taneda <morio@sozio.geist-soz.uni-karlsruhe.de>
* dBase needs it
* 03-Dec-96
*/
flockd.l_start = (offset & 0x7fffffff);
#endif
flockd.l_len = size;
result = fcntl(fh->fd, F_SETLK, &flockd);
XDPRINTF((2, 0, "nw_%s_datei result=%d, fh=%d, offset=%d, size=%d",
@ -689,6 +717,16 @@ int nw_lock_datei(int fhandle, int offset, int size, int do_lock)
return(-0x88); /* wrong filehandle */
}
int fd_2_fname(int fhandle, char *buf, int bufsize)
{
if (fhandle > HOFFS && (--fhandle < anz_fhandles)) {
FILE_HANDLE *fh=&(file_handles[fhandle]);
strmaxcpy(buf, fh->fname, bufsize-1);
return(0);
}
if (bufsize)
*buf='\0';
return(-0x88);
}

View File

@ -23,7 +23,8 @@ typedef struct {
#define FH_IS_PIPE 0x01
#define FH_IS_PIPE_COMMAND 0x02
#define FH_DO_NOT_REUSE 0x04
#define FH_IS_READONLY 0x20
#define FH_IS_READONLY 0x20 /* filesystem is readonly */
#define FH_OPENED_RO 0x40 /* is opened RO */
extern void sig_bus_mmap(int rsig);
@ -49,5 +50,6 @@ extern int nw_server_copy(int qfhandle, uint32 qoffset,
extern int nw_lock_datei(int fhandle, int offset, int size, int do_lock);
extern int fd_2_fname(int fhandle, char *buf, int bufsize);
#endif

View File

@ -1,4 +1,4 @@
/* nwroute.c 28-Oct-96 */
/* nwroute.c 12-Nov-96 */
/* (C)opyright (C) 1993,1995 Martin Stover, Marburg, Germany
*
* This program is free software; you can redistribute it and/or modify
@ -221,7 +221,9 @@ void insert_delete_server(uint8 *name, /* Server Name */
#endif
{
#if !IN_NWROUTED
ins_del_bind_net_addr(nr->name, nr->typ, NULL);
#endif
xfree(nr->name);
memset(nr, 0, sizeof(NW_SERVERS));
}
@ -230,9 +232,9 @@ void insert_delete_server(uint8 *name, /* Server Name */
/* here now i perhaps must change the entry */
if (nr->hops > 16 || memcmp(&(nr->addr), addr, sizeof(ipxAddr_t))) {
ins_del_bind_net_addr(nr->name, nr->typ, addr);
memcpy(&(nr->addr), addr, sizeof(ipxAddr_t));
#if !IN_NWROUTED
ins_del_bind_net_addr(nr->name, nr->typ, addr);
if (IPXCMPNODE(from_addr->node, my_server_adr.node) &&
IPXCMPNET (from_addr->net, my_server_adr.net)
&& GET_BE16(from_addr->sock) == SOCK_SAP) {
@ -326,7 +328,7 @@ static void send_rip_buff(ipxAddr_t *from_addr)
memset(to_addr.node, 0xFF, IPX_NODE_SIZE);
U16_TO_BE16(SOCK_RIP, to_addr.sock);
}
#if DO_DEBUG
if (nw_debug) {
uint8 *p = rip_buff;
int operation = GET_BE16(p);
@ -344,6 +346,7 @@ static void send_rip_buff(ipxAddr_t *from_addr)
p+=8;
}
}
#endif
send_ipx_data(sockfd[RIP_SLOT], 1,
datasize,
(char *)rip_buff,

View File

@ -1,4 +1,4 @@
/* nwserv.c 09-Nov-96 */
/* nwserv.c 12-Nov-96 */
/* MAIN Prog for NWSERV + NWROUTED */
/* (C)opyright (C) 1993,1996 Martin Stover, Marburg, Germany
@ -92,9 +92,11 @@ static struct pollfd polls[NEEDED_POLLS];
#if 0
static uint16 spx_diag_socket; /* SPX DIAGNOSE SOCKET */
#endif
#if !IN_NWROUTED
static ipxAddr_t nw386_adr; /* Address of NW-TEST Server */
static int nw386_found = 0;
static int client_mode = 0;
#endif
static int ipxdebug = 0;
static int pid_ncpserv = -1;
static int fd_ncpserv_in = -1; /* ctrl-pipe in from ncpserv */
@ -125,7 +127,6 @@ static int ipx_out_fd=-1;
/* next should be '1', is for testing only */
#define USE_PERMANENT_OUT_SOCKET 1
static void add_wdata(IPX_DATA *d, char *data, int size)
{
memcpy(d->owndata.d.data+d->owndata.d.size, data, size);
@ -224,6 +225,12 @@ void ins_del_bind_net_addr(uint8 *name, int styp, ipxAddr_t *adr)
write_to_nwbind(0x3333, 0, (char *)buf, len);
}
#else
# define USE_PERMANENT_OUT_SOCKET 0
# define write_to_ncpserv(what, connection, data, data_size) /* */
# define write_to_nwbind(what, connection, data, data_size) /* */
#endif
static int loc_open_ipx_socket(int sock_nr, int nr)
{
int ipx_fd=open_ipx_socket(&my_server_adr, sock_nr);
@ -235,11 +242,6 @@ static int loc_open_ipx_socket(int sock_nr, int nr)
errorp(0, "loc_open_ipx_socket", "nr=%d", sock_nr);
return(ipx_fd);
}
#else
# define USE_PERMANENT_OUT_SOCKET 0
# define write_to_ncpserv(what, connection, data, data_size) /* */
# define write_to_nwbind(what, connection, data, data_size) /* */
#endif
static int start_ncpserv(char *nwname, ipxAddr_t *addr)
@ -784,7 +786,9 @@ static void handle_event(int fd, uint16 socknr, int slot)
case DIAG_SLOT : handle_diag(fd, (int) ipx_pack_typ, ud.udata.len, &ipx_data_buff, &source_adr); break;
#endif
default : {
default :
#if DO_DEBUG
{
uint8 *p = (uint8*)&ipx_data_buff;
int k = 0;
XDPRINTF((1, 2, "UNKNOWN"));
@ -796,6 +800,7 @@ static void handle_event(int fd, uint16 socknr, int slot)
print_ud_data(&ud);
*/
}
#endif
break;
}
}
@ -952,7 +957,9 @@ static void get_ini(int full)
} /* while */
fclose(f);
}
#if !IN_NWROUTED
if (client_mode < 2) client_mode=0;
#endif
if (print_route_tac && !pr_route_info_fn && !*pr_route_info_fn)
print_route_tac = 0;
if (!print_route_tac) xfree(pr_route_info_fn);
@ -993,8 +1000,10 @@ static void get_ini(int full)
if (!get_ipx_addr(&my_server_adr)) {
internal_net = GET_BE32(my_server_adr.net);
} else exit(1);
} else {
errorp(1, "No ipx-router running !", NULL);
exit(1);
}
#if INTERNAL_RIP_SAP
if (no_internal) {
errorp(10, "WARNING:No use of internal net", NULL);
@ -1141,10 +1150,11 @@ static int server_is_down=0;
static int usage(char *prog)
{
#if !IN_NWROUTED
fprintf(stderr, "usage:\t%s [-h|-k|y]\n", prog);
fprintf(stderr, "usage:\t%s [-v|-h|-k|y]\n", prog);
#else
fprintf(stderr, "usage:\t%s [-h]|-k]\n", prog);
fprintf(stderr, "usage:\t%s [-v|-h]|-k]\n", prog);
#endif
fprintf(stderr, "\t-v: print version\n");
fprintf(stderr, "\t-h: send HUP to main process\n");
fprintf(stderr, "\t-k: stop main process\n");
#if !IN_NWROUTED
@ -1169,12 +1179,18 @@ int main(int argc, char **argv)
switch (*a) {
case 'h' : init_mode = 1; break;
case 'k' : init_mode = 2; break;
case 'v' : fprintf(stderr, "\n%s:Version %d.%d.pl%d\n",
argv[0], _VERS_H_, _VERS_L_, _VERS_P_ );
return(0);
default : return(usage(argv[0]));
}
}
} else if (*a == 'y')
}
#if !IN_NWROUTED
else if (*a == 'y')
client_mode=1;
/* in client mode the testprog 'nwclient' will be startet. */
#endif
else
return(usage(argv[0]));
}
@ -1379,8 +1395,8 @@ int main(int argc, char **argv)
} else {
#if !IN_NWROUTED
if (call_wdog) send_wdogs(1);
#endif
if (client_mode && difftime > 5) get_servers(); /* Here more often */
#endif
}
}
} /* while */

View File

@ -162,7 +162,8 @@ void nw_setup_home_vol(int len, uint8 *fn)
nw_volumes[k].maps_count = 0;
nw_volumes[k].unixnamlen = len;
new_str(nw_volumes[k].unixname, unixname);
volume_to_namespace_map(k, &(nw_volumes[k]));
if (len)
volume_to_namespace_map(k, &(nw_volumes[k]));
}
}
}

32
tools.c
View File

@ -1,4 +1,4 @@
/* tools.c 29-Sep-96 */
/* tools.c 30-Dec-96 */
/* (C)opyright (C) 1993,1995 Martin Stover, Marburg, Germany
*
* This program is free software; you can redistribute it and/or modify
@ -25,7 +25,9 @@ extern char *_sys_errlist[];
#endif
int nw_debug=0;
int nw_debug=0;
uint32 debug_mask=0; /* special debug masks */
FILE *logfile=stderr;
static int in_module=0; /* in which process i am ? */
@ -73,6 +75,7 @@ void x_x_xfree(char **p)
}
int strmaxcpy(uint8 *dest, uint8 *source, int len)
/* dest must be 1 byte larger than len */
{
int slen = (source != (uint8 *)NULL) ? min(len, strlen((char*)source)) : 0;
if (slen)
@ -171,7 +174,17 @@ FILE *open_nw_ini(void)
{
char *fname=FILENAME_NW_INI;
FILE *f=fopen(fname, "r");
if (f == (FILE*)NULL) fprintf(logfile, "Cannot open ini file `%s`\n", fname);
int uid=geteuid();
if (f == (FILE*)NULL && uid > 0) {
seteuid(0);
f=fopen(fname, "r");
if (seteuid(uid)) {
errorp(1, "seteuid", "uid=%d", uid);
exit(1);
}
}
if (f == (FILE*)NULL)
fprintf(logfile, "Cannot open ini file `%s`\n", fname);
return(f);
}
@ -362,7 +375,18 @@ void init_tools(int module, int options)
withlog++;
} else if (202 == what) {
new_log = atoi((char*)buf);
} else if (100+module == what) nw_debug=atoi((char*)buf);
} else if (100+module == what) {
char buf1[300], buf2[300];
int i=sscanf((char*)buf, "%s %s", buf1, buf2);
if (i > 0) {
nw_debug=atoi((char*)buf1);
if (i > 1) {
char dummy;
if (sscanf(buf2, "%ld%c", &debug_mask, &dummy) != 1)
sscanf(buf2, "%lx", &debug_mask);
}
}
}
}
fclose(f);
}

View File

@ -67,15 +67,19 @@ extern uint8 *station_fn;
extern int find_station_match(int entry, ipxAddr_t *addr);
extern int nw_debug;
extern int nw_debug;
extern uint32 debug_mask;
#include "debmask.h"
#if DO_DEBUG
# define DPRINTF(x) dprintf x
# define XDPRINTF(x) xdprintf x
# define D() XDPRINTF((3, 0, "Z: %d" , __LINE__));
# define MDEBUG(mask, x) if (mask & debug_mask) x
#else
# define DPRINTF(x) /* */
# define XDPRINTF(x) /* */
# define D() /* */
# define MDEBUG(mask, x) /* */
#endif
#endif /* _TOOLS_H_ */

View File

@ -1,4 +1,4 @@
/* unxfile.c: 29-Apr-96*/
/* unxfile.c: 20-Nov-96*/
/* (C)opyright (C) 1993,1996 Martin Stover, Marburg, Germany
*
@ -39,6 +39,15 @@ int unx_mvfile(uint8 *oldname, uint8 *newname)
return( (rename(oldname, newname) < 0) ? errno : 0);
}
int unx_mvfile_or_dir(uint8 *oldname, uint8 *newname)
{
struct stat statb;
if (!stat(newname, &statb)) return(EEXIST);
if (stat(oldname, &statb)) return(-1);
return( (rename(oldname, newname) < 0) ? errno : 0);
}
#else
int unx_mvdir(uint8 *oldname, uint8 *newname)
{

View File

@ -1,4 +1,4 @@
/* unxfile.h: 29-Apr-96*/
/* unxfile.h: 20-Nov-96*/
/* (C)opyright (C) 1993,1996 Martin Stover, Marburg, Germany
*
@ -19,4 +19,5 @@
extern int unx_mvdir(uint8 *oldname, uint8 *newname);
extern int unx_mvfile(uint8 *oldname, uint8 *newname);
extern int unx_mvfile_or_dir(uint8 *oldname, uint8 *newname);