ACC SHELL
/**
* File: include/samba-server/dialogs.ycp
* Package: Configuration of samba-server
* Summary: Dialogs definitions
* Authors: Stanislav Visnovsky <stanislav.visnovsky@suse.cz>
* Lukas Ocilka <locilka@suse.cz>
*
* $Id: dialogs.ycp 60883 2010-02-19 16:22:09Z locilka $
*/
{
textdomain "samba-server";
import "String";
import "Label";
import "Wizard";
import "Mode";
import "Popup";
import "ProductFeatures";
import "FileUtils";
import "SambaRole";
import "SambaServer";
import "SambaConfig";
import "SambaService";
import "SambaNetJoin";
import "SambaTrustDom";
import "SambaAccounts";
import "SambaNmbLookup";
import "Samba";
import "SambaAD";
import "CWM";
import "CWMTab";
import "CWMServiceStart";
import "CWMFirewallInterfaces";
include "samba-server/helps.ycp";
include "samba-server/dialogs-items.ycp";
include "samba-server/ldap-widget.ycp";
include "samba-client/routines.ycp";
include "samba-server/complex.ycp";
string return_tab = "startup";
string pdc = _("&Primary Domain Controller (PDC)");
string bdc = _("B&ackup Domain Controller (BDC)");
string standalone = _("Not a Domain &Controller");
// routines
list sharesItems(boolean filt) {
list<string> shares = SambaConfig::GetShares();
if (filt) {
list<string> system = ["homes","printers","print$","netlogon","profiles"];
shares = filter(string s, shares, ``(!contains(system, s)));
}
integer index = 0;
return maplist( string name, shares, ``{
index = index+1;
string pth = SambaConfig::ShareGetStr(name, "path", "");
string enabled = SambaConfig::ShareEnabled(name) ? _("Enabled") : _("Disabled");
string comment = SambaConfig::ShareGetStr(name, "comment", "");
boolean ro = SambaConfig::ShareGetTruth(name, "read only", true);
return `item( `id(index), enabled, ro ? _("Yes") : _("No"), name, pth , comment);
});
}
boolean confirmAbort() {
y2warning("confirm abort");
if (! SambaServer::GetModified())
return true;
return Popup::ReallyAbort (true);
}
any Installation_Step1 () {
string caption = _("Samba Installation") + ": " + _("Step 1 of 2");
// feature dropped
// list <string> workgroups = SambaNmbLookup::GetAvailableNeighbours(nil);
// always add the currently configured workgroup
string workgroup = SambaConfig::GlobalGetStr("workgroup", "");
// if (size(workgroup) > 0 && !contains(workgroups, workgroup)) {
// workgroups = add(workgroups, workgroup);
// }
term contents = `VBox (
`VSquash (
`Left (
// `ComboBox ( `id( "workgroups" ), `opt( `editable ), _("&Workgroup or Domain Name"), workgroups )
// TRANSLATORS: text entry
`InputField (`id ("workgroups"), `opt (`hstretch), _("&Workgroup or Domain Name"), workgroup)
)
),
`VStretch ()
);
Wizard::SetContents( caption, contents, HELPS["inst_step1"]:"", false, true);
Wizard::DisableBackButton();
if (size(workgroup)>0) {
UI::ChangeWidget(`id("workgroups"), `Value, workgroup);
}
any ret = nil;
while(true) {
ret = UI::UserInput();
if ( ret == `next || ret == `cancel || ret == `abort) {
break;
} else {
y2error( "unexpected retcode: %1", ret );
continue;
}
}
if ( ret == `next ) {
string sel = (string)UI::QueryWidget( `id ("workgroups"), `Value );
y2milestone ("Setting workgroup '%1'",sel);
SambaConfig::GlobalSetStr("workgroup", sel);
}
Wizard::RestoreBackButton();
return ret;
}
any Installation_Step2 () {
string caption = _("Samba Installation") + ": " + _("Step 2 of 2");
string workgroup = SambaConfig::GlobalGetStr("workgroup", "");
boolean has_pdc = SambaNmbLookup::HasPDC(workgroup);
boolean has_bdc = SambaNmbLookup::HasBDC(workgroup);
term contents = `VBox(
//header of status-like information. followed by domain name
`VSquash(`Left(`Label( _("Current Domain Name:") + " " + workgroup))),
`VSpacing(1),
`VSquash(`Frame(_("Samba Server Type"), `VBox(
`RadioButtonGroup(`id("samba_server_type"), `VBox(
`VSpacing(1),
`Left(`RadioButton(`id("PDC"), pdc, !has_pdc)),
`HBox(
`HSpacing(4),
// appears on new line after Primary Domain Controller radio button
`Left(`Label(has_pdc?_("Not available because a PDC is present."):""))),
`VBox(
`Left(`RadioButton(`id("BDC"), bdc, false)),
`HBox(
`HSpacing(4),
`Left(`Label("")))
),
`Left(`RadioButton(`id ("Standalone"), standalone, has_pdc)),
`VSpacing(1)))))),
`VStretch());
string help = HELPS["inst_step2"]:"";
Wizard::SetContents( caption, contents, help, true, true );
UI::ChangeWidget(`id(`pdc), `Enabled, !has_pdc);
any ret = nil;
while(true) {
ret = UI::UserInput();
if (ret == `abort || ret == `cancel) {
if (confirmAbort()) break;
continue;
}
if ( ret == `back || ret == `next || ret == `abort || ret == `cancel ) {
if ( ret == `next )
{
// store the value
SambaRole::SetRole((string)UI::QueryWidget(`id("samba_server_type"), `CurrentButton));
}
break;
}
else {
y2error( "unexpected retcode: %1", ret );
continue;
}
}
return ret;
}
/************************* initial wizard end **************************/
string initial_role = nil;
string getRole() {
string role = SambaRole::GetRole();
if (role == "MEMBER") return "STANDALONE";
return role;
}
void BaseSettingsWidgetInit(string key)
{
UI::ChangeWidget(`id("workgroup_domainname"), `Value, SambaConfig::GlobalGetStr("workgroup", ""));
// initial for this dialog
// see also BNC #553349
initial_role = getRole();
UI::ChangeWidget(`id("domain_controller"), `Value, initial_role);
y2milestone ("Initial role: %1", initial_role);
}
void WinsSettingsWidgetInit(string key)
{
boolean wins = SambaConfig::GlobalGetTruth("wins support", false);
UI::ChangeWidget(`id("wins_server_support"), `Value, wins);
UI::ChangeWidget(`id("remote_wins_server"), `Value, ! wins);
UI::ChangeWidget(`id("wins_server_name"), `Enabled, ! wins);
UI::ChangeWidget(`id("wins_server_name"), `Value, SambaConfig::GlobalGetStr("wins server",""));
}
void WinsViaDHCPWidgetInit (string key) {
UI::ChangeWidget(`id(`dhcp), `Value, Samba::GetDHCP());
}
void WinsHostResolutionWidgetInit (string key) {
UI::ChangeWidget(`id(`wins_dns), `Value, Samba::GetHostsResolution());
}
void GlobalConfigStringWidgetInit(string key)
{
UI::ChangeWidget(`id(key), `Value, SambaConfig::GlobalGetStr(key, ""));
}
void BaseSettingsWidgetStore(string key, map event_descr)
{
string sel = (string)UI::QueryWidget(`id("workgroup_domainname"), `Value);
y2milestone("Setting workgroup '%1'",sel);
SambaConfig::GlobalSetStr("workgroup", sel);
string role = (string)UI::QueryWidget(`id("domain_controller"), `Value);
if (role == "STANDALONE" && SambaNmbLookup::IsDomain(sel)) {
role = "MEMBER";
}
// Do not set the role if it is unchanged. It would rewrite some expert settings
// that might have been set manually (Expert Settings), bugzilla #255824
if (toupper (role) != toupper (initial_role)) {
y2milestone ("Setting role '%1' (was '%2')", role, SambaRole::GetRole());
SambaRole::SetRole (role);
} else {
y2milestone ("Role type not changed (%1)", role);
}
}
void WinsSettingsWidgetStore(string key, map event_descr)
{
if ( (boolean)UI::QueryWidget(`id("wins_server_support"), `Value)) {
y2milestone("Enabling wins support");
SambaConfig::GlobalSetTruth("wins support", true);
SambaConfig::GlobalSetStr("wins server", nil);
} else {
SambaConfig::GlobalSetTruth("wins support", false);
SambaConfig::GlobalSetStr("wins server", (string)UI::QueryWidget(`id("wins_server_name"), `Value));
y2milestone("Disabling wins support, using server '%1'", SambaConfig::GlobalGetStr("wins server", "<none>"));
}
}
void WinsViaDHCPWidgetStore (string key, map event_descr) {
boolean new_value = (boolean) UI::QueryWidget(`id (`dhcp), `Value);
if (new_value != nil) {
y2milestone ("Setting WINS via DHCP to '%1' returned '%2'",
new_value, Samba::SetDHCP (new_value)
);
}
}
void WinsHostResolutionWidgetStore (string key, map event_descr) {
boolean new_value = (boolean) UI::QueryWidget(`id (`wins_dns), `Value);
if (new_value != nil) {
y2milestone ("Setting WINS Host Resolution '%1' returned '%2'",
new_value, Samba::SetHostsResolution (new_value)
);
}
}
void GlobalConfigStringWidgetStore(string key, map event_descr)
{
string value = (string)UI::QueryWidget(`id(key), `Value);
boolean changed = SambaConfig::GlobalSetStr(key, value == "" ? nil : value);
// warn about the netbios name change
if (key == "netbios name" && changed && !Mode::config()) {
Popup::Warning( warnings["netbios"]:"" );
}
}
symbol WinsSettingsWidgetHandle(string key, map event_descr)
{
any event = event_descr["ID"]:nil;
if ( event == "wins_server_support" || event == "remote_wins_server" ) {
UI::ChangeWidget(`id("wins_server_name"), `Enabled, event == "remote_wins_server");
}
return nil;
}
symbol AdvancedSettingsWidgetHandle(string key, map event)
{
if (is(event["ID"]:nil, symbol) && contains([ `passdb, `global_settings], event["ID"]:`cancel)) {
return_tab = "identity";
return event["ID"]:`next;
}
return nil;
}
// User shares feature, bugzilla #143908
boolean allow_share = true;
integer max_shares = 0;
string shares_group = "";
// Guest Access check-box, BNC #579993
boolean guest_access = false;
void InitUserShareWidgets () {
max_shares = Samba::GetMaxShares ();
if (max_shares == 0) {
max_shares = 100;
allow_share = false;
} else {
allow_share = true;
}
guest_access = allow_share && Samba::GetGuessAccess();
shares_group = Samba::shares_group;
UI::ChangeWidget (`id(`group), `Value, shares_group);
UI::ChangeWidget (`id(`max_shares), `Value, max_shares);
UI::ChangeWidget (`id(`share_ch), `Value, allow_share);
UI::ChangeWidget (`id(`guest_ch), `Value, guest_access);
}
void AdjustUserShareWidgets () {
foreach (symbol t, [`group, `max_shares], {
UI::ChangeWidget (`id(t), `Enabled,
(boolean) UI::QueryWidget(`id(`share_ch),`Value)
);
});
}
void StoreUserShareWidgets (string key, map event_descr) {
boolean new_share = (boolean)UI::QueryWidget(`id(`share_ch),`Value);
if (new_share && ! allow_share && SharesExist (Samba::shares_dir)) {
Samba::remove_shares = AskForSharesRemoval ();
}
integer max = (integer)UI::QueryWidget(`id(`max_shares),`Value);
if (!new_share) {
max = 0;
// Samba::stop_services = AskToStopServices();
Samba::stop_services = false;
}
Samba::SetShares (max,(string)UI::QueryWidget(`id(`group),`Value));
SambaServer::SetModified();
}
void SharesWidgetInit(string key)
{
list items = sharesItems(false);
UI::ChangeWidget( `id(`table ), `Items, items );
UI::ChangeWidget( `id(`edit), `Enabled, size(items)>0 );
UI::ChangeWidget( `id(`delete), `Enabled, size(items)>0 );
UI::ChangeWidget( `id(`toggle), `Enabled, size(items)>0 );
InitUserShareWidgets();
AdjustUserShareWidgets();
}
// Bugzilla #263302
boolean RenameShare (string share) {
if (! SambaConfig::ShareExists (share)) {
y2error ("Share %1 doesn't exist", share);
return false;
}
term content = `VBox (
// TRANSLATORS: dialog caption
`Heading (_("Rename Share")),
`HSquash (`MinWidth (
35,
`VBox (
// TRANSLATORS: text entry
`InputField (`id ("share_name"), `opt(`hstretch), _("New Share &Name"), share)
)
)),
`VSpacing (1),
`ButtonBox (
`PushButton (`id (`ok), `opt (`okButton), Label::OKButton()),
`PushButton (`id (`cancel), `opt (`cancelButton), Label::CancelButton())
)
);
UI::OpenDialog (content);
UI::SetFocus (`id ("share_name"));
boolean fc_ret = false;
any ret = nil;
while (true) {
ret = UI::UserInput();
if (ret == `ok) {
string new_share_name = (string) UI::QueryWidget (`id ("share_name"), `Value);
if (new_share_name == "") {
// TRANSLATORS: popup error message
Report::Error (_("Please enter a new share name."));
continue;
} else if (share == new_share_name) {
y2milestone ("Old and new share names are the same");
break;
} else if (SambaConfig::ShareExists (new_share_name)) {
// TRANSLATORS: popup error message, %1 is a variable share name
Report::Error (sformat (
_("Share '%1' already exists.\nPlease choose another share name."),
new_share_name
));
continue;
}
// Renaming share
map <string, string> old_share_settings = SambaConfig::ShareGetMap (share);
boolean old_share_enabled = SambaConfig::ShareEnabled (share);
y2milestone (
"Creating new share '%1' %2 -> %3",
new_share_name, old_share_settings,
SambaConfig::ShareSetMap (new_share_name, old_share_settings)
);
y2milestone (
"Removing share '%1' -> %2",
share,
SambaConfig::ShareRemove (share)
);
// enable or disable new share according the old one
if (SambaConfig::ShareEnabled (new_share_name) != old_share_enabled) {
SambaConfig::ShareAdjust(new_share_name, !SambaConfig::ShareEnabled (new_share_name));
}
fc_ret = true;
break;
# cancel
} else {
break;
}
}
UI::CloseDialog();
return fc_ret;
}
symbol SharesWidgetHandle(string key, map event_descr)
{
if (! is(event_descr["ID"]:nil, symbol)) return nil;
symbol ret = (symbol) event_descr["ID"]:nil;
return_tab = "shares";
if (ret == `share_ch) {
AdjustUserShareWidgets();
return nil;
}
if (ret == `add) {
return ret;
}
if (ret == `filter_all || ret == `filter_non_system) {
list items = sharesItems(ret == `filter_non_system);
UI::ChangeWidget ( `id( `table ), `Items, items );
return nil;
}
integer id = (integer) UI::QueryWidget(`id(`table), `CurrentItem);
if (id == nil) return nil;
string share = (string)argsof((term)UI::QueryWidget(`id(`table), `Item(id)))[3]:nil;
if (share == nil) return nil;
if (ret == `edit) {
shareToEdit = share;
return `edit;
}
if (ret == `toggle) {
SambaConfig::ShareAdjust(share, !SambaConfig::ShareEnabled(share));
UI::ChangeWidget( `id(`table), `Items, sharesItems(false) );
UI::ChangeWidget( `id(`table), `CurrentItem, id );
return nil;
}
if (ret == `delete)
{
// confirmation dialog before deleting a share
if (Popup::YesNo( sformat( _("If you delete share %1,\nall its settings will be lost.\nReally delete it?"), share)))
{
y2milestone (
"Removing share '%1' -> %2",
share,
SambaConfig::ShareRemove (share)
);
UI::ChangeWidget( `id(`table), `Items, sharesItems(false));
}
}
if (ret == `rename) {
if (RenameShare (share)) {
UI::ChangeWidget (`id(`table), `Items, sharesItems(false));
}
return nil;
}
return nil;
}
void AddTrustedDomain ()
{
//rwalter I couldn't make this one show up. Please make sure my deletions didn't make it too confusing.
term contents = `VBox (
`InputField (`id(`domain), `opt (`hstretch), _("Trusted &Domain")),
`Password (`id(`password), _("&Password") ),
`VSpacing (1),
`HBox (
`PushButton (`id (`ok), `opt (`default), Label::OKButton ()),
`PushButton (`id (`cancel), Label::CancelButton ())
)
);
UI::OpenDialog (contents);
UI::SetFocus (`id (`domain) );
symbol ret = nil;
do
{
ret = (symbol)UI::UserInput ();
if (ret == `ok)
{
string domain = (string) UI::QueryWidget (`domain, `Value);
string passwd = (string) UI::QueryWidget (`password, `Value);
if (size(domain) == 0) {
import "Report";
Report::Error (_("Domain name cannot be empty.") );
ret = nil;
}
boolean success = SambaTrustDom::Establish(domain, passwd);
if (success != true) {
import "Report";
Report::Error (_("Cannot establish trusted domain relationship."));
ret = nil;
}
}
} while (ret == nil );
UI::CloseDialog ();
}
boolean autoyast_warning_done = false;
void TrustedDomainsWidgetInit(string key)
{
if ( Mode::config() && !autoyast_warning_done)
{
// issue a warning, if not already done so
Popup::Warning (_("The password for trusted domains
is stored in the autoinstallation control file. The password
is stored as plain text. This can be considered
a security threat."));
autoyast_warning_done = true;
}
list<term> domains = [];
// SambaTrustDom::List() might return 'nil'
list <string> samba_trust_domain_list = SambaTrustDom::List();
if (samba_trust_domain_list != nil || samba_trust_domain_list != []) {
foreach (string key, samba_trust_domain_list, {
domains = add (domains, `item ( `id(key), key ) );
});
}
UI::ReplaceWidget(`id(`domains_tr), `SelectionBox(`id("trusted_domains"), _("&Trusted Domains"), domains));
// disable delete button if needed
UI::ChangeWidget (`id (`delete_domain), `Enabled, size (domains) != 0);
}
symbol TrustedDomainsWidgetHandle (string key, map event_descr)
{
if ( event_descr["ID"]:nil == `add_domain )
{
AddTrustedDomain ();
}
else if ( event_descr["ID"]:nil == `delete_domain )
{
string to_delete = (string)UI::QueryWidget(`id("trusted_domains"), `CurrentItem );
// confirmation
if (Popup::ContinueCancel(sformat(_("Really abandon trust relationship\nto trusted domain %1?"), to_delete)))
{
SambaTrustDom::Revoke(to_delete);
}
}
// reinitialize contents
TrustedDomainsWidgetInit (key);
return nil;
}
/**
* EditShareDialog dialog
* @return dialog result
*/
symbol EditShareDialog () ``{
term contents = `HBox (`HSpacing (1), `VBox (
`VSpacing (1),
"share_edit"
), `HSpacing (1));
// dialog caption
string caption = sformat( _("Share %1"), shareToEdit );
return CWM::ShowAndRun($[
"widget_names" : ["share_edit"],
"widget_descr" : xx_widgets,
"contents" : contents,
"caption" : caption,
"back_button" : Label::BackButton(),
"next_button" : Label::OKButton(),
"fallback_functions" : $[`abort: confirmAbort]
]);
}
symbol GlobalSettingsDialog () ``{
term contents = `HBox (`HSpacing (1), `VBox (
`VSpacing (1),
"globalsettings"
), `HSpacing (1));
// dialog caption
string caption = _("Expert Global Settings Configuration");
symbol res = CWM::ShowAndRun($[
"widget_names" : ["globalsettings"],
"widget_descr" : xx_widgets,
"contents" : contents,
"caption" : caption,
"back_button" : Label::BackButton(),
"next_button" : Label::OKButton(),
"fallback_functions" : $[`abort: confirmAbort]
]);
// if (res == `next) {
// update the rest of the settings using the entered ones
// SambaServer::role = SambaServer::DetermineRole();
// }
return res;
}
symbol AddShareDialog () ``{
term contents = `HVSquash(`HBox(
`HSpacing(1),
`VBox(`opt(`hstretch),
`VSpacing(1),
`Frame(_("Identification"), `VBox(
`InputField (`id(`name), `opt (`hstretch), _("Share &Name")),
`InputField (`id(`comment), `opt (`hstretch), _("Share &Description")))),
`Frame(_("Share Type"), `HBox(
`HSpacing ( 1 ),
`VBox(`opt(`hstretch ),
`RadioButtonGroup(`VBox(
`Left(`RadioButton(`id(`printer), `opt(`notify), _("&Printer"))),
`Left(`RadioButton(`id(`directory), `opt(`notify), _("&Directory"), true)))),
`HBox(
// translators: text entry label
`TextEntry(`id(`path), _("Share &Path"), "/home"),
`Bottom(`PushButton(`id(`browse), Label::BrowseButton()))),
`HBox(
// translators: checkbox label, setting for share
`Left(`CheckBox(`id(`read_only), _("&Read-Only"), false)),
`Left(`CheckBox(`id(`inherit_acls), _("&Inherit ACLs"), true)))),
`HSpacing(1))))));
// translators: dialog caption
string caption = _("New Share");
Wizard::SetContentsButtons ( caption, contents, HELPS["add_share"]:"",
Label::BackButton (), Label::OKButton () );
UI::SetFocus ( `id (`name));
symbol ret = nil;
do
{
// enable/disable path
boolean on = (boolean)UI::QueryWidget ( `id( `directory ), `Value );
UI::ChangeWidget ( `id (`path), `Enabled, on );
UI::ChangeWidget ( `id (`browse), `Enabled, on );
UI::ChangeWidget ( `id (`read_only), `Enabled, on );
UI::ChangeWidget ( `id (`inherit_acls), `Enabled, on );
ret = (symbol)UI::UserInput ();
if (ret == `printer || ret == `directory)
{
ret = nil;
continue;
}
if (ret == `browse)
{
// translators: file selection dialog title
string dir = UI::AskForExistingDirectory (
(string)UI::QueryWidget (`id(`path), `Value)
, _("Path for a Share") );
if( dir != nil ) {
UI::ChangeWidget( `id (`path), `Value, dir );
}
ret = nil;
} else if (ret == `next)
{
// OK was pressed
string name = (string) UI::QueryWidget( `id( `name ), `Value );
string pathvalue = (string) UI::QueryWidget( `id( `path ), `Value );
string comment = (string) UI::QueryWidget( `id( `comment ), `Value );
boolean printable = (boolean) UI::QueryWidget (`id ( `printer ), `Value );
if( size( name ) == 0 ) {
// translators: error message
Popup::Error( _("Share name cannot be empty.") );
ret = nil;
continue;
} else if( size( pathvalue ) == 0 && ! printable ) {
// translators: error message
Popup::Error( _("Share path cannot be empty.") );
ret = nil;
continue;
} else if (!printable && !SharePathWarning(pathvalue)) {
ret = nil;
continue;
} else if (!printable && !Mode::config() && !FileUtils::CheckAndCreatePath(pathvalue)) {
ret = nil;
continue;
}
map<string,string> res = $[
"comment": comment,
];
if (printable)
{
res["printable"] = "Yes";
res["path"] = "/var/tmp";
}
else
{
boolean read_only = (boolean)UI::QueryWidget(`id(`read_only), `Value);
boolean inherit_acls = (boolean)UI::QueryWidget(`id(`inherit_acls), `Value);
res["read only"] = read_only ? "Yes" : "No";
res["inherit acls"] = inherit_acls ? "Yes" : "No";
res["path"] = pathvalue;
}
if (SambaConfig::ShareExists(name)) {
// translators: popup error message for "add share", %1 is share name
Popup::Error( sformat( _("Share %1 already exists."), name ) );
ret = nil;
}
SambaConfig::ShareSetMap( name , res );
}
} while( ret == nil );
return ret;
}
any Installation_Conf_Tab () {
term shares_widget = `HBox(
`HWeight(1, `Empty()),
`HWeight(100, `VBox(
`HBox(
`Left(`Label(_("Available Shares"))),
`HStretch(),
`Right(`MenuButton(_("&Filter"), [
`item(`id(`filter_all), _("Show &All Shares") ),
`item(`id(`filter_non_system), _("Do Not Show &System Shares") )]))),
// translators: table header texts
`Table( `id(`table ), `opt(`hvstretch), `header(_("Status"), _("Read-Only"), _("Name"), _("Path"), _("Comment")), []),
`HBox(
`PushButton(`id(`add), Label::AddButton() + "..."),
`PushButton(`id(`edit), Label::EditButton() + "..."),
`PushButton(`id(`delete), Label::DeleteButton()),
`HStretch(),
`PushButton(`id(`rename), _("&Rename...")),
`PushButton(`id(`toggle), _("&Toggle Status"))
)
)),
`HWeight(1, `Empty())
);
term wins_widget = `HBox(
`HSpacing(1),
`VBox(
`VSpacing(0.5),
`RadioButtonGroup(`id("wins_support"),`VBox(
`Left(`RadioButton(`id("wins_server_support"), `opt(`notify ), _("WINS Server Support"))),
`Left(`RadioButton(`id("remote_wins_server"), `opt(`notify ), _("Remote WINS Server"))))),
`HBox(
`HSpacing(3),
`TextEntry(`id("wins_server_name"), _("Na&me"))),
`VSpacing(1)
),
`HSpacing(1)
);
term wins_via_dhcp = DHCPSupportTerm (Samba::GetDHCP());
// TRANSLATORS: check box
term wins_host_resolution = `Left (`CheckBox (`id (`wins_dns), _("Use WINS for Hostname Resolution")));
list<term> roles = [
// translators: combobox item
`item(`id("STANDALONE"), _("Not a DC")),
// translators: combobox item
`item(`id("PDC"), _("Primary (PDC)"))
];
// translators: combobox item
roles = add( roles, `item ( `id("BDC"), _("Backup (BDC)") ));
term basesettings_widget = `Frame(_("Base Settings"), `HBox(
`HSpacing(1),
`VBox(
// `ComboBox(`id("workgroup_domainname"), `opt(`editable, `hstretch), _("&Workgroup or Domain Name"),
// SambaNmbLookup::GetAvailableNeighbours(nil)),
`InputField (`id("workgroup_domainname"), `opt(`hstretch), _("&Workgroup or Domain Name")),
// translators: combobox label
`ComboBox(`id("domain_controller"), `opt(`hstretch), _("Domain &Controller"), roles),
`VStretch()
),
`HSpacing(1)));
term advanced_settings_widget = `MenuButton(_("Advanced Settings..."), [
`item(`id(`global_settings), _("&Expert Global Settings")),
`item(`id(`passdb), _("&User Authentication Sources")) ] );
term trusted_domains_widget = `HBox(
`HWeight(1, `Empty()),
`HWeight(100, `VBox(
`VWeight(7, `ReplacePoint(`id(`domains_tr),
`SelectionBox(`id("trusted_domains"), _("&Trusted Domains"), [] ))),
`VWeight(1, `HBox(
`PushButton(`id(`add_domain), Label::AddButton() + "..."),
`PushButton(`id(`delete_domain), Label::DeleteButton()),
`HStretch())),
`VStretch())),
`HWeight(1, `Empty()));
string caption = _("Samba Configuration");
map tabs_descr = $[
"startup": $[
//tab label
"header" : _("Start-&Up"),
"contents": `HBox(
`HWeight(2, `Empty()),
`HWeight(100, `VBox(
`VSpacing(1),
"SERVICE START",
`VSpacing(1),
`Frame(_("Firewall Settings"), "FIREWALL"),
`VStretch())),
`HWeight(2, `Empty())),
"widget_names": ["SERVICE START", "FIREWALL"]
],
"shares": $[
"header" : _("&Shares"),
"contents": `VBox(
`VBox (
"SHARES"
),
`HBox (
`HSpacing(1),
// Bugzilla #143908
// Bugzilla #144787, comment #43
SharesTerm ($[
"allow_share" : allow_share,
"group" : shares_group,
"max_shares" : max_shares,
// BNC #579993, Allow guest access
"guest_access": guest_access,
]),
`HSpacing(1)
),
`VSpacing(1)
),
"widget_names": ["SHARES"]
],
"identity": $[
"header" : _("I&dentity"),
"contents": `HBox( "IDENTITY COMMON HELP",
`HWeight(1, `Empty()),
`HWeight(100, `VBox(
`VSpacing(0.5),
`VBox (
`HBox (
`HWeight (1,
`VBox (
"BASE SETTINGS"
)
),
`HSpacing(0.5),
`HWeight (1,
`Frame (_("WINS"), `VBox (
"WINS SETTINGS",
`HBox (`HSpacing (1), "WINS via DHCP"),
`HBox (`HSpacing (1), "WINS Host Resolution"),
`VStretch()
))
)
),
`VSpacing(0.5),
`HBox (
`HWeight (1, `VBox (
"netbios name",
"ADVANCED SETTINGS"
)),
`HSpacing(0.5),
`HWeight (1, `Empty ())
)
),
`VStretch())
),
`HWeight(1, `Empty())
),
"widget_names": ["IDENTITY COMMON HELP", "BASE SETTINGS", "WINS SETTINGS", "WINS via DHCP", "WINS Host Resolution", "netbios name", "ADVANCED SETTINGS"]
]
];
tabs_descr = union(tabs_descr, $[
"trusted_domains_tab": $[
"header": _("&Trusted Domains"),
"contents": `VBox("TRUSTED DOMAINS"),
"widget_names": ["TRUSTED DOMAINS"]
],
"ldap_settings_tab": $[
"header": _("&LDAP Settings"),
"contents": `VBox("LDAP ESSENTIAL"),
"widget_names": ["LDAP ESSENTIAL"]
]
]);
map tabs_widget_descr = $[
"SERVICE START": CWMServiceStart::CreateAutoStartWidget($[
"get_service_auto_start": SambaService::GetServiceAutoStart,
"set_service_auto_start": SambaService::SetServiceAutoStart,
]),
// BNC #247344
"FIREWALL": CWMFirewallInterfaces::CreateOpenFirewallWidget($[
"services": [ "service:samba-server" ],
"display_details": true
]),
"SHARES": $[
"widget" : `custom,
"custom_widget" : shares_widget,
"init" : SharesWidgetInit,
"handle" : SharesWidgetHandle,
"store" : StoreUserShareWidgets,
"help": HELPS["smb_conf_tab_shares"]:"" + SharesHelp()
],
"IDENTITY COMMON HELP": $[
"widget" : `custom,
"custom_widget" : `Empty(),
"help": HELPS["smb_conf_tab_identity"]:""
],
"BASE SETTINGS": $[
"widget" : `custom,
"custom_widget" : basesettings_widget,
"help": HELPS["smb_conf_tab_base_settings"]:"",
"init": BaseSettingsWidgetInit,
"store": BaseSettingsWidgetStore,
],
"WINS SETTINGS": $[
"widget" : `custom,
"custom_widget" : wins_widget,
"help": HostsResolutionHelp(),
"init": WinsSettingsWidgetInit,
"store": WinsSettingsWidgetStore,
"handle": WinsSettingsWidgetHandle,
],
"WINS via DHCP" : $[
"widget" : `custom,
"custom_widget" : wins_via_dhcp,
"help": HELPS["smb_conf_tab_wins_via_dhcp"]:"",
"init": WinsViaDHCPWidgetInit,
"store": WinsViaDHCPWidgetStore,
],
"WINS Host Resolution" : $[
"widget" : `custom,
"custom_widget" : wins_host_resolution,
"help" : HELPS["smb_conf_tab_wins_host_resolution"]:"",
"init": WinsHostResolutionWidgetInit,
"store": WinsHostResolutionWidgetStore,
],
"netbios name": $[
"widget": `textentry,
"label": _("NetBIOS &Hostname"),
"help": HELPS["smb_conf_tab_netbios_name"]:"",
"init": GlobalConfigStringWidgetInit,
"store": GlobalConfigStringWidgetStore,
],
"ADVANCED SETTINGS": $[
"widget" : `custom,
"custom_widget" : advanced_settings_widget,
"help": HELPS["smb_conf_tab_advanced_settings"]:"",
"handle": AdvancedSettingsWidgetHandle,
],
"TRUSTED DOMAINS": $[
"widget": `custom,
"custom_widget": trusted_domains_widget,
"init": TrustedDomainsWidgetInit,
"handle": TrustedDomainsWidgetHandle,
"help": HELPS["smb_conf_tab_trusted_domains"]:"",
],
"LDAP ESSENTIAL": CreateSambaLDAPSettingsEssentialWidget(),
];
map widget_descr = $[
"tab": CWMTab::CreateWidget($[
"tab_order": ["startup", "shares", "identity", "trusted_domains_tab", "ldap_settings_tab"],
"tabs": tabs_descr,
"widget_descr": tabs_widget_descr,
"initial_tab" : return_tab,
"tab_help" : "",
]),
];
term contents = `VBox( "tab", `VStretch ());
list<map <string, any> > w = CWM::CreateWidgets (["tab"], (map <string, map <string, any> >)widget_descr);
string help = CWM::MergeHelps(w);
contents = CWM::PrepareDialog(contents, w);
Wizard::SetContentsButtons(caption, contents, help, Label::BackButton (), Label::OKButton ());
// BNC #440538
// Adjusted according to the YaST Style Guide
Wizard::SetAbortButton (`abort, Label::CancelButton());
Wizard::HideBackButton();
any ret = CWM::Run(w, $[`abort: confirmAbort ]);
return ret;
}
/**
* Dialog to configure passdb backends.
* @return dialog result
*/
symbol PassdbDialog () {
// dialog caption
string caption = _("User Information Sources");
list<map<string, any> > w = CWM::CreateWidgets (["passdb_edit"], (map <string, map <string, any> >)xx_widgets);
term contents = `HBox (`HSpacing (1), `VBox (
`VSpacing (1),
w[0, "widget"]:`VSpacing (0)
), `HSpacing (1));
string help = CWM::MergeHelps (w);
Wizard::SetContentsButtons (caption, contents, help, Label::BackButton (), Label::OKButton ());
/*
UI::ReplaceWidget( `id(`_tp_table_repl),
// TRANSLATORS: menu button label for accessing the LDAP-related settings and actions
`MenuButton( "LDAP",
// translators: menu item to show a LDAP-related settings
[ `item( `id(`ldap), _("Global LDAP Settings") ),
// translators: menu item to test the currently selected LDAP url
`item( `id(`ldap_test), _("Test LDAP Connection") ),
]
)
);
*/
return CWM::Run (w, $[`abort: confirmAbort]);
}
symbol EnsureRootAccountDialog () ``{
if (SambaRole::GetRole() != "PDC" ||
Mode::autoinst() || Mode::test() ||
SambaAccounts::UserExists("root"))
{
return `ok;
}
// try to create it
// first, ask for password
UI::OpenDialog(`HVSquash(
`VBox(
`Label( _("For a proper function, Samba server needs an\nadministrative account (root).\nIt will be created now.")),
`Password(`id(`passwd1), _("Samba root &Password")),
`Password(`id(`passwd2), _("&Verify Password")),
`HBox(
`PushButton(`id(`ok), `opt(`default), Label::OKButton()),
`PushButton(`id(`cancel), Label::CancelButton())))));
UI::SetFocus(`id(`passwd1));
any ret = nil;
string passwd = nil;
do {
ret = UI::UserInput();
if (ret == `ok) {
string passwd1 = (string) UI::QueryWidget(`id(`passwd1), `Value);
string passwd2 = (string) UI::QueryWidget(`id(`passwd2), `Value);
if ( passwd1 != passwd2 ) {
// TRANSLATORS: popup error message
Popup::Error (_("The first and the second version\nof the password do not match."));
ret = nil;
} else {
passwd = passwd1;
}
}
} while (ret == nil);
UI::CloseDialog();
if (ret == `cancel) return `cancel;
if (SambaAccounts::UserAdd("root", passwd)) {
// TRANSLATORS: popup error message, %1 is a username
Popup::Error ( sformat(_("Cannot create account for user %1."), "root" ) );
return `error;
}
return `ok;
}
symbol AskJoinDomainDialog() ``{
string workgroup = SambaConfig::GlobalGetStr("workgroup", "");
string role = SambaRole::GetRole();
// for autoyast, skip testing
if (Mode::config() ||
(role != "MEMBER" && role != "BDC"))
// (!SambaNmbLookup::IsDomain(workgroup)))
{
return `ok;
}
SambaAD::ReadADS(workgroup);
SambaAD::ReadRealm();
boolean res = SambaNetJoin::Test(workgroup);
if (res == true) {
return `ok;
}
// Xtranslators: popup question, The workgroup is a domain in fact and the machine is not a member, ask user what to do.
// %1 is the domain name
// if (!Popup::YesNo(sformat(_("This host is not a member\nof the domain %1.") + "\n\n"
// + _("Join the domain %1?") + "\n", workgroup)))
// {
// return `ok;
// }
string user = "Administrator";
string passwd = "";
UI::OpenDialog(`VBox(
// translators: popup to fill in the domain joining info; %1 is the domain name
`Label(sformat(_("Enter the username and the password\nfor joining the domain %1."), workgroup) + "\n\n"
+ _("To join the domain anonymously, leave the\ntext entries empty.") + "\n"),
// text entry label
`TextEntry(`id(`user), _("&Username"), user),
// text entry label
`Password(`id(`passwd), _("&Password")),
`HBox(
// translators: button label to skip joining to domain
`PushButton(`id(`skip), _("Do &Not Join")),
`PushButton(`id(`cancel), Label::CancelButton()),
`PushButton(`id(`ok), `opt(`default), Label::OKButton()))));
any ret = UI::UserInput();
user = (string)UI::QueryWidget(`id(`user), `Value);
passwd = (string)UI::QueryWidget(`id(`passwd), `Value);
UI::CloseDialog();
if (ret == `skip) return `skip;
if (ret != `ok) {
return `cancel;
}
// try to join the domain
string error = SambaNetJoin::Join(workgroup, tolower(role), user, passwd,"");
if (error != nil) {
Popup::Error(error);
return `error;
}
// Translators: Information popup, %1 is the name of the domain
Popup::Message(sformat(_("Domain %1 joined successfully."), workgroup));
return `ok;
}
/* EOF */
}
ACC SHELL 2018