Adding a feature to the smbd

Thomas Langås tlan at stud.ntnu.no
Sun Jan 21 00:28:49 GMT 2001


I did some altering of the code I just sent (it's attached to this mail),
this is the code we're going to use at my university. After checking syslog
I see that the code is actually run for all shares, however, it's only
effective when it should be. So my question is, why is it run for every
share? 

-- 
-Thomas
-------------- next part --------------
495d494
< static BOOL handle_enhanced_path(char *pszParmValue,char **ptr);
562d560
<   {"enhanced path",    P_STRING,  P_LOCAL,  &sDefault.szPath,           handle_enhanced_path,   NULL,  FLAG_BASIC|FLAG_SHARE|FLAG_PRINT|FLAG_DOS_STRING},
1338,1339d1335
< //Don't know is this one is needed...
< FN_LOCAL_STRING(lp_enhanced_pathname,szPath)
1938,1991d1933
< 
< /***************************************************************************
<  This routine allows you to define a shell-script/program that returns a
<  string. This string will then be the path used.
<  pszParmValue - Contains the command
<  ptr          - Points to szPath
<  This routine is done by Thomas Lang?s (tlan at stud.ntnu.no)
< ***************************************************************************/
< static BOOL handle_enhanced_path(char *pszParmValue,char **ptr)
< {
< 	pstring output, cmd, temp;
< 	FILE *mypipe;
< 	int retvalue,i;
< 
< 	retvalue = 0;
< 
< 	pstrcpy(temp, *ptr);
< 	//If they've set path = already, we don't do this
< 	if (strlen(temp)>0) {
< 		DEBUG(0, ("handle_enhanced_path: \047path =\047 already set \047szPath = %s\047\n", temp));
< 		return (True);
< 	}
< 
< 	pstrcpy(cmd, pszParmValue);
< 	standard_sub_basic(cmd);
< 
< 	//sys_popen is a safe-wrapper around popen...
< 	if ((mypipe = sys_popen(cmd, "r", False)) != NULL) {
< 		if (fgets(output, sizeof(output), mypipe) != NULL) {
< 			retvalue = pclose(mypipe);
< 		} else {
< 			//Just ditch the rest of the output
< 			while (fgets(cmd, sizeof(cmd), mypipe) != NULL) {}
< 			retvalue = pclose(mypipe); 
< 		}
< 
<                 for (i=0;i<strlen(output);i++)
< 			if (output[i] == '\n')
< 				output[i] = '\0';
< 
< 		if (retvalue != 0) 
< 			DEBUG(0, ("handle_enhanced_path: Command exited with value %d, it echoed \047%s\047\n", retvalue, output));
< 
< 		unix_to_dos(output, True);
< 
< 		string_set(ptr, (char *) &output[0]);
< 		return(True);
< 	} else { //Error
< 		DEBUG(0, ("handle_enhanced_path: Failed trying to open \047%s\047 as pipe\n", pszParmValue));
< 		DEBUG(1, ("handle_enhanced_path: Actuall command was \047%s\047\n", cmd));
< 		return(True);
< 	}
< }
< 


More information about the samba-technical mailing list