Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Portability improvements, cleanup, and bug fixes #36

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
doc/ linguist-vendored
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
*~
*.o
*.ln
compile_commands.json
/supdup
/supdupd
71 changes: 71 additions & 0 deletions GNUmakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
# Makefile for the supdup server and client.

SHELL = /bin/sh
PREFIX ?= /usr/local

CC ?= cc
RM ?= rm -f

OS_NAME ?= $(shell uname 2> /dev/null)
CFLAGS += $(shell pkg-config --cflags ncurses 2> /dev/null)
NCURSES_LIBS ?= $(shell pkg-config --libs ncurses 2> /dev/null || printf '%s' "-lncurses")

# AIX (needs linking libcurses *after* libncurses)
ifeq ($(OS_NAME), AIX)
EXTRA_LDFLAGS = -lcurses
endif

# Mac OS X
ifeq ($(OS_NAME), Darwin)
LDFLAGS += -L/opt/local/lib
endif

# Solaris and illumos
ifeq ($(OS_NAME), SunOS)
CFLAGS += -I/usr/include/ncurses
EXTRA_LDFLAGS = -lnsl -lsocket
endif

# Haiku
ifeq ($(OS_NAME), Haiku)
EXTRA_LDFLAGS = -lnetwork
endif

# NetBSD
ifeq ($(OS_NAME), NetBSD)
CFLAGS += -I/usr/pkg/include -I/usr/pkg/include/ncurses
LDFLAGS += -L/usr/pkg/lib
endif

# The server (supdupd) isn't ready for prime time.
.PHONY: all
all: supdup

SUPDUP_OBJS = supdup.o charmap.o tcp.o chaos.o
supdup: $(SUPDUP_OBJS)
$(CC) $(LDFLAGS) -o $@ $(SUPDUP_OBJS) $(NCURSES_LIBS) $(EXTRA_LDFLAGS)

SUPDUPD_OBJS = supdupd.o
supdupd: $(SUPDUPD_OBJS)
$(CC) $(LDFLAGS) -o $@ $(SUPDUPD_OBJS)

.PHONY: install
install: supdup
install -m 0755 supdup $(PREFIX)/bin
test -x supdupd && install -m 0755 supdupd $(PREFIX)/bin

.PHONY: clean
clean:
$(RM) *.o
$(RM) supdup supdupd

.PHONY: distclean
distclean: clean
$(RM) *~ *.bak core *.core

# Dependencies
chaos.o: supdup.h
charmap.o: charmap.h
supdup.o: charmap.h
supdupd.o: supdup.h
tcp.o: supdup.h
2 changes: 1 addition & 1 deletion INFO
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ reappears. They also have a bug that if you type a meta character the
character that gets sent is shifted and if you type meta shift character
it sends a lowercase character. There is nothing I can do about this.

For some reason talk, amoung a few other things, core dumps when
For some reason talk, among a few other things, core dumps when
supduping in from a lisp machine (either a 3600 or a cadr). I've seen
the same bug a BBN bitgraph. It seems to be a bug with programs which
use curses and is evoked by large screen sizes.
36 changes: 0 additions & 36 deletions Makefile

This file was deleted.

94 changes: 93 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,93 @@
![](https://travis-ci.org/larsbrinkhoff/lbForth.svg?branch=master)
# `supdup`

## Overview

* `supdup` is a client (and `supdupd` is a server) implementing the SUPDUP (*Sup*er *Dup*er TELNET) protocol, a highly efficient [TELNET](https://www.rfc-editor.org/rfc/rfc854.txt)-style remote display protocol, on UNIX-like systems.

* It originated as a private protocol between the [Chaosnet](https://chaosnet.net/)-connected ITS systems at MIT to allow a user at any one of these systems to use one of the others as a display; later implementations were developed for [various platforms](https://gunkies.org/wiki/Chaosnet#Protocol_implementations).

* The software supports connections over TCP/IP and Chaosnet (optionally using the [cbridge](https://github.com/bictorv/chaosnet-bridge) software).

## Supported platforms

* Tested operating systems: Oracle Solaris, OpenIndiana illumos, Linux/musl, Linux/glibc, IBM AIX, IBM OS/400 (PASE), Haiku, FreeBSD, OpenBSD, NetBSD, Cygwin, and Apple macOS.

## Supported compilers

* Tested compilers: PCC, GCC, Clang, Xcode, IBM XL C, IBM Open XL C, Oracle Studio C, NVIDIA HPC SDK C, Portland Group C, and DMD ImportC.

## Building the `supdup` client

### Generic UNIX

* Building on generic UNIX-like systems (**Linux**, **\*BSD**, **macOS**, **Haiku**, etc.):
* Install prerequisite packages:
* Required: `make` (GNU), `ncurses` (libraries and headers),
* Recommended: `pkg-config`
* Build: `gmake` (or sometimes just `make`)
[]()

[]()
* The usual environment variables (*e.g.* `CC`, `CFLAGS`, `LDFLAGS`, etc.) are respected, for example:
* `env CC="gcc" CFLAGS="-Wall" LDFLAGS="-L/usr/local" gmake`

### IBM AIX

* Building on IBM AIX 7:
* Install prerequisite packages:
* `dnf install make ncurses-devel pkg-config`
* Build with GNU GCC:
* `env CC="gcc" CFLAGS="-maix64" LDFLAGS="-maix64 -Wl,-b64" gmake`
* Build with IBM XL C V16:
* `env CC="xlc" CFLAGS="-q64" LDFLAGS="-q64" gmake`
* Build with IBM Open XL C V17:
* `env CC="ibm-clang" CFLAGS="-m64" LDFLAGS="-m64" gmake`

### IBM i (OS/400)

* Building on PASE for IBM i (OS/400):
* Install prerequisite packages:
* `yum install gcc10 make-gnu ncurses-devel pkg-config`
* Build with GNU GCC:
* `env CC="gcc-10" CFLAGS="-maix64" LDFLAGS="-maix64 -Wl,-b64" gmake`

### DMD ImportC

* Building with DMD ImportC:
* `dmd -betterC -c -of=supdup.o chaos.c charmap.c supdup.c tcp.c $(pkg-config --cflags-only-I ncurses)`
* `cc -o supdup supdup.o $(pkg-config --libs ncurses)`

## Building the `supdup` server

* An *experimental* server, `supdupd`, is included.
* The server component is *incomplete* (and *may not* build on all platforms).
[]()

[]()
* To build the server on generic UNIX-like systems:
* Install prerequisite packages: `make` (GNU)
* Build: `gmake` (or sometimes just `make`)

## Bug Reporting

* To report a problem with `supdup`, use GitHub Issues:
* https://github.com/PDP-10/supdup/issues/new/choose

## External links

### SUPDUP

* [RFC 734: SUPDUP Protocol](https://www.rfc-editor.org/rfc/rfc734.txt)
* [RFC 736: TELNET SUPDUP Option](https://www.rfc-editor.org/rfc/rfc736.txt)
* [RFC 746: The SUPDUP Graphics Extension](https://www.rfc-editor.org/rfc/rfc746.txt)
* [RFC 747: Recent Extensions to the SUPDUP Protocol](https://www.rfc-editor.org/rfc/rfc747.txt)
* [RFC 749: TELNET SUPDUP-OUTPUT Option](https://www.rfc-editor.org/rfc/rfc749.txt)
* [AI Memo 643: A Local Front End for Remote Editing](http://www.bitsavers.org/pdf/mit/ai/aim/AIM-643.pdf)
* [AI Memo 644: The SUPDUP Protocol](http://www.bitsavers.org/pdf/mit/ai/aim/AIM-644.pdf)
* [PuTTY: SUPDUP Backend](https://git.tartarus.org/?p=simon/putty.git;a=blob;f=otherbackends/supdup.c;h=6f574c9fb9c34b1307b67326038aa713c2b1d07a;hb=HEAD)

### Chaosnet

* [AI Memo 628: Chaosnet](http://bitsavers.org/pdf/mit/ai/AIM-628_chaosnet.pdf)
* [Chaosnet Bridge](https://github.com/bictorv/chaosnet-bridge)
* [Chaosnet Wiki](https://chaosnet.net/)
44 changes: 23 additions & 21 deletions chaos.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,34 @@

#if USE_CHAOS_STREAM_SOCKET

#include <stdio.h>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems this is a but superfluous? I have no opinion though ..

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, that's just GNU style (modifications via GNU Cppi tool). If you hate it, I can revert.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see that this was resolved in the discussions. I think minor whitespace cleanup is ok, but major reformatting is not.

Copy link
Contributor Author

@johnsonjh johnsonjh Aug 9, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That change is from GNU Cppi which normalizes preprocessor indentation to GNU style - it's indenting by one space because those preprocessor directives are inside the conditional #if block.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, but we haven't adopted GNU style here. At least it hasn't been discussed and agreed on.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can revert to the previous flat style with no indentation (all preprocessor directives left justified) if it's preferred. I apologize, it's something that I (and my default editor configuration) do automatically.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh no, need to apologize! We have these reviews and discussions to hash things out.

In my view, reformatting be more nuisance than it's worth. Say, if someone patched a fork and wanted to apply it here later. It's also polite to adopt the existing code style. So that's my preference, but I'm not saying I have the final say.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I'll still lean to the new formatting due to the (IMO, massive) readability improvements, but let me know either way.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm with @larsbrinkhoff -- one benefit of keeping formatting is that when you compare to old versions of supdup that might surface it is much much easier to find changes.

As for GNU cppi .. I personally find it ugly, and it isn't that commonly adopted in GNU.

#include <netdb.h>
#include <unistd.h>
#include <string.h>
#include <sys/un.h>
#include <sys/errno.h>
# include <stdio.h>
# include <netdb.h>
# include <unistd.h>
# include <string.h>
# include <sys/un.h>
# include <errno.h>
# include <sys/socket.h>

// Where are the chaos sockets? Cf. https://github.com/bictorv/chaosnet-bridge
#ifndef CHAOS_SOCKET_DIRECTORY
#define CHAOS_SOCKET_DIRECTORY "/tmp"
#endif
# if !defined(CHAOS_SOCKET_DIRECTORY)
# define CHAOS_SOCKET_DIRECTORY "/tmp"
# endif
// What DNS domain should be used to translate Chaos addresses to names?
#ifndef CHAOS_ADDRESS_DOMAIN
#define CHAOS_ADDRESS_DOMAIN "ch-addr.net"
#endif
# if !defined(CHAOS_ADDRESS_DOMAIN)
# define CHAOS_ADDRESS_DOMAIN "ch-addr.net"
# endif
// What DNS server should be used to fetch Chaos class data?
#ifndef CHAOS_DNS_SERVER
# if !defined(CHAOS_DNS_SERVER)
// #define CHAOS_DNS_SERVER "130.238.19.25"
#define CHAOS_DNS_SERVER "dns.chaosnet.net"
#endif
# define CHAOS_DNS_SERVER "dns.chaosnet.net"
# endif

static int
connect_to_named_socket(int socktype, char *path)
{
int sock, slen;
struct sockaddr_un server;

if ((sock = socket(AF_UNIX, socktype, 0)) < 0) {
perror("socket(AF_UNIX)");
return -1;
Expand All @@ -41,7 +42,7 @@ connect_to_named_socket(int socktype, char *path)
slen = strlen(server.sun_path)+ 1 + sizeof(server.sun_family);

if (connect(sock, (struct sockaddr *)&server, slen) < 0) {
if (errno != ECONNREFUSED)
if (errno != ENOENT)
// Fail silently if Chaosnet bridge is not there
perror("connect(server)");
return -1;
Expand All @@ -61,7 +62,7 @@ static ssize_t write_all(int fd, void *buf, size_t n)
return m;
x += m;
n -= m;
}
}
return x - (char *)buf;
}

Expand All @@ -77,12 +78,12 @@ static ssize_t read_all(int fd, void *buf, size_t n)
return m;
x += m;
n -= m;
}
}
return x - (char *)buf;
}

static int
connection(int net, const char *host, const char *contact)
connection(int net, const char *host, const char *contact)
{
char buf[1000]; /*Bill Gates says this ought to be enough.*/
char *bp, cbuf[2];
Expand Down Expand Up @@ -114,7 +115,8 @@ chaos_connect(const char *hostname, const char *contact)
if (contact == NULL)
contact = "SUPDUP";
if (connection(fd, hostname, contact) < 0) {
close(fd);
if (fd >= 0)
close(fd);
return -1;
}
return fd;
Expand Down
4 changes: 2 additions & 2 deletions charmap.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef CHARMAP_H
#define CHARMAP_H
#if !defined(CHARMAP_H)
# define CHARMAP_H

typedef struct {
char *name;
Expand Down
16 changes: 8 additions & 8 deletions supdup-login.c
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@
#include <errno.h>
#include <syslog.h>

#define SCPYN(a, b) strncpy(a, b, sizeof(a))
#define SCPYN(a, b) strncpy(a, b, sizeof(a))

#define NMAX sizeof(utmp.ut_name)

#define FALSE 0
#define TRUE -1
#define FALSE 0
#define TRUE -1

char QUOTAWARN[] = "/usr/ucb/quota"; /* warn user about quotas */
char CANTRUN[] = "login: Can't run ";
Expand Down Expand Up @@ -218,7 +218,7 @@ main(argc, argv)
namep = crypt(pp, pwd->pw_passwd);
setpriority(PRIO_PROCESS, 0, 0);
/* loseit */
#ifdef PARANOIA
#if defined(PARANOIA)
/* If not secure check that password is long enough
and don't allow no-password logins */
if (!ttysecure) {
Expand Down Expand Up @@ -638,7 +638,7 @@ getstr(buf, cnt, err)
char *speeds[] =
{ "0", "50", "75", "110", "134", "150", "200", "300",
"600", "1200", "1800", "2400", "4800", "9600", "19200", "38400" };
#define NSPEEDS (sizeof (speeds) / sizeof (speeds[0]))
#define NSPEEDS (sizeof (speeds) / sizeof (speeds[0]))

doremoteterm(term, tp)
char *term;
Expand All @@ -658,19 +658,19 @@ doremoteterm(term, tp)
tp->sg_flags = ECHO|CRMOD|ANYP|XTABS;
}

#ifdef 0
#if 0
/* Use syslog instead */
logerr(fmt, a1, a2, a3)
char *fmt, *a1, *a2, *a3;
{
#ifdef LOGERR
# if defined(LOGERR)
FILE *cons = fopen("/dev/console", "w");

if (cons != NULL) {
fprintf(cons, fmt, a1, a2, a3);
fprintf(cons, "\n\r");
fclose(cons);
}
#endif
# endif
}
#endif /* 0 */
Loading