This is a quick patch for netatalk-1.4b2 to make it work on Linux 2.2.
The most important fix is to handle broadcasts properly under linux.
A few other minor itches has also been fixed.

Alan Cox did post the basis for the required fix on this list a few years
ago (!), and I've just implemented it.

Please just consider this patch as a very quick hack to get something
working; it needs further work on:

        Adding #ifdef linux or other #ifdefs where applicable

        Handling bytesex.h gracefully, and in a portable manner

        Handling the -lcrypt in the Makefile

        Handling the equivalent of TIOCNOTTY under Linux?

        Testing, testing
        
The patch was tested on a i386 Red Hat 6.2 system. I've only tested Linux
server side functions.
        
Egil

--------------------------CUT HERE-----------------------------
*** etc/afpd/Makefile.orig      Fri Sep 27 16:04:07 1996
--- etc/afpd/Makefile   Fri May 26 05:03:44 2000
***************
*** 12,16 ****
  CFLAGS=       ${DEFS} ${AFSDEFS} ${KRBDEFS} ${OPTOPTS} ${INCPATH} \
        -DAPPLCNAME -DCRLF # -DDOWNCASE
! LIBS= -latalk ${AFSLIBS} ${KRBLIBS} ${ADDLIBS}
  LIBDIRS=      -L../../libatalk ${AFSLIBDIRS} ${KRBLIBDIRS}
  TAGSFILE=     tags
--- 12,17 ----
  CFLAGS= ${DEFS} ${AFSDEFS} ${KRBDEFS} ${OPTOPTS} ${INCPATH} \
        -DAPPLCNAME -DCRLF # -DDOWNCASE
! # -l crypt required for Linux *EK*
! LIBS=   -latalk ${AFSLIBS} ${KRBLIBS} ${ADDLIBS} -lcrypt
  LIBDIRS=        -L../../libatalk ${AFSLIBDIRS} ${KRBLIBDIRS}
  TAGSFILE=       tags
*** etc/afpd/auth.c.orig        Mon Sep 16 18:33:55 1996
--- etc/afpd/auth.c     Fri May 26 05:02:43 2000
***************
*** 4,7 ****
--- 4,13 ----
   */
  
+ /* required to make crypt() work on Linux */
+ #define _XOPEN_SOURCE
+ typedef unsigned short u_short;
+ typedef unsigned char u_char;
+ #include <unistd.h>
+ 
  #include <stdio.h>
  #include <sys/types.h>
*** etc/afpd/unix.c.orig        Tue Oct  1 19:26:52 1996
--- etc/afpd/unix.c     Fri May 26 05:03:21 2000
***************
*** 416,420 ****
      DIR                       *desk, *sub;
  
!     if ( getwd( wd ) == NULL ) {
        return( -1 );
      }
--- 416,420 ----
      DIR                 *desk, *sub;
  
!     if ( getcwd( wd ,sizeof(wd) ) == NULL ) {
        return( -1 );
      }
***************
*** 534,538 ****
      DIR                       *desk, *sub;
  
!     if ( getwd( wd ) == NULL ) {
        return( -1 );
      }
--- 534,538 ----
      DIR                 *desk, *sub;
  
!     if ( getcwd( wd, sizeof(wd) ) == NULL ) {
        return( -1 );
      }
*** etc/atalkd/main.c.orig      Mon Oct 21 22:45:03 1996
--- etc/atalkd/main.c   Fri May 26 06:48:53 2000
***************
*** 1248,1251 ****
--- 1248,1257 ----
        sat.sat_port = ap->ap_port;
  
+       /* for Linux, as Alan Cox told us *EK*/
+       if (sat.sat_addr.s_node == ATADDR_BCAST) {
+           int one = 1;
+           setsockopt(ap->ap_fd, SOL_SOCKET, SO_BROADCAST,&one,sizeof(one));
+       }
+ 
        if ( bind( ap->ap_fd, (struct sockaddr *)&sat,
                sizeof( struct sockaddr_at )) < 0 ) {
*** etc/atalkd/zip.c.orig       Tue Sep 24 18:57:09 1996
--- etc/atalkd/zip.c    Fri May 26 06:48:51 2000
***************
*** 871,874 ****
--- 871,880 ----
      sat.sat_port = ap->ap_port;
  
+     /* for Linux, as Alan Cox told us *EK*/
+     if (sat.sat_addr.s_node == ATADDR_BCAST) {
+       int one = 1;
+       setsockopt(ap->ap_fd, SOL_SOCKET, SO_BROADCAST,&one,sizeof(one));
+     }
+ 
      if ( sendto( ap->ap_fd, packet, data - packet, 0, (struct sockaddr *)&sat,
            sizeof( struct sockaddr_at )) < 0 ) {
*** etc/papd/main.c.orig        Mon Oct 21 22:45:16 1996
--- etc/papd/main.c     Fri May 26 05:05:08 2000
***************
*** 212,216 ****
--- 212,219 ----
            }
            if (( i = open( "/dev/tty", O_RDWR )) >= 0 ) {
+ #ifdef TIOCNOTTY
+               /*EK* Linux hasn't got it BUG: do we need a replacement? */
                (void)ioctl( i, TIOCNOTTY, 0 );
+ #endif
                setpgid( 0, getpid());
                (void)close( i );
*** include/netatalk/endian.h.orig      Mon Oct 21 19:13:36 1996
--- include/netatalk/endian.h   Fri May 26 04:59:11 2000
***************
*** 30,34 ****
  
  #ifdef linux
! #include <bytesex.h>
  #define BYTE_ORDER    __BYTE_ORDER
  #include <asm/byteorder.h>
--- 30,36 ----
  
  #ifdef linux
! /* *EK* BUG: find a better way !!! */
! #include "/usr/i386-glibc20-linux/include/bytesex.h"
! /* #include <bytesex.h> */
  #define BYTE_ORDER      __BYTE_ORDER
  #include <asm/byteorder.h>
*** libatalk/nbp/nbp_rgstr.c.orig       Wed Sep 18 19:08:35 1996
--- libatalk/nbp/nbp_rgstr.c    Fri May 26 06:33:07 2000
***************
*** 54,57 ****
--- 54,63 ----
      bcopy( &nt, data, SZ_NBPTUPLE);
      data += SZ_NBPTUPLE;
+ 
+     /* for Linux, as Alan Cox told us *EK*/
+     if (sat->sat_addr.s_node == ATADDR_BCAST) {
+       int one = 1;
+       setsockopt(s, SOL_SOCKET, SO_BROADCAST,&one,sizeof(one));
+     }
  
      if ( obj ) {
--------------------------CUT HERE-----------------------------




-- 
Email: [EMAIL PROTECTED]  Voice: +47 22523641, 92022780 Fax: +47 22525899
Mail:  Egil Kvaleberg, Husebybakken 14A, 0379 Oslo, Norway
Home:  http://www.kvaleberg.com/

Reply via email to