#!/usr/bin/perl # # IPFire CGIs # # This code is distributed under the terms of the GPL # # (c) The IPFire Team # use strict; # enable only the following on debugging purpose use warnings; use CGI::Carp 'fatalsToBrowser'; require '/var/ipfire/general-functions.pl'; require "${General::swroot}/lang.pl"; require "${General::swroot}/header.pl"; my %sambasettings = (); my %checked = (); my %netsettings = (); my %ovpnsettings = (); my $message = ""; my $errormessage = ""; my $shareentry = ""; my @shares = (); my @shareline = (); my @proto = (); my %selected= () ; my $sharefile = "/var/ipfire/samba/shares"; &General::readhash("${General::swroot}/ethernet/settings", \%netsettings); &General::readhash("${General::swroot}/ovpn/settings", \%ovpnsettings); my %servicenames = ( 'SMB Daemon' => 'smbd', 'NetBIOS Nameserver' => 'nmbd', 'Winbind Daemon' => 'winbindd' ); &Header::showhttpheaders(); $sambasettings{'ENABLED'} = 'off'; $sambasettings{'EDIT'} = 'no'; $sambasettings{'VALID'} = 'yes'; $sambasettings{'WORKGRP'} = 'homeip.net'; $sambasettings{'NETBIOSNAME'} = 'IPFIRE'; $sambasettings{'SRVSTRING'} = 'Samba Server %v running on IPFire 2.0'; $sambasettings{'INTERFACES'} = 'eth0'; $sambasettings{'SECURITY'} = 'share'; $sambasettings{'OSLEVEL'} = '20'; $sambasettings{'PDC'} = 'off'; $sambasettings{'GREEN'} = 'on'; $sambasettings{'BLUE'} = 'off'; $sambasettings{'ORANGE'} = 'off'; $sambasettings{'VPN'} = 'off'; $sambasettings{'WINSSERV'} = ''; $sambasettings{'WINS'} = 'off'; ### Values that have to be initialized $sambasettings{'ACTION'} = ''; &General::readhash("${General::swroot}/samba/settings", \%sambasettings); &Header::getcgihash(\%sambasettings); &Header::openpage('Samba', 1, ''); &Header::openbigbox('100%', 'left', '', $errormessage); ############################################################################################################################ ############################################################################################################################ if ($sambasettings{'ACTION'} eq $Lang::tr{'save'}) { &General::writehash("${General::swroot}/samba/settings", \%sambasettings); } &General::readhash("${General::swroot}/samba/settings", \%sambasettings); if ($errormessage) { &Header::openbox('100%', 'left', $Lang::tr{'error messages'}); print "$errormessage\n"; print " \n"; &Header::closebox(); } $checked{'PDC'}{'on'} = ''; $checked{'PDC'}{'off'} = ''; $checked{'PDC'}{"$sambasettings{'PDC'}"} = 'checked'; $checked{'WINS'}{'on'} = ''; $checked{'WINS'}{'off'} = ''; $checked{'WINS'}{"$sambasettings{'WINS'}"} = 'checked'; $checked{'GREEN'}{'on'} = ''; $checked{'GREEN'}{'off'} = ''; $checked{'GREEN'}{"$sambasettings{'GREEN'}"} = 'checked'; $checked{'BLUE'}{'on'} = ''; $checked{'BLUE'}{'off'} = ''; $checked{'BLUE'}{"$sambasettings{'BLUE'}"} = 'checked'; $checked{'ORANGE'}{'on'} = ''; $checked{'ORANGE'}{'off'} = ''; $checked{'ORANGE'}{"$sambasettings{'ORANGE'}"} = 'checked'; $checked{'VPN'}{'on'} = ''; $checked{'VPN'}{'off'} = ''; $checked{'VPN'}{"$sambasettings{'VPN'}"} = 'checked'; $selected{'MAPTOGUEST'}{'Never'} = ''; $selected{'MAPTOGUEST'}{'Bad User'} = ''; $selected{'MAPTOGUEST'}{'Bad Password'} = ''; $selected{'MAPTOGUEST'}{$sambasettings{'MAPTOGUEST'}} = "selected='selected'"; $selected{'SECURITY'}{'share'} = ''; $selected{'SECURITY'}{'user'} = ''; $selected{'SECURITY'}{'server'} = ''; $selected{'SECURITY'}{'domain'} = ''; $selected{'SECURITY'}{$sambasettings{'SECURITY'}} = "selected='selected'"; ############################################################################################################################ ############################################################################################################################ &Header::openbox('100%', 'center', 'Samba'); print < END ; if ( $message ne "" ) { print "$message"; } my $lines = 0; my $key = ''; foreach $key (sort keys %servicenames) { if ($lines % 2) { print "\n"; } else { print "\n"; } print "$key\n"; my $shortname = $servicenames{$key}; my $status = &isrunning($shortname); print "$status\n"; print <
END ; print "\n"; $lines++; } print < Alle Dienste:
Basisoptionen
Workgroup:
NetBIOS-Name:
Server-String:
Interfaces: OpenVpn - $ovpnsettings{'DDEVICE'}
$Lang::tr{'green'} - $netsettings{'GREEN_DEV'} END ; if (&Header::blue_used()){ print < $Lang::tr{'wireless'} - $netsettings{'BLUE_DEV'} END ; } if (&Header::orange_used()){ print < $Lang::tr{'dmz'} - $netsettings{'ORANGE_DEV'} END ; } print <
Sicherheitsoptionen
Security:
Browsingoptionen
OS Level:
Primary Domain Controller:on / off
WINS-Optionen
WINS-Server:
WINS-Support:on / off
END ; &Header::closebox(); &Header::openbox('100%', 'center', 'Shares'); print <
Name der FreigabePfadOptionen END ; open( FILE, "< $sharefile" ) or die "Unable to read $sharefile"; @shares = ; close FILE; foreach $shareentry (sort @shares) { @shareline = split( /\;/, $shareentry ); print <$shareline[0] $shareline[2] END ; if ($shareline[1] eq 'enabled') { print <
END ; } elsif ($shareline[1] eq 'disabled') { print <
END ; } print <
END ; } print <
Legende:   Freigabe bearbeiten |  Freigabe loeschen  
END ; &Header::closebox(); if ($sambasettings{'SECURITY'} eq 'user') { &Header::openbox('100%', 'center', 'User'); print <
Benutzerverwaltung
END ; &Header::closebox(); } &Header::closebigbox(); &Header::closepage(); ############################################################################################################################ ############################################################################################################################ sub isrunning { my $cmd = $_[0]; my $status = "$Lang::tr{'stopped'}"; my $pid = ''; my $testcmd = ''; my $exename; $cmd =~ /(^[a-z]+)/; $exename = $1; if (open(FILE, "/var/run/${cmd}.pid")) { $pid = ; chomp $pid; close FILE; if (open(FILE, "/proc/${pid}/status")) { while () { if (/^Name:\W+(.*)/) { $testcmd = $1; } } close FILE; if ($testcmd =~ /$exename/) { $status = "$Lang::tr{'running'}"; } } } return $status; }