Samba-2.0.0-beta5

Pascal A. Dupuis dupuis at lei.ucl.ac.be
Tue Jan 5 08:56:29 GMT 1999


		[I'm not subscribed to the lists. Please CC any reply]

There are still a number of what I consider superflous calls to getenv()
in src/client/client.c. I had time to complain, now I take the time to
make a patch ;-)

-Modified the get_password_file() to be called with two args : first is a
pointer to an anv variable, second is a "method", currently one or two
-modified blocks like 
	if (getenv("USER")) {
                pstrcpy(username,getenv("USER"));
 as :
	if ((ptmp=getenv("USER"))) {
                pstrcpy(username, ptmp);

Changes are quite obvious. They are working here. (i686-pc-linux-glibc2)

Greetings

Pascal A. Dupuis 


-- 
linux : un noyau
windows : des pépins

-------------- next part --------------
--- client.c.org	Tue Jan  5 09:35:18 1999
+++ client.c	Tue Jan  5 09:44:22 1999
@@ -1773,7 +1773,7 @@
 get a password from a a file or file descriptor
 exit on failure
 ****************************************************************************/
-static void get_password_file(void)
+static void get_password_file(char *name, int method)
 {
 	int fd = -1;
 	char *p;
@@ -1781,14 +1781,14 @@
 	pstring spec;
 	char pass[128];
 		
-	if ((p = getenv("PASSWD_FD")) != NULL) {
+	if (1 == method) {
 		pstrcpy(spec, "descriptor ");
-		pstrcat(spec, p);
-		sscanf(p, "%d", &fd);
+		pstrcat(spec, name);
+		sscanf(name, "%d", &fd);
 		close_it = False;
-	} else if ((p = getenv("PASSWD_FILE")) != NULL) {
-		fd = sys_open(p, O_RDONLY, 0);
-		pstrcpy(spec, p);
+	} else if (2 == method) {
+		fd = sys_open(name, O_RDONLY, 0);
+		pstrcpy(spec, name);
 		if (fd < 0) {
 			fprintf(stderr, "Error opening PASSWD_FILE %s: %s\n",
 				spec, strerror(errno));
@@ -1796,6 +1796,11 @@
 		}
 		close_it = True;
 	}
+	else {
+	  fprintf(stderr, "%s internal error : method should be 1 or 2\n",
+		  __FILE__);
+	  exit(1);
+	}
 
 	for(p = pass, *p = '\0'; /* ensure that pass is null-terminated */
 	    p && p - pass < sizeof(pass);) {
@@ -1921,7 +1926,7 @@
 	static pstring servicesf = CONFIGFILE;
 	pstring term_code;
 	pstring new_name_resolve_order;
-	char *p;
+	char *p, *ptmp;
 
 #ifdef KANJI
 	pstrcpy(term_code, KANJI);
@@ -1965,8 +1970,8 @@
 	myumask = umask(0);
 	umask(myumask);
 
-	if (getenv("USER")) {
-		pstrcpy(username,getenv("USER"));
+	if ((ptmp=getenv("USER"))) {
+		pstrcpy(username, ptmp);
 
 		/* modification to support userid%passwd syntax in the USER var
 		   25.Aug.97, jdblair at uab.edu */
@@ -1982,18 +1987,21 @@
 
 	/* modification to support PASSWD environmental var
 	   25.Aug.97, jdblair at uab.edu */
-	if (getenv("PASSWD")) {
-		pstrcpy(password,getenv("PASSWD"));
+	if ((ptmp=getenv("PASSWD"))) {
+		pstrcpy(password, ptmp);
 		got_pass = True;
 	}
 
-	if (getenv("PASSWD_FD") || getenv("PASSWD_FILE")) {
-		get_password_file();
+	if ((ptmp=getenv("PASSWD_FD"))) {
+                get_password_file(ptmp, 1);
+                got_pass = True;
+        } else if ((ptmp=getenv("PASSWD_FILE"))) {
+		get_password_file(ptmp, 2);
 		got_pass = True;
 	}
 
-	if (*username == 0 && getenv("LOGNAME")) {
-		pstrcpy(username,getenv("LOGNAME"));
+	if (*username == 0 && (ptmp=getenv("LOGNAME")) != NULL) {
+		pstrcpy(username, ptmp);
 		strupper(username);
 	}
 


More information about the samba-technical mailing list