Gentoo Archives: gentoo-user

From: gentoo@×××××××.ch
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] sudo echo cannot write to /etc/ files ?
Date: Wed, 06 Jul 2005 14:30:46
Message-Id: 200507061620.47943.gentoo@depardo.ch
In Reply to: [gentoo-user] sudo echo cannot write to /etc/ files ? by Holly Bostick
1 Le Mercredi, 6 Juillet 2005 15.52, Holly Bostick a ecrit :
2 > Hey, ho--
3 >
4 > Here's (one of) today's non-critical problems that's getting on my
5 > nerves, so hopefully somebody can help.
6 >
7 > I've finally got around to setting up sudo. It works fine, except for
8 > one thing.
9 >
10 > I don't just give myself blanket permissions to sudo to all commands; I
11 > made a Cmd_Alias group which includes a lot of utility apps. And, like
12 > many of you, I included emerge in this group.
13 >
14 > But a lot of the time, when I do an emerge -av, I find that there's a
15 > USE flag I want or don't want for the package, or I want an unstable
16 > version, or whatever, which means I have to echo to one of the files in
17 > /etc/portage.
18 >
19 > Echo is in the sudo-ed group, and echo isn't the problem-- the problem
20 > is that permission is refused to write to the file itself (which is an
21 > error *from* echo, so it would seem that echo itself is OK as far as
22 > sudo goes). Which means that I have to su anyway, to echo to the file,
23 > which really isn't the point of the exercise.
24 >
25 > As I see it, this error can mean only one of two things:
26 >
27 > sudo does not give me a login shell (so my UID is 'really' still my UID
28 > and not root's, and I don't have permission to write to the file); or
29 >
30 > there is another, "invisible" cli utility responsible for actually
31 > writing to the file, which is not sudo-ed.
32 >
33 > Or could it be something else?
34 >
35 > In any case, does anybody know how I could fix this? It's really
36 > screwing up my useability, which was just starting to shape up nicely :-) .
37 >
38 > Thanks,
39 > Holly
40
41 I think the problem come from the fact that echo is sudo-ed but the shell
42 redirection isn't.
43
44 Compare this:
45 su -c "echo foo > /etc/portage/whatever"
46 and
47 su -c "echo foo" > /etc/portage/whatever
48
49 The first one will succeed, but not the second.
50
51 To solve your problem, I would just do:
52 chgrp -R portage /etc/portage
53 chmod -R g+w /etc/portage
54
55 --
56 mat
57 --
58 gentoo-user@g.o mailing list

Replies

Subject Author
Re: [gentoo-user] sudo echo cannot write to /etc/ files ? Holly Bostick <motub@××××××.nl>