HP-UX /etc/PATH

Stuart Craig scraig at eli.net
Fri Aug 25 09:50:48 EST 2000


Attached is an improved patch for the HP-UX /etc/PATH file, which also
uses the compiled-in default PATH information.

So far, the new snapshot is working well under HP-UX 10.20, built with
gcc 2.95.  I plan to do more testing tomorrow, and I will also build it
using the HP ANSI C compiler, and test it under HP-UX 11 and Red Hat
6.2.

 - Stu

--
Stuart J. Craig <scraig at eli.net>
Senior UNIX Administrator
Electric Lightwave, Inc.
-------------- next part --------------
*** session.c.orig	Tue Aug 22 17:46:24 2000
--- session.c	Thu Aug 24 11:59:05 2000
***************
*** 1116,1121 ****
--- 1116,1159 ----
  	do_pam_environment(&env, &envsize);
  #endif /* USE_PAM */
  
+ #ifdef HAVE_ETC_PATH
+ 	/* Under versions 10 and 11 of HP-UX, the /etc/PATH file should
+ 	 * contain a single line which is the value for the PATH environment
+ 	 * variable.  We will append this value to the default openssh PATH.
+          * We don't actually set the PATH unless /etc/PATH contains something.
+ 	 */
+ #define EPBUFLEN 4096
+ 	{
+ 		char epbuf[EPBUFLEN];
+ 		char *epptr;
+ 		int eplen;
+ 
+ 		f = fopen("/etc/PATH", "r");
+ 		if (f) {
+ 		    strncpy(epbuf, _PATH_STDPATH, EPBUFLEN - 2);
+ 		    epbuf[EPBUFLEN - 1] = '\0'; /* Make sure it's terminated */
+ 		    if((eplen = strlen(epbuf)) > 0) {
+ 			epptr = epbuf + eplen++;
+ 			*epptr++ = ':';
+ 		    }
+ 		    else
+ 			epptr = epbuf;
+ 
+ 		    /* This is pretty arbitrary -- make sure there's at least
+ 		     * a bit of space left in the buffer. */
+ 		    if(eplen < EPBUFLEN - 80) {
+ 			if (fgets(epptr, EPBUFLEN - eplen, f)) {
+ 			    if (strchr(epptr, '\n'))
+ 				*strchr(epptr, '\n') = '\0';
+ 			    if (strlen(epptr) > 0)
+ 				child_set_env(&env, &envsize, "PATH", epbuf);
+ 			}
+ 		    }
+ 		    fclose(f);
+ 		}
+ 	}
+ #endif /* HAVE_ETC_PATH */
+ 
  	read_environment_file(&env,&envsize,"/etc/environment");
  
  	if (xauthfile)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 2515 bytes
Desc: S/MIME Cryptographic Signature
Url : http://lists.mindrot.org/pipermail/openssh-unix-dev/attachments/20000824/de35bf1f/attachment.bin 


More information about the openssh-unix-dev mailing list