inetutils: Allow building.

This commit is contained in:
Alexpux 2014-12-12 14:42:56 +03:00
parent fa05d6182e
commit 4621c28308
17 changed files with 3045 additions and 15 deletions

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,67 @@
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

@ -0,0 +1,192 @@
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

272
inetutils/09-inetd.patch Normal file
View File

@ -0,0 +1,272 @@
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 (;;)
{

31
inetutils/11-telnet.patch Normal file
View File

@ -0,0 +1,31 @@
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;

122
inetutils/13-ftp.patch Normal file
View File

@ -0,0 +1,122 @@
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);

311
inetutils/14-ftpd.patch Normal file
View File

@ -0,0 +1,311 @@
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

@ -0,0 +1,49 @@
diff -Naur inetutils-1.9.2-orig/man/syslogd.8 inetutils-1.9.2/man/syslogd.8
--- inetutils-1.9.2-orig/man/syslogd.8 2013-12-23 15:26:57.000000000 +0300
+++ inetutils-1.9.2/man/syslogd.8 2014-12-12 11:55:13.134000000 +0300
@@ -30,6 +30,14 @@
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=\fIFILE\fR
override configuration file (default:
\fI/usr/local/etc/syslog.conf\fP)
diff -Naur inetutils-1.9.2-orig/src/syslogd.c inetutils-1.9.2/src/syslogd.c
--- inetutils-1.9.2-orig/src/syslogd.c 2013-10-29 13:38:56.000000000 +0300
+++ inetutils-1.9.2/src/syslogd.c 2014-12-12 11:55:13.149600000 +0300
@@ -348,6 +348,7 @@
{"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
@@ -431,6 +432,7 @@
break;
case 'n':
+ case 'D':
NoDetach = 1;
break;
@@ -1097,7 +1099,11 @@
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';)
{

131
inetutils/16-talk.patch Normal file
View File

@ -0,0 +1,131 @@
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>

94
inetutils/17-talkd.patch Normal file
View File

@ -0,0 +1,94 @@
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;

151
inetutils/99-msysize.patch Normal file
View File

@ -0,0 +1,151 @@
diff -Naur inetutils-1.9.2-orig/build-aux/config.guess inetutils-1.9.2/build-aux/config.guess
--- inetutils-1.9.2-orig/build-aux/config.guess 2013-12-03 17:57:34.000000000 +0300
+++ inetutils-1.9.2/build-aux/config.guess 2014-12-12 11:56:58.123800000 +0300
@@ -866,6 +866,9 @@
amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*)
echo x86_64-unknown-cygwin
exit ;;
+ amd64:MSTS*:*:* | x86_64:MSYS*:*:*)
+ echo x86_64-unknown-msys
+ exit ;;
p*:CYGWIN*:*)
echo powerpcle-unknown-cygwin
exit ;;
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:14.538000000 +0300
+++ inetutils-1.9.2/configure.ac 2014-12-12 11:56:27.001800000 +0300
@@ -1015,7 +1015,7 @@
AC_DEFINE([HAVE_STREAMSPTY], 1,
[Define to 1 for a system using streams for ptys])
;;
-*cygwin*)
+*cygwin* | *msys*)
LIBS="/usr/lib/textmode.o ${LIBS}"
AC_DEFINE(UTMPX, 1, [FIXME])
;;
diff -Naur inetutils-1.9.2-orig/lib/Makefile.am inetutils-1.9.2/lib/Makefile.am
--- inetutils-1.9.2-orig/lib/Makefile.am 2013-12-23 15:13:58.000000000 +0300
+++ inetutils-1.9.2/lib/Makefile.am 2014-12-12 11:57:48.699000000 +0300
@@ -947,7 +947,7 @@
case '$(host_os)' in \
darwin[56]*) \
need_charset_alias=true ;; \
- darwin* | cygwin* | mingw* | pw32* | cegcc*) \
+ darwin* | cygwin* | msys* | mingw* | pw32* | cegcc*) \
need_charset_alias=false ;; \
*) \
need_charset_alias=true ;; \
diff -Naur inetutils-1.9.2-orig/m4/btowc.m4 inetutils-1.9.2/m4/btowc.m4
--- inetutils-1.9.2-orig/m4/btowc.m4 2013-12-23 15:13:53.000000000 +0300
+++ inetutils-1.9.2/m4/btowc.m4 2014-12-12 11:58:26.919000000 +0300
@@ -49,7 +49,7 @@
changequote(,)dnl
case "$host_os" in
# Guess no on Cygwin.
- cygwin*) gl_cv_func_btowc_nul="guessing no" ;;
+ cygwin* | msys*) gl_cv_func_btowc_nul="guessing no" ;;
# Guess yes otherwise.
*) gl_cv_func_btowc_nul="guessing yes" ;;
esac
diff -Naur inetutils-1.9.2-orig/m4/double-slash-root.m4 inetutils-1.9.2/m4/double-slash-root.m4
--- inetutils-1.9.2-orig/m4/double-slash-root.m4 2013-12-23 15:13:53.000000000 +0300
+++ inetutils-1.9.2/m4/double-slash-root.m4 2014-12-12 11:58:40.007400000 +0300
@@ -16,7 +16,7 @@
# special semantics and is distinct from /, please report it to
# <bug-gnulib@gnu.org>.
case $host in
- *-cygwin | i370-ibm-openedition)
+ *-cygwin | *-msys | i370-ibm-openedition)
gl_cv_double_slash_root=yes ;;
*)
# Be optimistic and assume that / and // are the same when we
diff -Naur inetutils-1.9.2-orig/m4/dup2.m4 inetutils-1.9.2/m4/dup2.m4
--- inetutils-1.9.2-orig/m4/dup2.m4 2013-12-23 15:13:53.000000000 +0300
+++ inetutils-1.9.2/m4/dup2.m4 2014-12-12 11:58:53.641800000 +0300
@@ -51,7 +51,7 @@
[case "$host_os" in
mingw*) # on this platform, dup2 always returns 0 for success
gl_cv_func_dup2_works="guessing no" ;;
- cygwin*) # on cygwin 1.5.x, dup2(1,1) returns 0
+ cygwin* | msys*) # on cygwin 1.5.x, dup2(1,1) returns 0
gl_cv_func_dup2_works="guessing no" ;;
linux*) # On linux between 2008-07-27 and 2009-05-11, dup2 of a
# closed fd may yield -EBADF instead of -1 / errno=EBADF.
diff -Naur inetutils-1.9.2-orig/m4/getcwd.m4 inetutils-1.9.2/m4/getcwd.m4
--- inetutils-1.9.2-orig/m4/getcwd.m4 2013-12-23 15:13:54.000000000 +0300
+++ inetutils-1.9.2/m4/getcwd.m4 2014-12-12 11:59:13.656600000 +0300
@@ -49,7 +49,7 @@
# Guess yes on glibc systems.
*-gnu*) gl_cv_func_getcwd_null="guessing yes";;
# Guess yes on Cygwin.
- cygwin*) gl_cv_func_getcwd_null="guessing yes";;
+ cygwin* | msys*) gl_cv_func_getcwd_null="guessing yes";;
# If we don't know, assume the worst.
*) gl_cv_func_getcwd_null="guessing no";;
esac
diff -Naur inetutils-1.9.2-orig/m4/getdtablesize.m4 inetutils-1.9.2/m4/getdtablesize.m4
--- inetutils-1.9.2-orig/m4/getdtablesize.m4 2013-12-23 15:13:54.000000000 +0300
+++ inetutils-1.9.2/m4/getdtablesize.m4 2014-12-12 11:59:25.294200000 +0300
@@ -26,7 +26,7 @@
[gl_cv_func_getdtablesize_works=yes],
[gl_cv_func_getdtablesize_works=no],
[case "$host_os" in
- cygwin*) # on cygwin 1.5.25, getdtablesize() automatically grows
+ cygwin* | msys*) # on cygwin 1.5.25, getdtablesize() automatically grows
gl_cv_func_getdtablesize_works="guessing no" ;;
*) gl_cv_func_getdtablesize_works="guessing yes" ;;
esac])
diff -Naur inetutils-1.9.2-orig/m4/malloc.m4 inetutils-1.9.2/m4/malloc.m4
--- inetutils-1.9.2-orig/m4/malloc.m4 2013-12-23 15:13:54.000000000 +0300
+++ inetutils-1.9.2/m4/malloc.m4 2014-12-12 11:59:47.539800000 +0300
@@ -30,7 +30,7 @@
[case "$host_os" in
# Guess yes on platforms where we know the result.
*-gnu* | freebsd* | netbsd* | openbsd* \
- | hpux* | solaris* | cygwin* | mingw*)
+ | hpux* | solaris* | cygwin* | msys* | mingw*)
ac_cv_func_malloc_0_nonnull=yes ;;
# If we don't know, assume the worst.
*) ac_cv_func_malloc_0_nonnull=no ;;
diff -Naur inetutils-1.9.2-orig/m4/printf.m4 inetutils-1.9.2/m4/printf.m4
--- inetutils-1.9.2-orig/m4/printf.m4 2013-12-23 15:13:54.000000000 +0300
+++ inetutils-1.9.2/m4/printf.m4 2014-12-12 12:00:37.943400000 +0300
@@ -735,7 +735,7 @@
openbsd*) gl_cv_func_printf_directive_ls="guessing no";;
irix*) gl_cv_func_printf_directive_ls="guessing no";;
solaris*) gl_cv_func_printf_directive_ls="guessing no";;
- cygwin*) gl_cv_func_printf_directive_ls="guessing no";;
+ cygwin* | msys*) gl_cv_func_printf_directive_ls="guessing no";;
beos* | haiku*) gl_cv_func_printf_directive_ls="guessing no";;
*) gl_cv_func_printf_directive_ls="guessing yes";;
esac
@@ -812,7 +812,7 @@
[
changequote(,)dnl
case "$host_os" in
- cygwin*) gl_cv_func_printf_flag_grouping="guessing no";;
+ cygwin* | msys*) gl_cv_func_printf_flag_grouping="guessing no";;
netbsd*) gl_cv_func_printf_flag_grouping="guessing no";;
mingw* | pw*) gl_cv_func_printf_flag_grouping="guessing no";;
*) gl_cv_func_printf_flag_grouping="guessing yes";;
@@ -1464,7 +1464,7 @@
darwin[1-6].*) gl_cv_func_vsnprintf_zerosize_c99="guessing no";;
darwin*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
# Guess yes on Cygwin.
- cygwin*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
+ cygwin* | msys*) gl_cv_func_vsnprintf_zerosize_c99="guessing yes";;
# Guess yes on Solaris >= 2.6.
solaris2.[0-5] | solaris2.[0-5].*)
gl_cv_func_vsnprintf_zerosize_c99="guessing no";;
diff -Naur inetutils-1.9.2-orig/m4/realloc.m4 inetutils-1.9.2/m4/realloc.m4
--- inetutils-1.9.2-orig/m4/realloc.m4 2013-12-23 15:13:54.000000000 +0300
+++ inetutils-1.9.2/m4/realloc.m4 2014-12-12 12:00:59.065800000 +0300
@@ -30,7 +30,7 @@
[case "$host_os" in
# Guess yes on platforms where we know the result.
*-gnu* | freebsd* | netbsd* | openbsd* \
- | hpux* | solaris* | cygwin* | mingw*)
+ | hpux* | solaris* | cygwin* | msys* | mingw*)
ac_cv_func_realloc_0_nonnull=yes ;;
# If we don't know, assume the worst.
*) ac_cv_func_realloc_0_nonnull=no ;;

View File

@ -8,36 +8,96 @@ arch=('i686' 'x86_64')
url="http://www.gnu.org/software/inetutils/"
license=('GPL3')
groups=('base')
makedepends=('automake' 'autoconf' 'pkg-config' 'make')
depends=('gcc-libs' 'libintl' 'libcrypt' 'libreadline' 'ncurses')
makedepends=('automake' 'autoconf' 'pkg-config' 'make' 'gettext-devel' 'libcrypt-devel' 'libreadline-devel' 'ncurses-devel')
options=('!emptydirs')
install=inetutils.install
source=(http://ftp.gnu.org/gnu/inetutils/${pkgname}-${pkgver}.tar.xz)
sha1sums=('f9fc5c3ba7046d95fdfd0f1c6adf508220082893')
source=(http://ftp.gnu.org/gnu/inetutils/${pkgname}-${pkgver}.tar.xz
01-buildsystem-updates.patch
07-other-buildsys-updates.patch
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.2-1.src.patch
osockaddr.h
talkd.h
tftp.h
99-msysize.patch)
sha1sums=('f9fc5c3ba7046d95fdfd0f1c6adf508220082893'
'f21c5acb88bc639821e45d08ffd8b5342ea5c0aa'
'f51e1e91893938a75fe66cc6233b306de259dd16'
'af6d06e50853e1ba7dcde4bee177cbe2742c67ae'
'64036fe2a7e7a7d308c7c70ec4e611c7a681e0d6'
'a44a370740dc8ff75e54bc187589f19d3903743d'
'26ebe17ba0e3a58f07a043d14a7890f6d94ec35f'
'e91f9bdc5c267b6ced5177b972de3e1c9d20bfd9'
'b2dec127055c93f2bac284950725ecb4bba2df57'
'f8910a048ec8a70be59694e508ff9ce73c553d7e'
'd6fef2549638fef93453e37ce54c9a008c8fc1e6'
'd9e69d0bd383c98f94aa965b20ed8a62906d6f99'
'c36af37b6dd90981c38f781baf0deee1e7bfeafe'
'40bd20f45f8bb12350c9d159e633f3e16cf1fa75'
'1dfdf7bc6d9804d62615a094924f104735621928'
'f8d3bf25ee4be9535c04d9d5efe20728dd150707')
prepare() {
cd ${srcdir}/${pkgname}-${pkgver}
autoreconf -fi
mkdir -p headers/protocols
cp ${srcdir}/osockaddr.h headers/protocols/osockaddr.h
cp ${srcdir}/talkd.h headers/protocols/talkd.h
# mkdir -p headers/arpa
# cp ${srcdir}/tftp.h headers/arpa/tftp.h
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.2-1.src.patch
patch -p1 -i ${srcdir}/99-msysize.patch
autoreconf -fiv
}
build() {
CPPFLAGS+=" -I${srcdir}/${pkgname}-${pkgver}/headers"
cd ${srcdir}/${pkgname}-${pkgver}
./configure --prefix=/usr --libexec=/usr/bin \
--localstatedir=/var --sysconfdir=/etc \
--without-wrap --without-pam \
--enable-ftp --enable-ftpd \
--enable-telnet --enable-telnetd \
--enable-talk --enable-talkd \
--enable-rlogin --enable-rlogind \
--enable-rsh --enable-rshd \
--enable-rcp --enable-hostname \
--enable-dnsdomainname \
./configure --prefix=/usr \
--libexec=/usr/bin \
--localstatedir=/var \
--sysconfdir=/etc \
--infodir=/usr/share/info \
--mandir=/usr/share/man \
--datarootdir=/usr/share \
--docdir=/usr/share/doc/${pkgname} \
--with-wrap \
--without-pam \
--enable-ftp --disable-ftpd \
--enable-telnet --disable-telnetd \
--enable-talk --disable-talkd \
--enable-rlogin --disable-rlogind \
--enable-rsh --disable-rshd \
--enable-rcp --disable-hostname \
--disable-rexec --disable-rexecd \
--disable-tftp --disable-tftpd \
--disable-ping --disable-ping6 \
--disable-logger --disable-syslogd \
--disable-inetd --disable-whois \
--disable-uucpd --disable-ifconfig \
--disable-traceroute
--enable-dnsdomainname \
--disable-traceroute \
ac_cv_func_mmap_fixed_mapped=no
make
}

View File

@ -0,0 +1,57 @@
diff -Naur inetutils-1.9.2-orig/.version inetutils-1.9.2/.version
--- inetutils-1.9.2-orig/.version 1970-01-01 03:00:00.000000000 +0300
+++ inetutils-1.9.2/.version 2014-12-12 11:55:14.241600000 +0300
@@ -0,0 +1 @@
+1.9.2
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.996800000 +0300
+++ inetutils-1.9.2/configure.ac 2014-12-12 11:55:14.241600000 +0300
@@ -226,10 +226,15 @@
AC_SUBST(libls_BUILD)
# 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)
@@ -602,7 +607,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 -Naur inetutils-1.9.2-orig/libinetutils/daemon.c inetutils-1.9.2/libinetutils/daemon.c
--- inetutils-1.9.2-orig/libinetutils/daemon.c 2014-12-12 11:55:11.355600000 +0300
+++ inetutils-1.9.2/libinetutils/daemon.c 2014-12-12 11:55:14.241600000 +0300
@@ -56,6 +56,7 @@
#include <stdlib.h>
#include <sys/types.h>
#include <sys/wait.h>
+#include <string.h>
#include <unused-parameter.h>
/*
diff -Naur inetutils-1.9.2-orig/Makefile.am inetutils-1.9.2/Makefile.am
--- inetutils-1.9.2-orig/Makefile.am 2013-09-26 12:36:38.000000000 +0300
+++ inetutils-1.9.2/Makefile.am 2014-12-12 11:55:14.241600000 +0300
@@ -18,6 +18,8 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see `http://www.gnu.org/licenses/'.
+ACLOCAL_AMFLAGS = -I m4 -I am
+
EXTRA_DIST = paths ChangeLog.0 summary.sh.in CHECKLIST
SUBDIRS = lib \

View File

@ -0,0 +1,24 @@
infodir=usr/share/info
filelist="inetutils.info.gz"
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
[ -x usr/bin/install-info ] || return 0
for file in ${filelist}; do
install-info $infodir/$file $infodir/dir 2> /dev/null
done
}
post_upgrade() {
post_install $1
}
pre_remove() {
[ -x usr/bin/install-info ] || return 0
for file in ${filelist}; do
install-info --delete $infodir/$file $infodir/dir 2> /dev/null
done
}

19
inetutils/osockaddr.h Normal file
View File

@ -0,0 +1,19 @@
#ifndef __OSOCKADDR_H__
#define __OSOCKADDR_H__
#ifdef __cplusplus
extern "C" {
#endif
/* 4.3BSD sockaddr structure (used by talk protocol). */
struct osockaddr {
u_short sa_family; /* address family */
char sa_data[14]; /* up to 14 bytes of direct address */
};
#ifdef __cplusplus
}
#endif
#endif /* __OSOCKADDR_H__ */

125
inetutils/talkd.h Normal file
View File

@ -0,0 +1,125 @@
/*
* 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.
*
* @(#)talkd.h 8.1 (Berkeley) 6/2/93
*/
#ifndef _PROTOCOLS_TALKD_H
#define _PROTOCOLS_TALKD_H
/*
* This describes the protocol used by the talk server and clients.
*
* The talk server acts a repository of invitations, responding to
* requests by clients wishing to rendezvous for the purpose of
* holding a conversation. In normal operation, a client, the caller,
* initiates a rendezvous by sending a CTL_MSG to the server of
* type LOOK_UP. This causes the server to search its invitation
* tables to check if an invitation currently exists for the caller
* (to speak to the callee specified in the message). If the lookup
* fails, the caller then sends an ANNOUNCE message causing the server
* to broadcast an announcement on the callee's login ports requesting
* contact. When the callee responds, the local server uses the
* recorded invitation to respond with the appropriate rendezvous
* address and the caller and callee client programs establish a
* stream connection through which the conversation takes place.
*/
#include <sys/types.h>
#include <netinet/in.h>
#ifdef __cplusplus
extern "C" {
#endif
/*
* Client->server request message format.
*/
typedef struct {
u_char vers; /* protocol version */
u_char type; /* request type, see below */
u_char answer; /* not used */
u_char pad;
u_long id_num; /* message id */
struct osockaddr addr; /* old (4.3) style */
struct osockaddr ctl_addr; /* old (4.3) style */
long pid; /* caller's process id */
#define NAME_SIZE 12
char l_name[NAME_SIZE];/* caller's name */
char r_name[NAME_SIZE];/* callee's name */
#define TTY_SIZE 16
char r_tty[TTY_SIZE];/* callee's tty name */
} CTL_MSG;
/*
* Server->client response message format.
*/
typedef struct {
u_char vers; /* protocol version */
u_char type; /* type of request message, see below */
u_char answer; /* respose to request message, see below */
u_char pad;
u_long id_num; /* message id */
struct osockaddr addr; /* address for establishing conversation */
} CTL_RESPONSE;
#define TALK_VERSION 1 /* protocol version */
/* message type values */
#define LEAVE_INVITE 0 /* leave invitation with server */
#define LOOK_UP 1 /* check for invitation by callee */
#define DELETE 2 /* delete invitation by caller */
#define ANNOUNCE 3 /* announce invitation by caller */
/* answer values */
#define SUCCESS 0 /* operation completed properly */
#define NOT_HERE 1 /* callee not logged in */
#define FAILED 2 /* operation failed for unexplained reason */
#define MACHINE_UNKNOWN 3 /* caller's machine name unknown */
#define PERMISSION_DENIED 4 /* callee's tty doesn't permit announce */
#define UNKNOWN_REQUEST 5 /* request has invalid type value */
#define BADVERSION 6 /* request has invalid protocol version */
#define BADADDR 7 /* request has invalid addr value */
#define BADCTLADDR 8 /* request has invalid ctl_addr value */
/*
* Operational parameters.
*/
#define MAX_LIFE 60 /* max time daemon saves invitations */
/* RING_WAIT should be 10's of seconds less than MAX_LIFE */
#define RING_WAIT 30 /* time to wait before resending invitation */
#ifdef __cplusplus
}
#endif
#endif /* !_PROTOCOLS_TALKD_H */

88
inetutils/tftp.h Normal file
View File

@ -0,0 +1,88 @@
/*
* 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_ */