]> git.pld-linux.org Git - packages/ConsoleKit.git/blame - ConsoleKit-SIGINT.patch
- updated to 0.2.3
[packages/ConsoleKit.git] / ConsoleKit-SIGINT.patch
CommitLineData
6d313fb4 1From: William Jon McCann <mccann@jhu.edu>
2Date: Tue, 15 May 2007 15:15:12 +0000 (-0400)
3Subject: a few fixes for getfd suggested by Lennart
4X-Git-Url: http://gitweb.freedesktop.org/?p=ConsoleKit.git;a=commitdiff;h=17ff9ceb88e0b7f6dc5a7e6eac5ff98cb4a5cabe
5
6a few fixes for getfd suggested by Lennart
7
8I am currently investigating how to best integrate PulseAudio with
9ConsoleKit/PolicyKit. While doing that I had a look on your code, and
10found a few issues in getfd.c I'd like to report, before I forget
11them. I couldn't find any bugzilla with at consolekit project (neither
12fedora, nor fdo, nor gnome?) hence I am mailing you in person.
13
14In getfd.c in open_a_console() a close() is missing if is_a_console is
15missing.
16
17The open() in open_a_console() should probably use O_NOCTTY. Otherwise
18C-c on the console might end up in a SIGINT to your daemon process!
19
20Also I'd add an isatty() check to is_a_console(), to makes sure that
21you're actually talking to a TTY before you issue KDGKBTYPE on
22it. ioctl()s are unfortunately not unique, hence i'd recommend that check.
23
24That's it,
25
26Lennart
27---
28
29--- a/src/getfd.c
30+++ b/src/getfd.c
31@@ -30,7 +30,8 @@ is_a_console (int fd)
32 char arg;
33
34 arg = 0;
35- return (ioctl (fd, KDGKBTYPE, &arg) == 0
36+ return (isatty (fd)
37+ && ioctl (fd, KDGKBTYPE, &arg) == 0
38 && ((arg == KB_101) || (arg == KB_84)));
39 }
40
41@@ -39,11 +40,18 @@ open_a_console (char *fnam)
42 {
43 int fd;
44
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);
51+
52+ if (fd < 0)
53 return -1;
54+
55+ if (! is_a_console (fd)) {
56+ close (fd);
57+ fd = -1;
58+ }
59+
60 return fd;
61 }
62
This page took 0.485453 seconds and 4 git commands to generate.