mod_ifsession
For class-based qualifications, mod_ifsession will apply configuration directives to the current session as soon as the client has connected to the server; for user- and group-based qualifications, mod_ifsession applies configuration directives to the current session, if applicable, only after the client has successfully authenticated. This means that mod_ifsession cannot change the effect of some user- and group-qualified configuration directives, particularly those that influence the session prior to authentication. These directives include:
AccessDenyMsg AccessGrantMsg AnonRequirePassword <Anonymous> AuthGroupFile AuthUserFile CreateHome DefaultChdir DefaultRoot DefaultTransferMode DisplayConnect ExtendedLog MaxInstances RequireValidShell RootLogin ServerIdent ServerName ShowSymlinks TransferLog UseFtpUsers WtmpLog
mod_auth_pam
While the above list of configuration directives is daunting, there are still valid uses for this module, e.g. configuring <Directory> and/or <Limit> for certain sessions, Filter directives, transfer rates, maximum file sizes, etc. Plus, some of the above directives (e.g. DefaultChdir, DefaultRoot) already have their own configurable restrictions (group expressions in the case of DefaultChdir and DefaultRoot), so all is not entirely lost.
<Directory>
<Limit>
Filter
DefaultChdir
DefaultRoot
This module is contained in the contrib/mod_ifsession.c file for ProFTPD 1.2.x/1.3.x, and is not compiled by default. Installation instructions are discussed here.
contrib/mod_ifsession.c
The most current version of mod_ifsession is distributed with the ProFTPD source.
Please contact TJ Saunders <tj at castaglia.org> with any questions, concerns, or suggestions regarding this module.
<VirtualHost>
<Global>
The <IfAuthenticated> context should contain any configuration directives that should be in effect for any sessions where the client has successfully authenticated.
<IfAuthenticated>
Examples:
# Only configure SQL logging for authenticated users, to avoid cluttering # database tables with fail login data <IfAuthenticated> SQLLog ... </IfAuthenticated>
See also: <IfGroup>, <IfUser>
The <IfClass> context should contain any configuration directives that should be in effect for any sessions that match the class-expression. Classes must be enabled for this context to work properly; the connecting client must be in any of the classes listed in the expression for the directives contained to be applied. Note that ! notation in front of a class name in the expression is supported.
<IfClass>
Classes
!
The given class-expression may optionally be prefixed with either the "AND" or "OR" keywords, which affect how the expression is evaluated: if "AND" is used, then all portions of the expression must evaluate to TRUE for the configuration context to be applied to the current session; if "OR" is used, then any portion of the expression must be TRUE for the context to be applied. The default setting for <IfClass> is "OR".
If the "regex" keyword is used, the regexp should be a regular expression to match class names.
# Give friends, and local users, better transfer rates <IfClass local, friends> TransferRate RETR 8192 </IfClass> TransferRate RETR 4096
The <IfGroup> context should contain any configuration directives that should be in effect for any sessions that match the group-AND-expression. The authenticated user must be in all of the groups listed in the expression for the directives contained to be applied. Note that ! notation in front of a group name in the expression is supported.
<IfGroup>
The given group-expression may optionally be prefixed with either the "AND" or "OR" keywords, which affect how the expression is evaluated: if "AND" is used, then all portions of the expression must evaluate to TRUE for the configuration context to be applied to the current session; if "OR" is used, then any portion of the expression must be TRUE for the context to be applied. The default setting for <IfGroup> is "AND".
If the "regex" keyword is used, the regexp should be a regular expression to match group names.
Example:
# Only members of group webusers can upload/download HTML files <IfGroup !webusers> PathDenyFilter \.htm$|\.html$ </IfGroup>
See also: <IfClass>, <IfUser>
The IfSessionOptions directive is used to configure various optional behavior of mod_ifsession.
IfSessionOptions
IfSessionOptions PerUnauthenticatedUser
The currently implemented options are:
PerUnauthenticatedUser
By default, mod_ifsession will only use the authenticated identify of the remote client for conditional configurations, i.e. after the client has successfully authenticated.
However, some sites need to use different authentication-related conditional configurations, which means using the unauthenticated identity (usually the username requested). For such cases, use this option. Not recommended, as such conditional configurations can lead to timing differences, which can then be used to determine/test which usernames are valid for the site.
The <IfUser> context should contain any configuration directives that should be in effect for any sessions that match the user-OR-expression. The authenticated user must be one of the users listed in the expression for the directives contained to be applied. Note that ! notation in front of a user name in the expression is supported.
<IfUser>
The given user-expression may optionally be prefixed with either the "AND" or "OR" keywords, which affect how the expression is evaluated: if "AND" is used, then all portions of the expression must evaluate to TRUE for the configuration context to be applied to the current session; if "OR" is used, then any portion of the expression must be TRUE for the context to be applied. The default setting for <IfUser> is "OR".
If the "regex" keyword is used, the regexp should be a regular expression to match user names.
# Alter the view of files for everyone except the admin <IfUser !ftpadm> <Directory /> DirFakeUser on ~ DirFakeGroup on ~ DirFakeMode 0440 </Directory> </IfUser> # Impose a PathDenyFilter on ftp users <IfUser regex ^ftp> PathDenyFilter \.conf$ </IfUser>
See also: <IfClass>, <IfGroup>
As a Shared Module If your proftpd is compiled with mod_ifsession as a shared module, then you must make sure that mod_ifsession is loaded last:
proftpd
<IfModule mod_dso.c> LoadModule mod_sql.c LoadModule mod_sql_mysql.c LoadModule mod_tls.c LoadModule mod_rewrite.c LoadModule mod_ifsession.c </IfModule>
Todo Expressions, AND vs OR
$ ./configure --with-modules=mod_ifsession $ make $ make install
--with-modules
To build mod_ifsession as a DSO module:
$ ./configure --enable-dso --with-shared=mod_ifsession
$ make $ make install
Alternatively, if your proftpd was compiled with DSO support, you can use the prxs tool to build mod_ifsession as a shared module:
prxs
$ prxs -c -i -d mod_ifsession.c
Logging The mod_ifsession module supports trace logging, via the module-specific log channels:
proftpd.conf
TraceLog /path/to/ftpd/trace.log Trace ifsession:20