Home | History | Annotate | Download | only in edquota
History log of /src/usr.sbin/edquota/edquota.c
RevisionDateAuthorComments
 1.54  01-Aug-2023  mrg convert explicit length check before unchecked snprintf() with just a
overflow checked snprintf(). for res_debug.c and res_query.c, convert
from sprintf() to snprintf().

tested scp and rcp fail properly with too-long paths.
tested getaddrinfo fails as expected for too-long domains.
tested dig and ping for similar (res_debug.c/res_query.c).
created a temporary fs with quotas to test edquota with a long EDITOR.
did not test ypserv directly, but it's the same pattern.

avoids GCC 12 snprintf() warnings, and reduces total code size.
 1.53  09-Nov-2021  nia edquota(8): convert realloc(x * y) to reallocarr
 1.52  14-Aug-2012  dholland Grr. The ATF quota tests demand failing silently in certain circumstances.
For netbsd-6 we will just have to go with the flow, as I'm not touching
anything outside edquota tonight.
 1.51  14-Aug-2012  dholland three more minor fixes.
 1.50  14-Aug-2012  dholland Make editor-based edquota work again.

The format is somewhat different; I'm operating under the assumption
that nobody has automated editing scripts for the old format because
it's much easier just to use the command-line interface of
edquota. The new format is more scalable and more parseable.

Also, do a better job of diagnosing editing errors, and don't blindly
erase all quota information for the user being edited when a parse
error occurs after editing.
 1.49  13-Aug-2012  dholland Bail out early if none of the mounted volumes support quotas. Avoids a
null print in interactive use.
 1.48  13-Aug-2012  dholland Minor cleanup: use bitfields instead of a flags word for private state
flags, remove now-unused qfname field.
 1.47  07-Apr-2012  christos use getfsspecname()
 1.46  30-Jan-2012  dholland branches: 1.46.2;
Remove dependence on quotaprop.h, also quotautil.c (no longer used).

Like repquota, compile in the number of object types for now because
making it support an arbitrary number would take some hacking.
 1.45  30-Jan-2012  dholland Rely on libquota for fallback to direct access of old-style quota files.

Keep the code around in #if 0 blocks for now, just in case some of the
logic might turn out to be wanted in libquota.
 1.44  30-Jan-2012  dholland Don't use the old getvfsquota() here.
 1.43  29-Jan-2012  dholland Rename static inline "helper" functions:
ufsclass2qtype -> quota_idtype_to_ufs
qtype2ufsclass -> quota_idtype_from_ufs

The reason for the direction of "ufs" changing is that the old names
were among the symbols using "ufs" to mean "fs-independent". So the
old names were for translating "ufsclass" (fs-independent quota id
type) to "qtype" (ufs-specific quota id type) and vice versa.

These functions are used in only two places, both of which are
inappropriate, so at some point they should probably be removed.
They're also identity transformations so not particularly helpful,
unless one were to make a careful and concerted effort to distinguish
the ufs quota code numbers from the fs-independent ones. This has not
been done and is probably impossible without support from a program
verifier, and maybe not even then.

They are static inline, so no compat concerns arise.

Also adjust the symbols they use to avoid <quota/quotaprop.h>.
 1.42  29-Jan-2012  dholland Change dqblk_to_quotaval() from quota1_subr.c to dqblk_to_quotavals(),
and pass in two single quotaval structs (for blocks and inodes)
instead of an array of (implicitly) QUOTA_NLIMITS quotaval structs
indexed by constants from quotaprop.h.

Note: because this code is used by COMPAT_50 as well as ufs, this
change requires a kernel version bump. (The code is also used by
edquota, but via .PATH so it's not ABI-sensitive there.)
 1.41  09-Jan-2012  dholland "quotaclass" -> "idtype". After lengthy wrangling on the mailing lists
the best conclusion for naming was to give up on "classes" and "types"
and use "idtype" for users vs. groups and "objtype" for blocks vs. files.
 1.40  09-Jan-2012  dholland Use quota_put() and quota_delete() to update quotas instead of making
quota proplib RPCs.
 1.39  25-Nov-2011  dholland Rename struct ufs_quota_entry -> struct quotaval.
 1.38  13-Nov-2011  dholland Split up excessively large main().
Fix -d behavior to match documentation.
 1.37  13-Nov-2011  dholland Cleanup for edquota.

Factor out common malloc and linked list code. Distinguish lists of
quota info from single records.
 1.36  30-Sep-2011  jym branches: 1.36.2;
Fix an implementation inconsistency with the prop_*_send_syscall() and
prop_*_recv_syscall() functions from proplib(3). They now share the
same logic as the one from prop_*_send_ioctl() functions:
- returns an int
- 0 indicates "no error", otherwise returns the error number (and
set errno)

Many consumers of the prop_*_{ioctl, syscall} expect errno to be set
on error and use err() to display the error message. As such, ensures that
errno gets set before returning from these functions.

prop_*_send_syscall() functions returned a boolean, and now return an int.
Fix all call sites to use the new paradigm (only quota2 is affected in src).

As the prop_*_{send,recv}_syscall() API appeared in -current and is only
used by the recent quota2 code, I am not bumping the lib. The API change
only affects the prop_*_send_syscall() function (recv_syscall()s were
already used correctly), so ensure you are not mixing "old" -current
quota binaries with a new proplib(3) (or the other way around). This
change will be announced via a HEADS-UP and UPDATING.

Does not affect the kernel part of proplib.

Document the correct API in prop_array(3) and prop_dictionary(3).

Thanks to Francois Tigeot for noticing the API inconsistency and
reporting it on tech-kern@.

ok bouyer@.
 1.35  10-Jul-2011  dholland Minor cosmetic fixes, no semantic changes. (object file diffs have been
checked)
 1.34  10-Jul-2011  dholland tsort contents of file.
 1.33  10-Jul-2011  dholland use __dead
 1.32  24-Mar-2011  bouyer Add a new libquota library, which contains some blocks to build and/or
parse quota plists; as well as a getfsquota() function to retrieve quotas
for a single id from a single filesystem (whatever filesystem this is:
a local quota-enabled fs or NFS). This is build on functions getufsquota()
(for local filesystems with UFS-like quotas) and getnfsquota();
which are also available to userland programs.
move functions from quota2_subr.c to libquota or libprop as appropriate,
and ajust in-tree quota tools.
move some declarations from kernel headers to either sys/quota.h or
quota/quota.h as appropriate. ufs/ufs/quota.h still installed because
it's needed by other installed ufs headers.
ufs/ufs/quota1.h still installed as a quick&dirty way to get a code
using the old quotactl() to compile (just include ufs/ufs/quota1.h instead of
ufs/ufs/quota.h - old code won't compile without this change and this is
on purpose).
Discussed on tech-kern@ and tech-net@ (long thread, but not much about
libquota itself ...)
 1.31  06-Mar-2011  christos - KNF
- merge code
- fix error printing
- don't use static buffers
 1.30  06-Mar-2011  bouyer merge the bouyer-quota2 branch. This adds a new on-disk format
to store disk quota usage and limits, integrated with ffs
metadata. Usage is checked by fsck_ffs (no more quotacheck)
and is covered by the WAPBL journal. Enabled with kernel
option QUOTA2 (added where QUOTA was enabled in kernel config files),
turned on with tunefs(8) on a per-filesystem
basis. mount_mfs(8) can also turn quotas on.

See http://mail-index.netbsd.org/tech-kern/2011/02/19/msg010025.html
for details.
 1.29  21-Jul-2008  lukem branches: 1.29.16;
Remove the \n and tabs from the __COPYRIGHT() strings.
Tweak to use a consistent format.
 1.28  02-May-2008  xtraeme branches: 1.28.2;
WARNS=4 love.
 1.27  26-May-2006  jnemeth branches: 1.27.18;
Coverity CID 3785: calling fclose() twice on same file pointer
Coverity CID 3780: dereference of NULL pointer
Approved by: christos@
 1.26  23-May-2006  christos Coverity CID 3227, 3226: Don't leak fd's
 1.25  05-Jan-2004  jmmv Homogenize usage messages: make the 'usage' word all lowercase, as this seems
to be the most common practice in our tree.
 1.24  07-Aug-2003  agc Move UCB-licensed code from 4-clause to 3-clause licence.

Patches provided by Joel Baker in PR 22366, verified by myself.
 1.23  05-Dec-2002  jonb Fix the way $EDITOR is started so the variable can have flags in addition
to the name of the binary to run.
 1.22  04-Dec-2002  bouyer Add new command-line flags, which ease edquota use in bach scripts:
- -f, which allows to restrict edquota to only one quota-enabled filesystem
- -s and -h, which allows to set soft and hard limits respectively, without
the need to edit a file.
 1.21  14-Apr-2000  simonb branches: 1.21.6;
Don't declare 'extern opt*' getopt variables.
 1.20  21-Jan-2000  mycroft Nuke `extern int errno;' in code we compile with -Wstrict-prototypes. We get
the correct definition from errno.h.
 1.19  16-Dec-1999  bouyer Explicitely cast to (u_quad_t) calls to btodb() and dbtob() to avoid
int overflow. It's now possible to add/display quotas of more than
4G.
XXX I'm sure there is a PR open on this but I couln't find it with the
usual search engines. If someone knows it's number ...
 1.18  16-Aug-1999  simonb branches: 1.18.4;
Spell "privilege" correctly (correct spelling from Jonathan Stone).
 1.17  30-Mar-1998  mrg branches: 1.17.2;
remove unused extern.
 1.16  21-Oct-1997  mrg fix compile warning on the sparc (erik fair).
 1.15  17-Oct-1997  lukem branches: 1.15.2;
WARNSify, deprecate bcmp/perror et al in favour of memcmp/err* et al
 1.14  25-Aug-1997  kleink Lseek(2) usage cleanup: the use of L_SET/L_INCR/L_XTND is deprecated,
use SEEK_SET/SEEK_CUR/SEEK_END instead.
 1.13  08-Mar-1997  mikel prototype internal functions so this will build
 1.12  08-Mar-1997  mikel merge lite-2 changes.
also RCSid police, and add return types to all of the functions.
 1.11  30-Mar-1996  mark Use an integer instead of a char to store the getopt() return value in
order to work with compilers that default to unsigned chars.
Compare the getopt() return value with -1 instead of EOF.
 1.10  28-Nov-1995  jtc merge in changes from 1.1 release branch
 1.9  21-Apr-1995  cgd branches: 1.9.2;
need stdlib.h
 1.8  03-Jan-1995  cgd <sys/queue.h> is no longer needed.
 1.7  23-Dec-1994  cgd add headers for prototypes.
 1.6  13-Jun-1994  mycroft Fix lseek() calls.
 1.5  13-Jun-1994  mycroft Merge local changes.
 1.4  13-Jun-1994  cgd update for new fs includes
 1.3  30-Mar-1994  cgd kill bad casts
 1.2  01-Aug-1993  mycroft Add RCS identifiers.
 1.1  09-Apr-1993  cgd branches: 1.1.1;
added accton, edquota, flcopy, gettable, htable, iostat, quotaon,
repquota, trpt, and trsp, per (currently alpha) patch 125.
 1.1.1.2  08-Mar-1997  mikel import 4.4BSD-Lite2 version
 1.1.1.1  13-Jun-1994  mycroft Update from 4.4-Lite.
 1.9.2.1  01-Nov-1995  jtc Complete change from ufs -> ffs; (From Tatoku Ogaito; PR #1679)
 1.15.2.1  21-Oct-1997  mrg pull up from trunk: fix compile warning on the sparc (erik fair).
 1.17.2.2  23-Jan-2000  he Pull up revision 1.20 (requested by mycroft):
Always do the errno indirection hack, so that non-threaded
libraries get the right errno value when linked with -lpthread.
This means "always include <errno.h> and never declare errno
yourself".
 1.17.2.1  16-Dec-1999  he Pull up revision 1.19 (requested by bouyer):
Allow use of quotas bigger than 4GB by avoiding integer overflow.
 1.18.4.1  27-Dec-1999  wrstuden Pull up to last week's -current.
 1.21.6.1  26-Jan-2003  jmc Pull up versions 1.21-1.22 (requested by bouyer in ticket #1069)
Add new command-line flags, which ease edquota use in bach scripts:
-f, which allows to restrict edquota to only one quota-enabled
filesystem
-s and -h, which allows to set soft and hard limits respectively,
without the need to edit a file.
 1.27.18.1  18-May-2008  yamt sync with head.
 1.28.2.1  18-Sep-2008  wrstuden Sync with wrstuden-revivesa-base-2.
 1.29.16.12  05-Mar-2011  bouyer The new quotactl interface should be filesystem-independant, so check only the
MNT_QUOTA flag.
 1.29.16.11  09-Feb-2011  bouyer Fix quota1 grace time format.
 1.29.16.10  07-Feb-2011  bouyer Add -c option, which clears quota entries for the specified users/groups
 1.29.16.9  06-Feb-2011  bouyer Fix usage().
Document new behavior and options.
 1.29.16.8  06-Feb-2011  bouyer Change format to print the quota version for each filesystem in editor.
For version 1, have '-d' edit the filesystem's grace times.
 1.29.16.7  03-Feb-2011  bouyer Avoid core dump when a filesystem is specified and not found in
mounted filesystems.
 1.29.16.6  31-Jan-2011  bouyer Catch up with Q2V -> QL rename
 1.29.16.5  30-Jan-2011  bouyer Allow edquota to edit per-user grace times on quota2 (or the default, global
grace times on quota1). Use re-use -t to specify the grace time on command
line; editing the grace time on quota1 is done with -d now.
 1.29.16.4  30-Jan-2011  bouyer Change timeprt to print in weeks, days, hours, minutes, seconds
Change timeprt and intprt to take the number of acceptable char as argument
Drop HN_PRIV_UNLIMITED, the printable space will decide how to print
"unlimited"
 1.29.16.3  30-Jan-2011  bouyer Implement "get version" quotactl command, which return the filesystem's
enabled quota versiob (1 for legacy, 2 for new).
For quota2, make quota and repquota print the user's allowed grace period
if -v is given and not overquota (if overquota, the remaining time is
printed instead, as usual).
 1.29.16.2  30-Jan-2011  bouyer Handle humanized numbers for -h/-s
 1.29.16.1  30-Jan-2011  bouyer Convert to new quotactl()
 1.36.2.2  30-Oct-2012  yamt sync with head
 1.36.2.1  17-Apr-2012  yamt sync with head
 1.46.2.1  15-Aug-2012  riz Pull up following revision(s) (requested by dholland in ticket #498):
usr.sbin/edquota/edquota.c: revision 1.48
usr.sbin/edquota/edquota.c: revision 1.49
usr.sbin/edquota/edquota.c: revision 1.50
usr.sbin/edquota/edquota.c: revision 1.51
usr.sbin/edquota/edquota.c: revision 1.52
Minor cleanup: use bitfields instead of a flags word for private state
flags, remove now-unused qfname field.
Bail out early if none of the mounted volumes support quotas. Avoids a
null print in interactive use.
Make editor-based edquota work again.
The format is somewhat different; I'm operating under the assumption
that nobody has automated editing scripts for the old format because
it's much easier just to use the command-line interface of
edquota. The new format is more scalable and more parseable.
Also, do a better job of diagnosing editing errors, and don't blindly
erase all quota information for the user being edited when a parse
error occurs after editing.
three more minor fixes.
Grr. The ATF quota tests demand failing silently in certain circumstances.
For netbsd-6 we will just have to go with the flow, as I'm not touching
anything outside edquota tonight.

RSS XML Feed