Hello,
I was asked to resend the patches, here they are.
With kind regards,
Baurjan.
--
CT SE 2
Siemens AG, Mch P
nodetach:
diff -NaurPX ./dontdiff.ibr tftp-hpa-0.35.orig/tftpd/tftpd.8.in
tftp-hpa-0.35/tftpd/tftpd.8.in
--- tftp-hpa-0.35.orig/tftpd/tftpd.8.in 2003-08-23 02:33:15.000000000 +0200
+++ tftp-hpa-0.35/tftpd/tftpd.8.in 2004-01-12 17:19:54.000000000 +0100
@@ -162,6 +162,10 @@
.B \-V
Print the version number and configuration to standard output, then
exit gracefully.
+.TP
+.B \-n
+Do not detach the daemon. This option is necessary to run as Windows
+service, but can be also used for debugging purposes.
.SH "RFC 2347 OPTION NEGOTIATION"
This version of
.B tftpd
diff -NaurPX ./dontdiff.ibr tftp-hpa-0.35.orig/tftpd/tftpd.c
tftp-hpa-0.35/tftpd/tftpd.c
--- tftp-hpa-0.35.orig/tftpd/tftpd.c 2004-01-08 21:48:30.000000000 +0100
+++ tftp-hpa-0.35/tftpd/tftpd.c 2004-01-12 17:34:40.000000000 +0100
@@ -107,6 +107,7 @@
int secure = 0;
int cancreate = 0;
int unixperms = 0;
+int daemonize = 1;
int verbosity = 0;
@@ -162,7 +163,7 @@
static void
usage(void)
{
- syslog(LOG_ERR, "Usage: %s [-vcl][-a address][-m mappings][-u user][-t
inetd_timeout][-T pkt_timeout][-r option...] [-s] [directory ...]",
+ syslog(LOG_ERR, "Usage: %s [-vcl][-a address][-m mappings][-n][-u
user][-t inetd_timeout][-T pkt_timeout][-r option...] [-s] [directory
...]",
__progname);
exit(EX_USAGE);
}
@@ -281,7 +282,7 @@
openlog(__progname, LOG_PID|LOG_NDELAY, LOG_DAEMON);
- while ((c = getopt(argc, argv, "cspvVla:B:u:U:r:t:T:m:")) != -1)
+ while ((c = getopt(argc, argv, "cspvVnla:B:u:U:r:t:T:m:")) != -1)
switch (c) {
case 'c':
cancreate = 1;
@@ -364,6 +365,9 @@
printf("%s\n", TFTPD_CONFIG_STR);
exit(0);
break;
+ case 'n':
+ daemonize = 0;
+ break;
default:
usage();
break;
@@ -463,14 +467,18 @@
/* Daemonize this process */
{
- pid_t f = fork();
int nfd;
- if ( f > 0 )
- exit(0);
- if ( f < 0 ) {
- syslog(LOG_ERR, "cannot fork: %m");
- exit(EX_OSERR);
+
+ if (daemonize) {
+ pid_t f = fork();
+ if ( f > 0 )
+ exit(0);
+ if ( f < 0 ) {
+ syslog(LOG_ERR, "cannot fork: %m");
+ exit(EX_OSERR);
+ }
}
+
nfd = open("/dev/null", O_RDWR);
if ( nfd >= 3 ) {
#ifdef HAVE_DUP2
nodrop:
diff -NaurPX ./dontdiff.ibr tftp-hpa-0.35-nodetach/tftpd/tftpd.c
tftp-hpa-0.35/tftpd/tftpd.c
--- tftp-hpa-0.35-nodetach/tftpd/tftpd.c 2004-01-12 17:34:40.000000000 +0100
+++ tftp-hpa-0.35/tftpd/tftpd.c 2004-01-13 11:28:32.000000000 +0100
@@ -254,7 +254,6 @@
main(int argc, char **argv)
{
struct tftphdr *tp;
- struct passwd *pw;
struct options *opt;
struct sockaddr_in myaddr;
struct sockaddr_in bindaddr;
@@ -266,14 +265,17 @@
mode_t my_umask = 0;
int spec_umask = 0;
int c;
- int setrv;
int waittime = 900; /* Default time to wait for a connect*/
- const char *user = "nobody"; /* Default user */
char *p, *ep;
#ifdef WITH_REGEX
char *rewrite_file = NULL;
#endif
u_short tp_opcode;
+#ifndef __CYGWIN__
+ struct passwd *pw;
+ int setrv;
+ const char *user = "nobody"; /* Default user */
+#endif /* __CYGWIN__ */
/* basename() is way too much of a pain from a portability standpoint */
@@ -326,7 +328,11 @@
}
break;
case 'u':
+#ifndef __CYGWIN__
user = optarg;
+#else
+ syslog(LOG_WARNING, "\"-u\" option has no effect in the
Cygwin port.");
+#endif /* __CYGWIN__ */
break;
case 'U':
my_umask = strtoul(optarg, &ep, 8);
@@ -394,11 +400,13 @@
}
}
+#ifndef __CYGWIN__
pw = getpwnam(user);
if (!pw) {
syslog(LOG_ERR, "no user %s: %m", user);
exit(EX_NOUSER);
}
+#endif /* __CYGWIN__ */
if ( spec_umask || !unixperms )
umask(my_umask);
@@ -636,6 +644,7 @@
exit(EX_IOERR);
}
+#ifndef __CYGWIN__
/* Set up the supplementary group access list if possible */
/* /etc/group still need to be accessible at this point */
#ifdef HAVE_INITGROUPS
@@ -651,6 +660,7 @@
}
#endif
#endif
+#endif /* __CYGWIN__ */
/* Chroot and drop privileges */
if (secure) {
@@ -663,6 +673,7 @@
#endif
}
+#ifndef __CYGWIN__
#ifdef HAVE_SETREGID
setrv = setregid(pw->pw_gid, pw->pw_gid);
#else
@@ -681,6 +692,7 @@
syslog(LOG_ERR, "cannot drop privileges: %m");
exit(EX_OSERR);
}
+#endif /* __CYGWIN__ */
/* Other basic setup */
from.sin_family = AF_INET;
man:
diff -NaurPX ./dontdiff.ibr tftp-hpa-0.34-nodetach/tftpd/tftpd.8.in
tftp-hpa-0.34/tftpd/tftpd.8.in
--- tftp-hpa-0.34-nodetach/tftpd/tftpd.8.in 2003-12-10 11:22:32.000000000 +0100
+++ tftp-hpa-0.34/tftpd/tftpd.8.in 2003-12-10 14:05:21.000000000 +0100
@@ -38,7 +38,7 @@
.SH SYNOPSIS
.B in.tftpd
.RI [ options... ]
-.I directory...
+.RI [ directory... ]
.SH DESCRIPTION
.B tftpd
is a server for the IPv4 Trivial File Transfer Protocol. The TFTP