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


Groups > comp.lang.python > #46595

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

Date 2013-05-31 07:11 -0400
From Dave Angel <davea@davea.name>
Subject Re: Create a file in /etc/ as a non-root user
References <0e688580-c0fb-4caf-8fb1-f622b2c7bcb5@googlegroups.com> <4fc3af47-2dc4-4de1-9479-53741215c3a2@googlegroups.com>
Newsgroups comp.lang.python
Message-ID <mailman.2487.1369998737.3114.python-list@python.org> (permalink)

Show all headers | View raw


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




-- 
DaveA

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