diff --git a/.downloads/ncpfs-2.2.5.tar.gz b/.downloads/ncpfs-2.2.5.tar.gz new file mode 100644 index 0000000..8695e34 Binary files /dev/null and b/.downloads/ncpfs-2.2.5.tar.gz differ diff --git a/config.guess b/config.guess index e8c6fc0..77c7cba 100755 --- a/config.guess +++ b/config.guess @@ -1,9 +1,9 @@ #! /bin/sh # Attempt to guess a canonical system name. # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, -# 2000, 2001, 2002, 2003 Free Software Foundation, Inc. +# 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. -timestamp='2004-01-05' +timestamp='2004-08-13' # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by @@ -53,7 +53,7 @@ version="\ GNU config.guess ($timestamp) Originally written by Per Bothner. -Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 +Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO @@ -197,15 +197,21 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used. echo "${machine}-${os}${release}" exit 0 ;; + amd64:OpenBSD:*:*) + echo x86_64-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; amiga:OpenBSD:*:*) echo m68k-unknown-openbsd${UNAME_RELEASE} exit 0 ;; - arc:OpenBSD:*:*) - echo mipsel-unknown-openbsd${UNAME_RELEASE} + cats:OpenBSD:*:*) + echo arm-unknown-openbsd${UNAME_RELEASE} exit 0 ;; hp300:OpenBSD:*:*) echo m68k-unknown-openbsd${UNAME_RELEASE} exit 0 ;; + luna88k:OpenBSD:*:*) + echo m88k-unknown-openbsd${UNAME_RELEASE} + exit 0 ;; mac68k:OpenBSD:*:*) echo m68k-unknown-openbsd${UNAME_RELEASE} exit 0 ;; @@ -221,28 +227,33 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in mvmeppc:OpenBSD:*:*) echo powerpc-unknown-openbsd${UNAME_RELEASE} exit 0 ;; - pegasos:OpenBSD:*:*) - echo powerpc-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; - pmax:OpenBSD:*:*) - echo mipsel-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; sgi:OpenBSD:*:*) - echo mipseb-unknown-openbsd${UNAME_RELEASE} + echo mips64-unknown-openbsd${UNAME_RELEASE} exit 0 ;; sun3:OpenBSD:*:*) echo m68k-unknown-openbsd${UNAME_RELEASE} exit 0 ;; - wgrisc:OpenBSD:*:*) - echo mipsel-unknown-openbsd${UNAME_RELEASE} - exit 0 ;; *:OpenBSD:*:*) echo ${UNAME_MACHINE}-unknown-openbsd${UNAME_RELEASE} exit 0 ;; + *:ekkoBSD:*:*) + echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE} + exit 0 ;; + macppc:MirBSD:*:*) + echo powerppc-unknown-mirbsd${UNAME_RELEASE} + exit 0 ;; + *:MirBSD:*:*) + echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE} + exit 0 ;; alpha:OSF1:*:*) - if test $UNAME_RELEASE = "V4.0"; then + case $UNAME_RELEASE in + *4.0) UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` - fi + ;; + *5.*) + UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` + ;; + esac # According to Compaq, /usr/sbin/psrinfo has been available on # OSF/1 and Tru64 systems produced since 1995. I hope that # covers most systems running today. This code pipes the CPU @@ -280,14 +291,12 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in "EV7.9 (21364A)") UNAME_MACHINE="alphaev79" ;; esac + # A Pn.n version is a patched version. # A Vn.n version is a released version. # A Tn.n version is a released field test version. # A Xn.n version is an unreleased experimental baselevel. # 1.2 uses "1.2" for uname -r. - echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` - exit 0 ;; - Alpha*:OpenVMS:*:*) - echo alpha-hp-vms + echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` exit 0 ;; Alpha\ *:Windows_NT*:*) # How do we know it's Interix rather than the generic POSIX subsystem? @@ -405,6 +414,9 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*) echo m68k-unknown-mint${UNAME_RELEASE} exit 0 ;; + m68k:machten:*:*) + echo m68k-apple-machten${UNAME_RELEASE} + exit 0 ;; powerpc:machten:*:*) echo powerpc-apple-machten${UNAME_RELEASE} exit 0 ;; @@ -740,7 +752,7 @@ EOF echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit 0 ;; *:UNICOS/mp:*:*) - echo nv1-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' + echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/' exit 0 ;; F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*) FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` @@ -763,21 +775,7 @@ EOF echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} exit 0 ;; *:FreeBSD:*:*) - # Determine whether the default compiler uses glibc. - eval $set_cc_for_build - sed 's/^ //' << EOF >$dummy.c - #include - #if __GLIBC__ >= 2 - LIBC=gnu - #else - LIBC= - #endif -EOF - eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=` - # GNU/KFreeBSD systems have a "k" prefix to indicate we are using - # FreeBSD's kernel, but not the complete OS. - case ${LIBC} in gnu) kernel_only='k' ;; esac - echo ${UNAME_MACHINE}-unknown-${kernel_only}freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`${LIBC:+-$LIBC} + echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` exit 0 ;; i*:CYGWIN*:*) echo ${UNAME_MACHINE}-pc-cygwin @@ -829,6 +827,9 @@ EOF ia64:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit 0 ;; + m32r*:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux-gnu + exit 0 ;; m68*:Linux:*:*) echo ${UNAME_MACHINE}-unknown-linux-gnu exit 0 ;; @@ -1069,9 +1070,9 @@ EOF M680?0:D-NIX:5.3:*) echo m68k-diab-dnix exit 0 ;; - M68*:*:R3V[567]*:*) + M68*:*:R3V[5678]*:*) test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;; - 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0) + 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) OS_REL='' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` @@ -1169,9 +1170,10 @@ EOF echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE} exit 0 ;; *:Darwin:*:*) - case `uname -p` in + UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown + case $UNAME_PROCESSOR in *86) UNAME_PROCESSOR=i686 ;; - powerpc) UNAME_PROCESSOR=powerpc ;; + unknown) UNAME_PROCESSOR=powerpc ;; esac echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE} exit 0 ;; @@ -1230,9 +1232,16 @@ EOF SEI:*:*:SEIUX) echo mips-sei-seiux${UNAME_RELEASE} exit 0 ;; - *:DRAGONFLY:*:*) - echo ${UNAME_MACHINE}-unknown-dragonfly${UNAME_RELEASE} + *:DragonFly:*:*) + echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` exit 0 ;; + *:*VMS:*:*) + UNAME_MACHINE=`(uname -p) 2>/dev/null` + case "${UNAME_MACHINE}" in + A*) echo alpha-dec-vms && exit 0 ;; + I*) echo ia64-dec-vms && exit 0 ;; + V*) echo vax-dec-vms && exit 0 ;; + esac esac #echo '(No uname command or uname output not recognized.)' 1>&2 diff --git a/config.sub b/config.sub index 463186d..ac6de98 100755 --- a/config.sub +++ b/config.sub @@ -1,9 +1,9 @@ #! /bin/sh # Configuration validation subroutine script. # Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, -# 2000, 2001, 2002, 2003 Free Software Foundation, Inc. +# 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. -timestamp='2004-01-05' +timestamp='2004-06-24' # This file is (in principle) common to ALL GNU software. # The presence of a machine in this file suggests that SOME GNU software @@ -70,7 +70,7 @@ Report bugs and patches to ." version="\ GNU config.sub ($timestamp) -Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 +Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO @@ -145,7 +145,7 @@ case $os in -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ - -apple | -axis) + -apple | -axis | -knuth | -cray) os= basic_machine=$1 ;; @@ -237,7 +237,7 @@ case $basic_machine in | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ | i370 | i860 | i960 | ia64 \ | ip2k | iq2000 \ - | m32r | m68000 | m68k | m88k | mcore \ + | m32r | m32rle | m68000 | m68k | m88k | mcore \ | mips | mipsbe | mipseb | mipsel | mipsle \ | mips16 \ | mips64 | mips64el \ @@ -262,7 +262,7 @@ case $basic_machine in | pyramid \ | sh | sh[1234] | sh[23]e | sh[34]eb | shbe | shle | sh[1234]le | sh3ele \ | sh64 | sh64le \ - | sparc | sparc64 | sparc86x | sparclet | sparclite | sparcv9 | sparcv9b \ + | sparc | sparc64 | sparc86x | sparclet | sparclite | sparcv8 | sparcv9 | sparcv9b \ | strongarm \ | tahoe | thumb | tic4x | tic80 | tron \ | v850 | v850e \ @@ -300,7 +300,7 @@ case $basic_machine in | avr-* \ | bs2000-* \ | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \ - | clipper-* | cydra-* \ + | clipper-* | craynv-* | cydra-* \ | d10v-* | d30v-* | dlx-* \ | elxsi-* \ | f30[01]-* | f700-* | fr30-* | frv-* | fx80-* \ @@ -308,7 +308,7 @@ case $basic_machine in | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \ | i*86-* | i860-* | i960-* | ia64-* \ | ip2k-* | iq2000-* \ - | m32r-* \ + | m32r-* | m32rle-* \ | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \ | m88110-* | m88k-* | mcore-* \ | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \ @@ -326,8 +326,9 @@ case $basic_machine in | mipsisa64sb1-* | mipsisa64sb1el-* \ | mipsisa64sr71k-* | mipsisa64sr71kel-* \ | mipstx39-* | mipstx39el-* \ + | mmix-* \ | msp430-* \ - | none-* | np1-* | nv1-* | ns16k-* | ns32k-* \ + | none-* | np1-* | ns16k-* | ns32k-* \ | orion-* \ | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \ | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \ @@ -336,7 +337,7 @@ case $basic_machine in | sh-* | sh[1234]-* | sh[23]e-* | sh[34]eb-* | shbe-* \ | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \ | sparc-* | sparc64-* | sparc86x-* | sparclet-* | sparclite-* \ - | sparcv9-* | sparcv9b-* | strongarm-* | sv1-* | sx?-* \ + | sparcv8-* | sparcv9-* | sparcv9b-* | strongarm-* | sv1-* | sx?-* \ | tahoe-* | thumb-* \ | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \ | tron-* \ @@ -363,6 +364,9 @@ case $basic_machine in basic_machine=a29k-amd os=-udi ;; + abacus) + basic_machine=abacus-unknown + ;; adobe68k) basic_machine=m68010-adobe os=-scout @@ -442,12 +446,24 @@ case $basic_machine in basic_machine=j90-cray os=-unicos ;; + craynv) + basic_machine=craynv-cray + os=-unicosmp + ;; + cr16c) + basic_machine=cr16c-unknown + os=-elf + ;; crds | unos) basic_machine=m68k-crds ;; cris | cris-* | etrax*) basic_machine=cris-axis ;; + crx) + basic_machine=crx-unknown + os=-elf + ;; da30 | da30-*) basic_machine=m68k-da30 ;; @@ -648,10 +664,6 @@ case $basic_machine in mips3*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown ;; - mmix*) - basic_machine=mmix-knuth - os=-mmixware - ;; monitor) basic_machine=m68k-rom68k os=-coff @@ -732,10 +744,6 @@ case $basic_machine in np1) basic_machine=np1-gould ;; - nv1) - basic_machine=nv1-cray - os=-unicosmp - ;; nsr-tandem) basic_machine=nsr-tandem ;; @@ -1048,6 +1056,9 @@ case $basic_machine in romp) basic_machine=romp-ibm ;; + mmix) + basic_machine=mmix-knuth + ;; rs6000) basic_machine=rs6000-ibm ;; @@ -1070,7 +1081,7 @@ case $basic_machine in sh64) basic_machine=sh64-unknown ;; - sparc | sparcv9 | sparcv9b) + sparc | sparcv8 | sparcv9 | sparcv9b) basic_machine=sparc-sun ;; cydra) @@ -1143,8 +1154,9 @@ case $os in | -aos* \ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ - | -hiux* | -386bsd* | -knetbsd* | -netbsd* | -openbsd* | -kfreebsd* | -freebsd* | -riscix* \ - | -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ + | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* | -openbsd* \ + | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \ + | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ | -chorusos* | -chorusrdb* \ @@ -1362,6 +1374,9 @@ case $basic_machine in *-ibm) os=-aix ;; + *-knuth) + os=-mmixware + ;; *-wec) os=-proelf ;; diff --git a/configure b/configure index 1ff08b8..27c0c93 100755 --- a/configure +++ b/configure @@ -1,7 +1,7 @@ #! /bin/sh -# From configure.ac 2.2.4. +# From configure.ac 2.2.5. # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.59 for ncpfs 2.2.4. +# Generated by GNU Autoconf 2.59 for ncpfs 2.2.5. # # Report bugs to . # @@ -270,8 +270,8 @@ SHELL=${CONFIG_SHELL-/bin/sh} # Identity of this package. PACKAGE_NAME='ncpfs' PACKAGE_TARNAME='-ncpfs-' -PACKAGE_VERSION='2.2.4' -PACKAGE_STRING='ncpfs 2.2.4' +PACKAGE_VERSION='2.2.5' +PACKAGE_STRING='ncpfs 2.2.5' PACKAGE_BUGREPORT='vandrove@vc.cvut.cz' ac_unique_file="lib/ncplib.c" @@ -782,7 +782,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures ncpfs 2.2.4 to adapt to many kinds of systems. +\`configure' configures ncpfs 2.2.5 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -843,7 +843,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of ncpfs 2.2.4:";; + short | recursive ) echo "Configuration of ncpfs 2.2.5:";; esac cat <<\_ACEOF @@ -988,7 +988,7 @@ fi test -n "$ac_init_help" && exit 0 if $ac_init_version; then cat <<\_ACEOF -ncpfs configure 2.2.4 +ncpfs configure 2.2.5 generated by GNU Autoconf 2.59 Copyright (C) 2003 Free Software Foundation, Inc. @@ -1002,7 +1002,7 @@ cat >&5 <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by ncpfs $as_me 2.2.4, which was +It was created by ncpfs $as_me 2.2.5, which was generated by GNU Autoconf 2.59. Invocation command line was $ $0 $@ @@ -11777,7 +11777,7 @@ _ASBOX } >&5 cat >&5 <<_CSEOF -This file was extended by ncpfs $as_me 2.2.4, which was +This file was extended by ncpfs $as_me 2.2.5, which was generated by GNU Autoconf 2.59. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -11840,7 +11840,7 @@ _ACEOF cat >>$CONFIG_STATUS <<_ACEOF ac_cs_version="\\ -ncpfs config.status 2.2.4 +ncpfs config.status 2.2.5 configured by $0, generated by GNU Autoconf 2.59, with options \\"`echo "$ac_configure_args" | sed 's/[\\""\`\$]/\\\\&/g'`\\" diff --git a/configure.ac b/configure.ac index 03f1aab..e613419 100644 --- a/configure.ac +++ b/configure.ac @@ -1,8 +1,8 @@ dnl Process this file with autoconf to produce a configure script. AC_PREREQ(2.50) -AC_INIT([[ncpfs]],[[2.2.4]],[[vandrove@vc.cvut.cz]]) +AC_INIT([[ncpfs]],[[2.2.5]],[[vandrove@vc.cvut.cz]]) AC_CONFIG_SRCDIR([[lib/ncplib.c]]) -AC_REVISION([[2.2.4]]) +AC_REVISION([[2.2.5]]) AC_CONFIG_HEADER(include/config.h) diff --git a/contrib/pam/pam_ncp_auth.c b/contrib/pam/pam_ncp_auth.c index 260a814..bb02876 100644 --- a/contrib/pam/pam_ncp_auth.c +++ b/contrib/pam/pam_ncp_auth.c @@ -18,6 +18,33 @@ /* * $Log: pam_ncp_auth.c,v $ + * + * Revision 1.28 2002/10/02 PP + * 1) default zenflag is now 0 and not anymore ZF_CREATE_NWCLIENT | ZF_AUTOMOUNT_NWHOME | ZF_CREATE_NWINFOS + * that set trouble with some users not familiar with C coding. they turned these off in NDS + * and they were still applied. + * + * Revision 1.27 2002/10/02 PP + * Experimental code: + * 1) We experienced some stange behavior with contexless login. If user miss his password and retry to + * login nw_search_ctx is called again and freeze... + * 2) trying to find why console login do not work in RH73 ... this module says OK but session is closed + * immediatly (?) + * + * New Code: + * 1) Some users complained that this module consumes 2 connections to NDS (one for the authentication + * and one for the autmounting of the Netware home). Actually only one should stay permanent, to be + * later reused by mounting of extra Netware ressource via ncpmap without having to provide again + * login/password. Since the authenticating connection is not in /etc/mtab, so it cannot be "reused" + * by ncpmap anyway, so we must get rid of it at end of session opening part. + * 2) Paul Berger (bergerp@breedtech.com) signaled me that in some environnement, home directories paths + * are coded in NwAdmin as dir1/dir2/%LOGIN_NAME or dir1/dir2/%CN (with or without a terminating %) and + * the mapping of the home is done within the context login script, with automatic substitution + * of %LOGIN_NAME by the user's cn truncated to 8 or of %CN by the full user's CN. Some provisions are + * added to do the substitution here when automounting home and writing data in the ~/.nwinfos file. + * This is a crude code that chop off whatever starts with a % and append the user's name. We do not + * support dir1/dir2/%LOGIN_NAME/dir3 !!!! See nds_pp_home_directory function. + * * Revision 1.26 2002/05/24 PP * Extended -Z option to allow some zenflags to be turned OFF on that workstation. * With -Z all zenflags are off, but with -ZABCD, only flags ABCD are off. @@ -220,6 +247,7 @@ #define _GNU_SOURCE #define _BSD_SOURCE #define inline __inline__ +#define NCP_OBSOLETE #include #include #include @@ -245,10 +273,15 @@ static const char rcsid[] = "$Id: pam_ncp_auth.c,v 1.9 2001/21/26 16:52:07 PP Ex /* Define function prototypes */ -static void -nw_cleanup_conn(pam_handle_t * pamh, void *data, int error_status) +static void +nw_cleanup_conn(UNUSED(pam_handle_t *pamh), + void *data, + UNUSED(int error_status)) { - ncp_close((struct ncp_conn *) data); + NWCCODE err; + + err = ncp_close((struct ncp_conn*)data); + syslog(LOG_NOTICE, "pam closing authenticating connection: %s", strnwerror(err)); } #define QFC_FIRST_UNUSED 0 @@ -420,9 +453,9 @@ rather than Location for pre-DS 8 systems*/ #define ZF_OPENING_SCRIPTS (ZF_0 | ZF_1 | ZF_2) #define ZF_CLOSING_SCRIPTS (ZF_3 | ZF_4 | ZF_5) -//maybe overwritten ( not ORED !) by a -z directive on the command line -//note: no passwd in ~/.nwclient by default -#define ZF_DEFAULTS ZF_CREATE_NWCLIENT | ZF_AUTOMOUNT_NWHOME | ZF_CREATE_NWINFOS + +//#define ZF_DEFAULTS ZF_CREATE_NWCLIENT | ZF_AUTOMOUNT_NWHOME | ZF_CREATE_NWINFOS +#define ZF_DEFAULTS 0 // where must be the scripts // TODO: let PAM finds them somewhere in its path @@ -518,10 +551,35 @@ struct pam_ncp_state { }; -// PP:moved up here to be used by some of my routines -static int -getnumber(int *val, const char **str) -{ +// concat2a (give a local string that is destroyed at the end of the function) +#define concat2a(one,two) ({ \ + size_t lone = strlen(one); \ + size_t ltwo = strlen(two); \ + char* buf = alloca(lone + ltwo + 1); \ + memcpy(buf, one, lone); \ + memcpy(buf + lone, two, ltwo + 1); \ + buf; }) + +// concat2m (give a "global" string that is NOT destroyed at the end of the function) +#define concat2m(one,two) ({ \ + size_t lone = strlen(one); \ + size_t ltwo = strlen(two); \ + char* buf = malloc(lone + ltwo + 1); \ + memcpy(buf, one, lone); \ + memcpy(buf + lone, two, ltwo + 1); \ + buf; }) + + +#define concat3a(one,med,two) ({ \ + size_t lone = strlen(one); \ + size_t ltwo = strlen(two); \ + char* buf = alloca(lone + 1+ ltwo + 1); \ + memcpy(buf, one, lone); \ + buf[lone] = med; \ + memcpy(buf + lone + 1, two, ltwo + 1); \ + buf; }) + +static int getnumber(int* val, const char** str) { const char *p = *str; char *z; @@ -542,7 +600,7 @@ getnumber(int *val, const char **str) // flip Dos antislash to Unix // converts to uppercase for ncpmount to work with ROOT options ON -static char * +static void unixifyPathUC(char *dosPath) { size_t i; @@ -552,7 +610,6 @@ unixifyPathUC(char *dosPath) dosPath[i] = '/'; } str_upper(dosPath); - return dosPath; } // remove all spaces from a NDS name @@ -577,11 +634,10 @@ trim(char *string) #define QF_AUTOMODIFY 0x0020 #define QF_BINDERY 0x0040 #define QF_NO_PEER_CHECKS 0x0080 -// rev 1.25 add an extra -A server parameter to ncpmount (with -A option on command line) #define QF_USE_NETWARE_IP 0x1000 // version 1.24. automatically create home directory on local machine for new users // it is on by default -// should be turned of by -n option if homes are on a remote NFS server (automounted) +// should be turned off by -n option if homes are on a remote NFS server (automounted) #define QF_MOUNTLOCALLY 0x2000 #define QF_CREATEHOME 0x4000 // test v 1.25 impersonnating to current user when accessing his NFS mounted home @@ -732,7 +788,7 @@ fail2:; } static int -nw_get_nwid(NWCONN_HANDLE conn, NWObjectID * id, int qflag) +nw_get_nwid(NWCONN_HANDLE conn, NWObjectID * id, UNUSED(int qflag)) { NWCCODE err; @@ -788,7 +844,6 @@ nw_create_verify_conn_to_server(NWCONN_HANDLE * conn, NWObjectID * id, } } if (group) { -/*v 1.11 : if we talk to bindery we should not use NDS to test group membership ? */ if (!(qflag & QF_BINDERY)) { NWDSContextHandle ctx; nuint32 c; @@ -893,17 +948,15 @@ nw_ctx_search(const char *user_cn, NWCONN_HANDLE conn, char *contexts, size_t ma goto Exit2; } -/******************************************************************* - In order to search, we need: - A Filter Cursor (to build the search expression) - A Filter Buffer (to store the expression; used by NWDSSearch) - A Buffer to store which attributes we need information on - A Result Buffer (to store the search results) - */ + /********************************************************************** + * In order to search, we need: * + * A Filter Cursor (to build the search expression) * + * A Filter Buffer (to store the expression; used by NWDSSearch) * + * A Buffer to store which attributes we need information on * + * A Result Buffer (to store the search results) * + **********************************************************************/ - /******************************************************************* - ** Allocate Filter buffer and Cursor and populate - */ + /* Allocate Filter buffer and Cursor and populate */ ccode = NWDSAllocBuf(DEFAULT_MESSAGE_LEN, &searchFilter); if (ccode) { syslog(LOG_NOTICE, "nw_ctx_search:NWDSAllocBuf returned: %d\n", ccode); @@ -1372,13 +1425,13 @@ free_nw_user_info(struct nw_user_info *ui) // so we should use this data ONLY in a "PAM_open_session" call back // that happens just after the successful login static void -cleanup_user_info(pam_handle_t * pamh, void *data, int error_status) +cleanup_user_info(UNUSED(pam_handle_t * pamh), void *data, UNUSED(int error_status)) { free_nw_user_info((struct nw_user_info *) data); } static int -nw_retrieve_bindery_user_info(struct nw_user_info *ui, NWCONN_HANDLE conn, NWObjectID oid) +nw_retrieve_bindery_user_info(struct nw_user_info *ui, NWCONN_HANDLE conn, UNUSED(NWObjectID oid)) { /* we have to give some support here since: @@ -1457,7 +1510,8 @@ nw_retrieve_bindery_user_info(struct nw_user_info *ui, NWCONN_HANDLE conn, NWObj ui->nwhomeServer = strdup(ui->messageServer); ui->messageServer = NULL; ui->nwhomeVolume = v; - ui->nwhomePath = unixifyPathUC(v1); + unixifyPathUC(v1); + ui->nwhomePath = v1; } } @@ -1592,7 +1646,7 @@ struct nw_home_info { }; static NWDSCCODE -nds_pp_host_server(NWDSContextHandle ctx, const void *val, void *arg) +nds_pp_host_server(UNUSED(NWDSContextHandle ctx), const void *val, void *arg) { struct nw_home_info *hi = (struct nw_home_info *) arg; const char *src = val; @@ -1618,7 +1672,7 @@ nds_pp_host_server(NWDSContextHandle ctx, const void *val, void *arg) } static NWDSCCODE -nds_pp_host_resource_name(NWDSContextHandle ctx, const void *val, void *arg) +nds_pp_host_resource_name(UNUSED(NWDSContextHandle ctx), const void *val, void *arg) { struct nw_home_info *hi = (struct nw_home_info *) arg; @@ -1648,7 +1702,7 @@ nds_home_info(NWDSContextHandle ctx, const NWDSChar * objname, struct nw_home_in /** gather Unix groups informations */ static NWDSCCODE -nds_ga_group_unixgid(NWDSContextHandle ctx, const void *val, void *arg) +nds_ga_group_unixgid(UNUSED(NWDSContextHandle ctx), const void *val, void *arg) { struct nw_group_info *gi = (struct nw_group_info *) arg; @@ -1665,7 +1719,7 @@ nds_ga_group_unixgid(NWDSContextHandle ctx, const void *val, void *arg) // eg. everyone --> users // staff --> root static NWDSCCODE -nds_pp_group_location(NWDSContextHandle ctx, const void *val, void *arg) +nds_pp_group_location(UNUSED(NWDSContextHandle ctx), const void *val, void *arg) { struct nw_group_info *gi = (struct nw_group_info *) arg; const char *pt = (const char *) val; @@ -1727,10 +1781,10 @@ nds_group_info(NWDSContextHandle ctx, const NWDSChar * objname, struct nw_group_ // PP:called only if no "Unix name has been found in NDS for that group // a string N:nnnnn in L attribute static NWDSCCODE -nds_group_name(NWDSContextHandle ctx, const NWDSChar * objname, struct nw_group_info *gi) +nds_group_name(UNUSED(NWDSContextHandle ctx), const NWDSChar * objname, struct nw_group_info *gi) { char *buff; - const char *f; + const unsigned char *f; int c; /* Worst case: output is Z, two chars per one in input, and zero terminating byte */ @@ -1740,7 +1794,7 @@ nds_group_name(NWDSContextHandle ctx, const NWDSChar * objname, struct nw_group_ return ENOMEM; } f = objname; - for (; (c = *((const unsigned char *) f)++) != 0; *buff++ = c) { + for (; (c = *f++) != 0; *buff++ = c) { if (c >= 'a' && c <= 'z') continue; if (c >= 'A' && c <= 'Z') { @@ -1852,7 +1906,7 @@ build_groups_list(const struct nw_user_info *ui, char **list) /************************************ helper functions to extract some user's properties **/ static NWDSCCODE -nds_ga_unixuid(NWDSContextHandle ctx, const void *val, void *arg) +nds_ga_unixuid(UNUSED(NWDSContextHandle ctx), const void *val, void *arg) { struct nw_user_info *ui = (struct nw_user_info *) arg; if (ui->uid == (uid_t) -1) { @@ -1865,7 +1919,7 @@ nds_ga_unixuid(NWDSContextHandle ctx, const void *val, void *arg) } static NWDSCCODE -nds_ga_unixpgid(NWDSContextHandle ctx, const void *val, void *arg) +nds_ga_unixpgid(UNUSED(NWDSContextHandle ctx), const void *val, void *arg) { struct nw_user_info *ui = (struct nw_user_info *) arg; @@ -1882,7 +1936,7 @@ nds_ga_unixpgid(NWDSContextHandle ctx, const void *val, void *arg) // does Netware has two synonyms for the same property (UNIX:GID" // and UNIX:Primary GroupID??? static NWDSCCODE -nds_ga_unixgid(NWDSContextHandle ctx, const void *val, void *arg) +nds_ga_unixgid(UNUSED(NWDSContextHandle ctx), const void *val, void *arg) { struct nw_user_info *ui = (struct nw_user_info *) arg; @@ -1896,7 +1950,7 @@ nds_ga_unixgid(NWDSContextHandle ctx, const void *val, void *arg) } static NWDSCCODE -nds_ga_unixhome(NWDSContextHandle ctx, const void *val, void *arg) +nds_ga_unixhome(UNUSED(NWDSContextHandle ctx), const void *val, void *arg) { struct nw_user_info *ui = (struct nw_user_info *) arg; @@ -1915,7 +1969,7 @@ nds_ga_unixhome(NWDSContextHandle ctx, const void *val, void *arg) } static NWDSCCODE -nds_ga_unixshell(NWDSContextHandle ctx, const void *val, void *arg) +nds_ga_unixshell(UNUSED(NWDSContextHandle ctx), const void *val, void *arg) { struct nw_user_info *ui = (struct nw_user_info *) arg; @@ -1963,7 +2017,7 @@ nds_update_gecos(struct nw_user_info *ui, const char *str) // PP we append the Comment after the full name, separated by a comma static NWDSCCODE -nds_ga_unixcomment(NWDSContextHandle ctx, const void *val, void *arg) +nds_ga_unixcomment(UNUSED(NWDSContextHandle ctx), const void *val, void *arg) { struct nw_user_info *ui = (struct nw_user_info *) arg; @@ -1976,7 +2030,7 @@ nds_ga_unixcomment(NWDSContextHandle ctx, const void *val, void *arg) // PP can be any naming attribute returning a SYN_CI_STRING see define before nds_user_info() // PP we add the name before any comment that can be there static NWDSCCODE -nds_ga_gecos(NWDSContextHandle ctx, const void *val, void *arg) +nds_ga_gecos(UNUSED(NWDSContextHandle ctx), const void *val, void *arg) { struct nw_user_info *ui = (struct nw_user_info *) arg; NWDSCCODE err; @@ -2227,46 +2281,59 @@ nds_pp_location(NWDSContextHandle ctx, const void *val, void *arg) } #endif -static NWDSCCODE -nds_pp_home_directory(NWDSContextHandle ctx, const void *val, void *arg) -{ +static NWDSCCODE nds_pp_home_directory(NWDSContextHandle ctx, + const void* val, + void* arg) { struct nw_user_info *ui = (struct nw_user_info *) arg; const Path_T *pa = (const Path_T *) val; NWDSCCODE dserr; struct nw_home_info hi = { NULL, NULL }; char *v; + char * p; - if (ui->qflag & QF_DEBUG) - syslog(LOG_NOTICE, "start of NW home dir got %s %s \n", pa->volumeName, pa->path); + + if (ui->qflag & QF_DEBUG) syslog(LOG_NOTICE, "start of NW home dir got %s %s \n",pa->volumeName,pa->path); dserr = nds_home_info(ctx, (char *) pa->volumeName, &hi); if (dserr) return dserr; - if (ui->qflag & QF_DEBUG) - syslog(LOG_NOTICE, "got %s %s ", hi.hs, hi.hrn); + if (ui->qflag & QF_DEBUG) syslog(LOG_NOTICE, "got %s %s ",hi.hs,hi.hrn); ui->nwhomeServer = hi.hs; ui->nwhomeVolume = hi.hrn; - v = strdup(pa->path); + // revision 1.27. Do something smart ;-) if %LOGIN_ or %CN in the path to home. + if ((p = strstr(pa->path,"%CN")) != NULL) { + *p=0; // chop off %CN and replace by user's name + v = concat2m(pa->path,ui->name); + } else if ((p = strstr(pa->path, "%LOG")) != NULL) { // chop off %LOGIN_NAME or and replace by user's name up to 8 chars + char aux[9]; + *p=0; + + strncpy(aux, ui->name, 8); + aux[8] = 0; + v = concat2m(pa->path, aux); + } else { + v = strdup(pa->path); + } if (!v) { syslog(LOG_WARNING, "Not enough memory for strdup()\n"); return ENOMEM; } - ui->nwhomePath = unixifyPathUC(v); + unixifyPathUC(v); + ui->nwhomePath = v; if (ui->qflag & QF_DEBUG) - syslog(LOG_NOTICE, "end of NW home dir\n"); + syslog(LOG_NOTICE, "end of NW home dir: final path UNIX %s \n",ui->nwhomePath); return 0; } -static NWDSCCODE -nds_pp_smtp_email_address(NWDSContextHandle ctx, const void *val, void *arg) -{ +static NWDSCCODE nds_pp_smtp_email_address(UNUSED(NWDSContextHandle ctx), + const void* val, + void* arg) { struct nw_user_info *ui = (struct nw_user_info *) arg; const EMail_Address_T *em = (const EMail_Address_T *) val; char *v; - if (ui->qflag & QF_DEBUG) - syslog(LOG_NOTICE, "start of NW smtp email got %u %s\n", em->type, em->address); + if (ui->qflag & QF_DEBUG) syslog(LOG_NOTICE, "start of NW smtp email got %u %s\n",em->type,em->address); // pick up only the first with type=0 (SMTP) ! if ((!ui->emailSMTP && em->type == 0) && (!strncmp(em->address, "SMTP:", 5))) { // skip header SMTP: must be if type is 0 ? @@ -2284,7 +2351,7 @@ nds_pp_smtp_email_address(NWDSContextHandle ctx, const void *val, void *arg) } static NWDSCCODE -nds_pp_ldap_email_address(NWDSContextHandle ctx, const void *val, void *arg) +nds_pp_ldap_email_address(UNUSED(NWDSContextHandle ctx), const void *val, void *arg) { struct nw_user_info *ui = (struct nw_user_info *) arg; @@ -2307,7 +2374,7 @@ nds_pp_ldap_email_address(NWDSContextHandle ctx, const void *val, void *arg) } static NWDSCCODE -nds_pp_message_server(NWDSContextHandle ctx, const void *val, void *arg) +nds_pp_message_server(UNUSED(NWDSContextHandle ctx), const void *val, void *arg) { struct nw_user_info *ui = (struct nw_user_info *) arg; @@ -2481,7 +2548,7 @@ nw_retrieve_user_info(struct nw_user_info *ui) long err; NWObjectID oid; - err = pam_get_data(ui->pamh, "pam.ncpfs.passwd.conn", (const void **) &conn); + err = my_pam_get_data(ui->pamh, "pam.ncpfs.passwd.conn", &conn); if (err) return err; @@ -2498,7 +2565,7 @@ nw_retrieve_user_info(struct nw_user_info *ui) static int exechelper(const char *program, const char *argv[], const char *username) -{ // NULL is PAM so root +{ int i; int err; @@ -2512,10 +2579,10 @@ exechelper(const char *program, const char *argv[], const char *username) int status; switch (waitpid(i, &status, 0)) { - case 0: + case (pid_t)-1: syslog(LOG_ERR, "waitpid unexpectedly terminated: %s\n", strerror(errno)); return -1; - case (pid_t) - 1: + case 0: syslog(LOG_ERR, "waitpid: Fatal: No child processes\n"); return -1; default: @@ -2620,7 +2687,7 @@ do_chfn(const char *uname, const char *gecos, int verbose) if (p) { *p++ = '\0'; } else { - (const char *) p = ""; /* Use empty string for deletion */ + p = (char*)""; } argv[i++] = "-f"; @@ -3420,7 +3487,8 @@ mergeZenFlags(struct nw_user_info *ui) // su -l USER -c "ncpmount ..... " static int mount_nwhome(const char *unixname, const char *uname, // nw FQDN name - const char *pwd, const char *server, const char *volume, const char *path, const char *mntpoint, int uid, int zenFlag, int useIP, int verbose) + const char *pwd, const char *server, const char *volume, + const char *path, const char *mntpoint, int uid, UNUSED(int zenFlag), int useIP, int verbose) { const char *argv[30]; @@ -3713,7 +3781,7 @@ nw_create_nwclient(const char *uname, const struct nw_user_info *ui, const struc } static int -nw_process_forward_file(const char *uname, const struct nw_user_info *ui, const struct passwd *pwd) +nw_process_forward_file(UNUSED(const char *uname), const struct nw_user_info *ui, const struct passwd *pwd) { // what we do here it to setup a forward to any email address found in NDS // we do it during the authentication part so if the Netware home directory is mounted @@ -3786,19 +3854,19 @@ report(int err, const char *what, const char *info) } } -static void +static void __attribute__((unused)) test_pam_items(const char *me, pam_handle_t * pamh) { const char *info; int err; syslog(LOG_NOTICE, "%s testing for PAM items \n", me); - err = pam_get_item(pamh, PAM_RUSER, (const void **) &info); + err = my_pam_get_item(pamh, PAM_RUSER, &info); report(err, "PAM_RUSER", info); - err = pam_get_item(pamh, PAM_SERVICE, (const void **) &info); + err = my_pam_get_item(pamh, PAM_SERVICE, &info); report(err, "PAM_SERVICE", info); - err = pam_get_item(pamh, PAM_RHOST, (const void **) &info); + err = my_pam_get_item(pamh, PAM_RHOST, &info); report(err, "PAM_RHOST", info); - err = pam_get_item(pamh, PAM_TTY, (const void **) &info); + err = my_pam_get_item(pamh, PAM_TTY, &info); report(err, "PAM_TTY", info); } #endif @@ -3844,7 +3912,7 @@ static struct pam_auth_element pam_auth_table[] = { }; static int -process_zenflag_remote(pam_handle_t * pamh, const char *user, struct nw_user_info *ui) +process_zenflag_remote(pam_handle_t * pamh, UNUSED(const char *user), struct nw_user_info *ui) { int err; char *service; @@ -3863,7 +3931,7 @@ process_zenflag_remote(pam_handle_t * pamh, const char *user, struct nw_user_inf syslog(LOG_NOTICE, "Remote host and tty port are not checked\n"); return PAM_SUCCESS; } - err = pam_get_item(pamh, PAM_TTY, (const void **) &tty); + err = my_pam_get_item(pamh, PAM_TTY, &tty); if (err != PAM_SUCCESS) return PAM_SYSTEM_ERR; // local access @@ -3883,19 +3951,19 @@ process_zenflag_remote(pam_handle_t * pamh, const char *user, struct nw_user_inf } } - err = pam_get_item(pamh, PAM_RHOST, (const void **) &rhost); + err = my_pam_get_item(pamh, PAM_RHOST, &rhost); if (err != PAM_SUCCESS) { syslog(LOG_WARNING, "error getting PAM_RHOST"); return PAM_SYSTEM_ERR; } - err = pam_get_item(pamh, PAM_RUSER, (const void **) &ruser); + err = my_pam_get_item(pamh, PAM_RUSER, &ruser); if (err != PAM_SUCCESS) { syslog(LOG_WARNING, "error getting PAM_RUSER"); return PAM_SYSTEM_ERR; } - err = pam_get_item(pamh, PAM_SERVICE, (const void **) &service); + err = my_pam_get_item(pamh, PAM_SERVICE, &service); if (err != PAM_SUCCESS) { syslog(LOG_WARNING, "error getting PAM_SERVICE"); return PAM_SYSTEM_ERR; @@ -3946,7 +4014,7 @@ process_zenflag_remote(pam_handle_t * pamh, const char *user, struct nw_user_inf // must be done at this stage since they requires the user's current passwd static int -process_zenflag_auth(pam_handle_t * pamh, const char *user, struct nw_user_info *ui, const struct passwd *pwd, const char *userpass) +process_zenflag_auth(UNUSED(pam_handle_t * pamh), const char *user, struct nw_user_info *ui, const struct passwd *pwd, const char *userpass) { int err; // ignore errors for now @@ -4066,7 +4134,7 @@ pam_sm_authenticate(pam_handle_t * pamh, int flags, int argc, const char **argv) goto quit; /* Get password */ - pam_get_item(pamh, PAM_AUTHTOK, (void *) &p); + my_pam_get_item(pamh, PAM_AUTHTOK, &p); if (!p) { retval = _set_auth_tok(pamh, flags); @@ -4074,12 +4142,12 @@ pam_sm_authenticate(pam_handle_t * pamh, int flags, int argc, const char **argv) goto quit; } - pam_get_item(pamh, PAM_AUTHTOK, (void *) &p); + my_pam_get_item(pamh, PAM_AUTHTOK, &p); /* v 1.22 check the service is not a screensaver */ { const char *service; - if ((retval = pam_get_item(pamh, PAM_SERVICE, (const void **) &service)) != PAM_SUCCESS) + if ((retval = my_pam_get_item(pamh, PAM_SERVICE, &service)) != PAM_SUCCESS) goto quit; inf.isScreenSaverRelogin = strstr(service, "saver") != NULL; // report (retval, "PAM_SERVICE",service); @@ -4261,7 +4329,10 @@ pam_sm_authenticate(pam_handle_t * pamh, int flags, int argc, const char **argv) */ PAM_EXTERN int -pam_sm_setcred(pam_handle_t * pamh, int flags, int argc, const char **argv) +pam_sm_setcred(UNUSED(pam_handle_t * pamh), + UNUSED(int flags), + UNUSED(int argc), + UNUSED(const char **argv)) { //return PAM_IGNORE; return PAM_SUCCESS; @@ -4272,7 +4343,10 @@ pam_sm_setcred(pam_handle_t * pamh, int flags, int argc, const char **argv) */ PAM_EXTERN int -pam_sm_acct_mgmt(pam_handle_t * pamh, int flags, int argc, const char **argv) +pam_sm_acct_mgmt(UNUSED(pam_handle_t * pamh), + UNUSED(int flags), + UNUSED(int argc), + UNUSED(const char **argv)) { //return PAM_IGNORE; return PAM_SUCCESS; @@ -4282,7 +4356,7 @@ pam_sm_acct_mgmt(pam_handle_t * pamh, int flags, int argc, const char **argv) static int nw_attempt_passwd_prelim_server(pam_handle_t * pamh, const char *server, const char *user, const char *oldpwd, - int qflag, const char *group, int flags) + int qflag, const char *group, UNUSED(int flags)) { struct ncp_conn *conn; int err; @@ -4298,7 +4372,7 @@ nw_attempt_passwd_prelim_server(pam_handle_t * pamh, static int nw_attempt_passwd_prelim_tree(pam_handle_t * pamh, const char *tree, const char *user, const char *contexts, const char *oldpwd, - int qflag, const char *group, int flags, nuint nameFormat) + int qflag, const char *group, UNUSED(int flags), nuint nameFormat) { struct ncp_conn *conn; int err; @@ -4322,12 +4396,6 @@ nw_attempt_passwd_post(pam_handle_t * pamh, const char *pwd, const char *oldpwd, err = PAM_AUTHTOK_ERR; if (!(flags & PAM_UPDATE_AUTHTOK)) goto bailout_nf; - err = pam_get_data(pamh, "pam.ncpfs.passwd.conn", (const void **) &conn); - if (err) - goto bailout_nf; - err = nw_get_nwid(conn, &oid, qflag); - if (err) - goto bailout_nf; oldpwdup = strdup(oldpwd); if (!oldpwd) { @@ -4343,6 +4411,15 @@ nw_attempt_passwd_post(pam_handle_t * pamh, const char *pwd, const char *oldpwd, } str_upper(pwdup); + err = my_pam_get_data(pamh, "pam.ncpfs.passwd.conn", &conn); + if (err) + goto bailout; + err = nw_get_nwid(conn, &oid, qflag); + if (err) + goto bailout; + + + if (qflag & QF_BINDERY) { struct ncp_bindery_object uinfo; struct ncp_bindery_object u0; @@ -4410,13 +4487,17 @@ nw_attempt_passwd_post(pam_handle_t * pamh, const char *pwd, const char *oldpwd, syslog(LOG_DEBUG, "User %s has succesfully changed its NW pasword\n", username); bailoutctx:; NWDSFreeContext(ctx); + } bailout:; + // set it to null so nw_clean_up_conn will do no harm + err = pam_set_data(pamh, "pam.ncpfs.passwd.conn", NULL, NULL); + if (qflag & QF_DEBUG) + syslog (LOG_NOTICE,"pam end of PWD:setting conn to NULL %lx",err); free(pwdup); bailout_nf2:; free(oldpwdup); bailout_nf:; - pam_set_data(pamh, "ncpfs.pam.passwd.conn", NULL, NULL); return err; } @@ -4597,7 +4678,7 @@ quit:; // will process session on and session end zenFlag static int -nw_process_nwinfos_file(const char *uname, const struct nw_user_info *ui, const struct passwd *pwd) +nw_process_nwinfos_file(UNUSED(const char *uname), const struct nw_user_info *ui, const struct passwd *pwd) { // create a ~/.nwinfos file that can be "sourced" in future scripts FILE *f; @@ -4686,7 +4767,7 @@ nw_process_nwinfos_file(const char *uname, const struct nw_user_info *ui, const static int exechelper2(const char *program, // script name just to test if the command exist - const char *argv[], // extras arguments to -c program + const char *argv[], // extras arguments to -c program const char *unixname, // user to su to int verbose) { @@ -4742,7 +4823,7 @@ process_zenflag_session_opening(const char *user, const struct nw_user_info *ui, } PAM_EXTERN int -pam_sm_open_session(pam_handle_t * pamh, int flags, int argc, const char **argv) +pam_sm_open_session(pam_handle_t * pamh, UNUSED(int flags), int argc, const char **argv) { /* NO WAY to mount netware home here passord is lost, we are in the pam_session now. @@ -4750,8 +4831,8 @@ pam_sm_open_session(pam_handle_t * pamh, int flags, int argc, const char **argv) but I am not sure this is really safe !!! we only process here some ZENFLAGS red from NDS and stored in the PAM item "pam.ncpfs.user_info" - */ + struct ncp_conn *conn; struct nw_user_info *ui; const struct passwd *pwd; struct stat stt; @@ -4791,8 +4872,8 @@ pam_sm_open_session(pam_handle_t * pamh, int flags, int argc, const char **argv) if (qflag & QF_DEBUG) { syslog(LOG_NOTICE, "start of session \n"); } -// just in case user has been removed ??? - err = pam_get_item(pamh, PAM_USER, (const void **) &user); + // just in case user has been removed ??? + err = my_pam_get_item(pamh, PAM_USER, &user); if (err != PAM_SUCCESS || user == NULL || *user == '\0') goto doneok; @@ -4809,16 +4890,25 @@ pam_sm_open_session(pam_handle_t * pamh, int flags, int argc, const char **argv) } // get back user's info stored in PAM by the authentification section // no password there ! - err = pam_get_data(pamh, "pam.ncpfs.user_info", (const void **) &ui); + err = my_pam_get_data(pamh, "pam.ncpfs.user_info", &ui); if (!err) { if (qflag & QF_DEBUG) syslog(LOG_NOTICE, "got user info back %u", ui->uid); process_zenflag_session_opening(user, ui, pwd); - } else if (qflag & QF_DEBUG) - syslog(LOG_DEBUG, "failure reading back pam.ncpfs.user_info %u\n", err); + } else { + if (qflag & QF_DEBUG) + syslog(LOG_DEBUG, "failure reading back pam.ncpfs.user_info %u\n", err); + } // no problem, he is authenticated but "zen failed" doneok: - pam_set_data(pamh, "pam.ncpfs.passwd.conn", NULL, NULL); + // revision 1.27 we get rid of the authenticating connection . + // it is not in /etc/mtab, so it caoonot be "reused" by ncpmap anyway + err = my_pam_get_data(pamh, "pam.ncpfs.passwd.conn", &conn); + if (!err && conn) { + err = pam_set_data(pamh, "pam.ncpfs.passwd.conn", NULL, NULL); + if (qflag & QF_DEBUG) + syslog (LOG_NOTICE,"pam start of session :setting internal conn to NULL %x",err); + } return PAM_SUCCESS; } @@ -4828,7 +4918,7 @@ process_zenflag_session_closing(const char *user, const struct nw_user_info *ui, { int err = 0; -// first zenScripts in case they opeate on the mounted nwhome ! + // first zenScripts in case they opeate on the mounted nwhome ! if (ui->zenFlag & ZF_CLOSING_SCRIPTS) { const char *argv[5]; @@ -4836,7 +4926,7 @@ process_zenflag_session_closing(const char *user, const struct nw_user_info *ui, argv[2] = NWINFOS_FILE; // actual file name argv[3] = NULL; // argument 1 = location of nwinfos file to source in (=user's home dir) - //argument 2 = actual file name (default=.nwinfos) + // argument 2 = actual file name (default=.nwinfos) if (ui->qflag & QF_DEBUG) syslog(LOG_NOTICE, "running closing scripts.\n"); @@ -4865,7 +4955,7 @@ pam_do_close_session(const char *user, const struct nw_user_info *ui, const stru } PAM_EXTERN int -pam_sm_close_session(pam_handle_t * pamh, int flags, int argc, const char **argv) +pam_sm_close_session(pam_handle_t * pamh, UNUSED(int flags), int argc, const char **argv) // logout fom Netware at session end // no complains { @@ -4909,7 +4999,7 @@ pam_sm_close_session(pam_handle_t * pamh, int flags, int argc, const char **argv syslog(LOG_NOTICE, "end of session\n"); } // just in case user has been removed ??? - err = pam_get_item(pamh, PAM_USER, (const void **) &user); + err = my_pam_get_item(pamh, PAM_USER, &user); if (err != PAM_SUCCESS || user == NULL || *user == '\0') goto doneok; @@ -4927,7 +5017,7 @@ pam_sm_close_session(pam_handle_t * pamh, int flags, int argc, const char **argv goto doneok; } // read back all user data - err = pam_get_data(pamh, "pam.ncpfs.user_info", (const void **) &ui); + err = my_pam_get_data(pamh, "pam.ncpfs.user_info", &ui); if (!err) { if (qflag & QF_DEBUG) syslog(LOG_NOTICE, "got it back %u", ui->uid); @@ -4940,8 +5030,6 @@ pam_sm_close_session(pam_handle_t * pamh, int flags, int argc, const char **argv free_nw_user_info(ui); // forget about it doneok: closelog(); - - pam_set_data(pamh, "pam.ncpfs.passwd.conn", NULL, NULL); return PAM_SUCCESS; } diff --git a/contrib/pam/support.c b/contrib/pam/support.c index 08ed769..70fae1b 100644 --- a/contrib/pam/support.c +++ b/contrib/pam/support.c @@ -75,7 +75,7 @@ static int converse( pam_handle_t *pamh, int retval; struct pam_conv *conv; - retval = pam_get_item( pamh, PAM_CONV, (const void **) &conv ) ; + retval = my_pam_get_item(pamh, PAM_CONV, &conv); if ( retval == PAM_SUCCESS ) { retval = conv->conv( nargs, diff --git a/contrib/pam/support.h b/contrib/pam/support.h index 052cabc..e284d45 100644 --- a/contrib/pam/support.h +++ b/contrib/pam/support.h @@ -14,5 +14,20 @@ int _set_auth_tok(pam_handle_t *pamh, int flags); int _set_oldauth_tok(pam_handle_t *pamh, int flags); int _read_new_pwd(pam_handle_t *pamh, int flags); +#define UNUSED(x) x __attribute__((unused)) + +static inline int my_pam_get_item(const pam_handle_t *pamh, + int item_type, + void *item) { + return pam_get_item(pamh, item_type, (const void **)item); +} + +static inline int my_pam_get_data(const pam_handle_t *pamh, + const char *module_data_name, + void *data) { + return pam_get_data(pamh, module_data_name, (const void **)data); +} + + #endif /* __SUPPORT_H__ */ diff --git a/contrib/php/libtool b/contrib/php/libtool index 7ca53ed..bd79132 100755 --- a/contrib/php/libtool +++ b/contrib/php/libtool @@ -44,7 +44,7 @@ available_tags=" CXX" # ### BEGIN LIBTOOL CONFIG -# Libtool was configured on host vana: +# Libtool was configured on host evon: # Shell to use when invoking shell scripts. SHELL="/bin/sh" @@ -319,9 +319,8 @@ link_all_deplibs=unknown sys_lib_search_path_spec=" /usr/lib/gcc-lib/i486-linux/3.3.3/ /usr/lib/gcc/i486-linux/3.3.3/ /usr/lib/gcc-lib/i486-linux/3.3.3/../../../../i486-linux/lib/i486-linux/3.3.3/ /usr/lib/gcc-lib/i486-linux/3.3.3/../../../../i486-linux/lib/ /usr/lib/gcc-lib/i486-linux/3.3.3/../../../i486-linux/3.3.3/ /usr/lib/gcc-lib/i486-linux/3.3.3/../../../ /lib/i486-linux/3.3.3/ /lib/ /usr/lib/i486-linux/3.3.3/ /usr/lib/" # Run-time system search path for libraries -sys_lib_dlsearch_path_spec="/lib /usr/lib /usr/X11R6/lib/Xaw3d -/usr/X11R6/lib -/usr/local/lib +sys_lib_dlsearch_path_spec="/lib /usr/lib /usr/X11R6/lib + /usr/lib/libc5-compat /lib/libc5-compat /usr/i486-linuxlibc1/lib" @@ -6706,7 +6705,7 @@ build_old_libs=`case $build_libtool_libs in yes) $echo no;; *) $echo yes;; esac` # End: # ### BEGIN LIBTOOL TAG CONFIG: CXX -# Libtool was configured on host vana: +# Libtool was configured on host evon: # Shell to use when invoking shell scripts. SHELL="/bin/sh" @@ -6978,9 +6977,8 @@ link_all_deplibs=unknown sys_lib_search_path_spec=" /usr/lib/gcc-lib/i486-linux/3.3.3/ /usr/lib/gcc/i486-linux/3.3.3/ /usr/lib/gcc-lib/i486-linux/3.3.3/../../../../i486-linux/lib/i486-linux/3.3.3/ /usr/lib/gcc-lib/i486-linux/3.3.3/../../../../i486-linux/lib/ /usr/lib/gcc-lib/i486-linux/3.3.3/../../../i486-linux/3.3.3/ /usr/lib/gcc-lib/i486-linux/3.3.3/../../../ /lib/i486-linux/3.3.3/ /lib/ /usr/lib/i486-linux/3.3.3/ /usr/lib/" # Run-time system search path for libraries -sys_lib_dlsearch_path_spec="/lib /usr/lib /usr/X11R6/lib/Xaw3d -/usr/X11R6/lib -/usr/local/lib +sys_lib_dlsearch_path_spec="/lib /usr/lib /usr/X11R6/lib + /usr/lib/libc5-compat /lib/libc5-compat /usr/i486-linuxlibc1/lib" diff --git a/contrib/php/php_auth_nds.c b/contrib/php/php_auth_nds.c index d106bd8..668d094 100644 --- a/contrib/php/php_auth_nds.c +++ b/contrib/php/php_auth_nds.c @@ -37,10 +37,28 @@ string read_nds_string (tree, object, attribute) string read_nds_num (tree, object, attribute) - 1.04 2001, October 27 Patrick Pollet - Added nds_tree_auth allowing a tree name and a list of context to be searched - Simplified code by adding internal CreateCtx and CreateCtxAndConn (called by all NDS related functions) + 1.04 2001, October 27 Patrick Pollet + Added nds_tree_auth allowing a tree name and a list of context + to be searched + Simplified code by adding internal CreateCtx and CreateCtxAndConn + (called by all NDS related functions) + 1.05 2002, May 17 Patrick Pollet + Added contextless login when authenticating to NDS tree + + 1.06 2003, Feb 20 Patrick Pollet + Use NWCCOpenConnByName instead of ncp_open in nds_auth_fn + (auth against a NDS server) + Corrected the code of nds_read_int_fn that **was** returning + the value converted to string (!) so boolean returned + true/false and time stamp were converted to localized + time... Now it return the numeric value (still in a PHP + string). + + 1.07 2003, July 22 Patrick Pollet + Added read_nds_string2 and read_nds_int2 to fetch NDS data against + a server in a pure IP environnment where NWCXAttachTotreeByName + usually fails with err 0x8847 */ /* @@ -78,7 +96,7 @@ for more examples see /contrib/php/site */ -#include "config.h" +//#include "config.h" #include #include @@ -91,6 +109,9 @@ for more examples see /contrib/php/site #include #include #include +#include +#include +#define _(X) gettext(X) static int is_member_of_group_bind( char* errstr,NWCONN_HANDLE conn,const char* user,const char* group) { int err; @@ -159,7 +180,7 @@ bailout: /* internal; called by all functions requiring a context */ static int _createCtx ( char * errstr, NWDSContextHandle *ctx) { - NWDSCCODE dserr; + NWDSCCODE dserr; u_int32_t ctxflag = 0; u_int32_t confidence = 0; int eval = 0; @@ -310,14 +331,9 @@ static int nds_auth_fn(char* errstr, const char* server, const char* objectname, goto bailout; } } else { - struct ncp_conn_spec connsp; - long err; - - memset(&connsp, 0, sizeof(connsp)); - strcpy(connsp.server, server); - conn = ncp_open(&connsp, &err); - if (!conn) { - sprintf(errstr, "ncp_open failed with %s\n",strnwerror(err)); + dserr = NWCCOpenConnByName(NULL,server, NWCC_NAME_FORMAT_BIND, 0, 0, &conn); + if (dserr) { + sprintf(errstr, "ncp_open failed with %s\n",strnwerror(dserr)); eval=105; goto bailout; } @@ -360,6 +376,183 @@ bailout: } +// this code was contributed by Jean Francois Burdet +// in the pam authentication module +// to implement a contextless login if a list of context to serach is not provided in the command line +// ported to this php module by PP +// ctx and a conn have been set by caller and conn added to ctx +static NWDSCCODE nw_ctx_search( + char * errstr, + NWDSContextHandle context, + const char * user_cn, + char * contexts, + size_t maxsize) { + + NWDSCCODE ccode; + nuint32 iterationHandle = NO_MORE_ITERATIONS; + nint32 countObjectsSearched; + nuint32 objCntr; + nuint32 objCount; + char objectName[MAX_DN_CHARS+1]; + size_t ctxp=0; + int cnt=0; + + + // buffers + pBuf_T searchFilter=NULL; // search filter + pBuf_T retBuf=NULL; // result buffer for NWDSSearch + Filter_Cursor_T* cur=NULL; // search expression tree temporary buffer + + + + if (!contexts || maxsize < MAX_DN_CHARS+1) + return EINVAL; + + /******************************************************************* + In order to search, we need: + A Filter Cursor (to build the search expression) + A Filter Buffer (to store the expression; used by NWDSSearch) + A Buffer to store which attributes we need information on + A Result Buffer (to store the search results) + */ + + /******************************************************************* + ** Allocate Filter buffer and Cursor and populate + */ + ccode = NWDSAllocBuf(DEFAULT_MESSAGE_LEN,&searchFilter); + if (ccode ) { + sprintf(errstr,"nw_ctx_search:NWDSAllocBuf returned: %d\n", ccode); + goto Exit4; + } + + // Initialize the searchFilter buffer + ccode = NWDSInitBuf(context,DSV_SEARCH_FILTER,searchFilter); + if (ccode) { + sprintf(errstr,"nw_ctx_search:NWDSInitBuf returned: %d\n", ccode); + goto Exit4; + } + + // Allocate a filter cursor to put the search expression + ccode = NWDSAllocFilter(&cur); + if (ccode) { + sprintf(errstr,"nw_ctx_search:NWDSAllocFilter returned: %d\n", ccode); + goto Exit4; + } + + // Build the expression tree in cur, then place into searchFilter + // Object Class = User AND CN = user_cn + ccode = NWDSAddFilterToken(cur,FTOK_ANAME,"Object Class",SYN_CLASS_NAME); + ccode = NWDSAddFilterToken(cur,FTOK_EQ,NULL,0); + ccode = NWDSAddFilterToken(cur,FTOK_AVAL,"User",SYN_CLASS_NAME); + ccode = NWDSAddFilterToken(cur,FTOK_AND,NULL,0); + ccode = NWDSAddFilterToken(cur,FTOK_ANAME,"CN",SYN_CI_STRING); + ccode = NWDSAddFilterToken(cur,FTOK_EQ,NULL,0); + ccode = NWDSAddFilterToken(cur,FTOK_AVAL,(char *)user_cn,SYN_CI_STRING); + ccode = NWDSAddFilterToken(cur,FTOK_END,NULL,0); + + ccode = NWDSPutFilter(context,searchFilter,cur,NULL); + if (ccode ) { + sprintf(errstr,"nw_ctx_search:NWDSPutFilter returned: %d\n", ccode); + goto Exit4; + } + else + cur=NULL; + + + ccode = NWDSAllocBuf(DEFAULT_MESSAGE_LEN,&retBuf); + if (ccode ) { + sprintf(errstr,"nw_ctx_search:NWDSAllocBuf returned: %d\n", ccode); + goto Exit4; + } + + iterationHandle = NO_MORE_ITERATIONS; + ctxp = 0; + //syslog(LOG_NOTICE, "debut de recherche\n"); + // while NWDSSearch still can get some objects... + do { + + ccode = NWDSSearch(context, + "[Root]", + DS_SEARCH_SUBTREE, + 0, // don't dereference aliases + searchFilter, + 0, // we want attributes and values + 0, // only want information in attrNames + NULL, + &iterationHandle, + 0, // reserved + &countObjectsSearched, + retBuf); + if (ccode) { + sprintf(errstr,"nw_ctx_search:NWDSSearch returned: %s\n", strnwerror(ccode)); + goto Exit4; + } + syslog(LOG_NOTICE, "passe de recherche %d \n",cnt); + // count the object returned in the buffer + ccode = NWDSGetObjectCount(context,retBuf,&objCount); + if (ccode) { + sprintf(errstr,"nw_ctx_search:NWDSGetObjectCount returned: %d\n", ccode); + goto Exit4; + } + + // for the number of objects returned... + syslog(LOG_NOTICE, "trouvé %d \n",objCount); + + for (objCntr=0;objCntr= maxsize) { + break; + } + if (ctxp) { + *contexts++ = ','; + maxsize--; + } + memcpy(contexts, p + 1, ln); + contexts += ln; + maxsize -= ln; + ctxp = 1; + } // objCntr + } while (iterationHandle != NO_MORE_ITERATIONS); + if (iterationHandle != NO_MORE_ITERATIONS) { + // let's keep the final dserr as the 'out of memory error' from ptr->getval() + NWDSCloseIteration(context, DSV_SEARCH_FILTER, iterationHandle); + } + //lets remove trailing ',' + if (ctxp) + *contexts = 0; + else { + ccode=109; // not found... + sprintf(errstr,"Failure of contextless login: unknown user"); + + } + +Exit4: + if (retBuf) + NWDSFreeBuf(retBuf); + if (cur) + NWDSFreeFilter(cur, NULL); + if (searchFilter) + NWDSFreeBuf(searchFilter); + syslog(LOG_NOTICE, "fin de ctxless login err= %d :%s\n",ccode,contexts); + return ccode; + +} + + /* authenticate to a NDS tree and return FQDN of found user */ static int tree_auth_fn(char* errstr, const char* treename, const char* objectname, const char* contexts,const char* pwd, const char * group, char * fqdn) @@ -371,13 +564,27 @@ static int tree_auth_fn(char* errstr, const char* treename, const char* objectna const char * ctxStart; const char* ctxEnd; NWObjectID oid; - + char ctxbuf[4096]; // buffer to hold possible matches in a contexless login eval=_createCtxAndConn (errstr,treename, &ctx, &conn); if (eval) return eval; + openlog("pph_ncp_auth", LOG_PID, LOG_AUTHPRIV); + if (!contexts[0]) { + //if (!contexts) { + ctxbuf[0]=0; + if (nw_ctx_search(errstr,ctx,objectname,ctxbuf,sizeof(ctxbuf))) { + eval =109; + goto bailout; + } + ctxStart=ctxbuf; + } + else + ctxStart=contexts; + /* scan the search contexts list */ - ctxStart=contexts; + + syslog(LOG_NOTICE, "début de recherche %s :%s\n",ctxStart,contexts); do { strcpy(fqdn,objectname); if (ctxStart) { @@ -393,35 +600,42 @@ static int tree_auth_fn(char* errstr, const char* treename, const char* objectna strcat(fqdn,ctxStart); ctxStart=ctxEnd; } - eval=109; // don't forget to reset it !!!! - dserr=NWDSMapNameToID(ctx,conn, fqdn,&oid); - if (!dserr) { //found a matching user - dserr = NWDSVerifyObjectPassword(ctx, NDS_PASSWORD, fqdn, pwd); - if (dserr) { //password makes the difference - sprintf(errstr, "Verify password failed: %s\n", strnwerror(dserr)); - eval = 110; - } else { - eval=0; // got him - break; - } - } - } while (ctxStart ); + eval=109; // don't forget to reset it !!!! + + dserr=NWDSMapNameToID(ctx,conn,fqdn,&oid); + //dserr=0; + syslog(LOG_NOTICE, "essai avec %s %x %d\n",fqdn,oid,dserr); + if (!dserr) { //found a matching user + dserr = NWDSVerifyObjectPassword(ctx, NDS_PASSWORD, fqdn, pwd); + if (dserr) { //password makes the difference + syslog(LOG_NOTICE,"Verify password failed: %s\n", strnwerror(dserr)); + sprintf(errstr, "Verify password failed: %s\n", strnwerror(dserr)); + eval = 110; + } else { + eval=0; // got him + break; + } + } + } while (ctxStart); if (!dserr) { if (group[0]) - eval=is_member_of_group_nds(errstr,ctx,conn,oid,group); + eval=is_member_of_group_nds(errstr,ctx,conn,oid,group); + } +bailout: NWCCCloseConn(conn); dserr = NWDSFreeContext(ctx); - if (dserr) { + if (dserr) { sprintf(errstr, "NWDSFreeContext failed with %s\n", strnwerror(dserr)); eval=111; - } + } + closelog(); return eval; } -static int nds_read_string_fn(char* errstr, const char* treename, const char* objectname, const char* attrname,char ** buffer){ +static int nds_read_string_fn(char* errstr, const char* treename, const char* objectname, const char* attrname, char** buffer) { /* return single or multi string attributes */ NWDSCCODE dserr; NWDSContextHandle ctx=NULL; @@ -450,7 +664,66 @@ static int nds_read_string_fn(char* errstr, const char* treename, const char* ob return eval; } -static int nds_read_int_fn(char* errstr, const char* treename, const char* objectname, const char* attrname,char * buffer, int maxlen){ + +static int nds_read_string_fn2(char* errstr, const char* servername, const char* objectname, const char* attrname, char** buffer) { +/* return single or multi string attributes using a servername instead of a treename*/ + + NWDSCCODE dserr; + NWDSContextHandle ctx=NULL; + NWCONN_HANDLE conn=NULL; + int eval = 0; + + if (!servername || !objectname || !attrname ) { + sprintf (errstr," invalid parameters."); + return 98; + } + + eval=_createCtx (errstr,&ctx); + if (eval) + return eval; + + if (servername[0] == '/') { + dserr = ncp_open_mount(servername, &conn); + if (dserr) { + sprintf(errstr, "ncp_open_mount failed with %s\n", strnwerror(dserr)); + eval=104; + goto bailout; + } + } else { + dserr = NWCCOpenConnByName(NULL,servername, NWCC_NAME_FORMAT_BIND, 0, 0, &conn); + if (dserr) { + sprintf(errstr, "ncp_open failed with %s\n",strnwerror(dserr)); + eval=105; + goto bailout; + } + } + dserr = NWDSAddConnection(ctx, conn); + if (dserr) { + sprintf(errstr, "Cannot bind connection to context: %s\n",strnwerror(dserr)); + eval=106; + goto bailout; + } + + + dserr= NWCXGetMultiStringAttributeValue (ctx,objectname,attrname,buffer); + if (dserr) { + sprintf(errstr, "NWCXGetAttribute failed : %s\n",strnwerror(dserr)); + eval=106; + } +bailout: + if (conn) NWCCCloseConn(conn); + if (ctx) { + dserr = NWDSFreeContext(ctx); + if (dserr) { + sprintf(errstr, "NWDSFreeContext failed with %s\n", strnwerror(dserr)); + eval=107; + } + } + return eval; +} + + +static int nds_read_int_fn(char* errstr, const char* treename, const char* objectname, const char* attrname, int* result) { /* return single numeric NDS (include time and boolean attributes)*/ NWDSCCODE dserr; @@ -462,11 +735,12 @@ static int nds_read_int_fn(char* errstr, const char* treename, const char* objec sprintf (errstr," invalid parameters."); return 98; } - eval=_createCtxAndConn (errstr,treename, &ctx, &conn); + + eval=_createCtxAndConn (errstr,treename, &ctx, &conn); if (eval) return eval; - dserr=NWCXGetAttributeValueAsString (ctx,objectname,attrname,buffer,maxlen); + dserr=NWCXGetIntAttributeValue (ctx,objectname,attrname,result); if (dserr) { sprintf(errstr, "NWCXGetAttribute failed : %s\n",strnwerror(dserr)); eval=106; @@ -480,6 +754,64 @@ static int nds_read_int_fn(char* errstr, const char* treename, const char* objec return eval; } +static int nds_read_int_fn2(char* errstr, const char* servername, const char* objectname, const char* attrname,int* result) +{ +/* return single numeric NDS (include time and boolean attributes)*/ + NWDSCCODE dserr; + NWDSContextHandle ctx=NULL; + NWCONN_HANDLE conn=NULL; + int eval = 0; + + if (!servername || !objectname || !attrname ) { + sprintf (errstr," invalid parameters."); + return 98; + } + + eval=_createCtx (errstr,&ctx); + if (eval) + return eval; + + if (servername[0] == '/') { + dserr = ncp_open_mount(servername, &conn); + if (dserr) { + sprintf(errstr, "ncp_open_mount failed with %s\n", strnwerror(dserr)); + eval=104; + goto bailout; + } + } else { + dserr = NWCCOpenConnByName(NULL,servername, NWCC_NAME_FORMAT_BIND, 0, 0, &conn); + if (dserr) { + sprintf(errstr, "ncp_open failed with %s\n",strnwerror(dserr)); + eval=105; + goto bailout; + } + } + dserr = NWDSAddConnection(ctx, conn); + if (dserr) { + sprintf(errstr, "Cannot bind connection to context: %s\n",strnwerror(dserr)); + eval=106; + goto bailout; + } + + dserr=NWCXGetIntAttributeValue(ctx, objectname, attrname, result); + if (dserr) { + sprintf(errstr, "NWCXGetAttribute failed : %s\n",strnwerror(dserr)); + eval=106; + } + +bailout: + if (conn) NWCCCloseConn(conn); + if (ctx) { + dserr = NWDSFreeContext(ctx); + if (dserr) { + sprintf(errstr, "NWDSFreeContext failed with %s\n", strnwerror(dserr)); + eval=107; + } + } + return eval; + +} + PHP_FUNCTION (read_nds_string) { @@ -528,12 +860,59 @@ PHP_FUNCTION (read_nds_string) } +PHP_FUNCTION (read_nds_string2) +//use a servername instaed of a tree name +{ + int res; /* fcn result code */ + const char *servern, *objectn, *attributen; + char errstr[512]; + char local_buffer [8192]; + char * buffer; // returned by NWCXGetMultiStringAttributeValue + + int argc = ZEND_NUM_ARGS(); + zval **server, **object, **attribute; + + if (argc != 3 || zend_get_parameters_ex(argc, &server, &object, &attribute)) { + WRONG_PARAM_COUNT; + } + + sprintf(errstr, "Wrong parameters values"); + if (!server || !object || !attribute) { + RETURN_STRING(errstr,1); + } + + convert_to_string_ex(server); + convert_to_string_ex(object); + convert_to_string_ex(attribute); + + servern = (*server)->value.str.val; + objectn = (*object)->value.str.val; + attributen = (*attribute)->value.str.val; + + if (!servern || !objectn || !attributen) { + RETURN_STRING(errstr,1); + } + + sprintf(errstr, "failure"); + res=nds_read_string_fn2(errstr,servern,objectn,attributen,&buffer); + if (res) { + RETURN_STRING(errstr,1); + } + if (strlen(buffer) >=sizeof(local_buffer)) { + buffer[sizeof(local_buffer)-1]=0; + + } + strcpy(local_buffer,buffer); + free(buffer); + RETURN_STRING(local_buffer,1); + +} + PHP_FUNCTION (read_nds_int) { int res; /* fcn result code */ const char *treen, *objectn, *attributen; char errstr[512]; - char buffer [512]; int argc = ZEND_NUM_ARGS(); zval **tree, **object, **attribute; @@ -558,15 +937,61 @@ PHP_FUNCTION (read_nds_int) if (!treen || !objectn || !attributen) { RETURN_STRING(errstr,1); } - buffer[0]=0; sprintf(errstr, "failure"); - res=nds_read_int_fn(errstr,treen,objectn,attributen,buffer,sizeof(buffer)); - if (res) { - RETURN_STRING(errstr,1); - } - RETURN_STRING(buffer,1); + { + int result; + res = nds_read_int_fn(errstr, treen, objectn, attributen, &result); + if (!res) { + sprintf(errstr, "%d", result); + } + } + RETURN_STRING(errstr, 1); } + +PHP_FUNCTION (read_nds_int2) +// use a servername instead of a tree name as first argument +{ + int res; /* fcn result code */ + const char *servern, *objectn, *attributen; + char errstr[512]; + + int argc = ZEND_NUM_ARGS(); + zval **server, **object, **attribute; + + if (argc != 3 || zend_get_parameters_ex(argc, &server, &object, &attribute)) { + WRONG_PARAM_COUNT; + } + + sprintf(errstr, "Wrong parameters values"); + if (!server || !object || !attribute) { + RETURN_STRING(errstr,1); + } + + convert_to_string_ex(server); + convert_to_string_ex(object); + convert_to_string_ex(attribute); + + servern = (*server)->value.str.val; + objectn = (*object)->value.str.val; + attributen = (*attribute)->value.str.val; + + if (!servern || !objectn || !attributen) { + RETURN_STRING(errstr,1); + } + sprintf(errstr, "failure"); + { + int result; + + res = nds_read_int_fn2(errstr, servern, objectn, attributen, &result); + if (!res) { + sprintf(errstr, "%d", result); + } + } + RETURN_STRING(errstr, 1); +} + + PHP_FUNCTION(auth_bindery) { int res; /* fcn result code */ @@ -603,8 +1028,7 @@ PHP_FUNCTION(auth_tree) int res; /* fcn result code */ const char *servern, *ctxs,*usern, *sent_pw, *groupn; char errstr[512]; - char fqdn[MAX_DN_CHARS+1]; // to get the FQDN used - char fqdn_ret[MAX_DN_CHARS+5]; // to return to php DN=xxx.yyy.zzz + char fqdn[MAX_DN_CHARS+5]; // to get 'DN=' plus the FQDN used int argc = ZEND_NUM_ARGS(); zval **server, **user, **contexts, **password, **group; @@ -625,14 +1049,12 @@ PHP_FUNCTION(auth_tree) /* do they know the magic word? */ sprintf(errstr, "failure"); - res = tree_auth_fn(errstr, servern, usern, ctxs,sent_pw, groupn,fqdn); + strcpy(fqdn, "DN="); + res = tree_auth_fn(errstr, servern, usern, ctxs,sent_pw, groupn, fqdn + 3); if (res) { - RETURN_STRING(errstr,1); + RETURN_STRING(errstr, 1); } - //RETURN_FALSE; - strcpy(fqdn_ret,"DN="); - strcat(fqdn_ret,fqdn); - RETURN_STRING(fqdn_ret,1); + RETURN_STRING(fqdn, 1); } PHP_FUNCTION(auth_nds) @@ -675,8 +1097,8 @@ PHP_MINIT_FUNCTION(auth_nds) PHP_MINFO_FUNCTION(auth_nds) { php_info_print_table_start(); - php_info_print_table_row(3, "NDS/Bindery authentication support", "enabled","(c) 2000-2001 by P.Vandrovec & P.Pollet "); - php_info_print_table_row(3, "NDS reading properties support", "enabled","(c) 2001 by P.Pollet"); + php_info_print_table_row(3, "NDS/Bindery authentication support", "enabled", "(c) 2000-2001 by P.Vandrovec and P.Pollet"); + php_info_print_table_row(3, "NDS reading properties support", "enabled", "(c) 2001 by P.Pollet"); php_info_print_table_end(); } @@ -686,12 +1108,14 @@ function_entry auth_nds_functions[] = { PHP_FE(auth_tree, NULL) PHP_FE(read_nds_string, NULL) PHP_FE(read_nds_int, NULL) + PHP_FE(read_nds_string2, NULL) + PHP_FE(read_nds_int2, NULL) {NULL, NULL, NULL} }; zend_module_entry auth_nds_module_entry = { #if ZEND_MODULE_API_NO >= 20010901 - STANDARD_MODULE_HEADER, + STANDARD_MODULE_HEADER, #endif "auth_nds", auth_nds_functions, diff --git a/contrib/testing/readattr.c b/contrib/testing/readattr.c index 542801e..dc09dd6 100644 --- a/contrib/testing/readattr.c +++ b/contrib/testing/readattr.c @@ -57,6 +57,7 @@ typedef u_int32_t Time_T; #include #include +#include #include #include #include @@ -68,6 +69,8 @@ typedef u_int32_t Time_T; static char *progname; +static int nflag = 0; + static void usage(void) { @@ -81,6 +84,7 @@ help(void) "usage: %s [options]\n"), progname); printf(_("\n" "-h Print this help text\n" + "-n Only print attribute value\n" "-v value Context DCK_FLAGS value (default 0)\n" "-o object_name Name of object (default [Root])\n" "-c context_name Name of current context (default OrgUnit.Org.Country)\n" @@ -103,6 +107,410 @@ char* strnwerror(int err) { } #endif +static int nprintf(char const *format, ...) +{ + va_list ap; + int ret = 0; + + va_start(ap, format); + if (!nflag) + ret = vprintf(format, ap); + va_end(ap); + return ret; +} + +static void printenum(char const *label, int val, char const * const *names, + int maxval) +{ + if (!nflag) + printf("%s: ", label); + if (val < 0 || val >= maxval) + printf("%d", val); + else if (nflag) + printf("%s", names[val]); + else + printf("%s (%d)", names[val], val); + if (!nflag) + printf("\n"); +} + +static void printstring(char const *label, char const *val) +{ + if (nflag) + printf("%s", val); + else + printf("%s: '%s'\n", label, val); +} + +static char const * const syntaxes[] = { + "UNKNOWN", + "DIST_NAME", + "CE_STRING", + "CI_STRING", + "PR_STRING", + "NU_STRING", + "CI_LIST", + "BOOLEAN", + "INTEGER", + "OCTET_STRING", + "TEL_NUMBER", + "FAX_NUMBER", + "NET_ADDRESS", + "OCTET_LIST", + "EMAIL_ADDRESS", + "PATH", + "REPLICA_POINTER", + "OBJECT_ACL", + "PO_ADDRESS", + "TIMESTAMP", + "CLASS_NAME", + "STREAM", + "COUNTER", + "BACK_LINK", + "TIME", + "TYPED_NAME", + "HOLD", + "INTERVAL", +}; +#define NSYNTAXES (sizeof(syntaxes) / sizeof(syntaxes[0])) + +static char const * const nettypes[] = { + "IPX", + "IP", + "SDLC", + "TOKENRING_ETHERNET", + "OSI", + "APPLETALK", + "NETBEUI", + "SOCKADDR", + "UDP", + "TCP", + "UDP6", + "TCP6", + "INTERNAL", + "URL", +}; +#define NNETTYPES (sizeof(nettypes) / sizeof(nettypes[0])) + +static char const * const namespaces[] = { + "DOS", + "MACINTOSH", + "UNIX", + "FTAM", + "OS2", +}; +#define NNAMESPACES (sizeof(namespaces) / sizeof(namespaces[0])) + +static void printnetaddr(char *name) +{ + Net_Address_T* na = (Net_Address_T*)name; + size_t z; + + printenum(" Type", na->addressType, nettypes, NNETTYPES); + if (nflag) printf(":"); + nprintf(" Length: %u\n", na->addressLength); + nprintf(" Data: "); + switch (na->addressType) { + case NT_IPX: + for (z = 0; z < na->addressLength; z++) + printf("%02X%s", na->address[z], + z == 3 || z == 9 ? ":" : ""); + break; + case NT_IP: + if (na->addressLength < 4) break; + printf("%d.%d.%d.%d", na->address[0], na->address[1], + na->address[2], na->address[3]); + break; + case NT_TCP: + case NT_UDP: + if (na->addressLength < 6) break; + printf("%d.%d.%d.%d:%d", na->address[2], na->address[3], + na->address[4], na->address[5], + (na->address[0] << 8) + na->address[1]); + break; + case NT_URL: + /* Ugly, but URLs are confined to a subset of ASCII anyway */ + for (z = 0; z < na->addressLength; z += 2) + printf("%c", na->address[z]); + break; + default: + for (z = 0; z < na->addressLength; z++) + printf("%02X ", na->address[z]); + break; + } + printf("\n"); +} + +static void printattr(NWDSContextHandle ctx, int req, Buf_T *buf) +{ + char name[65536]; + NWObjectCount valcnt; + enum SYNTAX synt; + NWDSCCODE dserr; + + dserr = NWDSGetAttrName(ctx, buf, name, &valcnt, &synt); + if (dserr) { + fprintf(stderr, "GetAttrName failed with %s\n", + strnwerror(dserr)); + return; + } + if (!nflag) + printstring(" Attribute", name); + if (req > 0) { + if (!nflag) + printenum(" Syntax", synt, syntaxes, NSYNTAXES); + while (valcnt--) { + size_t cs; + + nprintf(" Value:\n"); + if ((req == 3) || (req == 4)) { + nuint32 flags; + TimeStamp_T stamp; + + dserr = NWDSGetAttrValFlags(ctx, buf, &flags); + if (dserr) { + fprintf(stderr, "GetAttrFlags failed with %s\n", + strnwerror(dserr)); + break; + } + nprintf(" Flags: %08X\n", flags); + dserr = NWDSGetAttrValModTime(ctx, buf, &stamp); + if (dserr) { + fprintf(stderr, "GetAttrModTime failed with %s\n", + strnwerror(dserr)); + break; + } + nprintf(" ModTime: %u / %u.%u\n", stamp.wholeSeconds, + stamp.replicaNum, stamp.eventID); + } + if (req == 4) { + nuint32 internalLen; + + dserr = NWDSGetAttrValFlags(ctx, buf, &internalLen); + if (dserr) { + fprintf(stderr, "GetAttrFlags failed with %s\n", + strnwerror(dserr)); + break; + } + nprintf(" Internal Value Length: %u\n", internalLen); + continue; + } + dserr = NWDSComputeAttrValSize(ctx, buf, synt, &cs); + if (dserr) { + fprintf(stderr, "ComputeAttrValSize failed for SYNT %d\n", synt); + cs = ~0; + } + memset(name, 0xEE, sizeof(name)); + dserr = NWDSGetAttrVal(ctx, buf, synt, name); + if (dserr) { + fprintf(stderr, "GetAttrVal failed with %s\n", + strnwerror(dserr)); + break; + } + { + size_t rl = sizeof(name); + while ((rl > 0) && (name[rl - 1] == '\xEE')) rl--; + if (cs != rl) { + nprintf("SYNT %d: computed: %u, real: %u\n", synt, cs, rl); + } + } + switch (synt) { + case SYN_DIST_NAME: + case SYN_CI_STRING: + case SYN_CE_STRING: + case SYN_PR_STRING: + case SYN_NU_STRING: + case SYN_TEL_NUMBER: + case SYN_CLASS_NAME: + printstring(" Value", name); + if (nflag) + printf("\n"); + break; + case SYN_OCTET_STRING: + { + Octet_String_T* os = (Octet_String_T*)name; + size_t i; + + nprintf(" Value: length=%u\n", os->length); + nprintf(" "); + for (i = 0; i < os->length; i++) + printf("%02X ", os->data[i]); + printf("\n"); + } + break; + case SYN_COUNTER: + case SYN_INTEGER: + case SYN_INTERVAL: + if (nflag) + printf("%d\n", *((Integer_T*)name)); + else + printf(" Value: %d (0x%X)\n", *((Integer_T*)name), *((Integer_T*)name)); + break; + case SYN_BOOLEAN: + { + Boolean_T* b = (Boolean_T*)name; + + if (nflag) + printf("%s", *b ? "TRUE" : "FALSE"); + else + printf(" Value: %u (%s)\n", *b, (*b==1)?"true":(*b)?"unknown":"false"); + } + break; + case SYN_TIMESTAMP: + { + TimeStamp_T* stamp = (TimeStamp_T*)name; + nprintf(" Value: "); + printf("%u / %u.%u\n", + stamp->wholeSeconds, stamp->replicaNum, + stamp->eventID); + } + break; + case SYN_NET_ADDRESS: + printnetaddr(name); + break; + case SYN_REPLICA_POINTER: + { + Replica_Pointer_T* rp = (Replica_Pointer_T*)name; + Net_Address_T* qp; + int cntv; + + nprintf(" Value:\n"); + nprintf(" Server Name: '%s'\n", rp->serverName); + nprintf(" Replica Type: %u\n", rp->replicaType); + nprintf(" Replica Number: %u\n", rp->replicaNumber); + nprintf(" Address Count: %u\n", rp->count); + for (cntv = rp->count, qp = rp->replicaAddressHint; cntv--; qp++) { + size_t z; + + nprintf(" Type: %u\n", qp->addressType); + nprintf(" Length: %u\n", qp->addressLength); + nprintf(" Data: "); + for (z = 0; z < qp->addressLength; z++) + nprintf("%02X ", qp->address[z]); + nprintf("\n"); + } + } + break; + case SYN_OBJECT_ACL: + { + Object_ACL_T* oacl = (Object_ACL_T*)name; + + nprintf(" Protected Attribute: '%s'\n", oacl->protectedAttrName); + nprintf(" Subject Name: '%s'\n", oacl->subjectName); + nprintf(" Privileges: %08X\n", oacl->privileges); + } + break; + case SYN_PATH: + { + Path_T* p = (Path_T*)name; + + printenum(" Name Space Type", + p->nameSpaceType, + namespaces, NNAMESPACES); + if (nflag) + printf("\n"); + printstring(" Volume Name", + p->volumeName); + if (nflag) + printf("\n"); + printstring(" Path", p->path); + if (nflag) + printf("\n"); + } + break; + case SYN_TIME: + { + nprintf(" Time: %s", ctime((Time_T*)name)); + } + break; + case SYN_TYPED_NAME: + { + Typed_Name_T* tn = (Typed_Name_T*)name; + + nprintf(" Interval: %u\n", tn->interval); + nprintf(" Level: %u\n", tn->level); + nprintf(" Name: '%s'\n", tn->objectName); + } + break; + case SYN_CI_LIST: + { + CI_List_T* cl = (CI_List_T*)name; + + for (; cl; cl = cl->next) { + nprintf(" Value: '%s'\n", cl->s); + } + } + break; + case SYN_OCTET_LIST: + { + Octet_List_T* ol = (Octet_List_T*)name; + + for (; ol; ol = ol->next) { + size_t i; + + nprintf(" Value: Length: %u\n", ol->length); + nprintf(" "); + for (i = 0; i < ol->length; i++) + nprintf("%02X ", ol->data[i]); + nprintf("\n"); + } + } + break; + case SYN_BACK_LINK: + { + Back_Link_T* bl = (Back_Link_T*)name; + + nprintf(" Remote ID: %08X\n", bl->remoteID); + nprintf(" Object Name: '%s'\n", bl->objectName); + } + break; + case SYN_FAX_NUMBER: + { + Fax_Number_T* fn = (Fax_Number_T*)name; + + nprintf(" Fax Number: '%s'\n", fn->telephoneNumber); + nprintf(" Parameter bits: %u\n", fn->parameters.numOfBits); + } + break; + case SYN_EMAIL_ADDRESS: + { + EMail_Address_T* ea = (EMail_Address_T*)name; + + nprintf(" Type: %u\n", ea->type); + nprintf(" Address: '%s'\n", ea->address); + } + break; + case SYN_PO_ADDRESS: + { + Postal_Address_T* pa = (Postal_Address_T*)name; + + nprintf(" Line 1: '%s'\n", (*pa)[0]); + nprintf(" Line 2: '%s'\n", (*pa)[1]); + nprintf(" Line 3: '%s'\n", (*pa)[2]); + nprintf(" Line 4: '%s'\n", (*pa)[3]); + nprintf(" Line 5: '%s'\n", (*pa)[4]); + nprintf(" Line 6: '%s'\n", (*pa)[5]); + } + break; + case SYN_HOLD: + { + Hold_T* h = (Hold_T*)name; + + nprintf(" Amount: %u\n", h->amount); + nprintf(" Object Name: '%s'\n", h->objectName); + } + break; + default: + nprintf(" Value: unprintable\n"); + break; + } + } + if (dserr) + return; + } + +} + int main(int argc, char *argv[]) { NWDSCCODE dserr; NWDSContextHandle ctx; @@ -141,10 +549,13 @@ int main(int argc, char *argv[]) { fprintf(stderr, "NWDSCretateContextHandle failed with %s\n", strnwerror(dserr)); return 123; } - while ((opt = getopt(argc, argv, "h?o:c:v:S:C:q:s:u:t:a:")) != EOF) + while ((opt = getopt(argc, argv, "h?no:c:v:S:C:q:s:u:t:a:")) != EOF) { switch (opt) { + case 'n': + nflag++; + break; case 'a': if (!attr) { dserr = NWDSAllocBuf(DEFAULT_MESSAGE_LEN, &attr); @@ -290,267 +701,26 @@ int main(int argc, char *argv[]) { unsigned char* pp; NWObjectCount cnt; - printf("Iteration handle: %08X\n", ih); + nprintf("Iteration handle: %08X\n", ih); pp = buf->curPos; dserr = NWDSGetAttrCount(ctx, buf, &cnt); if (dserr) { fprintf(stderr, "GetAttrCount failed with %s\n", strnwerror(dserr)); } else { - printf("Attributes: %u\n", cnt); + nprintf("Attributes: %u\n", cnt); pp = buf->curPos; while (cnt--) { - char name[65536]; - NWObjectCount valcnt; - enum SYNTAX synt; - - dserr = NWDSGetAttrName(ctx, buf, name, &valcnt, &synt); - if (dserr) { - fprintf(stderr, "GetAttrName failed with %s\n", - strnwerror(dserr)); - break; - } - printf(" Attribute: '%s'\n", name); - if (req > 0) { - printf(" Syntax: %d\n", synt); - printf(" Values count: %d\n", valcnt); - while (valcnt--) { - size_t cs; - - printf(" Value:\n"); - if ((req == 3) || (req == 4)) { - nuint32 flags; - TimeStamp_T stamp; - - dserr = NWDSGetAttrValFlags(ctx, buf, &flags); - if (dserr) { - fprintf(stderr, "GetAttrFlags failed with %s\n", - strnwerror(dserr)); - break; - } - printf(" Flags: %08X\n", flags); - dserr = NWDSGetAttrValModTime(ctx, buf, &stamp); - if (dserr) { - fprintf(stderr, "GetAttrModTime failed with %s\n", - strnwerror(dserr)); - break; - } - printf(" ModTime: %u / %u.%u\n", stamp.wholeSeconds, - stamp.replicaNum, stamp.eventID); - } - dserr = NWDSComputeAttrValSize(ctx, buf, synt, &cs); - if (dserr) { - fprintf(stderr, "ComputeAttrValSize failed for SYNT %d\n", synt); - cs = ~0; - } - memset(name, 0xEE, sizeof(name)); - dserr = NWDSGetAttrVal(ctx, buf, synt, name); - if (dserr) { - fprintf(stderr, "GetAttrVal failed with %s\n", - strnwerror(dserr)); - break; - } - { - size_t rl = sizeof(name); - while ((rl > 0) && (name[rl - 1] == '\xEE')) rl--; - if (cs != rl) { - printf("SYNT %d: computed: %u, real: %u\n", synt, cs, rl); - } - } - switch (synt) { - case SYN_DIST_NAME: - case SYN_CI_STRING: - case SYN_CE_STRING: - case SYN_PR_STRING: - case SYN_NU_STRING: - case SYN_TEL_NUMBER: - case SYN_CLASS_NAME: - printf(" Value: '%s'\n", name); - break; - case SYN_OCTET_STRING: - { - Octet_String_T* os = (Octet_String_T*)name; - size_t i; - - printf(" Value: length=%u\n", os->length); - printf(" "); - for (i = 0; i < os->length; i++) - printf("%02X ", os->data[i]); - printf("\n"); - } - break; - case SYN_COUNTER: - case SYN_INTEGER: - case SYN_INTERVAL: - printf(" Value: %u (0x%X)\n", *((Integer_T*)name), *((Integer_T*)name)); - break; - case SYN_BOOLEAN: - { - Boolean_T* b = (Boolean_T*)name; - - printf(" Value: %u (%s)\n", *b, (*b==1)?"true":(*b)?"unknown":"false"); - } - break; - case SYN_TIMESTAMP: - { - TimeStamp_T* stamp = (TimeStamp_T*)name; - printf(" Value: %u / %u.%u\n", - stamp->wholeSeconds, stamp->replicaNum, - stamp->eventID); - } - break; - case SYN_NET_ADDRESS: - { - Net_Address_T* na = (Net_Address_T*)name; - size_t z; - - printf(" Type: %u\n", na->addressType); - printf(" Length: %u\n", na->addressLength); - printf(" Data: "); - for (z = 0; z < na->addressLength; z++) - printf("%02X ", na->address[z]); - printf("\n"); - } - break; - case SYN_REPLICA_POINTER: - { - Replica_Pointer_T* rp = (Replica_Pointer_T*)name; - Net_Address_T* qp; - int cntv; - - printf(" Value:\n"); - printf(" Server Name: '%s'\n", rp->serverName); - printf(" Replica Type: %u\n", rp->replicaType); - printf(" Replica Number: %u\n", rp->replicaNumber); - printf(" Address Count: %u\n", rp->count); - for (cntv = rp->count, qp = rp->replicaAddressHint; cntv--; qp++) { - size_t z; - - printf(" Type: %u\n", qp->addressType); - printf(" Length: %u\n", qp->addressLength); - printf(" Data: "); - for (z = 0; z < qp->addressLength; z++) - printf("%02X ", qp->address[z]); - printf("\n"); - } - } - break; - case SYN_OBJECT_ACL: - { - Object_ACL_T* oacl = (Object_ACL_T*)name; - - printf(" Protected Attribute: '%s'\n", oacl->protectedAttrName); - printf(" Subject Name: '%s'\n", oacl->subjectName); - printf(" Privileges: %08X\n", oacl->privileges); - } - break; - case SYN_PATH: - { - Path_T* p = (Path_T*)name; - - printf(" Name Space Type: %u\n", p->nameSpaceType); - printf(" Volume Name: '%s'\n", p->volumeName); - printf(" Path: '%s'\n", p->path); - } - break; - case SYN_TIME: - { - printf(" Time: %s", ctime((Time_T*)name)); - } - break; - case SYN_TYPED_NAME: - { - Typed_Name_T* tn = (Typed_Name_T*)name; - - printf(" Interval: %u\n", tn->interval); - printf(" Level: %u\n", tn->level); - printf(" Name: '%s'\n", tn->objectName); - } - break; - case SYN_CI_LIST: - { - CI_List_T* cl = (CI_List_T*)name; - - for (; cl; cl = cl->next) { - printf(" Value: '%s'\n", cl->s); - } - } - break; - case SYN_OCTET_LIST: - { - Octet_List_T* ol = (Octet_List_T*)name; - - for (; ol; ol = ol->next) { - size_t i; - - printf(" Value: Length: %u\n", ol->length); - printf(" "); - for (i = 0; i < ol->length; i++) - printf("%02X ", ol->data[i]); - printf("\n"); - } - } - break; - case SYN_BACK_LINK: - { - Back_Link_T* bl = (Back_Link_T*)name; - - printf(" Remote ID: %08X\n", bl->remoteID); - printf(" Object Name: '%s'\n", bl->objectName); - } - break; - case SYN_FAX_NUMBER: - { - Fax_Number_T* fn = (Fax_Number_T*)name; - - printf(" Fax Number: '%s'\n", fn->telephoneNumber); - printf(" Parameter bits: %u\n", fn->parameters.numOfBits); - } - break; - case SYN_EMAIL_ADDRESS: - { - EMail_Address_T* ea = (EMail_Address_T*)name; - - printf(" Type: %u\n", ea->type); - printf(" Address: '%s'\n", ea->address); - } - break; - case SYN_PO_ADDRESS: - { - Postal_Address_T* pa = (Postal_Address_T*)name; - - printf(" Line 1: '%s'\n", (*pa)[0]); - printf(" Line 2: '%s'\n", (*pa)[1]); - printf(" Line 3: '%s'\n", (*pa)[2]); - printf(" Line 4: '%s'\n", (*pa)[3]); - printf(" Line 5: '%s'\n", (*pa)[4]); - printf(" Line 6: '%s'\n", (*pa)[5]); - } - break; - case SYN_HOLD: - { - Hold_T* h = (Hold_T*)name; - - printf(" Amount: %u\n", h->amount); - printf(" Object Name: '%s'\n", h->objectName); - } - break; - default: - printf(" Value: unprintable\n"); - break; - } - } - if (dserr) - break; - pp = buf->curPos; - } + printattr(ctx, req, buf); } + pp = buf->curPos; + } #ifndef N_PLAT_MSW4 for (; pp < buf->dataend; pp++) { - printf("%02X ", *pp); + nprintf("%02X ", *pp); } - printf("\n"); + nprintf("\n"); #endif } } while ((dserr == 0) && (ih != NO_MORE_ITERATIONS)); @@ -563,4 +733,3 @@ int main(int argc, char *argv[]) { finished: return 0; } - diff --git a/include/config.h.in b/include/config.h.in index 4b5fc13..1ea177e 100644 --- a/include/config.h.in +++ b/include/config.h.in @@ -1,433 +1,276 @@ /* include/config.h.in. Generated from configure.ac by autoheader. */ -/* - If you want native IP support, uncomment CONFIG_NATIVE_IP - 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. */ +/* If you want native IP support, uncomment CONFIG_NATIVE_IP 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. + */ #undef CONFIG_NATIVE_IP -/* - If you do not want IPX support, comment - CONFIG_NATIVE_IPX out... I cannot recommend doing it - */ +/* If you do not want IPX support, comment CONFIG_NATIVE_IPX out... I cannot + recommend doing it */ #undef CONFIG_NATIVE_IPX -/* - Define to one of `_getb67', `GETB67', `getb67' for - Cray-2 and Cray-YMP systems. This function is required - for `alloca.c' support on those systems. */ +/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP + systems. This function is required for `alloca.c' support on those systems. + */ #undef CRAY_STACKSEG_END -/* - Define to 1 if using `alloca.c'. */ +/* Define to 1 if using `alloca.c'. */ #undef C_ALLOCA -/* - Define to 1 if translation of program messages - to the user's native language is requested. */ +/* Define to 1 if translation of program messages to the user's native + language is requested. */ #undef ENABLE_NLS -/* - Define to 1 if you have `alloca', as - a function or macro. */ +/* Define to 1 if you have `alloca', as a function or macro. */ #undef HAVE_ALLOCA -/* - Define to 1 if you have and - it should be used (not on Ultrix). */ +/* Define to 1 if you have and it should be used (not on Ultrix). + */ #undef HAVE_ALLOCA_H -/* - Define to 1 if you have the - header file. */ +/* Define to 1 if you have the header file. */ #undef HAVE_ARGZ_H -/* - Define if the GNU dcgettext() function is already - present or preinstalled. */ +/* Define if the GNU dcgettext() function is already present or preinstalled. + */ #undef HAVE_DCGETTEXT -/* - Define to 1 if you have the `feof_unlocked' - function. */ +/* Define to 1 if you have the `feof_unlocked' function. */ #undef HAVE_FEOF_UNLOCKED -/* - Define to 1 if you have the `fgets_unlocked' - function. */ +/* Define to 1 if you have the `fgets_unlocked' function. */ #undef HAVE_FGETS_UNLOCKED -/* - Define to 1 if you have the `getcwd' - function. */ +/* Define to 1 if you have the `getcwd' function. */ #undef HAVE_GETCWD -/* - Define to 1 if you have the `getc_unlocked' - function. */ +/* Define to 1 if you have the `getc_unlocked' function. */ #undef HAVE_GETC_UNLOCKED -/* - Define to 1 if you have the `getegid' - function. */ +/* Define to 1 if you have the `getegid' function. */ #undef HAVE_GETEGID -/* - Define to 1 if you have the `geteuid' - function. */ +/* Define to 1 if you have the `geteuid' function. */ #undef HAVE_GETEUID -/* - Define to 1 if you have the `getgid' - function. */ +/* Define to 1 if you have the `getgid' function. */ #undef HAVE_GETGID -/* - Define to 1 if you have the `getpagesize' - function. */ +/* Define to 1 if you have the `getpagesize' function. */ #undef HAVE_GETPAGESIZE -/* - Define if the GNU gettext() function is already - present or preinstalled. */ +/* Define if the GNU gettext() function is already present or preinstalled. */ #undef HAVE_GETTEXT -/* - Define to 1 if you have the `getuid' - function. */ +/* Define to 1 if you have the `getuid' function. */ #undef HAVE_GETUID -/* - Define if you have the iconv() function. */ +/* Define if you have the iconv() function. */ #undef HAVE_ICONV -/* - Define to 1 if you have the - header file. */ +/* Define to 1 if you have the header file. */ #undef HAVE_ICONV_H -/* - Define if exists and doesn't clash with - . */ +/* Define if exists and doesn't clash with . */ #undef HAVE_INTTYPES_H -/* - Define if exists, doesn't clash with , - and declares uintmax_t. */ +/* Define if exists, doesn't clash with , and + declares uintmax_t. */ #undef HAVE_INTTYPES_H_WITH_UINTMAX -/* - Define if you have and nl_langinfo(CODESET). */ +/* Define if you have and nl_langinfo(CODESET). */ #undef HAVE_LANGINFO_CODESET -/* - Define if your file defines LC_MESSAGES. */ +/* Define if your file defines LC_MESSAGES. */ #undef HAVE_LC_MESSAGES -/* - Define to 1 if you have the - header file. */ +/* Define to 1 if you have the header file. */ #undef HAVE_LIMITS_H -/* - Define if you have IPX header linux/ipx.h */ +/* Define if you have IPX header linux/ipx.h */ #undef HAVE_LINUX_IPX_H -/* - Define to 1 if you have the - header file. */ +/* Define to 1 if you have the header file. */ #undef HAVE_LOCALE_H -/* - Define to 1 if you have the - header file. */ +/* Define to 1 if you have the header file. */ #undef HAVE_MALLOC_H -/* - Define to 1 if you have the - header file. */ +/* Define to 1 if you have the header file. */ #undef HAVE_MEMORY_H -/* - Define to 1 if you have the `mempcpy' - function. */ +/* Define to 1 if you have the `mempcpy' function. */ #undef HAVE_MEMPCPY -/* - Define to 1 if you have a working - `mmap' system call. */ +/* Define to 1 if you have a working `mmap' system call. */ #undef HAVE_MMAP -/* - Define to 1 if you have the `munmap' - function. */ +/* Define to 1 if you have the `munmap' function. */ #undef HAVE_MUNMAP -/* - Define if you have IPX header netipx/ipx.h */ +/* Define if you have IPX header netipx/ipx.h */ #undef HAVE_NETIPX_IPX_H -/* - Define to 1 if you have the - header file. */ +/* Define to 1 if you have the header file. */ #undef HAVE_NL_TYPES_H -/* - Define to 1 if you have the `putenv' - function. */ +/* Define to 1 if you have the `putenv' function. */ #undef HAVE_PUTENV -/* - Define to 1 if you have the `setenv' - function. */ +/* Define to 1 if you have the `setenv' function. */ #undef HAVE_SETENV -/* - Define to 1 if you have the `setlocale' - function. */ +/* Define to 1 if you have the `setlocale' function. */ #undef HAVE_SETLOCALE -/* - Define to 1 if you have the - header file. */ +/* Define to 1 if you have the header file. */ #undef HAVE_STDDEF_H -/* - Define to 1 if you have the - header file. */ +/* Define to 1 if you have the header file. */ #undef HAVE_STDINT_H -/* - Define if exists, doesn't clash with , - and declares uintmax_t. */ +/* Define if exists, doesn't clash with , and declares + uintmax_t. */ #undef HAVE_STDINT_H_WITH_UINTMAX -/* - Define to 1 if you have the - header file. */ +/* Define to 1 if you have the header file. */ #undef HAVE_STDLIB_H -/* - Define to 1 if you have the `stpcpy' - function. */ +/* Define to 1 if you have the `stpcpy' function. */ #undef HAVE_STPCPY -/* - Define to 1 if you have the `strcasecmp' - function. */ +/* Define to 1 if you have the `strcasecmp' function. */ #undef HAVE_STRCASECMP -/* - Define to 1 if you have the `strdup' - function. */ +/* Define to 1 if you have the `strdup' function. */ #undef HAVE_STRDUP -/* - Define to 1 if you have the - header file. */ +/* Define to 1 if you have the header file. */ #undef HAVE_STRINGS_H -/* - Define to 1 if you have the - header file. */ +/* Define to 1 if you have the header file. */ #undef HAVE_STRING_H -/* - Define to 1 if you have the `strtoul' - function. */ +/* Define to 1 if you have the `strtoul' function. */ #undef HAVE_STRTOUL -/* - Define to 1 if you have the - header file. */ +/* Define to 1 if you have the header file. */ #undef HAVE_SYS_PARAM_H -/* - Define to 1 if you have the - header file. */ +/* Define to 1 if you have the header file. */ #undef HAVE_SYS_STAT_H -/* - Define to 1 if you have the - header file. */ +/* Define to 1 if you have the header file. */ #undef HAVE_SYS_TYPES_H -/* - Define to 1 if you have that - is POSIX.1 compatible. */ +/* Define to 1 if you have that is POSIX.1 compatible. */ #undef HAVE_SYS_WAIT_H -/* - Define to 1 if you have the `tsearch' - function. */ +/* Define to 1 if you have the `tsearch' function. */ #undef HAVE_TSEARCH -/* - Define if you have the 'uintmax_t' type in - or . */ +/* Define if you have the 'uintmax_t' type in or . */ #undef HAVE_UINTMAX_T -/* - Define to 1 if you have the - header file. */ +/* Define to 1 if you have the header file. */ #undef HAVE_UNISTD_H -/* - Define if you have the unsigned long long - type. */ +/* Define if you have the 'unsigned long long' type. */ #undef HAVE_UNSIGNED_LONG_LONG -/* - Define to 1 if you have the - header file. */ +/* Define to 1 if you have the header file. */ #undef HAVE_WCHAR_H -/* - Define to 1 if you have the `wcscasecmp' - function. */ +/* Define to 1 if you have the `wcscasecmp' function. */ #undef HAVE_WCSCASECMP -/* - Define to 1 if you have the `wcscmp' - function. */ +/* Define to 1 if you have the `wcscmp' function. */ #undef HAVE_WCSCMP -/* - Define to 1 if you have the `wcscpy' - function. */ +/* Define to 1 if you have the `wcscpy' function. */ #undef HAVE_WCSCPY -/* - Define to 1 if you have the `wcsdup' - function. */ +/* Define to 1 if you have the `wcsdup' function. */ #undef HAVE_WCSDUP -/* - Define to 1 if you have the `wcslen' - function. */ +/* Define to 1 if you have the `wcslen' function. */ #undef HAVE_WCSLEN -/* - Define to 1 if you have the `wcsncasecmp' - function. */ +/* Define to 1 if you have the `wcsncasecmp' function. */ #undef HAVE_WCSNCASECMP -/* - Define to 1 if you have the `wcsncmp' - function. */ +/* Define to 1 if you have the `wcsncmp' function. */ #undef HAVE_WCSNCMP -/* - Define to 1 if you have the `wcsrev' - function. */ +/* Define to 1 if you have the `wcsrev' function. */ #undef HAVE_WCSREV -/* - Define to 1 if you have the `__argz_count' - function. */ +/* Define to 1 if you have the `__argz_count' function. */ #undef HAVE___ARGZ_COUNT -/* - Define to 1 if you have the `__argz_next' - function. */ +/* Define to 1 if you have the `__argz_next' function. */ #undef HAVE___ARGZ_NEXT -/* - Define to 1 if you have the `__argz_stringify' - function. */ +/* Define to 1 if you have the `__argz_stringify' function. */ #undef HAVE___ARGZ_STRINGIFY -/* - Define as const if the declaration of iconv() - needs const. */ +/* Define as const if the declaration of iconv() needs const. */ #undef ICONV_CONST -/* - Define if integer division by zero raises signal - SIGFPE. */ +/* Define if integer division by zero raises signal SIGFPE. */ #undef INTDIV0_RAISES_SIGFPE -/* - If defined, support for Linux2.0.x is compiled in - */ +/* If defined, support for Linux2.0.x is compiled in */ #undef MOUNT2 -/* - If defined, support for Linux2.1-3.x is compiled in - */ +/* If defined, support for Linux2.1-3.x is compiled in */ #undef MOUNT3 -/* - Define to 8 (big-endian) or 16 (32 bit - little-endian except i386) or 32 (i386) */ +/* Define to 8 (big-endian) or 16 (32 bit little-endian except i386) or 32 + (i386) */ #undef MULTUNITSIZE -/* - Enable support for NCP_DEBUG environment variable. */ +/* Enable support for NCP_DEBUG environment variable. */ #undef NCP_DEBUG -/* - If you want to trace ncp calls uncomment - this. */ +/* If you want to trace ncp calls uncomment this. */ #undef NCP_TRACE_ENABLE -/* - If you want to include NDS support, define - NDS_SUPPORT symbol Change only through 'configure', copies of - this value are in makefiles */ +/* If you want to include NDS support, define NDS_SUPPORT symbol Change only + through 'configure', copies of this value are in makefiles */ #undef NDS_SUPPORT -/* - neither net/if.h nor linux/if.h was found, so ipx_* - will not build... */ +/* neither net/if.h nor linux/if.h was found, so ipx_* will not build... */ #undef NO_NET_IF_SUPPORT -/* - neither net/route.h nor linux/route.h was found ... */ +/* neither net/route.h nor linux/route.h was found ... */ #undef NO_NET_ROUTE_SUPPORT -/* - Define to the address where bug reports for - this package should be sent. */ +/* Define to the address where bug reports for this package should be sent. */ #undef PACKAGE_BUGREPORT -/* - Define to the full name of this package. - */ +/* Define to the full name of this package. */ #undef PACKAGE_NAME -/* - Define to the full name and version of - this package. */ +/* Define to the full name and version of this package. */ #undef PACKAGE_STRING -/* - Define to the one symbol short name of - this package. */ +/* Define to the one symbol short name of this package. */ #undef PACKAGE_TARNAME -/* - Define to the version of this package. */ +/* Define to the version of this package. */ #undef PACKAGE_VERSION -/* - Define if exists and defines unusable PRI* - macros. */ +/* Define if exists and defines unusable PRI* macros. */ #undef PRI_MACROS_BROKEN -/* - If you want to include packet signature support - uncomment this. If you are using 2.0.x Linux - kernel, make sure that you also applied kernel - patches. Change only through 'configure', copies of this - value are in makefiles */ +/* If you want to include packet signature support uncomment this. If you are + using 2.0.x Linux kernel, make sure that you also applied kernel patches. + Change only through 'configure', copies of this value are in makefiles */ #undef SIGNATURES /* If using the C implementation of alloca, define if you know the @@ -438,42 +281,29 @@ STACK_DIRECTION = 0 => direction of growth unknown */ #undef STACK_DIRECTION -/* - Define to 1 if you have the ANSI - C header files. */ +/* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS -/* - Define to 1 if you can safely include - both and . */ +/* Define to 1 if you can safely include both and . */ #undef TIME_WITH_SYS_TIME -/* - Define to 1 if your declares `struct - tm'. */ +/* Define to 1 if your declares `struct tm'. */ #undef TM_IN_SYS_TIME -/* - Define to 8 (big-endian) or 16 (32 bit - little-endian except i386) or 32 (i386) */ +/* Define to 8 (big-endian) or 16 (32 bit little-endian except i386) or 32 + (i386) */ #undef UNITSIZE -/* - Define when compiling for Linux kernel */ +/* Define when compiling for Linux kernel */ #undef USE_KERNEL -/* - Define if you need this for correct threading_MIT_POSIX_THREADS - ... */ +/* Define if you need this for correct threading_MIT_POSIX_THREADS ... */ #undef _MIT_POSIX_THREADS -/* - Define to empty if `const' does not conform - to ANSI C. */ +/* Define to empty if `const' does not conform to ANSI C. */ #undef const -/* - Define to `int' if doesn't define. */ +/* Define to `int' if doesn't define. */ #undef gid_t /* Define to `__inline__' or `__inline' if that's what the C compiler @@ -482,36 +312,24 @@ #undef inline #endif -/* - Define to `int' if does not define. - */ +/* Define to `int' if does not define. */ #undef mode_t -/* - Define to `long' if does not define. - */ +/* Define to `long' if does not define. */ #undef off_t -/* - Define to `int' if does not define. - */ +/* Define to `int' if does not define. */ #undef pid_t -/* - Define to `unsigned' if does not define. - */ +/* Define to `unsigned' if does not define. */ #undef size_t -/* - Define to `int' if doesn't define. */ +/* Define to `int' if doesn't define. */ #undef uid_t -/* - Define to unsigned long or unsigned long long - if and don't define. */ +/* Define to unsigned long or unsigned long long if and + don't define. */ #undef uintmax_t -/* - Define to 'unsigned int' if wchar_t is not - defined. */ +/* Define to 'unsigned int' if wchar_t is not defined. */ #undef wchar_t diff --git a/include/ncp/ncplib.h b/include/ncp/ncplib.h index 72a946b..36de264 100644 --- a/include/ncp/ncplib.h +++ b/include/ncp/ncplib.h @@ -105,38 +105,6 @@ typedef u_int64_t ncp_off64_t; extern "C" { #endif -static inline word -WVAL_HL(const void * buf, int pos) -{ - return PVAL(buf, pos) << 8 | PVAL(buf, pos + 1); -} - -static inline dword -DVAL_HL(const void * buf, int pos) -{ - return WVAL_HL(buf, pos) << 16 | WVAL_HL(buf, pos + 2); -} - -static inline void -WSET_HL(void * buf, int pos, word val) -{ - BSET(buf, pos, val >> 8); - BSET(buf, pos + 1, val & 0xff); -} - -static inline void -DSET_HL(void * buf, int pos, dword val) -{ - WSET_HL(buf, pos, val >> 16); - WSET_HL(buf, pos + 2, val & 0xffff); -} - -static inline void -QSET_HL(void * buf, int pos, u_int64_t val) { - DSET_HL(buf, pos, val >> 32); - DSET_HL(buf, pos + 4, val); -} - /* we know that the 386 can handle misalignment and has the "right" byteorder */ #if defined(__i386__) @@ -177,6 +145,36 @@ QSET_LH(void * buf, int pos, u_int64_t val) *((u_int64_t *) (((u_int8_t*)buf) + pos)) = val; } +static inline word +WVAL_HL(const void * buf, int pos) +{ + return ntohs(WVAL_LH(buf, pos)); +} + +static inline dword +DVAL_HL(const void * buf, int pos) +{ + return ntohl(DVAL_LH(buf, pos)); +} + +static inline void +WSET_HL(void * buf, int pos, word val) +{ + WSET_LH(buf, pos, htons(val)); +} + +static inline void +DSET_HL(void * buf, int pos, dword val) +{ + DSET_LH(buf, pos, htonl(val)); +} + +static inline __attribute__((always_inline)) void +QSET_HL(void * buf, int pos, u_int64_t val) { + DSET_HL(buf, pos, val >> 32); + DSET_HL(buf, pos + 4, val); +} + #else static inline word @@ -218,6 +216,38 @@ QSET_LH(void * buf, int pos, u_int64_t val) DSET_LH(buf, pos + 4, val >> 32); } +static inline word +WVAL_HL(const void * buf, int pos) +{ + return PVAL(buf, pos) << 8 | PVAL(buf, pos + 1); +} + +static inline dword +DVAL_HL(const void * buf, int pos) +{ + return WVAL_HL(buf, pos) << 16 | WVAL_HL(buf, pos + 2); +} + +static inline void +WSET_HL(void * buf, int pos, word val) +{ + BSET(buf, pos, val >> 8); + BSET(buf, pos + 1, val & 0xff); +} + +static inline void +DSET_HL(void * buf, int pos, dword val) +{ + WSET_HL(buf, pos, val >> 16); + WSET_HL(buf, pos + 2, val & 0xffff); +} + +static inline void +QSET_HL(void * buf, int pos, u_int64_t val) { + DSET_HL(buf, pos, val >> 32); + DSET_HL(buf, pos + 4, val); +} + #endif static inline u_int64_t diff --git a/include/ncp/nwcalls.h b/include/ncp/nwcalls.h index eb412f4..aaffe2c 100644 --- a/include/ncp/nwcalls.h +++ b/include/ncp/nwcalls.h @@ -490,6 +490,12 @@ NWCCODE NWScanNCPExtensions(NWCONN_HANDLE __conn, nuint32* __iter, char* __extname, nuint8* __majorVersion, nuint8* __minorVersion, nuint8* __revision, nuint8 __queryData[32]); +NWCCODE NWFragNCPExtensionRequest(NWCONN_HANDLE conn, nuint32 NCPExtensionID, + nuint reqFragCount, NW_FRAGMENT* reqFragList, + nuint replyFragCount, NW_FRAGMENT* replyFragList); +NWCCODE NWNCPExtensionRequest(NWCONN_HANDLE conn, nuint32 NCPExtensionID, + const void* requestData, size_t requestDataLen, + void* replyData, size_t* replyDataLen); NWCCODE NWEnableBroadcasts(NWCONN_HANDLE __conn); NWCCODE NWDisableBroadcasts(NWCONN_HANDLE __conn); diff --git a/include/ncp/nwnet.h.in b/include/ncp/nwnet.h.in index 97b53ba..9d70b61 100644 --- a/include/ncp/nwnet.h.in +++ b/include/ncp/nwnet.h.in @@ -631,6 +631,8 @@ NWDSCCODE __NWGetFileServerUTCTime(NWCONN_HANDLE conn, nuint32* OUTPUT2, nuint32* OUTPUT3, nuint32* OUTPUT4, nuint32* OUTPUT5); /* D */ NWDSCCODE NWGetFileServerUTCTime(NWCONN_HANDLE conn, nuint32* timev); /* D */ +NWDSCCODE __NWTimeGetVersion(NWCONN_HANDLE conn, int req, + void* buffer, size_t* len, size_t maxlen); NWDSCCODE NWDSGetObjectHostServerAddress(NWDSContextHandle ctx, const NWDSChar* objectName, NWDSChar* serverDN, Buf_T* serverAddresses); /* D */ diff --git a/ipx-1.0/ipx_interface.c b/ipx-1.0/ipx_interface.c index 5c0ac6d..7f54718 100644 --- a/ipx-1.0/ipx_interface.c +++ b/ipx-1.0/ipx_interface.c @@ -216,7 +216,7 @@ ipx_add_interface(int argc, char **argv) } static int -ipx_delall_interface(int argc, char **argv) +ipx_delall_interface(int argc __attribute__((unused)), char **argv __attribute__((unused))) { struct sockaddr_ipx *sipx = (struct sockaddr_ipx *) &id.ifr_addr; int s; diff --git a/ipx-1.0/ipx_internal_net.c b/ipx-1.0/ipx_internal_net.c index f3c551a..d6979f4 100644 --- a/ipx-1.0/ipx_internal_net.c +++ b/ipx-1.0/ipx_internal_net.c @@ -120,7 +120,7 @@ ipx_add_internal_net(int argc, char **argv) } static int -ipx_del_internal_net(int argc, char **argv) +ipx_del_internal_net(int argc, char **argv __attribute__((unused))) { struct sockaddr_ipx *sipx = (struct sockaddr_ipx *) &id.ifr_addr; int s; diff --git a/lib/ds/setkeys.c b/lib/ds/setkeys.c index 4799ce6..c4587f5 100644 --- a/lib/ds/setkeys.c +++ b/lib/ds/setkeys.c @@ -219,6 +219,34 @@ static NWDSCCODE __NWDSGenerateObjectKeyPairStep3( return 0; } +static void __NWDSHashPasswordUpper(const nuint8* objectPassword, + NWObjectID pseudoID, + size_t pwdLen, + nuint8 pwdHash[16] +) { + nuint8 newPwd[pwdLen + 1]; + size_t i; + nuint8 tmpID[4]; + + for (i = 0; i < pwdLen; i++) + newPwd[i] = toupper(*objectPassword++); + newPwd[i] = 0; + + DSET_HL(tmpID, 0, pseudoID); + shuffle(tmpID, newPwd, pwdLen, pwdHash); +} + +static void __NWDSHashPassword(const nuint8* objectPassword, + NWObjectID pseudoID, + size_t pwdLen, + nuint8 pwdHash[16] +) { + nuint8 tmpID[4]; + + DSET_HL(tmpID, 0, pseudoID); + shuffle(tmpID, objectPassword, pwdLen, pwdHash); +} + static NWDSCCODE __NWDSGenerateObjectKeyPair( NWDSContextHandle ctx, const NWDSChar* objectName, @@ -241,18 +269,7 @@ static NWDSCCODE __NWDSGenerateObjectKeyPair( /* compute key... */ pwdLen = strlen(objectPassword); /* BEWARE! other NWDS*Password functions do NOT uppercase password */ - { - nuint8 newPwd[pwdLen + 1]; - size_t i; - nuint8 tmpID[4]; - - for (i = 0; i < pwdLen; i++) - newPwd[i] = toupper(*((const nuint8*)objectPassword)++); - newPwd[i] = 0; - - DSET_HL(tmpID, 0, pseudoID); - shuffle(tmpID, newPwd, pwdLen, pwdHash); - } + __NWDSHashPasswordUpper(objectPassword, pseudoID, pwdLen, pwdHash); err = __NWDSGenerateObjectKeyPairStep2(conn, objectID, rndseed, pseudoID, pwdLen, pwdHash, serverPublicKey); @@ -339,7 +356,7 @@ static NWDSCCODE __NWDSVerifyObjectPasswordStep2( return err; } -NWDSCCODE NWDSVerifyObjectPassword(NWDSContextHandle ctx, nflag32 flags, +NWDSCCODE NWDSVerifyObjectPassword(NWDSContextHandle ctx, UNUSED(nflag32 flags), const NWDSChar* objectName, const char* objectPassword ) { NWCONN_HANDLE conn; @@ -358,12 +375,7 @@ NWDSCCODE NWDSVerifyObjectPassword(NWDSContextHandle ctx, nflag32 flags, return err; /* compute key... */ pwdLen = strlen(objectPassword); - { - nuint8 tmpID[4]; - - DSET_HL(tmpID, 0, pseudoID); - shuffle(tmpID, objectPassword, pwdLen, pwdHash); - } + __NWDSHashPassword(objectPassword, pseudoID, pwdLen, pwdHash); err = __NWDSVerifyObjectPasswordStep2(conn, objectID, rndseed, pwdHash, serverPublicKey); __NWDSGenerateObjectKeyPairStep3(conn, serverPublicKey); @@ -524,19 +536,7 @@ NWDSCCODE nds_login( /* compute key... */ pwdLen = strlen(objectPassword); /* BEWARE! other NWDS*Password functions do NOT uppercase password */ - { - nuint8 newPwd[pwdLen + 1]; - size_t i; - nuint8 tmpID[4]; - - for (i = 0; i < pwdLen; i++) - newPwd[i] = toupper(*((const nuint8*)objectPassword)++); - newPwd[i] = 0; - - DSET_HL(tmpID, 0, pseudoID); - shuffle(tmpID, newPwd, pwdLen, pwdHash); - } - + __NWDSHashPasswordUpper(objectPassword, pseudoID, pwdLen, pwdHash); grace_err = __NWDSGetPrivateKey(conn, serverPublicKey, rndseed, objectID, pwdHash, logindata, &privKey, &privKeyLen); __NWDSGenerateObjectKeyPairStep3(conn, serverPublicKey); diff --git a/lib/filemgmt.c b/lib/filemgmt.c index cd361a6..de009e9 100644 --- a/lib/filemgmt.c +++ b/lib/filemgmt.c @@ -3396,14 +3396,28 @@ NWCCODE NWGetNSLoadedList(struct ncp_conn *conn, static NWCCODE ncp_get_mount_volume_list_compat(struct ncp_conn *conn, - unsigned int ns, - unsigned int flags, - unsigned int *volnum, - unsigned int *itemcnt, - void* buffer, size_t* blen) { + unsigned int ns, + unsigned int flags, + unsigned int *volnum, + unsigned int *itemcnt, + void* b, size_t* blen) { unsigned int vol; - - while ((vol = (*volnum)++) < 256) { + unsigned char* buffer = b; + unsigned int items = 0; + size_t needSize; + unsigned char* bend = buffer + *blen; + + if (flags & 1) { + needSize = 4 + 1 + 17; + } else { + needSize = 4; + } + + if (buffer + needSize > bend) { + return NWE_BUFFER_OVERFLOW; + } + + for (vol = *volnum; buffer + needSize <= bend && vol < 256; vol++) { unsigned char nspc[256]; size_t real; NWCCODE err; @@ -3412,23 +3426,27 @@ ncp_get_mount_volume_list_compat(struct ncp_conn *conn, if (!err) { if (memchr(nspc, ns, real)) { DSET_LH(buffer, 0, vol); - ((unsigned char*)buffer) += 4; - if (!(flags & 1)) { - *blen = 4; - return 0; - } - err = ncp_get_volume_name(conn, vol, ((unsigned char*)buffer)+1, 17); - if (!err) { - real = strlen(((char*)buffer)+1); - *(unsigned char*)buffer = real; - *blen = 4 + 1 + real; - *itemcnt = 1; - return 0; + if (flags & 1) { + err = ncp_get_volume_name(conn, vol, buffer+5, 17); + if (!err) { + real = strlen(buffer+5); + buffer[4] = real; + buffer += 4 + 1 + real; + items++; + } + } else { + buffer += 4; + items++; } } } } - return NWE_SERVER_FAILURE; + if (items == 0) { + return NWE_SERVER_FAILURE; + } + *itemcnt = items; + *blen = buffer - (unsigned char*)b; + return 0; } static NWCCODE diff --git a/lib/mpilib.c b/lib/mpilib.c index 0c4182f..4b1c15e 100644 --- a/lib/mpilib.c +++ b/lib/mpilib.c @@ -1723,6 +1723,7 @@ unsigned int countbits(const unit* r) } /* countbits */ +const 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 */ diff --git a/lib/ncpext.c b/lib/ncpext.c index 13e32db..bef60a0 100644 --- a/lib/ncpext.c +++ b/lib/ncpext.c @@ -29,6 +29,7 @@ #include "ncpcode.h" #include +#include #define ncp_array_size(x) (sizeof(x)/sizeof((x)[0])) @@ -112,3 +113,307 @@ NWGetNumberNCPExtensions( *exts = num; return 0; } + +static NWCCODE +NWFragLen(size_t *total, + nuint cnt, + const NW_FRAGMENT* frag) +{ + size_t len; + + if (cnt && !frag) { + return ERR_NULL_POINTER; + } + len = 0; + while (cnt--) { + len += frag->fragSize; + frag++; + } + *total = len; + return 0; +} + +typedef struct { + nuint8* current; + size_t space; + int currentActive; + nuint fragCount; + NW_FRAGMENT* fragList; +} NWFragger; + +static void +NWPushFragStart(NWFragger* fragger, + nuint fragCount, + NW_FRAGMENT* fragList) +{ + fragger->currentActive = 0; + fragger->fragCount = fragCount; + fragger->fragList = fragList; +} + +static NWCCODE +NWPushFragPush(NWFragger* fragger, + const nuint8* data, + size_t len) +{ + while (len) { + if (!fragger->currentActive) { + if (fragger->fragCount == 0) { + return NWE_BUFFER_OVERFLOW; + } + fragger->current = fragger->fragList->fragAddr.rw; + fragger->space = fragger->fragList->fragSize; + fragger->currentActive = 1; + } + if (len >= fragger->space) { + memcpy(fragger->current, data, fragger->space); + len -= fragger->space; + data += fragger->space; + fragger->fragList++; + fragger->fragCount--; + fragger->currentActive = 0; + } else { + memcpy(fragger->current, data, len); + fragger->current += len; + fragger->space -= len; + return 0; + } + } + return 0; +} + +static void +NWPushFragFinish(NWFragger* fragger) +{ + if (fragger->currentActive) { + fragger->fragList->fragSize -= fragger->space; + fragger->fragList++; + fragger->fragCount--; + } + while (fragger->fragCount--) { + fragger->fragList->fragSize = 0; + fragger->fragList++; + } +} + +NWCCODE +NWFragNCPExtensionRequest( + NWCONN_HANDLE conn, + nuint32 NCPExtensionID, + nuint reqFragCount, + NW_FRAGMENT* reqFragList, + nuint replyFragCount, + NW_FRAGMENT* replyFragList) +{ + NWCCODE err; + size_t reqLen; + size_t rpLen; + u_int16_t ver; + + err = NWFragLen(&reqLen, reqFragCount, reqFragList); + if (err) { + return err; + } + err = NWFragLen(&rpLen, replyFragCount, replyFragList); + if (err) { + return err; + } + err = NWGetFileServerVersion(conn, &ver); + if (err) { + return err; + } + if (reqLen < 523 && rpLen < 530 && (rpLen < 100 || ver > 0x030B)) { + NW_FRAGMENT* rq; + NW_FRAGMENT rp[2]; + u_int8_t rqhdr[8]; + u_int8_t rphdr[2]; + u_int8_t rpbuf[530]; + NWFragger fragger; + + rq = malloc(sizeof(NW_FRAGMENT) * (reqFragCount + 1)); + if (!rq) { + return ERR_NOT_ENOUGH_MEMORY; + } + memcpy(rq + 1, reqFragList, sizeof(NW_FRAGMENT) * reqFragCount); + rq->fragAddress = rqhdr; + rq->fragSize = 8; + + WSET_HL(rqhdr, 0, reqLen + 6); + DSET_LH(rqhdr, 2, NCPExtensionID); + WSET_LH(rqhdr, 6, rpLen); + + rp[0].fragAddress = rphdr; + rp[0].fragSize = 2; + rp[1].fragAddress = rpbuf; + rp[1].fragSize = 530; + + err = NWRequest(conn, 37, reqFragCount + 1, rq, 2, rp); + free(rq); + if (err) { + return err; + } + + NWPushFragStart(&fragger, replyFragCount, replyFragList); + NWPushFragPush(&fragger, rpbuf, rp[1].fragSize); + NWPushFragFinish(&fragger); + return 0; + } else { + NW_FRAGMENT rq[2]; + u_int8_t rqhdr[20]; + u_int8_t rqbuf[519]; + u_int8_t rphdr[10]; + u_int8_t rpbuf[524]; + size_t flen; + const u_int8_t* dptr; + size_t dlen; + NWFragger fragger; + + WSET_HL(rqhdr, 0, 0xFFFF); + DSET_LH(rqhdr, 2, NCPExtensionID); + DSET_LH(rqhdr, 6, 0); +// WSET_LH(rqhdr, 10, 0); //472 + DSET_LH(rqhdr, 12, reqLen); + DSET_LH(rqhdr, 16, rpLen); + + rq[0].fragAddress = rqhdr; + rq[0].fragSize = 20; + + flen = 511; + + if (reqLen) { + dptr = reqFragList->fragAddr.ro; + dlen = reqFragList->fragSize; + reqFragList++; + } else { + dptr = NULL; + dlen = 0; + } + do { + NW_FRAGMENT rp[3]; + + rq[1].fragSize = 0; + if (reqLen) { + if (dlen >= flen) { + rq[1].fragAddr.ro = dptr; + rq[1].fragSize = flen; + dptr += flen; + dlen -= flen; + reqLen -= flen; + if (dlen == 0 && reqLen) { + dptr = reqFragList->fragAddress; + dlen = reqFragList->fragSize; + reqFragList++; + } + } else if (dlen == reqLen) { + rq[1].fragAddr.ro = dptr; + rq[1].fragSize = dlen; + reqLen = 0; + } else { + u_int8_t* pptr; + + rq[1].fragAddress = pptr = rqbuf; + rq[1].fragSize = 0; + while (flen && reqLen) { + if (dlen > flen) { + memcpy(pptr, dptr, flen); + dptr += flen; + dlen -= flen; + rq[1].fragSize += flen; + reqLen -= flen; + break; + } else { + memcpy(pptr, dptr, dlen); + pptr += dlen; + flen -= dlen; + rq[1].fragSize += dlen; + reqLen -= dlen; + dptr = reqFragList->fragAddress; + dlen = reqFragList->fragSize; + reqFragList++; + } + } + } + } + WSET_LH(rqhdr, 10, rq[1].fragSize); + + rp[0].fragAddress = rphdr; + rp[0].fragSize = 10; + rp[1].fragAddress = rpbuf; + rp[1].fragSize = sizeof(rpbuf); + + err = NWRequest(conn, 37, 2, rq, 3, rp); + if (err) { + return err; + } + DSET_LH(rqhdr, 6, DVAL_LH(rphdr, 0)); + rq[0].fragSize = 12; + flen = 519; + } while (reqLen); + + { + size_t tlen = DVAL_LH(rphdr, 6); + if (rpLen > tlen) { + rpLen = tlen; + } + } + + NWPushFragStart(&fragger, replyFragCount, replyFragList); + while (rpLen) { + size_t fragLen; + + fragLen = WVAL_LH(rphdr, 4); + + if (fragLen <= rpLen) { + rpLen -= fragLen; + } else { + fragLen = rpLen; + rpLen = 0; + } + err = NWPushFragPush(&fragger, rpbuf, fragLen); + if (err) { + return err; + } + if (rpLen) { + NW_FRAGMENT rp[2]; + + rp[0].fragAddress = rphdr; + rp[0].fragSize = 6; + rp[1].fragAddress = rpbuf; + rp[1].fragSize = sizeof(rpbuf); + + err = NWRequest(conn, 37, 2, rq, 3, rp); + if (err) { + return err; + } + DSET_LH(rqhdr, 6, DVAL_LH(rphdr, 0)); + } + } + NWPushFragFinish(&fragger); + } + return 0; +} + +NWCCODE +NWNCPExtensionRequest( + NWCONN_HANDLE conn, + nuint32 NCPExtensionID, + const void* requestData, + size_t requestDataLen, + void* replyData, + size_t* replyDataLen) +{ + NW_FRAGMENT rq; + NW_FRAGMENT rp; + NWCCODE err; + + rq.fragAddr.ro = requestData; + rq.fragSize = requestDataLen; + rp.fragAddr.rw = replyData; + rp.fragSize = *replyDataLen; + + err = NWFragNCPExtensionRequest(conn, NCPExtensionID, 1, &rq, 1, &rp); + if (!err) { + *replyDataLen = rp.fragSize; + } + return err; +} diff --git a/lib/ncplib.c b/lib/ncplib.c index 35c5f42..7eb89a1 100644 --- a/lib/ncplib.c +++ b/lib/ncplib.c @@ -121,6 +121,7 @@ /* #define CONFIG_NATIVE_UNIX */ #undef CONFIG_NATIVE_UNIX +#define NCP_OBSOLETE #if 0 #define ncp_dprintf(X...) printf(X) @@ -431,6 +432,7 @@ x_recvfrom(int sock, void *buf, int len, unsigned int flags, { int result; +restart: if (timeout >= 0) { struct pollfd pfd; @@ -438,6 +440,10 @@ x_recvfrom(int sock, void *buf, int len, unsigned int flags, pfd.events = POLLIN | POLLHUP; if ((result = poll(&pfd, 1, timeout)) == -1) { + if (errno == EINTR) { + timeout /= 2; + goto restart; + } return errno; } if (!(pfd.revents & (POLLIN | POLLHUP))) { @@ -455,7 +461,7 @@ x_recvfrom(int sock, void *buf, int len, unsigned int flags, #ifdef CONFIG_NATIVE_IPX static int -exec_nwsfind(char* request[]) { +exec_nwsfind(const char* request[]) { int err; signal(SIGCHLD, SIG_DFL); @@ -470,7 +476,7 @@ exec_nwsfind(char* request[]) { dup2(0, 1); dup2(0, 2); request[0] = NWSFIND; - execv(request[0], request); + execv(request[0], (char**)request); /* OK, something bad happen... Drop it to /dev/null */ exit(127); } else { @@ -591,7 +597,7 @@ static int ipx_make_reachable_call(const struct sockaddr_ipx* target) { char buf[40]; - char *buf2[4]; + const char *buf2[4]; buf2[1] = "-a"; buf2[2] = buf; @@ -1218,7 +1224,7 @@ ncp_renegotiate_connparam(struct ncp_conn *conn, int buffsize, int newoptions) } static void -move_conn_to_kernel(struct ncp_conn *conn) { +move_conn_to_kernel(UNUSED(struct ncp_conn *conn)) { #if 0 int f; int e; @@ -1242,8 +1248,6 @@ move_conn_to_kernel(struct ncp_conn *conn) { conn->ncp_sock = -1; conn->is_connected = CONN_KERNELBASED; conn->mount_fid = f; -#else - (void*)conn; #endif } @@ -1359,7 +1363,7 @@ ncp_connect_ipx_addr(struct ncp_conn *conn, const struct sockaddr_ipx *target, #ifdef CONFIG_NATIVE_IP static long ncp_connect_in_addr(struct ncp_conn *conn, const struct sockaddr_in *target, - int wdog_needed) + UNUSED(int wdog_needed)) { static const unsigned char zero = 0; struct sockaddr_in addr; @@ -1424,7 +1428,7 @@ ncp_connect_in_addr(struct ncp_conn *conn, const struct sockaddr_in *target, static long ncp_connect_tcp_addr(struct ncp_conn *conn, const struct sockaddr_in *target, - int wdog_needed) + UNUSED(int wdog_needed)) { static const unsigned char connreq[19] = { 1, 16, 0, 0 }; struct sockaddr_in addr; @@ -1633,7 +1637,7 @@ ncp_connect_addr(struct ncp_conn *conn, const struct sockaddr *target, } static long -ncp_connect_any(NWCONN_HANDLE *conn, int wdog_needed) +ncp_connect_any(NWCONN_HANDLE *conn, UNUSED(int wdog_needed)) { return NWCCOpenConnByName(NULL, NULL, NWCC_NAME_FORMAT_BIND, 0, NWCC_RESERVED, conn); } @@ -2459,7 +2463,7 @@ ncp_initialize_2(int *argc, char **argv, int login_necessary, return NULL; } if (password) { - char* opw = password; + char* opw = (char*)password; password = strdup(password); memset(opw, 0, strlen(opw)); } @@ -3710,7 +3714,7 @@ ncp_login_object(struct ncp_conn *conn, } static NWCCODE -ncp_sign_stop(NWCONN_HANDLE conn) +ncp_sign_stop(UNUSED(NWCONN_HANDLE conn)) { #ifdef SIGNATURES return 0; @@ -4148,7 +4152,7 @@ ncp_set_private_key_perm(struct ncp_conn* conn, const void* pk, size_t pk_len) { return NWE_REQUESTER_FAILURE; if (pk_len && !pk) return ERR_NULL_POINTER; - (const void*)npi.data = pk; + npi.data = (void*)pk; npi.len = pk_len; if (ioctl(fd, NCP_IOC_SETPRIVATEDATA, &npi)) return errno; diff --git a/lib/ndslib.c b/lib/ndslib.c index a9b5661..aba6b28 100644 --- a/lib/ndslib.c +++ b/lib/ndslib.c @@ -51,6 +51,8 @@ /*#define DEBUG_PRINT*/ /*#define FIND_ISR */ /* if defined: show reasons for -330 invalid response */ +#define NCP_OBSOLETE + #include "config.h" #include @@ -90,10 +92,6 @@ typedef unsigned char boolean; #define ISRPrint(X...) do {} while (0) #endif -static void strcpy_cw(wchar_t *w, const char* s) { - while ((*w++ = *(const nuint8*)s++) != 0); -} - NWDSCCODE NWIsDSServer(NWCONN_HANDLE conn, char* treename) { char buf[128]; size_t size; @@ -255,7 +253,7 @@ static char keyprefix[] = {1, 0, 0, 0, 3, 0, 1, 0}; static int initkey(const char *key, char **keyptr, size_t *keylen) { /* 1=ok, 0=err */ if (!memcmp(key, keyprefix, 8)) { if (keylen) *keylen = WVAL_LH(key, 8); - if (keyptr) (const char *)(*keyptr) = key + 10; + if (keyptr) *keyptr = (char*)key + 10; return 1; } else return 0; @@ -277,7 +275,7 @@ static int findchunk(const char *keyptr, int keylen, const char *chunk, if ((p[0] != chunk[0]) || (p[1] != chunk[1])) p += 4 + (unsigned char)p[2] + (unsigned char)p[3]; else { - if (chunkptr) (const char *)(*chunkptr) = p + 4; + if (chunkptr) *chunkptr = (char*)p + 4; return (unsigned char)p[2] + (unsigned char)p[3]; } } @@ -1210,8 +1208,8 @@ static NWDSCCODE gen_auth_data( mp_add(up, n_mod); } mp_modexp(up2, up, n_exp, n_mod); - ((char *)up) += nblocksize; - ((char *)up2) += nblocksize_nw; + up = (unitptr)((char*)up + nblocksize); + up2 = (unitptr)((char*)up2 + nblocksize_nw); } nwhash2block(hashbuf, p+12, nblocksize_nw * 3); nwhash2end(hashbuf); @@ -1222,8 +1220,8 @@ static NWDSCCODE gen_auth_data( mp_modexp(up2, n_key, n_temp, n_mod); stage_modulus(n_mod); mp_modmult(up2, up2, up); - ((char *)up) += nblocksize; - ((char *)up2) += nblocksize_nw; + up = (unitptr)((char*)up + nblocksize); + up2 = (unitptr)((char*)up2 + nblocksize_nw); } if (n_temp) { mp_init0(n_temp); diff --git a/lib/nwcalls.c b/lib/nwcalls.c index 9f563b5..1055b4d 100644 --- a/lib/nwcalls.c +++ b/lib/nwcalls.c @@ -219,8 +219,9 @@ NWCCODE NWRequestSimple(NWCONN_HANDLE conn, nuint function, #ifndef MSG_DONTWAIT #define MSG_DONTWAIT 0 #endif -static int timedRecv(int fd, void* buff, size_t len, int timeout) { +static int timedRecv(int fd, void* b, size_t len, int timeout) { struct timeval tv; + unsigned char* buff = b; tv.tv_sec = timeout / 1000000; tv.tv_usec = timeout % 1000000; @@ -245,7 +246,7 @@ static int timedRecv(int fd, void* buff, size_t len, int timeout) { if (rd2 > len) break; - (unsigned char*)buff += rd2; + buff += rd2; len -= rd2; if (!len) return 0; @@ -293,7 +294,7 @@ static int timedRecvMsg(int fd, struct iovec* v, size_t vnum, int timeout) { return 0; } } - (char*)v->iov_base += rd2; + v->iov_base = (unsigned char*)v->iov_base + rd2; v->iov_len -= rd2; } } while (1); diff --git a/lib/nwclient.c b/lib/nwclient.c index 71b979a..8aa285c 100644 --- a/lib/nwclient.c +++ b/lib/nwclient.c @@ -96,7 +96,8 @@ #if 1 /*read hard degugging*/ - void printConn (NWCONN_HANDLE conn, int stage) { +void printConn (NWCONN_HANDLE conn, int stage); +void printConn (NWCONN_HANDLE conn, int stage) { printf("%s\n",conn->mount_point); printf ("------ info from kernel--------------------------------\n"); printf ("infoV2.version %d\n",conn->i.version); @@ -135,13 +136,11 @@ printf ("serverInfo.version.revision %x\n",conn->serverInfo.version.revision); printf ("NET_ADDRESS_TYPE nt %x\n",conn->nt); - - - } +} #endif static int NWCIsPermanentConnection (NWCONN_HANDLE conn) { - return (ncp_get_conn_type(conn) == NCP_CONN_PERMANENT); + return (ncp_get_conn_type(conn) == NCP_CONN_PERMANENT); } NWCCODE NWCXGetPermConnInfo(NWCONN_HANDLE conn, nuint info, size_t len, void* buffer) { @@ -359,76 +358,62 @@ static void strcpy_cw(wchar_t *w, const char* s) { while ((*w++ = *(const nuint8*)s++) != 0); } -NWDSCCODE NWDSCreateContextHandleMnt(NWDSContextHandle* ctx, const NWDSChar * treeName){ - +NWDSCCODE NWDSSetContextHandleTree(NWDSContextHandle ctx, const NWDSChar * treeName) +{ #define MAXCONNS 64 - NWDSCCODE err; - NWCONN_HANDLE conns[MAXCONNS]; + NWDSCCODE err; + NWCONN_HANDLE conns[MAXCONNS]; + int curEntries; + int i; + wchar_t treeNameW[MAX_DN_CHARS+1]; + char treeNameUTF[MAX_DN_CHARS*4 + 1]; - int curEntries=0; - NWDS_HANDLE dxh; - int i; - union __NWDSAuthInfo * ndai; - size_t authinfo_len; - wchar_t wc_treeName[MAX_DN_CHARS+1]; - - if (!treeName) - return ERR_NULL_POINTER; - - strcpy_cw (wc_treeName,treeName); - - err=NWDSCreateContextHandle (ctx); - if (err) - return err; - - err= NWCXGetPermConnListByTreeName (conns,MAXCONNS,&curEntries,getuid(),treeName); - if (err) { - NWDSFreeContext(*ctx); - return (err); - } -/* printf ("got %d connexion(s) to %s \n",curEntries,treeName);*/ - dxh=(*ctx)->ds_connection; - if (! dxh){ /* should not be ???*/ - NWDSFreeContext(*ctx); - return EINVAL; - } - for (i=0; i authinfo) { -/* printf ("trying to get authinfo \n");*/ - err = ncp_get_private_key(conn, NULL, &authinfo_len); - if (err) - continue; /* kernel without private key support */ - if (!authinfo_len) - continue; /* no private key on this connection */ - ndai = (union __NWDSAuthInfo*)malloc(authinfo_len); - if (!ndai) - continue; /* not enough memory */ - err = ncp_get_private_key(conn, ndai, &authinfo_len); - if (err) { - free(ndai); - continue; - } -/* printf ("got authinfo \n");*/ - mlock(ndai, authinfo_len); - dxh->authinfo = ndai; - if (dxh->dck.tree_name) - free(dxh->dck.tree_name); - dxh->dck.tree_name=wcsdup(wc_treeName); - } - - } - return 0; + if (!treeName) + return ERR_NULL_POINTER; + err = NWDSXlateFromCtx(ctx, treeNameW, sizeof(treeNameW), treeName); + if (err) + return err; + err = iconv_wchar_t_to_external(treeNameW, treeNameUTF, sizeof(treeNameUTF)); + if (err) + return err; + err = NWDSSetTreeNameW(ctx, treeNameW); + if (err) { + return err; + } + err = NWCXGetPermConnListByTreeName(conns, MAXCONNS, &curEntries, getuid(), treeNameUTF); + if (err) { + return err; + } + for (i = 0; i < curEntries; i++) { + NWCONN_HANDLE conn = conns[i]; + err = NWDSAddConnection(ctx, conn); + if (err) { + NWCCCloseConn(conn); + continue; + } + } + return 0; } +NWDSCCODE NWDSCreateContextHandleMnt(NWDSContextHandle* pctx, const NWDSChar * treeName) +{ + NWDSCCODE err; + NWDSContextHandle ctx; + + if (!pctx) { + return ERR_NULL_POINTER; + } + err = NWDSCreateContextHandle(&ctx); + if (err) + return err; + err = NWDSSetContextHandleTree(ctx, treeName); + if (err) + NWDSFreeContext(ctx); + else + *pctx = ctx; + return err; +} //#define NOENV 1 <-- testing reading of .nwinfos file #undef NOENV @@ -833,28 +818,32 @@ NWDSCCODE NWCXSplitNameAndContext (NWDSContextHandle ctx, const NWDSChar * dn, and return them as strings with comma separators attributes with fields are emitted on a single line with "," as separator*/ -static NWDSCCODE __docopy_string (NWDSContextHandle ctx, const void* val, +static NWDSCCODE __docopy_string (UNUSED(NWDSContextHandle ctx), const void* val, const enum SYNTAX synt, size_t currentSize, char* result, size_t maxSize){ - NWDSCCODE err; - char tmpBuf [MAX_DN_BYTES+1]; #ifdef DEBUG_PRINT printf ("__docopy_string got :%s synt = %d cursize=%d maxsize= %d\n",(char *)val,synt,currentSize,maxSize ); #endif - if (currentSize >maxSize) return NWE_BUFFER_OVERFLOW; + if (currentSize > maxSize) return NWE_BUFFER_OVERFLOW; if (!result) return ERR_NULL_POINTER; switch (synt) { case SYN_DIST_NAME: - /* - err = NWDSAbbreviateName(ctx, val, tmpBuf); - if (err) - return err; - //strcpy (result,tmpBuf); - *************************/ - strcpy(result,val); - break; +#if 0 + { + NWDSCCODE err; + char tmpBuf [MAX_DN_BYTES+1]; + + err = NWDSAbbreviateName(ctx, val, tmpBuf); + if (err) + return err; + strcpy (result,tmpBuf); + } +#else + strcpy(result,val); +#endif + break; case SYN_CI_STRING: case SYN_CE_STRING: case SYN_PR_STRING: @@ -1016,7 +1005,7 @@ NWDSCCODE docopy_string(NWDSContextHandle ctx, const void * val, const enum SYNT static -NWDSCCODE docopy_int(UNUSED(NWDSContextHandle ctx), const void * val, const enum SYNTAX synt, size_t currentSize, +NWDSCCODE docopy_int(UNUSED(NWDSContextHandle ctx), const void * val, const enum SYNTAX synt, UNUSED(size_t currentSize), void * result, size_t maxSize) { #ifdef DEBUG_PRINT printf ("docopy_int got :%s synt = %d cursize=%d maxsize= %d\n",(char *)val,synt,currentSize,maxSize ); @@ -1136,7 +1125,7 @@ static NWDSCCODE strlist_to_string (struct strlist * l, char ** result, char sep /* append the new string to a linked list */ static NWDSCCODE docopy_multistring(NWDSContextHandle ctx, const void * val, const enum SYNTAX synt, size_t currentSize, - void * result, size_t maxSize) { + void * result, UNUSED(size_t maxSize)) { NWDSCCODE err; char tmpBuf[MAX_DN_BYTES+1]; struct strlist* l=(struct strlist *) result; @@ -1328,9 +1317,11 @@ struct nw_home_info { }; -static NWDSCCODE docopy_host_server(NWDSContextHandle ctx, - const void* val, const enum SYNTAX synt, - size_t currentSize, void* result, size_t maxSize){ +/* Note that this function is completely wrong: host server is DN, and you should use DN operations on it... + * Cutting it at first dot is nonsense... It might work, but there is no reason why it should... */ +static NWDSCCODE docopy_host_server(UNUSED(NWDSContextHandle ctx), + const void* val, UNUSED(const enum SYNTAX synt), + UNUSED(size_t currentSize), void* result, UNUSED(size_t maxSize)) { struct nw_home_info* hi = (struct nw_home_info*)result; char buf [MAX_DN_CHARS]; char * dot; @@ -1350,9 +1341,9 @@ static NWDSCCODE docopy_host_server(NWDSContextHandle ctx, return 0; } -static NWDSCCODE docopy_host_resource_name(NWDSContextHandle ctx, - const void* val, const enum SYNTAX synt, - size_t currentSize, void* result, size_t maxSize){ +static NWDSCCODE docopy_host_resource_name(UNUSED(NWDSContextHandle ctx), + const void* val, UNUSED(const enum SYNTAX synt), + UNUSED(size_t currentSize), void* result, UNUSED(size_t maxSize)) { struct nw_home_info* hi = (struct nw_home_info*)result; @@ -1369,14 +1360,13 @@ static NWDSCCODE docopy_host_resource_name(NWDSContextHandle ctx, return 0; } -static NWDSCCODE docopy_home_directory(NWDSContextHandle ctx, - const void* val, const enum SYNTAX synt, - size_t currentSize, void* result, size_t maxSize){ +static NWDSCCODE docopy_home_directory(UNUSED(NWDSContextHandle ctx), + const void* val, UNUSED(const enum SYNTAX synt), + UNUSED(size_t currentSize), void* result, UNUSED(size_t maxSize)) { const Path_T* pa = (const Path_T*) val; Path_T* result_int = (Path_T*)result; - NWDSCCODE dserr; char * v; diff --git a/lib/nwnet.c b/lib/nwnet.c index 81d66ee..d151022 100644 --- a/lib/nwnet.c +++ b/lib/nwnet.c @@ -133,6 +133,7 @@ #include "ncplib_i.h" #include "ncpcode.h" #include "cfgfile.h" +#include "ncp/nwclient.h" static const char wchar_init[] = "WCHAR_T//"; static const char* wchar_encoding = wchar_init; @@ -673,7 +674,7 @@ static int __NWULocalToInternal(my_iconv_t h, wchar_t* dest, wchar_t* destEnd, srcLen = (srcEnd - src) * sizeof(*src); while (srcLen > 0) { - size_t n = my_iconv(h, &src, &srcLen, (char**)&dest, &destLen); + size_t n = my_iconv(h, &src, &srcLen, (char**)(char*)&dest, &destLen); if (n != (size_t)-1) break; err = errno; @@ -720,7 +721,7 @@ static int __NWUInternalToLocal(my_iconv_t h, char* dest, char* destEnd, /* GRRRR: why is not INTERNAL available for iconv?! */ while (srcLen > 0) { - size_t n = my_iconv(h, (const char**)&src, &srcLen, &dest, &destLen); + size_t n = my_iconv(h, (const char**)(const char*)&src, &srcLen, &dest, &destLen); if (n != (size_t)-1) break; err = errno; @@ -991,12 +992,16 @@ static NWDSCCODE NWDXSetTreeNameW(NWDS_HANDLE dsh, const wchar_t* treename) { return 0; } +NWDSCCODE NWDSSetTreeNameW(NWDSContextHandle ctx, const wchar_t* treename) { + return NWDXSetTreeNameW(ctx->ds_connection, treename); +} + int iconv_external_to_wchar_t(const char* inp, wchar_t* outp, size_t maxl) { int i; size_t inl; inl = strlen(inp) + sizeof(*inp); - i = iconv_utf8_to_wchar_t(&inp, &inl, (char**)&outp, &maxl); + i = iconv_utf8_to_wchar_t(&inp, &inl, (char**)(char*)&outp, &maxl); if (i < 0) return errno; return 0; @@ -1007,7 +1012,7 @@ int iconv_wchar_t_to_external(const wchar_t* inp, char* outp, size_t maxl) { size_t inl; inl = (wcslen(inp) + 1) * sizeof(*inp); - i = iconv_wchar_t_to_utf8((const char**)&inp, &inl, &outp, &maxl); + i = iconv_wchar_t_to_utf8((const char**)(const char*)&inp, &inl, &outp, &maxl); if (i < 0) return errno; return 0; @@ -1768,7 +1773,6 @@ restartLoop:; err = NWCCOpenConnByAddr(&tran, 0, NWCC_RESERVED, pconn); if (!err) return 0; -nextAddr:; } } if (err) @@ -1958,7 +1962,7 @@ static NWDSCCODE NWDSXlateCtxToUni(NWDSContextHandle ctx, unicode* data, wchar_t tbuff[128]; wchar_t* tEnd; - err2 = __NWULocalToInternal(ctx->xlate.from, tbuff, tbuff+128, src, srcEnd, NULL, &tEnd, (const char**)&src); + err2 = __NWULocalToInternal(ctx->xlate.from, tbuff, tbuff+128, src, srcEnd, NULL, &tEnd, (const char**)(const char*)&src); err = __NWUInternalToUnicode(dst, dstEnd, tbuff, tEnd, NULL, &dst, NULL); } while ((!err) && err2 == E2BIG); ncpt_mutex_unlock(&ctx->xlate.fromlock); @@ -6174,6 +6178,7 @@ freectx: // not sure that __NWDSGetConnection returns always an authenticated connection. // I had problems when I was "ncpmounted" and called this from a program with a -S parameter // pointing to another server +NWDSCCODE NWDSWhoAmI_Not_So_Good ( NWDSContextHandle ctx, NWDSChar * me ); NWDSCCODE NWDSWhoAmI_Not_So_Good ( NWDSContextHandle ctx, NWDSChar * me ) { NWDSCCODE dserr; NWCCODE err; @@ -6518,7 +6523,7 @@ NWDSCCODE NWDSReturnBlockOfAvailableTrees( } static NWDSCCODE __NWDSScanConnsForTrees( - NWDSContextHandle ctx, + UNUSED(NWDSContextHandle ctx), struct TreeList* t, NWCONN_HANDLE conn) { wchar_t tname[MAX_TREE_NAME_CHARS+1]; @@ -6594,7 +6599,8 @@ NWDSCCODE NWDSScanConnsForTrees ( // debugging and internal spying // caller MUST allocate a BIG buffer for output -NWDSCCODE NWDSSpyConns ( NWDSContextHandle ctx, NWDSChar * infos) { +NWDSCCODE NWDSSpyConns(NWDSContextHandle ctx, NWDSChar * infos); +NWDSCCODE NWDSSpyConns(NWDSContextHandle ctx, NWDSChar * infos) { NWCCODE err; NWCONN_HANDLE conn; nuint32 myID; diff --git a/lib/nwnet_i.h b/lib/nwnet_i.h index 6b17166..eda1bcc 100644 --- a/lib/nwnet_i.h +++ b/lib/nwnet_i.h @@ -416,6 +416,8 @@ NWDSCCODE NWDSXlateFromCtx(NWDSContextHandle ctx, wchar_t* dst, NWDSCCODE NWDSXlateToCtx(NWDSContextHandle ctx, void* data, size_t maxlen, const wchar_t* src, size_t* ln); +NWDSCCODE NWDSSetTreeNameW(NWDSContextHandle ctx, const wchar_t* treename); + /************************************************************************ * * * NWDS internal server calls * @@ -573,6 +575,13 @@ NWDSCCODE __NWDSReadObjectDSIInfo( nuint32 dsiFlags, Buf_T* dsiInfo); +NWDSCCODE __NWDSReadObjectInfo( + NWDSContextHandle ctx, + NWCONN_HANDLE conn, + NWObjectID id, + NWDSChar* distname, + Object_Info_T* oi); + NWDSCCODE NWDSDuplicateContextHandleInt( NWDSContextHandle srcctx, NWDSContextHandle* wctx); diff --git a/lib/o_ndslib.c b/lib/o_ndslib.c index 4b44113..42a1de0 100644 --- a/lib/o_ndslib.c +++ b/lib/o_ndslib.c @@ -110,7 +110,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, size_t *addr_len) { + int *entry_id, int *remote, UNUSED(struct sockaddr *serv_addr), size_t *addr_len) { NWDSCCODE err; NWDSContextHandle ctx; u_int32_t ctxflags; diff --git a/lib/queue.c b/lib/queue.c index 3fb37fd..e9e8616 100644 --- a/lib/queue.c +++ b/lib/queue.c @@ -52,7 +52,7 @@ static inline void ncp_add_queue_job(struct ncp_conn *conn, const struct nw_queu conn->current_point += sizeof(*j); } -static inline void ncp_reply_queue_entry(struct nw_queue_job_entry *j, const void * reply, size_t replys) { +static void ncp_reply_queue_entry(struct nw_queue_job_entry *j, const void * reply, size_t replys) { memcpy(j, reply, replys); if (replys < sizeof(*j)) { unsigned char * v = (unsigned char*)j; diff --git a/lib/resolve.c b/lib/resolve.c index 8e281e5..0c01d54 100644 --- a/lib/resolve.c +++ b/lib/resolve.c @@ -42,6 +42,10 @@ #include "ncpcode.h" #include "ncpi.h" +static NWCCODE NWCCOpenConnByNameTran(NWCONN_HANDLE startConn, const char *serverName, + nuint nameFormat, nuint openState, nuint reserved, + nuint transport, NWCONN_HANDLE* pconn); + struct resolver { const char* name; NWCCODE (*start)(void **rh, NWCONN_HANDLE conn, @@ -113,7 +117,13 @@ static NWCCODE bind_start(void **prh, NWCONN_HANDLE startConn, if (!startConn) { err = ncp_next_conn(NULL, &startConn); if (err) { - return err; + if (name != NULL || nameFormat != NWCC_NAME_FORMAT_BIND || transport != NT_IPX) { + err = NWCCOpenConnByNameTran(NULL, NULL, NWCC_NAME_FORMAT_BIND, + NWCC_OPEN_NEW_CONN, NWCC_RESERVED, NT_IPX, &startConn); + } + if (err) { + return err; + } } } else { ncp_conn_use(startConn); @@ -259,7 +269,7 @@ struct dns_rh { u_int32_t addresses[0]; }; -static NWCCODE dns_start(void **prh, NWCONN_HANDLE startConn, +static NWCCODE dns_start(void **prh, UNUSED(NWCONN_HANDLE startConn), const char *name, nuint nameFormat, nuint transport) { struct dns_rh* rh; struct hostent* he; @@ -554,7 +564,7 @@ static void sap_process(int fd, unsigned char *sap_request, size_t cmplen) { while (1) { long err; int recvtime; - int offs; + size_t offs; if (gettimeofday(&tv, NULL)) goto quitSock; @@ -597,8 +607,8 @@ quit: write(fd, &u32, sizeof(u32)); } -static NWCCODE sap_start(void **prh, NWCONN_HANDLE startConn, - const char *name, nuint nameFormat, nuint transport) { +static NWCCODE sap_start(void **prh, UNUSED(NWCONN_HANDLE startConn), + const char *name, nuint nameFormat, nuint transport) { struct sap_rh* rh; unsigned char sap_request[60]; size_t cmplen; @@ -867,18 +877,26 @@ NWCCODE ncp_find_server_addr(const char **serverName, int object_type, struct so if (!err) { if (ta.type == NT_IPX) { struct sockaddr_ipx* ipx = (struct sockaddr_ipx*)addr; - - ipx->sipx_family = AF_IPX; - memcpy(ipx->sipx_node, buffer + 4, 6); - memcpy(&ipx->sipx_network, buffer, 4); - memcpy(&ipx->sipx_port, buffer + 10, 2); - ipx->sipx_type = 0x11; + + if (len < sizeof(*ipx)) { + err = NWE_BUFFER_OVERFLOW; + } else { + ipx->sipx_family = AF_IPX; + memcpy(ipx->sipx_node, buffer + 4, 6); + memcpy(&ipx->sipx_network, buffer, 4); + memcpy(&ipx->sipx_port, buffer + 10, 2); + ipx->sipx_type = 0x11; + } } else if (ta.type == NT_UDP || ta.type == NT_TCP) { struct sockaddr_in* in = (struct sockaddr_in*)addr; - - in->sin_family = AF_INET; - memcpy(&in->sin_addr.s_addr, buffer + 2, 4); - memcpy(&in->sin_port, buffer, 2); + + if (len < sizeof(*in)) { + err = NWE_BUFFER_OVERFLOW; + } else { + in->sin_family = AF_INET; + memcpy(&in->sin_addr.s_addr, buffer + 2, 4); + memcpy(&in->sin_port, buffer, 2); + } } else { err = EINVAL; } diff --git a/man/ncpmount.8 b/man/ncpmount.8 index 9e97308..f1faa81 100644 --- a/man/ncpmount.8 +++ b/man/ncpmount.8 @@ -1,6 +1,6 @@ .TH NCPMOUNT 8 12/04/1998 ncpmount ncpmount .SH NAME -ncpmount, mount.ncp \- mount volume(s) from a specified NetWare fileserver. +ncpmount, mount.ncp, mount.ncpfs \- mount volume(s) from a specified NetWare fileserver. .SH SYNOPSIS .B ncpmount [ \fB-h\fP ] [ \fB-S\fP \fIserver\fP ] [ \fB-U\fP \fIuser name\fP ] @@ -462,12 +462,6 @@ configuration files and is logged into \fI/etc/mtab\fP, \fIdns_name\fP is used for connecting to server. In future, logical_name will be read from server. .RE -.B /etc/fstab -.RS 3 -You must specify filesystem type \fIncp\fP and not \fIncpfs\fP although -it is reported as \fIncpfs\fP in \fI/etc/mtab\fP and \fI/proc/mounts\fP. -.RE - .SH SEE ALSO .B syslogd(8), ncpumount(8), nfsd(8), mountd(8), mount(8) diff --git a/ncpfs.lsm b/ncpfs.lsm index dd24314..f59e495 100644 --- a/ncpfs.lsm +++ b/ncpfs.lsm @@ -1,7 +1,7 @@ Begin3 Title: ncpfs -Version: 2.2.4 -Entered-date: February 10, 2004 +Version: 2.2.5 +Entered-date: November 30, 2004 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 @@ -10,8 +10,8 @@ Keywords: filesystem ncp novell netware printing Author: vandrove@vc.cvut.cz (Petr Vandrovec) lendecke@Math.Uni-Goettingen.de (Volker Lendecke) Maintained-by: vandrove@vc.cvut.cz (Petr Vandrovec) -Primary-site: platan.vc.cvut.cz /pub/linux/ncpfs/ncpfs-2.2.4 - 1464k ncpfs-2.2.4.tgz +Primary-site: platan.vc.cvut.cz /pub/linux/ncpfs/ncpfs-2.2.5 + 1464k ncpfs-2.2.5.tgz 1k ncpfs.lsm Alternate-site: ftp.cvut.cz /ncpfs Copying-policy: GPL diff --git a/sutil/ncplogin.c b/sutil/ncplogin.c index 0141901..d5afbf2 100644 --- a/sutil/ncplogin.c +++ b/sutil/ncplogin.c @@ -87,6 +87,8 @@ */ +#define NCP_OBSOLETE + #include "ncpm_common.h" #include @@ -776,7 +778,9 @@ main(int argc, char *argv[]) } else #endif /* CONFIG_NATIVE_IP */ { +#if defined(CONFIG_NATIVE_UNIX) && !defined(CONFIG_NATIVE_IP) ncpipx:; +#endif #ifndef NCPMAP /*ncpmount & ncplogin */ if ((err = ncp_find_fileserver(spec.server, (struct sockaddr*)&info.mdata.serv_addr, sizeof(info.mdata.serv_addr))) != 0) { diff --git a/sutil/ncpm_common.c b/sutil/ncpm_common.c index 37fd3d3..6c9ad31 100644 --- a/sutil/ncpm_common.c +++ b/sutil/ncpm_common.c @@ -754,7 +754,7 @@ process_wdog_packet (int wdog_fd) sendto(wdog_fd, buf, 2, 0, (struct sockaddr *) &sender, addrlen); } -static void reapChld(int dummy) { +static void reapChld(UNUSED(int dummy)) { signal(SIGCHLD, reapChld); /* reap all exited childrens... */ while (wait4(-1, NULL, WNOHANG, NULL) > 0) ; @@ -975,7 +975,7 @@ static int getconn(NWCONN_HANDLE* cn) { return ncp_open_mount(nwcc_mount_point, cn); } -static int ncp_ext_perform(struct ncp_ext_client* clnt, const unsigned char* data, size_t rqlen) { +static int ncp_ext_perform(struct ncp_ext_client* clnt, UNUSED(const unsigned char* data), UNUSED(size_t rqlen)) { NWCONN_HANDLE cn; int err; @@ -1341,7 +1341,7 @@ void add_mnt_entry(char* mount_name, char* mpnt, unsigned long flags) { ment.mnt_fsname = mount_name; ment.mnt_dir = mpnt; - ment.mnt_type = "ncpfs"; + ment.mnt_type = (char*)"ncpfs"; ment.mnt_opts = mnt_opts; ment.mnt_freq = 0; ment.mnt_passno = 0; @@ -1446,7 +1446,7 @@ static void opt_clear_noexec(struct ncp_mount_info* info, unsigned int param) { } static void opt_remount(struct ncp_mount_info* info, unsigned int param) __attribute__((noreturn)); -static void opt_remount(struct ncp_mount_info* info, unsigned int param) { +static void opt_remount(UNUSED(struct ncp_mount_info* info), UNUSED(unsigned int param)) { errexit(7, _("Remounting not supported, sorry\n")); } @@ -1549,7 +1549,7 @@ static void opt_set_codepage(struct ncp_mount_info* info, const char* param) { strcpy(info->nls_cs.codepage, param); } -static void opt_not_implemented(struct ncp_mount_info* info, unsigned int param) { +static void opt_not_implemented(UNUSED(struct ncp_mount_info* info), UNUSED(unsigned int param)) { /* noop */ } diff --git a/sutil/ncpm_common.h b/sutil/ncpm_common.h index a94bc9b..16bff2b 100644 --- a/sutil/ncpm_common.h +++ b/sutil/ncpm_common.h @@ -119,4 +119,6 @@ void proc_option(const struct optinfo* opts, struct ncp_mount_info* info, const int proc_buildconn(struct ncp_mount_info* info); int proc_aftermount(const struct ncp_mount_info* info, NWCONN_HANDLE* conn); +#define UNUSED(x) x __attribute__((unused)) + #endif /* __NCPM_COMMON_H__ */ diff --git a/sutil/ncpmount.c b/sutil/ncpmount.c index 9e7b70c..027c655 100644 --- a/sutil/ncpmount.c +++ b/sutil/ncpmount.c @@ -90,6 +90,8 @@ */ +#define NCP_OBSOLETE + #include "ncpm_common.h" #include "mount_login.h" @@ -431,11 +433,14 @@ main(int argc, char *argv[]) #endif { if (info.volume) { - info.pathlen = ncp_path_to_NW_format(info.volume, info.NWpath, sizeof(info.NWpath)); + int ln; + + ln = ncp_path_to_NW_format(info.volume, info.NWpath, sizeof(info.NWpath)); info.remote_path = info.volume; - if (info.pathlen < 0) { - errexit(18, _("Volume path `%s' is invalid: `%s'\n"), info.volume, strerror(-info.pathlen)); + if (ln < 0) { + errexit(18, _("Volume path `%s' is invalid: `%s'\n"), info.volume, strerror(-ln)); }; + info.pathlen = ln; if (info.pathlen == 1) { info.mdata.mounted_vol = ""; info.remote_path = "/"; @@ -550,7 +555,9 @@ main(int argc, char *argv[]) } else #endif /* CONFIG_NATIVE_IP */ { +#if defined(CONFIG_NATIVE_UNIX) && !defined(CONFIG_NATIVE_IP) ncpipx:; +#endif if ((!info.allow_multiple_connections)&& ((tmp_mount = ncp_find_permanent(&spec)) != NULL)) { diff --git a/util/ncopy.c b/util/ncopy.c index 65c6950..05dce9c 100644 --- a/util/ncopy.c +++ b/util/ncopy.c @@ -1040,7 +1040,7 @@ handleFileArgs(int argc, char *const argv[]) /**************************************************************************** * */ -static void +static void __attribute__((noreturn)) handleSignals(int sigNumber) { /* Ignore Signal Handling while cleaning up */ diff --git a/util/ncptest.c b/util/ncptest.c index ddd00de..04a1097 100644 --- a/util/ncptest.c +++ b/util/ncptest.c @@ -78,7 +78,7 @@ test_connlist(struct ncp_conn *conn) return; } -static void +static void __attribute__((unused)) test_send(struct ncp_conn *conn) { u_int8_t conn_list[256] = @@ -137,7 +137,7 @@ test_create(struct ncp_conn *conn) printf(_("test_create: Passed.\n")); } -static int +static int __attribute__((unused)) test_change(struct ncp_conn *conn) { long result; diff --git a/util/nwauth.c b/util/nwauth.c index 2c5824e..4b97c38 100644 --- a/util/nwauth.c +++ b/util/nwauth.c @@ -76,15 +76,6 @@ main(int argc, char *argv[]) char *object_name = NULL; char *object_pwd = NULL; int object_type = NCP_BINDERY_USER; - union { - struct sockaddr any; -#ifdef CONFIG_NATIVE_IPX - struct sockaddr_ipx ipx; -#endif -#ifdef CONFIG_NATIVE_IP - struct sockaddr_in inet; -#endif - } addr; long err; int prterr; @@ -136,7 +127,7 @@ main(int argc, char *argv[]) } err = ncp_find_conn_spec3(server, object_name, "", - 1, daemon ? ~0 : getuid(), 0, &spec); + 1, daemon ? ~0U : getuid(), 0, &spec); if (err) { diff --git a/util/nwbpvalues.c b/util/nwbpvalues.c index 09a1e7b..7367b66 100644 --- a/util/nwbpvalues.c +++ b/util/nwbpvalues.c @@ -345,6 +345,11 @@ print_station_addr(const char *fmt, const struct ncp_station_addr *addr, char *b return ret; } +static inline size_t my_strftime(char *s, size_t max, const char *fmt, const struct tm *tm) { + return strftime(s, max, fmt, tm); +} + + static void print_login_control(u_int8_t * val, int segments) { @@ -369,7 +374,7 @@ print_login_control(u_int8_t * val, int segments) tm->tm_min = a->LastLogin[4]; tm->tm_sec = a->LastLogin[5]; tm->tm_isdst = 0; - strftime(text, sizeof(text), _("Last Login: %x, %X"), tm); + my_strftime(text, sizeof(text), _("Last Login: %x, %X"), tm); puts(text); } else { @@ -392,7 +397,7 @@ print_login_control(u_int8_t * val, int segments) tm->tm_mon = a->AccountExpireDate[1] - 1; tm->tm_mday = a->AccountExpireDate[2]; tm->tm_isdst = 0; - strftime(text, sizeof(text), _("Account expires on: %x"), tm); + my_strftime(text, sizeof(text), _("Account expires on: %x"), tm); puts(text); } if (a->PasswordExpireDate[2] || a->PasswordExpireDate[1] || @@ -408,7 +413,7 @@ print_login_control(u_int8_t * val, int segments) tm->tm_mon = a->PasswordExpireDate[1] - 1; tm->tm_mday = a->PasswordExpireDate[2]; tm->tm_isdst = 0; - strftime(text, sizeof(text), _("Password expires on: %x"), tm); + my_strftime(text, sizeof(text), _("Password expires on: %x"), tm); puts(text); printf(_("GraceLogins left: %d\nof max. : %d\n"), a->GraceLogins, a->MaxGraceLogins); @@ -525,7 +530,7 @@ formats[] = { print_string, "Q_DIRECTORY" }, { print_login_control, "LOGIN_CONTROL" }, { print_addr, "NET_ADDRESS" }, - { NULL, NULL }, + { print_hex, NULL }, }; static void diff --git a/util/nwdir.c b/util/nwdir.c index f9343e0..fa0451b 100644 --- a/util/nwdir.c +++ b/util/nwdir.c @@ -230,6 +230,10 @@ static void doID(NWCONN_HANDLE conn, nuint32 id) { } } +static inline size_t my_strftime(char *s, size_t max, const char *fmt, const struct tm *tm) { + return strftime(s, max, fmt, tm); +} + static void dodate(nuint date) { static const time_t zero_time_t = 0; struct tm* tm; @@ -240,7 +244,7 @@ static void dodate(nuint date) { tm->tm_mon = ((date>>5) & 0xF) - 1; tm->tm_mday = date & 0x1F; tm->tm_isdst = 0; - strftime(text, sizeof(text), "%x", tm); + my_strftime(text, sizeof(text), "%x", tm); printf("%s", text); } @@ -254,7 +258,7 @@ static void dotime(nuint dtime) { tm->tm_min = (dtime >> 5) & 0x3F; tm->tm_sec = (dtime << 1) & 0x3F; tm->tm_isdst = 0; - strftime(text, sizeof(text), "%X", tm); + my_strftime(text, sizeof(text), "%X", tm); printf("%s", text); } @@ -892,7 +896,7 @@ int main(int argc, char* argv[]) { if (i < argc) { path = argv[i++]; } else { - path = "."; + path = (char*)"."; } err = NWCallsInit(NULL, NULL); if (err) { diff --git a/util/nwfsinfo.c b/util/nwfsinfo.c index c620f9c..4f52bf5 100644 --- a/util/nwfsinfo.c +++ b/util/nwfsinfo.c @@ -114,6 +114,11 @@ print_info(struct ncp_file_server_info_2 *info) { return; } +static inline size_t my_strftime(char *s, size_t max, const char *fmt, const struct tm *tm) { + return strftime(s, max, fmt, tm); +} + + int main(int argc, char **argv) { @@ -183,7 +188,7 @@ main(int argc, char **argv) struct tm* tm; tm = localtime(&t); - strftime(text_server_time, sizeof(text_server_time), "%c", tm); + my_strftime(text_server_time, sizeof(text_server_time), "%c", tm); printf("%s\n", text_server_time); } break; diff --git a/util/nwfstime.c b/util/nwfstime.c index 5da9959..d07a7b9 100644 --- a/util/nwfstime.c +++ b/util/nwfstime.c @@ -65,6 +65,10 @@ help(void) "\n")); } +static inline size_t my_strftime(char *s, size_t max, const char *fmt, const struct tm *tm) { + return strftime(s, max, fmt, tm); +} + int main(int argc, char **argv) { @@ -153,7 +157,7 @@ main(int argc, char **argv) struct tm* tm; tm = localtime(&t); - strftime(text_server_time, sizeof(text_server_time), "%c", tm); + my_strftime(text_server_time, sizeof(text_server_time), "%c", tm); printf("%s\n", text_server_time); } } diff --git a/util/nwpjmv.c b/util/nwpjmv.c index 6a15fd2..96b7e6b 100644 --- a/util/nwpjmv.c +++ b/util/nwpjmv.c @@ -251,7 +251,7 @@ move_job(struct nw_queue *q, u_int32_t jobID) sizeof(buf), buf)) > 0) { offset += result; - if (write(fd[1], buf, result) != result) + if (write(fd[1], buf, result) != (int)result) { goto fail; } diff --git a/util/nwtrustee2.c b/util/nwtrustee2.c index dda3021..58feca2 100644 --- a/util/nwtrustee2.c +++ b/util/nwtrustee2.c @@ -123,7 +123,7 @@ main(int argc, char *argv[]) if (optind >= argc) { optind = argc - 1; - argv[optind] = "."; + argv[optind] = (char*)"."; } while (optind < argc) { int printed = 0; diff --git a/util/nwuserlist.c b/util/nwuserlist.c index 06436ae..7118715 100644 --- a/util/nwuserlist.c +++ b/util/nwuserlist.c @@ -169,6 +169,10 @@ static void print_value(int format, const char* title, const char* units, u_int6 } } +static inline size_t my_strftime(char *s, size_t max, const char *fmt, const struct tm *tm) { + return strftime(s, max, fmt, tm); +} + int main(int argc, char **argv) { @@ -350,7 +354,7 @@ main(int argc, char **argv) struct tm* tm; tm = localtime(&login_time); - strftime(text_login_time, sizeof(text_login_time), "%c", tm); + my_strftime(text_login_time, sizeof(text_login_time), "%c", tm); printf("%s\n", text_login_time); } if (print_file) { diff --git a/util/pserver.c b/util/pserver.c index 3148297..47097a0 100644 --- a/util/pserver.c +++ b/util/pserver.c @@ -262,7 +262,7 @@ poll_queue(struct nw_queue *q) sizeof(buf), buf)) > 0) { offset += result; - if (write(fd[1], buf, result) != result) + if (write(fd[1], buf, result) != (int)result) { goto fail; }