]> code.citadel.org Git - citadel.git/commitdiff
* citadel.c: accept -h <host> and -p arguments, so citadel can be called
authorArt Cancro <ajc@citadel.org>
Mon, 11 Sep 2000 22:05:04 +0000 (22:05 +0000)
committerArt Cancro <ajc@citadel.org>
Mon, 11 Sep 2000 22:05:04 +0000 (22:05 +0000)
  directly by telnetd, bypassing /bin/login.  It works, but not recommended at
  this time because it has to run as root.

citadel/ChangeLog
citadel/citadel.c

index fe07faa7757bea7150d919a0f0e79cc88805bfe0..9fe6b02b6fe930bf942cf739932bb8fce81e423f 100644 (file)
@@ -1,4 +1,9 @@
  $Log$
+ Revision 573.1  2000/09/11 22:05:04  ajc
+ * citadel.c: accept -h <host> and -p arguments, so citadel can be called
+   directly by telnetd, bypassing /bin/login.  It works, but not recommended at
+   this time because it has to run as root.
+
  Revision 573.0  2000/09/05 18:35:22  ajc
  * Tagged everything for version 5.73 release
 
@@ -2051,4 +2056,3 @@ Sat Jul 11 00:20:48 EDT 1998 Nathan Bryant <bryant@cs.usm.maine.edu>
 
 Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
        * Initial CVS import 
-
index e3a8e4c043b739f7e1b2767e325bde6836fac2c6..18e3eb64f7c79b2c9d2c0516f74a25f7708ec115 100644 (file)
@@ -707,7 +707,7 @@ int set_password(void)
 /*
  * get info about the server we've connected to
  */
-void get_serv_info(void)
+void get_serv_info(char *supplied_hostname)
 {
        char buf[512];
 
@@ -717,7 +717,15 @@ void get_serv_info(void)
        snprintf(buf, sizeof buf, "IDEN %d|%d|%d|%s|",
                 SERVER_TYPE, 0, REV_LEVEL,
                 (server_is_local ? "local" : CITADEL));
-       locate_host(&buf[strlen(buf)]);         /* append to the end */
+
+       /* Append a hostname */
+       if (supplied_hostname != NULL) {
+               strcat(buf, supplied_hostname);
+       }
+       else {
+               locate_host(&buf[strlen(buf)]); /* append to the end */
+       }
+
        serv_puts(buf);
        serv_gets(buf);         /* we don't care about the result code */
 }
@@ -828,6 +836,15 @@ void enternew(char *desc, char *buf, int maxlen)
 
 
 
+int shift(int argc, char **argv, int start, int count) {
+       int i;
+
+       for (i=start; i<(argc-count); ++i) {
+               argv[i] = argv[i+count];
+       }
+       argc = argc - count;
+       return argc;
+}
 
 /*
  * main
@@ -838,6 +855,7 @@ int main(int argc, char **argv)
        char aaa[100], bbb[100];/* general purpose variables */
        char argbuf[32];        /* command line buf */
        char nonce[NONCE_SIZE];
+       char *telnet_client_host = NULL;
        char *sptr, *sptr2;     /* USed to extract the nonce */
        char hexstring[MD5_HEXSTRING_SIZE];
        volatile int termn8 = 0;
@@ -851,6 +869,20 @@ int main(int argc, char **argv)
        signal(SIGTERM, dropcarr);      /* Cleanup gracefully if terminated */
        signal(SIGCONT, catch_sigcont);         /* Catch SIGCONT so we can reset terminal */
 
+       /* 
+        * Handle command line options as if we were called like /bin/login
+        * (i.e. from in.telnetd)
+        */
+       for (a=0; a<argc; ++a) {
+               if ((argc > a+1) && (!strcmp(argv[a], "-h")) ) {
+                       telnet_client_host = argv[a+1];
+                       argc = shift(argc, argv, a, 2);
+               }
+               if (!strcmp(argv[a], "-p")) {
+                       argc = shift(argc, argv, a, 1);
+               }
+       }
+
        printf("Attaching to server... \r");
        fflush(stdout);
        attach_to_server(argc, argv, hostbuf, portbuf);
@@ -885,7 +917,7 @@ int main(int argc, char **argv)
           }
        }
        
-       get_serv_info();
+       get_serv_info(telnet_client_host);
 
        look_for_ansi();
        cls(0);