#!/usr/bin/perl ########################################################################### ## Copyright (C) Wizardry and Steamworks 2013 - License: GNU GPLv3 ## ## Please see: http://www.gnu.org/licenses/gpl.html for legal details, ## ## rights of fair usage, the disclaimer and warranty conditions. ## ########################################################################### use JSON::XS; use File::Slurp; my $coder = JSON::XS->new->ascii->pretty->allow_nonref->relaxed; my $json = read_file('/etc/paxflags.conf'); my $cfg = $coder->decode($json); foreach $pax (keys $cfg) { foreach my $daemon (keys $cfg->{$pax}) { my $status=`service $daemon status 2>&1`; next if $status =~ /.+?unrecognized.+?/i; next if defined $ARGV[0] and $ARGV[0] ne $daemon; foreach my $file (@{$cfg->{$pax}->{$daemon}}) { my $flags = `paxctl -vqQ $file 2>/dev/null`; $flags =~ /([PEMRXSpemrxs\-]{12})/i; foreach(split(//, $pax)) { next if $_ eq "-"; if($flags !~ /$_/) { `service $daemon stop`; `paxctl -q -c$pax $file`; last; } } } `service $daemon start`; } }