Continued the war against cruft. Don't touch utmp anymore; always use the output...
authorArt Cancro <ajc@citadel.org>
Sun, 24 Apr 2016 17:38:57 +0000 (13:38 -0400)
committerArt Cancro <ajc@citadel.org>
Sun, 24 Apr 2016 17:38:57 +0000 (13:38 -0400)
textclient/configure.ac
textclient/src/getutline.c [deleted file]
textclient/src/routines.c

index daee0dc2c828b98962a97803e41eadce568da158..a979aa5d71cc8fee7f1b9b0f9d6903f51fc91d62 100644 (file)
@@ -642,7 +642,7 @@ dnl
 dnl TODO: for the DB header checks, we should check whether the headers
 dnl define db_env_create, somehow
 dnl
-AC_CHECK_HEADERS(dl.h fcntl.h limits.h malloc.h termios.h sys/ioctl.h sys/select.h sys/stat.h sys/time.h sys/prctl.h syslog.h unistd.h utmp.h utmpx.h paths.h db.h db4/db.h pthread.h netinet/in.h arpa/nameser.h arpa/nameser_compat.h syscall.h sys/syscall.h)
+AC_CHECK_HEADERS(dl.h fcntl.h limits.h malloc.h termios.h sys/ioctl.h sys/select.h sys/stat.h sys/time.h sys/prctl.h syslog.h unistd.h paths.h db.h db4/db.h pthread.h netinet/in.h arpa/nameser.h arpa/nameser_compat.h syscall.h sys/syscall.h)
 
 AC_CHECK_HEADER(resolv.h,AC_DEFINE(HAVE_RESOLV_H, [], [define this if you have the resolv.h header file.]),,
 [#ifdef HAVE_SYS_TYPES_H
@@ -665,14 +665,6 @@ AC_HEADER_TIME
 dnl defined in acinclude.m4:
 CIT_STRUCT_TM
 
-AC_CACHE_CHECK([for ut_type in struct utmp], ac_cv_struct_ut_type,
-[AC_TRY_COMPILE([#include <sys/types.h>
-#include <utmp.h>], [struct utmp ut; ut.ut_type;],
-ac_cv_struct_ut_type=yes, ac_cv_struct_ut_type=no)])
-if test $ac_cv_struct_ut_type = yes; then
-       AC_DEFINE(HAVE_UT_TYPE, [], [define this if struct utmp has an ut_type member])
-fi
-
 AC_CACHE_CHECK(
        [for call semantics from getpwuid_r], 
        ac_cv_call_getpwuid_r,
@@ -735,20 +727,12 @@ esac
 
 
 
-AC_CACHE_CHECK([for ut_host in struct utmp], ac_cv_struct_ut_host,
-[AC_TRY_COMPILE([#include <sys/types.h>
-#include <utmp.h>], [struct utmp ut; ut.ut_host;],
-ac_cv_struct_ut_host=yes, ac_cv_struct_ut_host=no)])
-if test $ac_cv_struct_ut_host = yes; then
-       AC_DEFINE(HAVE_UT_HOST, [], [define this if struct utmp has an ut_host member])
-fi
-
 dnl Checks for library functions.
 AC_FUNC_GETPGRP
 AC_PROG_GCC_TRADITIONAL
 AC_TYPE_SIGNAL
 AC_FUNC_VPRINTF
-AC_CHECK_FUNCS(getspnam getutxline mkdir mkfifo mktime rmdir select socket strerror strcasecmp strncasecmp)
+AC_CHECK_FUNCS(getspnam mkdir mkfifo mktime rmdir select socket strerror strcasecmp strncasecmp)
 
 dnl Now check for pthreads
 
@@ -832,8 +816,6 @@ AC_CACHE_CHECK([under the bed], ac_cv_under_the_bed, [
        ])
 
 
-STRUCT_UCRED
-
 dnl Done! Now write the Makefile and sysdep.h
 AC_SUBST(RESOLV)
 AC_SUBST(TARGETS)
diff --git a/textclient/src/getutline.c b/textclient/src/getutline.c
deleted file mode 100644 (file)
index 7c6b78e..0000000
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * getutline.c: not-quite-compatible replacement for getutline(3)
- * by nathan bryant, feb 1999
- */
-
-#include "sysdep.h"
-#ifdef HAVE_UTMP_H
-#include <stdio.h>
-#include <sys/types.h>
-#include <utmp.h>
-#ifdef HAVE_PATHS_H
-#include <paths.h>
-#endif
-#include <string.h>
-
-struct utmp *getutline(struct utmp *ut)
-{
-  static struct utmp retval;
-  FILE *utmp;
-
-#ifdef UTMP_FILE
-  if ((utmp = fopen(UTMP_FILE, "rb")) == NULL)
-#else
-  if ((utmp = fopen(_PATH_UTMP, "rb")) == NULL)
-#endif
-    return NULL;
-
-  do
-    if (!fread(&retval, sizeof retval, 1, utmp))
-      {
-       fclose(utmp);
-       return NULL;
-      }
-  while (strcmp(ut->ut_line, retval.ut_line));
-
-  fclose(utmp);
-  return &retval;
-}
-#endif /* HAVE_UTMP_H */
index 3ec4a3c9860630f3ad05e5c97bf81e0c990cc57f..856475911db64986b97639edb7f043bb5522ad90 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * Client-side support functions.
  *
- * Copyright (c) 1987-2012 by the citadel.org team
+ * Copyright (c) 1987-2016 by the citadel.org team
  *
  *  This program is open source software; you can redistribute it and/or modify
  *  it under the terms of the GNU General Public License version 3.
 #ifdef HAVE_LIMITS_H
 #include <limits.h>
 #endif
-#ifdef HAVE_UTMP_H
-#include <utmp.h>
-#endif
-#ifdef HAVE_UTMPX_H
-#include <utmpx.h>
-#endif
 
 #include <libcitadel.h>
-///#include "citadel.h"
 #include "citadel_ipc.h"
 #include "screen.h"
 
-#ifndef HAVE_GETUTLINE
-struct utmp *getutline(struct utmp *ut);
-#endif
-
 #define ROUTINES_C
 
-///#include "citadel.h"
 #include "routines.h"
 #include "commands.h"
 #include "citadel_decls.h"
@@ -462,79 +450,14 @@ void progress(CtdlIPC* ipc, unsigned long curr, unsigned long cmax)
  */
 void locate_host(CtdlIPC* ipc, char *hbuf)
 {
-#ifndef HAVE_UTMP_H
-       char buf[SIZ];
-       FILE *who;
-       int a,b;
-
-       who = (FILE *)popen("who am i","r");
+       FILE *who = (FILE *)popen("who am i","r");
        if (who==NULL) {
                strcpy(hbuf, ipc->ServInfo.fqdn);
                return; 
        }
-       fgets(buf,sizeof buf,who);
+       fgets(hbuf, SIZ, who);
        pclose(who);
-
-       b = 0;
-       for (a=0; !IsEmptyStr(&buf[a]); ++a) {
-               if ((buf[a]=='(')||(buf[a]==')')) ++b;
-       }
-       if (b<2) {
-               strcpy(hbuf, ipc->ServInfo.fqdn);
-               return;
-       }
-
-       for (a=0; a<strlen(buf); ++a) {
-               if (buf[a]=='(') {
-                       strcpy(buf,&buf[a+1]);
-               }
-       }
-       for (a=0; a<strlen(buf); ++a) {
-               if (buf[a]==')') buf[a] = 0;
-       }
-
-       if (IsEmptyStr(buf)) strcpy(hbuf, ipc->ServInfo.fqdn);
-       else strncpy(hbuf,buf,24);
-#else
-       char *tty = ttyname(0);
-#ifdef HAVE_GETUTXLINE
-       struct utmpx ut, *put;
-#else
-       struct utmp ut, *put;
-#endif
-
-       if (tty == NULL) {
-           fail:
-               safestrncpy(hbuf, ipc->ServInfo.fqdn, 24);
-               return;
-       }
-
-       if (strncmp(tty, "/dev/", 5))
-               goto fail;
-
-       safestrncpy(ut.ut_line, &tty[5], sizeof ut.ut_line);
-
-#ifdef HAVE_GETUTXLINE /* Solaris uses this */
-       if ((put = getutxline(&ut)) == NULL)
-#else
-       if ((put = getutline(&ut)) == NULL)
-#endif
-               goto fail;
-
-#if defined(HAVE_UT_TYPE) || defined(HAVE_GETUTXLINE)
-       if (put->ut_type == USER_PROCESS) {
-#endif
-#if defined(HAVE_UT_HOST) || defined(HAVE_GETUTXLINE)
-               if (*put->ut_host)
-                       safestrncpy(hbuf, put->ut_host, 24);
-               else
-#endif
-                       safestrncpy(hbuf, put->ut_line, 24);
-#if defined(HAVE_UT_TYPE) || defined(HAVE_GETUTXLINE)
-       }
-       else goto fail;
-#endif
-#endif /* HAVE_UTMP_H */
+       stripallbut(hbuf, '(' , ')' );
 }
 
 /*