Description of problem: No idea what's causing this. It's running in daemon mode, but if I try to run from command line (to see why entries in my /var/log/secure don't seem to be in hosts.deny), it doesn't run: python /usr/bin/denyhosts.py --debug -c /etc/denyhosts.conf --file /var/log/secure Could not find environment variable: HOSTNAME echo $HOSTNAME nbecker Version-Release number of selected component (if applicable): denyhosts-2.6-7.fc8 How reproducible: Steps to Reproduce: 1. 2. 3. Actual results: Expected results: Additional info:
That output doesn't look like it comes from the currently shipping initscript. Are you sure your package is installed correctly? Try rpm -V denyhosts. The initscript sets HOSTNAME explicitly and very early: # Make sure HOSTNAME is in the environment so denyhosts can # use it in report subjects HOSTNAME=$(hostname) export HOSTNAME so unless you don't have a /bin/hostname binary I don't see how it could possibly not be set.
And it looks like I can't read, sorry; someone else had reported a problem that the initscript didn't get updated properly and it had exactly the same symptoms. Honestly, the only think I can think of is that HOSTNAME isn't exported from your environment. I can't see anything there that looks like a bug in denyhosts.
And what about the fact that I can't run it from the command line, and as I showed, HOSTNAME _is_ set?
You showed that it's set, bou didn't show that it's exported from your environment. My apologies if I assumed in error that you would know what that meant; perhaps this will illustrate: > echo $B > B=blah > echo $B blah > sh -c 'echo $B' > export B > sh -c 'echo $B' blah See, it is possible to have a variable which is set for your current shell but not passed on to programs which are run from that shell. So try typing "export HOSTNAME" and then trying. All denyhosts is doing is trying to expand the environment variables so that it can fill in SMTP_SUBJECT, and all it does is this: env = os.environ.get(name) if not env: die("Could not find environment variable: %s" % name) and that's simple enough that I can't see how HOSTNAME could be exported from your environment and yet not accessible to that code. If that still doesn't work, though, you can change /etc/denyhosts.conf and remove the "$[HOSTNAME]" bit from SMTP_SUBJECT and see if it will start without it. One other thing which comes to mind, although I can't imagine why it would matter, is that you can just run /usr/bin/denyhosts.py directly and not call it with python. I guess it's possible for python to have some kind of environment cleansing feature, although I can't imagine why it would do so.
So I've tried some more, and I simply can't come up with any situation where you'd see what you're seeing except the one where HOSTNAME is set but not exported: [root@temp2 ~]# unset HOSTNAME [root@temp2 ~]# echo $HOSTNAME [root@temp2 ~]# python /usr/bin/denyhosts.py --debug -c /etc/denyhosts.conf --file /var/log/secure Could not find environment variable: HOSTNAME [root@temp2 ~]# HOSTNAME=temp2.math.uh.edu [root@temp2 ~]# python /usr/bin/denyhosts.py --debug -c /etc/denyhosts.conf --file /var/log/secure Could not find environment variable: HOSTNAME [root@temp2 ~]# export HOSTNAME [root@temp2 ~]# python /usr/bin/denyhosts.py --debug -c /etc/denyhosts.conf --file /var/log/secure Debug mode enabled. DenyHosts configuration settings: ADMIN_EMAIL: [root] AGE_RESET_INVALID: [864000] ...
I was originally trying to find out why I had entries in /var/log/secure that weren't being added to hosts.deny. I am getting (lots) of entries via the net download. I guess close for now, I'll look again later and see if there is still an issue. Thanks for your help.