Plus/RegexFilter

From DrFTPD

Jump to: navigation, search

Plus / RegexFilter

DrFTPD+ Documentation
The + means better

About DrFTPD+

        Features List Edit
FindNuke, IRCUserManagement, RegexFilter, SpeedLimit, Miscellaneus, ZipScript+
Other guidance

Wikipedia:Regex

Contents

Regex Path/File Filter

Initially commited in r1502

Description

A perms.conf regular expression permissions system similar to [GlobalCheck] by k2r, but more featureful (and we feel the code is cleaner). Since we already had this written when he released GlobalCheck, we have never actually tested his, since we already have the same features, but more functionality.

This feature is an approach to regex filtering. This regex filters can be used on different situations, see the list below:

  • MKD - Making directories.
  • STOR - Storing files.
  • RETR - Retrieving files.
  • RNFR - Renaming from.
  • RNTO - Renaming to.
  • WIPE - Wiping.

This plugin provides real nice error messages, if you can make a very precise regex.

Ex: 530 Access denied (The string "XXXXXX" not allowed in this directory name)

Important: All filters use the fullpath against the check.

Configuration

Configuration of this feature is done in perms.conf. If you don't configure any filters, you are effectively completely disabling this mod, so if you don't want it, you are not obligated to use it at all.

Here's how it works:

# This a Regexp filter
# This filter ALWAYS use the complete path of a file or a direcory
# Eg.1:
# Current Path = /TEST.DIR/ -> MKD TEST
# The filter will see this as 'MKD /TEST.DIR/TEST/'
# Eg.2:
# Current Path = /TEST.DIR/ -> STOR test.upload
# The filter will see this as 'STOR /TEST.DIR/test.upload'
#
# Syntax:
# filter 	<MKD|STOR|RETR|RNTO|RNFR|WIPE>	regexp					perms


Here's a few examples, as we have more time, we will eventually fill this in with some more details explaining what each line does and how the error messages are generated if a command matches a filter. And we'll show this by providing sample input/output. For now, this will have to suffice:

##########
## STOR ##
##########

#Filter autorenamed files like blah(2).nfo 
filter STOR (\([0-9]+\)\.)[a-z0-9]{3}$ =siteop !*

#Filter nfo's from being uploaded into certain directory names
filter STOR /((?:(?:cd|dis[ck])[a-f0-9]+|sample|subs/).*\.nfo)$ =siteop !*

#Filter sfv's in Covers/Sample dirs 
filter STOR /((?:covers|sample)/.*\.sfv)$ !*

#Only allow filenames with the defined allowed chars 
filter STOR ([^/a-z0-9()._-]) !*

#########
## MKD ##
#########

#Filter dirs like /release/cd1/release 
filter MKD /(([^/]+)/([^/]+)/([^/]+)/(\2|\3|\4))$ =siteop !* 
filter MKD /(([^/]+)/([^/]+)/(\2|\3))$ =siteop !* 
filter MKD /(([^/]+)/\2)$ =siteop !* 

#Only allow dirnames with the defined allowed chars 
filter MKD ([^/a-z0-9()._-]) !*

##########
## RNTO ##
##########

#Never allow renaming to [NUKED]- dirs
filter RNTO (\[NUKED\]-) =siteop !*

Bugs/Known Issues

RNFR and RNTO doesnt take full path, as far as i remember, this needs to be fixed.


Related Links

Personal tools
SourceForge.net Logo