mars_nwe-0.97.pl02

This commit is contained in:
Mario Fetka 2011-11-13 00:38:56 +01:00
parent a584c2191f
commit 55682d7171
24 changed files with 2252 additions and 1651 deletions

116
connect.c
View File

@ -1,4 +1,4 @@
/* connect.c 10-Mar-96 */
/* connect.c 20-Mar-96 */
/* (C)opyright (C) 1993,1996 Martin Stover, Marburg, Germany
*
* This program is free software; you can redistribute it and/or modify
@ -297,6 +297,7 @@ int fn_match(uint8 *s, uint8 *p, uint8 options)
typedef struct {
int attrib;
struct stat statb;
uint8 *ubuf; /* userbuff */
} FUNC_SEARCH;
static int func_search_entry(NW_PATH *nwpath, int attrib,
@ -313,11 +314,14 @@ static int func_search_entry(NW_PATH *nwpath, int attrib,
int volume = nwpath->volume;
uint8 soptions;
FUNC_SEARCH fs_local;
if (!fs) fs = &fs_local;
if (!fs) {
fs = &fs_local;
fs->ubuf = NULL;
}
fs->attrib = attrib;
if (volume < 0 || volume >= used_nw_volumes) return(-1); /* something wrong */
else soptions = nw_volumes[volume].options;
strcpy(entry, nwpath->fn);
strcpy((char*)entry, (char*)nwpath->fn);
if (soptions & 1) downstr(entry); /* now downshift chars */
nwpath->fn[0] = '\0';
strcpy(xkpath, build_unix_name(nwpath, 1|2));
@ -333,16 +337,16 @@ static int func_search_entry(NW_PATH *nwpath, int attrib,
uint8 *name=(uint8*)(dirbuff->d_name);
okflag = (name[0] != '.' &&
( (entry[0] == '*' && entry[1] == '\0')
|| (!strcmp(name, entry))
|| (!strcmp((char*)name, (char*)entry))
|| fn_match(name, entry, soptions)));
if (okflag) {
*kpath = '\0';
strcpy(kpath, name);
strcpy(kpath, (char*)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);
strcpy((char*)nwpath->fn, (char*)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);
@ -375,7 +379,7 @@ static int get_dir_entry(NW_PATH *nwpath,
uint8 soptions;
if (volume < 0 || volume >= used_nw_volumes) return(0); /* something wrong */
else soptions = nw_volumes[volume].options;
strcpy(entry, nwpath->fn);
strcpy((char*)entry, (char*)nwpath->fn);
if (soptions & 1) downstr(entry); /* now downshift chars */
nwpath->fn[0] = '\0';
@ -395,16 +399,16 @@ static int get_dir_entry(NW_PATH *nwpath,
uint8 *name=(uint8*)(dirbuff->d_name);
okflag = (name[0] != '.' &&
( (entry[0] == '*' && entry[1] == '\0')
|| (!strcmp(name, entry))
|| (!strcmp((char*)name, (char*)entry))
|| fn_match(name, entry, soptions)));
if (okflag) {
*kpath = '\0';
strcpy(kpath, name);
strcpy(kpath, (char*)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);
strcpy((char*)nwpath->fn, (char*)name);
if (soptions & 1) upstr(nwpath->fn);
XDPRINTF((5,0,"FOUND=:%s: attrib=0x%x", nwpath->fn, statb->st_mode));
break; /* ready */
@ -465,12 +469,12 @@ static int get_dh_entry(DIR_HANDLE *dh,
if (dirbuff->d_ino) {
uint8 *name=(uint8*)(dirbuff->d_name);
okflag = (name[0] != '.' && (
(!strcmp(name, entry)) ||
(!strcmp((char*)name, (char*)entry)) ||
(entry[0] == '*' && entry[1] == '\0')
|| fn_match(name, entry, dh->vol_options)));
if (okflag) {
strcpy(dh->kpath, name);
strcpy(dh->kpath, (char*)name);
XDPRINTF((5,0,"get_dh_entry Name=%s unixname=%s",
name, dh->unixname));
@ -478,7 +482,7 @@ static int get_dh_entry(DIR_HANDLE *dh,
okflag = ( (( (statb->st_mode & S_IFMT) == S_IFDIR) && (attrib & 0x10))
|| (((statb->st_mode & S_IFMT) != S_IFDIR) && !(attrib & 0x10)));
if (okflag){
strcpy(search, name);
strcpy((char*)search, (char*)name);
if (dh->vol_options & 1) upstr(search);
break; /* ready */
}
@ -530,10 +534,10 @@ void conn_build_path_fn( uint8 *vol,
*p1 = '\0';
if (fn != NULL) { /* if with filename */
if (p != NULL){ /* exist directory-path */
strcpy(fn, p);
strcpy((char*)fn, (char*)p);
*p = '\0';
} else { /* only filename */
strcpy(fn, path);
strcpy((char*)fn, (char*)path);
*path= '\0';
}
}
@ -564,7 +568,7 @@ static int build_path( NW_PATH *path,
if (vol[0]) { /* there is a volume in path */
int j = used_nw_volumes;
while (j--) {
if (!strcmp(nw_volumes[j].sysname, vol)) {
if (!strcmp((char*)nw_volumes[j].sysname, (char*)vol)) {
path->volume = j;
break;
}
@ -584,7 +588,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((char*)nwpath->path, (char*)d->path)){
return(d->inode);
}
d++;
@ -606,7 +610,7 @@ static int build_verz_name(NW_PATH *nwpath, /* gets complete path */
uint8 *p=searchpath;
int completition=0;
strcpy(searchpath, nwpath->path); /* save path */
strcpy((char*)searchpath, (char*)nwpath->path); /* save path */
if (nwpath->volume > -1) { /* absolute path */
nwpath->path[0] = '\0';
@ -618,7 +622,7 @@ static int build_verz_name(NW_PATH *nwpath, /* gets complete path */
p++;
nwpath->path[0] = '\0';
} else /* get path from dir_handle */
strcpy(nwpath->path, dirs[dir_handle].path);
strcpy((char*)nwpath->path, (char*)dirs[dir_handle].path);
} else return(-0x9b); /* wrong dir handle */
}
@ -754,12 +758,12 @@ static int get_file_attrib(NW_FILE_INFO *f, struct stat *stb,
NW_PATH *nwpath)
{
XDPRINTF((5,0, "get_file_attrib of %s", conn_get_nwpath_name(nwpath) ));
strncpy(f->name, nwpath->fn, sizeof(f->name));
strncpy((char*)f->name, (char*)nwpath->fn, sizeof(f->name));
/* Attribute */
/* 0x20 Archive Flag */
/* 0x80 Sharable */ /* TLINK (TCC 2.0) don't like it ???? */
#if 1
if (!strcmp(nwpath->fn, "TURBOC.$LN")) f->attrib = 0x20;
if (!strcmp((char*)nwpath->fn, "TURBOC.$LN")) f->attrib = 0x20;
else f->attrib = 0x80;
#else
f->attrib = 0x20;
@ -777,7 +781,7 @@ static int get_dir_attrib(NW_DIR_INFO *d, struct stat *stb,
NW_PATH *nwpath)
{
XDPRINTF((5,0, "get_dir_attrib of %s", conn_get_nwpath_name(nwpath)));
strncpy(d->name, nwpath->fn, sizeof(d->name));
strncpy((char*)d->name, (char*)nwpath->fn, sizeof(d->name));
d->attrib = 0x10; /* Verzeichnis */
d->ext_attrib = 0xff; /* effektive rights ?? */
@ -792,8 +796,6 @@ static int get_dir_attrib(NW_DIR_INFO *d, struct stat *stb,
return(1);
}
static int do_delete_file(NW_PATH *nwpath, FUNC_SEARCH *fs)
{
char unname[256];
@ -817,6 +819,38 @@ int nw_delete_datei(int dir_handle, uint8 *data, int len)
return(completition);
}
static int do_set_file_info(NW_PATH *nwpath, FUNC_SEARCH *fs)
{
char unname[256];
NW_FILE_INFO *f=(NW_FILE_INFO*)fs->ubuf;
strcpy(unname, build_unix_name(nwpath, 0));
XDPRINTF((5,0,"set_file_info unname:%s:", unname));
if (get_volume_options(nwpath->volume, 1) & VOL_OPTION_IS_PIPE)
return(0); /* don't change 'pipe commands' */
else {
struct utimbuf ut;
ut.actime = ut.modtime = nw_2_un_time(f->modify_date, f->modify_time);
if (!utime(unname, &ut)) return(0);
}
return(-0x85); /* NO Privileges */
}
int nw_set_file_information(int dir_handle, uint8 *data, int len,
int searchattrib, NW_FILE_INFO *f)
{
NW_PATH nwpath;
int completition = conn_get_kpl_path(&nwpath, dir_handle, data, len, 0);
if (completition > -1) {
FUNC_SEARCH fs;
fs.ubuf = (uint8*)f;
completition = func_search_entry(&nwpath, searchattrib,
do_set_file_info, &fs);
if (completition < 0) return(completition);
else if (!completition) return(-0xff);
}
return(completition);
}
int nw_chmod_datei(int dir_handle, uint8 *data, int len, int modus)
{
char unname[256];
@ -964,7 +998,7 @@ int nw_init_connect(void)
int what;
int k = MAX_NW_DIRS;
NW_DIR *d = &(dirs[0]);
strcpy(nwlogin.path, login);
strcpy((char*)nwlogin.path, (char*)login);
nwlogin.fn[0] = '\0';
nwlogin.volume = 0;
@ -985,13 +1019,13 @@ int nw_init_connect(void)
while (k++ < anz_dirhandles) free_dir_handle(k);
} else connect_is_init++;
while (0 != (what = get_ini_entry(f, 0, (char*)buff, sizeof(buff)))) {
while (0 != (what = get_ini_entry(f, 0, buff, sizeof(buff)))) {
if (what == 10) { /* GID */
default_gid = atoi(buff);
default_gid = atoi((char*)buff);
} else if (what == 11) { /* UID */
default_uid = atoi(buff);
default_uid = atoi((char*)buff);
} else if (what == 103) { /* Debug */
nw_debug = atoi(buff);
nw_debug = atoi((char*)buff);
}
} /* while */
nw_init_volumes(f);
@ -1278,7 +1312,7 @@ int nw_creat_open_file(int dir_handle, uint8 *data, int len,
int completition = conn_get_kpl_path(&nwpath, dir_handle, data, len, 0);
if (completition > -1) {
struct stat stbuff;
completition=file_creat_open(nwpath.volume, build_unix_name(&nwpath, 0),
completition=file_creat_open(nwpath.volume, (uint8*)build_unix_name(&nwpath, 0),
&stbuff, attrib, access, creatmode);
if (completition > -1)
@ -1307,7 +1341,7 @@ static int s_nw_scan_dir_info(int dir_handle,
uint8 dirname[256];
if (!dirsequenz) dirsequenz++;
strcpy(dirname, wild);
strcpy((char*)dirname, (char*)wild);
XDPRINTF((5,0,"SCAN_DIR: rights = 0x%x, subnr = %d",
(int)rights, (int)GET_BE16(subnr)));
@ -1321,13 +1355,13 @@ static int s_nw_scan_dir_info(int dir_handle,
XDPRINTF((5,0,"SCAN_DIR: von %s, found %s:", dh->unixname, dirname));
if (++aktsequenz == dirsequenz) { /* actual found */
U16_TO_BE16(aktsequenz, subnr);
strncpy(subname, dirname, 16);
strncpy((char*)subname, (char*)dirname, 16);
U32_TO_BE32(1L, owner); /* erstmal */
un_date_2_nw(stbuff.st_mtime, subdatetime);
un_time_2_nw(stbuff.st_mtime, subdatetime+2);
return(0xff);
}
strcpy(dirname, wild);
strcpy((char*)dirname, (char*)wild);
} /* while */
} else {
strcpy(dh->kpath, ".");
@ -1411,8 +1445,8 @@ static void get_dos_file_attrib(NW_DOS_FILE_INFO *f,
struct stat *stb,
NW_PATH *nwpath)
{
f->namlen=min(strlen(nwpath->fn), 12);
strncpy(f->name, nwpath->fn, f->namlen);
f->namlen=min(strlen((char*)nwpath->fn), 12);
strncpy((char*)f->name, (char*)nwpath->fn, f->namlen);
/* Attribute */
/* 0x20 Archive Flag */
/* 0x80 Sharable */
@ -1449,8 +1483,8 @@ static void get_dos_dir_attrib(NW_DOS_DIR_INFO *f,
struct stat *stb,
NW_PATH *nwpath)
{
f->namlen=min(strlen(nwpath->fn), 12);
strncpy(f->name, nwpath->fn, f->namlen);
f->namlen=min(strlen((char*)nwpath->fn), 12);
strncpy((char*)f->name, (char*)nwpath->fn, f->namlen);
f->attributes[0] = 0x10; /* Dir */
xun_date_2_nw(stb->st_mtime, f->created.date);
xun_time_2_nw(stb->st_mtime, f->created.time);
@ -1596,7 +1630,7 @@ static void set_entry_time(uint8 *entry_time)
entry_time[5] = (uint8) s_tm->tm_sec;
}
static int create_queue_file(char *job_file_name,
static int create_queue_file(uint8 *job_file_name,
uint32 q_id,
int jo_id,
int connection,
@ -1608,7 +1642,7 @@ static int create_queue_file(char *job_file_name,
int result;
NW_FILE_INFO fnfo;
*job_file_name
= sprintf(job_file_name+1, "%07lX%d.%03d", q_id, jo_id, connection);
= sprintf((char*)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)
@ -1713,12 +1747,12 @@ int nw_close_file_queue(uint8 *queue_id,
INT_QUEUE_JOB *jo=queue_jobs[jo_id-1];
int fhandle = (int)jo->fhandle;
char unixname[300];
strmaxcpy(unixname, file_get_unix_name(fhandle), sizeof(unixname)-1);
strmaxcpy((uint8*)unixname, (uint8*)file_get_unix_name(fhandle), sizeof(unixname)-1);
XDPRINTF((5,0,"nw_close_file_queue fhandle=%d", fhandle));
if (*unixname) {
char printcommand[256];
FILE *f=NULL;
strmaxcpy(printcommand, prc, prc_len);
strmaxcpy((uint8*)printcommand, prc, prc_len);
nw_close_datei(fhandle, 1);
jo->fhandle = 0L;
if (NULL != (f = fopen(unixname, "r"))) {

View File

@ -61,6 +61,9 @@ extern int nw_creat_open_file(int dir_handle, uint8 *data, int len,
NW_FILE_INFO *info, int attrib, int access, int mode);
extern int nw_delete_datei(int dir_handle, uint8 *data, int len);
extern int nw_set_file_information(int dir_handle, uint8 *data, int len,
int searchattrib, NW_FILE_INFO *f);
extern int nw_chmod_datei(int dir_handle, uint8 *data, int len, int modus);
extern int mv_file(int qdirhandle, uint8 *q, int qlen,

View File

@ -1,5 +1,5 @@
Sorry, this is in German only. :-(
Aenderungen in mars_nwe bis zum : 10-Feb-96
Aenderungen in mars_nwe bis zum : 21-Mar-96
--------------------------------
Erste 'oeffentliche' Version
^^^^^^^^^^ VERSION 0.94 ^^^^^^^^
@ -95,3 +95,12 @@ Erste 'oeffentliche' Version
- Moeglichkeit der stationsabhaengigen Steuerung von
Nearest Server Response eingebaut.
^^^^^^^^^^ VERSION 0.97 ^^^^^^^^
- Bug in connect.c (nw_scan_dir_info) korrigiert.
- neuses Modul nwbind erzeugt. Dadurch Designaenderungen an
allen Modulen.
- Alle NCP-Responses erhalten nun als Dest Addresse den NCP-Socket.
OS/2 Client u. evtl. auch andere (Win95 ?) erwarten es. !
- Password Schema leicht veraendert/erweitert.
modus '8' -> modus '7', neuer modus '8'.
- neue Routine 0x17, 0x10 (set file information) codiert.

View File

@ -1,4 +1,16 @@
# in this files are important notes for user of mars_nwe.
------21-Mar-96--- 0.97.pl2 ----------
Entry '7' in ini/conf file modified.
Old mode '8' is now mode '7' and mode '8'
is now extended by allowing empty mars_nwe passwords
although the linux password from this user is not empty.
-
Now mars_nwe works fine with OS/2 Client. :)
-
There is a new little kernelpatch 'kpatch1.3.72' in the
examples directory.
With this patch mars_nwe will speed up more than 30 %.
------10-Mar-96--- 0.97.pl0 ----------
New Conf-file entry '211' for broadcast periods.
Entries 400, 401 for special handling of the nearest server request.

View File

@ -1,7 +1,7 @@
Begin3
Title: mars_nwe
Version: 0.97
Entered-date: 10-Mar-96
Version: 0.97.pl2
Entered-date: 21-Mar-96
Description: full novell-server-emulator (src),beta
supports file-services, bindery-services,
printing-services, routing-services
@ -9,7 +9,7 @@ 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
110kB mars_nwe-0.97.tgz
120kB mars_nwe-0.97.pl2.tgz
Alternate-site: ftp.uni-duisburg.de /pub/linux/ipxware
Platforms: Linux (1.2.xx, 1.3.32, > 1.3.55 tested, others should work)
Copying-policy: GNU

View File

@ -191,17 +191,31 @@ int init_ipx(uint32 network, uint32 node, int ipx_debug)
int result=-1;
int sock=sock = socket(AF_IPX, SOCK_DGRAM, AF_IPX);
if (socket < 0) {
errorp(0, "EMUTLI:init_ipx", NULL);
errorp(1, "EMUTLI:init_ipx", NULL);
exit(1);
} else {
set_sock_debug(sock);
close(sock);
result=0;
/* makes new internal net */
if (network) {
struct sockaddr_ipx ipxs;
memset((char*)&ipxs, 0, sizeof(struct sockaddr_ipx));
ipxs.sipx_port = htons(SOCK_NCP);
ipxs.sipx_family = AF_IPX;
if (bind(sock, (struct sockaddr*)&ipxs,
sizeof(struct sockaddr_ipx))==-1) {
if (errno == EEXIST || errno == EADDRINUSE) result = -1;
} else result =-1;
close(sock);
if (result) {
errorp(1, "EMUTLI:init_ipx socket 0x451", NULL);
exit(1);
}
del_internal_net();
add_internal_net(network, node);
have_ipx_started++;
} else {
close(sock);
}
}
return(result);

View File

@ -0,0 +1,12 @@
The kernelpatch kpatch1.3.72 you can use directly for kernels 1.3.72 .. ???
but it should be easy to apply this patch to all kernels.
By older kernels 'sk->protinfo.af_ipx.' must become 'sk->' .
After applying this patch please rebuild mars_nwe (make clean)
for getting notice of new ioctl call 'SIOCIPXNCPCONN'.
This patch is only necessary to speed up mars_nwe. (ca. 30 .. 50 % )
Perhaps this patch will get a place in the kerneldistribution one day. :)
This kernelpatch was originally designed by Volker Lendecke.
Martin

72
examples/kpatch1.3.72 Normal file
View File

@ -0,0 +1,72 @@
Index: include/linux/ipx.h
--- linux.org/include/linux/ipx.h Mon Dec 11 19:55:58 1995
+++ linux/include/linux/ipx.h Thu Mar 21 17:14:49 1996
@@ -74,5 +74,6 @@
#define SIOCAIPXITFCRT (SIOCPROTOPRIVATE)
#define SIOCAIPXPRISLT (SIOCPROTOPRIVATE+1)
#define SIOCIPXCFGDATA (SIOCPROTOPRIVATE+2)
+#define SIOCIPXNCPCONN (SIOCPROTOPRIVATE+3)
#endif
Index: include/net/sock.h
Prereq: 1.0.4
--- linux.org/include/net/sock.h Mon Mar 11 02:08:59 1996
+++ linux/include/net/sock.h Thu Mar 21 02:36:23 1996
@@ -96,6 +96,7 @@
ipx_address dest_addr;
ipx_interface *intrfc;
unsigned short port;
+ unsigned short ipx_ncp_conn;
#ifdef CONFIG_IPX_INTERN
unsigned char node[IPX_NODE_LEN];
#endif
Index: net/ipx/af_ipx.c
--- linux.org/net/ipx/af_ipx.c Sun Mar 10 22:51:28 1996
+++ linux/net/ipx/af_ipx.c Thu Mar 21 17:26:54 1996
@@ -438,6 +438,20 @@
ipx_socket *sock1 = NULL, *sock2 = NULL;
struct sk_buff *skb1 = NULL, *skb2 = NULL;
+ if (intrfc == ipx_primary_net
+ && ntohs(ipx->ipx_dest.sock) == 0x451
+ && *((char*)(ipx+1)) == 0x22
+ && *((char*)(ipx+1)+1) == 0x22) {
+ int connection = (int) *((char*)(ipx+1)+3);
+ /* 255 connections are enough ;) */
+ if (connection) {
+ for (sock1=intrfc->if_sklist;
+ (sock1 != NULL) &&
+ (sock1->protinfo.af_ipx.ipx_ncp_conn != connection);
+ sock1=sock1->next);;
+ }
+ }
+ if (sock1 == NULL)
sock1 = ipxitf_find_socket(intrfc, ipx->ipx_dest.sock);
/*
@@ -1628,6 +1642,7 @@
sizeof(sk->protinfo.af_ipx.dest_addr));
sk->protinfo.af_ipx.port = 0;
sk->protinfo.af_ipx.ncp_server = 0;
+ sk->protinfo.af_ipx.ipx_ncp_conn = 0; /* no ncp socket yet */
sk->mtu=IPX_MTU;
if(sock!=NULL)
@@ -2128,6 +2143,17 @@
if(err) return err;
return(ipxcfg_get_config_data((void *)arg));
}
+
+ case SIOCIPXNCPCONN:
+ {
+ if (!suser()) return(-EPERM);
+ err = verify_area(VERIFY_READ, (void *)arg,
+ sizeof(unsigned short));
+ if (err) return err;
+ sk->protinfo.af_ipx.ipx_ncp_conn = get_fs_word(arg);
+ return 0;
+ }
+
case SIOCGSTAMP:
if (sk)
{

View File

@ -50,21 +50,24 @@
# that it is a 3.11 Server, although many calls
# (namespace services) of a real 3.11 Server are missing yet.
# simple namespace services are implemented for testing
# since V 0.96pl8. To test them, this entry must be set to '1'.
# and config.h must be altered to allow namespace calls.
# since V 0.96pl8. To test them, this entry must be set to > 0.
# and config.h must be altered to compile in namespace calls.
6 0 # tells server version: 0=2.15, 1=3.11, 2=3.12
######################################
# Password handling
7 0 # 0 = use only encrypted passwords stuff (default)
# 1 = allow the unencrypted change password routine.
# 8 = allow all unencrypted stuff.
# 7 = allow all unencrypted stuff, no empty nwe passwords.
# 8 = allow all unencrypted stuff, allow empty nwe passwords.
# 9 = use all unencryted calls + get crypt key will allways fail
# so the login program will use the old unencryted calls.
# this will *not* work with all clients !! (OS2/client)
######################################
# GID and UID for _minimal_ rights
# will be used for not logins or not assigned mars_nwe users.
10 200 # GID
11 201 # UID
#############################
######################################
# the following passwords should be removed after the first
# start, because these entries will be inserted (crypted) into
# the bindery. If you specify a password here, then this password
@ -81,7 +84,7 @@
# Read UnixUsers automaticly from passwd into bindery
# switch password
15 0 secure11
# ^^^ 0=off (default), 1=on, 99=overwrite existing users.
# ^^^ 0=off (default), 1=on, 99=overwrite existing mars_nwe users.
# !!! IMPORTANT !!!
# If you enable this feature you should chose a secure
# password for the users, because all not existent
@ -102,6 +105,7 @@
102 0 # debug NCPSERV
103 0 # debug NWCONN
104 0 # debug (start) NWCLIENT
105 0 # debug NWBIND
#############################
200 1 # 0 = no logfile and dont daemonize nwserv
# # 1 = daemonize nwserv and use logfile

View File

@ -1,5 +1,5 @@
#if 0
#makefile.unx 10-Mar-96
#makefile.unx 15-Mar-96
#endif
VPATH=$(V_VPATH)
@ -9,7 +9,7 @@ C=.c
V_H=0
V_L=97
P_L=1
P_L=2
#define D_P_L 1
DISTRIB=mars_nwe
@ -62,6 +62,7 @@ PROG2=nwserv
PROG3=nwconn
PROG4=ncpserv
PROG5=nwclient
PROG6=nwbind
#include "config.h"
#ifdef FILENAME_NW_INI
@ -91,17 +92,18 @@ NWROUTE_O=nwroute1$(O)
NWROUTE_O=nwroute1$(O)
#endif
PROGS=$(PROG1) $(PROG2) $(PROG3) $(PROG4) $(PROG5)
PROGS=$(PROG1) $(PROG2) $(PROG3) $(PROG4) $(PROG5) $(PROG6)
OBJ1= $(EMUTLIOBJ) net1$(O) tools$(O)
OBJ2= $(OBJ1) $(NWROUTE_O)
OBJ3= $(OBJ1) connect$(O) namspace$(O) nwvolume$(O) nwfile$(O)
OBJ4= $(OBJ1) nwdbm$(O) nwcrypt$(O)
OBJ4= $(OBJ1)
OBJ5= $(OBJ1)
OBJ6= $(OBJ1) nwdbm$(O) nwcrypt$(O)
OBJS= net1$(O) tools$(O) connect$(O) nwdbm$(O) $(NWROUTE_O) \
namspace$(O) nwvolume$(O) \
$(PROG2)$(O) $(PROG3)$(O) $(PROG4)$(O) $(PROG5)$(O)
$(PROG2)$(O) $(PROG3)$(O) $(PROG4)$(O) $(PROG5)$(O) $(PROG6)$(O)
HOBJ3= $(PROG3)$(O) connect$(O) namspace$(O) nwvolume$(O) nwfile$(O)
@ -120,11 +122,15 @@ $(PROG3): $(PROG3)$(O) $(OBJ3)
$(CC) -o $(VPATH)/$(PROG3) $(PROG3)$(O) $(OBJ3) $(NSLLIB)
$(PROG4): $(PROG4)$(O) $(OBJ4)
$(CC) -o $(VPATH)/$(PROG4) $(PROG4)$(O) $(OBJ4) $(NDBMLIB) $(CRYPTLIB) $(NSLLIB)
$(CC) -o $(VPATH)/$(PROG4) $(PROG4)$(O) $(OBJ4) $(NSLLIB)
$(PROG5): $(PROG5)$(O) $(OBJ5)
$(CC) -o $(VPATH)/$(PROG5) $(PROG5)$(O) $(OBJ5) $(NSLLIB)
$(PROG6): $(PROG6)$(O) $(OBJ6)
$(CC) -o $(VPATH)/$(PROG6) $(PROG6)$(O) $(OBJ6) $(NDBMLIB) $(CRYPTLIB) $(NSLLIB)
$(HOBJ3): namspace.h connect.h nwvolume.h nwfile.h
$(OBJS): net.h config.h

1363
ncpserv.c

File diff suppressed because it is too large Load Diff

62
net.h
View File

@ -1,4 +1,4 @@
/* net.h 01-Mar-96 */
/* net.h 20-Mar-96 */
/* (C)opyright (C) 1993,1996 Martin Stover, Marburg, Germany
*
@ -97,19 +97,18 @@
# undef CALL_NWCONN_OVER_SOCKET
#endif
#ifdef CALL_NCPSERV_OVER_SOCKET
# undef CALL_NCPSERV_OVER_SOCKET
#endif
#include "config.h"
#ifndef CALL_NWCONN_OVER_SOCKET
# define CALL_NWCONN_OVER_SOCKET 0
#endif
#ifndef CALL_NCPSERV_OVER_SOCKET
# define CALL_NCPSERV_OVER_SOCKET 1
# ifdef LINUX
# ifdef SIOCIPXNCPCONN
# define CALL_NWCONN_OVER_SOCKET 1
# else
# define CALL_NWCONN_OVER_SOCKET 0
# endif
# else
# define CALL_NWCONN_OVER_SOCKET 0
# endif
#endif
#ifndef DO_DEBUG
@ -298,9 +297,10 @@ typedef union {
} ncprequest;
struct S_OWN_DATA {
uint8 type[2]; /* 0xeeee */
uint8 type1[2]; /* 0xeeee */
uint8 sequence;
uint8 connection;
struct {
int size; /* size of next two entries */
int size; /* size of next two entries */
int function;
uint8 data[1];
} d;
@ -309,10 +309,10 @@ typedef union {
} IPX_DATA;
typedef struct S_SIP SIP;
typedef struct S_SQP SQP;
typedef struct S_SAP SAP;
typedef struct S_SAPS SAPS;
typedef struct S_RIP RIP;
typedef struct S_SQP SQP;
typedef struct S_SAP SAP;
typedef struct S_SAPS SAPS;
typedef struct S_RIP RIP;
typedef struct S_CONFREQ CONFREQ;
typedef struct S_DIAGRESP DIAGRESP;
@ -320,25 +320,27 @@ typedef struct S_NCPRESPONSE NCPRESPONSE;
typedef struct S_NCPREQUEST NCPREQUEST;
typedef struct S_OWN_DATA OWN_DATA;
#define OWN_DATA_IPX_BASE_SIZE 8
/* SOCKETS */
#define SOCK_AUTO 0x0000 /* Autobound Socket */
#define SOCK_ROUTE 0x0001 /* Routing Information */
#define SOCK_ECHO 0x0002 /* Echo Protokoll Packet */
#define SOCK_ERROR 0x0003 /* Error Handler Packet */
#define SOCK_NCP 0x0451 /* File Service CORE */
#define SOCK_ROUTE 0x0001 /* Routing Information */
#define SOCK_ECHO 0x0002 /* Echo Protokoll Packet */
#define SOCK_ERROR 0x0003 /* Error Handler Packet */
#define SOCK_NCP 0x0451 /* File Service CORE */
#define SOCK_SAP 0x0452 /* SAP Service Advertising Packet */
#define SOCK_RIP 0x0453 /* Routing Information Packet */
#define SOCK_NETBIOS 0x0455 /* NET BIOS Packet */
#define SOCK_DIAGNOSE 0x0456 /* Diagnostic Packet */
#define SOCK_RIP 0x0453 /* Routing Information Packet */
#define SOCK_NETBIOS 0x0455 /* NET BIOS Packet */
#define SOCK_DIAGNOSE 0x0456 /* Diagnostic Packet */
#define SOCK_NVT 0x8063 /* NVT (Network Virtual Terminal) */
/* PACKET TYPES */
#define PACKT_0 0 /* unknown */
#define PACKT_ROUTE 1 /* Routing Information */
#define PACKT_ECHO 2 /* Echo Packet */
#define PACKT_ERROR 3 /* Error Packet */
/* PACKET TYPES */
#define PACKT_0 0 /* unknown */
#define PACKT_ROUTE 1 /* Routing Information */
#define PACKT_ECHO 2 /* Echo Packet */
#define PACKT_ERROR 3 /* Error Packet */
#define PACKT_EXCH 4 /* Packet Exchange Packet */
#define PACKT_SPX 5 /* SPX Packet */
#define PACKT_SPX 5 /* SPX Packet */
/* 16 - 31 Experimental */
#define PACKT_CORE 17 /* Core Protokoll (NCP) */

47
net1.c
View File

@ -1,4 +1,4 @@
/* net1.c, 14-Jan-96 */
/* net1.c, 20-Mar-96 */
/* (C)opyright (C) 1993,1995 Martin Stover, Marburg, Germany
*
@ -192,3 +192,48 @@ int send_ipx_data(int fdx, int pack_typ,
return(result);
}
#if 0
int get_ipx_addr(ipxAddr_t *addr)
{
int fd=t_open("/dev/ipx", O_RDWR, NULL);
struct t_optmgmt optb;
int result = -1;
if (fd < 0) {
t_error("t_open !Ok");
return(-1);
}
optb.opt.maxlen = optb.opt.len = sizeof(ipxAddr_t);
optb.opt.buf = (char*)addr;
optb.flags = 0;
result = t_optmgmt(fd, &optb, &optb);
if (result < 0) t_error("t_optmgmt !Ok");
else result=0;
t_close(fd);
return(result);
}
#else
int get_ipx_addr(ipxAddr_t *addr)
{
int fd=t_open("/dev/ipx", O_RDWR, NULL);
struct t_bind bind;
int result = -1;
if (fd < 0) {
t_error("t_open !Ok");
return(-1);
}
bind.addr.len = sizeof(ipxAddr_t);
bind.addr.maxlen = sizeof(ipxAddr_t);
bind.addr.buf = (char*)addr;
bind.qlen = 0; /* ever */
memset(addr, 0, sizeof(ipxAddr_t));
if (t_bind(fd, &bind, &bind) < 0)
t_error("tbind:get_ipx_addr");
else {
result=0;
t_unbind(fd);
}
t_close(fd);
return(result);
}
#endif

8
net1.h
View File

@ -1,4 +1,4 @@
/* net1.h 14-Jan-96 */
/* net1.h 20-Mar-96 */
/* (C)opyright (C) 1993,1995 Martin Stover, Marburg, Germany
*
@ -16,7 +16,8 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#ifndef _M_NET1_H_
#define _M_NET1_H_
#ifndef LINUX
extern void print_t_info(struct t_info *t);
@ -37,3 +38,6 @@ extern int send_ipx_data(int fd, int pack_typ,
int data_len, char *data,
ipxAddr_t *to_addr, char *comment);
extern int get_ipx_addr(ipxAddr_t *addr);
#endif

1404
nwbind.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -201,7 +201,7 @@ ncp_request(0x2222, sequence, connection, 1, 0, \
static int get_conn_nr(void)
{
ncp_request(0x1111, sequence, 0xff, 0, 0xff, 0,
ncp_request(0x1111, sequence, 2, 2, 0xff, 0,
0, "Get Connection Nr.");
if (!handle_event()) {
@ -652,6 +652,16 @@ static void test2(void)
}
}
static void test3(void)
{
uint8 data[] = {0xfe,0x0,0x0,0x0,0x0,0x0,0x2};
RDATA(data, 0x3b, "test_3b ??");
if (!handle_event()) {
;
}
}
static int do_5f(void)
{
uint8 data[] = {0x10, 0, 0, 0};
@ -779,6 +789,7 @@ int main(int argc, char **argv)
test1();
test2();
test3();
get_connection_info(0);
get_connection_info(1);

352
nwconn.c
View File

@ -1,4 +1,4 @@
/* nwconn.c 14-Mar-96 */
/* nwconn.c 21-Mar-96 */
/* one process / connection */
/* (C)opyright (C) 1993,1996 Martin Stover, Marburg, Germany
@ -25,11 +25,13 @@
#include "connect.h"
#include "namspace.h"
#define FD_NCP_OUT 3
static int father_pid = -1;
static ipxAddr_t from_addr;
static ipxAddr_t my_addr;
static struct t_unitdata ud;
static int ipx_fd = -1;
static uint8 ipx_pack_typ = PACKT_CORE;
static int last_sequence = -9999;
@ -38,66 +40,80 @@ static NCPRESPONSE *ncpresponse=(NCPRESPONSE*)&ipxdata;
static uint8 *responsedata=((uint8*)&ipxdata)+sizeof(NCPRESPONSE);
static int requestlen;
static uint8 readbuff[IPX_MAX_DATA+500];
static uint8 readbuff[IPX_MAX_DATA];
static uint8 saved_readbuff[IPX_MAX_DATA];
static int saved_sequence=-1;
static NCPREQUEST *ncprequest = (NCPREQUEST*)readbuff;
static uint8 *requestdata = readbuff + sizeof(NCPREQUEST);
static int ncp_type;
static int open_ipx_socket(int wanted_sock)
{
struct t_bind bind;
ipx_fd=t_open("/dev/ipx", O_RDWR, NULL);
if (ipx_fd < 0) {
if (nw_debug) t_error("t_open !Ok");
return(-1);
}
U16_TO_BE16(wanted_sock, my_addr.sock); /* actual write socket */
bind.addr.len = sizeof(ipxAddr_t);
bind.addr.maxlen = sizeof(ipxAddr_t);
bind.addr.buf = (char*)&my_addr;
bind.qlen = 0; /* allways */
if (t_bind(ipx_fd, &bind, &bind) < 0){
if (nw_debug) t_error("t_bind !OK");
close(ipx_fd);
return(-1);
}
XDPRINTF((5, 0, "NWCONN OpenSocket: %s",
visable_ipx_adr((ipxAddr_t *) bind.addr.buf)));
return(0);
}
static int sock_nwbind=-1;
static int req_printed=0;
static int ncp_response(int sequence,
int completition, int data_len)
{
ncpresponse->sequence = (uint8) sequence;
ncpresponse->completition = (uint8) completition;
last_sequence = sequence;
if (req_printed) {
XDPRINTF((0,0, "NWCONN NCP_RESP seq:%d, conn:%d, compl=0x%x TO %s",
(int)ncpresponse->sequence, (int) ncpresponse->connection, (int)completition,
visable_ipx_adr((ipxAddr_t *) ud.addr.buf)));
}
ncpresponse->reserved = (uint8) 0;
last_sequence = sequence;
if (req_printed) {
XDPRINTF((0,0, "NWCONN NCP_RESP seq:%d, conn:%d, compl=0x%x task=%d TO %s",
(int)ncpresponse->sequence, (int) ncpresponse->connection, (int)completition,
(int)ncpresponse->task, visable_ipx_adr((ipxAddr_t *) ud.addr.buf)));
}
ud.udata.len = ud.udata.maxlen = sizeof(NCPRESPONSE) + data_len;
if (t_sndudata(ipx_fd, &ud) < 0){
if (t_sndudata(FD_NCP_OUT, &ud) < 0){
if (nw_debug) t_error("t_sndudata in NWCONN !OK");
return(-1);
}
return(0);
}
static int call_nwbind(void)
{
ipxAddr_t to_addr;
memcpy(&to_addr, &my_addr, sizeof(ipxAddr_t));
U16_TO_BE16(sock_nwbind, to_addr.sock);
ud.udata.len = ud.udata.maxlen = sizeof(NCPREQUEST) + requestlen;
ud.udata.buf = (char*)&readbuff;
ud.addr.buf = (char*)&to_addr;
if (t_sndudata(FD_NCP_OUT, &ud) < 0){
if (nw_debug) t_error("t_sndudata in NWCONN !OK");
ud.addr.buf = (char*)&from_addr;
ud.udata.buf = (char*)&ipxdata;
return(-1);
}
ud.addr.buf = (char*)&from_addr;
ud.udata.buf = (char*)&ipxdata;
return(0);
}
static void pr_debug_request()
{
if (req_printed++) return;
XDPRINTF((0, 0, "NCP REQUEST:type:0x%x, seq:%d, task:%d, reserved:0x%x, func:0x%x",
if (ncp_type == 0x2222) {
int ufunc = 0;
switch (ncprequest->function) {
case 0x16 :
case 0x17 : ufunc = (int) *(requestdata+2); break;
default : break;
} /* switch */
XDPRINTF((0, 0, "NCP REQUEST: func=0x%02x, ufunc=0x%02x, seq:%03d, task:%02d",
(int)ncprequest->function, ufunc,
(int)ncprequest->sequence,
(int)ncprequest->task));
} else {
XDPRINTF((0, 0, "Got NCP:type:0x%x, seq:%d, task:%d, reserved:0x%x, func=0x%x",
ncp_type,
(int)ncprequest->sequence,
(int)ncprequest->task,
(int)ncprequest->reserved,
(int)ncprequest->function));
}
if (requestlen > 0){
int j = requestlen;
uint8 *p=requestdata;
@ -112,7 +128,7 @@ static void pr_debug_request()
}
static int test_handle = -1;
static void handle_ncp_serv()
static int handle_ncp_serv(void)
{
int function = (int)ncprequest->function;
int completition = 0; /* first set */
@ -122,11 +138,11 @@ static void handle_ncp_serv()
if (last_sequence == (int)ncprequest->sequence
&& ncp_type != 0x1111){ /* send the same again */
if (t_sndudata(ipx_fd, &ud) < 0){
if (t_sndudata(FD_NCP_OUT, &ud) < 0){
if (nw_debug) t_error("t_sndudata !OK");
}
XDPRINTF((2,0, "Sequence %d is written twice", (int)ncprequest->sequence));
return;
return(0);
}
req_printed=0;
@ -633,7 +649,6 @@ static void handle_ncp_serv()
}
break;
#if 1
case 0x17 : { /* FILE SERVER ENVIRONMENT */
/* uint8 len = *(requestdata+1); */
uint8 ufunc = *(requestdata+2);
@ -652,23 +667,15 @@ static void handle_ncp_serv()
xdata->nw_debug = (uint8)org_nw_debug;
nw_debug = org_nw_debug = (int) *(rdata+1);
data_len = 1;
} else completition=0xff;
} else return(-1);
}
break;
#endif
case 0x14:
case 0x18: { /* ncpserv have change the structure */
struct INPUT {
uint8 header[7]; /* Requestheader */
uint8 div[3]; /* 0, len + ufunc */
uint8 align[2]; /* alignment ncpserv */
int gid; /* ncpserv */
int uid; /* ncpserv */
} *input = (struct INPUT *)ncprequest;
set_guid(input->gid, input->uid);
}
break;
case 0x18:
return(-2); /* nwbind must do prehandling */
case 0x0f: { /* Scan File Information */
struct INPUT {
@ -687,7 +694,8 @@ static void handle_ncp_serv()
struct OUTPUT {
uint8 sequence[2]; /* next sequence */
NW_FILE_INFO f;
/* NW_FILE_INFO f; */
uint8 f[sizeof(NW_FILE_INFO)];
uint8 owner_id[4];
uint8 archive_date[2];
uint8 archive_time[2];
@ -695,15 +703,15 @@ static void handle_ncp_serv()
} *xdata = (struct OUTPUT*)responsedata;
int len = input->len;
int searchsequence;
NW_FILE_INFO f;
memset(xdata, 0, sizeof(struct OUTPUT));
searchsequence = nw_search( (uint8*) &(xdata->f),
searchsequence = nw_search( (uint8*) &f,
(int)input->dir_handle,
(int) GET_BE16(input->sequence),
(int) input->search_attrib,
input->data, len);
if (searchsequence > -1) {
memcpy(xdata->f, &f, sizeof(NW_FILE_INFO));
U16_TO_BE16((uint16) searchsequence, xdata->sequence);
U32_TO_BE32(1L, xdata->owner_id); /* Supervisor */
data_len = sizeof(struct OUTPUT);
@ -712,56 +720,40 @@ static void handle_ncp_serv()
break;
case 0x10: { /* Set File Information */
completition = 0xfb;
struct INPUT {
uint8 header[7]; /* Requestheader */
uint8 div[3]; /* 0, len + ufunc */
uint8 f[sizeof(NW_FILE_INFO) - 14]; /* no name */
uint8 owner_id[4];
uint8 archive_date[2];
uint8 archive_time[2];
uint8 reserved[56];
uint8 dir_handle;
uint8 search_attrib; /* 0: NONE */
/* 02: HIDDEN */
/* 04: SYSTEM */
/* 06: BOTH */
/* 0x10: DIR */
uint8 len;
uint8 data[2]; /* Name */
} *input = (struct INPUT *)ncprequest;
NW_FILE_INFO f;
int result;
memcpy(((uint8*)&f)+14, input->f, sizeof(NW_FILE_INFO)-14);
result = nw_set_file_information((int)input->dir_handle,
input->data,
(int)input->len,
(int)input->search_attrib, &f);
/* no reply packet */
if (result <0) completition = (uint8)-result;
}
break;
case 0x68: /* create queue job and file old */
case 0x79: { /* create queue job and file */
/* some of this call is handled in ncpserv !! */
struct INPUT {
uint8 header[7]; /* Requestheader */
uint8 packetlen[2]; /* low high */
uint8 func; /* 0x79 or 0x68 */
uint8 queue_id[4]; /* Queue ID */
uint8 queue_job[280]; /* oldsize is 256 */
/* this is added by ncpserv */
uint8 dir_nam_len; /* len of dirname */
uint8 dir_name[1];
} *input = (struct INPUT *) (ncprequest);
int result = nw_creat_queue(ncpresponse->connection,
input->queue_id,
input->queue_job,
input->dir_name,
(int)input->dir_nam_len,
(ufunc == 0x68) );
if (!result) {
data_len = (ufunc == 0x68) ? 54 : 78;
memcpy(responsedata, input->queue_job, data_len);
} else completition= (uint8)-result;
}
break;
case 0x69: /* close file and start queue old ?? */
case 0x7f: { /* close file and start queue */
struct INPUT {
uint8 header[7]; /* Requestheader */
uint8 packetlen[2]; /* low high */
uint8 func; /* 0x7f or 0x6f */
uint8 queue_id[4]; /* Queue ID */
uint8 job_id[4]; /* result from creat queue */
/* if 0x69 then only 2 byte ! */
/* this is added by ncpserv */
uint8 prc_len; /* len of printcommand */
uint8 prc[1]; /* printcommand */
} *input = (struct INPUT *) (ncprequest);
int result = nw_close_file_queue(input->queue_id,
input->job_id,
input->prc,
input->prc_len);
if (result < 0) completition = (uint8)-result;
}
break;
case 0x69: /* close file and start queue old ?? */
case 0x79: /* create queue job and file */
case 0x7f: /* close file and start queue */
return(-2); /* nwbind must do prehandling */
case 0xf3: { /* Map Direktory Number TO PATH */
XDPRINTF((2,0, "TODO: Map Directory Number TO PATH"));
@ -775,12 +767,11 @@ static void handle_ncp_serv()
}
break;
default : completition = 0xfb;
default : return(-1);
break;
} /* switch (ufunc) */
} /* case 0x17 */
break;
#endif
case 0x18 : /* End of Job */
nw_free_handles((ncprequest->task > 0) ?
@ -790,6 +781,7 @@ static void handle_ncp_serv()
case 0x19 : /* logout, some of this call is handled in ncpserv. */
nw_free_handles(0);
set_default_guid();
return(-1); /* nwbind must do rest */
break;
case 0x1a : /* lock file */
@ -1266,7 +1258,11 @@ static void handle_ncp_serv()
#endif
default : completition = 0xfb; /* unknown request */
#if 0
case 0x68 : /* NDS NCP, NDS Fragger Protokoll ?? */
#endif
default : completition = 0xfb; /* unknown request */
break;
} /* switch function */
@ -1294,8 +1290,87 @@ static void handle_ncp_serv()
XDPRINTF((0,1, NULL));
}
}
#if 0
ncpresponse->task = ncprequest->task;
#endif
ncp_response(ncprequest->sequence, completition, data_len);
nw_debug = org_nw_debug;
return(0);
}
static void handle_after_bind()
{
NCPREQUEST *ncprequest = (NCPREQUEST*) saved_readbuff;
uint8 *requestdata = saved_readbuff + sizeof(NCPREQUEST);
uint8 *bindresponse = readbuff + sizeof(NCPRESPONSE);
int data_len = 0;
int completition = 0;
switch (ncprequest->function) {
case 0x17 : { /* FILE SERVER ENVIRONMENT */
uint8 ufunc = *(requestdata+2);
uint8 *rdata = requestdata+3;
switch (ufunc) {
case 0x14:
case 0x18: { /* ncpserv have change the structure */
set_guid(*((int*)bindresponse), *((int*)(bindresponse+sizeof(int))));
}
break;
case 0x68: /* create queue job and file old */
case 0x79: { /* create queue job and file */
/* nwbind must do prehandling */
struct INPUT {
uint8 header[7]; /* Requestheader */
uint8 packetlen[2]; /* low high */
uint8 func; /* 0x79 or 0x68 */
uint8 queue_id[4]; /* Queue ID */
uint8 queue_job[280]; /* oldsize is 256 */
} *input = (struct INPUT *) (ncprequest);
struct RINPUT {
uint8 dir_nam_len; /* len of dirname */
uint8 dir_name[1];
} *rinput = (struct RINPUT *) (bindresponse);
int result = nw_creat_queue(ncpresponse->connection,
input->queue_id,
input->queue_job,
rinput->dir_name,
(int)rinput->dir_nam_len,
(ufunc == 0x68) );
if (!result) {
data_len = (ufunc == 0x68) ? 54 : 78;
memcpy(responsedata, input->queue_job, data_len);
} else completition= (uint8)-result;
}
break;
case 0x69: /* close file and start queue old ?? */
case 0x7f: { /* close file and start queue */
struct INPUT {
uint8 header[7]; /* Requestheader */
uint8 packetlen[2]; /* low high */
uint8 func; /* 0x7f or 0x6f */
uint8 queue_id[4]; /* Queue ID */
uint8 job_id[4]; /* result from creat queue */
/* if 0x69 then only 2 byte ! */
} *input = (struct INPUT *) (ncprequest);
struct RINPUT {
uint8 prc_len; /* len of printcommand */
uint8 prc[1]; /* printcommand */
} *rinput = (struct RINPUT *) (bindresponse);
int result = nw_close_file_queue(input->queue_id,
input->job_id,
rinput->prc,
rinput->prc_len);
if (result < 0) completition = (uint8)-result;
}
break;
default : completition = 0xfb;
}
}
break;
default : completition = 0xfb;
} /* switch */
ncp_response(ncprequest->sequence, completition, data_len);
}
extern int t_errno;
@ -1304,12 +1379,7 @@ static void close_all(void)
{
nw_exit_connect();
close(0);
if (ipx_fd > -1){
while (t_unbind(ipx_fd) < 0) {
if (t_errno != TOUTSTATE) break;
}
t_close(ipx_fd);
}
close(FD_NCP_OUT);
}
static int fl_get_int=0;
@ -1349,39 +1419,39 @@ int main(int argc, char **argv)
ipxAddr_t client_addr;
struct t_unitdata iud;
#endif
int wanted_sock = (argc==5) ? atoi(*(argv+4)) : 0;
if (argc == 5) argc--;
if (argc != 4) {
fprintf(stderr, "usage nwconn PID FROM_ADDR Connection [sock]\n");
if (argc != 5) {
fprintf(stderr, "usage nwconn PID FROM_ADDR Connection nwbindsock\n");
exit(1);
} else father_pid = atoi(*(argv+1));
setuid(0);
setgid(0);
init_tools(NWCONN, atoi(*(argv+3)));
memset(saved_readbuff, 0, sizeof(saved_readbuff));
XDPRINTF((2, 0, "FATHER PID=%d, ADDR=%s CON:%s", father_pid, *(argv+2), *(argv+3)));
adr_to_ipx_addr(&from_addr, *(argv+2));
#if CALL_NWCONN_OVER_SOCKET
adr_to_ipx_addr(&client_addr, *(argv+2));
#endif
if (nw_init_connect()) exit(1);
sscanf(argv[4], "%x", &sock_nwbind);
#ifdef LINUX
set_emu_tli();
#endif
last_sequence = -9999;
#if !CALL_NWCONN_OVER_SOCKET
if (open_ipx_socket(wanted_sock)) exit(1);
#else
ipx_fd =0;
if (get_ipx_addr(&my_addr)) exit(1);
#if CALL_NWCONN_OVER_SOCKET
# if 1
# ifdef SIOCIPXNCPCONN
{
int conn = atoi(*(argv+3));
int result = ioctl(ipx_fd, SIOCIPXNCPCONN, &conn);
int result = ioctl(0, SIOCIPXNCPCONN, &conn);
XDPRINTF((2, 0, "ioctl:SIOCIPXNCPCONN result=%d", result));
}
# endif
@ -1422,7 +1492,7 @@ int main(int argc, char **argv)
while (1) {
#if CALL_NWCONN_OVER_SOCKET
int rcv_flags = 0;
int data_len = (t_rcvudata(ipx_fd, &iud, &rcv_flags) > -1)
int data_len = (t_rcvudata(0, &iud, &rcv_flags) > -1)
? iud.udata.len : -1;
#else
int data_len = read(0, readbuff, sizeof(readbuff));
@ -1437,28 +1507,32 @@ int main(int argc, char **argv)
if (data_len > 0) {
XDPRINTF((99, 0, "NWCONN GOT DATA len = %d",data_len));
if ((ncp_type = (int)GET_BE16(ncprequest->type)) == 0x3333) {
/* OK for direct sending */
data_len -= sizeof(NCPRESPONSE);
XDPRINTF((99,0, "NWCONN:direct sending:type 0x3333, completition=0x%x, len=%d",
if (saved_sequence > -1 && ((int)(ncprequest->sequence) == saved_sequence)
&& !ncprequest->function) {
handle_after_bind();
} else {
/* OK for direct sending */
XDPRINTF((6,0, "NWCONN:direct sending:type 0x3333, completition=0x%x, len=%d",
(int)(ncprequest->function), data_len));
if (data_len) memcpy(responsedata, readbuff+sizeof(NCPRESPONSE), data_len);
ncpresponse->connect_status = ((NCPRESPONSE*)readbuff)->connect_status;
ncp_response((int)(ncprequest->sequence), (int)(ncprequest->function), data_len);
if (data_len)
memcpy(responsedata, readbuff+sizeof(NCPRESPONSE), data_len);
ncpresponse->connect_status = ((NCPRESPONSE*)readbuff)->connect_status;
ncp_response((int)(ncprequest->sequence),
(int)(ncprequest->function), data_len);
}
saved_sequence = -1;
} else { /* this calls I must handle */
requestlen = data_len - sizeof(NCPREQUEST);
#if 0 /* CALL_NWCONN_OVER_SOCKET */
#ifdef SIOCIPXNCPCONN
if (ncp_type == 0x2222 &&
(0x17 == ncprequest->function || 0x15 == ncprequest->function)
&& IPXCMPSOCK (from_addr.sock, client_addr.sock)
&& IPXCMPNODE (from_addr.node, client_addr.node)
&& IPXCMPNET (from_addr.net, client_addr.net) {
/* this call must be prehandled by ncpserv */
XDPRINTF((2,0, "SEND TO NCPSERV"));
} else
#endif
#endif
handle_ncp_serv();
int result;
requestlen = data_len - sizeof(NCPREQUEST);
if (0 != (result = handle_ncp_serv()) ) {
if (result == -2) { /* here the actual call must be saved */
memcpy(saved_readbuff, readbuff, data_len);
saved_sequence = (int)(ncprequest->sequence);
} else saved_sequence = -1;
/* this call must go to nwbind */
call_nwbind();
}
}
}
} /* while */

17
nwdbm.c
View File

@ -1,4 +1,4 @@
/* nwdbm.c 22-Feb-96 data base for mars_nwe */
/* nwdbm.c 20-Mar-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
@ -1033,9 +1033,11 @@ int nw_test_passwd(uint32 obj_id, uint8 *vgl_key, uint8 *akt_key)
return (memcmp(akt_key, keybuff, sizeof(keybuff)) ? -0xff : 0);
} else {
if (password_scheme & PW_SCHEME_LOGIN) {
MYPASSWD *pw = nw_getpwnam(obj_id);
if (pw && *(pw->pw_passwd) && !crypt_pw_ok(NULL, pw->pw_passwd))
return(-0xff);
if (!(password_scheme & PW_SCHEME_ALLOW_EMPTY_PW)) {
MYPASSWD *pw = nw_getpwnam(obj_id);
if (pw && *(pw->pw_passwd) && !crypt_pw_ok(NULL, pw->pw_passwd))
return(-0xff);
}
if (obj_id == 1) return(-0xff);
}
return(0); /* no password */
@ -1242,7 +1244,7 @@ static void add_group(char *name, char *unname, char *password)
static int get_sys_unixname(uint8 *unixname, uint8 *sysentry)
{
uint8 sysname[256];
char optionstr[256];
uint8 optionstr[256];
int founds = sscanf((char*)sysentry, "%s %s %s",sysname, unixname, optionstr);
if (founds > 1 && *unixname) {
struct stat statb;
@ -1324,14 +1326,15 @@ int nw_fill_standard(char *servername, ipxAddr_t *adr)
while (0 != (what =get_ini_entry(f, 0, (char*)buff, sizeof(buff)))) {
if (1 == what && !*sysentry) {
xstrcpy(sysentry, buff);
} if (6 == what) { /* Server Version */
} else if (6 == what) { /* Server Version */
tells_server_version = atoi(buff);
} else if (7 == what) { /* password_scheme */
int pwscheme = atoi(buff);
password_scheme = 0;
switch (pwscheme) {
case 9 : password_scheme |= PW_SCHEME_GET_KEY_FAIL;
case 8 : password_scheme |= PW_SCHEME_LOGIN;
case 8 : password_scheme |= PW_SCHEME_ALLOW_EMPTY_PW;
case 7 : password_scheme |= PW_SCHEME_LOGIN;
case 1 : password_scheme |= PW_SCHEME_CHANGE_PW;
break;
default : password_scheme = 0;

View File

@ -63,9 +63,11 @@ typedef struct {
extern int tells_server_version;
extern int password_scheme;
#define PW_SCHEME_CHANGE_PW 1
#define PW_SCHEME_LOGIN 2
#define PW_SCHEME_GET_KEY_FAIL 4
#define PW_SCHEME_CHANGE_PW 1
#define PW_SCHEME_LOGIN 2
#define PW_SCHEME_GET_KEY_FAIL 4
#define PW_SCHEME_ALLOW_EMPTY_PW 8
extern void sync_dbm(void);

290
nwserv.c
View File

@ -1,4 +1,4 @@
/* nwserv.c 10-Mar-96 */
/* nwserv.c 20-Mar-96 */
/* (C)opyright (C) 1993,1996 Martin Stover, Marburg, Germany
*
* This program is free software; you can redistribute it and/or modify
@ -58,9 +58,9 @@ uint16 ipx_sock_nummern[]={ SOCK_AUTO /* WDOG */
#define NEEDED_SOCKETS (sizeof(ipx_sock_nummern) / sizeof(uint16))
#if FILE_SERVER_INACTIV
# define NEEDED_POLLS (NEEDED_SOCKETS)
#else
# define NEEDED_POLLS (NEEDED_SOCKETS+1)
#else
# define NEEDED_POLLS (NEEDED_SOCKETS+2)
#endif
static uint16 sock_nummern [NEEDED_SOCKETS];
@ -75,10 +75,11 @@ static int nw386_found = 0;
static int client_mode = 0;
static int ipxdebug = 0;
static int pid_ncpserv = -1;
#if !CALL_NCPSERV_OVER_SOCKET
static int fd_ncpserv_out = -1; /* ctrl-pipe out to ncpserv */
#endif
static int fd_ncpserv_in = -1; /* ctrl-pipe in from ncpserv */
static int fd_ncpserv_in = -1; /* ctrl-pipe in from ncpserv */
static int pid_nwbind = -1;
static int sock_nwbind = -1;
static int fd_nwbind_in = -1; /* ctrl-pipe in from nnwbind */
static time_t akttime_stamp = 0;
static int broadmillisecs = 2000; /* 2 sec */
@ -90,45 +91,41 @@ static int save_ipx_routes = 0;
static uint8 *station_fn=NULL;
static int nearest_request_flag=0;
#if !FILE_SERVER_INACTIV
static void add_wdata(IPX_DATA *d, char *data, int size)
{
memcpy(d->owndata.d.data+d->owndata.d.size, data, size);
d->owndata.d.size+=size;
}
static void write_wdata(IPX_DATA *d, int what)
static void write_wdata(IPX_DATA *d, int what, int sock)
{
#if CALL_NCPSERV_OVER_SOCKET
ipxAddr_t toaddr;
#endif
d->owndata.d.function=what;
d->owndata.d.size +=sizeof(int);
#if CALL_NCPSERV_OVER_SOCKET
memset(d->owndata.type, 0xee, 4);
memset(d->owndata.type, 0xee, 2);
d->owndata.sequence = 0;
d->owndata.connection = 0;
memcpy(&toaddr, &my_server_adr, sizeof(ipxAddr_t));
U16_TO_BE16(SOCK_NCP, toaddr.sock);
U16_TO_BE16(sock, toaddr.sock);
send_ipx_data(-1, 17,
4 + sizeof(int)+d->owndata.d.size, (char*)d,
&toaddr, "TO NCPSERV");
#else
write(fd_ncpserv_out, (char*) &(d->owndata.d),
sizeof(int)+d->owndata.d.size);
#endif
OWN_DATA_IPX_BASE_SIZE + sizeof(int)+d->owndata.d.size, (char*)d,
&toaddr, (sock == SOCK_NCP) ? "NCPSERV" : "NWBIND" );
d->owndata.d.size=0;
}
static void write_to_ncpserv(int what, int connection,
char *data, int data_size)
static void write_to_sons(int what, int connection,
char *data, int data_size, int sock)
{
IPX_DATA ipxd;
ipxd.owndata.d.size = 0;
XDPRINTF((2, 0, "write_to_ncpserv what=0x%x, conn=%d, data_size=%d",
XDPRINTF((2, 0, "write_to_sons what=0x%x, conn=%d, data_size=%d",
what, connection, data_size));
switch (what) {
case 0x5555 : /* kill connection */
case 0x2222 : /* insert connection */
add_wdata(&ipxd, (char*) &connection, sizeof(int));
add_wdata(&ipxd, (char*) &data_size, sizeof(int));
add_wdata(&ipxd, data, data_size);
break;
case 0x3333 : /* 'bindery' calls */
@ -136,6 +133,10 @@ static void write_to_ncpserv(int what, int connection,
add_wdata(&ipxd, data, data_size);
break;
case 0x5555 : /* kill connection */
add_wdata(&ipxd, (char*) &connection, sizeof(int));
break;
case 0xeeee : /* hup, read init */
break;
@ -143,18 +144,21 @@ static void write_to_ncpserv(int what, int connection,
add_wdata(&ipxd, (char*) &what, sizeof(int));
break;
default : return;
default : return;
}
write_wdata(&ipxd, what);
write_wdata(&ipxd, what, sock);
}
#if !FILE_SERVER_INACTIV
# define write_to_ncpserv(what, connection, data, data_size) \
write_to_sons((what), (connection), (data), (data_size), SOCK_NCP)
#else
static void write_to_ncpserv(int what, int connection,
char *data, int data_size)
{
;; /* dummy */
}
# define write_to_ncpserv(what, connection, data, data_size) /* */
#endif
#define write_to_nwbind(what, connection, data, data_size) \
write_to_sons((what), (connection), (data), (data_size), sock_nwbind)
void ins_del_bind_net_addr(uint8 *name, int styp, ipxAddr_t *adr)
{
uint8 buf[1024];
@ -179,7 +183,7 @@ void ins_del_bind_net_addr(uint8 *name, int styp, ipxAddr_t *adr)
strmaxcpy(p+1, name, *p);
len += (*p+1); p+=(*p + 1);
}
write_to_ncpserv(0x3333, 0, (char *)buf, len);
write_to_nwbind(0x3333, 0, (char *)buf, len);
}
static int open_ipx_socket(uint16 sock_nr, int nr, int open_mode)
@ -212,14 +216,8 @@ static int open_ipx_socket(uint16 sock_nr, int nr, int open_mode)
static int start_ncpserv(char *nwname, ipxAddr_t *addr)
{
#if !FILE_SERVER_INACTIV
#if !CALL_NCPSERV_OVER_SOCKET
int fds_out[2];
#endif
int fds_in[2];
int pid;
#if !CALL_NCPSERV_OVER_SOCKET
if (pipe(fds_out) < 0) return(-1);
#endif
if (pipe(fds_in) < 0) return(-1);
switch (pid=fork()) {
@ -227,43 +225,104 @@ static int start_ncpserv(char *nwname, ipxAddr_t *addr)
char *progname="ncpserv";
char addrstr[100];
char pathname[300];
char nwbindsock[20];
int j = FD_NWSERV;
#if !CALL_NCPSERV_OVER_SOCKET
close(fds_out[1]); /* no need to write */
dup2(fds_out[0], 0); /* becommes stdin */
close(fds_out[0]); /* no longer needed */
#endif
close(fds_in[0]); /* no need to read */
dup2(fds_in[1], FD_NWSERV); /* becommes fd FD_NWSERV */
close(fds_in[1]); /* no longer needed */
while (j++ < 100) close(j); /* close all > 4 */
U16_TO_BE16(SOCK_NCP, addr->sock);
ipx_addr_to_adr(addrstr, addr);
sprintf(nwbindsock, "%04x", sock_nwbind);
execl(get_exec_path(pathname, progname), progname,
nwname, addrstr, NULL);
nwname, addrstr, nwbindsock, NULL);
exit(1);
}
break;
case -1:
#if !CALL_NCPSERV_OVER_SOCKET
close(fds_out[0]);
close(fds_out[1]);
#endif
close(fds_in[0]);
close(fds_in[1]);
return(-1); /* error */
}
#if !CALL_NCPSERV_OVER_SOCKET
fds_out[0] = -1;
fd_ncpserv_out = fds_out[1];
#endif
fds_in[1] = -1;
close(fds_in[1]);
fd_ncpserv_in = fds_in[0];
pid_ncpserv = pid;
#endif
U16_TO_BE16(SOCK_NCP, addr->sock);
return(0); /* OK */
}
static int start_nwbind(char *nwname, ipxAddr_t *addr)
{
#if !FILE_SERVER_INACTIV
int fds_in[2];
int pid;
struct t_bind bind;
int ipx_fd=t_open("/dev/ipx", O_RDWR, NULL);
if (ipx_fd < 0) {
errorp(1, "start_nwbind", "t_open");
return(-1);
}
U16_TO_BE16(SOCK_AUTO, addr->sock);
bind.addr.len = sizeof(ipxAddr_t);
bind.addr.maxlen = sizeof(ipxAddr_t);
bind.addr.buf = (char*)addr;
bind.qlen = 0; /* allways */
if (t_bind(ipx_fd, &bind, &bind) < 0){
errorp(1, "start_nwbind", "t_bind");
t_close(ipx_fd);
return(-1);
}
if (pipe(fds_in) < 0){
errorp(1, "start_nwbind", "pipe");
t_close(ipx_fd);
return(-1);
}
sock_nwbind = (int) GET_BE16(addr->sock);
switch (pid=fork()) {
case 0 : { /* new Process */
char *progname="nwbind";
char addrstr[100];
char pathname[300];
char nwbindsock[20];
int j = FD_NWSERV;
close(fds_in[0]); /* no need to read */
if (fds_in[1] != FD_NWSERV) {
dup2(fds_in[1], FD_NWSERV); /* becommes fd FD_NWSERV */
close(fds_in[1]); /* no longer needed */
}
dup2(ipx_fd, 0); /* stdin */
close(ipx_fd);
while (j++ < 100) close(j); /* close all > FD_NWSERV */
U16_TO_BE16(SOCK_NCP, addr->sock);
ipx_addr_to_adr(addrstr, addr);
sprintf(nwbindsock, "%04x", sock_nwbind);
execl(get_exec_path(pathname, progname), progname,
nwname, addrstr, nwbindsock, NULL);
exit(1);
}
break;
case -1: close(fds_in[0]);
close(fds_in[1]);
t_close(ipx_fd);
errorp(1, "start_nwbind", "t_bind");
return(-1); /* error */
}
close(fds_in[1]);
close(ipx_fd);
fd_nwbind_in = fds_in[0];
pid_nwbind = pid;
#endif
return(0); /* OK */
}
static int start_nwclient(void)
{
switch (fork()){
@ -459,16 +518,16 @@ static int find_station_match(int entry, ipxAddr_t *addr)
{
int matched = 0;
if (station_fn && *station_fn) {
FILE *f=fopen(station_fn, "r");
FILE *f=fopen((char*)station_fn, "r");
if (f) {
char buff[200];
char addrstring[100];
uint8 buff[200];
uint8 addrstring[100];
int what;
ipx_addr_to_adr(addrstring, addr);
ipx_addr_to_adr((char*)addrstring, addr);
upstr(addrstring);
while (0 != (what = get_ini_entry(f, 0, buff, sizeof(buff)))){
if (what == entry) {
char *p = buff + strlen(buff);
uint8 *p = buff + strlen((char*)buff);
while (p-- > buff && *p==32) *p='\0';
upstr(buff);
if (name_match(addrstring, buff)) {
@ -730,54 +789,6 @@ static void handle_event(int fd, uint16 socknr, int slot)
}
}
#if 0
static int get_ipx_addr(ipxAddr_t *addr)
{
int fd=t_open("/dev/ipx", O_RDWR, NULL);
struct t_optmgmt optb;
int result = -1;
if (fd < 0) {
t_error("t_open !Ok");
return(-1);
}
optb.opt.maxlen = optb.opt.len = sizeof(ipxAddr_t);
optb.opt.buf = (char*)addr;
optb.flags = 0;
result = t_optmgmt(fd, &optb, &optb);
if (result < 0) t_error("t_optmgmt !Ok");
else result=0;
t_close(fd);
return(result);
}
#else
static int get_ipx_addr(ipxAddr_t *addr)
{
int fd=t_open("/dev/ipx", O_RDWR, NULL);
struct t_bind bind;
int result = -1;
if (fd < 0) {
t_error("t_open !Ok");
return(-1);
}
bind.addr.len = sizeof(ipxAddr_t);
bind.addr.maxlen = sizeof(ipxAddr_t);
bind.addr.buf = (char*)addr;
bind.qlen = 0; /* ever */
memset(addr, 0, sizeof(ipxAddr_t));
if (t_bind(fd, &bind, &bind) < 0)
t_error("tbind:get_ipx_addr");
else {
result=0;
t_unbind(fd);
}
t_close(fd);
return(result);
}
#endif
static void get_ini(int full)
{
FILE *f = open_nw_ini();
@ -788,9 +799,9 @@ static void get_ini(int full)
upstr((uint8*)my_nwname);
}
if (f){
char buff[500];
uint8 buff[500];
int what;
while (0 != (what=get_ini_entry(f, 0, (char*)buff, sizeof(buff)))) {
while (0 != (what=get_ini_entry(f, 0, buff, sizeof(buff)))) {
char inhalt[500];
char inhalt2[500];
char inhalt3[500];
@ -956,12 +967,6 @@ static void close_all(void)
if (pid_ncpserv > 0) {
int status;
#if !CALL_NCPSERV_OVER_SOCKET
if (fd_ncpserv_out > -1) {
close(fd_ncpserv_out);
fd_ncpserv_out =-1;
}
#endif
if (fd_ncpserv_in > -1) {
close(fd_ncpserv_in);
fd_ncpserv_in = -1;
@ -971,6 +976,17 @@ static void close_all(void)
kill(pid_ncpserv, SIGKILL); /* kill ncpserv */
}
if (pid_nwbind > 0) {
int status;
if (fd_nwbind_in > -1) {
close(fd_nwbind_in);
fd_nwbind_in = -1;
}
kill(pid_nwbind, SIGQUIT); /* terminate ncpserv */
waitpid(pid_nwbind, &status, 0);
kill(pid_nwbind, SIGKILL); /* kill ncpserv */
}
#ifdef LINUX
# if INTERNAL_RIP_SAP
if (!save_ipx_routes) {
@ -990,6 +1006,7 @@ static void down_server(void)
{
if (!server_down_stamp) {
write_to_ncpserv(0xffff, 0, NULL, 0);
write_to_nwbind( 0xffff, 0, NULL, 0);
signal(SIGHUP, SIG_IGN);
signal(SIGPIPE, SIG_IGN);
fprintf(stderr, "\007");
@ -1020,6 +1037,7 @@ static void handle_hup_reqest(void)
XDPRINTF((2,0, "Got HUP, reading ini."));
get_ini(0);
write_to_ncpserv(0xeeee, 0, NULL, 0); /* inform ncpserv */
write_to_nwbind( 0xeeee, 0, NULL, 0); /* inform nwbind */
fl_get_int=0;
}
@ -1069,17 +1087,18 @@ int main(int argc, char **argv)
polls[j].fd = -1;
}
}
U16_TO_BE16(SOCK_NCP, my_server_adr.sock);
if (!start_ncpserv(my_nwname, &my_server_adr)) {
if ( !start_nwbind( my_nwname, &my_server_adr)
&& !start_ncpserv(my_nwname, &my_server_adr) ) {
/* now do polling */
time_t broadtime;
time(&broadtime);
set_sigs();
polls[NEEDED_SOCKETS].fd = fd_nwbind_in;
#if !FILE_SERVER_INACTIV
{
ipxAddr_t server_adr_sap;
polls[NEEDED_SOCKETS].fd = fd_ncpserv_in;
polls[NEEDED_SOCKETS+1].fd = fd_ncpserv_in;
U16_TO_BE16(SOCK_NCP, my_server_adr.sock);
memcpy(&server_adr_sap, &my_server_adr, sizeof(ipxAddr_t));
U16_TO_BE16(SOCK_SAP, server_adr_sap.sock);
@ -1110,45 +1129,56 @@ int main(int argc, char **argv)
if (p->revents & ~POLLIN)
errorp(0, "STREAM error", "revents=0x%x", p->revents );
else {
if (p->fd == fd_ncpserv_in) {
if (p->fd > -1) {
int what;
int conn;
int size;
ipxAddr_t adr;
if (sizeof(int) == read(fd_ncpserv_in,
uint8 buf[200];
if (sizeof(int) == read(p->fd,
(char*)&what, sizeof(int))) {
XDPRINTF((2, 0, "GOT ncpserv_in what=0x%x", what));
XDPRINTF((2, 0, "GOT %s_in what=0x%x",
(p->fd == fd_ncpserv_in) ? "ncpserv" : "nwbind" , what));
switch (what) {
case 0x2222 : /* insert wdog connection */
if (sizeof(int) == read(fd_ncpserv_in,
if (sizeof(int) == read(p->fd,
(char*)&conn, sizeof(int))
&& sizeof(int) == read(fd_ncpserv_in,
&& sizeof(int) == read(p->fd,
(char*)&size, sizeof(int))
&& sizeof(ipxAddr_t) == read(fd_ncpserv_in,
(char*)&adr, size))
insert_wdog_conn(conn, &adr);
&& sizeof(ipxAddr_t) + sizeof(uint16)
== read(p->fd,
(char*)buf, size)) {
insert_wdog_conn(conn, (ipxAddr_t*)buf);
write_to_nwbind(what, conn, (char*)buf, size);
}
break;
case 0x4444 : /* reset wdog connection = 0 */
/* force test wdog conn 1 = 1 */
/* force test wdog conn 2 = 2 */
/* remove wdog = 99 */
if (sizeof(int) == read(fd_ncpserv_in,
if (sizeof(int) == read(p->fd,
(char*)&conn, sizeof(int))
&& sizeof(int) == read(fd_ncpserv_in,
&& sizeof(int) == read(p->fd,
(char*)&what, sizeof(what)))
modify_wdog_conn(conn, what);
if (what > 0 && what < 99) call_wdog++;
break;
case 0x5555 : /* close connection */
if (sizeof(int) == read(p->fd,
(char*)&conn, sizeof(int)))
modify_wdog_conn(conn, 99);
write_to_nwbind(what, conn, NULL, 0);
break;
case 0x6666 : /* bcast message */
if (sizeof(int) == read(fd_ncpserv_in,
if (sizeof(int) == read(p->fd,
(char*)&conn, sizeof(int)))
send_bcasts(conn);
break;
case 0xffff : /* down file server */
if (sizeof(int) == read(fd_ncpserv_in,
if (sizeof(int) == read(p->fd,
(char*)&conn, sizeof(int)) &&
conn == what) {
down_server();

View File

@ -1,4 +1,4 @@
/* nwvolume.c 07-Feb-96 */
/* nwvolume.c 20-Mar-96 */
/* (C)opyright (C) 1993,1995 Martin Stover, Marburg, Germany
*
* This program is free software; you can redistribute it and/or modify
@ -53,8 +53,8 @@ void nw_init_volumes(FILE *f)
}
rewind(f);
used_nw_volumes = 0;
while (0 != (what = get_ini_entry(f, 0, (char*)buff, sizeof(buff)))) {
if ( what == 1 && used_nw_volumes < MAX_NW_VOLS && strlen(buff) > 3){
while (0 != (what = get_ini_entry(f, 0, buff, sizeof(buff)))) {
if ( what == 1 && used_nw_volumes < MAX_NW_VOLS && strlen((char*)buff) > 3){
uint8 sysname[256];
uint8 unixname[256];
char optionstr[256];
@ -63,7 +63,7 @@ void nw_init_volumes(FILE *f)
int founds = sscanf((char*)buff, "%s %s %s",sysname, unixname, optionstr);
if (founds > 1) {
new_str(nw_volumes[used_nw_volumes].sysname, sysname);
len = strlen(unixname);
len = strlen((char*)unixname);
if (unixname[len-1] != '/') {
unixname[len++] = '/';
unixname[len] = '\0';
@ -164,10 +164,10 @@ int nw_get_volume_number(uint8 *volname, int namelen)
int result = -0x98; /* Volume not exist */
uint8 vname[255];
int j = used_nw_volumes;
strmaxcpy((char*)vname, (char*)volname, namelen);
strmaxcpy(vname, volname, namelen);
upstr(vname);
while (j--) {
if (!strcmp(nw_volumes[j].sysname, vname)) {
if (!strcmp((char*)nw_volumes[j].sysname, (char*)vname)) {
result = j;
break;
}
@ -182,9 +182,9 @@ int nw_get_volume_name(int volnr, uint8 *volname)
int result = -0x98; /* Volume not exist */;
if (volnr > -1 && volnr < used_nw_volumes) {
if (volname != NULL) {
strcpy(volname, nw_volumes[volnr].sysname);
result = strlen(volname);
} else result= strlen(nw_volumes[volnr].sysname);
strcpy((char*)volname, (char*)nw_volumes[volnr].sysname);
result = strlen((char*)volname);
} else result= strlen((char*)nw_volumes[volnr].sysname);
} else {
if (NULL != volname) *volname = '\0';
if (volnr < MAX_NW_VOLS) result=0;
@ -233,7 +233,7 @@ int nw_get_fs_usage(uint8 *volname, struct fs_usage *fsu)
/* returns 0 if OK, else errocode < 0 */
{
int volnr = nw_get_volume_number(volname, strlen((char*)volname));
return((volnr>-1 && !get_fs_usage(nw_volumes[volnr].unixname, fsu)) ? 0 : -1);
return((volnr>-1 && !get_fs_usage((char*)nw_volumes[volnr].unixname, fsu)) ? 0 : -1);
}
int get_volume_options(int volnr, int mode)

24
tools.c
View File

@ -1,4 +1,4 @@
/* tools.c 09-Mar-96 */
/* tools.c 20-Mar-96 */
/* (C)opyright (C) 1993,1995 Martin Stover, Marburg, Germany
*
* This program is free software; you can redistribute it and/or modify
@ -38,7 +38,8 @@ static char *modnames[] =
"NWSERV ",
"NCPSERV",
"NWCONN ",
"NWCLIEN" };
"NWCLIEN",
"NWBIND " };
static char *get_modstr(void)
{
@ -148,7 +149,7 @@ FILE *open_nw_ini(void)
return(f);
}
int get_ini_entry(FILE *f, int entry, char *str, int strsize)
int get_ini_entry(FILE *f, int entry, uint8 *str, int strsize)
/* returns ini_entry or 0 if nothing found */
{
char buff[512];
@ -200,10 +201,10 @@ char *get_exec_path(char *buff, char *progname)
int get_ini_int(int what)
{
char buff[30];
uint8 buff[30];
int i;
if (get_ini_entry(NULL, what, buff, sizeof(buff))
&& 1==sscanf(buff, "%d", &i) ) return(i);
&& 1==sscanf((char*)buff, "%d", &i) ) return(i);
return(-1);
}
@ -225,12 +226,14 @@ static void sig_segv(int isig)
XDPRINTF((0, 0, s, my_pid));
fprintf(stderr, "\n");
fprintf(stderr, s, my_pid);
#if 1
(*sigsegv_func)(isig);
#endif
}
void init_tools(int module, int conn)
{
char buff[300];
uint8 buff[300];
char logfilename[300];
FILE *f=open_nw_ini();
int withlog=0;
@ -241,13 +244,13 @@ void init_tools(int module, int conn)
if (f) {
int what;
while (0 != (what=get_ini_entry(f, 0, buff, sizeof(buff)))) { /* daemonize */
if (200 == what) dodaemon = atoi(buff);
if (200 == what) dodaemon = atoi((char*)buff);
else if (201 == what) {
strmaxcpy((uint8*)logfilename, (uint8*)buff, sizeof(logfilename)-1);
withlog++;
} else if (202 == what) {
new_log = atoi(buff);
} else if (100+module == what) nw_debug=atoi(buff);
new_log = atoi((char*)buff);
} else if (100+module == what) nw_debug=atoi((char*)buff);
}
fclose(f);
}
@ -268,7 +271,8 @@ void init_tools(int module, int conn)
}
if (NWSERV == module) setsid();
}
if (NWSERV == module || NCPSERV == module) {
if (NWSERV == module || NCPSERV == module || NWBIND == module ||
nw_debug > 1) {
XDPRINTF((1, 0, "Starting Version: %d.%02dpl%d",
_VERS_H_, _VERS_L_, _VERS_P_ ));
}

13
tools.h
View File

@ -1,4 +1,4 @@
/* tools.h : 10-Mar-96 */
/* tools.h : 20-Mar-96 */
/* (C)opyright (C) 1993,1995 Martin Stover, Marburg, Germany
*
@ -20,10 +20,11 @@
#define _TOOLS_H_
/* processes which need tools */
#define NWSERV 1
#define NCPSERV 2
#define NWCONN 3
#define NWCLIENT 4
#define NWSERV 1
#define NCPSERV 2
#define NWCONN 3
#define NWCLIENT 4
#define NWBIND 5
extern FILE *logfile;
extern void x_x_xfree(char **p);
@ -42,7 +43,7 @@ extern void dprintf(char *p, ...);
extern void xdprintf(int dlevel, int mode, char *p, ...);
extern void errorp(int mode, char *what, char *p, ...);
extern FILE *open_nw_ini(void);
extern int get_ini_entry(FILE *f, int entry, char *str, int strsize);
extern int get_ini_entry(FILE *f, int entry, uint8 *str, int strsize);
extern char *get_exec_path(char *buff, char *progname);
extern int get_ini_int(int what);
extern void get_ini_debug(int what);