From 2aecc52f43409c148021ae1075713d15c455f01e Mon Sep 17 00:00:00 2001 From: wenyuzifang Date: Tue, 28 Oct 2025 18:13:44 +0800 Subject: [PATCH] Update code from upstream --- ....03-Validate-upper-bound-of-RPC-port.patch | 29 +++++++ ...a-4.06-warnquota-configuration-tunes.patch | 80 +++++++++++++++++++ ...name-searched_dir-sd_dir-to-sd_isdir.patch | 52 ++++++++++++ ...Fix-error-handling-in-xfs_read_dquot.patch | 36 +++++++++ ...0-quotaio_xfs-Fix-quota-tools-on-XFS.patch | 64 +++++++++++++++ quota.spec | 26 ++++-- 6 files changed, 280 insertions(+), 7 deletions(-) create mode 100644 quota-4.03-Validate-upper-bound-of-RPC-port.patch create mode 100644 quota-4.06-warnquota-configuration-tunes.patch create mode 100644 quota-4.10-Rename-searched_dir-sd_dir-to-sd_isdir.patch create mode 100644 quota-4.10-quotaio_xfs-Fix-error-handling-in-xfs_read_dquot.patch create mode 100644 quota-4.10-quotaio_xfs-Fix-quota-tools-on-XFS.patch diff --git a/quota-4.03-Validate-upper-bound-of-RPC-port.patch b/quota-4.03-Validate-upper-bound-of-RPC-port.patch new file mode 100644 index 0000000..aa0d12b --- /dev/null +++ b/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/quota-4.06-warnquota-configuration-tunes.patch b/quota-4.06-warnquota-configuration-tunes.patch new file mode 100644 index 0000000..3f4e38f --- /dev/null +++ b/quota-4.06-warnquota-configuration-tunes.patch @@ -0,0 +1,80 @@ +From 6400cf65afed09c63d96cc62b1e7eee964bdb6cb 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). Later improved by the upstream in +0efb2331f1c39c9665fb6e92e83c7d080b877de1. + +Signed-off-by: Petr Písař +--- + warnquota.c | 2 +- + warnquota.conf | 16 ++++++++-------- + 2 files changed, 9 insertions(+), 9 deletions(-) + +diff --git a/warnquota.c b/warnquota.c +index 2882fee..48d79c0 100644 +--- a/warnquota.c ++++ b/warnquota.c +@@ -883,7 +883,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 5bbd0ab..366c3e0 100644 +--- a/warnquota.conf ++++ b/warnquota.conf +@@ -19,20 +19,20 @@ FAIL = "configure /etc/warnquota.conf before running warnquota" + # + # command used for sending mails + # +-MAIL_CMD = "/usr/lib/sendmail -t" ++MAIL_CMD = "/usr/sbin/sendmail -t" + + # + # Standard mail fields +-FROM = "root@localhost" +-SUBJECT = "Your account quota has exceeded!" ++FROM = "root@example.com" ++SUBJECT = "You are exceeding your allocated disk space limits" + # Note that if LDAP is configured, the name in CC_TO gets looked up in LDAP + # to obtain email address similarly to email recipient address. +-CC_TO = "root@localhost" ++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 = "root@localhost" ++SUPPORT = "root@example.com" + PHONE = "123 456 789" + # Text in the beginning of the mail (if not specified, default text is used) + # This way text can be split to more lines +@@ -40,11 +40,11 @@ PHONE = "123 456 789" + # 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.25.4 + diff --git a/quota-4.10-Rename-searched_dir-sd_dir-to-sd_isdir.patch b/quota-4.10-Rename-searched_dir-sd_dir-to-sd_isdir.patch new file mode 100644 index 0000000..39c67df --- /dev/null +++ b/quota-4.10-Rename-searched_dir-sd_dir-to-sd_isdir.patch @@ -0,0 +1,52 @@ +From c18e5a1b1e51c0382f5d1431120fe65f7e9c982c Mon Sep 17 00:00:00 2001 +From: Carlos Maiolino +Date: Fri, 26 Jan 2024 19:02:09 +0100 +Subject: [PATCH 1/3] Rename searched_dir->sd_dir to sd_isdir + +The field holds information if we are searching a directory mountpoint or a +device, rename the field to something more meaningful. + +We could switch it to bool, but it seems pointless to include a whole header +just for it, so keep the int type. + +Signed-off-by: Carlos Maiolino +Signed-off-by: Jan Kara +Signed-off-by: Pavel Reichl +--- + quotasys.c | 6 +++--- + 1 file changed, 3 insertions(+), 3 deletions(-) + +diff --git a/quotasys.c b/quotasys.c +index 3f50e32..9af9932 100644 +--- a/quotasys.c ++++ b/quotasys.c +@@ -1223,7 +1223,7 @@ int kern_quota_on(struct mount_entry *mnt, int type, int fmt) + */ + + struct searched_dir { +- int sd_dir; /* Is searched dir mountpoint or in fact device? */ ++ int sd_isdir; /* Is searched dir mountpoint or in fact device? */ + dev_t sd_dev; /* Device mountpoint lies on */ + ino_t sd_ino; /* Inode number of mountpoint */ + const char *sd_name; /* Name of given dir/device */ +@@ -1454,7 +1454,7 @@ static int process_dirs(int dcnt, char **dirs, int flags) + errstr(_("Cannot stat() given mountpoint %s: %s\nSkipping...\n"), dirs[i], strerror(errno)); + continue; + } +- check_dirs[check_dirs_cnt].sd_dir = S_ISDIR(st.st_mode); ++ check_dirs[check_dirs_cnt].sd_isdir = S_ISDIR(st.st_mode); + if (S_ISDIR(st.st_mode)) { + const char *realmnt = dirs[i]; + +@@ -1538,7 +1538,7 @@ restart: + return 0; + sd = check_dirs + act_checked; + for (i = 0; i < mnt_entries_cnt; i++) { +- if (sd->sd_dir) { ++ if (sd->sd_isdir) { + if (sd->sd_dev == mnt_entries[i].me_dev && sd->sd_ino == mnt_entries[i].me_ino) + break; + } +-- +2.45.2 + diff --git a/quota-4.10-quotaio_xfs-Fix-error-handling-in-xfs_read_dquot.patch b/quota-4.10-quotaio_xfs-Fix-error-handling-in-xfs_read_dquot.patch new file mode 100644 index 0000000..6adbfc1 --- /dev/null +++ b/quota-4.10-quotaio_xfs-Fix-error-handling-in-xfs_read_dquot.patch @@ -0,0 +1,36 @@ +From dba8c5ca95516b9550fc44b2a476ceca60ee4b38 Mon Sep 17 00:00:00 2001 +From: Jan Kara +Date: Tue, 7 May 2024 12:55:30 +0200 +Subject: [PATCH] quotaio_xfs: Fix error handling in xfs_read_dquot() + +When quotactl(2) fails, xfs_read_dquot() will happily return zero-filled +structure. This is fine when the user structure does not exist but it is +wrong when there's other error (like EACCESS). Fix the error handling. + +Signed-off-by: Jan Kara +Signed-off-by: Pavel Reichl +--- + quotaio_xfs.c | 7 ++++++- + 1 file changed, 6 insertions(+), 1 deletion(-) + +diff --git a/quotaio_xfs.c b/quotaio_xfs.c +index d742f9c..040e7d8 100644 +--- a/quotaio_xfs.c ++++ b/quotaio_xfs.c +@@ -176,7 +176,12 @@ static struct dquot *xfs_read_dquot(struct quota_handle *h, qid_t id) + qcmd = QCMD(Q_XFS_GETQUOTA, h->qh_type); + if (do_quotactl(qcmd, h->qh_quotadev, h->qh_dir, + id, (void *)&xdqblk) < 0) { +- ; ++ /* ++ * ENOENT means the structure just does not exist - return all ++ * zeros. Otherwise return failure. ++ */ ++ if (errno != ENOENT) ++ return NULL; + } + else { + xfs_kern2utildqblk(&dquot->dq_dqb, &xdqblk); +-- +2.45.2 + diff --git a/quota-4.10-quotaio_xfs-Fix-quota-tools-on-XFS.patch b/quota-4.10-quotaio_xfs-Fix-quota-tools-on-XFS.patch new file mode 100644 index 0000000..13e6bed --- /dev/null +++ b/quota-4.10-quotaio_xfs-Fix-quota-tools-on-XFS.patch @@ -0,0 +1,64 @@ +From bd13b74e6d181638023d8a89316417643d9e7fd8 Mon Sep 17 00:00:00 2001 +From: Jan Kara +Date: Tue, 7 May 2024 14:21:45 +0200 +Subject: [PATCH] quotaio_xfs: Fix quota-tools on XFS + +Patches implementing tmpfs quota support, commit 00534e79856c ("Enable +support for tmpfs quotas") in particular, broke quota-tools on XFS +because quotactl(2) syscall got called with wrong arguments. Fix it. + +Signed-off-by: Jan Kara +Signed-off-by: Pavel Reichl +--- + quotaio_xfs.c | 11 ++++------- + 1 file changed, 4 insertions(+), 7 deletions(-) + +diff --git a/quotaio_xfs.c b/quotaio_xfs.c +index 040e7d8..c10534d 100644 +--- a/quotaio_xfs.c ++++ b/quotaio_xfs.c +@@ -124,11 +124,9 @@ static inline int xfs_util2kerndqblk(struct xfs_kern_dqblk *k, struct util_dqblk + static int xfs_init_io(struct quota_handle *h) + { + struct xfs_mem_dqinfo info; +- int qcmd; + +- qcmd = QCMD(Q_XFS_GETQSTAT, h->qh_type); + memset(&info, 0, sizeof(struct xfs_mem_dqinfo)); +- if (quotactl_handle(qcmd, h, 0, (void *)&info) < 0) ++ if (quotactl_handle(Q_XFS_GETQSTAT, h, 0, (void *)&info) < 0) + return -1; + h->qh_info.dqi_bgrace = info.qs_btimelimit; + h->qh_info.dqi_igrace = info.qs_itimelimit; +@@ -142,7 +140,6 @@ static int xfs_init_io(struct quota_handle *h) + static int xfs_write_info(struct quota_handle *h) + { + struct xfs_kern_dqblk xdqblk; +- int qcmd; + + if (!XFS_USRQUOTA(h) && !XFS_GRPQUOTA(h) && !XFS_PRJQUOTA(h)) + return 0; +@@ -152,8 +149,7 @@ static int xfs_write_info(struct quota_handle *h) + xdqblk.d_btimer = h->qh_info.dqi_bgrace; + xdqblk.d_itimer = h->qh_info.dqi_igrace; + xdqblk.d_fieldmask |= FS_DQ_TIMER_MASK; +- qcmd = QCMD(Q_XFS_SETQLIM, h->qh_type); +- if (quotactl_handle(qcmd, h, 0, (void *)&xdqblk) < 0) ++ if (quotactl_handle(Q_XFS_SETQLIM, h, 0, (void *)&xdqblk) < 0) + return -1; + return 0; + } +@@ -180,8 +176,9 @@ static struct dquot *xfs_read_dquot(struct quota_handle *h, qid_t id) + * ENOENT means the structure just does not exist - return all + * zeros. Otherwise return failure. + */ +- if (errno != ENOENT) ++ if (errno != ENOENT) { + return NULL; ++ } + } + else { + xfs_kern2utildqblk(&dquot->dq_dqb, &xdqblk); +-- +2.45.2 + diff --git a/quota.spec b/quota.spec index b49529c..ccaeda5 100644 --- a/quota.spec +++ b/quota.spec @@ -1,4 +1,4 @@ -%define anolis_release 2 +%define anolis_release 3 # Scan ext file systems directly to increase the performace of a quota # initialization and check @@ -14,17 +14,22 @@ Name: quota Epoch: 1 -Version: 4.09 +Version: 4.09 Release: %{anolis_release}%{?dist} Summary: System administration tools for monitoring users disk usage License: GPLv2 and GPLv2+ 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 +Source0: http://downloads.sourceforge.net/linuxquota/quota-4.09.tar.gz +Source1: quota_nld.service +Source2: quota_nld.sysconfig +Source3: rpc-rquotad.service +Source4: rpc-rquotad.sysconfig +Patch1: quota-4.03-Validate-upper-bound-of-RPC-port.patch +Patch2: quota-4.10-quotaio_xfs-Fix-error-handling-in-xfs_read_dquot.patch +Patch3: quota-4.10-quotaio_xfs-Fix-quota-tools-on-XFS.patch +Patch4: quota-4.06-warnquota-configuration-tunes.patch +Patch5: quota-4.10-Rename-searched_dir-sd_dir-to-sd_isdir.patch BuildRequires: autoconf automake bash coreutils gcc make BuildRequires: pkgconfig(ext2fs) pkgconfig(ldap) gettext-devel @@ -40,6 +45,8 @@ BuildRequires: pkgconfig(libnl-3.0) >= 3.1 pkgconfig(libnl-genl-3.0) BuildRequires: rpcgen pkgconfig(libtirpc) systemd-rpm-macros %if %{with quota_enables_tcpwrappers} BuildRequires: tcp_wrappers-devel +BuildRequires: e2fsprogs-devel +BuildRequires: openldap-devel %endif %endif @@ -262,6 +269,11 @@ make check %doc Changelog README.ldap-support README.mailserver %changelog +* Tue Oct 28 2025 wenyuzifang - 1:4.09-3 +- Ensure port numbers are within the valid range to prevent invalid input and improve program reliability. +- Fix error handling to prevent masking critical quota access issues; ensure only ENOENT returns zeroed dquot. +- Fix quota-tools on XFS by correcting quotactl command usage to restore proper quota functionality. +- Improve configuration parsing safety and set professional, enterprise-appropriate defaults for emails and paths. * Thu Apr 13 2023 yuanhui - 4.09-2 - Optimize the spec file -- Gitee