summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/cu/cu.123
-rw-r--r--usr.bin/cu/cu.c25
2 files changed, 31 insertions, 17 deletions
diff --git a/usr.bin/cu/cu.1 b/usr.bin/cu/cu.1
index be0b8c7388a..035e3793cf7 100644
--- a/usr.bin/cu/cu.1
+++ b/usr.bin/cu/cu.1
@@ -1,4 +1,4 @@
-.\" $OpenBSD: cu.1,v 1.10 2014/03/26 13:00:50 nicm Exp $
+.\" $OpenBSD: cu.1,v 1.11 2014/03/31 09:09:19 nicm Exp $
.\"
.\" Copyright (c) 1980, 1990, 1993
.\" The Regents of the University of California. All rights reserved.
@@ -29,7 +29,7 @@
.\"
.\" @(#)tip.1 8.4 (Berkeley) 4/18/94
.\"
-.Dd $Mdocdate: March 26 2014 $
+.Dd $Mdocdate: March 31 2014 $
.Dt CU 1
.Os
.Sh NAME
@@ -79,7 +79,7 @@ is given,
.Nm
uses the
.Xr remote 5
-host description file to retrieve the
+database to retrieve the
.Sy dv Pq device
and
.Sy br Pq baud rate
@@ -152,16 +152,25 @@ dialogue and return the user to the remote machine.
guards against multiple users connecting to a remote system by opening
modems and terminal lines with exclusive access.
.Sh ENVIRONMENT
-If
-.Ev REMOTE
-is set and begins with a slash, the named file is searched before the
+.Bl -tag -width REMOTEXXX
+.It Ev HOST
+The default value for
+.Ar host
+if none is specified via the command line.
+.It Ev REMOTE
+A system description, or an absolute path to a
.Xr remote 5
-host description file; otherwise it is searched for as a host.
+system description database.
+.El
.Sh FILES
.Bl -tag -width /etc/remote
.It Pa /etc/remote
host description file
.El
+.Sh EXIT STATUS
+.Ex -std cu
+.Sh SEE ALSO
+.Xr remote 5
.Sh HISTORY
The
.Nm
diff --git a/usr.bin/cu/cu.c b/usr.bin/cu/cu.c
index 219e90f0e7a..769caf811da 100644
--- a/usr.bin/cu/cu.c
+++ b/usr.bin/cu/cu.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: cu.c,v 1.16 2014/03/26 13:00:50 nicm Exp $ */
+/* $OpenBSD: cu.c,v 1.17 2014/03/31 09:09:19 nicm Exp $ */
/*
* Copyright (c) 2012 Nicholas Marriott <nicm@openbsd.org>
@@ -60,7 +60,7 @@ void stream_read(struct bufferevent *, void *);
void stream_error(struct bufferevent *, short, void *);
void line_read(struct bufferevent *, void *);
void line_error(struct bufferevent *, short, void *);
-void try_remote(const char *, const char *);
+void try_remote(const char *, const char *, const char *);
__dead void
usage(void)
@@ -74,7 +74,7 @@ int
main(int argc, char **argv)
{
const char *errstr;
- char *tmp, *s;
+ char *tmp, *s, *host;
int opt, i;
if (isatty(STDIN_FILENO) && tcgetattr(STDIN_FILENO, &saved_tio) != 0)
@@ -113,14 +113,17 @@ main(int argc, char **argv)
if (argc != 0 && argc != 1)
usage();
- s = getenv("REMOTE");
- if (argc == 1) {
+ if (argc == 1)
+ host = argv[0];
+ else
+ host = getenv("HOST");
+ if (host != NULL && *host != '\0') {
+ s = getenv("REMOTE");
if (s != NULL && *s == '/')
- try_remote(argv[0], s);
+ try_remote(host, s, NULL);
else
- try_remote(argv[0], NULL);
- } else if (s != NULL && *s != '/')
- try_remote(s, NULL);
+ try_remote(host, NULL, s);
+ }
if (line_path == NULL)
line_path = "/dev/cua00";
@@ -306,7 +309,7 @@ line_error(struct bufferevent *bufev, short what, void *data)
}
void
-try_remote(const char *host, const char *path)
+try_remote(const char *host, const char *path, const char *entry)
{
const char *paths[] = { "/etc/remote", NULL, NULL };
char *cp, *s;
@@ -318,6 +321,8 @@ try_remote(const char *host, const char *path)
paths[1] = "/etc/remote";
}
+ if (entry != NULL && cgetset(entry) != 0)
+ cu_errx(1, "cgetset failed");
error = cgetent(&cp, (char**)paths, (char*)host);
if (error < 0) {
switch (error) {