Updates for NetBSD

This commit is contained in:
Michiel Broek
2002-01-27 12:59:38 +00:00
parent 2e4eb31b7e
commit 7750952ad5
4 changed files with 29 additions and 13 deletions

View File

@@ -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

View File

@@ -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
*/