Re: SUDO QUESTION

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Gordon,

Thanks for the suggestion but I was able to figure out a different way to get the same result.

Using sudo I copied the httpd config file to a backup copy and an httpd.tmp file. Then I used
changed the ownership of the httpd.tmp file to the user that is running the script, redirected
the new config info to the httpd.tmp and the sudo copied the httpd.tmp file to the real httpd.conf
file.


Thanks for the help.

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




From: "jim car" <macosxwhatelse@xxxxxxxxxxx>
Reply-To: psyche-list@xxxxxxxxxx
To: psyche-list@xxxxxxxxxx
Subject: Re: SUDO QUESTION
Date: Wed, 30 Jul 2003 05:10:20 -0700

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 <yinyang@xxxxxxxxx>
Reply-To: psyche-list@xxxxxxxxxx
To: psyche-list@xxxxxxxxxx
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
Psyche-list@xxxxxxxxxx
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 Psyche-list@xxxxxxxxxx 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 Psyche-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/psyche-list

[Index of Archives]     [Fedora General Discussion]     [Red Hat General Discussion]     [Centos]     [Kernel]     [Red Hat Install]     [Red Hat Watch]     [Red Hat Development]     [Red Hat 9]     [Gimp]     [Yosemite News]

  Powered by Linux