mirror of
https://github.com/samba-team/samba.git
synced 2024-12-23 17:34:34 +03:00
s3:net: Refactor net_ads_setspn_add(), allocate a talloc context
ADS_STRUCT will be allocated in the talloc context. Signed-off-by: Samuel Cabrero <scabrero@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
This commit is contained in:
parent
d8c84717ee
commit
d4059d525c
@ -3416,32 +3416,35 @@ out:
|
|||||||
|
|
||||||
static int net_ads_setspn_add(struct net_context *c, int argc, const char **argv)
|
static int net_ads_setspn_add(struct net_context *c, int argc, const char **argv)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
TALLOC_CTX *tmp_ctx = talloc_stackframe();
|
||||||
bool ok = false;
|
|
||||||
ADS_STRUCT *ads = NULL;
|
ADS_STRUCT *ads = NULL;
|
||||||
|
ADS_STATUS status;
|
||||||
|
bool ok = false;
|
||||||
|
int ret = -1;
|
||||||
|
|
||||||
if (c->display_usage || argc < 1) {
|
if (c->display_usage || argc < 1) {
|
||||||
d_printf("%s\n%s",
|
d_printf("%s\n%s",
|
||||||
_("Usage:"),
|
_("Usage:"),
|
||||||
_("net ads setspn add <machinename> SPN\n"));
|
_("net ads setspn add <machinename> SPN\n"));
|
||||||
ret = 0;
|
TALLOC_FREE(tmp_ctx);
|
||||||
goto done;
|
return 0;
|
||||||
}
|
}
|
||||||
if (!ADS_ERR_OK(ads_startup(c, true, &ads))) {
|
|
||||||
ret = -1;
|
status = ads_startup(c, true, &ads);
|
||||||
goto done;
|
if (!ADS_ERR_OK(status)) {
|
||||||
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (argc > 1) {
|
if (argc > 1) {
|
||||||
ok = ads_setspn_add(ads, argv[0], argv[1]);
|
ok = ads_setspn_add(ads, argv[0], argv[1]);
|
||||||
} else {
|
} else {
|
||||||
ok = ads_setspn_add(ads, lp_netbios_name(), argv[0]);
|
ok = ads_setspn_add(ads, lp_netbios_name(), argv[0]);
|
||||||
}
|
}
|
||||||
if (!ok) {
|
|
||||||
ret = -1;
|
ret = ok ? 0 : -1;
|
||||||
}
|
out:
|
||||||
done:
|
ads_destroy(&ads);
|
||||||
if (ads) {
|
TALLOC_FREE(tmp_ctx);
|
||||||
ads_destroy(&ads);
|
|
||||||
}
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user