s3: Add connections_forall_read()
[Samba/nascimento.git] / source3 / lib / substitute.c
blob64ef95a001f26af761546fce21a479c47ec19505
1 /*
2 Unix SMB/CIFS implementation.
3 string substitution functions
4 Copyright (C) Andrew Tridgell 1992-2000
5 Copyright (C) Gerald Carter 2006
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #include "includes.h"
24 static char *alloc_sub_basic(const char *smb_name, const char *domain_name,
25 const char *str);
27 userdom_struct current_user_info;
28 fstring remote_proto="UNKNOWN";
30 /**
31 * Set the 'local' machine name
32 * @param local_name the name we are being called
33 * @param if this is the 'final' name for us, not be be changed again
36 static char *local_machine;
38 void free_local_machine_name(void)
40 SAFE_FREE(local_machine);
43 bool set_local_machine_name(const char *local_name, bool perm)
45 static bool already_perm = false;
46 char *tmp_local_machine = NULL;
47 char addr[INET6_ADDRSTRLEN];
48 size_t len;
50 tmp_local_machine = SMB_STRDUP(local_name);
51 if (!tmp_local_machine) {
52 return false;
54 trim_char(tmp_local_machine,' ',' ');
57 * Windows NT/2k uses "*SMBSERVER" and XP uses "*SMBSERV"
58 * arrggg!!!
61 if (strequal(tmp_local_machine, "*SMBSERVER") ||
62 strequal(tmp_local_machine, "*SMBSERV") ) {
63 SAFE_FREE(local_machine);
64 local_machine = SMB_STRDUP(client_socket_addr(get_client_fd(),
65 addr, sizeof(addr)) );
66 SAFE_FREE(tmp_local_machine);
67 return local_machine ? true : false;
70 if (already_perm) {
71 return true;
74 SAFE_FREE(local_machine);
75 len = strlen(tmp_local_machine);
76 local_machine = SMB_CALLOC_ARRAY(char, len+1);
77 if (!local_machine) {
78 SAFE_FREE(tmp_local_machine);
79 return false;
81 /* alpha_strcpy includes the space for the terminating nul. */
82 alpha_strcpy(local_machine,tmp_local_machine,
83 SAFE_NETBIOS_CHARS,len+1);
84 strlower_m(local_machine);
85 SAFE_FREE(tmp_local_machine);
87 already_perm = perm;
89 return true;
92 const char *get_local_machine_name(void)
94 if (!local_machine || !*local_machine) {
95 return global_myname();
98 return local_machine;
102 * Set the 'remote' machine name
103 * @param remote_name the name our client wants to be called by
104 * @param if this is the 'final' name for them, not be be changed again
107 static char *remote_machine;
109 bool set_remote_machine_name(const char *remote_name, bool perm)
111 static bool already_perm = False;
112 char *tmp_remote_machine;
113 size_t len;
115 if (already_perm) {
116 return true;
119 tmp_remote_machine = SMB_STRDUP(remote_name);
120 if (!tmp_remote_machine) {
121 return false;
123 trim_char(tmp_remote_machine,' ',' ');
125 SAFE_FREE(remote_machine);
126 len = strlen(tmp_remote_machine);
127 remote_machine = SMB_CALLOC_ARRAY(char, len+1);
128 if (!remote_machine) {
129 SAFE_FREE(tmp_remote_machine);
130 return false;
133 /* alpha_strcpy includes the space for the terminating nul. */
134 alpha_strcpy(remote_machine,tmp_remote_machine,
135 SAFE_NETBIOS_CHARS,len+1);
136 strlower_m(remote_machine);
137 SAFE_FREE(tmp_remote_machine);
139 already_perm = perm;
141 return true;
144 const char *get_remote_machine_name(void)
146 return remote_machine ? remote_machine : "";
149 /*******************************************************************
150 Setup the string used by %U substitution.
151 ********************************************************************/
153 static char *smb_user_name;
155 void sub_set_smb_name(const char *name)
157 char *tmp;
158 size_t len;
159 bool is_machine_account = false;
161 /* don't let anonymous logins override the name */
162 if (!name || !*name) {
163 return;
166 tmp = SMB_STRDUP(name);
167 if (!tmp) {
168 return;
170 trim_char(tmp, ' ', ' ');
171 strlower_m(tmp);
173 len = strlen(tmp);
175 if (len == 0) {
176 SAFE_FREE(tmp);
177 return;
180 /* long story but here goes....we have to allow usernames
181 ending in '$' as they are valid machine account names.
182 So check for a machine account and re-add the '$'
183 at the end after the call to alpha_strcpy(). --jerry */
185 if (tmp[len-1] == '$') {
186 is_machine_account = True;
189 SAFE_FREE(smb_user_name);
190 smb_user_name = SMB_CALLOC_ARRAY(char, len+1);
191 if (!smb_user_name) {
192 SAFE_FREE(tmp);
193 return;
196 /* alpha_strcpy includes the space for the terminating nul. */
197 alpha_strcpy(smb_user_name, tmp,
198 SAFE_NETBIOS_CHARS,
199 len+1);
201 SAFE_FREE(tmp);
203 if (is_machine_account) {
204 len = strlen(smb_user_name);
205 smb_user_name[len-1] = '$';
209 static const char *get_smb_user_name(void)
211 return smb_user_name ? smb_user_name : "";
214 /*******************************************************************
215 Setup the strings used by substitutions. Called per packet. Ensure
216 %U name is set correctly also.
218 smb_name must be sanitized by alpha_strcpy
219 ********************************************************************/
221 void set_current_user_info(const char *smb_name, const char *unix_name,
222 const char *domain)
224 fstrcpy(current_user_info.smb_name, smb_name);
225 fstrcpy(current_user_info.unix_name, unix_name);
226 fstrcpy(current_user_info.domain, domain);
228 /* The following is safe as current_user_info.smb_name
229 * has already been sanitised in register_existing_vuid. */
231 sub_set_smb_name(current_user_info.smb_name);
234 /*******************************************************************
235 Return the current active user name.
236 *******************************************************************/
238 const char *get_current_username(void)
240 if (current_user_info.smb_name[0] == '\0' ) {
241 return get_smb_user_name();
244 return current_user_info.smb_name;
247 /*******************************************************************
248 Given a pointer to a %$(NAME) in p and the whole string in str
249 expand it as an environment variable.
250 Return a new allocated and expanded string.
251 Based on code by Branko Cibej <branko.cibej@hermes.si>
252 When this is called p points at the '%' character.
253 May substitute multiple occurrencies of the same env var.
254 ********************************************************************/
256 static char * realloc_expand_env_var(char *str, char *p)
258 char *envname;
259 char *envval;
260 char *q, *r;
261 int copylen;
263 if (p[0] != '%' || p[1] != '$' || p[2] != '(') {
264 return str;
268 * Look for the terminating ')'.
271 if ((q = strchr_m(p,')')) == NULL) {
272 DEBUG(0,("expand_env_var: Unterminated environment variable [%s]\n", p));
273 return str;
277 * Extract the name from within the %$(NAME) string.
280 r = p + 3;
281 copylen = q - r;
283 /* reserve space for use later add %$() chars */
284 if ( (envname = (char *)SMB_MALLOC(copylen + 1 + 4)) == NULL ) {
285 return NULL;
288 strncpy(envname,r,copylen);
289 envname[copylen] = '\0';
291 if ((envval = getenv(envname)) == NULL) {
292 DEBUG(0,("expand_env_var: Environment variable [%s] not set\n", envname));
293 SAFE_FREE(envname);
294 return str;
298 * Copy the full %$(NAME) into envname so it
299 * can be replaced.
302 copylen = q + 1 - p;
303 strncpy(envname,p,copylen);
304 envname[copylen] = '\0';
305 r = realloc_string_sub(str, envname, envval);
306 SAFE_FREE(envname);
308 return r;
311 /*******************************************************************
312 *******************************************************************/
314 static char *longvar_domainsid( void )
316 DOM_SID sid;
317 fstring tmp;
318 char *sid_string;
320 if ( !secrets_fetch_domain_sid( lp_workgroup(), &sid ) ) {
321 return NULL;
324 sid_string = SMB_STRDUP( sid_to_fstring( tmp, &sid ) );
326 if ( !sid_string ) {
327 DEBUG(0,("longvar_domainsid: failed to dup SID string!\n"));
330 return sid_string;
333 /*******************************************************************
334 *******************************************************************/
336 struct api_longvar {
337 const char *name;
338 char* (*fn)( void );
341 static struct api_longvar longvar_table[] = {
342 { "DomainSID", longvar_domainsid },
343 { NULL, NULL }
346 static char *get_longvar_val( const char *varname )
348 int i;
350 DEBUG(7,("get_longvar_val: expanding variable [%s]\n", varname));
352 for ( i=0; longvar_table[i].name; i++ ) {
353 if ( strequal( longvar_table[i].name, varname ) ) {
354 return longvar_table[i].fn();
358 return NULL;
361 /*******************************************************************
362 Expand the long smb.conf variable names given a pointer to a %(NAME).
363 Return the number of characters by which the pointer should be advanced.
364 When this is called p points at the '%' character.
365 ********************************************************************/
367 static char *realloc_expand_longvar(char *str, char *p)
369 fstring varname;
370 char *value;
371 char *q, *r;
372 int copylen;
374 if ( p[0] != '%' || p[1] != '(' ) {
375 return str;
378 /* Look for the terminating ')'.*/
380 if ((q = strchr_m(p,')')) == NULL) {
381 DEBUG(0,("realloc_expand_longvar: Unterminated environment variable [%s]\n", p));
382 return str;
385 /* Extract the name from within the %(NAME) string.*/
387 r = p+2;
388 copylen = MIN( (q-r), (sizeof(varname)-1) );
389 strncpy(varname, r, copylen);
390 varname[copylen] = '\0';
392 if ((value = get_longvar_val(varname)) == NULL) {
393 DEBUG(0,("realloc_expand_longvar: Variable [%s] not set. Skipping\n", varname));
394 return str;
397 /* Copy the full %(NAME) into envname so it can be replaced.*/
399 copylen = MIN( (q+1-p),(sizeof(varname)-1) );
400 strncpy( varname, p, copylen );
401 varname[copylen] = '\0';
402 r = realloc_string_sub(str, varname, value);
403 SAFE_FREE( value );
405 /* skip over the %(varname) */
407 return r;
410 /*******************************************************************
411 Patch from jkf@soton.ac.uk
412 Added this to implement %p (NIS auto-map version of %H)
413 *******************************************************************/
415 static const char *automount_path(const char *user_name)
417 TALLOC_CTX *ctx = talloc_tos();
418 const char *server_path;
420 /* use the passwd entry as the default */
421 /* this will be the default if WITH_AUTOMOUNT is not used or fails */
423 server_path = talloc_strdup(ctx, get_user_home_dir(ctx, user_name));
424 if (!server_path) {
425 return "";
428 #if (defined(HAVE_NETGROUP) && defined (WITH_AUTOMOUNT))
430 if (lp_nis_home_map()) {
431 const char *home_path_start;
432 char *automount_value = automount_lookup(ctx, user_name);
434 if(automount_value && strlen(automount_value) > 0) {
435 home_path_start = strchr_m(automount_value,':');
436 if (home_path_start != NULL) {
437 DEBUG(5, ("NIS lookup succeeded. "
438 "Home path is: %s\n",
439 home_path_start ?
440 (home_path_start+1):""));
441 server_path = talloc_strdup(ctx,
442 home_path_start+1);
443 if (!server_path) {
444 server_path = "";
447 } else {
448 /* NIS key lookup failed: default to
449 * user home directory from password file */
450 DEBUG(5, ("NIS lookup failed. Using Home path from "
451 "passwd file. Home path is: %s\n", server_path ));
454 #endif
456 DEBUG(4,("Home server path: %s\n", server_path));
457 return server_path;
460 /*******************************************************************
461 Patch from jkf@soton.ac.uk
462 This is Luke's original function with the NIS lookup code
463 moved out to a separate function.
464 *******************************************************************/
466 static const char *automount_server(const char *user_name)
468 TALLOC_CTX *ctx = talloc_tos();
469 const char *server_name;
470 const char *local_machine_name = get_local_machine_name();
472 /* use the local machine name as the default */
473 /* this will be the default if WITH_AUTOMOUNT is not used or fails */
474 if (local_machine_name && *local_machine_name) {
475 server_name = talloc_strdup(ctx, local_machine_name);
476 } else {
477 server_name = talloc_strdup(ctx, global_myname());
480 if (!server_name) {
481 return "";
484 #if (defined(HAVE_NETGROUP) && defined (WITH_AUTOMOUNT))
485 if (lp_nis_home_map()) {
486 char *p;
487 char *srv;
488 char *automount_value = automount_lookup(ctx, user_name);
489 if (!automount_value) {
490 return "";
492 srv = talloc_strdup(ctx, automount_value);
493 if (!srv) {
494 return "";
496 p = strchr_m(srv, ':');
497 if (!p) {
498 return "";
500 *p = '\0';
501 server_name = srv;
502 DEBUG(5, ("NIS lookup succeeded. Home server %s\n",
503 server_name));
505 #endif
507 DEBUG(4,("Home server: %s\n", server_name));
508 return server_name;
511 /****************************************************************************
512 Do some standard substitutions in a string.
513 len is the length in bytes of the space allowed in string str. If zero means
514 don't allow expansions.
515 ****************************************************************************/
517 void standard_sub_basic(const char *smb_name, const char *domain_name,
518 char *str, size_t len)
520 char *s;
522 if ( (s = alloc_sub_basic( smb_name, domain_name, str )) != NULL ) {
523 strncpy( str, s, len );
526 SAFE_FREE( s );
529 /****************************************************************************
530 Do some standard substitutions in a string.
531 This function will return an allocated string that have to be freed.
532 ****************************************************************************/
534 char *talloc_sub_basic(TALLOC_CTX *mem_ctx, const char *smb_name,
535 const char *domain_name, const char *str)
537 char *a, *t;
539 if ( (a = alloc_sub_basic(smb_name, domain_name, str)) == NULL ) {
540 return NULL;
542 t = talloc_strdup(mem_ctx, a);
543 SAFE_FREE(a);
544 return t;
547 /****************************************************************************
548 ****************************************************************************/
550 static char *alloc_sub_basic(const char *smb_name, const char *domain_name,
551 const char *str)
553 char *b, *p, *s, *r, *a_string;
554 fstring pidstr, vnnstr;
555 char addr[INET6_ADDRSTRLEN];
556 const char *local_machine_name = get_local_machine_name();
557 TALLOC_CTX *tmp_ctx = NULL;
559 /* workaround to prevent a crash while looking at bug #687 */
561 if (!str) {
562 DEBUG(0,("alloc_sub_basic: NULL source string! This should not happen\n"));
563 return NULL;
566 a_string = SMB_STRDUP(str);
567 if (a_string == NULL) {
568 DEBUG(0, ("alloc_sub_basic: Out of memory!\n"));
569 return NULL;
572 tmp_ctx = talloc_stackframe();
574 for (b = s = a_string; (p = strchr_m(s, '%')); s = a_string + (p - b)) {
576 r = NULL;
577 b = a_string;
579 switch (*(p+1)) {
580 case 'U' :
581 r = strlower_talloc(tmp_ctx, smb_name);
582 if (r == NULL) {
583 goto error;
585 a_string = realloc_string_sub(a_string, "%U", r);
586 break;
587 case 'G' : {
588 struct passwd *pass;
589 r = talloc_strdup(tmp_ctx, smb_name);
590 if (r == NULL) {
591 goto error;
593 pass = Get_Pwnam_alloc(tmp_ctx, r);
594 if (pass != NULL) {
595 a_string = realloc_string_sub(
596 a_string, "%G",
597 gidtoname(pass->pw_gid));
599 TALLOC_FREE(pass);
600 break;
602 case 'D' :
603 r = strupper_talloc(tmp_ctx, domain_name);
604 if (r == NULL) {
605 goto error;
607 a_string = realloc_string_sub(a_string, "%D", r);
608 break;
609 case 'I' : {
610 int offset = 0;
611 client_addr(get_client_fd(), addr, sizeof(addr));
612 if (strnequal(addr,"::ffff:",7)) {
613 offset = 7;
615 a_string = realloc_string_sub(a_string, "%I",
616 addr + offset);
617 break;
619 case 'i':
620 a_string = realloc_string_sub( a_string, "%i",
621 client_socket_addr(get_client_fd(), addr, sizeof(addr)) );
622 break;
623 case 'L' :
624 if ( StrnCaseCmp(p, "%LOGONSERVER%", strlen("%LOGONSERVER%")) == 0 ) {
625 break;
627 if (local_machine_name && *local_machine_name) {
628 a_string = realloc_string_sub(a_string, "%L", local_machine_name);
629 } else {
630 a_string = realloc_string_sub(a_string, "%L", global_myname());
632 break;
633 case 'N':
634 a_string = realloc_string_sub(a_string, "%N", automount_server(smb_name));
635 break;
636 case 'M' :
637 a_string = realloc_string_sub(a_string, "%M", client_name(get_client_fd()));
638 break;
639 case 'R' :
640 a_string = realloc_string_sub(a_string, "%R", remote_proto);
641 break;
642 case 'T' :
643 a_string = realloc_string_sub(a_string, "%T", current_timestring(tmp_ctx, False));
644 break;
645 case 'a' :
646 a_string = realloc_string_sub(a_string, "%a",
647 get_remote_arch_str());
648 break;
649 case 'd' :
650 slprintf(pidstr,sizeof(pidstr)-1, "%d",(int)sys_getpid());
651 a_string = realloc_string_sub(a_string, "%d", pidstr);
652 break;
653 case 'h' :
654 a_string = realloc_string_sub(a_string, "%h", myhostname());
655 break;
656 case 'm' :
657 a_string = realloc_string_sub(a_string, "%m",
658 remote_machine
659 ? remote_machine
660 : "");
661 break;
662 case 'v' :
663 a_string = realloc_string_sub(a_string, "%v", samba_version_string());
664 break;
665 case 'w' :
666 a_string = realloc_string_sub(a_string, "%w", lp_winbind_separator());
667 break;
668 case '$' :
669 a_string = realloc_expand_env_var(a_string, p); /* Expand environment variables */
670 break;
671 case '(':
672 a_string = realloc_expand_longvar( a_string, p );
673 break;
674 case 'V' :
675 slprintf(vnnstr,sizeof(vnnstr)-1, "%u", get_my_vnn());
676 a_string = realloc_string_sub(a_string, "%V", vnnstr);
677 break;
678 default:
679 break;
682 p++;
683 TALLOC_FREE(r);
685 if (a_string == NULL) {
686 goto done;
690 goto done;
692 error:
693 SAFE_FREE(a_string);
695 done:
696 TALLOC_FREE(tmp_ctx);
697 return a_string;
700 /****************************************************************************
701 Do some specific substitutions in a string.
702 This function will return an allocated string that have to be freed.
703 ****************************************************************************/
705 char *talloc_sub_specified(TALLOC_CTX *mem_ctx,
706 const char *input_string,
707 const char *username,
708 const char *domain,
709 uid_t uid,
710 gid_t gid)
712 char *a_string;
713 char *ret_string = NULL;
714 char *b, *p, *s;
715 TALLOC_CTX *tmp_ctx;
717 if (!(tmp_ctx = talloc_new(mem_ctx))) {
718 DEBUG(0, ("talloc_new failed\n"));
719 return NULL;
722 a_string = talloc_strdup(tmp_ctx, input_string);
723 if (a_string == NULL) {
724 DEBUG(0, ("talloc_sub_specified: Out of memory!\n"));
725 goto done;
728 for (b = s = a_string; (p = strchr_m(s, '%')); s = a_string + (p - b)) {
730 b = a_string;
732 switch (*(p+1)) {
733 case 'U' :
734 a_string = talloc_string_sub(
735 tmp_ctx, a_string, "%U", username);
736 break;
737 case 'u' :
738 a_string = talloc_string_sub(
739 tmp_ctx, a_string, "%u", username);
740 break;
741 case 'G' :
742 if (gid != -1) {
743 a_string = talloc_string_sub(
744 tmp_ctx, a_string, "%G",
745 gidtoname(gid));
746 } else {
747 a_string = talloc_string_sub(
748 tmp_ctx, a_string,
749 "%G", "NO_GROUP");
751 break;
752 case 'g' :
753 if (gid != -1) {
754 a_string = talloc_string_sub(
755 tmp_ctx, a_string, "%g",
756 gidtoname(gid));
757 } else {
758 a_string = talloc_string_sub(
759 tmp_ctx, a_string, "%g", "NO_GROUP");
761 break;
762 case 'D' :
763 a_string = talloc_string_sub(tmp_ctx, a_string,
764 "%D", domain);
765 break;
766 case 'N' :
767 a_string = talloc_string_sub(
768 tmp_ctx, a_string, "%N",
769 automount_server(username));
770 break;
771 default:
772 break;
775 p++;
776 if (a_string == NULL) {
777 goto done;
781 /* Watch out, using "mem_ctx" here, so all intermediate stuff goes
782 * away with the TALLOC_FREE(tmp_ctx) further down. */
784 ret_string = talloc_sub_basic(mem_ctx, username, domain, a_string);
786 done:
787 TALLOC_FREE(tmp_ctx);
788 return ret_string;
791 /****************************************************************************
792 ****************************************************************************/
794 static char *alloc_sub_advanced(const char *servicename, const char *user,
795 const char *connectpath, gid_t gid,
796 const char *smb_name, const char *domain_name,
797 const char *str)
799 char *a_string, *ret_string;
800 char *b, *p, *s;
802 a_string = SMB_STRDUP(str);
803 if (a_string == NULL) {
804 DEBUG(0, ("alloc_sub_advanced: Out of memory!\n"));
805 return NULL;
808 for (b = s = a_string; (p = strchr_m(s, '%')); s = a_string + (p - b)) {
810 b = a_string;
812 switch (*(p+1)) {
813 case 'N' :
814 a_string = realloc_string_sub(a_string, "%N", automount_server(user));
815 break;
816 case 'H': {
817 char *h;
818 if ((h = get_user_home_dir(talloc_tos(), user)))
819 a_string = realloc_string_sub(a_string, "%H", h);
820 TALLOC_FREE(h);
821 break;
823 case 'P':
824 a_string = realloc_string_sub(a_string, "%P", connectpath);
825 break;
826 case 'S':
827 a_string = realloc_string_sub(a_string, "%S", servicename);
828 break;
829 case 'g':
830 a_string = realloc_string_sub(a_string, "%g", gidtoname(gid));
831 break;
832 case 'u':
833 a_string = realloc_string_sub(a_string, "%u", user);
834 break;
836 /* Patch from jkf@soton.ac.uk Left the %N (NIS
837 * server name) in standard_sub_basic as it is
838 * a feature for logon servers, hence uses the
839 * username. The %p (NIS server path) code is
840 * here as it is used instead of the default
841 * "path =" string in [homes] and so needs the
842 * service name, not the username. */
843 case 'p':
844 a_string = realloc_string_sub(a_string, "%p",
845 automount_path(servicename));
846 break;
848 default:
849 break;
852 p++;
853 if (a_string == NULL) {
854 return NULL;
858 ret_string = alloc_sub_basic(smb_name, domain_name, a_string);
859 SAFE_FREE(a_string);
860 return ret_string;
864 * This obviously is inefficient and needs to be merged into
865 * alloc_sub_advanced...
868 char *talloc_sub_advanced(TALLOC_CTX *mem_ctx,
869 const char *servicename, const char *user,
870 const char *connectpath, gid_t gid,
871 const char *smb_name, const char *domain_name,
872 const char *str)
874 char *a, *t;
876 if (!(a = alloc_sub_advanced(servicename, user, connectpath, gid,
877 smb_name, domain_name, str))) {
878 return NULL;
880 t = talloc_strdup(mem_ctx, a);
881 SAFE_FREE(a);
882 return t;
886 void standard_sub_advanced(const char *servicename, const char *user,
887 const char *connectpath, gid_t gid,
888 const char *smb_name, const char *domain_name,
889 char *str, size_t len)
891 char *s;
893 s = alloc_sub_advanced(servicename, user, connectpath,
894 gid, smb_name, domain_name, str);
896 if ( s ) {
897 strncpy( str, s, len );
898 SAFE_FREE( s );
902 /****************************************************************************
903 Do some standard substitutions in a string.
904 ****************************************************************************/
906 char *standard_sub_conn(TALLOC_CTX *ctx, connection_struct *conn, const char *str)
908 return talloc_sub_advanced(ctx,
909 lp_servicename(SNUM(conn)),
910 conn->server_info->unix_name,
911 conn->connectpath,
912 conn->server_info->utok.gid,
913 get_smb_user_name(),
915 str);