ceph_common.sh: Do not sudo to root unless needed
PATCH 1/1 ceph_common.sh: Do not sudo to root unless needed
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
--- src/ceph_common.sh | 7 ++++++- 1 files changed, 6 insertions(+), 1 deletions(-)
src/ceph_common.sh +6 -1
@@ -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; }
Signature · 1 line
1.7.1
Tommi Virtanen
AppliedQuoted 8 lines · Jim Schutt
Using
do_root_cmd()doesn't really need to sudo to root if you're already root.Commit
71dc75bdafe62a098c0493ad62f2d0d2a6ca7946causes 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
Quoted 4 lines
when it is invoked by root with something like this:
ssh foo/etc/init.d/init-cephstartSigned-off-by Jim Schutt <[email protected]>
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 [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 12 lines · Tommi Virtanen
Quoted 11 lines · Jim Schutt
Using
do_root_cmd()doesn't really need to sudo to root if you're already root.Commit
71dc75bdafe62a098c0493ad62f2d0d2a6ca7946causes 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 sudowhen it is invoked by root with something like this:
ssh foo/etc/init.d/init-cephstart
Quoted 9 lines
Quoted 1 line
Signed-off-by Jim Schutt <[email protected]>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