[Kde-games-devel] KHighscore on multiple user systems
Nicolas Hadacek
hadacek at kde.org
Sun May 11 10:50:14 CEST 2003
Hi,
[I am cross-posting kde-core since there are some issues about "setgid"
programs and I think more knowlegeable people are on this list.]
There was from long time ago some support for using a global highscore file
for every user on a system but there were still two problems to solve. The
provided patch resolves both but I'd like to have some comments:
1. the global highscore file ("mygame.scores" usually in /var/games) should
allow write access to the "games" group (a user must not be able to modify
it...). To modify it, a game program should be "setgid games". My solution is
to drop this effective group id as soon as possible (before creating
KApplication) and then to renable it shortly when needed.
2. there should be a locking mechanism for modifying the file so that
different users playing at the same time do not mangle everything...
I am implementing that with "flock()".
The complete procedure is:
set "games" group id
open global file read only
flock it (if possible)
drop "games" group id
create a temporary file (in /tmp) and copy the global file in it
create a KSimpleConfig on the temp file
...
write new highscores data
...
commit changes to the temporary file
set "games" gid
truncate global file
copy temporary file to global file
drop "games" gid
remove temporary file
unlock global file
I have done some tests which are quite succesful...
What still need to be addressed is having the program executable being "setgig
games" at installation and creating the global highscore file with the
correct permissions if it does not exist.
Any comments ?
see you,
Nicolas
-------------- next part --------------
A non-text attachment was scrubbed...
Name: khighscore.diff
Type: text/x-diff
Size: 13127 bytes
Desc: not available
Url : http://mail.kde.org/pipermail/kde-games-devel/attachments/20030511/c1479780/khighscore.bin
More information about the kde-games-devel
mailing list