Adding a feature to the smbd

Thomas Langås tlan at stud.ntnu.no
Sat Jan 20 20:13:41 GMT 2001


Hi!

I've been trying to add a feature I called "enhanced path" to the smb.conf,
basically this was meant to be a command you specified (for instance a
shell-script) which, when executed, gave _one_ line of output, and this was
then treated as path. I only added a few lines of code, but it don't seem to
work like it should, cause the "enhanced path" option doesn't run. So, this
is what I did to the samba-code:

(all from loadparam.c)
This is the diff from the original one:
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,1976d1933
< 
<
/***************************************************************************
<  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;
<       FILE *mypipe;
<       int retvalue;
< 
<       pstrcpy(cmd, pszParmValue);
<       standard_sub_basic(cmd);
< 
<       if ((mypipe = popen(cmd, "r")) != 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); 
<               }
< 
<               if (retvalue != 0) 
<                       DEBUG(0, ("handle_enhanced_path: Command exited with value %d, it echoed \047%s\047", 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));
<               return(True);
<       }
< }
< 


And this is a snatch from syslog:
Jan 20 20:47:49 zebra smbd.tlan[559]: [2001/01/20 20:47:49, 0] param/loadparm.c:handle_enhanced_path(1964)
Jan 20 20:47:49 zebra smbd.tlan[559]:   handle_enhanced_path: Command exited with value -1, it echoed '%H/.profil/stud

So, what am I doing wrong? This code get's run each time there's a "path =" in
the config, but not when there's a "enhanced path =" instead.

You my ask why I want this, and it's all because we've got several labs
where I work, and we need different configuration for each lab, and we have
profiles over samba-shares. So the idea with this was something like this:

[profile]
  enhanced path = /usr/local/samba/bin/returnpath.sh %I

And, then path should be set to the path returned by that command (which
would depend on the IP in this case).

-- 
-Thomas




More information about the samba-technical mailing list