Copyright (C) Tom Jansen (Ninja ISD) 2002
Copyright (C) Derrell Lipman 2003-2008
Copyright (C) Jeremy Allison 2007, 2008
-
+
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
-
+
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
-
+
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
static int
hex2int( unsigned int _char )
{
- if ( _char >= 'A' && _char <='F')
- return _char - 'A' + 10;
- if ( _char >= 'a' && _char <='f')
- return _char - 'a' + 10;
- if ( _char >= '0' && _char <='9')
- return _char - '0';
- return -1;
+ if ( _char >= 'A' && _char <='F')
+ return _char - 'A' + 10;
+ if ( _char >= 'a' && _char <='f')
+ return _char - 'a' + 10;
+ if ( _char >= '0' && _char <='9')
+ return _char - '0';
+ return -1;
}
/*
- * SMBC_urldecode()
+ * smbc_urldecode()
* and urldecode_talloc() (internal fn.)
*
* Convert strings of %xx to their single character equivalent. Each 'x' must
newlen++;
}
- dest = TALLOC_ARRAY(ctx, char, newlen);
+ dest = talloc_array(ctx, char, newlen);
if (!dest) {
return err_count;
}
}
int
-SMBC_urldecode(char *dest,
+smbc_urldecode(char *dest,
char *src,
size_t max_dest_len)
{
}
/*
- * SMBC_urlencode()
+ * smbc_urlencode()
*
* Convert any characters not specifically allowed in a URL into their %xx
* equivalent.
* Returns the remaining buffer length.
*/
int
-SMBC_urlencode(char *dest,
+smbc_urlencode(char *dest,
char *src,
int max_dest_len)
{
*
* The method of locating the list of workgroups varies
* depending upon the setting of the context variable
- * context->browse_max_lmb_count. This value determines
- * the maximum number of local master browsers to query
- * for the list of workgroups. In order to ensure that
+ * context->options.browse_max_lmb_count. This value
+ * determines the maximum number of local master browsers to
+ * query for the list of workgroups. In order to ensure that
* a complete list of workgroups is obtained, all master
* browsers must be queried, but if there are many
* workgroups, the time spent querying can begin to add up.
* are supported.
*/
-static const char *smbc_prefix = "smb:";
+#define SMBC_PREFIX "smb:"
int
SMBC_parse_path(TALLOC_CTX *ctx,
char *s;
const char *p;
char *q, *r;
+ char *workgroup = NULL;
int len;
/* Ensure these returns are at least valid pointers. */
*pp_password = talloc_strdup(ctx, "");
if (!*pp_server || !*pp_share || !*pp_path ||
- !*pp_user || !*pp_password) {
+ !*pp_user || !*pp_password) {
return -1;
}
*/
if (pp_workgroup != NULL) {
*pp_workgroup =
- talloc_strdup(ctx, context->config.workgroup);
+ talloc_strdup(ctx, smbc_getWorkgroup(context));
}
if (pp_options) {
s = talloc_strdup(ctx, fname);
/* see if it has the right prefix */
- len = strlen(smbc_prefix);
- if (strncmp(s,smbc_prefix,len) || (s[len] != '/' && s[len] != 0)) {
+ len = strlen(SMBC_PREFIX);
+ if (strncmp(s,SMBC_PREFIX,len) || (s[len] != '/' && s[len] != 0)) {
return -1; /* What about no smb: ? */
}
DEBUG(4, ("Found options '%s'", q));
/* Copy the options */
- if (*pp_options != NULL) {
+ if (pp_options && *pp_options != NULL) {
TALLOC_FREE(*pp_options);
*pp_options = talloc_strdup(ctx, q);
}
}
if (*p == '/') {
- int wl = strlen(context->config.workgroup);
+ int wl = strlen(smbc_getWorkgroup(context));
if (wl > 16) {
wl = 16;
}
- *pp_server = talloc_strdup(ctx, context->config.workgroup);
+ *pp_server = talloc_strdup(ctx, smbc_getWorkgroup(context));
if (!*pp_server) {
return -1;
}
- *pp_server[wl] = '\0';
+ (*pp_server)[wl] = '\0';
return 0;
}
u = userinfo;
if (strchr_m(u, ';')) {
- char *workgroup;
next_token_no_ltrim_talloc(ctx, &u, &workgroup, ";");
if (!workgroup) {
return -1;
*/
if (*p != '\0') {
*pp_path = talloc_asprintf(ctx,
- "\\%s",
- p);
+ "\\%s",
+ p);
} else {
*pp_path = talloc_strdup(ctx, "");
}
}
string_replace(*pp_path, '/', '\\');
- decoding:
-
+decoding:
(void) urldecode_talloc(ctx, pp_path, *pp_path);
(void) urldecode_talloc(ctx, pp_server, *pp_server);
(void) urldecode_talloc(ctx, pp_share, *pp_share);
(void) urldecode_talloc(ctx, pp_user, *pp_user);
(void) urldecode_talloc(ctx, pp_password, *pp_password);
+ if (!workgroup) {
+ workgroup = talloc_strdup(ctx, smbc_getWorkgroup(context));
+ }
+ if (!workgroup) {
+ return -1;
+ }
+
+ /* set the credentials to make DFS work */
+ smbc_set_credentials_with_fallback(context,
+ workgroup,
+ *pp_user,
+ *pp_password);
return 0;
}