From c3cf075a1673640ad9d31f02ff6a1b2e14dc86ce Mon Sep 17 00:00:00 2001 From: Ezra Peisach Date: Thu, 2 Nov 1995 21:18:58 +0000 Subject: [PATCH] If invoked with the -D port option, do not die if proper entry is missing from /etc/services... This is for the dejagnu suite running on a machine following the installation instructions - i.e. make, make check. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@7010 dc483132-0cff-0310-8789-dd5450dbe970 --- src/appl/bsd/ChangeLog | 5 +++++ src/appl/bsd/krcp.c | 40 ++++++++++++++++++++++++---------------- src/appl/bsd/krlogin.c | 39 +++++++++++++++++++++++---------------- src/appl/bsd/krsh.c | 23 +++++++++++++---------- 4 files changed, 65 insertions(+), 42 deletions(-) diff --git a/src/appl/bsd/ChangeLog b/src/appl/bsd/ChangeLog index b56cfaa30..7d121ffe8 100644 --- a/src/appl/bsd/ChangeLog +++ b/src/appl/bsd/ChangeLog @@ -1,3 +1,8 @@ +Thu Nov 2 16:16:47 1995 Ezra Peisach + + * 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 * 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. diff --git a/src/appl/bsd/krcp.c b/src/appl/bsd/krcp.c index c5e0c8afc..42bb65591 100644 --- a/src/appl/bsd/krcp.c +++ b/src/appl/bsd/krcp.c @@ -117,7 +117,7 @@ int pflag; int forcenet; struct passwd *pwd; int userid; -int port; +int port = 0; struct buffer { int cnt; @@ -153,25 +153,12 @@ main(argc, argv) 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"); @@ -271,6 +258,27 @@ main(argc, argv) 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); diff --git a/src/appl/bsd/krlogin.c b/src/appl/bsd/krlogin.c index 135fa2606..3c2a78761 100644 --- a/src/appl/bsd/krlogin.c +++ b/src/appl/bsd/krlogin.c @@ -322,8 +322,8 @@ main(argc, argv) 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; @@ -341,7 +341,7 @@ main(argc, argv) if (argc > 0 && !strcmp(*argv, "-D")) { argv++; argc--; - debug_port = atoi(*argv); + debug_port = htons(atoi(*argv)); argv++; argc--; goto another; } @@ -459,28 +459,38 @@ main(argc, argv) 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); @@ -546,9 +556,6 @@ main(argc, argv) 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; @@ -560,7 +567,7 @@ main(argc, argv) 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, @@ -588,7 +595,7 @@ main(argc, argv) 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 */ diff --git a/src/appl/bsd/krsh.c b/src/appl/bsd/krsh.c index cb847a578..80be6dbeb 100644 --- a/src/appl/bsd/krsh.c +++ b/src/appl/bsd/krsh.c @@ -130,6 +130,7 @@ main(argc, argv0) fd_set readfrom, ready; int one = 1; struct servent *sp; + #ifdef POSIX_SIGNALS sigset_t omask, igmask; struct sigaction sa, osa; @@ -140,8 +141,8 @@ main(argc, argv0) 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; @@ -159,7 +160,7 @@ main(argc, argv0) if (argc > 0 && !strcmp(*argv, "-D")) { argv++; argc--; - debug_port = atoi(*argv); + debug_port = htons(atoi(*argv)); argv++; argc--; goto another; } @@ -309,12 +310,14 @@ main(argc, argv0) 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); @@ -322,11 +325,11 @@ main(argc, 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); @@ -339,7 +342,7 @@ main(argc, argv0) 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, @@ -368,7 +371,7 @@ main(argc, argv0) 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); -- 2.26.2