---
> (void) vsprintf(fmtbuf, fmt, ap);
922a928,995
>
>
> /*
> * UCB addition - Jerry B - March, 1998
> * quotas in kernel not working right so enforce here
> *
> * check if already over quota or message puts account over quota.
> * return 0 if ok, or error in checking, 1 if hit quota limit
> */
>
> #include <ufs/quota.h>
>
> quota_check ( uid, logon, fd )
> int uid;
> char *logon;
> int fd;
> {
> struct dqblk results;
> struct stat stat_info;
> int hard;
> int cur;
> int tmp_blocks;
> char quota_err_msg[200];
>
> if( quotactl( "/var/spool/mail",
> QCMD(Q_GETQUOTA,USRQUOTA), uid, &results ) ) {
> sprintf( quota_err_msg,
> "can't get quota info, ppid=%d, %s - quotactl fails, errno=%d",
> getppid(), logon, errno );
> warn( quota_err_msg );
> return(0);
> }
> hard = results.dqb_bhardlimit/2;
> cur = results.dqb_curblocks/2;
>
> /* check if has quota */
> if( hard == 0 ) return 0;
>
> /* check if currently over, or within an allocation unit */
> if( cur >= hard - 10 ) {
> sprintf( quota_err_msg,
> "ppid=%d, %s over quota", getppid(), logon );
> eval = EX_UNAVAILABLE;
> err( quota_err_msg );
> return(1);
> }
>
> /* check if message will put user over quota */
> if( fstat( fd, &stat_info ) != 0 ) {
> sprintf( quota_err_msg, "fstat failed, err=%d", errno );
> warn( quota_err_msg );
> return(0);
> }
>
> /* blocks are 512, even though st_blksize says 8192 */
> /* allocation is weird, so use st_size/1024 to get KB instead */
> tmp_blocks = stat_info.st_size/1024;
>
> if( cur + tmp_blocks >= hard ) {
> sprintf( quota_err_msg,
> "ppid=%d, %s: message of %d KB would hit quota",
> getppid(), logon, tmp_blocks );
> eval = EX_UNAVAILABLE;
> err( quota_err_msg );
> return(1);
> }
> return(0);
> }
Received on Mon May 11 1998 - 21:06:22 NZST
This archive was generated by hypermail 2.4.0 : Wed Nov 08 2023 - 11:53:37 NZDT