mblogin updates for FreeBSD
This commit is contained in:
parent
202fe3f0b1
commit
ce20472e98
@ -8,6 +8,9 @@
|
||||
/* Memory debugging */
|
||||
#undef MEMWATCH
|
||||
|
||||
/* Define if you have the snprintf function. */
|
||||
#undef HAVE_SNPRINTF
|
||||
|
||||
/* Has strcasestr function */
|
||||
#undef HAVE_STRCASESTR
|
||||
|
||||
@ -340,6 +343,12 @@
|
||||
/* Define if `utime(file, NULL)' sets file's timestamp to the present. */
|
||||
#undef HAVE_UTIME_NULL
|
||||
|
||||
/* Define if you have the <utmp.h> header file. */
|
||||
#undef HAVE_UTMP_H
|
||||
|
||||
/* Define if you have the <utmpx.h> header file. */
|
||||
#undef HAVE_UTMPX_H
|
||||
|
||||
/* Define if you have the <vfork.h> header file. */
|
||||
#undef HAVE_VFORK_H
|
||||
|
||||
|
@ -15,7 +15,7 @@ SRCS = bank.c commonio.c filesub.c language.c mbtoberep.c \
|
||||
door.c dispfile.c userlist.c timestats.c logentry.c pw_util.c \
|
||||
mblogin.c env.c chowntty.c ttytype.c shell.c basename.c \
|
||||
failure.c pwdcheck.c pwauth.c loginprompt.c utmp.c limits.c \
|
||||
setupenv.c sub.c ulimit.c log.c tz.c setugid.c
|
||||
setupenv.c sub.c ulimit.c log.c tz.c setugid.c utent.c
|
||||
HDRS = bank.h commonio.h filesub.h language.h mbsebbs.h misc.h offline.h \
|
||||
putpwent.h salt.h timeout.h bbslist.h email.h fsedit.h lineedit.h \
|
||||
mbstat.h msgutil.h oneline.h sgetpwent.h user.h bye.h morefile.h \
|
||||
@ -26,7 +26,7 @@ HDRS = bank.h commonio.h filesub.h language.h mbsebbs.h misc.h offline.h \
|
||||
door.h dispfile.h userlist.h timestats.h logentry.h lastcallers.h pw_util.h \
|
||||
mblogin.h env.h chowntty.h ttytype.h shell.h basename.h \
|
||||
failure.h pwdcheck.h pwauth.h loginprompt.h utmp.h limits.h \
|
||||
setupenv.h sub.h ulimit.h log.h tz.h setugid.h
|
||||
setupenv.h sub.h ulimit.h log.h tz.h setugid.h utent.h
|
||||
MBSEBBS_OBJS = bank.o bbslist.o chat.o file.o funcs.o mail.o menu.o \
|
||||
misc.o pinfo.o nextuser.o oneline.o page.o fsedit.o \
|
||||
bye.o change.o mbsebbs.o safe.o timeout.o user.o timecheck.o \
|
||||
@ -57,7 +57,7 @@ MBPASSWD_OBJS = mbpasswd.o commonio.o pwio.o shadowio.o sgetpwent.o \
|
||||
xmalloc.o myname.o rad64.o salt.o getdef.o encrypt.o putpwent.o pw_util.o
|
||||
MBLOGIN_OBJS = getdef.o env.o chowntty.o ttytype.o shell.o basename.o failure.o \
|
||||
pwdcheck.o pwauth.o encrypt.o loginprompt.o utmp.o limits.o setupenv.o sub.o \
|
||||
xmalloc.o ulimit.o log.o tz.o setugid.o mblogin.o
|
||||
xmalloc.o ulimit.o log.o tz.o setugid.o utent.o mblogin.o
|
||||
OTHER = Makefile
|
||||
TARGET = mbsebbs mbnewusr mball mblang mbchat mbstat mbtoberep mbuser mbuseradd mbpasswd mblogin
|
||||
|
||||
@ -238,4 +238,5 @@ ulimit.o: ../config.h ulimit.h
|
||||
log.o: ../config.h mblogin.h log.h
|
||||
tz.o: ../config.h mblogin.h getdef.h tz.h
|
||||
setugid.o: ../config.h mblogin.h getdef.h setugid.h
|
||||
utent.o: ../config.h mblogin.h
|
||||
# End of generated dependencies
|
||||
|
@ -138,10 +138,12 @@ int check_logins(const char *name, const char *maxlogins)
|
||||
if (ut->ut_type != USER_PROCESS)
|
||||
continue;
|
||||
#endif
|
||||
#ifndef __FreeBSD__
|
||||
if (ut->ut_user[0] == '\0')
|
||||
continue;
|
||||
if (strncmp(name, ut->ut_user, sizeof(ut->ut_user)) != 0)
|
||||
continue;
|
||||
#endif
|
||||
if (++count > limit)
|
||||
break;
|
||||
}
|
||||
|
@ -37,11 +37,7 @@
|
||||
#include <fcntl.h>
|
||||
#include <time.h>
|
||||
#include "mblogin.h"
|
||||
#if HAVE_LASTLOG_H
|
||||
#include <lastlog.h>
|
||||
#else
|
||||
// #include "lastlog_.h"
|
||||
#endif
|
||||
#include <utmp.h>
|
||||
#include "log.h"
|
||||
|
||||
|
||||
@ -91,7 +87,7 @@ void dolastlog(struct lastlog *ll, const struct passwd *pw, const char *line, co
|
||||
|
||||
time(&newlog.ll_time);
|
||||
strncpy(newlog.ll_line, line, sizeof newlog.ll_line);
|
||||
#if HAVE_LL_HOST
|
||||
#ifdef HAVE_LL_HOST
|
||||
strncpy(newlog.ll_host, host, sizeof newlog.ll_host);
|
||||
#endif
|
||||
if (lseek(fd, offset, SEEK_SET) == offset)
|
||||
|
@ -47,7 +47,7 @@
|
||||
#endif
|
||||
#include <signal.h>
|
||||
#include <unistd.h>
|
||||
#include <lastlog.h>
|
||||
#include <utmp.h>
|
||||
#include "getdef.h"
|
||||
|
||||
#ifdef SVR4_SI86_EUA
|
||||
@ -725,7 +725,9 @@ auth_ok:
|
||||
else
|
||||
failent_user = "UNKNOWN";
|
||||
}
|
||||
#ifndef __FreeBSD__
|
||||
strncpy(failent.ut_user, failent_user, sizeof(failent.ut_user));
|
||||
#endif
|
||||
#ifdef USER_PROCESS
|
||||
failent.ut_type = USER_PROCESS;
|
||||
#endif
|
||||
@ -780,7 +782,11 @@ auth_ok:
|
||||
if (getenv("IFS")) /* don't export user IFS ... */
|
||||
addenv("IFS= \t\n", NULL); /* ... instead, set a safe IFS */
|
||||
|
||||
#ifdef __FreeBSD__
|
||||
setutmp(username, tty); /* make entry in utmp & wtmp files */
|
||||
#else
|
||||
setutmp(username, tty, hostname); /* make entry in utmp & wtmp files */
|
||||
#endif
|
||||
if (pwent.pw_shell[0] == '*') { /* subsystem root */
|
||||
subsystem (&pwent); /* figure out what to execute */
|
||||
subroot++; /* say i was here again */
|
||||
|
114
mbsebbs/utent.c
Normal file
114
mbsebbs/utent.c
Normal file
@ -0,0 +1,114 @@
|
||||
/*****************************************************************************
|
||||
*
|
||||
* $Id$
|
||||
* Purpose ...............: MBSE BBS Shadow Password Suite
|
||||
* Original Source .......: Shadow Password Suite
|
||||
* Original Copyright ....: Julianne Frances Haugh and others.
|
||||
*
|
||||
*****************************************************************************
|
||||
* Copyright (C) 1997-2001
|
||||
*
|
||||
* Michiel Broek FIDO: 2:280/2802
|
||||
* Beekmansbos 10
|
||||
* 1971 BV IJmuiden
|
||||
* the Netherlands
|
||||
*
|
||||
* This file is part of MBSE BBS.
|
||||
*
|
||||
* This BBS is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License as published by the
|
||||
* Free Software Foundation; either version 2, or (at your option) any
|
||||
* later version.
|
||||
*
|
||||
* MBSE BBS 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
|
||||
* General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with MBSE BBS; see the file COPYING. If not, write to the Free
|
||||
* Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*****************************************************************************/
|
||||
|
||||
#include "../config.h"
|
||||
|
||||
#ifndef HAVE_GETUTENT
|
||||
|
||||
#include "mblogin.h"
|
||||
#include <stdio.h>
|
||||
#include <fcntl.h>
|
||||
#include <utmp.h>
|
||||
|
||||
|
||||
static int utmp_fd = -1;
|
||||
static struct utmp utmp_buf;
|
||||
|
||||
/*
|
||||
* setutent - open or rewind the utmp file
|
||||
*/
|
||||
|
||||
void
|
||||
setutent(void)
|
||||
{
|
||||
if (utmp_fd == -1)
|
||||
if ((utmp_fd = open (_UTMP_FILE, O_RDWR)) == -1)
|
||||
utmp_fd = open (_UTMP_FILE, O_RDONLY);
|
||||
|
||||
if (utmp_fd != -1)
|
||||
lseek (utmp_fd, (off_t) 0L, SEEK_SET);
|
||||
}
|
||||
|
||||
/*
|
||||
* endutent - close the utmp file
|
||||
*/
|
||||
|
||||
void
|
||||
endutent(void)
|
||||
{
|
||||
if (utmp_fd != -1)
|
||||
close (utmp_fd);
|
||||
|
||||
utmp_fd = -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* getutent - get the next record from the utmp file
|
||||
*/
|
||||
|
||||
struct utmp *
|
||||
getutent(void)
|
||||
{
|
||||
if (utmp_fd == -1)
|
||||
setutent ();
|
||||
|
||||
if (utmp_fd == -1)
|
||||
return 0;
|
||||
|
||||
if (read (utmp_fd, &utmp_buf, sizeof utmp_buf) != sizeof utmp_buf)
|
||||
return 0;
|
||||
|
||||
return &utmp_buf;
|
||||
}
|
||||
|
||||
/*
|
||||
* getutline - get the utmp entry matching ut_line
|
||||
*/
|
||||
|
||||
struct utmp *
|
||||
getutline(const struct utmp *utent)
|
||||
{
|
||||
struct utmp save;
|
||||
struct utmp *new;
|
||||
|
||||
save = *utent;
|
||||
while (new = getutent ())
|
||||
if (strncmp (new->ut_line, save.ut_line, sizeof new->ut_line))
|
||||
continue;
|
||||
else
|
||||
return new;
|
||||
|
||||
return (struct utmp *) 0;
|
||||
}
|
||||
#else
|
||||
extern int errno; /* warning: ANSI C forbids an empty source file */
|
||||
#endif
|
12
mbsebbs/utent.h
Normal file
12
mbsebbs/utent.h
Normal file
@ -0,0 +1,12 @@
|
||||
|
||||
|
||||
#include "../config.h"
|
||||
|
||||
#ifndef HAVE_GETUTENT
|
||||
|
||||
void setutent(void);
|
||||
void endutent(void);
|
||||
struct utmp *getutent(void);
|
||||
struct utmp *getutline(const struct utmp *utent);
|
||||
|
||||
#endif
|
@ -427,7 +427,9 @@ setutmp(const char *name, const char *line)
|
||||
* while System V has the name, PID and a type.
|
||||
*/
|
||||
|
||||
#ifndef __FreeBSD__
|
||||
strncpy(utmp.ut_user, name, sizeof utent.ut_user);
|
||||
#endif
|
||||
#ifdef USER_PROCESS
|
||||
utmp.ut_type = USER_PROCESS;
|
||||
utmp.ut_pid = getpid ();
|
||||
|
@ -16,6 +16,12 @@ static void updwtmpx(const char *, const struct utmpx *);
|
||||
#endif /* ! HAVE_UPDWTMPX */
|
||||
#endif /* ! HAVE_UTMPX_H */
|
||||
|
||||
#if defined(__linux__) /* XXX */
|
||||
void setutmp(const char *, const char *, const char *);
|
||||
#elif HAVE_UTMPX_H
|
||||
void setutmp(const char *, const char *, const char *);
|
||||
#else /* !SVR4 */
|
||||
void setutmp(const char *, const char *);
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
@ -74,7 +74,7 @@ grlist.o: ../lib/libs.h ../lib/structs.h ../lib/common.h ../lib/clcomm.h screen.
|
||||
m_domain.o: ../lib/libs.h ../lib/structs.h ../lib/records.h ../lib/common.h ../lib/clcomm.h screen.h mutil.h ledit.h m_global.h m_menu.h m_domain.h
|
||||
m_fgroup.o: ../lib/libs.h ../lib/structs.h ../lib/records.h ../lib/common.h ../lib/clcomm.h screen.h mutil.h ledit.h stlist.h m_global.h m_node.h m_ticarea.h m_fgroup.h
|
||||
m_lang.o: ../lib/libs.h ../lib/structs.h ../lib/records.h ../lib/common.h ../lib/clcomm.h screen.h mutil.h ledit.h stlist.h m_global.h m_lang.h
|
||||
m_marea.o: ../lib/libs.h ../lib/structs.h ../lib/records.h ../lib/common.h ../lib/clcomm.h screen.h mutil.h ledit.h grlist.h m_global.h m_node.h m_mgroup.h m_marea.h
|
||||
m_marea.o: ../lib/libs.h ../lib/structs.h ../lib/records.h ../lib/common.h ../lib/clcomm.h ../lib/msg.h screen.h mutil.h ledit.h grlist.h m_global.h m_node.h m_mgroup.h m_marea.h
|
||||
m_new.o: ../lib/libs.h ../lib/structs.h ../lib/records.h ../lib/common.h ../lib/clcomm.h screen.h mutil.h ledit.h stlist.h m_global.h grlist.h m_new.h m_lang.h m_marea.h m_ngroup.h
|
||||
m_protocol.o: ../lib/libs.h ../lib/structs.h ../lib/records.h ../lib/clcomm.h ../lib/common.h screen.h mutil.h ledit.h stlist.h m_global.h m_protocol.h
|
||||
m_ticarea.o: ../lib/libs.h ../lib/structs.h ../lib/records.h ../lib/common.h ../lib/clcomm.h screen.h mutil.h ledit.h stlist.h grlist.h m_global.h m_node.h m_fgroup.h m_farea.h m_archive.h m_ticarea.h
|
||||
|
Reference in New Issue
Block a user