-c      Allow new files to be created; otherwise uploaded files must
             already exist.  Files are created with default permissions
             allowing anyone to read or write to them.

Works for me in diskless(8) usage and manual tftp(1) get/put testing
with existing and new files.

Feedback? OK?

Index: tftpd.c
===================================================================
RCS file: /cvs/src/usr.sbin/tftpd/tftpd.c,v
retrieving revision 1.47
diff -u -p -r1.47 tftpd.c
--- tftpd.c     24 Oct 2021 21:24:19 -0000      1.47
+++ tftpd.c     1 Oct 2022 16:40:56 -0000
@@ -391,8 +391,13 @@ main(int argc, char *argv[])
        if (!debug && rdaemon(devnull) == -1)
                err(1, "unable to daemonize");
 
-       if (pledge("stdio rpath wpath cpath fattr dns inet", NULL) == -1)
-               lerr(1, "pledge");
+       if (cancreate) {
+               if (pledge("stdio rpath wpath cpath fattr dns inet", NULL) == 
-1)
+                       lerr(1, "pledge");
+       } else {
+               if (pledge("stdio rpath wpath fattr dns inet", NULL) == -1)
+                       lerr(1, "pledge");
+       }
 
        event_init();
 

Reply via email to