diff options
author | V3n3RiX <venerix@redcorelinux.org> | 2017-10-09 18:53:29 +0100 |
---|---|---|
committer | V3n3RiX <venerix@redcorelinux.org> | 2017-10-09 18:53:29 +0100 |
commit | 4f2d7949f03e1c198bc888f2d05f421d35c57e21 (patch) | |
tree | ba5f07bf3f9d22d82e54a462313f5d244036c768 /sys-fs/quota/files |
reinit the tree, so we can have metadata
Diffstat (limited to 'sys-fs/quota/files')
18 files changed, 978 insertions, 0 deletions
diff --git a/sys-fs/quota/files/ldap-scripts/applySystemQuotas.pl b/sys-fs/quota/files/ldap-scripts/applySystemQuotas.pl new file mode 100755 index 000000000000..41c74d919d37 --- /dev/null +++ b/sys-fs/quota/files/ldap-scripts/applySystemQuotas.pl @@ -0,0 +1,104 @@ +#!/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/sbin/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; +} diff --git a/sys-fs/quota/files/ldap-scripts/edquota_editor b/sys-fs/quota/files/ldap-scripts/edquota_editor new file mode 100755 index 000000000000..fdebd09e35a4 --- /dev/null +++ b/sys-fs/quota/files/ldap-scripts/edquota_editor @@ -0,0 +1,32 @@ +#!/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; +} diff --git a/sys-fs/quota/files/ldap-scripts/quota.schema b/sys-fs/quota/files/ldap-scripts/quota.schema new file mode 100644 index 000000000000..b5e216f8db96 --- /dev/null +++ b/sys-fs/quota/files/ldap-scripts/quota.schema @@ -0,0 +1,18 @@ +## +## 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 )) diff --git a/sys-fs/quota/files/ldap-scripts/setSystemQuotas.pl b/sys-fs/quota/files/ldap-scripts/setSystemQuotas.pl new file mode 100755 index 000000000000..90ab1e8076c9 --- /dev/null +++ b/sys-fs/quota/files/ldap-scripts/setSystemQuotas.pl @@ -0,0 +1,140 @@ +#!/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; +} diff --git a/sys-fs/quota/files/ldap-scripts/setquota-ldap.pl b/sys-fs/quota/files/ldap-scripts/setquota-ldap.pl new file mode 100644 index 000000000000..7cafc449d824 --- /dev/null +++ b/sys-fs/quota/files/ldap-scripts/setquota-ldap.pl @@ -0,0 +1,148 @@ +#!/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, ")"; +} diff --git a/sys-fs/quota/files/quota-4.03-default_fpic_fpie.patch b/sys-fs/quota/files/quota-4.03-default_fpic_fpie.patch new file mode 100644 index 000000000000..2ff519f2b846 --- /dev/null +++ b/sys-fs/quota/files/quota-4.03-default_fpic_fpie.patch @@ -0,0 +1,32 @@ +commit cd9dff0b5b53279442458360003831b6c14adc22 +Author: Tomáš Chvátal <tchvatal@suse.com> +Date: Tue Jan 5 11:20:52 2016 +0100 + + Set -fPIC and -pie as default params when building + + Signed-off-by: Tomáš Chvátal <tchvatal@suse.cz> + Signed-off-by: Jan Kara <jack@suse.cz> + +diff --git a/Makefile.am b/Makefile.am +index 7c7a866..77f8400 100644 +--- a/Makefile.am ++++ b/Makefile.am +@@ -1,4 +1,5 @@ + ACLOCAL_AMFLAGS = -I m4 ++AM_LDFLAGS = -pie + + BUILT_SOURCES = rquota.h rquota.c rquota_clnt.c + +diff --git a/configure.ac b/configure.ac +index 1552c15..68d5924 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -53,7 +53,7 @@ AS_IF([test "x${prefix}" = "xNONE"], [ + # ================ + # Check for cflags + # ================ +-CFLAGS="$CFLAGS -D_GNU_SOURCE -Wall -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64" ++CFLAGS="$CFLAGS -D_GNU_SOURCE -Wall -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -fPIC" + AC_ARG_ENABLE([werror], + [AS_HELP_STRING([--enable-werror], [Treat all warnings as errors, useful for development])], + [enable_werror="$enableval"], diff --git a/sys-fs/quota/files/quota-4.03-distribute_ldap-scripts.patch b/sys-fs/quota/files/quota-4.03-distribute_ldap-scripts.patch new file mode 100644 index 000000000000..83339159e0fb --- /dev/null +++ b/sys-fs/quota/files/quota-4.03-distribute_ldap-scripts.patch @@ -0,0 +1,23 @@ +commit 861154efb90ed049e0473cc36935b8d03c78a869 +Author: Tomáš Chvátal <tchvatal@suse.com> +Date: Mon Jan 4 13:01:36 2016 +0100 + + Distribute ldap-scripts directory too + + Signed-off-by: Tomáš Chvátal <tchvatal@suse.com> + Signed-off-by: Jan Kara <jack@suse.cz> + +diff --git a/Makefile.am b/Makefile.am +index eb62617..a880ebe 100644 +--- a/Makefile.am ++++ b/Makefile.am +@@ -52,7 +52,8 @@ EXTRA_DIST = \ + $(man_MANS) \ + $(rpcsvc_DATA) \ + autogen.sh \ +- Changelog ++ Changelog \ ++ ldap-scripts + + noinst_LIBRARIES = \ + libquota.a \ diff --git a/sys-fs/quota/files/quota-4.03-dont_override_cflags.patch b/sys-fs/quota/files/quota-4.03-dont_override_cflags.patch new file mode 100644 index 000000000000..e59341a702ac --- /dev/null +++ b/sys-fs/quota/files/quota-4.03-dont_override_cflags.patch @@ -0,0 +1,22 @@ +commit 776757a23e9930588950c7fcbc7827ec7a3e51c4 +Author: Tomáš Chvátal <tchvatal@suse.com> +Date: Mon Jan 4 15:48:19 2016 +0100 + + Do not accidentaly override commandline passed CFLAGS. + + Signed-off-by: Tomáš Chvátal <tchvatal@suse.com> + Signed-off-by: Jan Kara <jack@suse.cz> + +diff --git a/configure.ac b/configure.ac +index 3ba1386..1552c15 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -53,7 +53,7 @@ AS_IF([test "x${prefix}" = "xNONE"], [ + # ================ + # Check for cflags + # ================ +-CFLAGS="-D_GNU_SOURCE -Wall -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64" ++CFLAGS="$CFLAGS -D_GNU_SOURCE -Wall -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64" + AC_ARG_ENABLE([werror], + [AS_HELP_STRING([--enable-werror], [Treat all warnings as errors, useful for development])], + [enable_werror="$enableval"], diff --git a/sys-fs/quota/files/quota-4.03-explicitely_print_disabled_options.patch b/sys-fs/quota/files/quota-4.03-explicitely_print_disabled_options.patch new file mode 100644 index 000000000000..29627c03ab32 --- /dev/null +++ b/sys-fs/quota/files/quota-4.03-explicitely_print_disabled_options.patch @@ -0,0 +1,69 @@ +commit 6ccb66159a9eee6ca114b11b70eb06f4ac6900d7 +Author: Jan Kara <jack@suse.cz> +Date: Mon Jan 4 15:36:27 2016 +0100 + + Print explicitely disabled options properly + + Currently we printed only an empty string when some build option was + disabled explicitely via --disable-foo. Print 'no' in that case as well. + + Signed-off-by: Jan Kara <jack@suse.cz> + +diff --git a/configure.ac b/configure.ac +index 39631c4..3ba1386 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -74,7 +74,7 @@ AC_ARG_ENABLE([ldapmail], + AS_IF([test "x$enable_ldapmail" != "xno"], [ + build_ldap="yes" + AC_CHECK_LIB([ldap], [ldap_initialize], [], [ +- build_ldap=no ++ build_ldap="no" + AS_IF([test "x$enable_ldapmail" = "xyes"], [ + AC_MSG_ERROR([LDAP support required but library not found.]); + ]) +@@ -84,6 +84,8 @@ AS_IF([test "x$enable_ldapmail" != "xno"], [ + AC_DEFINE([USE_LDAP_MAIL_LOOKUP], 1, [Lookup email address using LDAP]) + COMPILE_OPTS="$COMPILE_OPTS USE_LDAP_MAIL_LOOKUP" + ]) ++], [ ++ build_ldap="no" + ]) + AC_SUBST(LDAP_LIBS) + +@@ -113,6 +115,8 @@ AS_IF([test "x$enable_ext2direct" != "xno"], [ + AC_DEFINE([EXT2_DIRECT], 1, [Scanning of ext? filesystems using e2fslib]) + COMPILE_OPTS="$COMPILE_OPTS EXT2_DIRECT" + ]) ++], [ ++ build_ext2direct="no" + ]) + AC_SUBST(EXT2FS_CFLAGS) + AC_SUBST(EXT2FS_LIBS) +@@ -141,6 +145,8 @@ AS_IF([test "x$enable_netlink" != "xno"], [ + AC_MSG_ERROR([Required libnl3 libraries for quota netlink daemon not found.]) + ]) + ]) ++], [ ++ build_netlink="no" + ]) + AM_CONDITIONAL([WITH_NETLINK], [test "x$build_netlink" != "xno"]) + AC_SUBST(DBUS_CFLAGS) +@@ -171,6 +177,8 @@ AS_IF([test "x$enable_libwrap" != "xno"], [ + AC_DEFINE([HOSTS_ACCESS], 1, [Use hosts.allow and hosts.deny for access checking of rpc.rquotad]) + COMPILE_OPTS="$COMPILE_OPTS HOSTS_ACCESS" + ]) ++], [ ++ build_libwrap="no" + ]) + AC_SUBST(WRAP_LIBS) + +@@ -199,6 +207,8 @@ AS_IF([test x"$enable_rpc" != "xno"], [ + AC_DEFINE([RPC], 1, [Support for RPC]) + COMPILE_OPTS="$COMPILE_OPTS RPC" + ]) ++], [ ++ build_rpc="no" + ]) + AM_CONDITIONAL([WITH_RPC], [test x"$build_rpc" != "xno"]) + diff --git a/sys-fs/quota/files/quota-4.03-fix_build_without_ldap.patch b/sys-fs/quota/files/quota-4.03-fix_build_without_ldap.patch new file mode 100644 index 000000000000..ba838bfe2838 --- /dev/null +++ b/sys-fs/quota/files/quota-4.03-fix_build_without_ldap.patch @@ -0,0 +1,85 @@ +commit 39fd30ce57e3c34c3649866bf9345a71f0b78667 +Author: Jan Kara <jack@suse.cz> +Date: Mon Jan 4 15:10:53 2016 +0100 + + Fix build with disabled ldap + + Reported-by: Tomas Chvatal <tchvatal@suse.com> + Signed-off-by: Jan Kara <jack@suse.cz> + +diff --git a/warnquota.c b/warnquota.c +index 3734f0e..e9868c1 100644 +--- a/warnquota.c ++++ b/warnquota.c +@@ -109,13 +109,13 @@ struct configparams { + char *user_signature; + char *group_message; + char *group_signature; ++ time_t cc_before; ++#ifdef USE_LDAP_MAIL_LOOKUP + int use_ldap_mail; /* 0 */ ++ int ldap_is_setup; /* 0 */ + int ldap_starttls; /* 0 */ + int ldap_tls; /* LDAP_OPT_X_TLS_NEVER */ + int ldap_vers; /* LDAP_VERSION3 */ +- time_t cc_before; +-#ifdef USE_LDAP_MAIL_LOOKUP +- int ldap_is_setup; /* 0 */ + char ldap_host[CNF_BUFFER]; + int ldap_port; + char ldap_uri[CNF_BUFFER]; +@@ -729,13 +729,13 @@ static int readconfigfile(const char *filename, struct configparams *config) + } + maildev[0] = 0; + config->user_signature = config->user_message = config->group_signature = config->group_message = NULL; ++ config->cc_before = -1; ++ ++#ifdef USE_LDAP_MAIL_LOOKUP + config->use_ldap_mail = 0; + config->ldap_starttls = 0; + config->ldap_tls = LDAP_OPT_X_TLS_NEVER; + config->ldap_vers = LDAP_VERSION3; +- config->cc_before = -1; +- +-#ifdef USE_LDAP_MAIL_LOOKUP + config->ldap_port = config->ldap_is_setup = 0; + config->ldap_host[0] = 0; + config->ldap_uri[0] = 0; +@@ -820,6 +820,18 @@ static int readconfigfile(const char *filename, struct configparams *config) + create_eoln(config->group_signature); + verify_format(config->group_signature, "GROUP_SIGNATURE"); + } ++ else if (!strcmp(var, "CC_BEFORE")) { ++ int num; ++ char unit[10]; ++ ++ if (sscanf(value, "%d%s", &num, unit) != 2) ++ goto cc_parse_err; ++ if (str2timeunits(num, unit, &config->cc_before) < 0) { ++cc_parse_err: ++ die(1, _("Cannot parse time at CC_BEFORE variable (line %d).\n"), line); ++ } ++ } ++#ifdef USE_LDAP_MAIL_LOOKUP + else if (!strcmp(var, "LDAP_MAIL")) { + if(strcasecmp(value, "true") == 0) + config->use_ldap_mail = 1; +@@ -846,18 +858,6 @@ static int readconfigfile(const char *filename, struct configparams *config) + else + config->ldap_starttls = 0; + } +- else if (!strcmp(var, "CC_BEFORE")) { +- int num; +- char unit[10]; +- +- if (sscanf(value, "%d%s", &num, unit) != 2) +- goto cc_parse_err; +- if (str2timeunits(num, unit, &config->cc_before) < 0) { +-cc_parse_err: +- die(1, _("Cannot parse time at CC_BEFORE variable (line %d).\n"), line); +- } +- } +-#ifdef USE_LDAP_MAIL_LOOKUP + else if (!strcmp(var, "LDAP_HOST")) + sstrncpy(config->ldap_host, value, CNF_BUFFER); + else if (!strcmp(var, "LDAP_PORT")) diff --git a/sys-fs/quota/files/quota-4.03-no_rpc.patch b/sys-fs/quota/files/quota-4.03-no_rpc.patch new file mode 100644 index 000000000000..c4f5007fca5d --- /dev/null +++ b/sys-fs/quota/files/quota-4.03-no_rpc.patch @@ -0,0 +1,57 @@ +From 07ec5c783ac16ed20735d6cb8ab167833f5877ee Mon Sep 17 00:00:00 2001 +From: Lars Wendler <polynomial-c@gentoo.org> +Date: Mon, 15 Feb 2016 14:36:28 +0100 +Subject: [PATCH] Don't build rpc.rquotad when --disable-rpc was requested. + +This fixes a buch of undefined references: + +x86_64-pc-linux-gnu-gcc -march=native -mtune=native -O2 -pipe -D_GNU_SOURCE -Wa +ll -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 -fPIC -pie -Wl,-O1 -Wl,--hash-st +yle=gnu -Wl,--sort-common -Wl,--as-needed -o rpc.rquotad rquota_server.o rquota_ +svc.o svc_socket.o libquota.a +rquota_svc.o: In function `rquotaprog_2': +rquota_svc.c:(.text+0x1d3): undefined reference to `xdr_setquota_rslt' +rquota_svc.c:(.text+0x1da): undefined reference to `xdr_ext_setquota_args' +rquota_svc.c:(.text+0x2b2): undefined reference to `xdr_setquota_rslt' +rquota_svc.c:(.text+0x2b9): undefined reference to `xdr_ext_setquota_args' +rquota_svc.c:(.text+0x2ff): undefined reference to `xdr_getquota_rslt' +rquota_svc.c:(.text+0x306): undefined reference to `xdr_ext_getquota_args' +rquota_svc.c:(.text+0x31a): undefined reference to `xdr_getquota_rslt' +rquota_svc.c:(.text+0x321): undefined reference to `xdr_ext_getquota_args' +rquota_svc.o: In function `rquotaprog_1': +rquota_svc.c:(.text+0x3f3): undefined reference to `xdr_setquota_rslt' +rquota_svc.c:(.text+0x3fa): undefined reference to `xdr_setquota_args' +rquota_svc.c:(.text+0x4d2): undefined reference to `xdr_setquota_rslt' +rquota_svc.c:(.text+0x4d9): undefined reference to `xdr_setquota_args' +rquota_svc.c:(.text+0x51f): undefined reference to `xdr_getquota_rslt' +rquota_svc.c:(.text+0x526): undefined reference to `xdr_getquota_args' +rquota_svc.c:(.text+0x53a): undefined reference to `xdr_getquota_rslt' +rquota_svc.c:(.text+0x541): undefined reference to `xdr_getquota_args' +collect2: error: ld returned 1 exit status +Makefile:901: recipe for target 'rpc.rquotad' failed + +Signed-off-by: Lars Wendler <polynomial-c@gentoo.org> +--- + Makefile.am | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +diff --git a/Makefile.am b/Makefile.am +index 77f8400..6d7ea0e 100644 +--- a/Makefile.am ++++ b/Makefile.am +@@ -116,8 +116,11 @@ sbin_PROGRAMS = \ + xqmstats \ + edquota \ + setquota \ +- convertquota \ ++ convertquota ++if WITH_RPC ++sbin_PROGRAMS += \ + rpc.rquotad ++endif + if WITH_NETLINK + sbin_PROGRAMS += \ + quota_nld +-- +2.7.1 + diff --git a/sys-fs/quota/files/quota-4.03-noldap_linking.patch b/sys-fs/quota/files/quota-4.03-noldap_linking.patch new file mode 100644 index 000000000000..dbaca69bb7d3 --- /dev/null +++ b/sys-fs/quota/files/quota-4.03-noldap_linking.patch @@ -0,0 +1,75 @@ +commit 1d9542df5d2ae5c21a1e96d100f899b3d7b2f27c +Author: Jan Kara <jack@suse.cz> +Date: Tue Jan 19 11:40:15 2016 +0100 + + Don't link all binaries with ldap library + + The default action-if-found of AC_CHECK_LIB() is to append checked + library to LIBS. Thus check for ldap library resulted in unwanted + addition of -lldap to LIBS as [] is an empty string in M4 and the + default action is used. + + Fix the problem by providing proper action-if-found which was currently + just hidden behind the check. Also do similar cleanup for + AC_CHECK_HEADER check although there it didn't have any undesired + side-effect. + + Reported-by: Petr Písař <petrp@users.sf.net> + Signed-off-by: Jan Kara <jack@suse.cz> + +diff --git a/configure.ac b/configure.ac +index 68d5924..d17b18c 100644 +--- a/configure.ac ++++ b/configure.ac +@@ -72,18 +72,17 @@ AC_ARG_ENABLE([ldapmail], + [enable_ldapmail=auto] + ) + AS_IF([test "x$enable_ldapmail" != "xno"], [ +- build_ldap="yes" +- AC_CHECK_LIB([ldap], [ldap_initialize], [], [ ++ AC_CHECK_LIB([ldap], [ldap_initialize], [ ++ build_ldap="yes" ++ LDAP_LIBS="-lldap -llber" ++ AC_DEFINE([USE_LDAP_MAIL_LOOKUP], 1, [Lookup email address using LDAP]) ++ COMPILE_OPTS="$COMPILE_OPTS USE_LDAP_MAIL_LOOKUP" ++ ], [ + build_ldap="no" + AS_IF([test "x$enable_ldapmail" = "xyes"], [ + AC_MSG_ERROR([LDAP support required but library not found.]); + ]) + ]) +- AS_IF([test "x$build_ldap" = "xyes"], [ +- LDAP_LIBS="-lldap -llber" +- AC_DEFINE([USE_LDAP_MAIL_LOOKUP], 1, [Lookup email address using LDAP]) +- COMPILE_OPTS="$COMPILE_OPTS USE_LDAP_MAIL_LOOKUP" +- ]) + ], [ + build_ldap="no" + ]) +@@ -163,8 +162,12 @@ AC_ARG_ENABLE([libwrap], + [enable_libwrap=auto] + ) + AS_IF([test "x$enable_libwrap" != "xno"], [ +- build_libwrap="yes" +- AC_CHECK_HEADER([tcpd.h],[], [ ++ AC_CHECK_HEADER([tcpd.h], [ ++ build_libwrap="yes" ++ WRAP_LIBS="-lwrap" ++ AC_DEFINE([HOSTS_ACCESS], 1, [Use hosts.allow and hosts.deny for access checking of rpc.rquotad]) ++ COMPILE_OPTS="$COMPILE_OPTS HOSTS_ACCESS" ++ ], [ + build_libwrap="no" + AS_IF([test "x$enable_libwrap" = "xyes"] , [ + AC_MSG_ERROR([tcpd.h not found and requested]) +@@ -172,11 +175,6 @@ AS_IF([test "x$enable_libwrap" != "xno"], [ + AC_MSG_WARN([tcpd.h not found]) + ]) + ]) +- AS_IF([test "x$build_libwrap" != "xno"], [ +- WRAP_LIBS="-lwrap" +- AC_DEFINE([HOSTS_ACCESS], 1, [Use hosts.allow and hosts.deny for access checking of rpc.rquotad]) +- COMPILE_OPTS="$COMPILE_OPTS HOSTS_ACCESS" +- ]) + ], [ + build_libwrap="no" + ]) diff --git a/sys-fs/quota/files/quota-4.03-repqouta_F_option_arg.patch b/sys-fs/quota/files/quota-4.03-repqouta_F_option_arg.patch new file mode 100644 index 000000000000..d4fffd4f03fa --- /dev/null +++ b/sys-fs/quota/files/quota-4.03-repqouta_F_option_arg.patch @@ -0,0 +1,27 @@ +commit ab2bf5b51a1ca14cef63e8a7a88b039f173a210a +Author: Eric Sandeen <sandeen@redhat.com> +Date: Mon Jan 18 20:11:01 2016 -0600 + + repquota: -F option takes an arg + + Commit a5876145 added a new -O option which takes an + argument, but in the process lost the argument specifier + for "F". As a result, the use of "-F" segfaults when NULL + is sent to name2fmt() instead of the provided argument. + + Signed-off-by: Eric Sandeen <sandeen@redhat.com> + Signed-off-by: Jan Kara <jack@suse.cz> + +diff --git a/repquota.c b/repquota.c +index 744af70..6fe9f0c 100644 +--- a/repquota.c ++++ b/repquota.c +@@ -90,7 +90,7 @@ static void parse_options(int argcnt, char **argstr) + { NULL, 0, NULL, 0 } + }; + +- while ((ret = getopt_long(argcnt, argstr, "VavughtspncCiFO:", long_opts, NULL)) != -1) { ++ while ((ret = getopt_long(argcnt, argstr, "VavughtspncCiF:O:", long_opts, NULL)) != -1) { + switch (ret) { + case '?': + case 'h': diff --git a/sys-fs/quota/files/quota-4.03-respect_docdir.patch b/sys-fs/quota/files/quota-4.03-respect_docdir.patch new file mode 100644 index 000000000000..214b3ad1f17a --- /dev/null +++ b/sys-fs/quota/files/quota-4.03-respect_docdir.patch @@ -0,0 +1,21 @@ +commit cac9a60c29106763cc6abd6f372f25f97d4122a3 +Author: Tomáš Chvátal <tchvatal@suse.com> +Date: Mon Jan 4 15:26:36 2016 +0100 + + Respect the docdir declaration and do not override. + + Signed-off-by: Tomáš Chvátal <tchvatal@suse.com> + Signed-off-by: Jan Kara <jack@suse.cz> + +diff --git a/Makefile.am b/Makefile.am +index a880ebe..7c7a866 100644 +--- a/Makefile.am ++++ b/Makefile.am +@@ -2,7 +2,6 @@ ACLOCAL_AMFLAGS = -I m4 + + BUILT_SOURCES = rquota.h rquota.c rquota_clnt.c + +-docdir = $(datadir)/doc/@PACKAGE@ + doc_DATA = \ + README.mailserver \ + README.ldap-support \ diff --git a/sys-fs/quota/files/quota-4.04-glibc226.patch b/sys-fs/quota/files/quota-4.04-glibc226.patch new file mode 100644 index 000000000000..5f63cde7d426 --- /dev/null +++ b/sys-fs/quota/files/quota-4.04-glibc226.patch @@ -0,0 +1,43 @@ +From bbb8819fc0f6ed379a05d635a61bcf9c8986079f Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Andreas=20K=2E=20H=C3=BCttel?= <dilfridge@gentoo.org> +Date: Sat, 16 Sep 2017 13:09:43 +0200 +Subject: [PATCH] Add $(TIRPC_CFLAGS) globally to CFLAGS for RPC support, + needed for libc 2.26 + +--- + Makefile.am | 5 ++--- + 1 file changed, 2 insertions(+), 3 deletions(-) + +diff --git a/Makefile.am b/Makefile.am +index 8d80bee..278290a 100644 +--- a/Makefile.am ++++ b/Makefile.am +@@ -51,6 +51,8 @@ EXTRA_DIST = \ + noinst_LIBRARIES = libquota.a + + if WITH_RPC ++CFLAGS += $(TIRPC_CFLAGS) ++ + rpcsvcdir = $(includedir)/rpcsvc + rpcsvc_DATA = \ + rquota.h \ +@@ -100,8 +102,6 @@ libquota_a_SOURCES = \ + mntopt.h \ + pot.c \ + pot.h +-libquota_a_CFLAGS = \ +- $(TIRPC_CFLAGS) + libquota_a_LIBADD = \ + $(RPCLIBS) + +@@ -235,7 +235,6 @@ rpc_rquotad_SOURCES = \ + rquota_server.c \ + rquota_svc.c \ + svc_socket.c +-rpc_rquotad_CFLAGS = $(TIRPC_CFLAGS) + rpc_rquotad_LDADD = \ + libquota.a \ + $(WRAP_LIBS) \ +-- +2.14.1 + diff --git a/sys-fs/quota/files/quota.confd b/sys-fs/quota/files/quota.confd new file mode 100644 index 000000000000..6e66c88dda14 --- /dev/null +++ b/sys-fs/quota/files/quota.confd @@ -0,0 +1,20 @@ +# /etc/conf.d/quota: config file for /etc/init.d/quota + +# Note: if your console is hooked up to a serial terminal, +# you prob want to drop the '-v' from the OPTS vars below. + + +# Run quotacheck ? +RUN_QUOTACHECK="yes" + + +# Options for quotacheck +QUOTACHECK_OPTS="-avug" + + +# Options for quotaon +QUOTAON_OPTS="-avug" + + +# Options for quotaoff +QUOTAOFF_OPTS="-avug" diff --git a/sys-fs/quota/files/quota.rc7 b/sys-fs/quota/files/quota.rc7 new file mode 100644 index 000000000000..bfc06232e992 --- /dev/null +++ b/sys-fs/quota/files/quota.rc7 @@ -0,0 +1,37 @@ +#!/sbin/openrc-run +# Copyright 1999-2012 Gentoo Foundation +# Distributed under the terms of the GNU General Public License, v2 + +extra_started_commands="check" +description_check="Running quotacheck with quota being offline" + +depend() { + need localmount + use portmap +} + +start() { + if [ "${RUN_QUOTACHECK}" = "yes" ] ; then + ebegin "Checking quotas (may take a while)" + quotacheck ${QUOTACHECK_OPTS} + eend $? + fi + + ebegin "Starting quota" + quotaon ${QUOTAON_OPTS} + eend $? +} + +stop() { + ebegin "Stopping quota" + quotaoff ${QUOTAOFF_OPTS} + eend $? +} + +check() { + ebegin "Checking quota" + quotaoff ${QUOTAOFF_OPTS} && \ + quotacheck ${QUOTACHECK_OPTS} && \ + quotaon ${QUOTAON_OPTS} + eend $? +} diff --git a/sys-fs/quota/files/rpc.rquotad.initd b/sys-fs/quota/files/rpc.rquotad.initd new file mode 100644 index 000000000000..528e46bf6bfa --- /dev/null +++ b/sys-fs/quota/files/rpc.rquotad.initd @@ -0,0 +1,25 @@ +#!/sbin/openrc-run +# Copyright 1999-2007 Gentoo Foundation +# Distributed under the terms of the GNU General Public License v2 + +[ -e /etc/conf.d/nfs ] && . /etc/conf.d/nfs + +rpc_bin=/usr/sbin/rpc.rquotad + +depend() { + use ypbind net + need portmap + after quota +} + +start() { + ebegin "Starting rpc.rquotad" + ${rpc_bin} ${OPTS_RPC_RQUOTAD} + eend $? +} + +stop() { + ebegin "Stopping rpc.rquotad" + start-stop-daemon --stop --quiet --exec ${rpc_bin} + eend $? +} |