Bug 8610 - libsmbclient: No method to set the smb.conf path
libsmbclient: No method to set the smb.conf path
Status: NEW
Product: Samba 3.6
Classification: Unclassified
Component: libsmbclient
3.6.10
All All
: P5 normal
: ---
Assigned To: Jeremy Allison
Samba QA Contact
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2011-11-14 17:05 UTC by SATOH Fumiyasu
Modified: 2012-12-19 23:46 UTC (History)
0 users

See Also:


Attachments
Patch to use SMB_CONF environment entry as first choice (1.57 KB, patch)
2011-11-16 01:51 UTC, Derrell Lipman
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description SATOH Fumiyasu 2011-11-14 17:05:36 UTC
I'm writing a Ruby module that uses libsmbclient to connect to
SMB/CIFS services. For this module, I want to use the own smb.conf
path instead of the default smb.conf path, $HOME/.smb/smb.conf and
$HOME/.smb/smb.conf.append, but there is no method to do it.
Comment 1 Derrell Lipman 2011-11-14 18:57:03 UTC
The way I wrote that code, a number of years ago, $HOME/.smb/smb.conf and $HOME/.smb/smb.conf.append take precedence over the global file (in some defined order). You don't need to call anything for that to happen. I believe that if there is a $HOME/.smb/smb.conf it overwrite completely the global configuration, and if there is a $HOME/.smb/smb.conf.append, the settings contained in there are added to the global settings. 

There is a precedence of files which I don't recall (and don't have quick access to the code at the moment). I think maybe the .append file is checked first, and if it doesn't exist, then the $HOME/.smb/smb.conf is looked for. It may be the other way around.

(It is conceivable that something has changed in the past few years regarding how those files are read.)

Derrell
Comment 2 SATOH Fumiyasu 2011-11-15 13:54:59 UTC
(In reply to comment #1)
> The way I wrote that code, a number of years ago, $HOME/.smb/smb.conf and
> $HOME/.smb/smb.conf.append take precedence over the global file (in some
> defined order). You don't need to call anything for that to happen. I believe
> that if there is a $HOME/.smb/smb.conf it overwrite completely the global
> configuration, and if there is a $HOME/.smb/smb.conf.append, the settings
> contained in there are added to the global settings. 

This has a problem that if $HOME/.smb/smb.conf exists, there is a no way
to ignore it without an ugly hack (see below) when we want to use default the
smb.conf.

  SMBCCTX *smbcctx;
  char *home = getenv("HOME");

  if (home) {
    unsetenv("HOME");
  }
  smbcctx = smbc_new_context();
  if (home) {
    setenv("HOME", home, 1);
  }
Comment 3 Derrell Lipman 2011-11-15 14:00:45 UTC
(In reply to comment #2)
> This has a problem that if $HOME/.smb/smb.conf exists, there is a no way
> to ignore it without an ugly hack

The intention was that the user knows a lot better than the application developer what configuration to use. If the user has provided an overriding configuration file, it feels unreasonable for the application to say, "No, you must use the global one as is, not the one you created to override the global one."

I'm curious... What is your use case that you would want the application to override the user's desire?
Comment 4 SATOH Fumiyasu 2011-11-15 15:14:06 UTC
(In reply to comment #3)
> I'm curious... What is your use case that you would want the application to
> override the user's desire?

Case 1:
-------

I have the $HOME/.smb/smb.conf for some libsmbclient applications.

On the other hand, I'm writing a libsmbclient application and test
programs for it. I want to use a specific smb.conf file (to avoid
/etc/samba/smb.conf and $HOME/.smb/smb.conf) for the application
when I run the test program.

Case 2:
-------

Someone uses a libsmbclient application to connect to server A and B.
He want to use /etc/samba/smb.conf for A, but $HOME/.smb/smb.conf for B.

Case 3:
-------

Someone uses libsmbclient applications, application X and Y.
He want to use $HOME/etc/smb.A.conf for X, but $HOME/etc/smb.B.conf
for Y.
Comment 5 Derrell Lipman 2011-11-16 01:51:14 UTC
Created attachment 7106 [details]
Patch to use SMB_CONF environment entry as first choice

Here's a likely patch to accommodate this request reasonably. It looks first for an environment variable SMB_CONF, and if found, uses that as the path to the configuration file to use. If not found, then the previous precedence is used.
Comment 6 SATOH Fumiyasu 2011-11-17 08:24:07 UTC
(In reply to comment #5)
> Created attachment 7106 [details]
> Patch to use SMB_CONF environment entry as first choice

You should s/SMB_CONF/SMB_CONF_PATH/ as same as other Samba commands
(smbd and others) that see SMB_CONF_PATH.
Comment 7 SATOH Fumiyasu 2011-11-17 09:29:46 UTC
(In reply to comment #6)
> You should s/SMB_CONF/SMB_CONF_PATH/ as same as other Samba commands
> (smbd and others) that see SMB_CONF_PATH.

... and how about SMB_CONF_APPEND_PATH?
Comment 8 SATOH Fumiyasu 2011-11-17 09:34:13 UTC
Hmmm... libsmbclient uses LIBSMBCLIENT_NO_CCACHE environment variable,
thus LIBSMBCLIENT_SMB_CONF_PATH is more reasonable?
Comment 9 SATOH Fumiyasu 2012-12-18 05:51:59 UTC
Are you there?
Comment 10 Jeremy Allison 2012-12-19 23:46:07 UTC
Derrell isn't working on this code anymore, I'll take over.

Jeremy.