From 8104cf634fe8d5c844bbeb1cc2fb91cbd22ff1c3 Mon Sep 17 00:00:00 2001 From: Jamie Cameron Date: Sun, 3 Mar 2013 22:00:54 -0800 Subject: [PATCH] Option to find master based on workgroup https://sourceforge.net/tracker/?func=detail&atid=117457&aid=3606665&group_id=17457 --- mount/CHANGELOG | 2 ++ mount/config.info | 3 ++- mount/lang/en | 6 ++++-- mount/smb_server.cgi | 47 ++++++++++++++++++++++++++++++++++---------- mount/smb_share.cgi | 21 ++++++++++---------- 5 files changed, 55 insertions(+), 24 deletions(-) diff --git a/mount/CHANGELOG b/mount/CHANGELOG index efaac68a0..b5df954a3 100644 --- a/mount/CHANGELOG +++ b/mount/CHANGELOG @@ -24,3 +24,5 @@ Improved support for filesystems on partitions identified by volume ID when the Show the used disk space for each filesystem on the main page. ---- Changes since 1.580 ---- Updated the UI for Linux and most other operating systems to use Webmin's new UI functions, for a more consistent look. +---- Changes since 1.620 ---- +Added a Module Config option to find the master CIFS server for browsing from a workgroup name. diff --git a/mount/config.info b/mount/config.info index 134343ebf..3141ce618 100644 --- a/mount/config.info +++ b/mount/config.info @@ -1,5 +1,6 @@ line1=Configurable options,11 -browse_server=Server to request browse list from,3,localhost +browse_server=Server to request CIFS browse list from,10,-localhost,*-Workgroup below,Other server +browse_group=CIFS workgroup for browse list,0 long_fstypes=Show long filesystem type names,1,1-Yes,0-No sort_mode=Sort filesystems by,1,2-Mount point,1-Type,0-Order in files show_used=Show used disk space in filesystems list,1,1-Yes,0-No diff --git a/mount/lang/en b/mount/lang/en index da3953f6d..2a951195b 100644 --- a/mount/lang/en +++ b/mount/lang/en @@ -44,7 +44,7 @@ edit_dos_opt=DOS-based filesystems options edit_hpfs_opt=hpfs specific options edit_iso9660_opt=ISO9660 specific options edit_autofs_opt=autofs specific options -edit_smbfs_opt=SMB filesystems options +edit_smbfs_opt=CIFS filesystems options edit_reiserfs_opt=Reiserfs specific options edit_tmpfs_opt=tmpfs specific options edit_xfs_opt=xfs specific options @@ -92,8 +92,10 @@ nfs_seldirv4=For an NFSv4 mount, you should select '/' nfs_dir=Directory nfs_clients=Clients -smb_choose=Choose SMB Server.. +smb_choose=Choose CIFS Server.. smb_elist=Failed to retrieve server list from $1. Maybe the server does not allow browsing +smb_eworkgroup=No workgroup set on the Module Config page +smb_emaster=No browse master was found for workgroup $1 smb_ehost=The server $1 does not exist smb_edown=The server $1 is down, unreachable or is not a file server smb_sel=Select a Windows Networking server to mount from.. diff --git a/mount/smb_server.cgi b/mount/smb_server.cgi index 20cd98e55..dafa83a1b 100755 --- a/mount/smb_server.cgi +++ b/mount/smb_server.cgi @@ -18,7 +18,35 @@ window.close(); EOF # call smbclient -$host = $config{'browse_server'} ? $config{'browse_server'} : "localhost"; +if ($config{'browse_server'} eq "*") { + # Get from workgroup + if ($config{'browse_group'}) { + # Find master for workgroup + $out = &backquote_command( + $config{'nmblookup_path'}." -N ". + $config{'browse_group'}." 2>&1 ",&text('smb_emaster', $config{'browse_group'}),"\n"; + exit; + } + } + else { + # No idea what to do + print "",&text('smb_eworkgroup'),"\n"; + exit; + } + } +elsif ($config{'browse_server'}) { + # Fixed host + $host = $config{'browse_server'}; + } +else { + # Poll local samba + $host = "localhost"; + } &execute_command("$config{'smbclient_path'} -d 0 -L $host -N", undef, \$out, \$out); if ($?) { @@ -45,17 +73,16 @@ if ($out =~ /Server\s+Comment\n.*\n((.+\n)+)/) { } if (@names) { - print "$text{'smb_sel'}
\n"; - print "\n"; - print " ", - "\n"; + print "$text{'smb_sel'}

\n"; + print &ui_columns_start([ $text{'smb_name'}, $text{'smb_desc'} ]); for($i=0; $i<@names; $i++) { - print "

\n"; - print "\n"; - print "\n"; + print &ui_columns_row([ + "$names[$i]\n", + &html_escape($comms[$i]), + ]); } - print "
$text{'smb_name'}$text{'smb_desc'}
$names[$i]$comms[$i]
\n"; + print &ui_columns_end(); } else { print "$text{'smb_none'}.

\n"; diff --git a/mount/smb_share.cgi b/mount/smb_share.cgi index 1bef8259c..c17b9e0ac 100755 --- a/mount/smb_share.cgi +++ b/mount/smb_share.cgi @@ -39,21 +39,20 @@ if ($out =~ /Sharename\s+Type\s+Comment\n((.+\n)+)/) { } } if (@names) { - print "$text{'smb_sel2'}
\n"; - print "\n"; - print " ", - "\n"; + print "$text{'smb_sel2'}

\n"; + print &ui_columns_start([ $text{'smb_share'}, + $text{'smb_comment'} ]); for($i=0; $i<@names; $i++) { - print "

\n"; - printf "\n", - $comms[$i] =~ /\S/ ? $comms[$i] : "
"; + print &ui_columns_row([ + "$names[$i]", + &html_escape($comms[$i]), + ]); } - print "
$text{'smb_share'}$text{'smb_comment'}
$names[$i]%s
\n"; + print &ui_columns_end(); } else { - print "",&text('smb_noshares', $in{'server'}),"\n"; + print "",&text('smb_noshares', $in{'server'}),"

\n"; } &popup_footer();