Compare commits

..

5 Commits
v0.11 ... v0.16

Author SHA1 Message Date
ncpfs archive import
5753870858 Import ncpfs 0.16 2026-04-28 20:39:57 +02:00
ncpfs archive import
b8ce93c8bd Import ncpfs 0.15 2026-04-28 20:39:57 +02:00
ncpfs archive import
7bef99df0f Import ncpfs 0.14 2026-04-28 20:39:57 +02:00
ncpfs archive import
d31ec2ab61 Import ncpfs 0.13 2026-04-28 20:39:57 +02:00
ncpfs archive import
1ee60bade6 Import ncpfs 0.12 2026-04-28 20:39:57 +02:00
46 changed files with 1610 additions and 266 deletions

BIN
.downloads/ncpfs-0.12.tgz Normal file

Binary file not shown.

BIN
.downloads/ncpfs-0.13.tgz Normal file

Binary file not shown.

BIN
.downloads/ncpfs-0.14.tgz Normal file

Binary file not shown.

BIN
.downloads/ncpfs-0.15.tgz Normal file

Binary file not shown.

BIN
.downloads/ncpfs-0.16.tgz Normal file

Binary file not shown.

21
BUGS
View File

@@ -3,17 +3,20 @@ them to be bugs.
But there are really problems that might be fixed in the future.
'df' returns 0:
Free disk space is distributed among the volumes in NetWare. df is
only able to report one number per mounted filesystem. As connections
are quite expensive for NetWare (with lwared that might change ...), I
rejected the alternative to mount only a single volume for a unix
mount point. So I simply return 0.
-------------------------------------------------------------------------------
'df' returns 0: Free disk space is distributed among the volumes in
NetWare. df is only able to report one number per mounted
filesystem. As connections are quite expensive for NetWare (with
mars_nwe and lwared that might change ...), I rejected the alternative
to mount only a single volume for a unix mount point. So I simply
return 0.
In your kernel log, there will appear messages like
-------------------------------------------------------------------------------
If you use Linux 1.2.x, In your kernel log there will appear messages
like
Nov 25 16:09:08 lx01 kernel: alloc_skb called nonatomically from interrupt 0000002e
These are a bit annoying, but completely harmless. Maybe this will be
fixed in the future.
These are a bit annoying, but completely harmless.

35
Changes Normal file
View File

@@ -0,0 +1,35 @@
I only began this file with ncpfs-0.12. If you're interested in older
versions, you can find them on linux01.gwdg.de:/pub/ncpfs/old.
ncpfs-0.15 -> ncpfs-0.16
- Included ipx-1.0, made available by Greg Page <greg@caldera.com>,
Caldera
- Made -n work for password-less accounts. Thanks to Alexander Jolk
<jolk@ap-pc513b.physik.uni-karlsruhe.de>.
- Fixed the kerneld support.
- Fixed the NetWare 4.1 problem. Many thanks to
Chatchai JANTARAPRIM <chat@ratree.psu.ac.th> and
hitesh.soneji@industry.net for their patience.
ncpfs-0.14 -> ncpfs-0.15
- A bug fixed that made normal mounting impossible. It was too late
yesterday. Sorry
- Manpage for pserver.c
ncpfs-0.13 -> ncpfs-0.14
- Improvements of manual pages by B. Galliart <bgallia@luc.edu> and
Terry Dawson <terry@perf.no.itg.telecom.com.au>
- fsinfo
- pserver.c. Please see this as ALPHA software. There is no
documentation, and it is not tested enough. But it might be useful for
you.
ncpfs-0.12 -> ncpfs-0.13
- support for automatic loading of ncpfs.o by kerneld.
Thanks to Steven N. Hirsch <hirsch@emba.uvm.edu>.
- A subtle problem in the read routines has been removed by Uwe Bonnes
<bon@elektron.ikp.physik.th-darmstadt.de>. Thanks a lot.

View File

@@ -2,13 +2,12 @@
# Makefile for the linux ncp-filesystem routines.
#
# KERNEL = 1.2
VERSION = 0.16
TOPDIR = $(shell pwd)
BINDIR = /usr/local/bin
INTERM_BINDIR = $(TOPDIR)/bin
SUBDIRS = util ipx-0.75 man
SUBDIRS = util ipx-1.0 man
#
# The following 2 lines are for those who use Kernel version 1.2.x.
@@ -16,10 +15,14 @@ SUBDIRS = util ipx-0.75 man
# the following lines. You have to recompile your kernel
# and say 'y' when 'make config' asks you for IPX and ncpfs.
#
SUBDIRS += kernel-1.2/src
INCLUDES = -I$(TOPDIR)/kernel-1.2
#SUBDIRS += kernel-1.2/src
#INCLUDES = -I$(TOPDIR)/kernel-1.2
export INCLUDES BINDIR INTERM_BINDIR
# If you are using kerneld to autoload ncp support,
# uncomment this (kerneld is in linux since about 1.3.57):
# KERNELD = -DHAVE_KERNELD
export INCLUDES BINDIR INTERM_BINDIR KERNELD VERSION
all:
for i in $(SUBDIRS); do make -C $$i; done
@@ -37,7 +40,7 @@ clean:
rm -f `find . -type f -name '*.out' -print`
for i in $(SUBDIRS); do make -C $$i clean; done
realclean: clean
mrproper: clean
rm -fr $(INTERM_BINDIR)/* ncpfs.tgz
make -C util realclean
@@ -51,7 +54,7 @@ dist: tgz
make dep
make all
tgz: realclean
tgz: mrproper
(cd ..; \
tar cvf - $(SRCDIR) | \
gzip -9 > $(DISTFILE); \

14
README
View File

@@ -1,11 +1,7 @@
This is version 0.11 of ncpfs, a free NetWare client filesystem for
Linux.
I would like to invite you to write documentation. As those whose
native tongue is English might have noticed, my C is better than my
English. So I doubt that everything in the man/ subdirectory is
written very well. Please feel free to send me any comments about
that.
This is ncpfs, a free NetWare client filesystem for Linux. Besides
some little utilities it also contains nprint, which enables you to
print on NetWare print queues. The opposite side, pserver, is also
provided.
INSTALLATION
@@ -74,7 +70,7 @@ I do not want to leave those unmentioned, who have helped me with
ncpfs.
The most enthusiastic user and tester is certainly Uwe Bonnes
<bon@elektron.ikp.physik.th-darmstadt.de>. Up to now he's the only one
<bon@elektron.ikp.physik.th-darmstadt.de>. So far he's the only one
who has contributed something, namely manpages and corretions to
existing manpages.

9
ipx-1.0/COPYING Normal file
View File

@@ -0,0 +1,9 @@
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the original work is
properly attributed to Greg Page and Caldera, Inc.
Neither the name of Greg Page nor Caldera, Inc. may be used to
endorse or promote products derived from this software without
specific prior written permission.
This software is provided by Greg Page and Caldera, Inc. "AS IS"
and without any express or implied warranties.

24
ipx-1.0/Gregs.Makefile Normal file
View File

@@ -0,0 +1,24 @@
CFLAGS = -O2 -Wall
UTILS = ipx_configure ipx_interface ipx_internal_net ipx_route
all: $(UTILS)
clean:
rm -f $(UTILS) *.o rip sap ipxrcv ipxsend
install: $(UTILS)
for i in $(UTILS); \
do \
install --strip $$i /sbin; \
install $$i.8 /usr/man/man8; \
done
install init.ipx /etc/rc.d/init.d/ipx
install -m 0644 config.ipx /etc/sysconfig/ipx
rm -f /etc/rc.d/rc2.d/S15ipx
ln -sf /etc/rc.d/init.d/ipx /etc/rc.d/rc2.d/S15ipx
rm -f /etc/rc.d/rc3.d/S15ipx
ln -sf /etc/rc.d/init.d/ipx /etc/rc.d/rc3.d/S15ipx
rm -f /etc/rc.d/rc5.d/S15ipx
ln -sf /etc/rc.d/init.d/ipx /etc/rc.d/rc5.d/S15ipx
rm -f /etc/rc.d/rc6.d/K55ipx
ln -sf /etc/rc.d/init.d/ipx /etc/rc.d/rc6.d/K55ipx

View File

@@ -25,6 +25,6 @@ clean:
install: $(UTILS)
for i in $(UTILS); \
do \
install --strip $$i $(BINDIR); \
install $$i $(BINDIR); \
done

View File

@@ -47,7 +47,7 @@ This program is used to read/write two configuration parameters:
By default, these are both turned off.
The following are sample IPX programs:
The following are sample IPX programs (found in directory Samples):
ipxrcv.c and ipxsend.c
ipxsend will send a single packet to an instance of ipxrcv running on the

View File

@@ -51,7 +51,7 @@ main(int argc, char **argv)
htonl(sipx.sipx_network),
sipx.sipx_node[0], sipx.sipx_node[1],
sipx.sipx_node[2], sipx.sipx_node[3],
sipx.sipx_node[4], sipx.sipx_node[5]);
sipx.sipx_node[6], sipx.sipx_node[5]);
bptr += 2;
rp = (struct rip_data *) bptr;
while (result >= sizeof(struct rip_data)) {

7
ipx-1.0/config.ipx Normal file
View File

@@ -0,0 +1,7 @@
IPX_AUTO_PRIMARY=on
IPX_AUTO_INTERFACE=on
IPX_CONFIGURED=no
IPX_DEVICE=eth0
IPX_FRAME=802.2
IPX_INTERNAL_NET=no
IPX_NETNUM=0

41
ipx-1.0/init.ipx Normal file
View File

@@ -0,0 +1,41 @@
#!/bin/sh
#
# ipx Bring up/down IPX networking
#
# Source function library.
. /etc/rc.d/init.d/functions
. /etc/sysconfig/network
. /etc/sysconfig/ipx
# Check that networking is up.
[ ${NETWORKING} = "no" ] && exit 0
# See how we were called.
case "$1" in
start)
if [ ${IPX_CONFIGURED} = "yes" ]; then
if [ ${IPX_INTERNAL_NET} = "yes" ]; then
/sbin/ipx_internal_net add ${IPX_NETNUM}
else
/sbin/ipx_interface add -p ${IPX_DEVICE} \
${IPX_FRAME} ${IPX_NETNUM}
fi
fi
ipx_configure \
--auto_primary=${IPX_AUTO_PRIMARY} \
--auto_interface=${IPX_AUTO_INTERFACE}
touch /var/lock/subsys/ipx
;;
stop)
ipx_configure --auto_primary=off --auto_interface=off
ipx_interface delall
rm -f /var/lock/subsys/ipx
;;
*)
echo "Usage: network {start|stop}"
exit 1
esac
exit 0

View File

@@ -1,3 +1,8 @@
/* Copyright (c) 1995-1996 Caldera, Inc. All Rights Reserved.
*
* See file COPYING for details.
*/
#include <stdio.h>
#include <unistd.h>
#include <ctype.h>

View File

@@ -1,3 +1,8 @@
/* Copyright (c) 1995-1996 Caldera, Inc. All Rights Reserved.
*
* See file COPYING for details.
*/
#include <stdio.h>
#include <ctype.h>
#include <errno.h>
@@ -19,7 +24,8 @@ usage(void)
{
fprintf(stderr, "Usage: %s add [-p] device frame_type [net_number]\n\
Usage: %s del device frame_type\n\
Usage: %s check device frame_type\n", progname, progname, progname);
Usage: %s delall\n\
Usage: %s check device frame_type\n", progname, progname, progname, progname);
exit(-1);
}
@@ -28,6 +34,9 @@ struct frame_type {
unsigned char ft_val;
} frame_types[] = {
{"802.2", IPX_FRAME_8022},
#ifdef IPX_FRAME_TR_8022
{"802.2TR", IPX_FRAME_TR_8022},
#endif
{"802.3", IPX_FRAME_8023},
{"SNAP", IPX_FRAME_SNAP},
{"EtherII", IPX_FRAME_ETHERII}
@@ -162,6 +171,76 @@ ipx_add_interface(int argc, char **argv)
exit(-1);
}
int
ipx_delall_interface(int argc, char **argv)
{
struct sockaddr_ipx *sipx = (struct sockaddr_ipx *)&id.ifr_addr;
int s;
int result;
char errmsg[80];
char buffer[80];
char device[20];
char frame_type[20];
int fti;
FILE *fp;
s = socket(AF_IPX, SOCK_DGRAM, AF_IPX);
if (s < 0) {
sprintf(errmsg, "%s: socket", progname);
perror(errmsg);
exit(-1);
}
fp = fopen("/proc/net/ipx_interface", "r");
if (fp == NULL) {
fprintf(stderr,
"%s: Unable to open \"/proc/net/ipx_interface.\"\n",
progname);
exit(-1);
}
fgets(buffer, 80, fp);
while (fscanf(fp, "%s %s %s %s %s", buffer, buffer, buffer,
device, frame_type) == 5) {
sipx->sipx_network = 0L;
if (strcasecmp(device, "Internal") == 0) {
sipx->sipx_special = IPX_INTERNAL;
} else {
sipx->sipx_special = IPX_SPECIAL_NONE;
strcpy(id.ifr_name, device);
fti = lookup_frame_type(frame_type);
if (fti < 0) continue;
sipx->sipx_type = frame_types[fti].ft_val;
}
sipx->sipx_action = IPX_DLTITF;
sipx->sipx_family = AF_IPX;
result = ioctl(s, SIOCSIFADDR, &id);
if (result == 0) continue;
switch (errno) {
case EPROTONOSUPPORT:
fprintf(stderr, "%s: Invalid frame type (%s).\n",
progname, frame_type);
break;
case ENODEV:
fprintf(stderr, "%s: No such device (%s).\n",
progname, device);
break;
case EINVAL:
fprintf(stderr, "%s: No such IPX interface %s %s.\n",
progname, device, frame_type);
break;
default:
sprintf(errmsg, "%s: ioctl", progname);
perror(errmsg);
break;
}
}
exit(0);
}
int
ipx_del_interface(int argc, char **argv)
{
@@ -176,6 +255,7 @@ ipx_del_interface(int argc, char **argv)
}
sipx->sipx_network = 0L;
sipx->sipx_special = IPX_SPECIAL_NONE;
strcpy(id.ifr_name, argv[1]);
fti = lookup_frame_type(argv[2]);
if (fti < 0)
@@ -289,6 +369,10 @@ main(int argc, char **argv)
for (i = 1; i < (argc-1); i++)
argv[i] = argv[i+1];
ipx_add_interface(argc-1, argv);
} else if (strncasecmp(argv[1], "delall", 6) == 0) {
for (i = 1; i < (argc-1); i++)
argv[i] = argv[i+1];
ipx_delall_interface(argc-1, argv);
} else if (strncasecmp(argv[1], "del", 3) == 0) {
for (i = 1; i < (argc-1); i++)
argv[i] = argv[i+1];

View File

@@ -1,3 +1,8 @@
/* Copyright (c) 1995-1996 Caldera, Inc. All Rights Reserved.
*
* See file COPYING for details.
*/
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>

View File

@@ -1,3 +1,8 @@
/* Copyright (c) 1995-1996 Caldera, Inc. All Rights Reserved.
*
* See file COPYING for details.
*/
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>

View File

@@ -3,7 +3,7 @@
#
CFLAGS = -Wall -Wstrict-prototypes -O2 -DMODULE -fomit-frame-pointer \
$(INCLUDES) \
$(INCLUDES) -DNCPFS_VERSION=\"$(VERSION)\"\
# -DDEBUG_NCP=1 -DDEBUG_NCP_MALLOC
# -DDEBUG_NCP_MALLOC

View File

@@ -567,6 +567,7 @@ ncp_init_root(struct ncp_server *server)
root->finfo.opened = 0;
i->attributes = aDIR;
i->dataStreamSize = 1024;
i->volNumber = NCP_NUMBER_OF_VOLUMES+1; /* illegal volnum */
ncp_date_unix2dos(0, &(i->creationTime), &(i->creationDate));
ncp_date_unix2dos(0, &(i->modifyTime), &(i->modifyDate));
ncp_date_unix2dos(0, &dummy, &(i->lastAccessDate));
@@ -624,6 +625,7 @@ ncp_find_inode(struct inode *dir, const char *name)
do
{
if ( (result->dir->finfo.i.DosDirNum == dir_info->DosDirNum)
&& (result->dir->finfo.i.volNumber == dir_info->volNumber)
&& (strcmp(result->finfo.i.entryName, name) == 0))
{
return result;
@@ -645,6 +647,8 @@ ncp_lookup(struct inode *dir, const char *__name, int len,
struct ncp_inode_info *result_info;
int found_in_cache;
char name[len+1];
*result = NULL;
if (!dir || !S_ISDIR(dir->i_mode))
@@ -687,7 +691,10 @@ ncp_lookup(struct inode *dir, const char *__name, int len,
}
}
result_info = ncp_find_inode(dir, __name);
memcpy(name, __name, len);
name[len] = 0;
result_info = ncp_find_inode(dir, name);
if (result_info != 0)
{
@@ -726,7 +733,7 @@ ncp_lookup(struct inode *dir, const char *__name, int len,
DDPRINTK("ncp_lookup: trying index: %d, name: %s\n",
i, c_entry[i].i.entryName);
if (strcmp(c_entry[i].i.entryName, __name) == 0)
if (strcmp(c_entry[i].i.entryName, name) == 0)
{
DPRINTK("ncp_lookup: found in cache!\n");
finfo.i = c_entry[i].i;
@@ -740,20 +747,15 @@ ncp_lookup(struct inode *dir, const char *__name, int len,
if (found_in_cache == 0)
{
char this_name[len+1];
memcpy(this_name, __name, len);
this_name[len] = 0;
str_upper(this_name);
str_upper(name);
DDPRINTK("ncp_lookup: do_lookup on %s/%s\n",
NCP_ISTRUCT(dir)->entryName, this_name);
NCP_ISTRUCT(dir)->entryName, name);
if (ncp_do_lookup(server,
dir->i_ino == (int)&(NCP_SERVER(dir)->root)
? NULL : NCP_ISTRUCT(dir),
this_name,
&(finfo.i)) != 0)
name, &(finfo.i)) != 0)
{
iput(dir);
return -ENOENT;
@@ -795,7 +797,8 @@ ncp_create(struct inode *dir, const char *name, int len, int mode,
if (ncp_open_create_file_or_subdir(NCP_SERVER(dir),
NCP_ISTRUCT(dir), _name,
OC_MODE_CREATE|OC_MODE_OPEN,
OC_MODE_CREATE|OC_MODE_OPEN|
OC_MODE_REPLACE,
0, AR_READ|AR_WRITE,
&finfo) != 0)
{
@@ -893,7 +896,7 @@ ncp_rmdir(struct inode *dir, const char *name, int len)
}
else
{
error = -EINVAL;
error = -EACCES;
}
}
iput(dir);
@@ -930,7 +933,7 @@ ncp_unlink(struct inode *dir, const char *name, int len)
}
else
{
error = -EINVAL;
error = -EACCES;
}
}
iput(dir);

View File

@@ -510,6 +510,7 @@ init_module( void)
ncp_init_dir_cache();
register_filesystem(&ncp_fs_type);
printk("ncpfs version %s loaded\n", NCPFS_VERSION);
return 0;
}

View File

@@ -417,12 +417,18 @@ ncp_open_create_file_or_subdir(struct ncp_server *server,
struct nw_file_info *target)
{
int result;
__u16 search_attribs = 0x0006;
if ((create_attributes & aDIR) != 0)
{
search_attribs |= 0x8000;
}
ncp_init_request(server);
ncp_add_byte(server, 1); /* subfunction */
ncp_add_byte(server, 0); /* dos name space */
ncp_add_byte(server, open_create_mode);
ncp_add_word(server, 0x8006);
ncp_add_word(server, search_attribs);
ncp_add_dword(server, RIM_ALL);
ncp_add_dword(server, create_attributes);
/* The desired acc rights seem to be the inherited rights mask
@@ -583,7 +589,7 @@ ncp_read(struct ncp_server *server, const char *file_id,
*bytes_read = ntohs(ncp_reply_word(server, 0));
memcpy_tofs(target, ncp_reply_data(server, 2), *bytes_read);
memcpy_tofs(target, ncp_reply_data(server, 2+(offset&1)), *bytes_read);
ncp_unlock_server(server);
return 0;

View File

@@ -9,6 +9,9 @@ add [-p] device frame_type [network number]
del device frame_type
.LP
.B ipx_interface
delall
.LP
.B ipx_interface
check device frame_type
.LP
.B ipx_interface
@@ -45,6 +48,9 @@ network.
.I del
This option is used to delete an IPX interface.
.TP
.I delall
This option is used to delete all IPX interfaces.
.TP
.I check
This option is used to display the device, frame type, and network number
of an IPX interface.

View File

@@ -1,27 +1,27 @@
.TH NCPMOUNT 8 12/27/1995 ncpmount ncpmount
.SH NAME
ncpmount \- mount program for ncpfs
ncpmount \- mount all volumes of a specified Novell fileserver.
.SH SYNOPSIS
.B ncpmount
[
.B -h
] [
.B -S
.I server
] [
.B -h
] [
.B -n
.B -U
.I user name
] [
.B -P
.I password
|
.B -n
] [
.B -C
] [
.B -c
.I client name
] [
.B -U
.I user name
] [
.B -u
.I uid
] [
@@ -33,14 +33,17 @@ ncpmount \- mount program for ncpfs
] [
.B -d
.I dir mode
]
] [
.B -v
]
mount-point
.SH DESCRIPTION
This program is an interface to the NCP filesystem.
This program is used to mount all volumes of the specified NetWare Fileserver
under the specified mount point.
.B ncpfs
is a filesystem which understands the NCP protocol. This is the
is a linux filesystem which understands the NCP protocol. This is the
protocol Novell NetWare clients use to talk to NetWare servers. ncpfs
was inspired by
.B lwared,
@@ -48,18 +51,23 @@ a free NetWare emulator for Linux written by Ales Dryak. See
ftp://klokan.sh.cvut.cz/pub/linux for this very intersting program.
.B ncpmount
looks up the file
when invoked with all appropriate arguments attaches, logs in and
mounts all of the volumes associated with the specified fileserver that are
readable by the user id under the specified mount point.
.B ncpmount
when invoked without any arguments specifying the fileserver, user id and
password checks the file
.I $HOME/.nwclient
to find a file server, a user name and possibly a password. See
nwclient(5) for more information. Please note that the access
permissions of .nwclient MUST be 600, for security reasons.
to find a file server, a user name and possibly a password to use for the
specified mount point. See nwclient(5) for more information. Please note
that the access permissions of .nwclient MUST be 600, for security reasons.
.SH OPTIONS
.B mount-point
.RS 3
.B mount-point
is the directory you want to mount the filesystem over. It's the same
as in the normal mount command.
is the directory you want to mount the filesystem over. Its function is the
the same as for a normal mount command.
If the real uid of the caller is not root,
.B ncpmount
@@ -87,42 +95,40 @@ is used to print out a short help text.
.B -C
.RS 3
By default, passwords are converted to uppercase before they are sent
to the server, because most servers require this. You can turn off
this conversion by
.B -C.
By default passwords are converted to uppercase before they are sent
to the server because most servers require this. This option disables this
feature ensuring that passwords are sent without any case conversion.
.RE
.B -n
.RS 3
.B -n
should be given to mount shares which do not require a password to log in.
must be specified for logins that do not have a password configured.
.RE
.B -P
.I password
.RS 3
You may want to give the password required by the server on the
command line. You should be careful to use passwords in scripts.
specifies the password to use for the Netware user id.
If neither
.B -n
nor
nor the
.B -P
are given, ncpmount prompts for a password. This makes it difficult to
use in scripts such as /etc/rc. But that's not ncpmount's fault, but a
general problem with the fact that you need a password on every
login. If anybody has a satisfying solution to this problem, please
tell me.
arguments are specified ncpmount will prompt for a password. This
makes it difficult to use in scripts such as /etc/rc. If you want to
have ncpmount work automatically from a script you must include the
appropriate option and be very careful to ensure that appopriate file
permissions are set for the script that includes your password to
ensure that others can not read it.
.RE
.B -U
.I user name
.RS 3
If the user name your NetWare administrator gave to you differs
from your unix user-id, you should use
.B -U
to tell the server about you NetWare user name.
Specifies the Netware user id to use when logging in to the fileserver. If
this option is not specified then ncpmount will attempt to login to the
fileserver using the Linux login id of the user invoking ncpmount.
.RE
.B -u
@@ -130,9 +136,9 @@ to tell the server about you NetWare user name.
.B -g
.I gid
.RS 3
Currently I did not implement a mapping from NetWare users/groups to
unix users/groups. Unix requires that each file has an owner
and a group it belongs to. With
ncpmount does not yet implement a scheme for mapping NetWare users/groups
to Linux users/groups. Linux requires that each file has an owner and group id.
With
.B -u
and
.B -g
@@ -145,19 +151,20 @@ The defaults for these values are the current uid and gid.
.B -c
.I user name
.RS 3
This option is only makes sense if root mounts the directory. root can
mount directories on behalf of other users.
.B -c
names the user who is the
.I owner
of the connection, where owner is not meant in the unix sense (that
"owner" is set by -u), but as the one who has mounted the directory.
This way it could be possible to mount a public read-only directory,
of the connection, where owner does not refer to file ownership (that
"owner" is set by the -u argument), but the owner of the mount, ie: who
is allowed to call ncpumount on this mount. The default owner of the
connection and the mount is the user who called ncpmount. This option
allows you to specify that some other user should be set as the owner.
In this this way it is possible to mount a public read-only directory,
but to allow the lp daemon to print on NetWare queues. This is
possible, because only users who have write permissions on a directory
may issue ncp requests over a connection. An exception is the owner
(in the sense mentioned above), who is also given 'request
permission'.
possible because only users who have write permissions on a directory
may issue ncp requests over a connection. The exception to this rule
is the 'mount owner', who is also granted 'request permission'.
.RE
.B -f
@@ -169,14 +176,11 @@ Like
.B -u
and
.B -g,
these options are also used to cover deficiencies in the
implementation of ncpfs. I did not implement a scheme to map NetWare
permissions to unix permissions. So ncpmount has to be told which
permissions it should assign to the mounted files and directories. The
values have to be given as octal numbers. The default values are taken
from the current umask, where the file mode is the current umask, and
the dir mode adds execute permissions where the file mode gives read
permissions.
these options are used to determine what permissions should be assigned
files and directories of the mounted volumes. The values must be specified
as octal numbers. The default values are taken from the current umask, where
the file mode is the current umask, and the dir mode adds execute permissions
where the file mode gives read permissions.
Note that these permissions can differ from the rights the server
gives to us. If you do not have write permissions on the server, you
@@ -184,8 +188,15 @@ can very well choose a file mode that tells that you have. This
certainly cannot override the restrictions imposed by the server.
.RE
.B -v
.RS 3
Print ncpfs version number
.RE
.SH NOTES
If you have difficulties in mounting, please make sure that you have configured your ipx subsystem correctly. It is especially important that there is a route to the internal network of your server.
You must configure the IPX subsystem before ncpmount will work.
It is especially important that there is a route to the internal network
of your server.
.SH ENVIRONMENT VARIABLES
.B USER / LOGNAME

View File

@@ -1,13 +1,14 @@
.TH NCPUMOUNT 8 12/27/1995 ncpumount ncpumount
.SH NAME
ncpumount \- umount for normal users
ncpumount \- unmount a NetWare filesystem mounted with ncpmount.
.SH SYNOPSIS
.B ncpumount
.B mount-point
.SH DESCRIPTION
With this program, normal users can unmount ncp-filesystems, provided
that it is suid root.
This utility unmounts a NetWare filesystem that was previously mounted
with the ncpmount utility. If the this utility is made suid root then
non-root users will also be able to make use of it.
.B ncpumount
has been written to give normal linux-users more control over their

View File

@@ -9,18 +9,16 @@ nprint \- NetWare print client
] [
.B -h
] [
.B -n
] [
.B -C
] [
.B -U
.I user name
] [
.B -P
.I password
] [
|
.B -n
] [
.B -C
] [
.B -q
.I queue name
] [
@@ -65,6 +63,13 @@ you can print files on print queues of a NetWare file server.
There are a lot of options, so you should probably wrap some default
configurations into some shell scripts.
.B nprint
looks up the file
.I $HOME/.nwclient
to find a file server, a user name and possibly a password. See
nwclient(5) for more information. Please note that the access
permissions of .nwclient MUST be 600, for security reasons.
.SH OPTIONS
.B file
.RS 3
@@ -73,6 +78,12 @@ is the name of the file you want to print. If file is '-', or no
filename is given, standard input is used.
.RE
.B -h
.RS 3
.B -h
is used to print out a short help text.
.RE
.B -S
.I server
.RS 3
@@ -105,12 +116,20 @@ prompts for a password.
should be given if no password is required for the print request.
.RE
.B -C
.RS 3
By default, passwords are converted to uppercase before they are sent
to the server, because most servers require this. You can turn off
this conversion by
.B -C.
.RE
.B -q
.I queue name
.RS 3
.B queue name
is the name of the print queue to use at the print server. At
present, you must give it in upper case characters.
present, you must specify it in upper case characters.
.RE
.B -d
@@ -161,6 +180,13 @@ is the number of lines to put on one page. Default: 66
is the number of rows to put on one page. Default: 80
.RE
.B -c
.I copies
.RS 3
.B copies
tells the print server to the specified number of copies. Default: 1
.RE
.B -t
.I tabs
.RS 3
@@ -189,4 +215,8 @@ different from the one currently in the printer, your job is only
printed if a printer operator has put in the correct form.
.RE
.SH SEE ALSO
.B nwclient(5), slist(1), pqlist(1), ncpmount(8), ncpumount(8)
.SH CREDITS
nprint was written by Volker Lendecke (lendecke@namu01.gwdg.de)

View File

@@ -13,8 +13,8 @@ connection. Lines beginning with # and empty lines are ignored as
comments.
Because you can store passwords in .nwclient, the user programs will
only scan .nwclient if ONLY the file owner has any access rights to
the file.
only scan .nwclient when only the file owner has access rights to
the file. The file must be have permissions 0600.
To specify a NWClient connection, the name of the file server, the
user name to be used and a password is necessary. The server name and
@@ -40,3 +40,16 @@ the the file server FS311 with user name ME on /mnt after asking the
user for a password.
\'nwmount -S cd-serv /cd' will silently mount the server cd-serv on /cd.
.B nprint
,
.B pqlist
and other user programs that require a valid login also look up
.I $HOME/.nwclient
to find a file server, a user name and possibly a password.
Please note that the access permissions of .nwclient MUST be 600, for
security reasons.
.SH SEE ALSO
.B ncpmount(8), ncpumount(8), slist(1), pqlist(1), nprint(1)

View File

@@ -4,25 +4,40 @@ pqlist \- List available NetWare print queues
.SH SYNOPSIS
.B pqlist
[
.B -h
] [
.B -S
.I server
] [
.B -U
.I user name
] [
.B -n
] [
.B -P
.I password
|
.B -n
] [
.B -C
] [
.I pattern
]
.SH DESCRIPTION
With
.B pqlist,
you can list the NetWare print queues available to you on some
server. If you are already connected to some server, this one is
used.
.B pqlist
lists all the NetWare print queues available to you on some server.
If you are already connected to some server, this one is used.
If pqlist does not print to a tty, the decorative header line is
not printed, so that you can count the printing queue available
on your server by doing
pqlist -S server | wc -l
.B pqlist
looks up the file
.I $HOME/.nwclient
to find a file server, a user name and possibly a password. See
nwclient(5) for more information. Please note that the access
permissions of .nwclient MUST be 600, for security reasons.
.SH OPTIONS
@@ -34,6 +49,57 @@ pattern, but you have to be careful to prevent shell interpretation of
wildcards like '*'.
.RE
See ncpmount(8) for an explanation of the other options. They are
necessary because you might have to login into a server before it
tells you where you may print.
.B -h
.RS 3
.B -h
is used to print out a short help text.
.RE
.B -S
.I server
.RS 3
.B server
is the name of the server you want to use.
.RE
.B -U
.I user name
.RS 3
If the user name your NetWare administrator gave to you differs
from your unix user-id, you should use
.B -U
to tell the server about you NetWare user name.
.RE
.B -P
.I password
.RS 3
You may want to give the password required by the server on the
command line. You should be careful to use passwords in scripts.
.RE
.B -n
.RS 3
.B -n
should be given to mount shares which do not require a password to log in.
If neither
.B -n
nor
.B -P
are given, pqlist prompts for a password.
.RE
.B -C
.RS 3
By default, passwords are converted to uppercase before they are sent
to the server, because most servers require this. You can turn off
this conversion by
.B -C.
.RE
.SH SEE ALSO
.B nwclient(5), nprint(1), slist(1), ncpmount(8), ncpumount(8)
.SH CREDITS
pqlist was written by Volker Lendecke (lendecke@namu01.gwdg.de)

142
man/pserver.1 Normal file
View File

@@ -0,0 +1,142 @@
.TH PSERVER 1 02/10/1996 pserver pserver
.SH NAME
pserver \- NetWare print server
.SH SYNOPSIS
.B pserver
[
.B -S
.I server
] [
.B -h
] [
.B -U
.I user name
] [
.B -P
.I password
|
.B -n
] [
.B -C
] [
.B -q
.I queue name
] [
.B -c
.I command
] [
.B -j
.I job type
] [
.B -t
.I timeout
] [
.B -d
]
.SH DESCRIPTION
.B pserver
is a program that connects to print queues on NetWare servers and
feeds incoming print jobs to the Linux printing system.
.SH OPTIONS
.B -h
.RS 3
.B -h
is used to print out a short help text.
.RE
.B -S
.I server
.RS 3
.B server
is the name of the server you want to use.
.RE
.B -U
.I user
.RS 3
.B user
is the print server name at the server.
.RE
.B -P
.I password
.RS 3
.B password
is the password to use for the print server at the server. If neither
.B -n
nor
.B -P
are given, and the user has no open connection to the server, pserver
prompts for a password.
.RE
.B -n
.RS 3
.B -n
should be given if the print server does not require a password.
.RE
.B -C
.RS 3
By default, passwords are converted to uppercase before they are sent
to the server, because most servers require this. You can turn off
this conversion by
.B -C.
.RE
.B -q
.I queue name
.RS 3
.B queue name
is the name of the print queue you want to service.
.RE
.B -c
.I command
.RS 3
When a job is received from the print queue, pserver forks off a new
process, and feeds the job file to stdin.
.I command
is the printing command that is executed for each job. The default
command is 'lpr'.
.RE
.B -j
.I job type
.RS 3
Each job in a NetWare print queue has a job type. For print jobs, this
corresponds to the number of the form the job should be printed
on. You can tell pserver that it should only receive jobs for one
specific form from the queue. The default is -1, which means that
everything is received.
.RE
.B -t
.I timeout
.RS 3
Pserver is not informed by NetWare servers when new jobs arrive. So a
polling scheme has to be used. When there are no jobs to service,
.I timeout
tells pserver how long to wait between two requests. The default is 30
seconds. When a job is finished, pserver asks the NetWare server
immediately for a new job, and does not wait
.I timeout
seconds.
.RE
.B -d
.RS 3
Normally, pserver daemonizes itself.
.B -d
tells it not to do so. This is useful if you want to see the
diagnostic messages that are printed when a error occurs.
.RE
.SH SEE ALSO
.B nwclient(5), slist(1), pqlist(1), ncpmount(8), ncpumount(8)
.SH CREDITS
pserver was written by Volker Lendecke (lendecke@namu01.gwdg.de)

View File

@@ -1,16 +1,16 @@
.TH SLIST 1 01/07/1996 slist slist
.SH NAME
slist \- List available NetWare Servers
slist \- Lists available NetWare Servers
.SH SYNOPSIS
.B slist
[
.I pattern
]
.SH DESCRIPTION
With
.B slist,
you can get a list of NetWare Servers available in your network. If
slist does not print to a tty, the decorative header line is not
.B slist
lists all NetWare Servers available in your network.
If slist does not print to a tty, the decorative header line is not
printed, so that you can count the servers on your network by doing
slist | wc -l
@@ -20,10 +20,10 @@ slist | wc -l
.B pattern
.RS 3
.B pattern
is used to list only selected servers. For a server to be listed, the
pattern must match the full server name. You can use wildcards for the
pattern, but you must protect these wildcards from any command line
expansion by quoting. Case doesn't matter.
is used to list only servers whose names match the specified pattern. For a
server to be listed, the pattern must match the full server name. You can use
wildcards for the pattern, but you must protect these wildcards from any
command line expansion by quoting. Case doesn't matter.
.RE
.SH EXAMPLE
@@ -34,3 +34,10 @@ or
.TP
slist "i*"
List all available Netware servers on your Network, that begin with an "I".
.SH SEE ALSO
.B ncpmount(8), ncpumount(8), pqlist(1), nprint(1)
.SH CREDITS
slist was written by Volker Lendecke (lendecke@namu01.gwdg.de)

View File

@@ -1,17 +0,0 @@
Begin3
Title: ncpfs
Version: 0.11
Entered-date: 10. January 1996
Description: With ncpfs you can mount volumes of your novell
server under Linux. You need kernel 1.2.x or
1.3.54 and above. ncpfs does NOT work with any 1.3.x
kernel below 1.3.54.
Keywords: filesystem kernel ncp novell netware
Author: lendecke@namu01.gwdg.de (Volker Lendecke)
Maintained-by: lendecke@namu01.gwdg.de (Volker Lendecke)
Primary-site: linux01.gwdg.de:/pub/ncpfs
Alternate-site: sunsite.unc.edu:/pub/system/Filesystems/
~66k ncpfs-0.11.tgz
~ 1k ncpfs-0.11.lsm
Copying-policy: GPL
End

19
ncpfs-0.16.lsm Normal file
View File

@@ -0,0 +1,19 @@
Begin3
Title: ncpfs
Version: 0.16
Entered-date: 21. February 1996
Description: With ncpfs you can mount volumes of your netware
server under Linux. You can also print to netware
print queues and spool netware print queues to the
Linux printing system. You need kernel 1.2.x or
1.3.54 and above. ncpfs does NOT work with any 1.3.x
kernel below 1.3.54.
Keywords: filesystem ncp novell netware printing
Author: lendecke@namu01.gwdg.de (Volker Lendecke)
Maintained-by: lendecke@namu01.gwdg.de (Volker Lendecke)
Primary-site: linux01.gwdg.de:/pub/ncpfs
Alternate-site: sunsite.unc.edu:/pub/system/Filesystems/
~73k ncpfs-0.16.tgz
~ 1k ncpfs-0.16.lsm
Copying-policy: GPL
End

View File

@@ -2,11 +2,12 @@
# Makefile for the linux ncp-filesystem routines.
#
UTIL_EXECS = ncpmount ncpumount nprint slist pqlist
UTIL_EXECS = ncpmount ncpumount nprint slist pqlist fsinfo pserver
UTILS = $(addprefix $(INTERM_BINDIR)/,$(UTIL_EXECS))
UIDUTILS = ncpmount ncpumount
CFLAGS = -Wall $(INCLUDES) -O2
#CFLAGS = -Wall $(INCLUDES) $(KERNELD) -g -DNCPFS_VERSION=\"$(VERSION)\"
CFLAGS = -Wall $(INCLUDES) $(KERNELD) -O2 -DNCPFS_VERSION=\"$(VERSION)\"
CC = gcc
all: $(UTILS) ncptest

View File

@@ -8,14 +8,14 @@
*/
#include <stdio.h>
#include <unistd.h>
#include "ncplib.h"
int
main(int argc, char **argv)
{
struct ncp_conn conn;
char strings[512];
char *s;
int opt;
if (ncp_initialize(&conn, &argc, argv, 0) != 0)
{
@@ -23,22 +23,54 @@ main(int argc, char **argv)
return 1;
}
if (ncp_get_file_server_description_strings(&conn, strings) != 0)
while ((opt = getopt(argc, argv, "dt")) != EOF)
{
perror("could not get strings");
ncp_close(&conn);
return 1;
}
s = strings;
while (s < strings+512)
{
if (strlen(s) == 0)
switch(opt)
{
case 'd':
{
char strings[512];
char *s;
if (ncp_get_file_server_description_strings(&conn,
strings)
!= 0)
{
perror("could not get strings");
ncp_close(&conn);
return 1;
}
s = strings;
while (s < strings+512)
{
if (strlen(s) == 0)
{
break;
}
puts(s);
s += strlen(s)+1;
}
break;
}
case 't':
{
time_t t;
if (ncp_get_file_server_time(&conn, &t) != 0)
{
perror("could not get server time");
ncp_close(&conn);
return 1;
}
fputs(ctime(&t), stdout);
break;
}
default:
printf("unknown option: %c\n", opt);
break;
}
puts(s);
s += strlen(s)+1;
}
ncp_close(&conn);

View File

@@ -34,8 +34,13 @@ extern pid_t wait(int *);
static int
ncp_negotiate_buffersize(struct ncp_conn *conn,
int size, int *target);
static int
ncp_login_object(struct ncp_conn *conn,
const unsigned char *username,
int login_type,
const unsigned char *password);
static void
void
str_upper(char *name)
{
while (*name) {
@@ -837,7 +842,8 @@ ncp_open_temporary(struct ncp_conn *conn,
if (strlen(spec->user) != 0)
{
if (ncp_login_user(conn, spec->user, spec->password) != 0)
if (ncp_login_object(conn, spec->user, spec->login_type,
spec->password) != 0)
{
ncp_close(conn);
errno = EACCES;
@@ -1195,6 +1201,7 @@ ncp_find_conn_spec(const char *server, const char *user, const char *password,
str_upper(spec.server);
str_upper(spec.user);
spec.login_type = NCP_BINDERY_USER;
if (ncp_open_permanent(&conn, &spec) == 0)
{
@@ -1230,35 +1237,36 @@ ncp_find_conn_spec(const char *server, const char *user, const char *password,
}
fclose(nwc);
}
}
if (strlen(spec.user) == 0)
if (strlen(spec.user) == 0)
{
return &spec;
}
if (strlen(spec.password) == 0)
{
char *password;
if (!(isatty(0) && isatty(1)))
{
return &spec;
return NULL;
}
printf("Logging into %s as %s\n",
spec.server, spec.user);
if (strlen(spec.password) == 0)
password = getpass("Password: ");
if (strlen(password) > sizeof(spec.password))
{
char *password;
if (!(isatty(0) && isatty(1)))
{
return NULL;
}
printf("Logging into %s as %s\n",
spec.server, spec.user);
password = getpass("Password: ");
if (strlen(password) > sizeof(spec.password))
{
return NULL;
}
strcpy(spec.password, password);
return NULL;
}
else
strcpy(spec.password, password);
}
else
{
if (strcmp(spec.password, NWC_NOPASSWORD) == 0)
{
if (strcmp(spec.password, NWC_NOPASSWORD) == 0)
{
*spec.password = '\0';
}
*spec.password = '\0';
}
}
@@ -1269,9 +1277,9 @@ ncp_find_conn_spec(const char *server, const char *user, const char *password,
}
int
ncp_initialize(struct ncp_conn *conn,
int *argc, char **argv,
int login_necessary)
ncp_initialize_as(struct ncp_conn *conn,
int *argc, char **argv,
int login_necessary, int login_type)
{
char *server = NULL;
char *user = NULL;
@@ -1306,6 +1314,7 @@ ncp_initialize(struct ncp_conn *conn,
}
errno = EINVAL;
memzero(*conn);
while (i < *argc)
{
@@ -1341,6 +1350,7 @@ ncp_initialize(struct ncp_conn *conn,
{
return -1;
}
password = NWC_NOPASSWORD;
continue;
}
i += 1;
@@ -1360,9 +1370,20 @@ ncp_initialize(struct ncp_conn *conn,
errno = 0;
spec->login_type = login_type;
return ncp_open(conn, spec);
}
int
ncp_initialize(struct ncp_conn *conn,
int *argc, char **argv,
int login_necessary)
{
return ncp_initialize_as(conn, argc, argv, login_necessary,
NCP_BINDERY_USER);
}
static int
ncp_request(struct ncp_conn *conn, int function)
{
@@ -1376,12 +1397,49 @@ ncp_request(struct ncp_conn *conn, int function)
return -ENOTCONN;
}
/****************************************************************************/
/* */
/* Helper functions */
/* */
/****************************************************************************/
static inline int
min(int a, int b)
{
return (a<b) ? a : b;
}
struct nw_time_buffer {
__u8 year __attribute__ ((packed));
__u8 month __attribute__ ((packed));
__u8 day __attribute__ ((packed));
__u8 hour __attribute__ ((packed));
__u8 minute __attribute__ ((packed));
__u8 second __attribute__ ((packed));
__u8 wday __attribute__ ((packed));
};
static time_t
nw_to_ctime(struct nw_time_buffer *source)
{
struct tm u_time;
memzero(u_time);
u_time.tm_sec = source->second;
u_time.tm_min = source->minute;
u_time.tm_hour = source->hour;
u_time.tm_mday = source->day;
u_time.tm_mon = source->month - 1;
u_time.tm_year = source->year;
if (u_time.tm_year < 80)
{
u_time.tm_year += 100;
}
return mktime(&u_time);
}
static void
assert_conn_locked(struct ncp_conn *conn)
{
@@ -1527,6 +1585,50 @@ ncp_get_file_server_description_strings(struct ncp_conn *conn,
return 0;
}
int
ncp_get_file_server_time(struct ncp_conn *conn, time_t *target)
{
int result;
ncp_init_request(conn);
if ((result = ncp_request(conn, 20)) != 0)
{
ncp_unlock_conn(conn);
return result;
}
*target= nw_to_ctime((struct nw_time_buffer *)ncp_reply_data(conn, 0));
ncp_unlock_conn(conn);
return 0;
}
int
ncp_get_connlist(struct ncp_conn *conn, __u32 last_id,
__u16 object_type, const char *object_name,
int *returned_no, __u16 conn_numbers[256])
{
int result;
ncp_init_request_s(conn, 27);
ncp_add_dword(conn, htonl(last_id));
ncp_add_word(conn, htons(object_type));
ncp_add_pstring(conn, object_name);
if ((result = ncp_request(conn, 23)) != 0)
{
ncp_unlock_conn(conn);
return result;
}
*returned_no = ncp_reply_byte(conn, 0);
memcpy(conn_numbers, ncp_reply_data(conn, 1),
sizeof(__u16) * (*returned_no));
return 0;
}
/*
* result is a 8-byte buffer
*/
@@ -1671,6 +1773,15 @@ int
ncp_login_user(struct ncp_conn *conn,
const unsigned char *username,
const unsigned char *password)
{
return ncp_login_object(conn, username, NCP_BINDERY_USER, password);
}
static int
ncp_login_object(struct ncp_conn *conn,
const unsigned char *username,
int login_type,
const unsigned char *password)
{
int result;
unsigned char ncp_key[8];
@@ -1680,7 +1791,7 @@ ncp_login_user(struct ncp_conn *conn,
return result;
}
if ((result = ncp_get_bindery_object_id(conn, NCP_BINDERY_USER,
if ((result = ncp_get_bindery_object_id(conn, login_type,
username, &user)) != 0) {
return result;
}
@@ -2272,14 +2383,22 @@ ncp_open_create_file_or_subdir(struct ncp_conn *conn,
int
ncp_initialize_search(struct ncp_conn *conn,
struct nw_info_struct *dir,
struct nw_search_sequence *target)
const struct nw_info_struct *dir,
int namespace,
struct ncp_search_seq *target)
{
int result;
if ((namespace < 0) || (namespace > 255))
{
return EINVAL;
}
memzero(*target);
ncp_init_request(conn);
ncp_add_byte(conn, 2); /* subfunction */
ncp_add_byte(conn, 0); /* dos name space */
ncp_add_byte(conn, namespace);
ncp_add_byte(conn, 0); /* reserved */
ncp_add_handle_path(conn, dir->volNumber,
dir->DosDirNum, 1, NULL);
@@ -2289,7 +2408,8 @@ ncp_initialize_search(struct ncp_conn *conn,
return result;
}
memcpy(target, ncp_reply_data(conn, 0), sizeof(*target));
memcpy(&(target->s), ncp_reply_data(conn, 0), sizeof(target->s));
target->namespace = namespace;
ncp_unlock_conn(conn);
return 0;
@@ -2298,18 +2418,18 @@ ncp_initialize_search(struct ncp_conn *conn,
/* Search for everything */
int
ncp_search_for_file_or_subdir(struct ncp_conn *conn,
struct nw_search_sequence *seq,
struct ncp_search_seq *seq,
struct nw_info_struct *target)
{
int result;
ncp_init_request(conn);
ncp_add_byte(conn, 3); /* subfunction */
ncp_add_byte(conn, 0); /* dos name space */
ncp_add_byte(conn, seq->namespace);
ncp_add_byte(conn, 0); /* data stream (???) */
ncp_add_word(conn, 0xffff); /* Search attribs */
ncp_add_dword(conn, RIM_ALL); /* return info mask */
ncp_add_mem(conn, seq, 9);
ncp_add_mem(conn, &(seq->s), 9);
ncp_add_byte(conn, 2); /* 2 byte pattern */
ncp_add_byte(conn, 0xff); /* following is a wildcard */
ncp_add_byte(conn, '*');
@@ -2384,7 +2504,6 @@ ncp_create_queue_job_and_file(struct ncp_conn *conn,
}
memcpy(&(job->j), ncp_reply_data(conn, 0), 78);
ConvertToNWfromDWORD(job->j.JobFileHandle, job->file_handle);
ncp_unlock_conn(conn);
@@ -2409,7 +2528,106 @@ ncp_close_file_and_start_job(struct ncp_conn *conn,
ncp_unlock_conn(conn);
return 0;
}
}
int
ncp_attach_to_queue(struct ncp_conn *conn,
__u32 queue_id)
{
int result;
ncp_init_request_s(conn, 111);
ncp_add_dword(conn, htonl(queue_id));
if ((result = ncp_request(conn, 23)) != 0) {
ncp_unlock_conn(conn);
return result;
}
ncp_unlock_conn(conn);
return 0;
}
int
ncp_detach_from_queue(struct ncp_conn *conn,
__u32 queue_id)
{
int result;
ncp_init_request_s(conn, 112);
ncp_add_dword(conn, htonl(queue_id));
if ((result = ncp_request(conn, 23)) != 0) {
ncp_unlock_conn(conn);
return result;
}
ncp_unlock_conn(conn);
return 0;
}
int
ncp_service_queue_job(struct ncp_conn *conn, __u32 queue_id, __u16 job_type,
struct queue_job *job)
{
int result;
ncp_init_request_s(conn, 124);
ncp_add_dword(conn, htonl(queue_id));
ncp_add_word(conn, htons(job_type));
if ((result = ncp_request(conn, 23)) != 0) {
ncp_unlock_conn(conn);
return result;
}
memcpy(&(job->j), ncp_reply_data(conn, 0), 78);
ConvertToNWfromDWORD(job->j.JobFileHandle, job->file_handle);
ncp_unlock_conn(conn);
return 0;
}
int
ncp_finish_servicing_job(struct ncp_conn *conn, __u32 queue_id,
__u32 job_number, __u32 charge_info)
{
int result;
ncp_init_request_s(conn, 131);
ncp_add_dword(conn, htonl(queue_id));
ncp_add_dword(conn, job_number);
ncp_add_dword(conn, htonl(charge_info));
if ((result = ncp_request(conn, 23)) != 0) {
ncp_unlock_conn(conn);
return result;
}
ncp_unlock_conn(conn);
return 0;
}
int
ncp_abort_servicing_job(struct ncp_conn *conn, __u32 queue_id,
__u32 job_number)
{
int result;
ncp_init_request_s(conn, 132);
ncp_add_dword(conn, htonl(queue_id));
ncp_add_dword(conn, job_number);
if ((result = ncp_request(conn, 23)) != 0) {
ncp_unlock_conn(conn);
return result;
}
ncp_unlock_conn(conn);
return 0;
}
static int
ncp_do_read(struct ncp_conn *conn, const char *file_id,
@@ -2523,3 +2741,68 @@ ncp_write(struct ncp_conn *conn, const char *file_id,
}
return already_written;
}
int
ncp_get_broadcast_message(struct ncp_conn *conn, char message[256])
{
int result;
int length;
ncp_init_request_s(conn, 1);
if ((result = ncp_request(conn, 21)) != 0)
{
ncp_unlock_conn(conn);
return result;
}
length = ncp_reply_byte(conn, 0);
message[length] = 0;
memcpy(message, ncp_reply_data(conn, 1), length);
ncp_unlock_conn(conn);
return 0;
}
int
ncp_dealloc_dir_handle(struct ncp_conn *conn, __u8 dir_handle)
{
int result;
ncp_init_request_s(conn, 20);
ncp_add_byte(conn, dir_handle);
if ((result = ncp_request(conn, 22)) != 0)
{
ncp_unlock_conn(conn);
return result;
}
ncp_unlock_conn(conn);
return 0;
}
int
ncp_alloc_short_dir_handle(struct ncp_conn *conn,
struct nw_info_struct *dir,
word alloc_mode,
byte *target)
{
int result;
ncp_init_request(conn);
ncp_add_byte(conn, 12); /* subfunction */
ncp_add_byte(conn, 0); /* dos name space */
ncp_add_byte(conn, 0); /* reserved */
ncp_add_word(conn, htons(alloc_mode));
ncp_add_handle_path(conn, dir->volNumber, dir->DosDirNum,
1, NULL);
if ((result = ncp_request(conn, 87)) != 0)
{
ncp_unlock_conn(conn);
return result;
}
*target = ncp_reply_byte(conn, 0);
ncp_unlock_conn(conn);
return result;
}

View File

@@ -14,13 +14,18 @@
#include <linux/ipx.h>
#include <sys/param.h>
#include <stdio.h>
#include <time.h>
#include "ipxlib.h"
#ifndef memzero
#include <string.h>
#define memzero(object) memset(&(object), 0, sizeof(object))
#endif
void
str_upper(char *name);
enum connect_state {
NOT_CONNECTED = 0,
CONN_PERMANENT,
@@ -64,9 +69,15 @@ struct ncp_conn_spec {
char server[NCP_BINDERY_NAME_LEN];
char user[NCP_BINDERY_NAME_LEN];
uid_t uid;
int login_type; /* NCP_BINDERY_USER / NCP_BINDERY_PSERVER */
char password[NCP_BINDERY_NAME_LEN];
};
struct ncp_search_seq {
struct nw_search_sequence s;
int namespace;
};
/* ncp_initialize is the main entry point for user programs which want
to connect to a NetWare Server. It looks for -S, -U, -P and -n in
the argument list, opens the connection and removes the arguments
@@ -77,6 +88,14 @@ ncp_initialize(struct ncp_conn *conn,
int *argc, char **argv,
int login_necessary);
/* You can login as another object by this procedure. As a first use
pserver comes to mind. */
int
ncp_initialize_as(struct ncp_conn *conn,
int *argc, char **argv,
int login_necessary, int login_type);
/* Open an existing permanent connection */
int
ncp_open(struct ncp_conn *conn,
@@ -127,6 +146,14 @@ int
ncp_get_file_server_description_strings(struct ncp_conn *conn,
char target[512]);
int
ncp_get_file_server_time(struct ncp_conn *conn, time_t *target);
int
ncp_get_connlist(struct ncp_conn *conn, __u32 last_id,
__u16 object_type, const char *object_name,
int *returned_no, __u16 conn_numbers[256]);
int
ncp_get_encryption_key(struct ncp_conn *conn,
char *target);
@@ -257,12 +284,13 @@ ncp_open_create_file_or_subdir(struct ncp_conn *conn,
int
ncp_initialize_search(struct ncp_conn *conn,
struct nw_info_struct *dir,
struct nw_search_sequence *target);
const struct nw_info_struct *dir,
int namespace,
struct ncp_search_seq *target);
int
ncp_search_for_file_or_subdir(struct ncp_conn *conn,
struct nw_search_sequence *seq,
struct ncp_search_seq *seq,
struct nw_info_struct *target);
int
@@ -280,4 +308,40 @@ ncp_close_file_and_start_job(struct ncp_conn *conn,
__u32 queue_id,
struct queue_job *job);
int
ncp_attach_to_queue(struct ncp_conn *conn,
__u32 queue_id);
int
ncp_detach_from_queue(struct ncp_conn *conn,
__u32 queue_id);
int
ncp_service_queue_job(struct ncp_conn *conn, __u32 queue_id, __u16 job_type,
struct queue_job *job);
int
ncp_finish_servicing_job(struct ncp_conn *conn, __u32 queue_id,
__u32 job_number, __u32 charge_info);
int
ncp_abort_servicing_job(struct ncp_conn *conn, __u32 queue_id,
__u32 job_number);
int
ncp_get_broadcast_message(struct ncp_conn *conn, char message[256]);
int
ncp_dealloc_dir_handle(struct ncp_conn *conn, __u8 dir_handle);
#define NCP_ALLOC_PERMANENT (0x0000)
#define NCP_ALLOC_TEMPORARY (0x0001)
#define NCP_ALLOC_SPECIAL (0x0002)
int
ncp_alloc_short_dir_handle(struct ncp_conn *conn,
struct nw_info_struct *dir,
__u16 alloc_mode,
__u8 *target);
#endif /* _NCPLIB_H */

View File

@@ -3,6 +3,16 @@
*
* Copyright (C) 1995 by Volker Lendecke
*
* 1/20/96 - Steven N. Hirsch (hirsch@emba.uvm.edu)
*
* If the ncpfs support is not loaded and we are using kerneld to
* autoload modules, then we don't want to do it here. I added
* a conditional which leaves out the test and load code.
*
* Even if we _do_ want ncpmount to load the module, passing a
* fully-qualified pathname to insmod causes it to bypass a
* path search. This may lead to ncpfs.o not being found on
* some systems.
*/
#include <stdio.h>
@@ -37,18 +47,18 @@ extern pid_t waitpid(pid_t, int *, int);
#include "ncplib.h"
static char *progname;
static void str_upper(char *name);
static void usage(void);
static void help(void);
#ifndef HAVE_KERNELD
/* Returns 0 if the filesystem is in the kernel after this routine
completes */
static int
load_ncpfs(void)
{
FILE *fver, *ffs;
FILE *ffs;
char s[1024];
char modname[1024];
char *p, *p1;
pid_t pid;
int status;
@@ -81,33 +91,6 @@ load_ncpfs(void)
{
return 0;
}
fver = fopen("/proc/version", "r");
if (fver == NULL)
{
perror("Error: \"/proc/version\" could not be read:");
return -1;
}
fgets(s, 1024, fver);
fclose(fver);
p = strstr(s, "version ");
if (p == NULL)
{
version_error:
fprintf(stderr, "Error: Unable to determine the Linux version"
"from \"/proc/version\n");
return -1;
}
p = strchr(p, ' ') + 1;
p1 = strchr(p, ' ');
if (p1 == NULL)
{
goto version_error;
}
strcpy(modname, "/lib/modules/");
strncat(modname, p, p1 - p);
strcat(modname, "/ncpfs.o");
/* system() function without signal handling, from Stevens */
@@ -118,7 +101,7 @@ load_ncpfs(void)
else if (pid == 0)
{
/* child */
execl("/sbin/insmod", "insmod", modname, NULL);
execl("/sbin/insmod", "insmod", "ncpfs", NULL);
_exit(127); /* execl error */
}
else
@@ -136,6 +119,8 @@ load_ncpfs(void)
return status;
}
#endif /* HAVE_KERNELD */
/* Check whether user is allowed to mount on the specified mount point */
static int
mount_ok(struct stat *st)
@@ -206,10 +191,11 @@ main(int argc, char *argv[])
umask(um);
data.file_mode = (S_IRWXU|S_IRWXG|S_IRWXO) & ~um;
data.dir_mode = 0;
data.flags |= NCP_MOUNT_SOFT;
upcase_password = 1;
while ((opt = getopt (argc, argv, "CS:U:c:u:g:f:d:P:nh")) != EOF)
while ((opt = getopt (argc, argv, "CS:U:c:u:g:f:d:P:nhv")) != EOF)
{
switch (opt)
{
@@ -305,6 +291,9 @@ main(int argc, char *argv[])
case 'h':
help();
exit(1);
case 'v':
fprintf(stderr, "ncpfs version %s\n", NCPFS_VERSION);
exit(1);
default:
usage();
return -1;
@@ -345,6 +334,7 @@ main(int argc, char *argv[])
exit(1);
}
#ifndef HAVE_KERNELD
/* Check if the ncpfs filesystem is in the kernel. If not, attempt
* to load the ncpfs module */
if (load_ncpfs() != 0)
@@ -352,6 +342,7 @@ main(int argc, char *argv[])
fprintf(stderr, "Error: Unable to load ncpfs, exiting...\n");
exit(1);
}
#endif
data.version = NCP_MOUNT_VERSION;
data.mounted_uid = conn_uid;
@@ -436,6 +427,31 @@ main(int argc, char *argv[])
exit(1);
}
#if NCP_MOUNT_VERSION>1
data.message_fd = socket(AF_IPX, SOCK_DGRAM, PF_IPX);
if (data.message_fd == -1)
{
fprintf(stderr, "could not open message socket: %s\n",
strerror(errno));
exit(1);
}
addr.sipx_port = htons(ntohs(addr.sipx_port) + 1);
if (bind(data.message_fd, (struct sockaddr *)&addr,sizeof(addr)) == -1)
{
fprintf(stderr, "bind(message_sock, ): %s\n",
strerror(errno));
exit(1);
}
if (strlen(mount_point) < sizeof(data.mount_point))
{
strcpy(data.mount_point, mount_point);
}
#endif
flags = MS_MGC_VAL;
data.time_out = 20;
@@ -504,15 +520,6 @@ main(int argc, char *argv[])
return 0;
}
static void
str_upper(char *name)
{
while (*name) {
*name = toupper(*name);
name = name + 1;
}
}
static void
usage(void)
{
@@ -540,5 +547,6 @@ help(void)
" If neither -P nor -n are given, you are\n"
" asked for a password.\n"
"-h print this help text\n"
"-v print ncpfs version number\n"
"\n");
}

View File

@@ -96,24 +96,110 @@ test_print(struct ncp_conn *conn)
}
void
main(void)
test_ls(struct ncp_conn *server)
{
struct nw_info_struct sys;
struct nw_info_struct public;
struct ncp_search_seq seq;
struct nw_info_struct found;
int res;
if (ncp_do_lookup(server, NULL, "SYS", &sys) != 0)
{
printf("lookup error\n");
return;
}
if (ncp_do_lookup(server, &sys, "PUBLIC", &public) != 0)
{
printf("lookup public error\n");
return;
}
if (ncp_initialize_search(server, &public, 4, &seq) != 0)
{
printf("init error\n");
return;
}
while ((res=ncp_search_for_file_or_subdir(server,&seq,&found)) == 0)
{
printf("found %s: %s\n",
(found.attributes & aDIR) ? "dir " : "file",
found.entryName);
}
if (res == 0xfe)
{
printf("result: no more files\n");
}
else
{
printf("other error: %x\n", res);
}
return;
}
void
test_connlist(struct ncp_conn *conn)
{
__u16 conn_list[256];
int no;
ncp_get_connlist(conn, 0, NCP_BINDERY_USER, "*", &no, conn_list);
return;
}
void
test_create(struct ncp_conn *conn)
{
struct nw_info_struct sys;
struct nw_info_struct me;
__u8 dir_handle;
struct ncp_file_info new_file;
if (ncp_do_lookup(conn, NULL, "SYS", &sys) != 0)
{
printf("lookup error\n");
return;
}
if (ncp_do_lookup(conn, &sys, "ME", &me) != 0)
{
printf("lookup public error\n");
return;
}
if (ncp_alloc_short_dir_handle(conn, &me, NCP_ALLOC_TEMPORARY,
&dir_handle) != 0)
{
printf("alloc_dir_handle error\n");
return;
}
if (ncp_create_file(conn, dir_handle, "BLUB.TXT", 0,
&new_file) != 0)
{
printf("create error\n");
return;
}
if (ncp_dealloc_dir_handle(conn, dir_handle) != 0)
{
printf("dealloc error\n");
return;
}
}
int
main(int argc, char *argv[])
{
struct ncp_conn conn;
struct ncp_conn_spec *spec;
if ((spec = ncp_find_conn_spec("NW311", "me", "", 0)) == NULL)
if (ncp_initialize(&conn, &argc, argv, 1) != 0)
{
perror("could not find spec");
exit(1);
perror("ncp_initialize");
return 1;
}
if (ncp_open(&conn, NULL) != 0)
{
perror("ncp_open");
exit(1);
}
test_print(&conn);
test_create(&conn);
ncp_close(&conn);
return 0;
}

View File

@@ -20,8 +20,7 @@
static char *progname;
static void
usage(void);
static void
str_upper(char *name);
static void help(void);
void
main(int argc, char *argv[])
@@ -48,6 +47,13 @@ main(int argc, char *argv[])
memzero(j); memzero(pj); memzero(q); memzero(conn);
if ( (argc == 2)
&& (strcmp(argv[1], "-h") == 0))
{
help();
exit(0);
}
if (ncp_initialize(&conn, &argc, argv, 1) != 0)
{
perror("Could not open connection");
@@ -71,9 +77,13 @@ main(int argc, char *argv[])
pj.Rows = htons(80);
strcpy(pj.FnameHeader, "stdin");
while ((opt = getopt(argc, argv, "q:d:p:b:f:l:r:c:t:F:TN"))!=EOF)
while ((opt = getopt(argc, argv, "hq:d:p:b:f:l:r:c:t:F:TN"))!=EOF)
{
switch (opt) {
case 'h':
help();
ncp_close(&conn);
exit(1);
case 'p':
/* Path */
pj.CtrlFlags |= PRINT_BANNER;
@@ -303,10 +313,27 @@ usage(void)
}
static void
str_upper(char *name)
help(void)
{
while (*name) {
*name = toupper(*name);
name = name + 1;
}
printf("\n");
printf("usage: %s [options] file\n", progname);
printf("\n"
"-S server Server name to be used\n"
"-U username Username sent to server\n"
"-P password Use this password\n"
"-n Do not use any password\n"
"-C Don't convert password to uppercase\n"
"-q queue name Name of the printing queue to use\n"
"-d job desc Job description\n"
"-p path name Path name to appear on banner\n"
"-b bannername Banner name (up to 12 chars)\n"
"-f filename Filename to appear on banner\n"
"-l lines Number of lines per page\n"
"-r rows Number of rows per page\n"
"-t tab Number of spaces per tab\n"
"-T Print server tab expantion\n"
"-N Surpress print server form feeds\n"
"-F form # Form number to print on\n"
"-h print this help text\n"
"\n");
}

View File

@@ -62,7 +62,7 @@ main(int argc, char **argv)
{
found = 1;
printf("%-52s", q.object_name);
printf("%08lx\n", q.object_id);
printf("%08X\n", q.object_id);
}
if ((found == 0) && (isatty(1)))

338
util/pserver.c Normal file
View File

@@ -0,0 +1,338 @@
/*
* pserver.c
*
* Copyright (C) 1996 by Volker Lendecke
*
*/
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <signal.h>
#include "ncplib.h"
struct nw_queue {
struct ncp_conn *conn;
char queue_name[NCP_BINDERY_NAME_LEN];
__u32 queue_id;
__u16 job_type;
char *command;
};
static struct nw_queue q;
static int term_request;
static char *progname;
static int
init_queue(struct ncp_conn *conn, char *queue_name,
char *command, struct nw_queue *q);
static int
poll_queue(struct nw_queue *q);
static void
usage(void)
{
fprintf(stderr, "usage: %s [options] file\n", progname);
exit(1);
}
static void
help(void)
{
printf("\n");
printf("usage: %s [options]\n", progname);
printf("\n"
"-S server Server name to be used\n"
"-U username Print Server name sent to server\n"
"-P password Use this password\n"
"-n Do not use any password\n"
"-C Don't convert password to uppercase\n"
"-q queue name Name of the printing queue to use\n"
"-c command Name of print command, default: 'lpr'\n"
"-j job type Type of job (Form number) to service\n"
"-t timeout Polling interval, default: 30 sec\n"
"-d Debug: don't daemonize\n"
"-h print this help text\n"
"\n");
}
#ifndef NCP_BINDERY_PSERVER
#define NCP_BINDERY_PSERVER (0x0007)
#endif
static void
terminate_handler()
{
signal(SIGTERM,terminate_handler);
signal(SIGINT, terminate_handler);
term_request=1;
}
static void
daemonize()
{
int fd,c;
if ((c = fork()) > 0) exit(0);
if (c < 0)
{
fprintf(stderr, "ipxripd: can't fork: %s\n",strerror(errno));
exit(1);
}
close(0);
close(1);
close(2);
if ((fd = open("/dev/tty", O_RDWR)) >= 0)
{
ioctl(fd, TIOCNOTTY, NULL);
close(fd);
}
}
int
main(int argc, char *argv[])
{
struct ncp_conn conn;
int poll_timeout = 30;
int opt;
int job_type = 0xffff;
int debug = 0;
int i;
char *queue_name = NULL;
char default_command[] = "lpr";
char *command = default_command;
progname = argv[0];
for (i = 1; i < argc; i += 1)
{
if ( (strcmp(argv[i], "-h") == 0)
|| (strcmp(argv[i], "-?") == 0))
{
help();
exit(0);
}
}
for (i = 1; i < argc; i += 1)
{
if (strcmp(argv[i], "-d") == 0)
{
debug = 1;
break;
}
}
if (debug == 0)
{
daemonize();
}
if (ncp_initialize_as(&conn, &argc, argv, 1, NCP_BINDERY_PSERVER) != 0)
{
perror("Could not open connection");
return 1;
}
while ((opt = getopt(argc, argv, "q:c:j:t:dh")) != EOF)
{
switch (opt)
{
case 'q':
queue_name = optarg;
break;
case 'c':
command = optarg;
break;
case 'j':
job_type = atoi(optarg);
break;
case 't':
poll_timeout = atoi(optarg);
break;
case 'd':
debug = 1;
break;
case 'h':
break;
default:
usage();
return -1;
}
}
if (argc != optind)
{
usage();
return -1;
}
memzero(q);
if (queue_name == NULL)
{
fprintf(stderr, "You must specify a queue\n");
return 1;
}
if (init_queue(&conn, queue_name, command, &q) != 0)
{
perror("Could not init queue");
ncp_close(&conn);
return 1;
}
q.job_type = job_type;
term_request = 0;
signal(SIGTERM,terminate_handler);
signal(SIGINT, terminate_handler);
while (1)
{
if ( (poll_queue(&q) != 0)
&& (term_request == 0))
{
continue;
}
if (term_request != 0)
{
break;
}
sleep(poll_timeout);
}
ncp_detach_from_queue(&conn, q.queue_id);
ncp_close(&conn);
return 0;
}
static int
init_queue(struct ncp_conn *conn, char *queue_name, char *command,
struct nw_queue *q)
{
struct ncp_bindery_object obj;
str_upper(queue_name);
q->conn = conn;
q->command = command;
if (ncp_get_bindery_object_id(conn, NCP_BINDERY_PQUEUE,
queue_name, &obj) != 0)
{
fprintf(stderr, "Queue %s not found\n", queue_name);
return -1;
}
q->queue_id = obj.object_id;
memcpy(q->queue_name, obj.object_name, sizeof(q->queue_name));
if (ncp_attach_to_queue(conn, q->queue_id) != 0)
{
fprintf(stderr, "Could not attach to queue %s\n",
queue_name);
return -1;
}
return 0;
}
static int
poll_queue(struct nw_queue *q)
{
struct queue_job job;
int fd[2];
int pid;
if (ncp_service_queue_job(q->conn, q->queue_id, q->job_type,
&job) != 0)
{
/* No job for us */
return 0;
}
if (pipe(fd) < 0)
{
perror("pipe");
goto fail;
}
if ((pid = fork()) < 0)
{
perror("fork");
goto fail;
}
if (pid > 0)
{
/* parent */
char buf[1024];
size_t result;
off_t offset = 0;
close(fd[0]); /* close read end */
while ((result = ncp_read(q->conn, job.file_handle, offset,
sizeof(buf), buf)) > 0)
{
offset += result;
if (write(fd[1], buf, result) != result)
{
goto fail;
}
}
close(fd[1]); /* and close write end */
if (waitpid(pid, NULL, 0) < 0)
{
perror("waitpid");
}
}
else
{
/* child */
close(fd[1]); /* close write end */
if (fd[0] != STDIN_FILENO)
{
if (dup2(fd[0], STDIN_FILENO) != STDIN_FILENO)
{
perror("dup2");
close(fd[0]);
exit(1);
}
close(fd[0]);
}
execl("/bin/sh", "sh", "-c", q->command, NULL);
perror("exec");
close(fd[0]);
exit(1);
}
ncp_finish_servicing_job(q->conn, q->queue_id, job.j.JobNumber,0);
return 1;
fail:
ncp_abort_servicing_job(q->conn, q->queue_id, job.j.JobNumber);
/* We tell that we did not have a job to avoid overloading
when something's wrong */
return 0;
}