1 |
On 15:52 Wed 06 Jul , Holly Bostick wrote: |
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 |
|
42 |
|
43 |
I assume you mean that you're trying to something like |
44 |
|
45 |
sudo echo foo >> bar |
46 |
|
47 |
The problem is that echo is running as root, but >> (a shell builtin) |
48 |
isn't. Your shell evaluates the >> before it does anything else, so you |
49 |
get permission denied if you aren't allowed to write to bar. (Think |
50 |
about what happens if you do |
51 |
|
52 |
cat foo > foo |
53 |
|
54 |
you end up with foo being empty regardless of what was in it before you |
55 |
ran the command (actually, that command fails with an error about the |
56 |
input and output files being the same, but I'm pretty sure that what I |
57 |
said used to be true)). |
58 |
|
59 |
Someone else asked the same question on this list not long ago, and the |
60 |
only solution I remember anyone having was to run |
61 |
|
62 |
su -c "echo foo >> bar" |
63 |
|
64 |
Dave |
65 |
|
66 |
-- |
67 |
gentoo-user@g.o mailing list |