--- proftpd-1.3.8c/src/pidfile.c.~1~ 2024-12-11 13:17:36.000000000 -0500 +++ proftpd-1.3.8c/src/pidfile.c 2025-01-06 01:04:36.506679884 -0500 @@ -49,6 +49,29 @@ return 0; } +// illumos does not have dprintf. Use code from https://stackoverflow.com/questions/4246588/fprintf-like-function-for-file-descriptors-i-e-int-fd-instead-of-file-fp and hack dprintf into this routine. +#ifdef __illumos__ +int +fdprintf ( int d_fd, size_t d_bufmax, const char * d_fmt, ... ) +{ + char * d_buffer; + int d_n; + va_list d_ap; + + d_buffer = ( char * ) malloc ( d_bufmax ); + if ( !d_buffer ) + return 0; + + va_start ( d_ap, d_fmt ); + d_n = vsnprintf ( d_buffer, d_bufmax, d_fmt, d_ap ); + va_end ( d_ap ); + + write ( d_fd, d_buffer, d_n ); + free ( d_buffer ); + return d_n; +} +#endif + int pr_pidfile_write(void) { int fd, res, xerrno; mode_t mode = 0644; @@ -74,7 +97,8 @@ pidfile_path, strerror(xerrno)); } - dprintf(fd, "%lu\n", (unsigned long) getpid()); +// assume pids (plus LF plus null) will never be greater than 22 characters long. + fdprintf(fd, 22, "%lu\n", (unsigned long) getpid()); if (close(fd) < 0) { fprintf(stderr, "error writing PidFile '%s': %s\n", pidfile_path, strerror(errno));