diff options
-rw-r--r-- | Changelog | 3 | ||||
-rw-r--r-- | edquota.c | 8 | ||||
-rw-r--r-- | mntopt.h | 1 | ||||
-rw-r--r-- | quot.8 | 5 | ||||
-rw-r--r-- | quot.c | 8 | ||||
-rw-r--r-- | quota.1 | 9 | ||||
-rw-r--r-- | quota.c | 16 | ||||
-rw-r--r-- | quotasys.c | 34 | ||||
-rw-r--r-- | quotasys.h | 3 | ||||
-rw-r--r-- | repquota.8 | 7 | ||||
-rw-r--r-- | repquota.c | 12 | ||||
-rw-r--r-- | setquota.c | 4 | ||||
-rw-r--r-- | warnquota.8 | 5 | ||||
-rw-r--r-- | warnquota.c | 14 |
14 files changed, 92 insertions, 37 deletions
@@ -1,7 +1,8 @@ Changes in quota-tools from 3.08 to 3.09 * fixed minor bug in documentation (Jan Kara, Lucas Brasilino) * repquota(8) handles multiple entries in /etc/passwd better (Jan Kara) -* made tools not to touch mountpoints mounted without quota options (Jan Kara, Paul Szabo) +* made tools not to touch mountpoints mounted without quota options (Jan Kara) +* added option for ignoring autofs mountpoints to quota(1), quot(8) and repquota(8) (Jan Kara, Paul Szabo) Changes in quota-tools from 3.07 to 3.08 * Fixed infinite loop in quotacheck under RH7.1 (?) @@ -34,7 +34,7 @@ #ident "$Copyright: (c) 1980, 1990 Regents of the University of California. $" #ident "$Copyright: All rights reserved. $" -#ident "$Id: edquota.c,v 1.11 2002/11/21 21:15:26 jkar8572 Exp $" +#ident "$Id: edquota.c,v 1.12 2003/02/14 18:50:16 jkar8572 Exp $" /* * Disk quota editor. @@ -51,6 +51,7 @@ #include <unistd.h> #include <paths.h> #include <stdlib.h> +#include <fcntl.h> #include "pot.h" #include "quotaops.h" @@ -147,7 +148,7 @@ int main(int argc, char **argv) usage(); init_kernel_interface(); - handles = create_handle_list(0, dirname ? &dirname : NULL, quotatype, fmt, rflag ? 0 : IOI_LOCALONLY); + handles = create_handle_list(0, dirname ? &dirname : NULL, quotatype, fmt, rflag ? 0 : IOI_LOCALONLY, 0); if (!handles[0]) { dispose_handle_list(handles); fputs(_("No filesystems with quota detected.\n"), stderr); @@ -240,6 +241,9 @@ int main(int argc, char **argv) errstr(_("Error while editting quotas.\n")); continue; } + close(tmpfd); + if ((tmpfd = open(tmpfil, O_RDONLY)) < 0) + die(1, _("Can't reopen!")); if (readprivs(curprivs, tmpfd) < 0) { errstr(_("Can't read quotas from file.\n")); continue; @@ -11,6 +11,7 @@ #define MNTTYPE_UDF "udf" /* OSTA UDF file system */ #define MNTTYPE_REISER "reiserfs" /* Reiser file system */ #define MNTTYPE_XFS "xfs" /* SGI XFS file system */ +#define MNTTYPE_AUTOFS "autofs" /* Automount mountpoint */ /* mount options */ #define MNTOPT_NOQUOTA "noquota" /* don't enforce quota */ @@ -3,7 +3,7 @@ quot \- summarize filesystem ownership .SH SYNOPSIS .nf -\f3quot\f1 [ \f3\-acfguv\f1 ] [ filesystem... ] +\f3quot\f1 [ \f3\-acfguvi\f1 ] [ filesystem... ] .fi .SH DESCRIPTION .IR quot @@ -36,6 +36,9 @@ Report on users (the default). .B \-v Display three columns containing the number of kilobytes not accessed in the last 30, 60, and 90 days. +.TP +.B \-i +Ignore mountpoints mounted by automounter. .SH FILES .PD 0 .TP 20 @@ -67,6 +67,7 @@ static int fflag; static int gflag; static int uflag; static int vflag; +static int iflag; static time_t now; char *progname; @@ -77,7 +78,7 @@ static void creport(const char *, char *); static void usage(void) { - errstr(_("Usage: %s [-acfugvV] [filesystem...]\n"), progname); + errstr(_("Usage: %s [-acfugvVi] [filesystem...]\n"), progname); exit(1); } @@ -108,6 +109,9 @@ int main(int argc, char **argv) case 'v': vflag++; break; + case 'i': + iflag++; + break; case 'V': version(); exit(0); @@ -119,7 +123,7 @@ int main(int argc, char **argv) usage(); if (!uflag && !gflag) uflag++; - if (init_mounts_scan(aflag ? 0 : argc - optind, argv + optind, 0) < 0) + if (init_mounts_scan(aflag ? 0 : argc - optind, argv + optind, (iflag ? MS_NO_AUTOFS : 0)) < 0) return 1; mounttable(); end_mounts_scan(); @@ -7,7 +7,7 @@ quota \- display disk usage and limits .B -F .I format-name ] [ -.BR -guvsl \ | +.BR -guvsil \ | .B q ] .br @@ -16,7 +16,7 @@ quota \- display disk usage and limits .B -F .I format-name ] [ -.BR -uvsl \ | +.BR -uvsil \ | .B q ] .I user @@ -26,7 +26,7 @@ quota \- display disk usage and limits .B -F .I format-name ] [ -.BR -gvsl \ | +.BR -gvsil \ | .B q ] .I group @@ -71,6 +71,9 @@ option will make .BR quota (1) try to choose units for showing limits, used space and used inodes. .TP +.B \-i +ignore mountpoints mounted by automounter +.TP .B \-l report quotas only on local filesystems (ie. ignore NFS mounted filesystems). .TP @@ -34,7 +34,7 @@ #ident "$Copyright: (c) 1980, 1990 Regents of the University of California. $" #ident "$Copyright: All rights reserved. $" -#ident "$Id: quota.c,v 1.12 2002/07/23 15:59:27 jkar8572 Exp $" +#ident "$Id: quota.c,v 1.13 2003/02/14 18:50:17 jkar8572 Exp $" /* * Disk quota reporting program. @@ -67,6 +67,7 @@ #define FL_SMARTSIZE 16 #define FL_LOCALONLY 32 #define FL_QUIETREFUSE 64 +#define FL_NOAUTOFS 128 int flags, fmt = -1; char *progname; @@ -84,7 +85,7 @@ int main(int argc, char **argv) gettexton(); progname = basename(argv[0]); - while ((ret = getopt(argc, argv, "guqvsVlQF:")) != -1) { + while ((ret = getopt(argc, argv, "guqvsVliQF:")) != -1) { switch (ret) { case 'g': flags |= FL_GROUP; @@ -111,6 +112,9 @@ int main(int argc, char **argv) case 'Q': flags |= FL_QUIETREFUSE; break; + case 'i': + flags |= FL_NOAUTOFS; + break; case 'V': version(); exit(0); @@ -154,9 +158,9 @@ int main(int argc, char **argv) void usage(void) { errstr( "%s%s%s", - _("Usage: quota [-guqvs] [-l | -Q] [-F quotaformat]\n"), - _("\tquota [-qvs] [-l | -Q] [-F quotaformat] -u username ...\n"), - _("\tquota [-qvs] [-l | -Q] [-F quotaformat] -g groupname ...\n")); + _("Usage: quota [-guqvs] [-l | -Q] [-i] [-F quotaformat]\n"), + _("\tquota [-qvs] [-l | -Q] [-i] [-F quotaformat] -u username ...\n"), + _("\tquota [-qvs] [-l | -Q] [-i] [-F quotaformat] -g groupname ...\n")); fprintf(stderr, _("Bugs to: %s\n"), MY_EMAIL); exit(1); } @@ -173,7 +177,7 @@ int showquotas(int type, qid_t id) time(&now); id2name(id, type, name); - handles = create_handle_list(0, NULL, type, fmt, IOI_READONLY | ((flags & FL_LOCALONLY) ? IOI_LOCALONLY : 0)); + handles = create_handle_list(0, NULL, type, fmt, IOI_READONLY | ((flags & FL_LOCALONLY) ? IOI_LOCALONLY : 0), ((flags & FL_NOAUTOFS) ? MS_NO_AUTOFS : 0)); qlist = getprivs(id, handles, !!(flags & FL_QUIETREFUSE)); over = 0; for (q = qlist; q; q = q->dq_next) { @@ -483,27 +483,27 @@ int get_qf_name(struct mntent *mnt, int type, int fmt, int flags, char **filenam * List of zero length means scan all entries in /etc/mtab */ struct quota_handle **create_handle_list(int count, char **mntpoints, int type, int fmt, - int flags) + int ioflags, int mntflags) { struct mntent *mnt; int gotmnt = 0; static struct quota_handle *hlist[MAXMNTPOINTS]; - if (init_mounts_scan(count, mntpoints, 0) < 0) + if (init_mounts_scan(count, mntpoints, mntflags) < 0) die(2, _("Can't initialize mountpoint scan.\n")); while ((mnt = get_next_mount())) { if (strcmp(mnt->mnt_type, MNTTYPE_NFS)) { /* No NFS? */ if (gotmnt+1 == MAXMNTPOINTS) die(2, _("Too many mountpoints with quota. Contact %s\n"), MY_EMAIL); - if (!(hlist[gotmnt] = init_io(mnt, type, fmt, flags))) + if (!(hlist[gotmnt] = init_io(mnt, type, fmt, ioflags))) continue; gotmnt++; } - else if (!(flags & IOI_LOCALONLY) && (fmt == -1 || fmt == QF_RPC)) { /* Use NFS? */ + else if (!(ioflags & IOI_LOCALONLY) && (fmt == -1 || fmt == QF_RPC)) { /* Use NFS? */ #ifdef RPC if (gotmnt+1 == MAXMNTPOINTS) die(2, _("Too many mountpoints with quota. Contact %s\n"), MY_EMAIL); - if (!(hlist[gotmnt] = init_io(mnt, type, fmt, flags))) + if (!(hlist[gotmnt] = init_io(mnt, type, fmt, ioflags))) continue; gotmnt++; #endif @@ -705,6 +705,7 @@ struct searched_dir { }; #define ALLOC_ENTRIES_NUM 16 /* Allocate entries by this number */ +#define AUTOFS_DIR_MAX 64 /* Maximum number of autofs directories */ static int mnt_entries_cnt; /* Number of cached mountpoint entries */ static struct mount_entry *mnt_entries; /* Cached mounted filesystems */ @@ -712,7 +713,7 @@ static int check_dirs_cnt, act_checked; /* Number of dirs to check; Actual check static struct searched_dir *check_dirs; /* Directories to check */ /* Cache mtab/fstab */ -static int cache_mnt_table(void) +static int cache_mnt_table(int flags) { FILE *mntf; struct mntent *mnt; @@ -721,6 +722,8 @@ static int cache_mnt_table(void) int allocated = 0, i = 0; dev_t dev = 0; char mntpointbuf[PATH_MAX]; + int autofsdircnt = 0; + char autofsdir[AUTOFS_DIR_MAX][PATH_MAX]; if (!(mntf = setmntent(_PATH_MOUNTED, "r"))) { if (errno != ENOENT) { @@ -745,11 +748,28 @@ static int cache_mnt_table(void) errstr(_("Can't get device name for %s\n"), mnt->mnt_fsname); continue; } + + /* Check for mountpoints under autofs and skip them*/ + for (i = 0; i < autofsdircnt; i++) { + int slen = strlen(autofsdir[i]); + + if (slen <= strlen(mnt->mnt_dir) && !strncmp(autofsdir[i], mnt->mnt_dir, slen)) + break; + } + if (i < autofsdircnt) + continue; + if (!realpath(mnt->mnt_dir, mntpointbuf)) { errstr(_("Can't resolve mountpoint path %s: %s\n"), mnt->mnt_dir, strerror(errno)); free((char *)devname); continue; } + if (flags & MS_NO_AUTOFS && !strcmp(mnt->mnt_type, MNTTYPE_AUTOFS)) { /* Autofs dir to remember? */ + if (autofsdircnt == AUTOFS_DIR_MAX) + die(3, "Too many autofs mountpoints. Please contact <jack@suse.cz>\n"); + sstrncpy(autofsdir[autofsdircnt++], mntpointbuf, PATH_MAX); + continue; + } if (statfs(mntpointbuf, &fsstat) != 0) { errstr(_("Can't statfs() %s: %s\n"), mntpointbuf, strerror(errno)); free((char *)devname); @@ -922,7 +942,7 @@ static int process_dirs(int dcnt, char **dirs, int flags) */ int init_mounts_scan(int dcnt, char **dirs, int flags) { - if (cache_mnt_table() < 0) + if (cache_mnt_table(flags) < 0) return -1; if (process_dirs(dcnt, dirs, flags) < 0) { end_mounts_scan(); @@ -105,7 +105,7 @@ int detect_quota_files(struct mntent *mnt, int type, int fmt); /* Create NULL-terminated list of handles for quotafiles for given mountpoints */ struct quota_handle **create_handle_list(int count, char **mntpoints, int type, int fmt, - int flags); + int ioflags, int mntflags); /* Dispose given list of handles */ int dispose_handle_list(struct quota_handle **hlist); @@ -123,6 +123,7 @@ int kern_quota_on(const char *dev, int type, int fmt); /* Flags for init_mounts_scan() */ #define MS_NO_MNTPOINT 0x01 /* Specified directory needn't be mountpoint */ +#define MS_NO_AUTOFS 0x02 /* Ignore autofs mountpoints */ /* Initialize mountpoints scan */ int init_mounts_scan(int dcnt, char **dirs, int flags); @@ -5,7 +5,7 @@ repquota \- summarize quotas for a filesystem .SH SYNOPSIS .B /usr/sbin/repquota [ -.B \-vsug +.B \-vsiug ] [ .B \-c | @@ -22,7 +22,7 @@ repquota \- summarize quotas for a filesystem .LP .B /usr/sbin/repquota [ -.B \-avtsug +.B \-avtsiug ] [ .B \-c | @@ -95,6 +95,9 @@ Don't resolve UIDs/GIDs to names. This can speedup printing a lot. Try to report used space, number of used inodes and limits in more appropriate units than default ones. .TP +.B \-i +Ignore mountpoints mounted by automounter. +.TP .B \-F \f2format-name\f1 Report quota for specified format (ie. don't perform format autodetection). Possible format names are: @@ -32,6 +32,7 @@ #define FL_SHORTNUMS 32 /* Try to print space in appropriate units */ #define FL_NONAME 64 /* Don't translate ids to names */ #define FL_NOCACHE 128 /* Don't cache dquots before resolving */ +#define FL_NOAUTOFS 256 /* Ignore autofs mountpoints */ int flags, fmt = -1; char **mnt; @@ -42,7 +43,7 @@ char *progname; static void usage(void) { - errstr(_("Utility for reporting quotas.\nUsage:\n%s [-vugs] [-c|C] [-t|n] [-F quotaformat] (-a | mntpoint)\n"), progname); + errstr(_("Utility for reporting quotas.\nUsage:\n%s [-vugsi] [-c|C] [-t|n] [-F quotaformat] (-a | mntpoint)\n"), progname); fprintf(stderr, _("Bugs to %s\n"), MY_EMAIL); exit(1); } @@ -52,7 +53,7 @@ static void parse_options(int argcnt, char **argstr) int ret; int cache_specified = 0; - while ((ret = getopt(argcnt, argstr, "VavughtsncCF:")) != -1) { + while ((ret = getopt(argcnt, argstr, "VavughtsncCiF:")) != -1) { switch (ret) { case '?': case 'h': @@ -85,6 +86,9 @@ static void parse_options(int argcnt, char **argstr) case 'c': cache_specified = 1; break; + case 'i': + flags |= FL_NOAUTOFS; + break; case 'F': if ((fmt = name2fmt(optarg)) == QF_ERROR) exit(1); @@ -258,9 +262,9 @@ static void report(int type) int i; if (flags & FL_ALL) - handles = create_handle_list(0, NULL, type, fmt, IOI_LOCALONLY | IOI_READONLY | IOI_OPENFILE); + handles = create_handle_list(0, NULL, type, fmt, IOI_LOCALONLY | IOI_READONLY | IOI_OPENFILE, (flags & FL_NOAUTOFS ? MS_NO_AUTOFS : 0)); else - handles = create_handle_list(mntcnt, mnt, type, fmt, IOI_LOCALONLY | IOI_READONLY | IOI_OPENFILE); + handles = create_handle_list(mntcnt, mnt, type, fmt, IOI_LOCALONLY | IOI_READONLY | IOI_OPENFILE, (flags & FL_NOAUTOFS ? MS_NO_AUTOFS : 0)); for (i = 0; handles[i]; i++) report_it(handles[i], type); dispose_handle_list(handles); @@ -262,9 +262,9 @@ int main(int argc, char **argv) init_kernel_interface(); if (flags & FL_ALL) - handles = create_handle_list(0, NULL, flag2type(flags), fmt, (flags & FL_RPC) ? 0 : IOI_LOCALONLY); + handles = create_handle_list(0, NULL, flag2type(flags), fmt, (flags & FL_RPC) ? 0 : IOI_LOCALONLY, 0); else - handles = create_handle_list(mntcnt, mnt, flag2type(flags), fmt, (flags & FL_RPC) ? 0 : IOI_LOCALONLY); + handles = create_handle_list(mntcnt, mnt, flag2type(flags), fmt, (flags & FL_RPC) ? 0 : IOI_LOCALONLY, 0); if (flags & FL_GRACE) setgraces(handles); diff --git a/warnquota.8 b/warnquota.8 index cd39cef..d9dfe32 100644 --- a/warnquota.8 +++ b/warnquota.8 @@ -4,7 +4,7 @@ warnquota \- send mail to users over quota .SH SYNOPSIS .B warnquota [ -.B \-ug +.B \-ugi ] [ .B \-F .I quotaformat @@ -64,6 +64,9 @@ check whether users are not exceeding quotas (default). .B -g check whether groups are not exceeding quotas. If group is exceeding quota a mail is sent to the user specified in /etc/quotagrpadmins. +.TP +.B \-i +ignore mountpoints mounted by automounter. .SH FILES .PD 0 .TP 20 diff --git a/warnquota.c b/warnquota.c index f973fa6..220f9f8 100644 --- a/warnquota.c +++ b/warnquota.c @@ -10,7 +10,7 @@ * * Author: Marco van Wieringen <mvw@planets.elm.net> * - * Version: $Id: warnquota.c,v 1.11 2002/07/23 15:59:27 jkar8572 Exp $ + * Version: $Id: warnquota.c,v 1.12 2003/02/14 18:50:17 jkar8572 Exp $ * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -75,6 +75,7 @@ #define FL_USER 1 #define FL_GROUP 2 +#define FL_NOAUTOFS 4 struct usage { char *devicename; @@ -578,7 +579,7 @@ void warn_quota(void) exit(1); if (flags & FL_USER) { - handles = create_handle_list(0, NULL, USRQUOTA, -1, IOI_LOCALONLY | IOI_READONLY | IOI_OPENFILE); + handles = create_handle_list(0, NULL, USRQUOTA, -1, IOI_LOCALONLY | IOI_READONLY | IOI_OPENFILE, (flags & FL_NOAUTOFS ? MS_NO_AUTOFS : 0)); for (i = 0; handles[i]; i++) handles[i]->qh_ops->scan_dquots(handles[i], check_offence); dispose_handle_list(handles); @@ -586,7 +587,7 @@ void warn_quota(void) if (flags & FL_GROUP) { if (get_groupadmins() < 0) exit(1); - handles = create_handle_list(0, NULL, GRPQUOTA, -1, IOI_LOCALONLY | IOI_READONLY | IOI_OPENFILE); + handles = create_handle_list(0, NULL, GRPQUOTA, -1, IOI_LOCALONLY | IOI_READONLY | IOI_OPENFILE, (flags & FL_NOAUTOFS ? MS_NO_AUTOFS : 0)); for (i = 0; handles[i]; i++) handles[i]->qh_ops->scan_dquots(handles[i], check_offence); dispose_handle_list(handles); @@ -598,14 +599,14 @@ void warn_quota(void) /* Print usage information */ static void usage(void) { - errstr(_("Usage:\n warnquota [-ug] [-F quotaformat] [-c configfile] [-q quotatabfile]\n")); + errstr(_("Usage:\n warnquota [-ugi] [-F quotaformat] [-c configfile] [-q quotatabfile]\n")); } static void parse_options(int argcnt, char **argstr) { int ret; - while ((ret = getopt(argcnt, argstr, "ugVF:hc:q:a:")) != -1) { + while ((ret = getopt(argcnt, argstr, "ugVF:hc:q:a:i")) != -1) { switch (ret) { case '?': case 'h': @@ -632,6 +633,9 @@ static void parse_options(int argcnt, char **argstr) case 'g': flags |= FL_GROUP; break; + case 'i': + flags |= FL_NOAUTOFS; + break; } } if (!(flags & FL_USER) && !(flags & FL_GROUP)) |