If there is no realm set we should not add it to the machine account.
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
{
char *pass = NULL;
char *account = NULL;
+ const char *realm = lp_realm();
+ int rc;
+
if (!get_cmdline_auth_info_use_machine_account(auth_info)) {
return false;
return false;
}
- if (asprintf(&account, "%s$@%s", lp_netbios_name(), lp_realm()) < 0) {
- return false;
+ if (realm != NULL && realm[0] != '\0') {
+ rc = asprintf(&account,
+ "%s$@%s",
+ lp_netbios_name(),
+ realm);
+ if (rc < 0) {
+ return false;
+ }
+ } else {
+ rc = asprintf(&account,
+ "%s$",
+ lp_netbios_name());
+ if (rc < 0) {
+ return false;
+ }
}
pass = secrets_fetch_machine_password(lp_workgroup(), NULL, NULL);