From 7750952ad5ad9a69e5e587fa8c1c736bcfd7c105 Mon Sep 17 00:00:00 2001 From: Michiel Broek Date: Sun, 27 Jan 2002 12:59:38 +0000 Subject: [PATCH] Updates for NetBSD --- mbsebbs/mbnewusr.c | 8 ++++++-- mbsebbs/mbsebbs.c | 24 +++++++++++++++--------- mbtask/mbtask.c | 4 ++-- unix/pw_util.c | 6 ++++++ 4 files changed, 29 insertions(+), 13 deletions(-) diff --git a/mbsebbs/mbnewusr.c b/mbsebbs/mbnewusr.c index ece08c2f..a486382c 100644 --- a/mbsebbs/mbnewusr.c +++ b/mbsebbs/mbnewusr.c @@ -87,8 +87,12 @@ int main(int argc, char **argv) #endif exit(1); } - if ((setuid(pw->pw_uid) == -1) || (setgid(pw->pw_gid) == -1)) { - perror("Can't setuid() or setgid() to \"mbse\" user"); + + /* + * Set effective user to mbse.bbs + */ + if ((seteuid(pw->pw_uid) == -1) || (setegid(pw->pw_gid) == -1)) { + perror("Can't seteuid() or setegid() to \"mbse\" user"); #ifdef MEMWATCH mwTerm(); #endif diff --git a/mbsebbs/mbsebbs.c b/mbsebbs/mbsebbs.c index c9830b41..3dcb55c3 100644 --- a/mbsebbs/mbsebbs.c +++ b/mbsebbs/mbsebbs.c @@ -66,6 +66,19 @@ int main(int argc, char **argv) pTTY = calloc(15, sizeof(char)); tty = ttyname(1); + /* + * Find username from the environment + */ + sUnixName[0] = '\0'; + if (getenv("LOGNAME") != NULL) { + strcpy(sUnixName, getenv("LOGNAME")); + } else if (getenv("USER") != NULL) { + strcpy(sUnixName, getenv("USER")); + } else { + WriteError("No username in environment"); + Quick_Bye(0); + } + /* * Set the users device to writable by other bbs users, so they * can send one-line messages @@ -90,7 +103,8 @@ int main(int argc, char **argv) * Initialize this client with the server. */ do_quiet = TRUE; - InitClient(getenv("LOGNAME"), (char *)"mbsebbs", (char *)"Unknown", CFG.logfile, CFG.bbs_loglevel, CFG.error_log); + InitClient(sUnixName, (char *)"mbsebbs", (char *)"Unknown", + CFG.logfile, CFG.bbs_loglevel, CFG.error_log); IsDoing("Loging in"); Syslog(' ', " "); @@ -102,14 +116,6 @@ int main(int argc, char **argv) if (!strncmp(p, "none", 4)) Syslog('+', "CALLER %s", p); - sUnixName[0] = '\0'; - if (getenv("LOGNAME") != NULL) { - strcpy(sUnixName, getenv("LOGNAME")); - } else { - WriteError("No username in environment"); - Quick_Bye(0); - } - /* * Initialize */ diff --git a/mbtask/mbtask.c b/mbtask/mbtask.c index 6e3db087..3def8556 100644 --- a/mbtask/mbtask.c +++ b/mbtask/mbtask.c @@ -215,7 +215,7 @@ void load_maincfg(void) /* * New Users */ - CFG.newuser_access.level = 5; + CFG.newuser_access.level = 20; CFG.iCapUserName = TRUE; CFG.iAnsi = TRUE; CFG.iDataPhone = TRUE; @@ -225,7 +225,7 @@ void load_maincfg(void) CFG.iLocation = TRUE; CFG.iHotkeys = TRUE; CFG.iCapLocation = FALSE; - CFG.AskAddress = FALSE; + CFG.AskAddress = TRUE; CFG.GiveEmail = TRUE; /* diff --git a/unix/pw_util.c b/unix/pw_util.c index 45f233e5..e92c9e8e 100644 --- a/unix/pw_util.c +++ b/unix/pw_util.c @@ -195,7 +195,13 @@ int pw_mkdb(char *username) execl(_PATH_PWD_MKDB, "pwd_mkdb", "-p", tempname, NULL); } else { syslog(LOG_WARNING, "updating the database for %s...", username); +#ifdef __FreeBSD__ execl(_PATH_PWD_MKDB, "pwd_mkdb", "-p", "-u", username, tempname, NULL); +#elif __NetBSD__ + execl(_PATH_PWD_MKDB, "pwd_mkdb", "-p", tempname, NULL); +#else +#error "Not FreeBSD or NetBSD - don't know what to do" +#endif } pw_error((char *)_PATH_PWD_MKDB, 1, 1); }