]> skyeroc.xyz Git - dgamelaunch/commitdiff
add USER-authentication support
authorJoshua Kwan <joshk@triplehelix.org>
Sat, 12 Jun 2004 00:11:18 +0000 (00:11 +0000)
committerJoshua Kwan <joshk@triplehelix.org>
Sat, 12 Jun 2004 00:11:18 +0000 (00:11 +0000)
git-svn-id: svn://katsu.triplehelix.org/dgamelaunch/trunk@291 db0b04b0-f4d1-0310-9a6d-de3e77497b0e

Changelog
dgamelaunch.c
dgamelaunch.h

index ada11dec7cb30a20a2914160463767c16cfc1cf8..6713a1648e315656e12d84b4a6d7b906665f61fc 100644 (file)
--- a/Changelog
+++ b/Changelog
@@ -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
index 379048b3cfee784c5750d9813a836f6e2e5aac80..f99337cfbd696afa8d784447e5f2830732ebc153 100644 (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();
 
index a5e5c32ae09f14fb906a777e477c8d8e620a29e5..17e53786badaaa27aaa9b1691497fd5461e5d4f0 100644 (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);