PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.ruby > about writing file???
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
about writing file???

Réponse
 
LinkBack Outils de la discussion
Vieux 13/05/2008, 04h58   #1
Pat Kiatchaipipat
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut about writing file???

hi, I have problem about writing file.
I use this

data = File.new("/options.sav","w")

and I get file name option.sav in my path but when I open it with
notepad. It can modify :'( I don't want this because options.sav has
save data from my app that can't hack it! how can I write file with
can't be modified???
--
Posted via http://www.ruby-forum.com/.

  Réponse avec citation
Vieux 13/05/2008, 05h26   #2
Phillip Gawlowski
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: about writing file???

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Pat Kiatchaipipat wrote:
| hi, I have problem about writing file.
| I use this
|
| data = File.new("/options.sav","w")
|
| and I get file name option.sav in my path but when I open it with
| notepad. It can modify :'( I don't want this because options.sav has
| save data from my app that can't hack it! how can I write file with
| can't be modified???

You can't. All it needs is the correct privileges to access the file.

If you want the data to be somewhat tamper-proof, use encryption. Note,
though, that all it needs is the key to tamper with the file again. Or
you could obfuscate the file (ROT13, BASE64 encoding, what have you).
It'll be a loosing battle, though.

If you find a solution to this, the RIAA and MPAA, as well as SecuROM
would like to have a word with you, since you made DRM possible.

- --
Phillip Gawlowski
Twitter: twitter.com/cynicalryan
Blog: http://justarubyist.blogspot.com

~ "Some things don't need the thought people give them." -Hobbes
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.8 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkgpGHgACgkQbtAgaoJTgL8lUgCeKxh9TO2Sde Ou+Wnlj1yCgN7g
kmEAnizWOaVe6fw6oqLsKe3XgVvUx8xF
=2h6b
-----END PGP SIGNATURE-----

  Réponse avec citation
Vieux 13/05/2008, 10h15   #3
Ron Fox
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: about writing file???

If you just want to prevent casual/accidental, rather than
determined modification, after you close the file:


File.chmod("/options.sav", 0440);

For example.

RF

Pat Kiatchaipipat wrote:
> hi, I have problem about writing file.
> I use this
>
> data = File.new("/options.sav","w")
>
> and I get file name option.sav in my path but when I open it with
> notepad. It can modify :'( I don't want this because options.sav has
> save data from my app that can't hack it! how can I write file with
> can't be modified???

  Réponse avec citation
Vieux 13/05/2008, 12h20   #4
Albert Schlef
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: about writing file???

Ron Fox wrote:
> If you just want to prevent casual/accidental, rather than
> determined modification, after you close the file:
>
>
> File.chmod("/options.sav", 0440);


Does 0440 work on windows too?

(I think it's clear, when he meantions "notepad", and saves to the root
folder, that he's using Windows.)
--
Posted via http://www.ruby-forum.com/.

  Réponse avec citation
Vieux 14/05/2008, 10h06   #5
Ron Fox
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: about writing file???

Yes, but I did get the arguments backwards.

File.chmod(0440, "/options.sav")

Works just fine on my windows box and does set the Readonly bit when
I look at the file later. The nice thing about good high level
languages, they abstract many differences in operating systems away
making it easier to write portable code.

Ron.

Albert Schlef wrote:
> Ron Fox wrote:
>> If you just want to prevent casual/accidental, rather than
>> determined modification, after you close the file:
>>
>>
>> File.chmod("/options.sav", 0440);

>
> Does 0440 work on windows too?
>
> (I think it's clear, when he meantions "notepad", and saves to the root
> folder, that he's using Windows.)

  Réponse avec citation
Vieux 14/05/2008, 10h25   #6
Pat Kiatchaipipat
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: about writing file???

thx you I will try with it
--
Posted via http://www.ruby-forum.com/.

  Réponse avec citation
Vieux 20/05/2008, 08h50   #7
Pat Kiatchaipipat
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: about writing file???

It's not work! :'(
I use that and it make read-only file that I can't modify it but when I
right click->property and check off in read-only box. it can modify!!

:-(
--
Posted via http://www.ruby-forum.com/.

  Réponse avec citation
Vieux 20/05/2008, 13h19   #8
Phillip Gawlowski
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: about writing file???

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Pat Kiatchaipipat wrote:
| It's not work! :'(
| I use that and it make read-only file that I can't modify it but when I
| right click->property and check off in read-only box. it can modify!!

And you will not be able to change that behavior, short of shipping your
own operating system.

- --
Phillip Gawlowski
Twitter: twitter.com/cynicalryan
Blog: http://justarubyist.blogspot.com

You thought I was taking your woman away from you. You're jealous.
You tried to kill me with your bare hands. Would a Kelvan do that?
Would he have to? You're reacting with the emotions of a human.
You are human.
~ -- Kirk, "By Any Other Name," stardate 4657.5
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.8 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAkgywckACgkQbtAgaoJTgL+AEwCeI2xF3bQE8F jtyOlpQ5ekib9n
2JAAnRMK9fHw+IRnx1N7aeOjBeeSTe4x
=OTa6
-----END PGP SIGNATURE-----

  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 10h53.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,13669 seconds with 16 queries