[pkg-fso-commits] [SCM] Automatic Display Manager branch, master, updated. debian/0.5-1-1-g672bb50

Enrico Zini enrico at enricozini.org
Sun Jul 26 19:18:17 UTC 2009


The following commit has been merged in the master branch:
commit 672bb503c5caf37c0356ce1f0cd30e00b1c0316c
Author: Enrico Zini <enrico at enricozini.org>
Date:   Sun Jul 26 20:40:26 2009 +0200

    Try harder to open the console device. Closes: #538640.

diff --git a/configure.ac b/configure.ac
index 8bb723d..ccf78c6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,5 +1,5 @@
 dnl Process this file with autoconf to produce a configure script.
-AC_INIT(nodm, 0.5, [enrico at enricozini.org, nomeata at debian.org])
+AC_INIT(nodm, 0.6, [enrico at enricozini.org, nomeata at debian.org])
 AC_CONFIG_SRCDIR([configure.ac])
 AC_CONFIG_AUX_DIR([config])
 AM_INIT_AUTOMAKE([-Wall std-options foreign])
diff --git a/debian/changelog b/debian/changelog
index 6de1e3e..9cb1259 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,10 @@
+nodm (0.6-1) unstable; urgency=low
+
+  * New upstream version
+     - try harder to open the console device. Closes: #538640.
+
+ -- Enrico Zini <enrico at debian.org>  Sun, 26 Jul 2009 20:39:25 +0200
+
 nodm (0.5-1) unstable; urgency=low
 
   * New upstream version
diff --git a/nodm.c b/nodm.c
index 79623ed..a7a68de 100644
--- a/nodm.c
+++ b/nodm.c
@@ -249,6 +249,29 @@ cleanup:
 	return ret;
 }
 
+static int try_vtstate(const char* dev, struct vt_stat* vtstat)
+{
+	int res = 0;
+	int fd = open(dev, O_WRONLY | O_NOCTTY, 0);
+	if (fd < 0)
+		goto cleanup;
+	if (ioctl (fd, VT_GETSTATE, vtstat) < 0)
+		goto cleanup;
+	res = 1;
+
+cleanup:
+	if (fd >= 0) close(fd);
+	return res;
+}
+
+static int get_vtstate(struct vt_stat* vtstat)
+{
+	if (try_vtstate("/dev/tty", vtstat)) return 1;
+	if (try_vtstate("/dev/tty0", vtstat)) return 1;
+	if (try_vtstate("/dev/console", vtstat)) return 1;
+	return 0;
+}
+
 /*
  * Allocate a new vt, open it and return the file descriptor and the vt number.
  *
@@ -260,16 +283,10 @@ int open_vt(int *vtnum)
 	int res = -1;
 	struct vt_stat vtstat;
 	unsigned short vtmask;
-	int fd = open("/dev/console", O_WRONLY | O_NOCTTY, 0);
-	if (fd < 0)
-	{
-		fprintf (stderr, _("%s: cannot open /dev/console: %m\n"), Prog);
-		goto cleanup;
-	}
 
-	if (ioctl (fd, VT_GETSTATE, &vtstat) < 0)
+	if (!get_vtstate(&vtstat))
 	{
-		fprintf (stderr, _("%s: VT_GETSTATE failed on /dev/console: %m\n"), Prog);
+		fprintf (stderr, _("%s: cannot find or open the console\n"), Prog);
 		goto cleanup;
 	}
 
@@ -289,8 +306,6 @@ int open_vt(int *vtnum)
 	}
 
 cleanup:
-	if (fd >= 0)
-		close(fd);
 	return res;
 }
 

-- 
Automatic Display Manager



More information about the pkg-fso-commits mailing list