public inbox for gentoo-user@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Boyd Stephen Smith Jr." <bss03@volumehost.com>
To: gentoo-user@lists.gentoo.org
Subject: Re: [gentoo-user] sudo echo cannot write to /etc/ files ?
Date: Wed, 06 Jul 2005 23:42:54 -0400	[thread overview]
Message-ID: <42CCA4BE.5000904@volumehost.com> (raw)
In-Reply-To: <42CBF70B.4010703@planet.nl>

Holly Bostick wrote:
> gentoo@depardo.ch schreef:
>>I think the problem come from the fact that echo is sudo-ed but the shell 
>>redirection isn't.
>>
>>Compare this:
>>su -c "echo foo > /etc/portage/whatever"
>>and 
>>su -c "echo foo" > /etc/portage/whatever
>>
>>The first one will succeed, but not the second.
> 
> Well, it didn't work (this to all the respondents).
> 
> "sudo echo 'media-video/xine-ui ~x86' >>/etc/portage/package.keywords"

This groups *everything* as one shell parameter, so it attempts to 
execute a file named "sudo echo 'media-video/xine-ui ~x86' 
 >>/etc/portage/package.keywords" in your path.

>>>/etc/portage/package.keywords: Onbekend bestand of map
> ("unknown file or folder")

Of course, since it's extremely unlikely a file with that name exists.

>  sudo echo 'media-video/xine-ui ~x86' >>/etc/portage/package.keywords

Now, you've completely left out the quotes, so the redirection is done 
in the user shell, not the sudo shell.  Of course, your user can't write 
to that file so you get:

> -bash: /etc/portage/package.keywords: Toegang geweigerd
> (permission refused)

You want:
sudo "echo 'media-video/xine-ui ~x86' >> /etc/portage/package.keywords"

This cause the command
echo 'media-video/xine-ui ~x86' >> /etc/portage/package.keywords
to be passed to the sudo shell which causes the bash built-in:
echo
to be called with the single parameter
media-video/xine-ui ~x86
and have it's output appended to the file
/etc/portage/package.keywords


> I'm really lost. Where am I going wrong?

You simply aren't being careful enough with you quotes and 
misunderstanding the intricacies of shell expansion and nesting.

> Oh, btw, just remembered-- this is bash 3. Does that make a difference?

No.

-- 
Boyd Stephen Smith Jr.
bss03@volumehost.com

-- 
gentoo-user@gentoo.org mailing list



  parent reply	other threads:[~2005-07-07  3:58 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-07-06 13:52 [gentoo-user] sudo echo cannot write to /etc/ files ? Holly Bostick
2005-07-06 14:02 ` A. Khattri
2005-07-06 14:25   ` Holly Bostick
2005-07-06 14:20 ` David Morgan
2005-07-06 14:20 ` gentoo
2005-07-06 15:21   ` Holly Bostick
2005-07-06 15:29     ` Christoph Gysin
2005-07-06 15:39     ` gentoo
2005-07-07  3:42     ` Boyd Stephen Smith Jr. [this message]
2005-07-07  5:31       ` Richard Fish
2005-07-06 14:22 ` Edward Catmur
2005-07-06 14:54   ` Holly Bostick
2005-07-06 15:12     ` David Morgan
2005-07-06 15:26       ` Neil Bothwick
2005-07-06 15:28       ` Christoph Gysin
2005-07-06 16:07         ` Holly Bostick
2005-07-06 16:47           ` Christoph Gysin
2005-07-06 18:22           ` Richard Fish
2005-07-06 18:36             ` Holly Bostick
2005-07-06 19:12               ` Richard Fish
2005-07-06 19:42                 ` Holly Bostick
2005-07-06 20:28                   ` John J. Foster
2005-07-06 20:52                   ` Manuel McLure
2005-07-06 19:13               ` Christoph Gysin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=42CCA4BE.5000904@volumehost.com \
    --to=bss03@volumehost.com \
    --cc=gentoo-user@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox