mars_nwe-0.99.pl04

This commit is contained in:
Mario Fetka 2011-11-13 00:38:59 +01:00
parent 2569082c2f
commit 0c09c074ef
20 changed files with 401 additions and 95 deletions

View File

@ -50,6 +50,9 @@ distrib: mk.li nw.ini
distrib_bin: mk.li nw.ini distrib_bin: mk.li nw.ini
./mk.li $@ ./mk.li $@
bintgz:
./mk.li $@
diff: diff:
./mk.li $@ ./mk.li $@

6
README
View File

@ -52,6 +52,12 @@ sent by uuencoded mail to Volker Lendecke, who puts them on
ftp.gwdg.de:/pub/linux/misc/ncpfs. sunsite mirrors this directory in ftp.gwdg.de:/pub/linux/misc/ncpfs. sunsite mirrors this directory in
sunsite.unc.edu:/pub/Linux/system/Filesystems/ncpfs. sunsite.unc.edu:/pub/Linux/system/Filesystems/ncpfs.
HTTP SITE
=========
Http downloads are available under 'www.compu-art.de/download/mars_nwe.html'.
A homepage should be available under 'www.compu-art.de/mars_nwe/'.
DOCUMENTATION DOCUMENTATION
============= =============

165
connect.c
View File

@ -1,4 +1,4 @@
/* connect.c 01-Nov-97 */ /* connect.c 28-Nov-97 */
/* (C)opyright (C) 1993,1996 Martin Stover, Marburg, Germany /* (C)opyright (C) 1993,1996 Martin Stover, Marburg, Germany
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -40,10 +40,13 @@ static int default_uid=-1;
static int default_gid=-1; static int default_gid=-1;
static int default_umode_dir=0775; static int default_umode_dir=0775;
static int default_umode_file=0664; static int default_umode_file=0664;
static int act_umode_dir=0;
static int act_umode_file=0;
#include "nwfname.h" #include "nwfname.h"
#include "nwvolume.h" #include "nwvolume.h"
#include "nwfile.h" #include "nwfile.h"
#include "nwconn.h"
#include "connect.h" #include "connect.h"
@ -64,8 +67,6 @@ int act_uid=-1;
int act_gid=-1; int act_gid=-1;
int act_obj_id=0L; /* not login */ int act_obj_id=0L; /* not login */
int entry8_flags=0; /* special flags, see examples nw.ini, entry 8 */ int entry8_flags=0; /* special flags, see examples nw.ini, entry 8 */
int act_umode_dir=0;
int act_umode_file=0;
static gid_t *act_grouplist=NULL; /* first element is counter !! */ static gid_t *act_grouplist=NULL; /* first element is counter !! */
@ -233,6 +234,11 @@ void set_guid(int gid, int uid)
|| setegid(gid) || setegid(gid)
|| seteuid(uid) ) { || seteuid(uid) ) {
set_default_guid(); set_default_guid();
if (gid < 0 && uid < 0) {
/* don't print error */
gid = act_gid;
uid = act_uid;
}
} else if (act_gid != gid || act_uid != uid) { } else if (act_gid != gid || act_uid != uid) {
struct passwd *pw = getpwuid(uid); struct passwd *pw = getpwuid(uid);
if (NULL != pw) { if (NULL != pw) {
@ -256,6 +262,7 @@ void set_guid(int gid, int uid)
*act_grouplist=(gid_t)k; *act_grouplist=(gid_t)k;
} }
} }
} }
XDPRINTF((5,0,"SET GID=%d, UID=%d %s", gid, uid, XDPRINTF((5,0,"SET GID=%d, UID=%d %s", gid, uid,
(gid==act_gid && uid == act_uid) ? "OK" : "failed")); (gid==act_gid && uid == act_uid) ? "OK" : "failed"));
@ -272,12 +279,6 @@ void reseteuid(void)
reset_guid(); reset_guid();
} }
void set_act_obj_id(uint32 obj_id)
{
act_obj_id=obj_id;
XDPRINTF((5, 0, "actual obj_id is set to 0x%x", obj_id));
}
int in_act_groups(gid_t gid) int in_act_groups(gid_t gid)
/* returns 1 if gid is member of act_grouplist else 0 */ /* returns 1 if gid is member of act_grouplist else 0 */
{ {
@ -292,6 +293,20 @@ int in_act_groups(gid_t gid)
return(0); return(0);
} }
void set_nw_user(int gid, int uid,
uint32 obj_id, uint8 *objname,
int homepathlen, uint8 *homepath)
{
nwconn_set_program_title(objname);
set_guid(gid, uid);
act_obj_id=obj_id;
XDPRINTF((5, 0, "actual obj_id is set to 0x%x", obj_id));
nw_setup_vol_opts(act_gid, act_uid,
act_umode_dir, act_umode_file,
homepathlen, homepath);
nw_setup_home_vol(homepathlen, homepath);
}
int get_real_access(struct stat *stb) int get_real_access(struct stat *stb)
/* returns F_OK, R_OK, W_OK, X_OK */ /* returns F_OK, R_OK, W_OK, X_OK */
/* ORED with 0x10 if owner access */ /* ORED with 0x10 if owner access */
@ -485,6 +500,63 @@ int fn_dos_match(uint8 *s, uint8 *p, int options)
return(x_str_match(s, p, options)); return(x_str_match(s, p, options));
} }
/* "Resolve" string 'topath' (possible with wildcards '?') using
* 'frompath' as source for substitution. Make changes directly in
* 'topath'. Return new length of topath (equal or less than original value)
* Routine from: Andrew Sapozhnikov
*/
int apply_wildcards (uint8 *frompath, int flen, uint8 *topath, int tlen)
{
int i,tlen2;
uint8 c,*topath2;
for (i=flen; i > 0; i--) {
c=frompath[i-1];
if (c == ':' || c == '\\' || c == '/') break;
}
frompath+=i;
flen-=i;
for (i=tlen; i > 0; i--) {
c=topath[i-1];
if(c == ':' || c == '\\' || c == '/') break;
}
topath2=(topath+=i);
tlen2=tlen-i;
while (tlen2--) {
switch (c=*topath2++) {
case '?':
case 0xbf:
if (flen && *frompath != '.' && *frompath != 0xae) {
*topath++ = *frompath++;
flen--;
} else tlen--;
break;
case '.':
case 0xae:
while (flen && *frompath != '.' && *frompath != 0xae) {
frompath++;
flen--;
}
if (flen) {
frompath++;
flen--;
}
*topath++=c;
break;
default:
if (flen && *frompath != '.' && *frompath != 0xae) {
frompath++;
flen--;
}
*topath++=c;
}
}
return tlen;
}
typedef struct { typedef struct {
int attrib; int attrib;
struct stat statb; struct stat statb;
@ -1127,7 +1199,8 @@ int un_nw_attrib(struct stat *stb, int attrib, int mode)
stb->st_mode |= mode; stb->st_mode |= mode;
mode = S_IWUSR | S_IWGRP; mode = S_IWUSR | S_IWGRP;
if (attrib & FILE_ATTR_R) /* R/O */ if ((!is_dir) && (attrib & FILE_ATTR_R)) /* R/O */
/* we do not set directories to readonly: 28-Nov-97 */
stb->st_mode &= ~mode; stb->st_mode &= ~mode;
else else
stb->st_mode |= mode; stb->st_mode |= mode;
@ -1311,6 +1384,57 @@ int nw_chmod_datei(int dir_handle, uint8 *data, int len,
return(-0x9c); /* wrong path */ return(-0x9c); /* wrong path */
} }
int nw_creat_node(int volnr, uint8 *unname, int mode)
/* creat file or directory, depending on mode */
/* mode & 0x1 == directory */
/* mode & 0x2 == creat/trunc */
/* mode & 0x8 == ignore rights, try to open as root */
{
struct stat stb;
if (mode & 1) { /* directory */
if (!mkdir(unname, 0777)) {
int umode_dir=get_volume_umode_dir(volnr);
if (umode_dir) {
if (umode_dir == -1) { /* we get parent dir */
uint8 fn[260];
strcpy(fn, unname);
strcat(fn, "/..");
if (!stat(fn, &stb)) {
umode_dir=stb.st_mode;
} else return(0);
}
chmod(unname, umode_dir);
}
return(0);
}
} else { /* file */
int fd=(mode & 2) ? open(unname, O_CREAT|O_TRUNC|O_RDWR, 0777)
: creat(unname, 0777);
if (fd < 0 && (mode & 8)) { /* creat always */
if ( (!seteuid(0)) && (-1 < (fd =
open(unname, O_CREAT|O_TRUNC|O_RDWR, 0777)))) {
int umode_file=get_volume_umode_file(volnr);
close(fd);
chown(unname, act_uid, act_gid);
if (umode_file > 0)
chmod(unname, umode_file);
reseteuid();
return(0);
}
reseteuid();
}
if ( fd > -1 ) {
int umode_file=get_volume_umode_file(volnr);
close(fd);
if (umode_file > 0)
chmod(unname, umode_file);
return(0);
}
}
return(-1);
}
int nw_mk_rd_dir(int dir_handle, uint8 *data, int len, int mode) int nw_mk_rd_dir(int dir_handle, uint8 *data, int len, int mode)
{ {
NW_PATH nwpath; NW_PATH nwpath;
@ -1323,11 +1447,8 @@ int nw_mk_rd_dir(int dir_handle, uint8 *data, int len, int mode)
return(mode ? -0x84 : -0x8a); return(mode ? -0x84 : -0x8a);
if (mode) { if (mode) {
XDPRINTF((5,0,"MKDIR dirname:%s:", unname)); XDPRINTF((5,0,"MKDIR dirname:%s:", unname));
if (!mkdir(unname, 0777)) { if (!nw_creat_node(nwpath.volume, unname, 1))
if (act_umode_dir)
chmod(unname, act_umode_dir);
return(0); return(0);
}
if (errno == EEXIST) if (errno == EEXIST)
completition = -0xff; completition = -0xff;
else else
@ -1369,7 +1490,10 @@ int mv_file(int qdirhandle, uint8 *q, int qlen,
{ {
NW_PATH quellpath; NW_PATH quellpath;
NW_PATH zielpath; NW_PATH zielpath;
int completition=conn_get_kpl_path(&quellpath, qdirhandle, q, qlen, 0); int completition;
zlen=apply_wildcards(q, qlen, z, zlen);
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); completition=conn_get_kpl_path(&zielpath, zdirhandle, z, zlen, 0);
if (completition > -1) { if (completition > -1) {
@ -1538,7 +1662,8 @@ int nw_init_connect(void)
if (connect_is_init) { if (connect_is_init) {
k = 0; k = 0;
while (k++ < anz_dirhandles) free_dir_handle(k); while (k++ < anz_dirhandles)
free_dir_handle(k);
} else } else
connect_is_init++; connect_is_init++;
@ -1551,10 +1676,10 @@ int nw_init_connect(void)
} else if (what == 8) { /* entry8_flags */ } else if (what == 8) { /* entry8_flags */
entry8_flags = hextoi((char*)buff); entry8_flags = hextoi((char*)buff);
} else if (what == 9) { /* umode */ } else if (what == 9) { /* umode */
int umode_dir, umode_file; uint8 buf1[300], buf2[300];
if (2 == sscanf((char*)buff, "%o %o", &umode_dir, &umode_file)) { if (2 == sscanf((char*)buff, "%s %s", buf1, buf2)) {
default_umode_dir = umode_dir; default_umode_dir = octtoi(buf1);
default_umode_file = umode_file; default_umode_file = octtoi(buf2);
} }
} else if (what == 10) { /* GID */ } else if (what == 10) { /* GID */
default_gid = atoi((char*)buff); default_gid = atoi((char*)buff);

View File

@ -1,4 +1,4 @@
/* connect.h 29-Jul-97 */ /* connect.h 27-Nov-97 */
#ifndef _CONNECT_H_ #ifndef _CONNECT_H_
#define _CONNECT_H_ #define _CONNECT_H_
@ -133,6 +133,8 @@ extern int mv_file(int qdirhandle, uint8 *q, int qlen,
extern int mv_dir(int dir_handle, uint8 *q, int qlen, extern int mv_dir(int dir_handle, uint8 *q, int qlen,
uint8 *z, int zlen); uint8 *z, int zlen);
extern int nw_creat_node(int volnr, uint8 *unname, int mode);
extern int nw_mk_rd_dir(int dir_handle, uint8 *data, int len, int mode); extern int nw_mk_rd_dir(int dir_handle, uint8 *data, int len, int mode);
extern int nw_search(uint8 *info, uint32 *fileowner, extern int nw_search(uint8 *info, uint32 *fileowner,
@ -208,8 +210,6 @@ extern int act_uid;
extern int act_gid; extern int act_gid;
extern int act_obj_id; /* not login == 0 */ extern int act_obj_id; /* not login == 0 */
extern int entry8_flags; /* special flags, see examples nw.ini, entry 8 */ extern int entry8_flags; /* special flags, see examples nw.ini, entry 8 */
extern int act_umode_dir;
extern int act_umode_file;
extern int conn_get_kpl_path(NW_PATH *nwpath, int dirhandle, extern int conn_get_kpl_path(NW_PATH *nwpath, int dirhandle,
uint8 *data, int len, int only_dir) ; uint8 *data, int len, int only_dir) ;
@ -224,8 +224,11 @@ extern void set_default_guid(void);
extern void set_guid(int gid, int uid); extern void set_guid(int gid, int uid);
extern void reset_guid(void); extern void reset_guid(void);
extern void reseteuid(void); extern void reseteuid(void);
extern void set_act_obj_id(uint32 obj_id);
extern int in_act_groups(gid_t gid); extern int in_act_groups(gid_t gid);
extern void set_nw_user(int gid, int uid,
uint32 obj_id, uint8 *objname,
int homepathlen, uint8 *homepath);
extern int get_real_access(struct stat *stb); extern int get_real_access(struct stat *stb);
extern uint32 get_file_owner(struct stat *stb); extern uint32 get_file_owner(struct stat *stb);

View File

@ -380,7 +380,7 @@ Erste 'oeffentliche' Version
- bei Schalter -k warten auf beenden eingebaut. - bei Schalter -k warten auf beenden eingebaut.
neuer Schalter -q (quick ohne warten) neuer Schalter -q (quick ohne warten)
- home volume feature erweitert von Andrew Sapozhnikov. - home volume feature erweitert von Andrew Sapozhnikov.
- Bei Verzeichnissen wird nicht mehr das SHARED flag zuruegesetzt. - Bei Verzeichnissen wird nicht mehr das SHARED flag zuruegesetzt.
(Andrew Sapozhnikov) (Andrew Sapozhnikov)
- Es kann nun mittels SYSCON verhindert werden, dass User sein Passwort - Es kann nun mittels SYSCON verhindert werden, dass User sein Passwort
aendern kann. ( Mr. Charlie Root (alexey) ) aendern kann. ( Mr. Charlie Root (alexey) )
@ -388,4 +388,8 @@ Erste 'oeffentliche' Version
- MAX_CONNECTIONS (default) auf 50 gesetzt. - MAX_CONNECTIONS (default) auf 50 gesetzt.
- Logfilepfade von /tmp auf /var/log/. geaendert. - Logfilepfade von /tmp auf /var/log/. geaendert.
<----- ^^^^^^^^^^ pl3 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ <----- ^^^^^^^^^^ pl3 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
- "wildcard rename bug" patch von Andrew Sapozhnikov eingebaut.
- Creat mode von Verzeichnissen erweitert.
- Verzeichnisse werden nicht mehr auf readonly gesetzt.
<----- ^^^^^^^^^^ pl4 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^

View File

@ -77,6 +77,7 @@ Andrew Sapozhnikov <sapa@hq.icb.chel.su>
fixed findfirst/findnext bug, fixed findfirst/findnext bug,
fixed directory access bug, fixed directory access bug,
added extend "Volume is home" feature. added extend "Volume is home" feature.
fixed "rename wildcard" bug.
Gregory Steuck <greg@nsu.ru> Gregory Steuck <greg@nsu.ru>
testings and errorreports testings and errorreports

View File

@ -1,3 +1,7 @@
------27-Nov-97--- 0.99.pl4 ---------
- section 1: dir/file creat modes can now be set volume dependent.
- section 9: dir creat mode may now be '-1' for use st_mode of
parent directory.
------10-Nov-97--- 0.99.pl3 --------- ------10-Nov-97--- 0.99.pl3 ---------
- some defaults in config.h and nw.ini changed. - some defaults in config.h and nw.ini changed.
default programpath is now /usr/sbin/ !! default programpath is now /usr/sbin/ !!

View File

@ -1,16 +1,16 @@
Begin3 Begin3
Title: mars_nwe Title: mars_nwe
Version: 0.99.pl3 Version: 0.99.pl4
Entered-date: 10-Nov-97 Entered-date: 28-Nov-97
Description: Full netware-emulator (src), beta. Description: Full netware-emulator (src), beta.
Supports file-services, bindery-services, Supports file-services, bindery-services,
printing-services, routing-services. printing-services, routing-services.
Keywords: novell, netware, server, ipx, ncp, tli Keywords: novell, netware, server, ipx, ncp, tli
Author: mstover@compu-art.de (Martin Stover) Author: mstover@compu-art.de (Martin Stover)
Maintained-by: mstover@compu-art.de (Martin Stover) Maintained-by: mstover@compu-art.de (Martin Stover)
Primary-site: http://www.compu-art.de/download/mars_nwe-0.99.pl3.tgz Primary-site: http://www.compu-art.de/download/mars_nwe-0.99.pl4.tgz
250 kB 250 kB
Alternate-site: ftp://gwdg.de/pub/linux/misc/ncpfs/mars_nwe-0.99.pl3.tgz Alternate-site: ftp://gwdg.de/pub/linux/misc/ncpfs/mars_nwe-0.99.pl4.tgz
Platforms: Linux (1.2.xx, 1.3.xx, 2.xx), UnixWare (2.xx) Platforms: Linux (1.2.xx, 1.3.xx, 2.xx), UnixWare (2.xx)
Copying-policy: GNU Copying-policy: GNU
End End

View File

@ -2,7 +2,7 @@
# This is the configuration-file for "mars_nwe", a free netware-emulator # This is the configuration-file for "mars_nwe", a free netware-emulator
# for Linux. # for Linux.
# #
# last changed: 09-Nov-97 # last changed: 27-Nov-97
# #
# !! section 4 : automatic creation of ipx-interfaces changed in 0.98.pl9 !! # !! section 4 : automatic creation of ipx-interfaces changed in 0.98.pl9 !!
# #
@ -65,7 +65,7 @@
# #
# ------------------------------------------------------------------------- # -------------------------------------------------------------------------
# Syntax: # Syntax:
# 1 VOLUMENAME DIRECTORY OPTIONS # 1 VOLUMENAME DIRECTORY [OPTIONS] [UMASKDIR UMASKFILE]
# #
# VOLUMENAME: the name of the mars_nwe-volume (max. 8 characters) # VOLUMENAME: the name of the mars_nwe-volume (max. 8 characters)
# DIRECTORY: the directory on your Linux-system associated with that # DIRECTORY: the directory on your Linux-system associated with that
@ -95,7 +95,7 @@
# dir *.* necessary. # dir *.* necessary.
# #
# OPTIONS: none or some of the following characters (without a seperator) # OPTIONS: none or some of the following characters (without a seperator)
# # - Placeholder.
# Next two options control DOS and OS/2 namespace. # Next two options control DOS and OS/2 namespace.
# i ignore case, handle mixing upper/lowercase filenames (slow) # i ignore case, handle mixing upper/lowercase filenames (slow)
# should only be used if you really need it. # should only be used if you really need it.
@ -118,15 +118,25 @@
# O (uppercase o) # O (uppercase o)
# + OS/2 namespace (useful for Win95 clients, see doc/FAQS). # + OS/2 namespace (useful for Win95 clients, see doc/FAQS).
# N + NFS namespace (not really tested). # N + NFS namespace (not really tested).
#
#
# UMASKDIR: default directory creat umask.
# UMASKFILE: default file creat umask.
# value are always octal, overwrite standard section 9 entries
# for this specific volume.
#
# ------------------------------------------------------------------------- # -------------------------------------------------------------------------
# #
# Examples: # Examples:
# 1 SYS /var/local/nwe/SYS k # 1 SYS /var/local/nwe/SYS k
# 1 CDROM /cdrom kmor # 1 CDROM /cdrom kmor
# 1 HOME ~ k # 1 HOME ~ k -1
# 1 HOMETMP ~/tmp kiO # 1 HOMETMP ~/tmp kiO
# 1 PRIVAT ~/privat kO 700 600
# 1 WORLD /var/world kiO 777 666
1 SYS /u3/SYS/ k
1 SYS /u3/SYS/ k -1
# ========================================================================= # =========================================================================
@ -402,8 +412,11 @@
# #
# mkdir mode (creat mode directories), creat mode files # mkdir mode (creat mode directories), creat mode files
# values are always interpreted as octal values ! # values are always interpreted as octal values !
# if 0 is specified then the standard umask will be used. # if 0 is specified the standard umask will be used.
# 9 0755 0664 # if -1 is specified for directories the st_mode of parent directory
# will be used.
# Volumes depended values can be set in section 1.
# 9 -1 0664
# #
9 0755 0664 9 0755 0664

35
examples/nwopt Normal file
View File

@ -0,0 +1,35 @@
# example for nwopt file.
#
# last changed: 18-Nov-97
#
# Syntax similar like nwserv.conf file.
#
# This file can be located in
# - user home dir as '.nwopt' ( ~/.nwopt )
# - volume path as '.nwopt.vol' ( /u3/SYS/.nwopt.vol )
# - and/or '.nwoptg.gid' ( /u3/SYS/.nwoptg.50 )
# - and/or '.nwoptu.uid' ( /u3/SYS/.nwoptu.100 )
# the nwopt files are read after logins in order
# ~/.nwopt, .nwopt.vol, .nwoptg.xxx, .nwoptu.xxx
#
# Section 1: special flags.
# =========================================================================
# Flags
# 0x1 when creating dirs, change group to directory group
# if possible. ( must be in groups of user )
#
# other flags may follow.
# value will be interpreted as hex value.
#
#1 0x0
# Section 9: Standard creat mode for creating directories and files.
# =========================================================================
#9 0755 0664

View File

@ -9,7 +9,7 @@ C=.c
V_H=0 V_H=0
V_L=99 V_L=99
P_L=3 P_L=4
#define D_P_L 1 #define D_P_L 1
DISTRIB=mars_nwe DISTRIB=mars_nwe
@ -60,6 +60,9 @@ distrib: $(DESTMAKEFILE)
distrib_bin: $(DESTMAKEFILE) distrib_bin: $(DESTMAKEFILE)
$(MAKE) -f $(DESTMAKEFILE) n_$@ $(MAKE) -f $(DESTMAKEFILE) n_$@
bintgz: $(DESTMAKEFILE)
$(MAKE) -f $(DESTMAKEFILE) n_$@
$(DESTMAKEFILE): $(VPATH)/makefile.unx $(VPATH)/config.h $(DESTMAKEFILE): $(VPATH)/makefile.unx $(VPATH)/config.h
rm -f $@ rm -f $@
cp $(VPATH)/makefile.unx makefile.c cp $(VPATH)/makefile.unx makefile.c
@ -217,7 +220,6 @@ cd $(OBJDIR) )
n_reboot: n_install n_reboot: n_install
-nwserv -k -nwserv -k
sleep 5
nwserv nwserv
clean_d: clean_d:
@ -273,6 +275,7 @@ n_distrib: n_diff
; rm $(DISTRIBF).uue \ ; rm $(DISTRIBF).uue \
; mv $(DISTRIBF).tgz /tmp/x/. \ ; mv $(DISTRIBF).tgz /tmp/x/. \
; cp -a $(DISTRIB)/doc/$(DISTRIB).lsm /tmp/x/. \ ; cp -a $(DISTRIB)/doc/$(DISTRIB).lsm /tmp/x/. \
; mv $(PATCHF).gz /tmp/x/. \
; cd $(OBJDIR) ) ; cd $(OBJDIR) )
-rm -f /tmp/mars_nwe.tgz -rm -f /tmp/mars_nwe.tgz
ln -s /tmp/x/$(DISTRIBF).tgz /tmp/mars_nwe.tgz ln -s /tmp/x/$(DISTRIBF).tgz /tmp/mars_nwe.tgz
@ -284,6 +287,11 @@ n_distrib_bin:
doc \ doc \
; cd $(OBJDIR)) ; cd $(OBJDIR))
n_bintgz:
cd $(VPATH) && (tar cvzf /tmp/mars_nwb.tgz \
$(PROGS) \
; cd $(OBJDIR))
n_showconf: n_showconf:
echo "#" $(M_FILENAME_NW_INI) echo "#" $(M_FILENAME_NW_INI)
grep "^[ \t]*[0-9]" $(M_FILENAME_NW_INI) grep "^[ \t]*[0-9]" $(M_FILENAME_NW_INI)

View File

@ -710,23 +710,17 @@ static int insert_get_base_entry(N_NW_PATH *nwpath,
if (!basehandle && creatmode) { /* now creat the entry (file or dir) */ if (!basehandle && creatmode) { /* now creat the entry (file or dir) */
int result = 0; int result = 0;
char *unname = nwpath_2_unix(nwpath, 2); char *unname = nwpath_2_unix(nwpath, 2);
if (get_volume_options(nwpath->volume) & if (get_volume_options(nwpath->volume) &
VOL_OPTION_READONLY) return(-0x8a); VOL_OPTION_READONLY) return(-0x8a);
if (creatmode & FILE_ATTR_DIR) { if (creatmode & FILE_ATTR_DIR) {
/* creat dir */ /* creat dir */
if (mkdir(unname, 0777)) if (nw_creat_node(nwpath->volume, unname, 1))
result=-0x84; result=-0x84;
else if (act_umode_dir)
chmod(unname, act_umode_dir);
} else { } else {
/* creat file */ /* creat file */
if ((result = creat(unname, 0777)) > -1) { if (nw_creat_node(nwpath->volume, unname, 0))
if (act_umode_file) result=-0x84;
chmod(unname, act_umode_file);
close(result);
result = 0;
} else result=-0x84;
} }
if (result) return(result); if (result) return(result);
basehandle = name_2_base(nwpath, namespace, 0); basehandle = name_2_base(nwpath, namespace, 0);

View File

@ -1,5 +1,5 @@
/* nwbind.c */ /* nwbind.c */
#define REVISION_DATE "01-Nov-97" #define REVISION_DATE "27-Nov-97"
/* NCP Bindery SUB-SERVER */ /* NCP Bindery SUB-SERVER */
/* authentification and some message handling */ /* authentification and some message handling */

View File

@ -1,4 +1,4 @@
/* nwconn.c 08-Oct-97 */ /* nwconn.c 18-Nov-97 */
/* one process / connection */ /* one process / connection */
/* (C)opyright (C) 1993,1996 Martin Stover, Marburg, Germany /* (C)opyright (C) 1993,1996 Martin Stover, Marburg, Germany
@ -104,7 +104,7 @@ typedef struct {
static BURST_W *burst_w=NULL; static BURST_W *burst_w=NULL;
#endif #endif
static void set_program_title(char *s) void nwconn_set_program_title(char *s)
{ {
memset(prog_title, 0, 49); memset(prog_title, 0, 49);
if (s&&*s) if (s&&*s)
@ -113,6 +113,7 @@ static void set_program_title(char *s)
strcpy(prog_title, "()"); strcpy(prog_title, "()");
} }
static int ncp_response(int sequence, int task, static int ncp_response(int sequence, int task,
int completition, int data_len) int completition, int data_len)
{ {
@ -1073,10 +1074,9 @@ NWCONN 1:len 15, DATA:,0x5,0x1,0x0,0x12,0xa,'0','9','0','6',
case 0x19 : /* logout, some of this call is handled in ncpserv. */ case 0x19 : /* logout, some of this call is handled in ncpserv. */
free_queue_jobs(); free_queue_jobs();
nw_free_handles(-1); nw_free_handles(-1);
set_default_guid(); set_nw_user(-1, -1,
nw_setup_home_vol(-1, NULL); 0, NULL,
set_act_obj_id(0); /* NOT logged in */ -1, NULL);
set_program_title(NULL);
return(-1); /* nwbind must do a little rest */ return(-1); /* nwbind must do a little rest */
break; break;
@ -1874,15 +1874,19 @@ static void handle_after_bind()
int fnlen = (int) *(bindresponse + 3 * sizeof(int)); int fnlen = (int) *(bindresponse + 3 * sizeof(int));
uint8 objname[48]; uint8 objname[48];
/* ncpserv have changed the structure */ /* ncpserv have changed the structure */
set_guid(*((int*)bindresponse), *((int*)(bindresponse+sizeof(int))));
set_act_obj_id(*((uint32*)(bindresponse + 2 * sizeof(int))));
nw_setup_home_vol(fnlen, bindresponse + 3 * sizeof(int) +1);
if (ufunc==0x14) { if (ufunc==0x14) {
xstrmaxcpy(objname, requestdata+6, (int) *(requestdata+5)); xstrmaxcpy(objname, requestdata+6, (int) *(requestdata+5));
} else if (ufunc==0x18){ } else if (ufunc==0x18){
xstrmaxcpy(objname, requestdata+14, (int) *(requestdata+13)); xstrmaxcpy(objname, requestdata+14, (int) *(requestdata+13));
} else objname[0]='\0'; } else objname[0]='\0';
set_program_title(objname);
set_nw_user(*((int*)bindresponse), /* gid */
*((int*)(bindresponse+sizeof(int))), /* uid */
*((uint32*)(bindresponse + 2 * sizeof(int))), /* id */
objname, /* login name */
fnlen, /* unix homepathlen */
bindresponse + 3 * sizeof(int) +1); /* unix homepath */
} }
break; break;
@ -2195,7 +2199,7 @@ int main(int argc, char **argv)
#endif #endif
set_default_guid(); set_default_guid();
set_program_title(NULL); nwconn_set_program_title(NULL);
ud.opt.len = sizeof(uint8); ud.opt.len = sizeof(uint8);
ud.opt.maxlen = sizeof(uint8); ud.opt.maxlen = sizeof(uint8);

View File

@ -1,7 +1,8 @@
/* nwconn.h 01-Aug-97 */ /* nwconn.h 19-Nov-97 */
#ifndef _NWCONN_H_ #ifndef _NWCONN_H_
#define _NWCONN_H_ #define _NWCONN_H_
extern int act_connection; extern int act_connection;
extern int act_pid; extern int act_pid;
extern void nwconn_set_program_title(char *s);
#endif #endif

View File

@ -1,4 +1,4 @@
/* nwfile.c 26-Aug-97 */ /* nwfile.c 26-Nov-97 */
/* (C)opyright (C) 1993,1996 Martin Stover, Marburg, Germany /* (C)opyright (C) 1993,1996 Martin Stover, Marburg, Germany
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -333,33 +333,25 @@ int file_creat_open(int volume, uint8 *unixname, struct stat *stbuff,
} else { } else {
/* <========= this is NOT a PIPE Volume ====================> */ /* <========= this is NOT a PIPE Volume ====================> */
if (creatmode&0x3) { /* creat File */ if (creatmode&0x3) { /* creat File */
int was_ok=0;
fh->fd=-1;
if (creatmode & 0x2) { /* creatnew */ if (creatmode & 0x2) { /* creatnew */
XDPRINTF((5,0,"CREAT FILE:%s: Handle=%d", fh->fname, fhandle)); XDPRINTF((5,0,"CREAT FILE:%s: Handle=%d", fh->fname, fhandle));
fh->fd = creat(fh->fname, 0777); if (!nw_creat_node(volume, fh->fname, 0))
if (fh->fd < 0) was_ok++;
completition = -0x84; /* no create Rights */ else
else if (act_umode_file) completition = -0x84; /* no create Rights */
chmod(fh->fname, act_umode_file);
} else { } else {
XDPRINTF((5,0,"CREAT FILE, ever with attrib:0x%x, access:0x%x, fh->fname:%s: handle:%d", XDPRINTF((5,0,"CREAT FILE, ever with attrib:0x%x, access:0x%x, fh->fname:%s: handle:%d",
attrib, access, fh->fname, fhandle)); attrib, access, fh->fname, fhandle));
fh->fd = open(fh->fname, O_CREAT|O_TRUNC|O_RDWR, 0777); if (!nw_creat_node(volume, fh->fname,
if (fh->fd < 0) { (creatmode & 0x8) ? (2|8) : 2))
if (creatmode & 0x8) { was_ok++;
if ( (!seteuid(0)) && (-1 < (fh->fd = else
open(fh->fname, O_CREAT|O_TRUNC|O_RDWR, 0777)))) { completition = -0x85; /* no delete /create Rights */
chown(fh->fname, act_uid, act_gid);
}
did_grpchange=0;
reset_guid();
}
if (fh->fd < 0)
completition = -0x85; /* no delete /create Rights */
} else if (act_umode_file)
chmod(fh->fname, act_umode_file);
} }
if (fh->fd > -1) { if (was_ok) {
close(fh->fd);
fh->fd = open(fh->fname, O_RDWR); fh->fd = open(fh->fname, O_RDWR);
fh->offd = 0L; fh->offd = 0L;
stat(fh->fname, stbuff); stat(fh->fname, stbuff);

View File

@ -1,4 +1,4 @@
/* nwvolume.c 01-Nov-97 */ /* nwvolume.c 28-Nov-97 */
/* (C)opyright (C) 1993,1996 Martin Stover, Marburg, Germany /* (C)opyright (C) 1993,1996 Martin Stover, Marburg, Germany
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -86,10 +86,13 @@ void nw_init_volumes(FILE *f)
if ( what == 1 && used_nw_volumes < max_nw_vols && strlen((char*)buff) > 3){ if ( what == 1 && used_nw_volumes < max_nw_vols && strlen((char*)buff) > 3){
uint8 sysname[256]; uint8 sysname[256];
uint8 unixname[256]; uint8 unixname[256];
char optionstr[256]; uint8 optionstr[256];
char *p; uint8 umode_dirstr[256];
uint8 umode_filestr[256];
uint8 *p;
int len; int len;
int founds = sscanf((char*)buff, "%s %s %s",sysname, unixname, optionstr); int founds = sscanf((char*)buff, "%s %s %s %s %s",
sysname, unixname, optionstr, umode_dirstr, umode_filestr);
if (founds > 1) { if (founds > 1) {
NW_VOL *vol=&(nw_volumes[used_nw_volumes]); NW_VOL *vol=&(nw_volumes[used_nw_volumes]);
vol->options = VOL_NAMESPACE_DOS; vol->options = VOL_NAMESPACE_DOS;
@ -160,6 +163,13 @@ void nw_init_volumes(FILE *f)
} }
} }
} }
vol->umode_dir = 0;
vol->umode_file = 0;
if (founds > 3) {
vol->umode_dir=octtoi(umode_dirstr);
if (founds > 4)
vol->umode_file=octtoi(umode_filestr);
}
used_nw_volumes++; used_nw_volumes++;
if (vol->options & VOL_OPTION_ONE_DEV) { if (vol->options & VOL_OPTION_ONE_DEV) {
vol->max_maps_count = 1; vol->max_maps_count = 1;
@ -226,6 +236,69 @@ void nw_setup_home_vol(int len, uint8 *fn)
} }
} }
void nw_setup_vol_opts(int act_gid, int act_uid,
int act_umode_dir, int act_umode_file,
int homepathlen, uint8 *homepath)
/* set's homevolume and volume's umodes */
{
int k=used_nw_volumes;
uint8 unixname[258];
uint8 fullname[258];
unixname[0] = '\0';
xfree(home_dir);
home_dir_len=0;
if (homepathlen > 0) {
strmaxcpy(unixname, homepath, homepathlen);
if (unixname[homepathlen-1] != '/') {
unixname[homepathlen++] = '/';
unixname[homepathlen] = '\0';
}
new_str(home_dir, unixname);
home_dir_len=homepathlen;
}
while (k--) { /* now set all HOME volumes */
uint8 *fname;
int flen;
if (nw_volumes[k].options & VOL_OPTION_IS_HOME) {
int i = -1;
while (++i < nw_volumes[k].maps_count)
xfree(nw_volumes[k].dev_namespace_maps[i]);
nw_volumes[k].maps_count = 0;
fname = unixname;
flen = homepathlen;
nw_volumes[k].umode_dir = 0;
nw_volumes[k].umode_file = 0;
if (homepathlen > 0 && nw_volumes[k].addonlen) {
if (homepathlen + nw_volumes[k].addonlen > 256) {
flen = 0;
fname = "";
} else {
strcpy(fullname, unixname);
/* concatenation $HOME/ and add/on/ */
strcpy(fullname + homepathlen, nw_volumes[k].homeaddon);
fname = fullname;
flen = homepathlen + nw_volumes[k].addonlen;
}
}
nw_volumes[k].unixnamlen = flen;
new_str(nw_volumes[k].unixname, fname);
if (flen>0)
volume_to_namespace_map(k, &(nw_volumes[k]));
}
if (!nw_volumes[k].umode_dir)
nw_volumes[k].umode_dir=act_umode_dir;
if (!nw_volumes[k].umode_file)
nw_volumes[k].umode_file=act_umode_file;
}
}
static int look_name_space_map(NW_VOL *v, DEV_NAMESPACE_MAP *dnm, static int look_name_space_map(NW_VOL *v, DEV_NAMESPACE_MAP *dnm,
int do_insert) int do_insert)
{ {
@ -334,6 +407,17 @@ int nw_get_volume_name(int volnr, uint8 *volname)
return(result); return(result);
} }
int get_volume_umode_dir(int volnr)
{
return( (volnr > -1 && volnr < used_nw_volumes) ?
nw_volumes[volnr].umode_dir : 0);
}
int get_volume_umode_file(int volnr)
{
return( (volnr > -1 && volnr < used_nw_volumes) ?
nw_volumes[volnr].umode_file : 0);
}
/* stolen from GNU-fileutils */ /* stolen from GNU-fileutils */
static long adjust_blocks (long blocks, int fromsize, int tosize) static long adjust_blocks (long blocks, int fromsize, int tosize)

View File

@ -1,4 +1,4 @@
/* nwvolume.h 01-Nov-97 */ /* nwvolume.h 28-Nov-97 */
/* (C)opyright (C) 1993,1995 Martin Stover, Marburg, Germany /* (C)opyright (C) 1993,1995 Martin Stover, Marburg, Germany
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -45,6 +45,9 @@ typedef struct {
uint32 high_inode; /* hight inode to can handle correct */ uint32 high_inode; /* hight inode to can handle correct */
int options; /* see defines below */ int options; /* see defines below */
uint8 *os2buf; /* special stuff for os2 namspace */ uint8 *os2buf; /* special stuff for os2 namspace */
int umode_dir; /* umask/umode for creating dirs */
int umode_file; /* umask/umode for creating files */
} NW_VOL; } NW_VOL;
/* vol options */ /* vol options */
@ -79,9 +82,16 @@ extern int home_dir_len;
extern char *path_vol_inodes_cache; /* for namespace routines */ extern char *path_vol_inodes_cache; /* for namespace routines */
extern void nw_init_volumes(FILE *f); extern void nw_init_volumes(FILE *f);
extern void nw_setup_vol_opts(int act_gid, int act_uid,
int act_umode_dir, int act_umode_file,
int homepathlen, uint8 *homepath);
extern void nw_setup_home_vol(int len, uint8 *fn); extern void nw_setup_home_vol(int len, uint8 *fn);
extern int nw_get_volume_number(uint8 *volname, int namelen); extern int nw_get_volume_number(uint8 *volname, int namelen);
extern int nw_get_volume_name(int volnr, uint8 *volname); extern int nw_get_volume_name(int volnr, uint8 *volname);
extern int get_volume_umode_dir(int volnr);
extern int get_volume_umode_file(int volnr);
extern int nw_get_fs_usage(uint8 *volname, struct fs_usage *fsu, int limit); extern int nw_get_fs_usage(uint8 *volname, struct fs_usage *fsu, int limit);
extern int get_volume_options(int volnr); extern int get_volume_options(int volnr);
extern int get_volume_inode(int volnr, struct stat *stb); extern int get_volume_inode(int volnr, struct stat *stb);

31
tools.c
View File

@ -1,4 +1,4 @@
/* tools.c 08-Jun-97 */ /* tools.c 26-Nov-97 */
/* (C)opyright (C) 1993,1995 Martin Stover, Marburg, Germany /* (C)opyright (C) 1993,1995 Martin Stover, Marburg, Germany
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@ -451,10 +451,6 @@ void init_tools(int module, int options)
} }
if (kill_pid > 1) { if (kill_pid > 1) {
kill(kill_pid, sig); kill(kill_pid, sig);
if (sig == SIGUSR1 || sig == SIGTERM) { /* we try twice */
sleep(2);
kill(kill_pid, sig);
}
if (sig == SIGTERM && options == 2 ) { /* we want to wait for stop */ if (sig == SIGTERM && options == 2 ) { /* we want to wait for stop */
int k = 120; /* max. 4 min */ int k = 120; /* max. 4 min */
fprintf(stdout, "\nwaiting for stop of %s ...\n", get_modstr()); fprintf(stdout, "\nwaiting for stop of %s ...\n", get_modstr());
@ -467,13 +463,16 @@ void init_tools(int module, int options)
exit(0); exit(0);
} }
} }
fprintf(stderr, "\n%s not stopped yet!\n", get_modstr()); fprintf(stderr, "\n%s not yet stopped!\n", get_modstr());
exit(1); exit(1);
} else if (sig == SIGUSR1 || sig == SIGTERM) { /* we try twice */
sleep(2);
kill(kill_pid, sig);
} }
} }
exit(0); exit(0);
} else if (options == 1 || options == 2 || options == 3 || options == 4) { } else if (options == 1 || options == 2 || options == 3 || options == 4) {
errorp(11, "INIT", "Program not running yet" ); errorp(11, "INIT", "Program not yet running." );
exit(1); exit(1);
} }
} }
@ -595,6 +594,24 @@ int hextoi(char *buf)
return(i); return(i);
} }
int octtoi(char *buf)
{
int i;
if (!buf) i=0;
else {
int m=0;
if (*buf == '-') {
++m;
++buf;
}
if (*buf == 0 || 1 != sscanf(buf, "%o", &i))
i=0;
else if (m)
i=-i;
}
return(i);
}
unsigned int atou(char *buf) unsigned int atou(char *buf)
{ {
unsigned int u; unsigned int u;

View File

@ -59,6 +59,8 @@ extern uint8 *downstr(uint8 *ss);
extern uint8 *upstr(uint8 *ss); extern uint8 *upstr(uint8 *ss);
extern int hextoi(char *buf); extern int hextoi(char *buf);
extern int octtoi(char *buf);
extern unsigned int atou(char *buf); extern unsigned int atou(char *buf);
extern char *hex_str(char *buf, uint8 *s, int len); extern char *hex_str(char *buf, uint8 *s, int len);