[Python-Dev] Revised 1.6 jobs list

Greg Ward gward@mems-exchange.org
Wed, 7 Jun 2000 09:57:41 -0400


--NzB8fVQJ5HfG6fxh
Content-Type: text/plain; charset=us-ascii

On 07 June 2000, I said:
> Then I wrote a little C program (source attached) that does the
> equivalent of

Oops, forgot the attachment.  Here 'tis.

--NzB8fVQJ5HfG6fxh
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="alt_ssh.c"

/*
 * alt_ssh
 *
 * exec ssh with an alternate "identity" (key pair) -- needed since
 * the CVS_RSH variable can't include options for the rsh-like
 * command.
 *
 * GPW 2000/05/28
 *
 * $Id: alt_ssh.c,v 1.3 2000/06/07 13:54:19 gward Exp $
 */

#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>

int main (int argc, char * argv[])
{
    char * keyfile = "/.ssh/alt-identity";
    char * keyfile_full;
    char * home;
    int  num_args;
    char ** ssh_args;
    int i;

    home = getenv("HOME");
    keyfile_full = (char *) malloc (strlen(home) + strlen(keyfile) + 1);
    assert (home != NULL && keyfile_full != NULL);
    strcpy(keyfile_full, home);
    strcat(keyfile_full, keyfile);

    num_args = argc + 2;                /* -i, identity-file */
    ssh_args = (char **) calloc (num_args+1, sizeof(char *));
    ssh_args[0] = "ssh";
    ssh_args[1] = "-i";
    ssh_args[2] = keyfile_full;

    for (i = 3; i < num_args; i++)
        ssh_args[i] = argv[i-2];
    ssh_args[i] = NULL;

    for (i = 0; i < num_args; i++)
    {
        printf(ssh_args[i]);
        if (i < num_args)
            printf(" ");
    }
    printf("\n");
    
    execvp("ssh", ssh_args);
    perror("couldn't exec ssh");
    exit(1);
}

--NzB8fVQJ5HfG6fxh--