"Mitch (WebCob)" <[EMAIL PROTECTED]> writes:
> Is there a way to have my central /etc/tmdarc pass options on the config
> vars by settings in the environment?
>
> I've already got a mechanism in my MDA which allows me to set env vars based
> on user preferences, and I'd like to use that to specify common features
> such as whitelist stuff etc.
>
> Any thoughts?
>
> I know nothing about Python, but as this file is supposed to be executable
> (the options file) can't I somehow set a value based on an env var?
Sure. For example, to set the default message behavior per user, that
is, to set ACTION_INCOMING based on an environment variable I've just
invented called USER_DEFAULT_ACTION, use Python code like this:
ACTION_INCOMING = os.environ.get('USER_DEFAULT_ACTION', 'confirm')
This will set ACTION_INCOMING to whatever $USER_DEFAULT_ACTION is or,
if the environment variable doesn't exist, to 'confirm'.
For file paths, something like the following might be easier. Note:
TMDA's default for FILTER_INCOMING is "~/.tmda/filters/incoming",
which is already user-specific. If, however, you have "virtual" users
without home directories, perhaps in /var/spool/mail, '~' won't expand
to anything, so you might use something like the following. Here I'm
assuming that $USER has been set by your MDA:
FILTER_INCOMING = os.path.expandvars('/var/spool/mail/$USER/.tmda/filters/incoming')
This isn't necessarily the best way to go about creating user-specific
.tmda/ directories (see docs on DATADIR), but should serve as a
concrete Python code example for accessing environment variables in a
pathname.
Tim
_____________________________________________
tmda-users mailing list ([EMAIL PROTECTED])
http://tmda.net/lists/listinfo/tmda-users