This is a patch for tftpd. It does 2 things: 1. adds an '-u' option for tftpd With this option I can run tftpd as current user - no switch to user none. Then I don't need to create world writable dir for tftp write requests. It is useful for QEMU with the user network stack and redirected ports. I can exchange files between my host OS and Plan9 guest in QEMU with tftp client in my host OS. I start tftpd in my working dir, send/receive files, kill tftpd. Example of batch file for starting QEMU in MS-Windows: set QEMU=C:/Program Files/QEMU "%QEMU%/qemu.exe" -hda plan9.10G.qcow2 -m 256 -net nic,model=rtl8139 -net user -redir udp:69::69 -redir tcp:567::567 -redir tcp:17010::17010 -L "%QEMU%" 2. it was impossible to send file to tftpd server (write request) due to an error. I corrected it. Reference: /n/sources/patch/maybe/tftpd-error Date: Thu Sep 11 21:13:18 CES 2008 Signed-off-by: antonin.vecera@gmail.com --- /sys/src/cmd/ip/tftpd.c Thu Sep 11 21:35:24 2008 +++ /sys/src/cmd/ip/tftpd.c Thu Sep 11 21:25:26 2008 @@ -13,6 +13,7 @@ int dbg; int restricted; +int user; void sendfile(int, char*, char*); void recvfile(int, char*, char*); void nak(int, int, char*); @@ -72,6 +73,9 @@ case 's': svc = EARGF(usage()); break; + case 'u': + user = 1; + break; case 'x': p = ARGF(); if(p == nil) @@ -107,7 +111,8 @@ if (cfd < 0) sysfatal("announcing on %s: %r", buf); syslog(dbg, flog, "tftpd started on %s dir %s", buf, adir); - setuser(); + if(!user) + setuser(); for(;;) { lcfd = listen(adir, ldir); if(lcfd < 0) @@ -306,11 +311,11 @@ if(op == Tftp_ERROR) goto error; - n -= 4; inblock = buf[2]<<8|buf[3]; + n -= 4; if(op == Tftp_DATA) { if(inblock == block) { - ret = write(file, buf, n); + ret = write(file, buf+4, n); if(ret < 0) { errstr(errbuf, sizeof errbuf); nak(fd, 0, errbuf); @@ -318,8 +323,8 @@ } ack(fd, block); block++; - } - ack(fd, 0xffff); + } else + ack(fd, 0xffff); } } error: --- /sys/man/8/dhcpd Thu Sep 11 21:36:10 2008 +++ /sys/man/8/dhcpd Thu Sep 11 21:26:06 2008 @@ -28,7 +28,7 @@ .IR netmtpt ] .PP .B ip/tftpd -.RB [ -dr ] +.RB [ -dru ] .RB [ -h .IR homedir ] .RB [ -x @@ -252,6 +252,9 @@ .TP .B d Print debugging to standard output. +.TP +.B u +Don't switch to user none, run as current user. .TP .B x The IP stack to use is mounted at