[BUG 5580] Allow access to DFS shares via libsmbclient
authorDerrell Lipman <derrell.lipman@unwireduniverse.com>
Wed, 9 Jul 2008 00:44:39 +0000 (20:44 -0400)
committerDerrell Lipman <derrell.lipman@unwireduniverse.com>
Wed, 9 Jul 2008 00:44:39 +0000 (20:44 -0400)
Brian Sheehan provided a nice patch intended for the 3.0 code base.  This
commit applies a similar patch for the 3.3 code base.  It adds a new public
function to libsmbclient -- smbc_set_credentials() -- that may be called from
the authentication callback when DFS referrals are in use.

Derrell
(This used to be commit 888f922bd0d1c84a687d404e95ae314a9dd0aee1)

source3/include/libsmbclient.h
source3/include/proto.h
source3/lib/util.c
source3/libsmb/libsmb_context.c

index 74d0d5c9ddb990f3701c42e99fa74146242af49c..2828e9e78054d26794e1ad1fdad0668e9f352ff9 100644 (file)
@@ -2561,6 +2561,33 @@ smbc_version(void);
 }
 #endif
 
+/**@ingroup misc
+ * Set the users credentials globally so they can be used for DFS
+ * referrals. Probably best to use this function in the smbc_get_auth_data_fn
+ * callback.
+ *
+ * @param workgroup      Workgroup of the user.
+ *
+ * @param user           Username of user.
+ *
+ * @param password       Password of user.
+ *
+ * @param use_kerberos   Whether to use Kerberos
+ *
+ * @param signing_state  One of these strings (all equivalents on same line):
+ *                         "off", "no", "false"
+ *                         "on", "yes", "true", "auto"
+ *                         "force", "required", "forced"
+ */
+
+void
+smbc_set_credentials(char *workgroup,
+                     char *user,
+                     char *password,
+                     bool use_kerberos,
+                     char *signing_state);
+
+
 /**
  * @ingroup structure
  * Structure that contains a client context information 
index 2a954f4efeb7535842e202aef0c87e5e4455881d..665a86d2c8b18da3888993b40bfe7463be8fced7 100644 (file)
@@ -1271,6 +1271,7 @@ const char *get_cmdline_auth_info_password(void);
 void set_cmdline_auth_info_password(const char *password);
 bool set_cmdline_auth_info_signing_state(const char *arg);
 int get_cmdline_auth_info_signing_state(void);
+void set_cmdline_auth_info_use_kerberos(bool b);
 bool get_cmdline_auth_info_use_kerberos(void);
 void set_cmdline_auth_info_use_krb5_ticket(void);
 void set_cmdline_auth_info_smb_encrypt(void);
index 68524a21ce09dfe7e6eff894585e83b47381c2ed..8d744a5ae3bc6ef7dcbbb5d57d25653d2a1b4243 100644 (file)
@@ -353,6 +353,11 @@ int get_cmdline_auth_info_signing_state(void)
        return cmdline_auth_info.signing_state;
 }
 
+void set_cmdline_auth_info_use_kerberos(bool b)
+{
+        cmdline_auth_info.use_kerberos = b;
+}
+
 bool get_cmdline_auth_info_use_kerberos(void)
 {
        return cmdline_auth_info.use_kerberos;
index dd78bcee35524b7d97ddf5af28afae71d26d7723..51948d16487b8673cd768821d4d6629d5c9a60c4 100644 (file)
@@ -610,3 +610,23 @@ smbc_version(void)
 }
 
 
+/*
+ * Set the credentials so DFS will work when following referrals.
+ */
+void
+smbc_set_credentials(char *workgroup,
+                     char *user,
+                     char *password,
+                     bool use_kerberos,
+                     char *signing_state)
+{
+        
+        set_cmdline_auth_info_username(user);
+        set_cmdline_auth_info_password(password);
+        set_cmdline_auth_info_use_kerberos(use_kerberos);
+        if (! set_cmdline_auth_info_signing_state(signing_state)) {
+                DEBUG(0, ("Invalid signing state: %s", signing_state));
+        }
+        set_global_myworkgroup(workgroup);
+        cli_cm_set_credentials();
+}