Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #46601

Re: Create a file in /etc/ as a non-root user

From Alister <alister.ware@ntlworld.com>
Subject Re: Create a file in /etc/ as a non-root user
Newsgroups comp.lang.python
References <0e688580-c0fb-4caf-8fb1-f622b2c7bcb5@googlegroups.com> <4fc3af47-2dc4-4de1-9479-53741215c3a2@googlegroups.com> <mailman.2487.1369998737.3114.python-list@python.org>
Message-ID <042qt.10122$tu1.2940@fx20.am4> (permalink)
Organization virginmedia.com
Date 2013-05-31 14:02 +0000

Show all headers | View raw


On Fri, 31 May 2013 07:11:58 -0400, Dave Angel wrote:

> On 05/31/2013 05:27 AM, Luca Cerone wrote:
>>> fd = open('/etc/file','w')
>>>
>>> fd.write('jpdas')
>>>
>>> fd.close()
>>>
>>>
>> Hi Bibhu, that is not a Python problem, but a permission one.
>> You should configure the permissions so that you have write access to
>> the folder.
>> However unless you know what you are doing it is discouraged to save
>> your file in the /etc/ folder.
>>
>> I don't know if on Mac the commands are the same, but in Unix systems
>> (that I guess Mac is) you can manage permissions with chmod.
>>
>>
> That directory is protected from users for a reason.  You defeat that
> and risk the system.
> 
> Bibhu:  for that reason I'd suggest simply telling your users to run
> your script as root.  If they trust you, and it breaks something, at
> least they know why they were doing it.
> 
>     sudo  python  riskyscript.py

Bibhu without wishing to seem rude, the fact that you had to ask this 
question indicates that you almost certainly should not be writing to 
this directory.

/etc is used to store configuration files for the operating system & if 
you inadvertently corrupt the wrong one then you could kill the system.

if you can provide more details regarding what you are actually trying to 
achieve you may get some better answers & will almost certainly save 
yourself a whole heap of pain


-- 
It is not for me to attempt to fathom the inscrutable workings of 
Providence.
		-- The Earl of Birkenhead

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

Create a file in /etc/ as a non-root user BIBHU DAS <b13das91@gmail.com> - 2013-05-31 02:12 -0700
  Re: Create a file in /etc/ as a non-root user Luca Cerone <luca.cerone@gmail.com> - 2013-05-31 02:27 -0700
    Re: Create a file in /etc/ as a non-root user Dave Angel <davea@davea.name> - 2013-05-31 07:11 -0400
      Re: Create a file in /etc/ as a non-root user Alister <alister.ware@ntlworld.com> - 2013-05-31 14:02 +0000
        Re: Create a file in /etc/ as a non-root user Chris Angelico <rosuav@gmail.com> - 2013-06-01 00:42 +1000
          Re: Create a file in /etc/ as a non-root user rusi <rustompmody@gmail.com> - 2013-05-31 21:39 -0700
  Re: Create a file in /etc/ as a non-root user Nobody <nobody@nowhere.com> - 2013-06-01 01:20 +0100
    Re: Create a file in /etc/ as a non-root user Tim Chase <python.list@tim.thechases.com> - 2013-05-31 19:49 -0500
  Re: Create a file in /etc/ as a non-root user Denis McMahon <denismfmcmahon@gmail.com> - 2013-06-01 21:19 +0000
    Re: Create a file in /etc/ as a non-root user rusi <rustompmody@gmail.com> - 2013-06-01 19:51 -0700

csiph-web