summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--perl-install/fs.pm11
-rw-r--r--perl-install/network/smb.pm57
2 files changed, 64 insertions, 4 deletions
diff --git a/perl-install/fs.pm b/perl-install/fs.pm
index 8e5c61b69..fddeb59c4 100644
--- a/perl-install/fs.pm
+++ b/perl-install/fs.pm
@@ -35,7 +35,7 @@ sub get_raw_hds {
];
my @fstab = read_fstab("$prefix/etc/fstab");
$all_hds->{nfss} = [ grep { isNfs($_) } @fstab ];
- $all_hds->{smbs} = [ grep { isThisFs('smb', $_) } @fstab ];
+ $all_hds->{smbs} = [ grep { isThisFs('smbfs', $_) } @fstab ];
}
sub read_fstab {
@@ -98,6 +98,7 @@ sub mount_options_unpack {
iso9660 => [ qw(unhide) ],
vfat => [ qw(umask=0) ],
nfs => [ qw(rsize=8192 wsize=8192) ],
+ smbfs => [ qw(username= password=) ],
);
while (my ($fs, $l) = each %per_fs) {
isThisFs($fs, $part) || $part->{type} eq 'auto' && member($fs, @auto_fs) or next;
@@ -108,7 +109,7 @@ sub mount_options_unpack {
$non_defaults->{supermount} = 1 if member(type2fs($part), 'auto', @auto_fs);
my $defaults = { reverse %$non_defaults };
- my %options = map { $_ => 0 } keys %$non_defaults;
+ my %options = map { $_ => '' } keys %$non_defaults;
my @unknown;
foreach (split(",", $packed_options)) {
if ($_ eq 'user') {
@@ -119,6 +120,8 @@ sub mount_options_unpack {
$options{$_} = 1;
} elsif ($defaults->{$_}) {
$options{$defaults->{$_}} = 0;
+ } elsif (/(.*?=)(.*)/) {
+ $options{$1} = $2;
} else {
push @unknown, $_;
}
@@ -155,7 +158,7 @@ sub mount_options_pack {
}
}
}
- push @l, grep { $options->{$_} } keys %$options;
+ push @l, map_each { if_($::b, $::a =~ /=$/ ? "$::a$::b" : $::a) } %$options;
push @l, $unknown;
$part->{options} = join(",", grep { $_ } @l);
@@ -163,7 +166,7 @@ sub mount_options_pack {
sub mount_options_help {
my %help = map { $_ => '' } @_;
- my %short = map { /(.*?)=/ ? ("$1=" => $_) : () } keys %help;
+ my %short = map { if_(/(.*?)=/, "$1=" => $_) } keys %help;
foreach (split(':', $ENV{LANGUAGE}), '') {
my $manpage = "/usr/share/man/$_/man8/mount.8.bz2";
diff --git a/perl-install/network/smb.pm b/perl-install/network/smb.pm
new file mode 100644
index 000000000..d5c128b41
--- /dev/null
+++ b/perl-install/network/smb.pm
@@ -0,0 +1,57 @@
+package network::smb;
+
+use common;
+use network::network;
+
+sub check {
+ my ($in) = @_;
+ my $f = '/usr/bin/nmblookup';
+ -e $f or $in->do_pkgs->install('samba-client');
+ -e $f or $in->ask_warn('', "Mandatory package samba-client is missing"), return;
+ 1;
+}
+
+
+sub find_servers() {
+ my (undef, @l) = `nmblookup "*"`;
+ s/\s.*\n// foreach @l;
+ my @servers = grep { network::network::is_ip($_) } @l;
+ my %servers;
+ $servers{$_}{ip} = $_ foreach @servers;
+ my ($ip);
+ foreach (`nmblookup -A @servers`) {
+ if (my $nb = /^Looking up status of (\S+)/ .. /^$/) {
+ if ($nb == 1) {
+ $ip = $1;
+ } else {
+ /<00>/ or next;
+ $servers{$ip}{/<GROUP>/ ? 'group' : 'name'} ||= lc first(/(\S+)/);
+ }
+ }
+ }
+ values %servers;
+}
+
+sub find_exports {
+ my ($server) = @_;
+ my @l;
+ my $name = $server->{name} ? " -L $server->{name}" : '';
+ my $group = $server->{group} ? " -W $server->{group}" : '';
+
+ # WARNING: using smbclient -L is ugly. It can't handle more than 15
+ # characters shared names
+
+ foreach (`smbclient -U% -L -I $server->{ip}$name$group`) {
+ chomp;
+ s/^\t//;
+ my ($name, $type, $comment) = unpack "A15 A10 A*", $_;
+ if ($name eq '---------' && $type eq '----' && $comment eq '-------' .. /^$/) {
+ push @l, { name => $name, type => $type, comment => $comment }
+ if $type eq 'Disk' && $name ne 'ADMIN$';
+ }
+ }
+ @l;
+}
+
+1;
+