add USER-authentication support

git-svn-id: svn://katsu.triplehelix.org/dgamelaunch/trunk@291 db0b04b0-f4d1-0310-9a6d-de3e77497b0e
This commit is contained in:
Joshua Kwan 2004-06-12 00:11:18 +00:00
parent 9937d763bf
commit 1a36469589
3 changed files with 39 additions and 2 deletions

View File

@ -1,4 +1,4 @@
1.4.5 (????/??/??)
1.4.5 (2004/06/11)
* Reset offset if necessary to show at least one game to avoid things
like "(15-14 of 14)".
* Provide several examples for dgl-create-chroot.conf.
@ -8,6 +8,8 @@
* Added ^W for delete word in mygetnstr().
* Begun generalization of code so that someone can get it to work
with stuff like Slash'EM etc. easier.
* Allow automatic authorization using the USER environment variable
that one can auto-set in .telnetrc.
1.4.4 (2004/03/07)
* Show total number of games in progress below the list, useful if

View File

@ -785,6 +785,21 @@ initcurses ()
/* ************************************************************* */
void
autologin (char* user, char *pass)
{
int me_index = -1;
if ((me_index = userexist(user)) != -1)
{
me = users[me_index];
if (passwordgood(pass))
{
loggedin = 1;
snprintf (rcfilename, 80, "%srcfiles/%s.nethackrc", myconfig->dglroot, me->username);
}
}
}
void
loginprompt (int from_ttyplay)
{
@ -1652,7 +1667,7 @@ int
main (int argc, char** argv)
{
/* for chroot and program execution */
char atrcfilename[81], *spool;
char atrcfilename[81], *spool, *auth = getenv("USER");
unsigned int len;
int c;
int nhext = 0, nhauth = 0;
@ -1760,6 +1775,25 @@ main (int argc, char** argv)
if (nhauth)
graceful_exit (authenticate ());
if (auth)
{
char *user, *pass, *p;
p = strchr(auth, ':');
if (p)
{
pass = p + 1;
if (pass != '\0')
{
*p = '\0';
user = auth;
autologin(user, pass);
}
}
}
initcurses ();
menuloop();

View File

@ -87,6 +87,7 @@ extern void freefile(void);
extern void initcurses(void);
extern void loginprompt(int from_ttyplay);
extern void newuser(void);
extern void autologin(char *user, char *pass);
extern int passwordgood(char *cpw);
extern int readfile(int nolock);
extern int userexist(char *cname);