public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH] Use absolute path for losetup.
@ 2014-03-14  0:00 Vinson Lee
  2014-03-17 14:43 ` chrubis
  0 siblings, 1 reply; 3+ messages in thread
From: Vinson Lee @ 2014-03-14  0:00 UTC (permalink / raw)
  To: ltp-list

From: Vinson Lee <vlee@twitter.com>

/sbin may not be in the default $PATH.

Signed-off-by: Vinson Lee <vlee@twitter.com>
---
 runltp                                |  6 +++---
 testcases/kernel/fs/acl/tacl_xattr.sh |  2 +-
 testcases/kernel/fs/acls/acl_test01   |  6 +++---
 testcases/kernel/fs/mongo/test.sh     | 10 +++++-----
 4 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/runltp b/runltp
index 3c8b94e..673e2ef 100755
--- a/runltp
+++ b/runltp
@@ -952,13 +952,13 @@ create_block()
         return 1
     else
         ##search for an unused loop dev
-        LOOP_DEV=$(losetup -f)
+        LOOP_DEV=$(/sbin/losetup -f)
         if [ $? -ne 0 ]; then
             echo "no unused loop device is found"
             return 1
         else
             ##attach the created file to loop dev.
-            losetup $LOOP_DEV ${TMP}/test.img
+            /sbin/losetup $LOOP_DEV ${TMP}/test.img
             if [ $? -ne 0 ]; then
                 echo "losetup failed to create block device"
                 return 1
@@ -988,7 +988,7 @@ set_block_device()
 
 cleanup()
 {
-    [ "$LOOP_DEV" ] && losetup -d $LOOP_DEV
+    [ "$LOOP_DEV" ] && /sbin/losetup -d $LOOP_DEV
     rm -rf ${TMP}
 }
 
diff --git a/testcases/kernel/fs/acl/tacl_xattr.sh b/testcases/kernel/fs/acl/tacl_xattr.sh
index 99f6a95..5fd711b 100755
--- a/testcases/kernel/fs/acl/tacl_xattr.sh
+++ b/testcases/kernel/fs/acl/tacl_xattr.sh
@@ -80,7 +80,7 @@ fi
 dd if=/dev/zero of=tacl/blkext2 bs=1k count=10240
 chmod 777 tacl/blkext2
 
-losetup /dev/loop0 tacl/blkext2 2>&1 > /dev/null
+/sbin/losetup /dev/loop0 tacl/blkext2 2>&1 > /dev/null
 if [ $? != 0 ]
 then
 	echo ""
diff --git a/testcases/kernel/fs/acls/acl_test01 b/testcases/kernel/fs/acls/acl_test01
index af65213..9dfcee1 100755
--- a/testcases/kernel/fs/acls/acl_test01
+++ b/testcases/kernel/fs/acls/acl_test01
@@ -89,7 +89,7 @@ do_cleanup() {
 	rm -f $FILE_ACL > /dev/null 2>&1
 	rm -f $FILE_ACL_LINK > /dev/null 2>&1
 	mount | grep "$TMP/tacl/mount-ext3" && umount -d $TMP/tacl/mount-ext3
-	[ "x$LOOP_DEV" != x ] && losetup -d $LOOP_DEV
+	[ "x$LOOP_DEV" != x ] && /sbin/losetup -d $LOOP_DEV
 	rm -rf $TMP/tacl
 }
 
@@ -125,12 +125,12 @@ else
 
 	# Avoid hardcoded loopback device values (-f tries to find the first
 	# available loopback device name)!
-	if ! LOOP_DEV=$(losetup -f) || [ "x$LOOP_DEV" = x ]; then
+	if ! LOOP_DEV=$(/sbin/losetup -f) || [ "x$LOOP_DEV" = x ]; then
 		tst_resm TCONF "[ losetup.1 ] Failed to find an available loopback device -- is the required support compiled in your kernel?"
 		exit 0
 	fi
 
-	if ! losetup $LOOP_DEV $TMP/tacl/blkext3 2>&1 > /dev/null; then
+	if ! /sbin/losetup $LOOP_DEV $TMP/tacl/blkext3 2>&1 > /dev/null; then
 		echo ""
 		tst_resm TCONF "[ losetup.2 ] Failed to setup the device."
 		exit 0
diff --git a/testcases/kernel/fs/mongo/test.sh b/testcases/kernel/fs/mongo/test.sh
index 5ec4e31..60f585d 100755
--- a/testcases/kernel/fs/mongo/test.sh
+++ b/testcases/kernel/fs/mongo/test.sh
@@ -57,13 +57,13 @@ reiserfs()
 cat > fs.sh <<EOF
 echo "performing mongo on reiserfs"
 dd if=/dev/zero of=reiserfs  bs=8k count=10240 > /dev/null 2>&1
-losetup /dev/loop0 reiserfs
+/sbin/losetup /dev/loop0 reiserfs
 mkdir -p $TEST_DIR
 ./mongo.pl LOG=/tmp/logfile1 file_size=10000 bytes=100000 fstype=reiserfs dev=/dev/loop0 dir=$TEST_DIR RUN   log=$LOG_DIR/reiserlog > /dev/null 2>&1
 
 echo "RESULTS LOGGED IN $LOG_DIR/reiserlog"
 export PATH=$PATH:/sbin
-losetup -d /dev/loop0
+/sbin/losetup -d /dev/loop0
 
 EOF
 }
@@ -76,12 +76,12 @@ cat >> fs.sh <<EOF
 echo "performing mongo on jfs file system"
 mkdir -p $TEST_DIR
 dd if=/dev/zero of=jfs  bs=8k count=10240 > /dev/null 2>&1
-losetup /dev/loop0 jfs
+/sbin/losetup /dev/loop0 jfs
 ./mongo.pl LOG=/tmp/logfile1 file_size=10000 bytes=100000 fstype=jfs dev=/dev/loop0 dir=$TEST_DIR   RUN log=$LOG_DIR/jfslog
 
 echo "RESULTS LOGGED IN $LOG_DIR/jfslog"
 export PATH=$PATH:/sbin
-losetup -d /dev/loop0
+/sbin/losetup -d /dev/loop0
 echo "rm -rf ./fs.sh" >> ./fs.sh 2>&1
 EOF
 }
@@ -105,5 +105,5 @@ echo "THIS MAY TAKE SOME MINUTES"
 sh fs.sh
 
 #performing cleanup
-#losetup -d /dev/loop0
+#/sbin/losetup -d /dev/loop0
 rm -rf $TEST_DIR
-- 
1.8.3.2


------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* Re: [LTP] [PATCH] Use absolute path for losetup.
  2014-03-14  0:00 [LTP] [PATCH] Use absolute path for losetup Vinson Lee
@ 2014-03-17 14:43 ` chrubis
       [not found]   ` <CACKvgLGan6cLbnkoQm4ueqxtTKTxhdW4tH34A46ph6BEyjOZkA@mail.gmail.com>
  0 siblings, 1 reply; 3+ messages in thread
From: chrubis @ 2014-03-17 14:43 UTC (permalink / raw)
  To: Vinson Lee; +Cc: ltp-list

Hi!
> From: Vinson Lee <vlee@twitter.com>
> 
> /sbin may not be in the default $PATH.

You are supposed to start runltp as a root, if losetup is not in your
$PATH something went wrong on your end.

-- 
Cyril Hrubis
chrubis@suse.cz

------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

* Re: [LTP] [PATCH] Use absolute path for losetup.
       [not found]   ` <CACKvgLGan6cLbnkoQm4ueqxtTKTxhdW4tH34A46ph6BEyjOZkA@mail.gmail.com>
@ 2014-03-25 14:47     ` chrubis
  0 siblings, 0 replies; 3+ messages in thread
From: chrubis @ 2014-03-25 14:47 UTC (permalink / raw)
  To: Vinson Lee; +Cc: ltp-list

Hi!
> >> From: Vinson Lee <vlee@twitter.com>
> >>
> >> /sbin may not be in the default $PATH.
> >
> > You are supposed to start runltp as a root, if losetup is not in your
> > $PATH something went wrong on your end.
> >
> > --
> > Cyril Hrubis
> > chrubis@suse.cz
> 
> This situation can arise, for example, on CentOS 5 running LTP with
> sudo instead of directly as root.

That is a "security" feature for sudo. See for example bug:

https://bugzilla.redhat.com/show_bug.cgi?id=80215

You can either add /sbin/ and /bin/ to your PATH manually
(PATH="$PATH:/sbin:/bin" sudo runltp) or add secure_path="/sbin:/bin:"
into /etc/sudoers.

Using absolute paths in LTP is out of question because that would bring
more harm than good. Note that distributions differ on placements for
some of the standard tools and adding a layer for resolving the paths
would add quite a bit complexity for a problem that could be solved by
adding a few paths to the PATH.

On the other hand we should fix the scripts to check if the tool they
use is available (see tst_check_cmds in testcases/lib/test.sh). And
maybe we can print a warning from runltp if /sbin or /bin are not in
$PATH.

-- 
Cyril Hrubis
chrubis@suse.cz

------------------------------------------------------------------------------
Learn Graph Databases - Download FREE O'Reilly Book
"Graph Databases" is the definitive new guide to graph databases and their
applications. Written by three acclaimed leaders in the field,
this first edition is now available. Download your free book today!
http://p.sf.net/sfu/13534_NeoTech
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

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

end of thread, other threads:[~2014-03-25 14:47 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-14  0:00 [LTP] [PATCH] Use absolute path for losetup Vinson Lee
2014-03-17 14:43 ` chrubis
     [not found]   ` <CACKvgLGan6cLbnkoQm4ueqxtTKTxhdW4tH34A46ph6BEyjOZkA@mail.gmail.com>
2014-03-25 14:47     ` chrubis

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