Date: Tue, 31 Aug 1999 23:42:44 -0500 (EST) From: Ben Vaughn <bvaughn@prophetnetworks.net> To: Evren Yurtesen <yurtesen@ispro.net.tr> Cc: "James F. Ruffer III" <freebsd@empireone.net>, freebsd-isp@FreeBSD.ORG Subject: setquota.c (Re: adduser) Message-ID: <Pine.BSF.4.10.9908312341100.45567-200000@shell01.prophetnetworks.net> In-Reply-To: <37CCAC11.7D11B2A2@ispro.net.tr>
next in thread | previous in thread | raw e-mail | index | archive | help
[-- Attachment #1 --]
Ive attached the source to setquota.c, a nifty prog that my friend dave
kirchner wrote for freebsd because it needs it. Syntax is:
setquota username 1M 5M filesystem
with the numbers being variable and the M being optional.
On Wed, 1 Sep 1999, Evren Yurtesen wrote:
> well you can copy 1 users quota settings with the -p option and
> you can say to the edquota that copy this settings to the UIDs between
> 1000-5000 this is working I have tried :)
>
> when you use adduser script it is giving the next available UID so
> you wont have trouble if that UID is one of the UIDs between 1000-5000
>
>
> "James F. Ruffer III" wrote:
>
> > basically i was using
> > edquota -p Quota username
> > this wil set it to a standard 20 mb soft 30 mb hard
> > im looking to set everyone at a 50 soft 60 hard
> > auto while adduser is running
> > i was being lazy by seeing if some one had a script already but i gues iill
> > have to code one
> > thankyou guys+dolls
> > ----- Original Message -----
> > From: Evren Yurtesen <yurtesen@ispro.net.tr>
> > To: James F. Ruffer III <freebsd@empireone.net>; <freebsd-isp@FreeBSD.ORG>
> > Sent: Tuesday, August 31, 1999 12:56 PM
> > Subject: Re: adduser
> >
> > > why do not you put a line to adduser script something like
> > > edquota -p 100 $UID
> > > well I am not sure what is the variable for UID in adduser script
> > > though,
> > > this would copy the quota settings of the account with uid 100 to the
> > > new account
> > > created...I believe this works even when you do not have an account with
> > > the
> > > $UID because I did something like edquota -p 100 1000-10000
> > > and now all the users have the same quotas automatically when I add them
> > >
> > > is this what you want to do?
> > >
> > > Evren
> > >
> > > "James F. Ruffer III" wrote:
> > >
> > > > hmm does anyone have a great adduser program that wil set repquota
> > > > while adding the user
> > > >
> > > > To Unsubscribe: send mail to majordomo@FreeBSD.org
> > > > with "unsubscribe freebsd-isp" in the body of the message
> > >
> > >
>
>
>
> To Unsubscribe: send mail to majordomo@FreeBSD.org
> with "unsubscribe freebsd-isp" in the body of the message
>
[-- Attachment #2 --]
/* (c) dpk */
#include <sys/types.h>
#include <ufs/ufs/quota.h>
#include <pwd.h>
int
main (int argc, char *argv[]) {
struct passwd *pw;
int uid;
int softblocks = 0;
int hardblocks = 0;
char *mntpoint;
char *softquota;
char *hardquota;
struct dqblk *block_c;
char *block = (char *)block_c;
if (argc != 5) {
printf ("usage: %s username softquota hardquota mountpoint\n", argv[0]);
return (1);
}
pw = getpwnam (argv[1]);
if (!pw) {
printf ("No such user: %s\n", argv[1]);
return (1);
}
uid = pw->pw_uid;
softquota = argv[2];
hardquota = argv[3];
mntpoint = argv[4];
softblocks = parsethingy (softquota);
hardblocks = parsethingy (hardquota);
if (softblocks > hardblocks) {
printf ("Error: softblocks > hardblocks\n");
return (2);
}
block_c->dqb_bsoftlimit = softblocks;
block_c->dqb_bhardlimit = hardblocks;
block_c->dqb_isoftlimit = 0;
block_c->dqb_ihardlimit = 0;
if (quotactl (mntpoint, QCMD(Q_SETQUOTA,0), uid, block) < 0) {
perror ("quotactl");
}
}
int
parsethingy (char *quota) {
int done = 0;
int blocks = 0;
while (*quota && !done) {
if (*quota > 47 && *quota < 58) {
blocks *= 10;
blocks += *quota - 48;
}
if (*quota == 'm' || *quota == 'M') {
blocks *= 1024;
done = 1; /* dump the chars after 'm' */
}
quota++;
}
blocks *= 2;
return (blocks);
}
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.10.9908312341100.45567-200000>
