Patch #: 195 Type: operational change Priority: none Modification: Add support for NetBSD 1.0 Submitted: Paul Nash Submitted: David Hornsby Modification: Add support for FreeBSD 2.0 Submitted: Dave Matthews Modification: Add support for BSDI BSD/386 1.1/2.0 Submitted: David Hornsby Submitted: Setsu Suzuki Modification: Add support for non-cleartext AUFS passwords Submitted: David Hornsby Modification: Minor fixes for Solaris 2.N Submitted: Andy Polyakov Submitted: Davin Milun Modification: Minor fixes for OSF/1 Submitted: Eric Santarelli Submitted: Bill Tutt Submitted: Castor Fu Submitted: Michel Le Berre Modification: Minor fixes for IRIX Submitted: Tim Wicinski Submitted: Frank Chen Modification: Minor fixes for HP-UX Submitted: Kim H|glund Submitted: Volker Weinberger Submitted: David Hornsby Modification: Fix spurious tab that confuses GNU make Submitted: Eric William Burger Modification: Workaround missing Solaris gettimeofday() timezone param. Submitted: Chris Edwards Modification: Fix missing papof index() definition Modification: Increment missing version numbers (from patches 193, 194) Submitted: Bruce Jerrick Modification: Change CREAT_AFPVOL_NAM to customize AUFS Mac vol. name Submitted: David Hornsby Submitted: Damon Atkins Modification: Change CREATE_AFPVOL to use ~usr instead of absolute paths Submitted: Heather Ebey Modification: Fix for PS software that requires first line to be "%!" Modification: Make lpr '-s' optional (broken OSF/1 2.0/3.0 "lpr -s -r") Submitted: Serge Modification: Fix for ash to avoid BitMapErr Submitted: Satoshi Adachi Modification: Allow AUFS user in ADMIN_GRP to login as superuser Modification: Allow AUFS alternate NBP type to be set as '-n name:type' Submitted: Tim Leamy Modification: Allow AUFS to add a 'wtmp' entry for each connection Submitted: Gavin Longmuir Submitted: Heather Ebey Modification: Report papif 'problems finding printer' in status Submitted: Giray Pultar Modification: Add DEBUG_AFP_CMD to dump all AFP command I/O parameters Modification: Extend USE_MAC_DATES to work with Folders Modification: Fix AUFS/SimpleText file saving bug Modification: Fix bug in FPGetAPPL application mapping Submitted: David Hornsby Archived: munnari.OZ.AU mac/cap.patches/cap60.patch195 Application: 'cd cap60; patch -p < cap60.patches/cap60.patch195' File: cap60/Configure File: cap60/conf.func.sh File: cap60/applications/aufs/afpos.c File: cap60/applications/lwsrv/lwsrv.c File: cap60/contrib/lwrename.c File: cap60/lib/cap/ablog.c File: cap60/support/ethertalk/aarpd.c File: cap60/support/ethertalk/abelap.c File: cap60/support/ethertalk/bpfiltp.c File: cap60/support/uab/asyncatalk.c File: cap60/support/uab/bpfiltp.c File: cap60/support/uab/kip_mpx.c File: cap60/applications/papif/papif.c File: cap60/applications/papif/add_at_printer File: cap60/applications/papif/papof.c File: cap60/support/ethertalk/Makefile.m4 File: cap60/lib/afp/afpcmd.c File: cap60/lib/cap/abversion.c File: cap60/lib/cap/absched.c File: cap60/lib/cap/abkip.c File: cap60/lib/cap/atalkdbm.c File: cap60/samples/papstatus.c File: cap60/samples/ash.c File: cap60/contrib/snitch.c File: cap60/contrib/printqueue.c File: cap60/applications/lwsrv/simple.c File: cap60/applications/aufs/afpvols.c File: cap60/applications/aufs/aufs.c File: cap60/applications/aufs/afpdir.c File: cap60/applications/aufs/afpdt.c File: cap60/applications/aufs/afpfile.c File: cap60/applications/aufs/afpfork.c File: cap60/applications/aufs/afpserver.c File: cap60/applications/aufs/afposfi.c File: cap60/applications/aufs/afpntoh.h File: cap60/applications/aufs/afposenum.c File: cap60/applications/aufs/aufsicon.c File: cap60/lib/afp/afperr.c File: cap60/lib/afp/afppacks.c File: cap60/lib/afp/afppass.c File: cap60/lib/afp/Makefile.m4 File: cap60/netat/afpc.h File: cap60/netat/afpcmd.h File: cap60/netat/afppass.h File: cap60/netat/Makefile.m4 File: cap60/extras/des.c File: cap60/man/AUFS.1 File: cap60/man/AUFS.8 File: cap60/man/aufsmkusr.8 File: cap60/man/aufsmkkey.8 File: cap60/contrib/aufsmkusr.c File: cap60/contrib/aufsmkkey.c File: cap60/contrib/Makefile.m4 File: cap60/contrib/README File: cap60/CAP60.README File: cap60/README *** Configure.orig Mon Oct 24 16:41:45 1994 --- Configure Sat Jul 1 00:33:08 1995 *************** *** 1,7 **** #!/bin/sh ! # $Author: djh $ $Date: 1994/10/24 06:41:28 $ ! # $Header: /mac/src/cap60/RCS/Configure,v 2.74 1994/10/24 06:41:28 djh Rel djh $ ! # $Revision: 2.74 $ # CAP configuration shell script. This ain't perfect, but it's a start. # Execute with /bin/sh Configure if your system won't run it (ksh is okay too) # --- 1,7 ---- #!/bin/sh ! # $Author: djh $ $Date: 1995/06/30 14:32:56 $ ! # $Header: /mac/src/cap60/RCS/Configure,v 2.97 1995/06/30 14:32:56 djh Rel djh $ ! # $Revision: 2.97 $ # CAP configuration shell script. This ain't perfect, but it's a start. # Execute with /bin/sh Configure if your system won't run it (ksh is okay too) # *************** *** 195,206 **** echo "HP-UX" osdefault="hpux" lpd="lp" - if [ `uname -r` -ge 6 ]; then - echo "Release 6.0 or later" - else - echo "OLD hpux version: you will have to define NEEDMSGHDR in CAPOSDEFS" - echo "by hand (c.f. PORTING and NOTES)" - fi break ;; "XENIX") --- 195,200 ---- *************** *** 267,273 **** fi fi fi ! # 386bsd, FreeBSD and derivatives if [ -z "${osdefault}" ]; then echo "Checking for 386bsd etc." if [ -x /386bsd ]; then --- 261,267 ---- fi fi fi ! # 386bsd, FreeBSD 1.n and derivatives if [ -z "${osdefault}" ]; then echo "Checking for 386bsd etc." if [ -x /386bsd ]; then *************** *** 275,280 **** --- 269,300 ---- osdefault="386bsd" fi fi + # NetBSD 1.0 + if [ -z "${osdefault}" ]; then + echo "Checking for NetBSD 1.0" + if [ -x /netbsd ]; then + echo "NetBSD 1.0" + osdefault="netbsd" + fi + fi + # FreeBSD 2.0 + if [ -z "${osdefault}" ]; then + echo "Checking for FreeBSD" + if [ -f /usr/bin/uname ]; then + if [ "`/usr/bin/uname -s`" = "FreeBSD" ]; then + echo "FreeBSD" + osdefault="freebsd" + fi + fi + fi + # BSDI 1.1 + if [ -z "${osdefault}" ]; then + echo "Checking for BSDI BSD/386 1.1" + if [ -f /bsd ]; then + echo "BSDI BSD/386 1.1" + osdefault="bsdi" + fi + fi # HP/Apollo Domain if [ -z "${osdefault}" ]; then echo "Checking for HP/Apollo Domain 10.4" *************** *** 347,352 **** --- 367,375 ---- "drsnx") valid=1;; "epix") valid=1;; "386bsd") valid=1;; + "netbsd") valid=1;; + "freebsd") valid=1;; + "bsdi") valid=1;; "domainosbsd") valid=1;; "?"|*) if [ "${os}" != "?" ]; then *************** *** 372,378 **** echo " newsos - Sony NEWS" echo " drsnx - ICL DRS/NX V4.0" echo " epix - Control Data EP/IX" ! echo " 386bsd - 386/BSD, FreeBSD and derivatives" echo " domainosbsd - HP/Apollo Domain BSD 4.3" ;; esac --- 395,404 ---- echo " newsos - Sony NEWS" echo " drsnx - ICL DRS/NX V4.0" echo " epix - Control Data EP/IX" ! echo " 386bsd - 386/BSD, FreeBSD 1.n and derivatives" ! echo " netbsd - NetBSD 1.0" ! echo " freebsd - FreeBSD 2.0" ! echo " bsdi - BSDI BSD/386 1.1" echo " domainosbsd - HP/Apollo Domain BSD 4.3" ;; esac *************** *** 438,443 **** --- 464,484 ---- uarsupport=1 ethersupport=1 ;; + "netbsd") + uabsupport=1 + uarsupport=1 + ethersupport=1 + ;; + "freebsd") + uabsupport=1 + uarsupport=1 + ethersupport=1 + ;; + "bsdi") + uabsupport=1 + uarsupport=1 + ethersupport=1 + ;; *) uabsupport=0 uarsupport=0 *************** *** 501,507 **** uabpobjs="define([uabpobjs],[spfiltp.o])";; "osf1") echo "OK, setting things up for UAB." ! uabpobjs="define([uabpobjs],[spfiltp.o pfopen.o])";; "pyr") echo "OK, setting things up for UAB." uabpobjs="define([uabpobjs],[senetp.o])";; --- 542,548 ---- uabpobjs="define([uabpobjs],[spfiltp.o])";; "osf1") echo "OK, setting things up for UAB." ! uabpobjs="define([uabpobjs],[spfiltp.o])";; "pyr") echo "OK, setting things up for UAB." uabpobjs="define([uabpobjs],[senetp.o])";; *************** *** 514,520 **** "hpux") echo "OK, setting things up for UAB." uabpobjs="define([uabpobjs],[sllap.o])";; ! "386bsd") echo "OK, setting things up for UAB." uabpobjs="define([uabpobjs],[bpfiltp.o])";; "solaris") --- 555,561 ---- "hpux") echo "OK, setting things up for UAB." uabpobjs="define([uabpobjs],[sllap.o])";; ! "386bsd"|"netbsd"|"freebsd"|"bsdi") echo "OK, setting things up for UAB." uabpobjs="define([uabpobjs],[bpfiltp.o])";; "solaris") *************** *** 631,637 **** esac case ${os} in "osf1") ! etherpobjs="define([etherpobjs],[spfiltp.o pfopen.o])" ;; "ultrix40") etherpobjs="define([etherpobjs],[spfiltp.o])" --- 672,678 ---- esac case ${os} in "osf1") ! etherpobjs="define([etherpobjs],[spfiltp.o])" ;; "ultrix40") etherpobjs="define([etherpobjs],[spfiltp.o])" *************** *** 644,649 **** --- 685,706 ---- "386bsd") echo "OK, setting things up for Native EtherTalk." etherpobjs="define([etherpobjs],[bpfiltp.o])";; + "netbsd"|"freebsd"|"bsdi") + ${PROMPT} "Do you want Phase 2 compatibility (no) ? " + read ans + if [ -z "${ans}" ]; then + ans="no" + fi + case ${ans} in + "yes"|"y") + usephase2=1 + echo "OK, setting things up for Native EtherTalk, Phase2." + ;; + *) + echo "OK, setting things up for Native EtherTalk." + ;; + esac + etherpobjs="define([etherpobjs],[bpfiltp.o])";; "solaris") ${PROMPT} "Do you want Phase 2 compatibility (no) ? " read ans *************** *** 898,905 **** # + CREATE_AFPVOL create user .afpvols and 'mac' directories if non-existent # define(`specialcflags',concat(specialcflags,` -DCREATE_AFPVOL=\"mac\"')) # ! # + CREATE_AFPVOL_NAME use the user name for the volume (modifies CREATE_AFPVOL) ! # define(`specialcflags',concat(specialcflags,` -DCREATE_AFPVOL_NAME')) # # + ISO_TRANSLATE use Macintosh/ISO 8859 character translation on I/O # define(`specialcflags',concat(specialcflags,` -DISO_TRANSLATE')) --- 955,963 ---- # + CREATE_AFPVOL create user .afpvols and 'mac' directories if non-existent # define(`specialcflags',concat(specialcflags,` -DCREATE_AFPVOL=\"mac\"')) # ! # + CREAT_AFPVOL_NAM customize name for the volume (modifies CREATE_AFPVOL) ! # (CREAT_AFPVOL_NAM fmt string: %U user, %H host, %V vol, %D home eg: "%U@%H") ! # define(`specialcflags',concat(specialcflags,` -DCREAT_AFPVOL_NAM="\"%U\""')) # # + ISO_TRANSLATE use Macintosh/ISO 8859 character translation on I/O # define(`specialcflags',concat(specialcflags,` -DISO_TRANSLATE')) *************** *** 927,932 **** --- 985,1011 ---- # # AUFS definable options (previously required editing m4.setup) # + # + DISTRIB_PASSWDS use ~/.afppass for encrypted passwords (see CAP60.README) + # define(`specialcflags',concat(specialcflags,` -DDISTRIB_PASSWDS')) + # + # + AFP_DISTPW_PATH alternate directory for .afppass files (not in ~user) + # define(`specialcflags',concat(specialcflags,` -DAFP_DISTPW_PATH=\"/etc/dp\"')) + # + # + AFP_DISTPW_MODE enforced .afppass mode (must be 0644 for NFS mounted dirs) + # define(`specialcflags',concat(specialcflags,` -DAFP_DISTPW_MODE=0600')) + # + # + DEBUG_AFP_CMD write detailed AUFS AFP debugging info to -Z specified file + # define(`specialcflags',concat(specialcflags,` -DDEBUG_AFP_CMD')) + # + # + LOG_WTMP add entry to the 'wtmp' file for each AUFS connection (not IRIX4) + # define(`aufsosflags',concat(aufsosflags,` -DLOG_WTMP')) + # + # + LOG_WTMP_FILE specify name of alternate wtmp file for LOG_WTMP feature + # define(`aufsosflags',concat(aufsosflags,` -DLOG_WTMP_FILE=\"/usr/adm/wtmp\"')) + # + # + ADMIN_GRP allows users in specified UNIX group to login as AUFS superuser + # define(`aufsosflags',concat(aufsosflags,` -DADMIN_GRP=\"macadm\"')) + # # + NONLXLATE for aufs # define(`aufsosflags',concat(aufsosflags,` -DNONLXLATE')) # *************** *** 972,977 **** --- 1051,1062 ---- # + LPRCMD redefine BSD lpr to use alternate path # define(`lwflags',concat(lwflags,` -DLPRCMD=\"/usr/local/bin/lpr\"')) # + # + TEMPFILE set alternative path for lwsrv spool files (default /tmp) + # define(`lwflags',concat(lwflags,` -DTEMPFILE=\"/usr/tmp/lwsrvXXXXXX\"')) + # + # + USELPRSYM add -s (symlink) option to lwsrv lpr call (not for OSF/1) + # define(`lwflags',concat(lwflags,` -DUSELPRSYM')) + # # + USESYSVLP required for HP-UX (and probably other System V) spooling # define(`lwflags',concat(lwflags,` -DUSESYSVLP')) # *************** *** 1244,1258 **** echo "Getting NeXT 2.0 name list from /lib/libsys_s.a..." ${PNM} /lib/libsys_s.a > /tmp/cx$$ else ! echo "Cannot get the namelist ... HELP" fi fi fi ;; esac names=$? ! # FreeBSD gives an error in nm, ignore it. ! if [ $names -ne 0 -a "${os}" != "386bsd" ]; then echo "Couldn't get the name list!" else echo "Done, running function configuration" --- 1329,1348 ---- echo "Getting NeXT 2.0 name list from /lib/libsys_s.a..." ${PNM} /lib/libsys_s.a > /tmp/cx$$ else ! if [ -f /lib/libc.so.1 ]; then ! echo "Getting IRIX 5 name list from /lib/libc.so.1" ! ${PNM} /lib/libc.so.1 > /tmp/cx$$ ! else ! echo "Cannot get the namelist ... HELP" ! fi fi fi fi ;; esac names=$? ! # FreeBSD (1.0) gives an error in nm, ignore it. ! if [ $names -ne 0 -a "${os}" != "386bsd" -a "${os}" != "freebsd" -a "${os}" != "bsdi" -a "${os}" != "netbsd" ]; then echo "Couldn't get the name list!" else echo "Done, running function configuration" *************** *** 1316,1329 **** # "newsos" - Sony NEWS # "drsnx" - ICL DRS/NX V4.0 # "epix" - Control Data EP/IX ! # "386bsd" - 386/BSD, FreeBSD and derivatives # "domainosbsd" - HP/Apollo Domain BSD 4.3 # Warning: hpux, pyr are hardcoded in some of the makefiles (sorry) # MAJOR CONFIGURATION # set to one of the above (or configure your own below) EOT ! echo "define([os],[$os])" echo echo "# System call configuration (not for system v compatibilty)" echo "# known: X_GETOPT, X_VPRINTF, X_GETMNT, X_STATFS, X_QUOTA," --- 1406,1422 ---- # "newsos" - Sony NEWS # "drsnx" - ICL DRS/NX V4.0 # "epix" - Control Data EP/IX ! # "386bsd" - 386/BSD and derivatives ! # "netbsd" - NetBSD 1.0 ! # "freebsd" - FreeBSD 2.0 ! # "bsdi" - BSDI BSD/386 1.1 # "domainosbsd" - HP/Apollo Domain BSD 4.3 # Warning: hpux, pyr are hardcoded in some of the makefiles (sorry) # MAJOR CONFIGURATION # set to one of the above (or configure your own below) EOT ! echo "define([os],[[$os]])" echo echo "# System call configuration (not for system v compatibilty)" echo "# known: X_GETOPT, X_VPRINTF, X_GETMNT, X_STATFS, X_QUOTA," *************** *** 1449,1454 **** --- 1542,1553 ---- [define([libafp],concat([-L],libdestdir,[ ],libafp))]) ifelse(os,[solaris], [define([libafpc],concat([-L],libdestdir,[ ],libafpc))]) + ifelse(os,[netbsd], + [define([libcap],concat([-L],libdestdir,[ ],libcap))]) + ifelse(os,[netbsd], + [define([libafp],concat([-L],libdestdir,[ ],libafp))]) + ifelse(os,[netbsd], + [define([libafpc],concat([-L],libdestdir,[ ],libafpc))]) # any special libraries define([libspecial],[]) ifelse(os,[ultrix40],[ *************** *** 1473,1478 **** --- 1572,1583 ---- define([libspecial],concat(libspecial,[ -lc -lsec]))]) ifelse(os,[386bsd],[ define([libspecial],concat(libspecial,[ -lrpc]))]) + ifelse(os,[netbsd],[ + define([libspecial],concat(libspecial,[ -lcrypt]))]) + ifelse(os,[freebsd],[ + define([libspecial],concat(libspecial,[ -lcrypt]))]) + ifelse(os,[bsdi],[ + define([libspecial],concat(libspecial,[ -lrpc -lkvm]))]) ifelse(os,[solaris],[ define([libspecial],concat(libspecial,[ -lsocket -lnsl ]))]) # rutgers specific *************** *** 1610,1616 **** ifelse(os,[newsos],[define([osname],[Sony NEWS])]) ifelse(os,[drsnx],[define([osname],[ICL DRS])]) ifelse(os,[epix],[define([osname],[Control Data EP/IX])]) ! ifelse(os,[386bsd],[define([osname],[386/BSD, FreeBSD etc])]) ifelse(os,[domainosbsd],[define([osname],[HP/Apollo Domain BSD 4.3])]) # define([cflags],ifdef([selfdefinetypes],[-D_TYPES],[])) --- 1715,1724 ---- ifelse(os,[newsos],[define([osname],[Sony NEWS])]) ifelse(os,[drsnx],[define([osname],[ICL DRS])]) ifelse(os,[epix],[define([osname],[Control Data EP/IX])]) ! ifelse(os,[386bsd],[define([osname],[386/BSD etc])]) ! ifelse(os,[netbsd],[define([osname],[NetBSD 1.0])]) ! ifelse(os,[freebsd],[define([osname],[FreeBSD])]) ! ifelse(os,[bsdi],[define([osname],[BSD/386])]) ifelse(os,[domainosbsd],[define([osname],[HP/Apollo Domain BSD 4.3])]) # define([cflags],ifdef([selfdefinetypes],[-D_TYPES],[])) *************** *** 1640,1645 **** --- 1748,1757 ---- define([cflags],concat(cflags,[ -DEPIX]))]) ifelse(os,[osf1],[ define([cflags],concat(cflags,[ -DUSEDIRENT]))]) + ifelse(os,[netbsd],[ + define([cflags],concat(cflags,[ -D__386BSD__]))]) + ifelse(os,[bsdi],[ + define([cflags],concat(cflags,[ -D__386BSD__]))]) # was used for nbp, but found we needed more... leave in case define([nbpflags],[]) *************** *** 1653,1664 **** define([cflags],concat(cflags,[ -n -Daux])) define([lflags],concat(lflags,[ -n]))]) # use the transitional option of the C compiler - interpret as K&R C, not ANSI ifelse(os,[drsnx],[ define([cflags],concat(cflags,[ -Xt -Ddrsnx]))]) # check to see if we need sysvinstall usage ! ifelse(os,[hpux],[define([sysvinstall],[yes])], os,[irix3],[define([sysvinstall],[yes])]) # or if we really want to use install --- 1765,1779 ---- define([cflags],concat(cflags,[ -n -Daux])) define([lflags],concat(lflags,[ -n]))]) + # for NetBSD 1.0 on 68k strip symbols to avoid ld error on some progs + ifelse(os,[netbsd],[define([lflags],concat(lflags,[ -s]))]) + # use the transitional option of the C compiler - interpret as K&R C, not ANSI ifelse(os,[drsnx],[ define([cflags],concat(cflags,[ -Xt -Ddrsnx]))]) # check to see if we need sysvinstall usage ! ifelse(os,[hpux6],[define([sysvinstall],[yes])], os,[irix3],[define([sysvinstall],[yes])]) # or if we really want to use install *** conf.func.sh.orig Mon Oct 10 18:54:23 1994 --- conf.func.sh Thu Jun 29 23:08:00 1995 *************** *** 1,7 **** #!/bin/sh ! # $Author: djh $ $Date: 1994/10/10 08:54:05 $ ! # $Header: /mac/src/cap60/RCS/conf.func.sh,v 2.6 1994/10/10 08:54:05 djh Rel djh $ ! # $Revision: 2.6 $ # # CAP function configuration script. This ain't perfect, but it's a start # execute with /bin/sh Configure if your system won't run it (ksh is okay --- 1,7 ---- #!/bin/sh ! # $Author: djh $ $Date: 1995/06/29 13:07:23 $ ! # $Header: /mac/src/cap60/RCS/conf.func.sh,v 2.8 1995/06/29 13:07:23 djh Rel djh $ ! # $Revision: 2.8 $ # # CAP function configuration script. This ain't perfect, but it's a start # execute with /bin/sh Configure if your system won't run it (ksh is okay *************** *** 102,110 **** gc="$" fi else ! echo "nm output has \"Symbols from\" in it, assuming" ! echo "System V style, will grep for function name followed by space" ! gc=" " fi fi else --- 102,116 ---- gc="$" fi else ! if [ `uname` = "IRIX" -a `uname -r` -ge "5.0" ]; then ! echo "nm output has \"Symbols from\" in it, but it looks like an" ! echo "SGI IRIX system, will grep for function name at end of line" ! gc="$" ! else ! echo "nm output has \"Symbols from\" in it, assuming" ! echo "System V style, will grep for function name followed by space" ! gc=" " ! fi fi fi else *** applications/aufs/afpos.c.orig Tue May 30 17:35:13 1995 --- applications/aufs/afpos.c Mon Jun 26 15:47:49 1995 *************** *** 1,7 **** /* ! * $Author: djh $ $Date: 1994/10/24 06:45:08 $ ! * $Header: /mac/src/cap60/applications/aufs/RCS/afpos.c,v 2.52 1994/10/24 06:45:08 djh Rel djh $ ! * $Revision: 2.52 $ * */ --- 1,7 ---- /* ! * $Author: djh $ $Date: 1995/06/26 05:47:32 $ ! * $Header: /local/mulga/mac/src/cap60/applications/aufs/RCS/afpos.c,v 2.71 1995/06/26 05:47:32 djh Rel djh $ ! * $Revision: 2.71 $ * */ *************** *** 71,77 **** * */ ! #ifdef __386BSD__ #define __BSD_4_4__ #endif /* __386BSD__ */ --- 71,77 ---- * */ ! #if (defined(__386BSD__) || defined(__FreeBSD__)) #define __BSD_4_4__ #endif /* __386BSD__ */ *************** *** 252,257 **** --- 252,272 ---- #include #endif ULTRIX_SECURITY + #ifdef LOG_WTMP + # if defined(sgi) || defined(SOLARIS) + # define LOG_WTMPX + # endif /* sgi || SOLARIS */ + # ifdef LOG_WTMPX + # include + # else /* LOG_WTMPX */ + # include + # endif /* LOG_WTMPX */ + #endif /* LOG_WTMP */ + + #ifdef DISTRIB_PASSWDS + #include + #endif /* DISTRIB_PASSWDS */ + #ifdef MAXBSIZE # define IOBSIZE MAXBSIZE /* set to max buf entry size by if there */ #else MAXBSIZE *************** *** 526,531 **** --- 541,549 ---- logit(0," Configured: reading unknown unix files to get finder information"); logit(0," Configured translation tables are:"); ncs_table_dump(); + #ifdef DISTRIB_PASSWDS + logit(0," Configured: Using Distributed Passwords for authentication"); + #endif DISTRIB_PASSWDS } /* *************** *** 1878,1884 **** --- 1896,1906 ---- struct stat buf; #endif NETWORKTRASH + #ifdef USE_MAC_DATES + if (fdp->fdp_dbitmap & (DP_FINFO|DP_ATTR|DP_PDOS|DP_CDATE|DP_MDATE)) + #else USE_MAC_DATES if (fdp->fdp_dbitmap & (DP_FINFO|DP_ATTR|DP_PDOS)) + #endif USE_MAC_DATES OSSetFA(ipdir,fn,fdp->fdp_dbitmap,fdp); grp = own = -1; *************** *** 2474,2480 **** #endif USEQUOTA #ifdef USEBSDQUOTA { ! char *fsname,*find_mount_spec(); if ((fsname = find_mount_spec(buf.st_dev)) == NULL) { errno = EPERM; return(-1); --- 2496,2503 ---- #endif USEQUOTA #ifdef USEBSDQUOTA { ! char *fsname; ! private char *find_mount_spec(); if ((fsname = find_mount_spec(buf.st_dev)) == NULL) { errno = EPERM; return(-1); *************** *** 2523,2529 **** } # else /* sgi || apollo */ if (statfs(path, &fsbuf) >= 0) { ! #if defined(__386BSD__) || defined(__osf__) /* * on 386/BSD, the block size is in f_fsize * and f_bsize is the optimum transfer size --- 2546,2552 ---- } # else /* sgi || apollo */ if (statfs(path, &fsbuf) >= 0) { ! #if (defined(__386BSD__) && !defined(__NetBSD__)) || defined(__osf__) /* * on 386/BSD, the block size is in f_fsize * and f_bsize is the optimum transfer size *************** *** 2687,2693 **** struct dqblk *dq; { int fd, res; ! struct quotactl qctl; switch (cmd) { case Q_GETQUOTA: /* let it be "read-only" */ --- 2710,2716 ---- struct dqblk *dq; { int fd, res; ! struct quotctl qctl; switch (cmd) { case Q_GETQUOTA: /* let it be "read-only" */ *************** *** 2977,2982 **** --- 3000,3006 ---- caddr_t addr; { char *fsname; + private char *find_mount_spec(); switch (cmd) { case Q_QUOTAON: *************** *** 3305,3310 **** --- 3329,3339 ---- } #endif DENYREADWRITE + if (i == noErr) { + attr |= ((typ == F_DATA) ? FPA_DAO : FPA_RAO); + OSSetAttr(pdir, file, attr); + } + return(i); } *************** *** 3351,3364 **** return(apasswdfile); } export OSErr OSLoginRand(nam) char *nam; { if (is_aufs_user(nam)) return(noErr); ! return(aeParamErr); } #ifdef PERMISSIVE_USER_NAME --- 3380,3429 ---- return(apasswdfile); } + /* + * check if user exists + * + * IE: check if user in file specified with -P option + * (not fatal if no file specified for DISTRIB_PASSWDS) + * + */ export OSErr OSLoginRand(nam) char *nam; { + OSErr err = aeParamErr; + + #ifdef DISTRIB_PASSWDS + char *cp, line[80]; + FILE *fp, *fopen(); + extern char *distribpassfile; + if (distribpassfile == NULL) + return(noErr); + if ((fp = fopen(distribpassfile, "r")) == NULL) + return(noErr); + err = aeUserNotAuth; + while (fgets(line, sizeof(line), fp) != NULL) { + if (line[0] == '#') + continue; + for (cp = line; *cp != '\0'; cp++) { + if (*cp == ' ' || *cp == '\t' || *cp == '\n') { + *cp = '\0'; + break; + } + } + if (strcmp(nam, line) == 0) { + err = noErr; + break; + } + } + fclose(fp); + #else /* DISTRIB_PASSWDS */ if (is_aufs_user(nam)) return(noErr); ! #endif /* DISTRIB_PASSWDS */ ! ! return(err); } #ifdef PERMISSIVE_USER_NAME *************** *** 3456,3461 **** --- 3521,3535 ---- } #endif PERMISSIVE_USER_NAME + #ifdef DISTRIB_PASSWDS + struct afppass *afp = NULL; + #endif /* DISTRIB_PASSWDS */ + + /* + * validate user 'nam' using User Authentication Method 'uam' + * + */ + export OSErr OSLogin(nam,pwd,pwdother,uam) char *nam,*pwd; *************** *** 3483,3488 **** --- 3557,3568 ---- #ifdef RUTGERS extern char *ru_crypt(); #endif RUTGERS + #ifdef DISTRIB_PASSWDS + OSErr err; + void afpdp_encr(); + int afpdp_init(), afpdp_writ(); + struct afppass afpp, *afpdp_read(); + #endif /* DISTRIB_PASSWDS */ extern int nousrvol; safedebug = (DBOSI || (getuid() != 0 && geteuid() != 0)); *************** *** 3503,3508 **** --- 3583,3593 ---- switch (uam) { case UAM_RANDNUM: + #ifndef DISTRIB_PASSWDS + /* + * 'Randnum Exchange' UAM using lookaside password file + * + */ if (!apasswdfile) return(aeBadUAM); if ((pass = user_aufs_passwd(nam)) == NULL) { *************** *** 3537,3543 **** --- 3622,3682 ---- usrdir = (char *)malloc(strlen(p->pw_dir)+1); strcpy(usrdir,p->pw_dir); break; + #else /* DISTRIB_PASSWDS */ + case UAM_2WAYRAND: + /* + * 'Randnum Exchange' or '2-Way Randnum exchange' + * UAM using distributed passwords (in ~/.afppass) + * + */ + err = aeUserNotAuth; + if ((p = (struct passwd *)getpwnam(nam)) != NILPWD) { + if (afpdp_init(AFP_DISTPW_FILE) >= 0) { + if ((afp = afpdp_read(nam, p->pw_uid, p->pw_dir)) != NULL) { + bcopy(pwdother, encrypted, sizeof(encrypted)); + if (uam == UAM_RANDNUM) { + desinit(0); + dessetkey(afp->afp_password); + endes(encrypted); + desdone(); + } else /* use key-shifted DES code */ + afpdp_encr(encrypted, afp->afp_password, NULL); + /* compare encrytpted passwords */ + if (bcmp(encrypted, pwd, 8) == 0) + err = noErr; + /* enforce & count failed login attempts */ + if (afp->afp_numattempt >= afp->afp_maxattempt + && afp->afp_maxattempt > 0) + err = aeParamErr; + if (err != noErr) { + if (afp->afp_numattempt < 255) + afp->afp_numattempt++; + } else + afp->afp_numattempt = 0; + /* update user password file (using copy of structure) */ + bcopy((char *)afp, (char *)&afpp, sizeof(struct afppass)); + (void)afpdp_writ(nam, p->pw_uid, p->pw_dir, &afpp); + } + } + } + if (err != noErr) { + logit(0, "Login failed for %s (%s)", nam, afperr(err)); + return(err); + } + /* save details */ + usrgid = p->pw_gid; + usruid = p->pw_uid; + usrnam = (char *)malloc(strlen(p->pw_name)+1); + strcpy(usrnam,p->pw_name); + usrdir = (char *)malloc(strlen(p->pw_dir)+1); + strcpy(usrdir,p->pw_dir); + break; + #endif /* DISTRIB_PASSWDS */ case UAM_ANON: + /* + * 'No User Authent' UAM + * + */ if (guestname == NULL) return(aeParamErr); p = (struct passwd *)getpwnam(guestname); *************** *** 3553,3558 **** --- 3692,3701 ---- usrdir = NULL; break; case UAM_CLEAR: + /* + * 'Cleartxt Passwrd' UAM + * + */ if (!apasswdfile) { p = (struct passwd *)getpwnam(nam); /* user name */ if (p == NILPWD) { *************** *** 3625,3631 **** if (strcmp(pass,pwd) != 0) return(aeUserNotAuth); } - usrgid = p->pw_gid; usruid = p->pw_uid; usrnam = (char *)malloc(strlen(p->pw_name)+1); --- 3768,3773 ---- *************** *** 3635,3640 **** --- 3777,3866 ---- break; } + #ifdef ADMIN_GRP + if (uam != UAM_ANON) { + struct group *grps; + if ((grps = getgrnam(ADMIN_GRP)) != NULL) { + while (grps->gr_mem != NULL) { + if (strcmp(p->pw_name, *grps->gr_mem) == 0) { + logit(0, "User %s has admin privs, logging in as superuser.", + p->pw_name); + p->pw_gid = grps->gr_gid; + p->pw_uid = 0; + break; + } + grps->gr_mem++; + } + } + } + #endif /* ADMIN_GRP */ + + #ifdef LOG_WTMP + /* + * write a 'wtmp' entry for user name, address & time (then we + * write a null entry to terminate, since wtmp is often set to + * mode 0644 and we're not running as root when we disconnect). + * + * This is unduly complex for the end result + * + */ + #ifdef LOG_WTMPX + # ifdef WTMPX_FILE + # undef WTMP_FILE + # define WTMP_FILE WTMPX_FILE + # define ut_time ut_xtime + # define utmp utmpx + # endif /* WTMPX_FILE */ + #endif /* LOG_WTMPX */ + { extern AddrBlock addr; + struct utmp ut; + int fd; + + bzero((char *)&ut, sizeof(struct utmp)); + + #if defined(WTMP_FILE) && defined(USER_PROCESS) + # define utusername ut.ut_user + ut.ut_type = USER_PROCESS; + ut.ut_id[0] = 'a'; + ut.ut_id[1] = 'f'; + ut.ut_id[2] = 'p'; + ut.ut_id[3] = '\0'; + #else /* WTMP_FILE && USER_PROCESS */ + # define utusername ut.ut_name + # ifdef _PATH_WTMP + # define WTMP_FILE _PATH_WTMP + # else /* _PATH_WTMP */ + # define WTMP_FILE "/var/adm/wtmp" + # endif /* _PATH_WTMP */ + #endif /* WTMP_FILE && USER_PROCESS */ + + #ifdef LOG_WTMP_FILE + #undef WTMP_FILE + #define WTMP_FILE LOG_WTMP_FILE + #endif /* LOG_WTMP_FILE */ + + (void)sprintf(ut.ut_host, "%d.%d.%d", + ntohs(addr.net), addr.node, addr.skt); + (void)strncpy(ut.ut_line, "aufs", sizeof(ut.ut_line)); + (void)strncpy(utusername, usrnam, sizeof(utusername)); + ut.ut_time = time((time_t *)0); + #ifdef LOG_WTMPX + (void)updwtmpx(WTMP_FILE, &ut); + ut.ut_host[0] = '\0'; /* null hostname */ + utusername[0] = '\0'; /* null username */ + (void)updwtmpx(WTMP_FILE, &ut); + #else /* LOG_WTMPX */ + if ((fd = open(WTMP_FILE, O_WRONLY|O_APPEND, 0)) >= 0) { + (void)write(fd, (char *)&ut, sizeof(struct utmp)); + ut.ut_host[0] = '\0'; /* null hostname */ + utusername[0] = '\0'; /* null username */ + (void)write(fd, (char *)&ut, sizeof(struct utmp)); + (void)close(fd); + } + #endif /* LOG_WTMPX */ + } + #endif /* LOG_WTMP */ + #ifdef LWSRV_AUFS_SECURITY /* budd... */ if( userlogindir != NULL ) { /* need to save user logins? */ *************** *** 3721,3742 **** } /* ! * change password. * ! * nice idea, but not really workable right now. ! * best we could do is fork passwd ! * AFP2.0 ! * ! */ OSChangePassword(nam, pwdold, pwdnew, uam) char *nam; byte *pwdold; byte *pwdnew; int uam; { ! if (uam != UAM_CLEAR) ! return(aeBadUAM); ! return(aeCallNotSupported); } /* --- 3947,4015 ---- } /* ! * change user password. * ! */ ! OSChangePassword(nam, pwdold, pwdnew, uam) char *nam; byte *pwdold; byte *pwdnew; int uam; { ! switch (uam) { ! case UAM_CLEAR: ! case UAM_2WAYRAND: ! return(aeBadUAM); ! break; ! case UAM_RANDNUM: ! #ifdef DISTRIB_PASSWDS ! { struct passwd *p; ! struct afppass *afpdp_read(); ! int afpdp_writ(), afpdp_pwex(); ! void afpdp_decr(), afpdp_upex(); ! ! /* must be an existing UNIX user */ ! if ((p = (struct passwd *)getpwnam(nam)) == NILPWD) ! return(aeUserNotAuth); ! /* grab user password details */ ! if ((afp = afpdp_read(nam, p->pw_uid, p->pw_dir)) == NULL) ! return(aeUserNotAuth); ! /* enforce different passwords */ ! if (bcmp(pwdold, pwdnew, 8) == 0) ! return(aePwdSameErr); ! desinit(0); ! /* use current password to decrypt new */ ! dessetkey(afp->afp_password); ! dedes(pwdnew); ! /* use new password to decrypt old */ ! dessetkey(pwdnew); ! dedes(pwdold); ! desdone(); ! /* old password OK ? */ ! if (strcmp((char *)afp->afp_password, (char *)pwdold) != 0) ! return(aeUserNotAuth); ! /* enforce password length control */ ! if (strlen((char *)pwdnew) < afp->afp_minmpwlen) ! return(aePwdTooShort); ! /* global expiry date, user changes not allowed */ ! if (afpdp_pwex(afp) < 0) ! return(aeAccessDenied); ! /* update structure & write */ ! afpdp_upex(afp); ! afp->afp_numattempt = 0; ! bcopy((char *)pwdnew, (char *)afp->afp_password, 8); ! if (afpdp_writ(nam, p->pw_uid, p->pw_dir, afp) < 0) ! return(aeUserNotAuth); ! return(noErr); ! } ! #else /* DISTRIB_PASSWDS */ ! return(aeBadUAM); ! #endif /* DISTRIB_PASSWDS */ ! break; ! } ! ! return(aeBadUAM); } /* *************** *** 4111,4117 **** for (dinfp = readdir(dptr); dinfp != NULL; dinfp = readdir(dptr)) { if (*dinfp->d_name == '.') { int namlen; ! #ifdef USEDIRENT namlen = dinfp->d_namlen; #else /* USEDIRENT */ namlen = strlen(dinfp->d_name); --- 4384,4390 ---- for (dinfp = readdir(dptr); dinfp != NULL; dinfp = readdir(dptr)) { if (*dinfp->d_name == '.') { int namlen; ! #if defined(USEDIRENT) && !defined(SOLARIS) namlen = dinfp->d_namlen; #else /* USEDIRENT */ namlen = strlen(dinfp->d_name); *************** *** 4453,4459 **** --- 4726,4734 ---- private char * syserr() { + #if !(defined(__FreeBSD__) || defined(__NetBSD__)) extern char *sys_errlist[]; + #endif extern int sys_nerr; static char buf[50]; int serrno; *** applications/lwsrv/lwsrv.c.orig Mon Oct 24 16:45:49 1994 --- applications/lwsrv/lwsrv.c Thu Jun 1 20:14:20 1995 *************** *** 1,6 **** ! static char rcsid[] = "$Author: djh $ $Date: 1994/10/24 06:45:41 $"; ! static char rcsident[] = "$Header: /mac/src/cap60/applications/lwsrv/RCS/lwsrv.c,v 2.34 1994/10/24 06:45:41 djh Rel djh $"; ! static char revision[] = "$Revision: 2.34 $"; /* * lwsrv - UNIX AppleTalk spooling program: act as a laserwriter --- 1,6 ---- ! static char rcsid[] = "$Author: djh $ $Date: 1995/06/01 10:14:02 $"; ! static char rcsident[] = "$Header: /mac/src/cap60/applications/lwsrv/RCS/lwsrv.c,v 2.36 1995/06/01 10:14:02 djh Rel djh $"; ! static char revision[] = "$Revision: 2.36 $"; /* * lwsrv - UNIX AppleTalk spooling program: act as a laserwriter *************** *** 139,145 **** #endif USESYSVLP #ifndef LPRCMD ! # ifdef xenix5 # define LPRCMD "/usr/bin/lpr" # else xenix5 # define LPRCMD "/usr/ucb/lpr" --- 139,145 ---- #endif USESYSVLP #ifndef LPRCMD ! # if defined(xenix5) || defined(__FreeBSD__) # define LPRCMD "/usr/bin/lpr" # else xenix5 # define LPRCMD "/usr/ucb/lpr" *************** *** 1108,1116 **** --- 1108,1118 ---- #endif xenix5 if (rhbuf[1] != '\0') childargv[argc++]=rhbuf; /* include h and/or r flags */ + #ifdef USELPRSYM #ifndef USESYSVLP childargv[argc++]="-s"; /* better for > 1M files */ #endif USESYSVLP + #endif USELPRSYM #ifdef LPRARGS while(*lprargs) childargv[argc++] = *lprargs++; *** contrib/lwrename.c.orig Wed Feb 16 18:18:44 1994 --- contrib/lwrename.c Mon May 29 20:45:18 1995 *************** *** 303,309 **** * Fill in fields for this element of linked list of printers. * */ ! lp->passwd = isnumber(buf) ? newstring(buf) : newpsstring(buf); /* * Look for third optional new type field, and make sure it is not null. --- 303,309 ---- * Fill in fields for this element of linked list of printers. * */ ! lp->passwd = is_it_a_number(buf) ? newstring(buf) : newpsstring(buf); /* * Look for third optional new type field, and make sure it is not null. *************** *** 648,654 **** return(newstring(buf)); } ! isnumber(str) register char *str; { while (*str) { --- 648,654 ---- return(newstring(buf)); } ! is_it_a_number(str) register char *str; { while (*str) { *** lib/cap/ablog.c.orig Tue Sep 28 18:25:12 1993 --- lib/cap/ablog.c Mon May 29 20:45:26 1995 *************** *** 1,6 **** ! static char rcsid[] = "$Author: djh $ $Date: 1993/09/28 08:24:19 $"; ! static char rcsident[] = "$Header: /mac/src/cap60/lib/cap/RCS/ablog.c,v 2.4 1993/09/28 08:24:19 djh Rel djh $"; ! static char revision[] = "$Revision: 2.4 $"; /* * ablog.c - simple logging facility --- 1,6 ---- ! static char rcsid[] = "$Author: djh $ $Date: 1995/05/29 10:45:18 $"; ! static char rcsident[] = "$Header: /mac/src/cap60/lib/cap/RCS/ablog.c,v 2.5 1995/05/29 10:45:18 djh Rel djh $"; ! static char revision[] = "$Revision: 2.5 $"; /* * ablog.c - simple logging facility *************** *** 92,98 **** --- 92,100 ---- int saveerr; extern int errno; extern int sys_nerr; + #ifndef __FreeBSD__ extern char *sys_errlist[]; + #endif if (lfp == NULL) /* no logging? */ return; *** support/ethertalk/aarpd.c.orig Mon May 29 20:36:00 1995 --- support/ethertalk/aarpd.c Wed May 31 17:34:18 1995 *************** *** 16,40 **** #include #ifdef PHASE2 #include ! #if !defined(ultrix) && !defined(__osf__) && !defined(__386BSD__) #include ! #endif /* ultrix && __osf__ && __386BSD__ */ #include #endif PHASE2 #include #include #include ! #if defined(__386BSD__) || defined(SOLARIS) #ifdef SOLARIS #define PORTMAP #endif SOLARIS #include ! #include ! #else /* __386BSD__ or SOLARIS */ #include #include #include ! #endif /* __386BSD__ */ #include "../uab/ethertalk.h" /* iso: level 1 */ #include "../uab/if_desc.h" #include "../uab/log.h" --- 16,41 ---- #include #ifdef PHASE2 #include ! #if !defined(ultrix) && !defined(__osf__) && !defined(__386BSD__) && !defined(__FreeBSD__) && !defined(__bsdi__) #include ! #endif /* ultrix && __osf__ && __386BSD__ && __FreeBSD__ */ #include #endif PHASE2 #include #include + #include #include ! ! #if (defined(__386BSD__) || defined(SOLARIS) || defined(__FreeBSD__)) && !defined(__bsdi__) #ifdef SOLARIS #define PORTMAP #endif SOLARIS #include ! #else /* __386BSD__ or SOLARIS or __FreeBSD__ */ #include #include #include ! #endif /* __386BSD__ or SOLARIS or __FreeBSD__ */ #include "../uab/ethertalk.h" /* iso: level 1 */ #include "../uab/if_desc.h" #include "../uab/log.h" *** support/ethertalk/abelap.c.orig Mon Oct 24 16:43:08 1994 --- support/ethertalk/abelap.c Mon May 29 20:45:36 1995 *************** *** 1,7 **** /* ! * $Author: djh $ $Date: 1994/10/24 06:43:01 $ ! * $Header: /mac/src/cap60/support/ethertalk/RCS/abelap.c,v 2.10 1994/10/24 06:43:01 djh Rel djh $ ! * $Revision: 2.10 $ */ /* --- 1,7 ---- /* ! * $Author: djh $ $Date: 1995/05/29 10:45:33 $ ! * $Header: /mac/src/cap60/support/ethertalk/RCS/abelap.c,v 2.11 1995/05/29 10:45:33 djh Rel djh $ ! * $Revision: 2.11 $ */ /* *************** *** 538,544 **** msg.msg_namelen = sizeof(from_sin); msg.msg_iov = iov; msg.msg_iovlen = iovlen; ! #ifdef __386BSD__ msg.msg_control = 0; msg.msg_controllen = 0; msg.msg_flags = 0; --- 538,544 ---- msg.msg_namelen = sizeof(from_sin); msg.msg_iov = iov; msg.msg_iovlen = iovlen; ! #if defined(__386BSD__) || defined(__FreeBSD__) msg.msg_control = 0; msg.msg_controllen = 0; msg.msg_flags = 0; *************** *** 768,774 **** msg.msg_namelen = sizeof(abfsin); msg.msg_iov = iov; msg.msg_iovlen = iovlen; ! #ifdef __386BSD__ msg.msg_control = 0; msg.msg_controllen = 0; msg.msg_flags = 0; --- 768,774 ---- msg.msg_namelen = sizeof(abfsin); msg.msg_iov = iov; msg.msg_iovlen = iovlen; ! #if defined(__386BSD__) || defined(__FreeBSD__) msg.msg_control = 0; msg.msg_controllen = 0; msg.msg_flags = 0; *** support/ethertalk/bpfiltp.c.orig Mon May 29 20:36:06 1995 --- support/ethertalk/bpfiltp.c Wed Jun 28 23:39:38 1995 *************** *** 1,6 **** ! static char rcsid[] = "$Author: djh $ $Date: 1993/11/22 10:16:53 $"; ! static char rcsident[] = "$Header: /mac/src/cap60/support/ethertalk/RCS/bpfiltp.c,v 2.1 1993/11/22 10:16:53 djh Rel djh $"; ! static char revision[] = "$Revision: 2.1 $"; /* * bpfiltp.c - Simple "protocol" level interface to BPF --- 1,6 ---- ! static char rcsid[] = "$Author: djh $ $Date: 1995/06/28 13:39:17 $"; ! static char rcsident[] = "$Header: /mac/src/cap60/support/ethertalk/RCS/bpfiltp.c,v 2.6 1995/06/28 13:39:17 djh Rel djh $"; ! static char revision[] = "$Revision: 2.6 $"; /* * bpfiltp.c - Simple "protocol" level interface to BPF *************** *** 25,31 **** * June 1991 Rakesh Patel/David Hornsby Add Phase 2 support * Oct 1993 David Matthews. Modified for Berkley Packet Filter * ! */ static char columbia_copyright[] = "Copyright (c) 1988 by The Trustees of \ Columbia University in the City of New York"; --- 25,31 ---- * June 1991 Rakesh Patel/David Hornsby Add Phase 2 support * Oct 1993 David Matthews. Modified for Berkley Packet Filter * ! */ static char columbia_copyright[] = "Copyright (c) 1988 by The Trustees of \ Columbia University in the City of New York"; *************** *** 49,54 **** --- 49,70 ---- #include #include "../uab/proto_intf.h" + #ifdef bsdi + #include + #define MULTI_BPF_PKT + #define USE_SIOCGIFCONF + #endif bsdi + + #ifdef __NetBSD__ + #define MULTI_BPF_PKT + #define USE_SIOCGIFCONF + #endif __NetBSD__ + + #ifdef USE_SIOCGIFCONF + #include + #include + #endif USE_SIOCGIFCONF + typedef struct ephandle { /* ethernet protocol driver handle */ int inuse; /* true if inuse */ int fd; /* file descriptor of socket */ *************** *** 101,106 **** --- 117,123 ---- char *dev; int devno; { + private int init_nit(); struct ephandle *eph; char devnamebuf[100]; /* room for device name */ int s; *************** *** 163,168 **** --- 180,186 ---- u_long if_flags; u_int imm; struct bpf_version vers; + private int setup_pf(); { register int i; *************** *** 215,221 **** return(-1); } ! read_buf = malloc(pf_bufsize); if (ioctl(s, BIOCSETIF, ifr) < 0) { perror("ioctl: set interface"); --- 233,239 ---- return(-1); } ! read_buf = (char *)malloc(pf_bufsize); if (ioctl(s, BIOCSETIF, ifr) < 0) { perror("ioctl: set interface"); *************** *** 234,242 **** #ifdef PHASE2 /* * add a multicast address to the interface - * - * This hasn't been tested because multicast addresses don't - * work in FreeBSD Release 1.0. */ int pi_addmulti(multi, ifr) --- 252,257 ---- *************** *** 389,394 **** --- 404,453 ---- return(-1); eph = &ephlist[edx-1]; + + #ifdef USE_SIOCGIFCONF + { + int len, sock; + struct ifconf ifconf; + struct sockaddr_dl *sadl; + struct ifreq ifrbuf[32], *ifra, *ifrb; + + ifconf.ifc_len = sizeof(ifrbuf); + ifconf.ifc_buf = (caddr_t)ifrbuf; + + if ((sock = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { + perror("SOCK_DGRAM"); + return(-1); + } + if (ioctl(sock, SIOCGIFCONF, &ifconf) < 0) { + perror("SIOCGIFCONF"); + close(sock); + return(-1); + } + close(sock); + ifra = ifrbuf; + ifrb = (struct ifreq *)((char *)ifra + ifconf.ifc_len); + while (ifra < ifrb) { + if (strcmp(eph->ifr.ifr_name, ifra->ifr_name) == 0) { + if (ifra->ifr_addr.sa_family == AF_LINK) { + sadl = (struct sockaddr_dl *)&ifra->ifr_addr; + if (sadl->sdl_type == IFT_ETHER) { + bcopy((char *)LLADDR(sadl), ea, 6); + return(0); + } + #ifdef bsdi + if (sadl->sdl_alen == 0) /* no addr, try other method */ + return(get_eth_addr(eph->fd, eph->ifr.ifr_name, ea)); + #endif bsdi + } + } + if ((len = ifra->ifr_addr.sa_len+sizeof(ifra->ifr_name)) < sizeof(*ifra)) + len = sizeof(*ifra); + ifra = (struct ifreq *)((char *)ifra + len); + } + } + return(-1); + #else USE_SIOCGIFCONF if (ioctl(eph->fd, SIOCGIFADDR, &eph->ifr) < 0) { perror("Ioctl: SIOCGIFADDR"); return(-1); *************** *** 396,401 **** --- 455,461 ---- sa = (struct sockaddr *)&eph->ifr.ifr_data; bcopy(sa->sa_data, ea, 6); return(0); + #endif USE_SIOCGIFCONF } export *************** *** 423,428 **** --- 483,505 ---- fdlistener(ephlist[edx-1].fd, listener, arg1, arg2); } + /* + * Note: BPF can return multiple packets in one read + * + */ + + #ifdef MULTI_BPF_PKT + #define NUMRDS 32 + + struct RDS { + u_short dataLen; + u_char *dataPtr; + }; + + struct RDS RDS[NUMRDS]; + export int read_buf_len = 0; + #endif /* MULTI_BPF_PKT */ + static int bp_readv(fd, iov, iovlen) int fd; *************** *** 433,438 **** --- 510,558 ---- struct bpf_hdr *bp; char *p; int i, size; + + #ifdef MULTI_BPF_PKT + static int rds_index; + char *q; + + if (read_buf_len == 0) { + /* Must read exactly the buffer size. */ + if ((cc = read(fd, read_buf, pf_bufsize)) < 0) + return(cc); + /* fill in RDS */ + p = read_buf; + q = read_buf+cc; + read_buf_len = cc; + for (i = 0; i < (NUMRDS-1) && p < q; i++) { + bp = (struct bpf_hdr *)p; + RDS[i].dataLen = bp->bh_caplen; + RDS[i].dataPtr = (u_char *)(p + bp->bh_hdrlen); + p += BPF_WORDALIGN(bp->bh_hdrlen+bp->bh_caplen); + } + RDS[i].dataLen = 0; + rds_index = 0; + } + if ((size = (int)RDS[rds_index].dataLen) == 0) { + read_buf_len = 0; + return(0); + } + p = (char *)RDS[rds_index].dataPtr; + for (i = 0; i < iovlen && size > 0; i++) { + if (size < iov[i].iov_len) + cc = size; + else + cc = iov[i].iov_len; + bcopy(p, iov[i].iov_base, cc); + p += cc; + size -= cc; + } + cc = RDS[rds_index].dataLen; + if (size > 0) + cc -= size; + rds_index++; + read_buf_len = RDS[rds_index].dataLen; + return(cc); + #else /* MULTI_BPF_PKT */ /* Must read exactly the buffer size. */ if ((cc = read(fd, read_buf, pf_bufsize)) < 0) { return(cc); *************** *** 449,454 **** --- 569,575 ---- } if (size > 0) return (bp->bh_caplen-size); else return bp->bh_caplen; + #endif /* MULTI_BPF_PKT */ } *************** *** 583,589 **** --- 704,715 ---- bcopy(eaddr, &eh.ether_dhost, 6); #ifdef PHASE2 + #ifdef __FreeBSD__ + /* This should really be fixed in the kernel. */ + eh.ether_type = buflen; + #else eh.ether_type = htons(buflen); + #endif /* * Fill in the remainder of the 802.2 and SNAP header bytes. * Clients have to leave 8 bytes free at the start of buf as *************** *** 599,605 **** --- 725,736 ---- *q++ = (eph->protocol >> 8) & 0xff; *q++ = (eph->protocol & 0xff); #else PHASE2 + #ifdef __FreeBSD__ + /* This should really be fixed in the kernel. */ + eh.ether_type = eph->protocol; + #else eh.ether_type = htons(eph->protocol); + #endif #endif PHASE2 if (writev(eph->fd, iov, 2) < 0) { *************** *** 638,640 **** --- 769,877 ---- } return(pi_write(edx, ebuf, len, eaddr)); } + + #ifdef bsdi + /* + * lifted from UAR pf.c + * + */ + + struct nlist nlst[] = { + { "_ifnet" }, + "", + }; + + /* + * BSDI + * + * Get interface address from the kernel since the SIOCGIFADDR + * ioctl isn't implemented in a number of ethernet drivers. + * + */ + + int + get_eth_addr(s, interface, addr) + int s; + char *interface; + u_char *addr; + { + kvm_t *kvmd; + int err = -1; + off_t ifnetptr; + off_t aifnetptr; + off_t ifaddrptr; + struct sockaddr sa; + struct ifnet ifnet; + struct ifaddr ifaddr; + struct arpcom arpcom; + struct sockaddr_dl *sdl; + char *cp, if_name[16]; + + if ((kvmd = kvm_open(NULL, NULL, NULL, O_RDONLY, NULL)) == NULL) { + fprintf(stderr, "kvm_open: can't open kernel!\n"); + return(-1); + } + if (kvm_nlist(kvmd, nlst) < 0 || nlst[0].n_type == 0) { + fprintf(stderr, "kvm_list: can't find namelist!\n"); + kvm_close(kvmd); + return(-1); + } + if (nlst[0].n_value == 0) { + fprintf(stderr, "kvm_list: _ifnet symbol not defined!\n"); + kvm_close(kvmd); + return(-1); + } + if (kvm_read(kvmd, nlst[0].n_value, (char *)&ifnetptr, + sizeof(ifnetptr)) != sizeof(ifnetptr)) { + fprintf(stderr, "kvm_read: bogus read!\n"); + kvm_close(kvmd); + return(-1); + } + while (ifnetptr) { + aifnetptr = ifnetptr; + if (kvm_read(kvmd, ifnetptr, (char *)&ifnet, + sizeof(ifnet)) == sizeof(ifnet)) { + if (kvm_read(kvmd, (off_t)ifnet.if_name, if_name, + sizeof(if_name)) == sizeof(if_name)) { + ifnetptr = (off_t)ifnet.if_next; + if_name[15] = '\0'; + cp = (char *)index(if_name, '\0'); + sprintf(cp, "%d", ifnet.if_unit); + if (strcmp(if_name, interface) != 0) + continue; + ifaddrptr = (off_t)ifnet.if_addrlist; + while (ifaddrptr) { + if (kvm_read(kvmd, ifaddrptr, (char *)&ifaddr, + sizeof(ifaddr)) == sizeof(ifaddr)) { + ifaddrptr = (off_t)ifaddr.ifa_next; + if (kvm_read(kvmd, (off_t)ifaddr.ifa_addr, (char *)&sa, + sizeof(sa)) == sizeof(sa)) { + if (sa.sa_family == AF_LINK) { + sdl = (struct sockaddr_dl *)&sa; + cp = (char *)LLADDR(sdl); + if (sdl->sdl_alen == 0) { + /* no address here, try ethernet driver */ + if (kvm_read(kvmd, aifnetptr, (char *)&arpcom, + sizeof(arpcom)) == sizeof(arpcom)) + cp = (char *)arpcom.ac_enaddr; + } + bcopy(cp, (char *)addr, 6); + fprintf(stderr, "BSDI: %-5s eth address %x:%x:%x:%x:%x:%x\n", + interface, addr[0], addr[1], addr[2], + addr[3], addr[4], addr[5]); + err = 0; + break; + } + continue; + } + } + break; + } + } + } + break; + } + kvm_close(kvmd); + return(err); + } + #endif bsdi *** support/uab/asyncatalk.c.orig Mon Nov 22 21:12:41 1993 --- support/uab/asyncatalk.c Mon May 29 20:45:44 1995 *************** *** 192,198 **** if(id->id_zone != NULL) strncpy(async_zone, id->id_zone+1, *id->id_zone); ! #ifdef __386BSD__ if((ah->ah_skt = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { #else /* __386BSD__ */ if((ah->ah_skt = socket(AF_INET, SOCK_DGRAM, 0, 0)) < 0) { --- 192,198 ---- if(id->id_zone != NULL) strncpy(async_zone, id->id_zone+1, *id->id_zone); ! #if (defined(__386BSD__) || defined(__FreeBSD__)) if((ah->ah_skt = socket(AF_INET, SOCK_DGRAM, 0)) < 0) { #else /* __386BSD__ */ if((ah->ah_skt = socket(AF_INET, SOCK_DGRAM, 0, 0)) < 0) { *** support/uab/bpfiltp.c.orig Mon Nov 22 21:34:21 1993 --- support/uab/bpfiltp.c Mon May 29 20:45:49 1995 *************** *** 1,6 **** ! static char rcsid[] = "$Author: djh $ $Date: 1993/11/22 10:20:06 $"; ! static char rcsident[] = "$Header: /mac/src/cap60/support/uab/RCS/bpfiltp.c,v 2.1 1993/11/22 10:20:06 djh Rel djh $"; ! static char revision[] = "$Revision: 2.1 $"; /* * bpfiltp.c - Simple "protocol" level interface to BPF --- 1,6 ---- ! static char rcsid[] = "$Author: djh $ $Date: 1995/05/29 10:45:45 $"; ! static char rcsident[] = "$Header: /mac/src/cap60/support/uab/RCS/bpfiltp.c,v 2.2 1995/05/29 10:45:45 djh Rel djh $"; ! static char revision[] = "$Revision: 2.2 $"; /* * bpfiltp.c - Simple "protocol" level interface to BPF *************** *** 409,415 **** --- 409,420 ---- return(-1); bcopy(eaddr, &eh.ether_dhost, 6); + #ifdef __FreeBSD__ + /* This should really be fixed in the kernel packet filter code. */ + eh.ether_type = eph->protocol; + #else eh.ether_type = htons(eph->protocol); + #endif if (writev(eph->socket, iov, 2) < 0) { return(-1); *** support/uab/kip_mpx.c.orig Mon Nov 22 21:03:03 1993 --- support/uab/kip_mpx.c Mon May 29 20:46:04 1995 *************** *** 1,6 **** ! static char rcsid[] = "$Author: djh $ $Date: 1993/11/22 10:02:49 $"; ! static char rcsident[] = "$Header: /mac/src/cap60/support/uab/RCS/kip_mpx.c,v 2.5 1993/11/22 10:02:49 djh Rel djh $"; ! static char revision[] = "$Revision: 2.5 $"; /* * kip_mpx.c - talks to cap processes via udp --- 1,6 ---- ! static char rcsid[] = "$Author: djh $ $Date: 1995/05/29 10:45:50 $"; ! static char rcsident[] = "$Header: /mac/src/cap60/support/uab/RCS/kip_mpx.c,v 2.6 1995/05/29 10:45:50 djh Rel djh $"; ! static char revision[] = "$Revision: 2.6 $"; /* * kip_mpx.c - talks to cap processes via udp *************** *** 169,175 **** msg.msg_namelen = sizeof(from_sin); msg.msg_iov = iov; msg.msg_iovlen = 3; ! #ifdef __386BSD__ msg.msg_control = 0; msg.msg_controllen = 0; msg.msg_flags = 0; --- 169,175 ---- msg.msg_namelen = sizeof(from_sin); msg.msg_iov = iov; msg.msg_iovlen = 3; ! #if (defined(__386BSD__) || defined(__FreeBSD__)) msg.msg_control = 0; msg.msg_controllen = 0; msg.msg_flags = 0; *************** *** 385,391 **** msg.msg_namelen = sizeof(k->sin); msg.msg_iov = iov; msg.msg_iovlen = 3; ! #ifdef __386BSD__ msg.msg_control = 0; msg.msg_controllen = 0; msg.msg_flags = 0; --- 385,391 ---- msg.msg_namelen = sizeof(k->sin); msg.msg_iov = iov; msg.msg_iovlen = 3; ! #if (defined(__386BSD__) || defined(__FreeBSD__)) msg.msg_control = 0; msg.msg_controllen = 0; msg.msg_flags = 0; *** applications/papif/papif.c.orig Mon Oct 24 16:46:10 1994 --- applications/papif/papif.c Thu Jun 1 19:06:05 1995 *************** *** 1,6 **** ! static char rcsid[] = "$Author: djh $ $Date: 1994/10/24 06:46:02 $"; ! static char rcsident[] = "$Header: /mac/src/cap60/applications/papif/RCS/papif.c,v 2.18 1994/10/24 06:46:02 djh Rel djh $"; ! static char revision[] = "$Revision: 2.18 $"; /* * papif - UNIX AppleTalk test program: simple line printer input filter --- 1,6 ---- ! static char rcsid[] = "$Author: djh $ $Date: 1995/06/01 08:59:19 $"; ! static char rcsident[] = "$Header: /mac/src/cap60/applications/papif/RCS/papif.c,v 2.21 1995/06/01 08:59:19 djh Rel djh $"; ! static char revision[] = "$Revision: 2.21 $"; /* * papif - UNIX AppleTalk test program: simple line printer input filter *************** *** 239,264 **** #define lpd_ERRORS 2 /* printed with errors */ #ifdef USESYSLOG log_i(fmt, a1,a2,a3,a4,a5,a6,a7,a8,a9,aa,ab,ac,ad,ae,af) char *fmt; { ! return(syslog(LOG_INFO, fmt, a1,a2,a3,a4,a5,a6,a7,a8,a9,aa,ab,ac,ad,ae,af)); } log_w(fmt, a1,a2,a3,a4,a5,a6,a7,a8,a9,aa,ab,ac,ad,ae,af) char *fmt; { ! return(syslog(LOG_WARNING,fmt,a1,a2,a3,a4,a5,a6,a7,a8,a9,aa,ab,ac,ad,ae,af)); } log_d(fmt, a1,a2,a3,a4,a5,a6,a7,a8,a9,aa,ab,ac,ad,ae,af) char *fmt; { ! return(syslog(LOG_DEBUG, fmt, a1,a2,a3,a4,a5,a6,a7,a8,a9,aa,ab,ac,ad,ae,af)); } #endif USESYSLOG ! /* quit gets called when we've been killed by lprm via SIGINT */ void quit() { --- 239,286 ---- #define lpd_ERRORS 2 /* printed with errors */ #ifdef USESYSLOG + #ifdef __STDC__ log_i(fmt, a1,a2,a3,a4,a5,a6,a7,a8,a9,aa,ab,ac,ad,ae,af) char *fmt; + ptrdiff_t a1,a2,a3,a4,a5,a6,a7,a8,a9,aa,ab,ac,ad,ae,af; + #else /* __STDC__ */ + log_i(fmt, a1,a2,a3,a4,a5,a6,a7,a8,a9,aa,ab,ac,ad,ae,af) + char *fmt; + #endif /* __STDC__ */ { ! syslog(LOG_INFO, fmt, a1,a2,a3,a4,a5,a6,a7,a8,a9,aa,ab,ac,ad,ae,af); } + #ifdef __STDC__ + log_w(fmt, a1,a2,a3,a4,a5,a6,a7,a8,a9,aa,ab,ac,ad,ae,af) + char *fmt; + ptrdiff_t a1,a2,a3,a4,a5,a6,a7,a8,a9,aa,ab,ac,ad,ae,af; + #else /* __STDC__ */ log_w(fmt, a1,a2,a3,a4,a5,a6,a7,a8,a9,aa,ab,ac,ad,ae,af) char *fmt; + #endif /* __STDC__ */ { ! syslog(LOG_WARNING,fmt,a1,a2,a3,a4,a5,a6,a7,a8,a9,aa,ab,ac,ad,ae,af); } + #ifdef __STDC__ + log_d(fmt, a1,a2,a3,a4,a5,a6,a7,a8,a9,aa,ab,ac,ad,ae,af) + char *fmt; + ptrdiff_t a1,a2,a3,a4,a5,a6,a7,a8,a9,aa,ab,ac,ad,ae,af; + #else /* __STDC__ */ log_d(fmt, a1,a2,a3,a4,a5,a6,a7,a8,a9,aa,ab,ac,ad,ae,af) char *fmt; + #endif /* __STDC__ */ { ! syslog(LOG_DEBUG, fmt, a1,a2,a3,a4,a5,a6,a7,a8,a9,aa,ab,ac,ad,ae,af); } #endif USESYSLOG ! /* ! * quit gets called when we've been killed by lprm via SIGINT ! * ! */ ! void quit() { *************** *** 748,753 **** --- 770,776 ---- openlw(lwname) u_char *lwname; { + char message[80]; int i, cno, ocomp, err; PAPStatusRec status; #ifdef ISO_TRANSLATE *************** *** 763,773 **** if ((i % 10) == 0) { /* waited 5 minutes? */ #ifdef ISO_TRANSLATE cMac2ISO(lwname); ! log_e("papif: Problems finding %s\n", (char *)lwname); cISO2Mac(lwname); #else ISO_TRANSLATE ! log_e("papif: Problems finding %s\n", (char *)lwname); #endif ISO_TRANSLATE i = 1; } else i++; } --- 786,801 ---- if ((i % 10) == 0) { /* waited 5 minutes? */ #ifdef ISO_TRANSLATE cMac2ISO(lwname); ! sprintf((message+1), "papif: Problems finding %s\n", (char *)lwname); cISO2Mac(lwname); #else ISO_TRANSLATE ! sprintf((message+1), "papif: Problems finding %s\n", (char *)lwname); #endif ISO_TRANSLATE + log_e((char *)(message+1)); + #ifndef SOLARIS + message[0] = strlen((char *)(message+1)); + pstatus(message); + #endif /* SOLARIS */ i = 1; } else i++; } *************** *** 1483,1489 **** continue; /* no = in string */ *ep = '\0'; /* set = to null now */ if (strcmp(buf,printer) == 0) { ! if (strlen(ep+1) == 0) /* no name */ continue; fclose(fd); return(ep+1); /* return pointer to value */ --- 1511,1517 ---- continue; /* no = in string */ *ep = '\0'; /* set = to null now */ if (strcmp(buf,printer) == 0) { ! if (strlen((char *)(ep+1)) == 0) /* no name */ continue; fclose(fd); return(ep+1); /* return pointer to value */ *** applications/papif/add_at_printer.orig Mon May 29 22:30:06 1995 --- applications/papif/add_at_printer Mon May 29 22:42:44 1995 *************** *** 12,24 **** ;; esac ! PAPIFHOME=${CAPHOME:-$MYHOME}${CAPHOME:+/bin}; export PAPIFHOME if [ ! -x $PAPIFHOME/papif ]; then echo "FATAL: can't find $PAPIFHOME/papif," echo " make sure that $0 resides in the same directory as papif" echo " or set CAPHOME variable properly." exit fi SUFFIX=`basename $0`.$$; export SUFFIX trap 'rm /tmp/*.$SUFFIX > /dev/null 2>&1' 0 --- 12,30 ---- ;; esac ! CAPHOME=${CAPHOME:-$MYHOME}; PAPIFHOME=${CAPHOME} if [ ! -x $PAPIFHOME/papif ]; then + PAPIFHOME=${PAPIFHOME}/bin + if [ ! -x $PAPIFHOME/papif ]; then echo "FATAL: can't find $PAPIFHOME/papif," echo " make sure that $0 resides in the same directory as papif" echo " or set CAPHOME variable properly." exit + fi fi + export PAPIFHOME + + PATH=$PATH:$CAPHOME:$CAPHOME/bin:$PAPIFHOME SUFFIX=`basename $0`.$$; export SUFFIX trap 'rm /tmp/*.$SUFFIX > /dev/null 2>&1' 0 *** applications/papif/papof.c.orig Mon Oct 10 19:00:54 1994 --- applications/papif/papof.c Wed May 31 23:48:04 1995 *************** *** 18,23 **** --- 18,29 ---- #include #include + #ifdef USESTRINGDOTH + # include + #else USESTRINGDOTH + # include + #endif USESTRINGDOTH + #ifdef BANNERFIRST # ifndef BANNER # define BANNER *************** *** 155,161 **** FILE *fd; unsigned char *line; { ! int l = strlen(line); static char spaces[] = " "; int i, pos; unsigned char c; --- 161,167 ---- FILE *fd; unsigned char *line; { ! int l = strlen((char *)line); static char spaces[] = " "; int i, pos; unsigned char c; *** support/ethertalk/Makefile.m4.orig Mon Oct 10 18:55:22 1994 --- support/ethertalk/Makefile.m4 Tue May 30 18:19:20 1995 *************** *** 41,47 **** # explict command because on pyramid we don't want -q for this senetp.o: senetp.c ../uab/proto_intf.h ! ifelse(os,[pyr],[cc -O -c senetp.c]) aarpd_clnt.o: aarpd_clnt.c aarpd.h --- 41,47 ---- # explict command because on pyramid we don't want -q for this senetp.o: senetp.c ../uab/proto_intf.h ! ifelse(os,[pyr],[ cc -O -c senetp.c]) aarpd_clnt.o: aarpd_clnt.c aarpd.h *** lib/afp/afpcmd.c.orig Fri Dec 24 15:09:13 1993 --- lib/afp/afpcmd.c Tue May 30 18:51:37 1995 *************** *** 1,7 **** /* ! * $Author: djh $ $Date: 1993/12/24 04:08:54 $ ! * $Header: /mac/src/cap60/lib/afp/RCS/afpcmd.c,v 2.4 1993/12/24 04:08:54 djh Rel djh $ ! * $Revision: 2.4 $ * */ --- 1,7 ---- /* ! * $Author: djh $ $Date: 1995/05/30 08:51:20 $ ! * $Header: /mac/src/cap60/lib/afp/RCS/afpcmd.c,v 2.5 1995/05/30 08:51:20 djh Rel djh $ ! * $Revision: 2.5 $ * */ *************** *** 151,157 **** struct timezone tzp; mactime_not_inited = 0; - gettimeofday(&tp, &tzp); if (flag) { mymactime = AS1DOT0_MACTIME; maczerotime = AS1DOT0_MACZEROTIME; --- 151,156 ---- *************** *** 159,165 **** --- 158,170 ---- mymactime = MACTIME; maczerotime = MACZEROTIME; } + #ifdef SOLARIS + tzset(); + mymactime -= ((long)timezone); + #else /* SOLARIS */ + gettimeofday(&tp, &tzp); mymactime -= ((long)tzp.tz_minuteswest*60); + #endif /* SOLARIS */ return; } *** lib/cap/abversion.c.orig Mon Oct 10 18:33:06 1994 --- lib/cap/abversion.c Tue May 30 22:40:56 1995 *************** *** 1,7 **** /* ! * $Author: djh $ $Date: 1994/02/16 07:21:11 $ ! * $Header: /mac/src/cap60/lib/cap/RCS/abversion.c,v 2.92 1994/02/16 07:21:11 djh Rel djh $ ! * $Revision: 2.92 $ * */ --- 1,7 ---- /* ! * $Author: djh $ $Date: 1995/05/30 12:40:48 $ ! * $Header: /mac/src/cap60/lib/cap/RCS/abversion.c,v 2.95 1995/05/30 12:40:48 djh Rel djh $ ! * $Revision: 2.95 $ * */ *************** *** 32,40 **** myversion.cv_name = "CAP"; myversion.cv_version = 6; myversion.cv_subversion = 0; ! myversion.cv_patchlevel = 192; ! myversion.cv_rmonth = "February"; ! myversion.cv_ryear = "1994"; switch (lap_proto) { case LAP_KIP: myversion.cv_type = "UDP encapsulation"; --- 32,40 ---- myversion.cv_name = "CAP"; myversion.cv_version = 6; myversion.cv_subversion = 0; ! myversion.cv_patchlevel = 195; ! myversion.cv_rmonth = "June"; ! myversion.cv_ryear = "1995"; switch (lap_proto) { case LAP_KIP: myversion.cv_type = "UDP encapsulation"; *** lib/cap/absched.c.orig Sun Sep 1 13:57:08 1991 --- lib/cap/absched.c Thu Jun 15 09:59:22 1995 *************** *** 1,7 **** /* ! * $Author: djh $ $Date: 1991/09/01 03:56:40 $ ! * $Header: /mac/src/cap60/lib/cap/RCS/absched.c,v 2.2 1991/09/01 03:56:40 djh Rel djh $ ! * $Revision: 2.2 $ */ /* --- 1,7 ---- /* ! * $Author: djh $ $Date: 1995/06/14 23:59:16 $ ! * $Header: /mac/src/cap60/lib/cap/RCS/absched.c,v 2.6 1995/06/14 23:59:16 djh Rel djh $ ! * $Revision: 2.6 $ */ /* *************** *** 43,48 **** --- 43,62 ---- #include /* to cover difference between bsd systems */ /* + * this is a hack that + * needs more elegance + * + */ + + #ifdef __bsdi__ + #define MULTI_BPF_PKT + #endif /* __bsdi__ */ + + #ifdef __NetBSD__ + #define MULTI_BPF_PKT + #endif /* __NetBSD__ */ + + /* * NOTE: it is not important to get the TZ information. It is simply * included because some systems complain if there isn't a valid pointer * there. *************** *** 690,696 **** --- 704,726 ---- if ((fd = FD_GETBIT(&rdybits, fdmaxdesc)) < 0) break; /* paranoia */ FD_CLR(fd, &rdybits); + #ifdef MULTI_BPF_PKT + /* + * BPF can return multiple packets + * + */ + { extern short lap_proto; + if (lap_proto == LAP_ETALK) { + extern int read_buf_len; + do { + fdlistenread(fd); + } while (read_buf_len > 0); + } else + fdlistenread(fd); + } + #else /* MULTI_BPF_PKT */ fdlistenread(fd); + #endif /* MULTI_BPF_PKT */ nevent++; } } else { *** lib/cap/abkip.c.orig Mon Oct 24 16:42:44 1994 --- lib/cap/abkip.c Wed May 31 18:28:46 1995 *************** *** 1,7 **** /* ! * $Author: djh $ $Date: 1994/10/24 06:42:34 $ ! * $Header: /mac/src/cap60/lib/cap/RCS/abkip.c,v 2.5 1994/10/24 06:42:34 djh Rel djh $ ! * $Revision: 2.5 $ * */ --- 1,7 ---- /* ! * $Author: djh $ $Date: 1995/05/31 08:28:31 $ ! * $Header: /mac/src/cap60/lib/cap/RCS/abkip.c,v 2.6 1995/05/31 08:28:31 djh Rel djh $ ! * $Revision: 2.6 $ * */ *************** *** 146,151 **** --- 146,153 ---- private int abfd; /* outgoing fd for UAB */ struct in_addr xdesthost; /* localhost address */ #endif UAB_MKIP + + int read_buf_len; /* dummy for absched.c */ import int ddp_protocol(); /* DDP protocol handler */ private int kip_get(); /* our KIP listener */ *** lib/cap/atalkdbm.c.orig Mon Oct 10 18:57:26 1994 --- lib/cap/atalkdbm.c Wed May 31 22:58:29 1995 *************** *** 1,7 **** /* ! * $Date: 1994/10/10 08:57:18 $ ! * $Header: /mac/src/cap60/lib/cap/RCS/atalkdbm.c,v 2.11 1994/10/10 08:57:18 djh Rel djh $ ! * $Revision: 2.11 $ * * mods for async appletalk support, /etc/etalk.local for EtherTalk and * changes for quoted zone names: djh@munnari.OZ.AU, 27/11/90 --- 1,7 ---- /* ! * $Date: 1995/05/31 12:58:21 $ ! * $Header: /mac/src/cap60/lib/cap/RCS/atalkdbm.c,v 2.12 1995/05/31 12:58:21 djh Rel djh $ ! * $Revision: 2.12 $ * * mods for async appletalk support, /etc/etalk.local for EtherTalk and * changes for quoted zone names: djh@munnari.OZ.AU, 27/11/90 *************** *** 433,439 **** getfield(value, sizeof(value), 0); if (strcmp(name, ETH_INTERFACE) == 0) ! strncpy(interface, value, sizeof(interface)); #ifdef PHASE2 else if (strcmp(name, ETH_NET_START) == 0) net_range_start = htons(atnetshort(value)); --- 433,439 ---- getfield(value, sizeof(value), 0); if (strcmp(name, ETH_INTERFACE) == 0) ! strncpy((char *)interface, value, sizeof(interface)); #ifdef PHASE2 else if (strcmp(name, ETH_NET_START) == 0) net_range_start = htons(atnetshort(value)); *** samples/papstatus.c.orig Mon Oct 24 16:43:47 1994 --- samples/papstatus.c Wed May 31 23:03:42 1995 *************** *** 1,6 **** ! static char rcsid[] = "$Author: djh $ $Date: 1994/10/24 06:43:36 $"; ! static char rcsident[] = "$Header: /mac/src/cap60/samples/RCS/papstatus.c,v 2.4 1994/10/24 06:43:36 djh Rel djh $"; ! static char revision[] = "$Revision: 2.4 $"; /* * papstatus - UNIX AppleTalk program: simple status display --- 1,6 ---- ! static char rcsid[] = "$Author: djh $ $Date: 1995/05/31 13:03:31 $"; ! static char rcsident[] = "$Header: /mac/src/cap60/samples/RCS/papstatus.c,v 2.5 1995/05/31 13:03:31 djh Rel djh $"; ! static char revision[] = "$Revision: 2.5 $"; /* * papstatus - UNIX AppleTalk program: simple status display *************** *** 182,188 **** do { PAPStatus (name, &status, &addr); ! nostat = strcmp (status.StatusStr + 1, "%no status"); if (verbose || nostat != 0) pstatus(status.StatusStr); } while (nostat == 0); --- 182,188 ---- do { PAPStatus (name, &status, &addr); ! nostat = strcmp ((char *)(status.StatusStr + 1), "%no status"); if (verbose || nostat != 0) pstatus(status.StatusStr); } while (nostat == 0); *** samples/ash.c.orig Mon Oct 24 16:43:45 1994 --- samples/ash.c Fri Jun 30 09:17:52 1995 *************** *** 1,7 **** /* ! * $Author: djh $ $Date: 1994/10/24 06:43:36 $ ! * $Header: /mac/src/cap60/samples/RCS/ash.c,v 2.4 1994/10/24 06:43:36 djh Rel djh $ ! * $Revision: 2.4 $ */ /* --- 1,7 ---- /* ! * $Author: djh $ $Date: 1995/06/29 23:17:32 $ ! * $Header: /mac/src/cap60/samples/RCS/ash.c,v 2.5 1995/06/29 23:17:32 djh Rel djh $ ! * $Revision: 2.5 $ */ /* *************** *** 675,681 **** int toread; comp = eFPOpenFork(srn, volid, dirid, 0x1, path, type, ! (word)FP_DFLEN|FP_RFLEN, &epar, &fd, &cr); if (comp < 0) { return(FALSE); } --- 675,681 ---- int toread; comp = eFPOpenFork(srn, volid, dirid, 0x1, path, type, ! (word)(type ? FP_RFLEN : FP_DFLEN), &epar, &fd, &cr); if (comp < 0) { return(FALSE); } *** contrib/snitch.c.orig Mon Oct 10 19:06:32 1994 --- contrib/snitch.c Wed May 31 23:35:55 1995 *************** *** 284,292 **** NBPTEntry nbpt[1]; /* table of entity names */ int err; ! strcpy(en.objStr.s, sobj); ! strcpy(en.typeStr.s, stype); ! strcpy(en.zoneStr.s, szone); nbpr.nbpAddress.skt = skt; --- 284,292 ---- NBPTEntry nbpt[1]; /* table of entity names */ int err; ! strcpy((char *)en.objStr.s, sobj); ! strcpy((char *)en.typeStr.s, stype); ! strcpy((char *)en.zoneStr.s, szone); nbpr.nbpAddress.skt = skt; *************** *** 311,319 **** EntityName en; int err; ! strcpy(en.objStr.s, sobj); ! strcpy(en.typeStr.s, stype); ! strcpy(en.zoneStr.s, szone); err = NBPRemove(&en); return(err); --- 311,319 ---- EntityName en; int err; ! strcpy((char *)en.objStr.s, sobj); ! strcpy((char *)en.typeStr.s, stype); ! strcpy((char *)en.zoneStr.s, szone); err = NBPRemove(&en); return(err); *** contrib/printqueue.c.orig Wed Jun 28 12:19:28 1995 --- contrib/printqueue.c Wed Jun 28 12:15:10 1995 *************** *** 299,307 **** tobds("Warning: \"%s\" is down: ", printer); fd = open(status, O_RDONLY); if (fd >= 0) { ! #ifndef SOLARIS (void) flock(fd, LOCK_SH); ! #endif SOLARIS while ((i = read(fd, line, BUFSIZ)) > 0) writebds(line, i); (void) close(fd); /* unlocks as well */ --- 299,307 ---- tobds("Warning: \"%s\" is down: ", printer); fd = open(status, O_RDONLY); if (fd >= 0) { ! #if !(defined(SOLARIS) || defined(hpux)) (void) flock(fd, LOCK_SH); ! #endif /* SOLARIS || hpux */ while ((i = read(fd, line, BUFSIZ)) > 0) writebds(line, i); (void) close(fd); /* unlocks as well */ *************** *** 338,346 **** */ fd = open(status, O_RDONLY); if (fd >= 0) { ! #ifndef SOLARIS (void) flock(fd, LOCK_SH); ! #endif SOLARIS while ((i = read(fd, line, BUFSIZ)) > 0) writebds(line, i); (void) close(fd); /* unlocks as well */ --- 338,346 ---- */ fd = open(status, O_RDONLY); if (fd >= 0) { ! #if !(defined(SOLARIS) || defined(hpux)) (void) flock(fd, LOCK_SH); ! #endif /* SOLARIS || hpux */ while ((i = read(fd, line, BUFSIZ)) > 0) writebds(line, i); (void) close(fd); /* unlocks as well */ *************** *** 643,649 **** --- 643,653 ---- nitems = 0; while ((d = readdir(dirp)) != NULL) { + #ifdef __hpux + if (d->d_name[0] != 'c' || d->d_name[1] != 'A') + #else /* __hpux */ if (d->d_name[0] != 'c' || d->d_name[1] != 'f') + #endif /* __hpux */ continue; /* daemon control files only */ if (stat(d->d_name, &statbuf) < 0) continue; /* Doesn't exist */ *** applications/lwsrv/simple.c.orig Mon Oct 24 16:45:50 1994 --- applications/lwsrv/simple.c Thu Jun 1 19:23:25 1995 *************** *** 1,6 **** ! static char rcsid[] = "$Author: djh $ $Date: 1994/10/24 06:45:41 $"; ! static char rcsident[] = "$Header: /mac/src/cap60/applications/lwsrv/RCS/simple.c,v 2.9 1994/10/24 06:45:41 djh Rel djh $"; ! static char revision[] = "$Revision: 2.9 $"; /* * lwsrv - UNIX AppleTalk spooling program: act as a laserwriter --- 1,6 ---- ! static char rcsid[] = "$Author: djh $ $Date: 1995/06/01 09:22:53 $"; ! static char rcsident[] = "$Header: /mac/src/cap60/applications/lwsrv/RCS/simple.c,v 2.10 1995/06/01 09:22:53 djh Rel djh $"; ! static char revision[] = "$Revision: 2.10 $"; /* * lwsrv - UNIX AppleTalk spooling program: act as a laserwriter *************** *** 528,534 **** p_clreof(pf); /* clear EOF indicator */ echo = TRUE; if (nodsc) { ! fprintf(outfile, "%%! PostScript Document, but non-conformant\n"); fprintf(outfile, "%% so psrv is not invoked\n"); } --- 528,534 ---- p_clreof(pf); /* clear EOF indicator */ echo = TRUE; if (nodsc) { ! fprintf(outfile, "%%!\n%% PostScript Document, but non-conformant\n"); fprintf(outfile, "%% so psrv is not invoked\n"); } *** applications/aufs/afpvols.c.orig Mon Jan 31 18:13:42 1994 --- applications/aufs/afpvols.c Mon Jun 26 16:27:15 1995 *************** *** 1,7 **** /* ! * $Author: djh $ $Date: 1994/01/31 07:13:32 $ ! * $Header: /mac/src/cap60/applications/aufs/RCS/afpvols.c,v 2.11 1994/01/31 07:13:32 djh Rel djh $ ! * $Revision: 2.11 $ * */ --- 1,7 ---- /* ! * $Author: djh $ $Date: 1995/06/26 06:26:55 $ ! * $Header: /local/mulga/mac/src/cap60/applications/aufs/RCS/afpvols.c,v 2.17 1995/06/26 06:26:55 djh Rel djh $ ! * $Revision: 2.17 $ * */ *************** *** 50,55 **** --- 50,58 ---- # include #endif USESTRINGDOTH + #ifdef DEBUG_AFP_CMD + extern FILE *dbg; + #endif /* DEBUG_AFP_CMD */ private VolPtr VolTbl[MAXVOLS]; /* table of VolEntry records */ private int VolCnt = 0; /* number of volumes */ *************** *** 338,343 **** --- 341,357 ---- VolPtr vp; ntohPackX(PsGetVolParms,p,l,(byte *) &gvp); /* decode packet */ + + #ifdef DEBUG_AFP_CMD + if (dbg != NULL) { + void dbg_print_vmap(); + fprintf(dbg, "\tVolID: %04x\n", gvp.gvp_volid); + fprintf(dbg, "\tBtMap: %04x\t", gvp.gvp_bitmap); + dbg_print_vmap(gvp.gvp_bitmap); + fflush(dbg); + } + #endif /* DEBUG_AFP_CMD */ + ivol = EtoIVolid(gvp.gvp_volid); /* pick up volume id */ if (ivol < 0) return(ivol); /* unknown volume */ *************** *** 355,360 **** --- 369,387 ---- return(err); vp->v_bitmap = gvp.gvp_bitmap; *rl = htonPackX(VolPackR,(byte *) vp,r); + + #ifdef DEBUG_AFP_CMD + if (dbg != NULL) { + void dbg_print_vmap(); + void dbg_print_vprm(); + fprintf(dbg, " Return Parameters:\n"); + fprintf(dbg, "\tBtMap: %04x\t", vp->v_bitmap); + dbg_print_vmap(vp->v_bitmap); + dbg_print_vprm(vp->v_bitmap, r+2, (*rl)-2); + fflush(dbg); + } + #endif /* DEBUG_AFP_CMD */ + return(noErr); /* all ok */ } *************** *** 381,386 **** --- 408,425 ---- ntohPackX(PsSetVolParms,p,l,(byte *) &svp); /* unpack */ + #ifdef DEBUG_AFP_CMD + if (dbg != NULL) { + void dbg_print_vmap(); + void dbg_print_date(); + fprintf(dbg, "\tVolID: %04x\n", svp.svp_volid); + fprintf(dbg, "\tBtMap: %04x\t", svp.svp_bitmap); + dbg_print_vmap(svp.svp_bitmap); + dbg_print_date(svp.svp_backdata); + fflush(dbg); + } + #endif /* DEBUG_AFP_CMD */ + ivol = EtoIVolid(svp.svp_volid); if (ivol < 0) return(aeParamErr); /* unknown volume */ *************** *** 417,422 **** --- 456,473 ---- ovl.ovl_pass[0] = '\0'; /* zero optional password */ ntohPackX(PsOpenVol,p,l,(byte *) &ovl); /* decode packet */ + + #ifdef DEBUG_AFP_CMD + if (dbg != NULL) { + void dbg_print_vmap(); + fprintf(dbg, "\tBtMap: %04x\t", ovl.ovl_bitmap); + dbg_print_vmap(ovl.ovl_bitmap); + fprintf(dbg, "\tVolNm: \"%s\"\n", ovl.ovl_name); + fprintf(dbg, "\tVolPw: \"%s\"\n", ovl.ovl_pass); + fflush(dbg); + } + #endif /* DEBUG_AFP_CMD */ + strncpy(pwd,(char *) ovl.ovl_pass,MAXPASSWD); /* copy optional pwd */ pwd[MAXPASSWD] = '\0'; /* tie off with a null */ *************** *** 448,453 **** --- 499,517 ---- vp->v_bitmap = ovl.ovl_bitmap; /* bitmap for packing result */ *rl = htonPackX(VolPackR,(byte *) vp,r); + + #ifdef DEBUG_AFP_CMD + if (dbg != NULL) { + void dbg_print_vmap(); + void dbg_print_vprm(); + fprintf(dbg, " Return Parameters:\n"); + fprintf(dbg, "\tBtMap: %04x\t", vp->v_bitmap); + dbg_print_vmap(vp->v_bitmap); + dbg_print_vprm(vp->v_bitmap, r+2, (*rl)-2); + fflush(dbg); + } + #endif /* DEBUG_AFP_CMD */ + return(noErr); /* return ok */ } *************** *** 470,475 **** --- 534,546 ---- ntohPackX(PsCloseVol,p,l,(byte *) &cv); + #ifdef DEBUG_AFP_CMD + if (dbg != NULL) { + fprintf(dbg, "\tVolID: %04x\n", cv.cv_volid); + fflush(dbg); + } + #endif /* DEBUG_AFP_CMD */ + ivol = EtoIVolid(cv.cv_volid); /* convert to internal format */ if (ivol < 0) /* error code */ return(ivol); *************** *** 504,509 **** --- 575,587 ---- ntohPackX(PsFlush,p,l,(byte *) &fls); + #ifdef DEBUG_AFP_CMD + if (dbg != NULL) { + fprintf(dbg, "\tVolID: %04x\n", fls.fls_volid); + fflush(dbg); + } + #endif /* DEBUG_AFP_CMD */ + if (DBVOL) printf("FPFLush: ...\n"); *************** *** 559,565 **** char * VolSName(volid) { ! char temp[9]; if (volid > VolCnt) return(""); --- 637,643 ---- char * VolSName(volid) { ! static char temp[9]; if (volid > VolCnt) return(""); *************** *** 621,639 **** logit(0, "CREATE_AFPVOL: can't open %s for writing", volfname); return(-1); } ! #ifdef CREATE_AFPVOL_NAME ! if (fprintf(fp, "%s/%s:%s\n", home, CREATE_AFPVOL, usr) < 0) { ! logit(0, "CREATE_AFPVOL: error in fprintf()"); ! (void)fclose(fp); ! return(-1); } ! #else CREATE_AFPVOL_NAME ! if (fprintf(fp, "%s/%s:%s\n", home, CREATE_AFPVOL, CREATE_AFPVOL) < 0) { logit(0, "CREATE_AFPVOL: error in fprintf()"); (void)fclose(fp); return(-1); } ! #endif CREATE_AFPVOL_NAME (void)fclose(fp); sprintf(subdir, "%s/%s", home, FIDIRFN); if (mkdir(subdir, 0700) < 0) { --- 699,725 ---- logit(0, "CREATE_AFPVOL: can't open %s for writing", volfname); return(-1); } ! #ifdef CREAT_AFPVOL_NAM ! { char *makeVolName(), *cp; ! char host[64], name[128]; ! gethostname(host, sizeof(host)); ! host[sizeof(host)-1] = '\0'; ! if ((cp = index(host, '.')) != NULL) ! *cp = '\0'; /* remove domain name */ ! sprintf(name, makeVolName(CREAT_AFPVOL_NAM,usr,host,CREATE_AFPVOL,home)); ! if (fprintf(fp, "~%s/%s:%s\n", usr, CREATE_AFPVOL, name) < 0) { ! logit(0, "CREATE_AFPVOL: error in fprintf()"); ! (void)fclose(fp); ! return(-1); ! } } ! #else CREAT_AFPVOL_NAM ! if (fprintf(fp, "~%s/%s:%s\n", usr, CREATE_AFPVOL, CREATE_AFPVOL) < 0) { logit(0, "CREATE_AFPVOL: error in fprintf()"); (void)fclose(fp); return(-1); } ! #endif CREAT_AFPVOL_NAM (void)fclose(fp); sprintf(subdir, "%s/%s", home, FIDIRFN); if (mkdir(subdir, 0700) < 0) { *************** *** 677,680 **** --- 763,1035 ---- (void)VRdVFile(fp); /* read vols file from user */ return(0); } + + #ifdef CREAT_AFPVOL_NAM + /* + * build a Mac volume name out of specified args in fmt + * %U username + * %H hostname + * %V volumename + * %D home directory + * + */ + + char * + makeVolName(fmt, user, host, volm, home) + char *fmt, *user, *host, *volm, *home; + { + char *p, *q; + static char string[128]; + + p = fmt; + q = string; + string[0] = '\0'; + + while (*p != '\0') { + if (*p == '%' && *(p+1) != '\0') { + switch (*(p+1)) { + case 'U': + strcat(string, user); + q += strlen(user); + break; + case 'H': + strcat(string, host); + q += strlen(host); + break; + case 'V': + strcat(string, volm); + q += strlen(volm); + break; + case 'D': + strcat(string, home); + q += strlen(home); + break; + } + p += 2; + continue; + } + *q++ = *p++; + *q = '\0'; + } + + return(string); + } + #endif CREAT_AFPVOL_NAM #endif CREATE_AFPVOL + + #ifdef DEBUG_AFP_CMD + /* + * print bitmap for Volume Parameters + * + */ + + void + dbg_print_vmap(bmap) + u_short bmap; + { + int i, j; + + if (dbg != NULL) { + fprintf(dbg, "("); + for (i = 0, j = 0; i < 16; i++) { + if (bmap & (0x0001 << i)) { + bmap &= ~(0x0001 << i); + switch (i) { + case 0: + fprintf(dbg, "Attributes"); + j++; + break; + case 1: + fprintf(dbg, "Signature"); + j++; + break; + case 2: + fprintf(dbg, "Creat Date"); + j++; + break; + case 3: + fprintf(dbg, "Modif Date"); + j++; + break; + case 4: + fprintf(dbg, "Bakup Date"); + j++; + break; + case 5: + fprintf(dbg, "Volume ID"); + j++; + break; + case 6: + fprintf(dbg, "Bytes Free"); + j++; + break; + case 7: + fprintf(dbg, "Bytes Total"); + j++; + break; + case 8: + fprintf(dbg, "Volume Name"); + j++; + break; + default: + fprintf(dbg, "Unknwn Bit"); + j++; + break; + } + if (bmap) + fprintf(dbg, ", "); + if (bmap && (j % 4) == 0) + fprintf(dbg, "\n\t\t\t"); + } + } + fprintf(dbg, ")\n"); + } + + return; + } + + /* + * dump Volume parameters described by bitmap + * + */ + + #define get2(s) (u_short)(((s)[0]<<8)|((s)[1])) + #define get4(s) (u_int)(((s)[0]<<24)|((s)[1]<<16)|((s)[2]<<8)|((s)[3])) + + void + dbg_print_vprm(bmap, r, rl) + u_short bmap; + byte *r; + int rl; + { + int i, j; + byte *p, *q; + short offset; + void dbg_print_date(); + void dbg_print_vatr(); + + p = r; /* parameters */ + + if (dbg != NULL) { + for (i = 0; i < 16 && rl > 0; i++) { + if (bmap & (0x0001 << i)) { + switch (i) { + case 0: + fprintf(dbg, "\tAttributes: "); + dbg_print_vatr(get2(r)); + rl -= 2; + r += 2; + break; + case 1: + fprintf(dbg, "\tVSignature: %04x\n", get2(r)); + rl -= 2; + r += 2; + break; + case 2: + fprintf(dbg, "\tCreat Date: "); + dbg_print_date(get4(r)); + rl -= 4; + r += 4; + break; + case 3: + fprintf(dbg, "\tModif Date: "); + dbg_print_date(get4(r)); + rl -= 4; + r += 4; + break; + case 4: + fprintf(dbg, "\tBakup Date: "); + dbg_print_date(get4(r)); + rl -= 4; + r += 4; + break; + case 5: + fprintf(dbg, "\t Volume ID: %04x\n", get2(r)); + rl -= 2; + r += 2; + break; + case 6: + fprintf(dbg, "\tBytes Free: %d\n", get4(r)); + rl -= 4; + r += 4; + break; + case 7: + fprintf(dbg, "\tBytes Totl: %d\n", get4(r)); + rl -= 4; + r += 4; + break; + case 8: + fprintf(dbg, "\tVolume Nam: \""); + offset = get2(r); + q = p + offset; + for (j = 0; j < *q; j++) + fprintf(dbg, "%c", *(q+j+1)); + fprintf(dbg, "\"\n"); + rl -= 2; + r += 2; + break; + default: + fprintf(dbg, "\tUnknwn Bit: %d\n", i); + break; + } + } + } + } + + return; + } + + /* + * print volume attributes + * + */ + + void + dbg_print_vatr(attr) + u_short attr; + { + int i, j; + + if (dbg != NULL) { + fprintf(dbg, "%04x (", attr); + for (i = 0, j = 0; i < 16; i++) { + if (attr & (0x0001 << i)) { + attr &= ~(0x0001 << i); + switch (i) { + case 0: + fprintf(dbg, "ReadOnlyVol"); + j++; + break; + case 1: + fprintf(dbg, "HasVolPaswd"); + j++; + break; + case 2: + fprintf(dbg, "SuppFileIDs"); + j++; + break; + case 3: + fprintf(dbg, "SuppCatSrch"); + j++; + break; + case 4: + fprintf(dbg, "SuppBlnkAcs"); + j++; + break; + default: + fprintf(dbg, "", i); + j++; + break; + } + if (attr) + fprintf(dbg, ", "); + if (attr && (j % 4) == 0) + fprintf(dbg, "\n\t\t\t"); + } + } + fprintf(dbg, ")\n"); + } + + return; + } + #endif /* DEBUG_AFP_CMD */ *** applications/aufs/aufs.c.orig Mon Oct 10 19:02:12 1994 --- applications/aufs/aufs.c Mon Jun 19 11:32:30 1995 *************** *** 1,7 **** /* ! * $Author: djh $ $Date: 1994/10/10 09:02:04 $ ! * $Header: /mac/src/cap60/applications/aufs/RCS/aufs.c,v 2.24 1994/10/10 09:02:04 djh Rel djh $ ! * $Revision: 2.24 $ * */ --- 1,7 ---- /* ! * $Author: djh $ $Date: 1995/06/19 01:32:20 $ ! * $Header: /mac/src/cap60/applications/aufs/RCS/aufs.c,v 2.27 1995/06/19 01:32:20 djh Rel djh $ ! * $Revision: 2.27 $ * */ *************** *** 72,77 **** --- 72,83 ---- # endif xenix5 #endif NOPGRP + #ifdef DEBUG_AFP_CMD + #ifndef DEBUG_AFP + #define DEBUG_AFP + #endif /* DEBUG_AFP */ + #endif /* DEBUG_AFP_CMD */ + /* known attention codes */ #define AFPSHUTDOWNTIME(x) (0x8000|((x)&0xfff)) #define AFPSHUTDOWNCANCEL (0x8fff) *************** *** 82,87 **** --- 88,94 ---- export int statflg = FALSE; /* default is not to show stats */ export u_char *srvrname = NULL; /* NBP registered name */ + export u_char *srvrtype = (u_char *)AFSTYPE; /* NBP registered type */ export char *messagefile = NULL; /* AFP2.1 GetSrvrMsg srvr msg filename */ export char *motdfile = NULL; /* AFP2.1 GetSrvrMsg login msg filename */ *************** *** 90,97 **** --- 97,108 ---- private char *guestid = NULL; /* any guest ids? */ private char *coredir = NULL; /* place to put coredumps */ + #ifdef DEBUG_AFP + private char *debugAFPFile = NULL; /* AFP debug file name */ + #endif DEBUG_AFP #ifdef ISO_TRANSLATE private u_char isoSrvrName[80]; + private u_char isoSrvrType[80]; #endif ISO_TRANSLATE #ifdef REREAD_AFPVOLS private int readafpvols = FALSE;/* set by USR1 signal */ *************** *** 119,124 **** --- 130,139 ---- export char *aufsreadmename; /* pointer into aufsreadme with just name */ #endif AUFS_README + #ifdef DEBUG_AFP + export FILE *dbg = NULL; + #endif /* DEBUG_AFP */ + private EntityName srvr_entity_name; /* our entity name */ private char zonetorun[34]; /* zone to run in if different than std. */ private char logfile[MAXPATHLEN]; /* log file name if any */ *************** *** 245,250 **** --- 260,268 ---- #ifdef LOGIN_AUTH_PROG fprintf(stderr,"\t-L to provide login authorization service\n"); #endif LOGIN_AUTH_PROG + #ifdef DEBUG_AFP + fprintf(stderr, "\t-Z to dump parameters from AFP commands\n"); + #endif DEBUG_AFP fprintf(stderr,"\nExample: %s -t 'bdelete irename' -a 'file fork dir' -s\n", name); exit(1); *************** *** 273,278 **** --- 291,297 ---- char **argv; { int c; + u_char *parsename(); extern char *optarg; extern int optind; extern boolean dochecksum; *************** *** 299,304 **** --- 318,326 ---- #ifdef LOGIN_AUTH_PROG strcat(optlist, "L:"); #endif LOGIN_AUTH_PROG + #ifdef DEBUG_AFP + strcat(optlist, "Z:"); + #endif DEBUG_AFP while ((c = getopt(argc,argv,optlist)) != EOF) { switch (c) { *************** *** 344,352 **** case 'n': case 'N': srvrname = (u_char *)optarg; /* '-n' to set server name */ #ifdef ISO_TRANSLATE ! bcopy(optarg, isoSrvrName, strlen(optarg)+1); cISO2Mac(srvrname); #endif ISO_TRANSLATE break; case 't': --- 366,377 ---- case 'n': case 'N': srvrname = (u_char *)optarg; /* '-n' to set server name */ + srvrtype = parsename(srvrname); /* (optional "-n name:type") */ #ifdef ISO_TRANSLATE ! bcopy(srvrname, isoSrvrName, strlen(srvrname)+1); cISO2Mac(srvrname); + bcopy(srvrtype, isoSrvrType, strlen(srvrtype)+1); + cISO2Mac(srvrtype); #endif ISO_TRANSLATE break; case 't': *************** *** 431,436 **** --- 456,466 ---- } break; #endif LOGIN_AUTH_PROG + #ifdef DEBUG_AFP + case 'Z': /* AFP command debugging */ + debugAFPFile = optarg; + break; + #endif /* DEBUG_AFP */ default: usage(argv[0]); break; *************** *** 438,443 **** --- 468,491 ---- } } + /* + * check name for optional ':' delimited type + * + */ + + u_char * + parsename(name) + u_char *name; + { + u_char *cp; + + if ((cp = (u_char *)index((char *)name, ':')) != NULL) { + *cp++ = '\0'; /* NULL terminate name */ + return(cp); + } + return((u_char *)AFSTYPE); + } + export AddrBlock addr; /* budd */ main(argc,argv) *************** *** 480,485 **** --- 528,534 ---- #ifdef ISO_TRANSLATE bcopy(srvrname, isoSrvrName, strlen(srvrname)+1); cISO2Mac(srvrname); + bcopy(AFSTYPE, isoSrvrType, strlen(AFSTYPE)+1); #endif ISO_TRANSLATE logfile[0] = '\0'; zonetorun[0] = '\0'; *************** *** 502,511 **** if (!DBDEB) { #ifdef ISO_TRANSLATE fprintf(stderr,"Apple Unix File Server (%s:%s@*) starting\n", ! (char *)isoSrvrName, AFSTYPE); #else ISO_TRANSLATE fprintf(stderr,"Apple Unix File Server (%s:%s@*) starting\n", ! (char *)srvrname, AFSTYPE); #endif ISO_TRANSLATE } --- 551,560 ---- if (!DBDEB) { #ifdef ISO_TRANSLATE fprintf(stderr,"Apple Unix File Server (%s:%s@*) starting\n", ! (char *)isoSrvrName, (char *)isoSrvrType); #else ISO_TRANSLATE fprintf(stderr,"Apple Unix File Server (%s:%s@*) starting\n", ! (char *)srvrname, (char *)srvrtype); #endif ISO_TRANSLATE } *************** *** 552,557 **** --- 601,612 ---- #endif POSIX } + #ifdef DEBUG_AFP + if (debugAFPFile != NULL) + if ((dbg = fopen(debugAFPFile, "w")) != NULL) + fprintf(dbg, "AUFS Debug Session\n"); + #endif /* DEBUG_AFP */ + mypid = parent_pid = getpid(); /* remember who we are */ if (logfile[0] == '\0') { #ifdef ISO_TRANSLATE *************** *** 564,573 **** logit(0,"****************************************"); #ifdef ISO_TRANSLATE logit(0,"Apple Unix File Server (%s:%s@*) starting", ! (char *)isoSrvrName, AFSTYPE); #else ISO_TRANSLATE logit(0,"Apple Unix File Server (%s:%s@*) starting", ! (char *)srvrname, AFSTYPE); #endif ISO_TRANSLATE logit(0,"Aufs version: %d(%d) as of %s",aufs_version[0], aufs_version[1], aufs_versiondate); --- 619,628 ---- logit(0,"****************************************"); #ifdef ISO_TRANSLATE logit(0,"Apple Unix File Server (%s:%s@*) starting", ! (char *)isoSrvrName, (char *)isoSrvrType); #else ISO_TRANSLATE logit(0,"Apple Unix File Server (%s:%s@*) starting", ! (char *)srvrname, (char *)srvrtype); #endif ISO_TRANSLATE logit(0,"Aufs version: %d(%d) as of %s",aufs_version[0], aufs_version[1], aufs_versiondate); *************** *** 649,664 **** GetMyAddr(&addr); /* set net and node */ addr.skt = atpskt; ! if (SrvrRegister(atpskt,srvrname,AFSTYPE,"*", &srvr_entity_name) != noErr) { ! logit(0,"SrvrRegister for %s failed...",srvrname); exit(2); } if (guestid != NULL) allowguestid(guestid); allowcleartext(); if (passwdlookaside != NULL) allowrandnum(passwdlookaside); #ifndef STAT_CACHE if (coredir) --- 704,727 ---- GetMyAddr(&addr); /* set net and node */ addr.skt = atpskt; ! if (SrvrRegister(atpskt,srvrname,srvrtype,"*", &srvr_entity_name) != noErr) { ! logit(0,"SrvrRegister for %s:%s failed...", srvrname, srvrtype); exit(2); } + /* + * set available User Authentication Methods + * + */ if (guestid != NULL) allowguestid(guestid); allowcleartext(); + #ifdef DISTRIB_PASSWDS + allow2wayrand(passwdlookaside); + #else /* DISTRIB_PASSWDS */ if (passwdlookaside != NULL) allowrandnum(passwdlookaside); + #endif /* DISTRIB_PASSWDS */ #ifndef STAT_CACHE if (coredir) *** applications/aufs/afpdir.c.orig Mon Sep 13 17:02:20 1993 --- applications/aufs/afpdir.c Mon Jun 12 23:13:45 1995 *************** *** 1,7 **** /* ! * $Author: djh $ $Date: 1993/09/13 07:01:49 $ ! * $Header: /mac/src/cap60/applications/aufs/RCS/afpdir.c,v 2.3 1993/09/13 07:01:49 djh Rel djh $ ! * $Revision: 2.3 $ * */ --- 1,7 ---- /* ! * $Author: djh $ $Date: 1995/06/12 13:13:08 $ ! * $Header: /mac/src/cap60/applications/aufs/RCS/afpdir.c,v 2.6 1995/06/12 13:13:08 djh Rel djh $ ! * $Revision: 2.6 $ * */ *************** *** 45,50 **** --- 45,56 ---- #include "afpntoh.h" #include "afps.h" /* common server header */ + #ifdef DEBUG_AFP_CMD + #include + #include + extern FILE *dbg; + #endif /* DEBUG_AFP_CMD */ + private int EnumPack(); /* *************** *** 71,76 **** --- 77,103 ---- err = EtoIfile(file,&idir,&ipdir,&ivol,gfdp.gdp_dirid, gfdp.gdp_volid,gfdp.gdp_ptype,gfdp.gdp_path); + #ifdef DEBUG_AFP_CMD + if (dbg != NULL) { + void dbg_print_bmap(); + void dbg_print_path(); + fprintf(dbg, "\tVolID: %04x\n", gfdp.gdp_volid); + fprintf(dbg, "\tDirID: %08x\n", gfdp.gdp_dirid); + fprintf(dbg, "\tFBMap: %04x\t", gfdp.gdp_fbitmap); + dbg_print_bmap(gfdp.gdp_fbitmap, 0); + fprintf(dbg, "\tDBMap: %04x\t", gfdp.gdp_dbitmap); + dbg_print_bmap(gfdp.gdp_dbitmap, 1); + fprintf(dbg, "\tPType: %d\t(%s Names)\n", gfdp.gdp_ptype, + (gfdp.gdp_ptype == 1) ? "Short" : "Long"); + dbg_print_path(gfdp.gdp_path); + if (err == noErr) + fprintf(dbg, "\tUPath: \"%s/%s\"\n", pathstr(ipdir), file); + else + fprintf(dbg, "\tUPath: \n", err); + fflush(dbg); + } + #endif /* DEBUG_AFP_CMD */ + if (err != noErr) { if (DBFIL || DBDIR) printf("FPGetFileDirParms: EtoIfile returns %d\n",err); *************** *** 100,105 **** --- 127,162 ---- *rl = htonPackX(DirParmPackR,(byte *)&fdp,r); *rl += htonPackX(FilePackR,(byte *)&fdp,r+(*rl)); } + + /* + * check for bogus bitmaps & truncate response + * (DON'T return aeBitMapErr) + * + */ + if ((!FDP_ISDIR(fdp.fdp_flg) && gfdp.gdp_dbitmap && !gfdp.gdp_fbitmap) + || (FDP_ISDIR(fdp.fdp_flg) && !gfdp.gdp_dbitmap && gfdp.gdp_fbitmap)) + *rl =6; + + #ifdef DEBUG_AFP_CMD + if (dbg != NULL) { + void dbg_print_parm(); + void dbg_print_bmap(); + fprintf(dbg, " Return Parameters:\n"); + fprintf(dbg, "\tFBMap: %04x\t", fdp.fdp_fbitmap); + dbg_print_bmap(fdp.fdp_fbitmap, 0); + fprintf(dbg, "\tDBMap: %04x\t", fdp.fdp_dbitmap); + dbg_print_bmap(fdp.fdp_dbitmap, 1); + fprintf(dbg, "\tFDFlg: %02x\t(%s)\n", fdp.fdp_flg, + FDP_ISDIR(fdp.fdp_flg) ? "Directory" : "File"); + if (*rl == 6) + fprintf(dbg, "\t\n"); + else + dbg_print_parm(FDP_ISDIR(fdp.fdp_flg) ? fdp.fdp_dbitmap:fdp.fdp_fbitmap, + r+6, (*rl)-6, FDP_ISDIR(fdp.fdp_flg) ? 1 : (idir) ? 1 : 0); + fflush(dbg); + } + #endif /* DEBUG_AFP_CMD */ + return(noErr); } *************** *** 130,138 **** --- 187,220 ---- extern int sqs; /* maximum send qs */ ntohPackX(PsEnumerate,p,l,(byte *) &enup); + err = EtoIfile(file,&idir,&ipdir,&ivol,enup.enu_dirid, enup.enu_volid,enup.enu_ptype,enup.enu_path); + #ifdef DEBUG_AFP_CMD + if (dbg != NULL) { + void dbg_print_bmap(); + void dbg_print_path(); + fprintf(dbg, "\tVolID: %04x\n", enup.enu_volid); + fprintf(dbg, "\tDirID: %08x\n", enup.enu_dirid); + fprintf(dbg, "\tFBMap: %04x\t", enup.enu_fbitmap); + dbg_print_bmap(enup.enu_fbitmap, 0); + fprintf(dbg, "\tDBMap: %04x\t", enup.enu_dbitmap); + dbg_print_bmap(enup.enu_dbitmap, 1); + fprintf(dbg, "\tRqCnt: %04x\n", enup.enu_reqcnt); + fprintf(dbg, "\tStart: %04x\n", enup.enu_stidx); + fprintf(dbg, "\tMaxRp: %04x\n", enup.enu_maxreply); + fprintf(dbg, "\tPType: %d\t(%s Names)\n", enup.enu_ptype, + (enup.enu_ptype == 1) ? "Short" : "Long"); + dbg_print_path(enup.enu_path); + if (err == noErr) + fprintf(dbg, "\tUPath: \"%s/%s\"\n", pathstr(ipdir), file); + else + fprintf(dbg, "\tUPath: \n", err); + fflush(dbg); + } + #endif /* DEBUG_AFP_CMD */ + if (err != noErr) return(err); *************** *** 198,203 **** --- 280,310 ---- printf("OSEnum: maxreply=%d, ourreply=%d, reqcnt=%d, ourcnt=%d\n", maxreply,len,reqcnt,cnt); + #ifdef DEBUG_AFP_CMD + if (dbg != NULL) { + int i = cnt; + byte *q = r + 6; + void dbg_print_bmap(); + void dbg_print_parm(); + fprintf(dbg, " Return Parameters:\n"); + fprintf(dbg, "\tFBtMap: %04x\t", enpr.enur_fbitmap); + dbg_print_bmap(enpr.enur_fbitmap, 0); + fprintf(dbg, "\tDBtMap: %04x\t", enpr.enur_dbitmap); + dbg_print_bmap(enpr.enur_dbitmap, 1); + fprintf(dbg, "\tActCnt: %d\n", cnt); + while (i-- > 0) { + fprintf(dbg, "\t----------\n"); + fprintf(dbg, "\tStrcLn: %d\n", (int)*q); + fprintf(dbg, "\tEnType: %02x\t(%s)\n", *(q+1), + (*(q+1) & 0x80) ? "Directory" : "File"); + dbg_print_parm((*(q+1) & 0x80) ? enpr.enur_dbitmap : enpr.enur_fbitmap, + q+2, (*q)-2, (*(q+1) & 0x80) ? 1 : 0); + q += *q; + } + fflush(dbg); + } + #endif /* DEBUG_AFP_CMD */ + return(noErr); /* all ok */ } *************** *** 277,282 **** --- 384,412 ---- err = EtoIfile(file,&idir,&ipdir,&ivol,sdp.sdp_dirid, sdp.sdp_volid,sdp.sdp_ptype,sdp.sdp_path); + + #ifdef DEBUG_AFP_CMD + if (dbg != NULL) { + char *pathstr(); + void dbg_print_bmap(); + void dbg_print_parm(); + void dbg_print_path(); + fprintf(dbg, "\tVolID: %04x\n", sdp.sdp_volid); + fprintf(dbg, "\tDirID: %08x\n", sdp.sdp_dirid); + fprintf(dbg, "\tFBMap: %04x\t", sdp.sdp_bitmap); + dbg_print_bmap(sdp.sdp_bitmap, 1); + fprintf(dbg, "\tPType: %d\t(%s Names)\n", sdp.sdp_ptype, + (sdp.sdp_ptype == 1) ? "Short" : "Long"); + dbg_print_path(sdp.sdp_path); + if (err == noErr) + fprintf(dbg, "\tUPath: \"%s/%s\"\n", pathstr(ipdir), file); + else + fprintf(dbg, "\tUPath: \n", err); + dbg_print_parm(sdp.sdp_bitmap, p+len, l-len, 1); + fflush(dbg); + } + #endif /* DEBUG_AFP_CMD */ + if (err != noErr) return(err); *************** *** 308,313 **** --- 438,460 ---- err = EtoIfile(file,&idir,&ipdir,&ivol,ODPkt.odr_dirid, ODPkt.odr_volid, ODPkt.odr_ptype,ODPkt.odr_path); + + #ifdef DEBUG_AFP_CMD + if (dbg != NULL) { + void dbg_print_path(); + fprintf(dbg, "\tVolID: %04x\n", ODPkt.odr_volid); + fprintf(dbg, "\tDirID: %08x\n", ODPkt.odr_dirid); + fprintf(dbg, "\tPType: %d\t(%s Names)\n", ODPkt.odr_ptype, + (ODPkt.odr_ptype == 1) ? "Short" : "Long"); + dbg_print_path(ODPkt.odr_path); + if (err == noErr) + fprintf(dbg, "\tUPath: \"%s/%s\"\n", pathstr(ipdir), file); + else + fprintf(dbg, "\tUPath: \n", err); + fflush(dbg); + } + #endif /* DEBUG_AFP_CMD */ + if ((err != noErr) && (DBDIR)) printf("error returned from EtoIfile\n"); PackDWord(ItoEdirid(idir,ivol),r); *************** *** 345,350 **** --- 492,514 ---- err = EtoIfile(file,&idir,&ipdir,&ivol,crd.crd_dirid, crd.crd_volid,crd.crd_ptype,crd.crd_path); + + #ifdef DEBUG_AFP_CMD + if (dbg != NULL) { + void dbg_print_path(); + fprintf(dbg, "\tVolID: %04x\n", crd.crd_volid); + fprintf(dbg, "\tDirID: %08x\n", crd.crd_dirid); + fprintf(dbg, "\tPType: %d\t(%s Names)\n", crd.crd_ptype, + (crd.crd_ptype == 1) ? "Short" : "Long"); + dbg_print_path(crd.crd_path); + if (err == noErr) + fprintf(dbg, "\tUPath: \"%s/%s\"\n", pathstr(ipdir), file); + else + fprintf(dbg, "\tUPath: \n", err); + fflush(dbg); + } + #endif /* DEBUG_AFP_CMD */ + if (err != noErr) return(err); *************** *** 384,389 **** --- 548,575 ---- err = EtoIfile(file,&idir,&ipdir,&ivol,scp.scp_dirid, scp.scp_volid,scp.scp_ptype,scp.scp_path); + + #ifdef DEBUG_AFP_CMD + if (dbg != NULL) { + void dbg_print_bmap(); + void dbg_print_parm(); + void dbg_print_path(); + fprintf(dbg, "\tVolID: %04x\n", scp.scp_volid); + fprintf(dbg, "\tDirID: %08x\n", scp.scp_dirid); + fprintf(dbg, "\tBtMap: %04x\t", scp.scp_bitmap); + dbg_print_bmap(scp.scp_bitmap, 0); + fprintf(dbg, "\tPType: %d\t(%s Names)\n", scp.scp_ptype, + (scp.scp_ptype == 1) ? "Short" : "Long"); + dbg_print_path(scp.scp_path); + if (err == noErr) + fprintf(dbg, "\tUPath: \"%s/%s\"\n", pathstr(ipdir), file); + else + fprintf(dbg, "\tUPath: \n", err); + dbg_print_parm(scp.scp_bitmap, p+len, l-len, (idir) ? 1 : 0); + fflush(dbg); + } + #endif /* DEBUG_AFP_CMD */ + if (err != noErr) return(err); *************** *** 395,397 **** --- 581,1063 ---- return(OSSetFileDirParms(ipdir,idir,file,&fdp)); } + + #ifdef DEBUG_AFP_CMD + /* + * describe FPGetFileDirParms/FPGetFileInfo bitmaps + * + */ + + void + dbg_print_bmap(bmap, typ) + u_short bmap; + int typ; + { + int i, j; + + if (dbg != NULL) { + fprintf(dbg, "("); + for (i = 0, j = 0; i < 16; i++) { + if (bmap & (0x0001 << i)) { + bmap &= ~(0x0001 << i); + switch (i) { + case 0: + fprintf(dbg, "Attributes"); + j++; + break; + case 1: + fprintf(dbg, "Parent DID"); + j++; + break; + case 2: + fprintf(dbg, "Creat Date"); + j++; + break; + case 3: + fprintf(dbg, "Modif Date"); + j++; + break; + case 4: + fprintf(dbg, "Bakup Date"); + j++; + break; + case 5: + fprintf(dbg, "Findr Info"); + j++; + break; + case 6: + fprintf(dbg, "Long Name"); + j++; + break; + case 7: + fprintf(dbg, "Short Name"); + j++; + break; + case 8: + if (typ) + fprintf(dbg, "Direct ID"); + else + fprintf(dbg, "File Numbr"); + j++; + break; + case 9: + if (typ) + fprintf(dbg, "OffSpr Cnt"); + else + fprintf(dbg, "DFork Len"); + j++; + break; + case 10: + if (typ) + fprintf(dbg, "Owner ID"); + else + fprintf(dbg, "RFork Len"); + j++; + break; + case 11: + if (typ) + fprintf(dbg, "Group ID"); + j++; + break; + case 12: + if (typ) { + fprintf(dbg, "Acs Rights"); + j++; + } + break; + case 13: + fprintf(dbg, "ProDos Inf"); + j++; + break; + default: + fprintf(dbg, "Unknwn Bit"); + j++; + break; + } + if (bmap) + fprintf(dbg, ", "); + if (bmap && (j % 4) == 0) + fprintf(dbg, "\n\t\t\t"); + } + } + fprintf(dbg, ")\n"); + } + + return; + } + + /* + * dump parameters described by bitmap + * + */ + + #define get2(s) (u_short)(((s)[0]<<8)|((s)[1])) + #define get4(s) (u_int)(((s)[0]<<24)|((s)[1]<<16)|((s)[2]<<8)|((s)[3])) + + void + dbg_print_parm(bmap, r, rl, typ) + u_short bmap; + byte *r; + int rl, typ; + { + int i, j; + byte *p, *q; + short offset; + void dbg_print_attr(); + void dbg_print_date(); + void dbg_print_accs(); + void dbg_print_fndr(); + + p = r; /* parameters */ + + if (dbg != NULL) { + for (i = 0; i < 16 && rl > 0; i++) { + if (bmap & (0x0001 << i)) { + switch (i) { + case 0: + fprintf(dbg, "\tAttributes: "); + dbg_print_attr(get2(r), typ); + rl -= 2; + r += 2; + break; + case 1: + fprintf(dbg, "\tParent DID: %08x\n", get4(r)); + rl -= 4; + r += 4; + break; + case 2: + fprintf(dbg, "\tCreat Date: "); + dbg_print_date(get4(r)); + rl -= 4; + r += 4; + break; + case 3: + fprintf(dbg, "\tModif Date: "); + dbg_print_date(get4(r)); + rl -= 4; + r += 4; + break; + case 4: + fprintf(dbg, "\tBakup Date: "); + dbg_print_date(get4(r)); + rl -= 4; + r += 4; + break; + case 5: + fprintf(dbg, "\tFindr Info:\n"); + dbg_print_fndr(r, typ); + rl -= 32; + r += 32; + break; + case 6: + fprintf(dbg, "\t Long Name: \""); + offset = get2(r); + q = p + offset; + for (j = 0; j < *q; j++) + fprintf(dbg, "%c", *(q+j+1)); + fprintf(dbg, "\"\n"); + rl -= 2; + r += 2; + break; + case 7: + fprintf(dbg, "\tShort Name: "); + offset = get2(r); + q = p + offset; + for (j = 0; j < *q; j++) + fprintf(dbg, "%c", *(q+j+1)); + fprintf(dbg, "\"\n"); + rl -= 2; + r += 2; + break; + case 8: + if (typ) + fprintf(dbg, "\t Direct ID: %08x\n", get4(r)); + else + fprintf(dbg, "\tFile Numbr: %08x\n", get4(r)); + rl -= 4; + r += 4; + break; + case 9: + if (typ) { + fprintf(dbg, "\tOffSpr Cnt: %d\n", get2(r)); + rl -= 2; + r += 2; + } else { + fprintf(dbg, "\t DFork Len: %d\n", get4(r)); + rl -= 4; + r += 4; + } + break; + case 10: + if (typ) + fprintf(dbg, "\t Owner ID: %08x\n", get4(r)); + else + fprintf(dbg, "\t RFork Len: %d\n", get4(r)); + rl -= 4; + r += 4; + break; + case 11: + if (typ) { + fprintf(dbg, "\t Group ID: %08x\n", get4(r)); + rl -= 4; + r += 4; + } + break; + case 12: + if (typ) { + fprintf(dbg, "\tAcs Rights: "); + dbg_print_accs(r); + rl -= 4; + r += 4; + } + break; + case 13: + fprintf(dbg, "\tProDos Inf:\n"); + rl -= 6; + r += 6; + break; + default: + fprintf(dbg, "\t\n", i); + break; + } + } + } + } + + return; + } + + /* + * Print the 16-bit File/Dir attributes + * + */ + + void + dbg_print_attr(attr, typ) + u_int attr; + int typ; + { + int i, j; + + if (dbg != NULL) { + fprintf(dbg, "%04x (", attr); + for (i = 0, j = 0; i < 16; i++) { + if (attr & (0x0001 << i)) { + attr &= ~(0x0001 << i); + switch (i) { + case 0: + fprintf(dbg, "Invisible"); + j++; + break; + case 1: + if (typ) + fprintf(dbg, "IsExpFolder"); + else + fprintf(dbg, "MultiUser"); + j++; + break; + case 2: + fprintf(dbg, "System"); + j++; + break; + case 3: + if (typ) + fprintf(dbg, "Mounted"); + else + fprintf(dbg, "DAlrdyOpen"); + j++; + break; + case 4: + if (typ) + fprintf(dbg, "InExpFolder"); + else + fprintf(dbg, "RAlrdyOpen"); + j++; + break; + case 5: + if (typ) + fprintf(dbg, "", i); + else + fprintf(dbg, "RDOnly/WrtInhib"); + j++; + break; + case 6: + fprintf(dbg, "BackupNeeded"); + j++; + break; + case 7: + fprintf(dbg, "RenameInhib"); + j++; + break; + case 8: + fprintf(dbg, "DeleteInhib"); + j++; + break; + case 9: + if (typ) + fprintf(dbg, ""); + else + fprintf(dbg, "CopyProtect"); + j++; + break; + case 15: + fprintf(dbg, "Set/Clear"); + j++; + break; + default: + fprintf(dbg, "", i); + j++; + break; + } + if (attr) + fprintf(dbg, ", "); + if (attr && (j % 4) == 0) + fprintf(dbg, "\n\t\t\t"); + } + } + fprintf(dbg, ")\n"); + } + + return; + } + + /* + * print Finder Information + * + */ + + void + dbg_print_fndr(f, typ) + byte *f; + int typ; + { + void dbg_print_type(); + + /* + * File Finder Info + * + */ + if (typ == 0) { + dbg_print_type("\t FilTyp:", f); + f += 4; + dbg_print_type("\t Creatr:", f); + f += 4; + fprintf(dbg, "\t FdrFlg: %04x\n", get2(f)); + f += 2; + fprintf(dbg, "\t Locatn: %04x %04x\n", get2(f), get2(f+2)); + f += 4; + fprintf(dbg, "\t Window: %04x\n", get2(f)); + f += 2; + fprintf(dbg, "\t IconID: %04x\n", get2(f)); + f += 2; + f += 8; /* unused */ + fprintf(dbg, "\t CommID: %04x\n", get2(f)); + f += 2; + fprintf(dbg, "\t HomeID: %08x\n", get4(f)); + + return; + } + + /* + * Directory Finder Info + * + */ + if (typ == 1) { + fprintf(dbg, "\t DiRect: %04x %04x %04x %04x\n", + get2(f), get2(f+2), get2(f+4), get2(f+6)); + f += 8; + fprintf(dbg, "\t FdrFlg: %04x %04x\n", get2(f), get2(f+2)); + f += 4; + fprintf(dbg, "\t FdView: %04x\n", get2(f)); + f += 2; + fprintf(dbg, "\t Scroll: %04x %04x\n", get2(f), get2(f+2)); + f += 4; + fprintf(dbg, "\t DChain: %08x\n", get4(f)); + f += 4; + f += 2; /* unused */ + fprintf(dbg, "\t CommID: %04x\n", get2(f)); + f += 2; + fprintf(dbg, "\t HomeID: %08x\n", get4(f)); + + return; + } + + return; + } + + /* + * print 4 byte access rights + * + */ + + void + dbg_print_accs(accs) + byte *accs; + { + if (dbg != NULL) { + if (accs[0] & 0x80) + fprintf(dbg, "OWNER, "); + if (accs[0] & 0x10) + fprintf(dbg, "BLANK ACCESS, "); + fprintf(dbg, "UARights %02x, World %02x, Group %02x, Owner %02x\n", + accs[0] & 0x07, accs[1], accs[2], accs[3]); + } + + return; + } + + /* + * print the AFP date + * + */ + + void + dbg_print_date(date) + time_t date; + { + char *ctime(); + time_t offset; + struct timeval tp; + struct timezone tzp; + + if (dbg != NULL) { + if (date == 0x80000000) { + fprintf(dbg, "\n"); + return; + } + #ifdef SOLARIS + tzset(); + offset = timezone; + #else /* SOLARIS */ + gettimeofday(&tp, &tzp); + offset = (time_t)(tzp.tz_minuteswest*60); + #endif /* SOLARIS */ + date = date - (((30*365+7)*(-24)*3600L)) + offset; + fprintf(dbg, "%s", ctime(&date)); + } + + return; + } + + /* + * print a path name (pascal string) + * + */ + + void + dbg_print_path(path) + char *path; + { + int i; + + if (dbg != NULL) { + fprintf(dbg, "\tMFile: \""); + for (i = 0; i < *path; i++) + if (isprint(*(path+i+1))) + fprintf(dbg, "%c", *(path+i+1)); + else + fprintf(dbg, "<0x%02x>", *(path+i+1)); + fprintf(dbg, "\"\n"); + } + } + #endif /* DEBUG_AFP_CMD */ *** applications/aufs/afpdt.c.orig Mon Oct 10 19:02:16 1994 --- applications/aufs/afpdt.c Mon Jun 26 15:58:02 1995 *************** *** 1,7 **** /* ! * $Author: djh $ $Date: 1994/10/10 09:02:04 $ ! * $Header: /mac/src/cap60/applications/aufs/RCS/afpdt.c,v 2.8 1994/10/10 09:02:04 djh Rel djh $ ! * $Revision: 2.8 $ * */ --- 1,7 ---- /* ! * $Author: djh $ $Date: 1995/06/26 05:57:53 $ ! * $Header: /local/mulga/mac/src/cap60/applications/aufs/RCS/afpdt.c,v 2.13 1995/06/26 05:57:53 djh Rel djh $ ! * $Revision: 2.13 $ * */ *************** *** 64,69 **** --- 64,73 ---- #include "afpudb.h" + #ifdef DEBUG_AFP_CMD + extern FILE *dbg; + #endif /* DEBUG_AFP_CMD */ + import int errno; private DeskTop *DeskTab[MAXVOLS]; /* table of open desktops by volume */ *************** *** 481,486 **** --- 485,512 ---- err = EtoIfile(file,&idir,&ipdir,&ivol,adc.adc_dirid, dt->dt_evol,adc.adc_ptype,adc.adc_path); + + #ifdef DEBUG_AFP_CMD + if (dbg != NULL) { + int i; + void dbg_print_path(); + fprintf(dbg, "\tDTRef: %d\n", adc.adc_dtrefnum); + fprintf(dbg, "\tDirID: %08x\n", adc.adc_dirid); + fprintf(dbg, "\tPType: %d\t(%s Names)\n", adc.adc_ptype, + (adc.adc_ptype == 1) ? "Short" : "Long"); + dbg_print_path(adc.adc_path); + if (err == noErr) + fprintf(dbg, "\tUPath: \"%s/%s\"\n", pathstr(ipdir), file); + else + fprintf(dbg, "\tUPath: \n", err); + fprintf(dbg, "\tComnt: (len %d) \"", *adc.adc_comment); + for (i = 0; i < *adc.adc_comment; i++) + fprintf(dbg, "%c", *(adc.adc_comment+i+1)); + fprintf(dbg, "\"\n"); + fflush(dbg); + } + #endif /* DEBUG_AFP_CMD */ + if (err != noErr) return(err); *************** *** 506,511 **** --- 532,554 ---- err = EtoIfile(file,&idir,&ipdir,&ivol,gcm.gcm_dirid, dt->dt_evol,gcm.gcm_ptype,gcm.gcm_path); + + #ifdef DEBUG_AFP_CMD + if (dbg != NULL) { + void dbg_print_path(); + fprintf(dbg, "\tDTRef: %d\n", gcm.gcm_dtrefnum); + fprintf(dbg, "\tDirID: %08x\n", gcm.gcm_dirid); + fprintf(dbg, "\tPType: %d\t(%s Names)\n", gcm.gcm_ptype, + (gcm.gcm_ptype == 1) ? "Short" : "Long"); + dbg_print_path(gcm.gcm_path); + if (err == noErr) + fprintf(dbg, "\tUPath: \"%s/%s\"\n", pathstr(ipdir), file); + else + fprintf(dbg, "\tUPath: \n", err); + fflush(dbg); + } + #endif /* DEBUG_AFP_CMD */ + if (err != noErr) return(err); *************** *** 515,520 **** --- 558,574 ---- *rl = pstrlen(r)+1; if (DBDSK) printf("FPGetComment: returns comment of length %d\n", *rl); + + #ifdef DEBUG_AFP_CMD + if (dbg != NULL) { + void dbg_print_name(); + fprintf(dbg, " Return Parameters:\n"); + fprintf(dbg, "\tComnt: (len %d)", *rl); + dbg_print_name("", r); + fflush(dbg); + } + #endif /* DEBUG_AFP_CMD */ + return(noErr); } *************** *** 562,567 **** --- 616,641 ---- err = EtoIfile(file,&idir,&ipdir,&ivol,aap.aap_dirid, dt->dt_evol,aap.aap_ptype,aap.aap_path); + + #ifdef DEBUG_AFP_CMD + if (dbg != NULL) { + void dbg_print_type(); + void dbg_print_path(); + fprintf(dbg, "\tDTRef: %d\n", aap.aap_dtrefnum); + fprintf(dbg, "\tDirID: %08x\n", aap.aap_dirid); + dbg_print_type("\tCreat:", aap.aap_fcreator); + fprintf(dbg, "\tApTag: %08x\n", aap.aap_apptag); + fprintf(dbg, "\tPType: %d\t(%s Names)\n", aap.aap_ptype, + (aap.aap_ptype == 1) ? "Short" : "Long"); + dbg_print_path(aap.aap_path); + if (err == noErr) + fprintf(dbg, "\tUPath: \"%s/%s\"\n", pathstr(ipdir), file); + else + fprintf(dbg, "\tUPath: \n", err); + fflush(dbg); + } + #endif /* DEBUG_AFP_CMD */ + if (err != noErr) return(err); *************** *** 631,644 **** GetAPPLPkt gap; APPLNode *ahead; DeskTop *dt; - int err; FileDirParm fdp; ntohPackX(PsGetAPPL,p,l,(byte *) &gap); if ((dt = VolGetDesk(gap.gap_dtrefnum)) == NILDT) return(aeParamErr); if (DBDSK) { char fc[5]; bcopy((char *)gap.gap_fcreator,(char *)fc,4); --- 705,732 ---- GetAPPLPkt gap; APPLNode *ahead; DeskTop *dt; FileDirParm fdp; + dword appltag; + int err; ntohPackX(PsGetAPPL,p,l,(byte *) &gap); if ((dt = VolGetDesk(gap.gap_dtrefnum)) == NILDT) return(aeParamErr); + #ifdef DEBUG_AFP_CMD + if (dbg != NULL) { + void dbg_print_type(); + void dbg_print_bmap(); + fprintf(dbg, "\tDTRef: %d\n", gap.gap_dtrefnum); + dbg_print_type("\tCreat:", gap.gap_fcreator); + fprintf(dbg, "\tAPidx: %d\n", gap.gap_applidx); + fprintf(dbg, "\tBtMap: %04x\t", gap.gap_bitmap); + dbg_print_bmap(gap.gap_bitmap, 0); + fflush(dbg); + } + #endif /* DEBUG_AFP_CMD */ + if (DBDSK) { char fc[5]; bcopy((char *)gap.gap_fcreator,(char *)fc,4); *************** *** 676,690 **** fdp.fdp_pdirid = ItoEdirid(ahead->an_ipdir,dt->dt_ivol); fdp.fdp_fbitmap = gap.gap_bitmap; fdp.fdp_dbitmap = 0; err = OSFileDirInfo(ahead->an_ipdir,NILDIR,ahead->an_fnam,&fdp,dt->dt_ivol); if (err != noErr) return(aeItemNotFound); if (FDP_ISDIR(fdp.fdp_flg)) /* should not happen */ return(aeItemNotFound); ! *rl = htonPackX(DirParmPackR,(byte *) &fdp,r); ! *rl += htonPackX(FilePackR,(byte *) &fdp,r+(*rl)); if (DBDSK) printf("FPGetAPPL: ...\n"); return(noErr); } --- 764,798 ---- fdp.fdp_pdirid = ItoEdirid(ahead->an_ipdir,dt->dt_ivol); fdp.fdp_fbitmap = gap.gap_bitmap; fdp.fdp_dbitmap = 0; + err = OSFileDirInfo(ahead->an_ipdir,NILDIR,ahead->an_fnam,&fdp,dt->dt_ivol); + if (err != noErr) return(aeItemNotFound); + if (FDP_ISDIR(fdp.fdp_flg)) /* should not happen */ return(aeItemNotFound); ! ! bcopy((char *)ahead->an_info.a_ATag, (char *)&appltag, 4); ! PackWord(fdp.fdp_fbitmap, r); ! PackDWord(appltag, r+2); ! *rl = 6 + htonPackX(FilePackR, (byte *)&fdp, r+6); ! if (DBDSK) printf("FPGetAPPL: ...\n"); + + #ifdef DEBUG_AFP_CMD + if (dbg != NULL) { + void dbg_print_bmap(); + fprintf(dbg, " Return Parameters:\n"); + fprintf(dbg, "\tBtMap: %04x\t", fdp.fdp_fbitmap); + dbg_print_bmap(fdp.fdp_fbitmap, 0); + fprintf(dbg, "\tAPTag: %08x\n", appltag); + dbg_print_parm(fdp.fdp_fbitmap, r+6, (*rl)-6, 0); + fflush(dbg); + } + #endif /* DEBUG_AFP_CMD */ + return(noErr); } *************** *** 709,714 **** --- 817,841 ---- err = EtoIfile(file,&idir,&ipdir,&ivol,rma.rma_dirid, dt->dt_evol,rma.rma_ptype,rma.rma_path); + + #ifdef DEBUG_AFP_CMD + if (dbg != NULL) { + void dbg_print_type(); + void dbg_print_path(); + fprintf(dbg, "\tDTRef: %d\n", rma.rma_refnum); + fprintf(dbg, "\tDirID: %08x\n", rma.rma_dirid); + dbg_print_type("\tCreat:", rma.rma_fcreator); + fprintf(dbg, "\tPType: %d\t(%s Names)\n", rma.rma_ptype, + (rma.rma_ptype == 1) ? "Short" : "Long"); + dbg_print_path(rma.rma_path); + if (err == noErr) + fprintf(dbg, "\tUPath: \"%s/%s\"\n", pathstr(ipdir), file); + else + fprintf(dbg, "\tUPath: \n", err); + fflush(dbg); + } + #endif /* DEBUG_AFP_CMD */ + if (err != noErr) return(err); *************** *** 746,758 **** ntohPackX(PsOpenDT,p,l,(byte *) &odt); ivol = EtoIVolid(odt.odt_volid); if (ivol < 0) return(ivol); - if (DBDSK) printf("FPOpenDT: ...\n"); if ((dt = VolGetDesk(odt.odt_volid)) == NILDT) { dt = (DeskTop *) malloc(sizeof(DeskTop)); dt->dt_ivol = ivol; --- 873,892 ---- ntohPackX(PsOpenDT,p,l,(byte *) &odt); + #ifdef DEBUG_AFP_CMD + if (dbg != NULL) { + fprintf(dbg, "\tVolID: %04x\n", odt.odt_volid); + fflush(dbg); + } + #endif /* DEBUG_AFP_CMD */ + ivol = EtoIVolid(odt.odt_volid); if (ivol < 0) return(ivol); if (DBDSK) printf("FPOpenDT: ...\n"); + if ((dt = VolGetDesk(odt.odt_volid)) == NILDT) { dt = (DeskTop *) malloc(sizeof(DeskTop)); dt->dt_ivol = ivol; *************** *** 765,770 **** --- 899,913 ---- VolSetDesk(odt.odt_volid,dt); /* tell volume about desktop */ PackWord(odt.odt_volid,r); /* return volid as DTRefnum */ *rl = sizeof(word); /* length of result */ + + #ifdef DEBUG_AFP_CMD + if (dbg != NULL) { + fprintf(dbg, " Return Parameters:\n"); + fprintf(dbg, "\tDTRef: %d\n", odt.odt_volid); + fflush(dbg); + } + #endif /* DEBUG_AFP_CMD */ + return(noErr); /* all done */ } *************** *** 795,800 **** --- 938,950 ---- ntohPackX(PsCloseDT,p,l,(byte *) &cdt); + #ifdef DEBUG_AFP_CMD + if (dbg != NULL) { + fprintf(dbg, "\tDTRef: %d\n", cdt.cdt_dtrefnum); + fflush(dbg); + } + #endif /* DEBUG_AFP_CMD */ + if (DBDSK) printf("FPCloseDT: ...\n"); *************** *** 992,997 **** --- 1142,1160 ---- ntohPackX(PsAddIcon,p,l,(byte *) &adi); + #ifdef DEBUG_AFP_CMD + if (dbg != NULL) { + void dbg_print_type(); + fprintf(dbg, "\tDTRef: %d\n", adi.adi_dtref); + dbg_print_type("\tCreat:", adi.adi_fcreator); + dbg_print_type("\tFlTyp:", adi.adi_ftype); + fprintf(dbg, "\tIcTyp: %d\n", adi.adi_icontype); + fprintf(dbg, "\tIcTag: %d\n", adi.adi_icontag); + fprintf(dbg, "\tBMSiz: %d\n", adi.adi_iconsize); + fflush(dbg); + } + #endif /* DEBUG_AFP_CMD */ + if ((dt = VolGetDesk(adi.adi_dtref)) == NULL) return(aeParamErr); *************** *** 1015,1020 **** --- 1178,1195 ---- return(comp); } + #ifdef DEBUG_AFP_CMD + if (dbg != NULL) { + void dbg_print_icon(); + if (adi.adi_icontype == 1) { + fprintf(dbg, "\tAIcon:\n"); + dbg_print_icon(icon, adi.adi_iconsize); + fprintf(dbg, "\n"); + } + fflush(dbg); + } + #endif /* DEBUG_AFP_CMD */ + /* Insert the new entry */ in = dtIconInsert(ihead, adi.adi_ftype, adi.adi_icontype, &replaced); /* assert in != NULL */ *************** *** 1082,1087 **** --- 1257,1275 ---- int len; ntohPackX(PsGetIcon,p,l,(byte *) &gic); + + #ifdef DEBUG_AFP_CMD + if (dbg != NULL) { + void dbg_print_type(); + fprintf(dbg, "\tDTRef: %d\n", gic.gic_dtrefnum); + dbg_print_type("\tCreat:", gic.gic_fcreator); + dbg_print_type("\tFlTyp:", gic.gic_ftype); + fprintf(dbg, "\tIcTyp: %d\n", gic.gic_itype); + fprintf(dbg, "\tIcLen: %d\n", gic.gic_length); + fflush(dbg); + } + #endif /* DEBUG_AFP_CMD */ + if ((dt = VolGetDesk(gic.gic_dtrefnum)) == NILDT) return(aeParamErr); *************** *** 1113,1118 **** --- 1301,1316 ---- return(aeItemNotFound); } *rl = len; + + #ifdef DEBUG_AFP_CMD + if (dbg != NULL) { + void dbg_print_icon(); + fprintf(dbg, " Return Parameters:\n"); + fprintf(dbg, "\tIcLen: %d\n", *rl); + dbg_print_icon(r, *rl); + } + #endif /* DEBUG_AFP_CMD */ + return(noErr); } *************** *** 1143,1153 **** --- 1341,1369 ---- err = EtoIfile(file,&idir,&ipdir,&ivol,rmc.rmc_dirid, dt->dt_evol,rmc.rmc_ptype,rmc.rmc_path); + + #ifdef DEBUG_AFP_CMD + if (dbg != NULL) { + void dbg_print_path(); + fprintf(dbg, "\tDTRef: %d\n", rmc.rmc_dtrefnum); + fprintf(dbg, "\tDirID: %08x\n", rmc.rmc_dirid); + fprintf(dbg, "\tPType: %d\t(%s Names)\n", rmc.rmc_ptype, + (rmc.rmc_ptype == 1) ? "Short" : "Long"); + dbg_print_path(rmc.rmc_path); + if (err == noErr) + fprintf(dbg, "\tUPath: \"%s/%s\"\n", pathstr(ipdir), file); + else + fprintf(dbg, "\tUPath: \n", err); + fflush(dbg); + } + #endif /* DEBUG_AFP_CMD */ + if (err != noErr) return(err); /* set comment to empty */ err = OSSetComment(ipdir,file,(byte *)"\0",0); + return(err); } *************** *** 1165,1170 **** --- 1381,1397 ---- int idx; ntohPackX(PsGetIconInfo,p,l,(byte *) &gii); + + #ifdef DEBUG_AFP_CMD + if (dbg != NULL) { + void dbg_print_type(); + fprintf(dbg, "\tDTRef: %d\n", gii.gii_dtrefnum); + dbg_print_type("\tCreat:", gii.gii_fcreator); + fprintf(dbg, "\tIcIdx: %d\n", gii.gii_iidx); + fflush(dbg); + } + #endif /* DEBUG_AFP_CMD */ + if ((dt = VolGetDesk(gii.gii_dtrefnum)) == NILDT) return(aeParamErr); *************** *** 1192,1197 **** --- 1419,1436 ---- giir.giir_zero = 0; giir.giir_size = ihead->in_info.i_bmsize; *rl = htonPackX(PsGetIconInfoReply, (byte *)&giir, r); + + #ifdef DEBUG_AFP_CMD + if (dbg != NULL) { + void dbg_print_type(); + fprintf(dbg, "\tIcTag: %d\n", giir.giir_itag); + dbg_print_type("\tFlTyp:", giir.giir_ftype); + fprintf(dbg, "\tIcTyp: %d\n", giir.giir_itype); + fprintf(dbg, "\tIcLen: %d\n", giir.giir_size); + fflush(dbg); + } + #endif /* DEBUG_AFP_CMD */ + return(noErr); } *************** *** 1843,1845 **** --- 2082,2156 ---- AVLMapTree(dt->dt_avlroot, wh == REMOVEAPPLIDB ? RemoveAPPLIDB : RemoveICONIDB, (char *) dt); } + + #ifdef DEBUG_AFP_CMD + /* + * print a 4 byte Creator or File Type + * + */ + + void + dbg_print_type(str, typ) + char *str; + byte *typ; + { + int i; + + if (dbg != NULL) { + fprintf(dbg, "%s '", str); + for (i= 0; i < 4; i++) + fprintf(dbg, "%c", (isprint(typ[i])) ? typ[i] : '?'); + fprintf(dbg, "'\n"); + } + + return; + } + + /* + * print out a representation of the ICN# + * + */ + + #define get2(s) (u_short)(((s)[0]<<8)|((s)[1])) + #define get4(s) (u_int)(((s)[0]<<24)|((s)[1]<<16)|((s)[2]<<8)|((s)[3])) + + void + dbg_print_icon(icn, len) + byte *icn; + int len; + { + u_char *p; + int i, j, k; + u_long data1, data2, mask; + + if (len != 256) + return; + + if (dbg != NULL) { + for (i = 0, p = icn; i < 32; i += 2, p += 8) { + for (j = 0; j < 2; j++) { + if (j == 1) + fprintf(dbg, "\t "); + data1 = get4(p+(j*128)); + data2 = get4(p+4+(j*128)); + for (k = 0; k < 32; k++) { + mask = ((u_long)0x80000000 >> k); + if (data1 & mask && data2 & mask) + fprintf(dbg, "8"); + else + if (data1 & mask) + fprintf(dbg, "\""); + else + if (data2 & mask) + fprintf(dbg, "o"); + else + fprintf(dbg, " "); + } + } + fprintf(dbg, "\n"); + } + } + + return; + } + #endif /* DEBUG_AFP_CMD */ *** applications/aufs/afpfile.c.orig Wed Jan 5 20:38:36 1994 --- applications/aufs/afpfile.c Mon Jun 12 16:58:51 1995 *************** *** 1,7 **** /* ! * $Author: djh $ $Date: 1994/01/05 09:38:03 $ ! * $Header: /mac/src/cap60/applications/aufs/RCS/afpfile.c,v 2.3 1994/01/05 09:38:03 djh Rel djh $ ! * $Revision: 2.3 $ * */ --- 1,7 ---- /* ! * $Author: djh $ $Date: 1995/06/12 06:58:18 $ ! * $Header: /mac/src/cap60/applications/aufs/RCS/afpfile.c,v 2.5 1995/06/12 06:58:18 djh Rel djh $ ! * $Revision: 2.5 $ * */ *************** *** 44,49 **** --- 44,53 ---- #include "afpntoh.h" #include "afps.h" + #ifdef DEBUG_AFP_CMD + extern FILE *dbg; + #endif /* DEBUG_AFP_CMD */ + /* * OSErr FPSetFileParms(...) * *************** *** 66,71 **** --- 70,97 ---- err = EtoIfile(file,&idir,&ipdir,&ivol,sfp.sfp_dirid, sfp.sfp_volid,sfp.sfp_ptype,sfp.sfp_path); + + #ifdef DEBUG_AFP_CMD + if (dbg != NULL) { + void dbg_print_bmap(); + void dbg_print_parm(); + void dbg_print_path(); + fprintf(dbg, "\tVolID: %04x\n", sfp.sfp_volid); + fprintf(dbg, "\tDirID: %08x\n", sfp.sfp_dirid); + fprintf(dbg, "\tBtMap: %08x\t", sfp.sfp_bitmap); + dbg_print_bmap(sfp.sfp_bitmap); + fprintf(dbg, "\tPType: %d\t(%s Names)\n", sfp.sfp_ptype, + (sfp.sfp_ptype == 1) ? "Short" : "Long"); + dbg_print_path(sfp.sfp_path); + if (err == noErr) + fprintf(dbg, "\tUPath: \"%s/%s\"\n", pathstr(ipdir), file); + else + fprintf(dbg, "\tUPath: \n", err); + dbg_print_parm(sfp.sfp_bitmap, p+len, l-len, 0); + fflush(dbg); + } + #endif /* DEBUG_AFP_CMD */ + if (err != noErr) return(err); *************** *** 100,105 **** --- 126,148 ---- ntohPackX(PsCreateFile,p,l,(byte *) &crf); err = EtoIfile(file,&idir,&ipdir,&ivol,crf.crf_dirid, crf.crf_volid,crf.crf_ptype,crf.crf_path); + + #ifdef DEBUG_AFP_CMD + if (dbg != NULL) { + void dbg_print_path(); + fprintf(dbg, "\tVolID: %04x\n", crf.crf_volid); + fprintf(dbg, "\tDirID: %08x\n", crf.crf_dirid); + fprintf(dbg, "\tPType: %d\t(%s Names)\n", crf.crf_ptype, + (crf.crf_ptype == 1) ? "Short" : "Long"); + dbg_print_path(crf.crf_path); + if (err == noErr) + fprintf(dbg, "\tUPath: \"%s/%s\"\n", pathstr(ipdir), file); + else + fprintf(dbg, "\tUPath: \n", err); + fflush(dbg); + } + #endif /* DEBUG_AFP_CMD */ + if (err != noErr) return(err); *************** *** 147,152 **** --- 190,217 ---- if (err != noErr) return(err); + #ifdef DEBUG_AFP_CMD + if (dbg != NULL) { + void dbg_print_path(); + fprintf(dbg, "\tSVolID: %04x\n", cpf.cpf_svolid); + fprintf(dbg, "\tSDirID: %08x\n", cpf.cpf_sdirid); + fprintf(dbg, "\tDVolID: %04x\n", cpf.cpf_dvolid); + fprintf(dbg, "\tDDirID: %08x\n", cpf.cpf_ddirid); + fprintf(dbg, "\tSPType: %d\t(%s Names)\n", cpf.cpf_sptype, + (cpf.cpf_sptype == 1) ? "Short" : "Long"); + dbg_print_path(cpf.cpf_spath); + fprintf(dbg, "\tSUPath: \"%s/%s\"\n", pathstr(sipdir), sfile); + fprintf(dbg, "\tDPType: %d\t(%s Names)\n", cpf.cpf_dptype, + (cpf.cpf_dptype == 1) ? "Short" : "Long"); + dbg_print_path(cpf.cpf_dpath); + fprintf(dbg, "\tDUPath: \"%s/%s\"\n", pathstr(dipdir), dfile); + fprintf(dbg, "\tNPType: %d\t(%s Names)\n", cpf.cpf_newtype, + (cpf.cpf_newtype == 1) ? "Short" : "Long"); + fprintf(dbg, "\tNMFile: \"%s\"\n", cpf.cpf_newname); + fflush(dbg); + } + #endif /* DEBUG_AFP_CMD */ + if (didir == NILDIR) /* destination directory */ return(aeParamErr); /* must be around */ *************** *** 207,212 **** --- 272,297 ---- if (err != noErr) return(err); + #ifdef DEBUG_AFP_CMD + if (dbg != NULL) { + void dbg_print_path(); + fprintf(dbg, "\tVolID: %04x\n", ren.ren_volid); + fprintf(dbg, "\tDirID: %08x\n", ren.ren_dirid); + fprintf(dbg, "\tPType: %d\t(%s Names)\n", ren.ren_ptype, + (ren.ren_ptype == 1) ? "Short" : "Long"); + dbg_print_path(ren.ren_path); + fprintf(dbg, "\tPPath: \"%s/%s\"\n", pathstr(ipdir), file); + fprintf(dbg, "\tNType: %d\t(%s Names)\n", ren.ren_ntype, + (ren.ren_ntype == 1) ? "Short" : "Long"); + dbg_print_path(ren.ren_npath); + fprintf(dbg, "\tNPath: \"%s/%s\"\n", pathstr(nipdir), nfile); + fprintf(dbg, "\tNwTyp: %d\t(%s Names)\n", ren.ren_ntype, + (ren.ren_ntype == 1) ? "Short" : "Long"); + dbg_print_path(ren.ren_npath); + fflush(dbg); + } + #endif /* DEBUG_AFP_CMD */ + if (DBFIL) { printf("FPRename path=%s, name=%s,",pathstr(ipdir),file); printf("to path=%s, name=%s\n",pathstr(nipdir),nfile); *************** *** 247,258 **** --- 332,362 ---- err = EtoIfile(file,&idir,&ipdir,&ivol,del.del_dirid, del.del_volid,del.del_ptype,del.del_path); + #ifdef DEBUG_AFP_CMD + if (dbg != NULL) { + void dbg_print_path(); + fprintf(dbg, "\tVolID: %04x\n", del.del_volid); + fprintf(dbg, "\tDirID: %08x\n", del.del_dirid); + fprintf(dbg, "\tPType: %d\t(%s Names)\n", del.del_ptype, + (del.del_ptype == 1) ? "Short" : "Long"); + dbg_print_path(del.del_path); + if (err == noErr) + fprintf(dbg, "\tUPath: \"%s/%s\"\n", pathstr(ipdir), file); + else + fprintf(dbg, "\tUPath: \n", err); + fflush(dbg); + } + #endif /* DEBUG_AFP_CMD */ + if (err != noErr) return(err); if (DBFIL) printf("FPDelete: path=%s file=%s\n",pathstr(ipdir),file); + if (is_open_file(ipdir, file)) + return(aeFileBusy); + #ifdef STAT_CACHE OScd(pathstr(ipdir)); /* so we don't try and delete current directory */ #endif STAT_CACHE *************** *** 306,311 **** --- 410,437 ---- if (err != noErr) return(err); + #ifdef DEBUG_AFP_CMD + if (dbg != NULL) { + void dbg_print_path(); + fprintf(dbg, "\tSVolID: %04x\n", mov.mov_volid); + fprintf(dbg, "\tSDirID: %08x\n", mov.mov_sdirid); + fprintf(dbg, "\tDVolID: %04x\n", mov.mov_volid); + fprintf(dbg, "\tDDirID: %08x\n", mov.mov_ddirid); + fprintf(dbg, "\tSPType: %d\t(%s Names)\n", mov.mov_sptype, + (mov.mov_sptype == 1) ? "Short" : "Long"); + dbg_print_path(mov.mov_spath); + fprintf(dbg, "\tSUPath: \"%s/%s\"\n", pathstr(ipdir), file); + fprintf(dbg, "\tDPType: %d\t(%s Names)\n", mov.mov_dptype, + (mov.mov_dptype == 1) ? "Short" : "Long"); + dbg_print_path(mov.mov_dpath); + fprintf(dbg, "\tDUPath: \"%s/%s\"\n", pathstr(nipdir), nfile); + fprintf(dbg, "\tNPType: %d\t(%s Names)\n", mov.mov_newtype, + (mov.mov_newtype == 1) ? "Short" : "Long"); + dbg_print_path(mov.mov_newname); + fflush(dbg); + } + #endif /* DEBUG_AFP_CMD */ + /* nidir, nfile must be a directory! */ if (nidir == NILDIR) return(aeParamErr); *************** *** 375,380 **** --- 501,522 ---- xch.exc_volid,xch.exc_bptype,xch.exc_bpath); if (err != noErr) return(err); + + #ifdef DEBUG_AFP_CMD + if (dbg != NULL) { + void dbg_print_path(); + fprintf(dbg, "\tEVolID: %04x\n", xch.exc_volid); + fprintf(dbg, "\tSDirID: %08x\n", xch.exc_adirid); + fprintf(dbg, "\tDDirID: %08x\n", xch.exc_bdirid); + fprintf(dbg, "\tSType: %d\t(%s Names)\n", xch.exc_aptype, + (xch.exc_aptype == 1) ? "Short" : "Long"); + dbg_print_path(xch.exc_apath); + fprintf(dbg, "\tDType: %d\t(%s Names)\n", xch.exc_bptype, + (xch.exc_bptype == 1) ? "Short" : "Long"); + dbg_print_path(xch.exc_bpath); + fflush(dbg); + } + #endif /* DEBUG_AFP_CMD */ /* * Neither a nor b should be directories. *** applications/aufs/afpfork.c.orig Thu Sep 9 16:56:57 1993 --- applications/aufs/afpfork.c Mon Jun 26 15:50:04 1995 *************** *** 1,7 **** /* ! * $Author: djh $ $Date: 1993/09/09 06:56:34 $ ! * $Header: /mac/src/cap60/applications/aufs/RCS/afpfork.c,v 2.5 1993/09/09 06:56:34 djh Rel djh $ ! * $Revision: 2.5 $ */ /* --- 1,7 ---- /* ! * $Author: djh $ $Date: 1995/06/26 05:49:55 $ ! * $Header: /local/mulga/mac/src/cap60/applications/aufs/RCS/afpfork.c,v 2.8 1995/06/26 05:49:55 djh Rel djh $ ! * $Revision: 2.8 $ */ /* *************** *** 45,50 **** --- 45,53 ---- #include "afpntoh.h" #include "afposncs.h" + #ifdef DEBUG_AFP_CMD + extern FILE *dbg; + #endif /* DEBUG_AFP_CMD */ typedef struct { int ofn_fd; /* file descriptor */ *************** *** 154,159 **** --- 157,185 ---- return(0); } + /* + * determine if file is already open + * + */ + + int + is_open_file(ipdir, file) + IDirP ipdir; + char *file; + { + OFN *ofn; + + if (!oinit) + return(0); + + for (ofn = OFNTBL; ofn < OFNTBL+MaxOFN; ofn++) + if (ofn->ofn_flgs & OF_INUSE) + if (ofn->ofn_ipdir == ipdir + && strcmp(ofn->ofn_fnam, file) == 0) + return(1); + + return(0); + } /* * OSErr FPGetForkParms(...) *************** *** 187,192 **** --- 213,229 ---- OFN *ofn; ntohPackX(PsGetForkParms,p,l,(byte *) &gfp); + + #ifdef DEBUG_AFP_CMD + if (dbg != NULL) { + void dbg_print_bmap(); + fprintf(dbg, "\tRefNum: %d\n", gfp.gfp_refnum); + fprintf(dbg, "\tBitMap: %04x\t", gfp.gfp_bitmap); + dbg_print_bmap(gfp.gfp_bitmap, 0); + fflush(dbg); + } + #endif /* DEBUG_AFP_CMD */ + if ((ofn = EtoIOFN(gfp.gfp_refnum)) == NULL) return(aeParamErr); *************** *** 200,205 **** --- 237,252 ---- PackWord(gfp.gfp_bitmap,r); *rl = 2; *rl += htonPackX(FilePackR,(byte *) &fdp,r+(*rl)); + + #ifdef DEBUG_AFP_CMD + if (dbg != NULL) { + void dbg_print_parm(); + fprintf(dbg, " Return Parameters:\n"); + dbg_print_parm(fdp.fdp_fbitmap, r+2, (*rl)-2, 0); + fflush(dbg); + } + #endif /* DEBUG_AFP_CMD */ + return(noErr); } *************** *** 235,240 **** --- 282,300 ---- sdword len; ntohPackX(PsSetForkParms,p,l,(byte *) &sfkp); + + #ifdef DEBUG_AFP_CMD + if (dbg != NULL) { + void dbg_print_bmap(); + fprintf(dbg, "\tRefNum: %d\n", sfkp.sfkp_refnum); + fprintf(dbg, "\tBitMap: %04x\t", sfkp.sfkp_bitmap); + dbg_print_bmap(sfkp.sfkp_bitmap, 0); + fprintf(dbg, "\tForkLn: %d\n", + (sfkp.sfkp_bitmap & FP_DFLEN) ? sfkp.sfkp_dflen : sfkp.sfkp_rflen); + fflush(dbg); + } + #endif /* DEBUG_AFP_CMD */ + if ((ofn = EtoIOFN(sfkp.sfkp_refnum)) == NULL) return(aeParamErr); *************** *** 272,277 **** --- 332,360 ---- err = EtoIfile(file,&idir,&ipdir,&ivol,ofk.ofk_dirid, ofk.ofk_volid,ofk.ofk_ptype,ofk.ofk_path); + #ifdef DEBUG_AFP_CMD + if (dbg != NULL) { + void dbg_print_mode(); + void dbg_print_bmap(); + void dbg_print_path(); + fprintf(dbg, "\tOFork: %s\n", (ofk.ofk_rdflg) ? "Resource" : "Data"); + fprintf(dbg, "\tVolID: %04x\n", ofk.ofk_volid); + fprintf(dbg, "\tDirID: %08x\n", ofk.ofk_dirid); + fprintf(dbg, "\tBtMap: %04x\t", ofk.ofk_bitmap); + dbg_print_bmap(ofk.ofk_bitmap, 0); + fprintf(dbg, "\tAMode: %04x\t", ofk.ofk_mode); + dbg_print_mode(ofk.ofk_mode); + fprintf(dbg, "\tPType: %d\t(%s Names)\n", ofk.ofk_ptype, + (ofk.ofk_ptype == 1) ? "Short" : "Long"); + dbg_print_path(ofk.ofk_path); + if (err == noErr) + fprintf(dbg, "\tUPath: \"%s/%s\"\n", pathstr(ipdir), file); + else + fprintf(dbg, "\tUPath: \n", err); + fflush(dbg); + } + #endif /* DEBUG_AFP_CMD */ + if (err != noErr) return(err); *************** *** 359,364 **** --- 442,461 ---- return(err); } + #ifdef DEBUG_AFP_CMD + if (dbg != NULL) { + void dbg_print_parm(); + void dbg_print_bmap(); + fprintf(dbg, " Return Parameters:\n"); + fprintf(dbg, "\tFDescr: %d\n", ofn->ofn_fd); + fprintf(dbg, "\tBitMap: %04x\t", ofr.ofkr_bitmap); + dbg_print_bmap(ofk.ofk_bitmap, 0); + fprintf(dbg, "\tRefNum: %d\n", ofr.ofkr_refnum); + dbg_print_parm(ofr.ofkr_bitmap, r+len, *rl, 0); + fflush(dbg); + } + #endif /* DEBUG_AFP_CMD */ + return(noErr); } *************** *** 369,378 **** --- 466,484 ---- int l,*rl; { CloseForkPkt cfk; + word attr; OFN *ofn; int err; ntohPackX(PsCloseFork,p,l,(byte *) &cfk); + + #ifdef DEBUG_AFP_CMD + if (dbg != NULL) { + fprintf(dbg, "\tRefNum: %d\n", cfk.cfk_refnum); + fflush(dbg); + } + #endif /* DEBUG_AFP_CMD */ + if (DBFRK) printf("CloseFork: refnum=%d\n",cfk.cfk_refnum); if ((ofn = EtoIOFN(cfk.cfk_refnum)) == NULL) *************** *** 382,387 **** --- 488,500 ---- VolModified(ofn->ofn_ivol); /* then set volume modification dt */ err = (ofn->ofn_flgs & OF_NOTOPEN) ? noErr : OSClose(ofn->ofn_fd); + + if (err == noErr) { + OSGetAttr(ofn->ofn_ipdir, ofn->ofn_fnam, &attr); + attr &= ~((ofn->ofn_type == F_DATA) ? FPA_DAO : FPA_RAO); + OSSetAttr(ofn->ofn_ipdir, ofn->ofn_fnam, attr); + } + relofn(ofn); return(err); } *************** *** 406,411 **** --- 519,536 ---- extern int sqs; /* get max send quantum size */ ntohPackX(PsRead,p,l,(byte *) &rp); + + #ifdef DEBUG_AFP_CMD + if (dbg != NULL) { + fprintf(dbg, "\tRefNum: %d\n", rp.rdf_refnum); + fprintf(dbg, "\tOffSet: %d\n", rp.rdf_offset); + fprintf(dbg, "\tReqCnt: %d\n", rp.rdf_reqcnt); + fprintf(dbg, "\tNLMask: %d\n", rp.rdf_flag); + fprintf(dbg, "\tNLChar: 0x%02x\n", rp.rdf_nlchar); + fflush(dbg); + } + #endif /* DEBUG_AFP_CMD */ + if (DBFRK) printf("Read: ofn=%d, offset=%d, reqcnt=%d, flg=%d, nlc=%02x\n", rp.rdf_refnum,rp.rdf_offset,rp.rdf_reqcnt, *************** *** 439,444 **** --- 564,580 ---- extern int n_rrpkts; ntohPackX(PsWrite,p,l,(byte *) &wrt); + + #ifdef DEBUG_AFP_CMD + if (dbg != NULL) { + fprintf(dbg, "\tS/EFlg: %02x\n", wrt.wrt_flag); + fprintf(dbg, "\tRefNum: %d\n", wrt.wrt_refnum); + fprintf(dbg, "\tOffset: %d\n", wrt.wrt_offset); + fprintf(dbg, "\tReqCnt: %d\n", wrt.wrt_reqcnt); + fflush(dbg); + } + #endif /* DEBUG_AFP_CMD */ + if ((ofn = EtoIOFN(wrt.wrt_refnum)) == NULL) return(aeParamErr); if (DBFRK) *************** *** 462,467 **** --- 598,612 ---- return(err); PackDWord(ofn->ofn_pos,r); *rl = sizeof(ofn->ofn_pos); + + #ifdef DEBUG_AFP_CMD + if (dbg != NULL) { + fprintf(dbg, " Return Parameters:\n"); + fprintf(dbg, "\tWrittn: %d\n", ofn->ofn_pos); + fflush(dbg); + } + #endif /* DEBUG_AFP_CMD */ + return(noErr); } *************** *** 475,480 **** --- 620,633 ---- FlushForkPkt flf; ntohPackX(PsFlush, p, l, (byte *)&flf); + + #ifdef DEBUG_AFP_CMD + if (dbg != NULL ) { + fprintf(dbg, "\tRefNum: %d\n", flf.flf_refnum); + fflush(dbg); + } + #endif /* DEBUG_AFP_CMD */ + if ((ofn = EtoIOFN(flf.flf_refnum)) == NULL) return(aeParamErr); if (DBFRK) *************** *** 493,498 **** --- 646,663 ---- OSErr err; ntohPackX(PsByteRangeLock, p, l, (byte *)&brl); + + #ifdef DEBUG_AFP_CMD + if (dbg != NULL) { + fprintf(dbg, "\tULFlag: %s\n", (brl.brl_flg & 0x01) ? "UNLOCK" : "LOCK"); + fprintf(dbg, "\tSEFlag: %s\n", (brl.brl_flg & 0x80) ? "END" : "START"); + fprintf(dbg, "\tRefNum: %d\n", brl.brl_refnum); + fprintf(dbg, "\tOffset: %d\n", brl.brl_offset); + fprintf(dbg, "\tLength: %d\n", brl.brl_length); + fflush(dbg); + } + #endif /* DEBUG_AFP_CMD */ + if ((ofn = EtoIOFN(brl.brl_refnum)) == NULL) return(aeParamErr); if (DBFRK) *************** *** 507,512 **** --- 672,705 ---- } PackDWord(ofn->ofn_pos,r); *rl = sizeof(ofn->ofn_pos); + + #ifdef DEBUG_AFP_CMD + if (dbg != NULL) { + fprintf(dbg, " Return Parameters:\n"); + fprintf(dbg, "\tRStart: %d\n", ofn->ofn_pos); + fflush(dbg); + } + #endif /* DEBUG_AFP_CMD */ + return(noErr); } + #ifdef DEBUG_AFP_CMD + void + dbg_print_mode(mode) + u_short mode; + { + if (dbg != NULL) { + fprintf(dbg, "("); + if (mode & 0x0001) + fprintf(dbg, "Read "); + if (mode & 0x0002) + fprintf(dbg, "Write "); + if (mode & 0x0004) + fprintf(dbg, "DenyRead "); + if (mode & 0x0008) + fprintf(dbg, "DenyWrite "); + fprintf(dbg, ")\n"); + } + } + #endif /* DEBUG_AFP_CMD */ *** applications/aufs/afpserver.c.orig Mon Jan 31 18:08:26 1994 --- applications/aufs/afpserver.c Fri Jun 30 08:43:01 1995 *************** *** 1,7 **** /* ! * $Author: djh $ $Date: 1994/01/31 07:07:50 $ ! * $Header: /mac/src/cap60/applications/aufs/RCS/afpserver.c,v 2.8 1994/01/31 07:07:50 djh Rel djh $ ! * $Revision: 2.8 $ * */ --- 1,7 ---- /* ! * $Author: djh $ $Date: 1995/06/29 22:42:37 $ ! * $Header: /mac/src/cap60/applications/aufs/RCS/afpserver.c,v 2.13 1995/06/29 22:42:37 djh Rel djh $ ! * $Revision: 2.13 $ * */ *************** *** 57,67 **** --- 57,76 ---- # include #endif + #ifdef DISTRIB_PASSWDS + #include + char *distribpassfile = NULL; + #endif /* DISTRIB_PASSWDS */ + /* consistency */ #ifdef USETIMES # define NORUSAGE #endif + #ifdef DEBUG_AFP_CMD + extern FILE *dbg; + #endif /* DEBUG_AFP_CMD */ + typedef struct { int dsp_cmd; PFE dsp_rtn; *************** *** 100,109 **** {NULL, AFPVersionUnknown} }; - #define MAX_USE_UAM 4 /* maximum number at one time */ #define NUAM "No User Authent" #define CUAM "Cleartxt passwrd" #define RUAM "Randnum exchange" private int numuam = 0; struct afpuamstruct { char *uamname; --- 109,121 ---- {NULL, AFPVersionUnknown} }; #define NUAM "No User Authent" #define CUAM "Cleartxt passwrd" #define RUAM "Randnum exchange" + #define TUAM "2-Way Randnum exchange" + + #define MAX_USE_UAM 5 /* maximum number at one time */ + private int numuam = 0; struct afpuamstruct { char *uamname; *************** *** 116,124 **** UAMP_USER|UAMP_PASS|UAMP_ZERO, /* user and password for cleartext */ /* zero means put a zero to even */ /* out packet between user & passwd */ ! UAMP_USER /* user only in randnum */ ! /* (not implemented) */ ! }; #define AFPUAMSZ (MAX_USE_UAM*17+1) /* room for IndStr */ --- 128,136 ---- UAMP_USER|UAMP_PASS|UAMP_ZERO, /* user and password for cleartext */ /* zero means put a zero to even */ /* out packet between user & passwd */ ! UAMP_USER, /* user only in randnum */ ! UAMP_USER /* user only in 2-way rand */ ! }; #define AFPUAMSZ (MAX_USE_UAM*17+1) /* room for IndStr */ *************** *** 236,242 **** #endif STAT_CACHE } ! private int loggedin = FALSE; OSErr SrvrDispatch(pkt,len,rsp,rlen,cno,reqref) --- 248,267 ---- #endif STAT_CACHE } ! /* ! * login states ! * ! */ ! #define LOGGED_NY 0x00 /* not yet logged in */ ! #define LOGGED_IN 0x01 /* authorised OK */ ! #define LOGGED_PX 0x02 /* password expired */ ! ! private int loginstate = LOGGED_NY; ! ! /* ! * command dispatcher ! * ! */ OSErr SrvrDispatch(pkt,len,rsp,rlen,cno,reqref) *************** *** 249,259 **** int err; byte *p; byte cmd; *rlen = 0; cmd = *pkt; ! if ((d = DispTab[cmd]) == (AFPDispEntry *) 0) { printf("SrvrDispatch: Unknown cmd=%d (%x)\n",cmd,cmd); DumpBuf(pkt,len,"Unknown Cmd",cmd); return(aeCallNotSupported); --- 274,304 ---- int err; byte *p; byte cmd; + #ifdef DEBUG_AFP_CMD + time_t diff; + #endif /* DEBUG_AFP_CMD */ *rlen = 0; cmd = *pkt; ! ! d = DispTab[cmd]; ! ! #ifdef DEBUG_AFP_CMD ! if (dbg != NULL) { ! char *ctime(); ! time_t now; ! time(&now); ! diff = clock(); ! if (d == (AFPDispEntry *)0) ! fprintf(dbg, "## UNKNOWN (%d) %s\n", cmd, ctime(&now)); ! else ! fprintf(dbg, "## %s (%d) %s", d->dsp_name, cmd, ctime(&now)); ! fflush(dbg); ! } ! #endif /* DEBUG_AFP_CMD */ ! ! if (d == (AFPDispEntry *) 0) { printf("SrvrDispatch: Unknown cmd=%d (%x)\n",cmd,cmd); DumpBuf(pkt,len,"Unknown Cmd",cmd); return(aeCallNotSupported); *************** *** 272,286 **** if (statflg) clockstart(); ! if (!loggedin && d->dsp_cmd != AFPLogin && d->dsp_cmd != AFPLoginCont) { ! logit(0,"SrvrDispath: Security. Cmd before login %s\n",d->dsp_name); err = aeMiscErr; } else { ! if (d->dsp_flg & DSPF_DOESSPWRITE) ! err = (*d->dsp_rtn)(pkt,len,rsp,rlen,cno,reqref); ! else ! err = (*d->dsp_rtn)(pkt,len,rsp,rlen); } if (statflg) clockend(d); --- 317,348 ---- if (statflg) clockstart(); ! if (loginstate == 0 ! && d->dsp_cmd != AFPLogin ! && d->dsp_cmd != AFPLoginCont) { ! logit(0,"SrvrDispatch: Security. Cmd before login %s\n",d->dsp_name); err = aeMiscErr; } else { ! if (loginstate & LOGGED_PX ! && d->dsp_cmd != AFPLogout ! && d->dsp_cmd != AFPChgPasswd) { ! logit(0,"SrvrDispatch: Security. Cmd before ChangePass %s\n",d->dsp_name); ! err = aePwdExpired; ! } else { ! if (d->dsp_flg & DSPF_DOESSPWRITE) ! err = (*d->dsp_rtn)(pkt,len,rsp,rlen,cno,reqref); ! else ! err = (*d->dsp_rtn)(pkt,len,rsp,rlen); ! } ! } ! ! #ifdef DEBUG_AFP_CMD ! if (dbg != NULL) { ! fprintf(dbg, "## %s returns %d (%s) [%4.2f mS]\n\n\n", d->dsp_name, ! err, afperr(err), ((float)((float)clock()-(float)diff))/1000); ! fflush(dbg); } + #endif /* DEBUG_AFP_CMD */ if (statflg) clockend(d); *************** *** 294,299 **** --- 356,362 ---- if (d->dsp_flg & DSPF_DMPOUT) DumpBuf(rsp,*rlen,d->dsp_name,cmd); + return(err); } *************** *** 341,346 **** --- 404,414 ---- printf(" ... too large to print ... "); } + /* + * Map a user name to a user ID, + * or a group name to a group ID. + * + */ /*ARGSUSED*/ OSErr *************** *** 354,367 **** --- 422,460 ---- MNPPtr mnp = (MNPPtr) p; cpyp2cstr(name,mnp->mpn_name); /* copy into c string */ + + #ifdef DEBUG_AFP_CMD + if (dbg != NULL) { + void dbg_print_func(); + fprintf(dbg, "\tMapFn: %d\t", (int)mnp->mpn_fcn); + dbg_print_func((int)mnp->mpn_fcn, 1); + fprintf(dbg, "\tMapNm: \"%s\"\n", name); + fflush(dbg); + } + #endif /* DEBUG_AFP_CMD */ + err = OSMapName(mnp->mpn_fcn,name,&id); if (err != noErr) return(err); PackDWord(id,r); /* pack long format */ *rl = 4; /* length of reply */ + + #ifdef DEBUG_AFP_CMD + if (dbg != NULL) { + fprintf(dbg, " Return Parameters:\n"); + fprintf(dbg, "\tMapID: %08x\n", id); + fflush(dbg); + } + #endif /* DEBUG_AFP_CMD */ + return(noErr); } + /* + * Map a user ID to a user name, + * or a group ID to a group name. + * + */ OSErr FPMapID(p,l,r,rl) *************** *** 373,383 **** --- 466,496 ---- MapIDPkt mip; ntohPackX(PsMapID,p,l,(byte *) &mip); + + #ifdef DEBUG_AFP_CMD + if (dbg != NULL) { + void dbg_print_func(); + fprintf(dbg, "\tMapFn: %d\t", (int)mip.mpi_fcn); + dbg_print_func((int)mip.mpi_fcn, 0); + fprintf(dbg, "\tMapID: %08x\n", mip.mpi_id); + fflush(dbg); + } + #endif /* DEBUG_AFP_CMD */ + err = OSMapID(mip.mpi_fcn,name,mip.mpi_id); if (err != noErr) return(err); cpyc2pstr(r,name); /* copy to pascal string for return */ *rl = strlen(name)+1; /* return length of reply packet */ + + #ifdef DEBUG_AFP_CMD + if (dbg != NULL) { + fprintf(dbg, " Return Parameters:\n"); + fprintf(dbg, "\tMapNm: \"%s\"\n", name); + fflush(dbg); + } + #endif /* DEBUG_AFP_CMD */ + return(noErr); } *************** *** 450,465 **** numuam++; } ! /* follow vars are used for randnum exchange */ private LoginReplyPkt rne = { /* initialize to minimize */ 0x0, /* possiblity of bad transaction */ 0xffff, /* when starting */ {0x1,0x2,0x3,0x4,0x5,0x6,0x7,0x8} }; private char username[50]; /* some reasonable length */ int sessvers = 0; /* keep protocol version */ /*ARGSUSED*/ OSErr FPLogin(p,l,r,rl) --- 563,609 ---- numuam++; } ! #ifdef DISTRIB_PASSWDS ! export void ! allow2wayrand(pw) ! char *pw; ! { ! /* ! * 2-Way implies Randnum for ! * ChangePasswd function. ! * ! */ ! distribpassfile = pw; ! afpuams[numuam].uamname = RUAM; ! afpuams[numuam].uam = UAM_RANDNUM; ! numuam++; ! afpuams[numuam].uamname = TUAM; ! afpuams[numuam].uam = UAM_2WAYRAND; ! numuam++; ! ! return; ! } ! #endif /* DISTRIB_PASSWDS */ ! ! /* ! * following vars are used for randnum exchange ! * ! */ private LoginReplyPkt rne = { /* initialize to minimize */ 0x0, /* possiblity of bad transaction */ 0xffff, /* when starting */ {0x1,0x2,0x3,0x4,0x5,0x6,0x7,0x8} }; + private int useruam; /* UAM_RANDNUM or UAM_2WAYRAND */ private char username[50]; /* some reasonable length */ int sessvers = 0; /* keep protocol version */ + /* + * establish an AFP session with the server + * + */ + /*ARGSUSED*/ OSErr FPLogin(p,l,r,rl) *************** *** 474,497 **** #ifdef SHORT_NAMES int temp; #endif SHORT_NAMES ! if (loggedin) /* already logged in */ return(aeMiscErr); (void) ntohPackX(PsLogin,p,l,(byte *) &lg); - /* locate user authentication method and unpack accordingly */ if ((sessvers = mapverstr(lg.log_ver)) == AFPVersionUnknown) { logit(0,"Bad version %s", lg.log_ver); return(aeBadVersNum); } ! /* mactime <-> unix time is different for afp 1.1 */ ! /* this calldown is to afpcmd */ ! InitPackTime(sessvers == AFPVersion1DOT0); ! ! if ((uam = mapuamstr(lg.log_uam)) == UAM_UNKNOWN) { /* map the uam */ logit(0,"BAD UAM %s in connection attempt", lg.log_uam); ! return(aeBadUAM); /* no... forget it */ } #ifdef SHORT_NAMES temp = 3 + p[1] + p[p[1] +2]; --- 618,658 ---- #ifdef SHORT_NAMES int temp; #endif SHORT_NAMES ! ! if (loginstate) /* already logged in */ return(aeMiscErr); (void) ntohPackX(PsLogin,p,l,(byte *) &lg); + #ifdef DEBUG_AFP_CMD + if (dbg != NULL) { + fprintf(dbg, "\tAFPVer: \"%s\"\n", (char *)lg.log_ver); + fprintf(dbg, "\tAFPUAM: \"%s\"\n", (char *)lg.log_uam); + fflush(dbg); + } + #endif /* DEBUG_AFP_CMD */ + + /* + * locate AFP version and UAM so we can unpack accordingly + * + */ if ((sessvers = mapverstr(lg.log_ver)) == AFPVersionUnknown) { logit(0,"Bad version %s", lg.log_ver); return(aeBadVersNum); } ! if ((uam = mapuamstr(lg.log_uam)) == UAM_UNKNOWN) { logit(0,"BAD UAM %s in connection attempt", lg.log_uam); ! return(aeBadUAM); /* no... forget it */ } + if (sessvers < AFPVersion2DOT1 && uam == UAM_2WAYRAND) + return(aeBadUAM); + + /* + * mactime <-> unix time is different for afp 1.1 + * this calldown is to afpcmd + * + */ + InitPackTime(sessvers == AFPVersion1DOT0); #ifdef SHORT_NAMES temp = 3 + p[1] + p[p[1] +2]; *************** *** 504,509 **** --- 665,679 ---- (void) ntohPackXbitmap(PsLogin,p,l,(byte *) &lg, uamflags[uam]); #endif SHORT_NAMES + #ifdef DEBUG_AFP_CMD + if (dbg != NULL) { + fprintf(dbg, "\tUserNm: \"%s\"\n", (char *)lg.log_user); + if (uam == UAM_CLEAR) + fprintf(dbg, "\tUserPw: (%d bytes)\n", strlen(lg.log_passwd)); + fflush(dbg); + } + #endif /* DEBUG_AFP_CMD */ + #ifdef LOGIN_AUTH_PROG if (login_auth_prog) { sprintf(log_command, "%s \"%d\" \"%d\" \"%s\" \"%s\"", *************** *** 516,537 **** } #endif LOGIN_AUTH_PROG ! if (uam == UAM_RANDNUM) { if ((err = OSLoginRand(lg.log_user)) != noErr) return(err); for (i = 0; i < 8; i++) rne.logr_randnum[i] = (byte)OSRandom(); strcpy(username, lg.log_user); /* remember it */ ! rne.logr_flag = UAMP_RAND|UAMP_INUM; rne.logr_idnum = OSRandom(); /* some random number */ *rl = htonPackXbitmap(PsLoginReply, (byte *)&rne, r, rne.logr_flag); return(aeAuthContinue); } if (uamflags[uam] & UAMP_PASS) { bcopy(lg.log_passwd,upwd,MAXPASSWD); /* copy the password */ upwd[MAXPASSWD] = '\0'; /* make sure null terminated */ } if (DBSRV) { printf("Login ver=%s, uam=%s, user=%s, pwd=%s\n", lg.log_ver,lg.log_uam, --- 686,728 ---- } #endif LOGIN_AUTH_PROG ! /* ! * 'Randnum exchange' or '2-Way Randnum exchange' ! * ! */ ! if (uam == UAM_RANDNUM || uam == UAM_2WAYRAND) { if ((err = OSLoginRand(lg.log_user)) != noErr) return(err); for (i = 0; i < 8; i++) rne.logr_randnum[i] = (byte)OSRandom(); + useruam = uam; strcpy(username, lg.log_user); /* remember it */ ! rne.logr_flag = UAMP_RAND | UAMP_INUM; rne.logr_idnum = OSRandom(); /* some random number */ *rl = htonPackXbitmap(PsLoginReply, (byte *)&rne, r, rne.logr_flag); + #ifdef DEBUG_AFP_CMD + if (dbg != NULL) { + fprintf(dbg, " Return Parameters:\n"); + fprintf(dbg, "\tAFPID: %04x\n", rne.logr_idnum); + fprintf(dbg, "\tRandm: "); + for (i = 0; i < 8; i++) + fprintf(dbg, "%02x", rne.logr_randnum[i]); + fprintf(dbg, "\n"); + fflush(dbg); + } + #endif /* DEBUG_AFP_CMD */ return(aeAuthContinue); } + /* + * 'Cleartxt Passwrd' + * + */ if (uamflags[uam] & UAMP_PASS) { bcopy(lg.log_passwd,upwd,MAXPASSWD); /* copy the password */ upwd[MAXPASSWD] = '\0'; /* make sure null terminated */ } + if (DBSRV) { printf("Login ver=%s, uam=%s, user=%s, pwd=%s\n", lg.log_ver,lg.log_uam, *************** *** 539,552 **** ((uamflags[uam] & UAMP_PASS) ? upwd : "no passwd")); } ! err = OSLogin((char *)lg.log_user, upwd, NULL, uam); ! if (err == noErr) { ! loggedin = TRUE; logit(0,"Using protocol '%s'", lg.log_ver); } return(err); } /*ARGSUSED*/ OSErr FPLoginCont(p,l,r,rl) --- 730,748 ---- ((uamflags[uam] & UAMP_PASS) ? upwd : "no passwd")); } ! if ((err = OSLogin((char *)lg.log_user, upwd, NULL, uam)) == noErr) { logit(0,"Using protocol '%s'", lg.log_ver); + loginstate = LOGGED_IN; } + return(err); } + /* + * continue login and user authentication process started by FPLogin + * + */ + /*ARGSUSED*/ OSErr FPLoginCont(p,l,r,rl) *************** *** 554,578 **** int l,*rl; { LoginContPkt lcp; OSErr err; - ntohPackXbitmap(PsLoginCont, p, l, &lcp, UAMP_INUM); /* get id num */ if (lcp.lgc_idno != rne.logr_idnum) ! return(aeParamErr); /* what else to do? */ ! /* everything okay, so unpack encrypted passwd */ ! ntohPackXbitmap(PsLoginCont, p, l, &lcp, UAMP_INUM|UAMP_ENCR); ! if (DBSRV) { ! printf("Login Randnum exchange for %s\n",username ); } ! err = OSLogin(username, lcp.lgc_encrypted, rne.logr_randnum, UAM_RANDNUM); if (err == noErr) ! loggedin = TRUE; return(err); } /* * AFP2.0: change user password ! */ OSErr FPChgPasswd(p, l, r, rl) byte *p, *r; --- 750,855 ---- int l,*rl; { LoginContPkt lcp; + word bitmap; OSErr err; + #ifdef DEBUG_AFP_CMD + int i; + #endif /* DEBUG_AFP_CMD */ + + /* + * get id number + * + */ + ntohPackXbitmap(PsLoginCont, p, l, &lcp, UAMP_INUM); + + #ifdef DEBUG_AFP_CMD + if (dbg != NULL) { + fprintf(dbg, "\tAFPID: %04x\n", lcp.lgc_idno); + fflush(dbg); + } + #endif /* DEBUG_AFP_CMD */ if (lcp.lgc_idno != rne.logr_idnum) ! return(aeParamErr); ! ! /* ! * ID numbers match, so unpack encrypted passwd(s) ! * ! */ ! bitmap = UAMP_INUM | UAMP_ENCR | ((useruam==UAM_2WAYRAND) ? UAMP_TWAY : 0); ! ntohPackXbitmap(PsLoginCont, p, l, &lcp, bitmap); ! ! #ifdef DEBUG_AFP_CMD ! if (dbg != NULL) { ! fprintf(dbg, "\tUserA: "); ! for (i = 0; i < 8; i++) ! fprintf(dbg, "%02x", lcp.lgc_encrypted[i]); ! fprintf(dbg, "\n"); ! if (useruam == UAM_2WAYRAND) { ! if (l == 20) { ! fprintf(dbg, "\tRandm: "); ! for (i = 0; i < 8; i++) ! fprintf(dbg, "%02x", lcp.lgc_wsencrypt[i]); ! fprintf(dbg, "\n"); ! } else ! fprintf(dbg, "\t\n"); ! } } ! #endif /* DEBUG_AFP_CMD */ ! ! if (DBSRV) ! printf("Login Randnum exchange for %s\n",username ); ! ! err = OSLogin(username, lcp.lgc_encrypted, rne.logr_randnum, useruam); ! if (err == noErr) ! loginstate = LOGGED_IN; ! ! if (useruam != UAM_2WAYRAND) ! return(err); ! ! #ifdef DISTRIB_PASSWDS ! { extern struct afppass *afp; ! void afpdp_encr(); ! int afpdp_pwex(); ! ! if (afp == NULL) ! err = aeUserNotAuth; ! ! if (err != noErr) ! return(err); ! ! /* encrypt in place */ ! afpdp_encr(lcp.lgc_wsencrypt, afp->afp_password, NULL); ! ! *rl = htonPackXbitmap(PsLoginContR, (byte *)&lcp, r, UAMP_TWAY); ! ! /* password expired ? */ ! if (afpdp_pwex(afp) != 0) ! loginstate |= LOGGED_PX; ! ! #ifdef DEBUG_AFP_CMD ! if (dbg != NULL) { ! fprintf(dbg, " Return Parameters:\n"); ! fprintf(dbg, "\tSrvrA: "); ! for (i = 0; i < 8; i++) ! fprintf(dbg, "%02x", lcp.lgc_wsencrypt[i]); ! fprintf(dbg, "\n"); ! fflush(dbg); ! } ! #endif /* DEBUG_AFP_CMD */ ! ! } ! #endif /* DISTRIB_PASSWDS */ ! return(err); } /* * AFP2.0: change user password ! * ! */ ! OSErr FPChgPasswd(p, l, r, rl) byte *p, *r; *************** *** 580,610 **** { ChgPasswdPkt cpp; ChgPasswdReplyPkt cprp; - int uam; OSErr err; (void)ntohPackX(PsChangePassword, p, l, (byte *)&cpp); if ((uam = mapuamstr(cpp.cp_uam)) == UAM_UNKNOWN) { logit(0,"BAD UAM %s in change password attempt", cpp.cp_uam); ! return(aeBadUAM); /* no... forget it */ } if (uam == UAM_ANON) return(aeBadUAM); ! if (DBSRV) { ! printf("ChangePassword uam=%s, user=%s\n", ! cpp.cp_uam, cpp.cp_user); } err = OSChangePassword(cpp.cp_user, cpp.cp_oldpass, cpp.cp_newpass, uam); if (err != noErr) ! return(err); ! /* only here if noErr in change and cleartext */ ! bzero(&cprp, sizeof(cprp)); /* make sure zero first */ ! cprp.cpr_cmd = 0; ! cprp.cpr_zero = 0; ! strcpy(cprp.cpr_uam, cpp.cp_uam); /* copy uam */ ! bcopy(cpp.cp_newpass, cprp.cpr_newpass, sizeof(cprp.cpr_newpass)); ! *rl = htonPackX(PsChangePasswordReply, (byte *)&cprp, r); ! return(noErr); } /* --- 857,919 ---- { ChgPasswdPkt cpp; ChgPasswdReplyPkt cprp; OSErr err; + int uam; (void)ntohPackX(PsChangePassword, p, l, (byte *)&cpp); + + #ifdef DEBUG_AFP_CMD + if (dbg != NULL) { + fprintf(dbg, "\tChgUAM: \"%s\"\n", cpp.cp_uam); + fprintf(dbg, "\tChgUsr: \"%s\"\n", cpp.cp_user); + fflush(dbg); + } + #endif /* DEBUG_AFP_CMD */ + if ((uam = mapuamstr(cpp.cp_uam)) == UAM_UNKNOWN) { logit(0,"BAD UAM %s in change password attempt", cpp.cp_uam); ! return(aeBadUAM); } if (uam == UAM_ANON) return(aeBadUAM); ! ! #ifdef DEBUG_AFP_CMD ! if (dbg != NULL) { ! int i; ! switch (uam) { ! case UAM_CLEAR: ! fprintf(dbg, "\tOldPwd: (%d bytes)\n", strlen(cpp.cp_oldpass)); ! fprintf(dbg, "\tNewPwd: (%d bytes)\n", strlen(cpp.cp_newpass)); ! break; ! case UAM_RANDNUM: ! fprintf(dbg, "\tOldPwd: "); ! for (i = 0; i < 8; i++) ! fprintf(dbg, "%02x", cpp.cp_oldpass[i]); ! fprintf(dbg, "\n"); ! fprintf(dbg, "\tNewPwd: "); ! for (i = 0; i < 8; i++) ! fprintf(dbg, "%02x", cpp.cp_newpass[i]); ! fprintf(dbg, "\n"); ! break; ! } ! fflush(dbg); } + #endif /* DEBUG_AFP_CMD */ + + if (DBSRV) + printf("ChangePassword uam=%s, user=%s\n", cpp.cp_uam, cpp.cp_user); + err = OSChangePassword(cpp.cp_user, cpp.cp_oldpass, cpp.cp_newpass, uam); + + #ifdef DISTRIB_PASSWDS + if (err == noErr) + loginstate &= ~LOGGED_PX; + #endif /* DISTRIB_PASSWDS */ + if (err != noErr) ! logit(0, "ChangePassword failed for %s (%s)", cpp.cp_user, afperr(err)); ! ! return(err); } /* *************** *** 622,627 **** --- 931,946 ---- OSErr err; (void)ntohPackX(PsGetSrvrMsg, p, l, (byte *)&smp); + + #ifdef DEBUG_AFP_CMD + if (dbg != NULL) { + fprintf(dbg, "\tMsgTyp: %04x\t", smp.msg_typ); + fprintf(dbg, "(%s)\n", (smp.msg_typ == 0) ? "Login" : "Server"); + fprintf(dbg, "\tMsgBMp: %04x\n", smp.msg_bitmap); + fflush(dbg); + } + #endif /* DEBUG_AFP_CMD */ + if (sessvers < AFPVersion2DOT1) return(aeCallNotSupported); if (smp.msg_bitmap != 0x01) *************** *** 633,638 **** --- 952,970 ---- if (err != noErr) return(err); *rl = htonPackX(PsGetSrvrMsgReply, (byte *)&smrp, r); + + #ifdef DEBUG_AFP_CMD + if (dbg != NULL) { + void dbg_print_name(); + fprintf(dbg, " Return Parameters:\n"); + fprintf(dbg, "\tMsgTyp: %04x\t", smrp.msgr_typ); + fprintf(dbg, "(%s)\n", (smrp.msgr_typ == 0) ? "Login" : "Server"); + fprintf(dbg, "\tMsgBMp: %04x\n", smrp.msgr_bitmap); + dbg_print_name("\tMsgStr:", smrp.msgr_data); + fflush(dbg); + } + #endif /* DEBUG_AFP_CMD */ + return(noErr); } *************** *** 650,660 **** --- 982,1017 ---- OSErr err; (void)ntohPackX(PsGetUserInfo, p, l, (byte *)&guip); + + #ifdef DEBUG_AFP_CMD + if (dbg != NULL) { + fprintf(dbg, "\tGUFlg: %02x\t", guip.gui_flag); + fprintf(dbg, "%s\n", (guip.gui_flag & 0x01) ? "(ThisUser)" : ""); + fprintf(dbg, "\tUsrID: %08x\t", guip.gui_userid); + fprintf(dbg, "%s\n", (guip.gui_flag & 0x01) ? "(Invalid)" : ""); + fprintf(dbg, "\tBtMap: %04x\n", guip.gui_bitmap); + fflush(dbg); + } + #endif /* DEBUG_AFP_CMD */ + guirp.guir_bitmap = guip.gui_bitmap; err=OSGetUserInfo((guip.gui_flag & GUI_THIS_USER)!=0,guip.gui_userid,&guirp); if (err != noErr) return(err); *rl=htonPackXbitmap(PsGetUserInfoReply,(byte *)&guirp,r,guirp.guir_bitmap); + + #ifdef DEBUG_AFP_CMD + if (dbg != NULL) { + fprintf(dbg, " Return Parameters:\n"); + fprintf(dbg, "\tBtMap: %04x\n", guirp.guir_bitmap); + if (guirp.guir_bitmap & 0x0001) + fprintf(dbg, "\tUsrID: %08x\n", guirp.guir_userid); + if (guirp.guir_bitmap & 0x0002) + fprintf(dbg, "\tGrpID: %08x\n", guirp.guir_pgroup); + fflush(dbg); + } + #endif /* DEBUG_AFP_CMD */ + return(noErr); } *************** *** 687,693 **** cpyc2pstr(sr.sr_servername,sname); /* set server capabilities */ sr.sr_flags = SupportsFPCopyFile; ! /*sr.sr_flags |= SupportsChgPwd; */ sr.sr_flags |= SupportsServerMsgs; if (nopwdsave) sr.sr_flags |= DontAllowSavePwd; --- 1044,1052 ---- cpyc2pstr(sr.sr_servername,sname); /* set server capabilities */ sr.sr_flags = SupportsFPCopyFile; ! #ifdef DISTRIB_PASSWDS ! sr.sr_flags |= SupportsChgPwd; ! #endif DISTRIB_PASSWDS sr.sr_flags |= SupportsServerMsgs; if (nopwdsave) sr.sr_flags |= DontAllowSavePwd; *************** *** 709,715 **** uamo.optr_len = IndStrLen(uamobuf); uamo.optr_loc = uamobuf; sr.sr_uamo = (byte *) &uamo; ! return(htonPackX(ProtoSRP,(byte *) &sr,r)); } PrtSrvrInfo(pkt,pktl) --- 1068,1090 ---- uamo.optr_len = IndStrLen(uamobuf); uamo.optr_loc = uamobuf; sr.sr_uamo = (byte *) &uamo; ! ! len = htonPackX(ProtoSRP,(byte *) &sr,r); ! ! #ifdef DEBUG_AFP_CMD ! if (dbg != NULL) { ! void dbg_print_info(); ! time_t now; ! time(&now); ! fprintf(dbg, "## FPGetSrvrInfo (15) %s", ctime(&now)); ! fprintf(dbg, " Return Parameters:\n"); ! dbg_print_info(r, len); ! fprintf(dbg, "## FPGetSrvrInfo returns %d (%s)\n\n\n", 0, afperr(0)); ! fflush(dbg); ! } ! #endif /* DEBUG_AFP_CMD */ ! ! return(len); } PrtSrvrInfo(pkt,pktl) *************** *** 767,772 **** --- 1142,1167 ---- cnt = htonPackX(ProtoGSPRP, (byte *)&gpr, r); cnt += VMakeVList(r+cnt); /* add vols, return count */ *rl = cnt; /* pkt length */ + + #ifdef DEBUG_AFP_CMD + if (dbg != NULL) { + byte *q = r + 5; + void dbg_print_name(); + fprintf(dbg, "\tSTime: %s", ctime((time_t *)&gpr.gspr_time)); + fprintf(dbg, "\tNVols: %02x\n", gpr.gspr_nvols); + while (q < (r + (*rl))) { + fprintf(dbg, "\tVFlag: %02x (", (int)(*q)); + fprintf(dbg, "%s", (*q & 0x80) ? "HasPasswd" : ""); + fprintf(dbg, "%s",((*q & 0x81) == 0x81) ? ", " : ""); + fprintf(dbg, "%s", (*q & 0x01) ? "HasConfig" : ""); + fprintf(dbg, ")\n"); + dbg_print_name("\tVName:", q+1); + q += (*(q+1) + 2); + } + fflush(dbg); + } + #endif /* DEBUG_AFP_CMD */ + return(noErr); /* no error */ } *************** *** 927,929 **** --- 1322,1505 ---- printf("\n"); } } + + #ifdef DEBUG_AFP_CMD + /* + * print the uid/gid Name/ID function + * + */ + + void + dbg_print_func(func, typ) + int func; + int typ; + { + if (dbg != NULL) { + if (typ == 0 && (!(func == 1 || func == 2))) { + fprintf(dbg, "\n", func); + return; + } + if (typ == 1 && (!(func == 3 || func == 4))) { + fprintf(dbg, "\n", func); + return; + } + switch (func) { + case 1: + fprintf(dbg, "(ID to Usrname)\n"); + break; + case 2: + fprintf(dbg, "(ID to Grpname)\n"); + break; + case 3: + fprintf(dbg, "(Usrname to ID)\n"); + break; + case 4: + fprintf(dbg, "(Grpname to ID)\n"); + break; + default: + fprintf(dbg, "(\n)"); + break; + } + } + + return; + } + + /* + * dump server information + * + */ + + #define get2(s) (u_short)(((s)[0]<<8)|((s)[1])) + #define get4(s) (u_int)(((s)[0]<<24)|((s)[1]<<16)|((s)[2]<<8)|((s)[3])) + + void + dbg_print_info(r, rl) + byte *r; + int rl; + { + int i; + byte *q = r; + u_short srvrflags; + short machoff, afpoff, uamoff, vicnoff; + void dbg_print_name(); + void dbg_print_sflg(); + void dbg_print_icon(); + + machoff = get2(q); q += 2; + fprintf(dbg, "\tMchOff: %d\n", machoff); + afpoff = get2(q); q += 2; + fprintf(dbg, "\tAFPOff: %d\n", afpoff); + uamoff = get2(q); q += 2; + fprintf(dbg, "\tUAMOff: %d\n", uamoff); + vicnoff = get2(q); q += 2; + fprintf(dbg, "\tICNOff: %d\n", vicnoff); + fprintf(dbg, "\tVolFlg: %04x\t", (srvrflags = get2(q))); q += 2; + dbg_print_sflg(srvrflags); + dbg_print_name("\tSrvrNm:", q); + if (machoff != 0) + dbg_print_name("\tMchTyp:", r+machoff); + if (afpoff != 0) { + q = r + afpoff; + fprintf(dbg, "\tVerCnt: %d\n", (int)(*q)); + for (i = *q++; i > 0; i--) { + dbg_print_name("\tAFPVer:", q); + q += ((*q) + 1); + } + } else + fprintf(dbg, "\t\n"); + if (uamoff != 0) { + q = r + uamoff; + fprintf(dbg, "\tUAMCnt: %d\n", (int)(*q)); + for (i = *q++; i > 0; i--) { + dbg_print_name("\tUAMStr:", q); + q += ((*q) + 1); + } + } else + fprintf(dbg, "\t\n"); + if (vicnoff != 0) { + fprintf(dbg, "\tVolICN:\n"); + dbg_print_icon((r+vicnoff), 256); + fprintf(dbg, "\n"); + } else + fprintf(dbg, "\t\n"); + + return; + } + + /* + * print a pascal string + * + */ + + void + dbg_print_name(str, nam) + char *str; + byte *nam; + { + int i; + + if (dbg != NULL) { + fprintf(dbg, "%s \"", str); + for (i = 0; i < *nam; i++) + fprintf(dbg, "%c", *(nam+i+1)); + fprintf(dbg, "\"\n"); + } + + return; + } + + /* + * print server flags + * + */ + + void + dbg_print_sflg(bmap) + u_short bmap; + { + int i, j; + + if (dbg != NULL) { + fprintf(dbg, "("); + for (i = 0, j = 0; i < 16; i++) { + if (bmap & (0x0001 << i)) { + bmap &= ~(0x0001 << i); + switch (i) { + case 0: + fprintf(dbg, "SuppCopyFile"); + j++; + break; + case 1: + fprintf(dbg, "SuppChngPass"); + j++; + break; + case 2: + fprintf(dbg, "DontSavePass"); + j++; + break; + case 3: + fprintf(dbg, "SuppSrvrMesg"); + j++; + break; + case 15: + fprintf(dbg, "SuppMGetReqs"); + j++; + break; + default: + fprintf(dbg, "", i); + j++; + break; + } + if (bmap) + fprintf(dbg, ", "); + if (bmap && (j % 4) == 0) + fprintf(dbg, "\n\t\t\t"); + } + } + fprintf(dbg, ")\n"); + } + + return; + } + #endif /* DEBUG_AFP_CMD */ *** applications/aufs/afposfi.c.orig Mon Jun 12 17:11:16 1995 --- applications/aufs/afposfi.c Mon Jun 12 17:10:51 1995 *************** *** 1,7 **** /* ! * $Author: djh $ $Date: 1994/01/30 22:26:14 $ ! * $Header: /mac/src/cap60/applications/aufs/RCS/afposfi.c,v 2.6 1994/01/30 22:26:14 djh Rel djh $ ! * $Revision: 2.6 $ */ /* --- 1,7 ---- /* ! * $Author: djh $ $Date: 1995/06/12 06:58:18 $ ! * $Header: /mac/src/cap60/applications/aufs/RCS/afposfi.c,v 2.7 1995/06/12 06:58:18 djh Rel djh $ ! * $Revision: 2.7 $ */ /* *************** *** 473,478 **** --- 473,479 ---- OSUnlockFile(fd); if (close(fd) != 0) printf("WriteFA: close error"); + fi->fi_attr = htons(fi->fi_attr); /* then swab back!!!@ */ /* horrible hack, but can't use utimes, because we must be owner then */ if (needu) { /* update directory modified time */ OSfname(path,ipdir,FIDIRFN,F_FNDR); /* pick bad name */ *************** *** 645,650 **** --- 646,664 ---- *attr |= FI_ATTR_READONLY; *attr &= FPA_MASK1; /* give only AFP 1.1 Attributes */ } + return(noErr); + } + + OSSetAttr(pdir, fn, attr) + IDirP pdir; + char *fn; + word attr; + { + FileInfo *fi; + + fi = os_getfi(pdir, fn); + fi->fi_attr = attr; + WriteFA(pdir, fn, fi); return(noErr); } *** applications/aufs/afpntoh.h.orig Mon Jun 19 12:07:26 1995 --- applications/aufs/afpntoh.h Mon Jun 19 11:32:29 1995 *************** *** 1,7 **** /* ! * $Author: djh $ $Date: 1994/01/30 22:26:14 $ ! * $Header: /mac/src/cap60/applications/aufs/RCS/afpntoh.h,v 2.3 1994/01/30 22:26:14 djh Rel djh $ ! * $Revision: 2.3 $ * */ --- 1,7 ---- /* ! * $Author: djh $ $Date: 1995/06/19 01:32:20 $ ! * $Header: /mac/src/cap60/applications/aufs/RCS/afpntoh.h,v 2.4 1995/06/19 01:32:20 djh Rel djh $ ! * $Revision: 2.4 $ * */ *************** *** 50,57 **** #define PsLogin ProtoLP extern PackEntry ProtoLRP[]; /* login reply */ #define PsLoginReply ProtoLRP ! extern PackEntry ProtoLCP[]; /* 19 LoginCont (NYI) */ #define PsLoginCont ProtoLCP /* 20 Logout */ extern PackEntry ProtoMIP[]; /* 21 MapID */ #define PsMapID ProtoMIP --- 50,59 ---- #define PsLogin ProtoLP extern PackEntry ProtoLRP[]; /* login reply */ #define PsLoginReply ProtoLRP ! extern PackEntry ProtoLCP[]; /* 19 LoginCont */ #define PsLoginCont ProtoLCP + extern PackEntry ProtoLCR[]; /* loginCont reply */ + #define PsLoginContR ProtoLCR /* 20 Logout */ extern PackEntry ProtoMIP[]; /* 21 MapID */ #define PsMapID ProtoMIP *************** *** 112,119 **** #define PsChangePassword ProtoCPP extern PackEntry ProtoCPP[]; - #define PsChangePasswordReply ProtoCPRP - extern PackEntry ProtoCPRP[]; #define PsGetUserInfo ProtoGUIP extern PackEntry ProtoGUIP[]; #define PsGetUserInfoReply ProtoGUIRP --- 114,119 ---- *** applications/aufs/afposenum.c.orig Mon Oct 10 19:02:23 1994 --- applications/aufs/afposenum.c Mon Jun 19 11:32:36 1995 *************** *** 1,7 **** /* ! * $Author: djh $ $Date: 1994/10/10 09:02:04 $ ! * $Header: /mac/src/cap60/applications/aufs/RCS/afposenum.c,v 2.13 1994/10/10 09:02:04 djh Rel djh $ ! * $Revision: 2.13 $ * */ --- 1,7 ---- /* ! * $Author: djh $ $Date: 1995/06/19 01:32:20 $ ! * $Header: /mac/src/cap60/applications/aufs/RCS/afposenum.c,v 2.14 1995/06/19 01:32:20 djh Rel djh $ ! * $Revision: 2.14 $ * */ *************** *** 56,61 **** --- 56,64 ---- #ifdef SOLARIS # include #endif /* SOLARIS */ + #ifdef DISTRIB_PASSWDS + #include + #endif /* DISTRIB_PASSWDS */ #include "afps.h" #include "afpdt.h" *************** *** 163,168 **** --- 166,175 ---- return(FALSE); if (strcmp(d->d_name,DESKTOP_APPL) == 0) return(FALSE); + #ifdef DISTRIB_PASSWDS + if (strcmp(d->d_name,AFP_DISTPW_USER) == 0) /* local password file */ + return(FALSE); + #endif /* DISTRIB_PASSWDS */ return(TRUE); } *** applications/aufs/aufsicon.c.orig Mon Feb 17 20:45:15 1992 --- applications/aufs/aufsicon.c Wed Jun 21 16:31:42 1995 *************** *** 1,7 **** /* ! * $Author: djh $ $Date: 1992/02/17 09:36:14 $ ! * $Header: /mac/src/cap60/applications/aufs/RCS/aufsicon.c,v 2.7 1992/02/17 09:36:14 djh Rel djh $ ! * $Revision: 2.7 $ */ /* --- 1,7 ---- /* ! * $Author: djh $ $Date: 1995/06/21 06:31:26 $ ! * $Header: /local/mulga/mac/src/cap60/applications/aufs/RCS/aufsicon.c,v 2.8 1995/06/21 06:31:26 djh rel djh $ ! * $Revision: 2.8 $ */ /* *************** *** 76,81 **** --- 76,84 ---- #ifdef vax #define INDEX 5 #endif vax + #ifdef __alpha + #define INDEX 5 + #endif __alpha #ifdef aux #define INDEX 6 #endif aux *** lib/afp/afperr.c.orig Thu Feb 28 23:43:21 1991 --- lib/afp/afperr.c Mon Jun 19 11:31:17 1995 *************** *** 1,8 **** /* ! * $Author: djh $ $Date: 91/02/15 22:35:14 $ ! * $Header: afperr.c,v 2.1 91/02/15 22:35:14 djh Rel $ ! * $Revision: 2.1 $ ! */ /* * afperr.c - Error messages --- 1,9 ---- /* ! * $Author: djh $ $Date: 1995/06/19 01:31:07 $ ! * $Header: /mac/src/cap60/lib/afp/RCS/afperr.c,v 2.2 1995/06/19 01:31:07 djh Rel djh $ ! * $Revision: 2.2 $ ! * ! */ /* * afperr.c - Error messages *************** *** 17,27 **** * Wed Apr 1 Schilit Created, based on Charlies routine * */ #include #include #include ! #define NUMERR 32 private char *afperrs[NUMERR] = { "Access Denied", /* 5000 */ --- 18,29 ---- * Wed Apr 1 Schilit Created, based on Charlies routine * */ + #include #include #include ! #define NUMERR 45 private char *afperrs[NUMERR] = { "Access Denied", /* 5000 */ *************** *** 55,61 **** "Can't rename", /* 5028 */ "Directory not found", /* 5029 */ "Icon Type error", /* 5030 */ ! "Volume locked" /* 5031 (2.0) */ }; char *afperr(err) --- 57,76 ---- "Can't rename", /* 5028 */ "Directory not found", /* 5029 */ "Icon Type error", /* 5030 */ ! "Volume locked", /* 5031 */ ! "Object locked", /* 5032 */ ! "unknown error -5033", /* 5033 */ ! "File ID not found", /* 5034 */ ! "File already has a file ID", /* 5035 */ ! "unknown error -5036", /* 5036 */ ! "Catalogue changed", /* 5037 */ ! "Exchanging same object", /* 5038 */ ! "Nonexistent file ID", /* 5039 */ ! "Same password", /* 5040 */ ! "Password too short", /* 5041 */ ! "Password expired", /* 5042 */ ! "Folder inside shared folder", /* 5043 */ ! "Folder inside Trash folder" /* 5044 */ }; char *afperr(err) *** lib/afp/afppacks.c.orig Mon Jun 19 11:58:52 1995 --- lib/afp/afppacks.c Mon Jun 19 11:31:19 1995 *************** *** 1,7 **** /* ! * $Author: djh $ $Date: 1994/01/30 22:32:06 $ ! * $Header: /mac/src/cap60/lib/afp/RCS/afppacks.c,v 2.3 1994/01/30 22:32:06 djh Rel djh $ ! * $Revision: 2.3 $ * */ --- 1,7 ---- /* ! * $Author: djh $ $Date: 1995/06/19 01:31:07 $ ! * $Header: /mac/src/cap60/lib/afp/RCS/afppacks.c,v 2.4 1995/06/19 01:31:07 djh Rel djh $ ! * $Revision: 2.4 $ * */ *************** *** 476,481 **** --- 476,487 ---- PACK(LCPPtr,P_ZERO,lgc_zero), /* is this here? */ PAKB(LCPPtr,P_WORD,lgc_idno, UAMP_INUM), /* ID number */ PKSB(LCPPtr,P_BYTS,lgc_encrypted, UAMP_ENCR), /* encrypted passwd */ + PKSB(LCPPtr,P_BYTS,lgc_wsencrypt, UAMP_TWAY), /* encrypted passwd */ + PACKEND() + }; + + PackEntry ProtoLCR[] = { /* FPLoginCont Reply */ + PKSB(LCPPtr,P_BYTS,lgc_wsencrypt,UAMP_TWAY), PACKEND() }; *************** *** 660,668 **** PACKEND() }; ! ! /* change password */ ! PackEntry ProtoCPP[] = { PACK(CPPtr, P_BYTE, cp_cmd), /* command */ PACK(CPPtr, P_ZERO, cp_zero), /* always zero */ PAKS(CPPtr, P_PSTR, cp_uam), /* authentication method */ --- 666,672 ---- PACKEND() }; ! PackEntry ProtoCPP[] = { /* ChangePassword */ PACK(CPPtr, P_BYTE, cp_cmd), /* command */ PACK(CPPtr, P_ZERO, cp_zero), /* always zero */ PAKS(CPPtr, P_PSTR, cp_uam), /* authentication method */ *************** *** 674,693 **** PACKEND() }; ! /* change password reply: only used for cleartext */ ! PackEntry ProtoCPRP[] = { ! PACK(CPRPtr, P_BYTE, cpr_cmd), /* command */ ! PACK(CPRPtr, P_ZERO, cpr_zero), /* always zero */ ! PAKS(CPRPtr, P_PSTR, cpr_uam), /* authentication method */ ! PACK(CPRPtr, P_EVEN, cpr_pad), /* pad to even */ ! PAKS(CPRPtr, P_PSTR, cpr_user), /* user name */ ! PACK(CPRPtr, P_EVEN, cpr_pad), /* pad to even */ ! PAKS(CPRPtr, P_BYTS, cpr_newpass), /* 8 bytes for new password */ ! PACKEND() ! }; ! ! /* get user information */ ! PackEntry ProtoGUIP[] = { PACK(GUIPtr, P_BYTE, gui_cmd), /* command */ PACK(GUIPtr, P_BYTE, gui_flag), /* flag word */ PACK(GUIPtr, P_DWRD, gui_userid), /* user id */ --- 678,684 ---- PACKEND() }; ! PackEntry ProtoGUIP[] = { /* GetUserInfo */ PACK(GUIPtr, P_BYTE, gui_cmd), /* command */ PACK(GUIPtr, P_BYTE, gui_flag), /* flag word */ PACK(GUIPtr, P_DWRD, gui_userid), /* user id */ *************** *** 695,710 **** PACKEND() }; ! /* get user information reply */ ! PackEntry ProtoGUIRP[] = { PACK(GUIRPtr, P_BMAP, guir_bitmap), /* bitmap to return */ PAKB(GUIRPtr, P_DWRD, guir_userid, UIP_USERID), PAKB(GUIRPtr, P_DWRD, guir_pgroup, UIP_PRIMARY_GID), PACKEND() }; ! /* exchange files */ ! PackEntry ProtoExP[] = { PACK(EXPtr, P_BYTE, exc_cmd), /* command */ PACK(EXPtr, P_ZERO, exc_zero), /* always zero */ PACK(EXPtr, P_WORD, exc_volid), /* volume id */ --- 686,699 ---- PACKEND() }; ! PackEntry ProtoGUIRP[] = { /* GetUserInfo Reply */ PACK(GUIRPtr, P_BMAP, guir_bitmap), /* bitmap to return */ PAKB(GUIRPtr, P_DWRD, guir_userid, UIP_USERID), PAKB(GUIRPtr, P_DWRD, guir_pgroup, UIP_PRIMARY_GID), PACKEND() }; ! PackEntry ProtoExP[] = { /* ExchangeFiles */ PACK(EXPtr, P_BYTE, exc_cmd), /* command */ PACK(EXPtr, P_ZERO, exc_zero), /* always zero */ PACK(EXPtr, P_WORD, exc_volid), /* volume id */ *************** *** 717,724 **** PACKEND() }; ! /* get server message */ ! PackEntry ProtoMsgP[] = { PACK(SrvrMsgPtr, P_BYTE, msg_cmd), /* command */ PACK(SrvrMsgPtr, P_ZERO, msg_zero), /* always zero */ PACK(SrvrMsgPtr, P_WORD, msg_typ), /* message type */ --- 706,712 ---- PACKEND() }; ! PackEntry ProtoMsgP[] = { /* GetSrvrMsg */ PACK(SrvrMsgPtr, P_BYTE, msg_cmd), /* command */ PACK(SrvrMsgPtr, P_ZERO, msg_zero), /* always zero */ PACK(SrvrMsgPtr, P_WORD, msg_typ), /* message type */ *************** *** 726,733 **** PACKEND() }; ! /* get message reply */ ! PackEntry ProtoMsgRP[] = { PACK(SrvrMsgReplyPtr, P_WORD, msgr_typ), /* message type */ PACK(SrvrMsgReplyPtr, P_WORD, msgr_bitmap), /* bitmap */ PAKS(SrvrMsgReplyPtr, P_PSTR, msgr_data), /* message string */ --- 714,720 ---- PACKEND() }; ! PackEntry ProtoMsgRP[] = { /* GetSrvrMsg Reply */ PACK(SrvrMsgReplyPtr, P_WORD, msgr_typ), /* message type */ PACK(SrvrMsgReplyPtr, P_WORD, msgr_bitmap), /* bitmap */ PAKS(SrvrMsgReplyPtr, P_PSTR, msgr_data), /* message string */ *** lib/afp/afppass.c.orig Mon Jun 19 11:22:40 1995 --- lib/afp/afppass.c Fri Jun 30 21:19:52 1995 *************** *** 0 **** --- 1,771 ---- + /* + * $Author: djh $ $Date: 1995/06/30 11:19:39 $ + * $Header: /mac/src/cap60/lib/afp/RCS/afppass.c,v 2.1 1995/06/30 11:19:39 djh Rel djh $ + * $Revision: 2.1 $ + * + */ + + /* + * AUFS Distributed Passwords + * + * Copyright 1995 - The University of Melbourne. All rights reserved. + * May be used only for CAP/AUFS authentication. Any other use + * requires prior permission in writing from the copyright owner. + * + * djh@munnari.OZ.AU + * June 1995 + * + * afppass.c - AUFS Distributed Password library routines. + * + * User passwords are normally stored in ~user/.afppass in DES encrypted + * form. This file also contains values for password expiry date, minimum + * password length, maximum failed login attempts and number of failed + * login attempts. + * + * For greater security, the file must be owned by the user and be set to + * mode AFP_DISTPW_MODE (usually 0600 or -rw-------), if this is not the + * case, the file is deleted. + * + * The decryption key is stored in a global afppass (defaults to the + * file /usr/local/lib/cap/afppass) which also contains default values + * for expiry date, minimum password length and maximum failed attempts. + * If this file is not owned by root and mode 0600 it will be removed. + * + * Notes: + * 1. In the case of user home directories mounted via NFS, the files must + * be set to mode 0644 (since root cannot read mode 0600 files on remote + * filesystems). You can change the mode using the define + * -DAFP_DISTPW_MODE=0644 + * + * 2. If you prefer to keep the .afppass files centrally, you can define + * the path using the define -DAFP_DISTPW_PATH=\"/usr/local/lib/cap/upw\" + * + * 3. The decryption key for the global afppass is defined by AFP_DIST_PASS + * Should be localized for each site, using -DAFP_DIST_PASS=\"password\". + * + * 4. AFP passwords can only be changed by the user with the AppleShare + * workstation client or by the UNIX superuser using aufsmkusr. + * + * 5. User AFP passwords MUST NOT be identical to UNIX login passwords, + * this restriction is enforced by the library routines. + * + */ + + #ifdef DISTRIB_PASSWDS + + #include + #include + #include + #include + #include + #include + #include + #include + + #include + #include + + #ifdef NEEDFCNTLDOTH + #include + #endif NEEDFCNTLDOTH + + static struct afppass global; + struct afppass *afp_glob = NULL; + + char hex[] = "0123456789ABCDEF"; + + /* + * Initialise data structure + * + * must be called by root to get global password & settings + * from the specified file (which must already exist). + * + */ + + int + afpdp_init(path) + char *path; + { + int fd, len; + struct stat buf; + char abuf[AFPPDSIZE]; + void afpdp_decr(); + + if (geteuid() != 0) + return(-1); + + bzero(&global, sizeof(struct afppass)); + + if (stat(path, &buf) < 0) + return(-1); + + /* + * check mode, size and owner + * + */ + if ((buf.st_mode&0777) != 0600 + || buf.st_size != AFPPDSIZE + || buf.st_uid != 0) { + unlink(path); + return(-1); + } + + if ((fd = open(path, O_RDONLY, 0644)) < 0) + return(fd); + + len = read(fd, abuf, sizeof(abuf)); + + close(fd); + + if (len != sizeof(abuf)) + return(-1); + + /* + * sanity check on file contents + * + */ + if (abuf[16] != '\n' || abuf[33] != '\n') + return(-1); + + /* + * decrypt each "line" into the structure + * using global key + * + */ + afpdp_decr(abuf, (u_char *)AFP_DISTPW_PASS, (u_char *)&global); + afpdp_decr((abuf+17), (u_char *)AFP_DISTPW_PASS, global.afp_password); + + /* + * another sanity check + * + */ + if (global.afp_magic != AFPDP_MAGIC) + return(-1); + + /* + * make sure password null terminated + * + */ + global.afp_password[KEYSIZE] = '\0'; + + afp_glob = &global; + + return(0); + } + + /* + * return pointer to structure representing ~user/.afppass + * + */ + + struct afppass * + afpdp_read(user, uid, home) + char *user; + int uid; + char *home; + { + int fd, len; + struct stat buf; + static struct afppass afppass; + char key[KEYSIZE], abuf[AFPPDSIZE], path[MAXPATHLEN]; + void afpdp_decr(); + + if (afp_glob == (struct afppass *)NULL) + return((struct afppass *)NULL); + + bzero(&afppass, sizeof(struct afppass)); + + #ifdef AFP_DISTPW_PATH + sprintf(path, "%s/%s%s", AFP_DISTPW_PATH, user, AFP_DISTPW_USER); + #else /* AFP_DISTPW_PATH */ + sprintf(path, "%s/%s", home, AFP_DISTPW_USER); + #endif /* AFP_DISTPW_PATH */ + + if (stat(path, &buf) < 0) + return((struct afppass *)NULL); + + /* + * check mode, size and owner + * + */ + if ((buf.st_mode&0777) != AFP_DISTPW_MODE + || buf.st_size != AFPPDSIZE) { + unlink(path); /* delete file */ + return((struct afppass *)NULL); + } + if (buf.st_uid != uid) + return((struct afppass *)NULL); + + if ((fd = open(path, O_RDONLY, 0644)) < 0) + return((struct afppass *)NULL); + + len = read(fd, abuf, sizeof(abuf)); + + close(fd); + + if (len != sizeof(abuf)) + return((struct afppass *)NULL); + + /* + * sanity check on file contents + * + */ + if (abuf[16] != '\n' || abuf[33] != '\n') + return((struct afppass *)NULL); + + /* + * copy global key, xor with 'user' to + * prevent interchange of .afppass files + * + */ + bcopy((char *)afp_glob->afp_password, key, KEYSIZE); + if ((len = strlen(user)) > KEYSIZE) + len = KEYSIZE; + while (--len >= 0) + key[len] ^= user[len]; + + /* + * decrypt each "line" into the structure using key + * + */ + afpdp_decr(abuf, key, (u_char *)&afppass); + afpdp_decr((abuf+17), key, afppass.afp_password); + + if (afppass.afp_magic != AFPDP_MAGIC) + return((struct afppass *)NULL); + + /* + * make sure password null terminated + * + */ + afppass.afp_password[KEYSIZE] = '\0'; + + return(&afppass); + } + + /* + * write a (possibly new) ~user/.afppass + * + * fail if UNIX password is used. + * + */ + + int + afpdp_writ(user, uid, home, afppass) + char *user; + int uid; + char *home; + struct afppass *afppass; + { + int fd, i, j; + char key[KEYSIZE], abuf[AFPPDSIZE], path[MAXPATHLEN]; + void afpdp_encr(); + + if (afp_glob == (struct afppass *)NULL) + return(-1); + + if (afppass == (struct afppass *)NULL) + return(-1); + + if (afppass->afp_magic != AFPDP_MAGIC) + return(-1); + + /* + * ensure password null padded + * + */ + if ((i = strlen(afppass->afp_password)) > KEYSIZE) + i = KEYSIZE; + + for (j = i; j < KEYSIZE; j++) + afppass->afp_password[j] = '\0'; + + /* + * check that the proposed new password + * is NOT identical to the UNIX password + * (and that the user exists ...) + * + */ + if (afpdp_upas(uid, afppass->afp_password) <= 0) + return(-1); + + #ifdef AFP_DISTPW_PATH + sprintf(path, "%s/%s%s", AFP_DISTPW_PATH, user, AFP_DISTPW_USER); + #else /* AFP_DISTPW_PATH */ + sprintf(path, "%s/%s", home, AFP_DISTPW_USER); + #endif /* AFP_DISTPW_PATH */ + + if ((fd = open(path, O_WRONLY|O_CREAT|O_TRUNC, AFP_DISTPW_MODE)) < 0) + return(-1); + + /* + * copy global key, xor with 'user' to + * prevent interchange of .afppass files + * + */ + bcopy((char *)afp_glob->afp_password, key, KEYSIZE); + if ((i = strlen(user)) > KEYSIZE) + i = KEYSIZE; + while (--i >= 0) + key[i] ^= user[i]; + + /* + * encrypt each half of structure into buffer + * + */ + afpdp_encr((u_char *)afppass, key, abuf); + afpdp_encr(afppass->afp_password, key, abuf+17); + + abuf[16] = '\n'; + abuf[33] = '\n'; + + if (write(fd, abuf, sizeof(abuf)) != sizeof(abuf)) + return(-1); + + fchmod(fd, AFP_DISTPW_MODE); + fchown(fd, uid, -1); + + close(fd); + + return(0); + } + + /* + * write a (possibly new) /usr/local/lib/cap/afppass + * + */ + + int + afpdp_make(path, afppass) + char *path; + struct afppass *afppass; + { + int fd, i, j; + char abuf[AFPPDSIZE]; + void afpdp_encr(); + + if (geteuid() != 0) + return(-1); + + if (afppass == (struct afppass *)NULL) + return(-1); + + if (afppass->afp_magic != AFPDP_MAGIC) + return(-1); + + /* + * ensure password null padded + * + */ + if ((i = strlen(afppass->afp_password)) > KEYSIZE) + i = KEYSIZE; + + for (j = i; j < KEYSIZE; j++) + afppass->afp_password[j] = '\0'; + + if ((fd = open(path, O_WRONLY|O_CREAT|O_TRUNC, 0600)) < 0) + return(-1); + + /* + * encrypt each half of structure into buffer + * + */ + afpdp_encr((u_char *)afppass, (u_char *)AFP_DISTPW_PASS, abuf); + afpdp_encr(afppass->afp_password, (u_char *)AFP_DISTPW_PASS, abuf+17); + + abuf[16] = '\n'; + abuf[33] = '\n'; + + if (write(fd, abuf, sizeof(abuf)) != sizeof(abuf)) + return(-1); + + fchmod(fd, 0600); + fchown(fd, 0, -1); + + close(fd); + + return(0); + } + + /* + * decrypt 'str' using 'key', into 'buf' + * + * 'str' assumed to be 16 hex chars or null + * 'buf' assumed to be 8 bytes long + * + */ + + void + afpdp_decr(str, key, buf) + char *str; + u_char *key, *buf; + { + int i, j, k; + u_char mykey[KEYSIZE]; + + if ((i = strlen((char *)key)) > KEYSIZE) + i = KEYSIZE; + + /* + * copy key. DES ignores bottom bit, + * so shift one up, add null padding + * + */ + for (j = 0; j < i; j++) + mykey[j] = *(key+j) << 1; + for (j = i; j < KEYSIZE; j++) + mykey[j] = '\0'; + + /* + * copy str. convert hex string to data + * + */ + if (str != NULL) { + for (i = 0, j = 0; i < KEYSIZE; i++) { + buf[i] = 0; + for (k = 0; k < 2; j++, k++) { + if (str[j] >= '0' && str[j] <= '9') + buf[i] += (str[j] - '0'); + if (str[j] >= 'A' && str[j] <= 'F') + buf[i] += (str[j] - 'A' + 10); + if (str[j] >= 'a' && str[j] <= 'f') + buf[i] += (str[j] - 'a' + 10); + if (k == 0) + buf[i] *= 16; + } + } + } + + /* + * initialise and run DES + * + */ + #ifndef DES_AVAIL + desinit(0); + dessetkey(mykey); + dedes(buf); + desdone(); + #else /* DES_AVAIL */ + { + char pass[64], pkey[64]; + + for (i = 0; i < 8; i++) + for (j = 0; j < 8; j++) + pass[(i*8)+j] = (buf[i] >> (7-j)) & 0x01; + for (i = 0; i < 8; i++) + for (j = 0; j < 8; j++) + pkey[(i*8)+j] = (mykey[i] >> (7-j)) & 0x01; + setkey(pkey); + encrypt(pass, 1); + for (i = 0; i < 8; i++) { + buf[i] = 0; + for (j = 0; j < 8; j++) + buf[i] |= ((pass[(i*8)+j] & 0x01) << (7-j)); + } + } + #endif /* DES_AVAIL */ + + return; + } + + /* + * encrypt 'buf' using 'key', into 'str' + * + * 'buf' assumed to be 8 bytes (null padded) + * 'str' assumed have space for 16 characters or null + * + */ + + void + afpdp_encr(buf, key, str) + u_char *buf, *key; + char *str; + { + int i, j, k; + u_char mykey[KEYSIZE]; + + if ((i = strlen(key)) > KEYSIZE) + i = KEYSIZE; + + /* + * copy key. DES ignores bottom bit, + * so shift one up, add null padding + * + */ + for (j = 0; j < i; j++) + mykey[j] = *(key+j) << 1; + for (j = i; j < KEYSIZE; j++) + mykey[j] = '\0'; + + /* + * initialise and run DES + * + */ + #ifndef DES_AVAIL + desinit(0); + dessetkey(mykey); + endes(buf); + desdone(); + #else /* DES_AVAIL */ + { + char pass[64], pkey[64]; + + for (i = 0; i < 8; i++) + for (j = 0; j < 8; j++) + pass[(i*8)+j] = (buf[i] >> (7-j)) & 0x01; + for (i = 0; i < 8; i++) + for (j = 0; j < 8; j++) + pkey[(i*8)+j] = (mykey[i] >> (7-j)) & 0x01; + setkey(pkey); + encrypt(pass, 0); + for (i = 0; i < 8; i++) { + buf[i] = 0; + for (j = 0; j < 8; j++) + buf[i] |= ((pass[(i*8)+j] & 0x01) << (7-j)); + } + } + #endif /* DES_AVAIL */ + + if (str == NULL) + return; + + /* + * convert to Hex digits + * + */ + for (i = 0, j = 0; i < KEYSIZE; i++) { + str[j++] = hex[(buf[i] >> 4) & 0x0f]; + str[j++] = hex[(buf[i] & 0x0f)]; + } + + return; + } + + /* + * compare password against UNIX account password + * + * returns: -1 if nonexistent, 0 if same, 1 if no match + * + */ + + int + afpdp_upas(uid, passwd) + int uid; + char *passwd; + { + struct passwd *pw, *getpwuid(); + + if ((pw = getpwuid(uid)) == NULL) + return(-1); + + if (strcmp((char *)crypt(passwd, pw->pw_passwd), pw->pw_passwd) == 0) + return(0); + + return(1); + } + + /* + * check password expiry date (global and user) + * + * return + * 1 if password expired and user allowed to update + * -1 if password expired and user can't update + * 0 if password hasn't expired + * + */ + + int + afpdp_pwex(afp) + struct afppass *afp; + { + time_t now, then; + + if (afp_glob == (struct afppass *)NULL + || afp == (struct afppass *)NULL) + return(-1); + + time(&now); + then = ntohl(afp_glob->afp_expires); + + /* + * enforce global expiry date + * + */ + if (then > SECS_10_YRS && now > then) + return(-1); + + /* + * otherwise check user expiry date + * + */ + if ((then = ntohl(afp->afp_expires)) == 0) + return(0); + + if (now > then) + return(1); + + return(0); + } + + /* + * update user expiry date + * + */ + + void + afpdp_upex(afp) + struct afppass *afp; + { + time_t now, then; + + if (afp_glob == (struct afppass *)NULL + || afp == (struct afppass *)NULL) + return; + + time(&now); + then = ntohl(afp_glob->afp_expires); + + if (then > SECS_10_YRS || then == 0) + afp->afp_expires = afp_glob->afp_expires; + else + afp->afp_expires = htonl(now+then); + + return; + } + + /* + * read a positive integer up to 'maxm' + * use 'def' if no input provided + * + */ + + int + afpdp_gnum(def, maxm) + int def, maxm; + { + int num = 0; + char abuf[80]; + + do { + fgets(abuf, sizeof(abuf), stdin); + if (abuf[0] == '\n') + return(def); + num = atoi(abuf); + if (num > maxm) + printf("Maximum value is %d, try again: [%d] ? ", maxm, def); + if (num < 0) + printf("Number must be positive, try again: [%d] ? ", def); + } while (num > maxm || num < 0); + + return(num); + } + + /* + * read a date or time from standard input + * + * format can be a period in the form + * NNNNd (days) + * NNNNm (months) + * + * or an absolute time + * YY/MM/DD [HH:MM:SS] + * + * return 0xffffffff if null response + * + */ + + time_t + afpdp_gdat() + { + struct tm tm; + time_t mult = 0; + char abuf[80], *cp; + + bzero(abuf, sizeof(abuf)); + fgets(abuf, sizeof(abuf), stdin); + + if (abuf[0] == '\n') + return(0xffffffff); + + /* + * explicit days ? + * + */ + if ((cp = (char *)index(abuf, 'd')) != NULL) { + *cp = '\0'; + mult = SECS_IN_DAY; + return(mult * atoi(abuf)); + } + + /* + * or months ? + * + */ + if ((cp = (char *)index(abuf, 'm')) != NULL) { + *cp = '\0'; + mult = SECS_IN_MON; + return(mult * atoi(abuf)); + } + + /* + * check for YY/MM/DD + * + */ + cp = abuf; + bzero((char *)&tm, sizeof(struct tm)); + if ((char *)index(cp, '/') != NULL) { + if (cp[2] == '/' && cp[5] == '/') { + cp[2] = cp[5] = cp[8] = '\0'; + if ((tm.tm_year = atoi(cp)) < 95) + tm.tm_year += 100; /* year - 1900 */ + tm.tm_mon = atoi(cp+3) - 1; /* 0 - 11 */ + tm.tm_mday = atoi(cp+6); /* 1 - 31 */ + tm.tm_isdst = 1; + cp += 8; + } else { + printf("Sorry I don't understand that format, use YY/MM/DD\n"); + return(0); + } + } + + /* + * and optional HH:MM:SS + * + */ + if (cp != abuf && *cp++ == '\0') { + if ((char *)index(cp, ':') != NULL) { + if (cp[2] == ':' && cp[5] == ':') { + cp[2] = cp[5] = cp[8] = '\0'; + tm.tm_hour = atoi(cp); /* 0 - 23 */ + tm.tm_min = atoi(cp+3); /* 0 - 59 */ + tm.tm_sec = atoi(cp+6); /* 0 - 59 */ + tm.tm_isdst = 1; + } else { + printf("Sorry I don't understand that format, use HH:MM:SS\n"); + return(0); + } + } + } + + /* + * tm set ? + * + */ + if (tm.tm_isdst) { + tm.tm_isdst = 0; + #if defined(sun) && !defined(SOLARIS) + return(timelocal(&tm)); + #else /* sun && !SOLARIS */ + return(mktime(&tm)); + #endif /* sun && !SOLARIS */ + } + + /* + * default days + * + */ + return(atoi(abuf)*SECS_IN_DAY); + } + #else /* DISTRIB_PASSWDS */ + int pass_dummy_for_ld; + #endif /* DISTRIB_PASSWDS */ *** lib/afp/Makefile.m4.orig Mon Jun 19 11:55:54 1995 --- lib/afp/Makefile.m4 Mon Jun 19 11:31:20 1995 *************** *** 5,12 **** I=includedir() DES=desloc() ! LIBAFPSRCS=afperr.c afpcmd.c afppacks.c afposlock.c ! LIBAFPOBJS=afperr.o afpcmd.o afppacks.o afposlock.o des.o $(LIBAFP): $(LIBAFPOBJS) ifdef([uselordertsort],[ar cr $(LIBAFP) `lorder $(LIBAFPOBJS)| tsort`], --- 5,12 ---- I=includedir() DES=desloc() ! LIBAFPSRCS=afperr.c afpcmd.c afppacks.c afposlock.c afppass.c ! LIBAFPOBJS=afperr.o afpcmd.o afppacks.o afposlock.o des.o afppass.o $(LIBAFP): $(LIBAFPOBJS) ifdef([uselordertsort],[ar cr $(LIBAFP) `lorder $(LIBAFPOBJS)| tsort`], *************** *** 50,52 **** --- 50,53 ---- afposlock.o: afposlock.c $I/netat/appletalk.h $I/netat/aberrors.h \ $I/netat/abqueue.h $I/netat/sysvcompat.h \ $I/netat/afp.h $I/netat/afpcmd.h + afppass.o: afppass.c $I/netat/afppass.h *** netat/afpc.h.orig Thu Feb 28 23:43:36 1991 --- netat/afpc.h Mon Jun 19 11:33:20 1995 *************** *** 1,7 **** /* ! * $Author: djh $ $Date: 91/02/15 22:58:49 $ ! * $Header: afpc.h,v 2.1 91/02/15 22:58:49 djh Rel $ ! * $Revision: 2.1 $ */ /* --- 1,7 ---- /* ! * $Author: djh $ $Date: 1995/06/19 01:33:09 $ ! * $Header: /mac/src/cap60/netat/RCS/afpc.h,v 2.2 1995/06/19 01:33:09 djh Rel djh $ ! * $Revision: 2.2 $ */ /* *************** *** 21,23 **** --- 21,24 ---- #define USE_UAM_ANON 0 #define USE_UAM_CLEAR 1 #define USE_UAM_RANDNUM 2 + #define USE_UAM_2WAYRAND 3 *** netat/afpcmd.h.orig Mon Jun 19 12:04:52 1995 --- netat/afpcmd.h Mon Jun 19 11:33:21 1995 *************** *** 1,7 **** /* ! * $Author: djh $ $Date: 1994/01/30 23:20:46 $ ! * $Header: /mac/src/cap60/netat/RCS/afpcmd.h,v 2.4 1994/01/30 23:20:46 djh Rel djh $ ! * $Revision: 2.4 $ * */ --- 1,7 ---- /* ! * $Author: djh $ $Date: 1995/06/19 01:33:09 $ ! * $Header: /mac/src/cap60/netat/RCS/afpcmd.h,v 2.5 1995/06/19 01:33:09 djh Rel djh $ ! * $Revision: 2.5 $ * */ *************** *** 326,331 **** --- 326,332 ---- #define UAM_ANON 0 #define UAM_CLEAR 1 #define UAM_RANDNUM 2 + #define UAM_2WAYRAND 3 #define UAMP_USER 1 /* need user name */ #define UAMP_PASS 2 /* need password */ *************** *** 333,338 **** --- 334,341 ---- #define UAMP_ENCR 8 /* need encrypted passwd */ #define UAMP_ZERO 0x10 /* need zero between user and passwd */ #define UAMP_INUM 0x20 /* id number for fplogin exchange */ + #define UAMP_TWAY 0x40 /* need second random dword */ + typedef struct { /* FPLogin */ byte log_cmd; /* Login command */ byte log_ver[MAXPSTR]; /* version string */ *************** *** 356,361 **** --- 359,366 ---- word lgc_idno; /* ID number */ byte lgc_encrypted[8]; /* encrypted version of random number */ /* for randnum exchange uam (64 bits) */ + byte lgc_wsencrypt[8]; /* encrypted version of workstation id */ + /* for 2-Way rand exchange uam (64 bits) */ byte lgc_flags; /* really just the uam */ } LoginContPkt, *LCPPtr; *** netat/afppass.h.orig Mon Jun 19 11:40:42 1995 --- netat/afppass.h Tue Jun 20 13:27:44 1995 *************** *** 0 **** --- 1,101 ---- + /* + * $Author: djh $ $Date: 1995/06/20 03:27:33 $ + * $Header: /mac/src/cap60/netat/RCS/afppass.h,v 2.1 1995/06/20 03:27:33 djh Rel djh $ + * $Revision: 2.1 $ + * + */ + + /* + * AUFS Distributed Passwords + * + * Copyright 1995 - The University of Melbourne. All rights reserved. + * May be used only for CAP/AUFS authentication. Any other use + * requires prior permission in writing from the copyright owner. + * + * djh@munnari.OZ.AU + * June 1995 + * + * afppass.h - AUFS Distributed Password defines. + * + * User passwords are normally stored in ~user/.afppass in DES encrypted + * form. This file also contains values for password expiry date, minimum + * password length, maximum failed login attempts and number of failed + * login attempts. + * + * For greater security, the file must be owned by the user and be set to + * mode AFP_DISTPW_MODE (usually 0600 or -rw-------), if this is not the + * case, the file is deleted. + * + * The decryption key is stored in a global afppass (defaults to the + * file /usr/local/lib/cap/afppass) which also contains default values + * for expiry date, minimum password length and maximum failed attempts. + * If this file is not owned by root and mode 0600 it will be removed. + * + * Notes: + * 1. In the case of user home directories mounted via NFS, the files must + * be set to mode 0644 (since root cannot read mode 0600 files on remote + * filesystems). You can change the mode using the define + * -DAFP_DISTPW_MODE=0644 + * + * 2. If you prefer to keep the .afppass files centrally, you can define + * the path using the define -DAFP_DISTPW_PATH=\"/usr/local/lib/cap/upw\" + * + * 3. The decryption key for the global afppass is defined by AFP_DIST_PASS + * Should be localized for each site, using -DAFP_DIST_PASS=\"password\". + * + * 4. AFP passwords can only be changed by the user with the AppleShare + * workstation client or by the UNIX superuser using aufsmkusr. + * + * 5. User AFP passwords MUST NOT be identical to UNIX login passwords, + * this restriction is enforced by the library routines. + * + */ + + #define KEYSIZE 8 + #define MINKEYSIZE 6 + #define AFPPDSIZE 34 + + struct afppass { + u_char afp_magic; /* magic for sanity checking */ + #define AFPDP_MAGIC 79 + u_char afp_minmpwlen; /* mininum password length */ + u_char afp_maxattempt; /* maximum failed login attempts */ + u_char afp_numattempt; /* count of attempts to date */ + time_t afp_expires; /* date password expires */ + u_char afp_password[10]; /* current user password */ + }; + + /* + * Gobal key. Should be localized by each site. + * + */ + + #ifndef AFP_DISTPW_PASS + #define AFP_DISTPW_PASS "%-[&'*!~" + #endif AFP_DISTPW_PASS + + /* + * Misc files & permission. + * + */ + + #ifndef AFP_DISTPW_FILE + #define AFP_DISTPW_FILE "/usr/local/lib/cap/afppass" + #endif AFP_DISTPW_FILE + + #ifndef AFP_DISTPW_USER + #define AFP_DISTPW_USER ".afppass" + #endif AFP_DISTPW_USER + + #ifndef AFP_DISTPW_MODE + #define AFP_DISTPW_MODE 0600 + #endif AFP_DISTPW_MODE + + /* + * Misc numbers. + * + */ + + #define SECS_IN_DAY 24*60*60 + #define SECS_IN_MON 30*24*60*60 + #define SECS_10_YRS 10*365*24*60*60 *** netat/Makefile.m4.orig Tue Nov 23 20:27:14 1993 --- netat/Makefile.m4 Fri Jun 30 08:36:16 1995 *************** *** 1,6 **** I=includedir() HFILES = aberrors.h abqueue.h appletalk.h afp.h afpcmd.h afpc.h \ ! compat.h sysvcompat.h macfile.h abnbp.h fcntldomv.h install: $(HFILES) -mkdir $I/netat --- 1,6 ---- I=includedir() HFILES = aberrors.h abqueue.h appletalk.h afp.h afpcmd.h afpc.h \ ! compat.h sysvcompat.h macfile.h abnbp.h fcntldomv.h afppass.h install: $(HFILES) -mkdir $I/netat *** extras/des.c.orig Thu Feb 28 23:43:55 1991 --- extras/des.c Mon Jun 19 21:36:55 1995 *************** *** 0 **** --- 1,4 ---- + #ifdef __alpha + #define long int + #endif /* __alpha */ + *** man/AUFS.1.orig Mon Jun 19 11:50:47 1995 --- man/AUFS.1 Mon Jun 19 11:33:51 1995 *************** *** 109,115 **** field (Chooser will supply the name from its name field as the default). Click in the .I Password: ! field to activate text entry there and type in your UNIX password (asterisks will show instead of the characters you typed for security). Press the RETURN key or click on OK. .I guest --- 109,116 ---- field (Chooser will supply the name from its name field as the default). Click in the .I Password: ! field to activate text entry there and type in either your UNIX password ! ("Clear text" is specified in the login dialog box) or your AUFS password (asterisks will show instead of the characters you typed for security). Press the RETURN key or click on OK. .I guest *** man/AUFS.8.orig Mon Jun 19 11:51:28 1995 --- man/AUFS.8 Fri Jun 30 14:46:47 1995 *************** *** 11,17 **** ] [ .BI \-U " " ] [ ! .BI \-P " " ] [ .BI \-G " " ] [ --- 11,17 ---- ] [ .BI \-U " " ] [ ! .BI \-P " " ] [ .BI \-G " " ] [ *************** *** 52,57 **** --- 52,59 ---- .BI \-t " <" "Input | Output | Both" > ] [ .BI \-L " " + ] [ + .BI \-Z " " ] .SH DESCRIPTION .I aufs *************** *** 98,106 **** value is limited solely by the number of DDP sockets available. One UNIX process is created for each open session. .TP 10 ! .BI \-P " " ! specifies the absolute pathname of a "lookaside" password file, to ! override use of the normal UNIX password file. This option requires special configuration when installing aufs -- see the installation instructions in the source directory. .TP 10 --- 100,110 ---- value is limited solely by the number of DDP sockets available. One UNIX process is created for each open session. .TP 10 ! .BI \-P " " ! specifies the absolute pathname of a "lookaside" password file containing ! cleartext usernames and passwords or to an optional administrative file ! that lists valid usernames for use with the DISTRIB_PASSWDS feature (must ! be specified at compile time by enabling the option at Configure time). This option requires special configuration when installing aufs -- see the installation instructions in the source directory. .TP 10 *************** *** 224,229 **** --- 228,238 ---- (this option must be specified at compile time by enabling the LOGIN_AUTH_PROG option at Configure time). .SH DEBUGGING OPTIONS + .TP 10 + .BI \-Z "" + is used to specify the name of the output file to use for detailed debugging + of AFP commands (this option must be specified at compile time by enabling + the DEBUG_AFP_CMD option at Configure time). .TP 10 .B \-s tells *** man/aufsmkusr.8.orig Tue Jun 20 19:03:22 1995 --- man/aufsmkusr.8 Wed Jun 21 20:59:56 1995 *************** *** 0 **** --- 1,107 ---- + .\" troff -man + .TH AUFSMKUSR 8L "Jun 20 1995" "AUFS Distributed Passwords" + .SH NAME + aufsmkusr \- AUFS distributed password tool + .SH SYNOPSIS + .B aufsmkusr + [ + .BI \-f " " + ] [ + .BI user\ ... + ] + .SH DESCRIPTION + .I aufsmkusr + is the administrative tool used to create or edit distributed user password + files for AUFS Randnum or 2-Way Randnum user authentication (this replaces + the current AUFS authentication code which uses cleartext passwords). This + feature must be enabled in CAP AUFS by defining DISTRIB_PASSWDS at CAP + configuration time. + .sp + .I aufsmkusr + must be run by the UNIX superuser. + .sp + User password files are normally kept in ~user/.afppass, set to mode 0600 + and owned by the user. The location and mode of the user password file may + be customised at compile time using the defines AFP_DISTPW_PATH + and AFP_DISTPW_MODE (useful, for example, if user home directories are + mounted via NFS from another machine). The user password files contain the + current password expiry date, minimum password length, maximum failed login + attempts (all can be set to zero to disable the feature), number of failed + login attempts and the user's AUFS password. + .sp + The ~user/.afppass files are encrypted with a global key created with the + .I aufsmkkey + tool. The global key is kept in the file /usr/local/lib/cap/afppass (or an + alternate file defined by AFP_DISTPW_FILE). The global file also stores + default values for password expiry (either an expiry period up to 10 years + or a global cutoff date), minimum AUFS password length and maximum failed + login attempts. This file is also encrypted and is expected to be owned by + user root and set to mode 0600. + .sp + AUFS passwords can only be altered by the user using the AppleShare + Workstation software (using the 'Set Password' button in the AppleShare + login dialog box). The software will not permit the new password to be + identical to the old password or to be the same as the user's UNIX + password. + .sp + .I aufsmkusr + may be used in batch or interactive modes. + .PP + The arguments that + .I aufsmkusr + accepts are: + .TP + .BI \-f " " + .sp + specifies that + .I aufsmkusr + creates AUFS user password files for the users listed in the "batch file". + The format is expected to be 'username password' with one entry per line + and the user name and password separated by white space. Comment lines may + begin with the # character, blank lines are ignored. Passwords containing + spaces may be quoted with double quotes. Passwords are limited to a maximum + of 8 characters and will be truncated if longer. + .sp + If the batch file is not set to mode 0600, the program will exit + (since this is considered to be a security breach). + .sp + When created from a batch file, the default values for minimum password + length and maximum failed login attempts are read from the global key + file. The expiry date of the password is set to the current time. This + forces the users to change their passwords when they first connect to AUFS. + .TP + .BI user\ ... + .sp + If used in interactive mode, + .I aufsmkusr + may be used to edit or create a + password file for users listed on the command line. If no user name is + provided, it will be prompted for. + .sp + The minimum password length may be set to values between 0 (disabled) and 8. + Maximum failed login attempts to between 0 (disabled) and 255. If non-zero, + the current number of failed login attempts may also be edited (ie: reset). + .sp + The expiry date may be set to a period measured in days or months, for + example: 60d, 60, 2m are equivalent input values or to a specific date + using a string of the form YY/MM/DD and an optional HH:MM:SS. EG: + 95/06/20 16:44:55 is Tuesday June 20, 1995 at 4:44:55pm. + .sp + If the user expiry date is later than the global expiry date, a warning + message is printed. + .sp + When the password has expired, the AppleShare user may still connect, but + the only command available is 'Set Password'. If the maximum number of login + failures have occurred, the user is advised that the account is disabled + and to contact the server administrator. + .sp + .SH FILES + ~/.afppass - user password file. + .br + /usr/local/lib/cap/afppass - global key file. + .SH SEE ALSO + aufsmkkey(8), CAP (Columbia AppleTalk Package) + .SH AUTHOR + djh\@munnari.OZ.AU, June 1995. + .SH NOTICE + Copyright (c) 1995, The University of Melbourne. *** man/aufsmkkey.8.orig Tue Jun 20 19:03:22 1995 --- man/aufsmkkey.8 Wed Jun 21 20:59:57 1995 *************** *** 0 **** --- 1,65 ---- + .\" troff -man + .TH AUFSMKKEY 8L "Jun 20 1995" "AUFS Distributed Passwords" + .SH NAME + aufsmkkey \- AUFS distributed password global key tool + .SH SYNOPSIS + .B aufsmkkey + .SH DESCRIPTION + .I aufsmkkey + is the administrative tool used to create or edit the global key file + used for AUFS Randnum or 2-Way Randnum user authentication (this replaces + the current AUFS authentication code which uses cleartext passwords). This + feature must be enabled in CAP AUFS by defining DISTRIB_PASSWDS at CAP + configuration time. + .sp + .I aufsmkkey + must be run by the UNIX superuser. + .sp + The global key is kept in the file /usr/local/lib/cap/afppass + (or an alternate file defined by AFP_DISTPW_FILE) and is used to encrypt + the contents of each user password file. The global file also stores default + values for password expiry (either an expiry period up to 10 years + or a global cutoff date), minimum AUFS password length and maximum failed + login attempts. This file is also encrypted and is expected to be owned by + user root and set to mode 0600. + .sp + User password files are created or edited by the + .I aufsmkusr + tool and are normally kept in ~user/.afppass, set to mode 0600 and owned by + the user. The location and mode of the user password file may be customised + at compile time using the defines AFP_DISTPW_PATH and AFP_DISTPW_MODE + (useful, for example, if user home directories are mounted via NFS from + another machine). The user password files contain the current password + expiry date, minimum password length, maximum failed login attempts (all + can be set to zero to disable the feature), number of failed login attempts + and the user's AUFS password. + .sp + AUFS passwords can only be altered by the user using the AppleShare + Workstation software (using the 'Set Password' button in the AppleShare + login dialog box). The software will not permit the new password to be + identical to the old password or to be the same as the user's UNIX + password. + .sp + The minimum password length may be set to values between 0 (disabled) and 8. + Maximum failed login attempts to between 0 (disabled) and 255. + .sp + The expiry date may be set to a period measured in days or months, for + example: 60d, 60, 2m are equivalent input values or to a specific date + using a string of the form YY/MM/DD and an optional HH:MM:SS. EG: + 95/06/20 16:44:55 is Tuesday June 20, 1995 at 4:44:55pm. + .sp + When the password has expired, the AppleShare user may still connect, but + the only command available is 'Set Password'. If the maximum number of login + failures have occurred, the user is advised that the account has been + disabled and to contact the server administrator. + .sp + .SH FILES + ~/.afppass - user password file. + .br + /usr/local/lib/cap/afppass - global key file. + .SH SEE ALSO + aufsmkusr(8), CAP (Columbia AppleTalk Package) + .SH AUTHOR + djh\@munnari.OZ.AU, June 1995. + .SH NOTICE + Copyright (c) 1995, The University of Melbourne. *** contrib/aufsmkusr.c.orig Tue Jun 20 18:58:35 1995 --- contrib/aufsmkusr.c Mon Jun 26 16:06:15 1995 *************** *** 0 **** --- 1,475 ---- + /* + * $Author: djh $ $Date: 1995/06/26 06:06:02 $ + * $Header: /local/mulga/mac/src/cap60/contrib/RCS/aufsmkusr.c,v 2.1 1995/06/26 06:06:02 djh Rel djh $ + * $Revision: 2.1 $ + * + */ + + /* + * CAP AFP 2.1 Distributed Passwords + * + * Copyright 1995 - The University of Melbourne. All rights reserved. + * May be used only for CAP/AUFS authentication. Any other use + * requires prior permission in writing from the copyright owner. + * + * djh@munnari.OZ.AU + * June 1995 + * + * aufsmkusr - modify or create a new .afppass file + * + * usage: aufsmkusr + * aufsmkusr user1 ... + * aufsmkusr -f batchfile + * + * The .afppass file stores the values for minimum password + * length, maximum login failures, current login failures, + * password expiry date and the user's AUFS password. + * + * It is encrypted with the global key set with aufsmkkey. + * + */ + + #include + #include + #include + #include + #include + #include + + #include + #include + + #ifdef DISTRIB_PASSWDS + + char *linep; + char *progname; + char *batchfile = NULL; + + main(argc, argv) + int argc; + char *argv[]; + { + int c; + char *cp; + char user[10]; + extern char *optarg; + extern int optind, opterr; + int aufsmkbatch(), aufsmkuser(); + + opterr = 0; + progname = argv[0]; + + if (geteuid() != 0) { + fprintf(stderr, "%s: Permission Denied.\n", progname); + exit(1); + } + + /* + * get global key parameters + * + */ + if (afpdp_init(AFP_DISTPW_FILE) < 0) { + fprintf(stderr, "%s: can't get key from %s\n", progname, AFP_DISTPW_FILE); + exit(2); + } + + /* + * process command line options + * + */ + while ((c = getopt(argc, argv, "f:")) != -1) { + switch (c) { + case 'f': + batchfile = optarg; + break; + default: + fprintf(stderr, "usage: aufsmkusr [-f file] [user ...]\n"); + exit(1); + break; + } + } + + /* + * process users in batch file + * + */ + if (batchfile != NULL) { + (void)aufsmkbatch(batchfile); + exit(0); + } + + /* + * process users in argument list + * + */ + if (optind < argc) { + for ( ; optind < argc; optind++) { + fprintf(stderr, "\nSetting AUFS password for %s\n", argv[optind]); + (void)aufsmkuser(argv[optind]); + } + exit(0); + } + + /* + * do single users + * + */ + printf("AUFS user: "); + fgets(user, sizeof(user), stdin); + if ((cp = (char *)index(user, '\n')) != NULL) + *cp = '\0'; + + if (user[0] == '\0') + exit(0); + + if (aufsmkuser(user) < 0) + exit(3); + + exit(0); + } + + /* + * make password file for 'user' + * + */ + + int + aufsmkuser(user) + char *user; + { + char abuf[80], *cp; + char pass1[10], pass2[10]; + struct passwd *pw, *getpwnam(); + extern struct afppass *afp_glob; + time_t now, when, then, afpdp_gdat(); + struct afppass afppass, *afp, *afpdp_read(); + int afpdp_init(), afpdp_gnum(), afpdp_writ(); + void print_date(); + + if ((pw = getpwnam(user)) == NULL) { + fprintf(stderr, "%s: no such user: \"%s\"\n", progname, user); + return(-1); + } + + bzero((char *)&afppass, sizeof(struct afppass)); + + /* + * get current values or set defaults + * + */ + if ((afp = afpdp_read(user, pw->pw_uid, pw->pw_dir)) != NULL) + bcopy((char *)afp, (char *)&afppass, sizeof(struct afppass)); + else + bcopy((char *)afp_glob, (char *)&afppass, 8); /* not password */ + + /* + * minimum password length 0 - 8 (0 to disable) + * + */ + printf("Minimum AUFS password length: [%d] ? ", afppass.afp_minmpwlen); + afppass.afp_minmpwlen = (u_char)afpdp_gnum(afppass.afp_minmpwlen, KEYSIZE); + + /* + * maximum failed logins (0 - 255) (0 to disable) + * + */ + printf("Maximum failed login attempts: [%d] ? ", afppass.afp_maxattempt); + afppass.afp_maxattempt = (u_char)afpdp_gnum(afppass.afp_maxattempt, 255); + + /* + * current login attempt failures + * + */ + if (afppass.afp_numattempt > 0) { + printf("User \"%s\" has %d failed login attempt%s.\n", user, + afppass.afp_numattempt, (afppass.afp_numattempt== 1) ? "" : "s"); + printf("Reset number of failed login attempts: [%d] ? ", + afppass.afp_numattempt); + afppass.afp_numattempt = (u_char)afpdp_gnum(afppass.afp_numattempt, 255); + } + + /* + * make sure user afppass not period + * (except if disabled) + * + */ + time(&now); + when = ntohl(afppass.afp_expires); + if (when <= SECS_10_YRS && when != 0) { + afppass.afp_expires = htonl(when+now); + when = ntohl(afppass.afp_expires); + } + + /* + * expiry date (0 to disable) + * + */ + print_date(when); + printf("Password Expires (NNd or NNm or YY/MM/DD [HH:MM:SS]): ? "); + if ((then = afpdp_gdat()) != 0xffffffff) { + if (then <= SECS_10_YRS && then != 0) + then += now; + afppass.afp_expires = htonl(then); + when = then; + } + print_date(when); + + then = ntohl(afp_glob->afp_expires); + if (then > SECS_10_YRS && when > then) + printf("WARNING: Global expiry date is %s", ctime(&then)); + + /* + * user password, up to 8 characters + * + */ + if (*afppass.afp_password) { + printf("Change %s's Password (y/n): [n] ? ", user); + fgets(abuf, sizeof(abuf), stdin); + if (abuf[0] == 'y' || abuf[0] == 'Y') + afppass.afp_password[0] = '\0'; + } + + while (*afppass.afp_password == '\0') { + strcpy(pass1, (char *)getpass("User Password: ")); + if (strlen(pass1) < afppass.afp_minmpwlen) { + printf("Password is shorter than minimum length (%d)\n"); + continue; + } + strcpy(pass2, (char *)getpass("Reenter User Password: ")); + if (strcmp(pass1, pass2) != 0) { + printf("Password mismatch!\n"); + continue; + } + strcpy(afppass.afp_password, pass1); + } + + /* + * reset defaults and write + * + */ + afppass.afp_magic = AFPDP_MAGIC; + + if (afpdp_writ(user, pw->pw_uid, pw->pw_dir, &afppass) < 0) { + fprintf(stderr, "%s: failed to set AUFS password (same as UNIX ?)\n", + progname); + return(-1); + } + + return(0); + } + + /* + * handle bulk batch file + * + * each line is expected to be of the format: user "password" + * passwords containing spaces must be enclosed in double quotes + * + * NB: the expiry date is set to now. This requires the user to change + * their password when they first login. + * + */ + + int + aufsmkbatch(file) + char *file; + { + time_t now; + struct stat buf; + FILE *fp, *fopen(); + struct afppass afppass; + extern struct afppass *afp_glob; + struct passwd *pw, *getpwnam(); + char *cp, line[96], user[32]; + int afpdp_writ(); + void getfield(); + + if (stat(file, &buf) >= 0) { + if ((buf.st_mode&0777) != 0600) { + fprintf(stderr, "WARNING: %s is mode %0o\n", file, buf.st_mode&0777); + exit(1); + } + } + + bzero((char *)&afppass, sizeof(struct afppass)); + bcopy((char *)afp_glob, (char *)&afppass, 8); /* not password */ + + if ((fp = fopen(file, "r")) == NULL) { + perror(file); + return(-1); + } + + time(&now); + + while (fgets(line, sizeof(line), fp) != NULL) { + if (line[0] == '#' || line[0] == '\n') + continue; + if ((cp = (char *)index(line, '\n')) != NULL) + *cp = '\0'; + + linep = line; + getfield(user, sizeof(user), 0); + getfield(afppass.afp_password, sizeof(afppass.afp_password), 0); + + printf("User \"%s\" - ", user); + + /* + * user exists ? + * + */ + if ((pw = getpwnam(user)) == NULL) { + printf("does not exist - continuing\n"); + continue; + } + + /* + * and has a passwod + * + */ + if (afppass.afp_password[0] == '\0') { + printf("has no password set - continuing\n"); + continue; + } + + /* + * which expires NOW + * + */ + afppass.afp_expires = htonl(now); + + /* + * then set defaults and write + * + */ + afppass.afp_numattempt = 0; + afppass.afp_magic = AFPDP_MAGIC; + if (afpdp_writ(user, pw->pw_uid, pw->pw_dir, &afppass) < 0) { + printf("can't create .afppass file - continuing\n"); + continue; + } + + printf("OK\n"); + } + + (void)fclose(fp); + + return(0); + } + + /* + * output date string + * + */ + + void + print_date(when) + time_t when; + { + time_t now; + + time(&now); + + if (when < SECS_10_YRS) { + if (when == 0) + printf("Password Expiry disabled.\n"); + else + printf("Password Expiry period %d day%s.\n", + when/(SECS_IN_DAY), (when/(SECS_IN_DAY) == 1) ? "" : "s"); + } else { + if (when < now) + printf("Warning, expiry date has already passed\n"); + printf("Password Expires on %s", ctime(&when)); + } + + return; + } + + /* + * Get next field from 'line' buffer into 'str'. 'linep' is the + * pointer to current position. + * + * Fields are white space separated, except within quoted strings. + * If 'quote' is true the quotes of such a string are retained, otherwise + * they are stripped. Quotes are included in strings by doubling them or + * escaping with '\'. + * + */ + + void + getfield(str, len, quote) + char *str; + int len, quote; + { + register char *lp = linep; + register char *cp = str; + + while (*lp == ' ' || *lp == '\t') + lp++; /* skip spaces/tabs */ + + if (*lp == 0 || *lp == '#') { + *cp = 0; + return; + } + len--; /* save a spot for a null */ + + if (*lp == '"' || *lp == '\'') { /* quoted string */ + register term = *lp; + + if (quote) { + *cp++ = term; + len -= 2; /* one for now, one for later */ + } + lp++; + while (*lp) { + if (*lp == term) { + if (lp[1] == term) + lp++; + else + break; + } + /* check for \', \", \\ only */ + if (*lp == '\\' + && (lp[1] == '\'' || lp[1] == '"' || lp[1] == '\\')) + lp++; + *cp++ = *lp++; + if (--len <= 0) { + fprintf(stderr, "string truncated: %s\n", str); + if (quote) + *cp++ = term; + *cp = 0; + linep = lp; + return; + } + } + if (!*lp) + fprintf(stderr,"unterminated string: %s", str); + else { + lp++; /* skip the terminator */ + + if (*lp && *lp != ' ' && *lp != '\t' && *lp != '#') { + fprintf(stderr, "garbage after string: %s", str); + while (*lp && *lp != ' ' && *lp != '\t' && *lp != '#') + lp++; + } + } + if (quote) + *cp++ = term; + } else { + while (*lp && *lp != ' ' && *lp != '\t' && *lp != '#') { + *cp++ = *lp++; + if (--len <= 0) { + fprintf(stderr, "string truncated: %s\n", str); + break; + } + } + } + *cp = 0; + linep = lp; + + return; + } + #else /* DISTRIB_PASSWDS */ + main() + { + printf("CAP not compiled with DISTRIB_PASSWDS\n"); + } + #endif /* DISTRIB_PASSWDS */ *** contrib/aufsmkkey.c.orig Tue Jun 20 18:58:35 1995 --- contrib/aufsmkkey.c Mon Jun 26 16:06:23 1995 *************** *** 0 **** --- 1,162 ---- + /* + * $Author: djh $ $Date: 1995/06/26 06:06:02 $ + * $Header: /local/mulga/mac/src/cap60/contrib/RCS/aufsmkkey.c,v 2.1 1995/06/26 06:06:02 djh Rel djh $ + * $Revision: 2.1 $ + * + */ + + /* + * CAP AFP 2.1 Distributed Passwords + * + * Copyright 1995 - The University of Melbourne. All rights reserved. + * May be used only for CAP/AUFS authentication. Any other use + * requires prior permission in writing from the copyright owner. + * + * djh@munnari.OZ.AU + * June 1995 + * + * aufsmkkey.c - modify or create a new global key file. + * + * usage: aufsmkkey + * + * The global key file stores default values for minimum password + * length, maximum login failures, password expiry period or date + * and the global key used to encrypt ~user/.afppass files. + * + * Note: Changing the global key invalidates all of the passwords + * of the existing user base. + * + */ + + #include + #include + #include + #include + + #include + #include + + #ifdef DISTRIB_PASSWDS + + main(argc, argv) + int argc; + char *argv[]; + { + struct afppass afppass; + char abuf[80], *progname; + char pass1[10], pass2[10]; + extern struct afppass *afp_glob; + time_t when, then, afpdp_gdat(); + int afpdp_init(), afpdp_gnum(), afpdp_make(); + void print_date(); + + progname = argv[0]; + + if (geteuid() != 0) { + fprintf(stderr, "%s: Permission Denied.\n", progname); + exit(1); + } + + /* + * get global key parameters, if file already exists + * + */ + if (afpdp_init(AFP_DISTPW_FILE) < 0) + bzero((char *)&afppass, sizeof(struct afppass)); + else + bcopy((char *)afp_glob, (char *)&afppass, sizeof(struct afppass)); + + /* + * minimum password length (0 - 8) (0 to disable) + * + */ + printf("Minimum AUFS password length: [%d] ? ", afppass.afp_minmpwlen); + afppass.afp_minmpwlen = (u_char)afpdp_gnum(afppass.afp_minmpwlen, KEYSIZE); + + /* + * maximum failed logins (0 - 255) (0 to disable) + * + */ + printf("Maximum failed login attempts: [%d] ? ", afppass.afp_maxattempt); + afppass.afp_maxattempt = (u_char)afpdp_gnum(afppass.afp_maxattempt, 255); + + when = ntohl(afppass.afp_expires); + + /* + * expiry period (0 - 10 years) or expiry date (0 to disable) + * + */ + print_date(when); + printf("Password Expires (NNd or NNm or YY/MM/DD [HH:MM:SS]): ? "); + if ((then = afpdp_gdat()) != 0xffffffff) { + afppass.afp_expires = htonl(then); + when = then; + } + print_date(when); + + /* + * global key, up to 8 characters + * + */ + if (*afppass.afp_password) { + printf("Change Global Key (y/n): [n] ? "); + fgets(abuf, sizeof(abuf), stdin); + if (abuf[0] == 'y' || abuf[0] == 'Y') + afppass.afp_password[0] = '\0'; + } + + while (*afppass.afp_password == '\0') { + strcpy(pass1, (char *)getpass("Global Key: ")); + if (strlen(pass1) < MINKEYSIZE) { + printf("Please use at least %d characters!\n", MINKEYSIZE); + continue; + } + strcpy(pass2, (char *)getpass("Reenter Global Key: ")); + if (strcmp(pass1, pass2) != 0) { + printf("Key Mismatch!\n"); + continue; + } + strcpy(afppass.afp_password, pass1); + } + + /* + * set defaults and write + * + */ + afppass.afp_numattempt = 0; + afppass.afp_magic = AFPDP_MAGIC; + + if (afpdp_make(AFP_DISTPW_FILE, &afppass) < 0) { + fprintf(stderr, "%s: failed to set global key\n", progname); + exit(1); + } + + exit(0); + } + + void + print_date(when) + time_t when; + { + time_t now; + + time(&now); + + if (when < SECS_10_YRS) { + printf("Password Expiry period %d day%s%s.\n", when/(SECS_IN_DAY), + (when/(SECS_IN_DAY) == 1) ? "" : "s", (when == 0) ? " (Disabled)" : ""); + } else { + if (when < now) + printf("Warning, expiry date has already passed\n"); + printf("Password Expires on %s", ctime(&when)); + } + + return; + } + + #else /* DISTRIB_PASSWDS */ + main() + { + printf("CAP not compiled with DISTRIB_PASSWDS\n"); + } + #endif /* DISTRIB_PASSWDS */ *** contrib/Makefile.m4.orig Sun Mar 8 17:38:47 1992 --- contrib/Makefile.m4 Tue Jun 20 18:57:11 1995 *************** *** 9,21 **** SLIB=libspecial() CAPLIB=libcap() UDESTDIR=capdestdir() SDESTDIR=capsrvrdestdir() RENAMEFLAG=-DLWRENAMEFILE=lwrenamefile() ifdef([useatis],[],[# ])ATISPROGS=snitch ! SRVR=lwrename printqueue ${ATISPROGS} USER=cvt2apple cvt2cap PROGS= ${USER} ${SRVR} --- 9,22 ---- SLIB=libspecial() CAPLIB=libcap() + AFPLIB=libafp() UDESTDIR=capdestdir() SDESTDIR=capsrvrdestdir() RENAMEFLAG=-DLWRENAMEFILE=lwrenamefile() ifdef([useatis],[],[# ])ATISPROGS=snitch ! SRVR=lwrename printqueue ${ATISPROGS} aufsmkusr aufsmkkey USER=cvt2apple cvt2cap PROGS= ${USER} ${SRVR} *************** *** 38,43 **** --- 39,50 ---- printqueue: printqueue.o ${CC} ${LFLAGS} -o printqueue printqueue.o ${O} ${CAPLIB} ${SLIB} + + aufsmkusr: aufsmkusr.o + ${CC} ${LFLAGS} -o aufsmkusr aufsmkusr.o ${O} ${AFPLIB} ${SLIB} + + aufsmkkey: aufsmkkey.o + ${CC} ${LFLAGS} -o aufsmkkey aufsmkkey.o ${O} ${AFPLIB} ${SLIB} att_getopt.c: ln -s ../extras/att_getopt.c *** contrib/README.orig Wed Mar 13 20:44:15 1991 --- contrib/README Wed Jun 21 20:02:22 1995 *************** *** 13,18 **** --- 13,22 ---- printqueue.c - allow a Mac DA to access UNIX lpd information : Contributed by Ed Moy + aufsmkkey.c - tool for creating global key for distributed passwords + aufsmkusr.c - tool for creating non-cleartext authentication password file + : Contributed by David Hornsby + The following are not automatically made with CAP and some have not been tested on (or ported to) all of the systems that otherwise fully support CAP. *** CAP60.README.orig Mon Oct 24 16:41:46 1994 --- CAP60.README Wed Jun 28 14:03:29 1995 *************** *** 18,24 **** * UAB now supports Asynchronous AppleTalk on a UNIX host. * The format of 'atalk.local' has been extended for async appletalk. * Zone names in 'atalk.local' MUST now be quoted to include spaces. ! * A "free format" 'etalk.local' is used by EtherTalk LAPs (& UAB). * atis is now Phase 2 NBP compatible (partial obj/type matches). * There are more (& updated) manual entries and documentation. * There are more contributed packages bundled with CAP. --- 18,24 ---- * UAB now supports Asynchronous AppleTalk on a UNIX host. * The format of 'atalk.local' has been extended for async appletalk. * Zone names in 'atalk.local' MUST now be quoted to include spaces. ! * A "free format" 'etalk.local' is used by EtherTalk LAPs (& UAB/UAR). * atis is now Phase 2 NBP compatible (partial obj/type matches). * There are more (& updated) manual entries and documentation. * There are more contributed packages bundled with CAP. *************** *** 33,40 **** AUFS comply with AFP2.0 specifications and adding extra facilities and host support to Configure. Currently, AUFS supports ProDOS* (Apple IIgs) workstations running AppleTalk, the extended directory and volume attributes ! and the additional error result codes. It does not currently support client ! altered passwords. * ProDOS requires the NOCASEMATCH feature, or use of upper-case application filenames only. --- 33,40 ---- AUFS comply with AFP2.0 specifications and adding extra facilities and host support to Configure. Currently, AUFS supports ProDOS* (Apple IIgs) workstations running AppleTalk, the extended directory and volume attributes ! and the additional error result codes. AUFS supports user editable encrypted ! passwords using the DISTRIB_PASSWDS feature. * ProDOS requires the NOCASEMATCH feature, or use of upper-case application filenames only. *************** *** 48,54 **** Sequent Balance William Roberts ICL DRS6000 Michael Brown DEC OSF/1 Alpha Scooter Morris ! 386/BSD, FreeBSD Dave Matthews HP/Apollo Domain BSD 4.3 Darrell Skinner --- 48,60 ---- Sequent Balance William Roberts ICL DRS6000 Michael Brown DEC OSF/1 Alpha Scooter Morris ! Amdahl UTS Mark Haynie ! Sun Solaris 2.N Andy Polyakov ! Sony NEWS TAYA Shin'ichiro ! Control Data CD4000-EP/IX John Huntley ! 386/BSD, FreeBSD 2.0 Dave Matthews ! NetBSD 1.0 Paul Nash ! BSDI BSD/386 1.1 David Hornsby HP/Apollo Domain BSD 4.3 Darrell Skinner *************** *** 155,161 **** XDEV_RENAME Allows AUFS to copy/move files across file systems. Mark Abbott - NOCHGRPEXEC Make AUFS use the third argument to chown(2) instead of exec'ing chgrp(1) to change group membership of file. --- 161,166 ---- *************** *** 181,187 **** An alternate subdirectory/volume name is specified with the string -DCREATE_AFPVOL=\"other\" in m4.features Heather Ebey ! CREATE_AFPVOL_NAME Modifies the CREATE_AFPVOL option to use the user/account name for the volume label instead of the value of the CREATE_AFPVOL variable. Assumes CREATE_AFPVOL. --- 186,192 ---- An alternate subdirectory/volume name is specified with the string -DCREATE_AFPVOL=\"other\" in m4.features Heather Ebey ! CREATE_AFPVOL_NAME (now CREAT_AFPVOL_NAM) Modifies the CREATE_AFPVOL option to use the user/account name for the volume label instead of the value of the CREATE_AFPVOL variable. Assumes CREATE_AFPVOL. *************** *** 283,288 **** --- 288,335 ---- If defined, PAPIF will send Information, Warning and Debug messages to syslog(). Andy Polyakov + DISTRIB_PASSWDS + If defined, CAP will use AUFS authentication methods that + involve exchanging encrypted random numbers instead of + sending passwords in clear text over the network. Refer to + manual entries aufsmkkey.8 and aufsmkusr.8 in cap60/man. + David Hornsby + AFP_DISTPW_PATH + Specifies that the distributed password files used in + DISTRIB_PASSWDS be kept in a directory other than the + user's home directory. For example, you could use the + following -DAFP_DISTPW_PATH=\"/usr/local/lib/cap/upw\" + David Hornsby + AFP_DISTPW_MODE + Modifies the file mode being enforced with DISTRIB_PASSWDS. + For use when user home directories are mounted via NFS. Uses + mode 0600 by default, use 0644 with NFS. + David Hornsby + DEBUG_AFP_CMD + If defined, AUFS will dump detailed logs of AFP command I/O + parameters in the file specified with the AUFS -Z option. + Use in conjunction with Inside AppleTalk 2nd edition for + debugging the AUFS AFP implementation. + David Hornsby + LOG_WTMP + If defined, AUFS will write an entry into the wtmp log file + on each successful AUFS connection. Allows usage tracking. + Gavin Longmuir + Heather Ebey + LOG_WTMP_PATH + Specifies alternat name for the wtmp file used in LOG_WTMP. + Heather Ebey + ADMIN_GRP + If defined, AUFS will check if the user is a member of a + special admin group and connect them with superuser privs. + Tim Leamy + TEMPFILE + Allow the LWSRV temporary file path to be specified. + Serge + USELPRSYM + Option to allow optional lpr '-s' (broken under OSF/1). + Serge + The following were originally to be defined in m4.setup, they have been moved to m4.features for convenience. *************** *** 336,345 **** % patch -p < cap60.patches/cap60.patch0NN where NN is the patch number. The -p option tells patch to obtain ! information about which file to alter from the patch header. If you attempt ! to apply a patch more than once, patch will enquire about "a reversed or ! previously applied patch", answering yes to this will remove the patch, ! leaving the original file (and bug), this is not good ... CAP and AppleTalk Phase 2 --- 383,393 ---- % patch -p < cap60.patches/cap60.patch0NN where NN is the patch number. The -p option tells patch to obtain ! information about which file to alter from the patch header (use -p0 on ! a DEC Alpha under OSF/1). If you attempt to apply a patch more than once, ! patch will enquire about "a reversed or previously applied patch", answering ! yes to this will remove the patch, leaving the original file (and bug), this ! is not good ... CAP and AppleTalk Phase 2 *************** *** 403,408 **** --- 451,457 ---- Native EtherTalk cap60/support/ethertalk/README Kernel AppleTalk lib/cap/abkas.c, netatalk-1.2 distribution + http://www.cs.mu.OZ.AU/appletalk/atalk.html Gotchas ------- *** README.orig Mon Oct 24 16:41:43 1994 --- README Wed Jun 21 21:07:06 1995 *************** *** 2,8 **** CAP - Columbia AppleTalk Package for UNIX o RELEASE NOTES ! o CAP Distribution 6.0, Patch Level 194, October 1994 Notice ------ --- 2,8 ---- CAP - Columbia AppleTalk Package for UNIX o RELEASE NOTES ! o CAP Distribution 6.0, Patch Level 195, June 1995 Notice ------ *************** *** 28,34 **** Portions Copyright (c) 1984, Apple Computer Inc. Gene Tyacke, Alan Oppenheimer, G. Sidhu, Rich Andrews. ! Portions Copyright (c) 1990 - 1994 The University of Melbourne Modules copyright in part or whole by any other entity than Columbia University are clearly marked as such. --- 28,34 ---- Portions Copyright (c) 1984, Apple Computer Inc. Gene Tyacke, Alan Oppenheimer, G. Sidhu, Rich Andrews. ! Portions Copyright (c) 1990 - 1995 The University of Melbourne Modules copyright in part or whole by any other entity than Columbia University are clearly marked as such. *************** *** 100,105 **** --- 100,109 ---- ARPANET, you can get on the mailing list by sending mail to info-appletalk-request@andrew.cmu.edu. + Information about CAP and related UNIX AppleTalk packages is available + via the World Wide Web using + + http://www.cs.mu.OZ.AU/appletalk/atalk.html Documentation -------------