1 From: William Jon McCann <mccann@jhu.edu>
2 Date: Tue, 15 May 2007 15:15:12 +0000 (-0400)
3 Subject: a few fixes for getfd suggested by Lennart
4 X-Git-Url: http://gitweb.freedesktop.org/?p=ConsoleKit.git;a=commitdiff;h=17ff9ceb88e0b7f6dc5a7e6eac5ff98cb4a5cabe
6 a few fixes for getfd suggested by Lennart
8 I am currently investigating how to best integrate PulseAudio with
9 ConsoleKit/PolicyKit. While doing that I had a look on your code, and
10 found a few issues in getfd.c I'd like to report, before I forget
11 them. I couldn't find any bugzilla with at consolekit project (neither
12 fedora, nor fdo, nor gnome?) hence I am mailing you in person.
14 In getfd.c in open_a_console() a close() is missing if is_a_console is
17 The open() in open_a_console() should probably use O_NOCTTY. Otherwise
18 C-c on the console might end up in a SIGINT to your daemon process!
20 Also I'd add an isatty() check to is_a_console(), to makes sure that
21 you're actually talking to a TTY before you issue KDGKBTYPE on
22 it. ioctl()s are unfortunately not unique, hence i'd recommend that check.
31 @@ -30,7 +30,8 @@ is_a_console (int fd)
35 - return (ioctl (fd, KDGKBTYPE, &arg) == 0
37 + && ioctl (fd, KDGKBTYPE, &arg) == 0
38 && ((arg == KB_101) || (arg == KB_84)));
41 @@ -39,11 +40,18 @@ open_a_console (char *fnam)
45 - fd = open (fnam, O_RDONLY);
46 + fd = open (fnam, O_RDONLY | O_NOCTTY);
47 if (fd < 0 && errno == EACCES)
48 - fd = open(fnam, O_WRONLY);
49 - if (fd < 0 || ! is_a_console (fd))
50 + fd = open (fnam, O_WRONLY | O_NOCTTY);
55 + if (! is_a_console (fd)) {