bug-inetutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug-inetutils] On logwtmp and ftpd, rlogind, and uucpd.


From: Mats Erik Andersson
Subject: Re: [bug-inetutils] On logwtmp and ftpd, rlogind, and uucpd.
Date: Thu, 24 Nov 2011 00:29:01 +0100
User-agent: Mutt/1.5.18 (2008-05-17)

tisdag den 22 november 2011 klockan 11:58 skrev Mats Erik Andersson detta:
> Dear all,
> 
> we have presently two implementations of logwtmp():
> 
>    libinetutils/logwtmpko.c
> 
>    ftpd/logwtmp.c
> 
> both building a "keep open" variant. Then there is
> a backing code
> 
>    libinetutils/logwtmp.c
> 
> which is written to build either "keep open" or "standard".

In fact "ftpd/logwtmp.c" is dead code since at least two
years time! It is included at linking time into "ftpd",
but is never ever used, since the relevant code is brought
in from the relevent libc and from libinetutils.

The patch suggestion exposed below is removing the compilation
and linking of "fTpd/logwtmp.c", and also inserts a minimal code
to bridge the gap to successfully build "uucpd" also under Solaris.
(Observe that also "libinetutils/cleansess.o" demands an instance
of logwtmp(), which would otherwise not be available in Solaris.)

I have test built this with success on GN/kFreeBSD, OpenBSD, and
GNU/OpenSolaris. Feel free to modify the suggestion for a better fit.
Can we leave "ftpd/logwtmp.c" as a relikt for the time being?

Best regards,
  Mats


diff --git a/ftpd/Makefile.am b/ftpd/Makefile.am
index b97d7f5..79c1c5a 100644
--- a/ftpd/Makefile.am
+++ b/ftpd/Makefile.am
@@ -23,7 +23,7 @@ inetdaemon_PROGRAMS = @ftpd_BUILD@
 
 EXTRA_PROGRAMS = ftpd
 
-ftpd_SOURCES = ftpcmd.y ftpd.c logwtmp.c popen.c pam.c auth.c \
+ftpd_SOURCES = ftpcmd.y ftpd.c popen.c pam.c auth.c \
                conf.c server_mode.c
 
 noinst_HEADERS = extern.h
diff --git a/libinetutils/logwtmpko.c b/libinetutils/logwtmpko.c
index 2818304..3e1d91c 100644
--- a/libinetutils/logwtmpko.c
+++ b/libinetutils/logwtmpko.c
@@ -19,5 +19,43 @@
 
 #include <config.h>
 
+#if HAVE_UTMPX_H && defined SOLARIS
+# include <utmpx.h>    /* updwtmp() */
+#endif
+
 #define KEEP_OPEN
 #include "logwtmp.c"
+
+/* Solaris does not provide logwtmp(3c).
+ * It is needed in addition to logwtmp_keep_open().
+ */
+#if HAVE_UPDWTMP && defined SOLARIS
+void
+logwtmp (char *line, char *name, char *host)
+{
+  struct utmp ut;
+#ifdef HAVE_STRUCT_UTMP_UT_TV
+  struct timeval tv;
+#endif
+
+  memset (&ut, 0, sizeof (ut));
+#ifdef HAVE_STRUCT_UTMP_UT_TYPE
+  ut.ut_type = USER_PROCESS;
+#endif
+  strncpy (ut.ut_line, line, sizeof ut.ut_line);
+  strncpy (ut.ut_name, name, sizeof ut.ut_name);
+#ifdef HAVE_STRUCT_UTMP_UT_HOST
+  strncpy (ut.ut_host, host, sizeof ut.ut_host);
+#endif
+
+# ifdef HAVE_STRUCT_UTMP_UT_TV
+  gettimeofday (&tv, NULL);
+  ut.ut_tv.tv_sec = tv.tv_sec;
+  ut.ut_tv.tv_usec = tv.tv_usec;
+# else
+  time (&ut.ut_time);
+# endif
+
+  updwtmp (PATH_WTMP, &ut);
+}
+#endif /* HAVE_UPDWTMP && defined SOLARIS */



reply via email to

[Prev in Thread] Current Thread [Next in Thread]