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 2 of the License, or
+ 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,
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, write to the Free Software
- Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
}
}
-char* sub_get_smb_name( void )
-{
- return smb_user_name;
-}
-
/*******************************************************************
Setup the strings used by substitutions. Called per packet. Ensure
%U name is set correctly also.
{
current_user_info = *pcui;
/* The following is safe as current_user_info.smb_name
- * has already been sanitised in register_vuid. */
+ * has already been sanitised in register_existing_vuid. */
fstrcpy(smb_user_name, current_user_info.smb_name);
}
char* (*fn)( void );
};
-struct api_longvar longvar_table[] = {
+static struct api_longvar longvar_table[] = {
{ "DomainSID", longvar_domainsid },
{ NULL, NULL }
};
static char *automount_path(const char *user_name)
{
- static pstring server_path;
+ pstring server_path;
/* use the passwd entry as the default */
/* this will be the default if WITH_AUTOMOUNT is not used or fails */
DEBUG(4,("Home server path: %s\n", server_path));
- return server_path;
+ return talloc_strdup(talloc_tos(), server_path);
}
/*******************************************************************
static const char *automount_server(const char *user_name)
{
- static pstring server_name;
+ pstring server_name;
const char *local_machine_name = get_local_machine_name();
/* use the local machine name as the default */
DEBUG(4,("Home server: %s\n", server_name));
- return server_name;
+ return talloc_strdup(talloc_tos(), server_name);
}
/****************************************************************************
const char *str)
{
char *b, *p, *s, *r, *a_string;
- fstring pidstr;
+ fstring pidstr, vnnstr;
struct passwd *pass;
const char *local_machine_name = get_local_machine_name();
case '(':
a_string = realloc_expand_longvar( a_string, p );
break;
+ case 'V' :
+ slprintf(vnnstr,sizeof(vnnstr)-1, "%u", get_my_vnn());
+ a_string = realloc_string_sub(a_string, "%V", vnnstr);
+ break;
default:
break;
}
/****************************************************************************
****************************************************************************/
-char *alloc_sub_advanced(const char *servicename, const char *user,
+static char *alloc_sub_advanced(const char *servicename, const char *user,
const char *connectpath, gid_t gid,
const char *smb_name, const char *domain_name,
const char *str)
return ret_string;
}
+/*
+ * This obviously is inefficient and needs to be merged into
+ * alloc_sub_advanced...
+ */
+
+char *talloc_sub_advanced(TALLOC_CTX *mem_ctx,
+ const char *servicename, const char *user,
+ const char *connectpath, gid_t gid,
+ const char *smb_name, const char *domain_name,
+ const char *str)
+{
+ char *a, *t;
+
+ if (!(a = alloc_sub_advanced(servicename, user, connectpath, gid,
+ smb_name, domain_name, str))) {
+ return NULL;
+ }
+ t = talloc_strdup(mem_ctx, a);
+ SAFE_FREE(a);
+ return t;
+}
+
+
void standard_sub_advanced(const char *servicename, const char *user,
const char *connectpath, gid_t gid,
const char *smb_name, const char *domain_name,
SAFE_FREE( s );
}
}
+
+/****************************************************************************
+ * Do some standard substitutions in a string.
+ * ****************************************************************************/
+
+void standard_sub_conn(connection_struct *conn, char *str, size_t len)
+{
+ char *s;
+
+ s = alloc_sub_advanced(lp_servicename(SNUM(conn)), conn->user, conn->connectpath,
+ conn->gid, smb_user_name, "", str);
+
+ if ( s ) {
+ strncpy( str, s, len );
+ SAFE_FREE( s );
+ }
+}
+