Author: vlendec Date: 2006-06-16 21:23:13 +0000 (Fri, 16 Jun 2006) New Revision: 16302
WebSVN: http://websvn.samba.org/cgi-bin/viewcvs.cgi?view=rev&root=samba&rev=16302 Log: Add the domain name as an argument to sub_advanced and get rid of sub_conn. This makes it a bit more verbose to call, but eventually I want to ripple this up the call chain so that the references to current_user_info etc disappear. This way the dependencies become more obvious. Volker Modified: trunk/source/lib/afs.c trunk/source/lib/substitute.c trunk/source/modules/vfs_expand_msdfs.c trunk/source/modules/vfs_full_audit.c trunk/source/modules/vfs_recycle.c trunk/source/nsswitch/winbindd_user.c trunk/source/rpc_server/srv_srvsvc_nt.c trunk/source/smbd/lanman.c trunk/source/smbd/service.c trunk/source/torture/vfstest.c Changeset: Modified: trunk/source/lib/afs.c =================================================================== --- trunk/source/lib/afs.c 2006-06-16 21:10:19 UTC (rev 16301) +++ trunk/source/lib/afs.c 2006-06-16 21:23:13 UTC (rev 16302) @@ -211,6 +211,7 @@ BOOL afs_login(connection_struct *conn) { + extern userdom_struct current_user_info; extern struct current_user current_user; DATA_BLOB ticket; pstring afs_username; @@ -222,7 +223,11 @@ struct ClearToken ct; pstrcpy(afs_username, lp_afs_username_map()); - standard_sub_conn(conn, afs_username, sizeof(afs_username)); + standard_sub_advanced(SNUM(conn), conn->user, + conn->connectpath, conn->gid, + get_current_username(), + current_user_info.domain, + afs_username, sizeof(afs_username)); user_sid = ¤t_user.nt_user_token->user_sids[0]; pstring_sub(afs_username, "%s", sid_string_static(user_sid)); Modified: trunk/source/lib/substitute.c =================================================================== --- trunk/source/lib/substitute.c 2006-06-16 21:10:19 UTC (rev 16301) +++ trunk/source/lib/substitute.c 2006-06-16 21:23:13 UTC (rev 16302) @@ -665,30 +665,10 @@ /**************************************************************************** ****************************************************************************/ -char *talloc_sub_advanced(TALLOC_CTX *mem_ctx, - int snum, - const char *user, - const char *connectpath, - gid_t gid, - const char *smb_name, - const char *str) -{ - char *a, *t; - a = alloc_sub_advanced(snum, user, connectpath, gid, smb_name, str); - if (!a) { - return NULL; - } - t = talloc_strdup(mem_ctx, a); - SAFE_FREE(a); - return t; -} - -/**************************************************************************** -****************************************************************************/ - char *alloc_sub_advanced(int snum, const char *user, - const char *connectpath, gid_t gid, - const char *smb_name, const char *str) + const char *connectpath, gid_t gid, + const char *smb_name, const char *domain_name, + const char *str) { char *a_string, *ret_string; char *b, *p, *s, *h; @@ -745,22 +725,20 @@ } } - ret_string = alloc_sub_basic(smb_name, current_user_info.domain, - a_string); + ret_string = alloc_sub_basic(smb_name, domain_name, a_string); SAFE_FREE(a_string); return ret_string; } -/**************************************************************************** - Do some standard substitutions in a string. -****************************************************************************/ - -void standard_sub_conn(connection_struct *conn, char *str, size_t len) +void standard_sub_advanced(int snum, const char *user, + const char *connectpath, gid_t gid, + const char *smb_name, const char *domain_name, + char *str, size_t len) { char *s; - s = alloc_sub_advanced(SNUM(conn), conn->user, conn->connectpath, - conn->gid, smb_user_name, str); + s = alloc_sub_advanced(snum, user, connectpath, gid, smb_name, + domain_name, str); if ( s ) { strncpy( str, s, len ); @@ -769,25 +747,6 @@ } /**************************************************************************** -****************************************************************************/ - -char *talloc_sub_conn(TALLOC_CTX *mem_ctx, connection_struct *conn, const char *str) -{ - return talloc_sub_advanced(mem_ctx, SNUM(conn), conn->user, - conn->connectpath, conn->gid, - smb_user_name, str); -} - -/**************************************************************************** -****************************************************************************/ - -char *alloc_sub_conn(connection_struct *conn, const char *str) -{ - return alloc_sub_advanced(SNUM(conn), conn->user, conn->connectpath, - conn->gid, smb_user_name, str); -} - -/**************************************************************************** Like standard_sub but by snum. ****************************************************************************/ @@ -806,7 +765,7 @@ } s = alloc_sub_advanced(snum, cached_user, "", current_user.ut.gid, - smb_user_name, str); + smb_user_name, current_user_info.domain, str); if ( s ) { strncpy( str, s, len ); Modified: trunk/source/modules/vfs_expand_msdfs.c =================================================================== --- trunk/source/modules/vfs_expand_msdfs.c 2006-06-16 21:10:19 UTC (rev 16301) +++ trunk/source/modules/vfs_expand_msdfs.c 2006-06-16 21:23:13 UTC (rev 16302) @@ -110,6 +110,7 @@ int filename_len; pstring targethost; pstring new_target; + extern userdom_struct current_user_info; if (filename_start == NULL) { DEBUG(10, ("No filename start in %s\n", target)); @@ -135,7 +136,11 @@ return False; } - standard_sub_conn(conn, mapfilename, sizeof(mapfilename)); + standard_sub_advanced(SNUM(conn), conn->user, + conn->connectpath, conn->gid, + get_current_username(), + current_user_info.domain, + mapfilename, sizeof(mapfilename)); DEBUG(10, ("Expanded targethost to %s\n", targethost)); Modified: trunk/source/modules/vfs_full_audit.c =================================================================== --- trunk/source/modules/vfs_full_audit.c 2006-06-16 21:10:19 UTC (rev 16301) +++ trunk/source/modules/vfs_full_audit.c 2006-06-16 21:23:13 UTC (rev 16302) @@ -641,10 +641,15 @@ static char *audit_prefix(connection_struct *conn) { static pstring prefix; + extern userdom_struct current_user_info; pstrcpy(prefix, lp_parm_const_string(SNUM(conn), "full_audit", "prefix", "%u|%I")); - standard_sub_snum(SNUM(conn), prefix, sizeof(prefix)-1); + standard_sub_advanced(SNUM(conn), conn->user, + conn->connectpath, conn->gid, + get_current_username(), + current_user_info.domain, + prefix, sizeof(prefix)); return prefix; } Modified: trunk/source/modules/vfs_recycle.c =================================================================== --- trunk/source/modules/vfs_recycle.c 2006-06-16 21:10:19 UTC (rev 16301) +++ trunk/source/modules/vfs_recycle.c 2006-06-16 21:23:13 UTC (rev 16302) @@ -367,11 +367,14 @@ } } +extern userdom_struct current_user_info; + /** * Check if file should be recycled **/ static int recycle_unlink(vfs_handle_struct *handle, const char *file_name) { + connection_struct *conn = handle->conn; char *path_name = NULL; char *temp_name = NULL; char *final_name = NULL; @@ -383,7 +386,11 @@ BOOL exist; int rc = -1; - repository = alloc_sub_conn(handle->conn, recycle_repository(handle)); + repository = alloc_sub_advanced(SNUM(conn), conn->user, + conn->connectpath, conn->gid, + get_current_username(), + current_user_info.domain, + recycle_repository(handle)); ALLOC_CHECK(repository, done); /* shouldn't we allow absolute path names here? --metze */ /* Yes :-). JRA. */ Modified: trunk/source/nsswitch/winbindd_user.c =================================================================== --- trunk/source/nsswitch/winbindd_user.c 2006-06-16 21:10:19 UTC (rev 16301) +++ trunk/source/nsswitch/winbindd_user.c 2006-06-16 21:23:13 UTC (rev 16302) @@ -51,7 +51,7 @@ shell. */ /* The substitution of %U and %D in the 'template homedir' is done - by alloc_sub_specified() below. */ + by talloc_sub_specified() below. */ templ = talloc_sub_specified(NULL, lp_template, username, domname, uid, gid); Modified: trunk/source/rpc_server/srv_srvsvc_nt.c =================================================================== --- trunk/source/rpc_server/srv_srvsvc_nt.c 2006-06-16 21:10:19 UTC (rev 16301) +++ trunk/source/rpc_server/srv_srvsvc_nt.c 2006-06-16 21:23:13 UTC (rev 16302) @@ -25,6 +25,7 @@ #include "includes.h" extern struct generic_mapping file_generic_mapping; +extern userdom_struct current_user_info; #undef DBGC_CLASS #define DBGC_CLASS DBGC_RPC_SRV @@ -70,11 +71,16 @@ static void init_srv_share_info_1(pipes_struct *p, SRV_SHARE_INFO_1 *sh1, int snum) { + connection_struct *conn = p->conn; pstring remark; char *net_name = lp_servicename(snum); pstrcpy(remark, lp_comment(snum)); - standard_sub_conn(p->conn, remark,sizeof(remark)); + standard_sub_advanced(SNUM(conn), conn->user, + conn->connectpath, conn->gid, + get_current_username(), + current_user_info.domain, + remark, sizeof(remark)); init_srv_share_info1(&sh1->info_1, net_name, get_share_type(snum), remark); init_srv_share_info1_str(&sh1->info_1_str, net_name, remark); @@ -86,6 +92,7 @@ static void init_srv_share_info_2(pipes_struct *p, SRV_SHARE_INFO_2 *sh2, int snum) { + connection_struct *conn = p->conn; pstring remark; pstring path; pstring passwd; @@ -94,7 +101,11 @@ char *net_name = lp_servicename(snum); pstrcpy(remark, lp_comment(snum)); - standard_sub_conn(p->conn, remark,sizeof(remark)); + standard_sub_advanced(SNUM(conn), conn->user, + conn->connectpath, conn->gid, + get_current_username(), + current_user_info.domain, + remark, sizeof(remark)); pstrcpy(path, "C:"); pstrcat(path, lp_pathname(snum)); @@ -179,11 +190,16 @@ static void init_srv_share_info_501(pipes_struct *p, SRV_SHARE_INFO_501 *sh501, int snum) { + connection_struct *conn = p->conn; pstring remark; const char *net_name = lp_servicename(snum); pstrcpy(remark, lp_comment(snum)); - standard_sub_conn(p->conn, remark, sizeof(remark)); + standard_sub_advanced(SNUM(conn), conn->user, + conn->connectpath, conn->gid, + get_current_username(), + current_user_info.domain, + remark, sizeof(remark)); init_srv_share_info501(&sh501->info_501, net_name, get_share_type(snum), remark, (lp_csc_policy(snum) << 4)); init_srv_share_info501_str(&sh501->info_501_str, net_name, remark); @@ -195,6 +211,7 @@ static void init_srv_share_info_502(pipes_struct *p, SRV_SHARE_INFO_502 *sh502, int snum) { + connection_struct *conn = p->conn; pstring net_name; pstring remark; pstring path; @@ -208,7 +225,11 @@ pstrcpy(net_name, lp_servicename(snum)); pstrcpy(remark, lp_comment(snum)); - standard_sub_conn(p->conn, remark,sizeof(remark)); + standard_sub_advanced(SNUM(conn), conn->user, + conn->connectpath, conn->gid, + get_current_username(), + current_user_info.domain, + remark, sizeof(remark)); pstrcpy(path, "C:"); pstrcat(path, lp_pathname(snum)); @@ -233,10 +254,15 @@ static void init_srv_share_info_1004(pipes_struct *p, SRV_SHARE_INFO_1004* sh1004, int snum) { + connection_struct *conn = p->conn; pstring remark; pstrcpy(remark, lp_comment(snum)); - standard_sub_conn(p->conn, remark, sizeof(remark)); + standard_sub_advanced(SNUM(conn), conn->user, + conn->connectpath, conn->gid, + get_current_username(), + current_user_info.domain, + remark, sizeof(remark)); ZERO_STRUCTP(sh1004); Modified: trunk/source/smbd/lanman.c =================================================================== --- trunk/source/smbd/lanman.c 2006-06-16 21:10:19 UTC (rev 16301) +++ trunk/source/smbd/lanman.c 2006-06-16 21:23:13 UTC (rev 16302) @@ -72,7 +72,11 @@ StrnCpy(buf,src,sizeof(buf)/2); pstring_sub(buf,"%S",lp_servicename(snum)); - standard_sub_conn(conn,buf,sizeof(buf)); + standard_sub_advanced(SNUM(conn), conn->user, + conn->connectpath, conn->gid, + get_current_username(), + current_user_info.domain, + buf, sizeof(buf)); l = push_ascii(*dst,buf,*n, STR_TERMINATE); (*dst) += l; (*n) -= l; @@ -99,7 +103,11 @@ } StrnCpy(buf,s,sizeof(buf)/2); pstring_sub(buf,"%S",lp_servicename(snum)); - standard_sub_conn(conn,buf,sizeof(buf)); + standard_sub_advanced(SNUM(conn), conn->user, + conn->connectpath, conn->gid, + get_current_username(), + current_user_info.domain, + buf, sizeof(buf)); return strlen(buf) + 1; } @@ -111,7 +119,11 @@ } StrnCpy(buf,s,sizeof(buf)/2); pstring_sub(buf,"%S",lp_servicename(snum)); - standard_sub_conn(conn,buf,sizeof(buf)); + standard_sub_advanced(SNUM(conn), conn->user, + conn->connectpath, conn->gid, + get_current_username(), + current_user_info.domain, + buf, sizeof(buf)); return &buf[0]; } @@ -2701,7 +2713,11 @@ SIVAL(p,6,0); } else { SIVAL(p,6,PTR_DIFF(p2,*rdata)); - standard_sub_conn(conn,comment,sizeof(comment)); + standard_sub_advanced(SNUM(conn), conn->user, + conn->connectpath, conn->gid, + get_current_username(), + current_user_info.domain, + comment, sizeof(comment)); StrnCpy(p2,comment,MAX(mdrcnt - struct_len,0)); p2 = skip_string(p2,1); } @@ -3126,8 +3142,12 @@ SSVALS(p,102,-1); /* bad_pw_count */ SSVALS(p,104,-1); /* num_logons */ SIVAL(p,106,PTR_DIFF(p2,*rdata)); /* logon_server */ - pstrcpy(p2,"\\\\%L"); - standard_sub_conn(conn, p2,0); + { + pstring tmp; + pstrcpy(tmp, "\\\\%L"); + standard_sub_basic("", "", tmp, sizeof(tmp)); + pstrcpy(p2, tmp); + } p2 = skip_string(p2,1); SSVAL(p,110,49); /* country_code */ SSVAL(p,112,860); /* code page */ Modified: trunk/source/smbd/service.c =================================================================== --- trunk/source/smbd/service.c 2006-06-16 21:10:19 UTC (rev 16301) +++ trunk/source/smbd/service.c 2006-06-16 21:23:13 UTC (rev 16302) @@ -746,7 +746,11 @@ { pstring s; pstrcpy(s,lp_pathname(snum)); - standard_sub_conn(conn,s,sizeof(s)); + standard_sub_advanced(SNUM(conn), conn->user, + conn->connectpath, conn->gid, + get_current_username(), + current_user_info.domain, + s, sizeof(s)); set_conn_connectpath(conn,s); DEBUG(3,("Connect path is '%s' for service [%s]\n",s, lp_servicename(snum))); @@ -821,7 +825,11 @@ if (*lp_rootpreexec(snum)) { pstring cmd; pstrcpy(cmd,lp_rootpreexec(snum)); - standard_sub_conn(conn,cmd,sizeof(cmd)); + standard_sub_advanced(SNUM(conn), conn->user, + conn->connectpath, conn->gid, + get_current_username(), + current_user_info.domain, + cmd, sizeof(cmd)); DEBUG(5,("cmd=%s\n",cmd)); ret = smbrun(cmd,NULL); if (ret != 0 && lp_rootpreexec_close(snum)) { @@ -854,7 +862,11 @@ if (*lp_preexec(snum)) { pstring cmd; pstrcpy(cmd,lp_preexec(snum)); - standard_sub_conn(conn,cmd,sizeof(cmd)); + standard_sub_advanced(SNUM(conn), conn->user, + conn->connectpath, conn->gid, + get_current_username(), + current_user_info.domain, + cmd, sizeof(cmd)); ret = smbrun(cmd,NULL); if (ret != 0 && lp_preexec_close(snum)) { DEBUG(1,("preexec gave %d - failing connection\n", @@ -1148,7 +1160,11 @@ change_to_user(conn, vuid)) { pstring cmd; pstrcpy(cmd,lp_postexec(SNUM(conn))); - standard_sub_conn(conn,cmd,sizeof(cmd)); + standard_sub_advanced(SNUM(conn), conn->user, + conn->connectpath, conn->gid, + get_current_username(), + current_user_info.domain, + cmd, sizeof(cmd)); smbrun(cmd,NULL); change_to_root_user(); } @@ -1158,7 +1174,11 @@ if (*lp_rootpostexec(SNUM(conn))) { pstring cmd; pstrcpy(cmd,lp_rootpostexec(SNUM(conn))); - standard_sub_conn(conn,cmd,sizeof(cmd)); + standard_sub_advanced(SNUM(conn), conn->user, + conn->connectpath, conn->gid, + get_current_username(), + current_user_info.domain, + cmd, sizeof(cmd)); smbrun(cmd,NULL); } Modified: trunk/source/torture/vfstest.c =================================================================== --- trunk/source/torture/vfstest.c 2006-06-16 21:10:19 UTC (rev 16301) +++ trunk/source/torture/vfstest.c 2006-06-16 21:23:13 UTC (rev 16302) @@ -575,6 +575,6 @@ process_cmd(&vfs, line); } - free(vfs.conn); + conn_free(vfs.conn); return 0; }