summary refs log tree commit diff stats
path: root/widgets/account.go
Commit message (Expand)AuthorAgeFilesLines
* Start building out command subsystemDrew DeVault2019-03-101-1/+9
* Fix buildElias Naur2019-02-101-1/+1
* Implement Container interface in widgets/Drew DeVault2019-01-201-0/+4
* Send commands up to the top-level aerc widgetDrew DeVault2019-01-141-4/+10
* Handle errors from worker initializationDrew DeVault2019-01-131-1/+1
* Swap message list placeholder for spinnerDrew DeVault2019-01-131-1/+3
* Handle connection errors properlyDrew DeVault2019-01-131-3/+4
* Simplify approach to directory listDrew DeVault2019-01-131-5/+17
* Filter dirlist according to user configDrew DeVault2019-01-131-1/+1
* Add directory list widgetDrew DeVault2019-01-131-23/+26
* Move ex line into accountDrew DeVault2019-01-131-26/+49
* Move status line into account, update behaviorDrew DeVault2019-01-131-9/+35
* Initialize worker in account widgetDrew DeVault2019-01-131-2/+50
* Add basic account widget, populate real acct viewsDrew DeVault2019-01-131-0/+41
f='#n155'>155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579
/*		Telnet Acees, Roligin, etc			HTTelnet.c
**		==========================
**
** Authors
**	TBL	Tim Berners-Lee timbl@info.cern.ch
**	JFG	Jean-Francois Groff jgh@next.com
**	DD	Denis DeLaRoca (310) 825-4580  <CSP1DWD@mvs.oac.ucla.edu>
** History
**       8 Jun 92 Telnet hopping prohibited as telnet is not secure (TBL)
**	26 Jun 92 When over DECnet, suppressed FTP, Gopher and News. (JFG)
**	 6 Oct 92 Moved HTClientHost and logfile into here. (TBL)
**	17 Dec 92 Tn3270 added, bug fix. (DD)
**	 2 Feb 93 Split from HTAccess.c. Registration.(TBL)
*/

#include "HTUtils.h"
#include "tcp.h"

/* Implements:
*/
#include "HTTelnet.h"

#include "HTParse.h"
#include "HTAnchor.h"
#include "HTTP.h"
#include "HTFile.h"
/*#include <errno.h> included by tcp.h -- FM */
/*#include <stdio.h> included by HTUtils.h -- FM */

#include "HText.h"

#include "HTAccess.h"
#include "HTAlert.h"
#ifndef VMS
#include "../../../userdefs.h"  /* for TELNET_COMMAND and RLOGIN_COMMAND */
#endif /* not VMS */

#include "LYLeaks.h"

#define FREE(x) if (x) {free(x); x = NULL;}

#define HT_NO_DATA -9999


/*	Telnet or "rlogin" access
**	-------------------------
*/
PRIVATE int remote_session ARGS2(char *, access, char *, host)
{
	char * user = host;
	char * password = NULL;
 	char * cp;
	char * hostname;
	char * port;
	char   command[256];
	enum _login_protocol { telnet, rlogin, tn3270 } login_protocol =
		strcmp(access, "rlogin") == 0 ? rlogin :
		strcmp(access, "tn3270") == 0 ? tn3270 : telnet;
#ifdef VMS
	extern int DCLsystem PARAMS((char *command));
#define system(a) DCLsystem(a) /* use LYCurses.c routines for spawns */
#endif /* VMS */

	/*
	 *	Modified to allow for odd chars in a username only if exists.
	 *	05-28-94 Lynx 2-3-1 Garrett Arch Blythe
	 */
	/* prevent telnet://hostname;rm -rf *  URL's (VERY BAD) 
	 *  *cp=0;  / * terminate at any ;,<,>,`,|,",' or space or return
	 *  or tab to prevent security whole 
	 */
	for(cp = (strchr(host, '@') ? strchr(host, '@') : host); *cp != '\0';
		cp++)	{
	    if(!isalnum(*cp) && *cp != '_' && *cp != '-' &&
				*cp != ':' && *cp != '.' && *cp != '@') {
	        *cp = '\0';
	        break;
	    }
	}

	hostname = strchr(host, '@');

	if (hostname) {
	    *hostname++ = '\0';	/* Split */
	} else {
	    hostname = host;
	    user = NULL;	/* No user specified */
	}

	port = strchr(hostname, ':');
	if (port)
	    *port++ = '\0';	/* Split */

    if (!hostname || *hostname == '\0') {
        if (TRACE)
	    fprintf(stderr, "HTTelnet: No host specified!\n");
	return HT_NO_DATA;
    }

    if (user) {
        password = strchr(user, ':');
	if (password) {
	    *password++ = '\0';
	}
    }

/* If the person is already telnetting etc, forbid hopping */
/* This is a security precaution, for us and remote site */

	if (HTSecure) {

#ifdef TELNETHOPPER_MAIL
	    sprintf(command, 
	      "finger @%s | mail -s \"**telnethopper %s\" tbl@dxcern.cern.ch",
	       HTClientHost, HTClientHost);
	    system(command);
#endif
	    printf("\n\nSorry, but the service you have selected is one\n");
	    printf("to which you have to log in.  If you were running www\n");
	    printf("on your own computer, you would be automatically connected.\n");
	    printf("For security reasons, this is not allowed when\n");
	    printf("you log in to this information service remotely.\n\n");

	    printf("You can manually connect to this service using %s\n",
		   access);
	    printf("to host %s", hostname);
	    if (user) printf(", user name %s", user);
	    if (password) printf(", password %s", password);
	    if (port) printf(", port %s", port);
	    printf(".\n\n");
	    return HT_NO_DATA;
	}

/* Not all telnet servers get it even if user name is specified
** so we always tell the guy what to log in as
*/
        if (user && login_protocol != rlogin)
	    printf("When you are connected, log in as:  %s\n", user);
        if (password && login_protocol != rlogin)
	    printf("                  The password is:  %s\n", password);

/*
 *	NeXTSTEP is the implied version of the NeXT operating system.
 *		You may need to define this yourself.
 */
#if     defined(NeXT) && defined(NeXTSTEP) && NeXTSTEP<=20100
	sprintf(command, "%s%s%s %s %s", TELNET_COMMAND,
		user ? " -l " : "",
		user ? user : "",
		hostname,
		port ? port : "");

	if (TRACE)
	    fprintf(stderr, "HTTelnet: Command is: %s\n\n", command);
	system(command);
	return HT_NO_DATA;		/* Ok - it was done but no data */
#define TELNET_DONE
#endif

/* Most unix machines suppport username only with rlogin */
#if defined(unix)
#ifndef TELNET_DONE
	if (login_protocol == rlogin) {
	    sprintf(command, "%s %s%s%s", RLOGIN_COMMAND,
		hostname,
		user ? " -l " : "",
		user ? user : "");

	} else if (login_protocol == tn3270) {
	    sprintf(command, "%s %s %s", TN3270_COMMAND,
		hostname,
		port ? port : "");

	} else {  /* TELNET */
	    sprintf(command, "%s %s %s", TELNET_COMMAND,
		hostname,
		port ? port : "");
	}

	if (TRACE)
	    fprintf(stderr, "HTTelnet: Normal: Command is: %s\n\n", command);
	system(command);
	return HT_NO_DATA;		/* Ok - it was done but no data */
#define TELNET_DONE
#endif /* !TELNET_DONE */
#endif /* unix */

/* VMS varieties */
#if defined(MULTINET)
	if (login_protocol == rlogin) {
	    sprintf(command, "RLOGIN%s%s%s%s%s %s",  /*lm 930713 */
		user ? "/USERNAME=\"" : "",
		user ? user : "",
		user ? "\"" : "",
		port ? "/PORT=" : "",
		port ? port : "",
		hostname);

	} else if (login_protocol == tn3270) {
	    sprintf(command, "TELNET/TN3270 %s%s %s",
		port ? "/PORT=" : "",
		port ? port : "",
		hostname);

	} else {  /* TELNET */
	    sprintf(command, "TELNET %s%s %s",
		port ? "/PORT=" : "",
		port ? port : "",
		hostname);
	}

	if (TRACE)
	    fprintf(stderr, "HTTelnet: Command is: %s\n\n", command);
	system(command);
	return HT_NO_DATA;		/* Ok - it was done but no data */
#define TELNET_DONE
#endif /* MULTINET */

#if defined(WIN_TCP)
        {
            char *cp;
    
	    if ((cp=getenv("WINTCP_COMMAND_STYLE")) != NULL &&
                0==strncasecomp(cp, "VMS", 3)) { /* VMS command syntax */ 
	        if (login_protocol == rlogin) {
	            sprintf(command, "RLOGIN%s%s%s%s%s %s",  /*lm 930713 */
		        user ? "/USERNAME=\"" : "",
		        user ? user : "",
			user ? "\"" : "",
		        port ? "/PORT=" : "",
		        port ? port : "",
		        hostname);

	        } else if (login_protocol == tn3270) {
	            sprintf(command, "TELNET/TN3270 %s%s %s",
		        port ? "/PORT=" : "",
		        port ? port : "",
		        hostname);

	        } else {  /* TELNET */
	            sprintf(command, "TELNET %s%s %s",
		        port ? "/PORT=" : "",
		        port ? port : "",
		        hostname);
	        }

            } else { /* UNIX command syntax */
	       if (login_protocol == rlogin) {
	           sprintf(command, "RLOGIN %s%s%s%s%s", 
		       hostname,
		       user ? " -l " : "",
		       user ? "\"" : "",
		       user ? user : "",
		       user ? "\"" : "");

	        } else if (login_protocol == tn3270) {
	            sprintf(command, "TN3270 %s %s",
		        hostname,
		        port ? port : "");

	        } else {  /* TELNET */
	            sprintf(command, "TELNET %s %s",
		        hostname,
		        port ? port : "");
	        }
            }

	    if (TRACE)
	        fprintf(stderr, "HTTelnet: Command is: %s\n\n", command);
	    system(command);
	    return HT_NO_DATA;		/* Ok - it was done but no data */
        }
#define TELNET_DONE
#endif /* WIN_TCP */

#ifdef UCX
	if (login_protocol == rlogin) {
	    sprintf(command, "RLOGIN%s%s%s %s %s",
		user ? "/USERNAME=\"" : "",
		user ? user : "",
		user ? "\"" : "",
		hostname,
		port ? port : "");

	} else if (login_protocol == tn3270) {
	    sprintf(command, "TN3270 %s %s",
		hostname,
		port ? port : "");

	} else {  /* TELNET */
	    sprintf(command, "TELNET %s %s",
		hostname,
		port ? port : "");
	}

	if (TRACE)
	    fprintf(stderr, "HTTelnet: Command is: %s\n\n", command);
	system(command);
	return HT_NO_DATA;		/* Ok - it was done but no data */
#define TELNET_DONE
#endif /* UCX */

#ifdef CMU_TCP
	if (login_protocol == telnet) {
	    sprintf(command, "TELNET %s%s %s",
		port ? "/PORT=" : "",
		port ? port : "",
		hostname);
	    if (TRACE)
	        fprintf(stderr, "HTTelnet: Command is: %s\n\n", command);
	    system(command);
	}
	else {
	    extern int LYgetch NOPARAMS;
	    extern BOOLEAN HadVMSInterrupt;

	    printf(
	"\nSorry, this browser was compiled without the %s access option.\n",
		access);
	    printf("\nPress <return> to return to Lynx.");
	    LYgetch();
	    HadVMSInterrupt = FALSE;
	}
	return HT_NO_DATA;		/* Ok - it was done but no data */
#define TELNET_DONE
#endif /* CMU_TCP */

#ifdef SOCKETSHR_TCP
  {
    char *cp;

    if (getenv("MULTINET_SOCKET_LIBRARY") != NULL) {
	if (login_protocol == rlogin) {
	    sprintf(command, "MULTINET RLOGIN%s%s%s%s %s",  /*lm 930713 */
		user ? "/USERNAME=" : "",
		user ? user : "",
		port ? "/PORT=" : "",
		port ? port : "",
		hostname);

	} else if (login_protocol == tn3270) {
	    sprintf(command, "MULTINET TELNET/TN3270 %s%s %s",
		port ? "/PORT=" : "",
		port ? port : "",
		hostname);

	} else {  /* TELNET */
	    sprintf(command, "MULTINET TELNET %s%s %s",
		port ? "/PORT=" : "",
		port ? port : "",
		hostname);
	}

	if (TRACE)
	    fprintf(stderr, "HTTelnet: Command is: %s\n\n", command);
	system(command);
	return HT_NO_DATA;		/* Ok - it was done but no data */
    }
    else if ((cp=getenv("WINTCP_COMMAND_STYLE")) != NULL) {
        if (0==strncasecomp(cp, "VMS", 3)) { /* VMS command syntax */ 
	    if (login_protocol == rlogin) {
	        sprintf(command, "RLOGIN%s%s%s%s %s",  /*lm 930713 */
		    user ? "/USERNAME=" : "",
		    user ? user : "",
		    port ? "/PORT=" : "",
		    port ? port : "",
		    hostname);
	    } else if (login_protocol == tn3270) {
	        sprintf(command, "TELNET/TN3270 %s%s %s",
		    port ? "/PORT=" : "",
		    port ? port : "",
		    hostname);
	    } else {  /* TELNET */
	        sprintf(command, "TELNET %s%s %s",
		    port ? "/PORT=" : "",
		    port ? port : "",
		    hostname);
	    }
        } else { /* UNIX command syntax */
	    if (login_protocol == rlogin) {
	        sprintf(command, "RLOGIN %s%s%s", 
		    hostname,
		    user ? " -l " : "",
		    user ? user : "");
	    } else if (login_protocol == tn3270) {
	        sprintf(command, "TN3270 %s %s",
		    hostname,
		    port ? port : "");
	    } else {  /* TELNET */
	        sprintf(command, "TELNET %s %s",
		    hostname,
		    port ? port : "");
	    }
        }

	if (TRACE)
	    fprintf(stderr, "HTTelnet: Command is: %s\n\n", command);
	system(command);
	return HT_NO_DATA;		/* Ok - it was done but no data */
    }
    else if (getenv("UCX$DEVICE") != NULL) {
	if (login_protocol == rlogin) {
	    sprintf(command, "RLOGIN%s%s %s %s",
		user ? "/USERNAME=" : "",
		user ? user : "",
		hostname,
		port ? port : "");

	} else if (login_protocol == tn3270) {
	    sprintf(command, "TN3270 %s %s",
		hostname,
		port ? port : "");

	} else {  /* TELNET */
	    sprintf(command, "TELNET %s %s",
		hostname,
		port ? port : "");
	}

	if (TRACE)
	    fprintf(stderr, "HTTelnet: Command is: %s\n\n", command);
	system(command);
	return HT_NO_DATA;		/* Ok - it was done but no data */
    }
    else if (getenv("CMUTEK_ROOT") != NULL) {
    	if (login_protocol == telnet) {
    	    sprintf(command, "TELNET %s%s %s",
    		port ? "/PORT=" : "",
    		port ? port : "",
    		hostname);
    	    if (TRACE)
	        fprintf(stderr, "HTTelnet: Command is: %s\n\n", command);
    	    system(command);
    	}
    	else {
    	    extern int LYgetch NOPARAMS;
	    extern BOOLEAN HadVMSInterrupt;

	    printf(
	  "\nSorry, this browser was compiled without the %s access option.\n",
    		access);
    	    printf("\nPress <return> to return to Lynx.");
    	    LYgetch();
	    HadVMSInterrupt = FALSE;
    	}
    	return HT_NO_DATA;		/* Ok - it was done but no data */
    }
    else {
	if (login_protocol == telnet) {
	    sprintf(command, "TELNET %s%s %s",
		port ? "/PORT=" : "",
		port ? port : "",
		hostname);
	    if (TRACE)
	        fprintf(stderr, "HTTelnet: Command is: %s\n\n", command);
	    system(command);
	}
	else {
	    extern int LYgetch NOPARAMS;
	    extern BOOLEAN HadVMSInterrupt;

	    printf(
	  "\nSorry, this browser was compiled without the %s access option.\n",
		access);
	    printf("\nPress <return> to return to Lynx.");
	    LYgetch();
	    HadVMSInterrupt = FALSE;
	}
	return HT_NO_DATA;		/* Ok - it was done but no data */
    }
  }
#define TELNET_DONE
#endif /* SOCKETSHR_TCP */

#ifdef VM
#define SIMPLE_TELNET
#endif
#ifdef SIMPLE_TELNET
	if (login_protocol == telnet) {			/* telnet only */
	    sprintf(command, "TELNET  %s",	/* @@ Bug: port ignored */
		hostname);
	    if (TRACE)
	        fprintf(stderr, "HTTelnet: Command is: %s\n\n", command);
	    system(command);
	    return HT_NO_DATA;		/* Ok - it was done but no data */
	}
#endif

#ifndef TELNET_DONE
	printf(
	"\nSorry, this browser was compiled without the %s access option.\n",
		access);
	printf(
	"\nTo access the information you must %s to %s", access, hostname);
	if (port)
	    printf(" (port %s)", port);
	if (user)
	    printf("\nlogging in with username %s", user);
	printf(".\n");
	{
	    extern int LYgetch NOPARAMS;

	    printf("\nPress <return> to return to Lynx.");
	    fflush(stdout);
	    LYgetch();
#ifdef VMS
	    {
		extern BOOLEAN HadVMSInterrupt;
		HadVMSInterrupt = FALSE;
	    }
#endif /* VMS */
        }
	return HT_NO_DATA;
#endif /* !TELNET_DONE */
}

/*	"Load a document" -- establishes a session
**	------------------------------------------
**
** On entry,
**	addr		must point to the fully qualified hypertext reference.
**
** On exit,
**	returns		<0	Error has occured.
**			>=0	Value of file descriptor or socket to be used
**				 to read data.
**	*pFormat	Set to the format of the file, if known.
**			(See WWW.h)
**
*/
PRIVATE int HTLoadTelnet
ARGS4
(
 CONST char *,		addr,
 HTParentAnchor *,	anchor,
 HTFormat,		format_out,
 HTStream *,		sink			/* Ignored */
)
{
    char * access;
    
    char * host;
    int status;
    
    if (sink) {
        if (TRACE)
	    fprintf(stderr,
	   "HTTelnet: Can't output a live session -- must be interactive!\n");
	return HT_NO_DATA;
    }
    access =  HTParse(addr, "file:", PARSE_ACCESS);
    
    host = HTParse(addr, "", PARSE_HOST);
    if (!host || *host == '\0') {
	status = HT_NO_DATA;
        if (TRACE)
	    fprintf(stderr, "HTTelnet: No host specified!\n");
    } else {
        status = remote_session(access, host);
    }

    FREE(host);	
    FREE(access);
    return status;
}


#ifdef GLOBALDEF_IS_MACRO
#define _HTTELNET_C_1_INIT { "telnet", HTLoadTelnet, NULL }
#define _HTTELNET_C_2_INIT { "rlogin", HTLoadTelnet, NULL }
#define _HTTELNET_C_3_INIT { "tn3270", HTLoadTelnet, NULL }
GLOBALDEF (HTProtocol, HTTelnet, _HTTELNET_C_1_INIT );
GLOBALDEF (HTProtocol, HTRlogin, _HTTELNET_C_2_INIT );
GLOBALDEF (HTProtocol, HTTn3270, _HTTELNET_C_3_INIT );
#else
GLOBALDEF PUBLIC HTProtocol HTTelnet = { "telnet", HTLoadTelnet, NULL };
GLOBALDEF PUBLIC HTProtocol HTRlogin = { "rlogin", HTLoadTelnet, NULL };
GLOBALDEF PUBLIC HTProtocol HTTn3270 = { "tn3270", HTLoadTelnet, NULL };
#endif /* GLOBALDEF_IS_MACRO */