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
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,
-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
])
-STRUCT_UCRED
-
dnl Done! Now write the Makefile and sysdep.h
AC_SUBST(RESOLV)
AC_SUBST(TARGETS)
+++ /dev/null
-/*
- * 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 */
/*
* 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"
*/
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, '(' , ')' );
}
/*