3 # Display a list of available samba shares. Special shares (like [homes] and
4 # [printers]) are included as well.
6 require './samba-lib.pl';
8 # Check for Samba executable
9 if (!-x $config{'samba_server'}) {
10 &ui_print_header(undef, $text{'index_title'}, "", undef, 1, 1, 0,
11 &help_search_link("samba", "man", "doc", "google"));
12 print &text('error_nosamba', $config{'samba_server'}, "$gconfig{'webprefix'}/config.cgi?$module_name"),"<p>\n";
14 &foreign_require("software", "software-lib.pl");
15 $lnk = &software::missing_install_link("samba", $text{'index_samba'},
16 "../$module_name/", $text{'index_title'});
17 print $lnk,"<p>\n" if ($lnk);
19 &ui_print_footer("/", $text{'index'});
23 # Check the samba version
24 if ($samba_version = &get_samba_version(\$out, 0)) {
26 &open_tempfile(VERSION, ">$module_config_directory/version");
27 &print_tempfile(VERSION, $samba_version,"\n");
28 &close_tempfile(VERSION);
31 &ui_print_header(undef, $text{'index_title'}, "", undef, 1, 1, 0,
32 &help_search_link("samba", "man", "doc", "google"));
33 print &text('error_version', $config{'samba_server'},
34 "$gconfig{'webprefix'}/config.cgi?$module_name"),"<p>\n";
35 print "<pre>$out</pre>\n";
36 &ui_print_footer("/", $text{'index'});
39 &ui_print_header(undef, $text{'index_title'}, "", undef, 1, 1, 0,
40 &help_search_link("samba", "man", "doc", "google"), undef, undef,
41 &text('index_version', &get_samba_version(\$out, 1)));
43 @empty = &list_shares();
44 if (!@empty && (-r $config{alt_smb_conf})) {
45 # Copy the sample smb.conf file to the real location
46 # This is a hack for slackware
47 system("cp $config{alt_smb_conf} $config{smb_conf} >/dev/null 2>&1");
49 if (!(-r $config{smb_conf})) {
50 print &text('error_config', $config{'smb_conf'}, "$gconfig{'webprefix'}/config.cgi?$module_name");
52 &ui_print_footer("/", $text{'index'});
56 # Check for 'config' or 'include' directives
58 if (&getval("config") || &getval("include")) {
59 print &text('index_einclude',
60 "<tt>$config{'smb_conf'}</tt>",
61 "<tt>config</tt>", "<tt>include</tt>"),"<p>\n";
64 # Work out links for adding things
66 push(@links, "<a href=edit_fshare.cgi>$text{'index_createfileshare'}</a>")
68 push(@links, "<a href=edit_pshare.cgi>$text{'index_createprnshare'}</a>")
70 push(@links, "<a href=create_copy.cgi>$text{'index_createcopy'}</a>")
72 push(@links, "<a href=view_users.cgi>$text{'index_view'}</a>")
73 if ($access{'view_all_con'});
75 foreach $s (&list_shares()) {
76 next unless &can('r', \%access, $s) || !$access{'hide'};
77 $us = "share=".&urlize($s);
78 if ($s eq "global") { next; }
82 print &ui_form_start("delete_shares.cgi", "post");
83 unshift(@links, &select_all_link("d"),
84 &select_invert_link("d"));
85 print &ui_links_row(\@links);
86 print &ui_columns_start([
88 $text{'index_sharename'},
90 $text{'index_security'} ], 100, 0, \@tds);
97 if ($cp = &getval("copy")) { $cp = "(copy of <i>$cp</i>)"; }
98 if (&istrue("printable")) {
99 push(@cols, "<a href=\"edit_pshare.cgi?$us\">".
100 &html_escape($s)."</a> $cp");
103 push(@cols, "<a href=\"edit_fshare.cgi?$us\">".
104 &html_escape($s)."</a> $cp");
107 # Output location / path info
109 $p = "<i>$text{'index_homedir'}</i>";
111 elsif ($s eq "printers") {
112 $p = "<i>$text{'index_allprinter'}</i>";
114 elsif (&istrue("printable")) {
115 $p = &getval("printer") ? $text{'index_printer'}." ".&html_escape(&getval("printer")) : $text{'index_defaultprn'};
118 $p = &html_escape(&getval("path"));
122 # Output security information
123 if (&istrue("printable")) {
124 if (&getval("valid users")) {
125 # Only accessible to some users..
126 $sc = $text{'index_printableto'}." ".
127 &user_list(&getval("valid users"));
129 elsif (&istrue("public")) {
130 # Accessible to everyone
131 $sc = $text{'index_prneveryone'};
134 $sc = $text{'index_prnalluser'};
137 elsif (&istrue("writable")) {
138 # Default is read/write access
139 if (&istrue("public")) {
140 # No password needed..
141 $sc = $text{'index_rwpublic'};
145 if (&getval("read list")) {
146 $sc = &text('index_readonly', &user_list(&getval("read list")));
149 $sc = $text{'index_rwalluser'};
154 # Default is read-only access
155 if (&istrue("public")) {
156 # No password needed..
157 $sc = $text{'index_roeveryone'};
161 if (&getval("write list")) {
162 $sc = &text('index_readwrite', &user_list(&getval("write list")));
165 $sc = $text{'index_roalluser'};
170 print &ui_checked_columns_row(\@cols, \@tds, "d", $s);
173 print &ui_columns_end();
176 print "<b>$text{'index_noshares'}</b>. <p>\n";
178 print &ui_links_row(\@links);
180 print &ui_form_end([ [ "delete", $text{'index_delete'} ] ]);
183 @gc_acl = qw(conf_net conf_smb conf_pass conf_print conf_misc conf_bind
184 ACLfs_global ACLps_global manual swat winbind);
185 @gc_progs = ("conf_net.cgi", "conf_smb.cgi", "conf_pass.cgi",
186 "conf_print.cgi", "conf_misc.cgi", "conf_bind.cgi",
187 "edit_fshare.cgi?share=global", "edit_pshare.cgi?share=global",
189 @gc_names = ($text{'global_unixnetwork'}, $text{'global_winnetwork'},
190 $text{'global_auth'}, $text{'global_printing'},
191 $text{'global_misc'}, $text{'global_bind'},
192 $text{'global_filedefault'},
193 $text{'global_prndefault'},
194 $text{'manual_title'});
195 @gc_icons = ("images/icon_0.gif", "images/icon_1.gif", "images/icon_2.gif",
196 "images/icon_3.gif", "images/icon_4.gif",
197 "images/icon_10.gif", "images/icon_5.gif", "images/icon_6.gif",
198 "images/manual.gif");
199 if (&has_command($config{'swat_path'})) {
200 push(@gc_progs, "swat.cgi");
201 push(@gc_names, "SWAT");
202 push(@gc_icons, "images/icon_9.gif");
205 foreach $i (0..$#gc_acl) {
206 next unless ($access{$gc_acl[$i]} && $gc_progs[$i]);
207 next if ($gc_acl[$i] eq "conf_winbind" && $samba_version < 3);
208 push(@gc_progs1, $gc_progs[$i]);
209 push(@gc_names1, $gc_names[$i]);
210 push(@gc_icons1, $gc_icons[$i]);
216 print &ui_subheading($text{'global_title'});
217 &icons_table(\@gc_progs1, \@gc_names1, \@gc_icons1, 4);
220 # Generate table of accessible user and group editing icons
221 if ($access{'view_users'}) {
222 push(@utitles, $text{'global_edit'});
223 push(@ulinks, "edit_epass.cgi");
224 push(@uicons, "images/editepass.gif");
226 if ($access{'maint_makepass'}) {
227 push(@utitles, $text{'global_convert'});
228 push(@ulinks, "ask_epass.cgi");
229 push(@uicons, "images/askepass.gif");
231 if ($access{'maint_sync'}) {
232 push(@utitles, $text{'global_sync'});
233 push(@ulinks, "edit_sync.cgi");
234 push(@uicons, "images/editsync.gif");
236 if ($samba_version >= 3) {
237 if ($access{'maint_groups'}) {
238 push(@utitles, $text{'global_gedit'});
239 push(@ulinks, "list_groups.cgi");
240 push(@uicons, "images/listgroups.gif");
242 if ($access{'maint_gsync'}) {
243 push(@utitles, $text{'global_gsync'});
244 push(@ulinks, "edit_gsync.cgi");
245 push(@uicons, "images/editgsync.gif");
247 if ($access{'winbind'} && $has_net) {
248 push(@utitles, $text{'global_winbind'});
249 push(@ulinks, "edit_winbind.cgi");
250 push(@uicons, "images/winbind.gif");
255 # We have some icons to show
257 print &ui_subheading($text{'global_users'});
258 &icons_table(\@ulinks, \@utitles, \@uicons, 3);
261 if ($access{'apply'}) {
262 $isrun = &is_samba_running();
264 print &ui_buttons_start();
267 print &ui_buttons_row("start.cgi", $text{'index_start'},
268 $text{'index_startmsg'});
270 elsif ($isrun == 1) {
271 # Restart / stop buttons
272 print &ui_buttons_row("restart.cgi", $text{'index_restart'},
273 $text{'index_restartmsg'}."\n".
274 $text{'index_restartmsg2'});
275 print &ui_buttons_row("stop.cgi", $text{'index_stop'},
276 $text{'index_stopmsg'});
278 print &ui_buttons_end();
279 if (&has_command("winbindd")) {
280 $isrun2 = &is_winbind_running();
282 print &ui_buttons_start();
285 print &ui_buttons_row("start_wb.cgi", $text{'index_start_wb'},
286 $text{'index_startmsg_wb'});
288 elsif ($isrun2 == 1) {
289 # Restart / stop buttons
290 print &ui_buttons_row("restart_wb.cgi", $text{'index_restart_wb'},
291 $text{'index_restartmsg_wb'});
292 print &ui_buttons_row("stop_wb.cgi", $text{'index_stop_wb'},
293 $text{'index_stopmsg_wb'});
296 print &ui_buttons_end();
299 &ui_print_footer("/", $text{'index'});