Hi all, Im totally new here.
Here is step-by-step reproduction of a bug I’ve encountered after installation of rockstor:
- Enable samba
- Join domain controller by Win2008R2 which has groups/users with cyrillic names
- Wait for a while.
- Check users/group or try to set permission to a share.
- Thats it! You’ll receive two types of errors: “ascii codec cant decode” or just “not found” page.
after 2 days (yeah, im not great in python rly) of reversing I’ve found the way to fix it. The problem was in system calls:
/opt/rockstor/src/rockstor/system/users.py:def get_users
fix:
import chardet
def get_users(min_uid=5000, uname=None):
users = {}
for u in pwd.getpwall():
charset = chardet.detect( u.pw_name ) # fix
uname = u.pw_name.decode( charset['encoding'] ); # fix
users[uname] = (u.pw_uid, u.pw_gid,) # fix
return users
/opt/rockstor/src/rockstor/system/users.py:def get_groups
def get_groups(*gids):
groups = {}
if (len(gids) > 0):
for g in gids:
entry = grp.getgrgid(g)
charset = chardet.detect( entry.gr_name ) # fix
gr_name = entry.gr_name.decode( charset['encoding'] ) # fix
groups[gr_name] = entry.gr_gid # fix
else:
for g in grp.getgrall():
charset = chardet.detect( g.gr_name ) # fix
gr_name = g.gr_name.decode( charset['encoding'] ) # fix
groups[gr_name] = g.gr_gid # fix
return groups
/opt/rockstor/src/rockstor/storageadmin/models/user.py:def groupname
import chardet
def groupname(self, *args, **kwargs):
if (self.group is not None):
return self.group.groupname
if (self.gid is not None):
groupname = grp.getgrgid(self.gid).gr_name # fixed
charset = chardet.detect( groupname ) # fixed
groupname = groupname.decode( charset['encoding'] ) #fixed
return groupname # fixed
return None
Notice, that we use here “chardet” package of python.
I think it would be useful to community. Possible there is better solution.
Hope next release will be cured of this problem:slight_smile: