$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
Fri Jul 10 1998 Art Cancro <ajc@uncensored.citadel.org>
* Initial CVS import
-
/*
* get info about the server we've connected to
*/
-void get_serv_info(void)
+void get_serv_info(char *supplied_hostname)
{
char buf[512];
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 */
}
+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
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;
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);
}
}
- get_serv_info();
+ get_serv_info(telnet_client_host);
look_for_ansi();
cls(0);