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

Reply or subscribe to this bug.

Toggle useless messages

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to x2go-dev@lists.x2go.org, X2Go Developers <x2go-dev@lists.x2go.org>:
Bug#1032; Package x2gocdmanager. (Fri, 29 Apr 2016 14:55:01 GMT) (full text, mbox, link).


Acknowledgement sent to Arne Wichmann <aw@anhrefn.saar.de>:
New Bug report received and forwarded. Copy sent to X2Go Developers <x2go-dev@lists.x2go.org>. (Fri, 29 Apr 2016 14:55:02 GMT) (full text, mbox, link).


Message #5 received at submit@bugs.x2go.org (full text, mbox, reply):

From: Arne Wichmann <aw@anhrefn.saar.de>
To: submit@bugs.x2go.org
Subject: x2gocdmanager failing in a number of corner cases
Date: Fri, 29 Apr 2016 16:50:44 +0200
[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: Fri Mar 29 10:39:41 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.