commit 34566f3278a6f2dedebbb4d20b24abacb41bffa3 Author: overweight <5324761+overweight@user.noreply.gitee.com> Date: Mon Sep 30 11:16:07 2019 -0400 Package init diff --git a/0000-quota-4.04-warnquota-configuration-tunes.patch b/0000-quota-4.04-warnquota-configuration-tunes.patch new file mode 100644 index 0000000..9030e2e --- /dev/null +++ b/0000-quota-4.04-warnquota-configuration-tunes.patch @@ -0,0 +1,76 @@ +From 67a0dbf6434552e720b0d311597553b3a76f779e Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= +Date: Tue, 23 Aug 2011 13:45:15 +0200 +Subject: [PATCH] warnquota configuration tunes +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Rest of changes (378a64006bb1e818e84a1c77808563b802b028fa) not +accepted by upstream (we had root@... addresses and more enterprise +wordings usually there). + +Signed-off-by: Petr Písař +--- + warnquota.c | 2 +- + warnquota.conf | 17 ++++++++--------- + 2 files changed, 9 insertions(+), 10 deletions(-) + +diff --git a/warnquota.c b/warnquota.c +index 0d911e4..2c8e084 100644 +--- a/warnquota.c ++++ b/warnquota.c +@@ -837,7 +837,7 @@ cc_parse_err: + } + #ifdef USE_LDAP_MAIL_LOOKUP + else if (!strcmp(var, "LDAP_MAIL")) { +- if(strcasecmp(value, "true") == 0) ++ if(strncasecmp(value, "true", 4) == 0) + config->use_ldap_mail = 1; + else + config->use_ldap_mail = 0; +diff --git a/warnquota.conf b/warnquota.conf +index b06f81f..7e00947 100644 +--- a/warnquota.conf ++++ b/warnquota.conf +@@ -4,17 +4,16 @@ + # and even blank lines + + # values can be quoted: +-#MAIL_CMD = "/usr/my/sendmail/instead/sendmail -t" +-MAIL_CMD = "/bin/echo" +-FROM = "bas@example.com" ++MAIL_CMD = "/usr/sbin/sendmail -t" ++FROM = "root@example.com" + # but they don't have to be: +-SUBJECT = Hey, user, clean up your account! +-CC_TO = "sysadm@example.com" ++SUBJECT = NOTE: You are exceeding your allocated disk space limits ++CC_TO = "root@example.com" + # If you set this variable CC will be used only when user has less than + # specified grace time left (examples of possible times: 5 seconds, 1 minute, + # 12 hours, 5 days) + # CC_BEFORE = 2 days +-SUPPORT = "support@example.com" ++SUPPORT = "root@example.com" + PHONE = "(123) 456-1111 or (222) 333-4444" + # Text in the beginning of the mail (if not specified, default text is used) + # This way text can be split to more lines +@@ -22,11 +21,11 @@ PHONE = "(123) 456-1111 or (222) 333-4444" + # The expressions %i, %h, %d, and %% are substituted for user/group name, + # host name, domain name, and '%' respectively. For backward compatibility + # %s behaves as %i but is deprecated. +-MESSAGE = Hello user %i, I've noticed you use too much space\ +- on my disk in %h.%d.|Delete your files on the following filesystems:| ++MESSAGE = Your disk usage has exceeded the agreed limits\ ++ on this server|Please delete any unnecessary files on following filesystems:| + # Text in the end of the mail (if not specified, default text using SUPPORT and PHONE + # is created) +-SIGNATURE = See you!| Your admin of %h| ++SIGNATURE = root@example.com + # Following text is used for mails about group exceeding quotas + GROUP_MESSAGE = Hello,|\ + your group %i is using too much disk space at %h.|\ +-- +2.13.5 + diff --git a/0001-quota-4.03-Validate-upper-bound-of-RPC-port.patch b/0001-quota-4.03-Validate-upper-bound-of-RPC-port.patch new file mode 100644 index 0000000..aa0d12b --- /dev/null +++ b/0001-quota-4.03-Validate-upper-bound-of-RPC-port.patch @@ -0,0 +1,29 @@ +From c9a2a6fea0668579f5fb8d77cb219f51d104581f Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= +Date: Wed, 6 Jan 2016 17:58:22 +0100 +Subject: [PATCH] Validate upper bound of RPC port +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Signed-off-by: Petr Písař +--- + rquota_svc.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/rquota_svc.c b/rquota_svc.c +index 338b70f..93472e0 100644 +--- a/rquota_svc.c ++++ b/rquota_svc.c +@@ -142,7 +142,7 @@ static void parse_options(int argc, char **argv) + break; + case 'p': + port = strtol(optarg, &endptr, 0); +- if (*endptr || port <= 0) { ++ if (*endptr || port <= 0 || port > 0xffff) { + errstr(_("Illegal port number: %s\n"), optarg); + show_help(); + exit(1); +-- +2.5.0 + diff --git a/0002-quota-4.04-Install-rquota-3-only-if-RPC-is-enabled.patch b/0002-quota-4.04-Install-rquota-3-only-if-RPC-is-enabled.patch new file mode 100644 index 0000000..a35bf5f --- /dev/null +++ b/0002-quota-4.04-Install-rquota-3-only-if-RPC-is-enabled.patch @@ -0,0 +1,44 @@ +From b5ed9878d60bf2c6764ce8e1de4f69e64c4bdfaf Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= +Date: Wed, 6 Sep 2017 16:25:09 +0200 +Subject: [PATCH] Install rquota(3) only if RPC is enabled +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +rquote(3) documents rpcsvc header files. Thus it should be installed +only if the the header files are installed and that is only if RPC +configure feature is enabled. + +Signed-off-by: Petr Písař +--- + Makefile.am | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +diff --git a/Makefile.am b/Makefile.am +index 8d80bee..9b852d2 100644 +--- a/Makefile.am ++++ b/Makefile.am +@@ -27,7 +27,6 @@ man_MANS = \ + quota.1 \ + quot.8 \ + repquota.8 \ +- rquota.3 \ + setquota.8 \ + warnquota.conf.5 \ + warnquota.8 \ +@@ -69,7 +68,10 @@ librpcclient_a_CFLAGS = -Wno-unused + RPCLIBS = librpcclient.a + BUILT_SOURCES = rquota.h rquota.c rquota_clnt.c + CLEANFILES = rquota.c rquota.h rquota_clnt.c +-man_MANS += rpc.rquotad.8 ++man_MANS += \ ++ rpc.rquotad.8 \ ++ rquota.3 ++ + endif + + libquota_a_SOURCES = \ +-- +2.13.5 + diff --git a/0003-quota-4.04-Add-TIRPC_CFLAGS-globally-to-CFLAGS-for-RPC-support-.patch b/0003-quota-4.04-Add-TIRPC_CFLAGS-globally-to-CFLAGS-for-RPC-support-.patch new file mode 100644 index 0000000..5f63cde --- /dev/null +++ b/0003-quota-4.04-Add-TIRPC_CFLAGS-globally-to-CFLAGS-for-RPC-support-.patch @@ -0,0 +1,43 @@ +From bbb8819fc0f6ed379a05d635a61bcf9c8986079f Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Andreas=20K=2E=20H=C3=BCttel?= +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/0004-quota-4.04-repquota-Fix-output-when-user-2-exists.patch b/0004-quota-4.04-repquota-Fix-output-when-user-2-exists.patch new file mode 100644 index 0000000..285c5d1 --- /dev/null +++ b/0004-quota-4.04-repquota-Fix-output-when-user-2-exists.patch @@ -0,0 +1,59 @@ +From 1806ee01060d363beac01fda28c613ab27dbc4df Mon Sep 17 00:00:00 2001 +From: Jan Kara +Date: Wed, 10 Jan 2018 10:18:43 +0100 +Subject: [PATCH] repquota: Fix output when user -2 exists +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Vladimit Meshkov reported that when user -2 exists and user namespaces +are enabled in the kernel, repquota(8) fails to output anything. He also +analyzed this is because in such case repquota(8) tries to query info +for user -1 which is invalid ID, gets error from the kernel, and bails +out. + +Fix the problem by stopping iteration over IDs when we reach ID -1. + +Reported-by: Vladimir Meshkov +Signed-off-by: Jan Kara +Signed-off-by: Petr Písař +--- + quotaio_generic.c | 5 +++++ + quotaio_xfs.c | 5 +++++ + 2 files changed, 10 insertions(+) + +diff --git a/quotaio_generic.c b/quotaio_generic.c +index 025d712..5b23955 100644 +--- a/quotaio_generic.c ++++ b/quotaio_generic.c +@@ -204,6 +204,11 @@ int vfs_scan_dquots(struct quota_handle *h, + if (ret < 0) + break; + id = kdqblk.dqb_id + 1; ++ /* id -1 is invalid and the last one... */ ++ if (id == -1) { ++ errno = ENOENT; ++ break; ++ } + } + free(dquot); + +diff --git a/quotaio_xfs.c b/quotaio_xfs.c +index 1374cf4..56daf89 100644 +--- a/quotaio_xfs.c ++++ b/quotaio_xfs.c +@@ -219,6 +219,11 @@ static int xfs_kernel_scan_dquots(struct quota_handle *h, + if (ret < 0) + break; + id = xdqblk.d_id + 1; ++ /* id -1 is invalid and the last one... */ ++ if (id == -1) { ++ errno = ENOENT; ++ break; ++ } + } + free(dquot); + +-- +2.13.6 + diff --git a/0005-quota-4.04-warnquota-Check-snprintf-for-overflows.patch b/0005-quota-4.04-warnquota-Check-snprintf-for-overflows.patch new file mode 100644 index 0000000..e59c687 --- /dev/null +++ b/0005-quota-4.04-warnquota-Check-snprintf-for-overflows.patch @@ -0,0 +1,76 @@ +From eeef53917864600e0f5ac42ce5c3d884967012a1 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= +Date: Mon, 5 Feb 2018 10:31:47 +0100 +Subject: [PATCH 1/2] warnquota: Check snprintf() for overflows +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +GCC 8 with GNU libc 2.27 prerelease warns: + +gcc -DHAVE_CONFIG_H -I. -g -O2 -Wall -fPIC -I/usr/include/tirpc -c -o warnquota.o warnquota.c +warnquota.c: In function ‘lookup_user’: +warnquota.c:415:29: warning: ‘%s’ directive output may be truncated writing up to 2047 bytes into a region of size 255 [-Wformat-truncation=] + snprintf(searchbuf, 256, "(%s=%s)", config->ldap_search_attr, user); + ^~ +warnquota.c:415:2: note: ‘snprintf’ output 4 or more bytes (assuming 2051) into a destination of size 256 + snprintf(searchbuf, 256, "(%s=%s)", config->ldap_search_attr, user); + ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +warnquota.c: In function ‘warn_quota’: +warnquota.c:896:51: warning: ‘%s’ directive output may be truncated writing up to 2047 bytes into a region of size 2041 [-Wformat-truncation=] + snprintf(config->ldap_uri, CNF_BUFFER, "ldap://%s:%d", config->ldap_host, config->ldap_port); + ^~ ~~~~~~~~~~~~~~~~~ +warnquota.c:896:4: note: ‘snprintf’ output between 10 and 2067 bytes into a destination of size 2048 + snprintf(config->ldap_uri, CNF_BUFFER, "ldap://%s:%d", config->ldap_host, config->ldap_port); + ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +This is patch fixes it by catching the cases when snprintf() truncates and +reporting an error. + +Perfect fix would fall back into dynamically allocated buffers but +I think that would make these corner case too complicated provided +nobody had yet complained about them. + +Signed-off-by: Petr Písař +--- + warnquota.c | 17 +++++++++++++++-- + 1 file changed, 15 insertions(+), 2 deletions(-) + +diff --git a/warnquota.c b/warnquota.c +index 073c45e..bc11055 100644 +--- a/warnquota.c ++++ b/warnquota.c +@@ -412,7 +412,13 @@ static char *lookup_user(struct configparams *config, char *user) + } + + /* search for the offender_name in ldap */ +- snprintf(searchbuf, 256, "(%s=%s)", config->ldap_search_attr, user); ++ if (256 <= snprintf(searchbuf, 256, "(%s=%s)", config->ldap_search_attr, ++ user)) { ++ errstr(_("Could not format LDAP search filter for %s user and " ++ "%s search attribute due to excessive length.\n"), ++ user, config->ldap_search_attr); ++ return NULL; ++ } + ret = ldap_search_ext_s(ldapconn, + config->ldap_basedn, LDAP_SCOPE_SUBTREE, + searchbuf, NULL, 0, NULL, NULL, NULL, +@@ -893,7 +899,14 @@ cc_parse_err: + if (config->use_ldap_mail) + { + if (!config->ldap_uri[0]) { +- snprintf(config->ldap_uri, CNF_BUFFER, "ldap://%s:%d", config->ldap_host, config->ldap_port); ++ if (CNF_BUFFER <= snprintf(config->ldap_uri, CNF_BUFFER, ++ "ldap://%s:%d", config->ldap_host, ++ config->ldap_port)) { ++ errstr(_("Could not format LDAP URI because " ++ "it's longer than %d bytes.\n"), ++ CNF_BUFFER); ++ return -1; ++ } + errstr(_("LDAP library version >= 2.3 detected. Please use LDAP_URI instead of hostname and port.\nGenerated URI %s\n"), config->ldap_uri); + } + } +-- +2.13.6 + diff --git a/0006-quota-4.04-warnquota-Fix-comparing-user-name-to-non-null-termin.patch b/0006-quota-4.04-warnquota-Fix-comparing-user-name-to-non-null-termin.patch new file mode 100644 index 0000000..27b22ef --- /dev/null +++ b/0006-quota-4.04-warnquota-Fix-comparing-user-name-to-non-null-termin.patch @@ -0,0 +1,74 @@ +From 59b280ebe22eceaf4250cb3b776674619a4d4ece Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= +Date: Mon, 5 Feb 2018 11:07:41 +0100 +Subject: [PATCH] warnquota: Fix comparing user name to non-null-terminated + utmp.ut_user +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +GCC 8 with GNU libc 2.27 warns: + +gcc -DHAVE_CONFIG_H -I. -I/usr/include/dbus-1.0 -I/usr/lib64/dbus-1.0/include -I/usr/include/libnl3 -g -O2 -Wall -fPIC -I/usr/include/tirpc -c -o quota_nld-quota_nld.o `test -f 'quota_nld.c' || echo './'`quota_nld.c +quota_nld.c: In function ‘write_console_warning’: +quota_nld.c:273:7: warning: ‘strcmp’ argument 2 declared attribute ‘nonstring’ [-Wstringop-overflow=] + if (strcmp(user, uent->ut_user)) + ^~~~~~~~~~~~~~~~~~~~~~~~~~~ +In file included from /usr/include/utmp.h:29, + from quota_nld.c:23: +/usr/include/bits/utmp.h:65:8: note: argument ‘ut_user’ declared here + char ut_user[UT_NAMESIZE] + ^~~~~~~ + +This is because ut_user value misses the terminating null byte if it +fits exactly into ut_user array, as document in utmp(5): + + String fields are terminated by a null byte ('\0') if they are + shorter than the size of the field. + +Recent GCC and glibc recevied compile-time checks and annotations +(__attribute_nonstring_) that catches these mistakes. + +This patch fixes it by using strncmp(3) and by ignoring user names +that does not fit into utmp log format. It's better not to warn than +spamming unrelated user. + +Signed-off-by: Petr Písař +Signed-off-by: Jan Kara +--- + quota_nld.c | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +diff --git a/quota_nld.c b/quota_nld.c +index ea541e0..8559f25 100644 +--- a/quota_nld.c ++++ b/quota_nld.c +@@ -262,6 +262,8 @@ static void write_console_warning(struct quota_warning *warn) + warn->warntype == QUOTA_NL_BSOFTBELOW) && !(flags & FL_PRINTBELOW)) + return; + uid2user(warn->caused_id, user); ++ if (strlen(user) > UT_NAMESIZE) ++ goto skip_utmp; + strcpy(dev, "/dev/"); + + setutent(); +@@ -270,7 +272,7 @@ static void write_console_warning(struct quota_warning *warn) + if (uent->ut_type != USER_PROCESS) + continue; + /* Entry for a different user? */ +- if (strcmp(user, uent->ut_user)) ++ if (strncmp(user, uent->ut_user, UT_NAMESIZE)) + continue; + sstrncpy(dev+5, uent->ut_line, PATH_MAX-5); + if (stat(dev, &st) < 0) +@@ -281,6 +283,7 @@ static void write_console_warning(struct quota_warning *warn) + } + } + if (!max_atime) { ++skip_utmp: + /* + * This can happen quite easily so don't spam syslog with + * the error +-- +2.13.6 + diff --git a/0007-quota-4.04-quotacheck-Avoid-question-in-non-interactive-mode.patch b/0007-quota-4.04-quotacheck-Avoid-question-in-non-interactive-mode.patch new file mode 100644 index 0000000..3ad605d --- /dev/null +++ b/0007-quota-4.04-quotacheck-Avoid-question-in-non-interactive-mode.patch @@ -0,0 +1,36 @@ +From 4179911dc38af1b6499704a7f7fb710a40c95bdb Mon Sep 17 00:00:00 2001 +From: Jan Kara +Date: Mon, 5 Feb 2018 15:39:12 +0100 +Subject: [PATCH] quotacheck: Avoid question in non-interactive mode +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +A question when quota file version is incorrect is asked even if +quotacheck is run in non-interactive mode. Avoid asking the question in +that case and fail the check instead. + +Reproted-by: Christoph Biedl +Signed-off-by: Jan Kara +Signed-off-by: Petr Písař +--- + quotacheck_v2.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/quotacheck_v2.c b/quotacheck_v2.c +index 4cc8558..86fbf42 100644 +--- a/quotacheck_v2.c ++++ b/quotacheck_v2.c +@@ -363,7 +363,8 @@ static int check_header(char *filename, int fd, int type, int version) + "specified on command line (%d). Quota file header " + "may be corrupted.\n"), + le32toh(head.dqh_version), version); +- if (!ask_yn(_("Continue checking assuming version from command line?"), 1)) ++ if (!(flags & FL_INTERACTIVE) || ++ !ask_yn(_("Continue checking assuming version from command line?"), 1)) + return -1; + detected_versions[type] = version; + } else +-- +2.13.6 + diff --git a/0008-quota-4.04-quotacheck-Report-error-when-caching-of-quota-file-f.patch b/0008-quota-4.04-quotacheck-Report-error-when-caching-of-quota-file-f.patch new file mode 100644 index 0000000..cc363db --- /dev/null +++ b/0008-quota-4.04-quotacheck-Report-error-when-caching-of-quota-file-f.patch @@ -0,0 +1,88 @@ +From 7b6dfd6390476ec7b811c76e4e2653db2994cad4 Mon Sep 17 00:00:00 2001 +From: Jan Kara +Date: Mon, 5 Feb 2018 15:54:54 +0100 +Subject: [PATCH] quotacheck: Report error when caching of quota file fails +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Currently quotacheck returns with zero exit code even though caching of +quota file fails. Fix it to return with non-zero exit code in that case +as expected. + +Reported-by: Christoph Biedl +Signed-off-by: Petr Písař +--- + quotacheck.c | 29 ++++++++++++++++++++++------- + 1 file changed, 22 insertions(+), 7 deletions(-) + +diff --git a/quotacheck.c b/quotacheck.c +index 9d7940b..b1302b6 100644 +--- a/quotacheck.c ++++ b/quotacheck.c +@@ -924,6 +924,7 @@ static int check_dir(struct mount_entry *mnt) + struct stat st; + int remounted = 0; + int failed = 0; ++ int ret; + + if (lstat(mnt->me_dir, &st) < 0) + die(2, _("Cannot stat mountpoint %s: %s\n"), mnt->me_dir, strerror(errno)); +@@ -939,14 +940,22 @@ static int check_dir(struct mount_entry *mnt) + */ + if (cfmt == QF_XFS) + goto start_scan; +- if (ucheck) +- if (process_file(mnt, USRQUOTA) < 0) ++ if (ucheck) { ++ ret = process_file(mnt, USRQUOTA); ++ if (ret < 0) { ++ failed |= ret; + ucheck = 0; +- if (gcheck) +- if (process_file(mnt, GRPQUOTA) < 0) ++ } ++ } ++ if (gcheck) { ++ ret = process_file(mnt, GRPQUOTA); ++ if (ret < 0) { ++ failed |= ret; + gcheck = 0; ++ } ++ } + if (!ucheck && !gcheck) /* Nothing to check? */ +- return 0; ++ return failed; + if (!(flags & FL_NOREMOUNT)) { + /* Now we try to remount fs read-only to prevent races when scanning filesystem */ + if (mount +@@ -978,8 +987,11 @@ start_scan: + !strcmp(mnt->me_type, MNTTYPE_EXT3) || + !strcmp(mnt->me_type, MNTTYPE_NEXT3) || + !strcmp(mnt->me_type, MNTTYPE_EXT4)) { +- if ((failed = ext2_direct_scan(mnt->me_devname)) < 0) ++ ret = ext2_direct_scan(mnt->me_devname); ++ if (ret < 0) { ++ failed |= ret; + goto out; ++ } + } + else { + #else +@@ -987,8 +999,11 @@ start_scan: + #endif + if (flags & FL_VERYVERBOSE) + putchar('\n'); +- if ((failed = scan_dir(mnt->me_dir)) < 0) ++ ret = scan_dir(mnt->me_dir); ++ if (ret < 0) { ++ failed |= ret; + goto out; ++ } + } + dirs_done++; + if (flags & FL_VERBOSE || flags & FL_DEBUG) +-- +2.13.6 + diff --git a/0009-quota-4.04-quotacheck-Fail-check-if-quota-file-magic-is-invalid.patch b/0009-quota-4.04-quotacheck-Fail-check-if-quota-file-magic-is-invalid.patch new file mode 100644 index 0000000..8d99cec --- /dev/null +++ b/0009-quota-4.04-quotacheck-Fail-check-if-quota-file-magic-is-invalid.patch @@ -0,0 +1,35 @@ +From b9525abadba082073e20e54ee7ad2423fc1ae6a8 Mon Sep 17 00:00:00 2001 +From: Jan Kara +Date: Mon, 5 Feb 2018 16:27:59 +0100 +Subject: [PATCH] quotacheck: Fail check if quota file magic is invalid +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Currently quotacheck will just continue if quotafile magic is invalid. +Instead ask whether we should continue assuming quota format passed from +the command line. + +Signed-off-by: Jan Kara +Signed-off-by: Petr Písař +--- + quotacheck_v2.c | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/quotacheck_v2.c b/quotacheck_v2.c +index 86fbf42..465765b 100644 +--- a/quotacheck_v2.c ++++ b/quotacheck_v2.c +@@ -357,6 +357,9 @@ static int check_header(char *filename, int fd, int type, int version) + le32toh(head.dqh_version) > known_versions[type]) { + errstr(_("WARNING - Quota file %s has corrupted headers\n"), + filename); ++ if (!(flags & FL_INTERACTIVE) || ++ !ask_yn(_("Continue checking assuming format from command line?"), 0)) ++ return -1; + } + if (le32toh(head.dqh_version) != version) { + errstr(_("Quota file format version %d does not match the one " +-- +2.13.6 + diff --git a/0010-quota-4.04-Listen-on-a-TCP-socket.patch b/0010-quota-4.04-Listen-on-a-TCP-socket.patch new file mode 100644 index 0000000..cf1bd4a --- /dev/null +++ b/0010-quota-4.04-Listen-on-a-TCP-socket.patch @@ -0,0 +1,77 @@ +From 31ecd29b3b3f51145fd78f63087c10e9fcadf999 Mon Sep 17 00:00:00 2001 +From: Steve Dickson +Date: Tue, 22 May 2018 12:41:59 +0200 +Subject: [PATCH] Listen on a TCP socket +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +rpc.rquotad spins in libtirpc's rendezvous_request() on accepting TCP +connections because the polled TCP socket is not listening: + +poll([{fd=4, events=POLLIN|POLLPRI|POLLRDNORM|POLLRDBAND}, {fd=5, + events=POLLIN|POLLPRI|POLLRDNORM|POLLRDBAND}, {fd=6, + events=POLLIN|POLLPRI|POLLRDNORM|POLLRDBAND}, {fd=7, + events=POLLIN|POLLPRI|POLLRDNORM|POLLRDBAND}], 4, -1) = 2 ([{fd=5, + revents=POLLHUP}, {fd=7, revents=POLLHUP}]) +accept(5, 0x7ffe61698700, [128]) = -1 EINVAL (Invalid argument) +accept(7, 0x7ffe61698700, [128]) = -1 EINVAL (Invalid argument) + +The polled descriptors are: + +rpc.rquot 21981 root 4u IPv4 80449159 0t0 UDP *:rquotad +rpc.rquot 21981 root 5u sock 0,9 0t0 80449162 protocol: TCP +rpc.rquot 21981 root 6u IPv6 80449165 0t0 UDP *:rquotad +rpc.rquot 21981 root 7u sock 0,9 0t0 80449168 protocol: TCPv6 + +That results into a high CPU usage just after staring rpc.rquotad +process. + +This patch adds a listen() call to svc_create_sock() +routine which is needed with libtirpc version of svc_tli_create() +as well as a needed IPv6 setsockopt(). + +Signed-off-by: Petr Písař +--- + svc_socket.c | 18 ++++++++++++++++++ + 1 file changed, 18 insertions(+) + +diff --git a/svc_socket.c b/svc_socket.c +index 8a44604..d2e3abf 100644 +--- a/svc_socket.c ++++ b/svc_socket.c +@@ -118,6 +118,15 @@ static int svc_create_sock(struct addrinfo *ai) + return -1; + } + ++ if (ai->ai_family == AF_INET6) { ++ if (setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY, ++ &optval, sizeof(optval)) < 0) { ++ errstr(_("Cannot set IPv6 socket options: %s\n"), strerror(errno)); ++ close(fd); ++ return -1; ++ } ++ } ++ + if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof(optval)) < 0) { + errstr(_("Cannot set socket options: %s\n"), strerror(errno)); + close(fd); +@@ -129,6 +138,15 @@ static int svc_create_sock(struct addrinfo *ai) + close(fd); + return -1; + } ++ ++ if (ai->ai_protocol == IPPROTO_TCP) { ++ if (listen(fd, SOMAXCONN) < 0) { ++ errstr(_("Cannot listen to address: %s\n"), strerror(errno)); ++ close(fd); ++ return -1; ++ } ++ } ++ + return fd; + } + +-- +2.14.3 + diff --git a/0011-quota-4.04-rpc-Fix-wrong-limit-for-space-usage.patch b/0011-quota-4.04-rpc-Fix-wrong-limit-for-space-usage.patch new file mode 100644 index 0000000..5d4ed11 --- /dev/null +++ b/0011-quota-4.04-rpc-Fix-wrong-limit-for-space-usage.patch @@ -0,0 +1,35 @@ +From d7694c952073bf2ebb852014d9f979b5e3e7c018 Mon Sep 17 00:00:00 2001 +From: Jan Kara +Date: Mon, 28 May 2018 18:08:24 +0200 +Subject: [PATCH] rpc: Fix wrong limit for space usage +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Limit of maximum allowable space usage for RPC transfer was wrongly set +to ~4GB instead of ~4TB due to overflow in constant initialization. Fix +it. + +Signed-off-by: Jan Kara +Signed-off-by: Petr Písař +--- + quotaio_rpc.c | 3 ++- + 1 file changed, 2 insertions(+), 1 deletion(-) + +diff --git a/quotaio_rpc.c b/quotaio_rpc.c +index 6f25144..edc1e9f 100644 +--- a/quotaio_rpc.c ++++ b/quotaio_rpc.c +@@ -33,7 +33,8 @@ static int rpc_init_io(struct quota_handle *h) + #ifdef RPC + h->qh_info.dqi_max_b_limit = ~(uint32_t)0; + h->qh_info.dqi_max_i_limit = ~(uint32_t)0; +- h->qh_info.dqi_max_b_usage = (~(uint32_t)0) << QUOTABLOCK_BITS; ++ h->qh_info.dqi_max_b_usage = ((uint64_t)(~(uint32_t)0)) ++ << QUOTABLOCK_BITS; + h->qh_info.dqi_max_i_usage = ~(uint32_t)0; + return 0; + #else +-- +2.14.3 + diff --git a/0012-quota-4.04-quota-1-Distinguish-between-none-quota-limits-and-no.patch b/0012-quota-4.04-quota-1-Distinguish-between-none-quota-limits-and-no.patch new file mode 100644 index 0000000..ca1c68e --- /dev/null +++ b/0012-quota-4.04-quota-1-Distinguish-between-none-quota-limits-and-no.patch @@ -0,0 +1,72 @@ +From bd36c3cf438ac4fd44b6779714ad0a44453d41b5 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= +Date: Mon, 16 Jul 2018 11:22:53 +0200 +Subject: [PATCH] quota(1): Distinguish between none quota limits and no + allocated resources +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +If a user does not occupies any space or inodes on a file system but +quota limits are set, quota(1) tool still reports "none": + + # quota -u test + Disk quotas for user test (uid 500): none + +That's because the tool skips printing details for file systems +without any used resources but uses the shares the message with file +system without any quota limits. + +This patch makes the distinction and changes "none" message into "no +quota limits set" and "no limited resources used" respectively. + +Signed-off-by: Petr Písař +--- + quota.c | 15 ++++++++++----- + 1 file changed, 10 insertions(+), 5 deletions(-) + +diff --git a/quota.c b/quota.c +index 15c2a53..0303c7d 100644 +--- a/quota.c ++++ b/quota.c +@@ -188,7 +188,7 @@ static int showquotas(int type, qid_t id, int mntcnt, char **mnt) + char timebuf[MAXTIMELEN]; + char name[MAXNAMELEN]; + struct quota_handle **handles; +- int lines = 0, bover, iover, over; ++ int lines = 0, bover, iover, over, unlimited; + time_t now; + + time(&now); +@@ -204,11 +204,16 @@ static int showquotas(int type, qid_t id, int mntcnt, char **mnt) + goto out_handles; + } + over = 0; ++ unlimited = 1; + for (q = qlist; q; q = q->dq_next) { + bover = iover = 0; +- if (!(flags & FL_VERBOSE) && !q->dq_dqb.dqb_isoftlimit && !q->dq_dqb.dqb_ihardlimit +- && !q->dq_dqb.dqb_bsoftlimit && !q->dq_dqb.dqb_bhardlimit) +- continue; ++ if (!q->dq_dqb.dqb_isoftlimit && !q->dq_dqb.dqb_ihardlimit ++ && !q->dq_dqb.dqb_bsoftlimit && !q->dq_dqb.dqb_bhardlimit) { ++ if (!(flags & FL_VERBOSE)) ++ continue; ++ } else { ++ unlimited = 0; ++ } + msgi = NULL; + if (q->dq_dqb.dqb_ihardlimit && q->dq_dqb.dqb_curinodes >= q->dq_dqb.dqb_ihardlimit) { + msgi = _("File limit reached on"); +@@ -300,7 +305,7 @@ static int showquotas(int type, qid_t id, int mntcnt, char **mnt) + } + } + if (!(flags & FL_QUIET) && !lines && qlist) +- heading(type, id, name, _("none")); ++ heading(type, id, name, unlimited ? _("none") : _("no limited resources used")); + freeprivs(qlist); + out_handles: + dispose_handle_list(handles); +-- +2.14.4 + diff --git a/6000-Fix-file-descriptor-leaks-in-error-code-paths-1.patch b/6000-Fix-file-descriptor-leaks-in-error-code-paths-1.patch new file mode 100644 index 0000000..aea343a --- /dev/null +++ b/6000-Fix-file-descriptor-leaks-in-error-code-paths-1.patch @@ -0,0 +1,30 @@ +From 78403029375dbfe809b5b1034301dc687a94397f Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= +Date: Thu, 23 Aug 2018 11:09:10 +0200 +Subject: [PATCH 1/3] convertquota: Fix a file descriptor leak in + convert_endian() +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Signed-off-by: Petr Písař +--- + convertquota.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/convertquota.c b/convertquota.c +index d913e05..6c8a553 100644 +--- a/convertquota.c ++++ b/convertquota.c +@@ -363,6 +363,7 @@ static int convert_endian(int type, struct mount_entry *mnt) + } + ret = endian_scan_structures(ofd, type); + end_io(qn); ++ close(ofd); + if (ret < 0) + return ret; + +-- +2.14.4 + + diff --git a/6001-Fix-file-descriptor-leaks-in-error-code-paths-2.patch b/6001-Fix-file-descriptor-leaks-in-error-code-paths-2.patch new file mode 100644 index 0000000..be7028b --- /dev/null +++ b/6001-Fix-file-descriptor-leaks-in-error-code-paths-2.patch @@ -0,0 +1,24 @@ +From 0f255ef2570478a855361937445a57a168c8629d Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= +Date: Thu, 23 Aug 2018 11:23:43 +0200 +Subject: [PATCH 2/3] quotackeck: Fix a directory descriptor leak in scan_dir() +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Signed-off-by: Petr Písař +--- + quotacheck.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/quotacheck.c b/quotacheck.c +index fd01dfc..2cdf475 100644 +--- a/quotacheck.c ++++ b/quotacheck.c +@@ -538,6 +538,7 @@ + if ((lstat(de->d_name, &st)) == -1) { + errstr(_("lstat: Cannot stat `%s/%s': %s\nGuess you'd better run fsck first !\nexiting...\n"), + pathname, de->d_name, strerror(errno)); ++ closedir(dp); + goto out; + } diff --git a/6002-Fix-file-descriptor-leaks-in-error-code-paths-3.patch b/6002-Fix-file-descriptor-leaks-in-error-code-paths-3.patch new file mode 100644 index 0000000..7e075e8 --- /dev/null +++ b/6002-Fix-file-descriptor-leaks-in-error-code-paths-3.patch @@ -0,0 +1,25 @@ +From 869f514310b72169a294baa37f5a90a291f719f3 Mon Sep 17 00:00:00 2001From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= +Date: Thu, 23 Aug 2018 11:51:47 +0200 +Subject: [PATCH 3/3] xqmstats: Fix a file descriptor leak in main() +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +Signed-off-by: Petr Písař +--- + xqmstats.c | 1 + + 1 file changed, 1 insertion(+) + +diff --git a/xqmstats.c b/xqmstats.c +index cdac4a6..59b1d66 100644 +--- a/xqmstats.c ++++ b/xqmstats.c +@@ -35,6 +35,7 @@ + if ((stats = fopen(XQMSTATS, "r")) == NULL) { + if ((stats = fopen(STATFILE, "r")) == NULL) { + errstr(_("The running kernel does not support XFS\n")); ++ fclose(xqm); + return 1; + } + } + diff --git a/quota-4.04.tar.gz b/quota-4.04.tar.gz new file mode 100644 index 0000000..fcb0747 Binary files /dev/null and b/quota-4.04.tar.gz differ diff --git a/quota.spec b/quota.spec new file mode 100644 index 0000000..75a1af2 --- /dev/null +++ b/quota.spec @@ -0,0 +1,144 @@ +Name: quota +Version: 4.04 +Epoch: 1 +Release: 11 +Summary: Linux Diskquota system as part of the Linux kernel +License: BSD and GPLv2 and GPLv2+ and LGPLv2+ +URL: http://sourceforge.net/projects/linuxquota/ + +Source0: http://downloads.sourceforge.net/linuxquota/%{name}-%{version}.tar.gz +Source1: quota_nld.service +Source2: quota_nld.sysconfig +Source3: rpc-rquotad.service +Source4: rpc-rquotad.sysconfig + +Patch0000: 0000-quota-4.04-warnquota-configuration-tunes.patch +Patch0001: 0001-quota-4.03-Validate-upper-bound-of-RPC-port.patch +Patch0002: 0002-quota-4.04-Install-rquota-3-only-if-RPC-is-enabled.patch +Patch0003: 0003-quota-4.04-Add-TIRPC_CFLAGS-globally-to-CFLAGS-for-RPC-support-.patch +Patch0004: 0004-quota-4.04-repquota-Fix-output-when-user-2-exists.patch +Patch0005: 0005-quota-4.04-warnquota-Check-snprintf-for-overflows.patch +Patch0006: 0006-quota-4.04-warnquota-Fix-comparing-user-name-to-non-null-termin.patch +Patch0007: 0007-quota-4.04-quotacheck-Avoid-question-in-non-interactive-mode.patch +Patch0008: 0008-quota-4.04-quotacheck-Report-error-when-caching-of-quota-file-f.patch +Patch0009: 0009-quota-4.04-quotacheck-Fail-check-if-quota-file-magic-is-invalid.patch +Patch0010: 0010-quota-4.04-Listen-on-a-TCP-socket.patch +Patch0011: 0011-quota-4.04-rpc-Fix-wrong-limit-for-space-usage.patch +Patch0012: 0012-quota-4.04-quota-1-Distinguish-between-none-quota-limits-and-no.patch + +Patch6000: 6000-Fix-file-descriptor-leaks-in-error-code-paths-1.patch +Patch6001: 6001-Fix-file-descriptor-leaks-in-error-code-paths-2.patch +Patch6002: 6002-Fix-file-descriptor-leaks-in-error-code-paths-3.patch + +BuildRequires: autoconf, automake, coreutils, rpcgen, systemd +BuildRequires: e2fsprogs-devel, gettext-devel, openldap-devel +BuildRequires: pkgconfig(dbus-1), pkgconfig(libnl-3.0) >= 3.1, pkgconfig(libnl-genl-3.0), pkgconfig(libtirpc) +Requires(post): systemd +Requires(preun): systemd +Requires(postun): systemd +Requires: rpcbind + +Provides: %{name}-doc = %{epoch}:%{version}-%{release} +Obsoletes: %{name}-doc +Provides: %{name}-nld = %{epoch}:%{version}-%{release} +Obsoletes: %{name}-nld +Provides: %{name}-nls = %{epoch}:%{version}-%{release} +Obsoletes: %{name}-nls +Provides: %{name}-rpc = %{epoch}:%{version}-%{release} +Obsoletes: %{name}-rpc +Provides: %{name}-warnquota = %{epoch}:%{version}-%{release} +Obsoletes: %{name}-warnquota + + +%description +Tools and patches for the Linux Diskquota system as part of the Linux kernel +It also include quota_nld daemon, + + +%package devel +Summary: Including header files for the developing of quota RPC +License: GPLv2 +Requires: quota = %{epoch}:%{version}-%{release} + + +%description devel +This contains header files for the developing of quota RPC. + + +%package help +Summary: Including man files for quota +Requires: man + +%description help +This contains man files for the using of quota. + + +%prep +%autosetup -n %{name}-%{version} -p1 +autoreconf -fi + +%build +%configure \ + --enable-bsd-behaviour \ + --enable-ext2direct=yes \ + --enable-ldapmail=yes \ + --disable-libwrap \ + --enable-netlink=yes \ + --enable-nls \ + --disable-rpath \ + --enable-rpc=yes \ + --enable-rpcsetquota=yes \ + --disable-silent-rules \ + --disable-xfs-roothack +make + + +%install +%make_install + +install -D -p -m 644 %{SOURCE1} $RPM_BUILD_ROOT%{_unitdir}/quota_nld.service +install -D -p -m 644 %{SOURCE2} $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/quota_nld +install -D -p -m 644 %{SOURCE3} $RPM_BUILD_ROOT%{_unitdir}/rpc-rquotad.service +install -D -p -m 644 %{SOURCE4} $RPM_BUILD_ROOT%{_sysconfdir}/sysconfig/rpc-rquotad + +%find_lang %{name} + +%check +make check + + +%post +%systemd_post quota_nld.service rpc-rquotad.service + +%preun +%systemd_preun quota_nld.service rpc-rquotad.service + +%postun +%systemd_postun_with_restart quota_nld.service rpc-rquotad.service + + + +%files -f %{name}.lang +%license COPYING +%doc Changelog +%{_bindir}/* +%{_sbindir}/* +%{_unitdir}/*.service +%config(noreplace) %{_sysconfdir}/* +%exclude %{_docdir}/%{name} + +%files devel +%doc doc/* ldap-scripts +%dir %{_includedir}/rpcsvc +%{_includedir}/rpcsvc/* + + +%files help +%{_mandir}/man*/* + +%changelog +* Sun Sep 29 2019 zhanghaibo - 1:4.04-11 +- Remove some comments + +* Fri Sep 6 2019 openEuler Buildteam - 1:4.04-10 +- Package init diff --git a/quota_nld.service b/quota_nld.service new file mode 100644 index 0000000..d069003 --- /dev/null +++ b/quota_nld.service @@ -0,0 +1,12 @@ +[Unit] +Description=Disk quota netlink message daemon +After=syslog.target + +[Service] +Type=forking +EnvironmentFile=-/etc/sysconfig/quota_nld +ExecStart=/usr/sbin/quota_nld $QUOTA_NLD_OPTS +PIDFile=/var/run/quota_nld.pid + +[Install] +WantedBy=multi-user.target diff --git a/quota_nld.sysconfig b/quota_nld.sysconfig new file mode 100644 index 0000000..51df5be --- /dev/null +++ b/quota_nld.sysconfig @@ -0,0 +1,5 @@ +# Arguments to pass to quota_nld daemon. +# -b, --print-below Inform about falling usage bellow limits too +# -C, --no-console Do not print messages on last user's terminal +# -D, --no-dbus Do not forward messages to D-Bus +QUOTA_NLD_OPTS="" diff --git a/rpc-rquotad.service b/rpc-rquotad.service new file mode 100644 index 0000000..f9c794e --- /dev/null +++ b/rpc-rquotad.service @@ -0,0 +1,15 @@ +[Unit] +Description=Remote quota server +Documentation=man:rpc.rquotad(8) +Requires=rpcbind.service +PartOf=rpcbind.service +After=rpcbind.service + +[Service] +Type=forking +EnvironmentFile=-/etc/sysconfig/rpc-rquotad +ExecStart=/usr/sbin/rpc.rquotad $RPCRQUOTADOPTS + +[Install] +WantedBy=multi-user.target +WantedBy=nfs-server.service diff --git a/rpc-rquotad.sysconfig b/rpc-rquotad.sysconfig new file mode 100644 index 0000000..4c67c13 --- /dev/null +++ b/rpc-rquotad.sysconfig @@ -0,0 +1,8 @@ +# Optionas to pass to rpc.rquotad daemon. See rpc.rquotad(8) manual page for +# more details. +# -I, --autofs Ignore autofs mount points +# -p port, --port port Listen on alternative port +# -s, --no-setquota Don't allow setting quotas with RPC (default) +# -S, --setquota Allow setting quotas with RPC +# -x path, --xtab path Use alternative NFSD export table +RPCRQUOTADOPTS=""