Mailing List Archive

mod_dav question
Hello list,

We are using mod_dav with apache2.4 to manage files via webdav protocol.
We want to limit file uploading based on the user's total storage.
For instance, if a user has his storage size reached to the max limit, he
can't upload files anymore.
Do you have any suggestions on how I can implement this by modperl?

Thanks in advance.
Yamada
Re: mod_dav question [ In reply to ]
Yamada-san,

Yamada??? wrote:
: We are using mod_dav with apache2.4 to manage files via webdav protocol.
: We want to limit file uploading based on the user's total storage.
: For instance, if a user has his storage size reached to the max limit, he
: can't upload files anymore.
: Do you have any suggestions on how I can implement this by modperl?

This depends on how exact do you want the limiting to be. It is possible,
for example, to write a PerlFixupHandler, hook on the PUT method, check
for the storage used by that user, and then return something like
Apache2::Const::HTTP_INSUFFICIENT_STORAGE or even ::FORBIDDEN if the
storage space is exceeded.

This does not catch the case when the user is below the allocated quota,
but a large PUT request exceeds it, nor the case when multiple PUT requests
are initiated at the same time. Depending on the backing storage, it could
even be possible to map the problem to a filesystem quota.

Hope this helps,

-Yenya

--
| Jan "Yenya" Kasprzak <kas at {fi.muni.cz - work | yenya.net - private}> |
| http://www.fi.muni.cz/~kas/ GPG: 4096R/A45477D5 |
We all agree on the necessity of compromise. We just can't agree on
when it's necessary to compromise. --Larry Wall
Re: mod_dav question [ In reply to ]
Yamada-san,

You would need to set up a perl response handler like:
<Location /webdav>
    SetHandler modperl
    PerlSetupEnv On
    PerlResponseHandler +Your::WebDav::Module
</Location>

and in your module Your::WebDav::Module you would write something like:

BEGIN
{
    use strict;
    use warnings;
    use Apache2::RequestRec ();
    use Apache2::Log ();
    use Apache2::Const -compile => qw( DECLINED OK :http );
    use Apache2::RequestUtil ();
    use Apache2::SubRequest ();
    use APR::Request ();
};

sub handler : method
{
    my $self = shift( @_ );
    # Do stuff to handle the request, accepting it, declining it, etc.
}

Kind regards,
Jacques Deguest
(incidentally Tokyo, Japan)

On 2022/01/11 13:49, Yamada??? wrote:
> Hello list,
>
> We are using mod_dav with apache2.4 to manage files via webdav protocol.
> We want to limit file uploading based on the user's total storage.
> For instance, if a user has his storage size reached to the max limit,
> he can't upload files anymore.
> Do you have any suggestions on how I can implement this by modperl?
>
> Thanks in advance.
> Yamada
Re: mod_dav question [ In reply to ]
????????
Thank you Jan and Jack
I will try to implement that.

Regards
Yamada


On Tue, Jan 11, 2022 at 4:10 PM Jacques Deguest <jack@deguest.jp> wrote:

> Yamada-san,
>
> You would need to set up a perl response handler like:
> <Location /webdav>
> SetHandler modperl
> PerlSetupEnv On
> PerlResponseHandler +Your::WebDav::Module
> </Location>
>
> and in your module Your::WebDav::Module you would write something like:
>
> BEGIN
> {
> use strict;
> use warnings;
> use Apache2::RequestRec ();
> use Apache2::Log ();
> use Apache2::Const -compile => qw( DECLINED OK :http );
> use Apache2::RequestUtil ();
> use Apache2::SubRequest ();
> use APR::Request ();
> };
>
> sub handler : method
> {
> my $self = shift( @_ );
> # Do stuff to handle the request, accepting it, declining it, etc.
> }
>
> Kind regards,
> Jacques Deguest
> (incidentally Tokyo, Japan)
>
> On 2022/01/11 13:49, Yamada??? wrote:
>
> Hello list,
>
> We are using mod_dav with apache2.4 to manage files via webdav protocol.
> We want to limit file uploading based on the user's total storage.
> For instance, if a user has his storage size reached to the max limit, he
> can't upload files anymore.
> Do you have any suggestions on how I can implement this by modperl?
>
> Thanks in advance.
> Yamada
>
>
>