Solaris tftp server (tftpd) to handle >32MB files

Answered Question
Apr 22nd, 2009

Assuming it's not legally allowed to separately install the Cisco tftpd shipped with LMS on a non-LMS server, can anyone verify the following Sun patches address the same >32MB file handling problem for the tftpd shipped with Solaris 10?

http://sunsolve.sun.com/search/document.do?assetkey=urn:cds:docid:1-21-123333-02-1

SPARC 123332

x86 123333

I have this problem too.
0 votes
Correct Answer by Joe Clarke about 7 years 7 months ago

This is a bug. You need the attached patch to build on BSD-based operating systems like OS X.

Yes, you can install the tftpd from Solaris media, but it will only work on UltraSPARC Solaris.

Correct Answer by Joe Clarke about 7 years 7 months ago

It is completely legal to install the LMS TFTP server on a non-LMS server. We ship hpa-tftpd which is BSD-licensed open source code.

That said, it does look like this patch will also do the trick with Solaris' built-in in.tftpd.

  • 1
  • 2
  • 3
  • 4
  • 5
Overall Rating: 0 (3 ratings)
Loading.
Correct Answer
Joe Clarke Wed, 04/22/2009 - 10:32

It is completely legal to install the LMS TFTP server on a non-LMS server. We ship hpa-tftpd which is BSD-licensed open source code.

That said, it does look like this patch will also do the trick with Solaris' built-in in.tftpd.

yjdabear Wed, 04/22/2009 - 13:09

Awesome news (to me). Could you point to a link of the BSD-style license for the LMS tftpd? What other advantages does it have over Sun's tftpd?

yjdabear Wed, 04/22/2009 - 15:51

Could it be installed off the LMS media though?

Just for kicks, I tried to build v5.0 on OS X (gcc 4.0.1 or 4.2.1). The "make" fails if IPv6 support is enabled:

tftpd.c: In function 'pmtu_discovery_off':

tftpd.c:194: warning: unused parameter 'fd'

gcc -g -O2 -W -Wall -Wpointer-arith -Wbad-function-cast -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wnested-externs -Winline -Wwrite-strings -Wundef -Wshadow -Wsign-compare -pipe -fno-strict-aliasing -I/Users/myusername/tftp-hpa-5.0 -c recvfrom.c

recvfrom.c: In function 'myrecvfrom':

recvfrom.c:218: error: 'IPV6_RECVPKTINFO' undeclared (first use in this function)

recvfrom.c:218: error: (Each undeclared identifier is reported only once

recvfrom.c:218: error: for each function it appears in.)

make[1]: *** [recvfrom.o] Error 1

make: *** [tftpd.build] Error 2

Correct Answer
Joe Clarke Wed, 04/22/2009 - 16:28

This is a bug. You need the attached patch to build on BSD-based operating systems like OS X.

Yes, you can install the tftpd from Solaris media, but it will only work on UltraSPARC Solaris.

Attachment: 
yjdabear Wed, 04/22/2009 - 17:57

Thanks for the patch. That got it built. However, in.tftpd keeps crashing with 10 counts of "cannot bind to local IPv4 socket: Address already in use" whether I try put a file via IPv6 or IPv4. It was listening on both fine, prior to the put. I'm using the "system daemon" launchd plist adapted directly from Apple's own.

Never mind, it's resolved by taking out the -l option.

Interestingly, /tftpboot (/private/tftpboot) is not even group- and world-writable.

yjdabear Thu, 03/01/2012 - 22:47

Update: In order to compile tftp-hpa (up to 5.2.0) on Mac OS X 10.7.3 (Lion) with IPv6, ./tftpd/recvfrom.c needs a little extra header definition. Below is the updated patch (generated with "diff -rupN tftpd/recvfrom.c.orig tftpd/recvfrom.c > tftpd/recvfrom.c.diff", and apply through "patch -p0 < tftpd/recvfrom.c.diff" from the root of tftp-hpa source code directory).

--- tftpd/recvfrom.c.orig    2011-12-11 14:13:52.000000000 -0800

+++ tftpd/recvfrom.c    2012-03-01 22:58:36.000000000 -0800

@@ -17,6 +17,12 @@

  *

  */

+#if defined(__APPLE__)

+#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1070

+#define __APPLE_USE_RFC_3542 1

+#endif

+#endif

+

#include "config.h"             /* Must be included first! */

#include "common/tftpsubs.h"

#include "recvfrom.h"

@@ -222,7 +228,11 @@ myrecvfrom(int s, void *buf, int len, un

#ifdef HAVE_STRUCT_IN6_PKTINFO

                 if (cmptr->cmsg_level == IPPROTO_IPV6 &&

+#ifdef IPV6_RECVPKTINFO

                     (cmptr->cmsg_type == IPV6_RECVPKTINFO ||

+#else

+             (

+#endif

                      cmptr->cmsg_type == IPV6_PKTINFO)) {

                     memcpy(&pktinfo6, CMSG_DATA(cmptr),

                            sizeof(struct in6_pktinfo));


Then simply

# ./configure --with-ipv6

# make

# sudo make install

To test

# chmod 777 /path/to/tftpboot

# sudo /usr/local/sbin/in.tftpd -L -c -s /path/to/tftpboot

# nettop -n

in.tftpd.66083                                                                             0           0 B

    udp6 *.69<->*.*                                                                        0           0 B

    udp4 *:69<->*:*                                                                        0           0 B

OR stick it in a launchd plist, but make sure it doesn't daemonize by leaving out the "-L" flag.

<?xml version="1.0" encoding="UTF-8"?>

http://www.apple.com/DTDs/PropertyList-1.0.dtd">

    InitGroups

   

    Label

    org.kernel.tftpd

    ProgramArguments

   

        /usr/local/sbin/in.tftpd

        -c

        -s

        /private/tftpboot

   

    Sockets

   

        Listeners

       

            SockServiceName

            tftp

            SockType

            dgram

       

   

    inetdCompatibility

   

        Wait

       

   

Actions

This Discussion