@@ -846,10 +846,11 @@ fprintf(output, " -d, --daemon\n"); fprintf(output, " -b
, --bind
\n"); fprintf(output, " -p , --port \n"); fprintf(output, " -t , --threads \n"); fprintf(output, " -c , --cache \n"); + fprintf(output, " -l , --log \n"); fprintf(output, " -u , --user \n"); fprintf(output, " -r , --root \n"); if (long_help) { fprintf(output, "\n"); @@ -876,10 +877,18 @@ fprintf(output, " well as an open file descriptor to the file, so resource\n"); fprintf(output, " limits (i.e., ulimit) should be considered. This should\n"); fprintf(output, " be a prime number for ideal use with the lookup method.\n"); fprintf(output, " The default is %lu.\n", (unsigned long) CACHE_SIZE); fprintf(output, "\n"); + fprintf(output, " -l (or --log) specifies a filename to open for writing log entries. Log\n"); + fprintf(output, " entries are made for various stages in transfering files.\n"); + fprintf(output, " The log file is opened before switching users (see \"-u\")\n"); + fprintf(output, " and root directories (see \"-r\"). The log file is never\n"); + fprintf(output, " closed so log rotation without stopping the daemon is will\n"); + fprintf(output, " not work. The value of \"-\" indicates that standard output\n"); + fprintf(output, " should be used for logging. The default is \"%s\".\n", LOG_FILE); + fprintf(output, "\n"); fprintf(output, " -u (or --user) specifies the user to switch user IDs to before servicing\n"); fprintf(output, " requests. The default is not change user IDs.\n"); fprintf(output, "\n"); fprintf(output, " -r (or --root) specifies the directory to act as the root directory for\n"); fprintf(output, " the file server. If this option is specified, chroot(2)\n"); @@ -993,11 +1002,11 @@ return(0); } /* Run process */ int main(int argc, char **argv) { - struct option options[9]; + struct option options[10]; const char *bind_addr = BIND_ADDR, *newroot = NULL, *log_file = LOG_FILE; uid_t user = 0; int port = PORT, thread_count = THREAD_COUNT; int cache_size = CACHE_SIZE; int init_ret, chroot_ret, setuid_ret, lookup_ret, chdir_ret; @@ -1012,12 +1021,13 @@ filed_getopt_long_setopt(&options[3], "bind", required_argument, 'b'); filed_getopt_long_setopt(&options[4], "user", required_argument, 'u'); filed_getopt_long_setopt(&options[5], "root", required_argument, 'r'); filed_getopt_long_setopt(&options[6], "help", no_argument, 'h'); filed_getopt_long_setopt(&options[7], "daemon", no_argument, 'd'); - filed_getopt_long_setopt(&options[8], NULL, 0, 0); - while ((ch = getopt_long(argc, argv, "p:t:c:b:u:r:hd", options, NULL)) != -1) { + filed_getopt_long_setopt(&options[8], "log", required_argument, 'l'); + filed_getopt_long_setopt(&options[9], NULL, 0, 0); + while ((ch = getopt_long(argc, argv, "p:t:c:b:u:r:l:hd", options, NULL)) != -1) { switch(ch) { case 'p': port = atoi(optarg); break; case 't': @@ -1039,10 +1049,13 @@ } break; case 'r': newroot = strdup(optarg); break; + case 'l': + log_file = strdup(optarg); + break; case 'd': daemon_enabled = 1; break; case '?': case ':':