[Dovecot] file descriptor errors
Timo Sirainen
tss at iki.fi
Sun Dec 8 23:07:30 EET 2013
On 4.12.2013, at 13.47, Christian Rößner <cr at sys4.de> wrote:
>> Dec 4 08:53:37 mx dovecot: auth: Error: close failed in file object destructor:
>> Dec 4 08:53:37 mx dovecot: auth: Error: IOError: [Errno 9] Bad file descriptor
>
> I found the problem, but do not know, if my solution is okay. It is the checkpassword script that I wrote in python:
>
> …
> # Return data to Dovecot
> try:
> fd = os.fdopen(dovecot_out, "w")
> except:
> sl.syslog(sl.LOG_ERR,
> "Can not write to FD 4")
> sys.exit(1)
> os.write(fd.fileno(),
> "\tuserdb_uid=%i"
> "\tuserdb_gid=%i"
> % (uid, gid))
> #os.close(fd.fileno())
>
> try:
> os.putenv('USER', username)
> os.putenv('HOME', local_part_dir)
> except:
> sl.syslog(sl.LOG_WARN,
> "Can not set environment variables“)
> …
>
> When it comes to the os.close(fd.fileno()) call dovecot throws an error.
Dovecot doesn’t throw error, Python does. Dovecot just logs it. If os.write() succeeds for the fd, but os.close() immediately afterwards fails, I have no idea why it would be doing that.
> So for now, I leave the file descriptor open and wait for the script to terminate. I thought, I would have to close the descriptor after using it, do I?
Doesn’t really matter. The process dies immediately anyway.
More information about the dovecot
mailing list