CEPH filesystem development
 help / color / mirror / Atom feed
* [PATCH] ceph_common.sh: Do not sudo to root unless needed
@ 2011-09-14 15:09 Jim Schutt
  2011-09-19 16:49 ` Tommi Virtanen
  0 siblings, 1 reply; 3+ messages in thread
From: Jim Schutt @ 2011-09-14 15:09 UTC (permalink / raw)
  To: ceph-devel; +Cc: Jim Schutt

Using do_root_cmd() doesn't really need to sudo to root
if you're already root.

Commit 71dc75bdafe62a098c0493ad62f2d0d2a6ca7946 causes a regression:
when system "foo" has a sudoers config that requires a tty,
init-ceph now fails like this:
  sudo: sorry, you must have a tty to run sudo

when it is invoked by root with something like this:
   ssh foo /etc/init.d/init-ceph start

Signed-off-by: Jim Schutt <jaschut@sandia.gov>
---
 src/ceph_common.sh |    7 ++++++-
 1 files changed, 6 insertions(+), 1 deletions(-)

diff --git a/src/ceph_common.sh b/src/ceph_common.sh
index adb8783..1da42bd 100644
--- a/src/ceph_common.sh
+++ b/src/ceph_common.sh
@@ -97,7 +97,12 @@ do_root_cmd() {
     if [ -z "$ssh" ]; then
 	[ $verbose -eq 1 ] && echo "--- $host# $1"
 	ulimit -c unlimited
-	sudo bash -c "$1" || { echo "failed: '$1'" ; exit 1; }
+	whoami=`whoami`
+	if [ "$whoami" = "root" ]; then
+	    bash -c "$1" || { echo "failed: '$1'" ; exit 1; }
+	else
+	    sudo bash -c "$1" || { echo "failed: '$1'" ; exit 1; }
+	fi
     else
 	[ $verbose -eq 1 ] && echo "--- $rootssh $2 \"cd $sshdir ; ulimit -c unlimited ; $1\""
 	$rootssh $2 "cd $sshdir ; ulimit -c unlimited ; $1" || { echo "failed: '$rootssh $1'" ; exit 1; }
-- 
1.7.1



^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] ceph_common.sh: Do not sudo to root unless needed
  2011-09-14 15:09 [PATCH] ceph_common.sh: Do not sudo to root unless needed Jim Schutt
@ 2011-09-19 16:49 ` Tommi Virtanen
  2011-09-19 17:12   ` Jim Schutt
  0 siblings, 1 reply; 3+ messages in thread
From: Tommi Virtanen @ 2011-09-19 16:49 UTC (permalink / raw)
  To: Jim Schutt; +Cc: ceph-devel

On Wed, Sep 14, 2011 at 08:09, Jim Schutt <jaschut@sandia.gov> wrote:
> Using do_root_cmd() doesn't really need to sudo to root
> if you're already root.
>
> Commit 71dc75bdafe62a098c0493ad62f2d0d2a6ca7946 causes a regression:
> when system "foo" has a sudoers config that requires a tty,
> init-ceph now fails like this:
>  sudo: sorry, you must have a tty to run sudo
>
> when it is invoked by root with something like this:
>   ssh foo /etc/init.d/init-ceph start
>
> Signed-off-by: Jim Schutt <jaschut@sandia.gov>

Applied as d64237a6a555944d6d35676490bc4fb7c7db965d, thank you.

(It seems I screwed up the author field in the commit, sorry about
that. I don't want to force push just to fix that; Signed-off-by gives
you credit anyway.)
--
To unsubscribe from this list: send the line "unsubscribe ceph-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] ceph_common.sh: Do not sudo to root unless needed
  2011-09-19 16:49 ` Tommi Virtanen
@ 2011-09-19 17:12   ` Jim Schutt
  0 siblings, 0 replies; 3+ messages in thread
From: Jim Schutt @ 2011-09-19 17:12 UTC (permalink / raw)
  To: Tommi Virtanen; +Cc: ceph-devel

Tommi Virtanen wrote:
> On Wed, Sep 14, 2011 at 08:09, Jim Schutt <jaschut@sandia.gov> wrote:
>> Using do_root_cmd() doesn't really need to sudo to root
>> if you're already root.
>>
>> Commit 71dc75bdafe62a098c0493ad62f2d0d2a6ca7946 causes a regression:
>> when system "foo" has a sudoers config that requires a tty,
>> init-ceph now fails like this:
>>  sudo: sorry, you must have a tty to run sudo
>>
>> when it is invoked by root with something like this:
>>   ssh foo /etc/init.d/init-ceph start
>>
>> Signed-off-by: Jim Schutt <jaschut@sandia.gov>
> 
> Applied as d64237a6a555944d6d35676490bc4fb7c7db965d, thank you.
> 
> (It seems I screwed up the author field in the commit, sorry about
> that. I don't want to force push just to fix that; Signed-off-by gives
> you credit anyway.)
> 
> 

No problem - thanks for taking a look.

-- Jim



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2011-09-19 17:13 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-09-14 15:09 [PATCH] ceph_common.sh: Do not sudo to root unless needed Jim Schutt
2011-09-19 16:49 ` Tommi Virtanen
2011-09-19 17:12   ` Jim Schutt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox