summaryrefslogtreecommitdiffstats
path: root/samba_wizard/Samba.pm
diff options
context:
space:
mode:
authorAntoine Ginies <aginies@mandriva.com>2005-05-30 08:05:58 +0000
committerAntoine Ginies <aginies@mandriva.com>2005-05-30 08:05:58 +0000
commit481a8690e8016fc6fa743bdaefaa500658e23cf3 (patch)
tree527f56264a12c66497b82073ac24a6d937b924e0 /samba_wizard/Samba.pm
parent9c17e6ac41e29b6ee737eadfe9a491aa196c44a5 (diff)
downloaddrakwizard-481a8690e8016fc6fa743bdaefaa500658e23cf3.tar
drakwizard-481a8690e8016fc6fa743bdaefaa500658e23cf3.tar.gz
drakwizard-481a8690e8016fc6fa743bdaefaa500658e23cf3.tar.bz2
drakwizard-481a8690e8016fc6fa743bdaefaa500658e23cf3.tar.xz
drakwizard-481a8690e8016fc6fa743bdaefaa500658e23cf3.zip
detect previous Samba type, add more tips, add more information, add
more help, add ldap configuration, add more test, fix Samba type
Diffstat (limited to 'samba_wizard/Samba.pm')
-rwxr-xr-xsamba_wizard/Samba.pm222
1 files changed, 170 insertions, 52 deletions
diff --git a/samba_wizard/Samba.pm b/samba_wizard/Samba.pm
index 561f96ac..e0253cca 100755
--- a/samba_wizard/Samba.pm
+++ b/samba_wizard/Samba.pm
@@ -35,6 +35,7 @@ my $wiz = new MDK::Wizard::Wizcommon;
my $DOMAINNAME = chomp_(`dnsdomainname`);
my $SHORTHOSTNAME = chomp_(`hostname -s`);
+my $wiz_samba_etc = "/etc/sysconfig/wizard_samba";
my $o = {
name => 'Samba wizard',
@@ -76,7 +77,12 @@ my $o = {
wiz_domain_master => '',
wiz_password_server => '',
wiz_passdb_backend => '',
+ wiz_passdb_backend_yn => '',
wiz_domain => '',
+ wiz_ldap_admin_dn => '',
+ wiz_ldap_suffix => '',
+ wiz_ldap_root_pw => '',
+ wiz_ldap_root_pw_2 => '',
test => '',
},
init => sub {
@@ -115,8 +121,13 @@ $o->{pages} = {
name => N('Samba Configuration Wizard') . "\n\n" . N('Samba allows your server to behave as a file and print server for workstations running non-Linux systems.') . "\n\n" . N('This wizard will help you configuring the Samba services of your server.') . "\n\n" . N('PDC: primary domain controller') . "\n" . N('BDC: backup domain controller') . "\n" . N('standalone: standalone server') . "\n" . N('Member: member of a domain'),
no_back => 1,
pre => sub {
- $o->{var}{wiz_type} ||= 1;
- },
+ if (-f $wiz_samba_etc) {
+ $::in->ask_warn(N("Information"), N("It seems you previously setup a Samba server. This wizard will re-read your old configuration, and show you the Samba server type you choose"));
+ my $data = cat_($wiz_samba_etc);
+ my ($old_type) = $data =~ /type=(\d)/;
+ $o->{var}{wiz_type} = chomp_($old_type);
+ } else { $o->{var}{wiz_type} = 2 }
+ },
next => 'ask_type',
post => sub {
if ($o->{var}{wiz_type} == 2) {
@@ -124,7 +135,7 @@ $o->{pages} = {
elsif ($o->{var}{wiz_type} == 1) {
return 'bdc' }
elsif ($o->{var}{wiz_type} == 3) {
- return 'standalone' }
+ return 'ask_workgroup' }
elsif ($o->{var}{wiz_type} == 4) {
return 'member' }
},
@@ -138,17 +149,29 @@ $o->{pages} = {
$o->{var}{wiz_domain_master} = "yes";
$o->{var}{wiz_security} = "user";
$o->{var}{wiz_domain_logons} = "yes";
- $o->{var}{wiz_passdb_backend} ||= $samba->{global}{'passdb backend'};
- $o->{var}{wiz_wins_support} ||= $samba->{global}{'wins support'};
+ $o->{var}{wiz_wins_support} ||= $samba->{global}{'wins support'};
+ if ($samba->{global}{'passdb backend'}) {
+ $o->{var}{wiz_passdb_backend_yn} = "yes"
+ } else {
+ $o->{var}{wiz_passdb_backend_yn} = "no"
+ }
},
+ post => sub {
+ $o->{var}{wiz_passdb_backend_yn} =~ /yes/ and return 'ldap_conf';
+ },
data => [
{ label => N('Domain logons:'), fixed_val => \$o->{var}{wiz_domain_logons} },
{ label => N('Domain master:'), fixed_val => \$o->{var}{wiz_domain_master} },
{ label => N('Security:'), fixed_val => \$o->{var}{wiz_security} },
{ label => N('Wins support:'), val => \$o->{var}{wiz_wins_support}, fixed_list => \@yesorno },
- { label => N('Passdb backend'), val => \$o->{var}{wiz_passdb_backend}, help => "ldapsam:ldap://<ldap server name>" },
+ { label => N('Use LDAP Passdb backend'), val => \$o->{var}{wiz_passdb_backend_yn}, fixed_list => \@yesorno },
],
-# complete => {},
+ complete => sub {
+ if (!$o->{var}{wiz_domain_master}) {
+ $::in->ask_warn(N("Error"), N("The domain is wrong."));
+ return 1
+ } else { return 0 };
+ },
next => 'ask_workgroup',
},
bdc => {
@@ -161,7 +184,12 @@ $o->{pages} = {
{ label => N('Security:'), fixed_val => \$o->{var}{wiz_security} },
{ label => N('Domain master:'), fixed_val => \$o->{var}{wiz_domain_master} },
],
-# complete => {},
+ complete => sub {
+ if (!$o->{var}{wiz_domain_master}) {
+ $::in->ask_warn(N("Error"), N("The domain is wrong."));
+ return 1
+ } else { return 0 };
+ },
next => 'ask_workgroup',
},
member => {
@@ -171,27 +199,76 @@ $o->{pages} = {
$o->{var}{wiz_domain_master} = "no";
$o->{var}{wiz_password_server} ||= $samba->{global}{'password server'};
$o->{var}{wiz_domain} ||= $samba->{global}{domain};
- $o->{var}{wiz_passdb_backend} ||= $samba->{global}{'passdb backend'};;
- },
+ if ($samba->{global}{'passdb backend'}) {
+ $o->{var}{wiz_passdb_backend_yn} = "yes"
+ } else {
+ $o->{var}{wiz_passdb_backend_yn} = "no"
+ }
+ },
+ post => sub {
+ $o->{var}{wiz_passdb_backend_yn} =~ /yes/ and return 'ldap_conf';
+ },
data => [
{ label => N('Password server'), val => \$o->{var}{wiz_password_server} },
{ label => N('Domain:'), val => \$o->{var}{wiz_domain} },
- { label => N('Passdb backend'), val => \$o->{var}{wiz_passdb_backend}, help => "ldapsam:ldap://<ldap server name>" },
+ { label => N('Use LDAP Passdb backend'), val => \$o->{var}{wiz_passdb_backend_yn}, fixed_list => \@yesorno },
{ label => N('Security:'), fixed_val => \$o->{var}{wiz_security} },
{ label => N('Domain master:'), fixed_val => \$o->{var}{wiz_domain_master} },
],
-# complete => {},
+ complete => sub {
+ if (!$o->{var}{wiz_domain}) {
+ $::in->ask_warn(N("Error"), N("The domain is wrong."));
+ return 1
+ } else { return 0 };
+ },
next => 'ask_workgroup',
},
- standalone => {
- name => N('Standalone server') . "\n\n" . ('Share data, users home or printers.'),
- data => [
- { label => N('val:'), val => \$o->{var}{test} },
-# { label => N(':'), val => \$o->{var}{} },
- ],
-# complete => {},
- next => 'ask_workgroup',
+ ldap_conf => {
+ name => N('LDAP configuration for Domain Controlling') . "\n\n" . N('The account (dn) that samba uses to access the LDAP server. This account needs to have write access to the LDAP tree. You will need to give samba the password for this dn.'),
+ pre => sub {
+ if ($samba->{global}{'ldap suffix'}) {
+ $o->{var}{wiz_ldap_suffix} = $samba->{global}{'ldap suffix'};
+ } else {
+ $o->{var}{wiz_ldap_suffix} = "dc=mydomain,dc=com";
+ }
+ if ($samba->{global}{'ldap admin dn'})
+ { $o->{var}{wiz_ldap_admin_dn} ||= $samba->{global}{'ldap admin dn'}
+ } else {
+ $o->{var}{wiz_ldap_admin_dn} = "root";
+ }
+ if ($samba->{global}{'passdb backend'}) {
+ $o->{var}{wiz_passdb_backend} = $samba->{global}{'passdb backend'}
+ } else {
+ $o->{var}{wiz_passdb_backend} = "ldapsam:ldap://localhost";
+ }
+ },
+ data => [
+ { label => N('Passdb backend'), val => \$o->{var}{wiz_passdb_backend}, help => "ldapsam:ldap://<ldap server name>" },
+ { label => N('LDAP administrator'), val => \$o->{var}{wiz_ldap_admin_dn}, help => "root" },
+ { label => N('LDAP suffix'), val => \$o->{var}{wiz_ldap_suffix}, help => "dc=$DOMAINNAME,dc=com" },
+ { label => N('LDAP password'), hidden => 1, val => \$o->{var}{wiz_ldap_root_pw} },
+ { label => N('LDAP password check:'), hidden => 1, val => \$o->{var}{wiz_ldap_root_pw_2} },
+ ],
+ complete => sub {
+ if (!($o->{var}{wiz_ldap_suffix})) {
+ $::in->ask_warn(N('Error'), N('Please provide an LDAP suffix.'));
+ return 1;
+ }
+ if (! ($o->{var}{wiz_ldap_admin_dn})) {
+ $::in->ask_warn(N('Error'), N('Please enter an LDAP administrator.'));
+ return 1;
+ }
+ if (! ($o->{var}{wiz_ldap_root_pw})) {
+ $::in->ask_warn(N('Error'), N('Please enter an LDAP password.'));
+ return 1;
+ }
+ if ($o->{var}{wiz_ldap_root_pw} ne $o->{var}{wiz_ldap_root_pw_2}) {
+ $::in->ask_warn(N('Error'), N('Pasword dont match.'));
+ return 1;
+ }
},
+ next => 'ask_workgroup',
+ },
ask_workgroup => {
name => N('Workgroup') . "\n\n" . N('Samba needs to know the Windows Workgroup it will serve.'),
pre => sub {
@@ -199,7 +276,7 @@ $o->{pages} = {
$o->{var}{wiz_netbios} ||= $samba->{global}{netbios};
},
data => [
- { label => N('Workgroup:'), val => \$o->{var}{wiz_workgroup} },
+ { label => N('Workgroup:'), val => \$o->{var}{wiz_workgroup} },
],
complete => sub {
if (!$o->{var}{wiz_workgroup}) {
@@ -215,7 +292,7 @@ $o->{pages} = {
$o->{var}{wiz_banner} ||= $samba->{global}{'server string'}
},
data => [
- { label => N('Banner:'), val => \$o->{var}{wiz_banner} },
+ { label => N('Banner:'), val => \$o->{var}{wiz_banner}, help => "Samba Server %v" },
],
complete => sub {
if (!$o->{var}{wiz_banner}) {
@@ -233,8 +310,8 @@ $o->{pages} = {
$o->{var}{wiz_max_log_size} ||= $samba->{global}{'max log size'};
},
data => [
- { label => N('Log file:'), val => \$o->{var}{wiz_log_file} },
- { label => N('Max log size:'), val => \$o->{var}{wiz_max_log_size} },
+ { label => N('Log file:'), val => \$o->{var}{wiz_log_file}, help => "/var/log/samba/log.%m" },
+ { label => N('Max log size:'), val => \$o->{var}{wiz_max_log_size}, help => "50" },
{ label => N('Log level:'), val => \$o->{var}{wiz_log_level}, fixed_list => \@loglevel },
],
next => 'ask_services',
@@ -258,9 +335,8 @@ $o->{pages} = {
},
post => \&check,
data => [
- { label => N('Allow hosts:'), val => \$o->{var}{wiz_allow_host} },
- { label => N('Deny hosts:'), val => \$o->{var}{wiz_deny_host} },
- ],
+ { label => N('Allow hosts:'), val => \$o->{var}{wiz_allow_host}, help => "150.203. EXCEPT 150.203.6.66" },
+ { label => N('Deny hosts:'), val => \$o->{var}{wiz_deny_host}, help => "guibux, 10.0.1.253" }, ],
next => 'ask_services',
},
ask_services => {
@@ -290,7 +366,11 @@ $o->{pages} = {
name => N('Shared directory:') . "\n\n" . N('Type the path of the directory you want being shared.'),
pre => sub {
$o->{var}{wiz_dir} ||= $samba->{public}{path};
- $o->{var}{wiz_share_comment} ||= $samba->{public}{comment};
+ if ($samba->{public}{comment}) {
+ $o->{var}{wiz_share_comment} ||= $samba->{public}{comment}
+ } else {
+ $o->{var}{wiz_share_comment} = "Public Share";
+ }
$o->{var}{wiz_share_browseable} ||= $samba->{public}{browseable};
$o->{var}{wiz_share_writable} ||= $samba->{public}{writable};
},
@@ -301,16 +381,20 @@ $o->{pages} = {
{ label => N('Writable:'), val => \$o->{var}{wiz_share_writable}, fixed_list => \@yesorno },
{ text => N("Create shared directory if it doesn't exist"), type => 'bool', val => \$o->{var}{create_missing_directory} },
],
- post => sub {
- if (! -d $o->{var}{wiz_dir} and $o->{var}{create_missing_directory}) {
- wiz_mkdir_p($o->{var}{wiz_dir}) or $::in->ask_warn(N("Error"), N("Failed to create directory."));
- return 1;
- } else { return 0 }
+ complete => sub {
+ if(!$o->{var}{wiz_dir}) {
+ $::in->ask_warn(N("Error"), N("Please enter directory path."));
+ } else {
+ if (! -d $o->{var}{wiz_dir} and $o->{var}{create_missing_directory}) {
+ wiz_mkdir_p($o->{var}{wiz_dir}) or $::in->ask_warn(N("Error"), N("Failed to create directory."));
+ return 1;
+ }
+ }
},
next => 'ask_access'
},
ask_access => {
- name => N('File permissions') . "\n\n" . N('Type users or group separated by a comma (groups must be preceded by a \'@\') like this :') . "\n". N('root, fred, @users, @wheel for each kind of permission.') . "\n",
+ name => N('File permissions') . "\n\n" . N('Type users or group separated by a comma (groups must be preceded by a \'@\') like this :') . "\n". N('root, fred, @users, @wheel for each kind of permission.') . "\n" . N('You need to use filesystem with ACL support, like XFS or ext3 mounted with ACL options, or you file permissions won\'t work.'),
pre => sub {
$o->{var}{wiz_read_list} ||= $samba->{public}{'read list'};
$o->{var}{wiz_write_list} ||= $samba->{public}{'write list'};
@@ -343,10 +427,18 @@ $o->{pages} = {
ask_printers_options => {
name => N('Now you can configure your printers service. Change value only if you know what your are doing.'),
pre => sub {
- $o->{var}{wiz_printers_comment} ||= $samba->{printers}{comment};
+ if ($samba->{printers}{comment}) {
+ $o->{var}{wiz_printers_comment} ||= $samba->{printers}{comment}
+ } else {
+ $o->{var}{wiz_printers_comment} = "All Printers";
+ }
$o->{var}{wiz_printers_browseable} ||= $samba->{printers}{browseable};
$o->{var}{wiz_printers_guestok} ||= $samba->{printers}{'guest ok'};
- $o->{var}{wiz_printers_createmode} ||= $samba->{printers}{'create mode'};
+ if ($samba->{printers}{'create mode'}) {
+ $o->{var}{wiz_printers_createmode} ||= $samba->{printers}{'create mode'}
+ } else {
+ $o->{var}{wiz_printers_createmode} = "0700";
+ }
},
post => sub {
if ($o->{var}{wiz_do_homes} == 1) {
@@ -364,10 +456,18 @@ $o->{pages} = {
ask_homes => {
name => N('Users home options') . "\n" . N('You have selected to allow user access their home directories via samba but you/they must use smbpasswd to set a password.') . "\n" . N('Comment: description of users home directory') . "\n" . N('Browseable: view share') . "\n" . N('Writable: user can write in their home') . "\n" . N('Create mode: man chmod for more info'),
pre => sub {
- $o->{var}{wiz_home_comment} ||= $samba->{homes}{comment};
+ if ($samba->{homes}{comment}) {
+ $o->{var}{wiz_home_comment} ||= $samba->{homes}{comment};
+ } else {
+ $o->{var}{wiz_home_comment} = "Home Directories";
+ }
$o->{var}{wiz_home_browseable} ||= $samba->{homes}{browseable};
$o->{var}{wiz_home_writable} ||= $samba->{homes}{writable};
- $o->{var}{wiz_home_createmode} ||= $samba->{homes}{'create mode'};
+ if ($samba->{homes}{'create mode'}) {
+ $o->{var}{wiz_home_createmode} ||= $samba->{homes}{'create mode'};
+ } else {
+ $o->{var}{wiz_home_createmode} = "0755";
+ }
},
data => [
{ label => N('Comment:'), val => \$o->{var}{wiz_home_comment} },
@@ -397,6 +497,9 @@ $o->{pages} = {
},
end => {
name => N('Congratulations') . "\n\n" . N('The wizard successfully configured your Samba server.'),
+ post => sub {
+ store_samba_type($o->{var}{wiz_type});
+ },
end => 1,
next => 0
},
@@ -433,7 +536,7 @@ sub wiz_mkdir_p {
1;
}
-sub check {
+sub check() {
$> and return 1;
$wiz->{net}->is_dhcp() and return 2;
0;
@@ -451,9 +554,8 @@ sub remove_printer {
delete $samba->{$printer};
}
-sub list_printers {
+sub list_printers() {
my @list if 0;
-
return @list if @list;
@list = sort grep /^(?!\#).+/, map {
my ($printer) = split(':', $_);
@@ -463,7 +565,7 @@ sub list_printers {
} else { () }
}
-sub list_share {
+sub list_share() {
my @listshare;
foreach my $clef (keys %$samba) {
if ($samba->{$clef}{printable} =~ /yes/i) {
@@ -476,7 +578,7 @@ sub list_share {
}
}
-sub printer_sharing {
+sub printer_sharing() {
# create default sedction for printers with default value
$samba->{printers};
$samba->{printers}{comment} = $o->{var}{wiz_printers_comment};
@@ -499,7 +601,7 @@ sub printer_sharing {
}
}
-sub global_special_options {
+sub global_special_options() {
$o->{var}{wiz_domain_master} and $samba->{global}{'domain master'} = $o->{var}{wiz_domain_master};
$o->{var}{wiz_security} and $samba->{global}{security} = $o->{var}{wiz_security};
$o->{var}{wiz_domain_logons} and $samba->{global}{'domain logons'} = $o->{var}{wiz_domain_logons};
@@ -507,9 +609,15 @@ sub global_special_options {
$o->{var}{wiz_wins_support} and $samba->{global}{'wins support'} = $o->{var}{wiz_wins_support};
$o->{var}{wiz_password_server} and $samba->{global}{'password server'} = $o->{var}{wiz_password_server};
$o->{var}{wiz_domain} and $samba->{global}{domain} = $o->{var}{wiz_domain};
+ # ldap options
+ if ($o->{var}{wiz_passdb_backend_yn} == "yes" ) {
+ $samba->{global}{'passdb backend'} = $o->{var}{wiz_passdb_backend};
+ $samba->{global}{'ldap admin_dn'} = $o->{var}{wiz_ldap_admin_dn};
+ $samba->{global}{'ldap suffix'} = $o->{var}{wiz_ldap_suffix};
+ }
}
-sub get_printers {
+sub get_printers() {
if ($o->{var}{wiz_do_printer_sharing}) {
my $string;
$o->{var}{wiz_all_printers} and return "all printers";
@@ -523,6 +631,18 @@ sub get_printers {
}
}
+sub store_samba_type {
+ my ($type) = @_;
+ output($wiz_samba_etc, <<EOF);
+# 1 = BDC - backup domain controller
+# 2 = PDC - primary domain controller
+# 3 = Standalone - standalone server
+# 4 = Member - member of a domain
+EOF
+
+ append_to_file($wiz_samba_etc, "type=$type\n");
+}
+
# remember one variable cannot be commented and not in the same file.
sub do_it {
$::testing and return;
@@ -552,12 +672,8 @@ sub do_it {
# public share
if ($o->{var}{wiz_do_file_sharing}) {
$samba->{public};
- if ($o->{var}{wiz_write_list}) {
- $samba->{public}{'write list'} = $o->{var}{wiz_write_list};
- }
- if ($o->{var}{wiz_read_list}) {
- $samba->{public}{'read list'} = $o->{var}{wiz_read_list};
- }
+ $o->{var}{wiz_write_list} and $samba->{public}{'write list'} = $o->{var}{wiz_write_list};
+ $o->{var}{wiz_read_list} and $samba->{public}{'read list'} = $o->{var}{wiz_read_list};
# enable options if exist
$o->{var}{wiz_share_comment} and $samba->{public}{comment} = $o->{var}{wiz_share_comment};
$o->{var}{wiz_share_browseable} and $samba->{public}{browseable} = $o->{var}{wiz_share_browseable};
@@ -599,7 +715,7 @@ sub do_it {
standalone->explanations("Disabling printer sharing");
if ($o->{var}{wiz_box_list}) {
for(my $i; $i < @{$o->{var}{wiz_box_list}}; $i++) {
- remove_printer($o->{var}{list_printers}[$i]);
+ $o->{var}{list_printers}[$i] and remove_printer($o->{var}{list_printers}[$i]);
}
}
delete $samba->{printers};
@@ -608,6 +724,8 @@ sub do_it {
if (services::is_service_running('smb')) {
services::restart('smb')
} else { services::start('smb') }
+
+ # remove wait message
undef $w;
check_started('smbd');
}