Merge pull request #3661 from lazka/inetutils-2.4

inetutils: Update to 2.4
This commit is contained in:
Christoph Reiter 2023-03-16 20:53:42 +01:00 committed by GitHub
commit f38840e22b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 7401 additions and 49812 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,67 +0,0 @@
diff -Naur inetutils-1.9.2-orig/configure.ac inetutils-1.9.2/configure.ac
--- inetutils-1.9.2-orig/configure.ac 2014-12-12 11:55:10.606800000 +0300
+++ inetutils-1.9.2/configure.ac 2014-12-12 11:55:10.653600000 +0300
@@ -560,7 +560,13 @@
AC_MSG_CHECKING(hosts_ctl in -lwrap);
save_LIBS=$LIBS
LIBS="$save_LIBS -lwrap"
- AC_TRY_LINK([int allow_severity = 1; int deny_severity = 1;],
+ AC_TRY_LINK([#ifdef __CYGWIN__
+ extern int allow_severity = 1;
+ extern int deny_severity = 1;
+ #else
+ int allow_severity = 1;
+ int deny_severity = 1;
+ #endif],
hosts_ctl(), eval "ac_cv_lib_wrap_hosts_ctl=yes",
eval "ac_cv_lib_wrap_hosts_ctl=no")
LIBS=$save_LIBS
@@ -596,7 +602,7 @@
sys/proc.h sys/select.h sys/time.h sys/wait.h \
sys/resource.h \
stropts.h tcpd.h utmp.h utmpx.h unistd.h \
- vis.h osockaddr.h], [], [], [
+ vis.h osockaddr.h crypt.h], [], [], [
#include <sys/types.h>
#ifdef HAVE_STDIO_H
# include <stdio.h>
@@ -860,7 +866,11 @@
AC_DECL_SYS_SIGLIST
-AC_CHECK_DECLS(crypt, , , [#include <unistd.h>])
+AC_CHECK_DECLS(crypt, , ,
+ [IU_FLUSHLEFT([#include <unistd.h>
+ #ifdef HAVE_CRYPT_H
+ # include <crypt.h>
+ #endif])])
# EWOULDBLOCK is more or less the BSD version of posix EAGAIN.
IU_CHECK_MACRO(EWOULDBLOCK, [#include <errno.h>], , ,
@@ -887,6 +897,8 @@
iu_syslog_includes), , iu_syslog_includes),)
undefine([iu_syslog_includes])
+IU_CHECK_MACRO(TIOCNOTTY, [#include <sys/ioctl.h>],,,)
+
# Some systems don't declare common functions (especially if they
# return int), at least in the expected header file. Check.
AC_CHECK_DECLS([fclose, pclose], , , [#include <stdio.h>])
@@ -999,8 +1011,6 @@
[Define to 1 for a system using streams for ptys])
;;
*cygwin*)
- CFLAGS="${CFLAGS} -DNCURSES_STATIC"
- LDFLAGS="${LDFLAGS} -Wl,-static"
LIBS="/usr/lib/textmode.o ${LIBS}"
AC_DEFINE(UTMPX, 1, [FIXME])
;;
diff -Naur inetutils-1.9.2-orig/man/Makefile.am inetutils-1.9.2/man/Makefile.am
--- inetutils-1.9.2-orig/man/Makefile.am 2013-09-26 12:36:38.000000000 +0300
+++ inetutils-1.9.2/man/Makefile.am 2014-12-12 11:55:10.653600000 +0300
@@ -216,4 +216,4 @@
--include=$(srcdir)/$(TOOL).h2m \
--output=$(TOOL).$(SECTION) \
--section $(SECTION) \
- $(mapped_name)
+ $(mapped_name)$(EXEEXT)

View File

@ -1,192 +0,0 @@
diff -Naur inetutils-1.9.2-orig/libinetutils/daemon.c inetutils-1.9.2/libinetutils/daemon.c
--- inetutils-1.9.2-orig/libinetutils/daemon.c 2013-12-03 17:57:44.000000000 +0300
+++ inetutils-1.9.2/libinetutils/daemon.c 2014-12-12 11:55:11.043600000 +0300
@@ -51,6 +51,7 @@
#include <fcntl.h>
#include <unistd.h>
#include <signal.h>
+#include <syslog.h>
#include <error.h>
#include <stdlib.h>
#include <sys/types.h>
@@ -103,13 +104,87 @@
#define MAXFD 64
-void
+/* copy signal stuff from inetd.c -- POSIX says that the various
+ signal interfaces should not be mixed in the same program.
+ Because inetd uses 'most recent signal interface' it can find,
+ we should too.
+*/
+
+#define SIGBLOCK (sigmask(SIGCHLD)|sigmask(SIGHUP)|sigmask(SIGALRM))
+#if defined(HAVE_SIGACTION)
+# define SIGSTATUS sigset_t
+# define sigstatus_empty(s) sigemptyset(&s)
+#else
+# define SIGSTATUS long
+# define sigstatus_empty(s) s = 0
+#endif
+
+static void
+signal_set_handler (int signo, RETSIGTYPE (*handler) ())
+{
+#if defined(HAVE_SIGACTION)
+ struct sigaction sa;
+ memset ((char *)&sa, 0, sizeof(sa));
+ sigemptyset (&sa.sa_mask);
+ sigaddset (&sa.sa_mask, signo);
+#ifdef SA_RESTART
+ sa.sa_flags = SA_RESTART;
+#endif
+ sa.sa_handler = handler;
+ sigaction (signo, &sa, NULL);
+#elif defined(HAVE_SIGVEC)
+ struct sigvec sv;
+ memset (&sv, 0, sizeof(sv));
+ sv.sv_mask = SIGBLOCK;
+ sv.sv_handler = handler;
+ sigvec (signo, &sv, NULL);
+#else /* !HAVE_SIGVEC */
+ signal (signo, handler);
+#endif /* HAVE_SIGACTION */
+}
+
+static void
+signal_block (SIGSTATUS *old_status)
+{
+#ifdef HAVE_SIGACTION
+ sigset_t sigs;
+
+ sigemptyset (&sigs);
+ sigaddset (&sigs, SIGCHLD);
+ sigaddset (&sigs, SIGHUP);
+ sigaddset (&sigs, SIGALRM);
+ sigprocmask (SIG_BLOCK, &sigs, old_status);
+#else
+ long omask = sigblock (SIGBLOCK);
+ if (old_status)
+ *old_status = omask;
+#endif
+}
+
+static void
+signal_unblock (SIGSTATUS *status)
+{
+#ifdef HAVE_SIGACTION
+ if (status)
+ sigprocmask (SIG_SETMASK, status, 0);
+ else
+ {
+ sigset_t empty;
+ sigemptyset (&empty);
+ sigprocmask (SIG_SETMASK, &empty, 0);
+ }
+#else
+ sigsetmask (status ? *status : 0);
+#endif
+}
+
+RETSIGTYPE
waitdaemon_timeout (int signo _GL_UNUSED_PARAMETER)
{
int left;
left = alarm (0);
- signal (SIGALRM, SIG_DFL);
+ signal_set_handler (SIGALRM, SIG_DFL);
if (left == 0)
error (EXIT_FAILURE, 0, "timed out waiting for child");
}
@@ -138,9 +213,29 @@
default: /* In the parent. */
if (maxwait > 0)
{
- signal (SIGALRM, waitdaemon_timeout);
+ int status;
+ pid_t wpid;
+
+ signal_unblock(NULL);
+ signal_set_handler (SIGALRM, waitdaemon_timeout);
alarm (maxwait);
- pause ();
+ do
+ {
+ wpid = waitpid(childpid, &status, WUNTRACED
+#ifdef WCONTINUED /* Not all implementations support this */
+ | WCONTINUED
+#endif
+ );
+ if (wpid == -1)
+ {
+ /* should't happen for timeouts, because the
+ SIGALRM handler will error (and exit). However,
+ we may recieve some OTHER signal...
+ */
+ error (1, 0, "interrupted while waiting for child");
+ }
+ }
+ while (!WIFEXITED(status) && !WIFSIGNALED(status));
}
_exit (EXIT_SUCCESS);
}
@@ -152,7 +247,7 @@
then SIGHUP is sent to all process belonging to the same session,
i.e., also to the second child.
*/
- signal (SIGHUP, SIG_IGN);
+ signal_set_handler (SIGHUP, SIG_IGN);
switch (fork ())
{
@@ -202,5 +297,9 @@
int
daemon (int nochdir, int noclose)
{
+#ifdef __CYGWIN__
+ return (waitdaemon (nochdir, noclose, 5) == -1) ? -1 : 0;
+#else
return (waitdaemon (nochdir, noclose, 0) == -1) ? -1 : 0;
+#endif
}
diff -Naur inetutils-1.9.2-orig/libinetutils/logwtmp.c inetutils-1.9.2/libinetutils/logwtmp.c
--- inetutils-1.9.2-orig/libinetutils/logwtmp.c 2013-09-26 12:36:38.000000000 +0300
+++ inetutils-1.9.2/libinetutils/logwtmp.c 2014-12-12 11:55:11.043600000 +0300
@@ -50,6 +50,10 @@
extern int errno;
#endif
+#ifndef O_BINARY
+#define O_BINARY 0
+#endif
+
#ifdef HAVE_UTMPX_H
static void
_logwtmp (struct utmpx *ut)
@@ -62,9 +66,9 @@
static int fd = -1;
if (fd < 0)
- fd = open (OUR_WTMP, O_WRONLY | O_APPEND, 0);
+ fd = open (OUR_WTMP, O_WRONLY | O_APPEND | O_BINARY, 0);
#else
- int fd = open (OUR_WTMP, O_WRONLY | O_APPEND, 0);
+ int fd = open (OUR_WTMP, O_WRONLY | O_APPEND | O_BINARY, 0);
#endif
if (fd >= 0)
diff -Naur inetutils-1.9.2-orig/libinetutils/setsig.c inetutils-1.9.2/libinetutils/setsig.c
--- inetutils-1.9.2-orig/libinetutils/setsig.c 2013-09-26 12:36:38.000000000 +0300
+++ inetutils-1.9.2/libinetutils/setsig.c 2014-12-12 11:55:11.059200000 +0300
@@ -26,6 +26,10 @@
#include <signal.h>
+#ifdef __CYGWIN__
+typedef _sig_func_ptr sig_t;
+#endif
+
/* This is exactly like the traditional signal function, but turns on the
SA_RESTART bit where possible. */
sighandler_t

View File

@ -1,272 +0,0 @@
diff -Naur inetutils-1.9.2-orig/src/inetd.c inetutils-1.9.2/src/inetd.c
--- inetutils-1.9.2-orig/src/inetd.c 2013-12-23 14:57:54.000000000 +0300
+++ inetutils-1.9.2/src/inetd.c 2014-12-12 11:55:11.402400000 +0300
@@ -138,6 +138,13 @@
#include "version-etc.h"
#include "unused-parameter.h"
+#ifdef __CYGWIN__
+#include <windows.h>
+#include <exceptions.h>
+#include <sys/cygwin.h>
+#endif /* __CYGWIN__ */
+
+
#ifndef EAI_ADDRFAMILY
# define EAI_ADDRFAMILY 1
#endif
@@ -151,7 +158,14 @@
#endif
#define SIGBLOCK (sigmask(SIGCHLD)|sigmask(SIGHUP)|sigmask(SIGALRM))
+enum {
+ NO_DAEMON = 0,
+ UNIX_DAEMON
+};
+
bool debug = false;
+static int daemonize = UNIX_DAEMON;
+
int nsock, maxsock;
fd_set allsock;
int options;
@@ -196,6 +210,13 @@
{"resolve", OPT_RESOLVE, NULL, 0,
"resolve IP addresses when setting environment variables "
"(see --environment)", GRP+1},
+#ifdef __CYGWIN__
+ {0,0,0,0,"Cygwin-specific options:",GRP+2},
+ {"no-daemonize", 'D', NULL, 0,
+ "Do not run as a daemon", GRP+2},
+ {"traditional-daemon", 'T', NULL, 0,
+ "This option is present for backwards compatibility.", GRP+2},
+#endif /* __CYGWIN__ */
#undef GRP
{NULL, 0, NULL, 0, NULL, 0}
};
@@ -237,6 +258,16 @@
resolve_option = true;
break;
+#ifdef __CYGWIN__
+ case 'D': /* don't become a daemon */
+ daemonize = NO_DAEMON;
+ break;
+
+ case 'T': /* act like a normal unix daemon */
+ daemonize = UNIX_DAEMON;
+ break;
+#endif /* __CYGWIN__ */
+
default:
return ARGP_ERR_UNKNOWN;
}
@@ -412,6 +443,44 @@
#endif
}
+#ifdef __CYGWIN__
+void
+hide_console ()
+{
+ HMODULE lib;
+ HWND WINAPI (*GetConsoleWindow) (void) = NULL;
+ HWND console = NULL;
+
+ AllocConsole ();
+ if (lib = LoadLibrary ("kernel32.dll"))
+ GetConsoleWindow = (HWND WINAPI (*) (void))
+ GetProcAddress (lib, "GetConsoleWindow");
+
+ if (GetConsoleWindow)
+ /* If GetConsoleWindow exists (W2K and newer), use it. */
+ console = GetConsoleWindow ();
+ if (!console)
+ {
+ /* Get console window handle as described in KB article Q124103 */
+ char title[32];
+ snprintf (title, 32, "inetd.%d", getpid ());
+ SetConsoleTitle (title);
+ Sleep (40);
+ console = FindWindow (NULL, title);
+ if (console)
+ {
+ char ctitle[256];
+ if (!GetWindowText (console, ctitle, 256) || strcmp (title, ctitle))
+ console = NULL;
+ }
+ }
+ if (console)
+ ShowWindow (console, SW_HIDE);
+}
+#endif /* __CYGWIN__ */
+
+
+
void
run_service (int ctrl, struct servtab *sep)
{
@@ -431,6 +500,10 @@
close (ctrl);
dup2 (0, 1);
dup2 (0, 2);
+#ifdef __CYGWIN__
+ if (strcmp (sep->se_user, "root"))
+ {
+#endif
pwd = getpwnam (sep->se_user);
if (pwd == NULL)
{
@@ -452,14 +525,21 @@
_exit (EXIT_FAILURE);
}
}
+#ifdef __CYGWIN__
+ }
+ else
+ {
+ pwd = getpwuid (getuid ());
+ }
+#endif
if (pwd->pw_uid)
{
if (grp && grp->gr_gid)
{
if (setgid (grp->gr_gid) < 0)
{
- syslog (LOG_ERR, "%s: can't set gid %d: %m",
- sep->se_service, grp->gr_gid);
+ syslog (LOG_ERR, "%s: can't set gid %d uid(%d): %m",
+ sep->se_service, pwd->pw_gid, pwd->pw_uid);
_exit (EXIT_FAILURE);
}
}
@@ -1278,6 +1358,10 @@
}
while ((sep = getconfigent (fconfig, file, &line)))
{
+#ifdef __CYGWIN__
+ if (strcmp (sep->se_user, "root"))
+ {
+#endif
pwd = getpwnam (sep->se_user);
if (pwd == NULL)
{
@@ -1285,6 +1369,9 @@
sep->se_service, sep->se_proto, sep->se_user);
continue;
}
+#ifdef __CYGWIN__
+ }
+#endif
if (sep->se_group && *sep->se_group)
{
grp = getgrnam (sep->se_group);
@@ -1497,10 +1584,48 @@
}
else
snprintf (buf, sizeof buf, "-%s", a);
- strncpy (cp, buf, LastArg - cp);
- cp += strlen (cp);
- while (cp < LastArg)
- *cp++ = ' ';
+
+ /* the non-portable code in the #else block relies on
+ the system allocating all of the strings in argv[]
+ contiguously. On cygwin this is not necessarily so,
+ and to assume otherwise will lead to segfaults.
+ The downside here is we get supposed ps entries for
+ internal services like:
+ '-echo' instead of '-echo [remoteIP]' (okay?)
+ '-char' instead of '-chargen [remoteIP]' (awful)
+ '-disc' instead of '-discard [remoteIP]' (awful)
+ because the original argv[0] might be 'inetd' unless
+ it was specifically invoked with a full path. However,
+ this is mostly moot:
+ (1) cygwin's ps uses its own internal version of the
+ exe name (or GetModuleName) and then calls
+ cygwin_conv_xxx() for display.
+ (2) procps DOES use the modified argv[0] value
+ */
+ {
+#ifdef __CYGWIN__
+ char* LastNullChar = cp + strlen(cp);
+ char** scan;
+#else
+ char* LastNullChar = LastArg;
+#endif
+
+ strncpy (cp, buf, LastNullChar - cp);
+ cp += strlen (cp);
+ while (cp < LastNullChar)
+ *cp++ = ' ';
+
+#ifdef __CYGWIN__
+ /* individually blank out the rest of the args */
+ for (scan = Argv + 1; *scan != NULL; scan++)
+ {
+ char* nullChar = *scan + strlen(*scan);
+ cp = *scan;
+ while (cp < nullChar)
+ *cp++ = ' ';
+ }
+#endif
+ }
}
/*
@@ -1939,6 +2064,16 @@
envp++;
LastArg = envp[-1] + strlen (envp[-1]);
+#ifdef __CYGWIN__
+ /* on cygwin, open the log early -- because even
+ help and cmdline processing messages go directly
+ to syslog. This is because inetd is often run
+ under the SYSTEM account (which is not quite like
+ the *nix 'root')
+ */
+ openlog("inetd", LOG_PID | LOG_NOWAIT, LOG_DAEMON);
+#endif
+
/* Parse command line */
iu_argp_init ("inetd", program_authors);
argp_parse (&argp, argc, argv, 0, &index, NULL);
@@ -1962,7 +2097,7 @@
config_files[1] = newstr (PATH_INETDDIR);
}
- if (!debug)
+ if ((debug == 0) && daemonize)
{
if (daemon (0, 0) < 0)
{
@@ -1971,6 +2106,12 @@
exit (EXIT_FAILURE);
};
}
+#ifndef __CYGWIN__
+ exception_list except_list;
+ cygwin_internal (CW_INIT_EXCEPTIONS, &except_list);
+ hide_console ();
+#endif /* __CYGWIN__ */
+
openlog ("inetd", LOG_PID | LOG_NOWAIT, LOG_DAEMON);
@@ -1995,6 +2136,7 @@
signal_set_handler (SIGCHLD, reapchild);
signal_set_handler (SIGPIPE, SIG_IGN);
+#ifndef __CYGWIN__
{
/* space for daemons to overwrite environment for ps */
#define DUMMYSIZE 100
@@ -2004,6 +2146,7 @@
dummy[DUMMYSIZE - 1] = '\0';
setenv ("inetd_dummy", dummy, 1);
}
+#endif /* __CYGWIN__ */
for (;;)
{

View File

@ -1,31 +0,0 @@
diff -Naur inetutils-1.9.2-orig/telnet/telnet.c inetutils-1.9.2/telnet/telnet.c
--- inetutils-1.9.2-orig/telnet/telnet.c 2013-09-26 12:36:38.000000000 +0300
+++ inetutils-1.9.2/telnet/telnet.c 2014-12-12 11:55:11.761200000 +0300
@@ -51,7 +51,7 @@
#include <sys/types.h>
-#if defined unix || defined __unix || defined __unix__
+#if defined unix || defined __unix || defined __unix__ || defined __CYGWIN__
# include <signal.h>
/* By the way, we need to include curses.h before telnet.h since,
* among other things, telnet.h #defines 'DO', which is a variable
@@ -756,7 +756,8 @@
* mklist will examine this buffer, so erase it
* to cover corner cases.
*/
-char termbuf[2048] = { 0 };
+#define TERMBUF_SZ 2048
+char termbuf[TERMBUF_SZ] = { 0 };
static int
init_term (char *tname, int *errp)
@@ -2371,7 +2372,7 @@
netex = !SYNCHing;
/* If we have seen a signal recently, reset things */
-#if defined TN3270 && (defined unix || defined __unix || defined __unix__)
+#if defined TN3270 && (defined unix || defined __unix || defined __unix__ || defined __CYGWIN__)
if (HaveInput)
{
HaveInput = 0;

View File

@ -1,122 +0,0 @@
diff -Naur inetutils-1.9.2-orig/ftp/cmds.c inetutils-1.9.2/ftp/cmds.c
--- inetutils-1.9.2-orig/ftp/cmds.c 2013-12-03 17:57:43.000000000 +0300
+++ inetutils-1.9.2/ftp/cmds.c 2014-12-12 11:55:12.135600000 +0300
@@ -102,6 +102,10 @@
# endif
#endif /* !DEFPORT */
+#ifdef __CYGWIN__
+typedef _sig_func_ptr sig_t;
+#endif
+
/* Returns true if STR is entirely lower case. */
static int
all_lower (char *str)
@@ -297,6 +301,13 @@
if (autologin)
login (host);
+#ifdef __CYGWIN__
+# ifndef unix
+# define unix
+# endif
+# define NBBY 8
+#endif /* __CYGWIN__ */
+
#if (defined unix || defined __unix || defined __unix__) && NBBY == 8
/*
* this ifdef is to keep someone form "porting" this to an incompatible
@@ -1852,7 +1863,7 @@
len += strlen (strcpy (&buf[len], argv[i]));
}
}
- if (command (buf) == PRELIM)
+ if (command ("%s", buf) == PRELIM)
{
while (getreply (0) == PRELIM)
continue;
diff -Naur inetutils-1.9.2-orig/ftp/ftp.c inetutils-1.9.2/ftp/ftp.c
--- inetutils-1.9.2-orig/ftp/ftp.c 2013-12-23 14:57:54.000000000 +0300
+++ inetutils-1.9.2/ftp/ftp.c 2014-12-12 11:55:12.135600000 +0300
@@ -90,6 +90,11 @@
#include "ftp_var.h"
#include "unused-parameter.h"
+#ifdef __CYGWIN__
+#include <io.h>
+typedef _sig_func_ptr sig_t;
+#endif
+
#if !HAVE_DECL_FCLOSE
/* Some systems don't declare fclose in <stdio.h>, so do it ourselves. */
extern int fclose (FILE *);
@@ -100,7 +105,9 @@
extern int pclose (FILE *);
#endif
+#ifndef __CYGWIN__
extern int h_errno;
+#endif
int data = -1;
int abrtflag = 0;
@@ -641,7 +648,15 @@
}
else
{
+#ifdef __CYGWIN__
+ if (curtype != TYPE_A) {
+ fin = fopen (local, "rb");
+ } else {
+ fin = fopen (local, "r");
+ }
+#else
fin = fopen (local, "r");
+#endif
if (fin == NULL)
{
error (0, errno, "local: %s", local);
@@ -685,6 +700,7 @@
break;
case TYPE_I:
case TYPE_L:
+ setmode (fileno (fin), O_BINARY);
rc = lseek (fileno (fin), restart_point, SEEK_SET);
break;
}
@@ -753,6 +769,8 @@
case TYPE_I:
case TYPE_L:
+ setmode (fileno (fin), O_BINARY);
+ setmode (fileno (dout), O_BINARY);
errno = d = 0;
while ((c = read (fileno (fin), buf, bufsize)) > 0)
{
@@ -987,7 +1005,17 @@
{
struct stat st;
+#ifdef __CYGWIN__
+ {
+ char nmode[8];
+ strcpy (nmode, lmode);
+ if (curtype != TYPE_A)
+ strcat (nmode, "b");
+ fout = fopen (local, nmode);
+ }
+#else
fout = fopen (local, lmode);
+#endif
if (fout == NULL || fstat (fileno (fout), &st) < 0)
{
error (0, errno, "local: %s", local);
@@ -1016,6 +1044,8 @@
case TYPE_I:
case TYPE_L:
+ setmode (fileno (fout), O_BINARY);
+ setmode (fileno (din), O_BINARY);
if (restart_point && lseek (fileno (fout), restart_point, SEEK_SET) < 0)
{
error (0, errno, "local: %s", local);

View File

@ -1,311 +0,0 @@
diff -Naur inetutils-1.9.2-orig/ftpd/auth.c inetutils-1.9.2/ftpd/auth.c
--- inetutils-1.9.2-orig/ftpd/auth.c 2013-09-26 12:36:38.000000000 +0300
+++ inetutils-1.9.2/ftpd/auth.c 2014-12-12 11:55:12.478800000 +0300
@@ -19,6 +19,17 @@
#include <config.h>
+#ifdef __CYGWIN__
+# undef ERROR
+# include <windows.h>
+# include <pwd.h>
+# include <sys/cygwin.h>
+# include <io.h>
+# define is_winnt (GetVersion() < 0x80000000)
+#else
+# define is_winnt (0)
+#endif
+
#include <sys/types.h>
#include <stdlib.h>
#include <string.h>
@@ -44,6 +55,9 @@
shell as returned by getusershell(). Disallow anyone mentioned in the file
PATH_FTPUSERS to allow people such as root and uucp to be avoided. */
+static int
+do_cygwin_auth (const char* passwd, struct credentials *pcred);
+
int
auth_user (const char *name, struct credentials *pcred)
{
@@ -84,6 +98,12 @@
if (pcred->message == NULL)
return -1;
+#ifdef __CYGWIN__
+ /* when running under WinNT, password is always required. */
+ if (!is_winnt)
+ {
+#endif /* __CYGWIN__ */
+
/* Check for anonymous log in.
*
* This code simulates part of `pam_ftp.so'
@@ -113,6 +133,9 @@
}
return err;
}
+#ifdef __CYGWIN__
+ }
+#endif /* __CYGWIN__ */
if (sgetcred (name, pcred) == 0)
{
@@ -184,18 +207,49 @@
case AUTH_TYPE_PASSWD:
default:
{
+#ifdef __CYGWIN__
+ if (!is_winnt)
+ {
+#endif /* __CYGWIN__ */
char *xpasswd;
char *salt = pcred->passwd;
/* Try to authenticate the user. */
if (pcred->passwd == NULL || *pcred->passwd == '\0')
return 1; /* Failed. */
- xpasswd = crypt (passwd, salt);
+ xpasswd = (char*) crypt (passwd, salt);
return (!xpasswd || strcmp (xpasswd, pcred->passwd) != 0);
+#ifdef __CYGWIN__
+ } else {
+ return do_cygwin_auth (passwd, pcred);
+ }
+#endif /* __CYGWIN__ */
}
} /* switch (auth_type) */
return -1;
}
+#ifdef __CYGWIN__
+static int
+do_cygwin_auth (const char* passwd, struct credentials *pcred)
+{
+ struct passwd *p;
+ if ((pcred == NULL) || (pcred->name == NULL) || (pcred->name[0] == '\0'))
+ return 1;
+
+ /* can't "recreate" p from contents of pcred, because
+ struct passwd might contain extension elements
+ unknown to us
+ */
+ p = getpwnam (pcred->name);
+ if (p == NULL)
+ return 1;
+
+ HANDLE hToken = (HANDLE) cygwin_logon_user (p, passwd);
+ cygwin_set_impersonation_token (hToken);
+ return (hToken == INVALID_HANDLE_VALUE); // non-zero on error
+}
+#endif /* __CYGWIN__ */
+
int
sgetcred (const char *name, struct credentials *pcred)
{
diff -Naur inetutils-1.9.2-orig/ftpd/ftpcmd.y inetutils-1.9.2/ftpd/ftpcmd.y
--- inetutils-1.9.2-orig/ftpd/ftpcmd.y 2013-12-23 14:57:54.000000000 +0300
+++ inetutils-1.9.2/ftpd/ftpcmd.y 2014-12-12 11:55:12.478800000 +0300
@@ -592,7 +592,7 @@
# endif /* BSD */
#endif /* !HAVE_UNAME */
-#if defined unix || defined __unix || defined __unix__
+#if defined unix || defined __unix || defined __unix__ || defined __CYGWIN__
sys_type = "UNIX";
#else
sys_type = "UNKNOWN";
diff -Naur inetutils-1.9.2-orig/ftpd/ftpd.c inetutils-1.9.2/ftpd/ftpd.c
--- inetutils-1.9.2-orig/ftpd/ftpd.c 2013-12-23 14:57:54.000000000 +0300
+++ inetutils-1.9.2/ftpd/ftpd.c 2014-12-12 11:55:12.478800000 +0300
@@ -113,6 +113,10 @@
# define LOG_FTP LOG_DAEMON /* Use generic facility. */
#endif
+#ifndef LARGE_TRANSFER_BLOCKSIZE
+# define LARGE_TRANSFER_BLOCKSIZE 4096
+#endif
+
#ifndef MAP_FAILED
# define MAP_FAILED (void*)-1
#endif
@@ -445,11 +449,21 @@
NULL
};
+#if defined(WITH_WRAP) && defined(__CYGWIN__)
+extern int allow_severity; /* set value in main() */
+extern int deny_severity; /* set value in main() */
+#endif
+
int
main (int argc, char *argv[], char **envp)
{
int index;
+#if defined(WITH_WRAP) && defined(__CYGWIN__)
+ allow_severity = LOG_INFO;
+ deny_severity = LOG_NOTICE;
+#endif
+
set_program_name (argv[0]);
#ifdef HAVE_TZSET
@@ -560,7 +574,7 @@
}
#endif
-#ifdef F_SETOWN
+#if defined(F_SETOWN) && !defined(__CYGWIN__)
if (fcntl (STDIN_FILENO, F_SETOWN, getpid ()) == -1)
syslog (LOG_ERR, "fcntl F_SETOWN: %m");
#endif
@@ -684,19 +698,29 @@
/* We MUST do a chdir () after the chroot. Otherwise
the old current directory will be accessible as "."
outside the new root! */
- if (chroot (pcred->rootdir) < 0 || chdir (pcred->homedir) < 0)
+ if (chroot (pcred->rootdir) < 0)
{
reply (550, "Can't set guest privileges.");
goto bad;
}
+ if (chdir (pcred->homedir) < 0)
+ {
+ reply(550, "Can't access home directory.");
+ goto bad;
+ }
}
else if (pcred->dochroot)
{
- if (chroot (pcred->rootdir) < 0 || chdir (pcred->homedir) < 0)
+ if (chroot (pcred->rootdir) < 0)
{
reply (550, "Can't change root.");
goto bad;
}
+ if (chdir (pcred->homedir) < 0)
+ {
+ reply(550, "Can't access home directory.");
+ goto bad;
+ }
}
if (seteuid ((uid_t) pcred->uid) < 0)
@@ -862,7 +886,7 @@
char *remotehost = pcred->remotehost;
int atype = pcred->auth_type;
- seteuid ((uid_t) 0);
+ seteuid (getuid ());
if (pcred->logged_in)
{
logwtmp_keep_open (ttyline, "", "");
@@ -972,7 +996,13 @@
if (cmd == 0)
{
+#ifdef __CYGWIN__
+ if (type != TYPE_A)
+ fin = fopen (name, "rb"), closefunc = fclose;
+ else
+#else
fin = fopen (name, "r"), closefunc = fclose;
+#endif /* __CYGWIN__ */
st.st_size = 0;
}
else
@@ -1059,6 +1089,13 @@
FILE *fout, *din;
struct stat st;
int (*closefunc) (FILE *);
+ char nmode[8];
+
+ strcpy (nmode, mode);
+#ifdef __CYGWIN__
+ if (type != TYPE_A)
+ strcat (nmode, "b");
+#endif
if (unique && stat (name, &st) == 0)
{
@@ -1074,8 +1111,16 @@
}
if (restart_point)
- mode = "r+";
- fout = fopen (name, mode);
+ {
+#ifdef __CYGWIN__
+ if (type != TYPE_A)
+ mode = "rb+";
+ else
+#endif
+ mode = "r+";
+ strcpy (nmode, mode);
+ }
+ fout = fopen (name, nmode);
closefunc = fclose;
if (fout == NULL || fstat (fileno (fout), &st) < 0)
{
@@ -1151,7 +1196,7 @@
if (data >= 0)
return fdopen (data, mode);
- seteuid ((uid_t) 0);
+ seteuid (getuid ());
s = socket (ctrl_addr.ss_family, SOCK_STREAM, 0);
if (s < 0)
goto bad;
@@ -1414,7 +1459,14 @@
len = filesize;
do
{
+#ifdef __CYGWIN__
+ cnt = write (netfd, bp,
+ (len < LARGE_TRANSFER_BLOCKSIZE ?
+ len : LARGE_TRANSFER_BLOCKSIZE));
+#else
cnt = write (netfd, bp, len);
+#endif /* __CYGWIN__ */
+
len -= cnt;
bp += cnt;
if (cnt > 0)
@@ -1439,6 +1491,9 @@
syslog (LOG_DEBUG, "Starting at position %jd.", curpos);
}
+ if (blksize <= 0)
+ blksize = LARGE_TRANSFER_BLOCKSIZE;
+
buf = malloc ((u_int) blksize);
if (buf == NULL)
{
@@ -1978,7 +2033,7 @@
else /* !AF_INET6 */
((struct sockaddr_in *) &pasv_addr)->sin_port = 0;
- seteuid ((uid_t) 0);
+ seteuid (getuid ());
if (bind (pdata, (struct sockaddr *) &pasv_addr, pasv_addrlen) < 0)
{
if (seteuid ((uid_t) cred.uid))
diff -Naur inetutils-1.9.2-orig/ftpd/server_mode.c inetutils-1.9.2/ftpd/server_mode.c
--- inetutils-1.9.2-orig/ftpd/server_mode.c 2013-09-26 12:36:38.000000000 +0300
+++ inetutils-1.9.2/ftpd/server_mode.c 2014-12-12 11:55:12.478800000 +0300
@@ -58,8 +58,14 @@
extern int hosts_ctl (char *, char *, char *, char *);
# endif
+#ifdef __CYGWIN__
+/* provided by library (e.g. extern, here) on cygwin */
+extern int allow_severity; /* set value in main() */
+extern int deny_severity; /* set value in main() */
+#else
int allow_severity = LOG_INFO;
int deny_severity = LOG_NOTICE;
+#endif
static int
check_host (struct sockaddr *sa, socklen_t len)

View File

@ -1,49 +0,0 @@
diff -durNp inetutils-1.9.4.orig/man/syslogd.8 inetutils-1.9.4/man/syslogd.8
--- inetutils-1.9.4.orig/man/syslogd.8 2015-05-12 20:17:12.000000000 +0800
+++ inetutils-1.9.4/man/syslogd.8 2017-05-14 21:25:31.093750000 +0800
@@ -30,6 +30,14 @@ print debug information (implies \fB\-\-
override configuration directory (default:
\fI\,/usr/local/etc/syslog.d\/\fP)
.TP
+\fB\-D\fR, \fB\-\-no\-daemonize\fR
+This is a synonym for \fB\-\-no\-detach\fR, and is provided for
+backwards compatibility with previous Cygwin ports. This flag
+(or its synonym) is necessary when installing syslogd as service
+started from cygrunsrv. The usual way to +install syslogd as
+service is to run the syslogd-config script. See
+/usr/share/doc/Cygwin/inetutils.README for more information.
+.TP
\fB\-f\fR, \fB\-\-rcfile\fR=\fI\,FILE\/\fR
override configuration file (default:
\fI\,/usr/local/etc/syslog.conf\/\fP)
diff -durNp inetutils-1.9.4.orig/src/syslogd.c inetutils-1.9.4/src/syslogd.c
--- inetutils-1.9.4.orig/src/syslogd.c 2015-05-12 20:13:25.000000000 +0800
+++ inetutils-1.9.4/src/syslogd.c 2017-05-14 21:27:45.562500000 +0800
@@ -348,6 +348,7 @@ static struct argp_option argp_options[]
{"mark", 'm', "INTVL", 0, "specify timestamp interval in minutes"
" (0 for no timestamping)", GRP+1},
{"no-detach", 'n', NULL, 0, "do not enter daemon mode", GRP+1},
+ {"no-daemonize", 'D', NULL, 0, "Synonym for -n", GRP+1},
{"no-forward", OPT_NO_FORWARD, NULL, 0, "do not forward any messages "
"(overrides --hop)", GRP+1},
#ifdef PATH_KLOG
@@ -432,6 +433,7 @@ parse_opt (int key, char *arg, struct ar
break;
case 'n':
+ case 'D':
NoDetach = 1;
break;
@@ -1108,7 +1110,11 @@ printsys (const char *msg)
char *lp, *q, line[MAXLINE + 1];
const char *p;
+#ifdef __CYGWIN__
+ strcpy (line, "kernel: ");
+#else
strcpy (line, "vmunix: ");
+#endif
lp = line + strlen (line);
for (p = msg; *p != '\0';)
{

View File

@ -1,131 +0,0 @@
diff -Naur inetutils-1.9.2-orig/talk/ctl.c inetutils-1.9.2/talk/ctl.c
--- inetutils-1.9.2-orig/talk/ctl.c 2013-09-26 12:36:38.000000000 +0300
+++ inetutils-1.9.2/talk/ctl.c 2014-12-12 11:55:13.492800000 +0300
@@ -57,6 +57,13 @@
#include <sys/types.h>
#include <sys/socket.h>
+#ifdef HAVE_OSOCKADDR_H
+# include <osockaddr.h>
+#else
+# ifndef HAVE_STRUCT_OSOCKADDR
+# include <protocols/osockaddr.h>
+# endif
+#endif
#include <protocols/talkd.h>
#include <netinet/in.h>
#include "talk.h"
diff -Naur inetutils-1.9.2-orig/talk/ctl_transact.c inetutils-1.9.2/talk/ctl_transact.c
--- inetutils-1.9.2-orig/talk/ctl_transact.c 2013-09-26 12:36:38.000000000 +0300
+++ inetutils-1.9.2/talk/ctl_transact.c 2014-12-12 11:55:13.492800000 +0300
@@ -55,6 +55,13 @@
#include <time.h>
#include <netinet/in.h>
#include <sys/select.h>
+#ifdef HAVE_OSOCKADDR_H
+# include <osockaddr.h>
+#else
+# ifndef HAVE_STRUCT_OSOCKADDR
+# include <protocols/osockaddr.h>
+# endif
+#endif
#include <protocols/talkd.h>
#include <errno.h>
#include "talk_ctl.h"
diff -Naur inetutils-1.9.2-orig/talk/display.c inetutils-1.9.2/talk/display.c
--- inetutils-1.9.2-orig/talk/display.c 2013-09-26 12:36:38.000000000 +0300
+++ inetutils-1.9.2/talk/display.c 2014-12-12 11:55:13.492800000 +0300
@@ -125,7 +125,11 @@
for (i = 0; i < size; i++)
{
+#ifdef __CYGWIN__
+ if ((*text == '\n') || (*text == '\r'))
+#else
if (*text == '\n')
+#endif
{
xscroll (win, 0);
text++;
diff -Naur inetutils-1.9.2-orig/talk/get_addrs.c inetutils-1.9.2/talk/get_addrs.c
--- inetutils-1.9.2-orig/talk/get_addrs.c 2013-09-26 12:36:38.000000000 +0300
+++ inetutils-1.9.2/talk/get_addrs.c 2014-12-12 11:55:13.492800000 +0300
@@ -55,6 +55,13 @@
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
+#ifdef HAVE_OSOCKADDR_H
+# include <osockaddr.h>
+#else
+# ifndef HAVE_STRUCT_OSOCKADDR
+# include <protocols/osockaddr.h>
+# endif
+#endif
#include <protocols/talkd.h>
#include <netdb.h>
#include <stdio.h>
diff -Naur inetutils-1.9.2-orig/talk/get_names.c inetutils-1.9.2/talk/get_names.c
--- inetutils-1.9.2-orig/talk/get_names.c 2013-09-26 12:36:38.000000000 +0300
+++ inetutils-1.9.2/talk/get_names.c 2014-12-12 11:55:13.492800000 +0300
@@ -55,6 +55,13 @@
#include <sys/types.h>
#include <sys/param.h>
#include <sys/socket.h>
+#ifdef HAVE_OSOCKADDR_H
+# include <osockaddr.h>
+#else
+# ifndef HAVE_STRUCT_OSOCKADDR
+# include <protocols/osockaddr.h>
+# endif
+#endif
#include <netinet/in.h>
#include <protocols/talkd.h>
#include <pwd.h>
diff -Naur inetutils-1.9.2-orig/talk/invite.c inetutils-1.9.2/talk/invite.c
--- inetutils-1.9.2-orig/talk/invite.c 2013-09-26 12:36:38.000000000 +0300
+++ inetutils-1.9.2/talk/invite.c 2014-12-12 11:55:13.492800000 +0300
@@ -57,6 +57,13 @@
#include <time.h>
#include <signal.h>
#include <netinet/in.h>
+#ifdef HAVE_OSOCKADDR_H
+# include <osockaddr.h>
+#else
+# ifndef HAVE_STRUCT_OSOCKADDR
+# include <protocols/osockaddr.h>
+# endif
+#endif
#include <protocols/talkd.h>
#include <errno.h>
#include <unistd.h>
diff -Naur inetutils-1.9.2-orig/talk/io.c inetutils-1.9.2/talk/io.c
--- inetutils-1.9.2-orig/talk/io.c 2013-09-26 12:36:38.000000000 +0300
+++ inetutils-1.9.2/talk/io.c 2014-12-12 11:55:13.508400000 +0300
@@ -69,6 +69,10 @@
#include <sys/select.h>
#include "talk.h"
+#ifdef __CYGWIN__
+#include <sys/socket.h>
+#endif
+
#define A_LONG_TIME 10000000
/*
diff -Naur inetutils-1.9.2-orig/talk/look_up.c inetutils-1.9.2/talk/look_up.c
--- inetutils-1.9.2-orig/talk/look_up.c 2013-09-26 12:36:38.000000000 +0300
+++ inetutils-1.9.2/talk/look_up.c 2014-12-12 11:55:13.508400000 +0300
@@ -54,6 +54,13 @@
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
+#ifdef HAVE_OSOCKADDR_H
+# include <osockaddr.h>
+#else
+# ifndef HAVE_STRUCT_OSOCKADDR
+# include <protocols/osockaddr.h>
+# endif
+#endif
#include <protocols/talkd.h>
#include <unistd.h>
#include <errno.h>

View File

@ -1,94 +0,0 @@
diff -Naur inetutils-1.9.2-orig/talkd/acl.c inetutils-1.9.2/talkd/acl.c
--- inetutils-1.9.2-orig/talkd/acl.c 2013-09-26 12:36:38.000000000 +0300
+++ inetutils-1.9.2/talkd/acl.c 2014-12-12 11:55:13.867200000 +0300
@@ -332,6 +332,28 @@
level = -1; /* Enforce a deny rule. */
}
+ /* existence check */
+ if (access (filename, F_OK) != 0)
+ {
+ switch (errno)
+ {
+ case ENOENT:
+ /* no error message if user doesn't have a .talkrc file */
+ break;
+ default:
+ syslog (LOG_ERR, "con't open config file %s: %m", filename);
+ break;
+ }
+ return NULL;
+ }
+
+ /* read check */
+ if (access (filename, R_OK) != 0)
+ {
+ syslog (LOG_ERR, "con't open config file %s: %m", filename);
+ return NULL;
+ }
+
mark = acl_tail;
read_acl (filename, level);
free (filename);
diff -Naur inetutils-1.9.2-orig/talkd/announce.c inetutils-1.9.2/talkd/announce.c
--- inetutils-1.9.2-orig/talkd/announce.c 2013-09-26 12:36:38.000000000 +0300
+++ inetutils-1.9.2/talkd/announce.c 2014-12-12 11:55:13.867200000 +0300
@@ -88,7 +88,7 @@
}
static int
-print_mesg (char *tty, CTL_MSG * request, char *remote_machine)
+print_mesg (char *tty, CTL_MSG * request, const char *remote_machine)
{
time_t t;
LINE ln;
@@ -125,7 +125,7 @@
/* See if the user is accepting messages. If so, announce that
a talk is requested. */
int
-announce (CTL_MSG * request, char *remote_machine)
+announce (CTL_MSG * request, const char *remote_machine)
{
char *ttypath;
int len;
diff -Naur inetutils-1.9.2-orig/talkd/intalkd.h inetutils-1.9.2/talkd/intalkd.h
--- inetutils-1.9.2-orig/talkd/intalkd.h 2013-09-26 12:36:38.000000000 +0300
+++ inetutils-1.9.2/talkd/intalkd.h 2014-12-12 11:55:13.867200000 +0300
@@ -22,6 +22,13 @@
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
+#ifdef HAVE_OSOCKADDR_H
+# include <osockaddr.h>
+#else
+# ifndef HAVE_STRUCT_OSOCKADDR
+# include <protocols/osockaddr.h>
+# endif
+#endif
#include <protocols/talkd.h>
#include <netdb.h>
#include <syslog.h>
@@ -65,4 +72,4 @@
extern int new_id (void);
extern void read_acl (char *config_file, int system);
extern int acl_match (CTL_MSG * msg, struct sockaddr_in *sa_in);
-extern int announce (CTL_MSG * request, char *remote_machine);
+extern int announce (CTL_MSG * request, const char *remote_machine);
diff -Naur inetutils-1.9.2-orig/talkd/process.c inetutils-1.9.2/talkd/process.c
--- inetutils-1.9.2-orig/talkd/process.c 2013-10-29 13:38:56.000000000 +0300
+++ inetutils-1.9.2/talkd/process.c 2014-12-12 11:55:13.867200000 +0300
@@ -236,12 +236,14 @@
if (stat (ftty, &statb) == 0)
{
+#ifndef __CYGWIN__
if (!(statb.st_mode & S_IWGRP))
{
if (status != SUCCESS)
status = PERMISSION_DENIED;
continue;
}
+#endif
if (statb.st_atime > last_time)
{
last_time = statb.st_atime;

View File

@ -1,84 +1,57 @@
# Maintainer: Martell Malone <martellmalone@gmail.com> # Maintainer: Martell Malone <martellmalone@gmail.com>
pkgname=inetutils pkgname=inetutils
pkgver=1.9.4 pkgver=2.4
pkgrel=5 pkgrel=1
pkgdesc="A collection of common network programs." pkgdesc="A collection of common network programs."
arch=('i686' 'x86_64') arch=('i686' 'x86_64')
url="https://www.gnu.org/software/inetutils/" url="https://www.gnu.org/software/inetutils/"
license=('GPL3') license=('spdx:GPL-3.0-or-later')
depends=('gcc-libs' 'libintl' 'libcrypt' 'libreadline' 'ncurses') depends=('gcc-libs' 'libintl' 'libcrypt' 'libreadline' 'ncurses')
makedepends=('gettext-devel' 'libcrypt-devel' 'libreadline-devel' 'ncurses-devel' 'autotools' 'gcc' 'tftp-hpa' 'help2man') makedepends=('gettext-devel' 'libcrypt-devel' 'libreadline-devel' 'ncurses-devel' 'autotools' 'gcc' 'tftp-hpa' 'help2man')
options=('!emptydirs') options=('!emptydirs')
install=inetutils.install
source=(https://ftp.gnu.org/gnu/inetutils/${pkgname}-${pkgver}.tar.xz source=(https://ftp.gnu.org/gnu/inetutils/${pkgname}-${pkgver}.tar.xz
01-buildsystem-updates.patch inetutils-2.4-1.src.patch
07-other-buildsys-updates.patch icmp6.h
08-libinetutils.patch
09-inetd.patch
11-telnet.patch
13-ftp.patch
14-ftpd.patch
15-syslogd.patch
16-talk.patch
17-talkd.patch
inetutils-1.9.4-1.src.patch
osockaddr.h osockaddr.h
talkd.h talkd.h)
tftp.h sha256sums=('1789d6b1b1a57dfe2a7ab7b533ee9f5dfd9cbf5b59bb1bb3c2612ed08d0f68b2'
inetutils-1.9.4-update-gnulib.patch) 'f70555d075a9c02cbc9b3580d4401b27a3069febac86152da06a76ee4da91df3'
sha256sums=('849d96f136effdef69548a940e3e0ec0624fc0c81265296987986a0dd36ded37' 'efad23dea555319c503c0b6ed7ec6b46c8faa48c138c763749686fc66e98c4b8'
'e88387223e1559bc4919dc8963149ecdb6ee8d812bdd07afa0342bd35de4fd65'
'ba3131b7825bb1b23280515a104391f69ae00f4e0caf285b2487080e008a979d'
'bd5308733b610233b23af51760d849f53aae038253ead1430193be03b89c0e45'
'b760c8adf10fa630101370a7cbb1c602d4ee10f18378dbffa98d1c1fbc6653c3'
'2751a47380c59d0d99a4d5c9eea0cf14ef9f40469a33fa32af1b12c3cac1d90d'
'277491be3779b4993f3e1a200c8fa899201c4630e18e62fd268556d4c8e1a3c5'
'90bc197ed42fe646b44b40fa68c0b76c1baf82daa047bd9e63758513f4e0e6f3'
'09f4b2375eb350613aea8c2ae6726bf3df6f7d4cc737f3ea7473e6d2e0ba0257'
'4260c0a18a7a16e4485aeb7cd8acc998cbb8e4c29d4b8d6bcbc535d86c79452c'
'd749005e6733f3ab7912a1c5952713499b76155386c2bfa9235a3e02dbce4fd8'
'66fa288a99beed6d7b885b980d06c8b13ce43f5c34461e515875f8705fbb84c1'
'e19596afff3b2ed163cf1a5c8a8d034208f9f996ace1ac76fd877a2d16aa448d' 'e19596afff3b2ed163cf1a5c8a8d034208f9f996ace1ac76fd877a2d16aa448d'
'5ad3115e95be02f1d0467ec13750f2d9096c7dfd6cf723a775e8718954e58018' 'b9e2401b0756c9bebcb0b0835d3c8f218198a121013f4990637ed1b9af0c72fd')
'f486d5235c54c03af270c85a9c519e21315534412d0787e159116e132f1b47da'
'22d6de583f4313a37eec070fb2a15bac576b95d62acc4ad759ec25cb2133dc6c')
prepare() { prepare() {
cd ${srcdir}/${pkgname}-${pkgver} cd ${srcdir}/${pkgname}-${pkgver}
# from cygwin
mkdir -p headers/protocols mkdir -p headers/protocols
cp ${srcdir}/osockaddr.h headers/protocols/osockaddr.h cp ${srcdir}/osockaddr.h headers/protocols/osockaddr.h
cp ${srcdir}/talkd.h headers/protocols/talkd.h cp ${srcdir}/talkd.h headers/protocols/talkd.h
# mkdir -p headers/arpa mkdir -p headers/netinet
# cp ${srcdir}/tftp.h headers/arpa/tftp.h cp ${srcdir}/icmp6.h headers/netinet/icmp6.h
patch -p2 -i ${srcdir}/inetutils-2.4-1.src.patch
patch -p1 -i ${srcdir}/01-buildsystem-updates.patch
patch -p1 -i ${srcdir}/07-other-buildsys-updates.patch
patch -p1 -i ${srcdir}/08-libinetutils.patch
patch -p1 -i ${srcdir}/09-inetd.patch
patch -p1 -i ${srcdir}/11-telnet.patch
patch -p1 -i ${srcdir}/13-ftp.patch
patch -p1 -i ${srcdir}/14-ftpd.patch
patch -p1 -i ${srcdir}/15-syslogd.patch
patch -p1 -i ${srcdir}/16-talk.patch
patch -p1 -i ${srcdir}/17-talkd.patch
patch -p1 -i ${srcdir}/inetutils-1.9.4-1.src.patch
patch -p1 -i ${srcdir}/inetutils-1.9.4-update-gnulib.patch
autoreconf -fiv autoreconf -fiv
} }
build() { build() {
CPPFLAGS+=" -I${srcdir}/${pkgname}-${pkgver}/headers"
cd ${srcdir}/${pkgname}-${pkgver} cd ${srcdir}/${pkgname}-${pkgver}
cat > config.cache << EOF mkdir -p "${srcdir}/build-${MSYSTEM}" && cd "${srcdir}/build-${MSYSTEM}"
gl_cv_func_getcwd_path_max=yes
ac_cv_func_mmap_fixed_mapped=no # copied from cygwin
EOF export ac_cv_func_mmap_fixed_mapped=no
# the cygwin patch adds talkd.h, but not in a way configure can detect it
# so force it here
export ac_cv_header_protocols_talkd_h=yes
# this isn't set in ./configure but needed to get a valid Makefile -- don't ask me...
export EXEEXT=.exe
local CYGWIN_CHOST="${CHOST/-msys/-cygwin}" local CYGWIN_CHOST="${CHOST/-msys/-cygwin}"
./configure --prefix=/usr \ ../${pkgbase}-${pkgver}/configure --prefix=/usr \
--build=${CYGWIN_CHOST} \ --build=${CYGWIN_CHOST} \
--libexec=/usr/bin \ --libexec=/usr/bin \
--localstatedir=/var \ --localstatedir=/var \
@ -102,13 +75,13 @@ EOF
--disable-inetd --disable-whois \ --disable-inetd --disable-whois \
--disable-uucpd --disable-ifconfig \ --disable-uucpd --disable-ifconfig \
--enable-dnsdomainname \ --enable-dnsdomainname \
--disable-traceroute \ --disable-traceroute
--cache-file=config.cache
make make
} }
package() { package() {
cd ${srcdir}/${pkgname}-${pkgver} cd "${srcdir}/build-${MSYSTEM}"
make DESTDIR="${pkgdir}" install make DESTDIR="${pkgdir}" install
} }

345
inetutils/icmp6.h Normal file
View File

@ -0,0 +1,345 @@
/* Copyright (C) 1991-1997,2000,2006,2009 Free Software Foundation, Inc.
This file is part of the GNU C Library.
The GNU C Library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
The GNU C Library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with the GNU C Library; if not, see
<http://www.gnu.org/licenses/>. */
#ifndef _NETINET_ICMP6_H
#define _NETINET_ICMP6_H 1
#include <inttypes.h>
#include <string.h>
#include <sys/types.h>
#include <netinet/in.h>
#define ICMP6_FILTER 1
#define ICMP6_FILTER_BLOCK 1
#define ICMP6_FILTER_PASS 2
#define ICMP6_FILTER_BLOCKOTHERS 3
#define ICMP6_FILTER_PASSONLY 4
struct icmp6_filter
{
uint32_t icmp6_filt[8];
};
struct icmp6_hdr
{
uint8_t icmp6_type; /* type field */
uint8_t icmp6_code; /* code field */
uint16_t icmp6_cksum; /* checksum field */
union
{
uint32_t icmp6_un_data32[1]; /* type-specific field */
uint16_t icmp6_un_data16[2]; /* type-specific field */
uint8_t icmp6_un_data8[4]; /* type-specific field */
} icmp6_dataun;
};
#define icmp6_data32 icmp6_dataun.icmp6_un_data32
#define icmp6_data16 icmp6_dataun.icmp6_un_data16
#define icmp6_data8 icmp6_dataun.icmp6_un_data8
#define icmp6_pptr icmp6_data32[0] /* parameter prob */
#define icmp6_mtu icmp6_data32[0] /* packet too big */
#define icmp6_id icmp6_data16[0] /* echo request/reply */
#define icmp6_seq icmp6_data16[1] /* echo request/reply */
#define icmp6_maxdelay icmp6_data16[0] /* mcast group membership */
#define ICMP6_DST_UNREACH 1
#define ICMP6_PACKET_TOO_BIG 2
#define ICMP6_TIME_EXCEEDED 3
#define ICMP6_PARAM_PROB 4
#define ICMP6_INFOMSG_MASK 0x80 /* all informational messages */
#define ICMP6_ECHO_REQUEST 128
#define ICMP6_ECHO_REPLY 129
#define MLD_LISTENER_QUERY 130
#define MLD_LISTENER_REPORT 131
#define MLD_LISTENER_REDUCTION 132
#define ICMP6_DST_UNREACH_NOROUTE 0 /* no route to destination */
#define ICMP6_DST_UNREACH_ADMIN 1 /* communication with destination */
/* administratively prohibited */
#define ICMP6_DST_UNREACH_BEYONDSCOPE 2 /* beyond scope of source address */
#define ICMP6_DST_UNREACH_ADDR 3 /* address unreachable */
#define ICMP6_DST_UNREACH_NOPORT 4 /* bad port */
#define ICMP6_TIME_EXCEED_TRANSIT 0 /* Hop Limit == 0 in transit */
#define ICMP6_TIME_EXCEED_REASSEMBLY 1 /* Reassembly time out */
#define ICMP6_PARAMPROB_HEADER 0 /* erroneous header field */
#define ICMP6_PARAMPROB_NEXTHEADER 1 /* unrecognized Next Header */
#define ICMP6_PARAMPROB_OPTION 2 /* unrecognized IPv6 option */
#define ICMP6_FILTER_WILLPASS(type, filterp) \
((((filterp)->icmp6_filt[(type) >> 5]) & (1 << ((type) & 31))) == 0)
#define ICMP6_FILTER_WILLBLOCK(type, filterp) \
((((filterp)->icmp6_filt[(type) >> 5]) & (1 << ((type) & 31))) != 0)
#define ICMP6_FILTER_SETPASS(type, filterp) \
((((filterp)->icmp6_filt[(type) >> 5]) &= ~(1 << ((type) & 31))))
#define ICMP6_FILTER_SETBLOCK(type, filterp) \
((((filterp)->icmp6_filt[(type) >> 5]) |= (1 << ((type) & 31))))
#define ICMP6_FILTER_SETPASSALL(filterp) \
memset (filterp, 0, sizeof (struct icmp6_filter));
#define ICMP6_FILTER_SETBLOCKALL(filterp) \
memset (filterp, 0xFF, sizeof (struct icmp6_filter));
#define ND_ROUTER_SOLICIT 133
#define ND_ROUTER_ADVERT 134
#define ND_NEIGHBOR_SOLICIT 135
#define ND_NEIGHBOR_ADVERT 136
#define ND_REDIRECT 137
struct nd_router_solicit /* router solicitation */
{
struct icmp6_hdr nd_rs_hdr;
/* could be followed by options */
};
#define nd_rs_type nd_rs_hdr.icmp6_type
#define nd_rs_code nd_rs_hdr.icmp6_code
#define nd_rs_cksum nd_rs_hdr.icmp6_cksum
#define nd_rs_reserved nd_rs_hdr.icmp6_data32[0]
struct nd_router_advert /* router advertisement */
{
struct icmp6_hdr nd_ra_hdr;
uint32_t nd_ra_reachable; /* reachable time */
uint32_t nd_ra_retransmit; /* retransmit timer */
/* could be followed by options */
};
#define nd_ra_type nd_ra_hdr.icmp6_type
#define nd_ra_code nd_ra_hdr.icmp6_code
#define nd_ra_cksum nd_ra_hdr.icmp6_cksum
#define nd_ra_curhoplimit nd_ra_hdr.icmp6_data8[0]
#define nd_ra_flags_reserved nd_ra_hdr.icmp6_data8[1]
#define ND_RA_FLAG_MANAGED 0x80
#define ND_RA_FLAG_OTHER 0x40
#define ND_RA_FLAG_HOME_AGENT 0x20
#define nd_ra_router_lifetime nd_ra_hdr.icmp6_data16[1]
struct nd_neighbor_solicit /* neighbor solicitation */
{
struct icmp6_hdr nd_ns_hdr;
struct in6_addr nd_ns_target; /* target address */
/* could be followed by options */
};
#define nd_ns_type nd_ns_hdr.icmp6_type
#define nd_ns_code nd_ns_hdr.icmp6_code
#define nd_ns_cksum nd_ns_hdr.icmp6_cksum
#define nd_ns_reserved nd_ns_hdr.icmp6_data32[0]
struct nd_neighbor_advert /* neighbor advertisement */
{
struct icmp6_hdr nd_na_hdr;
struct in6_addr nd_na_target; /* target address */
/* could be followed by options */
};
#define nd_na_type nd_na_hdr.icmp6_type
#define nd_na_code nd_na_hdr.icmp6_code
#define nd_na_cksum nd_na_hdr.icmp6_cksum
#define nd_na_flags_reserved nd_na_hdr.icmp6_data32[0]
#if BYTE_ORDER == BIG_ENDIAN
#define ND_NA_FLAG_ROUTER 0x80000000
#define ND_NA_FLAG_SOLICITED 0x40000000
#define ND_NA_FLAG_OVERRIDE 0x20000000
#else /* BYTE_ORDER == LITTLE_ENDIAN */
#define ND_NA_FLAG_ROUTER 0x00000080
#define ND_NA_FLAG_SOLICITED 0x00000040
#define ND_NA_FLAG_OVERRIDE 0x00000020
#endif
struct nd_redirect /* redirect */
{
struct icmp6_hdr nd_rd_hdr;
struct in6_addr nd_rd_target; /* target address */
struct in6_addr nd_rd_dst; /* destination address */
/* could be followed by options */
};
#define nd_rd_type nd_rd_hdr.icmp6_type
#define nd_rd_code nd_rd_hdr.icmp6_code
#define nd_rd_cksum nd_rd_hdr.icmp6_cksum
#define nd_rd_reserved nd_rd_hdr.icmp6_data32[0]
struct nd_opt_hdr /* Neighbor discovery option header */
{
uint8_t nd_opt_type;
uint8_t nd_opt_len; /* in units of 8 octets */
/* followed by option specific data */
};
#define ND_OPT_SOURCE_LINKADDR 1
#define ND_OPT_TARGET_LINKADDR 2
#define ND_OPT_PREFIX_INFORMATION 3
#define ND_OPT_REDIRECTED_HEADER 4
#define ND_OPT_MTU 5
#define ND_OPT_RTR_ADV_INTERVAL 7
#define ND_OPT_HOME_AGENT_INFO 8
struct nd_opt_prefix_info /* prefix information */
{
uint8_t nd_opt_pi_type;
uint8_t nd_opt_pi_len;
uint8_t nd_opt_pi_prefix_len;
uint8_t nd_opt_pi_flags_reserved;
uint32_t nd_opt_pi_valid_time;
uint32_t nd_opt_pi_preferred_time;
uint32_t nd_opt_pi_reserved2;
struct in6_addr nd_opt_pi_prefix;
};
#define ND_OPT_PI_FLAG_ONLINK 0x80
#define ND_OPT_PI_FLAG_AUTO 0x40
#define ND_OPT_PI_FLAG_RADDR 0x20
struct nd_opt_rd_hdr /* redirected header */
{
uint8_t nd_opt_rh_type;
uint8_t nd_opt_rh_len;
uint16_t nd_opt_rh_reserved1;
uint32_t nd_opt_rh_reserved2;
/* followed by IP header and data */
};
struct nd_opt_mtu /* MTU option */
{
uint8_t nd_opt_mtu_type;
uint8_t nd_opt_mtu_len;
uint16_t nd_opt_mtu_reserved;
uint32_t nd_opt_mtu_mtu;
};
struct mld_hdr
{
struct icmp6_hdr mld_icmp6_hdr;
struct in6_addr mld_addr; /* multicast address */
};
#define mld_type mld_icmp6_hdr.icmp6_type
#define mld_code mld_icmp6_hdr.icmp6_code
#define mld_cksum mld_icmp6_hdr.icmp6_cksum
#define mld_maxdelay mld_icmp6_hdr.icmp6_data16[0]
#define mld_reserved mld_icmp6_hdr.icmp6_data16[1]
#define ICMP6_ROUTER_RENUMBERING 138
struct icmp6_router_renum /* router renumbering header */
{
struct icmp6_hdr rr_hdr;
uint8_t rr_segnum;
uint8_t rr_flags;
uint16_t rr_maxdelay;
uint32_t rr_reserved;
};
#define rr_type rr_hdr.icmp6_type
#define rr_code rr_hdr.icmp6_code
#define rr_cksum rr_hdr.icmp6_cksum
#define rr_seqnum rr_hdr.icmp6_data32[0]
/* Router renumbering flags */
#define ICMP6_RR_FLAGS_TEST 0x80
#define ICMP6_RR_FLAGS_REQRESULT 0x40
#define ICMP6_RR_FLAGS_FORCEAPPLY 0x20
#define ICMP6_RR_FLAGS_SPECSITE 0x10
#define ICMP6_RR_FLAGS_PREVDONE 0x08
struct rr_pco_match /* match prefix part */
{
uint8_t rpm_code;
uint8_t rpm_len;
uint8_t rpm_ordinal;
uint8_t rpm_matchlen;
uint8_t rpm_minlen;
uint8_t rpm_maxlen;
uint16_t rpm_reserved;
struct in6_addr rpm_prefix;
};
/* PCO code values */
#define RPM_PCO_ADD 1
#define RPM_PCO_CHANGE 2
#define RPM_PCO_SETGLOBAL 3
struct rr_pco_use /* use prefix part */
{
uint8_t rpu_uselen;
uint8_t rpu_keeplen;
uint8_t rpu_ramask;
uint8_t rpu_raflags;
uint32_t rpu_vltime;
uint32_t rpu_pltime;
uint32_t rpu_flags;
struct in6_addr rpu_prefix;
};
#define ICMP6_RR_PCOUSE_RAFLAGS_ONLINK 0x20
#define ICMP6_RR_PCOUSE_RAFLAGS_AUTO 0x10
#if BYTE_ORDER == BIG_ENDIAN
# define ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME 0x80000000
# define ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME 0x40000000
#elif BYTE_ORDER == LITTLE_ENDIAN
# define ICMP6_RR_PCOUSE_FLAGS_DECRVLTIME 0x80
# define ICMP6_RR_PCOUSE_FLAGS_DECRPLTIME 0x40
#endif
struct rr_result /* router renumbering result message */
{
uint16_t rrr_flags;
uint8_t rrr_ordinal;
uint8_t rrr_matchedlen;
uint32_t rrr_ifid;
struct in6_addr rrr_prefix;
};
#if BYTE_ORDER == BIG_ENDIAN
# define ICMP6_RR_RESULT_FLAGS_OOB 0x0002
# define ICMP6_RR_RESULT_FLAGS_FORBIDDEN 0x0001
#elif BYTE_ORDER == LITTLE_ENDIAN
# define ICMP6_RR_RESULT_FLAGS_OOB 0x0200
# define ICMP6_RR_RESULT_FLAGS_FORBIDDEN 0x0100
#endif
/* Mobile IPv6 extension: Advertisement Interval. */
struct nd_opt_adv_interval
{
uint8_t nd_opt_adv_interval_type;
uint8_t nd_opt_adv_interval_len;
uint16_t nd_opt_adv_interval_reserved;
uint32_t nd_opt_adv_interval_ival;
};
/* Mobile IPv6 extension: Home Agent Info. */
struct nd_opt_home_agent_info
{
uint8_t nd_opt_home_agent_info_type;
uint8_t nd_opt_home_agent_info_len;
uint16_t nd_opt_home_agent_info_reserved;
uint16_t nd_opt_home_agent_info_preference;
uint16_t nd_opt_home_agent_info_lifetime;
};
#endif /* netinet/icmpv6.h */

View File

@ -1,45 +0,0 @@
diff -durN inetutils-1.9.4.orig/.version inetutils-1.9.4/.version
--- inetutils-1.9.4.orig/.version 1970-01-01 08:00:00.000000000 +0800
+++ inetutils-1.9.4/.version 2017-05-14 21:33:59.421875000 +0800
@@ -0,0 +1 @@
+1.9.4
diff -durN inetutils-1.9.4.orig/configure.ac inetutils-1.9.4/configure.ac
--- inetutils-1.9.4.orig/configure.ac 2017-05-14 21:30:40.875000000 +0800
+++ inetutils-1.9.4/configure.ac 2017-05-14 21:36:54.406250000 +0800
@@ -230,10 +230,15 @@
AM_CONDITIONAL([ENABLE_libls], [test "$enable_libls" = yes])
# At least OpenSolaris is missing <protocols/talkd.h>.
-AC_CHECK_HEADER(protocols/talkd.h, , ,
+AC_CHECK_HEADER(protocols/osockaddr.h, , ,
[IU_FLUSHLEFT([#include <sys/types.h>
#include <sys/socket.h>])])
+AC_CHECK_HEADER(protocols/talkd.h, , ,
+ [IU_FLUSHLEFT([#include <sys/types.h>
+ #include <sys/socket.h>
+ #include <protocols/osockaddr.h>])])
+
if test "$ac_cv_header_protocols_talkd_h" = no; then
AC_MSG_WARN([protocols/talkd.h is not available, not building talk, nor talkd])
IU_DISABLE_TARGET(talk)
@@ -611,7 +616,7 @@
sys/proc.h sys/select.h sys/time.h sys/wait.h \
sys/resource.h \
stropts.h tcpd.h utmp.h utmpx.h unistd.h \
- vis.h osockaddr.h crypt.h], [], [], [
+ vis.h crypt.h], [], [], [
#include <sys/types.h>
#ifdef HAVE_STDIO_H
# include <stdio.h>
diff -durN inetutils-1.9.4.orig/libinetutils/daemon.c inetutils-1.9.4/libinetutils/daemon.c
--- inetutils-1.9.4.orig/libinetutils/daemon.c 2017-05-14 21:30:39.781250000 +0800
+++ inetutils-1.9.4/libinetutils/daemon.c 2017-05-14 21:37:41.578125000 +0800
@@ -56,6 +56,7 @@
#include <stdlib.h>
#include <sys/types.h>
#include <sys/wait.h>
+#include <string.h>
#include <unused-parameter.h>
/*

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,13 +0,0 @@
post_install() {
setcap cap_net_bind_service=+ep usr/bin/rcp 2>/dev/null || chmod +s usr/bin/rcp
setcap cap_net_bind_service=+ep usr/bin/rlogin 2>/dev/null || chmod +s usr/bin/rlogin
setcap cap_net_bind_service=+ep usr/bin/rsh 2>/dev/null || chmod +s usr/bin/rsh
}
post_upgrade() {
post_install $1
}
pre_remove() {
return 0
}

View File

@ -69,10 +69,10 @@ typedef struct {
u_char type; /* request type, see below */ u_char type; /* request type, see below */
u_char answer; /* not used */ u_char answer; /* not used */
u_char pad; u_char pad;
u_long id_num; /* message id */ u_int32_t id_num; /* message id */
struct osockaddr addr; /* old (4.3) style */ struct osockaddr addr; /* old (4.3) style */
struct osockaddr ctl_addr; /* old (4.3) style */ struct osockaddr ctl_addr; /* old (4.3) style */
long pid; /* caller's process id */ int32_t pid; /* caller's process id */
#define NAME_SIZE 12 #define NAME_SIZE 12
char l_name[NAME_SIZE];/* caller's name */ char l_name[NAME_SIZE];/* caller's name */
char r_name[NAME_SIZE];/* callee's name */ char r_name[NAME_SIZE];/* callee's name */
@ -88,7 +88,7 @@ typedef struct {
u_char type; /* type of request message, see below */ u_char type; /* type of request message, see below */
u_char answer; /* respose to request message, see below */ u_char answer; /* respose to request message, see below */
u_char pad; u_char pad;
u_long id_num; /* message id */ u_int32_t id_num; /* message id */
struct osockaddr addr; /* address for establishing conversation */ struct osockaddr addr; /* address for establishing conversation */
} CTL_RESPONSE; } CTL_RESPONSE;

View File

@ -1,88 +0,0 @@
/*
* Copyright (c) 1983, 1993
* The Regents of the University of California. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* @(#)tftp.h 8.1 (Berkeley) 6/2/93
*/
#ifndef _TFTP_H_
#define _TFTP_H_
#ifdef __cplusplus
extern "C" {
#endif
/*
* Trivial File Transfer Protocol (IEN-133)
*/
#define SEGSIZE 512 /* data segment size */
/*
* Packet types.
*/
#define RRQ 01 /* read request */
#define WRQ 02 /* write request */
#define DATA 03 /* data packet */
#define ACK 04 /* acknowledgement */
#define ERROR 05 /* error code */
struct tftphdr {
short th_opcode; /* packet type */
union {
short tu_block; /* block # */
short tu_code; /* error code */
char tu_stuff[1]; /* request packet stuff */
} th_u;
char th_data[1]; /* data or error string */
};
#define th_block th_u.tu_block
#define th_code th_u.tu_code
#define th_stuff th_u.tu_stuff
#define th_msg th_data
/*
* Error codes.
*/
#define EUNDEF 0 /* not defined */
#define ENOTFOUND 1 /* file not found */
#define EACCESS 2 /* access violation */
#define ENOSPACE 3 /* disk full or allocation exceeded */
#define EBADOP 4 /* illegal TFTP operation */
#define EBADID 5 /* unknown transfer ID */
#define EEXISTS 6 /* file already exists */
#define ENOUSER 7 /* no such user */
#ifdef __cplusplus
}
#endif
#endif /* !_TFTP_H_ */