antoinemartin / django-windows-tools

Django application providing management commands to host Django projects in Windows environments
BSD 2-Clause "Simplified" License
51 stars 13 forks source link

bugfix for non-english windows installations #10

Closed the-digital-engineer closed 9 years ago

the-digital-engineer commented 9 years ago

"manage.py winfcgi_install" fails on non-english localization, because the users group and the admins group have different (localized) names there.

import win32security

def users_group():

    # THE BUG

    # choose language by commenting
    #users_name='Users' # english
    users_name='Benutzer' # german

    explicit_users, domain, type = win32security.LookupAccountName ("", users_name)
    print 'the sid of the user group is %s'%win32security.ConvertSidToStringSid(explicit_users)

    # THE FIX

    WinBuiltinUsersSid=27 # not exported by win32security. according to WELL_KNOWN_SID_TYPE enumeration from http://msdn.microsoft.com/en-us/library/windows/desktop/aa379650%28v=vs.85%29.aspx
    well_known_users=win32security.CreateWellKnownSid(WinBuiltinUsersSid)
    print 'the sid of the user group is %s'%win32security.ConvertSidToStringSid(well_known_users)

    # PLAY SAFE

    assert(win32security.ConvertSidToStringSid(explicit_users)==win32security.ConvertSidToStringSid(well_known_users))

def admins_group():

    # THE BUG

    # choose language by commenting
    #admins_name='Administrators' # english
    admins_name='Administratoren' # german

    explicit_admins, domain, type = win32security.LookupAccountName ("", admins_name)
    print 'the sid of the admins group is %s'%win32security.ConvertSidToStringSid(explicit_admins)

    # THE FIX

    WinBuiltinAdministratorsSid=26 # not exported by win32security. according to WELL_KNOWN_SID_TYPE enumeration from http://msdn.microsoft.com/en-us/library/windows/desktop/aa379650%28v=vs.85%29.aspx
    well_known_admins=win32security.CreateWellKnownSid(WinBuiltinAdministratorsSid)
    print 'the sid of the admins group is %s'%win32security.ConvertSidToStringSid(well_known_admins)

    # PLAY SAFE

    assert(win32security.ConvertSidToStringSid(explicit_admins)==win32security.ConvertSidToStringSid(well_known_admins))

if __name__=='__main__':
    users_group()
    admins_group()
mrbean-bremen commented 9 years ago

See also issue #4. This project seems to be unmaintained since 2012...

the-digital-engineer commented 9 years ago

Hi MrBean.

This yields the question about a new maintainer. I'm too unreliable for such job. Still would support if someone applies.

Sincerely, mayk.

mrbean-bremen commented 9 years ago

Hi Mayk,

unfortunately, the same is true for me, though I could provide or review the occasional patch. The problem seems to be that the combination of IIS and django is (understandably) not really wide-spread. If Antoine is not following this any more, we may be out of luck anyway...

Cheers, Andreas

the-digital-engineer commented 9 years ago

Yes and no.

We do not need to put our full time effort into this. Just a little here and a little there to keep the software evolution going.

If both of us become moderators, there are good chances, that one of us is available to answer patches from anyone. This approach feels more comfortable to me than having all responsibility on one shoulder.

For the following suggestions please keep in mind, that I'm not too familiar with github's mechanisms yet.

(Option 1) : Looks like Antoine ignores his github account. I consider, how to contact Antoine outside of github. He may hand out the current master branch's privileges to us.

(Option 2) : We still can fork Antoine's original repo without barrier. Two or three support requests on Stackoverflow may "advertise" the new repository. This is the less ideal approach, I know. But still, it would keep dwt reasonably alive.

I experience a range of engineering organizations going towards python (django naturally following). Often they are catched in an MS-centric ICT-landscape. As long as they don't find answers on Google (with #1, #4 and #10 for example), they will skip django on MS servers and use stupid tools like ASP "for practical reasons".

mrbean-bremen commented 9 years ago

Agreed. I have to get familiar with github, too, but this sounds like a plan. Are you going to try option 1 (e.g. contact Antoine) first?

Regards, Andreas

antoinemartin commented 9 years ago

Hi guys,

I'm sorry but I don't have time to maintain this package. I developed it two years ago for a client that could not afford to run Django on Linux. I have no more access to a Windows Server installation.

I've added the two of you as contributors to the project in order for you to merge the pull requests. Your two pull requests seem to fix the internationalization issue with two different methods. I don't know which is best. I let you decide.

mrbean-bremen commented 9 years ago

Hi Antoine, thanks - we appreciate the work you have done, it is a great help if you don't have to fiddle with the IIS management tools yourself. About the fix - I did the easy thing and just copied the 2 lines from winservice_install.py, where it was already fixed. The fix from the-digital-engineer is a little nicer as it uses the magic SIDs more explicitly, so I would prefer that one (maybe adapting the other file the same way). @the-digital-engineer: feel free to merge your patch.

the-digital-engineer commented 9 years ago

@antoinemartin : Thank you for sharing. @mrbean-bremen : Thank for the compliment. Learned another lesson how to use github today. #10 finished.