tags:

views:

56

answers:

3

Hi all,

Is it possible to create read only files in python which can not be changed later and in which users can not change its attribute from read-only to normal file?

Please suggest.

Thanks in advance.

A: 

This is just impossible. Any user with administrative rights can remove readonly restrictions of any kind.

Another option might be "Write a python program to kill all users over the worls so that they would not be able to change file attributes or security settings" :-)

BarsMonster
`from users import killall`
katrielalex
Thanks for your valuable inputs. I just wanted to know whether this is possible or not. I was not sure,but thought may be there is some way.
anand
+3  A: 

This is not python specific.

If the files are made by a different user that the one viewing it the script can make it read-only. As the file is owned by the python user, the viewing user cannot just change the attributes.

So it's very much an OS question, and not a Python question.

Oh, and there is no way to prevent an administrator changing the file, or for the file to be readable but not copyable.

extraneon
A: 

Take a look at os.chmod() function and execute it with appropriate parameters (filename, stat.S_IWUSR | stat.S_IRGRP | stat.S_IROTH) for your just created file.

On linux other users then you will not be able to change file or change attributes to writable.

Some root user or someone logged into you account will be able to change it though.

Kamil Szot