Updates for mblogin FreeBSD port

This commit is contained in:
Michiel Broek 2002-01-06 13:24:23 +00:00
parent 1e6a95c4b8
commit aaae44dbd9
10 changed files with 2450 additions and 4591 deletions

View File

@ -65,6 +65,8 @@
/* Defined if it includes *Pw functions. */ /* Defined if it includes *Pw functions. */
#undef HAVE_LIBCRACK_PW #undef HAVE_LIBCRACK_PW
/* Defined if you have libutil.h */
#undef HAVE_LIBUTIL_H
/* Defined if it includes *Pw functions. */ /* Defined if it includes *Pw functions. */
#undef HAVE_LIBCRACK_PW #undef HAVE_LIBCRACK_PW

6813
configure vendored

File diff suppressed because it is too large Load Diff

View File

@ -114,6 +114,12 @@ if test "$result" = "yes"; then
AC_CHECK_HEADERS(crypt.h) AC_CHECK_HEADERS(crypt.h)
fi fi
AC_CHECK_LIB(util,login,result=yes,result=no)
if test "$result" = "yes"; then
LIBS="$LIBS -lutil"
AC_CHECK_HEADERS(libutil.h)
fi
dnl Checks for header files. dnl Checks for header files.
AC_HEADER_STDC AC_HEADER_STDC
AC_HEADER_DIRENT AC_HEADER_DIRENT

View File

@ -7,17 +7,17 @@ include ../Makefile.global
SRCS = commonio.c putpwent.c salt.c sgetpwent.c xmalloc.c myname.c encrypt.c \ SRCS = commonio.c putpwent.c salt.c sgetpwent.c xmalloc.c myname.c encrypt.c \
pwio.c shadowio.c mbpasswd.c mbuseradd.c rad64.c getdef.c pw_util.c \ pwio.c shadowio.c mbpasswd.c mbuseradd.c rad64.c getdef.c pw_util.c \
mblogin.c env.c chowntty.c shell.c basename.c pwdcheck.c pwauth.c \ mblogin.c env.c chowntty.c shell.c basename.c pwdcheck.c pwauth.c \
loginprompt.c utmp.c limits.c setupenv.c sub.c log.c setugid.c utent.c loginprompt.c utmp.c limits.c setupenv.c sub.c log.c setugid.c
HDRS = commonio.h putpwent.h salt.h sgetpwent.h xmalloc.h myname.h encrypt.h \ HDRS = commonio.h putpwent.h salt.h sgetpwent.h xmalloc.h myname.h encrypt.h \
pwio.h shadowio.h mbpasswd.h mbuseradd.h rad64.h getdef.h pw_util.h \ pwio.h shadowio.h mbpasswd.h mbuseradd.h rad64.h getdef.h pw_util.h \
mblogin.h env.h chowntty.h shell.h basename.h pwdcheck.h pwauth.h \ mblogin.h env.h chowntty.h shell.h basename.h pwdcheck.h pwauth.h \
loginprompt.h utmp.h limits.h setupenv.h sub.h log.h setugid.h utent.h loginprompt.h utmp.h limits.h setupenv.h sub.h log.h setugid.h
MBUSERADD_OBJS = mbuseradd.o MBUSERADD_OBJS = mbuseradd.o
MBPASSWD_OBJS = mbpasswd.o commonio.o pwio.o shadowio.o sgetpwent.o \ 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 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 shell.o basename.o pwdcheck.o pwauth.o encrypt.o \ MBLOGIN_OBJS = getdef.o env.o chowntty.o shell.o basename.o pwdcheck.o pwauth.o encrypt.o \
loginprompt.o utmp.o limits.o setupenv.o sub.o xmalloc.o log.o setugid.o \ loginprompt.o utmp.o limits.o setupenv.o sub.o xmalloc.o log.o setugid.o \
utent.o mblogin.o mblogin.o
OTHER = Makefile login.defs.in OTHER = Makefile login.defs.in
TARGET = mbuseradd mbpasswd mblogin TARGET = mbuseradd mbpasswd mblogin
@ -112,5 +112,4 @@ setupenv.o: ../config.h mblogin.h getdef.h xmalloc.h env.h setupenv.h
sub.o: ../config.h mblogin.h sub.h sub.o: ../config.h mblogin.h sub.h
log.o: ../config.h mblogin.h log.h log.o: ../config.h mblogin.h log.h
setugid.o: ../config.h mblogin.h getdef.h setugid.h setugid.o: ../config.h mblogin.h getdef.h setugid.h
utent.o: ../config.h mblogin.h
# End of generated dependencies # End of generated dependencies

View File

@ -1,7 +1,7 @@
/* $Id$ */ /* $Id$ */
#ifndef _LIMITS_H_ #ifndef _LIMITS_H_H
#define _LIMITS_H_ #define _LIMITS_H_H
void setup_limits(const struct passwd *); void setup_limits(const struct passwd *);

View File

@ -12,7 +12,8 @@
# #
# #
# Allow user "mbse" to login and get a shell. # Allow user "mbse" to login and get a shell. You better leave this to "no"
# and install ssh if you want to login using a shell.
# #
ALLOW_MBSE no ALLOW_MBSE no
@ -47,7 +48,7 @@ LOG_UNKFAIL_ENAB no
LOG_OK_LOGINS no LOG_OK_LOGINS no
# #
# Enable logging and display of /var/log/lastlog login time info. # Enable logging of lastlog login time info.
# #
LASTLOG_ENAB yes LASTLOG_ENAB yes

View File

@ -42,12 +42,11 @@
#endif #endif
#if HAVE_UTMPX_H #if HAVE_UTMPX_H
#include <utmpx.h> #include <utmpx.h>
#else
#include <utmp.h>
#endif #endif
#include <utmp.h>
#include <signal.h> #include <signal.h>
#include <unistd.h> #include <unistd.h>
#include <utmp.h> #include <ctype.h>
#include "getdef.h" #include "getdef.h"
#ifdef SVR4_SI86_EUA #ifdef SVR4_SI86_EUA
@ -377,8 +376,6 @@ int main(int argc, char **argv)
*/ */
wipe_clear_pass = 0; wipe_clear_pass = 0;
#endif #endif
printf("\nMBSE BBS v%s\n", VERSION);
printf("%s\n\n", COPYRIGHT);
/* /*
* Some quick initialization. * Some quick initialization.
@ -427,6 +424,14 @@ int main(int argc, char **argv)
if (!isatty(0) || !isatty(1) || !isatty(2)) if (!isatty(0) || !isatty(1) || !isatty(2))
exit(1); /* must be a terminal */ exit(1); /* must be a terminal */
if (hflg) {
/*
* Only show this before a prompt from telnetd
*/
printf("\nMBSE BBS v%s\n", VERSION);
printf("%s\n\n", COPYRIGHT);
}
/* /*
* Be picky if run by normal users (possible if installed setuid * Be picky if run by normal users (possible if installed setuid
* root), but not if run by root. This way it still allows logins * root), but not if run by root. This way it still allows logins
@ -586,11 +591,16 @@ top:
* Here we try usernames on unix names and Fidonet style * Here we try usernames on unix names and Fidonet style
* names that are stored in the bbs userdatabase. * names that are stored in the bbs userdatabase.
* The name "bbs" is for new users, don't check the bbs userfile. * The name "bbs" is for new users, don't check the bbs userfile.
* If allowed from login.defs accept the name "mbse".
*/ */
if (strcmp(username, "bbs") == 0) { FoundName = 0;
if (strcmp(username, getdef_str("NEWUSER_ACCOUNT")) == 0) {
FoundName = 1; FoundName = 1;
} else { }
FoundName = 0; if ((getdef_bool("ALLOW_MBSE") != 0) && (strcmp(username, "mbse") == 0)) {
FoundName = 1;
}
if (! FoundName) {
if ((ufp = fopen(userfile, "r"))) { if ((ufp = fopen(userfile, "r"))) {
fread(&usrconfighdr, sizeof(usrconfighdr), 1, ufp); fread(&usrconfighdr, sizeof(usrconfighdr), 1, ufp);
while (fread(&usrconfig, usrconfighdr.recsize, 1, ufp) == 1) { while (fread(&usrconfig, usrconfighdr.recsize, 1, ufp) == 1) {
@ -606,6 +616,22 @@ top:
} }
} }
if (!FoundName) {
if (getdef_bool("ASK_NEWUSER") != 0) {
/*
* User entered none excisting name, offer him/her the choice
* to register as a new user.
*/
login_prompt(_("Do you want to register as new user? [y/N]: "), username, sizeof username);
if ((username[0] && (toupper(username[0]) == 'Y'))) {
FoundName = 1;
preauth_flag = 0;
STRFCPY(username, getdef_str("NEWUSER_ACCOUNT"));
syslog(LOG_WARNING, "unknown user wants to register");
}
}
}
if ((! (pwd = getpwnam(username))) || (FoundName == 0)) { if ((! (pwd = getpwnam(username))) || (FoundName == 0)) {
pwent.pw_name = username; pwent.pw_name = username;
strcpy(temp_pw, "!"); strcpy(temp_pw, "!");
@ -714,11 +740,8 @@ auth_ok:
if (getenv("IFS")) /* don't export user IFS ... */ if (getenv("IFS")) /* don't export user IFS ... */
addenv("IFS= \t\n", NULL); /* ... instead, set a safe 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 */ setutmp(username, tty, hostname); /* make entry in utmp & wtmp files */
#endif
if (pwent.pw_shell[0] == '*') { /* subsystem root */ if (pwent.pw_shell[0] == '*') { /* subsystem root */
subsystem (&pwent); /* figure out what to execute */ subsystem (&pwent); /* figure out what to execute */
subroot++; /* say i was here again */ subroot++; /* say i was here again */
@ -816,7 +839,6 @@ auth_ok:
syslog(LOG_INFO, REG_LOGIN, username, fromhost); syslog(LOG_INFO, REG_LOGIN, username, fromhost);
closelog(); closelog();
sleep(3);
shell (pwent.pw_shell, (char *) 0); /* exec the shell finally. */ shell (pwent.pw_shell, (char *) 0); /* exec the shell finally. */
/*NOTREACHED*/ /*NOTREACHED*/
return 0; return 0;

View File

@ -61,6 +61,8 @@ int pw_auth(const char *cipher, const char *user, int reason, const char *input)
const char *cp; const char *cp;
int retval; int retval;
printf("\n%s %s %d %s\n", cipher, user, reason, input);
/* /*
* There are programs for adding and deleting authentication data. * There are programs for adding and deleting authentication data.
*/ */

View File

@ -38,6 +38,11 @@
#include <utmpx.h> #include <utmpx.h>
#endif #endif
#ifdef __FreeBSD__
#include <sys/types.h>
#include <libutil.h>
#endif
#include <fcntl.h> #include <fcntl.h>
#include <stdio.h> #include <stdio.h>
#include "utmp.h" #include "utmp.h"
@ -70,8 +75,7 @@ extern struct utmp utent;
#if defined(__linux__) /* XXX */ #if defined(__linux__) /* XXX */
void void checkutmp(int picky)
checkutmp(int picky)
{ {
char *line; char *line;
struct utmp *ut; struct utmp *ut;
@ -113,14 +117,14 @@ checkutmp(int picky)
#elif defined(LOGIN_PROCESS) #elif defined(LOGIN_PROCESS)
void void checkutmp(int picky)
checkutmp(int picky)
{ {
char *line; char *line;
struct utmp *ut; struct utmp *ut;
#if HAVE_UTMPX_H #if HAVE_UTMPX_H
struct utmpx *utx; struct utmpx *utx;
#endif #endif
pid_t pid = getpid(); pid_t pid = getpid();
#if HAVE_UTMPX_H #if HAVE_UTMPX_H
@ -208,8 +212,10 @@ checkutmp(int picky)
#else /* !USG */ #else /* !USG */
void /*
checkutmp(int picky) * Also used for FreeBSD
*/
void checkutmp(int picky)
{ {
char *line; char *line;
@ -252,8 +258,7 @@ void updwtmp(const char *filename, const struct utmp *ut)
#ifdef HAVE_UTMPX_H #ifdef HAVE_UTMPX_H
#ifndef HAVE_UPDWTMPX #ifndef HAVE_UPDWTMPX
static void static void updwtmpx(const char *filename, const struct utmpx *utx)
updwtmpx(const char *filename, const struct utmpx *utx)
{ {
int fd; int fd;
@ -276,8 +281,7 @@ updwtmpx(const char *filename, const struct utmpx *utx)
#if defined(__linux__) /* XXX */ #if defined(__linux__) /* XXX */
void void setutmp(const char *name, const char *line, const char *host)
setutmp(const char *name, const char *line, const char *host)
{ {
utent.ut_type = USER_PROCESS; utent.ut_type = USER_PROCESS;
strncpy(utent.ut_user, name, sizeof utent.ut_user); strncpy(utent.ut_user, name, sizeof utent.ut_user);
@ -291,14 +295,14 @@ setutmp(const char *name, const char *line, const char *host)
#elif HAVE_UTMPX_H #elif HAVE_UTMPX_H
void void setutmp(const char *name, const char *line, const char *host)
setutmp(const char *name, const char *line, const char *host)
{ {
struct utmp *utmp, utline; struct utmp *utmp, utline;
struct utmpx *utmpx, utxline; struct utmpx *utmpx, utxline;
pid_t pid = getpid (); pid_t pid = getpid ();
int found_utmpx = 0, found_utmp = 0; int found_utmpx = 0, found_utmp = 0;
printf("setutmp HAVE_UTMP_H\n");
/* /*
* The canonical device name doesn't include "/dev/"; skip it * The canonical device name doesn't include "/dev/"; skip it
* if it is already there. * if it is already there.
@ -385,10 +389,30 @@ setutmp(const char *name, const char *line, const char *host)
utent = utline; utent = utline;
} }
#elif __FreeBSD__
/*
* FreeBSD version, simple and mean.
*/
void setutmp(const char *name, const char *line, const char *host)
{
struct utmp utmp;
memset(&utmp, 0, sizeof(utmp));
strncpy(utmp.ut_line, line, (int) sizeof utmp.ut_line);
strncpy(utmp.ut_name, name, sizeof utent.ut_name);
strncpy(utmp.ut_host, host, sizeof utent.ut_host);
(void) time (&utmp.ut_time);
login(&utmp);
utent = utmp;
}
#else /* !SVR4 */ #else /* !SVR4 */
void void setutmp(const char *name, const char *line)
setutmp(const char *name, const char *line)
{ {
struct utmp utmp; struct utmp utmp;
int fd; int fd;
@ -420,9 +444,7 @@ setutmp(const char *name, const char *line)
* while System V has the name, PID and a type. * while System V has the name, PID and a type.
*/ */
#ifndef __FreeBSD__
strncpy(utmp.ut_user, name, sizeof utent.ut_user); strncpy(utmp.ut_user, name, sizeof utent.ut_user);
#endif
#ifdef USER_PROCESS #ifdef USER_PROCESS
utmp.ut_type = USER_PROCESS; utmp.ut_type = USER_PROCESS;
utmp.ut_pid = getpid (); utmp.ut_pid = getpid ();

View File

@ -20,6 +20,8 @@ static void updwtmpx(const char *, const struct utmpx *);
void setutmp(const char *, const char *, const char *); void setutmp(const char *, const char *, const char *);
#elif HAVE_UTMPX_H #elif HAVE_UTMPX_H
void setutmp(const char *, const char *, const char *); void setutmp(const char *, const char *, const char *);
#elif __FreeBSD__
void setutmp(const char *, const char *, const char *);
#else /* !SVR4 */ #else /* !SVR4 */
void setutmp(const char *, const char *); void setutmp(const char *, const char *);
#endif #endif