dgrant / eyefiserver2

A standalone Eye-Fi server in Python, for Linux
GNU General Public License v3.0
140 stars 40 forks source link

FIle owner problem #14

Closed dukesrg closed 9 years ago

dukesrg commented 9 years ago

Just noticed, if file UID=0, it is not set, properly. I have by default admin/admininstrators (UID/GID=0), The owner/group for .jpg and .log became eyefi/administrators (UID=502/GID=0). but XMP have no this rights issue. As soon as GID/SID changes, all three files get the correct GID.

dukesrg commented 9 years ago

For all three files there is a similar code to chown if uid != 0 and gid != 0: os.chown(xmpPath, uid, gid) XMP seems to be written initially with UID/SSID=0, so see no difference. I'll remove zero check and test

dukesrg commented 9 years ago

Tested with removed UID/GID zero check, worked fine on my QNAP (Linux version 3.4.6 (root@NasX86-12) (gcc version 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2))). Will be commited later with the changes on QNAP-QTS package

dgrant commented 9 years ago

Do you know why the "uid != 0 and gid != 0" was there in the first place?

dgrant commented 9 years ago

Ok, I get it now. "0" is the default, meaning uid and gid are "unset". Like null. Ok, I think we need to make it so that uid = self.server.config.getint('EyeFiServer','upload_uid') returns "-1" or "None" if upload_uid is unset in the config file. Then we can put the check back in.

dukesrg commented 9 years ago

I suspected it was something like default. For the original instance mode it make sence but not for the daemon mode.

dgrant commented 9 years ago

Ah, we set it to "0" by default in the file, so it is always there. If I comment it out "config.getint" throws an exception

dukesrg commented 9 years ago

Can we just put -1 there for the default UID/GID?

dukesrg commented 9 years ago

However it's not a good idea to set it by default just because WEB GUI have no value for that

dgrant commented 9 years ago

hehe, yeah that's exactly what I'm doing now, having -1 as the default. Then the default in the .ini can be that it is commented out

dgrant commented 9 years ago

I'm not sure how this affects the web ui as I've never used the web UI. I'll push my changes to a branch and you can see the change and we'll go from there.

dukesrg commented 9 years ago

In the WEB GUI combobox is used to select uid/guid. It is preloaded with the names from passwd/group, so I'll need to make some changes in cgi. I still have no idea how eyefi user was used be default whily my daemon is running, because this user was created for ftp uploads and never linked with the eyefiserver daemon :)

dgrant commented 9 years ago

Have a look at my commit, I created a branch for it: bugfix/14-file-owner-problem

dukesrg commented 9 years ago

The changes only in .py and .conf, right? Well the script works fine, uid/gid is set. However those settings can't be saved until commented. Can you commit to master only .py changes but keep default zeroes in .conf? I just assume one who wants to use a WEB GUI should not modify .conf manually, but one who experienced/needs to run in instance mode will edit .conf anyway.

dgrant commented 9 years ago

Sure, see latest commit. So you tested it? Go ahead and merge to master, or let me know if you are ok with this and I can merge to master.

dukesrg commented 9 years ago

Yes I've just tested successfully.Got admin/admins (0/0) with the commented one, which is as it should be IMO. And the selected UID/GID if uncomment. You can commit .py to master if agreed to keep .conf as it is now, i.e. with zeroes by default.