summaryrefslogtreecommitdiffstats
path: root/usr.bin/rlogin
diff options
context:
space:
mode:
authorpeter <peter@FreeBSD.org>1999-05-25 11:14:33 +0000
committerpeter <peter@FreeBSD.org>1999-05-25 11:14:33 +0000
commit1245084308e713dbd3aaf2c69a72adef9d65cf93 (patch)
tree29f183078f3b80344e5e0519e9e77b50bc35d3fd /usr.bin/rlogin
parentb12800119af0fe4e1e856b7f769743ba5ad73047 (diff)
downloadFreeBSD-src-1245084308e713dbd3aaf2c69a72adef9d65cf93.zip
FreeBSD-src-1245084308e713dbd3aaf2c69a72adef9d65cf93.tar.gz
Add a -i localname switch (restricted to root) to specify a different
local "login" name for rcmd(3). This is particularly useful for things like portslave and other packages with terminal server functionality where a login can either run ppp locally or get shunted off to another box via rlogin depending on radius authentication etc. Quite often the local box doesn't even have accounts, so a flag such as this is needed. Obviously this is restricted to callers with uid == 0.
Diffstat (limited to 'usr.bin/rlogin')
-rw-r--r--usr.bin/rlogin/rlogin.16
-rw-r--r--usr.bin/rlogin/rlogin.c20
2 files changed, 21 insertions, 5 deletions
diff --git a/usr.bin/rlogin/rlogin.1 b/usr.bin/rlogin/rlogin.1
index 869791f..9290ea1 100644
--- a/usr.bin/rlogin/rlogin.1
+++ b/usr.bin/rlogin/rlogin.1
@@ -41,6 +41,7 @@
.Ar rlogin
.Op Fl 8DEKLdx
.Op Fl e Ar char
+.Op Fl i Ar localname
.Op Fl k Ar realm
.Op Fl l Ar username
.Ar host
@@ -98,6 +99,11 @@ option allows user specification of the escape character, which is
``~'' by default.
This specification may be as a literal character, or as an octal
value in the form \ennn.
+.It Fl i
+The
+.Fl i
+option allows the caller to specify a different local name to be used
+for authentication. This option is restricted to processes with uid 0.
.It Fl k
The
.Fl k
diff --git a/usr.bin/rlogin/rlogin.c b/usr.bin/rlogin/rlogin.c
index e6ee16c..1af423d 100644
--- a/usr.bin/rlogin/rlogin.c
+++ b/usr.bin/rlogin/rlogin.c
@@ -40,7 +40,7 @@ static const char copyright[] =
#ifndef lint
static const char sccsid[] = "@(#)rlogin.c 8.1 (Berkeley) 6/6/93";
static const char rcsid[] =
- "$Id: rlogin.c,v 1.17 1998/03/26 18:03:41 markm Exp $";
+ "$Id: rlogin.c,v 1.18 1998/10/09 06:45:28 markm Exp $";
#endif /* not lint */
/*
@@ -154,6 +154,7 @@ main(argc, argv)
#ifdef KERBEROS
char *k;
#endif
+ char *localname = NULL;
argoff = dflag = Dflag = 0;
one = 1;
@@ -174,9 +175,9 @@ main(argc, argv)
}
#ifdef KERBEROS
-#define OPTIONS "8DEKLde:k:l:x"
+#define OPTIONS "8DEKLde:i:k:l:x"
#else
-#define OPTIONS "8DEKLde:l:"
+#define OPTIONS "8DEKLde:i:l:"
#endif
while ((ch = getopt(argc - argoff, argv + argoff, OPTIONS)) != -1)
switch(ch) {
@@ -204,6 +205,13 @@ main(argc, argv)
noescape = 0;
escapechar = getescape(optarg);
break;
+ case 'i':
+ if (getuid() != 0) {
+ fprintf(stderr, "rlogin: -i user: permission denied\n");
+ exit(1);
+ }
+ localname = optarg;
+ break;
#ifdef KERBEROS
case 'k':
dest_realm = dst_realm_buf;
@@ -237,6 +245,8 @@ main(argc, argv)
errx(1, "unknown user id");
if (!user)
user = pw->pw_name;
+ if (!localname)
+ localname = pw->pw_name;
sp = NULL;
#ifdef KERBEROS
@@ -324,10 +334,10 @@ main(argc, argv)
if (doencrypt)
errx(1, "the -x flag requires Kerberos authentication");
#endif /* CRYPT */
- rem = rcmd(&host, sp->s_port, pw->pw_name, user, term, 0);
+ rem = rcmd(&host, sp->s_port, localname, user, term, 0);
}
#else
- rem = rcmd(&host, sp->s_port, pw->pw_name, user, term, 0);
+ rem = rcmd(&host, sp->s_port, localname, user, term, 0);
#endif /* KERBEROS */
if (rem < 0)
OpenPOWER on IntegriCloud