+Thu Nov 2 16:16:47 1995 Ezra Peisach <epeisach@kangaroo.mit.edu>
+
+ * krlogin.c, krcp.c, krsh.c (main): If invoked with -D port, do
+ not die if entry is missing from /etc/services.
+
Mon Oct 16 17:27:43 1995 Sam Hartman <hartmans@tertius.mit.edu>
* login.c (main): Don't print warning about no tickets obtained if we didn't ask for a password. Also, define LOGNAME for so sysvish systems are happy. Patch from ramus@nersc.gov.
int forcenet;
struct passwd *pwd;
int userid;
-int port;
+int port = 0;
struct buffer {
int cnt;
int euid;
char **orig_argv = save_argv(argc, argv);
- sp = getservbyname("kshell", "tcp");
krb5_init_context(&bsd_context);
krb5_init_ets(bsd_context);
desinbuf.data = des_inbuf;
desoutbuf.data = des_outbuf; /* Set up des buffers */
-#else
- sp = getservbyname("shell", "tcp");
-#endif /* KERBEROS */
-
- if (sp == NULL) {
-#ifdef KERBEROS
- fprintf(stderr, "rcp: kshell/tcp: unknown service\n");
- try_normal(orig_argv);
-#else
- fprintf(stderr, "rcp: shell/tcp: unknown service\n");
- exit(1);
-#endif /* KERBEROS */
- }
- port = sp->s_port;
+#endif
+
pwd = getpwuid(userid = getuid());
if (pwd == 0) {
fprintf(stderr, "who are you?\n");
if (argc > 2)
targetshouldbedirectory = 1;
rem = -1;
+
+
+ if (port == 0) {
+#ifdef KERBEROS
+ sp = getservbyname("kshell", "tcp");
+#else
+ sp = getservbyname("shell", "tcp");
+#endif /* KERBEROS */
+
+ if (sp == NULL) {
+#ifdef KERBEROS
+ fprintf(stderr, "rcp: kshell/tcp: unknown service\n");
+ try_normal(orig_argv);
+#else
+ fprintf(stderr, "rcp: shell/tcp: unknown service\n");
+ exit(1);
+#endif /* KERBEROS */
+ }
+ port = sp->s_port;
+ }
+
#ifdef KERBEROS
if (krb_realm != NULL)
cmdsiz += strlen(krb_realm);
int sock;
krb5_flags authopts;
krb5_error_code status;
- int debug_port = 0;
#endif
+ int debug_port = 0;
if (strrchr(argv[0], '/'))
argv[0] = strrchr(argv[0], '/')+1;
if (argc > 0 && !strcmp(*argv, "-D")) {
argv++; argc--;
- debug_port = atoi(*argv);
+ debug_port = htons(atoi(*argv));
argv++; argc--;
goto another;
}
krb5_init_ets(bsd_context);
desinbuf.data = des_inbuf;
desoutbuf.data = des_outbuf; /* Set up des buffers */
+#endif
+
+
+ if(debug_port == 0) {
+#ifdef KERBEROS
/*
* if there is an entry in /etc/services for Kerberos login,
* attempt to login with Kerberos.
* If we fail at any step, use the standard rlogin
*/
- if (encrypt_flag)
- sp = getservbyname("eklogin","tcp");
- else
- sp = getservbyname("klogin","tcp");
- if (sp == 0) {
+ if (encrypt_flag)
+ sp = getservbyname("eklogin","tcp");
+ else
+ sp = getservbyname("klogin","tcp");
+ if (sp == 0) {
fprintf(stderr, "rlogin: %s/tcp: unknown service\n",
encrypt_flag ? "eklogin" : "klogin");
try_normal(orig_argv);
- }
+ }
#else
- sp = getservbyname("login", "tcp");
- if (sp == 0) {
+ sp = getservbyname("login", "tcp");
+ if (sp == 0) {
fprintf(stderr, "rlogin: login/tcp: unknown service\n");
exit(2);
- }
+ }
#endif /* KERBEROS */
+
+ debug_port = sp->s_port;
+ }
+
+
if (cp == (char *) NULL) cp = getenv("TERM");
if (cp)
(void) strcpy(term, cp);
oldmask = sigblock(sigmask(SIGURG) | sigmask(SIGUSR1));
#endif
#endif /* POSIX_SIGNALS */
-
- if (debug_port)
- sp->s_port = htons(debug_port);
#ifdef KERBEROS
authopts = AP_OPTS_MUTUAL_REQUIRED;
if (Fflag)
authopts |= OPTS_FORWARDABLE_CREDS;
- status = kcmd(&sock, &host, sp->s_port,
+ status = kcmd(&sock, &host, debug_port,
null_local_username ? NULL : pwd->pw_name,
name ? name : pwd->pw_name, term,
0, "host", krb_realm,
exit(1);
}
#else
- rem = rcmd(&host, sp->s_port,
+ rem = rcmd(&host, debug_port,
null_local_username ? NULL : pwd->pw_name,
name ? name : pwd->pw_name, term, 0);
#endif /* KERBEROS */
fd_set readfrom, ready;
int one = 1;
struct servent *sp;
+
#ifdef POSIX_SIGNALS
sigset_t omask, igmask;
struct sigaction sa, osa;
krb5_flags authopts;
krb5_error_code status;
int fflag = 0, Fflag = 0, Aflag = 0;
- int debug_port = 0;
#endif /* KERBEROS */
+ int debug_port = 0;
if (strrchr(argv[0], '/'))
argv[0] = strrchr(argv[0], '/')+1;
if (argc > 0 && !strcmp(*argv, "-D")) {
argv++; argc--;
- debug_port = atoi(*argv);
+ debug_port = htons(atoi(*argv));
argv++; argc--;
goto another;
}
if (ap[1])
*cp++ = ' ';
}
+
+ if(debug_port == 0) {
#ifdef KERBEROS
- sp = getservbyname("kshell", "tcp");
+ sp = getservbyname("kshell", "tcp");
#else
- sp = getservbyname("shell", "tcp");
+ sp = getservbyname("shell", "tcp");
#endif /* KERBEROS */
- if (sp == 0) {
+ if (sp == 0) {
#ifdef KERBEROS
fprintf(stderr, "rsh: kshell/tcp: unknown service\n");
try_normal(argv0);
fprintf(stderr, "rsh: shell/tcp: unknown service\n");
#endif /* KERBEROS */
exit(1);
+ }
+
+ debug_port = sp->s_port;
}
- if (debug_port)
- sp->s_port = htons(debug_port);
-
#ifdef KERBEROS
krb5_init_context(&bsd_context);
krb5_init_ets(bsd_context);
if (Fflag)
authopts |= OPTS_FORWARDABLE_CREDS;
- status = kcmd(&rem, &host, sp->s_port,
+ status = kcmd(&rem, &host, debug_port,
pwd->pw_name,
user ? user : pwd->pw_name,
args, &rfd2, "host", krb_realm,
exit(1);
}
#else /* !KERBEROS */
- rem = rcmd(&host, sp->s_port, pwd->pw_name,
+ rem = rcmd(&host, debug_port, pwd->pw_name,
user ? user : pwd->pw_name, args, &rfd2);
if (rem < 0)
exit(1);