From 889329363f2d2adad0292008b2d223352d4bfe2a Mon Sep 17 00:00:00 2001 From: maniacikarus Date: Fri, 13 Apr 2007 19:57:32 +0000 Subject: [PATCH] Wie immer Samba und Tripwirek> git-svn-id: http://svn.ipfire.org/svn/ipfire/trunk@499 ea5c0bd1-69bd-2848-81d8-4f18e57aeed8 --- doc/language_issues.de | 3 + doc/language_issues.en | 3 + html/cgi-bin/samba.cgi | 21 ++- html/cgi-bin/tripwire.cgi | 120 +++++++++--- langs/de/cgi-bin/de.pl | 8 +- langs/en/cgi-bin/en.pl | 8 +- src/misc-progs/sambactrl.c | 335 ++++++++++++++++++---------------- src/misc-progs/tripwirectrl.c | 68 +++++-- 8 files changed, 358 insertions(+), 208 deletions(-) diff --git a/doc/language_issues.de b/doc/language_issues.de index 4d198dd37c..1e8cd91e76 100644 --- a/doc/language_issues.de +++ b/doc/language_issues.de @@ -273,6 +273,7 @@ WARNING: translation string unused: too long 80 char max WARNING: translation string unused: traffic on WARNING: translation string unused: transfer limits WARNING: translation string unused: transparent on +WARNING: translation string unused: tripwire cronjob WARNING: translation string unused: umount WARNING: translation string unused: umount removable media before to unplug WARNING: translation string unused: unencrypted @@ -304,6 +305,7 @@ WARNING: translation string unused: written sectors WARNING: translation string unused: xtaccess bad transfert WARNING: translation string unused: year WARNING: untranslated string: IPFires hostname +WARNING: untranslated string: add cronjob WARNING: untranslated string: allmsg WARNING: untranslated string: alt proxy WARNING: untranslated string: dial profile @@ -334,6 +336,7 @@ WARNING: untranslated string: trafficred WARNING: untranslated string: traffics WARNING: untranslated string: trafficsum WARNING: untranslated string: trafficto +WARNING: untranslated string: tripwire cronjobs WARNING: untranslated string: up WARNING: untranslated string: urlfilter background image WARNING: untranslated string: urlfilter log diff --git a/doc/language_issues.en b/doc/language_issues.en index 9fab328795..f8b34ecff6 100644 --- a/doc/language_issues.en +++ b/doc/language_issues.en @@ -279,6 +279,7 @@ WARNING: translation string unused: to install an update WARNING: translation string unused: traffic on WARNING: translation string unused: transfer limits WARNING: translation string unused: transparent on +WARNING: translation string unused: tripwire cronjob WARNING: translation string unused: unencrypted WARNING: translation string unused: update transcript WARNING: translation string unused: updates @@ -308,6 +309,7 @@ WARNING: translation string unused: written sectors WARNING: translation string unused: year WARNING: translation string unused: yearly firewallhits WARNING: untranslated string: IPFires hostname +WARNING: untranslated string: add cronjob WARNING: untranslated string: alt proxy WARNING: untranslated string: down WARNING: untranslated string: firewall logs ip @@ -322,6 +324,7 @@ WARNING: untranslated string: red WARNING: untranslated string: remove x509 WARNING: untranslated string: settingsc WARNING: untranslated string: smbrestart +WARNING: untranslated string: tripwire cronjobs WARNING: untranslated string: up WARNING: untranslated string: urlfilter background image WARNING: untranslated string: urlfilter log diff --git a/html/cgi-bin/samba.cgi b/html/cgi-bin/samba.cgi index 089cd3852c..b49c0bc990 100644 --- a/html/cgi-bin/samba.cgi +++ b/html/cgi-bin/samba.cgi @@ -85,6 +85,7 @@ $sambasettings{'OTHERINTERFACES'} = '127.0.0.1'; $sambasettings{'GUESTACCOUNT'} = 'samba'; $sambasettings{'MAPTOGUEST'} = 'Never'; $sambasettings{'LOGLEVEL'} = '3 passdb:5 auth:5 winbind:2'; +$sambasettings{'SOCKETOPTIONS'} = 'TCP_NODELAY SO_RCVBUF=8192 SO_SNDBUF=8192 SO_KEEPALIVE'; ### Values that have to be initialized $sambasettings{'ACTION'} = ''; my $LOGLINES = '50'; @@ -143,6 +144,7 @@ if ($sambasettings{'ACTION'} eq 'globalresetyes') $sambasettings{'LOCALMASTER'} = 'off'; $sambasettings{'DOMAINMASTER'} = 'off'; $sambasettings{'PREFERREDMASTER'} = 'off'; + $sambasettings{'SOCKETOPTIONS'} = 'TCP_NODELAY SO_RCVBUF=8192 SO_SNDBUF=8192 SO_KEEPALIVE'; $PDCOPTIONS = `cat ${General::swroot}/samba/pdc`; system("/usr/local/bin/sambactrl smbreload"); } @@ -423,7 +425,7 @@ null passwords = yes bind interfaces only = true interfaces = $sambasettings{'INTERFACES'} -socket options = TCP_NODELAY SO_RCVBUF=8192 SO_SNDBUF=8192 SO_KEEPALIVE +socket options = $sambasettings{'SOCKETOPTIONS'} remote announce = $sambasettings{'REMOTEANNOUNCE'} username level = 1 @@ -601,6 +603,7 @@ print <
$Lang::tr{'network options'} $Lang::tr{'os level'} +$Lang::tr{'socket options'} $Lang::tr{'remote announce'} END ; @@ -960,8 +963,11 @@ print < -
- + + + +
+ END ; @@ -990,10 +996,9 @@ if ($sambasettings{'ACTION'} eq 'shareadd' || $sambasettings{'ACTION'} eq 'optio - +
$Lang::tr{'add share'}
$Lang::tr{'show share options'}
- - -
$Lang::tr{'show share options'} + +

@@ -1046,8 +1051,6 @@ END ; } - - &Header::closebox(); ############################################################################################################################ diff --git a/html/cgi-bin/tripwire.cgi b/html/cgi-bin/tripwire.cgi index aa87806f3c..3b009211a7 100755 --- a/html/cgi-bin/tripwire.cgi +++ b/html/cgi-bin/tripwire.cgi @@ -22,6 +22,7 @@ my $message = ""; my $errormessage = ""; my @Logs = qx(ls -r /var/ipfire/tripwire/report/); my $file = `ls -tr /var/ipfire/tripwire/report/ | tail -1`; +my @cronjobs = `ls /etc/fcron.daily/tripwire*`; my $Log =$Lang::tr{'no log selected'}; ############################################################################################################################ @@ -54,8 +55,9 @@ $tripwiresettings{'ACTION'} = ''; ######################################################### Tripwire HTML Part ############################################### &Header::showhttpheaders(); + &Header::getcgihash(\%tripwiresettings); -&Header::openpage('Tripwire', 1, ''); +&Header::openpage('Tripwire', 1,); &Header::openbigbox('100%', 'left', '', $errormessage); ############################################################################################################################ @@ -63,7 +65,7 @@ $tripwiresettings{'ACTION'} = ''; if ($tripwiresettings{'ACTION'} eq $Lang::tr{'save'}) { -system("/usr/local/bin/tripwirectrl readconfig"); +system("/usr/local/bin/tripwirectrl readconfig >& /dev/null"); open (FILE, ">${General::swroot}/tripwire/twcfg.txt") or die "Can't save tripwire config: $!"; flock (FILE, 2); @@ -92,12 +94,32 @@ END close FILE; &General::writehash("${General::swroot}/tripwire/settings", \%tripwiresettings); -system("/usr/local/bin/tripwirectrl lockconfig"); +system("/usr/local/bin/tripwirectrl lockconfig >& /dev/null"); } ############################################################################################################################ ################################################## Sicherheitsabfrage für CGI ############################################## +if ($tripwiresettings{'ACTION'} eq 'addcron') + { + print < + + + + + +
$Lang::tr{'add cron'} + +
HHMM

+ $Lang::tr{'ok'} +
+ $Lang::tr{'cancel'} +
+END +; +} + if ($tripwiresettings{'ACTION'} eq 'globalreset') { print <$Lang::tr{'resetglobals'} $Lang::tr{'defaultwarning'}

- $Lang::tr{'yes'} + $Lang::tr{'ok'}
- $Lang::tr{'no'} + $Lang::tr{'cancel'}
@@ -125,12 +147,12 @@ if ($tripwiresettings{'ACTION'} eq 'generatepolicypw') $Lang::tr{'generatepolicy'} $Lang::tr{'tripwirewarningpolicy'}

$Lang::tr{'sitekey'} - $Lang::tr{'localkey'} + $Lang::tr{'localkey'}

- $Lang::tr{'yes'} + $Lang::tr{'ok'}
- $Lang::tr{'no'} + $Lang::tr{'cancel'}
@@ -146,12 +168,12 @@ if ($tripwiresettings{'ACTION'} eq 'policyresetpw') $Lang::tr{'resetpolicy'} $Lang::tr{'tripwirewarningpolicy'}

$Lang::tr{'sitekey'} - $Lang::tr{'localkey'} + $Lang::tr{'localkey'}

- $Lang::tr{'yes'} + $Lang::tr{'ok'}
- $Lang::tr{'no'} + $Lang::tr{'cancel'}
@@ -166,12 +188,12 @@ if ($tripwiresettings{'ACTION'} eq 'updatedatabasepw') - +
$Lang::tr{'updatedatabase'}
$Lang::tr{'tripwirewarningdatabase'}

$Lang::tr{'localkey'}
$Lang::tr{'localkey'}

- $Lang::tr{'yes'} + $Lang::tr{'ok'}
- $Lang::tr{'no'} + $Lang::tr{'cancel'}
@@ -186,10 +208,10 @@ if ($tripwiresettings{'ACTION'} eq 'keyreset') $Lang::tr{'keyreset'} $Lang::tr{'tripwirewarningkeys'}

- $Lang::tr{'yes'} + $Lang::tr{'ok'}
- $Lang::tr{'no'} + $Lang::tr{'cancel'}
@@ -205,10 +227,10 @@ if ($tripwiresettings{'ACTION'} eq 'generatekeys') $Lang::tr{'generatekeys'} $Lang::tr{'tripwirewarningkeys'}

- $Lang::tr{'yes'} + $Lang::tr{'ok'}
- $Lang::tr{'no'} + $Lang::tr{'cancel'}
@@ -221,6 +243,7 @@ END if ($tripwiresettings{'ACTION'} eq 'globalresetyes') { +&Header::openbox( 'Waiting', 1, "" );print "

$Lang::tr{'tripwireoperating'}
"; $tripwiresettings{'ROOT'} = '/usr/sbin'; $tripwiresettings{'POLFILE'} = '/var/ipfire/tripwire/tw.pol'; $tripwiresettings{'DBFILE'} = '/var/ipfire/tripwire/$(HOSTNAME).twd'; @@ -241,7 +264,7 @@ $tripwiresettings{'MAILPROGRAM'} = '/usr/sbin/sendmail -oi -t'; $tripwiresettings{'SITEKEY'} = 'ipfire'; $tripwiresettings{'LOCALKEY'} = 'ipfire'; $tripwiresettings{'ACTION'} = ''; -system("/usr/local/bin/tripwirectrl readconfig"); +system("/usr/local/bin/tripwirectrl readconfig >& /dev/null"); open (FILE, ">${General::swroot}/tripwire/twcfg.txt") or die "Can't save tripwire config: $!"; flock (FILE, 2); print FILE <& /dev/null"); +system("/usr/local/bin/tripwirectrl keys ipfire ipfire >& /dev/null");$tripwiresettings{'SITEKEY'} = 'ipfire';$tripwiresettings{'LOCALKEY'} = 'ipfire'; } -if ($tripwiresettings{'ACTION'} eq 'generatekeysyes'){system("/usr/local/bin/tripwirectrl keys $tripwiresettings{'SITEKEY'} $tripwiresettings{'LOCALKEY'}");$tripwiresettings{'SITEKEY'} = 'ipfire';$tripwiresettings{'LOCALKEY'} = 'ipfire';} -if ($tripwiresettings{'ACTION'} eq 'keyresetyes'){system("/usr/local/bin/tripwirectrl keys ipfire ipfire");$tripwiresettings{'SITEKEY'} = 'ipfire';$tripwiresettings{'LOCALKEY'} = 'ipfire';} -if ($tripwiresettings{'ACTION'} eq 'resetpolicyyes'){system("/usr/local/bin/tripwirectrl resetpolicy tripwiresettings{'SITEKEY'} $tripwiresettings{'LOCALKEY'}");$tripwiresettings{'SITEKEY'} = 'ipfire';$tripwiresettings{'LOCALKEY'} = 'ipfire';} -if ($tripwiresettings{'ACTION'} eq 'generatepolicyyes'){system("/usr/local/bin/tripwirectrl generatepolicy $tripwiresettings{'SITEKEY'} $tripwiresettings{'LOCALKEY'}");$tripwiresettings{'SITEKEY'} = 'ipfire';$tripwiresettings{'LOCALKEY'} = 'ipfire';} -if ($tripwiresettings{'ACTION'} eq 'updatedatabaseyes'){system("/usr/local/bin/tripwirectrl updatedatabase $tripwiresettings{'LOCALKEY'} /var/ipfire/tripwire/report/$file");$tripwiresettings{'LOCALKEY'} = 'ipfire';} -if ($tripwiresettings{'ACTION'} eq 'generatereport'){system("/usr/local/bin/tripwirectrl generatereport");} +if ($tripwiresettings{'ACTION'} eq 'generatekeysyes'){&Header::openbox( 'Waiting', 1, "" );print "

$Lang::tr{'tripwireoperating'}
";system("/usr/local/bin/tripwirectrl keys $tripwiresettings{'SITEKEY'} $tripwiresettings{'LOCALKEY'} >& /dev/null");$tripwiresettings{'SITEKEY'} = 'ipfire';$tripwiresettings{'LOCALKEY'} = 'ipfire';} +if ($tripwiresettings{'ACTION'} eq 'keyresetyes'){&Header::openbox( 'Waiting', 1, "" );print "

$Lang::tr{'tripwireoperating'}
";system("/usr/local/bin/tripwirectrl keys ipfire ipfire >& /dev/null");$tripwiresettings{'SITEKEY'} = 'ipfire';$tripwiresettings{'LOCALKEY'} = 'ipfire';} +if ($tripwiresettings{'ACTION'} eq 'resetpolicyyes'){&Header::openbox( 'Waiting', 1, "" );print "

$Lang::tr{'tripwireoperating'}
";system("/usr/local/bin/tripwirectrl resetpolicy tripwiresettings{'SITEKEY'} $tripwiresettings{'LOCALKEY'} >& /dev/null");$tripwiresettings{'SITEKEY'} = 'ipfire';$tripwiresettings{'LOCALKEY'} = 'ipfire';} +if ($tripwiresettings{'ACTION'} eq 'generatepolicyyes'){&Header::openbox( 'Waiting', 1, "" );print "

$Lang::tr{'tripwireoperating'}
";system("/usr/local/bin/tripwirectrl generatepolicy $tripwiresettings{'SITEKEY'} $tripwiresettings{'LOCALKEY'} >& /dev/null");$tripwiresettings{'SITEKEY'} = 'ipfire';$tripwiresettings{'LOCALKEY'} = 'ipfire';} +if ($tripwiresettings{'ACTION'} eq 'updatedatabaseyes'){&Header::openbox( 'Waiting', 1, "" );print "

$Lang::tr{'tripwireoperating'}
";system("/usr/local/bin/tripwirectrl updatedatabase $tripwiresettings{'LOCALKEY'} /var/ipfire/tripwire/report/$file >& /dev/null");$tripwiresettings{'LOCALKEY'} = 'ipfire';} +if ($tripwiresettings{'ACTION'} eq 'generatereport'){&Header::openbox( 'Waiting', 1, "" );print "

$Lang::tr{'tripwireoperating'}
";system("/usr/local/bin/tripwirectrl generatereport >& /dev/null");} +if ($tripwiresettings{'ACTION'} eq 'addcronyes'){system("/usr/local/bin/tripwirectrl addcron $tripwiresettings{'HOUR'} $tripwiresettings{'MINUTE'} >& /dev/null");} ############################################################################################################################ ##################################################### Tripwire globale Optionen ############################################ @@ -369,6 +393,7 @@ END ; } + &Header::closebox(); ############################################################################################################################ @@ -455,5 +480,46 @@ END &Header::closebox(); +############################################################################################################################ +####################################################### Tripwire Cronjob ################################################## + +&Header::openbox('100%', 'center', $Lang::tr{'tripwire cronjobs'}); +print < +
+ + +END +; +foreach my $cronjob (@cronjobs) {chomp $cronjob;my $time=$cronjob; $time=~s/\/etc\/fcron.daily\/tripwire//g;print"";} +print < +
+

$cronjob at $time daily
+ + +
+ +
+ +
+END +; + +if ($tripwiresettings{'ACTION'} eq 'croncaption') +{ +print < + + + + +
$Lang::tr{'caption'}
$Lang::tr{'add cron'}
$Lang::tr{'delete cron'}
+END +; +} + +&Header::closebox(); + &Header::closebigbox(); &Header::closepage(); \ No newline at end of file diff --git a/langs/de/cgi-bin/de.pl b/langs/de/cgi-bin/de.pl index 2990b554f0..d8c52b4fde 100644 --- a/langs/de/cgi-bin/de.pl +++ b/langs/de/cgi-bin/de.pl @@ -44,6 +44,7 @@ 'add' => 'Hinzufügen', 'add a host' => 'Host hinzufügen:', 'add a new rule' => 'Neue Regel hinzufügen:', +'add cron' => 'Cronjob hinzufügen', 'add device' => 'Gerät hinzufügen', 'add network' => 'Netzwerk hinzufügen', 'add new alias' => 'Neue Alias-Adresse hinzufügen:', @@ -499,6 +500,7 @@ 'default services' => 'Standard Dienste', 'defaultwarning' => 'ACHTUNG - Ihre Einstellungen gehen hiermit verloren und werden durch die Standarteinstellungen ersetzt.', 'delete' => 'Löschen', +'delete cron' => 'Cronjob löschen', 'delete pc' => 'PC löschen', 'delete share' => 'Freigabe löschen', 'delete user' => 'Benutzer löschen', @@ -1027,6 +1029,7 @@ 'o-no' => 'Inaktiv', 'o-yes' => 'Aktiv', 'october' => 'Oktober', +'ok' => 'OK', 'older' => 'Älter', 'online help en' => 'Online-Hilfe (auf Deutsch)', 'only digits allowed in holdoff field' => 'Im Holdoff-Feld sind nur Ziffern erlaubt', @@ -1263,6 +1266,7 @@ 'smtphost' => 'Smtp Host', 'smtpport' => 'Smtp Port', 'snort hits' => 'Gesamtanzahl der aktivierten Intrusion-Regeln für', +'socket options' => 'Socket Options', 'sort ascending' => 'Sortiere aufsteigend', 'sort descending' => 'Sortiere absteigend', 'sound' => 'Klang', @@ -1364,11 +1368,13 @@ 'traffic shaping settings' => 'Einstellungen der Datenflußkontrolle', 'transfer limits' => 'Transferbeschränkungen', 'transparent on' => 'Transparent auf', +'tripwire cronjob' => 'Tripwire Cronjob', 'tripwire functions' => 'Tripwire Funktionen', 'tripwire reports' => 'Tripwire Reports', +'tripwireoperating' => 'Der Prozess wurde gestartet. Dies kann einige Minuten in Anspruch nehmen, bitte haben Sie Geduld, das Fenster wird sich automatisch aktualisieren sobald der Vorgang beendet ist.', 'tripwirewarningdatabase' => 'ACHTUNG - Ihre Datenbank wird auf den Stand des letzten Reports gesetzt, bitte versichern sie sich, dass keine unautorisiertend Änderungen vorgenommen wurden. Hierfür wird der Local-Key benötigt.', 'tripwirewarningkeys' => 'ACHTUNG - Sie löschen hiermit ihre bestehenden Schlüssel, ihre Konfiguration und Datenbank und legen Alles neu an.', -'tripwirewarningpolicy' => 'ACHTUNG - Ihr Policy wird neu erzeugt, anschließen wird die Datenbank neu initialisiert. Hierfür wird der Site-Key benötigt.', +'tripwirewarningpolicy' => 'ACHTUNG - Ihr Policy wird neu erzeugt, anschließen wird die Datenbank neu initialisiert. Hierfür wird der Site-Key und Local-Key benötigt.', 'tuesday' => 'Dienstag', 'type' => 'Typ', 'umount' => 'Abmelden', diff --git a/langs/en/cgi-bin/en.pl b/langs/en/cgi-bin/en.pl index d06bf6bbc1..3df237e843 100644 --- a/langs/en/cgi-bin/en.pl +++ b/langs/en/cgi-bin/en.pl @@ -44,6 +44,7 @@ 'add' => 'Add', 'add a host' => 'Add a host:', 'add a new rule' => 'Add a new rule:', +'add cron' => 'add cronjob', 'add device' => 'Add device', 'add network' => 'Add network', 'add new alias' => 'Add a new alias:', @@ -514,6 +515,7 @@ 'default services' => 'Default services', 'defaultwarning' => 'WARNING - Your settings will be lost and replaced by the default ones.', 'delete' => 'Delete', +'delete cron' => 'delete cronjob', 'delete pc' => 'delete workstation', 'delete share' => 'delete share', 'delete user' => 'delete User', @@ -1044,6 +1046,7 @@ 'o-no' => 'Inactiv', 'o-yes' => 'Activ', 'october' => 'October', +'ok' => 'OK', 'older' => 'Older', 'online help en' => 'Online Help (in English)', 'only digits allowed in holdoff field' => 'Only digits allowed in holdoff field', @@ -1276,6 +1279,7 @@ 'smtphost' => 'Smtp Host', 'smtpport' => 'Smtp Port', 'snort hits' => 'Total of number of Intrusion rules activated for', +'socket options' => 'Socket Options', 'sort ascending' => 'Sort Ascending', 'sort descending' => 'Sort Descending', 'sound' => 'Sound', @@ -1386,11 +1390,13 @@ 'trafficto' => 'To', 'transfer limits' => 'Transfer limits', 'transparent on' => 'Transparent on', +'tripwire cronjob' => 'tripwire cronjob', 'tripwire functions' => 'tripwire functions', 'tripwire reports' => 'tripwire reports', +'tripwireoperating' => 'The process was started. This may take serverall minutes, please wait the window will automaticly refresh after the process has finished.', 'tripwirewarningdatabase' => 'WARNING - Your Database will be updated with the data of the last report. Please ensure that no unauthorized changes are reported. Therefor the Local-Key is needed.', 'tripwirewarningkeys' => 'WARNING - This will erase your current keys, config, and database and generate them new.', -'tripwirewarningpolicy' => 'WARNING - Your policy will be rebuild, after that your database will be reinitalised. Therefor the Site-Key ist neeeded.', +'tripwirewarningpolicy' => 'WARNING - Your policy will be rebuild, after that your database will be reinitalised. Therefor the Site-Key and the Local-Ley are neeeded.', 'tuesday' => 'Tuesday', 'type' => 'type', 'unable to alter profiles while red is active' => 'Unable to alter profiles while RED is active.', diff --git a/src/misc-progs/sambactrl.c b/src/misc-progs/sambactrl.c index 315a8c2f90..a6e1f7c2d4 100644 --- a/src/misc-progs/sambactrl.c +++ b/src/misc-progs/sambactrl.c @@ -13,162 +13,183 @@ char command[BUFFER_SIZE]; int main(int argc, char *argv[]) { - if (!(initsetuid())) - exit(1); - - // Check what command is asked - if (argc==1) - { - fprintf (stderr, "Missing smbctrl command!\n"); - return 1; - } - - if (strcmp(argv[1], "smbuserdisable")==0) - { - snprintf(command, BUFFER_SIZE-1, "/usr/bin/smbpasswd -d %s", argv[2]); - safe_system(command); - return 0; - } - - if (strcmp(argv[1], "smbuserenable")==0) - { - snprintf(command, BUFFER_SIZE-1, "/usr/bin/smbpasswd -e %s", argv[2]); - safe_system(command); - return 0; - } - - if (strcmp(argv[1], "smbuserdelete")==0) - { - snprintf(command, BUFFER_SIZE-1, "/usr/bin/smbpasswd -x %s", argv[2]); - safe_system(command); - snprintf(command, BUFFER_SIZE-1, "/usr/sbin/userdel %s", argv[2]); - safe_system(command); - return 0; - } - - if (strcmp(argv[1], "smbsafeconf")==0) - { - safe_system("/bin/cat /var/ipfire/samba/global /var/ipfire/samba/shares > /var/ipfire/samba/smb.conf"); - return 0; - } - - if (strcmp(argv[1], "smbsafeconfcups")==0) - { - safe_system("/bin/cat /var/ipfire/samba/global /var/ipfire/samba/shares /var/ipfire/samba/printer > /var/ipfire/samba/smb.conf"); - return 0; - } - - if (strcmp(argv[1], "smbsafeconfpdc")==0) - { - safe_system("/bin/cat /var/ipfire/samba/global /var/ipfire/samba/pdc /var/ipfire/samba/shares > /var/ipfire/samba/smb.conf"); - return 0; - } - - if (strcmp(argv[1], "smbsafeconfpdccups")==0) - { - safe_system("/bin/cat /var/ipfire/samba/global /var/ipfire/samba/pdc /var/ipfire/samba/shares /var/ipfire/samba/printer > /var/ipfire/samba/smb.conf"); - return 0; - } - - if (strcmp(argv[1], "smbglobalreset")==0) - { - safe_system("/bin/cat /var/ipfire/samba/default.global /var/ipfire/samba/shares > /var/ipfire/samba/smb.conf"); - safe_system("/bin/cat /var/ipfire/samba/default.settings > /var/ipfire/samba/settings"); - safe_system("/bin/cat /var/ipfire/samba/default.global > /var/ipfire/samba/global"); - safe_system("/bin/cat /var/ipfire/samba/default.pdc > /var/ipfire/samba/pdc"); - return 0; - } - - if (strcmp(argv[1], "smbsharesreset")==0) - { - safe_system("/bin/cat /var/ipfire/samba/global /var/ipfire/samba/default.shares > /var/ipfire/samba/smb.conf"); - safe_system("/bin/cat /var/ipfire/samba/default.shares > /var/ipfire/samba/shares"); - return 0; - } - - if (strcmp(argv[1], "smbprinterreset")==0) - { - safe_system("/bin/cat /var/ipfire/samba/global /var/ipfire/samba/shares /var/default.printer > /var/ipfire/samba/smb.conf"); - safe_system("/bin/cat /var/ipfire/samba/default.printer > /var/ipfire/samba/printer"); - return 0; - } - - if (strcmp(argv[1], "smbstop")==0) - { - safe_system("/etc/rc.d/init.d/samba stop"); - return 0; - } - - if (strcmp(argv[1], "smbstart")==0) - { - safe_system("/etc/rc.d/init.d/samba start"); - return 0; - } - - if (strcmp(argv[1], "smbrestart")==0) - { - safe_system("/etc/rc.d/init.d/samba restart"); - return 0; - } - - if (strcmp(argv[1], "smbreload")==0) - { - safe_system("/etc/rc.d/init.d/samba reload"); - return 0; - } - - if (strcmp(argv[1], "smbstatus")==0) - { - snprintf(command, BUFFER_SIZE-1, "/usr/bin/smbstatus"); - safe_system(command); - return 0; - } - - if (strcmp(argv[1], "smbuseradd")==0) - { - snprintf(command, BUFFER_SIZE-1, "/usr/sbin/groupadd sambauser"); - safe_system(command); - snprintf(command, BUFFER_SIZE-1, "/usr/sbin/useradd -c 'Samba User' -m -g %s -p %s -s %s %s", argv[4], argv[3], argv[5], argv[2]); - safe_system(command); - snprintf(command, BUFFER_SIZE-1, "/usr/bin/printf '%s\n%s\n' | /usr/bin/smbpasswd -as %s", argv[3], argv[3], argv[2]); - safe_system(command); - return 0; - } - - if (strcmp(argv[1], "smbpcadd")==0) - { - snprintf(command, BUFFER_SIZE-1, "/usr/sbin/groupadd sambawks"); - safe_system(command); - snprintf(command, BUFFER_SIZE-1, "/usr/sbin/useradd -c 'Samba Workstation' -g %s -s %s %s", argv[3], argv[4], argv[2]); - safe_system(command); - snprintf(command, BUFFER_SIZE-1, "/usr/bin/smbpasswd -a -m %s", argv[2]); - safe_system(command); - return 0; - } - - if (strcmp(argv[1], "smbchangepw")==0) - { - snprintf(command, BUFFER_SIZE-1, "/usr/bin/printf '%s\n%s\n' | /usr/bin/smbpasswd -as %s", argv[3], argv[3], argv[2]); - safe_system(command); - return 0; - } - - if (strcmp(argv[1], "readsmbpasswd")==0) - { - safe_system("/bin/chown root:nobody /var/ipfire/samba/private"); - safe_system("/bin/chown root:nobody /var/ipfire/samba/private/smbpasswd"); - safe_system("/bin/chmod 640 /var/ipfire/samba/private/smbpasswd"); - safe_system("/bin/chmod 650 /var/ipfire/samba/private"); - return 0; - } - - if (strcmp(argv[1], "locksmbpasswd")==0) - { - safe_system("/bin/chown root:root /var/ipfire/samba/private"); - safe_system("/bin/chown root:root /var/ipfire/samba/private/smbpasswd"); - safe_system("/bin/chmod 600 /var/ipfire/samba/private/smbpasswd"); - safe_system("/bin/chmod 600 /var/ipfire/samba/private"); - return 0; - } +if (!(initsetuid())) +exit(1); + +// Check what command is asked +if (argc==1) +{ +fprintf (stderr, "Missing smbctrl command!\n"); +return 1; +} + +if (strcmp(argv[1], "smbuserdisable")==0) +{ +snprintf(command, BUFFER_SIZE-1, "/usr/bin/smbpasswd -d %s", argv[2]); +safe_system(command); +return 0; +} + +if (strcmp(argv[1], "smbuserenable")==0) +{ +snprintf(command, BUFFER_SIZE-1, "/usr/bin/smbpasswd -e %s", argv[2]); +safe_system(command); +return 0; +} + +if (strcmp(argv[1], "smbuserdelete")==0) +{ +snprintf(command, BUFFER_SIZE-1, "/usr/bin/smbpasswd -x %s", argv[2]); +safe_system(command); +snprintf(command, BUFFER_SIZE-1, "/usr/sbin/userdel %s", argv[2]); +safe_system(command); +return 0; +} + +if (strcmp(argv[1], "smbsafeconf")==0) +{ +safe_system("/bin/cat /var/ipfire/samba/global /var/ipfire/samba/shares > /var/ipfire/samba/smb.conf"); +return 0; +} + +if (strcmp(argv[1], "smbsafeconfcups")==0) +{ +safe_system("/bin/cat /var/ipfire/samba/global /var/ipfire/samba/shares /var/ipfire/samba/printer > /var/ipfire/samba/smb.conf"); +return 0; +} + +if (strcmp(argv[1], "smbsafeconfpdc")==0) +{ +safe_system("/bin/cat /var/ipfire/samba/global /var/ipfire/samba/pdc /var/ipfire/samba/shares > /var/ipfire/samba/smb.conf"); +return 0; +} + +if (strcmp(argv[1], "smbsafeconfpdccups")==0) +{ +safe_system("/bin/cat /var/ipfire/samba/global /var/ipfire/samba/pdc /var/ipfire/samba/shares /var/ipfire/samba/printer > /var/ipfire/samba/smb.conf"); +return 0; +} + +if (strcmp(argv[1], "smbglobalreset")==0) +{ +safe_system("/bin/cat /var/ipfire/samba/default.global /var/ipfire/samba/shares > /var/ipfire/samba/smb.conf"); +safe_system("/bin/cat /var/ipfire/samba/default.settings > /var/ipfire/samba/settings"); +safe_system("/bin/cat /var/ipfire/samba/default.global > /var/ipfire/samba/global"); +safe_system("/bin/cat /var/ipfire/samba/default.pdc > /var/ipfire/samba/pdc"); +return 0; +} + +if (strcmp(argv[1], "smbsharesreset")==0) +{ +safe_system("/bin/cat /var/ipfire/samba/global /var/ipfire/samba/default.shares > /var/ipfire/samba/smb.conf"); +safe_system("/bin/cat /var/ipfire/samba/default.shares > /var/ipfire/samba/shares"); +return 0; +} + +if (strcmp(argv[1], "smbprinterreset")==0) +{ +safe_system("/bin/cat /var/ipfire/samba/global /var/ipfire/samba/shares /var/default.printer > /var/ipfire/samba/smb.conf"); +safe_system("/bin/cat /var/ipfire/samba/default.printer > /var/ipfire/samba/printer"); +return 0; +} + +if (strcmp(argv[1], "smbstop")==0) +{ +safe_system("/etc/rc.d/init.d/samba stop"); +return 0; +} + +if (strcmp(argv[1], "smbstart")==0) +{ +safe_system("/etc/rc.d/init.d/samba start"); +return 0; +} + +if (strcmp(argv[1], "smbrestart")==0) +{ +safe_system("/etc/rc.d/init.d/samba restart"); +return 0; +} + +if (strcmp(argv[1], "smbreload")==0) +{ +safe_system("/etc/rc.d/init.d/samba reload"); +return 0; +} + +if (strcmp(argv[1], "smbstatus")==0) +{ +snprintf(command, BUFFER_SIZE-1, "/usr/bin/smbstatus"); +safe_system(command); +return 0; +} + +if (strcmp(argv[1], "smbuseradd")==0) +{ +snprintf(command, BUFFER_SIZE-1, "/usr/sbin/groupadd sambauser"); +safe_system(command); +snprintf(command, BUFFER_SIZE-1, "/usr/sbin/useradd -c 'Samba User' -m -g %s -p %s -s %s %s", argv[4], argv[3], argv[5], argv[2]); +safe_system(command); +snprintf(command, BUFFER_SIZE-1, "/usr/bin/printf '%s\n%s\n' | /usr/bin/smbpasswd -as %s", argv[3], argv[3], argv[2]); +safe_system(command); +return 0; +} + +if (strcmp(argv[1], "smbpcadd")==0) +{ +snprintf(command, BUFFER_SIZE-1, "/usr/sbin/groupadd sambawks"); +safe_system(command); +snprintf(command, BUFFER_SIZE-1, "/usr/sbin/useradd -c 'Samba Workstation' -g %s -s %s %s", argv[3], argv[4], argv[2]); +safe_system(command); +snprintf(command, BUFFER_SIZE-1, "/usr/bin/smbpasswd -a -m %s", argv[2]); +safe_system(command); +return 0; +} + +if (strcmp(argv[1], "smbchangepw")==0) +{ +snprintf(command, BUFFER_SIZE-1, "/usr/bin/printf '%s\n%s\n' | /usr/bin/smbpasswd -as %s", argv[3], argv[3], argv[2]); +safe_system(command); +return 0; +} + +if (strcmp(argv[1], "readsmbpasswd")==0) +{ +safe_system("/bin/chown root:nobody /var/ipfire/samba/private"); +safe_system("/bin/chown root:nobody /var/ipfire/samba/private/smbpasswd"); +safe_system("/bin/chmod 640 /var/ipfire/samba/private/smbpasswd"); +safe_system("/bin/chmod 650 /var/ipfire/samba/private"); +return 0; +} + +if (strcmp(argv[1], "locksmbpasswd")==0) +{ +safe_system("/bin/chown root:root /var/ipfire/samba/private"); +safe_system("/bin/chown root:root /var/ipfire/samba/private/smbpasswd"); +safe_system("/bin/chmod 600 /var/ipfire/samba/private/smbpasswd"); +safe_system("/bin/chmod 600 /var/ipfire/samba/private"); +return 0; +} +if (strcmp(argv[1], "enable")==0) +{ +safe_system("touch /var/ipfire/samba/enable"); +safe_system("/etc/rc.d/init.d/samba start"); +safe_system("ln -snf /etc/rc.d/init.d/samba /etc/rc.d/rc2.d/S50samba"); +safe_system("ln -snf /etc/rc.d/init.d/samba /etc/rc.d/rc2.d/K50samba"); +safe_system("ln -snf /etc/rc.d/init.d/samba /etc/rc.d/rc3.d/S50samba"); +safe_system("ln -snf /etc/rc.d/init.d/samba /etc/rc.d/rc3.d/K50samba"); +return 0; +} + +if (strcmp(argv[1], "disable")==0) +{ +safe_system("unlink /var/ipfire/samba/enable"); +safe_system("/etc/rc.d/init.d/samba stop"); +safe_system("unlink /etc/rc.d/rc2.d/S50samba"); +safe_system("unlink /etc/rc.d/rc2.d/K50samba"); +safe_system("unlink /etc/rc.d/rc3.d/S50samba"); +safe_system("unlink /etc/rc.d/rc3.d/K50samba"); +return 0; +} return 0; } \ No newline at end of file diff --git a/src/misc-progs/tripwirectrl.c b/src/misc-progs/tripwirectrl.c index 7ab3da7055..f414d5af24 100644 --- a/src/misc-progs/tripwirectrl.c +++ b/src/misc-progs/tripwirectrl.c @@ -32,7 +32,7 @@ return 0; if (strcmp(argv[1], "generatereport")==0) { -safe_system("/usr/sbin/tripwire --check --cfgfile /var/ipfire/tripwire/tw.cfg --polfile /var/ipfire/tripwire/tw.pol >/dev/null 2>&1"); +safe_system("/usr/sbin/tripwire --check --cfgfile /var/ipfire/tripwire/tw.cfg --polfile /var/ipfire/tripwire/tw.pol"); return 0; } @@ -45,42 +45,40 @@ return 0; if (strcmp(argv[1], "updatedatabase")==0) { -snprintf(command, BUFFER_SIZE-1, "/usr/sbin/tripwire --update --accept-all --cfgfile /var/ipfire/tripwire/tw.cfg --polfile /var/ipfire/tripwire/tw.pol --local-passphrase %s --twrfile %s >/dev/null 2>&1", argv[2], argv[3]); +snprintf(command, BUFFER_SIZE-1, "/usr/sbin/tripwire --update --accept-all --cfgfile /var/ipfire/tripwire/tw.cfg --polfile /var/ipfire/tripwire/tw.pol --local-passphrase %s --twrfile %s", argv[2], argv[3]); safe_system(command); return 0; } if (strcmp(argv[1], "keys")==0) { -snprintf(command, BUFFER_SIZE-1, "rm -rf /var/ipfire/tripwire/site.key && /usr/sbin/twadmin --generate-keys --site-keyfile /var/ipfire/tripwire/site.key --site-passphrase %s >/dev/null 2>&1 && chmod 640 /var/ipfire/tripwire/site.key", argv[2]); +snprintf(command, BUFFER_SIZE-1, "rm -rf /var/ipfire/tripwire/site.key && /usr/sbin/twadmin --generate-keys --site-keyfile /var/ipfire/tripwire/site.key --site-passphrase %s && chmod 640 /var/ipfire/tripwire/site.key", argv[2]); safe_system(command); -snprintf(command, BUFFER_SIZE-1, "rm -rf /var/ipfire/tripwire/local.key && /usr/sbin/twadmin --generate-keys --local-keyfile /var/ipfire/tripwire/local.key --local-passphrase %s >/dev/null 2>&1 && chmod 640 /var/ipfire/tripwire/local.key", argv[3]); +snprintf(command, BUFFER_SIZE-1, "rm -rf /var/ipfire/tripwire/local.key && /usr/sbin/twadmin --generate-keys --local-keyfile /var/ipfire/tripwire/local.key --local-passphrase %s && chmod 640 /var/ipfire/tripwire/local.key", argv[3]); safe_system(command); -snprintf(command, BUFFER_SIZE-1, "rm -rf /var/ipfire/tripwire/tw.cfg && /usr/sbin/twadmin --create-cfgfile --cfgfile /var/ipfire/tripwire/tw.cfg --site-keyfile /var/ipfire/tripwire/site.key --site-passphrase %s /var/ipfire/tripwire/twcfg.txt >/dev/null 2>&1 && chmod 640 /var/ipfire/tripwire/tw.cfg", argv[2]); +snprintf(command, BUFFER_SIZE-1, "rm -rf /var/ipfire/tripwire/tw.cfg && /usr/sbin/twadmin --create-cfgfile --cfgfile /var/ipfire/tripwire/tw.cfg --site-keyfile /var/ipfire/tripwire/site.key --site-passphrase %s /var/ipfire/tripwire/twcfg.txt && chmod 640 /var/ipfire/tripwire/tw.cfg", argv[2]); safe_system(command); -snprintf(command, BUFFER_SIZE-1, "rm -rf /var/ipfire/tripwire/tw.pol && /usr/sbin/twadmin --create-polfile --cfgfile /var/ipfire/tripwire/tw.cfg --site-keyfile /var/ipfire/tripwire/site.key --site-passphrase %s /var/ipfire/tripwire/twpol.txt >/dev/null 2>&1 && chmod 640 /var/ipfire/tripwire/tw.pol", argv[2]); +snprintf(command, BUFFER_SIZE-1, "rm -rf /var/ipfire/tripwire/tw.pol && /usr/sbin/twadmin --create-polfile --cfgfile /var/ipfire/tripwire/tw.cfg --site-keyfile /var/ipfire/tripwire/site.key --site-passphrase %s /var/ipfire/tripwire/twpol.txt && chmod 640 /var/ipfire/tripwire/tw.pol", argv[2]); safe_system(command); -snprintf(command, BUFFER_SIZE-1, "/usr/sbin/tripwire --init --cfgfile /var/ipfire/tripwire/tw.cfg --polfile /var/ipfire/tripwire/tw.pol --local-passphrase %s >/dev/null 2>&1", argv[3]); +snprintf(command, BUFFER_SIZE-1, "/usr/sbin/tripwire --init --cfgfile /var/ipfire/tripwire/tw.cfg --polfile /var/ipfire/tripwire/tw.pol --local-passphrase %s", argv[3]); safe_system(command); return 0; } if (strcmp(argv[1], "generatepolicy")==0) { -printf("Generating Policy File
"); -snprintf(command, BUFFER_SIZE-1, "/usr/sbin/twadmin --create-polfile --site-keyfile /var/ipfire/tripwire/site.key --site-passphrase %s --polfile /var/ipfire/tripwire/tw.pol --cfgfile /var/ipfire/tripwire/tw.cfg /var/ipfire/tripwire/twpol.txt >/dev/null 2>&1", argv[2]); +snprintf(command, BUFFER_SIZE-1, "/usr/sbin/twadmin --create-polfile --site-keyfile /var/ipfire/tripwire/site.key --site-passphrase %s --polfile /var/ipfire/tripwire/tw.pol --cfgfile /var/ipfire/tripwire/tw.cfg /var/ipfire/tripwire/twpol.txt, argv[2]); safe_system(command); -printf("Initialising - This may take a while depending on your Policy
"); -snprintf(command, BUFFER_SIZE-1, "/usr/sbin/tripwire --init --cfgfile /var/ipfire/tripwire/tw.cfg --polfile /var/ipfire/tripwire/tw.cfg --local-passphrase %s >/dev/null 2>&1", argv[3]); +snprintf(command, BUFFER_SIZE-1, "/usr/sbin/tripwire --init --cfgfile /var/ipfire/tripwire/tw.cfg --polfile /var/ipfire/tripwire/tw.pol --local-passphrase %s", argv[3]); safe_system(command); return 0; } if (strcmp(argv[1], "resetpolicy")==0) { -snprintf(command, BUFFER_SIZE-1, "/usr/sbin/twadmin --create-polfile --site-keyfile /var/ipfire/tripwire/site.key --site-passphrase %s --polfile /var/ipfire/tripwire/tw.pol --cfgfile /var/ipfire/tripwire/tw.cfg /var/ipfire/tripwire/twpol.default >/dev/null 2>&1", argv[2]); +snprintf(command, BUFFER_SIZE-1, "/usr/sbin/twadmin --create-polfile --site-keyfile /var/ipfire/tripwire/site.key --site-passphrase %s --polfile /var/ipfire/tripwire/tw.pol --cfgfile /var/ipfire/tripwire/tw.cfg /var/ipfire/tripwire/twpol.default", argv[2]); safe_system(command); -snprintf(command, BUFFER_SIZE-1, "/usr/sbin/tripwire --init --cfgfile /var/ipfire/tripwire/tw.cfg --polfile /var/ipfire/tripwire/tw.cfg --local-passphrase %s >/dev/null 2>&1", argv[3]); +snprintf(command, BUFFER_SIZE-1, "/usr/sbin/tripwire --init --cfgfile /var/ipfire/tripwire/tw.cfg --polfile /var/ipfire/tripwire/tw.pol --local-passphrase %s", argv[3]); safe_system(command); return 0; } @@ -96,5 +94,49 @@ if (strcmp(argv[1], "lockconfig")==0) safe_system("/bin/chown root:root /var/ipfire/tripwire/twcfg.txt"); return 0; } + +if (strcmp(argv[1], "enable")==0) +{ +safe_system("touch /var/ipfire/tripwire/enable"); +safe_system("rm -rf /var/ipfire/tripwire/site.key && /usr/sbin/twadmin --generate-keys --site-keyfile /var/ipfire/tripwire/site.key --site-passphrase ipfire && chmod 640 /var/ipfire/tripwire/site.key"); +safe_system("rm -rf /var/ipfire/tripwire/local.key && /usr/sbin/twadmin --generate-keys --local-keyfile /var/ipfire/tripwire/local.key --local-passphrase ipfire && chmod 640 /var/ipfire/tripwire/local.key"); +safe_system("rm -rf /var/ipfire/tripwire/tw.cfg && /usr/sbin/twadmin --create-cfgfile --cfgfile /var/ipfire/tripwire/tw.cfg --site-keyfile /var/ipfire/tripwire/site.key --site-passphrase ipfire /var/ipfire/tripwire/twcfg.txt && chmod 640 /var/ipfire/tripwire/tw.cfg"); +safe_system("rm -rf /var/ipfire/tripwire/tw.pol && /usr/sbin/twadmin --create-polfile --cfgfile /var/ipfire/tripwire/tw.cfg --site-keyfile /var/ipfire/tripwire/site.key --site-passphrase ipfire /var/ipfire/tripwire/twpol.txt && chmod 640 /var/ipfire/tripwire/tw.pol"); +safe_system("/usr/sbin/tripwire --init --cfgfile /var/ipfire/tripwire/tw.cfg --polfile /var/ipfire/tripwire/tw.pol --local-passphrase ipfire"); +safe_system("cat /usr/sbin/tripwire --check --cfgfile /var/ipfire/tripwire/tw.cfg --polfile /var/ipfire/tripwire/tw.pol > /etc/fcron.daily/tripwire0600"); +safe_system("chmod 755 /etc/fcron.daily/tripwire0600"); +safe_system("touch -t 01010600 /etc/fcron.daily/tripwire0600"); +return 0; +} + +if (strcmp(argv[1], "disable")==0) +{ +safe_system("unlink /var/ipfire/tripwire/enable"); +safe_system("unlink /etc/fcron.daily/tripwire*"); +safe_system("rm -rf /var/ipfire/tripwire/site.key"); +safe_system("rm -rf /var/ipfire/tripwire/local.key"); +safe_system("rm -rf /var/ipfire/tripwire/tw.cfg*"); +safe_system("rm -rf /var/ipfire/tripwire/tw.pol*"); +safe_system("rm -rf /var/ipfire/tripwire/*.twd*"); +safe_system("rm -rf /var/ipfire/tripwire/report/*"); +return 0; +} + +if (strcmp(argv[1], "addcron")==0) +{ +snprintf(command, BUFFER_SIZE-1, "cat /usr/sbin/tripwire --check --cfgfile /var/ipfire/tripwire/tw.cfg --polfile /var/ipfire/tripwire/tw.pol > /etc/fcron.daily/tripwire%s%s", argv[2], argv[3]); +safe_system(command); +snprintf(command, BUFFER_SIZE-1, "chmod 755 /etc/fcron.daily/tripwire%s%s", argv[2], argv[3]); +safe_system(command); +snprintf(command, BUFFER_SIZE-1, "touch -t 0101%s%s /etc/fcron.daily/tripwire%s%s", argv[2], argv[3], argv[2], argv[3]); +safe_system(command); +return 0; +} +if (strcmp(argv[1], "disablecron")==0) +{ +snprintf(command, BUFFER_SIZE-1, "unlink /etc/fcron.daily/tripwire%s", argv[2]); +safe_system(command); +return 0; +} return 0; } \ No newline at end of file -- 2.39.2