Compare commits

..

2 Commits

Author SHA1 Message Date
ncpfs archive import
0979ae6a41 Import ncpfs 2.2.0 2026-04-28 20:39:59 +02:00
ncpfs archive import
c6c6fbe4ca Import ncpfs 2.1.1 2026-04-28 20:39:59 +02:00
57 changed files with 2378 additions and 3693 deletions

BIN
.downloads/ncpfs-2.1.1.tgz Normal file

Binary file not shown.

BIN
.downloads/ncpfs-2.2.0.tgz Normal file

Binary file not shown.

14
BUGS
View File

@@ -33,3 +33,17 @@ like
Nov 25 16:09:08 lx01 kernel: alloc_skb called nonatomically from interrupt 0000002e
These are a bit annoying, but completely harmless.
-------------------------------------------------------------------------------
Known bugs:
- It returns error 255 during bindery login on one site... I do not know why.
- If GetNearsetServer returns invalid (nonexistant, downed) server, all
utilities gives up. VLM/Client32 in this situation tries randomly choosen
server after 30 secs timeout. You have to fix your routers at this time.
Sorry.
- NFS namespace does not work on Netware Storage Services volume... Sorry,
it is not my fault and I did not found any workaround (maybe that I have
workaround for NSS from NW5Beta3)

66
Changes
View File

@@ -1,7 +1,48 @@
I only began this file with ncpfs-0.12. If you're interested in older
versions, you can find them on ftp.gwdg.de:/pub/linux/misc/ncpfs/old.
[Versions ncpfs-2.0.11.x are available at ftp://platan.vc.cvut.cz/pub/linux/ncpfs]
[Versions ncpfs-2.0.12.x are available at ftp://platan.vc.cvut.cz/pub/linux/ncpfs]
ncpfs-2.0.12.10 -> ncpfs-2.2.0
- VANA: minor cleanup
ncpfs-2.0.12.9 -> ncpfs-2.0.12.10
- VANA: you can now access NDS server without replica of its conteiner
(TODO: access to server if server has R/W replica of your account but
does not have replica of itself)
- VANA: Alpha still no go :-(
ncpfs-2.0.12.8 -> ncpfs-2.0.12.9
- Eloy A. Paris: Fixes in library code
ncpfs-2.0.12.7 -> ncpfs-2.0.12.8
- VANA: bugfix, now it works again without ipxripd
- VANA: still cleaning up, ncp_open() and NDS byte ordering
ncpfs-2.0.12.6 -> ncpfs-2.0.12.7
- VANA: bugfixes, nwpurge
ncpfs-2.0.12.5 -> ncpfs-2.0.12.6
- VANA: ncpmount supports NCP over IP (no incoming broadcast at this time)
ncpfs-2.0.12.4 -> ncpfs-2.0.12.5
- Eloy A. Paris: Makefile bugfix
ncpfs-2.0.12.3 -> ncpfs-2.0.12.4
- VANA: Bugfixes
- VANA: Alpha stage of native NCP over IP support (no kernel at this time)
ncpfs-2.0.12.2 -> ncpfs-2.0.12.3
- VANA: Major makefile changes, compile warning cleanup
ncpfs-2.0.12.1 -> ncpfs-2.0.12.2
- Eloy A. Paris <peloy@ven.ra.rockwell.com>: Makefile cleanup
- VANA: More merging sutil/ncplib.c and lib/ncplib.c, not fully functional yet
ncpfs-2.0.12 -> ncpfs-2.0.12.1
- Dave, VANA: Bindery logins for all utilities (-b)
- VANA: Specify signature level for ncpmount (-i number)
- VANA: Start of merging sutil/*lib* with lib/*lib*
ncpfs-2.0.11.19 -> ncpfs-2.0.12
- Polished for release 2.0.12
@@ -12,12 +53,13 @@ ncpfs-2.0.11.18 -> ncpfs-2.0.11.19
ncpfs-2.0.11.17 -> ncpfs-2.0.11.18 (no userspace change)
- Dave: getwd() did not work on 2.1.x
- VANA: Volumes are now allways listed lowercased on 2.1.x
- VANA: Volumes are now always listed lowercased on 2.1.x
ncpfs-2.0.11.16 -> ncpfs-2.0.11.17
- Dave@imladris.demon.co.uk: Patch to pserver, ncp_get_broadcast_message
- David Woodhouse <Dave@imladris.demon.co.uk>: Patch to pserver,
ncp_get_broadcast_message
- VANA & Dave: Cleanup for glibc, I hope that complete (xcpt. few warnings
about long int vs. u_int32_t
about long int vs. u_int32_t)
ncpfs-2.0.11.15 -> ncpfs-2.0.11.16
- VANA: Removed symlink latest from archive :-)
@@ -30,22 +72,22 @@ ncpfs-2.0.11.14 -> ncpfs-2.0.11.15
ncpfs-2.0.11.13 -> ncpfs-2.0.11.14
- VANA: One source for 2.0 and 2.1 kernels
- Chirstian Groessler: Added strong mounts
- Chirstian Groessler <cpg@aladdin.de>: Added strong mounts
ncpfs-2.0.11.12 -> ncpfs-2.0.11.13
- Arne: Signatures added to ncpfs-nds-0.06
- VANA: Synchronized sources with Arne
ncpfs-2.0.11.11 -> ncpfs-2.0.11.12
- VANA: Fixed compilation error if compiled against kernel without signatures even
if SIGNATURES = 0 set
- VANA: Fixed compilation error if compiled against kernel without signatures
even if SIGNATURES = 0 set
ncpfs-2.0.11.10 -> ncpfs-2.0.11.11
- VANA: Fixed segfault on invalid user name in NDS mode
- VANA: Added locking features (through ncpfs-specific ioctl(2))
ncpfs-2.0.11.9 -> ncpfs-2.0.11.10
- VANA: Synchronized with nds-patches-0.05 from Arne@knoware.nl
- VANA: Synchronized with nds-patches-0.05 from Arne de Bruijn <Arne@knoware.nl>
ncpfs-2.0.11.8 -> ncpfs-2.0.11.9
- VANA: Added call to lock connection (dropped in 2.0.11.7, sorry)
@@ -55,7 +97,7 @@ ncpfs-2.0.11.7 -> ncpfs-2.0.11.8
- VANA: Fix in kernel in setting task number
ncpfs-2.0.11.6 -> ncpfs-2.0.11.7
- VANA: Codebase synchronized with arne@knoware.nl
- VANA: Codebase synchronized with Arne de Bruijn <Arne@knoware.nl>
- ARNE: Gracelogins on NDS
- VANA: Removed some (one) compilation warnings
@@ -71,14 +113,14 @@ ncpfs-2.0.11.3 -> ncpfs-2.0.11.4
- Added parameter "-b" to ncpmount for bindery login to NDS server
ncpfs-2.0.11.2 -> ncpfs-2.0.11.3
- Added NDS support by Arne@knoware.nl; small fixes in code; moved sections
to do same things as DOS login does.
- Added NDS support by Arne de Bruijn <Arne@knoware.nl>; small fixes in code;
moved sections to do same things as DOS login does.
ncpfs-2.0.11.1 -> ncpfs-2.0.11.2
- VANA: Fixed that some error conditions in LOGIN should start packet signatures
ncpfs-2.0.11 -> ncpfs-2.0.11.1
- VANA: Added packet signatures by ... (Arne?)
- VANA: Added packet signatures by Arne de Bruijn <Arne@knoware.nl>
ncpfs-2.0.10 -> ncpfs-2.0.11
- Added Martin's patch to Linux 2.0.30 to get rid of the lockups.

View File

@@ -2,54 +2,30 @@
# Makefile for the linux ncp-filesystem routines.
#
VERSION = 2.0.12
# If you are using kerneld to autoload ncp support,
# uncomment this (kerneld is in linux since about 1.3.57):
KERNELD = -DHAVE_KERNELD
# If your system is ELF, either also do a 'make install', or append the util/
# directory where the dynamic library resides to the environment
# variable LD_LIBRARY_PATH
HAVE_ELF=$(shell file `whereis gcc|cut -d ' ' -f 2`| \
grep ELF >/dev/null && echo -n yes )
# If you want to include NDS support for ncpmount uncomment this:
# WARNING! NDS support is very beta, uncomment only if you are testing
# because anything can happen (like crashing the linux box or nw server).
NDS_SUPPORT = 1
# If you want to include packet signature support uncomment this:
# WARNING! packet signature support is in beta stage, uncomment only when you
# know what you are doing, anything can happen (like crashing the linux box or
# netware server).
# When enabling, make sure you have applied the kernel patches too,
# otherwise the packet signatures won't work.
SIGNATURES = 1
# Include code for Linux2.0.x
MOUNT2 = 1
# Include code for Linux2.1.x
MOUNT3 = 1
TOPDIR = $(shell pwd)
BINDIR = /usr/bin
SBINDIR = /sbin
SUBDIRS = lib sutil util ipx-1.0 man
include ./Makeinit
KVERSION=$(shell uname -r | cut -b1-3)
EXECSUBDIRS = lib-static-su sutil util ipx-1.0
SUBDIRS := $(EXECSUBDIRS) lib-shared lib-static man
INSTALL_SUBDIRS := util sutil man ipx-1.0
ifeq ($(HAVE_ELF),yes)
EXECSUBDIRS := lib-shared $(EXECSUBDIRS)
INSTALL_SUBDIRS := lib-shared $(INSTALL_SUBDIRS)
else
EXECSUBDIRS := lib-static $(EXECSUBDIRS)
INSTALL_SUBDIRS := lib-static $(INSTALL_SUBDIRS)
endif
INCLUDES=-I$(TOPDIR)/include
COPT = -O2
# COPT += -g
CFLAGS = $(COPT) -Wall $(INCLUDES) $(KERNELD) -DNCPFS_VERSION=\"$(VERSION)\"
export INCLUDES BINDIR SBINDIR KERNELD VERSION HAVE_ELF CFLAGS NDS_SUPPORT \
SIGNATURES MOUNT2 MOUNT3
export INCLUDES VERSION HAVE_ELF CFLAGS
all:
set -e; for i in $(SUBDIRS); do make -C $$i all; done
set -e; for i in $(EXECSUBDIRS); do make -C $$i all; done
@if [ "$(HAVE_ELF)" = yes ] ;\
then \
echo ; echo ; echo ;\
@@ -66,7 +42,7 @@ dep:
for i in $(SUBDIRS); do make -C $$i dep; done
install:
for i in $(SUBDIRS); do make -C $$i install; done
for i in $(INSTALL_SUBDIRS); do make -C $$i install; done
clean_me:
rm -f `find -name '*.out'`

79
Makeinit Normal file
View File

@@ -0,0 +1,79 @@
VERSION = 2.2.0
# If you want to include NDS support for ncpmount uncomment this:
# WARNING! NDS support is very beta, uncomment only if you are testing
# because anything can happen (like crashing the linux box or nw server).
NDS_SUPPORT = 1
# If you want to include packet signature support uncomment this:
# WARNING! packet signature support is in beta stage, uncomment only when you
# know what you are doing, anything can happen (like crashing the linux box or
# netware server).
# When enabling, make sure you have applied the kernel patches too,
# otherwise the packet signatures won't work.
SIGNATURES = 1
# If you want to eat only one NDS connection. Does not work at this time.
# (waiting for Novell...)
NDS_PRIVATEKEY = 1
# If you want native IP support, uncomment CONFIG_NATIVEIP
# Do not forget that it is VERY ALPHA code, with almost no support
# Enable only if you are interested in NCP over IP and you want help
# me. -A ip.address is your friend. At this time you have to silently
# ignore Login to server XXXX as YYYY - think that XXXX is ip.address and
# not one taken from .nwclient. Also, if you have not .nwclient, you have
# to add -S DUMMY on commandline.
CONFIG_NATIVE_IP = 1
# Include code for Linux2.0.x
MOUNT2 = 1
# Include code for Linux2.1.x
MOUNT3 = 1
# ########################################################
BINDIR = /usr/bin
SBINDIR = /sbin
LIBSODIR = /lib
LIBADIR = /usr/lib
MANDIR = /usr/local/man
CC = gcc
COPT = -O2
CWARN = -Wall
# CWARN = -Wall -Wstrict-prototypes -Wpointer-arith -Wcast-qual -Waggregate-return -Wnested-externs -Winline -Wbad-function-cast -W #-Werror #-Wwrite-strings -Wtraditional -Wshadow
# ########################################################
ifdef SIGNATURES
CFLAGS_DEFINES += -DSIGNATURES
endif
ifdef NDS_SUPPORT
CFLAGS_DEFINES += -DNDS_SUPPORT
endif
ifdef CONFIG_NATIVE_IP
CFLAGS_DEFINES += -DCONFIG_NATIVE_IP
endif
ifdef MOUNT2
CFLAGS_DEFINES += -DMOUNT2
endif
ifdef MOUNT3
CFLAGS_DEFINES += -DMOUNT3
endif
CFLAGS_DEFINES += -DNCPFS_VERSION=\"$(VERSION)\"
CFLAGS_OPTIONS += $(COPT)
CFLAGS_OPTIONS += $(CWARN)
CCFLAGS = $(CFLAGS_DEFINES) $(CFLAGS_OPTIONS) -I../include
# If your system is ELF, either also do a 'make install', or append the util/
# directory where the dynamic library resides to the environment
# variable LD_LIBRARY_PATH
HAVE_ELF=$(shell file `whereis gcc|cut -d ' ' -f 2`| \
grep ELF >/dev/null && echo -n yes )
#HAVE_ELF=yes
TOPDIR = $(shell pwd)
INCLUDES=-I$(TOPDIR)/include

16
README
View File

@@ -32,20 +32,17 @@ The IPX protocol (CONFIG_IPX) [N/y/m/?]
simply answer 'y'. Probably you do not need the full internal net that
you are asked for next.
If you are not running kerneld, please comment the corresponding line in
the Makefile to reflect this.
If you are not using 2.0.x kernels, you can comment out MOUNT2=1 line
in the Makefile.
in the Makeinit.
If you are not using 2.1.x kernels, you can comment out MOUNT3=1 line
in the Makefile.
in the Makeinit.
If you are not using NDS access, you can comment out NDS_SUPPORT=1 in
the Makefile.
the Makeinit.
If you are not using packet signatures, you can comment out SIGNATURES=1
in the Makefile.
in the Makeinit.
After you adapted your Makefile, type 'make' and, as root, 'make install'.
After you adapted your Makeinit, type 'make' and, as root, 'make install'.
HELP
@@ -127,9 +124,6 @@ limitation is the lack of uid, gid and permission information per
file. You have to assign those values once for a complete mounted
directory.
You will not be able to access servers that require packet
signatures. This seems to be one of Novell's bigger secrets :-(.
Have fun with ncpfs!
Volker

View File

@@ -15,6 +15,7 @@
typedef u_int32_t IPXNet;
typedef u_int16_t IPXPort;
typedef u_int8_t IPXNode[IPX_NODE_LEN];
typedef const u_int8_t CIPXNode[IPX_NODE_LEN];
#define IPX_USER_PTYPE (0x00)
#define IPX_RIP_PTYPE (0x01)
@@ -54,7 +55,7 @@ struct ipx_rip_packet
u_int16_t operation __attribute__((packed));
struct ipx_rt_def
{
u_int16_t network __attribute__((packed));
u_int32_t network __attribute__((packed));
u_int16_t hops __attribute__((packed));
u_int16_t ticks __attribute__((packed));
}
@@ -88,13 +89,10 @@ void
int
ipx_sscanf_node(char *buf, unsigned char node[IPX_NODE_LEN]);
void
ipx_assign_node(IPXNode dest, IPXNode src);
ipx_assign_node(IPXNode dest, CIPXNode src);
int
ipx_node_equal(IPXNode n1, IPXNode n2);
#ifdef __MAKE_NCPMOUNT__
ipx_node_equal(CIPXNode n1, CIPXNode n2);
int
ipx_sscanf_saddr(char* buf, struct sockaddr_ipx* sipx);
#endif
#endif /* _IPXLIB_H */

View File

@@ -8,4 +8,8 @@
#include <linux/ipx.h>
#endif
#ifndef IPXPROTO_IPX
#define IPXPROTO_IPX (PF_IPX)
#endif
#endif

View File

@@ -77,6 +77,7 @@ struct ncp_volume_info {
#define NW_NS_FTAM 3
#define NW_NS_OS2 4
#if 0 /* Sorry, I do not think so... VANA */
/* Defines for ReturnInformationMask */
#define RIM_NAME (ntohl(0x01000000L))
#define RIM_SPACE_ALLOCATED (ntohl(0x02000000L))
@@ -92,6 +93,22 @@ struct ncp_volume_info {
#define RIM_RIGHTS (ntohl(0x00080000L))
#define RIM_ALL (ntohl(0xFF0F0000L))
#define RIM_COMPRESSED_INFO (ntohl(0x00000080L))
#else
#define RIM_NAME 0x00000001
#define RIM_SPACE_ALLOCATED 0x00000002
#define RIM_ATTRIBUTES 0x00000004
#define RIM_DATA_SIZE 0x00000008
#define RIM_TOTAL_SIZE 0x00000010
#define RIM_EXT_ATTR_INFO 0x00000020
#define RIM_ARCHIVE 0x00000040
#define RIM_MODIFY 0x00000080
#define RIM_CREATION 0x00000100
#define RIM_OWNING_NAMESPACE 0x00000200
#define RIM_DIRECTORY 0x00000400
#define RIM_RIGHTS 0x00000800
#define RIM_ALL 0x00000FFF
#define RIM_COMPRESSED_INFO 0x80000000UL
#endif
/* open/create modes */
#define OC_MODE_OPEN 0x01

View File

@@ -62,6 +62,22 @@ struct ncp_setroot_ioctl
__u32 dirEntNum;
};
struct ncp_objectname_ioctl
{
#define NCP_AUTH_NONE 0x00
#define NCP_AUTH_BIND 0x31
#define NCP_AUTH_NDS 0x32
int auth_type;
size_t object_name_len;
void* object_name;
};
struct ncp_privatedata_ioctl
{
size_t len;
void* data; /* ~1000 for NDS */
};
#define NCP_IOC_NCPREQUEST _IOR('n', 1, struct ncp_ioctl_request)
#define NCP_IOC_GETMOUNTUID _IOW('n', 2, __kernel_uid_t)
#define NCP_IOC_CONN_LOGGED_IN _IO('n', 3)
@@ -77,6 +93,12 @@ struct ncp_setroot_ioctl
#define NCP_IOC_GETROOT _IOW('n', 8, struct ncp_setroot_ioctl)
#define NCP_IOC_SETROOT _IOR('n', 8, struct ncp_setroot_ioctl)
#define NCP_IOC_GETOBJECTNAME _IOWR('n', 9, struct ncp_objectname_ioctl)
#define NCP_IOC_SETOBJECTNAME _IOR('n', 9, struct ncp_objectname_ioctl)
#define NCP_IOC_GETPRIVATEDATA _IOWR('n', 10, struct ncp_privatedata_ioctl)
#define NCP_IOC_SETPRIVATEDATA _IOR('n', 10, struct ncp_privatedata_ioctl)
/*
* The packet size to allocate. One page should be enough.
*/

View File

@@ -12,7 +12,7 @@
typedef u_int16_t __kerXX_uid_t;
#include <asm/posix_types.h>
#include <linux/posix_types.h>
typedef __kernel_pid_t __ker20_pid_t;
typedef __kernel_uid_t __ker20_uid_t;

View File

@@ -26,22 +26,25 @@ typedef __u8 byte;
typedef __u16 word;
typedef __u32 dword;
typedef int NWCCODE;
#ifndef memzero
#include <string.h>
#define memzero(object) memset(&(object), 0, sizeof(object))
#endif
#define BVAL(buf,pos) (((__u8 *)(buf))[pos])
#define BVAL(buf,pos) (((const __u8 *)(buf))[pos])
#define BWVAL(buf,pos) (((__u8*)(buf))[pos])
#define PVAL(buf,pos) ((unsigned)BVAL(buf,pos))
#define BSET(buf,pos,val) (BVAL(buf,pos) = (val))
#define BSET(buf,pos,val) (BWVAL(buf,pos) = (val))
static inline word
WVAL_HL(__u8 * buf, int pos)
WVAL_HL(const __u8 * buf, int pos)
{
return PVAL(buf, pos) << 8 | PVAL(buf, pos + 1);
}
static inline dword
DVAL_HL(__u8 * buf, int pos)
DVAL_HL(const __u8 * buf, int pos)
{
return WVAL_HL(buf, pos) << 16 | WVAL_HL(buf, pos + 2);
}
@@ -64,14 +67,14 @@ DSET_HL(__u8 * buf, int pos, dword val)
#if defined(__i386__)
static inline word
WVAL_LH(__u8 * buf, int pos)
WVAL_LH(const __u8 * buf, int pos)
{
return *((word *) (buf + pos));
return *((const word *) (buf + pos));
}
static inline dword
DVAL_LH(__u8 * buf, int pos)
DVAL_LH(const __u8 * buf, int pos)
{
return *((dword *) (buf + pos));
return *((const dword *) (buf + pos));
}
static inline void
WSET_LH(__u8 * buf, int pos, word val)
@@ -87,12 +90,12 @@ DSET_LH(__u8 * buf, int pos, dword val)
#else
static inline word
WVAL_LH(__u8 * buf, int pos)
WVAL_LH(const __u8 * buf, int pos)
{
return PVAL(buf, pos) | PVAL(buf, pos + 1) << 8;
}
static inline dword
DVAL_LH(__u8 * buf, int pos)
DVAL_LH(const __u8 * buf, int pos)
{
return WVAL_LH(buf, pos) | WVAL_LH(buf, pos + 2) << 16;
}
@@ -111,9 +114,6 @@ DSET_LH(__u8 * buf, int pos, dword val)
#endif
void
str_upper(char *name);
@@ -151,13 +151,13 @@ struct ncp_conn
int current_size;
int has_subfunction;
int verbose;
int ncp_reply_size;
size_t ncp_reply_size;
int lock;
char packet[NCP_PACKET_SIZE];
#ifdef SIGNATURES
/* Fields used to make packet signatures */
/* Field used to make packet signatures */
int sign_wanted;
int sign_active;
char sign_root[8];
@@ -174,11 +174,13 @@ struct ncp_conn_spec
char password[NCP_BINDERY_NAME_LEN];
};
#ifndef __MAKE_SULIB__
struct ncp_search_seq
{
struct nw_search_sequence s;
int namespace;
};
#endif /* not __MAKE_SULIB__ */
struct ncp_property_info
{
@@ -208,29 +210,29 @@ struct ncp_conn *
/* Open a connection */
struct ncp_conn *
ncp_open(const struct ncp_conn_spec *spec, long *err);
ncp_open(const struct ncp_conn_spec *spec, long *err);
/* Open a connection on an existing mount point */
struct ncp_conn *
ncp_open_mount(const char *mount_point, long *err);
int
ncp_open_mount(const char *mount_point, struct ncp_conn** conn);
/* Find a permanent connection that fits the spec, return NULL if
* there is none. */
char *
ncp_find_permanent(const struct ncp_conn_spec *spec);
ncp_find_permanent(const struct ncp_conn_spec *spec);
/* Find the address of a file server */
struct sockaddr_ipx *
ncp_find_fileserver(const char *server_name, long *err);
long
ncp_find_fileserver(const char *server_name, struct sockaddr* addr, size_t addrlen);
/* Find the address of a server */
struct sockaddr_ipx *
ncp_find_server(const char **server_name, int type, long *err);
long
ncp_find_server(const char **server_name, int type, struct sockaddr* addr, size_t addrlen);
/* Detach from a permanent connection or destroy a temporary
connection */
long
ncp_close(struct ncp_conn *conn);
ncp_close(struct ncp_conn *conn);
/* like getmntent, get_ncp_conn_ent scans /etc/mtab for usable
connections */
@@ -244,7 +246,7 @@ struct ncp_conn_ent
};
struct ncp_conn_ent *
ncp_get_conn_ent(FILE * filep);
ncp_get_conn_ent(FILE * filep);
#define NWCLIENT (".nwclient")
#define NWC_NOPASSWORD ("-")
@@ -255,6 +257,12 @@ struct ncp_conn_spec *
ncp_find_conn_spec(const char *server, const char *user, const char *password,
int login_necessary, uid_t uid, long *err);
#ifdef __MAKE_SULIB__
struct ncp_conn_spec *
ncp_find_conn_spec2(const char *server, const char *user, const char *password,
int login_necessary, uid_t uid, int allow_multiple_conns,
long *err);
#else /* __MAKE_SULIB__ */
long
ncp_get_file_server_description_strings(struct ncp_conn *conn,
char target[512]);
@@ -316,10 +324,12 @@ long
ncp_send_broadcast2(struct ncp_conn *conn,
unsigned int conns, const unsigned int* connlist,
const char* message);
#endif /* not __MAKE_SULIB__ */
long
ncp_get_encryption_key(struct ncp_conn *conn,
char *target);
#ifndef __MAKE_SULIB__
long
ncp_get_bindery_object_id(struct ncp_conn *conn,
__u16 object_type,
@@ -349,6 +359,7 @@ long
__u16 object_type,
const char *object_name,
__u8 security);
#endif /* not __MAKE_SULIB__ */
struct ncp_station_addr
{
@@ -382,10 +393,11 @@ long
int object_type, const char *object_name,
int segment, const char *prop_name,
struct nw_property *target);
#ifndef __MAKE_SULIB__
long
ncp_scan_property(struct ncp_conn *conn,
__u16 object_type, const char *object_name,
__u32 last_id, char *search_string,
__u32 last_id, const char *search_string,
struct ncp_property_info *property_info);
long
ncp_add_object_to_set(struct ncp_conn *conn,
@@ -418,7 +430,7 @@ long
__u16 object_type, const char *object_name,
const char *property_name,
__u8 segment,
struct nw_property *property_value);
const struct nw_property *property_value);
/* Bit masks for security flag */
#define NCP_SEC_CHECKSUMMING_REQUESTED (1)
@@ -452,14 +464,24 @@ long
const unsigned char *key,
const unsigned char *oldpasswd,
const unsigned char *newpasswd);
#endif /* not __MAKE_SULIB__ */
#define NWE_SIGNATURE_LEVEL_CONFLICT (0x8861)
#define NWE_SIGNATURE_LEVEL_CONFLICT (0x8861)
#define NCP_GRACE_PERIOD (0xdf)
#ifndef __MAKE_SULIB__
long
ncp_get_bindery_object_id(struct ncp_conn *conn,
__u16 object_type,
const char *object_name,
struct ncp_bindery_object *target);
#endif /* not __MAKE_SULIB__ */
long
ncp_login_user(struct ncp_conn *conn,
const unsigned char *username,
const unsigned char *password);
#ifndef __MAKE_SULIB__
long
ncp_get_volume_info_with_number(struct ncp_conn *conn, int n,
struct ncp_volume_info *target);
@@ -560,6 +582,15 @@ long
__u32 count,
__u32 * copied_count);
#define SA_NORMAL (0x0000)
#define SA_HIDDEN (0x0002)
#define SA_SYSTEM (0x0004)
#define SA_SUBDIR_ONLY (0x0010)
#define SA_SUBDIR_FILES (0x8000)
#define SA_ALL (SA_SUBDIR_FILES | SA_SYSTEM | SA_HIDDEN)
#define SA_SUBDIR_ALL (SA_SUBDIR_ONLY | SA_SYSTEM | SA_HIDDEN)
#define SA_FILES_ALL (SA_NORMAL | SA_SYSTEM | SA_HIDDEN)
long
ncp_obtain_file_or_subdir_info(struct ncp_conn *conn,
__u8 source_ns, __u8 target_ns,
@@ -587,7 +618,7 @@ long
long
ncp_do_lookup(struct ncp_conn *conn,
struct nw_info_struct *dir,
char *path, /* may only be one component */
const char *path, /* may only be one component */
struct nw_info_struct *target);
long
@@ -615,6 +646,13 @@ long
int namespace,
struct ncp_search_seq *target);
long
ncp_search_for_file_or_subdir2(struct ncp_conn *conn,
int search_attributes,
u_int32_t RIM,
struct ncp_search_seq *seq,
struct nw_info_struct *target);
long
ncp_search_for_file_or_subdir(struct ncp_conn *conn,
struct ncp_search_seq *seq,
@@ -675,10 +713,12 @@ long
long
ncp_abort_servicing_job(struct ncp_conn *conn, __u32 queue_id,
__u32 job_number);
#endif /* not __MAKE_SULIB__ */
long
ncp_get_broadcast_message(struct ncp_conn *conn, char message[256]);
#ifndef __MAKE_SULIB__
long
ncp_dealloc_dir_handle(struct ncp_conn *conn, __u8 dir_handle);
@@ -708,31 +748,76 @@ long
__u8 volume_number, __u32 dir_entry,
__u16 rights_mask,
int object_count, struct ncp_trustee_struct *rights);
struct ncp_deleted_file
{
int32_t seq;
__u32 vol;
__u32 base;
};
long
ncp_ns_scan_salvageable_file(struct ncp_conn* conn, __u8 src_ns,
int dirstyle, __u8 vol_num,
__u32 dir_base,
const unsigned char* encpath, int pathlen,
struct ncp_deleted_file* finfo,
char* name, int maxnamelen);
long
ncp_ns_purge_file(struct ncp_conn* conn, const struct ncp_deleted_file* finfo);
long
ncp_ns_get_full_name(struct ncp_conn* conn, __u8 src_ns, __u8 dst_ns,
int dirstyle, __u8 vol_num, __u32 dir_base,
const unsigned char* encpath, size_t pathlen,
char* name, size_t maxnamelen);
#endif /* not __MAKE_SULIB__ */
#ifdef SIGNATURES
long
ncp_sign_start(struct ncp_conn *conn, const char *sign_root);
#endif
#endif /* SIGNATURES */
#ifdef NDS_SUPPORT
long
ncp_send_nds_frag(struct ncp_conn *conn,
int ndsverb,
char *inbuf, int inbuflen,
char *outbuf, int outbufsize, int *outbuflen);
const char *inbuf, size_t inbuflen,
char *outbuf, size_t outbufsize, size_t *outbuflen);
long
ncp_send_nds(struct ncp_conn *conn, int fn,
char *data_in, int data_in_len,
char *data_out, int data_out_max, int *data_out_len);
const char *data_in, size_t data_in_len,
char *data_out, size_t data_out_max, size_t *data_out_len);
long
ncp_change_conn_state(struct ncp_conn *conn, int new_state);
#endif
struct ncp_conn *
ncp_open_addr(struct sockaddr_ipx *target, long *err);
ncp_open_addr(struct sockaddr *target, long *err);
#ifdef __MAKE_SULIB__
int
ncp_path_to_NW_format(const char* path, unsigned char* buff, int buffsize);
long
ncp_obtain_file_or_subdir_info2(struct ncp_conn* conn, __u8 source_ns,
__u8 target_ns, __u16 search_attribs, __u32 rim,
int dir_style, __u8 vol, __u32 dirent,
const unsigned char* path, int pathlen,
struct nw_info_struct* target);
#endif /* __MAKE_SULIB__ */
int
ncp_get_mount_uid(int fid, uid_t* uid);
#endif
#ifdef __MAKE_SULIB__
long
ncp_renegotiate_connparam(struct ncp_conn* conn, int buffsize, int options);
#endif /* __MAKE_SULIB__ */
#endif /* _NCPLIB_H */
#endif /* _NCPLIB_H */

View File

@@ -1,5 +1,8 @@
CFLAGS = -O2 -Wall -I../include
include ../Makeinit
# CFLAGS = -O2 -Wall -I../include
UTILS = ipx_configure ipx_interface ipx_internal_net ipx_route
MAN8 := $(UTILS)
CFLAGS := $(CCFLAGS)
all: $(UTILS)
@@ -17,3 +20,4 @@ install: $(UTILS)
do \
install $$i $(BINDIR); \
done
for i in $(MAN8); do install $$i.8 -m 644 $(MANDIR)/man8; done

View File

@@ -66,7 +66,7 @@ frame_types[] =
int
lookup_frame_type(char *frame)
{
int j;
size_t j;
for (j = 0; (j < NFTYPES) &&
(strcasecmp(frame_types[j].ft_name, frame));

View File

@@ -62,6 +62,7 @@ void handle_frame(unsigned char *buf, int length, struct sockaddr *saddr);
void handle_ipx(char *frame, unsigned char *buf);
static int filter = 0;
static int allframes = 0;
static IPXNode filter_node;
static int exit_request = 0;
@@ -84,11 +85,24 @@ main(int argc, char *argv[])
signal(SIGINT, int_handler);
if (argc > 1)
while (1) {
int opt;
opt = getopt(argc, argv, "r");
if (opt == -1) break;
switch (opt) {
case 'r':allframes = 1; break;
case ':':;
case '?':break;
default: printf("?? unknown option returned by getopt\n");
break;
}
}
if (optind < argc)
{
if (ipx_sscanf_node(argv[1], filter_node) != 0)
if (ipx_sscanf_node(argv[optind], filter_node) != 0)
{
fprintf(stderr, "usage: %s [node]\n", argv[0]);
fprintf(stderr, "usage: %s [-a] [node]\n", argv[0]);
exit(1);
}
filter = 1;
@@ -127,7 +141,18 @@ main(int argc, char *argv[])
&saddr, &sizeaddr);
if (length < 0)
continue;
handle_frame(buf, length, &saddr);
if (allframes) {
unsigned char* ptr = buf;
if (filter) {
if (memcmp(filter_node, buf, 6)&&memcmp(filter_node, buf+6, 6))
continue;
}
printf("raweth ");
while (length--) printf("%02X", *ptr++);
printf("\n");
} else {
handle_frame(buf, length, &saddr);
}
}
/* This should be rewritten to cooperate with other net tools */

View File

@@ -630,16 +630,16 @@ handle_ncp(struct sockaddr_ipx *source,
printf("fn: %-3d\n", rq->function);
printf("Packet Burst Connection Request\n");
printf("local_conn_id: %lx\n",
ntohl(i->local_conn_id));
printf("local_max_packet_size: %lx\n",
ntohl(i->local_max_packet_size));
printf("local_target_socket: %lx\n",
ntohl(i->local_target_socket));
printf("local_max_send_size: %lx\n",
ntohl(i->local_max_send_size));
printf("local_max_recv_size: %lx\n",
ntohl(i->local_max_recv_size));
printf("local_conn_id: %x\n",
(u_int32_t)ntohl(i->local_conn_id));
printf("local_max_packet_size: %x\n",
(u_int32_t)ntohl(i->local_max_packet_size));
printf("local_target_socket: %x\n",
(u_int32_t)ntohl(i->local_target_socket));
printf("local_max_send_size: %x\n",
(u_int32_t)ntohl(i->local_max_send_size));
printf("local_max_recv_size: %x\n",
(u_int32_t)ntohl(i->local_max_recv_size));
}
break;
case 104:
@@ -1012,10 +1012,10 @@ handle_ncp(struct sockaddr_ipx *source,
*x = (struct XDATA *) data;
printf("completion_code: %x\n",
x->completion_code);
printf("remote_target_id: %lx\n",
ntohl(x->remote_target_id));
printf("remote_max_packet_size: %lx\n",
ntohl(x->remote_max_packet_size));
printf("remote_target_id: %x\n",
(u_int32_t)ntohl(x->remote_target_id));
printf("remote_max_packet_size: %x\n",
(u_int32_t)ntohl(x->remote_max_packet_size));
}
break;
}

28
lib-shared/Makefile Normal file
View File

@@ -0,0 +1,28 @@
include ../Makeinit
NCPLIB = libncp.so
NCPLIB_BIN = $(NCPLIB).1.0
NCPLIB_SONAME = $(NCPLIB).1
CCFLAGS += -I../include -I.
PIC_FLAG = -fPIC
export PIC_FLAG
CCFLAGS += $(PIC_FLAG)
vpath %.c ../lib
vpath %.et ../lib
include ../lib/Makelib
install: all
rm -f $(LIBSODIR)/$(NCPLIB)
install $(NCPLIB_BIN) $(LIBSODIR)
ldconfig
ln -sf $(NCPLIB_SONAME) $(LIBSODIR)/$(NCPLIB)
$(NCPLIB): $(NCPLIB_BIN)
rm -f $@
ln -sf $< $@
$(NCPLIB_BIN): $(O_OBJ) $(O_LIB)
$(CC) -shared -o $@ -Wl,-soname=$(NCPLIB_SONAME) $(O_OBJ) -lc

17
lib-static-su/Makefile Normal file
View File

@@ -0,0 +1,17 @@
include ../Makeinit
NCPLIB = libncp.a
NCPLIB_BIN := $(NCPLIB)
CCFLAGS += -I../include -I.
CCFLAGS += -D__MAKE_SULIB__
vpath %.c ../lib
vpath %.et ../lib
include ../lib/Makelib
install:
$(NCPLIB_BIN): $(O_OBJ)
ar r $@ $(O_OBJ)

17
lib-static/Makefile Normal file
View File

@@ -0,0 +1,17 @@
include ../Makeinit
NCPLIB = libncp.a
NCPLIB_BIN = $(NCPLIB)
CCFLAGS += -I../include -I.
vpath %.c ../lib
vpath %.et ../lib
include ../lib/Makelib
install: all
install $(NCPLIB_BIN) $(LIBADIR)
$(NCPLIB_BIN): $(O_OBJ)
ar r $@ $(O_OBJ)

View File

@@ -2,89 +2,19 @@
# Makefile for the linux ncp-filesystem routines.
#
CC = gcc
ifeq ($(HAVE_ELF),yes)
PIC_FLAG = -fPIC
NCP_LIB = libncp.so.1.0
LIB_LINK_COMMAND = gcc -shared -Wl,-soname,libncp.so.1 -o $(NCP_LIB)
INSTALL_LIB = install $(NCP_LIB) -m 755 /lib; \
ln -sf $(NCP_LIB) /lib/libncp.so.1; \
ldconfig
export PIC_FLAG
else
NCP_LIB = libncp.a
LIB_LINK_COMMAND = ar r libncp.a
endif
CFLAGS += $(PIC_FLAG)
ifdef NDS_SUPPORT
CFLAGS += -DNDS_SUPPORT
NDS_OBJ = ndslib.o mpilib.o ndscrypt.o
endif
ifdef SIGNATURES
CFLAGS += -DSIGNATURES
SIGN_OBJ = ncpsign.o
endif
default:
make -C ..
all: libcom_err.a ncplib_err.o $(NCP_LIB)
all:
install:
$(INSTALL_LIB)
mpilib.o: mpilib.c
$(CC) $(CFLAGS) -DPORTABLE -DSMITH -DUNIT32 -DMUNIT16 -c mpilib.c
ndscrypt.o: ndscrypt.c
$(CC) $(CFLAGS) -c ndscrypt.c
ndslib.o: ndslib.c
$(CC) $(CFLAGS) -DPORTABLE -DSMITH -DUNIT32 -DMUNIT16 -c ndslib.c
ncpsign.o: ncpsign.c
$(CC) $(CFLAGS) -c ncpsign.c
ncplib.o: ncplib.c ncplib_err.h
$(CC) $(CFLAGS) -c ncplib.c
COM_ERR_CFILES = com_err/com_err.c com_err/error_message.c com_err/et_name.c \
com_err/init_et.c
COM_ERR_OFILES = com_err/com_err.o com_err/error_message.o com_err/et_name.o \
com_err/init_et.o
libcom_err.a: $(COM_ERR_CFILES)
make -C com_err
$(NCP_LIB): ncplib.o ncplib_err.o libcom_err.a $(SIGN_OBJ) $(NDS_OBJ)
$(LIB_LINK_COMMAND) ncplib.o ncplib_err.o $(SIGN_OBJ) \
$(COM_ERR_OFILES) $(NDS_OBJ)
ln -sf libncp.so.1.0 libncp.so.1
ln -sf libncp.so.1 libncp.so
export LD_LIBRARY_PATH=`pwd`:LD_LIBRARY_PATH
ncplib_err.o: ncplib_err.h ncplib_err.c
$(CC) $(CFLAGS) -c ncplib_err.c
ncplib_err.h: ncplib_err.et
com_err/compile_et ncplib_err
ln -sf ../lib/ncplib_err.h ../include/ncplib_err.h
ncplib_err.c: ncplib_err.et
com_err/compile_et ncplib_err
dep: ncplib_err.h
make -C com_err dep
$(CPP) -M $(INCLUDES) *.c > .depend
make -C com_err install
clean:
make -C com_err clean
rm -f *.o *~ ncplib_err.[ch] ../include/ncplib_err.h
rm -f libncp.*
mrproper: clean
mrproper:
make -C com_err mrproper
rm -f $(UTILS) .depend $(DISTFILE)
#
# include a dependency file if one exists

61
lib/Makelib Normal file
View File

@@ -0,0 +1,61 @@
#
# Makefile for the linux ncp-filesystem routines.
#
BASE_OBJ = ncplib.o
ifdef NDS_SUPPORT
NDS_OBJ = ndslib.o mpilib.o
BASE_OBJ += ndscrypt.o
endif
ifdef SIGNATURES
BASE_OBJ += ncpsign.o
endif
O_OBJ := $(BASE_OBJ) $(NDS_OBJ) ncplib_err.o
all: $(NCPLIB)
$(NDS_OBJ): %.o: %.c ncplib_err.h
$(CC) $(CFLAGS) $(CCFLAGS) -DPORTABLE -DSMITH -DUNIT32 -DMUNIT16 -o $@ -c $<
$(BASE_OBJ): %.o: %.c ncplib_err.h
$(CC) $(CFLAGS) $(CCFLAGS) -o $@ -c $<
COM_ERR = ../lib/com_err
COM_ERR_CFILES = $(COM_ERR)/com_err.c $(COM_ERR)/error_message.c \
$(COM_ERR)/et_name.c $(COM_ERR)/init_et.c
COM_ERR_OFILES = $(COM_ERR)/com_err.o $(COM_ERR)/error_message.o \
$(COM_ERR)/et_name.o $(COM_ERR)/init_et.o
O_OBJ += $(COM_ERR_OFILES)
$(COM_ERR_OFILES): %.o: %.c
make -C $(COM_ERR)
ncplib_err.o: ncplib_err.h ncplib_err.c
$(CC) $(CFLAGS) $(CCFLAGS) -c ncplib_err.c
ncplib_err.h ncplib_err.c: ncplib_err.et
$(COM_ERR)/compile_et ../lib/ncplib_err
dep: ncplib_err.h
make -C $(COM_ERR) dep
$(CPP) -M $(INCLUDES) *.c > .depend
clean:
make -C $(COM_ERR) clean
rm -f *.o *~ ncplib_err.[ch] ../include/ncplib_err.h
rm -f libncp.* libcom_err.a
mrproper: clean
make -C $(COM_ERR) mrproper
rm -f $(UTILS) .depend $(DISTFILE)
#
# include a dependency file if one exists
#
ifeq (.depend,$(wildcard .depend))
include .depend
endif

View File

@@ -5,14 +5,13 @@
OBJECTS = com_err.o error_message.o et_name.o init_et.o
CFLAGS = -Wall -O2 $(PIC_FLAG)
all: ../libcom_err.a
../libcom_err.a: $(OBJECTS)
ar r ../libcom_err.a $(OBJECTS)
all: $(OBJECTS)
dep:
$(CPP) -M $(INCLUDES) *.c > .depend
install:
clean:
rm -f *.o ../libcom_err.a

View File

@@ -2,7 +2,7 @@
#
#
AWK=/usr/bin/awk
DIR=com_err/
DIR=../lib/com_err
ROOT=`echo $1 | sed -e s/.et$//`
BASE=`basename $ROOT`

View File

@@ -190,7 +190,7 @@ boolean mp_rotate_left(register unitptr r1,register boolean carry)
/* multiprecision rotate left 1 bit with carry, result in r1. */
/* carry is incoming carry flag-- value should be 0 or 1 */
{ register int precision; /* number of units to rotate */
unsigned int mcarry = carry, nextcarry; /* int is supposed to be
unsigned int mcarry = carry, nextcarry=0; /* int is supposed to be
* the efficient size for ops*/
precision = global_precision;
make_lsbptr(r1,precision);
@@ -1664,7 +1664,7 @@ int countbits(unitptr r)
} /* countbits */
char *copyright_notice(void)
const char *copyright_notice(void)
/* force linker to include copyright notice in the executable object image. */
{ return ("(c)1986 Philip Zimmermann"); } /* copyright_notice */

File diff suppressed because it is too large Load Diff

View File

@@ -14,7 +14,7 @@
(((i)&0xffffffff)>>(32-c)))
/* i386: 32-bit, little endian, handles mis-alignment */
#ifdef __i386__
#define GET_LE32(p) (*(int *)(p))
#define GET_LE32(p) (*(const int *)(p))
#define PUT_LE32(p,v) { *(int *)(p)=v; }
#else
#define GET_LE32(p) DVAL_LH(p,0)
@@ -23,7 +23,7 @@
#define min(a,b) ((a)<(b)?(a):(b))
static void nwsign(char *r_data1, char *r_data2, char *outdata) {
static void nwsign(const char *r_data1, char *r_data2, char *outdata) {
int i;
unsigned int w0,w1,w2,w3;
static int rbit[4]={0, 2, 1, 3};
@@ -68,9 +68,9 @@ static void nwsign(char *r_data1, char *r_data2, char *outdata) {
* the last 8 bytes the encryption key as received from the server.
*/
void sign_init(const char *logindata, char *sign_root) {
char initlast[16]={0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef,
static const char initlast[16]={0x01,0x23,0x45,0x67,0x89,0xab,0xcd,0xef,
0xfe,0xdc,0xba,0x98,0x76,0x54,0x32,0x10};
char *initdata="Authorized NetWare Client";
static const char *initdata="Authorized NetWare Client";
char msg[64];
char hash[16];

View File

@@ -19,6 +19,7 @@
#include <string.h>
#include "ndscrypt.h"
#include "ncplib.h"
static unsigned int rol16(unsigned int i, int c) {
return ((i << c) & 65535) | ((unsigned int)(i & 65535) >> (16 - c));
@@ -27,7 +28,7 @@ static unsigned int ror16(unsigned int i, int c) {
return ((unsigned int)(i & 65535) >> c) | ((i << (16 - c)) & 65535);
}
char nwcryptdata[256]={
static unsigned char nwcryptdata[256]={
0xD9,0x78,0xF9,0xC4,0x19,0xDD,0xB5,0xED,0x28,0xE9,0xFD,0x79,
0x4A,0xA0,0xD8,0x9D,0xC6,0x7E,0x37,0x83,0x2B,0x76,0x53,0x8E,
0x62,0x4C,0x64,0x88,0x44,0x8B,0xFB,0xA2,0x17,0x9A,0x59,0xF5,
@@ -52,13 +53,13 @@ char nwcryptdata[256]={
0xFE,0x7F,0xC1,0xAD};
#if 0
char shuffle_table[32]=
static unsigned char shuffle_table[32]=
{0x48,0x93,0x46,0x67,0x98,0x3D,0xE6,0x8D,
0xB7,0x10,0x7A,0x26,0x5A,0xB9,0xB1,0x35,
0x6B,0x0F,0xD5,0x70,0xAE,0xFB,0xAD,0x11,
0xF4,0x47,0xDC,0xA7,0xEC,0xCF,0x50,0xC0};
char shuffle_table2[256] =
static unsigned char shuffle_table2[256] =
{0x7,0x8,0x0,0x8,0x6,0x4,0xE,0x4,0x5,0xC,0x1,0x7,0xB,0xF,0xA,0x8,
0xF,0x8,0xC,0xC,0x9,0x4,0x1,0xE,0x4,0x6,0x2,0x4,0x0,0xA,0xB,0x9,
0x2,0xF,0xB,0x1,0xD,0x2,0x1,0x9,0x5,0xE,0x7,0x0,0x0,0x2,0x6,0x6,
@@ -77,7 +78,7 @@ char shuffle_table2[256] =
0xC,0x0,0x3,0x6,0xF,0x8,0x7,0xB,0x2,0xD,0xC,0x6,0xA,0xA,0x8,0xD};
#endif
char nwhashdata[256] =
static unsigned char nwhashdata[256] =
{0xBD,0x56,0xEA,0xF2,0xA2,0xF1,0xAC,0x2A,0xB0,0x93,0xD1,0x9C,
0x1B,0x33,0xFD,0xD0,0x30,0x04,0xB6,0xDC,0x7D,0xDF,0x32,0x4B,
0xF7,0xCB,0x45,0x9B,0x31,0xBB,0x21,0x5A,0x41,0x9F,0xE1,0xD9,
@@ -105,13 +106,13 @@ char nwhashdata[256] =
void nwencrypt(const unsigned short *cryptbuf, const char *in, char *out) {
int i, j;
register unsigned int i1, i2, i3, i4;
unsigned short *p;
const unsigned short *p;
i1 = *((unsigned short *)in);
i2 = *((unsigned short *)in + 1);
i3 = *((unsigned short *)in + 2);
i4 = *((unsigned short *)in + 3);
p = (unsigned short *)cryptbuf;
i1 = WVAL_LH(in, 0);
i2 = WVAL_LH(in, 2);
i3 = WVAL_LH(in, 4);
i4 = WVAL_LH(in, 6);
p = cryptbuf;
for (j = 3; j; j--) {
for (i = (j == 2) ? 6 : 5; i; i--) {
i1 = rol16(i1 + (*p++) + (i4 & i3) + (~i4 & i2), 1);
@@ -126,22 +127,22 @@ void nwencrypt(const unsigned short *cryptbuf, const char *in, char *out) {
i4 += cryptbuf[i3 & 63];
}
}
*((unsigned short *)out) = i1;
*((unsigned short *)out + 1) = i2;
*((unsigned short *)out + 2) = i3;
*((unsigned short *)out + 3) = i4;
WSET_LH(out, 0, i1);
WSET_LH(out, 2, i2);
WSET_LH(out, 4, i3);
WSET_LH(out, 6, i4);
}
void nwdecrypt(const unsigned short *cryptbuf, const char *in, char *out) {
int i, j;
unsigned short *p;
const unsigned short *p;
register unsigned int i1, i2, i3, i4;
i1 = *((unsigned short *)in);
i2 = *((unsigned short *)in + 1);
i3 = *((unsigned short *)in + 2);
i4 = *((unsigned short *)in + 3);
p = (unsigned short *)cryptbuf + 64;
i1 = WVAL_LH(in, 0);
i2 = WVAL_LH(in, 2);
i3 = WVAL_LH(in, 4);
i4 = WVAL_LH(in, 6);
p = cryptbuf + 64;
for (j = 3; j; j--) {
for (i = (j == 2) ? 6 : 5; i; i--) {
i4 = ror16(i4, 5) - (~i3 & i1) - (i3 & i2) - (*--p);
@@ -156,10 +157,10 @@ void nwdecrypt(const unsigned short *cryptbuf, const char *in, char *out) {
i1 -= cryptbuf[i4 & 63];
}
}
*((unsigned short *)out) = i1;
*((unsigned short *)out + 1) = i2;
*((unsigned short *)out + 2) = i3;
*((unsigned short *)out + 3) = i4;
WSET_LH(out, 0, i1);
WSET_LH(out, 2, i2);
WSET_LH(out, 4, i3);
WSET_LH(out, 6, i4);
}
void nwcryptinit(unsigned short *scryptbuf, const char *key) {
@@ -219,11 +220,12 @@ void nwdecryptblock(const char *cryptkey, const char *buf, int buflen,
}
void nwhash1(char *hash, int hashlen, const char *data, int datalen) {
unsigned char *hp, *hp1, *dp, *hend, c;
unsigned char *hp, *hp1, *hend, c;
const unsigned char *dp;
hp1 = (hp = (unsigned char *)hash) + 1;
hend = hp + hashlen;
dp = (unsigned char *)data;
dp = (const unsigned char *)data;
while (datalen--) {
*hp = nwhashdata[*hp1 ^ *hp] ^ *dp++;
hp = hp1++;

View File

@@ -37,9 +37,10 @@
#include "ndscrypt.h"
#define USUALS
typedef __u32 word32;
typedef __u16 word16;
typedef u_int32_t word32;
typedef u_int16_t word16;
typedef unsigned char boolean;
#include "mpilib.h"
#include <unistd.h>
#include <fcntl.h>
@@ -47,12 +48,12 @@ typedef unsigned char boolean;
#include <errno.h>
#include "ndslib.h"
static int buf_get_dword_lh(char **buf, char *bufend, unsigned int *v) {
int bindery_only = 0;
static int buf_get_dword_lh(char **buf, char *bufend, u_int32_t *v) {
if ((*buf) + 4 <= bufend) {
if (v)
*v = (unsigned char)(**buf) | (unsigned char)(*(*buf + 1)) << 8 |
(unsigned char)(*(*buf + 2)) << 16 |
(unsigned char)(*(*buf + 3)) << 24;
*v = DVAL_LH(*buf, 0);
(*buf) += 4;
return 0;
} else
@@ -76,41 +77,39 @@ static int buf_get_lbuf(char **buf, char *bufend, char *out, int outmax,
return -1;
}
static int buf_put_word_lh2(char **buf, char *bufend, unsigned int v) {
static int buf_put_word_lh2(char **buf, char *bufend, u_int16_t v) {
if ((*buf) + 2 <= bufend) {
*((*buf)++) = v & 255;
*((*buf)++) = v >> 8;
WSET_LH(*buf, 0, v);
*buf += 2;
return 0;
} else
return -1;
}
static int buf_put_dword_lh(char **buf, char *bufend, unsigned long v) {
static int buf_put_dword_lh(char **buf, char *bufend, u_int32_t v) {
if ((buf) && ((*buf) + 4 <= bufend)) {
*((*buf)++) = v & 255;
*((*buf)++) = (v >> 8) & 255;
*((*buf)++) = (v >> 16) & 255;
*((*buf)++) = v >> 24;
DSET_LH(*buf, 0, v);
*buf += 4;
return 0;
} else
return -1;
}
static int buf_put_dword_hl(char **buf, char *bufend, unsigned long v) {
static int buf_put_dword_hl(char **buf, char *bufend, u_int32_t v) {
if ((*buf) + 4 <= bufend) {
*((*buf)++) = v >> 24;
*((*buf)++) = (v >> 16) & 255;
*((*buf)++) = (v >> 8) & 255;
*((*buf)++) = v & 255;
DSET_HL(*buf, 0, v);
*buf += 4;
return 0;
} else
return -1;
}
static int buf_put_lbuf(char **buf, char *bufend, const char *databuf,
int buflen) {
if ((databuf) && (!buf_put_dword_lh(buf, bufend, buflen)) &&
size_t buflen) {
if ((!buf_put_dword_lh(buf, bufend, buflen)) &&
(*buf + buflen <= bufend)) {
if (!buflen) return 0; /* explicitly allow {NULL, 0} buffer */
if (!databuf) return -1;
memcpy(*buf, databuf, buflen);
(*buf) += buflen;
while (buflen++ & 3)
@@ -121,7 +120,7 @@ static int buf_put_lbuf(char **buf, char *bufend, const char *databuf,
}
static int buf_put_buf(char **buf, char *bufend, const char *databuf,
int buflen) {
size_t buflen) {
if ((databuf) && (*buf + buflen <= bufend)) {
memcpy(*buf, databuf, buflen);
(*buf) += buflen;
@@ -137,7 +136,7 @@ static int buf_put_unistr(char **buf, char *bufend, const uni_char *str) {
if ((str) && (!buf_put_dword_lh(buf, bufend, i)) &&
(*buf + i <= bufend)) {
memcpy(*buf, (char *)str, i);
memcpy(*buf, str, i);
(*buf) += i;
while (i++ & 3)
*(*buf)++ = 0;
@@ -146,13 +145,10 @@ static int buf_put_unistr(char **buf, char *bufend, const uni_char *str) {
return -1;
}
static int buf_get_dword_hl(char **buf, char *bufend, unsigned int *v) {
static int buf_get_dword_hl(char **buf, char *bufend, u_int32_t *v) {
if ((*buf) + 4 <= bufend) {
if (v) {
*v = (unsigned char)(**buf) << 24 |
(unsigned char)(*(*buf + 1)) << 16 |
(unsigned char)(*(*buf + 2)) << 8 |
(unsigned char)(*(*buf + 3));
*v = DVAL_HL(*buf, 0);
}
(*buf) += 4;
return 0;
@@ -160,18 +156,22 @@ static int buf_get_dword_hl(char **buf, char *bufend, unsigned int *v) {
return -1;
}
static int buf_get_word_lh(char **buf, char *bufend, unsigned int *v) {
if ((v) && ((*buf) + 2 <= bufend)) {
*v = (unsigned char)(**buf) | (unsigned char)(*(*buf + 1)) << 8;
static int buf_get_word_lh(char **buf, char *bufend, u_int16_t *v) {
if (((*buf) + 2 <= bufend)) {
if (v) {
*v = WVAL_LH(*buf, 0);
}
(*buf) += 4;
return 0;
} else
return -1;
}
static int buf_get_word_lh2(char **buf, char *bufend, unsigned int *v) {
if ((v) && ((*buf) + 2 <= bufend)) {
*v = (unsigned char)(**buf) | (unsigned char)(*(*buf + 1)) << 8;
static int buf_get_word_lh2(char **buf, char *bufend, u_int16_t *v) {
if (((*buf) + 2 <= bufend)) {
if (v) {
*v = WVAL_LH(*buf, 0);
}
(*buf) += 2;
return 0;
} else
@@ -199,7 +199,7 @@ static int buf_get_lbuf_alloc(char **buf, char *bufend,
}
}
static int buf_get_buf(char **buf, char *bufend, char *outbuf, int bufsize) {
static int buf_get_buf(char **buf, char *bufend, char *outbuf, size_t bufsize) {
if (*buf + bufsize <= bufend) {
if (outbuf) memcpy(outbuf, *buf, bufsize);
*buf += (bufsize + 3) & (~3);
@@ -251,7 +251,9 @@ long nds_get_tree_name(struct ncp_conn *conn, char *name, int name_buf_len) {
int size;
long err;
char *p, *pend;
if (bindery_only) return -1;
if (!(err = ncp_send_nds(conn, 1, "\0\0\0", 3, buf, sizeof(buf),
&size))) {
p = buf + 4;
@@ -272,7 +274,7 @@ long nds_get_tree_name(struct ncp_conn *conn, char *name, int name_buf_len) {
/* for login */
long nds_resolve_name(struct ncp_conn *conn, int flags, uni_char *entry_name,
int *entry_id, int *remote, struct sockaddr *serv_addr, int *addr_len) {
int *entry_id, int *remote, struct sockaddr *serv_addr, size_t *addr_len) {
char *buf, *p, *pend, addr_buf[12];
long err;
int i;
@@ -455,7 +457,7 @@ void fillrandom(char *buf, int buflen) {
}
#endif
int countbits_l(char *buf, int bufsize) {
static int countbits_l(char *buf, int bufsize) {
unsigned char b;
while ((--bufsize) && (!buf[bufsize]));
@@ -467,34 +469,33 @@ int countbits_l(char *buf, int bufsize) {
return bufsize;
}
void copyfill(void *outbuf, int outsize, const void *inbuf, int insize) {
static void copyfill(void *outbuf, int outsize, const void *inbuf, int insize) {
if (outsize < insize) insize = outsize;
memcpy(outbuf, inbuf, insize);
memset((char *)outbuf + insize, 0, outsize - insize);
}
uni_char c_public_key[] = {'P','u','b','l','i','c',' ','K','e','y',0};
static uni_char c_public_key[] = {'P','u','b','l','i','c',' ','K','e','y',0};
char keyprefix[] = {1, 0, 0, 0, 3, 0, 1, 0};
static char keyprefix[] = {1, 0, 0, 0, 3, 0, 1, 0};
int initkey(const char *key, char **keyptr, int *keylen) { /* 1=ok, 0=err */
static int initkey(const char *key, char **keyptr, int *keylen) { /* 1=ok, 0=err */
if (!memcmp(key, keyprefix, 8)) {
if (keylen) *keylen = (unsigned char)key[8] | \
(unsigned char)key[9] << 8;
if (keylen) *keylen = WVAL_LH(key, 8);
if (keyptr) (const char *)(*keyptr) = key + 10;
return 1;
} else
return 0;
}
void clearkey(char *key) {
static void clearkey(char *key) {
char *keyptr;
int keylen;
if (initkey(key, &keyptr, &keylen))
memset(key, 0, keylen + 10);
}
int findchunk(const char *keyptr, int keylen, const char *chunk,
static int findchunk(const char *keyptr, int keylen, const char *chunk,
char **chunkptr) {
const char *p;
@@ -512,7 +513,7 @@ int findchunk(const char *keyptr, int keylen, const char *chunk,
return 0;
}
int checkkey(const char *key) { /* 0 - wrong key, != 0 - key ok */
static int checkkey(const char *key) { /* 0 - wrong key, != 0 - key ok */
char temp[8];
char *keyptr, *p;
int keylen;
@@ -520,15 +521,14 @@ int checkkey(const char *key) { /* 0 - wrong key, != 0 - key ok */
if ((initkey(key, &keyptr, &keylen)) &&
(findchunk(keyptr, keylen, "MA", &p))) {
nwhash1init(temp, 8);
nwhash1(temp, 8, key + 10, (unsigned char)key[8] +
((unsigned char)key[9] << 8) - 20);
nwhash1(temp, 8, key + 10, WVAL_LH(key, 8) - 20);
return (!memcmp(p, temp, 8));
} else
return 0;
}
long modexpkey(const char *s_key, char *buf, char *outbuf, int bufsize) {
static long modexpkey(const char *s_key, char *buf, char *outbuf, int bufsize) {
char *s_keyptr;
int s_keylen, i, nbits, nblocksize;
int err = -1;
@@ -580,7 +580,7 @@ long get_public_key(struct ncp_conn *conn, long obj_id, char **key) {
if ((err = nds_read(conn, obj_id, c_public_key, &keybuf, &keylen))) {
return err;
}
ofs = (unsigned char)keybuf[10] + ((unsigned char)keybuf[11] << 8) + 0x1a;
ofs = WVAL_LH(keybuf, 10) + 0x1a;
if ((ofs > keylen) || (!initkey(keybuf + ofs, &kptr, &klen)) ||
(klen + ofs > keylen) || (!checkkey(keybuf + ofs))) {
err = NCPL_ET_REPLY_FORMAT;
@@ -603,7 +603,7 @@ err_exit:
char buf2str1[8] = {1,0,0,0,9,0,2,0};
char buf2str2[16] = {65,0,0,0,1,0,0,0,1,0,9,0,53,0,28,0};
char buf2str3[8] = {1,0,0,0,1,0,6,0};
long rsa_crypt(struct ncp_conn *conn, char *data, int datalen,
static long rsa_crypt(struct ncp_conn *conn, char *data, int datalen,
long serv_id, char **outp, char *pend) {
char rand[28];
char hashrand[8], temp[8];
@@ -665,7 +665,7 @@ long rsa_crypt(struct ncp_conn *conn, char *data, int datalen,
return 0;
}
char bufstr[16]={28, 0, 0, 0, 1, 0, 0, 0, 1, 0, 6, 0, 16, 0, 4, 0};
static char bufstr[16]={28, 0, 0, 0, 1, 0, 0, 0, 1, 0, 6, 0, 16, 0, 4, 0};
long nds_login(struct ncp_conn *conn, long user_id, const char *pwd,
long serv_id, char *logindata, char **u_priv_key) {
char *buf, *p, *pend;
@@ -677,7 +677,8 @@ long nds_login(struct ncp_conn *conn, long user_id, const char *pwd,
char randbuf[1024];
char *tempbuf;
int i, outlen;
int n1, n2, n3;
int n1, n2;
u_int16_t n2a, n3;
long err;
int grace_period = 0;
@@ -787,9 +788,9 @@ long nds_login(struct ncp_conn *conn, long user_id, const char *pwd,
pend = p + n3;
nwdecryptblock(hashshuf, p, n3, p);
if ((buf_get_dword_lh(&p, pend, &n1)) ||
(buf_get_word_lh2(&p, pend, &n2)) ||
(buf_get_word_lh2(&p, pend, &n2a)) ||
(buf_get_word_lh2(&p, pend, &n3)) ||
(n1 != 1) || (n2 != 2) || (n3 > pend - p))
(n1 != 1) || (n2a != 2) || (n3 > pend - p))
goto err_exit;
if (u_priv_key) {
if (!(tempbuf = malloc(n3 + 10))) {
@@ -800,8 +801,7 @@ long nds_login(struct ncp_conn *conn, long user_id, const char *pwd,
tempbuf[0] = 1;
tempbuf[4] = 3;
tempbuf[6] = 1;
tempbuf[8] = n3 & 255;
tempbuf[9] = n3 >> 8;
WSET_LH(tempbuf, 8, n3);
memcpy(tempbuf + 10, p, n3);
if (!checkkey(tempbuf)) {
free(tempbuf);
@@ -825,13 +825,14 @@ err_exit:
return err;
}
long nds_beginauth(struct ncp_conn *conn, long user_id,
long nds_beginauth(struct ncp_conn *conn, long user_id, struct ncp_conn *readkey_conn,
long serv_id, char *authid) {
char *buf, *p, *pend, *n_temp, temp[8];
char *s_key;
char randno[4];
long err;
int outlen, n1, n2, n3, n4;
u_int16_t n3a;
if (!(buf = malloc(2048)))
return ENOMEM;
@@ -861,20 +862,20 @@ long nds_beginauth(struct ncp_conn *conn, long user_id,
if ((buf_get_dword_lh(&p, pend, &n1)) ||
(buf_get_dword_lh(&p, pend, &n1)) ||
(buf_get_dword_lh(&p, pend, &n2)) ||
(buf_get_word_lh(&p, pend, &n3)) ||
(n1 != 1) || (n2 != 0x0a0001) || (n3 > pend - p))
(buf_get_word_lh(&p, pend, &n3a)) ||
(n1 != 1) || (n2 != 0x0a0001) || (n3a > pend - p))
goto err_exit;
n1 = ((countbits_l(p, n3) + 31) & (~31)) >> 3;
n1 = ((countbits_l(p, n3a) + 31) & (~31)) >> 3;
if (n1 < 52)
goto err_exit;
if (!(n_temp = malloc(n1))) {
err = ENOMEM;
goto err_exit;
}
copyfill(n_temp, n1, p, n3);
p += (n3 + 3) & (~3);
copyfill(n_temp, n1, p, n3a);
p += (n3a + 3) & (~3);
if ((err = get_public_key(conn, serv_id, &s_key)))
if ((err = get_public_key(readkey_conn, serv_id, &s_key)))
goto err_exit;
err = modexpkey(s_key, n_temp, n_temp, n1);
free(s_key);
@@ -908,7 +909,7 @@ err_exit:
return err;
}
char *allocfillchunk(const char *keyptr, int keylen, const char *chunk,
static char *allocfillchunk(const char *keyptr, int keylen, const char *chunk,
int destsize) {
char *p, *p2;
int i;
@@ -921,7 +922,7 @@ char *allocfillchunk(const char *keyptr, int keylen, const char *chunk,
return p2;
}
long gen_auth_data(char **outp, char *outend,
static long gen_auth_data(char **outp, char *outend,
const char *u_key, const char *u_priv_key,
const char *authid, char *loginstrc, int loginstrc_len) {
char *keyptr;
@@ -1054,7 +1055,7 @@ err_exit:
}
long nds_authenticate(struct ncp_conn *conn, long user_id,
long nds_authenticate(struct ncp_conn *conn, long user_id, struct ncp_conn* readkey_conn,
long serv_id, const char *logindata, const char *u_priv_key) {
char authid[4];
long err;
@@ -1068,8 +1069,9 @@ long nds_authenticate(struct ncp_conn *conn, long user_id,
char signkey[8];
#endif
if (!readkey_conn) readkey_conn = conn;
u_key = loginstrc = buf = NULL;
if ((err = nds_beginauth(conn, user_id, serv_id, authid)))
if ((err = nds_beginauth(conn, user_id, readkey_conn, serv_id, authid)))
return err;
if ((err = nds_readentryname(conn, user_id, &user_name, &user_name_len)))
return err;
@@ -1083,8 +1085,7 @@ long nds_authenticate(struct ncp_conn *conn, long user_id,
loginstrc[4] = 6;
memcpy(loginstrc + 6, logindata, 8);
fillrandom(loginstrc + 14, 4);
loginstrc[20] = user_name_len & 255;
loginstrc[21] = user_name_len >> 8;
WSET_LH(loginstrc, 20, user_name_len);
memcpy(loginstrc + 22, user_name, user_name_len);
free(user_name); user_name = NULL;
if ((err = get_public_key(conn, user_id, &u_key)))
@@ -1098,7 +1099,7 @@ long nds_authenticate(struct ncp_conn *conn, long user_id,
#ifdef SIGNATURES
if (conn->sign_wanted) {
fillrandom(signkey, 8);
rsa_crypt(conn, signkey, 8, serv_id, &p, pend);
rsa_crypt(readkey_conn, signkey, 8, serv_id, &p, pend);
} else
#endif
buf_put_dword_lh(&p, pend, 0);
@@ -1132,7 +1133,7 @@ long nds_login_auth(struct ncp_conn *conn, const char *user,
uni_char *server_name = NULL;
__u32 serv_id, user_id;
struct sockaddr_ipx wserv_addr;
struct ncp_conn *login_conn, *wserv_conn = NULL;
struct ncp_conn *login_conn, *wserv_conn = NULL, *readkey_conn = NULL;
int not_wserv; /* =1: current server doesn't have a writable replica */
int i;
struct timeval tv;
@@ -1177,7 +1178,7 @@ long nds_login_auth(struct ncp_conn *conn, const char *user,
goto err_exit;
}
if (not_wserv) {
if (!(login_conn = wserv_conn = ncp_open_addr(&wserv_addr, &err)))
if (!(login_conn = wserv_conn = ncp_open_addr((struct sockaddr*)&wserv_addr, &err)))
goto err_exit;
} else
login_conn = conn;
@@ -1201,17 +1202,26 @@ err_exit2:;
grace_period = 1;
}
if (not_wserv) {
struct sockaddr xaddr;
int remoteserver;
int i;
free(server_name);
if ((err = nds_get_server_name(conn, &server_name)) != 0)
goto err_exit;
i = sizeof(xaddr);
if ((err = nds_resolve_name(conn, 0x62, server_name, &serv_id,
NULL, NULL, NULL)) != 0)
&remoteserver, (struct sockaddr*)&xaddr, &i)) != 0)
goto err_exit;
if (remoteserver) {
if (!(readkey_conn = ncp_open_addr((struct sockaddr*)&xaddr, &err)))
goto err_exit;
}
if ((err = nds_resolve_name(conn, 0x51, user_u, &user_id,
NULL, NULL, NULL)) !=0)
goto err_exit;
}
if ((err = nds_authenticate(conn, user_id, serv_id, logindata,
if ((err = nds_authenticate(conn, user_id, readkey_conn, serv_id, logindata,
u_priv_key))) {
#ifdef ERR_MSG
if (err == NCPL_ET_REQUEST_ERROR)
@@ -1224,6 +1234,7 @@ err_exit2:;
err = NCPL_ET_REQUEST_ERROR;
}
err_exit:
if (readkey_conn) ncp_close(readkey_conn);
if (wserv_conn) ncp_close(wserv_conn);
if (u_priv_key) { clearkey(u_priv_key); free(u_priv_key); }
free(server_name);
@@ -1233,3 +1244,10 @@ err_exit:
#endif
return err;
}
#ifdef NDS_PRIVATEKEY
long
nds_authenticate(struct ncp_conn* conn, uni_char* name, u_int8_t* code1, void* privateKey, size_t privateKeyLen) {
}
#endif /* NDS_PRIVATE_KEY */

View File

@@ -211,6 +211,7 @@ nw_encrypt(const unsigned char *fra,
til[s] = k[s] ^ k[15 - s];
}
#ifndef __MAKE_SULIB__
/*****************************************************************************/
/* */
@@ -341,3 +342,5 @@ newpassencrypt(char *old, char *new, char *out)
memcpy(copy, out, 8);
}
}
#endif /* __MAKE_SULIB__ */

View File

@@ -3,16 +3,14 @@
#ifndef USUALS /* Assures no redefinitions of usual types...*/
#define USUALS
#include <sys/types.h>
typedef unsigned char boolean; /* values are TRUE or FALSE */
typedef unsigned char byte; /* values are 0-255 */
typedef u_int8_t byte; /* values are 0-255 */
typedef byte *byteptr; /* pointer to byte */
typedef char *string; /* pointer to ASCII character string */
typedef unsigned short word16; /* values are 0-65535 */
#ifdef __alpha
typedef unsigned int word32; /* values are 0-4294967295 */
#else
typedef unsigned long word32; /* values are 0-4294967295 */
#endif
typedef u_int16_t word16; /* values are 0-65535 */
typedef u_int32_t word32; /* values are 0-4294967295 */
#ifndef TRUE
#define FALSE 0

View File

@@ -1,12 +1,22 @@
include ../Makeinit
MAN1 = ncopy nwbols nwfsinfo nwsfind pqlist nprint nwboprops nwfstime \
nwtrustee pserver nsend nwbpset nwpasswd nwuserlist slist \
nwauth nwbpvalues nwrights nwvolinfo pqrm pqstat nwpurge
MAN5 = nwclient
MAN8 = ncpmount nwbpadd nwmsg ncpumount nwbpcreate nwrevoke nwbocreate \
nwbprm nwborm nwgrant
all:
dep:
install:
for i in *.1; do install $$i -m 755 /usr/local/man/man1; done
for i in *.5; do install $$i -m 755 /usr/local/man/man5; done
for i in *.8; do install $$i -m 755 /usr/local/man/man8; done
for i in $(MAN1); do install $$i.1 -m 644 $(MANDIR)/man1; done
for i in $(MAN5); do install $$i.5 -m 644 $(MANDIR)/man5; done
for i in $(MAN8); do install $$i.8 -m 644 $(MANDIR)/man8; done
clean:
rm -f *~
rm -f *~
mrproper: clean

65
man/nwpurge.1 Normal file
View File

@@ -0,0 +1,65 @@
.TH NWPURGE 1 4/2/1998 nwpurge nwpurge
.SH NAME
nwpurge \- Permanently delete previously erased files
.SH SYNOPSIS
.B nwpurge
[
.B -h
] [
.B -a
] [
.B -l
] [
.B -s
] [
.B directory
]
.SH DESCRIPTION
.B nwpurge
purges files from specified NetWare directory.
.SH OPTIONS
.B -h
.RS 3
.B -h
is used to print out a short help text.
.RE
.B -a
.RS 3
.B -a
is used to specify that not only specified directory, but also its
subdirectories have to be purged.
.RE
.B -l
.RS 3
.B -l
is used to disable purge. Files are only printed out.
.RE
.B -s
.RS 3
.B -s
specifies silent mode (no print output, only total is printed).
.RE
.B directory
.RS 3
You can specify the directory in which you want to purge files. Current
working directory is used by default. You have to specify path in
Linux format, not in NetWare format.
.SH EXAMPLES
nwpurge -a /NetWare/server/sys
With this example, all files from directory /NetWare/server/sys and from
all its subdirectories are purged.
.SH AUTHORS
nwpurge was written by Petr Vandrovec with the corresponding NetWare
utility in mind. See the Changes file of ncpfs for other contributors.

View File

@@ -1,7 +1,7 @@
Begin3
Title: ncpfs
Version: 2.0.12
Entered-date: March 13, 1998
Version: 2.2.0
Entered-date: May 1, 1998
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
@@ -12,7 +12,8 @@ Maintained-by: lendecke@Math.Uni-Goettingen.de (Volker Lendecke),
vandrove@vc.cvut.cz (Petr Vandrovec)
Primary-site: ftp.gwdg.de:/pub/linux/misc/ncpfs
Alternate-site: sunsite.unc.edu:/pub/Linux/system/Filesystems/ncpfs
~195k ncpfs-2.0.12.tgz
~ 1k ncpfs-2.0.12.lsm
platan.vc.cvut.cz:/pub/linux/ncpfs
~190k ncpfs-2.2.0.tgz
~ 1k ncpfs-2.2.0.lsm
Copying-policy: GPL
End

View File

@@ -2,28 +2,18 @@
# Makefile for the linux ncp-filesystem routines.
#
UTILS = ncpmount ncpumount nwsfind
include ../Makeinit
CC = gcc
CFLAGS += -D__MAKE_NCPMOUNT__
ifdef NDS_SUPPORT
CFLAGS += -DNDS_SUPPORT
NDS_OBJ = ../lib/ndslib.o ../lib/mpilib.o ../lib/ndscrypt.o
endif
ifdef SIGNATURES
CFLAGS += -DSIGNATURES
SIGN_OBJ = ../lib/ncpsign.o
endif
ifdef MOUNT2
CFLAGS += -DMOUNT2
endif
ifdef MOUNT3
# _GNU_SOURCE for environ variable
CFLAGS += -DMOUNT3 -D_GNU_SOURCE
# environ in ncpmount
CCFLAGS += -D_GNU_SOURCE
endif
O_UTILS = ncpmount.o ncpumount.o nwsfind.o
UTILS = $(O_UTILS:%.o=%)
CCFLAGS += -D__MAKE_SULIB__
default:
make -C ..
@@ -33,20 +23,20 @@ install: all
for i in $(UTILS); \
do install $$i -m 4755 $(BINDIR); done
$(UTILS): %: %.o libncp.a
$(CC) -o $@ $(addsuffix .o,$@) -L. -lncp -L../lib -lcom_err
$(O_UTILS): %.o: %.c ../lib-static-su/ncplib_err.h
$(CC) $(CFLAGS) $(CCFLAGS) -I../lib-static-su -o $@ -c $<
ncplib.o: ncplib.c ncplib.h
$(CC) $(CFLAGS) -finline-functions -c ncplib.c
$(UTILS): %: %.o ../lib-static-su/libncp.a
$(CC) -o $@ $(addsuffix .o,$@) -L../lib-static-su -lncp
libncp.a: ncplib.o ../lib/ncplib_err.o $(SIGN_OBJ) $(NDS_OBJ)
ar r libncp.a ncplib.o ../lib/ncplib_err.o $(SIGN_OBJ) $(NDS_OBJ)
../lib-static-su/libncp.a ../lib-static-su/ncplib_err.h:
make -C ../lib-static-su libncp.a
dep:
$(CPP) -M $(INCLUDES) *.c > .depend
clean:
rm -f *.o *~ libncp.a $(UTILS)
rm -f *.o *~ $(UTILS)
mrproper: clean
rm -f .depend

File diff suppressed because it is too large Load Diff

View File

@@ -1,339 +0,0 @@
/*
* ncplib.h
*
* Copyright (C) 1995, 1996 by Volker Lendecke
*
*/
#ifndef _NCPLIB_H
#define _NCPLIB_H
#include <sys/types.h>
#include "ncp.h"
#include <sys/param.h>
#include <stdio.h>
#include <time.h>
#include "ipxlib.h"
#include "com_err.h"
#ifndef memzero
#include <string.h>
#define memzero(object) memset(&(object), 0, sizeof(object))
#endif
typedef __u8 byte;
typedef __u16 word;
typedef __u32 dword;
#define BVAL(buf,pos) (((__u8 *)(buf))[pos])
#define PVAL(buf,pos) ((unsigned)BVAL(buf,pos))
#define BSET(buf,pos,val) (BVAL(buf,pos) = (val))
static inline word
WVAL_HL(__u8 * buf, int pos)
{
return PVAL(buf, pos) << 8 | PVAL(buf, pos + 1);
}
static inline dword
DVAL_HL(__u8 * buf, int pos)
{
return WVAL_HL(buf, pos) << 16 | WVAL_HL(buf, pos + 2);
}
static inline void
WSET_HL(__u8 * buf, int pos, word val)
{
BSET(buf, pos, val >> 8);
BSET(buf, pos + 1, val & 0xff);
}
static inline void
DSET_HL(__u8 * buf, int pos, dword val)
{
WSET_HL(buf, pos, val >> 16);
WSET_HL(buf, pos + 2, val & 0xffff);
}
/* we know that the 386 can handle misalignment and has the "right"
byteorder */
#if defined(__i386__)
static inline word
WVAL_LH(__u8 * buf, int pos)
{
return *((word *) (buf + pos));
}
static inline dword
DVAL_LH(__u8 * buf, int pos)
{
return *((dword *) (buf + pos));
}
static inline void
WSET_LH(__u8 * buf, int pos, word val)
{
*((word *) (buf + pos)) = val;
}
static inline void
DSET_LH(__u8 * buf, int pos, dword val)
{
*((dword *) (buf + pos)) = val;
}
#else
static inline word
WVAL_LH(__u8 * buf, int pos)
{
return PVAL(buf, pos) | PVAL(buf, pos + 1) << 8;
}
static inline dword
DVAL_LH(__u8 * buf, int pos)
{
return WVAL_LH(buf, pos) | WVAL_LH(buf, pos + 2) << 16;
}
static inline void
WSET_LH(__u8 * buf, int pos, word val)
{
BSET(buf, pos, val & 0xff);
BSET(buf, pos + 1, val >> 8);
}
static inline void
DSET_LH(__u8 * buf, int pos, dword val)
{
WSET_LH(buf, pos, val & 0xffff);
WSET_LH(buf, pos + 2, val >> 16);
}
#endif
void
str_upper(char *name);
enum connect_state
{
NOT_CONNECTED = 0,
CONN_PERMANENT,
CONN_TEMPORARY
};
struct ncp_conn
{
enum connect_state is_connected;
char server[NCP_BINDERY_NAME_LEN];
char user[NCP_BINDERY_NAME_LEN];
struct ncp_fs_info i;
/* Fields for use with permanent connections */
int mount_fid;
char mount_point[MAXPATHLEN];
/* Fields for use with temporary connections */
int ncp_sock;
int wdog_sock;
int wdog_pid;
__u8 sequence;
int completion;
int conn_status;
int reply_size;
/* Fields used to setup ncp requests */
int current_size;
int has_subfunction;
int verbose;
int ncp_reply_size;
int lock;
char packet[NCP_PACKET_SIZE];
#ifdef SIGNATURES
/* Field used to make packet signatures */
int sign_wanted;
int sign_active;
char sign_root[8];
char sign_last[16];
#endif
};
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_property_info
{
__u8 property_name[16];
__u8 property_flags;
__u8 property_security;
__u32 search_instance;
__u8 value_available_flag;
__u8 more_properties_flag;
};
/* 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
from the list. It was designed after the X Windows init
functions. */
struct ncp_conn *
ncp_initialize(int *argc, char **argv,
int login_necessary, long *err);
/* You can login as another object by this procedure. As a first use
pserver comes to mind. */
struct ncp_conn *
ncp_initialize_as(int *argc, char **argv,
int login_necessary, int login_type, long *err);
/* Open a connection */
struct ncp_conn *
ncp_open(struct ncp_conn_spec *spec, long *err);
/* Open a connection on an existing mount point */
struct ncp_conn *
ncp_open_mount(const char *mount_point, long *err);
/* Find a permanent connection that fits the spec, return NULL if
* there is none. */
char *
ncp_find_permanent(const struct ncp_conn_spec *spec);
/* Find the address of a file server */
struct sockaddr_ipx *
ncp_find_fileserver(char *server_name, long *err);
/* Find the address of a server */
struct sockaddr_ipx *
ncp_find_server(char **server_name, int type, long *err);
/* Detach from a permanent connection or destroy a temporary
connection */
long
ncp_close(struct ncp_conn *conn);
/* like getmntent, get_ncp_conn_ent scans /etc/mtab for usable
connections */
struct ncp_conn_ent
{
char server[NCP_BINDERY_NAME_LEN];
char user[NCP_BINDERY_NAME_LEN];
uid_t uid;
char mount_point[MAXPATHLEN];
};
struct ncp_conn_ent *
ncp_get_conn_ent(FILE * filep);
#define NWCLIENT (".nwclient")
#define NWC_NOPASSWORD ("-")
/* find an appropriate connection */
struct ncp_conn_spec *
ncp_find_conn_spec(const char *server, const char *user, const char *password,
int login_necessary, uid_t uid, long *err);
struct ncp_conn_spec *
ncp_find_conn_spec2(const char *server, const char *user, const char *password,
int login_necessary, uid_t uid, int allow_multiple_conns,
long *err);
long
ncp_get_encryption_key(struct ncp_conn *conn,
char *target);
struct ncp_station_addr
{
__u32 NetWork __attribute__((packed));
__u8 Node[6] __attribute__((packed));
__u16 Socket __attribute__((packed));
};
struct ncp_prop_login_control
{
__u8 AccountExpireDate[3] __attribute__((packed));
__u8 Disabled __attribute__((packed));
__u8 PasswordExpireDate[3] __attribute__((packed));
__u8 GraceLogins __attribute__((packed));
__u16 PasswordExpireInterval __attribute__((packed));
__u8 MaxGraceLogins __attribute__((packed));
__u8 MinPasswordLength __attribute__((packed));
__u16 MaxConnections __attribute__((packed));
__u8 ConnectionTimeMask[42] __attribute__((packed));
__u8 LastLogin[6] __attribute__((packed));
__u8 RestrictionMask __attribute__((packed));
__u8 reserved __attribute__((packed));
__u32 MaxDiskUsage __attribute__((packed));
__u16 BadLoginCount __attribute__((packed));
__u32 BadLoginCountDown __attribute__((packed));
struct ncp_station_addr LastIntruder __attribute__((packed));
};
long
ncp_read_property_value(struct ncp_conn *conn,
int object_type, const char *object_name,
int segment, const char *prop_name,
struct nw_property *target);
#define NWE_SIGNATURE_LEVEL_CONFLICT (0x8861)
#define NCP_GRACE_PERIOD (0xdf)
long
ncp_get_bindery_object_id(struct ncp_conn *conn,
__u16 object_type,
const char *object_name,
struct ncp_bindery_object *target);
long
ncp_login_user(struct ncp_conn *conn,
const unsigned char *username,
const unsigned char *password);
long
ncp_get_broadcast_message(struct ncp_conn *conn, char message[256]);
#ifdef SIGNATURES
long
ncp_sign_start(struct ncp_conn *conn, const char *sign_root);
#endif
#ifdef NDS_SUPPORT
long
ncp_send_nds_frag(struct ncp_conn *conn,
int ndsverb,
char *inbuf, int inbuflen,
char *outbuf, int outbufsize, int *outbuflen);
long
ncp_send_nds(struct ncp_conn *conn, int fn,
char *data_in, int data_in_len,
char *data_out, int data_out_max, int *data_out_len);
long
ncp_change_conn_state(struct ncp_conn *conn, int new_state);
struct ncp_conn *
ncp_open_addr(struct sockaddr_ipx *target, long *err);
#endif
int
ncp_path_to_NW_format(const char* path, unsigned char* buff, int buffsize);
long
ncp_obtain_file_or_subdir_info2(struct ncp_conn* conn, __u8 source_ns,
__u8 target_ns, __u16 search_attribs, __u32 rim,
int dir_style, __u8 vol, __u32 dirent,
const unsigned char* path, int pathlen,
struct nw_info_struct* target);
int
ncp_get_mount_uid(int fid, uid_t* uid);
#endif /* _NCPLIB_H */

View File

@@ -68,6 +68,7 @@ static char mount_point[MAXPATHLEN + 1];
static void usage(void);
static void help(void);
#ifdef MOUNT2
/* Returns 0 if the filesystem is in the kernel after this routine
completes */
static int
@@ -130,9 +131,34 @@ load_ncpfs(void)
}
return status;
}
#endif /* MOUNT2 */
struct ncp_mount_data_independent {
int ncp_fd;
int wdog_fd;
int message_fd;
uid_t mounted_uid;
struct sockaddr_ipx serv_addr;
unsigned char *server_name;
unsigned char *mount_point;
unsigned char *mounted_vol;
unsigned int time_out;
unsigned int retry_count;
struct {
unsigned int mount_soft:1;
unsigned int mount_intr:1;
unsigned int mount_strong:1;
unsigned int mount_no_os2:1;
unsigned int mount_no_nfs:1;
} flags;
uid_t uid;
gid_t gid;
mode_t file_mode;
mode_t dir_mode;
};
#ifdef MOUNT3
static int process_connection(int wdog_fd, int msg_fd);
static int process_connection(const struct ncp_mount_data_independent* mnt);
#endif
#if MULTIVERSION_MOUNT
@@ -201,7 +227,7 @@ mount_ok(struct stat *st)
* This function changes the processes name as shown by the system.
* Stolen from Marcin Dalecki's modald :-)
*/
static void inststr(char *dst[], int argc, char *src)
static void inststr(char *dst[], int argc, const char *src)
{
/* stolen from the source to perl 4.036 (assigning to $0) */
char *ptr, *ptr2;
@@ -228,34 +254,14 @@ static void inststr(char *dst[], int argc, char *src)
}
#endif
struct ncp_mount_data_independent {
unsigned int ncp_fd;
unsigned int wdog_fd;
unsigned int message_fd;
uid_t mounted_uid;
struct sockaddr_ipx serv_addr;
unsigned char *server_name;
unsigned char *mount_point;
unsigned char *mounted_vol;
unsigned int time_out;
unsigned int retry_count;
struct {
unsigned int mount_soft:1;
unsigned int mount_intr:1;
unsigned int mount_strong:1;
unsigned int mount_no_os2:1;
unsigned int mount_no_nfs:1;
} flags;
uid_t uid;
gid_t gid;
mode_t file_mode;
mode_t dir_mode;
};
#ifdef MOUNT2
int ncp_mount_v2(const char* mount_name, unsigned long flags, const struct ncp_mount_data_independent* data) {
struct ncp_mount_data_v2 datav2;
if (data->serv_addr.sipx_family != AF_IPX) {
errno = EPROTONOSUPPORT;
return -1;
}
datav2.version = NCP_MOUNT_VERSION_V2;
datav2.ncp_fd = data->ncp_fd;
datav2.wdog_fd = data->wdog_fd;
@@ -302,7 +308,7 @@ int ncp_mount_v3(const char* mount_name, unsigned long flags, const struct ncp_m
datav3.gid = data->gid;
datav3.file_mode = data->file_mode;
datav3.dir_mode = data->dir_mode;
connect(datav3.ncp_fd, (struct sockaddr *)&data->serv_addr, sizeof(data->serv_addr));
connect(datav3.ncp_fd, (const struct sockaddr *)&data->serv_addr, sizeof(data->serv_addr));
datav3.wdog_pid = fork();
if (datav3.wdog_pid < 0) {
fprintf(stderr, "could not fork: %s\n", strerror(errno));
@@ -311,7 +317,7 @@ int ncp_mount_v3(const char* mount_name, unsigned long flags, const struct ncp_m
if (datav3.wdog_pid == 0) {
/* Child */
inststr(argv, argc, "ncpd");
process_connection(data->wdog_fd, data->message_fd);
process_connection(data);
exit(0); /* Should not return from process_connection */
}
err=mount(mount_name, data->mount_point, "ncpfs", flags, (void*) &datav3);
@@ -382,7 +388,6 @@ main(int argc, char *argv[])
int fd, result;
struct sockaddr_ipx addr;
struct sockaddr_ipx *server_addr;
int addrlen;
int upcase_password;
@@ -404,9 +409,16 @@ main(int argc, char *argv[])
int opt;
#ifdef SIGNATURES
int sig_level = -1;
#endif
#ifdef NDS_SUPPORT
int force_bindery_login = 0;
#endif
#ifdef CONFIG_NATIVE_IP
struct sockaddr_in server_in;
const char* server_name = NULL;
#endif
char *tmp_mount;
int allow_multiple_connections = 0;
@@ -449,6 +461,9 @@ main(int argc, char *argv[])
while ((opt = getopt(argc, argv, "CS:U:c:u:g:f:d:P:nh?vV:t:r:"
"sN:"
#ifdef SIGNATURES
"i:"
#endif
#ifdef NDS_SUPPORT
"b"
#endif
@@ -458,6 +473,9 @@ main(int argc, char *argv[])
#endif
#ifdef MOUNT3
"3"
#endif
#ifdef CONFIG_NATIVE_IP
"A:"
#endif
)) != EOF)
{
@@ -553,7 +571,7 @@ main(int argc, char *argv[])
} else if (*NWpath != 1) {
mdata.mounted_vol = "dummy";
} else if (strlen(optarg) > NCP_VOLNAME_LEN) {
printf("Volume too long: %s\n", optarg);
fprintf(stderr, "Volume too long: %s\n", optarg);
exit(1);
} else {
mdata.mounted_vol=optarg;
@@ -578,6 +596,15 @@ main(int argc, char *argv[])
case 's':
mdata.flags.mount_strong = 1;
break;
#ifdef SIGNATURES
case 'i':
sig_level = atoi(optarg);
if ((sig_level < 0) || (sig_level > 3)) {
fprintf(stderr, "Invalid NCP signature level option `%s' (must be number between 0 and 3)\n", optarg);
exit(1);
}
break;
#endif
#ifdef NDS_SUPPORT
case 'b':
force_bindery_login = 1;
@@ -595,6 +622,11 @@ main(int argc, char *argv[])
case '3':
mount_protocol_version = 3;
break;
#endif
#ifdef CONFIG_NATIVE_IP
case 'A':
server_name = optarg;
break;
#endif
case 'N':
{
@@ -655,13 +687,18 @@ main(int argc, char *argv[])
mount_point, strerror(errno));
exit(1);
}
/* Check if the ncpfs filesystem is in the kernel. If not, attempt
* to load the ncpfs module */
if (load_ncpfs() != 0)
{
fprintf(stderr, "Error: Unable to load ncpfs, exiting...\n");
exit(1);
#ifdef MOUNT2
if (mount_protocol_version < 3) {
/* Check if the ncpfs filesystem is in the kernel. If not, attempt
* to load the ncpfs module */
if (load_ncpfs() != 0)
{
fprintf(stderr, "Error: Unable to load ncpfs, exiting...\n");
exit(1);
}
}
#endif
mdata.server_name = spec->server;
@@ -675,40 +712,79 @@ main(int argc, char *argv[])
if ((mdata.dir_mode & S_IROTH) != 0)
mdata.dir_mode |= S_IXOTH;
}
if ((!allow_multiple_connections)&&
((tmp_mount = ncp_find_permanent(spec)) != NULL))
{
fprintf(stderr,
"You already have mounted server %s\nas user "
"%s\non mount point %s\n", spec->server, spec->user,
tmp_mount);
exit(1);
}
if ((server_addr = ncp_find_fileserver(spec->server, &err)) == NULL)
{
com_err("ncpmount", err, "when trying to find %s",
spec->server);
exit(1);
}
mdata.serv_addr = *server_addr;
#ifdef CONFIG_NATIVE_IP
if (server_name) {
struct hostent* h;
mdata.ncp_fd = socket(AF_IPX, SOCK_DGRAM, PF_IPX);
if (mdata.ncp_fd == -1)
h = gethostbyname(server_name);
if (!h) {
fprintf(stderr, "Get host address `%s': ", server_name);
herror(NULL);
return 1;
}
if (h->h_addrtype != AF_INET) {
fprintf(stderr, "Get host address `%s': Not AF_INET\n", server_name);
return 1;
}
if (h->h_length != 4) {
fprintf(stderr, "Get host address `%s': Bad address length\n", server_name);
return 1;
}
server_in.sin_family = h->h_addrtype;
memcpy(&server_in.sin_addr.s_addr, h->h_addr, 4);
server_in.sin_port = htons(0x020C);
memcpy(&mdata.serv_addr, &server_in, sizeof(server_in));
} else
#endif /* CONFIG_NATIVE_IP */
{
com_err("ncpmount", err, "opening ncp_socket");
exit(1);
if ((!allow_multiple_connections)&&
((tmp_mount = ncp_find_permanent(spec)) != NULL))
{
fprintf(stderr,
"You already have mounted server %s\nas user "
"%s\non mount point %s\n", spec->server, spec->user,
tmp_mount);
exit(1);
}
if ((err = ncp_find_fileserver(spec->server, (struct sockaddr*)&mdata.serv_addr, sizeof(mdata.serv_addr))) != 0)
{
com_err("ncpmount", err, "when trying to find %s",
spec->server);
exit(1);
}
}
mdata.wdog_fd = socket(AF_IPX, SOCK_DGRAM, PF_IPX);
if (mdata.wdog_fd == -1)
{
fprintf(stderr, "could not open wdog socket: %s\n",
strerror(errno));
exit(1);
}
memzero(addr);
addr.sipx_family = AF_IPX;
addr.sipx_type = NCP_PTYPE;
#ifdef CONFIG_NATIVE_IP
if (mdata.serv_addr.sipx_family == AF_INET) {
mdata.ncp_fd = socket(PF_INET, SOCK_DGRAM, IPPROTO_UDP);
if (mdata.ncp_fd == -1) {
com_err("ncpmount", err, "opening ncp_socket");
exit(1);
}
mdata.wdog_fd = -1;
mdata.message_fd = -1;
memzero(addr);
addr.sipx_family = AF_INET;
} else
#endif
{
mdata.ncp_fd = socket(AF_IPX, SOCK_DGRAM, PF_IPX);
if (mdata.ncp_fd == -1)
{
com_err("ncpmount", err, "opening ncp_socket");
exit(1);
}
mdata.wdog_fd = socket(AF_IPX, SOCK_DGRAM, PF_IPX);
if (mdata.wdog_fd == -1)
{
fprintf(stderr, "could not open wdog socket: %s\n",
strerror(errno));
exit(1);
}
memzero(addr);
addr.sipx_family = AF_IPX;
addr.sipx_type = NCP_PTYPE;
}
if (bind(mdata.ncp_fd, (struct sockaddr *) &addr, sizeof(addr)) == -1)
{
fprintf(stderr, "\nbind: %s\n",
@@ -719,42 +795,45 @@ main(int argc, char *argv[])
"and try again after waiting a minute.\n\n");
exit(1);
}
addrlen = sizeof(addr);
if (getsockname(mdata.ncp_fd, (struct sockaddr *) &addr, &addrlen) == -1)
{
perror("getsockname ncp socket");
close(mdata.ncp_fd);
close(mdata.wdog_fd);
exit(1);
}
addr.sipx_port = htons(ntohs(addr.sipx_port) + 1);
if (mdata.serv_addr.sipx_family == AF_IPX) {
addrlen = sizeof(addr);
if (bind(mdata.wdog_fd, (struct sockaddr *) &addr, sizeof(addr)) == -1)
{
fprintf(stderr, "bind(wdog_sock, ): %s\n",
strerror(errno));
exit(1);
}
if (getsockname(mdata.ncp_fd, (struct sockaddr *) &addr, &addrlen) == -1)
{
perror("getsockname ncp socket");
close(mdata.ncp_fd);
close(mdata.wdog_fd);
exit(1);
}
addr.sipx_port = htons(ntohs(addr.sipx_port) + 1);
if (bind(mdata.wdog_fd, (struct sockaddr *) &addr, sizeof(addr)) == -1)
{
fprintf(stderr, "bind(wdog_sock, ): %s\n",
strerror(errno));
exit(1);
}
#if 1
mdata.message_fd = socket(AF_IPX, SOCK_DGRAM, PF_IPX);
if (mdata.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(mdata.message_fd, (struct sockaddr *) &addr, sizeof(addr)) == -1)
{
fprintf(stderr, "bind(message_sock, ): %s\n",
strerror(errno));
exit(1);
mdata.message_fd = socket(AF_IPX, SOCK_DGRAM, PF_IPX);
if (mdata.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(mdata.message_fd, (struct sockaddr *) &addr, sizeof(addr)) == -1)
{
fprintf(stderr, "bind(message_sock, ): %s\n",
strerror(errno));
exit(1);
}
#endif
}
mdata.mount_point = mount_point;
#endif
flags = MS_MGC_VAL;
@@ -782,12 +861,36 @@ main(int argc, char *argv[])
com_err("ncpmount", errno, "in mount(2)");
exit(1);
}
if ((conn = ncp_open_mount(mount_point, &err)) == NULL)
if ((err = ncp_open_mount(mount_point, &conn)) != 0)
{
com_err("ncpmount", err, "attempt to open mount point");
umount(mount_point);
exit(1);
}
#ifdef SIGNATURES
if (sig_level >= 0) {
int err = 0;
err = ncp_renegotiate_connparam(conn, conn->i.buffer_size, (sig_level > 1)? 2:0);
#if 0
if (conn->sign_wanted) {
if (sig_level < 2) {
err = ncp_renegotiate_connparam(conn, conn->i.buffer_size, 0);
}
} else {
if (sig_level >= 2) {
err = ncp_renegotiate_connparam(conn, conn->i.buffer_size, 2);
}
}
#endif
if (err || ((sig_level == 0) && (conn->sign_wanted))
|| ((sig_level == 3) && (!conn->sign_wanted))) {
fprintf(stderr, "Unable to negotiate requested security level\n");
umount(mount_point);
exit(1);
}
}
#endif
#ifdef NDS_SUPPORT
if ((!force_bindery_login) && (!nds_get_tree_name(conn, NULL, 0)))
{
@@ -920,6 +1023,9 @@ help(void)
#ifdef NDS_SUPPORT
"-b Force bindery login to NDS servers\n"
#endif
#ifdef SIGNATURES
"-i level Signature level, 0=never, 1=supported, 2=preferred, 3=required\n"
#endif
"-m Allow multiple logins to server\n"
"-N os2,nfs Do not use specified namespaces on mounted volume\n"
"\n");
@@ -1027,7 +1133,7 @@ msg_received (void)
openlog ("nwmsg", LOG_PID, LOG_LPR);
if ((conn = ncp_open_mount(mount_point, &err)) == NULL) {
if ((err = ncp_open_mount(mount_point, &conn)) != 0) {
return;
}
if (ncp_get_broadcast_message(conn, message) != 0) {
@@ -1123,7 +1229,7 @@ process_wdog_packet (int wdog_fd)
char buf[2];
if (recvfrom_notm(wdog_fd, buf, sizeof(buf),
(struct sockaddr *) &sender, &addrlen) < sizeof(buf)) {
(struct sockaddr *) &sender, &addrlen) < (int)sizeof(buf)) {
return;
}
if (buf[1] != '?') {
@@ -1134,14 +1240,47 @@ process_wdog_packet (int wdog_fd)
}
static int
process_connection (int wdog_fd, int msg_fd)
process_connection (const struct ncp_mount_data_independent* mnt)
{
int i;
int result;
int max;
int wdog_fd = mnt->wdog_fd;
int msg_fd = mnt->message_fd;
chdir("/");
setsid();
#ifdef CONFIG_NATIVE_IP
if (wdog_fd == -1) {
unsigned char buf[]={0x3E, 0x3E, 0, 0, 0, 0, 0, 0, 0, 'Y'};
struct ncp_fs_info fsinfo;
int fd, err;
int ncp_fd = mnt->ncp_fd;
for (i = 0; i < NR_OPEN; i++) {
if (i == ncp_fd) continue;
close(i);
}
/* we sleep here because of mount(2) must have enough time to run */
sleep(180); /* 3 min. */
fd = open(mnt->mount_point, O_RDONLY);
if (fd < 0) return 1; /* Give up */
fsinfo.version = NCP_GET_FS_INFO_VERSION;
err = ioctl(fd, NCP_IOC_GET_FS_INFO, &fsinfo);
close(fd);
if (err) return 1; /* Give up */
buf[3] = buf[8] = fsinfo.connection&0xFF;
buf[5] = buf[7] = (fsinfo.connection>>8)&0xFF;
while (1) {
send(ncp_fd, buf, sizeof(buf), 0);
sleep(180); /* 3 min. */
}
return 0;
}
#endif
for (i = 0; i < NR_OPEN; i++) {
if ((i == wdog_fd) || (i == msg_fd)) {
continue;

View File

@@ -1,212 +0,0 @@
/*$*********************************************************
$*
$* This code has been taken from DDJ 11/93, from an
$* article by Pawel Szczerbina.
$*
$* Password encryption routines follow.
$* Converted to C from Barry Nance's Pascal
$* prog published in the March -93 issue of Byte.
$*
$* Adapted to be useable for ncpfs by
$* Volker Lendecke <lendecke@namu01.gwdg.de> in
$* October 1995.
$*
$********************************************************* */
/****************************************************************************
I read that Novell is not very open when it comes to technical details
of the Netware Core Protocol. This might be especially true for the
encryption stuff. I took the necessary code from Dr. Dobb's Journal
11/93, Undocumented Corner. I asked Jon Erickson <jon@ddj.com> about
the legal status of this piece of code:
---
Date: Thu, 12 Oct 1995 13:44:18 +0100
From: Volker Lendecke <lendecke>
To: jon@ddj.com
Subject: legal status of your source code?
Hello!
I hope that you're the right one to write to, you are the first on your WWW
server. If you are not, could you please forward this message to the right
person? Thanks.
I'm currently exploring the possibility to write a free (in the GNU GPL
sense) NCP filesystem, which would allow me to access a novell server
transparently. For that I would like to use the encryption functions you
published in DDJ 11/93, Undocumented Corner. I would make some cosmetic
changes, such as other indentations, minor code changes and so on. But I do
not know if that allows me to publish this code under GPL. One alternative
would be to publish a diff against your listing, but that would probably
contain much of your code as well, and it would be very inconvenient for
the average user.
I think that you have some kind of standard procedure for such a
case. Please tell me what I should do.
Many thanks in advance,
Volker
+=================================================================+
! Volker Lendecke Internet: lendecke@namu01.gwdg.de !
! D-37081 Goettingen, Germany !
+=================================================================+
--
I got the following answer:
---
From: Jon Erickson <jon@ddj.com>
X-Mailer: SCO System V Mail (version 3.2)
To: lendecke@namu01.gwdg.de
Subject: Re: legal status of your source code?
Date: Thu, 12 Oct 95 5:42:56 PDT
Volker,
Code from Dr. Dobb's Journal related articles is provided for
anyone to use. Clearly, the author of the article should be
given credit.
Jon Erickson
---
With this answer in mind, I took the code and made it a bit more
C-like. The original seemed to be translated by a mechanical pascal->c
translator. Jon's answer encouraged me to publish nwcrypt.c under the
GPL. If anybody who knows more about copyright and sees any problems
with this, please tell me.
****************************************************************************/
/******************* Data types ***************************/
typedef unsigned char buf32[32];
typedef unsigned char buf16[16];
typedef unsigned char buf8[8];
typedef unsigned char buf4[4];
static unsigned char encrypttable[256] =
{0x7, 0x8, 0x0, 0x8, 0x6, 0x4, 0xE, 0x4, 0x5, 0xC, 0x1, 0x7, 0xB, 0xF, 0xA, 0x8,
0xF, 0x8, 0xC, 0xC, 0x9, 0x4, 0x1, 0xE, 0x4, 0x6, 0x2, 0x4, 0x0, 0xA, 0xB, 0x9,
0x2, 0xF, 0xB, 0x1, 0xD, 0x2, 0x1, 0x9, 0x5, 0xE, 0x7, 0x0, 0x0, 0x2, 0x6, 0x6,
0x0, 0x7, 0x3, 0x8, 0x2, 0x9, 0x3, 0xF, 0x7, 0xF, 0xC, 0xF, 0x6, 0x4, 0xA, 0x0,
0x2, 0x3, 0xA, 0xB, 0xD, 0x8, 0x3, 0xA, 0x1, 0x7, 0xC, 0xF, 0x1, 0x8, 0x9, 0xD,
0x9, 0x1, 0x9, 0x4, 0xE, 0x4, 0xC, 0x5, 0x5, 0xC, 0x8, 0xB, 0x2, 0x3, 0x9, 0xE,
0x7, 0x7, 0x6, 0x9, 0xE, 0xF, 0xC, 0x8, 0xD, 0x1, 0xA, 0x6, 0xE, 0xD, 0x0, 0x7,
0x7, 0xA, 0x0, 0x1, 0xF, 0x5, 0x4, 0xB, 0x7, 0xB, 0xE, 0xC, 0x9, 0x5, 0xD, 0x1,
0xB, 0xD, 0x1, 0x3, 0x5, 0xD, 0xE, 0x6, 0x3, 0x0, 0xB, 0xB, 0xF, 0x3, 0x6, 0x4,
0x9, 0xD, 0xA, 0x3, 0x1, 0x4, 0x9, 0x4, 0x8, 0x3, 0xB, 0xE, 0x5, 0x0, 0x5, 0x2,
0xC, 0xB, 0xD, 0x5, 0xD, 0x5, 0xD, 0x2, 0xD, 0x9, 0xA, 0xC, 0xA, 0x0, 0xB, 0x3,
0x5, 0x3, 0x6, 0x9, 0x5, 0x1, 0xE, 0xE, 0x0, 0xE, 0x8, 0x2, 0xD, 0x2, 0x2, 0x0,
0x4, 0xF, 0x8, 0x5, 0x9, 0x6, 0x8, 0x6, 0xB, 0xA, 0xB, 0xF, 0x0, 0x7, 0x2, 0x8,
0xC, 0x7, 0x3, 0xA, 0x1, 0x4, 0x2, 0x5, 0xF, 0x7, 0xA, 0xC, 0xE, 0x5, 0x9, 0x3,
0xE, 0x7, 0x1, 0x2, 0xE, 0x1, 0xF, 0x4, 0xA, 0x6, 0xC, 0x6, 0xF, 0x4, 0x3, 0x0,
0xC, 0x0, 0x3, 0x6, 0xF, 0x8, 0x7, 0xB, 0x2, 0xD, 0xC, 0x6, 0xA, 0xA, 0x8, 0xD};
static buf32 encryptkeys =
{0x48, 0x93, 0x46, 0x67, 0x98, 0x3D, 0xE6, 0x8D,
0xB7, 0x10, 0x7A, 0x26, 0x5A, 0xB9, 0xB1, 0x35,
0x6B, 0x0F, 0xD5, 0x70, 0xAE, 0xFB, 0xAD, 0x11,
0xF4, 0x47, 0xDC, 0xA7, 0xEC, 0xCF, 0x50, 0xC0};
static void
shuffle1(buf32 temp, unsigned char *target)
{
short b4;
unsigned char b3;
int s, b2, i;
b4 = 0;
for (b2 = 0; b2 <= 1; ++b2)
{
for (s = 0; s <= 31; ++s)
{
b3 = (temp[s] + b4) ^ (temp[(s + b4) & 31] - encryptkeys[s]);
b4 = b4 + b3;
temp[s] = b3;
}
}
for (i = 0; i <= 15; ++i)
{
target[i] = encrypttable[temp[2 * i]]
| (encrypttable[temp[2 * i + 1]] << 4);
}
}
void
shuffle(const unsigned char *lon, const unsigned char *buf, int buflen,
unsigned char *target)
{
int b2, d, s;
buf32 temp;
while ((buflen > 0)
&& (buf[buflen - 1] == 0))
{
buflen = buflen - 1;
}
for (s = 0; s < 32; s++)
{
temp[s] = 0;
}
d = 0;
while (buflen >= 32)
{
for (s = 0; s <= 31; ++s)
{
temp[s] = temp[s] ^ buf[d];
d = d + 1;
}
buflen = buflen - 32;
}
b2 = d;
if (buflen > 0)
{
for (s = 0; s <= 31; ++s)
{
if (d + buflen == b2)
{
b2 = d;
temp[s] = temp[s] ^ encryptkeys[s];
} else
{
temp[s] = temp[s] ^ buf[b2];
b2 = b2 + 1;
}
}
}
for (s = 0; s <= 31; ++s)
temp[s] = temp[s] ^ lon[s & 3];
shuffle1(temp, target);
}
static void
nw_encrypt(const unsigned char *fra,
const unsigned char *buf,
unsigned char *til)
{
buf32 k;
int s;
shuffle(&(fra[0]), buf, 16, &(k[0]));
shuffle(&(fra[4]), buf, 16, &(k[16]));
for (s = 0; s <= 15; ++s)
k[s] = k[s] ^ k[31 - s];
for (s = 0; s <= 7; ++s)
til[s] = k[s] ^ k[15 - s];
}

View File

@@ -47,10 +47,9 @@ swallow_error(const char *name, long code, const char *format, va_list arg)
int
main(int argc, char *argv[])
{
char *server = NULL;
const char *server = NULL;
int object_type = NCP_BINDERY_FSERVER;
struct sockaddr_ipx *result;
struct sockaddr_ipx resultbuf;
struct sockaddr_ipx addr;
struct ncp_conn *conn;
long err;
int is_address = 0;
@@ -89,17 +88,16 @@ main(int argc, char *argv[])
if (is_address)
{
if ((optind > argc - 1) ||
ipx_sscanf_saddr(argv[optind], &resultbuf))
ipx_sscanf_saddr(argv[optind], &addr))
{
usage();
exit(1);
}
if ((!(conn = ncp_open_addr(&resultbuf, &err))) ||
(err = ncp_close(conn)))
result = NULL;
if ((!(conn = ncp_open_addr((struct sockaddr*)&addr, &err))) ||
(err = ncp_close(conn))) {;
}
else
{
result = &resultbuf;
server = argv[optind];
}
}
@@ -114,15 +112,15 @@ main(int argc, char *argv[])
exit(1);
}
}
result = ncp_find_server(&server, object_type, &err);
err = ncp_find_server(&server, object_type, (struct sockaddr*)&addr, sizeof(addr));
}
if (result == NULL)
if (err != 0)
{
com_err(argv[0], err, "when trying to find server");
exit(1);
}
ipx_print_saddr(result);
ipx_print_saddr(&addr);
printf(" %s\n", server);
return 0;
}

View File

@@ -2,24 +2,30 @@
# Makefile for the linux ncp-filesystem routines.
#
USERUTILS = slist pqlist nwfsinfo pserver nprint nsend ncopy nwpasswd
USERUTILS += nwbols nwbocreate nwborm nwboprops pqstat pqrm
USERUTILS += nwbpcreate nwbprm nwbpvalues nwbpadd nwbpset
USERUTILS += nwgrant nwrevoke nwuserlist nwrights nwauth
USERUTILS += nwfstime nwvolinfo nwtrustee
include ../Makeinit
O_USERUTILS = slist.o pqlist.o nwfsinfo.o pserver.o nprint.o nsend.o \
ncopy.o nwpasswd.o nwbols.o nwbocreate.o nwborm.o nwboprops.o \
pqstat.o pqrm.o nwbpcreate.o nwbprm.o nwbpvalues.o nwbpadd.o \
nwbpset.o nwgrant.o nwrevoke.o nwuserlist.o nwrights.o nwauth.o \
nwfstime.o nwvolinfo.o nwtrustee.o nwpurge.o
ifdef MOUNT2
SBINUTILS = nwmsg
O_SBINUTILS = nwmsg.o
endif
USERUTILS = $(O_USERUTILS:%.o=%)
SBINUTILS = $(O_SBINUTILS:%.o=%)
UTILS = $(USERUTILS) $(SBINUTILS) ncptest
CC = gcc
ifeq ($(HAVE_ELF),yes)
NCP_LIB = libncp.so.1.0
NCP_LIB = libncp.so
NCPLIB_DIR = ../lib-shared
LIBDEP = $(NCPLIB_DIR)/$(NCP_LIB)
else
NCP_LIB = libncp.a
LIBDEP = ../lib/libncp.a
NCPLIB_DIR = ../lib-static
LIBDEP = $(NCPLIB_DIR)/$(NCP_LIB)
endif
default:
@@ -33,11 +39,20 @@ install: all
for i in $(SBINUTILS); \
do install $$i -m 755 $(SBINDIR); done
../lib-static/libncp.a:
make -C ../lib-static libncp.a
../lib-shared/libncp.so:
make -C ../lib-shared libncp.so
$(O_USERUTILS) $(O_SBINUTILS) ncptest.o: %.o: %.c
$(CC) $(CFLAGS) $(CCFLAGS) -o $@ -c $<
$(UTILS): %: %.o $(LIBDEP)
$(CC) -o $@ $(addsuffix .o,$@) -L../lib -lncp
$(CC) $(CFLAGS) -o $@ $(addsuffix .o,$@) -L$(NCPLIB_DIR) -lncp
ipx_probe: ipx_probe.c
$(CC) $(CFLAGS) -o ipx_probe ipx_probe.c
$(CC) $(CFLAGS) $(CCFLAGS) -o ipx_probe ipx_probe.c
dep:
$(CPP) -M $(INCLUDES) *.c > .depend

View File

@@ -72,7 +72,7 @@ static struct sigaction sTermSig;
*
*/
static void
usage()
usage(void)
{
fprintf(stderr, "usage: %s [-V]\n", ProgramName);
fprintf(stderr, " %s [-vn] [-s amt] sourcefile destinationfile|directory\n", ProgramName);
@@ -209,7 +209,7 @@ duplicateStr(const char *InStr)
* load a table of ncpfs mount points.
*/
int
loadMountTable()
loadMountTable(void)
{
FILE *mountedFile;
struct mntent *mountEntry = NULL;
@@ -256,7 +256,7 @@ loadMountTable()
* Releases the table of ncpfs mount points.
*/
void
releaseMountTable()
releaseMountTable(void)
{
int loop;
if (!ncpCount)
@@ -514,8 +514,8 @@ netwareCopyFile(int ncpMountIndex, const char *sourcefile,
one is not already established. */
if (!NcpMountTable[ncpMountIndex].conn)
{
NcpMountTable[ncpMountIndex].conn =
ncp_open_mount(NcpMountTable[ncpMountIndex].mountDir, &err);
err = ncp_open_mount(NcpMountTable[ncpMountIndex].mountDir,
&NcpMountTable[ncpMountIndex].conn);
if (err)
{
com_err(ProgramName, err, "opening ncp connection on mount point %s",
@@ -856,7 +856,7 @@ handleSignals(int sigNumber)
* We'll trap Hangup, Interrupt, Quit or Terminate
*/
static int
trapSignals()
trapSignals(void)
{
if (sigaction(SIGHUP, NULL, &sHangupSig))
{ /* init structure fields */

View File

@@ -22,7 +22,7 @@ static void
usage(void);
static void help(void);
void
int
main(int argc, char *argv[])
{
struct ncp_conn *conn;
@@ -299,7 +299,7 @@ main(int argc, char *argv[])
printf("close error\n");
}
ncp_close(conn);
return;
return 0;
}
static void

View File

@@ -47,6 +47,7 @@ main(int argc, char *argv[])
char *server = NULL;
char *object_name = NULL;
int object_type = NCP_BINDERY_USER;
struct sockaddr_ipx addr;
long err;
char *str;
@@ -90,7 +91,7 @@ main(int argc, char *argv[])
com_err(argv[0], err, "when trying to find server");
exit(1);
}
if (ncp_find_fileserver(spec->server, &err) == NULL)
if ((err = ncp_find_fileserver(spec->server, (struct sockaddr*)&addr, sizeof(addr))) != 0)
{
com_err(argv[0], err, "when trying to find server");
exit(1);

View File

@@ -155,7 +155,7 @@ main(int argc, char *argv[])
if ((property_flag & 2) == 0)
{
/* ITEM property */
int i;
size_t i;
int length;
int segno;
char property_value[255 * 128];

View File

@@ -243,7 +243,7 @@ print_string(__u8 * val)
}
static char *
print_station_addr(char *fmt, struct ncp_station_addr *addr, char *buff)
print_station_addr(const char *fmt, const struct ncp_station_addr *addr, char *buff)
{
char *ret = buff;
@@ -295,7 +295,7 @@ print_login_control(__u8 * val)
int i, j, mask;
char buff[32];
struct ncp_prop_login_control *a = (struct ncp_prop_login_control *) val;
static char *days[]
static const char *days[]
=
{"Sun", "Mon", "Tue", "Wen", "Thu", "Fri", "Sat"};
@@ -408,9 +408,9 @@ print_addr(__u8 * val)
printf("%s\n", buff);
}
static struct
static const struct
{
char *pname;
const char *pname;
void (*func) (__u8 *);
}
formats[] =

View File

@@ -28,7 +28,7 @@ static int search_utmp(char *user, char *tty);
static char *progname;
void
int
main(int argc, char *argv[])
{
struct ncp_conn *conn;
@@ -55,7 +55,7 @@ main(int argc, char *argv[])
exit(1);
}
mount_point = argv[1];
if ((conn = ncp_open_mount(mount_point, &err)) == NULL)
if ((err = ncp_open_mount(mount_point, &conn)) != 0)
{
com_err(progname, err, "in ncp_open_mount");
exit(1);
@@ -126,7 +126,7 @@ main(int argc, char *argv[])
fprintf(tty_file, "%s\r\n", message);
fclose(tty_file);
fclose(mtab);
return;
return 0;
}
/* The following routines have been taken from util-linux-2.5's write.c */

127
util/nwpurge.c Normal file
View File

@@ -0,0 +1,127 @@
#include <ncplib.h>
#include <unistd.h>
void usage(void) {
printf(
"usage: nwpurge [options] [directory]\n"
"\n"
"-h Print this help text\n"
"-a Purge files in subdirectories\n"
"-l Do not purge files\n"
"-s Silent mode\n"
"\n"
"directory Directory to purge\n"
"\n"
);
}
int subdirs = 0;
int show = 1;
int purge = 1;
int files = 0;
int failures = 0;
void processpurge(struct ncp_conn* conn, int volume, __u32 directory_id) {
struct ncp_deleted_file info;
char tmp[1024];
if (show) {
if (!ncp_ns_get_full_name(conn, NW_NS_DOS, NW_NS_DOS,
1, volume, directory_id, NULL, 0,
tmp, sizeof(tmp))) {
printf("%s\n", tmp);
}
}
info.seq = -1;
while (!ncp_ns_scan_salvageable_file(conn, NW_NS_DOS,
1, volume, directory_id, NULL, 0,
&info, tmp, sizeof(tmp))) {
if (show) {
printf("%8s%s\n", "", tmp);
}
files++;
if (purge) {
if (ncp_ns_purge_file(conn, &info)) {
failures++;
if (!show) {
printf("%8s%s\n", "", tmp);
}
printf("%8s-- failed\n", "");
}
}
}
if (show) printf("\n");
if (subdirs) {
struct nw_info_struct dir;
struct ncp_search_seq seq;
dir.volNumber = volume;
dir.DosDirNum = directory_id;
if (!ncp_initialize_search(conn, &dir, NW_NS_DOS, &seq)) {
while (!ncp_search_for_file_or_subdir2(conn,
SA_SUBDIR_ALL,
/* RIM_ATTRIBUTES | */ RIM_DIRECTORY,
&seq,
&dir)) {
processpurge(conn, dir.volNumber, dir.DosDirNum);
}
}
}
}
int main(int argc, char* argv[]) {
const char* path;
struct ncp_conn* conn;
int err;
int c;
while ((c = getopt(argc, argv, "ahls")) != -1) {
switch (c) {
case '?':
case ':':break;
case 'a':subdirs = 1;
break;
case 'h':usage(); exit(2);
case 'l':purge = 0;
break;
case 's':show = 0;
break;
default: fprintf(stderr, "Unexpected option `-%c'\n", c);
break;
}
}
if (optind < argc) {
path = argv[optind++];
} else {
path = ".";
}
err = ncp_open_mount(path, &conn);
if (err) {
com_err("nwpurge", err, "in ncp_open_mount");
exit(1);
}
processpurge(conn, conn->i.volume_number, conn->i.directory_id);
files = files-failures;
if (!files) {
printf("No files were");
} else if (files == 1) {
printf("1 file was");
} else {
printf("%d files were", files);
}
printf(" purged from server.\n");
if (failures) {
if (failures == 1) {
printf("1 file was not purged due to error.");
} else {
printf("%d files were not purged due to errors.", failures);
}
}
ncp_close(conn);
return 0;
}

View File

@@ -35,7 +35,7 @@ int
main(int argc, char *argv[])
{
struct ncp_conn *conn = NULL;
char *path = ".";
const char *path = ".";
long err;
int result = 1;
int opt;
@@ -66,7 +66,7 @@ main(int argc, char *argv[])
{
path = argv[optind];
}
if ((conn = ncp_open_mount(path, &err)) == NULL)
if ((err = ncp_open_mount(path, &conn)) != 0)
{
com_err(argv[0], err, "when initializing");
goto finished;

View File

@@ -46,7 +46,7 @@ main(int argc, char **argv)
struct ncp_conn *conn;
struct ncp_volume_info o;
char *volname = "SYS";
const char *volname = "SYS";
long err;
int opt;
int numk;

View File

@@ -1,9 +1,9 @@
/*
* pqstat.c
* pqrm.c
*
* List the jobs in a print queue on a server
* Remove job from a print queue on a server
*
* Copyright (C) 1998 by David Woodhouse
* Copyright (C) 1998 by Petr Vandrovec, David Woodhouse
* Derived from pqlist.c, (C) 1996 Volker Lendecke
*
*/

View File

@@ -73,7 +73,7 @@ help(void)
#endif
static void
terminate_handler()
terminate_handler(int dummy)
{
signal(SIGTERM, terminate_handler);
signal(SIGINT, terminate_handler);
@@ -259,7 +259,7 @@ build_command(struct nw_queue *q, struct queue_job *j,
char *s = q->command;
char *target_end = target + target_size;
void add_string(char *s)
void add_string(const char *s)
{
int len = strlen(s);
if (target + len + 1 > target_end)

View File

@@ -14,7 +14,7 @@
#include <string.h>
#include <ctype.h>
void
int
main(int argc, char *argv[])
{
struct ncp_conn *conn;
@@ -83,4 +83,5 @@ main(int argc, char *argv[])
printf("No servers found\n");
}
ncp_close(conn);
return 0;
}