From: Ezra Peisach Date: Mon, 8 Apr 1996 02:47:37 +0000 (+0000) Subject: Add an option -L to pass an environment variable to a client. X-Git-Tag: krb5-1.0-beta6~260 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=065e4060cca04b939b83b8b03bb65ddfcddfac51;p=krb5.git Add an option -L to pass an environment variable to a client. This is used by the DejaGnu test suite to pass the shared library paths to start up rcp properly. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@7752 dc483132-0cff-0310-8789-dd5450dbe970 --- diff --git a/src/appl/bsd/ChangeLog b/src/appl/bsd/ChangeLog index 3cdec7a68..527407bf1 100644 --- a/src/appl/bsd/ChangeLog +++ b/src/appl/bsd/ChangeLog @@ -1,3 +1,8 @@ +Sun Apr 7 22:46:07 1996 Ezra Peisach + + * krshd.c: Add an option -L to pass certain environment variables + to the client. + Wed Apr 3 17:09:19 1996 Richard Basch * krlogind.c: Under Solaris, when the connection pipe goes away, diff --git a/src/appl/bsd/krshd.c b/src/appl/bsd/krshd.c index c701850fa..867319700 100644 --- a/src/appl/bsd/krshd.c +++ b/src/appl/bsd/krshd.c @@ -155,7 +155,7 @@ char copyright[] = #include "com_err.h" #include "loginpaths.h" -#define ARGSTR "rek54cD:S:M:AP:?" +#define ARGSTR "rek54cD:S:M:AP:?L:" #define RSHD_BUFSIZ 5120 @@ -211,6 +211,11 @@ char *progname; #define MAX_PROG_NAME 10 +/* Leave room for 4 environment variables to be passed */ +#define MAXENV 4 +char *save_env[MAXENV]; +int num_env = 0; + #ifdef CRAY int secflag; extern @@ -351,6 +356,20 @@ main(argc, argv) case 'P': kprogdir = optarg; break; + + case 'L': + if (num_env < MAXENV) { + save_env[num_env] = strdup(optarg); + if(!save_env[num_env++]) { + com_err(progname, ENOMEM, "in saving environment"); + exit(2); + } + } else { + fprintf(stderr, "%s: Only %d -L arguments allowed\n", + progname, MAXENV); + exit(2); + } + break; #endif case 'D': debug_port = atoi(optarg); @@ -442,20 +461,21 @@ char shell[64] = "SHELL="; char term[64] = "TERM=network"; char path_rest[] = RPATH; +/* The following include extra space for TZ and MAXENV pointers... */ #ifdef CRAY char *envinit[] = -{homedir, shell, 0, username, "TZ=GMT0", tmpdir, term, 0,0}; +{homedir, shell, 0, username, "TZ=GMT0", tmpdir, term, 0, 0, 0, 0, 0, 0}; #define TZENV 4 #define TMPDIRENV 5 char *getenv(); #else /* CRAY */ #ifdef KERBEROS char *envinit[] = -{homedir, shell, 0, username, term, 0, 0, 0}; +{homedir, shell, 0, username, term, 0, 0, 0, 0, 0, 0, 0}; #define TZENV 5 #else /* KERBEROS */ char *envinit[] = -{homedir, shell, 0, username, term, 0, 0}; +{homedir, shell, 0, username, term, 0, 0, 0, 0, 0, 0}; #define TZENV 5 #endif /* KERBEROS */ #endif /* CRAY */ @@ -1285,12 +1305,30 @@ if (ccache) int i; char *buf = (char *)malloc(strlen(getenv("KRB5CCNAME")) +strlen("KRB5CCNAME=")+1); - if (buf) { - sprintf(buf, "KRB5CCNAME=%s",getenv("KRB5CCNAME")); - - for (i = 0; envinit[i]; i++); - envinit[i] =buf; - } + if (buf) { + sprintf(buf, "KRB5CCNAME=%s",getenv("KRB5CCNAME")); + + for (i = 0; envinit[i]; i++); + envinit[i] =buf; + } + } + + /* If we do anything else, make sure there is space in the array. */ + + for(cnt=0; cnt < num_env; cnt++) { + int i; + char *buf; + + if(getenv(save_env[cnt])) { + buf = (char *)malloc(strlen(getenv(save_env[cnt])) + +strlen(save_env[cnt]+2)); + if (buf) { + sprintf(buf, "%s=%s", save_env[cnt], + getenv(save_env[cnt])); + for (i = 0; envinit[i]; i++); + envinit[i] =buf; + } + } } /* XXX - If we do anything else, make sure there is space in the array. */