Re: permission to write to /usr/local/share/packagename

2013-10-12 Thread Beco
On 4 October 2013 18:09, Vincent Bernat ber...@debian.org wrote:
4 octobre 2013 22:56 CEST, Beco r...@beco.cc :


 On Debian, those high scores are usually stored in /var/games/X. The
 file permissions allow a user from the group games to write the
 file. See for example `monsterz`.
 --
 Make sure your code does nothing gracefully.
 - The Elements of Programming Style (Kernighan  Plauger)


Thanks Vincent,

I've downloaded Monsterz and it's quite good example.

Cheers,
Beco.



-- 
Dr Beco
A.I. researcher

Sometimes the heart sees what is invisible to the eye. (H. Jackson Brown Jr.)


-- 
To UNSUBSCRIBE, email to debian-mentors-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Archive: 
http://lists.debian.org/CALuYw2xpKa=43VUepxir3QG1QAvfc=aq6y8m3qiojqxfbjl...@mail.gmail.com



Re: permission to write to /usr/local/share/packagename

2013-10-05 Thread Gert Wollny
On Sat, 2013-10-05 at 00:02 -0300, Beco wrote:
 On 4 October 2013 22:56, Beco r...@beco.cc wrote:
  Hi mentors,
 
 [snip]
 
 
  I suppose that is all I have to do. But myapp still tells me
  permission denied.
 
 I got it working using something I was trying to avoid. SGID.
 
 chmod g+s mytouch

You shouldn't have to do this. Are you sure that you are in the games
group?, i.e. after adding yourself to the games group, did you logout
and login again? 

As member of the games group on my Debian system I can co 
  nano /var/games/some-games-file 
without problems, and nano is certainly not SGID. 

BTW: The freedesktop description Paul Wise linked to didn't talk about
the user being in the games group. The disadvantage of the user being in
the games group is of course that she can simple edit the highscore
file ;)

Cheers, 
Gert



-- 
To UNSUBSCRIBE, email to debian-mentors-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Archive: http://lists.debian.org/1380969819.5843.9.camel@localhost.localdomain



Re: permission to write to /usr/local/share/packagename

2013-10-05 Thread Beco
On 5 October 2013 07:43, Gert Wollny gw.foss...@gmail.com wrote:

[snip]

 chmod g+s mytouch

 You shouldn't have to do this. Are you sure that you are in the games
 group?, i.e. after adding yourself to the games group, did you logout
 and login again?

 As member of the games group on my Debian system I can co
   nano /var/games/some-games-file
 without problems, and nano is certainly not SGID.

 BTW: The freedesktop description Paul Wise linked to didn't talk about
 the user being in the games group. The disadvantage of the user being in
 the games group is of course that she can simple edit the highscore
 file ;)

 Cheers,
 Gert


Hi Gert,

Yep, now it worked. I probably forgot to login/logout! :)

Regarding the options (A) use SGID or (B) add all users to games group,
I'm (much) more inclined to only allow the binary to have such permissions!

Of course one can change the source and recompile, but the new binary wont
have the SGID set (I suppose).

And it is much more difficult to download a source, change the
program, recompile, etc.,
than just let some curious user use vi, or nano, or rm command.

Isn't that so?

Thanks man.

Beco.


-- 
To UNSUBSCRIBE, email to debian-mentors-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Archive: 
http://lists.debian.org/CALuYw2zSWk0mkeZv_fmjmimvOr_Ercf2=SREnCuKX7G-xfws=g...@mail.gmail.com



Re: permission to write to /usr/local/share/packagename

2013-10-04 Thread Andrey Rahmatullin
On Fri, Oct 04, 2013 at 04:58:10PM -0300, Beco wrote:
 Following the suggestion from Maysima (Linux-fan name?), after reading
 something about hierarchy, I'm using the following structure:
 
 /usr/local/game for the binary
 /usr/local/share/locale for the language file .mo
 /usr/local/share/packagename for the data file.
You shouldn't put anything in /usr/local.

 What I'm not getting is that I have no write permissions to this
 directory where the data will be.
Apps that run with user rights usually store their data in that user's
home directory. Do you really need to write the data into the global
location? What kind of data is it?

-- 
WBR, wRAR


signature.asc
Description: Digital signature


Re: permission to write to /usr/local/share/packagename

2013-10-04 Thread Hermann Sorgel

On 10/05/2013 12:12 AM, Andrey Rahmatullin wrote:
Apps that run with user rights usually store their data in that user's

home directory.


And /tmp directory for files that are required temporarily.


--
To UNSUBSCRIBE, email to debian-mentors-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Archive: http://lists.debian.org/524f2978.4090...@gmail.com



Re: permission to write to /usr/local/share/packagename

2013-10-04 Thread Beco
On 4 October 2013 17:12, Andrey Rahmatullin w...@wrar.name wrote:

 What I'm not getting is that I have no write permissions to this
 directory where the data will be.
 Apps that run with user rights usually store their data in that user's
 home directory. Do you really need to write the data into the global
 location? What kind of data is it?

 --
 WBR, wRAR


Hi Andrey,

Thanks for your attention. It's a game score (top 10 players).

I thought saving under $HOME, but then others players would see only
their own name.

Any suggestion?

Hi Hermann,

While tmp is a good idea for some other things I have here, in the
case of scores it would be better if the file is protected from
accidental deletion.

Thanks!

Cheers,

Beco.





--
Dr Beco
A.I. researcher

Sometimes the heart sees what is invisible to the eye. (H. Jackson Brown Jr.)


-- 
To UNSUBSCRIBE, email to debian-mentors-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Archive: 
http://lists.debian.org/caluyw2z44+9tn6ue4fspyxq6f7v8fpa4kan66r4ocodikd4...@mail.gmail.com



Re: permission to write to /usr/local/share/packagename

2013-10-04 Thread Vincent Bernat
 ❦  4 octobre 2013 22:56 CEST, Beco r...@beco.cc :

 What I'm not getting is that I have no write permissions to this
 directory where the data will be.
 Apps that run with user rights usually store their data in that user's
 home directory. Do you really need to write the data into the global
 location? What kind of data is it?

 Hi Andrey,

 Thanks for your attention. It's a game score (top 10 players).

 I thought saving under $HOME, but then others players would see only
 their own name.

On Debian, those high scores are usually stored in /var/games/X. The
file permissions allow a user from the group games to write the
file. See for example `monsterz`.
-- 
Make sure your code does nothing gracefully.
- The Elements of Programming Style (Kernighan  Plauger)


signature.asc
Description: PGP signature


Re: permission to write to /usr/local/share/packagename

2013-10-04 Thread Martin Eberhard Schauer

 Following the suggestion from Maysima (Linux-fan name?), after reading
 something about hierarchy, I'm using the following structure:

First of all, you've decided to work with Debian. I recommend not to use
$(random cookbook/advice), but Debian docs instead, asking here ore filing
bugs whenever your question is not/seems not to be answered (yet) in the
Debian docs.

 /usr/local/game for the binary
 /usr/local/share/locale for the language file .mo
 /usr/local/share/packagename for the data file.
 You shouldn't put anything in /usr/local.

When I dived into Linux, there was the following workflow:
 - download the tarball,
 - extract it (tar xzf),
 - cd into new directory -
 ./configure
 make
 make install

I'm quite shure that configure's default was to choose /usr/local and its
subdirectories as default. It was quite instructive as well to see that 
$PATH
did not include /usr/local ;-). Building some .rpm/.deb is different 
from the

workflow described in the last paragraph. Look for files such as READ.ME,
INSTALL, … And try ./configure --help.

 What I'm not getting is that I have no write permissions to this
 directory where the data will be.

There is a difference between building some software and installing it. You
need root rights for installations beyond your home directory.

Cheers,
   Martin


--
To UNSUBSCRIBE, email to debian-mentors-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Archive: http://lists.debian.org/524f31c3.5060...@gmx.de



Re: permission to write to /usr/local/share/packagename

2013-10-04 Thread Beco
On 4 October 2013 18:23, Martin Eberhard Schauer
martin.e.scha...@gmx.de wrote:

 There is a difference between building some software and installing it. You
 need root rights for installations beyond your home directory.

 Cheers,
Martin


Hi Martin,

Thanks for the help. Are you saying that my program can't run
correctly until I install it?

If I make a program (using VI and writing a C code) that tries to save
a file gamex.scores under /var/games, then I compile it with a
simple gcc command (forget make, and configure for now), the program
won't work because of permissions?

I tried this simple command under bash:
$ touch /var/games/test.txt
permission denied!

I added myself to group games, but to no avail.

What is the miracle? After installing with root permissions, the game
won't run with root permission, will it?

Please, help clarifying this topic. I'm not getting it.

Tx,
Beco.


-- 
To UNSUBSCRIBE, email to debian-mentors-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Archive: 
http://lists.debian.org/CALuYw2zBz72c-pj=BGbPQMOkWyM=mymuovtsue1e7q6ffhs...@mail.gmail.com



Re: permission to write to /usr/local/share/packagename

2013-10-04 Thread Beco
Hi mentors,

I'm putting my thoughts together. I think what I'm trying to ask is
how to make it work manually?

Suppose I do the following:

Step 1: binary
 gcc myapp.c -o myapp
 sudo cp myapp /usr/games/

Step 2: prepare translations:

 mkdir -p /usr/share/locale/en/LC_MESSAGES
 xgettext -k_ --flag=_:1:pass-c-format -d myapp -s -o myapp.pot myapp.c
 msginit -l en_US -o en_US-myapp.po -i myapp.pot
 msgfmt -c -v -o en_US-myapp.mo en_US-myapp.po
 sudo cp en_US-myapp.mo /usr/share/locale/en/LC_MESSAGES/myapp.mo


Step 3: scores:

mkdir -p /var/games/myapp/
cp myapp.scores /var/games/myapp/

Then I probably need to get some permissions right. Here is the problem. I did:

For the binary:
chown root:games /usr/games/myapp


For the score directory and file:
chown root:games /var/games/myapp
chown root:games /var/games/myapp/myapp
chmod g+w /var/games/myapp
chmod g+w /var/games/myapp/myapp


I suppose that is all I have to do. But myapp still tells me
permission denied.

Holding my breath!

Beco.


-- 
Dr Beco
A.I. researcher

Sometimes the heart sees what is invisible to the eye. (H. Jackson Brown Jr.)


-- 
To UNSUBSCRIBE, email to debian-mentors-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Archive: 
http://lists.debian.org/caluyw2wvdh7ospoazxcbw5g-pqqldn2miugbaxbfgu+wqpc...@mail.gmail.com



Re: permission to write to /usr/local/share/packagename

2013-10-04 Thread Beco
On 4 October 2013 22:56, Beco r...@beco.cc wrote:
 Hi mentors,

[snip]


 I suppose that is all I have to do. But myapp still tells me
 permission denied.

I got it working using something I was trying to avoid. SGID.

chmod g+s mytouch

I think its kind of dangerous. But hell, is there any other safe way?
Is this the correct way to allow an app to write to some directory
outside its HOME?

Thanks!
Beco



-- 
Dr Beco
A.I. researcher

Sometimes the heart sees what is invisible to the eye. (H. Jackson Brown Jr.)


-- 
To UNSUBSCRIBE, email to debian-mentors-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Archive: 
http://lists.debian.org/CALuYw2xUgZ2FR1O2KqdPum7rjvqqu_Zbr5=md-ner5fep4g...@mail.gmail.com



Re: permission to write to /usr/local/share/packagename

2013-10-04 Thread Paul Wise
On Sat, Oct 5, 2013 at 5:09 AM, Vincent Bernat wrote:

 On Debian, those high scores are usually stored in /var/games/X. The
 file permissions allow a user from the group games to write the
 file. See for example `monsterz`.

That usually requires the game to be setgid, which isn't worth the
trouble. It is better to either only use per-user high-scores or
implement a network service to share high scores. However, do not send
or download network highscores (or anything else on the network)
without permission/instruction from the user.

http://www.freedesktop.org/wiki/Games/Upstream/

-- 
bye,
pabs

http://wiki.debian.org/PaulWise


-- 
To UNSUBSCRIBE, email to debian-mentors-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Archive: 
http://lists.debian.org/CAKTje6GiPEFwHhQ_U5zQ06MEjcPN5S1x=-jjaz6tb1zncxk...@mail.gmail.com



Re: permission to write to /usr/local/share/packagename

2013-10-04 Thread Paul Wise
On Sat, Oct 5, 2013 at 11:58 AM, Paul Wise wrote:

 per-user high-scores or

I forgot to mention that most computers these days (at least in rich
countries) are not multi-user so this isn't as big of an issue as it
would seem.

 network service to share high scores

You need to ensure that both the server side and the client side are
sufficiently secure that this doesn't cause issues. Obviously for FOSS
games the code can easily be modified to submit fake scores. One
interesting way around that (which I saw used with the puzzle game
primrose) is for the game to submit all data needed to create the high
score and then the server side can verify that data gives the right
high score. This works better for puzzle games with defined rules
though.

-- 
bye,
pabs

http://wiki.debian.org/PaulWise


-- 
To UNSUBSCRIBE, email to debian-mentors-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org
Archive: 
http://lists.debian.org/caktje6hhnabsrwefduyjskmsa6mrh998gycu6xwn9q-sktv...@mail.gmail.com