|
Lines 89-95
Link Here
|
| 89 |
int editit __P((char *)); |
89 |
int editit __P((char *)); |
| 90 |
void freeprivs __P((struct quotause *)); |
90 |
void freeprivs __P((struct quotause *)); |
| 91 |
int getentry __P((char *, int)); |
91 |
int getentry __P((char *, int)); |
| 92 |
struct quotause *getprivs __P((long, int)); |
92 |
struct quotause *getprivs __P((long, int, char *)); |
| 93 |
int hasquota __P((struct fstab *, int, char **)); |
93 |
int hasquota __P((struct fstab *, int, char **)); |
| 94 |
void putprivs __P((long, int, struct quotause *)); |
94 |
void putprivs __P((long, int, struct quotause *)); |
| 95 |
int readprivs __P((struct quotause *, char *)); |
95 |
int readprivs __P((struct quotause *, char *)); |
|
Lines 109-114
Link Here
|
| 109 |
register uid_t startuid, enduid; |
109 |
register uid_t startuid, enduid; |
| 110 |
char *protoname, *cp, ch; |
110 |
char *protoname, *cp, ch; |
| 111 |
int tflag = 0, pflag = 0; |
111 |
int tflag = 0, pflag = 0; |
|
|
112 |
char *fspath = NULL; |
| 112 |
char buf[30]; |
113 |
char buf[30]; |
| 113 |
|
114 |
|
| 114 |
if (argc < 2) |
115 |
if (argc < 2) |
|
Lines 116-123
Link Here
|
| 116 |
if (getuid()) |
117 |
if (getuid()) |
| 117 |
errx(1, "permission denied"); |
118 |
errx(1, "permission denied"); |
| 118 |
quotatype = USRQUOTA; |
119 |
quotatype = USRQUOTA; |
| 119 |
while ((ch = getopt(argc, argv, "ugtp:")) != -1) { |
120 |
while ((ch = getopt(argc, argv, "ugtf:p:")) != -1) { |
| 120 |
switch(ch) { |
121 |
switch(ch) { |
|
|
122 |
case 'f': |
| 123 |
fspath = optarg; |
| 124 |
break; |
| 121 |
case 'p': |
125 |
case 'p': |
| 122 |
protoname = optarg; |
126 |
protoname = optarg; |
| 123 |
pflag++; |
127 |
pflag++; |
|
Lines 140-146
Link Here
|
| 140 |
if (pflag) { |
144 |
if (pflag) { |
| 141 |
if ((protoid = getentry(protoname, quotatype)) == -1) |
145 |
if ((protoid = getentry(protoname, quotatype)) == -1) |
| 142 |
exit(1); |
146 |
exit(1); |
| 143 |
protoprivs = getprivs(protoid, quotatype); |
147 |
protoprivs = getprivs(protoid, quotatype, fspath); |
| 144 |
for (qup = protoprivs; qup; qup = qup->next) { |
148 |
for (qup = protoprivs; qup; qup = qup->next) { |
| 145 |
qup->dqblk.dqb_btime = 0; |
149 |
qup->dqblk.dqb_btime = 0; |
| 146 |
qup->dqblk.dqb_itime = 0; |
150 |
qup->dqblk.dqb_itime = 0; |
|
Lines 173-179
Link Here
|
| 173 |
tmpfd = mkstemp(tmpfil); |
177 |
tmpfd = mkstemp(tmpfil); |
| 174 |
fchown(tmpfd, getuid(), getgid()); |
178 |
fchown(tmpfd, getuid(), getgid()); |
| 175 |
if (tflag) { |
179 |
if (tflag) { |
| 176 |
protoprivs = getprivs(0, quotatype); |
180 |
protoprivs = getprivs(0, quotatype, fspath); |
| 177 |
if (writetimes(protoprivs, tmpfd, quotatype) == 0) |
181 |
if (writetimes(protoprivs, tmpfd, quotatype) == 0) |
| 178 |
exit(1); |
182 |
exit(1); |
| 179 |
if (editit(tmpfil) && readtimes(protoprivs, tmpfil)) |
183 |
if (editit(tmpfil) && readtimes(protoprivs, tmpfil)) |
|
Lines 186-192
Link Here
|
| 186 |
for ( ; argc > 0; argc--, argv++) { |
190 |
for ( ; argc > 0; argc--, argv++) { |
| 187 |
if ((id = getentry(*argv, quotatype)) == -1) |
191 |
if ((id = getentry(*argv, quotatype)) == -1) |
| 188 |
continue; |
192 |
continue; |
| 189 |
curprivs = getprivs(id, quotatype); |
193 |
curprivs = getprivs(id, quotatype, fspath); |
| 190 |
if (writeprivs(curprivs, tmpfd, *argv, quotatype) == 0) |
194 |
if (writeprivs(curprivs, tmpfd, *argv, quotatype) == 0) |
| 191 |
continue; |
195 |
continue; |
| 192 |
if (editit(tmpfil) && readprivs(curprivs, tmpfil)) |
196 |
if (editit(tmpfil) && readprivs(curprivs, tmpfil)) |
|
Lines 202-211
Link Here
|
| 202 |
usage() |
206 |
usage() |
| 203 |
{ |
207 |
{ |
| 204 |
fprintf(stderr, "%s\n%s\n%s\n%s\n", |
208 |
fprintf(stderr, "%s\n%s\n%s\n%s\n", |
| 205 |
"usage: edquota [-u] [-p username] username ...", |
209 |
"usage: edquota [-u] [-f fspath] [-p username] username ...", |
| 206 |
" edquota -g [-p groupname] groupname ...", |
210 |
" edquota -g [-f fspath] [-p groupname] groupname ...", |
| 207 |
" edquota [-u] -t", |
211 |
" edquota [-u] -t [-f fspath]", |
| 208 |
" edquota -g -t"); |
212 |
" edquota -g -t [-f fspath]"); |
| 209 |
exit(1); |
213 |
exit(1); |
| 210 |
} |
214 |
} |
| 211 |
|
215 |
|
|
Lines 247-255
Link Here
|
| 247 |
* Collect the requested quota information. |
251 |
* Collect the requested quota information. |
| 248 |
*/ |
252 |
*/ |
| 249 |
struct quotause * |
253 |
struct quotause * |
| 250 |
getprivs(id, quotatype) |
254 |
getprivs(id, quotatype, fspath) |
| 251 |
register long id; |
255 |
register long id; |
| 252 |
int quotatype; |
256 |
int quotatype; |
|
|
257 |
char *fspath; |
| 253 |
{ |
258 |
{ |
| 254 |
register struct fstab *fs; |
259 |
register struct fstab *fs; |
| 255 |
register struct quotause *qup, *quptail; |
260 |
register struct quotause *qup, *quptail; |
|
Lines 262-267
Link Here
|
| 262 |
quphead = (struct quotause *)0; |
267 |
quphead = (struct quotause *)0; |
| 263 |
qcmd = QCMD(Q_GETQUOTA, quotatype); |
268 |
qcmd = QCMD(Q_GETQUOTA, quotatype); |
| 264 |
while ((fs = getfsent())) { |
269 |
while ((fs = getfsent())) { |
|
|
270 |
if (fspath && *fspath && strcmp(fspath, fs->fs_spec) && |
| 271 |
strcmp(fspath, fs->fs_file)) |
| 272 |
continue; |
| 265 |
if (strcmp(fs->fs_vfstype, "ufs")) |
273 |
if (strcmp(fs->fs_vfstype, "ufs")) |
| 266 |
continue; |
274 |
continue; |
| 267 |
if (!hasquota(fs, quotatype, &qfpathname)) |
275 |
if (!hasquota(fs, quotatype, &qfpathname)) |