summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2024-07-20Add support for bcachefs REINHERIT_ATTRS ioctl to setprojectHEADmasterKent Overstreet
2024-07-20Simple utility for setting projects on files/directoriesKent Overstreet
Signed-off-by: Kent Overstreet <kent.overstreet@gmail.com>
2024-07-20Add bcachefs supportKent Overstreet
bcachefs multi device filesystems require a bit of hackery, since the line in /proc/mounts isn't actually a device: when checking if a bcachefs device has quotas, we return an actually device path in @dev. Signed-off-by: Kent Overstreet <kent.overstreet@linux.dev>
2024-05-07quotaio_xfs: Convert remaining quotactl(2) calls to quotactl_handle()Jan Kara
quotaio_xfs has a mix of quotactl calls using do_quotactl() and using quotactl_handle(). This is confusing because the command argument behaves differently. Convert all places to use quotactl_handle(). Signed-off-by: Jan Kara <jack@suse.cz>
2024-05-07quotaio_xfs: Fix quota-tools on XFSJan Kara
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 <jack@suse.cz>
2024-05-07quotaio_xfs: Fix error handling in xfs_read_dquot()Jan Kara
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 <jack@suse.cz>
2024-05-07Disable BSD_BEHAVIOUR by defaultJan Kara
These days BSD_BEHAVIOUR is really old legacy and there's no point in doing permission checks in userspace when kernel does it for us. So disable BSD_BEHAVIOUR by default. Signed-off-by: Jan Kara <jack@suse.cz>
2024-05-07quotaops: Checking egid with BSD_BEHAVIORJan Kara
It is undefined whether getgroups() call will return current egid in the list of groups it returns. Add an explicit check for egid to the permission checks performed when BSD_BEHAVIOUR is enabled. Signed-off-by: Jan Kara <jack@suse.cz>
2024-01-29Enable support for tmpfs quotasCarlos Maiolino
To achieve so, add a new function quotactl_handle() to the quotaio subsystem, this will call do_quotactl() with or without a valid quotadev, according to the filesystem type. Signed-off-by: Carlos Maiolino <cmaiolino@redhat.com> Signed-off-by: Lukas Czerner <lczerner@redhat.com> Signed-off-by: Jan Kara <jack@suse.cz>
2024-01-29Add quotactl_fd() supportCarlos Maiolino
To be able to set quotas on filesystems without a backing device, quota tools should be able to use quotactl_fd(). To achieve that, add a new helper, do_quotactl(), to select between quotactl() and quotactl_fd(). This shouldn't change the semantics of current code. quotactl_fd() will be called if and only if the handlers contain an empty device, and a valid mountpoint. All current calls containing a value device should be still handled by quotactl(). The same is true for calls passing a NULL device on purpose, aiming to sync active quotas. Signed-off-by: Carlos Maiolino <cmaiolino@redhat.com> Signed-off-by: Lukas Czerner <lczerner@redhat.com> Signed-off-by: Jan Kara <jack@suse.cz>
2024-01-29Rename searched_dir->sd_dir to sd_isdirCarlos Maiolino
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 <cmaiolino@redhat.com> Signed-off-by: Jan Kara <jack@suse.cz>
2022-12-06quota-nld: fix open PID file failed when systemd read itlihaoxiang (F)
Running quota_nld by systemd might cause the problem that systemd couldn't open the PID file generated by quota_nld. In fact, the PID file hasn't existed yet because it originates from the child process of quota_nld which is a daemon process. As the main process exit, systemd try to access the PID file but the daemon hadn't create it that time. In this situation, we move the procedure of creating PID file into the parent process to ensure the PID file must existed when quota_nld exit. After that, the above problem would never occur again. [JK: Fixed up SIGTERM handling and format strings] Signed-off-by: lihaoxiang <lihaoxiang9@huawei.com> Signed-off-by: Jan Kara <jack@suse.cz>
2022-11-01edquota: Fix editing of individual user grace timesJan Kara
When user is not over softlimit, there's no point to set the grace time. The kernel will just ignore it. Output error message instead so that user is not confused. Also editing of grace times when quotas are enabled did not really work because we didn't tell the kernel grace times have changed. Fix it. Signed-off-by: Jan Kara <jack@suse.cz>
2022-11-01setquota: Avoid false error messages when setting grace timesJan Kara
When setting grace times for a user with only inodes or blocks over softlimit, setquota(8) was wrongly complaining about not being able to set the grace time of the non-exceeded entity although it was left unset. Silence this bogus error message. Signed-off-by: Jan Kara <jack@suse.cz>
2022-09-26Make configure.ac POSIX compliantSam James
Configure scripts need to be runnable with a POSIX-compliant /bin/sh. Replace == comparison operator (bashism) with = (POSIX) to fix errors: configure: WARNING: tcpd.h not found ./configure: 8453: test: X: unexpected operator checking that generated files are newer than configure... done Signed-off-by: Sam James <sam@gentoo.org> Signed-off-by: Jan Kara <jack@suse.cz>
2022-09-23Update required gettext versionJan Kara
Update required gettext version to 0.19 so that newer autoconf macros get copied. The old ones from 2014 start to have compatibility issues. Reported-by: Sam James <thesamesam@users.sourceforge.net> Signed-off-by: Jan Kara <jack@suse.cz>
2022-09-21Release quota-tools 4.09Jan Kara
Signed-off-by: Jan Kara <jack@suse.cz>
2022-09-21Avoid including manpages multiple times in man_MANSJan Kara
Due to variable assignments getting reordered by automake the variable man_MANS contained some manpages two times. This then resulted in complaints when installing the manpages. Avoid the problem by reworking how the list of manpages is constructed. Signed-off-by: Jan Kara <jack@suse.cz>
2022-09-19Release quota-tools 4.08Jan Kara
Signed-off-by: Jan Kara <jack@suse.cz>
2022-09-19Include unconfigured manpages into distributionJan Kara
Include manpages for features not configured by configure script into the distribution tarball. This makes the distribution tarball complete. Signed-off-by: Jan Kara <jack@suse.cz>
2022-09-16Release quota-tools 4.07Jan Kara
Signed-off-by: Jan Kara <jack@suse.cz>
2021-09-17quotasys.c: fix strncpy usageDmitry V. Levin
When quota is configured using --enable-werror, gcc -flto fails with the following diagnostics: In function 'strncpy', inlined from 'sstrncpy' at common.c:107:2, inlined from 'copy_mntoptarg' at quotasys.c:774:3, inlined from 'copy_mntoptarg' at quotasys.c:769:13: /usr/include/bits/string_fortified.h:91:10: error: '__builtin_strncpy' specified bound depends on the length of the source argument [-Werror=stringop-overflow=] 91 | return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest)); | ^ quotasys.c: In function 'copy_mntoptarg': quotasys.c:774:25: note: length computed here 774 | sstrncpy(buf, optarg, min(buflen, strlen(optarg) + 1)); | ^ This diagnostics is correct: strcpy() copies at most "len" bytes of the string pointed to by "src", including the terminating null byte, to the buffer pointed to by "dest". Signed-off-by: Dmitry V. Levin <ldv@altlinux.org> Signed-off-by: Jan Kara <jack@suse.cz>
2021-09-17common.c: fix strncat usageDmitry V. Levin
When quota is configured using --enable-werror, gcc -flto fails with the following diagnostics: In function 'strncat', inlined from 'sstrncat' at common.c:113:2, inlined from 'get_proc_num' at quotastats.c:46:2: /usr/include/bits/string_fortified.h:122:10: error: '__builtin___strncat_chk' specified bound 4096 equals destination size [-Werror=str ingop-overflow=] 122 | return __builtin___strncat_chk (__dest, __src, __len, __bos (__dest)); | ^ This diagnostics is correct: when "src" contains "len" or more bytes, strncat() writes "len"+1 bytes to "dest" ("len" from "src" plus the terminating null byte). Signed-off-by: Dmitry V. Levin <ldv@altlinux.org> Signed-off-by: Jan Kara <jack@suse.cz>
2021-08-20quotacheck, quotaon: Always display message about deprecated usageJan Kara
Visible quota files on ext4 filesystem are deprecated. Make sure we always display the warning message and also expand the message to explain how the filesystem can be converted. Signed-off-by: Jan Kara <jack@suse.cz>
2021-03-16quota_nld: Initialize sa_mask when registering PID file removalPetr Písař
term_action.sa_mask is an automatic variable and and thus unitialized. This patch empties the signal mask. Signed-off-by: Petr Písař <ppisar@redhat.com> Signed-off-by: Jan Kara <jack@suse.cz>
2020-11-30Drop sys/cdefs.h usageJan Kara
quota.h header includes sys/cdefs.h because it uses __P() macro in quotactl syscall declaration. However glibc currently defines __P() is nop and it only causes issues with other libc implementations (e.g. musl libc). So just drop __P() usage and sys/cdefs.h include. Reported-by: 2xsaiko <git@dblsaiko.net> Signed-off-by: Jan Kara <jack@suse.cz>
2020-11-24quotaio_xfs: Warn when large kernel timestamps cannot be handledJan Kara
When time_t is 32-bit, warn if the kernel returns anything that cannot fit in these time stamps. This also fixes a compilation warning that shift exceeds data type size. Similarly when converting data to pass to kernel, just avoid the pointless shift (generating compiler warning) when time_t is 32-bit. Reported-by: "Dmitry V. Levin" <ldv@altlinux.org> Signed-off-by: Jan Kara <jack@suse.cz>
2020-11-23quotaops: fix compilation warningDmitry V. Levin
When quota is configured using --enable-werror --disable-bsd_behaviour, the compilation fails with the following diagnostics: quotaops.c: In function 'getprivs': quotaops.c:143:1: error: label 'out_err' defined but not used [-Werror=unused-label] Fixes: 7942290a ("quotaops: Do not leak dquot structures on failure") Signed-off-by: Dmitry V. Levin <ldv@altlinux.org> Signed-off-by: Jan Kara <jack@suse.cz>
2020-11-23quotacheck: Remove a dead code from process_file()Petr Písař
The ret variable inicialization is useless because it is assigned in all (two) subsequent code branches. Signed-off-by: Petr Písař <ppisar@redhat.com> Signed-off-by: Jan Kara <jack@suse.cz>
2020-11-11quota: Use realloc(3) instead of reallocarray(3)Fabrice Fontaine
reallocarray(3) has been added to glibc relatively recently (version 2.26, from 2017) and apparently not all users run new enough glibc. Just use realloc(3) for now since in this case there's no real risk of overflow. Signed-off-by: Fabrice Fontaine <fontaine.fabrice@gmail.com> Signed-off-by: Jan Kara <jack@suse.cz>
2020-11-09Release quota-tools 4.06Jan Kara
2020-11-09Remove quot toolJan Kara
The tool hasn't been compiled already in the previous version and nobody complained. Just delete it completely. Signed-off-by: Jan Kara <jack@suse.cz>
2020-10-19quotacheck,quotaon: Suggest using quota feature for ext4Jan Kara
Ext4 supports quota using internal quota files for quite some time. Suggest using this quota feature instead of external quota files if the kernel is new enough since external quota files on ext4 will be deprecated. Signed-off-by: Jan Kara <jack@suse.cz>
2020-09-21quota: Add --filesystem optionJan Kara
Add option --filesystem to specify filesystem to report quotas for while still maintaining the capability of specifying also names to report quotas for. Signed-off-by: Jan Kara <jack@suse.cz>
2020-09-21quota: Add synopsis for project quotaJan Kara
Signed-off-by: Jan Kara <jack@suse.cz>
2020-09-21Handle grace time overflows for XFS quotasJan Kara
Add checks and error handling to report when grace times set for XFS quotas would overflow. Signed-off-by: Jan Kara <jack@suse.cz>
2020-09-07Support grace period expirations past y2038 for XFSDarrick J. Wong
Add the ability to interpret the larger quota grace period expiration timestamps that the kernel can export via struct xfs_kern_dqblk. Signed-off-by: Darrick J. Wong <darrick.wong@oracle.com> Signed-off-by: Jan Kara <jack@suse.cz>
2020-05-21Fix limits setting on XFS filesystemJan Kara
xfs_commit_dquot() always set FS_DQ_LIMIT_MASK when calling Q_XFS_SETQLIM. So far this wasn't a problem since quota tools didn't support setting of anything else for XFS but now that kernel will start supporting setting of grace times for XFS, we need to be more careful and set limits bits only if we really want to update them. Also FS_DQ_LIMIT_MASK contains real-time limits as well. Quota tools currently don't support them in any way so avoid telling kernel to set them. Reviewed-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Jan Kara <jack@suse.cz>
2020-05-14quota-tools: Set FS_DQ_TIMER_MASK for individual xfs grace timesEric Sandeen
xfs quota code doesn't currently allow increasing an individual user's grace time, but kernel patches are in development for this. In order for setquota to be able to send this update via setquota -T, we need to add the FS_DQ_TIMER_MASK when we are trying to update the grace times on an individual user's dquot. Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Jan Kara <jack@suse.cz>
2020-05-13quota-tools: pass quota type to QCMD for Q_XFS_GETQSTATEric Sandeen
Older kernels ignored the type sent to Q_XFS_GETQSTAT, and returned timer information for the first quota type which was found to be enabled. As of 555b2c3da1fc ("quota: honor quota type in Q_XGETQSTAT[V] calls") the kernel now honors the quota type requested, so send that from the Q_XFS_GETQSTAT calls in quota tools. Older kernels ignore the type altogether, so this change should be backwards compatible with no change in behavior. Signed-off-by: Eric Sandeen <sandeen@redhat.com> Signed-off-by: Jan Kara <jack@suse.cz>
2020-03-26Fix ignoring disabled quotasPetr Písař
quota(1) command ignores file systems without enabled quotas. (In contrast to "quota -f".) This works for local file systems and it used to work for NFS file system until commit 4cd287f3fa38 ("rpc: Clarify error message when cannot connect to rpc.rquotad"). quota(1) command now reports an error whenever at least one NFS-mounted file system has disabled the quotas. This renders the tool unusable. This patch readds an exception for the ENOENT errno that was removed with the commit probably by a mistake. [JK: Improve commit message, make getprivs() print more descriptive message in case quota is not enabled] Signed-off-by: Petr Písař <ppisar@redhat.com> Signed-off-by: Jan Kara <jack@suse.cz>
2019-11-05warnquota: Initialize all members of a configparams structurePetr Písař
Running warnquota under valgrind reported many "Conditional jump or move depends on uninitialised value" mistakes because readconfigfile() did not initizalize ldap_bindpw member if some of the configuration options were missing from the configuration file. This patch simply initializes all bytes of the configparams structure to 0 instead of settting each of the members explicitly. Signed-off-by: Petr Písař <ppisar@redhat.com> Signed-off-by: Jan Kara <jack@suse.cz>
2019-11-05warnquota: Free LDAP error messagePetr Písař
ldap_get_option(3) documents that a pointer set by LDAP_OPT_DIAGNOSTIC_MESSAGE must be freed with ldap_memfree(3). Signed-off-by: Petr Písař <ppisar@redhat.com> Signed-off-by: Jan Kara <jack@suse.cz>
2019-10-04Make a directory for quota_nld PID file configurablePetr Písař
While Filesystem Hierarchy Standard prescribes /var/run path for storing PID files, some (systemd-based) distributions uses /run. This patch adds a --with-pid-dir=DIRECTORY option to the ./configure script. The option enables to change the path. Default one is /var/run as used to be until now. (I did not use $localstatedir environment variable because Autoconf manual allows using "precious" variables only in a makefile.) Signed-off-by: Petr Písař <ppisar@redhat.com> Signed-off-by: Jan Kara <jack@suse.cz>
2019-09-12warnquota: Clarify that CC_TO gets resolved through LDAPJan Kara
Clarify that CC_TO field from warnquota.conf gets resolved through LDAP lookup similarly to normal message recifient. Signed-off-by: Jan Kara <jack@suse.cz>
2019-09-12warnquota: Print also additional error info for LDAP errorsJan Kara
LDAP library provides additional error information in some cases. Print it make debugging LDAP setup easier. Signed-off-by: Jan Kara <jack@suse.cz>
2019-09-08warnquota: Properly detect LDAP errorsJan Kara
ldap_search_ext_s() and ldap_sasl_bind_s() can return also positive error result codes. Catch them properly. Signed-off-by: Jan Kara <jack@suse.cz>
2019-08-15warnquota: Do not ignore errors in config fileJan Kara
Currently warnquota ignores unknown variables, or lines we cannot parse in the config file. This is potentially dangerous as that may result in errors being missed and warnquota operating differently than administrator intended. Change warnquota to abort on errors in config file and provide -I option for ignoring errors for backward compatibility. Signed-off-by: Jan Kara <jack@suse.cz>
2019-08-12warnquota: Fix help textJan Kara
The help text was wrongly saying that -v is equivalent to --version. It should be -V. Signed-off-by: Jan Kara <jack@suse.cz>
2019-07-30quotacheck: Skip checking of filesystems with hidded quota files earlyJan Kara
Currently when filesystem tracks quotas in hidden quota files (but is also capable of tracking it in regular files), we scan the whole filesystem and only after that find out we cannot actually make use of newly created quota files. Just detect this case before scanning the fs and skip it. Signed-off-by: Jan Kara <jack@suse.cz>