Koozali.org formerly Contribs.org

Samba Users simple admin panel

Samba Users simple admin panel
« on: June 20, 2016, 01:22:31 PM »
Just thought I'd share this little gem I made a few years ago, and it works on SME8 and probably SME9 as well (haven't gone there yet).

Basically copy/paste the code below into a file called smbstatus in /etc/e-smith/web/functions
Code: [Select]
#!/usr/bin/perl -U

#----------------------------------------------------------------------
# heading     : Administration
# description : Samba Status
# navigation  : 4000 4200
#----------------------------------------------------------------------

package esmith;

use strict;
use CGI ':all';
use CGI::Carp qw(fatalsToBrowser);

use esmith::cgi;
use esmith::config;
use esmith::util;
use esmith::db;

BEGIN
{
    # Clear PATH and related environment variables so that calls to
    # external programs do not cause results to be tainted. See
    # "perlsec" manual page for details.

    $ENV {'PATH'} = '';
    $ENV {'SHELL'} = '/bin/bash';
    delete $ENV {'ENV'};
}

esmith::util::setRealToEffective ();

$CGI::POST_MAX=1024 * 100;  # max 100K posts
$CGI::DISABLE_UPLOADS = 1;  # no uploads

my $q = new CGI;

my $q = new CGI;
$q->default_dtd('-//W3C//DTD XHTML 1.0 Transitional//EN');
print $q->header ('text/html');
          print $q->start_html (
          -TITLE => "smbstatus",
          -CLASS => "main",
          -STYLE => {
          -verbatim => '@import url("/server-common/css/sme_main.css");',
          src => '/server-common/css/sme_core.css'});

print $q->h1 ("Samba logged on users and file shares");

my @ss = `/usr/bin/smbstatus`;

print ("<font size=\"3\"><pre>");

foreach my $tt (@ss)
{
  print ($tt);
}
print ("</pre>");

esmith::cgi::genFooter ($q);
exit (0);


change the file permission

Code: [Select]
chmod 4750 smbstatus
then change to /etc/e-smith/web/panels/manager/cgi-bin and create a link

Code: [Select]
ln -s  ../../../functions/smbstatus
Then log in to server manager and see the status under Administration->Samba Status.

Shows the current Samba version too which is sometimes handy.


Offline Stefano

  • *
  • 10,779
  • Skype account: maghissimo
    • Smeserver italian community
Re: Samba Users simple admin panel
« Reply #1 on: June 20, 2016, 01:58:52 PM »
thank you

please post it also as a NFR in bugzilla and attach your code, thank you again
Consulente di Smeserver.it -  Soluzioni e supporto su Sme server in Italia

Re: Samba Users simple admin panel
« Reply #2 on: June 20, 2016, 02:17:35 PM »
OKey Dokey

https://bugs.contribs.org/show_bug.cgi?id=9611

Look forward to seeing it one day.

Re: Samba Users simple admin panel
« Reply #3 on: June 20, 2016, 06:42:53 PM »
Running with 'perl -U' is not the preferred way to deal with taint issues. -U means "allow Perl to do unsafe operations." Better is to use pattern matching to validate the output 'smbstatus' before incorporating it in your page.

Offline Stefano

  • *
  • 10,779
  • Skype account: maghissimo
    • Smeserver italian community
Re: Samba Users simple admin panel
« Reply #4 on: June 20, 2016, 07:41:58 PM »
well, you'd post your considerations in bugzilla too ;-)

thank you in advance
Consulente di Smeserver.it -  Soluzioni e supporto su Sme server in Italia