Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

creditloss breaks if user has leech/ratio 0 and you set a creditloss #255

Open
flasherss opened this issue Nov 14, 2021 · 12 comments
Open
Milestone

Comments

@flasherss
Copy link

Describe the bug*
If a user has leech/ratio 0 and you set a creditloss for the group the user is in or that specific user they can't download even though they have leech/ratio 0. If you give them credits then it will work.

To Reproduce
Steps to reproduce the behavior:

  1. Change user to ratio 0 and make sure they have 0 credits or negative credits. Ratio: 0.0 Credits: 0B
  2. Add to perms config
    creditloss /TEST/* 4 =grp -testuser
  3. Login to ftp and try to download something from that specific section under the testuser
  4. Error RETR test.sample.mkv
    550 Not enough credits

Expected behavior
Before when using creditloss if a user has leech/ratio 0 it would not affect the user due to them having unlimited credits

DrFTPD

  • OS: Debian
  • Java version openjdk 15.0.2 2021-01-19
    OpenJDK Runtime Environment AdoptOpenJDK (build 15.0.2+7)
    OpenJDK 64-Bit Server VM AdoptOpenJDK (build 15.0.2+7, mixed mode, sharing)
  • DrFTPD version 4.0.7 but I assume has not worked since version 4 came along
@mvangoor
Copy link
Contributor

Hello @flasherss,

I have checked the code and this particular plugin (stats) has not been touched since 3.4.3.

Reading the code it would appear that this "creditloss" config is a global overwrite on the user ratio.

Can you provide more information regarding which version this might have worked differently?

@flasherss
Copy link
Author

flasherss commented Nov 14, 2021

Hi @mvangoor,

It has been a while since I have used it so not sure when it may of changed so maybe it changed between dr2 and dr 3.
I can't remember if it worked the way I am thinking so it may of been this way always.

I am assuming it was setup to by how glftpd handles it when set to where if a user a ratio 0/leech then they are excluded from the creditloss check since they have unlimited credits

If you look at

It says that if a user has ratio 0 then it should allow them unless they have negative credits but it does not currently.

@mvangoor
Copy link
Contributor

mvangoor commented Nov 6, 2022

Hi @flasherss,

It has been a while, sorry for that...

I am unable to reproduce this on latest master.
Checking code this should guard against your scenario:
https://github.com/drftpd-ng/drftpd/blob/3.4.3/src/plugins/org.drftpd.plugins.stats/src/org/drftpd/plugins/stats/StatsPreHook.java#L51-L53

Please let me know if you can still reproduce this.

@flasherss
Copy link
Author

flasherss commented Nov 9, 2022

Hi @mvangoor,

I installed DrFTPD 4.0.9 version and java 17 version and it still gives the same error as before.

  • testuser shows no credits and the user is ratio 0

200- Username: testuser Created: Wed Nov 09 01:20:46 CET 2022
200- Comment: Added by test Last seen: Wed Nov 09 01:28:51 CET 2022
200- Total logins: 3
200- Idle time: 300 Weekly Allotment: 0
200- Ratio: 0.0 Credits: 0B

  • From client as testuser

TYPE I
200 Command okay
PRET RETR testing.sample.mkv
200 OK, planning for upcoming download
PASV
227- Using test for upcoming transfer
227 Entering Passive Mode (x,x,x,x,136,141).
Opening data connection IP: x.x.x.x PORT: xxx
RETR testing.sample.mkv
550 Not enough credits
[i] Failed 1 file(s) and Skipped 0 file(s)

  • Java Version
    openjdk 17.0.5 2022-10-18
    OpenJDK Runtime Environment Temurin-17.0.5+8 (build 17.0.5+8)
    OpenJDK 64-Bit Server VM Temurin-17.0.5+8 (build 17.0.5+8, mixed mode, sharing)

@ghost ghost added this to the 4.0.X-dev milestone Mar 26, 2023
@ghost
Copy link

ghost commented Mar 28, 2023

Hello @flasherss
Confirmed issue...

@ghost
Copy link

ghost commented Mar 28, 2023

add import :

import org.drftpd.master.commands.usermanagement.*;

replace with :

            if (user.getKeyedMap().getObjectFloat(UserManagement.RATIO) == 0) {
                request.setAllowed(true);
            } else if (userCredits < creditsLoss) {
                // this comparison doesn't allow a user with negative credits,
                // but a 0 ratio to download files :)
                request.setAllowed(false);
                request.setDeniedResponse(new CommandResponse(550, "Not enough credits"));
            }

and test again please

@flasherss
Copy link
Author

Hi @zc0nf,

Where are you wanting me to add what you said as I am not understanding where you want me to add and replace to test.

Thank you

@mike-codez
Copy link
Contributor

Hi @flasherss,

I tested with a brand new installation added a user gave him ratio 0.
Tried to download a file and it worked fine.

Only scenario I can think of is when you setup creditloss in perms.conf.
This overrides the ratio in the current code base.

Could that be it?

@flasherss
Copy link
Author

flasherss commented Nov 5, 2023 via email

@mike-codez
Copy link
Contributor

Hello @flasherss,

If you can confirm that you have a creditloss statement in perms.conf, then we can explain it.

The follow-up question is whether this is expected/wanted behaviour, but that is step 2.

@flasherss
Copy link
Author

flasherss commented Nov 6, 2023 via email

@mike-codez
Copy link
Contributor

Hello @flasherss,

Thank you for confirming as I do not have that statement in the configurations on my end and therefor the test results differ.

As stated before this is the way creditloss and creditcheck have worked for years in drftpd.

Based on that this is not a bug BUT a "working as designed" kind of thing.

Best way forward would be to provide a config option to change this behaviour so people can influence it.

I'll discuss internally to see what the best course forward actually is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants