diff options
author | Rusty Russell <rusty@rustcorp.com.au> | 2012-07-18 15:07:23 +0930 |
---|---|---|
committer | Rusty Russell <rusty@rustcorp.com.au> | 2012-07-18 15:07:23 +0930 |
commit | fe72740e8221575921c22030d6d4fcb19201b03b (patch) | |
tree | 0b1bb254e23d6541eede8f2ff4494af477fd5566 /source3/utils | |
parent | c809eec53fb1d2a36909e4934dff349f91e3359e (diff) | |
download | samba-fe72740e8221575921c22030d6d4fcb19201b03b.tar.gz samba-fe72740e8221575921c22030d6d4fcb19201b03b.tar.bz2 samba-fe72740e8221575921c22030d6d4fcb19201b03b.zip |
loadparm: make the source3/ lp_ functions take an explicit TALLOC_CTX *.
They use talloc_tos() internally: hoist that up to the callers, some
of whom don't want to us talloc_tos().
A simple patch, but hits a lot of files.
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
Diffstat (limited to 'source3/utils')
-rw-r--r-- | source3/utils/net_idmap.c | 3 | ||||
-rw-r--r-- | source3/utils/net_sam.c | 15 | ||||
-rw-r--r-- | source3/utils/net_usershare.c | 8 | ||||
-rw-r--r-- | source3/utils/smbpasswd.c | 4 | ||||
-rw-r--r-- | source3/utils/testparm.c | 44 |
5 files changed, 40 insertions, 34 deletions
diff --git a/source3/utils/net_idmap.c b/source3/utils/net_idmap.c index 28f9ed938e..f067071de1 100644 --- a/source3/utils/net_idmap.c +++ b/source3/utils/net_idmap.c @@ -79,7 +79,8 @@ static const char* net_idmap_dbfile(struct net_context *c) d_fprintf(stderr, _("Out of memory!\n")); } } else if (strequal(lp_idmap_backend(), "tdb2")) { - dbfile = lp_parm_talloc_string(-1, "tdb", "idmap2.tdb", NULL); + dbfile = lp_parm_talloc_string(talloc_tos(), + -1, "tdb", "idmap2.tdb", NULL); if (dbfile == NULL) { dbfile = talloc_asprintf(talloc_tos(), "%s/idmap2.tdb", lp_private_dir()); diff --git a/source3/utils/net_sam.c b/source3/utils/net_sam.c index 7163e663f8..c21d9daec1 100644 --- a/source3/utils/net_sam.c +++ b/source3/utils/net_sam.c @@ -1699,7 +1699,8 @@ static int net_sam_provision(struct net_context *c, int argc, const char **argv) uname = talloc_strdup(tc, "domusers"); wname = talloc_strdup(tc, "Domain Users"); - dn = talloc_asprintf(tc, "cn=%s,%s", "domusers", lp_ldap_group_suffix()); + dn = talloc_asprintf(tc, "cn=%s,%s", "domusers", + lp_ldap_group_suffix(talloc_tos())); gidstr = talloc_asprintf(tc, "%u", (unsigned int)domusers_gid); gtype = talloc_asprintf(tc, "%d", SID_NAME_DOM_GRP); @@ -1775,7 +1776,8 @@ domu_done: uname = talloc_strdup(tc, "domadmins"); wname = talloc_strdup(tc, "Domain Admins"); - dn = talloc_asprintf(tc, "cn=%s,%s", "domadmins", lp_ldap_group_suffix()); + dn = talloc_asprintf(tc, "cn=%s,%s", "domadmins", + lp_ldap_group_suffix(talloc_tos())); gidstr = talloc_asprintf(tc, "%u", (unsigned int)domadmins_gid); gtype = talloc_asprintf(tc, "%d", SID_NAME_DOM_GRP); @@ -1865,7 +1867,8 @@ doma_done: } name = talloc_strdup(tc, "Administrator"); - dn = talloc_asprintf(tc, "uid=Administrator,%s", lp_ldap_user_suffix()); + dn = talloc_asprintf(tc, "uid=Administrator,%s", + lp_ldap_user_suffix(talloc_tos())); uidstr = talloc_asprintf(tc, "%u", (unsigned int)uid); gidstr = talloc_asprintf(tc, "%u", (unsigned int)domadmins_gid); dir = talloc_sub_specified(tc, lp_template_homedir(), @@ -1989,7 +1992,8 @@ doma_done: } } - dn = talloc_asprintf(tc, "uid=%s,%s", pwd->pw_name, lp_ldap_user_suffix ()); + dn = talloc_asprintf(tc, "uid=%s,%s", pwd->pw_name, + lp_ldap_user_suffix (talloc_tos())); uidstr = talloc_asprintf(tc, "%u", (unsigned int)pwd->pw_uid); gidstr = talloc_asprintf(tc, "%u", (unsigned int)pwd->pw_gid); if (!dn || !uidstr || !gidstr) { @@ -2074,7 +2078,8 @@ doma_done: uname = talloc_strdup(tc, "domguests"); wname = talloc_strdup(tc, "Domain Guests"); - dn = talloc_asprintf(tc, "cn=%s,%s", "domguests", lp_ldap_group_suffix()); + dn = talloc_asprintf(tc, "cn=%s,%s", "domguests", + lp_ldap_group_suffix(talloc_tos())); gidstr = talloc_asprintf(tc, "%u", (unsigned int)pwd->pw_gid); gtype = talloc_asprintf(tc, "%d", SID_NAME_DOM_GRP); diff --git a/source3/utils/net_usershare.c b/source3/utils/net_usershare.c index b11757a611..153b45e7f8 100644 --- a/source3/utils/net_usershare.c +++ b/source3/utils/net_usershare.c @@ -135,7 +135,7 @@ int net_usershare_usage(struct net_context *c, int argc, const char **argv) static char *get_basepath(TALLOC_CTX *ctx) { - char *basepath = talloc_strdup(ctx, lp_usershare_path()); + char *basepath = lp_usershare_path(ctx); if (!basepath) { return NULL; @@ -174,7 +174,7 @@ static int net_usershare_delete(struct net_context *c, int argc, const char **ar us_path = talloc_asprintf(talloc_tos(), "%s/%s", - lp_usershare_path(), + lp_usershare_path(talloc_tos()), sharename); if (!us_path) { TALLOC_FREE(sharename); @@ -1104,13 +1104,13 @@ int net_usershare(struct net_context *c, int argc, const char **argv) return -1; } - dp = opendir(lp_usershare_path()); + dp = opendir(lp_usershare_path(talloc_tos())); if (!dp) { int err = errno; d_fprintf(stderr, _("net usershare: cannot open usershare directory %s. " "Error %s\n"), - lp_usershare_path(), strerror(err) ); + lp_usershare_path(talloc_tos()), strerror(err) ); if (err == EACCES) { d_fprintf(stderr, _("You do not have permission to create a " diff --git a/source3/utils/smbpasswd.c b/source3/utils/smbpasswd.c index 3689983444..43edab24ee 100644 --- a/source3/utils/smbpasswd.c +++ b/source3/utils/smbpasswd.c @@ -286,7 +286,7 @@ static bool store_ldap_admin_pw (char* pw) if (!secrets_init()) return False; - return secrets_store_ldap_pw(lp_ldap_admin_dn(), pw); + return secrets_store_ldap_pw(lp_ldap_admin_dn(talloc_tos()), pw); } @@ -301,7 +301,7 @@ static int process_root(int local_flags) char *old_passwd = NULL; if (local_flags & LOCAL_SET_LDAP_ADMIN_PW) { - char *ldap_admin_dn = lp_ldap_admin_dn(); + char *ldap_admin_dn = lp_ldap_admin_dn(talloc_tos()); if ( ! *ldap_admin_dn ) { DEBUG(0,("ERROR: 'ldap admin dn' not defined! Please check your smb.conf\n")); goto done; diff --git a/source3/utils/testparm.c b/source3/utils/testparm.c index b75fc61b6e..105f1c5746 100644 --- a/source3/utils/testparm.c +++ b/source3/utils/testparm.c @@ -170,8 +170,8 @@ cannot be set in the smb.conf file. nmbd will abort with this setting.\n"); if (!lp_pam_password_change()) { #endif - if((lp_passwd_program() == NULL) || - (strlen(lp_passwd_program()) == 0)) + if((lp_passwd_program(talloc_tos()) == NULL) || + (strlen(lp_passwd_program(talloc_tos())) == 0)) { fprintf( stderr, "ERROR: the 'unix password sync' parameter is set and there is no valid 'passwd program' \ parameter.\n" ); @@ -181,7 +181,7 @@ parameter.\n" ); char *truncated_prog = NULL; const char *p; - passwd_prog = lp_passwd_program(); + passwd_prog = lp_passwd_program(talloc_tos()); p = passwd_prog; next_token_talloc(talloc_tos(), &p, @@ -197,18 +197,18 @@ cannot be executed (error was %s).\n", truncated_prog, strerror(errno) ); } #endif - if(lp_passwd_chat() == NULL) { + if(lp_passwd_chat(talloc_tos()) == NULL) { fprintf(stderr, "ERROR: the 'unix password sync' parameter is set and there is no valid 'passwd chat' \ parameter.\n"); ret = 1; } - if ((lp_passwd_program() != NULL) && - (strlen(lp_passwd_program()) > 0)) + if ((lp_passwd_program(talloc_tos()) != NULL) && + (strlen(lp_passwd_program(talloc_tos())) > 0)) { /* check if there's a %u parameter present */ - if(strstr_m(lp_passwd_program(), "%u") == NULL) { - fprintf(stderr, "ERROR: the 'passwd program' (%s) requires a '%%u' parameter.\n", lp_passwd_program()); + if(strstr_m(lp_passwd_program(talloc_tos()), "%u") == NULL) { + fprintf(stderr, "ERROR: the 'passwd program' (%s) requires a '%%u' parameter.\n", lp_passwd_program(talloc_tos())); ret = 1; } } @@ -219,9 +219,9 @@ parameter.\n"); */ if(lp_encrypted_passwords()) { - if(strstr_m( lp_passwd_chat(), "%o")!=NULL) { + if(strstr_m( lp_passwd_chat(talloc_tos()), "%o")!=NULL) { fprintf(stderr, "ERROR: the 'passwd chat' script [%s] expects to use the old plaintext password \ -via the %%o substitution. With encrypted passwords this is not possible.\n", lp_passwd_chat() ); +via the %%o substitution. With encrypted passwords this is not possible.\n", lp_passwd_chat(talloc_tos()) ); ret = 1; } } @@ -283,7 +283,7 @@ static void do_per_share_checks(int s) char *hasquery = strchr_m(deny_list[i], '?'); if(hasstar || hasquery) { fprintf(stderr,"Invalid character %c in hosts deny list (%s) for service %s.\n", - hasstar ? *hasstar : *hasquery, deny_list[i], lp_servicename(s) ); + hasstar ? *hasstar : *hasquery, deny_list[i], lp_servicename(talloc_tos(), s) ); } } } @@ -294,7 +294,7 @@ static void do_per_share_checks(int s) char *hasquery = strchr_m(allow_list[i], '?'); if(hasstar || hasquery) { fprintf(stderr,"Invalid character %c in hosts allow list (%s) for service %s.\n", - hasstar ? *hasstar : *hasquery, allow_list[i], lp_servicename(s) ); + hasstar ? *hasstar : *hasquery, allow_list[i], lp_servicename(talloc_tos(), s) ); } } } @@ -302,7 +302,7 @@ static void do_per_share_checks(int s) if(lp_level2_oplocks(s) && !lp_oplocks(s)) { fprintf(stderr,"Invalid combination of parameters for service %s. \ Level II oplocks can only be set if oplocks are also set.\n", - lp_servicename(s) ); + lp_servicename(talloc_tos(), s) ); } if (!lp_store_dos_attributes(s) && lp_map_hidden(s) @@ -310,34 +310,34 @@ static void do_per_share_checks(int s) { fprintf(stderr,"Invalid combination of parameters for service " "%s. Map hidden can only work if create mask includes " - "octal 01 (S_IXOTH).\n", lp_servicename(s)); + "octal 01 (S_IXOTH).\n", lp_servicename(talloc_tos(), s)); } if (!lp_store_dos_attributes(s) && lp_map_hidden(s) && (lp_force_create_mode(s) & S_IXOTH)) { fprintf(stderr,"Invalid combination of parameters for service " "%s. Map hidden can only work if force create mode " - "excludes octal 01 (S_IXOTH).\n", lp_servicename(s)); + "excludes octal 01 (S_IXOTH).\n", lp_servicename(talloc_tos(), s)); } if (!lp_store_dos_attributes(s) && lp_map_system(s) && !(lp_create_mask(s) & S_IXGRP)) { fprintf(stderr,"Invalid combination of parameters for service " "%s. Map system can only work if create mask includes " - "octal 010 (S_IXGRP).\n", lp_servicename(s)); + "octal 010 (S_IXGRP).\n", lp_servicename(talloc_tos(), s)); } if (!lp_store_dos_attributes(s) && lp_map_system(s) && (lp_force_create_mode(s) & S_IXGRP)) { fprintf(stderr,"Invalid combination of parameters for service " "%s. Map system can only work if force create mode " - "excludes octal 010 (S_IXGRP).\n", lp_servicename(s)); + "excludes octal 010 (S_IXGRP).\n", lp_servicename(talloc_tos(), s)); } #ifdef HAVE_CUPS - if (lp_printing(s) == PRINT_CUPS && *(lp_printcommand(s)) != '\0') { + if (lp_printing(s) == PRINT_CUPS && *(lp_printcommand(talloc_tos(), s)) != '\0') { fprintf(stderr,"Warning: Service %s defines a print command, but \ rameter is ignored when using CUPS libraries.\n", - lp_servicename(s) ); + lp_servicename(talloc_tos(), s) ); } #endif } @@ -424,7 +424,7 @@ rameter is ignored when using CUPS libraries.\n", for (s=0;s<1000;s++) { if (VALID_SNUM(s)) - if (strlen(lp_servicename(s)) > 12) { + if (strlen(lp_servicename(talloc_tos(), s)) > 12) { fprintf(stderr, "WARNING: You have some share names that are longer than 12 characters.\n" ); fprintf(stderr, "These may not be accessible to some older clients.\n" ); fprintf(stderr, "(Eg. Windows9x, WindowsMe, and smbclient prior to Samba 3.0.)\n" ); @@ -489,10 +489,10 @@ rameter is ignored when using CUPS libraries.\n", if (allow_access(lp_hostsdeny(-1), lp_hostsallow(-1), cname, caddr) && allow_access(lp_hostsdeny(s), lp_hostsallow(s), cname, caddr)) { fprintf(stderr,"Allow connection from %s (%s) to %s\n", - cname,caddr,lp_servicename(s)); + cname,caddr,lp_servicename(talloc_tos(), s)); } else { fprintf(stderr,"Deny connection from %s (%s) to %s\n", - cname,caddr,lp_servicename(s)); + cname,caddr,lp_servicename(talloc_tos(), s)); } } } |