Skip to content

Commit

Permalink
add checkbox for the net ads join --no-dns-updates switch
Browse files Browse the repository at this point in the history
Signed-off-by: Aurelien Aptel <aaptel@suse.com>
  • Loading branch information
aaptel committed Aug 18, 2016
1 parent 62fd9cc commit ae3d587
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 6 deletions.
11 changes: 10 additions & 1 deletion src/include/samba-client/dialogs.rb
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,13 @@ def MembershipDialog
Ops.get_string(pw_data, "machine", "") != nil ?
Ops.get_string(pw_data, "machine", "") :
""
)
),
CheckBox(
Id(:update_dns),
Opt(:hstretch),
_('Update DNS blah'),
!!pw_data['update_dns'],
),
)
),
VSpacing(),
Expand Down Expand Up @@ -760,6 +766,9 @@ def MembershipDialog
val = Convert.to_string(UI.QueryWidget(Id(key), :Value))
Ops.set(Samba.password_data, key, val) if val != nil && val != ""
end
# update_dns is a boolean, using to_string is incorrect
Samba.password_data["update_dns"] = UI.QueryWidget(Id(:update_dns), :Value)

if Convert.to_string(UI.QueryWidget(Id(:ads), :Value)) != ""
SambaAD.SetADS(
Convert.to_string(UI.QueryWidget(Id(:ads), :Value))
Expand Down
8 changes: 6 additions & 2 deletions src/include/samba-client/routines.rb
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ def passwordUserPopup(message, defaultuser, domain, what)
default_id = "default_entry"
# default value of Machine Account
default_entry = Item(Id(default_id), _("(default)"))
update_dns = Empty()
if SambaAD.ADS != "" && what != :leave
machines = [default_entry]
machine_term = HBox(
Expand All @@ -77,6 +78,7 @@ def passwordUserPopup(message, defaultuser, domain, what)
),
VBox(Label(""), PushButton(Id(:acquire), _("O&btain list")))
)
update_dns = CheckBox(Id(:update_dns), Opt(:hstretch), _('Update DNS'), true)
end
UI.OpenDialog(
Opt(:decorated),
Expand All @@ -90,6 +92,7 @@ def passwordUserPopup(message, defaultuser, domain, what)
InputField(Id(:user), Opt(:hstretch), _("&Username"), defaultuser),
Password(Id(:passwd), Opt(:hstretch), Label.Password),
machine_term,
update_dns,
VSpacing(0.2),
ButtonBox(
PushButton(Id(:ok), Opt(:default), Label.OKButton),
Expand Down Expand Up @@ -146,7 +149,7 @@ def passwordUserPopup(message, defaultuser, domain, what)
end
end

result = ret == :ok ? { "user" => user, "password" => pass } : nil
result = ret == :ok ? { "user" => user, "password" => pass, "update_dns" => UI.QueryWidget(Id(:update_dns), :Value) } : nil
if SambaAD.ADS != "" && ret == :ok && what != :leave
machine = Convert.to_string(UI.QueryWidget(Id(:machines), :Value))
Ops.set(result, "machine", machine) if machine != default_id
Expand Down Expand Up @@ -267,7 +270,8 @@ def JoinDomain(workgroup)
Ops.get(passwd, "password", ""),
Ops.get(passwd, "machine"),
relname,
relver
relver,
passwd["update_dns"]
)

if error != nil
Expand Down
5 changes: 3 additions & 2 deletions src/modules/Samba.rb
Original file line number Diff line number Diff line change
Expand Up @@ -821,7 +821,8 @@ def Write(write_only)
),
Ops.get(@password_data, "machine"),
relname,
relver
relver,
!!@password_data['update_dns']
)
end
end
Expand Down Expand Up @@ -959,7 +960,7 @@ def Import(settings)
Ops.get_string(settings, ["active_directory", "kdc"], "")
)
elsif key == "join"
@password_data = Ops.get_map(settings, "join", {})
@password_data = Ops.get_map(settings, "join", {'update_dns' => true})
elsif key == "mkhomedir"
SetMkHomeDir(Ops.get_boolean(settings, "mkhomedir", @mkhomedir))
elsif key == "disable_dhcp_hostname"
Expand Down
6 changes: 5 additions & 1 deletion src/modules/SambaNetJoin.pm
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ BEGIN{$TYPEINFO{Join}=[
"function","string","string","string","string","string","string", "string", "string"]}
sub Join {
my ($self, $domain, $join_level, $user, $passwd, $machine, $release_name,
$release_version) = @_;
$release_version, $update_dns) = @_;

my $netbios_name = SambaConfig->GlobalGetStr("netbios name", undef);
my $server = SambaAD->ADS ();
Expand Down Expand Up @@ -341,6 +341,10 @@ sub Join {
. " osVer='" . String->Quote ($release_version) . "'"
. " osName='" . String->Quote ($release_name) . "'";

if ($server ne "" && !$update_dns) {
$cmd .= " --no-dns-update"
}

if ($machine) {
$machine =~ s/dc=([^,]*)//gi; # remove DC=* parts
$machine =~ s/([^,]*)=//gi; # leave only values from the rest
Expand Down

0 comments on commit ae3d587

Please sign in to comment.