Skip to content

os.getlogin() - Inappropriate ioctl for device (mod_wsgi)#39

@gvalkov

Description

@gvalkov

Using gitpython from within a mod_wsgi web app results in the following exception when trying to commit:

File"...GitPython-0.3.2.RC1-py2.6.egg/git/index/base.py", line887, incommitreturnCommit.create_from_tree(self.repo, tree, message, parent_commits, head) File"...GitPython-0.3.2.RC1-py2.6.egg/git/objects/commit.py", line302, increate_from_treecommitter=Actor.committer(cr) File"...GitPython-0.3.2.RC1-py2.6.egg/git/util.py", line354, incommitterreturncls._main_actor(cls.env_committer_name, cls.env_committer_email, config_reader) File"...GitPython-0.3.2.RC1-py2.6.egg/git/util.py", line327, in_main_actordefault_email=get_user_id() File"...GitPython-0.3.2.RC1-py2.6.egg/git/util.py", line120, inget_user_idusername=os.getlogin() OSError: [Errno25] Inappropriateioctlfordevice

A possible explanation might be that since apache/mod_wsgi are not started by a login shell, no call to setlogin() has been made (in order for getlogin() to succeed a previous call to setlogin() must have been made). Perhaps the problem is in mod_wsgi running in daemon mode. Either way, a more robust get_user_id() function would be nice.

A non-portable solution:

120: username=pwd.getpwuid(os.getuid()).pw_name

These could also be helpful:
http://defect.opensolaris.org/bz/show_bug.cgi?id=3595
http://www.agmweb.ca/blog/andy/2172/ (comment by Graham Dumpleton)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions