Re: SUDO QUESTION

"jim car" <[email protected]>
Newsgroups gmane.linux.redhat.release.psyche
Message-ID <[email protected]>
Gordon -

There is a problem with the command you suggested.  When you run

sudo dd if=./httpd.tmp of=/etc/httpd/conf/httpd.conf

the contents of httpd.tmp just overwrites /etc/httpd/conf/httpd.conf

Looking at the dd man page I played with the seek and notrunc options.
With seek it will keep the original file then add however much blank space 
until
you reach the seek amount and then write httpd.tmp to httpd.conf.   Problem
then becomes the second time you run the script it will write over what was 
written
during the first run unless I were to delete all of the blank lines.

Even though notrunc is listed in the man page and on the little help 
description of
dd, when you try to issue the command there is an error stating that notrunc 
is not
a recognized option of dd.

Any ideas?  Thanks.


On the desktop - MacOS X
In the server room - Linux
Windows? In the trash?


>From: Gordon Messmer <[email protected]>
>Reply-To: [email protected]
>To: [email protected]
>Subject: Re: SUDO QUESTION
>Date: Tue, 29 Jul 2003 22:12:12 -0700
>
>jim car wrote:
>>Why can't a user issue the following commands using sudo?  It always comes 
>>back as permission denied.  The sudoer's password is accepted.
>>
>>sudo cat ./httpd.tmp >> /etc/httpd/conf/httpd.conf
>
>In this example, two things are happening:
>1) sudo authenticates the user and runs "cat ./httpd.tmp" as root
>2) the user's shell attempts to open /etc/httpd/conf/httpd.conf and write 
>the output of "sudo" into that file.
>
>Redirection is not handled by "sudo", or any other command you run: it's a 
>function of the shell in which the redirection was requested. Naturally, 
>you can't sudo that.  You can however, accomplish what you want this way:
>
>cat ./httpd.tmp | sudo dd if=/dev/stdin of=/etc/httpd/conf/httpd.conf
>   ( useless use of cat, primarily intended to display the use of
>     /dev/stdin )
>
>or more simply:
>
>sudo dd if=./httpd.tmp of=/etc/httpd/conf/httpd.conf
>
>dd, unlike the shell, will do redirection in a command that can be evoked 
>from sudo.
>
>
>
>--
>Psyche-list mailing list
>[email protected]
>https://www.redhat.com/mailman/listinfo/psyche-list

_________________________________________________________________
MSN 8 helps eliminate e-mail viruses. Get 2 months FREE*.  
http://join.msn.com/?page=features/virus


-- 
Psyche-list mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/psyche-list
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.