Файловый менеджер - Редактировать - /var/www/iplanru/data/www/intesco.ru/d59ed/quota.tar
Назад
etc/init.d/quota 0000666 00000006025 15077126552 0007601 0 ustar 00 #!/bin/sh ### BEGIN INIT INFO # Provides: quota # Short-Description: Enable user quota # Required-Start: $remote_fs # Required-Stop: $remote_fs # Default-Start: S # Default-Stop: 0 6 ### END INIT INFO PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin DESC="quota service" # names of binaries check=/sbin/quotacheck on=/sbin/quotaon off=/sbin/quotaoff quotaisoff=/var/lib/quota/off quotaisnew=/var/lib/quota/new ALLFLAGS=-aug CHECKFLAGS=${ALLFLAGS}m USERFLAGS=-uc GROUPFLAGS=-gc . /lib/lsb/init-functions # create list of all fs with quota scan_fstab() { tmplist=`grep "^[ ]*[^#].*$1" /etc/fstab | \ sed -e 's/\(^[[:space:]]*[^[:space:]]*[[:space:]]*[^[:space:]]*[[:space:]]*[^[:space:]]*\).*/\1/g' \ -e 's/^[[:space:]]*[^[:space:]]*[[:space:]]*//g'` list=${tmplist:=empty} } set -e case "$1" in start) # Check if quota already has been enabled LC_MESSAGES=C $on -ap|grep -q "is off" || exit 0 # Check all filesystems if quota is new or wasn't shut down correctly log_action_begin_msg 'Checking quotas'; if [ -x $check ] && ( [ ! -f $quotaisoff ] || [ -f $quotaisnew ] ); then $check $CHECKFLAGS || $check -c $CHECKFLAGS log_action_end_msg 0 else # if some filesystems are new check just these filesystems scan_fstab "usrquota" set -- $list while [ $# -ge 2 ] do if [ "$2" != "xfs" ] then if test ! -e $1/quota.user && test ! -e $1/aquota.user; then log_warning_msg "Warning: user quota not configured in filesystem \`$1.'" elif test ! -e $1/aquota.user; then test ! -s $1/quota.user && $check $USERFLAGS $1 elif test ! -s $1/aquota.user; then $check $USERFLAGS $1 fi fi shift; shift done scan_fstab "grpquota" set $list while [ $# -ge 2 ] do if [ "$2" != "xfs" ] then if test ! -e $1/quota.group && test ! -e $1/aquota.group; then log_warning_msg "Warning: group quota not configured in filesystem \`$1.'" elif test ! -e $1/aquota.group; then test ! -s $1/quota.group && $check $GROUPFLAGS $1 elif test ! -s $1/aquota.group; then $check $GROUPFLAGS $1 fi fi shift; shift done log_action_end_msg 0 fi # Remove quota-off and quota-new files rm -f $quotaisoff $quotaisnew # Turn quotas on. if [ -x $on ] then log_action_begin_msg 'Turning on quotas'; $on $ALLFLAGS log_action_end_msg 0 fi ;; stop) if [ -x $off ] then log_action_begin_msg 'Turning off quotas' $off $ALLFLAGS || true # Create quota-on file touch $quotaisoff log_action_end_msg 0 fi ;; restart|force-reload) # # If the "reload" option is implemented, move the "force-reload" # option to the "reload" entry above. If not, "force-reload" is # just the same as "restart". # $0 stop $0 start ;; status) if LC_MESSAGES=C $on -ap | grep -q "is off"; then log_failure_msg "quota is off" exit 3 else log_success_msg "quota is on" exit 0 fi ;; *) echo "Usage: $0 {start|stop|restart|force-reload|status}" >&2 exit 1 ;; esac exit 0 etc/cron.daily/quota 0000666 00000000531 15077130422 0010441 0 ustar 00 #! /bin/sh # check if quota package is available test -x /usr/sbin/warnquota || exit 0 # check if warnquota run is configured test -f /etc/default/quota || exit 0 . /etc/default/quota if [ "$run_warnquota" = "true" ]; then # check if quotas are enabled if grep -q '^[^#]*quota' /etc/fstab; then /usr/sbin/warnquota fi fi exit 0 off 0000666 00000000000 15077166013 0005241 0 ustar 00 ldap/quota.schema 0000666 00000001050 15077166225 0010012 0 ustar 00 ## ## schema file for Unix Quotas ## Schema for storing Unix Quotas in LDAP ## OIDs are owned by Cogent Innovators, LLC ## ## 1.3.6.1.4.1.19937.1.1.x - attributetypes ## 1.3.6.1.4.1.19937.1.2.x - objectclasses ## attributetype ( 1.3.6.1.4.1.19937.1.1.1 NAME 'quota' DESC 'Quotas (FileSystem:BlocksSoft,BlocksHard,InodesSoft,InodesHard)' EQUALITY caseIgnoreIA5Match SYNTAX 1.3.6.1.4.1.1466.115.121.1.26{255} ) objectclass ( 1.3.6.1.4.1.19937.1.2.1 NAME 'systemQuotas' SUP posixAccount AUXILIARY DESC 'System Quotas' MUST ( uid ) MAY ( quota )) ldap/setSystemQuotas.pl 0000666 00000007532 15077166225 0011244 0 ustar 00 #!/usr/bin/perl -w # $0 -b "ou=People,dc=borgia,dc=com" -Q /dev/with/quota=0:0:0:0 -F '(attr=value)' # Synopsis # setSystemQuotas.pl is a script solely for modifying the quota attribute in # LDAP. It expects that the users you intend to have quotas already have the # systemQuotas objectClass set. # This tool is capable of applying standard LDAP filters to the user-supplied # base DN for modifying multiple users' quotas at once. # Examples: # Set quota on /dev/sda7 and /dev/sda8 for user stefan # ./setSystemQuotas.pl -b "uid=stefan,ou=People,dc=borgia,dc=com" -Q /dev/sda7=4000000:4400000:10000:11000 -Q /dev/sda8=4000000:4400000:10000:11000 # # Set quota on /dev/sda8 for user all People with description of Student # ./setSystemQuotas.pl -b "ou=People,dc=borgia,dc=com" -Q /dev/sda8=40000:44000:1000:1100 -F "(description=Student)" # # Delete quotas for user stefan # ./setSystemQuotas.pl -b "uid=stefan,ou=People,dc=borgia,dc=com" use strict; use Net::LDAP; use Getopt::Long; chomp(my $Password = `cat /etc/ldap.secret`); my $Host = 'localhost'; my $Port = '389'; my $BindDN = 'cn=Manager,dc=borgia,dc=com'; my $SSL = 0; my $b = ''; my %Q = (); my $F = ''; GetOptions( 'b=s' => \$b, 'Q=s' => \%Q, 'F=s' => \$F, ); die "Usage: $0 -b userdn [-F '(extrafilter)'] [-Q /fs=sb:hb:sf:hf ...]\n" unless $b; foreach ( keys %Q ) { local @_ = split /:/, $Q{$_}; unless ( $#_ == 3 ) { print "Ignoring $_: invalid format\n"; delete $Q{$_}; } } my $ldap = connectLDAP(); my $quota = {}; my $search; $search = $ldap->search( base => $b, filter => "(&(objectClass=systemQuotas)$F)", attrs => ['*', 'quota'], ); $search->code && die $search->error; my $i = 0; my $max = $search->count; for ( $i=0; $i<$max; $i++ ) { my $entry = $search->entry($i); my $dn = $entry->dn; if ( keys %Q ) { $quota->{$dn} = 1; foreach ( $entry->get_value('quota') ) { my @quota = split /:/; my $fs = shift @quota; delete $quota->{$dn} if $quota->{$dn} == 1; $quota->{$dn}->{$fs} = join ':', @quota; } } else { $quota->{$dn} = 0; delete $quota->{$dn} unless $entry->get_value('quota'); } } foreach my $dn ( keys %{$quota} ) { if ( ref $quota->{$dn} eq 'HASH' ) { print STDERR "Modify $dn:\n"; foreach ( keys %Q ) { print STDERR "\t$_:$Q{$_}\n"; $quota->{$dn}->{$_} = $Q{$_}; } my @quota = map { "$_:$quota->{$dn}->{$_}" } keys %{$quota->{$dn}}; my $modify = $ldap->modify( $dn, replace => { quota => [@quota], }, ); $modify->code && warn "Failed to modify quota: ", $modify->error, "\n"; } else { if ( $quota->{$dn} == 1 ) { delete $quota->{$dn}; print STDERR "Add $dn:\n"; foreach ( keys %Q ) { print STDERR "\t$_:$Q{$_}\n"; $quota->{$dn}->{$_} = $Q{$_} } my @quota = map { "$_:$quota->{$dn}->{$_}" } keys %{$quota->{$dn}}; my $modify = $ldap->modify( $dn, add => { quota => [@quota], }, ); $modify->code && warn "Failed to modify quota: ", $modify->error, "\n"; } elsif ( $quota->{$dn} == 0 ) { print STDERR "Delete $dn:\n"; my $modify = $ldap->modify( $dn, delete => ['quota'], ); $modify->code && warn "Failed to modify quota: ", $modify->error, "\n"; } } } $ldap->unbind; sub connectLDAP { # bind to a directory with dn and password my $ldap = Net::LDAP->new( $Host, port => $Port, version => 3, # debug => 0xffff, ) or die "Can't contact LDAP server ($@)\n"; if ( $SSL ) { $ldap->start_tls( # verify => 'require', # clientcert => 'mycert.pem', # clientkey => 'mykey.pem', # decryptkey => sub { 'secret'; }, # capath => '/usr/local/cacerts/' ); } $ldap->bind($BindDN, password=>$Password); return $ldap; } ldap/setquota-ldap.pl 0000666 00000013627 15077166225 0010634 0 ustar 00 #!/usr/bin/perl # A Perl wrapper for setquota utility which updates LDAP accordingly. # /etc/fstab: usrquota,grpquota # mount -o remount /f/s # touch /f/s/aquota.{user,group} # chmod 600 /f/s/aquota.{user,group} # quotacheck -cguvamf use strict; use warnings; use Net::LDAP; use Net::LDAP::Entry; use Getopt::Long; Getopt::Long::Configure ("bundling"); my $help = $#ARGV >= 0 ? 0 : 1; my $ldaphost = 'localhost'; my $passwordfile = ''; my $password = ''; my $binddn = $ENV{BINDDN}; my $basedn = $ENV{BASEDN}; my $oc = 'systemQuotas'; my $attr = 'quota'; my %Q = (); my $F = 'cn=*'; GetOptions( 'help|?' => \$help, 'oc|o=s' => \$oc, 'attr|a=s' => \$attr, 'quota|Q=s' => \%Q, 'filter|F=s' => \$F, 'ldaphost|h=s' => \$ldaphost, 'basedn|b=s' => \$basedn, 'binddn|D=s' => \$binddn, 'password|w=s' => \$password, 'passwordfile|W=s' => \$passwordfile, ); die "Usage: $0 -b basedn [-o objectClass] [-a attr] [-F '(extrafilter)'] [-Q /f/s=sb:hb:gb:sf:hf:gf ...]\n" if $help; %Q = checkQ(%Q); my ($ldap, $bind); if ( $ldap = Net::LDAP->new($ldaphost, version => 3, timeout => 3) ) { if ( $binddn && $password ) { $bind = $ldap->bind($binddn, password=>$password); } elsif ( $binddn && $passwordfile ){ $bind = $ldap->bind($binddn, password=>bindpw($passwordfile)); } else { $bind = $ldap->bind(); } die "Unable to connect to LDAP\n" if $bind->code; undef $passwordfile; } else { die "Unable to connect to LDAP\n"; } my $search = $ARGV[0] ? $ldap->search(base=>$basedn, filter=>"uid=$ARGV[0]") : $ldap->search(base=>$basedn, filter=>$F); if ( $search->code ) { die "LDAP Error: ", error($search), "\n"; } elsif ( $search->count <= 0 ) { die "0 results found in LDAP\n"; } else { my $i = 0; for ( $i=0; $i<$search->count; $i++ ) { my $entry = $search->entry($i); my @oc = $entry->get_value('objectClass'); # objectClass: $oc unless ( grep { /^$oc$/ } @oc ) { my $modify = $ldap->modify($entry->dn, add => {objectClass => $oc}); if ( $modify->code ) { print STDERR "Failed to add objectClass $oc:", error($modify), "\n"; } } # $attr: /f/s=sb:hb:sf:hf if ( $entry->exists($attr) ) { my @attr = $entry->get_value($attr); if ( keys %Q ) { foreach my $fs ( keys %Q ) { foreach ( @attr ) { next unless /^$fs=/; my $modify = $ldap->modify($entry->dn, delete => {$attr => "$_"}); if ( $modify->code ) { print STDERR "Failed to delete $attr: $_: ", error($modify), "\n"; } } my $modify = $ldap->modify($entry->dn, add => {$attr => "$fs=$Q{$fs}"}); if ( $modify->code ) { print STDERR "Failed to add $attr: $fs=$Q{$fs}: ", error($modify), "\n"; } else { print STDERR "Failed to setquota: $fs=$Q{$fs}\n" if setquota($entry->get_value('uid'), $fs, $Q{$fs}); } } } else { my $modify = $ldap->modify($entry->dn, delete => [($attr)]); if ( $modify->code ) { print STDERR "Failed to delete $attr: ", error($modify), "\n"; } else { foreach ( @attr ) { my ($fs) = m!^(/[^=]*)!; $Q{$fs} = '0:0:0:0:0:0'; print STDERR "Failed to setquota: $fs=$Q{$fs}\n" if setquota($entry->get_value('uid'), $fs, $Q{$fs}); } } } } else { if ( keys %Q ) { foreach my $fs ( keys %Q ) { my $modify = $ldap->modify($entry->dn, add => {$attr => "$fs=$Q{$fs}"}); if ( $modify->code ) { print STDERR "Failed to add $attr: $fs=$Q{$fs}: ", error($modify), "\n"; } else { print STDERR "Failed to setquota: $fs=$Q{$fs}\n" if setquota($entry->get_value('uid'), $fs, $Q{$fs}); } } } } } } sub setquota { $_[2] = '0:0:0:0:0:0' unless $_[2]; $_[2] =~ /^(\d+):(\d+):(\d+):(\d+):(\d+):(\d+)$/; qx{/usr/sbin/setquota -u $_[0] $1 $2 $4 $5 $_[1]}; qx{/usr/sbin/setquota -T -u $_[0] $3 $6 $_[1]}; return 0; } sub checkQ { my (%Q) = @_; foreach ( keys %Q ) { die "$_: invalid format\n" unless m!^(/[^=]*)! && $Q{$_} =~ /^(\d+):(\d+):(\d+):(\d+):(\d+):(\d+)$/; } return %Q; } sub bindpw { my ($passwordfile) = @_; open P, $passwordfile or die "Can't open passwordfile: $!"; chomp(my $password = <P>); close P; return $password; } sub error { return $_[0]->error, "(", $_[0]->code, ")"; } ldap/applySystemQuotas.pl 0000666 00000006251 15077166225 0011573 0 ustar 00 #!/usr/bin/perl -w # $0 -b "ou=People,dc=borgia,dc=com" -F '(attr=value)' # Synopsis # applyQuotas.pl is a script solely for making the quota set within LDAP take # affect by running the linuxquota tool edquota with the figures set in LDAP. # This tool is capable of applying standard LDAP filters to the user-supplied # base DN for applying multiple users' quotas at once. # Examples: # Apply the quotas using the linuxquota tool edquota for user stefan # ./applySystemQuotas.pl -b "uid=stefan,ou=People,dc=borgia,dc=com" # # Apply the quotas using the linuxquota tool edquota for all People with description of Student # ./applySystemQuotas.pl -b "ou=People,dc=borgia,dc=com" -F "(description=Student)" use strict; use Net::LDAP; use Getopt::Long; chomp(my $Password = `cat /etc/ldap.secret`); my $Host = 'localhost'; my $Port = '389'; my $BindDN = 'cn=Manager,dc=borgia,dc=com'; my $SSL = 0; my $edquota_editor = '/usr/share/quota/ldap/edquota_editor'; my $edquota = '/usr/sbin/edquota'; my $b = ''; my $F = ''; GetOptions( 'b=s' => \$b, 'F=s' => \$F, ); die "Usage: $0 -b basedn [-F '(extrafilter)']\n" unless $b; my $ldap = connectLDAP(); my $search; $search = $ldap->search( base => $b, filter => "(&(objectClass=systemQuotas)$F)", attrs => ['uid', 'quota'], ); $search->code && die $search->error; my $i = 0; my $max = $search->count; for ( $i=0; $i<$max; $i++ ) { my $entry = $search->entry($i); my $editor = $ENV{'VISUAL'} if $ENV{'VISUAL'}; $ENV{'VISUAL'} = $edquota_editor; $ENV{'QUOTA_USER'} = $entry->get_value('uid'); # Delete all existing quotas for QUOTA_USER $ENV{'QUOTA_FILESYS'} = '*'; $ENV{'QUOTA_SBLOCKS'} = 0; $ENV{'QUOTA_HBLOCKS'} = 0; $ENV{'QUOTA_SFILES'} = 0; $ENV{'QUOTA_HFILES'} = 0; print "$ENV{'QUOTA_USER'}: $ENV{'QUOTA_FILESYS'}:$ENV{'QUOTA_SBLOCKS'},$ENV{'QUOTA_HBLOCKS'},$ENV{'QUOTA_SFILES'},$ENV{'QUOTA_HFILES'}\n"; qx(/usr/sbin/edquota -u $ENV{'QUOTA_USER'}); my @quotas = $entry->get_value('quota'); if ( $#quotas >= 0 ) { foreach ( @quotas ) { my @quota = split /:/; $ENV{'QUOTA_FILESYS'} = $quota[0]; $ENV{'QUOTA_SBLOCKS'} = $quota[1]; $ENV{'QUOTA_HBLOCKS'} = $quota[2]; $ENV{'QUOTA_SFILES'} = $quota[3]; $ENV{'QUOTA_HFILES'} = $quota[4]; print "$ENV{'QUOTA_USER'}: $ENV{'QUOTA_FILESYS'}:$ENV{'QUOTA_SBLOCKS'},$ENV{'QUOTA_HBLOCKS'},$ENV{'QUOTA_SFILES'},$ENV{'QUOTA_HFILES'}\n"; qx($edquota -u $ENV{'QUOTA_USER'}); } } if ($editor) { $ENV{'VISUAL'} = $editor; } else { delete $ENV{'VISUAL'}; } } $search = $ldap->unbind; sub connectLDAP { # bind to a directory with dn and password my $ldap = Net::LDAP->new( $Host, port => $Port, version => 3, # debug => 0xffff, ) or die "Can't contact LDAP server ($@)\n"; if ( $SSL ) { $ldap->start_tls( # verify => 'require', # clientcert => 'mycert.pem', # clientkey => 'mykey.pem', # decryptkey => sub { 'secret'; }, # capath => '/usr/local/cacerts/' ); } $ldap->bind($BindDN, password=>$Password); return $ldap; } ldap/edquota_editor 0000666 00000002333 15077166225 0010437 0 ustar 00 #!/usr/bin/perl -w use strict; die "QUOTA_USER environment variable not set\n" unless defined $ENV{'QUOTA_USER'}; die "QUOTA_FILESYS environment variable not set\n" unless defined $ENV{'QUOTA_FILESYS'}; die "QUOTA_SBLOCKS environment variable not set\n" unless defined $ENV{'QUOTA_SBLOCKS'}; die "QUOTA_HBLOCKS environment variable not set\n" unless defined $ENV{'QUOTA_HBLOCKS'}; die "QUOTA_SFILES environment variable not set\n" unless defined $ENV{'QUOTA_SFILES'}; die "QUOTA_HFILES environment variable not set\n" unless defined $ENV{'QUOTA_HFILES'}; open FILE, $ARGV[0]; my $qdata = join '', (@_=<FILE>); close FILE; open FILE, ">$ARGV[0]"; print FILE &edit_quota_file($qdata, $ENV{'QUOTA_FILESYS'}, $ENV{'QUOTA_SBLOCKS'}, $ENV{'QUOTA_HBLOCKS'}, $ENV{'QUOTA_SFILES'}, $ENV{'QUOTA_HFILES'}); close FILE; # edit_quota_file(data, filesys, sblocks, hblocks, sfiles, hfiles) sub edit_quota_file { my($rv, $line, @line, $i); @line = split /\n/, $_[0]; for ( $i=0; $i<@line; $i++ ) { if ($line[$i] =~ /^\s+(\S+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+)$/ && ($1 eq $_[1] || $_[1] eq '*')) { # new-style line to change $rv .= " $1 $2 $_[2] $_[3] $5 $_[4] $_[5]\n"; } else { $rv .= "$line[$i]\n"; } } return $rv; }
| ver. 1.4 |
Github
|
.
| PHP 5.4.45-1~dotdeb+6.1 | Генерация страницы: 0.01 |
proxy
|
phpinfo
|
Настройка