Bug#765431: open-iscsi: umountiscsi.sh script does not properly check while traverse sysfs structure

2014-11-13 Thread Ritesh Raj Sarraf
On 11/12/2014 11:57 PM, dmitry wrote:
 Thanks.
 When it appear in current stable release (Wheezy) ?  And if not, why?


Oh!! I should have paid more attention to your initial email of this bug
report.

The old version in Wheezy does not have this fix. Yes.
Stable release policies, and my time and priorities, do not accommodate
backporting  fixes to old stable releases.

Your best bet would be to eventually upgrade to Jessy, once it is
released. Or else backport the fixes by yourself, or hire a consultant
to do that.

-- 
Ritesh Raj Sarraf
RESEARCHUT - http://www.researchut.com
Necessity is the mother of invention.



signature.asc
Description: OpenPGP digital signature


Bug#765431: open-iscsi: umountiscsi.sh script does not properly check while traverse sysfs structure

2014-11-12 Thread dmitry

Hello!

On Tue, 11 Nov 2014 12:46:42 +0530 Ritesh Raj Sarraf 
r...@researchut.com wrote:

On 11/11/2014 01:44 AM, dmitry wrote:

 I am sorry, but could you please be answered:

 If code above present in umountiscsi.sh init script where can I
 found correct (not tampered) version? As far as I see from contents 
of

 package umountiscsi.sh script does not contain this code. I look at
 packages from any different repository (ftp.de.debian.org,
 ftp.fi.debian.org, ftp.ru.debian.org) and could not found it.


https://packages.qa.debian.org/o/open-iscsi.html


Thanks.
When it appear in current stable release (Wheezy) ?  And if not, 
why?



--
Dmitry Danilov.


--
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



Bug#765431: open-iscsi: umountiscsi.sh script does not properly check while traverse sysfs structure

2014-11-10 Thread dmitry

Hello!

On Sat, 08 Nov 2014 21:09:30 +0530 Ritesh Raj Sarraf 
r...@researchut.com wrote:

On 10/20/2014 08:58 AM, dmitry wrote:
 Adding -x parameter to umountiscsi.sh

 And try to restart service:
 root@archive:~# /etc/init.d/open-iscsi restart

 Look on exerpt output(full report in attached file):

 Here (the cause of problem):
 + [ -d /sys/devices/platform/host4/iscsi_host ]
 + [ -d /sys/devices/platform/host4/session1/target4:0:0 ]
 + sed s/.*block\///
 + echo /sys/devices/platform/host4/session1/target*/*:*/block/*
 + BLOCK_DEV=*

I still think we do not need the patch. Because...

BLOCK_DEV=`echo $BLOCK_FILE | sed 's/.*block\///'`
if [ ${BLOCK_DEV} = * ];then
log_warning_msg iSCSI target without
block devices found
continue
fi

Ideally you should have seen this warning message. But you are not
seeing this message. Which may be that you are using an older or
tampered version of the init script.



I am sorry, but could you please be answered:

If code above present in umountiscsi.sh init script where can I 
found correct (not tampered) version? As far as I see from contents of 
package umountiscsi.sh script does not contain this code. I look at 
packages from any different repository (ftp.de.debian.org, 
ftp.fi.debian.org, ftp.ru.debian.org) and could not found it.





And the patch you provided is wrong. Because those block devices we 
are

looping for are not directories.


Are you speaking about /dev/ contents? Am I wrong, that code:

for BLOCK_FILE in $SESSION_DIR/target*/*\:*/block/*; do

 -  loop for filesystem with directories?




 + awk /^\/dev\/*/ { print $2; }
 + DOS_PARTITIONS=/
 + umount /
 umount: /: device is busy.
 (In some cases useful info about processes that use
 the device is found by lsof(8) or fuser(1))
 + exit_status=1


--
Ritesh Raj Sarraf
RESEARCHUT - http://www.researchut.com
Necessity is the mother of invention.



--
Dmitry Danilov.


--
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



Bug#765431: open-iscsi: umountiscsi.sh script does not properly check while traverse sysfs structure

2014-11-10 Thread Ritesh Raj Sarraf
On 11/11/2014 01:44 AM, dmitry wrote:

 I am sorry, but could you please be answered:

 If code above present in umountiscsi.sh init script where can I
 found correct (not tampered) version? As far as I see from contents of
 package umountiscsi.sh script does not contain this code. I look at
 packages from any different repository (ftp.de.debian.org,
 ftp.fi.debian.org, ftp.ru.debian.org) and could not found it.


https://packages.qa.debian.org/o/open-iscsi.html




 And the patch you provided is wrong. Because those block devices we are
 looping for are not directories.

 Are you speaking about /dev/ contents? Am I wrong, that code:
 
 for BLOCK_FILE in $SESSION_DIR/target*/*\:*/block/*; do
 
  -  loop for filesystem with directories?

Yes. Here we only loop through device files.


-- 
Ritesh Raj Sarraf
RESEARCHUT - http://www.researchut.com
Necessity is the mother of invention.



signature.asc
Description: OpenPGP digital signature


Bug#765431: open-iscsi: umountiscsi.sh script does not properly check while traverse sysfs structure

2014-11-08 Thread Ritesh Raj Sarraf
On 10/20/2014 08:58 AM, dmitry wrote:
 Adding -x parameter to umountiscsi.sh

 And try to restart service:
 root@archive:~# /etc/init.d/open-iscsi restart

 Look on exerpt output(full report in attached file):

 Here (the cause of problem):
 + [ -d /sys/devices/platform/host4/iscsi_host ]
 + [ -d /sys/devices/platform/host4/session1/target4:0:0 ]
 + sed s/.*block\///
 + echo /sys/devices/platform/host4/session1/target*/*:*/block/*
 + BLOCK_DEV=*

I still think we do not need the patch.  Because...

BLOCK_DEV=`echo $BLOCK_FILE | sed 's/.*block\///'`
if [ ${BLOCK_DEV} = * ];then
log_warning_msg iSCSI target without
block devices found
continue
fi

Ideally you should have seen this warning message. But you are not
seeing this message. Which may be that you are using an older or
tampered version of the init script.


And the patch you provided is wrong. Because those block devices we are
looping for are not directories.


 + awk /^\/dev\/*/ { print $2; }
 + DOS_PARTITIONS=/
 + umount /
 umount: /: device is busy.
 (In some cases useful info about processes that use
  the device is found by lsof(8) or fuser(1))
 + exit_status=1 


-- 
Ritesh Raj Sarraf
RESEARCHUT - http://www.researchut.com
Necessity is the mother of invention.



signature.asc
Description: OpenPGP digital signature


Bug#765431: open-iscsi: umountiscsi.sh script does not properly check while traverse sysfs structure

2014-10-20 Thread dmitry

Hello !
17.10.2014 00:44, Ritesh Raj Sarraf пишет:

On Thursday 16 October 2014 09:10 AM, Dmitry Danilov wrote:



Yes, as I see, BLOCK_FILE variable should serves that.


Sorry. But I'm not understanding this correct. Are  you saying we 
don't need the

patch ?

--
Ritesh Raj Sarraf
RESEARCHUT -http://www.researchut.com
Necessity is the mother of invention.


I think we need a patch.

Let's look at problem again:

What we have:

system:

root@archive:~# uname -a
Linux archive 3.2.0-4-amd64 #1 SMP Debian 3.2.60-1+deb7u3 x86_64 
GNU/Linux


root@archive:~# lsb_release -a
No LSB modules are available.
Distributor ID: Debian
Description:Debian GNU/Linux 7.6 (wheezy)
Release:7.6
Codename:   wheezy

mounted partitions:

root@archive:~# mount
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)
proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
udev on /dev type devtmpfs 
(rw,relatime,size=10240k,nr_inodes=62130,mode=755)
devpts on /dev/pts type devpts 
(rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
tmpfs on /run type tmpfs 
(rw,nosuid,noexec,relatime,size=50896k,mode=755)
/dev/disk/by-uuid/51c02def-2358-4270-a76d-3161633a1b22 on / type ext4 
(rw,relatime,errors=remount-ro,user_xattr,barrier=1,data=ordered)
tmpfs on /run/lock type tmpfs 
(rw,nosuid,nodev,noexec,relatime,size=5120k)
tmpfs on /run/shm type tmpfs 
(rw,nosuid,nodev,noexec,relatime,size=296960k)
/dev/sdb1 on /mnt/sites_backup type ext4 
(rw,relatime,user_xattr,acl,barrier=1,data=ordered,_netdev)
/dev/sda1 on /mnt/sites_backup#2 type ext4 
(rw,relatime,user_xattr,barrier=1,stripe=128,data=ordered,_netdev)



Trying to restart|stop open-iscsi as if we have a new configured 
target:


root@archive:~# /etc/init.d/open-iscsi restart
[] Unmounting iscsi-backed filesystems: Unmounting all devices 
marked _netdevumount: /: device is busy.

(In some cases useful info about processes that use
 the device is found by lsof(8) or fuser(1))
[warn] Could not unmount / ... (warning).
 failed!
invoke-rc.d: initscript umountiscsi.sh, action stop failed.
[FAIL] Couldn't unmount all iSCSI devices. Cannot stop iSCSI service 
... failed!

root@archive:~#

From initscript errors : umountiscsi trying to unmount / partition -- 
Why?


Inspect the situation:

Adding -x parameter to umountiscsi.sh

And try to restart service:
root@archive:~# /etc/init.d/open-iscsi restart

Look on exerpt output(full report in attached file):

Here (the cause of problem):
+ [ -d /sys/devices/platform/host4/iscsi_host ]
+ [ -d /sys/devices/platform/host4/session1/target4:0:0 ]
+ sed s/.*block\///
+ echo /sys/devices/platform/host4/session1/target*/*:*/block/*
+ BLOCK_DEV=*
+ awk /^\/dev\/*/ { print $2; }
+ DOS_PARTITIONS=/
+ umount /
umount: /: device is busy.
(In some cases useful info about processes that use
 the device is found by lsof(8) or fuser(1))
+ exit_status=1

I think, shell expansion leds to that, so that is why I suggest code to 
test BLOCK_DEV

variable as empty 'directory' in sysfs i.e. :

+   if  ! [ -d $BLOCK_FILE ]; then
+   continue
+   fi



And another view to the same problem:

Code snippet for debug purposes (taken from 'umountiscsi.sh' file) 
contains only traverse sysfs section:


root@archive:~# cat traverse.sh

#!/bin/sh -x

for HOST_DIR in /sys/devices/platform/host*; do
if ! [ -d $HOST_DIR/iscsi_host* ]; then
continue
fi
for SESSION_DIR in $HOST_DIR/session*; do
if ! [ -d $SESSION_DIR/target* ]; then
continue
fi
for BLOCK_FILE in $SESSION_DIR/target*/*\:*/block/*; do
BLOCK_DEV=`echo $BLOCK_FILE | sed 's/.*block\///'`
		DOS_PARTITIONS=`awk /^\/dev\/$BLOCK_DEV/ { print \\$2; }  
/proc/mounts`

echo DEBUG:${BLOCK_FILE}
echo DEBUG:${DOS_PARTITIONS}
for DEVICE in $DOS_PARTITIONS; do
#log_progress_msg $DEVICE
#echo $DEVICE
echo umount ${DEVICE}
exit_status=$?
if ! [ $exit_status -eq 0 ]; then
umount_fail=1
log_warning_msg Could not unmount $DEVICE
fi
done
done
done
done

Output with trace mode i.e. bin/sh -x:

root@archive:~# ./traverse.sh
+ [ -d /sys/devices/platform/host4/iscsi_host ]
+ [ -d /sys/devices/platform/host4/session1/target4:0:0 ]
+ sed s/.*block\///
+ echo /sys/devices/platform/host4/session1/target*/*:*/block/*
+ BLOCK_DEV=*
+ awk /^\/dev\/*/ { print $2; }
+ DOS_PARTITIONS=/
+ echo DEBUG:/sys/devices/platform/host4/session1/target*/*:*/block/*
DEBUG:/sys/devices/platform/host4/session1/target*/*:*/block/*
+ echo DEBUG:/
DEBUG:/
+ echo umount /
umount /
+ exit_status=0
+ [ 0 -eq 0 ]
+ [ -d /sys/devices/platform/host5/iscsi_host ]
+ [ -d 

Bug#765431: open-iscsi: umountiscsi.sh script does not properly check while traverse sysfs structure

2014-10-20 Thread Ritesh Raj Sarraf
Thanks for the detailed analysis. I'll look into it very soon.

s3nt fr0m a $martph0ne, excuse typ0s
On Oct 20, 2014 9:03 AM, dmitry dmi...@bti.secna.ru wrote:

 Hello !
 17.10.2014 00:44, Ritesh Raj Sarraf пишет:

 On Thursday 16 October 2014 09:10 AM, Dmitry Danilov wrote:


  Yes, as I see, BLOCK_FILE variable should serves that.


 Sorry. But I'm not understanding this correct. Are  you saying we don't
 need the
 patch ?

 --
 Ritesh Raj Sarraf
 RESEARCHUT -http://www.researchut.com
 Necessity is the mother of invention.

  I think we need a patch.

 Let's look at problem again:

 What we have:

 system:

 root@archive:~# uname -a
 Linux archive 3.2.0-4-amd64 #1 SMP Debian 3.2.60-1+deb7u3 x86_64 GNU/Linux

 root@archive:~# lsb_release -a
 No LSB modules are available.
 Distributor ID: Debian
 Description:Debian GNU/Linux 7.6 (wheezy)
 Release:7.6
 Codename:   wheezy

 mounted partitions:

 root@archive:~# mount
 sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)
 proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
 udev on /dev type devtmpfs (rw,relatime,size=10240k,nr_
 inodes=62130,mode=755)
 devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,
 gid=5,mode=620,ptmxmode=000)
 tmpfs on /run type tmpfs (rw,nosuid,noexec,relatime,size=50896k,mode=755)
 /dev/disk/by-uuid/51c02def-2358-4270-a76d-3161633a1b22 on / type ext4
 (rw,relatime,errors=remount-ro,user_xattr,barrier=1,data=ordered)
 tmpfs on /run/lock type tmpfs (rw,nosuid,nodev,noexec,relatime,size=5120k)
 tmpfs on /run/shm type tmpfs (rw,nosuid,nodev,noexec,
 relatime,size=296960k)
 /dev/sdb1 on /mnt/sites_backup type ext4 (rw,relatime,user_xattr,acl,
 barrier=1,data=ordered,_netdev)
 /dev/sda1 on /mnt/sites_backup#2 type ext4 (rw,relatime,user_xattr,
 barrier=1,stripe=128,data=ordered,_netdev)


 Trying to restart|stop open-iscsi as if we have a new configured target:

 root@archive:~# /etc/init.d/open-iscsi restart
 [] Unmounting iscsi-backed filesystems: Unmounting all devices marked
 _netdevumount: /: device is busy.
 (In some cases useful info about processes that use
  the device is found by lsof(8) or fuser(1))
 [warn] Could not unmount / ... (warning).
  failed!
 invoke-rc.d: initscript umountiscsi.sh, action stop failed.
 [FAIL] Couldn't unmount all iSCSI devices. Cannot stop iSCSI service ...
 failed!
 root@archive:~#

 From initscript errors : umountiscsi trying to unmount / partition --
 Why?

 Inspect the situation:

 Adding -x parameter to umountiscsi.sh

 And try to restart service:
 root@archive:~# /etc/init.d/open-iscsi restart

 Look on exerpt output(full report in attached file):

 Here (the cause of problem):
 + [ -d /sys/devices/platform/host4/iscsi_host ]
 + [ -d /sys/devices/platform/host4/session1/target4:0:0 ]
 + sed s/.*block\///
 + echo /sys/devices/platform/host4/session1/target*/*:*/block/*
 + BLOCK_DEV=*
 + awk /^\/dev\/*/ { print $2; }
 + DOS_PARTITIONS=/
 + umount /
 umount: /: device is busy.
 (In some cases useful info about processes that use
  the device is found by lsof(8) or fuser(1))
 + exit_status=1

 I think, shell expansion leds to that, so that is why I suggest code to
 test BLOCK_DEV
 variable as empty 'directory' in sysfs i.e. :

 +   if  ! [ -d $BLOCK_FILE ]; then
 +   continue
 +   fi



 And another view to the same problem:

 Code snippet for debug purposes (taken from 'umountiscsi.sh' file)
 contains only traverse sysfs section:

 root@archive:~# cat traverse.sh

 #!/bin/sh -x

 for HOST_DIR in /sys/devices/platform/host*; do
 if ! [ -d $HOST_DIR/iscsi_host* ]; then
 continue
 fi
 for SESSION_DIR in $HOST_DIR/session*; do
 if ! [ -d $SESSION_DIR/target* ]; then
 continue
 fi
 for BLOCK_FILE in $SESSION_DIR/target*/*\:*/block/*; do
 BLOCK_DEV=`echo $BLOCK_FILE | sed 's/.*block\///'`
 DOS_PARTITIONS=`awk /^\/dev\/$BLOCK_DEV/ { print \\$2;
 }  /proc/mounts`
 echo DEBUG:${BLOCK_FILE}
 echo DEBUG:${DOS_PARTITIONS}
 for DEVICE in $DOS_PARTITIONS; do
 #log_progress_msg $DEVICE
 #echo $DEVICE
 echo umount ${DEVICE}
 exit_status=$?
 if ! [ $exit_status -eq 0 ]; then
 umount_fail=1
 log_warning_msg Could not unmount $DEVICE
 fi
 done
 done
 done
 done

 Output with trace mode i.e. bin/sh -x:

 root@archive:~# ./traverse.sh
 + [ -d /sys/devices/platform/host4/iscsi_host ]
 + [ -d /sys/devices/platform/host4/session1/target4:0:0 ]
 + sed s/.*block\///
 + echo /sys/devices/platform/host4/session1/target*/*:*/block/*
 + BLOCK_DEV=*
 + awk /^\/dev\/*/ { print $2; }
 + DOS_PARTITIONS=/
 + echo 

Bug#765431: open-iscsi: umountiscsi.sh script does not properly check while traverse sysfs structure

2014-10-16 Thread Ritesh Raj Sarraf
On Thursday 16 October 2014 09:10 AM, Dmitry Danilov wrote:

 Yes, as I see, BLOCK_FILE variable should serves that.

Sorry. But I'm not understanding this correct. Are  you saying we don't
need the patch ?

-- 
Ritesh Raj Sarraf
RESEARCHUT - http://www.researchut.com
Necessity is the mother of invention.



signature.asc
Description: OpenPGP digital signature


Bug#765431: open-iscsi: umountiscsi.sh script does not properly check while traverse sysfs structure

2014-10-15 Thread Ritesh Raj Sarraf
Hello Dmitry,

Thank you for the patch. Since I do not have an iscsi setup handy with
me right now, I'm gonna depend on you for some questions.


On Wednesday 15 October 2014 08:31 AM, Dmitry Danilov wrote:
   for BLOCK_FILE in $SESSION_DIR/target*/*\:*/block/*; do
 + if  ! [ -d $BLOCK_FILE ]; then 
 + continue
 + fi

I named the variable BLOCK_FILE. From what I'm guessing, it'd give us
the file names type block. No ??

-- 
Ritesh Raj Sarraf
RESEARCHUT - http://www.researchut.com
Necessity is the mother of invention.



signature.asc
Description: OpenPGP digital signature


Bug#765431: open-iscsi: umountiscsi.sh script does not properly check while traverse sysfs structure

2014-10-15 Thread Dmitry Danilov

Hello,

15.10.2014 17:49, Ritesh Raj Sarraf пишет:

Hello Dmitry,

Thank you for the patch. Since I do not have an iscsi setup handy with
me right now, I'm gonna depend on you for some questions.


On Wednesday 15 October 2014 08:31 AM, Dmitry Danilov wrote:

for BLOCK_FILE in $SESSION_DIR/target*/*\:*/block/*; do
+   if  ! [ -d $BLOCK_FILE ]; then
+   continue
+   fi


I named the variable BLOCK_FILE. From what I'm guessing, it'd give us
the file names type block. No ??

--
Ritesh Raj Sarraf
RESEARCHUT -http://www.researchut.com
Necessity is the mother of invention.


Yes, as I see, BLOCK_FILE variable should serves that.

--
Dmitry Danilov.


--
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of unsubscribe. Trouble? Contact listmas...@lists.debian.org



Bug#765431: open-iscsi: umountiscsi.sh script does not properly check while traverse sysfs structure

2014-10-14 Thread Dmitry Danilov
Package: open-iscsi
Version: 2.0.873-3
Severity: important
Tags: patch

Dear Maintainer,

The umountiscsi.sh helper script does not properly check while traverse sysfs 
filesystem for mounted 
iSCSI devices. This cause a problem unmounting / or other filesystems when 
'restart', 'stop' option 
used with open-iscsi init script.

I suggest patch (below) to repair this.



-- System Information:
Debian Release: 7.6
  APT prefers stable-updates
  APT policy: (500, 'stable-updates'), (500, 'stable')
Architecture: amd64 (x86_64)

Kernel: Linux 3.2.0-4-amd64 (SMP w/1 CPU core)
Locale: LANG=ru_RU.UTF-8, LC_CTYPE=ru_RU.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages open-iscsi depends on:
ii  libc6  2.13-38+deb7u4
ii  udev   175-7.2

open-iscsi recommends no packages.

open-iscsi suggests no packages.

-- Configuration Files:
/etc/init.d/umountiscsi.sh changed [not included]
/etc/iscsi/initiatorname.iscsi changed [not included]

-- no debconf information
--- umountiscsi.sh	2012-06-28 00:35:52.0 +0700
+++ umountiscsi-20141014.sh	2014-10-14 01:12:35.459559179 +0700
@@ -54,6 +54,9 @@
 			continue
 		fi
 		for BLOCK_FILE in $SESSION_DIR/target*/*\:*/block/*; do
+			if  ! [ -d $BLOCK_FILE ]; then 
+continue
+			fi
 			BLOCK_DEV=`echo $BLOCK_FILE | sed 's/.*block\///'`
 			DOS_PARTITIONS=`awk /^\/dev\/$BLOCK_DEV/ { print \\$2; }  /proc/mounts`
 			for DEVICE in $DOS_PARTITIONS; do