X2Go Bug report logs - #1032
x2gocdmanager failing in a number of corner cases

version graph

Package: x2gocdmanager; Maintainer for x2gocdmanager is X2Go Developers <x2go-dev@lists.x2go.org>; Source for x2gocdmanager is src:x2gocdmanager.

Reported by: Arne Wichmann <aw@anhrefn.saar.de>

Date: Fri, 29 Apr 2016 14:55:01 UTC

Severity: normal

Tags: patch

Found in version 1.1.0.2-0x2go1+git20150607.485+jessie.main.1

Full log


🔗 View this message in rfc822 format

X-Loop: owner@bugs.x2go.org
Subject: Bug#1032: x2gocdmanager failing in a number of corner cases
Reply-To: Arne Wichmann <aw@anhrefn.saar.de>, 1032@bugs.x2go.org
Resent-From: Arne Wichmann <aw@anhrefn.saar.de>
Resent-To: x2go-dev@lists.x2go.org
Resent-CC: X2Go Developers <x2go-dev@lists.x2go.org>
X-Loop: owner@bugs.x2go.org
Resent-Date: Fri, 29 Apr 2016 14:55:01 +0000
Resent-Message-ID: <handler.1032.B.14619414536063@bugs.x2go.org>
Resent-Sender: owner@bugs.x2go.org
X-X2Go-PR-Message: report 1032
X-X2Go-PR-Package: x2gocdmanager
X-X2Go-PR-Keywords: patch
Received: via spool by submit@bugs.x2go.org id=B.14619414536063
          (code B); Fri, 29 Apr 2016 14:55:01 +0000
Received: (at submit) by bugs.x2go.org; 29 Apr 2016 14:50:53 +0000
X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on
	ymir.das-netzwerkteam.de
X-Spam-Level: 
X-Spam-Status: No, score=0.8 required=3.0 tests=BAYES_50,URIBL_BLOCKED
	autolearn=ham version=3.3.2
Received: from localhost (localhost [127.0.0.1])
	by ymir.das-netzwerkteam.de (Postfix) with ESMTP id A60765DA98
	for <submit@bugs.x2go.org>; Fri, 29 Apr 2016 16:50:51 +0200 (CEST)
X-Virus-Scanned: Debian amavisd-new at ymir.das-netzwerkteam.de
Received: from ymir.das-netzwerkteam.de ([127.0.0.1])
	by localhost (ymir.das-netzwerkteam.de [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id FLPoPbFtextg for <submit@bugs.x2go.org>;
	Fri, 29 Apr 2016 16:50:44 +0200 (CEST)
Received: from apu.snow-crash.org (apu.snow-crash.org [78.47.227.179])
	by ymir.das-netzwerkteam.de (Postfix) with ESMTP id C9DC55DA93
	for <submit@bugs.x2go.org>; Fri, 29 Apr 2016 16:50:44 +0200 (CEST)
Received: from chao.old-forest.org (arne.local [10.99.0.2])
	by apu.snow-crash.org (Postfix) with ESMTP id 8C5B18276A
	for <submit@bugs.x2go.org>; Fri, 29 Apr 2016 16:50:44 +0200 (CEST)
Received: from anhrefn ([192.168.10.23] helo=anhrefn.saar.de)
	by chao.old-forest.org with esmtps (Exim 4.84_2)
	(envelope-from <aw@old-forest.org>)
	id 1aw9ki-00032X-6l
	for submit@bugs.x2go.org; Fri, 29 Apr 2016 16:50:44 +0200
Received: from aw by anhrefn.saar.de with local (Exim 4.87)
	(envelope-from <aw@old-forest.org>)
	id 1aw9ki-00063M-7e
	for submit@bugs.x2go.org; Fri, 29 Apr 2016 16:50:44 +0200
Date: Fri, 29 Apr 2016 16:50:44 +0200
From: Arne Wichmann <aw@anhrefn.saar.de>
To: submit@bugs.x2go.org
Message-ID: <20160429145044.GA23150@anhrefn.saar.de>
MIME-Version: 1.0
Content-Type: multipart/signed; micalg=pgp-sha256;
	protocol="application/pgp-signature"; boundary="AhhlLboLdkugWU4S"
Content-Disposition: inline
User-Agent: Mutt/1.5.23 (2014-03-12)
[Message part 1 (text/plain, inline)]
Package: x2gocdmanager
Version: 1.1.0.2-0x2go1+git20150607.485+jessie.main.1
Tags: patch

I found a number of cases where x2gocdmanager was not mounting/unmounting
CDROMs as expected. Namely:
- When CDs were changed quickly, the change of CD was not detected and the
  old CD stayed mounted
- Sometimes the umount failed because some files were still open (and
  similar cases). In that case x2gocdmanager considered the CD umounted and
  all further tries to mount a CD failed.

I append a patch which apart from these problem cases
- creates support for a log file, so problems can be more easily debugged.
  If the log file is not present a warning will be printed, but
  x2gocdmanager will work without logging as it was before
- makes an effort to unmount everything in /media at the start of the
  manager
- includes some basic debug output so that further problems can be
  pinpointed more easily

Indentations are a bit broken in the patch...

cu

AW

--- /usr/sbin/x2gocdmanager.dpkg-dist   2016-04-29 16:01:19.000000000 +0200
+++ /usr/sbin/x2gocdmanager     2016-04-29 16:01:41.000000000 +0200
@@ -46,11 +46,19 @@
 
        # silence this daemon script completely...
        close(STDIN);
-       close(STDOUT);
-       close(STDERR);
 
        $SIG{TERM}=\&catch_term;
 
+       # do not die here - file unwritable is a way to silence this
+       open(STDOUT,">>/var/log/x2gocdmanager") || warn "open failed: $!";
+       open(STDERR,">>&STDOUT") || print("open failed: $!");
+       print("Started ",time(),"\n");
+
+       # unmount everything which is mounted in /media
+       for (glob("/media/*")) {
+         system("umount -ff $_") or warn "could not umount $_";
+       }
+
        my @mounted;
        my @idedrives;
 
@@ -108,7 +116,11 @@
                        }
                        elsif($rez==101) 
                        {
-                               push(@cdarray,@drives[$i]);
+                               # do not push if media change detected
+                               # this will umount the CD. after the next
+                               # iteration the new one will be mounted
+                               $_=ioctl(CDROM,0x5325,0);
+                               push(@cdarray,@drives[$i]) unless $_==1;
                        }
                        close (CDROM);
                }
@@ -129,33 +141,35 @@
                                open (D,">",expand_filename("~x2gothinclient/export/$name.unexport"));
                                print D "unexport=/media/$name\n";
                                close(D);
-                               system("umount -ff /media/$name");
-
+                               print("umounting $name\n");
+                               if (system("umount -ff /media/$name")==0) {
                                system("killall x2goejectcd");
                                splice(@mounted,$i,1);
                        }
                }
+               }
 
                # enumerate all available CD/DVD devices
                for my $i (0..$#cdarray)
                {
                        # mount the CD/DVD device if not yet mounted...
                        my @arr=grep { "$_" eq "@cdarray[$i]" } @mounted;
-                       if (@arr == 0)
-                       {
+                 if (@arr == 0) {
                                my @name=split("/","@cdarray[$i]");
                                my $name="CDROM-@name[2]";
                                mkdir("/media");
                                mkdir("/media/$name");
+                   print("mounting @cdarray[$i]\n");
                                {
                                        open (D,">",expand_filename("~x2gothinclient/export/$name"));
                                        print D "export=/media/$name\n";
                                        close(D);
+                     print("mount worked: @cdarray[$i]\n");
                                        push (@mounted,@cdarray[$i]);
                                        system("killall x2goejectcd");
                                        system("DISPLAY=:0 x2goejectcd&");
-                               }
+                   } else { warn("mount failed: $?"); }
                        }
                }
        }



-- 
[...] If you don't want to be restricted, don't agree to it. If you are
coerced, comply as much as you must to protect yourself, just don't support
it. Noone can free you but yourself. (crag, on Debian Planet)
Arne Wichmann (aw@saar.de)
[signature.asc (application/pgp-signature, inline)]

Send a report that this bug log contains spam.


X2Go Developers <owner@bugs.x2go.org>. Last modified: Wed Dec 4 08:36:10 2024; Machine Name: ymir.das-netzwerkteam.de

X2Go Bug tracking system

Debbugs is free software and licensed under the terms of the GNU Public License version 2. The current version can be obtained from https://bugs.debian.org/debbugs-source/.

Copyright © 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson, 2005-2017 Don Armstrong, and many other contributors.