create-tarball: Adapt script to changed directory structure.
[Samba/gbeck.git] / source3 / lib / substitute.c
blobacfe55d7617d6499c461b65a476f2aa562524203
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 userdom_struct current_user_info;
25 fstring remote_proto="UNKNOWN";
27 /**
28 * Set the 'local' machine name
29 * @param local_name the name we are being called
30 * @param if this is the 'final' name for us, not be be changed again
33 static char *local_machine;
35 void free_local_machine_name(void)
37 SAFE_FREE(local_machine);
40 bool set_local_machine_name(const char *local_name, bool perm)
42 static bool already_perm = false;
43 char *tmp_local_machine = NULL;
44 char addr[INET6_ADDRSTRLEN];
45 size_t len;
47 tmp_local_machine = SMB_STRDUP(local_name);
48 if (!tmp_local_machine) {
49 return false;
51 trim_char(tmp_local_machine,' ',' ');
54 * Windows NT/2k uses "*SMBSERVER" and XP uses "*SMBSERV"
55 * arrggg!!!
58 if (strequal(tmp_local_machine, "*SMBSERVER") ||
59 strequal(tmp_local_machine, "*SMBSERV") ) {
60 SAFE_FREE(local_machine);
61 local_machine = SMB_STRDUP(client_socket_addr(get_client_fd(),
62 addr, sizeof(addr)) );
63 SAFE_FREE(tmp_local_machine);
64 return local_machine ? true : false;
67 if (already_perm) {
68 return true;
71 SAFE_FREE(local_machine);
72 len = strlen(tmp_local_machine);
73 local_machine = SMB_CALLOC_ARRAY(char, len+1);
74 if (!local_machine) {
75 SAFE_FREE(tmp_local_machine);
76 return false;
78 /* alpha_strcpy includes the space for the terminating nul. */
79 alpha_strcpy(local_machine,tmp_local_machine,
80 SAFE_NETBIOS_CHARS,len+1);
81 strlower_m(local_machine);
82 SAFE_FREE(tmp_local_machine);
84 already_perm = perm;
86 return true;
89 const char *get_local_machine_name(void)
91 if (!local_machine || !*local_machine) {
92 return global_myname();
95 return local_machine;
98 /**
99 * Set the 'remote' machine name
100 * @param remote_name the name our client wants to be called by
101 * @param if this is the 'final' name for them, not be be changed again
104 static char *remote_machine;
106 bool set_remote_machine_name(const char *remote_name, bool perm)
108 static bool already_perm = False;
109 char *tmp_remote_machine;
110 size_t len;
112 if (already_perm) {
113 return true;
116 tmp_remote_machine = SMB_STRDUP(remote_name);
117 if (!tmp_remote_machine) {
118 return false;
120 trim_char(tmp_remote_machine,' ',' ');
122 SAFE_FREE(remote_machine);
123 len = strlen(tmp_remote_machine);
124 remote_machine = SMB_CALLOC_ARRAY(char, len+1);
125 if (!remote_machine) {
126 SAFE_FREE(tmp_remote_machine);
127 return false;
130 /* alpha_strcpy includes the space for the terminating nul. */
131 alpha_strcpy(remote_machine,tmp_remote_machine,
132 SAFE_NETBIOS_CHARS,len+1);
133 strlower_m(remote_machine);
134 SAFE_FREE(tmp_remote_machine);
136 already_perm = perm;
138 return true;
141 const char *get_remote_machine_name(void)
143 return remote_machine ? remote_machine : "";
146 /*******************************************************************
147 Setup the string used by %U substitution.
148 ********************************************************************/
150 static char *smb_user_name;
152 void sub_set_smb_name(const char *name)
154 char *tmp;
155 size_t len;
156 bool is_machine_account = false;
158 /* don't let anonymous logins override the name */
159 if (!name || !*name) {
160 return;
163 tmp = SMB_STRDUP(name);
164 if (!tmp) {
165 return;
167 trim_char(tmp, ' ', ' ');
168 strlower_m(tmp);
170 len = strlen(tmp);
172 if (len == 0) {
173 SAFE_FREE(tmp);
174 return;
177 /* long story but here goes....we have to allow usernames
178 ending in '$' as they are valid machine account names.
179 So check for a machine account and re-add the '$'
180 at the end after the call to alpha_strcpy(). --jerry */
182 if (tmp[len-1] == '$') {
183 is_machine_account = True;
186 SAFE_FREE(smb_user_name);
187 smb_user_name = SMB_CALLOC_ARRAY(char, len+1);
188 if (!smb_user_name) {
189 SAFE_FREE(tmp);
190 return;
193 /* alpha_strcpy includes the space for the terminating nul. */
194 alpha_strcpy(smb_user_name, tmp,
195 SAFE_NETBIOS_CHARS,
196 len+1);
198 SAFE_FREE(tmp);
200 if (is_machine_account) {
201 len = strlen(smb_user_name);
202 smb_user_name[len-1] = '$';
206 static const char *get_smb_user_name(void)
208 return smb_user_name ? smb_user_name : "";
211 /*******************************************************************
212 Setup the strings used by substitutions. Called per packet. Ensure
213 %U name is set correctly also.
215 smb_name must be sanitized by alpha_strcpy
216 ********************************************************************/
218 void set_current_user_info(const char *smb_name, const char *unix_name,
219 const char *full_name, const char *domain)
221 fstrcpy(current_user_info.smb_name, smb_name);
222 fstrcpy(current_user_info.unix_name, unix_name);
223 fstrcpy(current_user_info.full_name, full_name);
224 fstrcpy(current_user_info.domain, domain);
226 /* The following is safe as current_user_info.smb_name
227 * has already been sanitised in register_existing_vuid. */
229 sub_set_smb_name(current_user_info.smb_name);
232 /*******************************************************************
233 Return the current active user name.
234 *******************************************************************/
236 const char *get_current_username(void)
238 if (current_user_info.smb_name[0] == '\0' ) {
239 return get_smb_user_name();
242 return current_user_info.smb_name;
245 /*******************************************************************
246 Given a pointer to a %$(NAME) in p and the whole string in str
247 expand it as an environment variable.
248 Return a new allocated and expanded string.
249 Based on code by Branko Cibej <branko.cibej@hermes.si>
250 When this is called p points at the '%' character.
251 May substitute multiple occurrencies of the same env var.
252 ********************************************************************/
254 static char * realloc_expand_env_var(char *str, char *p)
256 char *envname;
257 char *envval;
258 char *q, *r;
259 int copylen;
261 if (p[0] != '%' || p[1] != '$' || p[2] != '(') {
262 return str;
266 * Look for the terminating ')'.
269 if ((q = strchr_m(p,')')) == NULL) {
270 DEBUG(0,("expand_env_var: Unterminated environment variable [%s]\n", p));
271 return str;
275 * Extract the name from within the %$(NAME) string.
278 r = p + 3;
279 copylen = q - r;
281 /* reserve space for use later add %$() chars */
282 if ( (envname = (char *)SMB_MALLOC(copylen + 1 + 4)) == NULL ) {
283 return NULL;
286 strncpy(envname,r,copylen);
287 envname[copylen] = '\0';
289 if ((envval = getenv(envname)) == NULL) {
290 DEBUG(0,("expand_env_var: Environment variable [%s] not set\n", envname));
291 SAFE_FREE(envname);
292 return str;
296 * Copy the full %$(NAME) into envname so it
297 * can be replaced.
300 copylen = q + 1 - p;
301 strncpy(envname,p,copylen);
302 envname[copylen] = '\0';
303 r = realloc_string_sub(str, envname, envval);
304 SAFE_FREE(envname);
306 return r;
309 /*******************************************************************
310 *******************************************************************/
312 static char *longvar_domainsid( void )
314 DOM_SID sid;
315 fstring tmp;
316 char *sid_string;
318 if ( !secrets_fetch_domain_sid( lp_workgroup(), &sid ) ) {
319 return NULL;
322 sid_string = SMB_STRDUP( sid_to_fstring( tmp, &sid ) );
324 if ( !sid_string ) {
325 DEBUG(0,("longvar_domainsid: failed to dup SID string!\n"));
328 return sid_string;
331 /*******************************************************************
332 *******************************************************************/
334 struct api_longvar {
335 const char *name;
336 char* (*fn)( void );
339 static struct api_longvar longvar_table[] = {
340 { "DomainSID", longvar_domainsid },
341 { NULL, NULL }
344 static char *get_longvar_val( const char *varname )
346 int i;
348 DEBUG(7,("get_longvar_val: expanding variable [%s]\n", varname));
350 for ( i=0; longvar_table[i].name; i++ ) {
351 if ( strequal( longvar_table[i].name, varname ) ) {
352 return longvar_table[i].fn();
356 return NULL;
359 /*******************************************************************
360 Expand the long smb.conf variable names given a pointer to a %(NAME).
361 Return the number of characters by which the pointer should be advanced.
362 When this is called p points at the '%' character.
363 ********************************************************************/
365 static char *realloc_expand_longvar(char *str, char *p)
367 fstring varname;
368 char *value;
369 char *q, *r;
370 int copylen;
372 if ( p[0] != '%' || p[1] != '(' ) {
373 return str;
376 /* Look for the terminating ')'.*/
378 if ((q = strchr_m(p,')')) == NULL) {
379 DEBUG(0,("realloc_expand_longvar: Unterminated environment variable [%s]\n", p));
380 return str;
383 /* Extract the name from within the %(NAME) string.*/
385 r = p+2;
386 copylen = MIN( (q-r), (sizeof(varname)-1) );
387 strncpy(varname, r, copylen);
388 varname[copylen] = '\0';
390 if ((value = get_longvar_val(varname)) == NULL) {
391 DEBUG(0,("realloc_expand_longvar: Variable [%s] not set. Skipping\n", varname));
392 return str;
395 /* Copy the full %(NAME) into envname so it can be replaced.*/
397 copylen = MIN( (q+1-p),(sizeof(varname)-1) );
398 strncpy( varname, p, copylen );
399 varname[copylen] = '\0';
400 r = realloc_string_sub(str, varname, value);
401 SAFE_FREE( value );
403 /* skip over the %(varname) */
405 return r;
408 /*******************************************************************
409 Patch from jkf@soton.ac.uk
410 Added this to implement %p (NIS auto-map version of %H)
411 *******************************************************************/
413 static const char *automount_path(const char *user_name)
415 TALLOC_CTX *ctx = talloc_tos();
416 const char *server_path;
418 /* use the passwd entry as the default */
419 /* this will be the default if WITH_AUTOMOUNT is not used or fails */
421 server_path = talloc_strdup(ctx, get_user_home_dir(ctx, user_name));
422 if (!server_path) {
423 return "";
426 #if (defined(HAVE_NETGROUP) && defined (WITH_AUTOMOUNT))
428 if (lp_nis_home_map()) {
429 const char *home_path_start;
430 char *automount_value = automount_lookup(ctx, user_name);
432 if(automount_value && strlen(automount_value) > 0) {
433 home_path_start = strchr_m(automount_value,':');
434 if (home_path_start != NULL) {
435 DEBUG(5, ("NIS lookup succeeded. "
436 "Home path is: %s\n",
437 home_path_start ?
438 (home_path_start+1):""));
439 server_path = talloc_strdup(ctx,
440 home_path_start+1);
441 if (!server_path) {
442 server_path = "";
445 } else {
446 /* NIS key lookup failed: default to
447 * user home directory from password file */
448 DEBUG(5, ("NIS lookup failed. Using Home path from "
449 "passwd file. Home path is: %s\n", server_path ));
452 #endif
454 DEBUG(4,("Home server path: %s\n", server_path));
455 return server_path;
458 /*******************************************************************
459 Patch from jkf@soton.ac.uk
460 This is Luke's original function with the NIS lookup code
461 moved out to a separate function.
462 *******************************************************************/
464 static const char *automount_server(const char *user_name)
466 TALLOC_CTX *ctx = talloc_tos();
467 const char *server_name;
468 const char *local_machine_name = get_local_machine_name();
470 /* use the local machine name as the default */
471 /* this will be the default if WITH_AUTOMOUNT is not used or fails */
472 if (local_machine_name && *local_machine_name) {
473 server_name = talloc_strdup(ctx, local_machine_name);
474 } else {
475 server_name = talloc_strdup(ctx, global_myname());
478 if (!server_name) {
479 return "";
482 #if (defined(HAVE_NETGROUP) && defined (WITH_AUTOMOUNT))
483 if (lp_nis_home_map()) {
484 char *p;
485 char *srv;
486 char *automount_value = automount_lookup(ctx, user_name);
487 if (!automount_value) {
488 return "";
490 srv = talloc_strdup(ctx, automount_value);
491 if (!srv) {
492 return "";
494 p = strchr_m(srv, ':');
495 if (!p) {
496 return "";
498 *p = '\0';
499 server_name = srv;
500 DEBUG(5, ("NIS lookup succeeded. Home server %s\n",
501 server_name));
503 #endif
505 DEBUG(4,("Home server: %s\n", server_name));
506 return server_name;
509 /****************************************************************************
510 Do some standard substitutions in a string.
511 len is the length in bytes of the space allowed in string str. If zero means
512 don't allow expansions.
513 ****************************************************************************/
515 void standard_sub_basic(const char *smb_name, const char *domain_name,
516 char *str, size_t len)
518 char *s;
520 if ( (s = alloc_sub_basic( smb_name, domain_name, str )) != NULL ) {
521 strncpy( str, s, len );
524 SAFE_FREE( s );
528 /****************************************************************************
529 Do some standard substitutions in a string.
530 This function will return an allocated string that have to be freed.
531 ****************************************************************************/
533 char *talloc_sub_basic(TALLOC_CTX *mem_ctx, const char *smb_name,
534 const char *domain_name, const char *str)
536 char *a, *t;
538 if ( (a = alloc_sub_basic(smb_name, domain_name, str)) == NULL ) {
539 return NULL;
541 t = talloc_strdup(mem_ctx, a);
542 SAFE_FREE(a);
543 return t;
546 /****************************************************************************
547 ****************************************************************************/
549 char *alloc_sub_basic(const char *smb_name, const char *domain_name,
550 const char *str)
552 char *b, *p, *s, *r, *a_string;
553 fstring pidstr, vnnstr;
554 char addr[INET6_ADDRSTRLEN];
555 const char *local_machine_name = get_local_machine_name();
556 TALLOC_CTX *tmp_ctx = NULL;
558 /* workaround to prevent a crash while looking at bug #687 */
560 if (!str) {
561 DEBUG(0,("alloc_sub_basic: NULL source string! This should not happen\n"));
562 return NULL;
565 a_string = SMB_STRDUP(str);
566 if (a_string == NULL) {
567 DEBUG(0, ("alloc_sub_basic: Out of memory!\n"));
568 return NULL;
571 tmp_ctx = talloc_stackframe();
573 for (b = s = a_string; (p = strchr_m(s, '%')); s = a_string + (p - b)) {
575 r = NULL;
576 b = a_string;
578 switch (*(p+1)) {
579 case 'U' :
580 r = strdup_lower(smb_name);
581 if (r == NULL) {
582 goto error;
584 a_string = realloc_string_sub(a_string, "%U", r);
585 break;
586 case 'G' : {
587 struct passwd *pass;
588 r = SMB_STRDUP(smb_name);
589 if (r == NULL) {
590 goto error;
592 pass = Get_Pwnam_alloc(tmp_ctx, r);
593 if (pass != NULL) {
594 a_string = realloc_string_sub(
595 a_string, "%G",
596 gidtoname(pass->pw_gid));
598 TALLOC_FREE(pass);
599 break;
601 case 'D' :
602 r = strdup_upper(domain_name);
603 if (r == NULL) {
604 goto error;
606 a_string = realloc_string_sub(a_string, "%D", r);
607 break;
608 case 'I' : {
609 int offset = 0;
610 client_addr(get_client_fd(), addr, sizeof(addr));
611 if (strnequal(addr,"::ffff:",7)) {
612 offset = 7;
614 a_string = realloc_string_sub(a_string, "%I",
615 addr + offset);
616 break;
618 case 'i':
619 a_string = realloc_string_sub( a_string, "%i",
620 client_socket_addr(get_client_fd(), addr, sizeof(addr)) );
621 break;
622 case 'L' :
623 if ( StrnCaseCmp(p, "%LOGONSERVER%", strlen("%LOGONSERVER%")) == 0 ) {
624 break;
626 if (local_machine_name && *local_machine_name) {
627 a_string = realloc_string_sub(a_string, "%L", local_machine_name);
628 } else {
629 a_string = realloc_string_sub(a_string, "%L", global_myname());
631 break;
632 case 'N':
633 a_string = realloc_string_sub(a_string, "%N", automount_server(smb_name));
634 break;
635 case 'M' :
636 a_string = realloc_string_sub(a_string, "%M", client_name(get_client_fd()));
637 break;
638 case 'R' :
639 a_string = realloc_string_sub(a_string, "%R", remote_proto);
640 break;
641 case 'T' :
642 a_string = realloc_string_sub(a_string, "%T", current_timestring(tmp_ctx, False));
643 break;
644 case 'a' :
645 a_string = realloc_string_sub(a_string, "%a",
646 get_remote_arch_str());
647 break;
648 case 'd' :
649 slprintf(pidstr,sizeof(pidstr)-1, "%d",(int)sys_getpid());
650 a_string = realloc_string_sub(a_string, "%d", pidstr);
651 break;
652 case 'h' :
653 a_string = realloc_string_sub(a_string, "%h", myhostname());
654 break;
655 case 'm' :
656 a_string = realloc_string_sub(a_string, "%m",
657 remote_machine
658 ? remote_machine
659 : "");
660 break;
661 case 'v' :
662 a_string = realloc_string_sub(a_string, "%v", SAMBA_VERSION_STRING);
663 break;
664 case 'w' :
665 a_string = realloc_string_sub(a_string, "%w", lp_winbind_separator());
666 break;
667 case '$' :
668 a_string = realloc_expand_env_var(a_string, p); /* Expand environment variables */
669 break;
670 case '(':
671 a_string = realloc_expand_longvar( a_string, p );
672 break;
673 case 'V' :
674 slprintf(vnnstr,sizeof(vnnstr)-1, "%u", get_my_vnn());
675 a_string = realloc_string_sub(a_string, "%V", vnnstr);
676 break;
677 default:
678 break;
681 p++;
682 SAFE_FREE(r);
684 if (a_string == NULL) {
685 goto done;
689 goto done;
691 error:
692 SAFE_FREE(a_string);
694 done:
695 TALLOC_FREE(tmp_ctx);
696 return a_string;
699 /****************************************************************************
700 Do some specific substitutions in a string.
701 This function will return an allocated string that have to be freed.
702 ****************************************************************************/
704 char *talloc_sub_specified(TALLOC_CTX *mem_ctx,
705 const char *input_string,
706 const char *username,
707 const char *domain,
708 uid_t uid,
709 gid_t gid)
711 char *a_string;
712 char *ret_string = NULL;
713 char *b, *p, *s;
714 TALLOC_CTX *tmp_ctx;
716 if (!(tmp_ctx = talloc_new(mem_ctx))) {
717 DEBUG(0, ("talloc_new failed\n"));
718 return NULL;
721 a_string = talloc_strdup(tmp_ctx, input_string);
722 if (a_string == NULL) {
723 DEBUG(0, ("talloc_sub_specified: Out of memory!\n"));
724 goto done;
727 for (b = s = a_string; (p = strchr_m(s, '%')); s = a_string + (p - b)) {
729 b = a_string;
731 switch (*(p+1)) {
732 case 'U' :
733 a_string = talloc_string_sub(
734 tmp_ctx, a_string, "%U", username);
735 break;
736 case 'u' :
737 a_string = talloc_string_sub(
738 tmp_ctx, a_string, "%u", username);
739 break;
740 case 'G' :
741 if (gid != -1) {
742 a_string = talloc_string_sub(
743 tmp_ctx, a_string, "%G",
744 gidtoname(gid));
745 } else {
746 a_string = talloc_string_sub(
747 tmp_ctx, a_string,
748 "%G", "NO_GROUP");
750 break;
751 case 'g' :
752 if (gid != -1) {
753 a_string = talloc_string_sub(
754 tmp_ctx, a_string, "%g",
755 gidtoname(gid));
756 } else {
757 a_string = talloc_string_sub(
758 tmp_ctx, a_string, "%g", "NO_GROUP");
760 break;
761 case 'D' :
762 a_string = talloc_string_sub(tmp_ctx, a_string,
763 "%D", domain);
764 break;
765 case 'N' :
766 a_string = talloc_string_sub(
767 tmp_ctx, a_string, "%N",
768 automount_server(username));
769 break;
770 default:
771 break;
774 p++;
775 if (a_string == NULL) {
776 goto done;
780 /* Watch out, using "mem_ctx" here, so all intermediate stuff goes
781 * away with the TALLOC_FREE(tmp_ctx) further down. */
783 ret_string = talloc_sub_basic(mem_ctx, username, domain, a_string);
785 done:
786 TALLOC_FREE(tmp_ctx);
787 return ret_string;
790 /****************************************************************************
791 ****************************************************************************/
793 static char *alloc_sub_advanced(const char *servicename, const char *user,
794 const char *connectpath, gid_t gid,
795 const char *smb_name, const char *domain_name,
796 const char *str)
798 char *a_string, *ret_string;
799 char *b, *p, *s;
801 a_string = SMB_STRDUP(str);
802 if (a_string == NULL) {
803 DEBUG(0, ("alloc_sub_advanced: Out of memory!\n"));
804 return NULL;
807 for (b = s = a_string; (p = strchr_m(s, '%')); s = a_string + (p - b)) {
809 b = a_string;
811 switch (*(p+1)) {
812 case 'N' :
813 a_string = realloc_string_sub(a_string, "%N", automount_server(user));
814 break;
815 case 'H': {
816 char *h;
817 if ((h = get_user_home_dir(talloc_tos(), user)))
818 a_string = realloc_string_sub(a_string, "%H", h);
819 TALLOC_FREE(h);
820 break;
822 case 'P':
823 a_string = realloc_string_sub(a_string, "%P", connectpath);
824 break;
825 case 'S':
826 a_string = realloc_string_sub(a_string, "%S", servicename);
827 break;
828 case 'g':
829 a_string = realloc_string_sub(a_string, "%g", gidtoname(gid));
830 break;
831 case 'u':
832 a_string = realloc_string_sub(a_string, "%u", user);
833 break;
835 /* Patch from jkf@soton.ac.uk Left the %N (NIS
836 * server name) in standard_sub_basic as it is
837 * a feature for logon servers, hence uses the
838 * username. The %p (NIS server path) code is
839 * here as it is used instead of the default
840 * "path =" string in [homes] and so needs the
841 * service name, not the username. */
842 case 'p':
843 a_string = realloc_string_sub(a_string, "%p",
844 automount_path(servicename));
845 break;
847 default:
848 break;
851 p++;
852 if (a_string == NULL) {
853 return NULL;
857 ret_string = alloc_sub_basic(smb_name, domain_name, a_string);
858 SAFE_FREE(a_string);
859 return ret_string;
863 * This obviously is inefficient and needs to be merged into
864 * alloc_sub_advanced...
867 char *talloc_sub_advanced(TALLOC_CTX *mem_ctx,
868 const char *servicename, const char *user,
869 const char *connectpath, gid_t gid,
870 const char *smb_name, const char *domain_name,
871 const char *str)
873 char *a, *t;
875 if (!(a = alloc_sub_advanced(servicename, user, connectpath, gid,
876 smb_name, domain_name, str))) {
877 return NULL;
879 t = talloc_strdup(mem_ctx, a);
880 SAFE_FREE(a);
881 return t;
885 void standard_sub_advanced(const char *servicename, const char *user,
886 const char *connectpath, gid_t gid,
887 const char *smb_name, const char *domain_name,
888 char *str, size_t len)
890 char *s;
892 s = alloc_sub_advanced(servicename, user, connectpath,
893 gid, smb_name, domain_name, str);
895 if ( s ) {
896 strncpy( str, s, len );
897 SAFE_FREE( s );
901 /****************************************************************************
902 Do some standard substitutions in a string.
903 ****************************************************************************/
905 char *standard_sub_conn(TALLOC_CTX *ctx, connection_struct *conn, const char *str)
907 return talloc_sub_advanced(ctx,
908 lp_servicename(SNUM(conn)),
909 conn->server_info->unix_name,
910 conn->connectpath,
911 conn->server_info->utok.gid,
912 get_smb_user_name(),
914 str);