Newsgroups: comp.parallel.pvm
From: mcduff@bribie.hpcu.uq.edu.au (Dr. Rodney McDuff)
Subject: Re: Using ssh instead of rsh with PVM?
Organization: Advanced Computation and Modelling Centre,The University of Queensland
Date: 8 May 1996 02:26:08 GMT
Message-ID: <4mp0o0$o2q@hobyah.cc.uq.oz.au>

Fredrik Nyman (ice@eos-vid3.gsfc.nasa.gov) wrote:
: Has anyone managed to get pvm to use ssh rather than ssh to
: open connections?

Yes. The problem is that pvm closes the alot of open file handles. This is no good
for ssh authentication channel. I did something like

+	 int ssh_authentication_fd=-1;
+	 char *evar;
+        if (evar=getenv("SSH_AUTHENTICATION_FD")) {
+                ssh_authentication_fd = atoi(evar);
+        }


        if (!fork()) {
                if (!fork()) {
                        for (cc = getdtablesize(); cc-- > 0; ) {
+                                if (cc!=ssh_authentication_fd) 
                                        (void)close(cc);
                        }
                        (void)open("/dev/null", O_RDONLY, 0);
                        (void)open("/dev/null", O_WRONLY, 0);
                        (void)dup2(1, 2);
                        execvp(av[0], av);
                }
                _exit(0);
        }

My full pacthes are include below. Hope this helps
--

  +-------------------------+------------------------------------------+
  |        _   ^   _        | Dr. Rodney McDuff                        |
  |       |\  /|\  /|       | Advanced Computation and Modelling Centre|
  |         \  |  /         | The University of Queensland             |
  |          \ | /          | St. Lucia, Brisbane                      |
  |           \|/           | Queensland, Australia. 4072.             |
  |   <--------+-------->   |                                          |
  |           /|\           | TELEPHONE: +61 7 365 7415                |
  |          / | \          | INTERNET:mcduff@bribie.hpcu.uq.edu.au    |
  |         /  |  \         | FACSIMILE: +61 7 365 1242                |
  |       |/  \|/  \|       |                                          |
  |        -   v   -        |        Ex ignorantia ad sapientiam       |
  |                         |            Ex luce ad tenebras           |
  +-------------------------+------------------------------------------+
diff src/lpvm.c src.orig/lpvm.c
2590a2591
> 
2599,2601c2600
<       int cc,ssh_authentication_fd=-1;
<       char *evar;
<       
---
>       int cc;
2645,2649d2643
<       if (evar=getenv("SSH_AUTHENTICATION_FD")) {
<               ssh_authentication_fd = atoi(evar);
<       }
< 
< 
2652,2655c2646,2647
<                       for (cc = getdtablesize(); cc-- > 0; ) {
<                               if (cc!=ssh_authentication_fd) 
<                                       (void)close(cc);
<                       }
---
>                       for (cc = getdtablesize(); cc-- > 0; )
>                               (void)close(cc);
diff src/pvmd.c src.orig/pvmd.c
2698,2699c2698
<       int i,ssh_authentication_fd=-1;
<       char *evar;
---
>       int i;
2779,2783d2777
< 
<                       if (evar=getenv("SSH_AUTHENTICATION_FD")) {
<                               ssh_authentication_fd = atoi(evar);
<                       }
< 
2790,2794c2784,2785
<                               for (i = getdtablesize(); --i > 2; ) {
<                                       if (i!=ssh_authentication_fd) {
<                                               (void)close(i);
<                                       }
<                               }
---
>                               for (i = getdtablesize(); --i > 2; )
>                                       (void)close(i);
2871,2872c2862
<       int i,ssh_authentication_fd=-1;
<       char *evar;
---
>       int i;
2912,2915d2901
<       if (evar=getenv("SSH_AUTHENTICATION_FD")) {
<               ssh_authentication_fd = atoi(evar);
<       }
< 
2917c2903
<               if (i != netsock && i != log_fd && i != ssh_authentication_fd)
---
>               if (i != netsock && i != log_fd)
diff src/startup.c src.orig/startup.c
576,577c576,577
<       int i,ssh_authentication_fd=-1;
<       char *s,*evar;
---
>       int i;
>       char *s;
661,664d660
<       
<       if (evar=getenv("SSH_AUTHENTICATION_FD")) {
<               ssh_authentication_fd = atoi(evar);
<       }
668c664
<               if (i != netsock && i != ppnetsock && i != loclsock && i != log_fd && i  != ssh_authentication_fd )
---
>               if (i != netsock && i != ppnetsock && i != loclsock && i != log_fd)
698c694
<       int i, j,ssh_authentication_fd=-1;
---
>       int i, j;
703c699
<       char *p,*evar;
---
>       char *p;
792,794d787
<               if (evar=getenv("SSH_AUTHENTICATION_FD")) {
<                       ssh_authentication_fd = atoi(evar);
<               }
798c791
<                       if (i != netsock && i != loclsock && i != log_fd && i != ssh_authentication_fd)
---
>                       if (i != netsock && i != loclsock && i != log_fd)
1229,1230c1222
<               int i,ssh_authentication_fd=-1;
<               char *evar;
---
>               int i;
1258,1261d1249
<               
<               if (evar=getenv("SSH_AUTHENTICATION_FD")) {
<                       ssh_authentication_fd = atoi(evar);
<               }
1271,1275c1259,1260
<                       for (i = getdtablesize(); --i > 2; ) {
<                               if (i!=ssh_authentication_fd) {
<                                       (void)close(i);
<                               }
<                       }
---
>                       for (i = getdtablesize(); --i > 2; )
>                               (void)close(i);

