From a50faed99ac4c096df0a729d88de78f376de7f64 Mon Sep 17 00:00:00 2001 From: "raveit65 (via Travis CI)" Date: Wed, 21 Feb 2024 23:51:38 +0000 Subject: Deploy mate-desktop/mate-screensaver to github.com/mate-desktop/mate-screensaver.git:gh-pages --- .../index.html | 189 ++ .../report-062a69.html | 848 +++++ .../report-069bf4.html | 1355 ++++++++ .../report-06c118.html | 1283 ++++++++ .../report-09b55a.html | 848 +++++ .../report-0bc662.html | 1236 ++++++++ .../report-19ddc6.html | 3250 ++++++++++++++++++++ .../report-2084b3.html | 898 ++++++ .../report-24761d.html | 1355 ++++++++ .../report-2dd8bc.html | 1355 ++++++++ .../report-489c44.html | 848 +++++ .../report-4b9cac.html | 848 +++++ .../report-534ad8.html | 1490 +++++++++ .../report-57e5d7.html | 1236 ++++++++ .../report-5a3c1b.html | 848 +++++ .../report-68e8c1.html | 1490 +++++++++ .../report-86b9eb.html | 1490 +++++++++ .../report-88c30c.html | 1236 ++++++++ .../report-8aee73.html | 848 +++++ .../report-958ab4.html | 1236 ++++++++ .../report-a25f69.html | 1236 ++++++++ .../report-ac5343.html | 3250 ++++++++++++++++++++ .../report-b0e322.html | 1236 ++++++++ .../report-ba3e4e.html | 1309 ++++++++ .../report-bdd56f.html | 848 +++++ .../report-be2741.html | 1355 ++++++++ .../report-c2b391.html | 3250 ++++++++++++++++++++ .../report-e0169c.html | 3250 ++++++++++++++++++++ .../report-e73a25.html | 848 +++++ .../report-fa48d9.html | 1490 +++++++++ .../report-fc5910.html | 815 +++++ .../scanview.css | 62 + .../sorttable.js | 492 +++ 33 files changed, 43628 insertions(+) create mode 100644 2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/index.html create mode 100644 2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-062a69.html create mode 100644 2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-069bf4.html create mode 100644 2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-06c118.html create mode 100644 2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-09b55a.html create mode 100644 2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-0bc662.html create mode 100644 2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-19ddc6.html create mode 100644 2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-2084b3.html create mode 100644 2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-24761d.html create mode 100644 2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-2dd8bc.html create mode 100644 2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-489c44.html create mode 100644 2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-4b9cac.html create mode 100644 2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-534ad8.html create mode 100644 2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-57e5d7.html create mode 100644 2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-5a3c1b.html create mode 100644 2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-68e8c1.html create mode 100644 2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-86b9eb.html create mode 100644 2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-88c30c.html create mode 100644 2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-8aee73.html create mode 100644 2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-958ab4.html create mode 100644 2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-a25f69.html create mode 100644 2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-ac5343.html create mode 100644 2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-b0e322.html create mode 100644 2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-ba3e4e.html create mode 100644 2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-bdd56f.html create mode 100644 2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-be2741.html create mode 100644 2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-c2b391.html create mode 100644 2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-e0169c.html create mode 100644 2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-e73a25.html create mode 100644 2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-fa48d9.html create mode 100644 2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-fc5910.html create mode 100644 2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/scanview.css create mode 100644 2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/sorttable.js (limited to '2022-11-11-203102-6531-1@d85b90eff925_v1.27.0') diff --git a/2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/index.html b/2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/index.html new file mode 100644 index 0000000..a1427d6 --- /dev/null +++ b/2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/index.html @@ -0,0 +1,189 @@ + + +rootdir - scan-build results + + + + + + +

rootdir - scan-build results

+ + + + + + + +
User:root@881be7baff4e
Working Directory:/rootdir
Command Line:make -j 2
Clang Version:clang version 14.0.5 (Fedora 14.0.5-1.fc36) +
Date:Fri Nov 11 20:31:02 2022
+

Bug Summary

+ + + + + + + + + + + + +
Bug TypeQuantityDisplay?
All Bugs30
Logic error
Out-of-bound access1
Memory error
Memory leak1
Security
Potential insecure memory buffer bounds restriction in call 'strcat'4
Potential insecure memory buffer bounds restriction in call 'strcpy'4
Unused code
Dead assignment18
Unreachable code2
+

Reports

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
Bug GroupBug Type ▾FileFunction/MethodLinePath Length
Unused codeDead assignmentrc/gs-watcher-x11.cconnect_presence_watcher4671View Report
Unused codeDead assignmentavers/gste-popsquares.cmake_color_ramp2321View Report
Unused codeDead assignmentrc/gs-window-x11.cspawn_on_window11291View Report
Unused codeDead assignmentrc/gs-watcher-x11.cdisable_builtin_screensaver5991View Report
Unused codeDead assignmentrc/gs-watcher-x11.cdisable_builtin_screensaver5961View Report
Unused codeDead assignmentrc/gs-auth-pam.ccreate_pam_handle3801View Report
Unused codeDead assignmentrc/mate-screensaver-command.cdo_command4401View Report
Unused codeDead assignmentrc/gs-auth-pam.cgs_auth_pam_verify_user6751View Report
Unused codeDead assignmentrc/gs-auth-pam.cpam_conversation2551View Report
Unused codeDead assignmentrc/mate-screensaver-command.cdo_command3401View Report
Unused codeDead assignmentrc/mate-screensaver-command.cdo_command4301View Report
Unused codeDead assignmentrc/mate-screensaver-command.cdo_command4351View Report
Unused codeDead assignmentrc/gs-window-x11.cerror_watch10261View Report
Unused codeDead assignmentrc/mate-screensaver-command.cdo_command4451View Report
Unused codeDead assignmentrc/gs-watcher-x11.cdisable_builtin_screensaver5971View Report
Unused codeDead assignmentrc/gs-window-x11.ckeyboard_command_watch13621View Report
Unused codeDead assignmentrc/gs-window-x11.clock_command_watch16301View Report
Unused codeDead assignmentrc/gs-auth-pam.ccreate_pam_handle3821View Report
Memory errorMemory leakrc/mate-screensaver-command.cget_string_from_iter32727View Report
Logic errorOut-of-bound accessavers/xdg-user-dir-lookup.cxdg_user_dir_lookup9117View Report
SecurityPotential insecure memory buffer bounds restriction in call 'strcat'avers/xdg-user-dir-lookup.cxdg_user_dir_lookup551View Report
SecurityPotential insecure memory buffer bounds restriction in call 'strcat'avers/xdg-user-dir-lookup.cxdg_user_dir_lookup1181View Report
SecurityPotential insecure memory buffer bounds restriction in call 'strcat'avers/xdg-user-dir-lookup.cxdg_user_dir_lookup1461View Report
SecurityPotential insecure memory buffer bounds restriction in call 'strcat'avers/xdg-user-dir-lookup.cxdg_user_dir_lookup611View Report
SecurityPotential insecure memory buffer bounds restriction in call 'strcpy'avers/xdg-user-dir-lookup.cxdg_user_dir_lookup1171View Report
SecurityPotential insecure memory buffer bounds restriction in call 'strcpy'avers/xdg-user-dir-lookup.cxdg_user_dir_lookup601View Report
SecurityPotential insecure memory buffer bounds restriction in call 'strcpy'avers/xdg-user-dir-lookup.cxdg_user_dir_lookup1451View Report
SecurityPotential insecure memory buffer bounds restriction in call 'strcpy'avers/xdg-user-dir-lookup.cxdg_user_dir_lookup541View Report
Unused codeUnreachable coderc/mate-screensaver-command.cmain5291View Report
Unused codeUnreachable coderc/test-fade.cmain941View Report
+ + diff --git a/2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-062a69.html b/2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-062a69.html new file mode 100644 index 0000000..8b5107f --- /dev/null +++ b/2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-062a69.html @@ -0,0 +1,848 @@ + + + +xdg-user-dir-lookup.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:avers/xdg-user-dir-lookup.c
Warning:line 117, column 4
Call to function 'strcpy' is insecure as it does not provide bounding of the memory buffer. Replace unbounded copy functions with analogous functions that support length arguments such as 'strlcpy'. CWE-119
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name xdg-user-dir-lookup.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/savers -resource-dir /usr/lib64/clang/14.0.5 -D HAVE_CONFIG_H -I . -I .. -I . -I . -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -D LIBEXECDIR="/usr/local/libexec" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -internal-isystem /usr/lib64/clang/14.0.5/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/12/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdebug-compilation-dir=/rootdir/savers -ferror-limit 19 -fgnuc-version=4.2.1 -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2022-11-11-203102-6531-1 -x c xdg-user-dir-lookup.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/*
2 This file is not licenced under the GPL like the rest of the code.
3 Its is under the MIT license, to encourage reuse by cut-and-paste.
4
5 Copyright (c) 2007 Red Hat, inc
6 Copyright (C) 2012-2021 MATE Developers
7
8 Permission is hereby granted, free of charge, to any person
9 obtaining a copy of this software and associated documentation files
10 (the "Software"), to deal in the Software without restriction,
11 including without limitation the rights to use, copy, modify, merge,
12 publish, distribute, sublicense, and/or sell copies of the Software,
13 and to permit persons to whom the Software is furnished to do so,
14 subject to the following conditions:
15
16 The above copyright notice and this permission notice shall be
17 included in all copies or substantial portions of the Software.
18
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
23 BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
24 ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
25 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26 SOFTWARE.
27*/
28
29#include <stdio.h>
30#include <stdlib.h>
31#include <string.h>
32
33#include "xdg-user-dir-lookup.h"
34
35char *
36xdg_user_dir_lookup (const char *type)
37{
38 FILE *file;
39 char *home_dir, *config_home, *config_file;
40 char buffer[512];
41 char *user_dir;
42 char *p, *d;
43 int relative;
44
45 home_dir = getenv ("HOME");
46
47 if (home_dir == NULL((void*)0))
48 return strdup ("/tmp");
49
50 config_home = getenv ("XDG_CONFIG_HOME");
51 if (config_home == NULL((void*)0) || config_home[0] == 0)
52 {
53 config_file = malloc (strlen (home_dir) + strlen ("/.config/user-dirs.dirs") + 1);
54 strcpy (config_file, home_dir);
55 strcat (config_file, "/.config/user-dirs.dirs");
56 }
57 else
58 {
59 config_file = malloc (strlen (config_home) + strlen ("/user-dirs.dirs") + 1);
60 strcpy (config_file, config_home);
61 strcat (config_file, "/user-dirs.dirs");
62 }
63
64 file = fopen (config_file, "r");
65 free (config_file);
66 if (file == NULL((void*)0))
67 goto error;
68
69 user_dir = NULL((void*)0);
70 while (fgets (buffer, sizeof (buffer), file))
71 {
72 /* Remove newline at end */
73 size_t len = strlen (buffer);
74 if (len != 0 && buffer[len-1] == '\n')
75 buffer[len-1] = 0;
76
77 p = buffer;
78 while (*p == ' ' || *p == '\t')
79 p++;
80
81 if (strncmp (p, "XDG_", 4) != 0)
82 continue;
83 p += 4;
84 if (strncmp (p, type, strlen (type)) != 0)
85 continue;
86 p += strlen (type);
87 if (strncmp (p, "_DIR", 4) != 0)
88 continue;
89 p += 4;
90
91 while (*p == ' ' || *p == '\t')
92 p++;
93
94 if (*p != '=')
95 continue;
96 p++;
97
98 while (*p == ' ' || *p == '\t')
99 p++;
100
101 if (*p != '"')
102 continue;
103 p++;
104
105 relative = 0;
106 if (strncmp (p, "$HOME/", 6) == 0)
107 {
108 p += 6;
109 relative = 1;
110 }
111 else if (*p != '/')
112 continue;
113
114 if (relative)
115 {
116 user_dir = malloc (strlen (home_dir) + 1 + strlen (p) + 1);
117 strcpy (user_dir, home_dir);
Call to function 'strcpy' is insecure as it does not provide bounding of the memory buffer. Replace unbounded copy functions with analogous functions that support length arguments such as 'strlcpy'. CWE-119
118 strcat (user_dir, "/");
119 }
120 else
121 {
122 user_dir = malloc (strlen (p) + 1);
123 *user_dir = 0;
124 }
125
126 d = user_dir + strlen (user_dir);
127 while (*p && *p != '"')
128 {
129 if ((*p == '\\') && (*(p+1) != 0))
130 p++;
131 *d++ = *p++;
132 }
133 *d = 0;
134 }
135 fclose (file);
136
137 if (user_dir)
138 return user_dir;
139
140error:
141 /* Special case desktop for historical compatibility */
142 if (strcmp (type, "DESKTOP") == 0)
143 {
144 user_dir = malloc (strlen (home_dir) + strlen ("/Desktop") + 1);
145 strcpy (user_dir, home_dir);
146 strcat (user_dir, "/Desktop");
147 return user_dir;
148 }
149 else
150 return strdup (home_dir);
151}
152
153#ifdef STANDALONE
154
155int
156main (int argc, char *argv[])
157{
158 if (argc != 2)
159 {
160 fprintf (stderrstderr, "Usage %s <dir-type>\n", argv[0]);
161 exit (1);
162 }
163
164 printf ("%s\n", xdg_user_dir_lookup (argv[1]));
165 return 0;
166}
167
168#endif
diff --git a/2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-069bf4.html b/2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-069bf4.html new file mode 100644 index 0000000..5320c49 --- /dev/null +++ b/2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-069bf4.html @@ -0,0 +1,1355 @@ + + + +gs-watcher-x11.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rc/gs-watcher-x11.c
Warning:line 467, column 4
Value stored to 'status' is never read
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name gs-watcher-x11.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/14.0.5 -D HAVE_CONFIG_H -I . -I .. -I . -I . -D MATEMENU_I_KNOW_THIS_IS_UNSTABLE -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/dconf -I /usr/include/mate-menus -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/dconf -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/dconf -I /usr/include/mate-menus -D PREFIX="/usr/local" -D BINDIR="/usr/local/bin" -D LIBDIR="/usr/local/lib" -D LIBEXECDIR="/usr/local/libexec" -D DATADIR="/usr/local/share" -D SYSCONFDIR="/usr/local/etc" -D MATELOCALEDIR="/usr/local/share/locale" -D PKGLIBEXECDIR="/usr/local/libexec/mate-screensaver" -D SAVERDIR="/usr/local/libexec/mate-screensaver" -D THEMESDIR="/usr/local/share/mate-screensaver/themes" -D GTKBUILDERDIR="/usr/local/share/mate-screensaver" -D MATE_SCREENSAVER_GL_HELPER_PATH="/usr/local/libexec/mate-screensaver-gl-helper" -D PAM_SERVICE_NAME="mate-screensaver" -D G_DISABLE_ASSERT -D G_DISABLE_CHECKS -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -internal-isystem /usr/lib64/clang/14.0.5/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/12/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2022-11-11-203102-6531-1 -x c gs-watcher-x11.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
2 *
3 * Copyright (C) 2004-2006 William Jon McCann <mccann@jhu.edu>
4 * Copyright (C) 2008 Red Hat, Inc.
5 * Copyright (C) 2012-2021 MATE Developers
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
20 *
21 * Authors: William Jon McCann <mccann@jhu.edu>
22 *
23 */
24
25#include "config.h"
26#include <stdlib.h>
27#include <stdio.h>
28#include <time.h>
29#include <errno(*__errno_location ()).h>
30
31#include <string.h>
32#include <gdk/gdkx.h>
33
34#include <dbus/dbus.h>
35#include <dbus/dbus-glib.h>
36
37#include "gs-watcher.h"
38#include "gs-marshal.h"
39#include "gs-debug.h"
40
41static void gs_watcher_finalize (GObject *object);
42
43static gboolean watchdog_timer (GSWatcher *watcher);
44
45struct GSWatcherPrivate
46{
47 /* settings */
48 guint enabled : 1;
49 guint delta_notice_timeout;
50
51 /* state */
52 guint active : 1;
53 guint idle : 1;
54 guint idle_notice : 1;
55
56 guint idle_id;
57 char *status_message;
58
59 DBusGProxy *presence_proxy;
60 guint watchdog_timer_id;
61};
62
63enum
64{
65 PROP_0,
66 PROP_STATUS_MESSAGE
67};
68
69enum
70{
71 IDLE_CHANGED,
72 IDLE_NOTICE_CHANGED,
73 LAST_SIGNAL
74};
75
76static guint signals [LAST_SIGNAL] = { 0, };
77
78G_DEFINE_TYPE_WITH_PRIVATE (GSWatcher, gs_watcher, G_TYPE_OBJECT)static void gs_watcher_init (GSWatcher *self); static void gs_watcher_class_init
(GSWatcherClass *klass); static GType gs_watcher_get_type_once
(void); static gpointer gs_watcher_parent_class = ((void*)0)
; static gint GSWatcher_private_offset; static void gs_watcher_class_intern_init
(gpointer klass) { gs_watcher_parent_class = g_type_class_peek_parent
(klass); if (GSWatcher_private_offset != 0) g_type_class_adjust_private_offset
(klass, &GSWatcher_private_offset); gs_watcher_class_init
((GSWatcherClass*) klass); } __attribute__ ((__unused__)) static
inline gpointer gs_watcher_get_instance_private (GSWatcher *
self) { return (((gpointer) ((guint8*) (self) + (glong) (GSWatcher_private_offset
)))); } GType gs_watcher_get_type (void) { static gsize static_g_define_type_id
= 0; if ((__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); (void
) (0 ? (gpointer) *(&static_g_define_type_id) : ((void*)0
)); (!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
(*(&static_g_define_type_id)) gapg_temp_newval; __typeof__
((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id
); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5)
; gapg_temp_newval; })) && g_once_init_enter (&static_g_define_type_id
)); }))) { GType g_define_type_id = gs_watcher_get_type_once (
); (__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); 0 ?
(void) (*(&static_g_define_type_id) = (g_define_type_id)
) : (void) 0; g_once_init_leave ((&static_g_define_type_id
), (gsize) (g_define_type_id)); })); } return static_g_define_type_id
; } __attribute__ ((__noinline__)) static GType gs_watcher_get_type_once
(void) { GType g_define_type_id = g_type_register_static_simple
(((GType) ((20) << (2))), g_intern_static_string ("GSWatcher"
), sizeof (GSWatcherClass), (GClassInitFunc)(void (*)(void)) gs_watcher_class_intern_init
, sizeof (GSWatcher), (GInstanceInitFunc)(void (*)(void)) gs_watcher_init
, (GTypeFlags) 0); { {{ GSWatcher_private_offset = g_type_add_instance_private
(g_define_type_id, sizeof (GSWatcherPrivate)); };} } return g_define_type_id
; }
79
80static void
81remove_watchdog_timer (GSWatcher *watcher)
82{
83 if (watcher->priv->watchdog_timer_id != 0)
84 {
85 g_source_remove (watcher->priv->watchdog_timer_id);
86 watcher->priv->watchdog_timer_id = 0;
87 }
88}
89
90static void
91add_watchdog_timer (GSWatcher *watcher,
92 guint timeout)
93{
94 watcher->priv->watchdog_timer_id = g_timeout_add (timeout,
95 (GSourceFunc)watchdog_timer,
96 watcher);
97}
98
99static void
100gs_watcher_get_property (GObject *object,
101 guint prop_id,
102 GValue *value,
103 GParamSpec *pspec)
104{
105 GSWatcher *self;
106
107 self = GS_WATCHER (object)((((GSWatcher*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((gs_watcher_get_type ()))))))
;
108
109 switch (prop_id)
110 {
111 case PROP_STATUS_MESSAGE:
112 g_value_set_string (value, self->priv->status_message);
113 break;
114 default:
115 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec)do { GObject *_glib__object = (GObject*) ((object)); GParamSpec
*_glib__pspec = (GParamSpec*) ((pspec)); guint _glib__property_id
= ((prop_id)); g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'"
, "gs-watcher-x11.c", 115, ("property"), _glib__property_id, _glib__pspec
->name, g_type_name ((((((GTypeClass*) (((GTypeInstance*) (
_glib__pspec))->g_class))->g_type)))), (g_type_name (((
(((GTypeClass*) (((GTypeInstance*) (_glib__object))->g_class
))->g_type)))))); } while (0)
;
116 break;
117 }
118}
119
120static void
121set_status_text (GSWatcher *watcher,
122 const char *text)
123{
124 g_free (watcher->priv->status_message);
125
126 watcher->priv->status_message = g_strdup (text);
127 g_object_notify (G_OBJECT (watcher)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((watcher)), (((GType) ((20) << (2))))))))
, "status-message");
128}
129
130static void
131gs_watcher_set_property (GObject *object,
132 guint prop_id,
133 const GValue *value,
134 GParamSpec *pspec)
135{
136 GSWatcher *self;
137
138 self = GS_WATCHER (object)((((GSWatcher*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((gs_watcher_get_type ()))))))
;
139
140 switch (prop_id)
141 {
142 case PROP_STATUS_MESSAGE:
143 set_status_text (self, g_value_get_string (value));
144 break;
145 default:
146 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec)do { GObject *_glib__object = (GObject*) ((object)); GParamSpec
*_glib__pspec = (GParamSpec*) ((pspec)); guint _glib__property_id
= ((prop_id)); g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'"
, "gs-watcher-x11.c", 146, ("property"), _glib__property_id, _glib__pspec
->name, g_type_name ((((((GTypeClass*) (((GTypeInstance*) (
_glib__pspec))->g_class))->g_type)))), (g_type_name (((
(((GTypeClass*) (((GTypeInstance*) (_glib__object))->g_class
))->g_type)))))); } while (0)
;
147 break;
148 }
149}
150
151static void
152gs_watcher_class_init (GSWatcherClass *klass)
153{
154 GObjectClass *object_class = G_OBJECT_CLASS (klass)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((klass)), (((GType) ((20) << (2))))))))
;
155
156 object_class->finalize = gs_watcher_finalize;
157 object_class->get_property = gs_watcher_get_property;
158 object_class->set_property = gs_watcher_set_property;
159
160 g_object_class_install_property (object_class,
161 PROP_STATUS_MESSAGE,
162 g_param_spec_string ("status-message",
163 NULL((void*)0),
164 NULL((void*)0),
165 NULL((void*)0),
166 G_PARAM_READWRITE));
167
168 signals [IDLE_CHANGED] =
169 g_signal_new ("idle-changed",
170 G_TYPE_FROM_CLASS (object_class)(((GTypeClass*) (object_class))->g_type),
171 G_SIGNAL_RUN_LAST,
172 G_STRUCT_OFFSET (GSWatcherClass, idle_changed)((glong) __builtin_offsetof(GSWatcherClass, idle_changed)),
173 NULL((void*)0),
174 NULL((void*)0),
175 gs_marshal_BOOLEAN__BOOLEAN,
176 G_TYPE_BOOLEAN((GType) ((5) << (2))),
177 1, G_TYPE_BOOLEAN((GType) ((5) << (2))));
178 signals [IDLE_NOTICE_CHANGED] =
179 g_signal_new ("idle-notice-changed",
180 G_TYPE_FROM_CLASS (object_class)(((GTypeClass*) (object_class))->g_type),
181 G_SIGNAL_RUN_LAST,
182 G_STRUCT_OFFSET (GSWatcherClass, idle_notice_changed)((glong) __builtin_offsetof(GSWatcherClass, idle_notice_changed
))
,
183 NULL((void*)0),
184 NULL((void*)0),
185 gs_marshal_BOOLEAN__BOOLEAN,
186 G_TYPE_BOOLEAN((GType) ((5) << (2))),
187 1, G_TYPE_BOOLEAN((GType) ((5) << (2))));
188}
189
190static gboolean
191_gs_watcher_set_session_idle_notice (GSWatcher *watcher,
192 gboolean in_effect)
193{
194 gboolean res;
195
196 res = FALSE(0);
197
198 if (in_effect != watcher->priv->idle_notice)
199 {
200
201 g_signal_emit (watcher, signals [IDLE_NOTICE_CHANGED], 0, in_effect, &res);
202 if (res)
203 {
204 gs_debug ("Changing idle notice state: %d", in_effect)gs_debug_real (__func__, "gs-watcher-x11.c", 204, "Changing idle notice state: %d"
, in_effect)
;
205
206 watcher->priv->idle_notice = (in_effect != FALSE(0));
207 }
208 else
209 {
210 gs_debug ("Idle notice signal not handled: %d", in_effect)gs_debug_real (__func__, "gs-watcher-x11.c", 210, "Idle notice signal not handled: %d"
, in_effect)
;
211 }
212 }
213
214 return res;
215}
216
217static gboolean
218_gs_watcher_set_session_idle (GSWatcher *watcher,
219 gboolean is_idle)
220{
221 gboolean res;
222
223 res = FALSE(0);
224
225 if (is_idle != watcher->priv->idle)
226 {
227
228 g_signal_emit (watcher, signals [IDLE_CHANGED], 0, is_idle, &res);
229 if (res)
230 {
231 gs_debug ("Changing idle state: %d", is_idle)gs_debug_real (__func__, "gs-watcher-x11.c", 231, "Changing idle state: %d"
, is_idle)
;
232
233 watcher->priv->idle = (is_idle != FALSE(0));
234 }
235 else
236 {
237 gs_debug ("Idle changed signal not handled: %d", is_idle)gs_debug_real (__func__, "gs-watcher-x11.c", 237, "Idle changed signal not handled: %d"
, is_idle)
;
238 }
239 }
240
241 return res;
242}
243
244gboolean
245gs_watcher_get_active (GSWatcher *watcher)
246{
247 gboolean active;
248
249 g_return_val_if_fail (GS_IS_WATCHER (watcher), FALSE)do{ (void)0; }while (0);
250
251 active = watcher->priv->active;
252
253 return active;
254}
255
256static void
257_gs_watcher_reset_state (GSWatcher *watcher)
258{
259 watcher->priv->idle = FALSE(0);
260 watcher->priv->idle_notice = FALSE(0);
261}
262
263static gboolean
264_gs_watcher_set_active_internal (GSWatcher *watcher,
265 gboolean active)
266{
267 if (active != watcher->priv->active)
268 {
269 /* reset state */
270 _gs_watcher_reset_state (watcher);
271
272 watcher->priv->active = (active != FALSE(0));
273 }
274
275 return TRUE(!(0));
276}
277
278gboolean
279gs_watcher_set_active (GSWatcher *watcher,
280 gboolean active)
281{
282 g_return_val_if_fail (GS_IS_WATCHER (watcher), FALSE)do{ (void)0; }while (0);
283
284 gs_debug ("turning watcher: %s", active ? "ON" : "OFF")gs_debug_real (__func__, "gs-watcher-x11.c", 284, "turning watcher: %s"
, active ? "ON" : "OFF")
;
285
286 if (watcher->priv->active == active)
287 {
288 gs_debug ("Idle detection is already %s",gs_debug_real (__func__, "gs-watcher-x11.c", 289, "Idle detection is already %s"
, active ? "active" : "inactive")
289 active ? "active" : "inactive")gs_debug_real (__func__, "gs-watcher-x11.c", 289, "Idle detection is already %s"
, active ? "active" : "inactive")
;
290 return FALSE(0);
291 }
292
293 if (! watcher->priv->enabled)
294 {
295 gs_debug ("Idle detection is disabled, cannot activate")gs_debug_real (__func__, "gs-watcher-x11.c", 295, "Idle detection is disabled, cannot activate"
)
;
296 return FALSE(0);
297 }
298
299 return _gs_watcher_set_active_internal (watcher, active);
300}
301
302gboolean
303gs_watcher_set_enabled (GSWatcher *watcher,
304 gboolean enabled)
305{
306 g_return_val_if_fail (GS_IS_WATCHER (watcher), FALSE)do{ (void)0; }while (0);
307
308 if (watcher->priv->enabled != enabled)
309 {
310 gboolean is_active = gs_watcher_get_active (watcher);
311
312 watcher->priv->enabled = (enabled != FALSE(0));
313
314 /* if we are disabling the watcher and we are
315 active shut it down */
316 if (! enabled && is_active)
317 {
318 _gs_watcher_set_active_internal (watcher, FALSE(0));
319 }
320 }
321
322 return TRUE(!(0));
323}
324
325gboolean
326gs_watcher_get_enabled (GSWatcher *watcher)
327{
328 gboolean enabled;
329
330 g_return_val_if_fail (GS_IS_WATCHER (watcher), FALSE)do{ (void)0; }while (0);
331
332 enabled = watcher->priv->enabled;
333
334 return enabled;
335}
336
337static gboolean
338on_idle_timeout (GSWatcher *watcher)
339{
340 gboolean res;
341
342 res = _gs_watcher_set_session_idle (watcher, TRUE(!(0)));
343
344 _gs_watcher_set_session_idle_notice (watcher, FALSE(0));
345
346 /* try again if we failed i guess */
347 return !res;
348}
349
350static void
351set_status (GSWatcher *watcher,
352 guint status)
353{
354 gboolean is_idle;
355
356 if (! watcher->priv->active)
357 {
358 gs_debug ("GSWatcher: not active, ignoring status changes")gs_debug_real (__func__, "gs-watcher-x11.c", 358, "GSWatcher: not active, ignoring status changes"
)
;
359 return;
360 }
361
362 is_idle = (status == 3);
363
364 if (!is_idle && !watcher->priv->idle_notice)
365 {
366 /* no change in idleness */
367 return;
368 }
369
370 if (is_idle)
371 {
372 _gs_watcher_set_session_idle_notice (watcher, is_idle);
373 /* queue an activation */
374 if (watcher->priv->idle_id > 0)
375 {
376 g_source_remove (watcher->priv->idle_id);
377 }
378 watcher->priv->idle_id = g_timeout_add (watcher->priv->delta_notice_timeout,
379 (GSourceFunc)on_idle_timeout,
380 watcher);
381 }
382 else
383 {
384 /* cancel notice too */
385 if (watcher->priv->idle_id > 0)
386 {
387 g_source_remove (watcher->priv->idle_id);
388 watcher->priv->idle_id = 0;
389 }
390 _gs_watcher_set_session_idle (watcher, FALSE(0));
391 _gs_watcher_set_session_idle_notice (watcher, FALSE(0));
392 }
393}
394
395static void
396on_presence_status_changed (DBusGProxy *presence_proxy,
397 guint status,
398 GSWatcher *watcher)
399{
400 set_status (watcher, status);
401}
402
403static void
404on_presence_status_text_changed (DBusGProxy *presence_proxy,
405 const char *status_text,
406 GSWatcher *watcher)
407{
408 set_status_text (watcher, status_text);
409}
410
411static gboolean
412connect_presence_watcher (GSWatcher *watcher)
413{
414 DBusGConnection *bus;
415 GError *error;
416 gboolean ret;
417
418 ret = FALSE(0);
419
420 error = NULL((void*)0);
421 bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
422 if (bus == NULL((void*)0))
423 {
424 g_warning ("Unable to get session bus: %s", error->message);
425 g_error_free (error);
426 goto done;
427 }
428
429 error = NULL((void*)0);
430 watcher->priv->presence_proxy = dbus_g_proxy_new_for_name_owner (bus,
431 "org.gnome.SessionManager",
432 "/org/gnome/SessionManager/Presence",
433 "org.gnome.SessionManager.Presence",
434 &error);
435 if (watcher->priv->presence_proxy != NULL((void*)0))
436 {
437 DBusGProxy *proxy;
438
439 dbus_g_proxy_add_signal (watcher->priv->presence_proxy,
440 "StatusChanged",
441 G_TYPE_UINT((GType) ((7) << (2))),
442 G_TYPE_INVALID((GType) ((0) << (2))));
443 dbus_g_proxy_connect_signal (watcher->priv->presence_proxy,
444 "StatusChanged",
445 G_CALLBACK (on_presence_status_changed)((GCallback) (on_presence_status_changed)),
446 watcher,
447 NULL((void*)0));
448 dbus_g_proxy_add_signal (watcher->priv->presence_proxy,
449 "StatusTextChanged",
450 G_TYPE_STRING((GType) ((16) << (2))),
451 G_TYPE_INVALID((GType) ((0) << (2))));
452 dbus_g_proxy_connect_signal (watcher->priv->presence_proxy,
453 "StatusTextChanged",
454 G_CALLBACK (on_presence_status_text_changed)((GCallback) (on_presence_status_text_changed)),
455 watcher,
456 NULL((void*)0));
457
458 proxy = dbus_g_proxy_new_from_proxy (watcher->priv->presence_proxy,
459 "org.freedesktop.DBus.Properties",
460 "/org/gnome/SessionManager/Presence");
461 if (proxy != NULL((void*)0))
462 {
463 guint status;
464 const char *status_text;
465 GValue value = { 0, };
466
467 status = 0;
Value stored to 'status' is never read
468 status_text = NULL((void*)0);
469
470 error = NULL((void*)0);
471 dbus_g_proxy_call (proxy,
472 "Get",
473 &error,
474 G_TYPE_STRING((GType) ((16) << (2))), "org.gnome.SessionManager.Presence",
475 G_TYPE_STRING((GType) ((16) << (2))), "status",
476 G_TYPE_INVALID((GType) ((0) << (2))),
477 G_TYPE_VALUE(g_value_get_type ()), &value,
478 G_TYPE_INVALID((GType) ((0) << (2))));
479
480 if (error != NULL((void*)0))
481 {
482 g_warning ("Couldn't get presence status: %s", error->message);
483 g_error_free (error);
484 goto done;
485 }
486 else
487 {
488 status = g_value_get_uint (&value);
489 }
490
491 g_value_unset (&value);
492
493 error = NULL((void*)0);
494 dbus_g_proxy_call (proxy,
495 "Get",
496 &error,
497 G_TYPE_STRING((GType) ((16) << (2))), "org.gnome.SessionManager.Presence",
498 G_TYPE_STRING((GType) ((16) << (2))), "status-text",
499 G_TYPE_INVALID((GType) ((0) << (2))),
500 G_TYPE_VALUE(g_value_get_type ()), &value,
501 G_TYPE_INVALID((GType) ((0) << (2))));
502
503 if (error != NULL((void*)0))
504 {
505 g_warning ("Couldn't get presence status text: %s", error->message);
506 g_error_free (error);
507 }
508 else
509 {
510 status_text = g_value_get_string (&value);
511 }
512
513 set_status (watcher, status);
514 set_status_text (watcher, status_text);
515 }
516 }
517 else
518 {
519 g_warning ("Failed to get session presence proxy: %s", error->message);
520 g_error_free (error);
521 goto done;
522 }
523
524 ret = TRUE(!(0));
525
526done:
527 return ret;
528}
529
530static void
531gs_watcher_init (GSWatcher *watcher)
532{
533 watcher->priv = gs_watcher_get_instance_private (watcher);
534
535 watcher->priv->enabled = TRUE(!(0));
536 watcher->priv->active = FALSE(0);
537
538 connect_presence_watcher (watcher);
539
540 /* time before idle signal to send notice signal */
541 watcher->priv->delta_notice_timeout = 10000;
542
543 add_watchdog_timer (watcher, 600000);
544}
545
546static void
547gs_watcher_finalize (GObject *object)
548{
549 GSWatcher *watcher;
550
551 g_return_if_fail (object != NULL)do{ (void)0; }while (0);
552 g_return_if_fail (GS_IS_WATCHER (object))do{ (void)0; }while (0);
553
554 watcher = GS_WATCHER (object)((((GSWatcher*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((gs_watcher_get_type ()))))))
;
555
556 g_return_if_fail (watcher->priv != NULL)do{ (void)0; }while (0);
557
558 remove_watchdog_timer (watcher);
559
560 if (watcher->priv->idle_id > 0)
561 {
562 g_source_remove (watcher->priv->idle_id);
563 watcher->priv->idle_id = 0;
564 }
565
566 watcher->priv->active = FALSE(0);
567
568 if (watcher->priv->presence_proxy != NULL((void*)0))
569 {
570 g_object_unref (watcher->priv->presence_proxy);
571 }
572
573 g_free (watcher->priv->status_message);
574
575 G_OBJECT_CLASS (gs_watcher_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((gs_watcher_parent_class)), (((GType) ((20) << (2))
))))))
->finalize (object);
576}
577
578/* Figuring out what the appropriate XSetScreenSaver() parameters are
579 (one wouldn't expect this to be rocket science.)
580*/
581static void
582disable_builtin_screensaver (GSWatcher *watcher,
583 gboolean unblank_screen)
584{
585 int current_server_timeout, current_server_interval;
586 int current_prefer_blank, current_allow_exp;
587 int desired_server_timeout, desired_server_interval;
588 int desired_prefer_blank, desired_allow_exp;
589
590 XGetScreenSaver (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ())(gdk_x11_display_get_xdisplay (gdk_display_get_default ())),
591 &current_server_timeout,
592 &current_server_interval,
593 &current_prefer_blank,
594 &current_allow_exp);
595
596 desired_server_timeout = current_server_timeout;
597 desired_server_interval = current_server_interval;
598 desired_prefer_blank = current_prefer_blank;
599 desired_allow_exp = current_allow_exp;
600
601 desired_server_interval = 0;
602
603 /* I suspect (but am not sure) that DontAllowExposures might have
604 something to do with powering off the monitor as well, at least
605 on some systems that don't support XDPMS? Who know... */
606 desired_allow_exp = AllowExposures1;
607
608 /* When we're not using an extension, set the server-side timeout to 0,
609 so that the server never gets involved with screen blanking, and we
610 do it all ourselves. (However, when we *are* using an extension,
611 we tell the server when to notify us, and rather than blanking the
612 screen, the server will send us an X event telling us to blank.)
613 */
614 desired_server_timeout = 0;
615
616 if (desired_server_timeout != current_server_timeout
617 || desired_server_interval != current_server_interval
618 || desired_prefer_blank != current_prefer_blank
619 || desired_allow_exp != current_allow_exp)
620 {
621
622 gs_debug ("disabling server builtin screensaver:"gs_debug_real (__func__, "gs-watcher-x11.c", 627, "disabling server builtin screensaver:"
" (xset s %d %d; xset s %s; xset s %s)", desired_server_timeout
, desired_server_interval, (desired_prefer_blank ? "blank" : "noblank"
), (desired_allow_exp ? "expose" : "noexpose"))
623 " (xset s %d %d; xset s %s; xset s %s)",gs_debug_real (__func__, "gs-watcher-x11.c", 627, "disabling server builtin screensaver:"
" (xset s %d %d; xset s %s; xset s %s)", desired_server_timeout
, desired_server_interval, (desired_prefer_blank ? "blank" : "noblank"
), (desired_allow_exp ? "expose" : "noexpose"))
624 desired_server_timeout,gs_debug_real (__func__, "gs-watcher-x11.c", 627, "disabling server builtin screensaver:"
" (xset s %d %d; xset s %s; xset s %s)", desired_server_timeout
, desired_server_interval, (desired_prefer_blank ? "blank" : "noblank"
), (desired_allow_exp ? "expose" : "noexpose"))
625 desired_server_interval,gs_debug_real (__func__, "gs-watcher-x11.c", 627, "disabling server builtin screensaver:"
" (xset s %d %d; xset s %s; xset s %s)", desired_server_timeout
, desired_server_interval, (desired_prefer_blank ? "blank" : "noblank"
), (desired_allow_exp ? "expose" : "noexpose"))
626 (desired_prefer_blank ? "blank" : "noblank"),gs_debug_real (__func__, "gs-watcher-x11.c", 627, "disabling server builtin screensaver:"
" (xset s %d %d; xset s %s; xset s %s)", desired_server_timeout
, desired_server_interval, (desired_prefer_blank ? "blank" : "noblank"
), (desired_allow_exp ? "expose" : "noexpose"))
627 (desired_allow_exp ? "expose" : "noexpose"))gs_debug_real (__func__, "gs-watcher-x11.c", 627, "disabling server builtin screensaver:"
" (xset s %d %d; xset s %s; xset s %s)", desired_server_timeout
, desired_server_interval, (desired_prefer_blank ? "blank" : "noblank"
), (desired_allow_exp ? "expose" : "noexpose"))
;
628
629 XSetScreenSaver (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ())(gdk_x11_display_get_xdisplay (gdk_display_get_default ())),
630 desired_server_timeout,
631 desired_server_interval,
632 desired_prefer_blank,
633 desired_allow_exp);
634
635 XSync (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ())(gdk_x11_display_get_xdisplay (gdk_display_get_default ())), FALSE(0));
636 }
637
638 if (unblank_screen)
639 {
640 /* Turn off the server builtin saver if it is now running. */
641 XForceScreenSaver (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ())(gdk_x11_display_get_xdisplay (gdk_display_get_default ())), ScreenSaverReset0);
642 }
643}
644
645/* This timer goes off every few minutes, whether the user is idle or not,
646 to try and clean up anything that has gone wrong.
647
648 It calls disable_builtin_screensaver() so that if xset has been used,
649 or some other program (like xlock) has messed with the XSetScreenSaver()
650 settings, they will be set back to sensible values (if a server extension
651 is in use, messing with xlock can cause the screensaver to never get a wakeup
652 event, and could cause monitor power-saving to occur, and all manner of
653 heinousness.)
654
655 */
656
657static gboolean
658watchdog_timer (GSWatcher *watcher)
659{
660
661 disable_builtin_screensaver (watcher, FALSE(0));
662
663 return TRUE(!(0));
664}
665
666GSWatcher *
667gs_watcher_new (void)
668{
669 GSWatcher *watcher;
670
671 watcher = g_object_new (GS_TYPE_WATCHER(gs_watcher_get_type ()),
672 NULL((void*)0));
673
674 return GS_WATCHER (watcher)((((GSWatcher*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((watcher)), ((gs_watcher_get_type ()))))))
;
675}
diff --git a/2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-06c118.html b/2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-06c118.html new file mode 100644 index 0000000..e55a9dd --- /dev/null +++ b/2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-06c118.html @@ -0,0 +1,1283 @@ + + + +gste-popsquares.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:avers/gste-popsquares.c
Warning:line 232, column 3
Value stored to 'wanted' is never read
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name gste-popsquares.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/savers -resource-dir /usr/lib64/clang/14.0.5 -D HAVE_CONFIG_H -I . -I .. -I . -I . -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -D LIBEXECDIR="/usr/local/libexec" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -internal-isystem /usr/lib64/clang/14.0.5/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/12/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdebug-compilation-dir=/rootdir/savers -ferror-limit 19 -fgnuc-version=4.2.1 -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2022-11-11-203102-6531-1 -x c gste-popsquares.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/* -*- Mode: C; indent-tabs-mode: nil; c-basic-offset: 8; tab-width: 8 -*-
2 *
3 * Copyright (C) 2005 William Jon McCann <mccann@jhu.edu>
4 * Copyright (C) 2012-2021 MATE Developers
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; either version 2 of the
9 * License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
19 * 02110-1301, USA.
20 *
21 */
22
23#include "config.h"
24
25#include <stdio.h>
26#include <stdlib.h>
27#include <unistd.h>
28#include <string.h>
29
30#include <glib.h>
31#include <gtk/gtk.h>
32
33#include "gs-theme-engine.h"
34#include "gste-popsquares.h"
35
36static void gste_popsquares_finalize (GObject *object);
37static void draw_frame (GSTEPopsquares *pop,
38 cairo_t *cr);
39
40typedef struct _square
41{
42 int x, y, w, h;
43 int color;
44} square;
45
46struct GSTEPopsquaresPrivate
47{
48 guint timeout_id;
49
50 int ncolors;
51 int subdivision;
52
53 GdkRGBA *colors;
54 square *squares;
55};
56
57static GObjectClass *parent_class = NULL((void*)0);
58
59G_DEFINE_TYPE_WITH_PRIVATE (GSTEPopsquares, gste_popsquares, GS_TYPE_THEME_ENGINE)static void gste_popsquares_init (GSTEPopsquares *self); static
void gste_popsquares_class_init (GSTEPopsquaresClass *klass)
; static GType gste_popsquares_get_type_once (void); static gpointer
gste_popsquares_parent_class = ((void*)0); static gint GSTEPopsquares_private_offset
; static void gste_popsquares_class_intern_init (gpointer klass
) { gste_popsquares_parent_class = g_type_class_peek_parent (
klass); if (GSTEPopsquares_private_offset != 0) g_type_class_adjust_private_offset
(klass, &GSTEPopsquares_private_offset); gste_popsquares_class_init
((GSTEPopsquaresClass*) klass); } __attribute__ ((__unused__
)) static inline gpointer gste_popsquares_get_instance_private
(GSTEPopsquares *self) { return (((gpointer) ((guint8*) (self
) + (glong) (GSTEPopsquares_private_offset)))); } GType gste_popsquares_get_type
(void) { static gsize static_g_define_type_id = 0; if ((__extension__
({ _Static_assert (sizeof *(&static_g_define_type_id) ==
sizeof (gpointer), "Expression evaluates to false"); (void) (
0 ? (gpointer) *(&static_g_define_type_id) : ((void*)0));
(!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
(*(&static_g_define_type_id)) gapg_temp_newval; __typeof__
((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id
); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5)
; gapg_temp_newval; })) && g_once_init_enter (&static_g_define_type_id
)); }))) { GType g_define_type_id = gste_popsquares_get_type_once
(); (__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); 0 ?
(void) (*(&static_g_define_type_id) = (g_define_type_id)
) : (void) 0; g_once_init_leave ((&static_g_define_type_id
), (gsize) (g_define_type_id)); })); } return static_g_define_type_id
; } __attribute__ ((__noinline__)) static GType gste_popsquares_get_type_once
(void) { GType g_define_type_id = g_type_register_static_simple
((gs_theme_engine_get_type ()), g_intern_static_string ("GSTEPopsquares"
), sizeof (GSTEPopsquaresClass), (GClassInitFunc)(void (*)(void
)) gste_popsquares_class_intern_init, sizeof (GSTEPopsquares)
, (GInstanceInitFunc)(void (*)(void)) gste_popsquares_init, (
GTypeFlags) 0); { {{ GSTEPopsquares_private_offset = g_type_add_instance_private
(g_define_type_id, sizeof (GSTEPopsquaresPrivate)); };} } return
g_define_type_id; }
60
61static void
62hsv_to_rgb (int h,
63 double s,
64 double v,
65 double *r,
66 double *g,
67 double *b)
68{
69 double H, S, V, R, G, B;
70 double p1, p2, p3;
71 double f;
72 int i;
73
74 if (s < 0)
75 {
76 s = 0;
77 }
78 if (v < 0)
79 {
80 v = 0;
81 }
82 if (s > 1)
83 {
84 s = 1;
85 }
86 if (v > 1)
87 {
88 v = 1;
89 }
90
91 S = s;
92 V = v;
93 H = (h % 360) / 60.0;
94 i = H;
95 f = H - i;
96 p1 = V * (1 - S);
97 p2 = V * (1 - (S * f));
98 p3 = V * (1 - (S * (1 - f)));
99
100 if (i == 0)
101 {
102 R = V;
103 G = p3;
104 B = p1;
105 }
106 else if (i == 1)
107 {
108 R = p2;
109 G = V;
110 B = p1;
111 }
112 else if (i == 2)
113 {
114 R = p1;
115 G = V;
116 B = p3;
117 }
118 else if (i == 3)
119 {
120 R = p1;
121 G = p2;
122 B = V;
123 }
124 else if (i == 4)
125 {
126 R = p3;
127 G = p1;
128 B = V;
129 }
130 else
131 {
132 R = V;
133 G = p1;
134 B = p2;
135 }
136
137 *r = R;
138 *g = G;
139 *b = B;
140}
141
142static void
143rgb_to_hsv (double r,
144 double g,
145 double b,
146 int *h,
147 double *s,
148 double *v)
149{
150 double R, G, B, H, S, V;
151 double cmax, cmin;
152 double cmm;
153 int imax;
154
155 R = r;
156 G = g;
157 B = b;
158 cmax = R;
159 cmin = G;
160 imax = 1;
161
162 if (cmax < G)
163 {
164 cmax = G;
165 cmin = R;
166 imax = 2;
167 }
168 if (cmax < B)
169 {
170 cmax = B;
171 imax = 3;
172 }
173 if (cmin > B)
174 {
175 cmin = B;
176 }
177
178 cmm = cmax - cmin;
179 V = cmax;
180
181 if (cmm == 0)
182 {
183 S = H = 0;
184 }
185 else
186 {
187 S = cmm / cmax;
188 if (imax == 1)
189 {
190 H = (G - B) / cmm;
191 }
192 else if (imax == 2)
193 {
194 H = 2.0 + (B - R) / cmm;
195 }
196 else
197 {
198 /*if (imax == 3)*/
199 H = 4.0 + (R - G) / cmm;
200 }
201
202 if (H < 0)
203 {
204 H += 6.0;
205 }
206 }
207
208 *h = (H * 60.0);
209 *s = S;
210 *v = V;
211}
212
213static void
214make_color_ramp (int h1,
215 double s1,
216 double v1,
217 int h2,
218 double s2,
219 double v2,
220 GdkRGBA *colors,
221 int n_colors,
222 gboolean closed)
223{
224 double dh, ds, dv; /* deltas */
225 int i;
226 int ncolors, wanted;
227 int total_ncolors = n_colors;
228
229 wanted = total_ncolors;
230 if (closed)
231 {
232 wanted = (wanted / 2) + 1;
Value stored to 'wanted' is never read
233 }
234
235 ncolors = total_ncolors;
236
237 memset (colors, 0, n_colors * sizeof (*colors));
238
239 if (closed)
240 {
241 ncolors = (ncolors / 2) + 1;
242 }
243
244 /* Note: unlike other routines in this module, this function assumes that
245 if h1 and h2 are more than 180 degrees apart, then the desired direction
246 is always from h1 to h2 (rather than the shorter path.) make_uniform
247 depends on this.
248 */
249 dh = ((double)h2 - (double)h1) / ncolors;
250 ds = (s2 - s1) / ncolors;
251 dv = (v2 - v1) / ncolors;
252
253 for (i = 0; i < ncolors; i++)
254 {
255 hsv_to_rgb ((int) (h1 + (i * dh)),
256 (s1 + (i * ds)),
257 (v1 + (i * dv)),
258 &colors [i].red,
259 &colors [i].green,
260 &colors [i].blue);
261 colors [i].alpha = 1.0;
262 }
263
264 if (closed)
265 {
266 for (i = ncolors; i < n_colors; i++)
267 {
268 colors [i] = colors [n_colors - i];
269 }
270 }
271
272}
273
274static void
275randomize_square_colors (square *squares,
276 int nsquares,
277 int ncolors)
278{
279 int i;
280 square *s;
281
282 s = squares;
283
284 for (i = 0; i < nsquares; i++)
285 {
286 s[i].color = g_random_int_range (0, ncolors);
287 }
288}
289
290static void
291set_colors (GtkWidget *widget,
292 GdkRGBA *fg,
293 GdkRGBA *bg)
294{
295 GtkStyleContext *style;
296
297 style = gtk_widget_get_style_context (widget);
298
299 gtk_style_context_save (style);
300 gtk_style_context_set_state (style, GTK_STATE_FLAG_SELECTED);
301 gtk_style_context_get_background_color (style,
302 gtk_style_context_get_state (style),
303 bg);
304 if (bg->alpha == 0.0)
305 {
306 gtk_style_context_add_class (style, GTK_STYLE_CLASS_VIEW"view");
307 gtk_style_context_get_background_color (style,
308 gtk_style_context_get_state (style),
309 bg);
310 }
311 gtk_style_context_restore (style);
312
313 fg->red = bg->red * 0.7;
314 fg->green = bg->green * 0.7;
315 fg->blue = bg->blue * 0.7;
316 fg->alpha = bg->alpha;
317}
318
319static void
320gste_popsquares_set_property (GObject *object,
321 guint prop_id,
322 const GValue *value,
323 GParamSpec *pspec)
324{
325 GSTE_POPSQUARES (object)((((GSTEPopsquares*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((gste_popsquares_get_type ()))))))
;
326
327 switch (prop_id)
328 {
329 default:
330 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec)do { GObject *_glib__object = (GObject*) ((object)); GParamSpec
*_glib__pspec = (GParamSpec*) ((pspec)); guint _glib__property_id
= ((prop_id)); g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'"
, "gste-popsquares.c", 330, ("property"), _glib__property_id,
_glib__pspec->name, g_type_name ((((((GTypeClass*) (((GTypeInstance
*) (_glib__pspec))->g_class))->g_type)))), (g_type_name
((((((GTypeClass*) (((GTypeInstance*) (_glib__object))->g_class
))->g_type)))))); } while (0)
;
331 break;
332 }
333}
334
335static void
336gste_popsquares_get_property (GObject *object,
337 guint prop_id,
338 GValue *value,
339 GParamSpec *pspec)
340{
341 GSTE_POPSQUARES (object)((((GSTEPopsquares*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((gste_popsquares_get_type ()))))))
;
342
343 switch (prop_id)
344 {
345 default:
346 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec)do { GObject *_glib__object = (GObject*) ((object)); GParamSpec
*_glib__pspec = (GParamSpec*) ((pspec)); guint _glib__property_id
= ((prop_id)); g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'"
, "gste-popsquares.c", 346, ("property"), _glib__property_id,
_glib__pspec->name, g_type_name ((((((GTypeClass*) (((GTypeInstance
*) (_glib__pspec))->g_class))->g_type)))), (g_type_name
((((((GTypeClass*) (((GTypeInstance*) (_glib__object))->g_class
))->g_type)))))); } while (0)
;
347 break;
348 }
349}
350
351static void
352setup_squares (GSTEPopsquares *pop)
353{
354 int window_width;
355 int window_height;
356 int nsquares;
357 int x, y;
358 int sw, sh, gw, gh;
359 GdkWindow *window;
360
361 window = gs_theme_engine_get_window (GS_THEME_ENGINE (pop)((((GSThemeEngine*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((pop)), ((gs_theme_engine_get_type ()))))))
);
362
363 if (window == NULL((void*)0))
364 {
365 return;
366 }
367
368 gs_theme_engine_get_window_size (GS_THEME_ENGINE (pop)((((GSThemeEngine*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((pop)), ((gs_theme_engine_get_type ()))))))
, &window_width, &window_height);
369
370 sw = window_width / pop->priv->subdivision;
371 sh = window_height / pop->priv->subdivision;
372
373 gw = pop->priv->subdivision;
374 gh = pop->priv->subdivision;
375 nsquares = gw * gh;
376
377 if (pop->priv->squares)
378 {
379 g_free (pop->priv->squares);
380 }
381 pop->priv->squares = g_new0 (square, nsquares)((square *) g_malloc0_n ((nsquares), sizeof (square)));
382
383 for (y = 0; y < gh; y++)
384 {
385 for (x = 0; x < gw; x++)
386 {
387 square *s = (square *) &pop->priv->squares [gw * y + x];
388 s->w = sw;
389 s->h = sh;
390 s->x = x * sw;
391 s->y = y * sh;
392 }
393 }
394}
395
396static void
397setup_colors (GSTEPopsquares *pop)
398{
399 double s1, v1, s2, v2 = 0;
400 int h1, h2 = 0;
401 int nsquares;
402 GdkRGBA fg;
403 GdkRGBA bg;
404 GdkWindow *window;
405
406 window = gs_theme_engine_get_window (GS_THEME_ENGINE (pop)((((GSThemeEngine*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((pop)), ((gs_theme_engine_get_type ()))))))
);
407
408 if (window == NULL((void*)0))
409 {
410 return;
411 }
412
413 set_colors (GTK_WIDGET (pop)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((pop)), ((gtk_widget_get_type ()))))))
, &fg, &bg);
414
415 if (pop->priv->colors)
416 {
417 g_free (pop->priv->colors);
418 }
419 pop->priv->colors = g_new0 (GdkRGBA, pop->priv->ncolors)((GdkRGBA *) g_malloc0_n ((pop->priv->ncolors), sizeof (
GdkRGBA)))
;
420
421 rgb_to_hsv (fg.red, fg.green, fg.blue, &h1, &s1, &v1);
422 rgb_to_hsv (bg.red, bg.green, bg.blue, &h2, &s2, &v2);
423
424 make_color_ramp (h1, s1, v1,
425 h2, s2, v2,
426 pop->priv->colors,
427 pop->priv->ncolors,
428 TRUE(!(0)));
429
430 nsquares = pop->priv->subdivision * pop->priv->subdivision;
431
432 randomize_square_colors (pop->priv->squares, nsquares, pop->priv->ncolors);
433}
434
435static void
436gste_popsquares_real_show (GtkWidget *widget)
437{
438 GSTEPopsquares *pop = GSTE_POPSQUARES (widget)((((GSTEPopsquares*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gste_popsquares_get_type ()))))))
;
439
440 /* start */
441 setup_squares (pop);
442 setup_colors (pop);
443
444 if (GTK_WIDGET_CLASS (parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((parent_class)), ((gtk_widget_get_type ()))))))
->show)
445 {
446 GTK_WIDGET_CLASS (parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((parent_class)), ((gtk_widget_get_type ()))))))
->show (widget);
447 }
448}
449
450static gboolean
451gste_popsquares_real_draw (GtkWidget *widget,
452 cairo_t *cr)
453{
454 if (GTK_WIDGET_CLASS (parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((parent_class)), ((gtk_widget_get_type ()))))))
->draw) {
455 GTK_WIDGET_CLASS (parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((parent_class)), ((gtk_widget_get_type ()))))))
->draw (widget, cr);
456 }
457
458 draw_frame (GSTE_POPSQUARES (widget)((((GSTEPopsquares*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gste_popsquares_get_type ()))))))
, cr);
459
460 return TRUE(!(0));
461}
462
463static gboolean
464gste_popsquares_real_configure (GtkWidget *widget,
465 GdkEventConfigure *event)
466{
467 GSTEPopsquares *pop = GSTE_POPSQUARES (widget)((((GSTEPopsquares*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gste_popsquares_get_type ()))))))
;
468 gboolean handled = FALSE(0);
469
470 /* resize */
471
472 /* just reset everything */
473 setup_squares (pop);
474 setup_colors (pop);
475
476 /* schedule a redraw */
477 gtk_widget_queue_draw (widget);
478
479 if (GTK_WIDGET_CLASS (parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((parent_class)), ((gtk_widget_get_type ()))))))
->configure_event)
480 {
481 handled = GTK_WIDGET_CLASS (parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((parent_class)), ((gtk_widget_get_type ()))))))
->configure_event (widget, event);
482 }
483
484 return handled;
485}
486
487static void
488gste_popsquares_class_init (GSTEPopsquaresClass *klass)
489{
490 GObjectClass *object_class = G_OBJECT_CLASS (klass)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((klass)), (((GType) ((20) << (2))))))))
;
491 GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((klass)), ((gtk_widget_get_type ()))))))
;
492
493 parent_class = g_type_class_peek_parent (klass);
494
495 object_class->finalize = gste_popsquares_finalize;
496 object_class->get_property = gste_popsquares_get_property;
497 object_class->set_property = gste_popsquares_set_property;
498
499 widget_class->show = gste_popsquares_real_show;
500 widget_class->draw = gste_popsquares_real_draw;
501 widget_class->configure_event = gste_popsquares_real_configure;
502}
503
504static void
505draw_frame (GSTEPopsquares *pop,
506 cairo_t *cr)
507{
508 int border = 1;
509 gboolean twitch = FALSE(0);
510 int x, y;
511 int gw, gh;
512 int nsquares;
513 int window_width;
514 int window_height;
515 GdkWindow *window;
516
517 window = gs_theme_engine_get_window (GS_THEME_ENGINE (pop)((((GSThemeEngine*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((pop)), ((gs_theme_engine_get_type ()))))))
);
518
519 if (window == NULL((void*)0))
520 {
521 return;
522 }
523
524 gs_theme_engine_get_window_size (GS_THEME_ENGINE (pop)((((GSThemeEngine*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((pop)), ((gs_theme_engine_get_type ()))))))
,
525 &window_width,
526 &window_height);
527
528 gw = pop->priv->subdivision;
529 gh = pop->priv->subdivision;
530 nsquares = gw * gh;
531
532 for (y = 0; y < gh; y++)
533 {
534 for (x = 0; x < gw; x++)
535 {
536 square *s = (square *) &pop->priv->squares [gw * y + x];
537
538 gdk_cairo_set_source_rgba (cr, &(pop->priv->colors [s->color]));
539 cairo_rectangle (cr, s->x, s->y,
540 border ? s->w - border : s->w,
541 border ? s->h - border : s->h);
542 cairo_fill (cr);
543 s->color++;
544
545 if (s->color == pop->priv->ncolors)
546 {
547 if (twitch && ((g_random_int_range (0, 4)) == 0))
548 {
549 randomize_square_colors (pop->priv->squares, nsquares, pop->priv->ncolors);
550 }
551 else
552 {
553 s->color = g_random_int_range (0, pop->priv->ncolors);
554 }
555 }
556 }
557 }
558}
559
560static gboolean
561draw_iter (GSTEPopsquares *pop)
562{
563 gtk_widget_queue_draw (GTK_WIDGET (pop)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((pop)), ((gtk_widget_get_type ()))))))
);
564 return TRUE(!(0));
565}
566
567static void
568gste_popsquares_init (GSTEPopsquares *pop)
569{
570 int delay;
571
572 pop->priv = gste_popsquares_get_instance_private (pop);
573
574 pop->priv->ncolors = 128;
575 pop->priv->subdivision = 5;
576
577 delay = 25;
578 pop->priv->timeout_id = g_timeout_add (delay, (GSourceFunc)draw_iter, pop);
579}
580
581static void
582gste_popsquares_finalize (GObject *object)
583{
584 GSTEPopsquares *pop;
585
586 g_return_if_fail (object != NULL)do { if ((object != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "object != NULL")
; return; } } while (0)
;
587 g_return_if_fail (GSTE_IS_POPSQUARES (object))do { if (((((__extension__ ({ GTypeInstance *__inst = (GTypeInstance
*) ((object)); GType __t = ((gste_popsquares_get_type ())); gboolean
__r; if (!__inst) __r = (0); else if (__inst->g_class &&
__inst->g_class->g_type == __t) __r = (!(0)); else __r
= g_type_check_instance_is_a (__inst, __t); __r; })))))) { }
else { g_return_if_fail_warning (((gchar*) 0), ((const char*
) (__func__)), "GSTE_IS_POPSQUARES (object)"); return; } } while
(0)
;
588
589 pop = GSTE_POPSQUARES (object)((((GSTEPopsquares*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((gste_popsquares_get_type ()))))))
;
590
591 g_return_if_fail (pop->priv != NULL)do { if ((pop->priv != ((void*)0))) { } else { g_return_if_fail_warning
(((gchar*) 0), ((const char*) (__func__)), "pop->priv != NULL"
); return; } } while (0)
;
592
593 if (pop->priv->timeout_id > 0)
594 {
595 g_source_remove (pop->priv->timeout_id);
596 pop->priv->timeout_id = 0;
597 }
598
599 g_free (pop->priv->squares);
600 g_free (pop->priv->colors);
601
602 G_OBJECT_CLASS (parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((parent_class)), (((GType) ((20) << (2))))))))
->finalize (object);
603}
diff --git a/2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-09b55a.html b/2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-09b55a.html new file mode 100644 index 0000000..93382e0 --- /dev/null +++ b/2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-09b55a.html @@ -0,0 +1,848 @@ + + + +xdg-user-dir-lookup.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:avers/xdg-user-dir-lookup.c
Warning:line 60, column 3
Call to function 'strcpy' is insecure as it does not provide bounding of the memory buffer. Replace unbounded copy functions with analogous functions that support length arguments such as 'strlcpy'. CWE-119
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name xdg-user-dir-lookup.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/savers -resource-dir /usr/lib64/clang/14.0.5 -D HAVE_CONFIG_H -I . -I .. -I . -I . -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -D LIBEXECDIR="/usr/local/libexec" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -internal-isystem /usr/lib64/clang/14.0.5/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/12/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdebug-compilation-dir=/rootdir/savers -ferror-limit 19 -fgnuc-version=4.2.1 -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2022-11-11-203102-6531-1 -x c xdg-user-dir-lookup.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/*
2 This file is not licenced under the GPL like the rest of the code.
3 Its is under the MIT license, to encourage reuse by cut-and-paste.
4
5 Copyright (c) 2007 Red Hat, inc
6 Copyright (C) 2012-2021 MATE Developers
7
8 Permission is hereby granted, free of charge, to any person
9 obtaining a copy of this software and associated documentation files
10 (the "Software"), to deal in the Software without restriction,
11 including without limitation the rights to use, copy, modify, merge,
12 publish, distribute, sublicense, and/or sell copies of the Software,
13 and to permit persons to whom the Software is furnished to do so,
14 subject to the following conditions:
15
16 The above copyright notice and this permission notice shall be
17 included in all copies or substantial portions of the Software.
18
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
23 BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
24 ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
25 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26 SOFTWARE.
27*/
28
29#include <stdio.h>
30#include <stdlib.h>
31#include <string.h>
32
33#include "xdg-user-dir-lookup.h"
34
35char *
36xdg_user_dir_lookup (const char *type)
37{
38 FILE *file;
39 char *home_dir, *config_home, *config_file;
40 char buffer[512];
41 char *user_dir;
42 char *p, *d;
43 int relative;
44
45 home_dir = getenv ("HOME");
46
47 if (home_dir == NULL((void*)0))
48 return strdup ("/tmp");
49
50 config_home = getenv ("XDG_CONFIG_HOME");
51 if (config_home == NULL((void*)0) || config_home[0] == 0)
52 {
53 config_file = malloc (strlen (home_dir) + strlen ("/.config/user-dirs.dirs") + 1);
54 strcpy (config_file, home_dir);
55 strcat (config_file, "/.config/user-dirs.dirs");
56 }
57 else
58 {
59 config_file = malloc (strlen (config_home) + strlen ("/user-dirs.dirs") + 1);
60 strcpy (config_file, config_home);
Call to function 'strcpy' is insecure as it does not provide bounding of the memory buffer. Replace unbounded copy functions with analogous functions that support length arguments such as 'strlcpy'. CWE-119
61 strcat (config_file, "/user-dirs.dirs");
62 }
63
64 file = fopen (config_file, "r");
65 free (config_file);
66 if (file == NULL((void*)0))
67 goto error;
68
69 user_dir = NULL((void*)0);
70 while (fgets (buffer, sizeof (buffer), file))
71 {
72 /* Remove newline at end */
73 size_t len = strlen (buffer);
74 if (len != 0 && buffer[len-1] == '\n')
75 buffer[len-1] = 0;
76
77 p = buffer;
78 while (*p == ' ' || *p == '\t')
79 p++;
80
81 if (strncmp (p, "XDG_", 4) != 0)
82 continue;
83 p += 4;
84 if (strncmp (p, type, strlen (type)) != 0)
85 continue;
86 p += strlen (type);
87 if (strncmp (p, "_DIR", 4) != 0)
88 continue;
89 p += 4;
90
91 while (*p == ' ' || *p == '\t')
92 p++;
93
94 if (*p != '=')
95 continue;
96 p++;
97
98 while (*p == ' ' || *p == '\t')
99 p++;
100
101 if (*p != '"')
102 continue;
103 p++;
104
105 relative = 0;
106 if (strncmp (p, "$HOME/", 6) == 0)
107 {
108 p += 6;
109 relative = 1;
110 }
111 else if (*p != '/')
112 continue;
113
114 if (relative)
115 {
116 user_dir = malloc (strlen (home_dir) + 1 + strlen (p) + 1);
117 strcpy (user_dir, home_dir);
118 strcat (user_dir, "/");
119 }
120 else
121 {
122 user_dir = malloc (strlen (p) + 1);
123 *user_dir = 0;
124 }
125
126 d = user_dir + strlen (user_dir);
127 while (*p && *p != '"')
128 {
129 if ((*p == '\\') && (*(p+1) != 0))
130 p++;
131 *d++ = *p++;
132 }
133 *d = 0;
134 }
135 fclose (file);
136
137 if (user_dir)
138 return user_dir;
139
140error:
141 /* Special case desktop for historical compatibility */
142 if (strcmp (type, "DESKTOP") == 0)
143 {
144 user_dir = malloc (strlen (home_dir) + strlen ("/Desktop") + 1);
145 strcpy (user_dir, home_dir);
146 strcat (user_dir, "/Desktop");
147 return user_dir;
148 }
149 else
150 return strdup (home_dir);
151}
152
153#ifdef STANDALONE
154
155int
156main (int argc, char *argv[])
157{
158 if (argc != 2)
159 {
160 fprintf (stderrstderr, "Usage %s <dir-type>\n", argv[0]);
161 exit (1);
162 }
163
164 printf ("%s\n", xdg_user_dir_lookup (argv[1]));
165 return 0;
166}
167
168#endif
diff --git a/2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-0bc662.html b/2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-0bc662.html new file mode 100644 index 0000000..6098302 --- /dev/null +++ b/2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-0bc662.html @@ -0,0 +1,1236 @@ + + + +mate-screensaver-command.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rc/mate-screensaver-command.c
Warning:line 529, column 3
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name mate-screensaver-command.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/14.0.5 -D HAVE_CONFIG_H -I . -I .. -I . -I . -D MATEMENU_I_KNOW_THIS_IS_UNSTABLE -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/dconf -I /usr/include/mate-menus -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/dconf -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/dconf -I /usr/include/mate-menus -D PREFIX="/usr/local" -D BINDIR="/usr/local/bin" -D LIBDIR="/usr/local/lib" -D LIBEXECDIR="/usr/local/libexec" -D DATADIR="/usr/local/share" -D SYSCONFDIR="/usr/local/etc" -D MATELOCALEDIR="/usr/local/share/locale" -D PKGLIBEXECDIR="/usr/local/libexec/mate-screensaver" -D SAVERDIR="/usr/local/libexec/mate-screensaver" -D THEMESDIR="/usr/local/share/mate-screensaver/themes" -D GTKBUILDERDIR="/usr/local/share/mate-screensaver" -D MATE_SCREENSAVER_GL_HELPER_PATH="/usr/local/libexec/mate-screensaver-gl-helper" -D PAM_SERVICE_NAME="mate-screensaver" -D G_DISABLE_ASSERT -D G_DISABLE_CHECKS -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -internal-isystem /usr/lib64/clang/14.0.5/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/12/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2022-11-11-203102-6531-1 -x c mate-screensaver-command.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
2 *
3 * Copyright (C) 2004-2006 William Jon McCann <mccann@jhu.edu>
4 * Copyright (C) 2012-2021 MATE Developers
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; either version 2 of the
9 * License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
19 * 02110-1301, USA.
20 *
21 * Authors: William Jon McCann <mccann@jhu.edu>
22 *
23 */
24
25#include "config.h"
26
27#include <stdlib.h>
28#include <locale.h>
29#include <glib.h>
30#include <glib/gi18n.h>
31
32#define DBUS_API_SUBJECT_TO_CHANGE
33#include <dbus/dbus.h>
34#include <dbus/dbus-glib.h>
35#include <dbus/dbus-glib-lowlevel.h>
36
37#define GS_SERVICE"org.mate.ScreenSaver" "org.mate.ScreenSaver"
38#define GS_PATH"/org/mate/ScreenSaver" "/org/mate/ScreenSaver"
39#define GS_INTERFACE"org.mate.ScreenSaver" "org.mate.ScreenSaver"
40
41static gboolean do_quit = FALSE(0);
42static gboolean do_lock = FALSE(0);
43static gboolean do_unlock = FALSE(0);
44static gboolean do_cycle = FALSE(0);
45static gboolean do_activate = FALSE(0);
46static gboolean do_deactivate = FALSE(0);
47static gboolean do_version = FALSE(0);
48static gboolean do_poke = FALSE(0);
49static gboolean do_inhibit = FALSE(0);
50
51static gboolean do_query = FALSE(0);
52static gboolean do_time = FALSE(0);
53
54static char *inhibit_reason = NULL((void*)0);
55static char *inhibit_application = NULL((void*)0);
56
57static GOptionEntry entries [] =
58{
59 {
60 "exit", 0, 0, G_OPTION_ARG_NONE, &do_quit,
61 N_("Causes the screensaver to exit gracefully")("Causes the screensaver to exit gracefully"), NULL((void*)0)
62 },
63 {
64 "query", 'q', 0, G_OPTION_ARG_NONE, &do_query,
65 N_("Query the state of the screensaver")("Query the state of the screensaver"), NULL((void*)0)
66 },
67 {
68 "time", 't', 0, G_OPTION_ARG_NONE, &do_time,
69 N_("Query the length of time the screensaver has been active")("Query the length of time the screensaver has been active"), NULL((void*)0)
70 },
71 {
72 "lock", 'l', 0, G_OPTION_ARG_NONE, &do_lock,
73 N_("Tells the running screensaver process to lock the screen immediately")("Tells the running screensaver process to lock the screen immediately"
)
, NULL((void*)0)
74 },
75 {
76 "unlock", 'u', 0, G_OPTION_ARG_NONE, &do_unlock,
77 N_("Tells the running screensaver process to unlock the screen immediately")("Tells the running screensaver process to unlock the screen immediately"
)
, NULL((void*)0)
78 },
79 {
80 "cycle", 'c', 0, G_OPTION_ARG_NONE, &do_cycle,
81 N_("If the screensaver is active then switch to another graphics demo")("If the screensaver is active then switch to another graphics demo"
)
, NULL((void*)0)
82 },
83 {
84 "activate", 'a', 0, G_OPTION_ARG_NONE, &do_activate,
85 N_("Turn the screensaver on (blank the screen)")("Turn the screensaver on (blank the screen)"), NULL((void*)0)
86 },
87 {
88 "deactivate", 'd', 0, G_OPTION_ARG_NONE, &do_deactivate,
89 N_("If the screensaver is active then deactivate it (un-blank the screen)")("If the screensaver is active then deactivate it (un-blank the screen)"
)
, NULL((void*)0)
90 },
91 {
92 "poke", 'p', 0, G_OPTION_ARG_NONE, &do_poke,
93 N_("Poke the running screensaver to simulate user activity")("Poke the running screensaver to simulate user activity"), NULL((void*)0)
94 },
95 {
96 "inhibit", 'i', 0, G_OPTION_ARG_NONE, &do_inhibit,
97 N_("Inhibit the screensaver from activating. Command blocks while inhibit is active.")("Inhibit the screensaver from activating. Command blocks while inhibit is active."
)
, NULL((void*)0)
98 },
99 {
100 "application-name", 'n', 0, G_OPTION_ARG_STRING, &inhibit_application,
101 N_("The calling application that is inhibiting the screensaver")("The calling application that is inhibiting the screensaver"
)
, NULL((void*)0)
102 },
103 {
104 "reason", 'r', 0, G_OPTION_ARG_STRING, &inhibit_reason,
105 N_("The reason for inhibiting the screensaver")("The reason for inhibiting the screensaver"), NULL((void*)0)
106 },
107 {
108 "version", 'V', 0, G_OPTION_ARG_NONE, &do_version,
109 N_("Version of this application")("Version of this application"), NULL((void*)0)
110 },
111 { NULL((void*)0), 0, 0, G_OPTION_ARG_NONE, NULL((void*)0), NULL((void*)0), NULL((void*)0) }
112};
113
114static GMainLoop *loop = NULL((void*)0);
115
116static gboolean
117screensaver_is_running (DBusConnection *connection)
118{
119 DBusError error;
120 gboolean exists;
121
122 g_return_val_if_fail (connection != NULL, FALSE)do{ (void)0; }while (0);
123
124 dbus_error_init (&error);
125 exists = dbus_bus_name_has_owner (connection, GS_SERVICE"org.mate.ScreenSaver", &error);
126 if (dbus_error_is_set (&error))
127 dbus_error_free (&error);
128
129 return exists;
130}
131
132static DBusMessage *
133screensaver_send_message_inhibit (DBusConnection *connection,
134 const char *application,
135 const char *reason)
136{
137 DBusMessage *message;
138 DBusMessage *reply;
139 DBusError error;
140 DBusMessageIter iter;
141
142 g_return_val_if_fail (connection != NULL, NULL)do{ (void)0; }while (0);
143
144 dbus_error_init (&error);
145
146 message = dbus_message_new_method_call (GS_SERVICE"org.mate.ScreenSaver", GS_PATH"/org/mate/ScreenSaver", GS_INTERFACE"org.mate.ScreenSaver", "Inhibit");
147 if (message == NULL((void*)0))
148 {
149 g_warning ("Couldn't allocate the dbus message");
150 return NULL((void*)0);
151 }
152
153 dbus_message_iter_init_append (message, &iter);
154 dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING((int) 's'), &application);
155 dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING((int) 's'), &reason);
156
157 reply = dbus_connection_send_with_reply_and_block (connection,
158 message,
159 -1, &error);
160 if (dbus_error_is_set (&error))
161 {
162 g_warning ("%s raised:\n %s\n\n", error.name, error.message);
163 reply = NULL((void*)0);
164 }
165
166 dbus_connection_flush (connection);
167
168 dbus_message_unref (message);
169 dbus_error_free (&error);
170
171 return reply;
172}
173
174static DBusMessage *
175screensaver_send_message_bool (DBusConnection *connection,
176 const char *name,
177 gboolean value)
178{
179 DBusMessage *message;
180 DBusMessage *reply;
181 DBusError error;
182 DBusMessageIter iter;
183
184 g_return_val_if_fail (connection != NULL, NULL)do{ (void)0; }while (0);
185 g_return_val_if_fail (name != NULL, NULL)do{ (void)0; }while (0);
186
187 dbus_error_init (&error);
188
189 message = dbus_message_new_method_call (GS_SERVICE"org.mate.ScreenSaver", GS_PATH"/org/mate/ScreenSaver", GS_INTERFACE"org.mate.ScreenSaver", name);
190 if (message == NULL((void*)0))
191 {
192 g_warning ("Couldn't allocate the dbus message");
193 return NULL((void*)0);
194 }
195
196 dbus_message_iter_init_append (message, &iter);
197 dbus_message_iter_append_basic (&iter, DBUS_TYPE_BOOLEAN((int) 'b'), &value);
198
199 reply = dbus_connection_send_with_reply_and_block (connection,
200 message,
201 -1, &error);
202 if (dbus_error_is_set (&error))
203 {
204 g_warning ("%s raised:\n %s\n\n", error.name, error.message);
205 reply = NULL((void*)0);
206 }
207
208 dbus_connection_flush (connection);
209
210 dbus_message_unref (message);
211 dbus_error_free (&error);
212
213 return reply;
214}
215
216static DBusMessage *
217screensaver_send_message_void (DBusConnection *connection,
218 const char *name,
219 gboolean expect_reply)
220{
221 DBusMessage *message;
222 DBusMessage *reply;
223 DBusError error;
224
225 g_return_val_if_fail (connection != NULL, NULL)do{ (void)0; }while (0);
226 g_return_val_if_fail (name != NULL, NULL)do{ (void)0; }while (0);
227
228 dbus_error_init (&error);
229
230 message = dbus_message_new_method_call (GS_SERVICE"org.mate.ScreenSaver", GS_PATH"/org/mate/ScreenSaver", GS_INTERFACE"org.mate.ScreenSaver", name);
231 if (message == NULL((void*)0))
232 {
233 g_warning ("Couldn't allocate the dbus message");
234 return NULL((void*)0);
235 }
236
237 if (! expect_reply)
238 {
239 if (!dbus_connection_send (connection, message, NULL((void*)0)))
240 g_warning ("could not send message");
241 reply = NULL((void*)0);
242 }
243 else
244 {
245 reply = dbus_connection_send_with_reply_and_block (connection,
246 message,
247 -1, &error);
248 if (dbus_error_is_set (&error))
249 {
250 g_warning ("%s raised:\n %s\n\n", error.name, error.message);
251 reply = NULL((void*)0);
252 }
253 }
254 dbus_connection_flush (connection);
255
256 dbus_message_unref (message);
257 dbus_error_free (&error);
258
259 return reply;
260}
261
262static char **
263get_string_from_iter (DBusMessageIter *iter,
264 int *num_elements)
265{
266 int count;
267 char **buffer;
268
269 if (num_elements != NULL((void*)0))
270 {
271 *num_elements = 0;
272 }
273
274 count = 0;
275 buffer = (char **)malloc (sizeof (char *) * 8);
276
277 if (buffer == NULL((void*)0))
278 {
279 goto oom;
280 }
281
282 buffer[0] = NULL((void*)0);
283 while (dbus_message_iter_get_arg_type (iter) == DBUS_TYPE_STRING((int) 's'))
284 {
285 const char *value;
286 char *str;
287
288 if ((count % 8) == 0 && count != 0)
289 {
290 buffer = realloc (buffer, sizeof (char *) * (count + 8));
291 if (buffer == NULL((void*)0))
292 {
293 goto oom;
294 }
295 }
296
297 dbus_message_iter_get_basic (iter, &value);
298 str = strdup (value);
299 if (str == NULL((void*)0))
300 {
301 goto oom;
302 }
303
304 buffer[count] = str;
305
306 dbus_message_iter_next (iter);
307 count++;
308 }
309
310 if ((count % 8) == 0)
311 {
312 buffer = realloc (buffer, sizeof (char *) * (count + 1));
313 if (buffer == NULL((void*)0))
314 {
315 goto oom;
316 }
317 }
318
319 buffer[count] = NULL((void*)0);
320 if (num_elements != NULL((void*)0))
321 {
322 *num_elements = count;
323 }
324 return buffer;
325
326oom:
327 g_debug ("%s %d : error allocating memory\n", __FILE__"mate-screensaver-command.c", __LINE__327);
328 return NULL((void*)0);
329
330}
331
332static gboolean
333do_command (gpointer data)
334{
335 DBusConnection *connection = data;
336 DBusMessage *reply;
337
338 if (do_quit)
339 {
340 reply = screensaver_send_message_void (connection, "Quit", FALSE(0));
341 goto done;
342 }
343
344 if (do_query)
345 {
346 DBusMessageIter iter;
347 DBusMessageIter array;
348 dbus_bool_t v;
349
350 reply = screensaver_send_message_void (connection, "GetActive", TRUE(!(0)));
351 if (! reply)
352 {
353 g_message ("Did not receive a reply from the screensaver.");
354 goto done;
355 }
356
357 dbus_message_iter_init (reply, &iter);
358 dbus_message_iter_get_basic (&iter, &v);
359 g_print (_("The screensaver is %s\n")gettext ("The screensaver is %s\n"), v ? _("active")gettext ("active") : _("inactive")gettext ("inactive"));
360
361 dbus_message_unref (reply);
362
363 reply = screensaver_send_message_void (connection, "GetInhibitors", TRUE(!(0)));
364 if (! reply)
365 {
366 g_message ("Did not receive a reply from screensaver.");
367 goto done;
368 }
369
370 dbus_message_iter_init (reply, &iter);
371 dbus_message_iter_recurse (&iter, &array);
372
373 if (dbus_message_iter_get_arg_type (&array) == DBUS_TYPE_INVALID((int) '\0'))
374 {
375 g_print (_("The screensaver is not inhibited\n")gettext ("The screensaver is not inhibited\n"));
376 }
377 else
378 {
379 char **inhibitors;
380 int i;
381 int num;
382
383 g_print (_("The screensaver is being inhibited by:\n")gettext ("The screensaver is being inhibited by:\n"));
384 inhibitors = get_string_from_iter (&array, &num);
385 for (i = 0; i < num; i++)
386 {
387 g_print ("\t%s\n", inhibitors[i]);
388 }
389 g_strfreev (inhibitors);
390 }
391
392 dbus_message_unref (reply);
393 }
394
395 if (do_time)
396 {
397 DBusMessageIter iter;
398 dbus_bool_t v;
399 dbus_int32_t t;
400
401 reply = screensaver_send_message_void (connection, "GetActive", TRUE(!(0)));
402 if (! reply)
403 {
404 g_message ("Did not receive a reply from the screensaver.");
405 goto done;
406 }
407
408 dbus_message_iter_init (reply, &iter);
409 dbus_message_iter_get_basic (&iter, &v);
410 dbus_message_unref (reply);
411
412 if (v)
413 {
414
415 reply = screensaver_send_message_void (connection, "GetActiveTime", TRUE(!(0)));
416 dbus_message_iter_init (reply, &iter);
417 dbus_message_iter_get_basic (&iter, &t);
418 g_print (_("The screensaver has been active for %d seconds.\n")gettext ("The screensaver has been active for %d seconds.\n"), t);
419
420 dbus_message_unref (reply);
421 }
422 else
423 {
424 g_print (_("The screensaver is not currently active.\n")gettext ("The screensaver is not currently active.\n"));
425 }
426 }
427
428 if (do_lock)
429 {
430 reply = screensaver_send_message_void (connection, "Lock", FALSE(0));
431 }
432
433 if (do_unlock)
434 {
435 reply = screensaver_send_message_void (connection, "Unlock", FALSE(0));
436 }
437
438 if (do_cycle)
439 {
440 reply = screensaver_send_message_void (connection, "Cycle", FALSE(0));
441 }
442
443 if (do_poke)
444 {
445 reply = screensaver_send_message_void (connection, "SimulateUserActivity", FALSE(0));
446 }
447
448 if (do_activate)
449 {
450 reply = screensaver_send_message_bool (connection, "SetActive", TRUE(!(0)));
451 if (! reply)
452 {
453 g_message ("Did not receive a reply from the screensaver.");
454 goto done;
455 }
456 dbus_message_unref (reply);
457 }
458
459 if (do_deactivate)
460 {
461 reply = screensaver_send_message_bool (connection, "SetActive", FALSE(0));
462 if (! reply)
463 {
464 g_message ("Did not receive a reply from the screensaver.");
465 goto done;
466 }
467 dbus_message_unref (reply);
468 }
469
470 if (do_inhibit)
471 {
472 reply = screensaver_send_message_inhibit (connection,
473 inhibit_application ? inhibit_application : "Unknown",
474 inhibit_reason ? inhibit_reason : "Unknown");
475 if (! reply)
476 {
477 g_message ("Did not receive a reply from the screensaver.");
478 goto done;
479 }
480 dbus_message_unref (reply);
481
482 return FALSE(0);
483 }
484
485done:
486 g_main_loop_quit (loop);
487
488 return FALSE(0);
489}
490
491int
492main (int argc,
493 char **argv)
494{
495 DBusConnection *connection;
496 DBusError dbus_error;
497 GOptionContext *context;
498 gboolean retval;
499 GError *error = NULL((void*)0);
500
501#ifdef ENABLE_NLS1
502 bindtextdomain (GETTEXT_PACKAGE"mate-screensaver", MATELOCALEDIR"/usr/local/share/locale");
503# ifdef HAVE_BIND_TEXTDOMAIN_CODESET
504 bind_textdomain_codeset (GETTEXT_PACKAGE"mate-screensaver", "UTF-8");
505# endif
506 textdomain (GETTEXT_PACKAGE"mate-screensaver");
507#endif
508
509 g_set_prgname (argv[0]);
510
511 if (setlocale (LC_ALL6, "") == NULL((void*)0))
512 g_warning ("Locale not understood by C library, internationalization will not work\n");
513
514 context = g_option_context_new (NULL((void*)0));
515 g_option_context_add_main_entries (context, entries, NULL((void*)0));
516 retval = g_option_context_parse (context, &argc, &argv, &error);
517
518 g_option_context_free (context);
519
520 if (! retval)
521 {
522 g_warning ("%s", error->message);
523 g_error_free (error);
524 exit (1);
525 }
526
527 if (do_version)
528 {
529 g_print ("%s %s\n", argv [0], VERSION"1.27.0");
This statement is never executed
530 exit (1);
531 }
532
533 dbus_error_init (&dbus_error);
534 connection = dbus_bus_get (DBUS_BUS_SESSION, &dbus_error);
535 if (! connection)
536 {
537 g_message ("Failed to connect to the D-BUS daemon: %s", dbus_error.message);
538 dbus_error_free (&dbus_error);
539 exit (1);
540 }
541
542 dbus_connection_setup_with_g_main (connection, NULL((void*)0));
543
544 if (! screensaver_is_running (connection))
545 {
546 g_message ("Screensaver is not running!");
547 exit (1);
548 }
549
550 g_idle_add (do_command, connection);
551
552 loop = g_main_loop_new (NULL((void*)0), FALSE(0));
553 g_main_loop_run (loop);
554
555 return 0;
556}
diff --git a/2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-19ddc6.html b/2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-19ddc6.html new file mode 100644 index 0000000..03b367d --- /dev/null +++ b/2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-19ddc6.html @@ -0,0 +1,3250 @@ + + + +gs-window-x11.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rc/gs-window-x11.c
Warning:line 1129, column 2
Value stored to 'id' is never read
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name gs-window-x11.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/14.0.5 -D HAVE_CONFIG_H -I . -I .. -I . -I . -D MATEMENU_I_KNOW_THIS_IS_UNSTABLE -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/dconf -I /usr/include/mate-menus -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/dconf -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/dconf -I /usr/include/mate-menus -D PREFIX="/usr/local" -D BINDIR="/usr/local/bin" -D LIBDIR="/usr/local/lib" -D LIBEXECDIR="/usr/local/libexec" -D DATADIR="/usr/local/share" -D SYSCONFDIR="/usr/local/etc" -D MATELOCALEDIR="/usr/local/share/locale" -D PKGLIBEXECDIR="/usr/local/libexec/mate-screensaver" -D SAVERDIR="/usr/local/libexec/mate-screensaver" -D THEMESDIR="/usr/local/share/mate-screensaver/themes" -D GTKBUILDERDIR="/usr/local/share/mate-screensaver" -D MATE_SCREENSAVER_GL_HELPER_PATH="/usr/local/libexec/mate-screensaver-gl-helper" -D PAM_SERVICE_NAME="mate-screensaver" -D G_DISABLE_ASSERT -D G_DISABLE_CHECKS -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -internal-isystem /usr/lib64/clang/14.0.5/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/12/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2022-11-11-203102-6531-1 -x c gs-window-x11.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
2 *
3 * Copyright (C) 2004-2008 William Jon McCann <mccann@jhu.edu>
4 * Copyright (C) 2012-2021 MATE Developers
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
19 *
20 * Authors: William Jon McCann <mccann@jhu.edu>
21 *
22 */
23
24#include "config.h"
25
26#include <sys/types.h>
27#include <errno(*__errno_location ()).h>
28#include <sys/wait.h>
29#include <string.h>
30
31#include <gdk/gdkx.h>
32#include <gdk/gdkkeysyms.h>
33#include <gtk/gtk.h>
34#include <gtk/gtkx.h>
35
36#include "gs-window.h"
37#include "gs-marshal.h"
38#include "subprocs.h"
39#include "gs-debug.h"
40
41#ifdef HAVE_SHAPE_EXT1
42#include <X11/extensions/shape.h>
43#endif
44
45static void gs_window_finalize (GObject *object);
46
47static gboolean popup_dialog_idle (gpointer data);
48static void gs_window_dialog_finish (GSWindow *window);
49static void remove_command_watches (GSWindow *window);
50
51enum
52{
53 DIALOG_RESPONSE_CANCEL,
54 DIALOG_RESPONSE_OK
55};
56
57#define MAX_QUEUED_EVENTS16 16
58#define INFO_BAR_SECONDS30 30
59#define MATE_SCREENSAVER_DIALOG_PATH"/usr/local/libexec" "/mate-screensaver-dialog" LIBEXECDIR"/usr/local/libexec" "/mate-screensaver-dialog"
60
61struct GSWindowPrivate
62{
63 GdkMonitor *monitor;
64
65 GdkRectangle geometry;
66 guint obscured : 1;
67 guint dialog_up : 1;
68
69 guint lock_enabled : 1;
70 guint user_switch_enabled : 1;
71 guint logout_enabled : 1;
72 guint keyboard_enabled : 1;
73
74 guint64 logout_timeout;
75 char *logout_command;
76 char *keyboard_command;
77 char *status_message;
78
79 GtkWidget *vbox;
80 GtkWidget *drawing_area;
81 GtkWidget *lock_box;
82 GtkWidget *lock_socket;
83 GtkWidget *keyboard_socket;
84 GtkWidget *info_bar;
85 GtkWidget *info_content;
86
87 cairo_surface_t *background_surface;
88
89 guint popup_dialog_idle_id;
90
91 guint dialog_map_signal_id;
92 guint dialog_unmap_signal_id;
93 guint dialog_response_signal_id;
94
95 guint watchdog_timer_id;
96 guint info_bar_timer_id;
97
98 gint lock_pid;
99 gint lock_watch_id;
100 gint dialog_response;
101 gboolean dialog_quit_requested;
102 gboolean dialog_shake_in_progress;
103
104 gint keyboard_pid;
105 gint keyboard_watch_id;
106
107 GList *key_events;
108
109 gdouble last_x;
110 gdouble last_y;
111
112 GTimer *timer;
113
114#ifdef HAVE_SHAPE_EXT1
115 int shape_event_base;
116#endif
117};
118
119enum
120{
121 ACTIVITY,
122 DEACTIVATED,
123 LAST_SIGNAL
124};
125
126enum
127{
128 PROP_0,
129 PROP_OBSCURED,
130 PROP_DIALOG_UP,
131 PROP_LOCK_ENABLED,
132 PROP_LOGOUT_ENABLED,
133 PROP_KEYBOARD_ENABLED,
134 PROP_KEYBOARD_COMMAND,
135 PROP_LOGOUT_COMMAND,
136 PROP_LOGOUT_TIMEOUT,
137 PROP_MONITOR,
138 PROP_STATUS_MESSAGE
139};
140
141static guint signals [LAST_SIGNAL] = { 0, };
142
143G_DEFINE_TYPE_WITH_PRIVATE (GSWindow, gs_window, GTK_TYPE_WINDOW)static void gs_window_init (GSWindow *self); static void gs_window_class_init
(GSWindowClass *klass); static GType gs_window_get_type_once
(void); static gpointer gs_window_parent_class = ((void*)0);
static gint GSWindow_private_offset; static void gs_window_class_intern_init
(gpointer klass) { gs_window_parent_class = g_type_class_peek_parent
(klass); if (GSWindow_private_offset != 0) g_type_class_adjust_private_offset
(klass, &GSWindow_private_offset); gs_window_class_init (
(GSWindowClass*) klass); } __attribute__ ((__unused__)) static
inline gpointer gs_window_get_instance_private (GSWindow *self
) { return (((gpointer) ((guint8*) (self) + (glong) (GSWindow_private_offset
)))); } GType gs_window_get_type (void) { static gsize static_g_define_type_id
= 0; if ((__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); (void
) (0 ? (gpointer) *(&static_g_define_type_id) : ((void*)0
)); (!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
(*(&static_g_define_type_id)) gapg_temp_newval; __typeof__
((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id
); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5)
; gapg_temp_newval; })) && g_once_init_enter (&static_g_define_type_id
)); }))) { GType g_define_type_id = gs_window_get_type_once (
); (__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); 0 ?
(void) (*(&static_g_define_type_id) = (g_define_type_id)
) : (void) 0; g_once_init_leave ((&static_g_define_type_id
), (gsize) (g_define_type_id)); })); } return static_g_define_type_id
; } __attribute__ ((__noinline__)) static GType gs_window_get_type_once
(void) { GType g_define_type_id = g_type_register_static_simple
((gtk_window_get_type ()), g_intern_static_string ("GSWindow"
), sizeof (GSWindowClass), (GClassInitFunc)(void (*)(void)) gs_window_class_intern_init
, sizeof (GSWindow), (GInstanceInitFunc)(void (*)(void)) gs_window_init
, (GTypeFlags) 0); { {{ GSWindow_private_offset = g_type_add_instance_private
(g_define_type_id, sizeof (GSWindowPrivate)); };} } return g_define_type_id
; }
144
145static void
146set_invisible_cursor (GdkWindow *window,
147 gboolean invisible)
148{
149 GdkDisplay *display;
150 GdkCursor *cursor = NULL((void*)0);
151
152 if (invisible)
153 {
154 display = gdk_window_get_display (window);
155 cursor = gdk_cursor_new_for_display (display, GDK_BLANK_CURSOR);
156 }
157
158 gdk_window_set_cursor (window, cursor);
159
160 if (cursor)
161 {
162 g_object_unref (cursor);
163 }
164}
165
166/* derived from tomboy */
167static void
168gs_window_override_user_time (GSWindow *window)
169{
170 guint32 ev_time = gtk_get_current_event_time ();
171
172 if (ev_time == 0)
173 {
174 gint ev_mask = gtk_widget_get_events (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
);
175 if (!(ev_mask & GDK_PROPERTY_CHANGE_MASK))
176 {
177 gtk_widget_add_events (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
,
178 GDK_PROPERTY_CHANGE_MASK);
179 }
180
181 /*
182 * NOTE: Last resort for D-BUS or other non-interactive
183 * openings. Causes roundtrip to server. Lame.
184 */
185 ev_time = gdk_x11_get_server_time (gtk_widget_get_window (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
));
186 }
187
188 gdk_x11_window_set_user_time (gtk_widget_get_window (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
), ev_time);
189}
190
191static void
192clear_children (Window window)
193{
194 Window root;
195 Window parent;
196 Window *children;
197 unsigned int n_children;
198 int status;
199
200 children = NULL((void*)0);
201 status = XQueryTree (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ())(gdk_x11_display_get_xdisplay (gdk_display_get_default ())), window, &root, &parent, &children, &n_children);
202
203 if (status == 0)
204 {
205 if (children)
206 {
207 XFree (children);
208 }
209 return;
210 }
211
212 if (children)
213 {
214 while (n_children)
215 {
216 Window child;
217
218 child = children [--n_children];
219
220 XClearWindow (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ())(gdk_x11_display_get_xdisplay (gdk_display_get_default ())), child);
221
222 clear_children (child);
223 }
224
225 XFree (children);
226 }
227}
228
229static void
230widget_clear_all_children (GtkWidget *widget)
231{
232 GdkWindow *w;
233 GdkDisplay *display;
234
235 gs_debug ("Clearing all child windows")gs_debug_real (__func__, "gs-window-x11.c", 235, "Clearing all child windows"
)
;
236 display = gtk_widget_get_display (widget);
237
238 gdk_x11_display_error_trap_push (display);
239
240 w = gtk_widget_get_window (widget);
241
242 clear_children (GDK_WINDOW_XID (w)(gdk_x11_window_get_xid (w)));
243
244 gdk_x11_display_error_trap_pop_ignored (display);
245
246}
247
248void
249gs_window_set_background_surface (GSWindow *window,
250 cairo_surface_t *surface)
251{
252 g_return_if_fail (GS_IS_WINDOW (window))do{ (void)0; }while (0);
253
254 if (window->priv->background_surface != NULL((void*)0))
255 {
256 cairo_surface_destroy (window->priv->background_surface);
257 }
258 window->priv->background_surface = NULL((void*)0);
259
260 if (surface != NULL((void*)0))
261 {
262 window->priv->background_surface = cairo_surface_reference (surface);
263 }
264
265 gtk_widget_queue_draw (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
);
266}
267
268void
269gs_window_clear (GSWindow *window)
270{
271 GdkDisplay *display;
272 g_return_if_fail (GS_IS_WINDOW (window))do{ (void)0; }while (0);
273
274 gs_debug ("Clearing widgets")gs_debug_real (__func__, "gs-window-x11.c", 274, "Clearing widgets"
)
;
275
276 if (gtk_widget_get_realized (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
))
277 {
278 gtk_widget_queue_draw (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
);
279 /* If a screensaver theme adds child windows
280 we need to clear them too */
281 widget_clear_all_children (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
);
282 }
283
284 if (gtk_widget_get_realized (window->priv->drawing_area))
285 {
286 gtk_widget_queue_draw (window->priv->drawing_area);
287 widget_clear_all_children (window->priv->drawing_area);
288 }
289
290 display = gtk_widget_get_display (GTK_WIDGET(window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
);
291 gdk_display_flush (display);
292}
293
294static cairo_region_t *
295get_outside_region (GSWindow *window)
296{
297 GdkDisplay *display;
298 int i;
299 int num_monitors;
300 cairo_region_t *region;
301
302 display = gtk_widget_get_display (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
);
303
304 region = cairo_region_create ();
305
306 num_monitors = gdk_display_get_n_monitors (display);
307 for (i = 0; i < num_monitors; i++)
308 {
309 GdkMonitor *mon = gdk_display_get_monitor (display, i);
310
311 if (mon != window->priv->monitor)
312 {
313 GdkRectangle geometry;
314 cairo_rectangle_int_t rectangle;
315
316 gdk_monitor_get_geometry (mon, &geometry);
317 rectangle.x = geometry.x;
318 rectangle.y = geometry.y;
319 rectangle.width = geometry.width;
320 rectangle.height = geometry.height;
321 cairo_region_union_rectangle (region, &rectangle);
322 }
323 else
324 {
325 break;
326 }
327 }
328
329 return region;
330}
331
332static void
333update_geometry (GSWindow *window)
334{
335 GdkRectangle geometry;
336 cairo_region_t *outside_region;
337 cairo_region_t *monitor_region;
338
339 outside_region = get_outside_region (window);
340
341 gdk_monitor_get_geometry (window->priv->monitor, &geometry);
342 gs_debug ("got geometry for monitor: x=%d y=%d w=%d h=%d",gs_debug_real (__func__, "gs-window-x11.c", 346, "got geometry for monitor: x=%d y=%d w=%d h=%d"
, geometry.x, geometry.y, geometry.width, geometry.height)
343 geometry.x,gs_debug_real (__func__, "gs-window-x11.c", 346, "got geometry for monitor: x=%d y=%d w=%d h=%d"
, geometry.x, geometry.y, geometry.width, geometry.height)
344 geometry.y,gs_debug_real (__func__, "gs-window-x11.c", 346, "got geometry for monitor: x=%d y=%d w=%d h=%d"
, geometry.x, geometry.y, geometry.width, geometry.height)
345 geometry.width,gs_debug_real (__func__, "gs-window-x11.c", 346, "got geometry for monitor: x=%d y=%d w=%d h=%d"
, geometry.x, geometry.y, geometry.width, geometry.height)
346 geometry.height)gs_debug_real (__func__, "gs-window-x11.c", 346, "got geometry for monitor: x=%d y=%d w=%d h=%d"
, geometry.x, geometry.y, geometry.width, geometry.height)
;
347 monitor_region = cairo_region_create_rectangle ((const cairo_rectangle_int_t *)&geometry);
348 cairo_region_subtract (monitor_region, outside_region);
349 cairo_region_destroy (outside_region);
350
351 cairo_region_get_extents (monitor_region, (cairo_rectangle_int_t *)&geometry);
352 cairo_region_destroy (monitor_region);
353
354 gs_debug ("using geometry for monitor: x=%d y=%d w=%d h=%d",gs_debug_real (__func__, "gs-window-x11.c", 358, "using geometry for monitor: x=%d y=%d w=%d h=%d"
, geometry.x, geometry.y, geometry.width, geometry.height)
355 geometry.x,gs_debug_real (__func__, "gs-window-x11.c", 358, "using geometry for monitor: x=%d y=%d w=%d h=%d"
, geometry.x, geometry.y, geometry.width, geometry.height)
356 geometry.y,gs_debug_real (__func__, "gs-window-x11.c", 358, "using geometry for monitor: x=%d y=%d w=%d h=%d"
, geometry.x, geometry.y, geometry.width, geometry.height)
357 geometry.width,gs_debug_real (__func__, "gs-window-x11.c", 358, "using geometry for monitor: x=%d y=%d w=%d h=%d"
, geometry.x, geometry.y, geometry.width, geometry.height)
358 geometry.height)gs_debug_real (__func__, "gs-window-x11.c", 358, "using geometry for monitor: x=%d y=%d w=%d h=%d"
, geometry.x, geometry.y, geometry.width, geometry.height)
;
359
360 window->priv->geometry.x = geometry.x;
361 window->priv->geometry.y = geometry.y;
362 window->priv->geometry.width = geometry.width;
363 window->priv->geometry.height = geometry.height;
364}
365
366static void
367monitor_geometry_notify (GdkMonitor *monitor,
368 GParamSpec *pspec,
369 GSWindow *window)
370{
371 gs_debug ("Got monitor geometry notify signal")gs_debug_real (__func__, "gs-window-x11.c", 371, "Got monitor geometry notify signal"
)
;
372 gtk_widget_queue_resize (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
);
373}
374
375/* copied from panel-toplevel.c */
376static void
377gs_window_move_resize_window (GSWindow *window,
378 gboolean move,
379 gboolean resize)
380{
381 GtkWidget *widget;
382 GdkWindow *gdkwindow;
383
384 widget = GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
;
385 gdkwindow = gtk_widget_get_window (widget);
386
387 g_assert (gtk_widget_get_realized (widget))do { (void) 0; } while (0);
388
389 gs_debug ("Move and/or resize window: x=%d y=%d w=%d h=%d",gs_debug_real (__func__, "gs-window-x11.c", 393, "Move and/or resize window: x=%d y=%d w=%d h=%d"
, window->priv->geometry.x, window->priv->geometry
.y, window->priv->geometry.width, window->priv->geometry
.height)
390 window->priv->geometry.x,gs_debug_real (__func__, "gs-window-x11.c", 393, "Move and/or resize window: x=%d y=%d w=%d h=%d"
, window->priv->geometry.x, window->priv->geometry
.y, window->priv->geometry.width, window->priv->geometry
.height)
391 window->priv->geometry.y,gs_debug_real (__func__, "gs-window-x11.c", 393, "Move and/or resize window: x=%d y=%d w=%d h=%d"
, window->priv->geometry.x, window->priv->geometry
.y, window->priv->geometry.width, window->priv->geometry
.height)
392 window->priv->geometry.width,gs_debug_real (__func__, "gs-window-x11.c", 393, "Move and/or resize window: x=%d y=%d w=%d h=%d"
, window->priv->geometry.x, window->priv->geometry
.y, window->priv->geometry.width, window->priv->geometry
.height)
393 window->priv->geometry.height)gs_debug_real (__func__, "gs-window-x11.c", 393, "Move and/or resize window: x=%d y=%d w=%d h=%d"
, window->priv->geometry.x, window->priv->geometry
.y, window->priv->geometry.width, window->priv->geometry
.height)
;
394
395 if (move && resize)
396 {
397 gdk_window_move_resize (gdkwindow,
398 window->priv->geometry.x,
399 window->priv->geometry.y,
400 window->priv->geometry.width,
401 window->priv->geometry.height);
402 }
403 else if (move)
404 {
405 gdk_window_move (gdkwindow,
406 window->priv->geometry.x,
407 window->priv->geometry.y);
408 }
409 else if (resize)
410 {
411 gdk_window_resize (gdkwindow,
412 window->priv->geometry.width,
413 window->priv->geometry.height);
414 }
415}
416
417static void
418gs_window_real_unrealize (GtkWidget *widget)
419{
420 GdkMonitor *monitor = GS_WINDOW (widget)((((GSWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gs_window_get_type ()))))))
->priv->monitor;
421
422 g_signal_handlers_disconnect_by_func (monitor, monitor_geometry_notify,g_signal_handlers_disconnect_matched ((monitor), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (monitor_geometry_notify), (widget))
423 widget)g_signal_handlers_disconnect_matched ((monitor), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (monitor_geometry_notify), (widget))
;
424
425 if (GTK_WIDGET_CLASS (gs_window_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((gs_window_parent_class)), ((gtk_widget_get_type ()))))))
->unrealize)
426 {
427 GTK_WIDGET_CLASS (gs_window_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((gs_window_parent_class)), ((gtk_widget_get_type ()))))))
->unrealize (widget);
428 }
429}
430
431/* copied from gdk */
432extern char **environ;
433
434static gchar **
435spawn_make_environment_for_display (GdkDisplay *display,
436 gchar **envp)
437{
438 gchar **retval = NULL((void*)0);
439 const gchar *display_name;
440 gint display_index = -1;
441 gint i, env_len;
442
443 g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL)do{ (void)0; }while (0);
444
445 if (envp == NULL((void*)0))
446 envp = environ;
447
448 for (env_len = 0; envp[env_len]; env_len++)
449 if (strncmp (envp[env_len], "DISPLAY", strlen ("DISPLAY")) == 0)
450 display_index = env_len;
451
452 retval = g_new (char *, env_len + 1)((char * *) g_malloc_n ((env_len + 1), sizeof (char *)));
453 retval[env_len] = NULL((void*)0);
454
455 display_name = gdk_display_get_name (display);
456
457 for (i = 0; i < env_len; i++)
458 if (i == display_index)
459 retval[i] = g_strconcat ("DISPLAY=", display_name, NULL((void*)0));
460 else
461 retval[i] = g_strdup (envp[i]);
462
463 g_assert (i == env_len)do { (void) 0; } while (0);
464
465 return retval;
466}
467
468static gboolean
469spawn_command_line_on_display_sync (GdkDisplay *display,
470 const gchar *command_line,
471 char **standard_output,
472 char **standard_error,
473 int *exit_status,
474 GError **error)
475{
476 char **argv = NULL((void*)0);
477 char **envp = NULL((void*)0);
478 gboolean retval;
479
480 g_return_val_if_fail (command_line != NULL, FALSE)do{ (void)0; }while (0);
481
482 if (! g_shell_parse_argv (command_line, NULL((void*)0), &argv, error))
483 {
484 return FALSE(0);
485 }
486
487 envp = spawn_make_environment_for_display (display, NULL((void*)0));
488
489 retval = g_spawn_sync (NULL((void*)0),
490 argv,
491 envp,
492 G_SPAWN_SEARCH_PATH,
493 NULL((void*)0),
494 NULL((void*)0),
495 standard_output,
496 standard_error,
497 exit_status,
498 error);
499
500 g_strfreev (argv);
501 g_strfreev (envp);
502
503 return retval;
504}
505
506static GdkVisual *
507get_best_visual_for_display (GdkDisplay *display)
508{
509 GdkScreen *screen;
510 char *std_output;
511 int exit_status;
512 GError *error;
513 unsigned long v;
514 char c;
515 GdkVisual *visual;
516 gboolean res;
517
518 visual = NULL((void*)0);
519 screen = gdk_display_get_default_screen (display);
520
521 error = NULL((void*)0);
522 std_output = NULL((void*)0);
523 res = spawn_command_line_on_display_sync (display,
524 MATE_SCREENSAVER_GL_HELPER_PATH"/usr/local/libexec/mate-screensaver-gl-helper",
525 &std_output,
526 NULL((void*)0),
527 &exit_status,
528 &error);
529 if (! res)
530 {
531 gs_debug ("Could not run command '%s': %s",gs_debug_real (__func__, "gs-window-x11.c", 532, "Could not run command '%s': %s"
, "/usr/local/libexec/mate-screensaver-gl-helper", error->
message)
532 MATE_SCREENSAVER_GL_HELPER_PATH, error->message)gs_debug_real (__func__, "gs-window-x11.c", 532, "Could not run command '%s': %s"
, "/usr/local/libexec/mate-screensaver-gl-helper", error->
message)
;
533 g_error_free (error);
534 goto out;
535 }
536
537 if (1 == sscanf (std_output, "0x%lx %c", &v, &c))
538 {
539 if (v != 0)
540 {
541 VisualID visual_id;
542
543 visual_id = (VisualID) v;
544 visual = gdk_x11_screen_lookup_visual (screen, visual_id);
545
546 gs_debug ("Found best GL visual for display %s: 0x%x",gs_debug_real (__func__, "gs-window-x11.c", 548, "Found best GL visual for display %s: 0x%x"
, gdk_display_get_name (display), (unsigned int) visual_id)
547 gdk_display_get_name (display),gs_debug_real (__func__, "gs-window-x11.c", 548, "Found best GL visual for display %s: 0x%x"
, gdk_display_get_name (display), (unsigned int) visual_id)
548 (unsigned int) visual_id)gs_debug_real (__func__, "gs-window-x11.c", 548, "Found best GL visual for display %s: 0x%x"
, gdk_display_get_name (display), (unsigned int) visual_id)
;
549 }
550 }
551out:
552 g_free (std_output);
553
554 return g_object_ref (visual)((__typeof__ (visual)) (g_object_ref) (visual));
555}
556
557static void
558widget_set_best_visual (GtkWidget *widget)
559{
560 GdkVisual *visual;
561
562 g_return_if_fail (widget != NULL)do{ (void)0; }while (0);
563
564 visual = get_best_visual_for_display (gtk_widget_get_display (widget));
565 if (visual != NULL((void*)0))
566 {
567 gtk_widget_set_visual (widget, visual);
568 g_object_unref (visual);
569 }
570}
571
572static void
573gs_window_real_realize (GtkWidget *widget)
574{
575 GdkMonitor *monitor = GS_WINDOW (widget)((((GSWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gs_window_get_type ()))))))
->priv->monitor;
576
577 widget_set_best_visual (widget);
578
579 if (GTK_WIDGET_CLASS (gs_window_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((gs_window_parent_class)), ((gtk_widget_get_type ()))))))
->realize)
580 {
581 GTK_WIDGET_CLASS (gs_window_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((gs_window_parent_class)), ((gtk_widget_get_type ()))))))
->realize (widget);
582 }
583
584 gs_window_override_user_time (GS_WINDOW (widget)((((GSWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gs_window_get_type ()))))))
);
585
586 gs_window_move_resize_window (GS_WINDOW (widget)((((GSWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gs_window_get_type ()))))))
, TRUE(!(0)), TRUE(!(0)));
587
588 g_signal_connect (monitor,g_signal_connect_data ((monitor), ("notify::geometry"), (((GCallback
) (monitor_geometry_notify))), (widget), ((void*)0), (GConnectFlags
) 0)
589 "notify::geometry",g_signal_connect_data ((monitor), ("notify::geometry"), (((GCallback
) (monitor_geometry_notify))), (widget), ((void*)0), (GConnectFlags
) 0)
590 G_CALLBACK (monitor_geometry_notify),g_signal_connect_data ((monitor), ("notify::geometry"), (((GCallback
) (monitor_geometry_notify))), (widget), ((void*)0), (GConnectFlags
) 0)
591 widget)g_signal_connect_data ((monitor), ("notify::geometry"), (((GCallback
) (monitor_geometry_notify))), (widget), ((void*)0), (GConnectFlags
) 0)
;
592}
593
594/* every so often we should raise the window in case
595 another window has somehow gotten on top */
596static gboolean
597watchdog_timer (GSWindow *window)
598{
599 GtkWidget *widget = GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
;
600
601 gdk_window_focus (gtk_widget_get_window (widget), GDK_CURRENT_TIME0L);
602
603 return TRUE(!(0));
604}
605
606static void
607remove_watchdog_timer (GSWindow *window)
608{
609 if (window->priv->watchdog_timer_id != 0)
610 {
611 g_source_remove (window->priv->watchdog_timer_id);
612 window->priv->watchdog_timer_id = 0;
613 }
614}
615
616static void
617add_watchdog_timer (GSWindow *window,
618 guint timeout)
619{
620 window->priv->watchdog_timer_id = g_timeout_add (timeout,
621 (GSourceFunc)watchdog_timer,
622 window);
623}
624
625static void
626remove_popup_dialog_idle (GSWindow *window)
627{
628 if (window->priv->popup_dialog_idle_id != 0)
629 {
630 g_source_remove (window->priv->popup_dialog_idle_id);
631 window->priv->popup_dialog_idle_id = 0;
632 }
633}
634
635static void
636add_popup_dialog_idle (GSWindow *window)
637{
638 window->priv->popup_dialog_idle_id = g_idle_add (popup_dialog_idle, window);
639}
640
641static gboolean
642emit_deactivated_idle (GSWindow *window)
643{
644 g_signal_emit (window, signals [DEACTIVATED], 0);
645
646 return FALSE(0);
647}
648
649static void
650add_emit_deactivated_idle (GSWindow *window)
651{
652 g_idle_add ((GSourceFunc)emit_deactivated_idle, window);
653}
654
655static void
656gs_window_raise (GSWindow *window)
657{
658 GdkWindow *win;
659
660 g_return_if_fail (GS_IS_WINDOW (window))do{ (void)0; }while (0);
661
662 gs_debug ("Raising screensaver window")gs_debug_real (__func__, "gs-window-x11.c", 662, "Raising screensaver window"
)
;
663
664 win = gtk_widget_get_window (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
);
665
666 gdk_window_raise (win);
667}
668
669static gboolean
670x11_window_is_ours (Window window)
671{
672 GdkWindow *gwindow;
673 gboolean ret;
674
675 ret = FALSE(0);
676
677 gwindow = gdk_x11_window_lookup_for_display (gdk_display_get_default (), window);
678 if (gwindow && (window != GDK_ROOT_WINDOW ()(gdk_x11_get_default_root_xwindow ())))
679 {
680 ret = TRUE(!(0));
681 }
682
683 return ret;
684}
685
686#ifdef HAVE_SHAPE_EXT1
687static void
688unshape_window (GSWindow *window)
689{
690 gdk_window_shape_combine_region (gtk_widget_get_window (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
),
691 NULL((void*)0),
692 0,
693 0);
694}
695#endif
696
697static void
698gs_window_xevent (GSWindow *window,
699 GdkXEvent *xevent)
700{
701 XEvent *ev;
702
703 ev = xevent;
704
705 /* MapNotify is used to tell us when new windows are mapped.
706 ConfigureNofify is used to tell us when windows are raised. */
707 switch (ev->xany.type)
708 {
709 case MapNotify19:
710 {
711 XMapEvent *xme = &ev->xmap;
712
713 if (! x11_window_is_ours (xme->window))
714 {
715 gs_window_raise (window);
716 }
717 else
718 {
719 gs_debug ("not raising our windows")gs_debug_real (__func__, "gs-window-x11.c", 719, "not raising our windows"
)
;
720 }
721
722 break;
723 }
724 case ConfigureNotify22:
725 {
726 XConfigureEvent *xce = &ev->xconfigure;
727
728 if (! x11_window_is_ours (xce->window))
729 {
730 gs_window_raise (window);
731 }
732 else
733 {
734 gs_debug ("not raising our windows")gs_debug_real (__func__, "gs-window-x11.c", 734, "not raising our windows"
)
;
735 }
736
737 break;
738 }
739 default:
740 /* extension events */
741#ifdef HAVE_SHAPE_EXT1
742 if (ev->xany.type == (window->priv->shape_event_base + ShapeNotify0))
743 {
744 /*XShapeEvent *xse = (XShapeEvent *) ev;*/
745 unshape_window (window);
746 gs_debug ("Window was reshaped!")gs_debug_real (__func__, "gs-window-x11.c", 746, "Window was reshaped!"
)
;
747 }
748#endif
749
750 break;
751 }
752
753}
754
755static GdkFilterReturn
756xevent_filter (GdkXEvent *xevent,
757 GdkEvent *event,
758 GSWindow *window)
759{
760 gs_window_xevent (window, xevent);
761
762 return GDK_FILTER_CONTINUE;
763}
764
765static void
766select_popup_events (void)
767{
768 XWindowAttributes attr;
769 unsigned long events;
770 GdkDisplay *display;
771
772 display = gdk_display_get_default ();
773
774 gdk_x11_display_error_trap_push (display);
775
776 memset (&attr, 0, sizeof (attr));
777 XGetWindowAttributes (GDK_DISPLAY_XDISPLAY (display)(gdk_x11_display_get_xdisplay (display)), GDK_ROOT_WINDOW ()(gdk_x11_get_default_root_xwindow ()), &attr);
778
779 events = SubstructureNotifyMask(1L<<19) | attr.your_event_mask;
780 XSelectInput (GDK_DISPLAY_XDISPLAY (display)(gdk_x11_display_get_xdisplay (display)), GDK_ROOT_WINDOW ()(gdk_x11_get_default_root_xwindow ()), events);
781
782 gdk_x11_display_error_trap_pop_ignored (display);
783}
784
785static void
786window_select_shape_events (GSWindow *window)
787{
788#ifdef HAVE_SHAPE_EXT1
789 unsigned long events;
790 int shape_error_base;
791 GdkDisplay *display;
792
793 display = gtk_widget_get_display (GTK_WIDGET(window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
);
794
795 gdk_x11_display_error_trap_push (display);
796
797 if (XShapeQueryExtension (GDK_DISPLAY_XDISPLAY (display)(gdk_x11_display_get_xdisplay (display)), &window->priv->shape_event_base, &shape_error_base)) {
798 events = ShapeNotifyMask(1L << 0);
799 XShapeSelectInput (GDK_DISPLAY_XDISPLAY (display)(gdk_x11_display_get_xdisplay (display)), GDK_WINDOW_XID (gtk_widget_get_window (GTK_WIDGET (window)))(gdk_x11_window_get_xid (gtk_widget_get_window (((((GtkWidget
*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window
)), ((gtk_widget_get_type ())))))))))
, events);
800 }
801
802 gdk_x11_display_error_trap_pop_ignored (display);
803#endif
804}
805
806static gboolean
807gs_window_real_draw (GtkWidget *widget,
808 cairo_t *cr)
809{
810 GSWindow *window = GS_WINDOW (widget)((((GSWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gs_window_get_type ()))))))
;
811 cairo_surface_t *bg_surface = window->priv->background_surface;
812
813 cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
814 if (bg_surface != NULL((void*)0))
815 {
816 cairo_set_source_surface (cr, bg_surface, 0, 0);
817 }
818 else
819 {
820 cairo_set_source_rgb (cr, 0, 0, 0);
821 }
822 cairo_paint (cr);
823
824 return FALSE(0);
825}
826
827static void
828gs_window_real_show (GtkWidget *widget)
829{
830 GSWindow *window;
831
832 if (GTK_WIDGET_CLASS (gs_window_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((gs_window_parent_class)), ((gtk_widget_get_type ()))))))
->show)
833 {
834 GTK_WIDGET_CLASS (gs_window_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((gs_window_parent_class)), ((gtk_widget_get_type ()))))))
->show (widget);
835 }
836
837 gs_window_clear (GS_WINDOW (widget)((((GSWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gs_window_get_type ()))))))
);
838
839 set_invisible_cursor (gtk_widget_get_window (widget), TRUE(!(0)));
840
841 window = GS_WINDOW (widget)((((GSWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gs_window_get_type ()))))))
;
842 if (window->priv->timer)
843 {
844 g_timer_destroy (window->priv->timer);
845 }
846 window->priv->timer = g_timer_new ();
847
848 remove_watchdog_timer (window);
849 add_watchdog_timer (window, 30000);
850
851 select_popup_events ();
852 window_select_shape_events (window);
853 gdk_window_add_filter (NULL((void*)0), (GdkFilterFunc)xevent_filter, window);
854}
855
856static void
857set_info_text_and_icon (GSWindow *window,
858 const char *icon_name,
859 const char *primary_text,
860 const char *secondary_text)
861{
862 GtkWidget *content_area;
863 GtkWidget *hbox_content;
864 GtkWidget *image;
865 GtkWidget *vbox;
866 gchar *primary_markup;
867 gchar *secondary_markup;
868 GtkWidget *primary_label;
869 GtkWidget *secondary_label;
870
871 hbox_content = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 8);
872 gtk_widget_show (hbox_content);
873
874 image = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_DIALOG);
875 gtk_widget_show (image);
876 gtk_box_pack_start (GTK_BOX (hbox_content)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((hbox_content)), ((gtk_box_get_type ()))))))
, image, FALSE(0), FALSE(0), 0);
877 gtk_widget_set_valign (image, GTK_ALIGN_START);
878
879 vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
880 gtk_widget_show (vbox);
881 gtk_box_pack_start (GTK_BOX (hbox_content)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((hbox_content)), ((gtk_box_get_type ()))))))
, vbox, FALSE(0), FALSE(0), 0);
882
883 primary_markup = g_strdup_printf ("<b>%s</b>", primary_text);
884 primary_label = gtk_label_new (primary_markup);
885 g_free (primary_markup);
886 gtk_widget_show (primary_label);
887 gtk_box_pack_start (GTK_BOX (vbox)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((vbox)), ((gtk_box_get_type ()))))))
, primary_label, TRUE(!(0)), TRUE(!(0)), 0);
888 gtk_label_set_use_markup (GTK_LABEL (primary_label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((primary_label)), ((gtk_label_get_type ()))))))
, TRUE(!(0)));
889 gtk_label_set_line_wrap (GTK_LABEL (primary_label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((primary_label)), ((gtk_label_get_type ()))))))
, TRUE(!(0)));
890 gtk_widget_set_halign (primary_label, GTK_ALIGN_START);
891
892 if (secondary_text != NULL((void*)0))
893 {
894 secondary_markup = g_strdup_printf ("<small>%s</small>",
895 secondary_text);
896 secondary_label = gtk_label_new (secondary_markup);
897 g_free (secondary_markup);
898 gtk_widget_show (secondary_label);
899 gtk_box_pack_start (GTK_BOX (vbox)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((vbox)), ((gtk_box_get_type ()))))))
, secondary_label, TRUE(!(0)), TRUE(!(0)), 0);
900 gtk_label_set_use_markup (GTK_LABEL (secondary_label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((secondary_label)), ((gtk_label_get_type ()))))))
, TRUE(!(0)));
901 gtk_label_set_line_wrap (GTK_LABEL (secondary_label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((secondary_label)), ((gtk_label_get_type ()))))))
, TRUE(!(0)));
902 gtk_widget_set_halign (secondary_label, GTK_ALIGN_START);
903 }
904
905 /* remove old content */
906 content_area = gtk_info_bar_get_content_area (GTK_INFO_BAR (window->priv->info_bar)((((GtkInfoBar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->info_bar)), ((gtk_info_bar_get_type(
)))))))
);
907 if (window->priv->info_content != NULL((void*)0))
908 {
909 gtk_container_remove (GTK_CONTAINER (content_area)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((content_area)), ((gtk_container_get_type ()))))))
, window->priv->info_content);
910 }
911 gtk_box_pack_start (GTK_BOX (content_area)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((content_area)), ((gtk_box_get_type ()))))))
,
912 hbox_content,
913 TRUE(!(0)), FALSE(0), 0);
914 window->priv->info_content = hbox_content;
915}
916
917static gboolean
918info_bar_timeout (GSWindow *window)
919{
920 window->priv->info_bar_timer_id = 0;
921 gtk_widget_hide (window->priv->info_bar);
922 return FALSE(0);
923}
924
925void
926gs_window_show_message (GSWindow *window,
927 const char *summary,
928 const char *body,
929 const char *icon)
930{
931 g_return_if_fail (GS_IS_WINDOW (window))do{ (void)0; }while (0);
932
933 set_info_text_and_icon (window,
934 icon,
935 summary,
936 body);
937 gtk_widget_show (window->priv->info_bar);
938
939 if (window->priv->info_bar_timer_id > 0)
940 {
941 g_source_remove (window->priv->info_bar_timer_id);
942 }
943
944 window->priv->info_bar_timer_id = g_timeout_add_seconds (INFO_BAR_SECONDS30,
945 (GSourceFunc)info_bar_timeout,
946 window);
947}
948
949void
950gs_window_show (GSWindow *window)
951{
952 g_return_if_fail (GS_IS_WINDOW (window))do{ (void)0; }while (0);
953
954 gtk_widget_show (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
);
955}
956
957static void
958gs_window_real_hide (GtkWidget *widget)
959{
960 GSWindow *window;
961
962 window = GS_WINDOW (widget)((((GSWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gs_window_get_type ()))))))
;
963
964 gdk_window_remove_filter (NULL((void*)0), (GdkFilterFunc)xevent_filter, window);
965
966 remove_watchdog_timer (window);
967
968 if (GTK_WIDGET_CLASS (gs_window_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((gs_window_parent_class)), ((gtk_widget_get_type ()))))))
->hide)
969 {
970 GTK_WIDGET_CLASS (gs_window_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((gs_window_parent_class)), ((gtk_widget_get_type ()))))))
->hide (widget);
971 }
972}
973
974void
975gs_window_destroy (GSWindow *window)
976{
977 g_return_if_fail (GS_IS_WINDOW (window))do{ (void)0; }while (0);
978
979 gs_window_cancel_unlock_request (window);
980
981 gtk_widget_destroy (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
);
982}
983
984GdkWindow *
985gs_window_get_gdk_window (GSWindow *window)
986{
987 g_return_val_if_fail (GS_IS_WINDOW (window), NULL)do{ (void)0; }while (0);
988
989 return gtk_widget_get_window (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
);
990}
991
992GtkWidget *
993gs_window_get_drawing_area (GSWindow *window)
994{
995 g_return_val_if_fail (GS_IS_WINDOW (window), NULL)do{ (void)0; }while (0);
996
997 return window->priv->drawing_area;
998}
999
1000/* just for debugging */
1001static gboolean
1002error_watch (GIOChannel *source,
1003 GIOCondition condition,
1004 gpointer data)
1005{
1006 gboolean finished = FALSE(0);
1007
1008 if (condition & G_IO_IN)
1009 {
1010 GIOStatus status;
1011 GError *error = NULL((void*)0);
1012 char *line;
1013
1014 line = NULL((void*)0);
1015 status = g_io_channel_read_line (source, &line, NULL((void*)0), NULL((void*)0), &error);
1016
1017 switch (status)
1018 {
1019 case G_IO_STATUS_NORMAL:
1020 gs_debug ("command error output: %s", line)gs_debug_real (__func__, "gs-window-x11.c", 1020, "command error output: %s"
, line)
;
1021 break;
1022 case G_IO_STATUS_EOF:
1023 finished = TRUE(!(0));
1024 break;
1025 case G_IO_STATUS_ERROR:
1026 finished = TRUE(!(0));
1027 gs_debug ("Error reading from child: %s\n", error->message)gs_debug_real (__func__, "gs-window-x11.c", 1027, "Error reading from child: %s\n"
, error->message)
;
1028 g_error_free (error);
1029 return FALSE(0);
1030 case G_IO_STATUS_AGAIN:
1031 default:
1032 break;
1033 }
1034 g_free (line);
1035 }
1036 else if (condition & G_IO_HUP)
1037 {
1038 finished = TRUE(!(0));
1039 }
1040
1041 if (finished)
1042 {
1043 return FALSE(0);
1044 }
1045
1046 return TRUE(!(0));
1047}
1048
1049static gboolean
1050spawn_on_window (GSWindow *window,
1051 char *command,
1052 int *pid,
1053 GIOFunc watch_func,
1054 gpointer user_data,
1055 gint *watch_id)
1056{
1057 int argc;
1058 char **argv;
1059 char **envp;
1060 GError *error;
1061 gboolean result;
1062 GIOChannel *channel;
1063 int standard_output;
1064 int standard_error;
1065 int child_pid;
1066 int id;
1067
1068 error = NULL((void*)0);
1069 if (! g_shell_parse_argv (command, &argc, &argv, &error))
1070 {
1071 gs_debug ("Could not parse command: %s", error->message)gs_debug_real (__func__, "gs-window-x11.c", 1071, "Could not parse command: %s"
, error->message)
;
1072 g_error_free (error);
1073 return FALSE(0);
1074 }
1075
1076 error = NULL((void*)0);
1077 envp = spawn_make_environment_for_display (gtk_widget_get_display (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
), NULL((void*)0));
1078 result = g_spawn_async_with_pipes (NULL((void*)0),
1079 argv,
1080 envp,
1081 G_SPAWN_DO_NOT_REAP_CHILD | G_SPAWN_SEARCH_PATH,
1082 NULL((void*)0),
1083 NULL((void*)0),
1084 &child_pid,
1085 NULL((void*)0),
1086 &standard_output,
1087 &standard_error,
1088 &error);
1089
1090 if (! result)
1091 {
1092 gs_debug ("Could not start command '%s': %s", command, error->message)gs_debug_real (__func__, "gs-window-x11.c", 1092, "Could not start command '%s': %s"
, command, error->message)
;
1093 g_error_free (error);
1094 g_strfreev (argv);
1095 return FALSE(0);
1096 }
1097
1098 if (pid != NULL((void*)0))
1099 {
1100 *pid = child_pid;
1101 }
1102 else
1103 {
1104 g_spawn_close_pid (child_pid);
1105 }
1106
1107 /* output channel */
1108 channel = g_io_channel_unix_new (standard_output);
1109 g_io_channel_set_close_on_unref (channel, TRUE(!(0)));
1110 g_io_channel_set_flags (channel,
1111 g_io_channel_get_flags (channel) | G_IO_FLAG_NONBLOCK,
1112 NULL((void*)0));
1113 id = g_io_add_watch (channel,
1114 G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL,
1115 watch_func,
1116 user_data);
1117 if (watch_id != NULL((void*)0))
1118 {
1119 *watch_id = id;
1120 }
1121 g_io_channel_unref (channel);
1122
1123 /* error channel */
1124 channel = g_io_channel_unix_new (standard_error);
1125 g_io_channel_set_close_on_unref (channel, TRUE(!(0)));
1126 g_io_channel_set_flags (channel,
1127 g_io_channel_get_flags (channel) | G_IO_FLAG_NONBLOCK,
1128 NULL((void*)0));
1129 id = g_io_add_watch (channel,
Value stored to 'id' is never read
1130 G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL,
1131 error_watch,
1132 NULL((void*)0));
1133 g_io_channel_unref (channel);
1134
1135 g_strfreev (argv);
1136 g_strfreev (envp);
1137
1138 return result;
1139}
1140
1141static void
1142lock_plug_added (GtkWidget *widget,
1143 GSWindow *window)
1144{
1145 gtk_widget_show (widget);
1146}
1147
1148static gboolean
1149lock_plug_removed (GtkWidget *widget,
1150 GSWindow *window)
1151{
1152 gtk_widget_hide (widget);
1153 gtk_container_remove (GTK_CONTAINER (window->priv->vbox)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->vbox)), ((gtk_container_get_type ())
)))))
, GTK_WIDGET (window->priv->lock_box)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->lock_box)), ((gtk_widget_get_type ()
))))))
);
1154 window->priv->lock_box = NULL((void*)0);
1155
1156 return TRUE(!(0));
1157}
1158
1159static void
1160keyboard_plug_added (GtkWidget *widget,
1161 GSWindow *window)
1162{
1163 gtk_widget_show (widget);
1164}
1165
1166static gboolean
1167keyboard_plug_removed (GtkWidget *widget,
1168 GSWindow *window)
1169{
1170 gtk_widget_hide (widget);
1171 gtk_container_remove (GTK_CONTAINER (window->priv->vbox)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->vbox)), ((gtk_container_get_type ())
)))))
, GTK_WIDGET (window->priv->keyboard_socket)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->keyboard_socket)), ((gtk_widget_get_type
()))))))
);
1172
1173 return TRUE(!(0));
1174}
1175
1176static void
1177keyboard_socket_destroyed (GtkWidget *widget,
1178 GSWindow *window)
1179{
1180 g_signal_handlers_disconnect_by_func (widget, keyboard_socket_destroyed, window)g_signal_handlers_disconnect_matched ((widget), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (keyboard_socket_destroyed), (window))
;
1181 g_signal_handlers_disconnect_by_func (widget, keyboard_plug_added, window)g_signal_handlers_disconnect_matched ((widget), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (keyboard_plug_added), (window))
;
1182 g_signal_handlers_disconnect_by_func (widget, keyboard_plug_removed, window)g_signal_handlers_disconnect_matched ((widget), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (keyboard_plug_removed), (window))
;
1183
1184 window->priv->keyboard_socket = NULL((void*)0);
1185}
1186
1187static void
1188forward_key_events (GSWindow *window)
1189{
1190 window->priv->key_events = g_list_reverse (window->priv->key_events);
1191
1192 while (window->priv->key_events != NULL((void*)0))
1193 {
1194 GdkEventKey *event = window->priv->key_events->data;
1195
1196 gtk_window_propagate_key_event (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
, event);
1197
1198 gdk_event_free ((GdkEvent *)event);
1199 window->priv->key_events = g_list_delete_link (window->priv->key_events,
1200 window->priv->key_events);
1201 }
1202}
1203
1204static void
1205remove_key_events (GSWindow *window)
1206{
1207 window->priv->key_events = g_list_reverse (window->priv->key_events);
1208
1209 while (window->priv->key_events)
1210 {
1211 GdkEventKey *event = window->priv->key_events->data;
1212
1213 gdk_event_free ((GdkEvent *)event);
1214 window->priv->key_events = g_list_delete_link (window->priv->key_events,
1215 window->priv->key_events);
1216 }
1217}
1218
1219static void
1220lock_socket_show (GtkWidget *widget,
1221 GSWindow *window)
1222{
1223 gtk_widget_child_focus (window->priv->lock_socket, GTK_DIR_TAB_FORWARD);
1224
1225 /* send queued events to the dialog */
1226 forward_key_events (window);
1227}
1228
1229static void
1230lock_socket_destroyed (GtkWidget *widget,
1231 GSWindow *window)
1232{
1233 g_signal_handlers_disconnect_by_func (widget, lock_socket_show, window)g_signal_handlers_disconnect_matched ((widget), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (lock_socket_show), (window))
;
1234 g_signal_handlers_disconnect_by_func (widget, lock_socket_destroyed, window)g_signal_handlers_disconnect_matched ((widget), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (lock_socket_destroyed), (window))
;
1235 g_signal_handlers_disconnect_by_func (widget, lock_plug_added, window)g_signal_handlers_disconnect_matched ((widget), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (lock_plug_added), (window))
;
1236 g_signal_handlers_disconnect_by_func (widget, lock_plug_removed, window)g_signal_handlers_disconnect_matched ((widget), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (lock_plug_removed), (window))
;
1237
1238 window->priv->lock_socket = NULL((void*)0);
1239}
1240
1241static void
1242create_keyboard_socket (GSWindow *window,
1243 guint32 id)
1244{
1245 int height;
1246
1247 height = (HeightOfScreen (gdk_x11_screen_get_xscreen (gtk_widget_get_screen (GTK_WIDGET (window))))((gdk_x11_screen_get_xscreen (gtk_widget_get_screen (((((GtkWidget
*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window
)), ((gtk_widget_get_type ())))))))))->height)
) / 4;
1248
1249 window->priv->keyboard_socket = gtk_socket_new ();
1250 gtk_widget_set_size_request (window->priv->keyboard_socket, -1, height);
1251
1252 g_signal_connect (window->priv->keyboard_socket, "destroy",g_signal_connect_data ((window->priv->keyboard_socket),
("destroy"), (((GCallback) (keyboard_socket_destroyed))), (window
), ((void*)0), (GConnectFlags) 0)
1253 G_CALLBACK (keyboard_socket_destroyed), window)g_signal_connect_data ((window->priv->keyboard_socket),
("destroy"), (((GCallback) (keyboard_socket_destroyed))), (window
), ((void*)0), (GConnectFlags) 0)
;
1254 g_signal_connect (window->priv->keyboard_socket, "plug_added",g_signal_connect_data ((window->priv->keyboard_socket),
("plug_added"), (((GCallback) (keyboard_plug_added))), (window
), ((void*)0), (GConnectFlags) 0)
1255 G_CALLBACK (keyboard_plug_added), window)g_signal_connect_data ((window->priv->keyboard_socket),
("plug_added"), (((GCallback) (keyboard_plug_added))), (window
), ((void*)0), (GConnectFlags) 0)
;
1256 g_signal_connect (window->priv->keyboard_socket, "plug_removed",g_signal_connect_data ((window->priv->keyboard_socket),
("plug_removed"), (((GCallback) (keyboard_plug_removed))), (
window), ((void*)0), (GConnectFlags) 0)
1257 G_CALLBACK (keyboard_plug_removed), window)g_signal_connect_data ((window->priv->keyboard_socket),
("plug_removed"), (((GCallback) (keyboard_plug_removed))), (
window), ((void*)0), (GConnectFlags) 0)
;
1258 gtk_box_pack_start (GTK_BOX (window->priv->vbox)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->vbox)), ((gtk_box_get_type ()))))))
, window->priv->keyboard_socket, FALSE(0), FALSE(0), 0);
1259 gtk_socket_add_id (GTK_SOCKET (window->priv->keyboard_socket)((((GtkSocket*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->keyboard_socket)), ((gtk_socket_get_type
()))))))
, id);
1260}
1261
1262/* adapted from gspawn.c */
1263static int
1264wait_on_child (int pid)
1265{
1266 int status;
1267
1268wait_again:
1269 if (waitpid (pid, &status, 0) < 0)
1270 {
1271 if (errno(*__errno_location ()) == EINTR4)
1272 {
1273 goto wait_again;
1274 }
1275 else if (errno(*__errno_location ()) == ECHILD10)
1276 {
1277 ; /* do nothing, child already reaped */
1278 }
1279 else
1280 {
1281 gs_debug ("waitpid () should not fail in 'GSWindow'")gs_debug_real (__func__, "gs-window-x11.c", 1281, "waitpid () should not fail in 'GSWindow'"
)
;
1282 }
1283 }
1284
1285 return status;
1286}
1287
1288static void
1289kill_keyboard_command (GSWindow *window)
1290{
1291 if (window->priv->keyboard_pid > 0)
1292 {
1293 signal_pid (window->priv->keyboard_pid, SIGTERM15);
1294 }
1295}
1296
1297static void
1298kill_dialog_command (GSWindow *window)
1299{
1300 /* If a dialog is up we need to signal it
1301 and wait on it */
1302 if (window->priv->lock_pid > 0)
1303 {
1304 signal_pid (window->priv->lock_pid, SIGTERM15);
1305 }
1306}
1307
1308static void
1309keyboard_command_finish (GSWindow *window)
1310{
1311 g_return_if_fail (GS_IS_WINDOW (window))do{ (void)0; }while (0);
1312
1313 /* send a signal just in case */
1314 kill_keyboard_command (window);
1315
1316 gs_debug ("Keyboard finished")gs_debug_real (__func__, "gs-window-x11.c", 1316, "Keyboard finished"
)
;
1317
1318 if (window->priv->keyboard_pid > 0)
1319 {
1320 wait_on_child (window->priv->keyboard_pid);
1321
1322 g_spawn_close_pid (window->priv->keyboard_pid);
1323 window->priv->keyboard_pid = 0;
1324 }
1325}
1326
1327static gboolean
1328keyboard_command_watch (GIOChannel *source,
1329 GIOCondition condition,
1330 GSWindow *window)
1331{
1332 gboolean finished = FALSE(0);
1333
1334 g_return_val_if_fail (GS_IS_WINDOW (window), FALSE)do{ (void)0; }while (0);
1335
1336 if (condition & G_IO_IN)
1337 {
1338 GIOStatus status;
1339 GError *error = NULL((void*)0);
1340 char *line;
1341
1342 line = NULL((void*)0);
1343 status = g_io_channel_read_line (source, &line, NULL((void*)0), NULL((void*)0), &error);
1344
1345 switch (status)
1346 {
1347 case G_IO_STATUS_NORMAL:
1348 {
1349 guint32 id;
1350 char c;
1351 gs_debug ("keyboard command output: %s", line)gs_debug_real (__func__, "gs-window-x11.c", 1351, "keyboard command output: %s"
, line)
;
1352 if (1 == sscanf (line, " %" G_GUINT32_FORMAT"u" " %c", &id, &c))
1353 {
1354 create_keyboard_socket (window, id);
1355 }
1356 }
1357 break;
1358 case G_IO_STATUS_EOF:
1359 finished = TRUE(!(0));
1360 break;
1361 case G_IO_STATUS_ERROR:
1362 finished = TRUE(!(0));
1363 gs_debug ("Error reading from child: %s\n", error->message)gs_debug_real (__func__, "gs-window-x11.c", 1363, "Error reading from child: %s\n"
, error->message)
;
1364 g_error_free (error);
1365 return FALSE(0);
1366 case G_IO_STATUS_AGAIN:
1367 default:
1368 break;
1369 }
1370
1371 g_free (line);
1372 }
1373 else if (condition & G_IO_HUP)
1374 {
1375 finished = TRUE(!(0));
1376 }
1377
1378 if (finished)
1379 {
1380 window->priv->keyboard_watch_id = 0;
1381 keyboard_command_finish (window);
1382 return FALSE(0);
1383 }
1384
1385 return TRUE(!(0));
1386}
1387
1388static void
1389embed_keyboard (GSWindow *window)
1390{
1391 gboolean res;
1392
1393 if (! window->priv->keyboard_enabled
1394 || window->priv->keyboard_command == NULL((void*)0))
1395 return;
1396
1397 gs_debug ("Adding embedded keyboard widget")gs_debug_real (__func__, "gs-window-x11.c", 1397, "Adding embedded keyboard widget"
)
;
1398
1399 /* FIXME: verify command is safe */
1400
1401 gs_debug ("Running command: %s", window->priv->keyboard_command)gs_debug_real (__func__, "gs-window-x11.c", 1401, "Running command: %s"
, window->priv->keyboard_command)
;
1402
1403 res = spawn_on_window (window,
1404 window->priv->keyboard_command,
1405 &window->priv->keyboard_pid,
1406 (GIOFunc)keyboard_command_watch,
1407 window,
1408 &window->priv->keyboard_watch_id);
1409 if (! res)
1410 {
1411 gs_debug ("Could not start command: %s", window->priv->keyboard_command)gs_debug_real (__func__, "gs-window-x11.c", 1411, "Could not start command: %s"
, window->priv->keyboard_command)
;
1412 }
1413}
1414
1415static void
1416create_lock_socket (GSWindow *window,
1417 guint32 id)
1418{
1419 window->priv->lock_socket = gtk_socket_new ();
1420 window->priv->lock_box = gtk_grid_new ();
1421 gtk_widget_set_halign (GTK_WIDGET (window->priv->lock_box)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->lock_box)), ((gtk_widget_get_type ()
))))))
,
1422 GTK_ALIGN_CENTER);
1423 gtk_widget_set_valign (GTK_WIDGET (window->priv->lock_box)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->lock_box)), ((gtk_widget_get_type ()
))))))
,
1424 GTK_ALIGN_CENTER);
1425 gtk_widget_show (window->priv->lock_box);
1426 gtk_box_pack_start (GTK_BOX (window->priv->vbox)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->vbox)), ((gtk_box_get_type ()))))))
, window->priv->lock_box, TRUE(!(0)), TRUE(!(0)), 0);
1427
1428 gtk_container_add (GTK_CONTAINER (window->priv->lock_box)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->lock_box)), ((gtk_container_get_type
()))))))
, window->priv->lock_socket);
1429
1430 g_signal_connect (window->priv->lock_socket, "show",g_signal_connect_data ((window->priv->lock_socket), ("show"
), (((GCallback) (lock_socket_show))), (window), ((void*)0), (
GConnectFlags) 0)
1431 G_CALLBACK (lock_socket_show), window)g_signal_connect_data ((window->priv->lock_socket), ("show"
), (((GCallback) (lock_socket_show))), (window), ((void*)0), (
GConnectFlags) 0)
;
1432 g_signal_connect (window->priv->lock_socket, "destroy",g_signal_connect_data ((window->priv->lock_socket), ("destroy"
), (((GCallback) (lock_socket_destroyed))), (window), ((void*
)0), (GConnectFlags) 0)
1433 G_CALLBACK (lock_socket_destroyed), window)g_signal_connect_data ((window->priv->lock_socket), ("destroy"
), (((GCallback) (lock_socket_destroyed))), (window), ((void*
)0), (GConnectFlags) 0)
;
1434 g_signal_connect (window->priv->lock_socket, "plug_added",g_signal_connect_data ((window->priv->lock_socket), ("plug_added"
), (((GCallback) (lock_plug_added))), (window), ((void*)0), (
GConnectFlags) 0)
1435 G_CALLBACK (lock_plug_added), window)g_signal_connect_data ((window->priv->lock_socket), ("plug_added"
), (((GCallback) (lock_plug_added))), (window), ((void*)0), (
GConnectFlags) 0)
;
1436 g_signal_connect (window->priv->lock_socket, "plug_removed",g_signal_connect_data ((window->priv->lock_socket), ("plug_removed"
), (((GCallback) (lock_plug_removed))), (window), ((void*)0),
(GConnectFlags) 0)
1437 G_CALLBACK (lock_plug_removed), window)g_signal_connect_data ((window->priv->lock_socket), ("plug_removed"
), (((GCallback) (lock_plug_removed))), (window), ((void*)0),
(GConnectFlags) 0)
;
1438
1439 gtk_socket_add_id (GTK_SOCKET (window->priv->lock_socket)((((GtkSocket*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->lock_socket)), ((gtk_socket_get_type
()))))))
, id);
1440
1441 if (window->priv->keyboard_enabled)
1442 {
1443 embed_keyboard (window);
1444 }
1445}
1446
1447static void
1448gs_window_dialog_finish (GSWindow *window)
1449{
1450 g_return_if_fail (GS_IS_WINDOW (window))do{ (void)0; }while (0);
1451
1452 gs_debug ("Dialog finished")gs_debug_real (__func__, "gs-window-x11.c", 1452, "Dialog finished"
)
;
1453
1454 /* make sure we finish the keyboard thing too */
1455 keyboard_command_finish (window);
1456
1457 /* send a signal just in case */
1458 kill_dialog_command (window);
1459
1460 if (window->priv->lock_pid > 0)
1461 {
1462 wait_on_child (window->priv->lock_pid);
1463
1464 g_spawn_close_pid (window->priv->lock_pid);
1465 window->priv->lock_pid = 0;
1466 }
1467
1468 /* remove events for the case were we failed to show socket */
1469 remove_key_events (window);
1470}
1471
1472static void
1473maybe_kill_dialog (GSWindow *window)
1474{
1475 if (!window->priv->dialog_shake_in_progress
1476 && window->priv->dialog_quit_requested
1477 && window->priv->lock_pid > 0)
1478 {
1479 kill (window->priv->lock_pid, SIGTERM15);
1480 }
1481}
1482
1483/* very rudimentary animation for indicating an auth failure */
1484static void
1485shake_dialog (GSWindow *window)
1486{
1487 int i;
1488 guint start, end;
1489
1490 window->priv->dialog_shake_in_progress = TRUE(!(0));
1491
1492 for (i = 0; i < 8; i++)
1493 {
1494 if (i % 2 == 0)
1495 {
1496 start = 30;
1497 end = 0;
1498 }
1499 else
1500 {
1501 start = 0;
1502 end = 30;
1503 }
1504
1505 if (! window->priv->lock_box)
1506 {
1507 break;
1508 }
1509
1510 gtk_widget_set_margin_start (GTK_WIDGET (window->priv->lock_box)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->lock_box)), ((gtk_widget_get_type ()
))))))
,
1511 start);
1512 gtk_widget_set_margin_end (GTK_WIDGET (window->priv->lock_box)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->lock_box)), ((gtk_widget_get_type ()
))))))
,
1513 end);
1514
1515 while (gtk_events_pending ())
1516 {
1517 gtk_main_iteration ();
1518 }
1519
1520 g_usleep (10000);
1521 }
1522
1523 window->priv->dialog_shake_in_progress = FALSE(0);
1524 maybe_kill_dialog (window);
1525}
1526
1527static void
1528window_set_dialog_up (GSWindow *window,
1529 gboolean dialog_up)
1530{
1531 if (window->priv->dialog_up == dialog_up)
1532 {
1533 return;
1534 }
1535
1536 window->priv->dialog_up = (dialog_up != FALSE(0));
1537 g_object_notify (G_OBJECT (window)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), (((GType) ((20) << (2))))))))
, "dialog-up");
1538}
1539
1540static void
1541popdown_dialog (GSWindow *window)
1542{
1543 gs_window_dialog_finish (window);
1544
1545 gtk_widget_show (window->priv->drawing_area);
1546
1547 gs_window_clear (window);
1548 set_invisible_cursor (gtk_widget_get_window (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
), TRUE(!(0)));
1549
1550 window_set_dialog_up (window, FALSE(0));
1551
1552 /* reset the pointer positions */
1553 window->priv->last_x = -1;
1554 window->priv->last_y = -1;
1555
1556 if (window->priv->lock_box != NULL((void*)0))
1557 {
1558 gtk_container_remove (GTK_CONTAINER (window->priv->vbox)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->vbox)), ((gtk_container_get_type ())
)))))
, GTK_WIDGET (window->priv->lock_box)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->lock_box)), ((gtk_widget_get_type ()
))))))
);
1559 window->priv->lock_box = NULL((void*)0);
1560 }
1561
1562 remove_popup_dialog_idle (window);
1563 remove_command_watches (window);
1564}
1565
1566static gboolean
1567lock_command_watch (GIOChannel *source,
1568 GIOCondition condition,
1569 GSWindow *window)
1570{
1571 gboolean finished = FALSE(0);
1572
1573 g_return_val_if_fail (GS_IS_WINDOW (window), FALSE)do{ (void)0; }while (0);
1574
1575 if (condition & G_IO_IN)
1576 {
1577 GIOStatus status;
1578 GError *error = NULL((void*)0);
1579 char *line;
1580
1581 line = NULL((void*)0);
1582 status = g_io_channel_read_line (source, &line, NULL((void*)0), NULL((void*)0), &error);
1583
1584 switch (status)
1585 {
1586 case G_IO_STATUS_NORMAL:
1587 gs_debug ("command output: %s", line)gs_debug_real (__func__, "gs-window-x11.c", 1587, "command output: %s"
, line)
;
1588
1589 if (strstr (line, "WINDOW ID=") != NULL((void*)0))
1590 {
1591 guint32 id;
1592 char c;
1593 if (1 == sscanf (line, " WINDOW ID= %" G_GUINT32_FORMAT"u" " %c", &id, &c))
1594 {
1595 create_lock_socket (window, id);
1596 }
1597 }
1598 else if (strstr (line, "NOTICE=") != NULL((void*)0))
1599 {
1600 if (strstr (line, "NOTICE=AUTH FAILED") != NULL((void*)0))
1601 {
1602 shake_dialog (window);
1603 }
1604 }
1605 else if (strstr (line, "RESPONSE=") != NULL((void*)0))
1606 {
1607 if (strstr (line, "RESPONSE=OK") != NULL((void*)0))
1608 {
1609 gs_debug ("Got OK response")gs_debug_real (__func__, "gs-window-x11.c", 1609, "Got OK response"
)
;
1610 window->priv->dialog_response = DIALOG_RESPONSE_OK;
1611 }
1612 else
1613 {
1614 gs_debug ("Got CANCEL response")gs_debug_real (__func__, "gs-window-x11.c", 1614, "Got CANCEL response"
)
;
1615 window->priv->dialog_response = DIALOG_RESPONSE_CANCEL;
1616 }
1617 finished = TRUE(!(0));
1618 }
1619 else if (strstr (line, "REQUEST QUIT") != NULL((void*)0))
1620 {
1621 gs_debug ("Got request for quit")gs_debug_real (__func__, "gs-window-x11.c", 1621, "Got request for quit"
)
;
1622 window->priv->dialog_quit_requested = TRUE(!(0));
1623 maybe_kill_dialog (window);
1624 }
1625 break;
1626 case G_IO_STATUS_EOF:
1627 finished = TRUE(!(0));
1628 break;
1629 case G_IO_STATUS_ERROR:
1630 finished = TRUE(!(0));
1631 gs_debug ("Error reading from child: %s\n", error->message)gs_debug_real (__func__, "gs-window-x11.c", 1631, "Error reading from child: %s\n"
, error->message)
;
1632 g_error_free (error);
1633 return FALSE(0);
1634 case G_IO_STATUS_AGAIN:
1635 default:
1636 break;
1637 }
1638
1639 g_free (line);
1640 }
1641 else if (condition & G_IO_HUP)
1642 {
1643 finished = TRUE(!(0));
1644 }
1645
1646 if (finished)
1647 {
1648 popdown_dialog (window);
1649
1650 if (window->priv->dialog_response == DIALOG_RESPONSE_OK)
1651 {
1652 add_emit_deactivated_idle (window);
1653 }
1654
1655 window->priv->lock_watch_id = 0;
1656
1657 return FALSE(0);
1658 }
1659
1660 return TRUE(!(0));
1661}
1662
1663static gboolean
1664is_logout_enabled (GSWindow *window)
1665{
1666 double elapsed;
1667
1668 if (! window->priv->logout_enabled)
1669 {
1670 return FALSE(0);
1671 }
1672
1673 if (! window->priv->logout_command)
1674 {
1675 return FALSE(0);
1676 }
1677
1678 elapsed = g_timer_elapsed (window->priv->timer, NULL((void*)0));
1679
1680 if (window->priv->logout_timeout < (elapsed * 1000))
1681 {
1682 return TRUE(!(0));
1683 }
1684
1685 return FALSE(0);
1686}
1687
1688static gboolean
1689is_user_switch_enabled (GSWindow *window)
1690{
1691 return window->priv->user_switch_enabled;
1692}
1693
1694static void
1695popup_dialog (GSWindow *window)
1696{
1697 gboolean result;
1698 GString *command;
1699
1700 gs_debug ("Popping up dialog")gs_debug_real (__func__, "gs-window-x11.c", 1700, "Popping up dialog"
)
;
1701
1702 command = g_string_new (MATE_SCREENSAVER_DIALOG_PATH"/usr/local/libexec" "/mate-screensaver-dialog");
1703
1704 if (is_logout_enabled (window))
1705 {
1706 command = g_string_append (command, " --enable-logout");
1707 g_string_append_printf (command, " --logout-command='%s'", window->priv->logout_command);
1708 }
1709
1710 if (window->priv->status_message)
1711 {
1712 char *quoted;
1713
1714 quoted = g_shell_quote (window->priv->status_message);
1715 g_string_append_printf (command, " --status-message=%s", quoted);
1716 g_free (quoted);
1717 }
1718
1719 if (is_user_switch_enabled (window))
1720 {
1721 command = g_string_append (command, " --enable-switch");
1722 }
1723
1724 if (gs_debug_enabled ())
1725 {
1726 command = g_string_append (command, " --verbose");
1727 }
1728
1729 gtk_widget_hide (window->priv->drawing_area);
1730
1731 gtk_widget_queue_draw (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
);
1732 set_invisible_cursor (gtk_widget_get_window (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
), FALSE(0));
1733
1734 window->priv->dialog_quit_requested = FALSE(0);
1735 window->priv->dialog_shake_in_progress = FALSE(0);
1736
1737 result = spawn_on_window (window,
1738 command->str,
1739 &window->priv->lock_pid,
1740 (GIOFunc)lock_command_watch,
1741 window,
1742 &window->priv->lock_watch_id);
1743 if (! result)
1744 {
1745 gs_debug ("Could not start command: %s", command->str)gs_debug_real (__func__, "gs-window-x11.c", 1745, "Could not start command: %s"
, command->str)
;
1746 }
1747
1748 g_string_free (command, TRUE(!(0)));
1749}
1750
1751static gboolean
1752popup_dialog_idle (gpointer data)
1753{
1754 GSWindow *window = data;
1755
1756 popup_dialog (window);
1757 window->priv->popup_dialog_idle_id = 0;
1758 return FALSE(0);
1759}
1760
1761void
1762gs_window_request_unlock (GSWindow *window)
1763{
1764 g_return_if_fail (GS_IS_WINDOW (window))do{ (void)0; }while (0);
1765
1766 gs_debug ("Requesting unlock")gs_debug_real (__func__, "gs-window-x11.c", 1766, "Requesting unlock"
)
;
1767
1768 if (! gtk_widget_get_visible (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
))
1769 {
1770 gs_debug ("Request unlock but window is not visible!")gs_debug_real (__func__, "gs-window-x11.c", 1770, "Request unlock but window is not visible!"
)
;
1771 return;
1772 }
1773
1774 if (window->priv->lock_watch_id > 0)
1775 {
1776 return;
1777 }
1778
1779 if (! window->priv->lock_enabled)
1780 {
1781 add_emit_deactivated_idle (window);
1782
1783 return;
1784 }
1785
1786 if (window->priv->popup_dialog_idle_id == 0)
1787 {
1788 add_popup_dialog_idle (window);
1789 }
1790
1791 window_set_dialog_up (window, TRUE(!(0)));
1792}
1793
1794void
1795gs_window_cancel_unlock_request (GSWindow *window)
1796{
1797 /* FIXME: This is a bit of a hammer approach...
1798 * Maybe we should send a delete-event to
1799 * the plug?
1800 */
1801 g_return_if_fail (GS_IS_WINDOW (window))do{ (void)0; }while (0);
1802
1803 popdown_dialog (window);
1804}
1805
1806void
1807gs_window_set_lock_enabled (GSWindow *window,
1808 gboolean lock_enabled)
1809{
1810 g_return_if_fail (GS_IS_WINDOW (window))do{ (void)0; }while (0);
1811
1812 if (window->priv->lock_enabled == lock_enabled)
1813 {
1814 return;
1815 }
1816
1817 window->priv->lock_enabled = (lock_enabled != FALSE(0));
1818 g_object_notify (G_OBJECT (window)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), (((GType) ((20) << (2))))))))
, "lock-enabled");
1819}
1820
1821GdkDisplay *
1822gs_window_get_display (GSWindow *window)
1823{
1824 g_return_val_if_fail (GS_IS_WINDOW (window), NULL)do{ (void)0; }while (0);
1825
1826 return gtk_widget_get_display (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
);
1827}
1828
1829void
1830gs_window_set_keyboard_enabled (GSWindow *window,
1831 gboolean enabled)
1832{
1833 g_return_if_fail (GS_IS_WINDOW (window))do{ (void)0; }while (0);
1834
1835 window->priv->keyboard_enabled = (enabled != FALSE(0));
1836}
1837
1838void
1839gs_window_set_keyboard_command (GSWindow *window,
1840 const char *command)
1841{
1842 g_return_if_fail (GS_IS_WINDOW (window))do{ (void)0; }while (0);
1843
1844 g_free (window->priv->keyboard_command);
1845
1846 if (command != NULL((void*)0))
1847 {
1848 window->priv->keyboard_command = g_strdup (command);
1849 }
1850 else
1851 {
1852 window->priv->keyboard_command = NULL((void*)0);
1853 }
1854}
1855
1856void
1857gs_window_set_logout_enabled (GSWindow *window,
1858 gboolean logout_enabled)
1859{
1860 g_return_if_fail (GS_IS_WINDOW (window))do{ (void)0; }while (0);
1861
1862 window->priv->logout_enabled = (logout_enabled != FALSE(0));
1863}
1864
1865void
1866gs_window_set_user_switch_enabled (GSWindow *window,
1867 gboolean user_switch_enabled)
1868{
1869 g_return_if_fail (GS_IS_WINDOW (window))do{ (void)0; }while (0);
1870
1871 window->priv->user_switch_enabled = (user_switch_enabled != FALSE(0));
1872}
1873
1874void
1875gs_window_set_logout_timeout (GSWindow *window,
1876 glong logout_timeout)
1877{
1878 g_return_if_fail (GS_IS_WINDOW (window))do{ (void)0; }while (0);
1879
1880 if (logout_timeout < 0)
1881 {
1882 window->priv->logout_timeout = 0;
1883 }
1884 else
1885 {
1886 window->priv->logout_timeout = logout_timeout;
1887 }
1888}
1889
1890void
1891gs_window_set_logout_command (GSWindow *window,
1892 const char *command)
1893{
1894 g_return_if_fail (GS_IS_WINDOW (window))do{ (void)0; }while (0);
1895
1896 g_free (window->priv->logout_command);
1897
1898 if (command)
1899 {
1900 window->priv->logout_command = g_strdup (command);
1901 }
1902 else
1903 {
1904 window->priv->logout_command = NULL((void*)0);
1905 }
1906}
1907
1908void
1909gs_window_set_status_message (GSWindow *window,
1910 const char *status_message)
1911{
1912 g_return_if_fail (GS_IS_WINDOW (window))do{ (void)0; }while (0);
1913
1914 g_free (window->priv->status_message);
1915 window->priv->status_message = g_strdup (status_message);
1916}
1917
1918void
1919gs_window_set_monitor (GSWindow *window,
1920 GdkMonitor *monitor)
1921{
1922 g_return_if_fail (GS_IS_WINDOW (window))do{ (void)0; }while (0);
1923
1924 if (window->priv->monitor == monitor)
1925 {
1926 return;
1927 }
1928
1929 window->priv->monitor = monitor;
1930
1931 gtk_widget_queue_resize (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
);
1932
1933 g_object_notify (G_OBJECT (window)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), (((GType) ((20) << (2))))))))
, "monitor");
1934}
1935
1936GdkMonitor *
1937gs_window_get_monitor (GSWindow *window)
1938{
1939 g_return_val_if_fail (GS_IS_WINDOW (window), NULL)do{ (void)0; }while (0);
1940
1941 return window->priv->monitor;
1942}
1943
1944static void
1945gs_window_set_property (GObject *object,
1946 guint prop_id,
1947 const GValue *value,
1948 GParamSpec *pspec)
1949{
1950 GSWindow *self;
1951
1952 self = GS_WINDOW (object)((((GSWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((gs_window_get_type ()))))))
;
1953
1954 switch (prop_id)
1955 {
1956 case PROP_LOCK_ENABLED:
1957 gs_window_set_lock_enabled (self, g_value_get_boolean (value));
1958 break;
1959 case PROP_KEYBOARD_ENABLED:
1960 gs_window_set_keyboard_enabled (self, g_value_get_boolean (value));
1961 break;
1962 case PROP_KEYBOARD_COMMAND:
1963 gs_window_set_keyboard_command (self, g_value_get_string (value));
1964 break;
1965 case PROP_LOGOUT_ENABLED:
1966 gs_window_set_logout_enabled (self, g_value_get_boolean (value));
1967 break;
1968 case PROP_LOGOUT_COMMAND:
1969 gs_window_set_logout_command (self, g_value_get_string (value));
1970 break;
1971 case PROP_STATUS_MESSAGE:
1972 gs_window_set_status_message (self, g_value_get_string (value));
1973 break;
1974 case PROP_LOGOUT_TIMEOUT:
1975 gs_window_set_logout_timeout (self, g_value_get_long (value));
1976 break;
1977 case PROP_MONITOR:
1978 gs_window_set_monitor (self, g_value_get_pointer (value));
1979 break;
1980 default:
1981 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec)do { GObject *_glib__object = (GObject*) ((object)); GParamSpec
*_glib__pspec = (GParamSpec*) ((pspec)); guint _glib__property_id
= ((prop_id)); g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'"
, "gs-window-x11.c", 1981, ("property"), _glib__property_id, _glib__pspec
->name, g_type_name ((((((GTypeClass*) (((GTypeInstance*) (
_glib__pspec))->g_class))->g_type)))), (g_type_name (((
(((GTypeClass*) (((GTypeInstance*) (_glib__object))->g_class
))->g_type)))))); } while (0)
;
1982 break;
1983 }
1984}
1985
1986static void
1987gs_window_get_property (GObject *object,
1988 guint prop_id,
1989 GValue *value,
1990 GParamSpec *pspec)
1991{
1992 GSWindow *self;
1993
1994 self = GS_WINDOW (object)((((GSWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((gs_window_get_type ()))))))
;
1995
1996 switch (prop_id)
1997 {
1998 case PROP_LOCK_ENABLED:
1999 g_value_set_boolean (value, self->priv->lock_enabled);
2000 break;
2001 case PROP_KEYBOARD_ENABLED:
2002 g_value_set_boolean (value, self->priv->keyboard_enabled);
2003 break;
2004 case PROP_KEYBOARD_COMMAND:
2005 g_value_set_string (value, self->priv->keyboard_command);
2006 break;
2007 case PROP_LOGOUT_ENABLED:
2008 g_value_set_boolean (value, self->priv->logout_enabled);
2009 break;
2010 case PROP_LOGOUT_COMMAND:
2011 g_value_set_string (value, self->priv->logout_command);
2012 break;
2013 case PROP_STATUS_MESSAGE:
2014 g_value_set_string (value, self->priv->status_message);
2015 break;
2016 case PROP_LOGOUT_TIMEOUT:
2017 g_value_set_long (value, self->priv->logout_timeout);
2018 break;
2019 case PROP_MONITOR:
2020 g_value_set_pointer (value, (gpointer) self->priv->monitor);
2021 break;
2022 case PROP_OBSCURED:
2023 g_value_set_boolean (value, self->priv->obscured);
2024 break;
2025 case PROP_DIALOG_UP:
2026 g_value_set_boolean (value, self->priv->dialog_up);
2027 break;
2028 default:
2029 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec)do { GObject *_glib__object = (GObject*) ((object)); GParamSpec
*_glib__pspec = (GParamSpec*) ((pspec)); guint _glib__property_id
= ((prop_id)); g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'"
, "gs-window-x11.c", 2029, ("property"), _glib__property_id, _glib__pspec
->name, g_type_name ((((((GTypeClass*) (((GTypeInstance*) (
_glib__pspec))->g_class))->g_type)))), (g_type_name (((
(((GTypeClass*) (((GTypeInstance*) (_glib__object))->g_class
))->g_type)))))); } while (0)
;
2030 break;
2031 }
2032}
2033
2034static void
2035queue_key_event (GSWindow *window,
2036 GdkEventKey *event)
2037{
2038 /* Eat the first return, enter, escape, or space */
2039 if (window->priv->key_events == NULL((void*)0)
2040 && (event->keyval == GDK_KEY_Return0xff0d
2041 || event->keyval == GDK_KEY_KP_Enter0xff8d
2042 || event->keyval == GDK_KEY_Escape0xff1b
2043 || event->keyval == GDK_KEY_space0x020))
2044 {
2045 return;
2046 }
2047
2048 /* Only cache MAX_QUEUED_EVENTS key events. If there are any more than this then
2049 something is wrong */
2050 /* Don't queue keys that may cause focus navigation in the dialog */
2051 if (g_list_length (window->priv->key_events) < MAX_QUEUED_EVENTS16
2052 && event->keyval != GDK_KEY_Tab0xff09
2053 && event->keyval != GDK_KEY_Up0xff52
2054 && event->keyval != GDK_KEY_Down0xff54)
2055 {
2056 window->priv->key_events = g_list_prepend (window->priv->key_events,
2057 gdk_event_copy ((GdkEvent *)event));
2058 }
2059}
2060
2061static gboolean
2062maybe_handle_activity (GSWindow *window)
2063{
2064 gboolean handled;
2065
2066 handled = FALSE(0);
2067
2068 /* if we already have a socket then don't bother */
2069 if (! window->priv->lock_socket
2070 && gtk_widget_get_sensitive (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
))
2071 {
2072 g_signal_emit (window, signals [ACTIVITY], 0, &handled);
2073 }
2074
2075 return handled;
2076}
2077
2078static gboolean
2079gs_window_real_key_press_event (GtkWidget *widget,
2080 GdkEventKey *event)
2081{
2082 /*g_message ("KEY PRESS state: %u keyval %u", event->state, event->keyval);*/
2083
2084 /* Ignore brightness keys */
2085 if (event->hardware_keycode == 101 || event->hardware_keycode == 212)
2086 {
2087 gs_debug ("Ignoring brightness keys")gs_debug_real (__func__, "gs-window-x11.c", 2087, "Ignoring brightness keys"
)
;
2088 return TRUE(!(0));
2089 }
2090
2091 maybe_handle_activity (GS_WINDOW (widget)((((GSWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gs_window_get_type ()))))))
);
2092
2093 queue_key_event (GS_WINDOW (widget)((((GSWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gs_window_get_type ()))))))
, event);
2094
2095 if (GTK_WIDGET_CLASS (gs_window_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((gs_window_parent_class)), ((gtk_widget_get_type ()))))))
->key_press_event)
2096 {
2097 GTK_WIDGET_CLASS (gs_window_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((gs_window_parent_class)), ((gtk_widget_get_type ()))))))
->key_press_event (widget, event);
2098 }
2099
2100 return TRUE(!(0));
2101}
2102
2103static gboolean
2104gs_window_real_motion_notify_event (GtkWidget *widget,
2105 GdkEventMotion *event)
2106{
2107 GSWindow *window;
2108 gdouble distance;
2109 gdouble min_distance;
2110 gdouble min_percentage = 0.1;
2111 GdkDisplay *display;
2112 GdkScreen *screen;
2113
2114 window = GS_WINDOW (widget)((((GSWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gs_window_get_type ()))))))
;
2115
2116 display = gs_window_get_display (window);
2117 screen = gdk_display_get_default_screen (display);
2118 min_distance = WidthOfScreen (gdk_x11_screen_get_xscreen (screen))((gdk_x11_screen_get_xscreen (screen))->width) * min_percentage;
2119
2120 /* if the last position was not set then don't detect motion */
2121 if (window->priv->last_x < 0 || window->priv->last_y < 0)
2122 {
2123 window->priv->last_x = event->x;
2124 window->priv->last_y = event->y;
2125
2126 return FALSE(0);
2127 }
2128
2129 /* just an approximate distance */
2130 distance = MAX (ABS (window->priv->last_x - event->x),((((((window->priv->last_x - event->x) < 0) ? -(window
->priv->last_x - event->x) : (window->priv->last_x
- event->x))) > ((((window->priv->last_y - event
->y) < 0) ? -(window->priv->last_y - event->y)
: (window->priv->last_y - event->y)))) ? ((((window
->priv->last_x - event->x) < 0) ? -(window->priv
->last_x - event->x) : (window->priv->last_x - event
->x))) : ((((window->priv->last_y - event->y) <
0) ? -(window->priv->last_y - event->y) : (window->
priv->last_y - event->y))))
2131 ABS (window->priv->last_y - event->y))((((((window->priv->last_x - event->x) < 0) ? -(window
->priv->last_x - event->x) : (window->priv->last_x
- event->x))) > ((((window->priv->last_y - event
->y) < 0) ? -(window->priv->last_y - event->y)
: (window->priv->last_y - event->y)))) ? ((((window
->priv->last_x - event->x) < 0) ? -(window->priv
->last_x - event->x) : (window->priv->last_x - event
->x))) : ((((window->priv->last_y - event->y) <
0) ? -(window->priv->last_y - event->y) : (window->
priv->last_y - event->y))))
;
2132
2133 if (distance > min_distance)
2134 {
2135 maybe_handle_activity (window);
2136
2137 window->priv->last_x = -1;
2138 window->priv->last_y = -1;
2139 }
2140
2141 return FALSE(0);
2142}
2143
2144static gboolean
2145gs_window_real_button_press_event (GtkWidget *widget,
2146 GdkEventButton *event)
2147{
2148 GSWindow *window;
2149
2150 window = GS_WINDOW (widget)((((GSWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gs_window_get_type ()))))))
;
2151 maybe_handle_activity (window);
2152
2153 return FALSE(0);
2154}
2155
2156static gboolean
2157gs_window_real_scroll_event (GtkWidget *widget,
2158 GdkEventScroll *event)
2159{
2160 GSWindow *window;
2161
2162 window = GS_WINDOW (widget)((((GSWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gs_window_get_type ()))))))
;
2163 maybe_handle_activity (window);
2164
2165 return FALSE(0);
2166}
2167
2168static void
2169gs_window_real_size_request (GtkWidget *widget,
2170 GtkRequisition *requisition)
2171{
2172 GSWindow *window;
2173 GtkBin *bin;
2174 GtkWidget *child;
2175 GdkRectangle old_geometry;
2176 int position_changed = FALSE(0);
2177 int size_changed = FALSE(0);
2178
2179 window = GS_WINDOW (widget)((((GSWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gs_window_get_type ()))))))
;
2180 bin = GTK_BIN (widget)((((GtkBin*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_bin_get_type ()))))))
;
2181 child = gtk_bin_get_child (bin);
2182
2183 if (child && gtk_widget_get_visible (child))
2184 {
2185 gtk_widget_get_preferred_size (child, requisition, NULL((void*)0));
2186 }
2187
2188 old_geometry = window->priv->geometry;
2189
2190 update_geometry (window);
2191
2192 requisition->width = window->priv->geometry.width;
2193 requisition->height = window->priv->geometry.height;
2194
2195 if (! gtk_widget_get_realized (widget))
2196 {
2197 return;
2198 }
2199
2200 if (old_geometry.width != window->priv->geometry.width ||
2201 old_geometry.height != window->priv->geometry.height)
2202 {
2203 size_changed = TRUE(!(0));
2204 }
2205
2206 if (old_geometry.x != window->priv->geometry.x ||
2207 old_geometry.y != window->priv->geometry.y)
2208 {
2209 position_changed = TRUE(!(0));
2210 }
2211
2212 gs_window_move_resize_window (window, position_changed, size_changed);
2213}
2214
2215static void
2216gs_window_real_get_preferred_width (GtkWidget *widget,
2217 gint *minimal_width,
2218 gint *natural_width)
2219{
2220 GtkRequisition requisition;
2221 gs_window_real_size_request (widget, &requisition);
2222 *minimal_width = *natural_width = requisition.width;
2223}
2224
2225static void
2226gs_window_real_get_preferred_height (GtkWidget *widget,
2227 gint *minimal_height,
2228 gint *natural_height)
2229{
2230 GtkRequisition requisition;
2231 gs_window_real_size_request (widget, &requisition);
2232 *minimal_height = *natural_height = requisition.height;
2233}
2234
2235static gboolean
2236gs_window_real_grab_broken (GtkWidget *widget,
2237 GdkEventGrabBroken *event)
2238{
2239 if (event->grab_window != NULL((void*)0))
2240 {
2241 gs_debug ("Grab broken on window %X %s, new grab on window %X",gs_debug_real (__func__, "gs-window-x11.c", 2244, "Grab broken on window %X %s, new grab on window %X"
, (guint32) (gdk_x11_window_get_xid (event->window)), event
->keyboard ? "keyboard" : "pointer", (guint32) (gdk_x11_window_get_xid
(event->grab_window)))
2242 (guint32) GDK_WINDOW_XID (event->window),gs_debug_real (__func__, "gs-window-x11.c", 2244, "Grab broken on window %X %s, new grab on window %X"
, (guint32) (gdk_x11_window_get_xid (event->window)), event
->keyboard ? "keyboard" : "pointer", (guint32) (gdk_x11_window_get_xid
(event->grab_window)))
2243 event->keyboard ? "keyboard" : "pointer",gs_debug_real (__func__, "gs-window-x11.c", 2244, "Grab broken on window %X %s, new grab on window %X"
, (guint32) (gdk_x11_window_get_xid (event->window)), event
->keyboard ? "keyboard" : "pointer", (guint32) (gdk_x11_window_get_xid
(event->grab_window)))
2244 (guint32) GDK_WINDOW_XID (event->grab_window))gs_debug_real (__func__, "gs-window-x11.c", 2244, "Grab broken on window %X %s, new grab on window %X"
, (guint32) (gdk_x11_window_get_xid (event->window)), event
->keyboard ? "keyboard" : "pointer", (guint32) (gdk_x11_window_get_xid
(event->grab_window)))
;
2245 }
2246 else
2247 {
2248 gs_debug ("Grab broken on window %X %s, new grab is outside application",gs_debug_real (__func__, "gs-window-x11.c", 2250, "Grab broken on window %X %s, new grab is outside application"
, (guint32) (gdk_x11_window_get_xid (event->window)), event
->keyboard ? "keyboard" : "pointer")
2249 (guint32) GDK_WINDOW_XID (event->window),gs_debug_real (__func__, "gs-window-x11.c", 2250, "Grab broken on window %X %s, new grab is outside application"
, (guint32) (gdk_x11_window_get_xid (event->window)), event
->keyboard ? "keyboard" : "pointer")
2250 event->keyboard ? "keyboard" : "pointer")gs_debug_real (__func__, "gs-window-x11.c", 2250, "Grab broken on window %X %s, new grab is outside application"
, (guint32) (gdk_x11_window_get_xid (event->window)), event
->keyboard ? "keyboard" : "pointer")
;
2251 }
2252
2253 return FALSE(0);
2254}
2255
2256gboolean
2257gs_window_is_obscured (GSWindow *window)
2258{
2259 g_return_val_if_fail (GS_IS_WINDOW (window), FALSE)do{ (void)0; }while (0);
2260
2261 return window->priv->obscured;
2262}
2263
2264gboolean
2265gs_window_is_dialog_up (GSWindow *window)
2266{
2267 g_return_val_if_fail (GS_IS_WINDOW (window), FALSE)do{ (void)0; }while (0);
2268
2269 return window->priv->dialog_up;
2270}
2271
2272static void
2273window_set_obscured (GSWindow *window,
2274 gboolean obscured)
2275{
2276 if (window->priv->obscured == obscured)
2277 {
2278 return;
2279 }
2280
2281 window->priv->obscured = (obscured != FALSE(0));
2282 g_object_notify (G_OBJECT (window)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), (((GType) ((20) << (2))))))))
, "obscured");
2283}
2284
2285static gboolean
2286gs_window_real_visibility_notify_event (GtkWidget *widget,
2287 GdkEventVisibility *event)
2288{
2289 switch (event->state)
2290 {
2291 case GDK_VISIBILITY_FULLY_OBSCURED:
2292 window_set_obscured (GS_WINDOW (widget)((((GSWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gs_window_get_type ()))))))
, TRUE(!(0)));
2293 break;
2294 case GDK_VISIBILITY_PARTIAL:
2295 break;
2296 case GDK_VISIBILITY_UNOBSCURED:
2297 window_set_obscured (GS_WINDOW (widget)((((GSWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gs_window_get_type ()))))))
, FALSE(0));
2298 break;
2299 default:
2300 break;
2301 }
2302
2303 return FALSE(0);
2304}
2305
2306static void
2307gs_window_class_init (GSWindowClass *klass)
2308{
2309 GObjectClass *object_class = G_OBJECT_CLASS (klass)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((klass)), (((GType) ((20) << (2))))))))
;
2310 GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((klass)), ((gtk_widget_get_type ()))))))
;
2311
2312 object_class->finalize = gs_window_finalize;
2313 object_class->get_property = gs_window_get_property;
2314 object_class->set_property = gs_window_set_property;
2315
2316 widget_class->show = gs_window_real_show;
2317 widget_class->hide = gs_window_real_hide;
2318 widget_class->draw = gs_window_real_draw;
2319 widget_class->realize = gs_window_real_realize;
2320 widget_class->unrealize = gs_window_real_unrealize;
2321 widget_class->key_press_event = gs_window_real_key_press_event;
2322 widget_class->motion_notify_event = gs_window_real_motion_notify_event;
2323 widget_class->button_press_event = gs_window_real_button_press_event;
2324 widget_class->scroll_event = gs_window_real_scroll_event;
2325 widget_class->get_preferred_width = gs_window_real_get_preferred_width;
2326 widget_class->get_preferred_height = gs_window_real_get_preferred_height;
2327 widget_class->grab_broken_event = gs_window_real_grab_broken;
2328 widget_class->visibility_notify_event = gs_window_real_visibility_notify_event;
2329
2330 signals [ACTIVITY] =
2331 g_signal_new ("activity",
2332 G_TYPE_FROM_CLASS (object_class)(((GTypeClass*) (object_class))->g_type),
2333 G_SIGNAL_RUN_LAST,
2334 G_STRUCT_OFFSET (GSWindowClass, activity)((glong) __builtin_offsetof(GSWindowClass, activity)),
2335 NULL((void*)0),
2336 NULL((void*)0),
2337 gs_marshal_BOOLEAN__VOID,
2338 G_TYPE_BOOLEAN((GType) ((5) << (2))),
2339 0);
2340 signals [DEACTIVATED] =
2341 g_signal_new ("deactivated",
2342 G_TYPE_FROM_CLASS (object_class)(((GTypeClass*) (object_class))->g_type),
2343 G_SIGNAL_RUN_LAST,
2344 G_STRUCT_OFFSET (GSWindowClass, deactivated)((glong) __builtin_offsetof(GSWindowClass, deactivated)),
2345 NULL((void*)0),
2346 NULL((void*)0),
2347 g_cclosure_marshal_VOID__VOID,
2348 G_TYPE_NONE((GType) ((1) << (2))),
2349 0);
2350
2351 g_object_class_install_property (object_class,
2352 PROP_OBSCURED,
2353 g_param_spec_boolean ("obscured",
2354 NULL((void*)0),
2355 NULL((void*)0),
2356 FALSE(0),
2357 G_PARAM_READABLE));
2358 g_object_class_install_property (object_class,
2359 PROP_DIALOG_UP,
2360 g_param_spec_boolean ("dialog-up",
2361 NULL((void*)0),
2362 NULL((void*)0),
2363 FALSE(0),
2364 G_PARAM_READABLE));
2365 g_object_class_install_property (object_class,
2366 PROP_LOCK_ENABLED,
2367 g_param_spec_boolean ("lock-enabled",
2368 NULL((void*)0),
2369 NULL((void*)0),
2370 FALSE(0),
2371 G_PARAM_READWRITE));
2372 g_object_class_install_property (object_class,
2373 PROP_LOGOUT_ENABLED,
2374 g_param_spec_boolean ("logout-enabled",
2375 NULL((void*)0),
2376 NULL((void*)0),
2377 FALSE(0),
2378 G_PARAM_READWRITE));
2379 g_object_class_install_property (object_class,
2380 PROP_LOGOUT_TIMEOUT,
2381 g_param_spec_long ("logout-timeout",
2382 NULL((void*)0),
2383 NULL((void*)0),
2384 -1,
2385 G_MAXLONG9223372036854775807L,
2386 0,
2387 G_PARAM_READWRITE));
2388 g_object_class_install_property (object_class,
2389 PROP_LOGOUT_COMMAND,
2390 g_param_spec_string ("logout-command",
2391 NULL((void*)0),
2392 NULL((void*)0),
2393 NULL((void*)0),
2394 G_PARAM_READWRITE));
2395 g_object_class_install_property (object_class,
2396 PROP_STATUS_MESSAGE,
2397 g_param_spec_string ("status-message",
2398 NULL((void*)0),
2399 NULL((void*)0),
2400 NULL((void*)0),
2401 G_PARAM_READWRITE));
2402 g_object_class_install_property (object_class,
2403 PROP_KEYBOARD_ENABLED,
2404 g_param_spec_boolean ("keyboard-enabled",
2405 NULL((void*)0),
2406 NULL((void*)0),
2407 FALSE(0),
2408 G_PARAM_READWRITE));
2409 g_object_class_install_property (object_class,
2410 PROP_KEYBOARD_COMMAND,
2411 g_param_spec_string ("keyboard-command",
2412 NULL((void*)0),
2413 NULL((void*)0),
2414 NULL((void*)0),
2415 G_PARAM_READWRITE));
2416
2417 g_object_class_install_property (object_class,
2418 PROP_MONITOR,
2419 g_param_spec_pointer ("monitor",
2420 "Gdk monitor",
2421 "The monitor (in terms of Gdk) which the window is on",
2422 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
2423}
2424
2425static void
2426create_info_bar (GSWindow *window)
2427{
2428 window->priv->info_bar = gtk_info_bar_new ();
2429 gtk_widget_set_no_show_all (window->priv->info_bar, TRUE(!(0)));
2430 gtk_box_pack_end (GTK_BOX (window->priv->vbox)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->vbox)), ((gtk_box_get_type ()))))))
, window->priv->info_bar, FALSE(0), FALSE(0), 0);
2431}
2432
2433static gboolean
2434on_drawing_area_draw (GtkWidget *widget,
2435 cairo_t *cr)
2436{
2437 cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
2438 cairo_set_source_rgb (cr, 0, 0, 0);
2439 cairo_paint (cr);
2440
2441 return FALSE(0);
2442}
2443
2444static void
2445gs_window_init (GSWindow *window)
2446{
2447 window->priv = gs_window_get_instance_private (window);
2448
2449 window->priv->geometry.x = -1;
2450 window->priv->geometry.y = -1;
2451 window->priv->geometry.width = -1;
2452 window->priv->geometry.height = -1;
2453
2454 window->priv->last_x = -1;
2455 window->priv->last_y = -1;
2456
2457 gtk_window_set_decorated (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
, FALSE(0));
2458
2459 gtk_window_set_skip_taskbar_hint (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
, TRUE(!(0)));
2460 gtk_window_set_skip_pager_hint (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
, TRUE(!(0)));
2461
2462 gtk_window_set_keep_above (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
, TRUE(!(0)));
2463
2464 gtk_window_fullscreen (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
);
2465
2466 gtk_widget_set_events (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
,
2467 gtk_widget_get_events (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
)
2468 | GDK_POINTER_MOTION_MASK
2469 | GDK_BUTTON_PRESS_MASK
2470 | GDK_BUTTON_RELEASE_MASK
2471 | GDK_KEY_PRESS_MASK
2472 | GDK_KEY_RELEASE_MASK
2473 | GDK_EXPOSURE_MASK
2474 | GDK_VISIBILITY_NOTIFY_MASK
2475 | GDK_ENTER_NOTIFY_MASK
2476 | GDK_LEAVE_NOTIFY_MASK);
2477
2478 window->priv->vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
2479 gtk_widget_show (window->priv->vbox);
2480 gtk_container_add (GTK_CONTAINER (window)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_container_get_type ()))))))
, window->priv->vbox);
2481
2482 window->priv->drawing_area = gtk_drawing_area_new ();
2483 gtk_widget_show (window->priv->drawing_area);
2484 gtk_widget_set_app_paintable (window->priv->drawing_area, TRUE(!(0)));
2485 gtk_box_pack_start (GTK_BOX (window->priv->vbox)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->vbox)), ((gtk_box_get_type ()))))))
,
2486 window->priv->drawing_area, TRUE(!(0)), TRUE(!(0)), 0);
2487 g_signal_connect (window->priv->drawing_area,g_signal_connect_data ((window->priv->drawing_area), ("draw"
), (((GCallback) (on_drawing_area_draw))), (((void*)0)), ((void
*)0), (GConnectFlags) 0)
2488 "draw",g_signal_connect_data ((window->priv->drawing_area), ("draw"
), (((GCallback) (on_drawing_area_draw))), (((void*)0)), ((void
*)0), (GConnectFlags) 0)
2489 G_CALLBACK (on_drawing_area_draw),g_signal_connect_data ((window->priv->drawing_area), ("draw"
), (((GCallback) (on_drawing_area_draw))), (((void*)0)), ((void
*)0), (GConnectFlags) 0)
2490 NULL)g_signal_connect_data ((window->priv->drawing_area), ("draw"
), (((GCallback) (on_drawing_area_draw))), (((void*)0)), ((void
*)0), (GConnectFlags) 0)
;
2491 create_info_bar (window);
2492
2493}
2494
2495static void
2496remove_command_watches (GSWindow *window)
2497{
2498 if (window->priv->lock_watch_id != 0)
2499 {
2500 g_source_remove (window->priv->lock_watch_id);
2501 window->priv->lock_watch_id = 0;
2502 }
2503 if (window->priv->keyboard_watch_id != 0)
2504 {
2505 g_source_remove (window->priv->keyboard_watch_id);
2506 window->priv->keyboard_watch_id = 0;
2507 }
2508}
2509
2510static void
2511gs_window_finalize (GObject *object)
2512{
2513 GSWindow *window;
2514
2515 g_return_if_fail (object != NULL)do{ (void)0; }while (0);
2516 g_return_if_fail (GS_IS_WINDOW (object))do{ (void)0; }while (0);
2517
2518 window = GS_WINDOW (object)((((GSWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((gs_window_get_type ()))))))
;
2519
2520 g_return_if_fail (window->priv != NULL)do{ (void)0; }while (0);
2521
2522 g_free (window->priv->logout_command);
2523 g_free (window->priv->keyboard_command);
2524
2525 if (window->priv->info_bar_timer_id > 0)
2526 {
2527 g_source_remove (window->priv->info_bar_timer_id);
2528 window->priv->info_bar_timer_id = 0;
2529 }
2530
2531 remove_watchdog_timer (window);
2532 remove_popup_dialog_idle (window);
2533
2534 if (window->priv->timer)
2535 {
2536 g_timer_destroy (window->priv->timer);
2537 }
2538
2539 remove_key_events (window);
2540
2541 remove_command_watches (window);
2542
2543 gs_window_dialog_finish (window);
2544
2545 if (window->priv->background_surface)
2546 {
2547 cairo_surface_destroy (window->priv->background_surface);
2548 }
2549
2550 G_OBJECT_CLASS (gs_window_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((gs_window_parent_class)), (((GType) ((20) << (2)))
)))))
->finalize (object);
2551}
2552
2553GSWindow *
2554gs_window_new (GdkMonitor *monitor,
2555 gboolean lock_enabled)
2556{
2557 GObject *result;
2558 GdkDisplay *display = gdk_monitor_get_display (monitor);
2559 GdkScreen *screen = gdk_display_get_default_screen (display);
2560
2561 result = g_object_new (GS_TYPE_WINDOW(gs_window_get_type ()),
2562 "type", GTK_WINDOW_POPUP,
2563 "screen", screen,
2564 "monitor", monitor,
2565 "lock-enabled", lock_enabled,
2566 "app-paintable", TRUE(!(0)),
2567 NULL((void*)0));
2568
2569 return GS_WINDOW (result)((((GSWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((result)), ((gs_window_get_type ()))))))
;
2570}
diff --git a/2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-2084b3.html b/2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-2084b3.html new file mode 100644 index 0000000..48168ab --- /dev/null +++ b/2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-2084b3.html @@ -0,0 +1,898 @@ + + + +xdg-user-dir-lookup.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:avers/xdg-user-dir-lookup.c
Warning:line 91, column 10
Out of bound memory access (accessed memory precedes memory block)
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name xdg-user-dir-lookup.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/savers -resource-dir /usr/lib64/clang/14.0.5 -D HAVE_CONFIG_H -I . -I .. -I . -I . -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -D LIBEXECDIR="/usr/local/libexec" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -internal-isystem /usr/lib64/clang/14.0.5/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/12/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdebug-compilation-dir=/rootdir/savers -ferror-limit 19 -fgnuc-version=4.2.1 -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2022-11-11-203102-6531-1 -x c xdg-user-dir-lookup.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/*
2 This file is not licenced under the GPL like the rest of the code.
3 Its is under the MIT license, to encourage reuse by cut-and-paste.
4
5 Copyright (c) 2007 Red Hat, inc
6 Copyright (C) 2012-2021 MATE Developers
7
8 Permission is hereby granted, free of charge, to any person
9 obtaining a copy of this software and associated documentation files
10 (the "Software"), to deal in the Software without restriction,
11 including without limitation the rights to use, copy, modify, merge,
12 publish, distribute, sublicense, and/or sell copies of the Software,
13 and to permit persons to whom the Software is furnished to do so,
14 subject to the following conditions:
15
16 The above copyright notice and this permission notice shall be
17 included in all copies or substantial portions of the Software.
18
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
23 BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
24 ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
25 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26 SOFTWARE.
27*/
28
29#include <stdio.h>
30#include <stdlib.h>
31#include <string.h>
32
33#include "xdg-user-dir-lookup.h"
34
35char *
36xdg_user_dir_lookup (const char *type)
37{
38 FILE *file;
39 char *home_dir, *config_home, *config_file;
40 char buffer[512];
41 char *user_dir;
42 char *p, *d;
43 int relative;
44
45 home_dir = getenv ("HOME");
46
47 if (home_dir
0.1
'home_dir' is not equal to NULL
== NULL((void*)0))
1
Taking false branch
48 return strdup ("/tmp");
49
50 config_home = getenv ("XDG_CONFIG_HOME");
51 if (config_home
1.1
'config_home' is equal to NULL
== NULL((void*)0) || config_home[0] == 0)
52 {
53 config_file = malloc (strlen (home_dir) + strlen ("/.config/user-dirs.dirs") + 1);
54 strcpy (config_file, home_dir);
55 strcat (config_file, "/.config/user-dirs.dirs");
56 }
57 else
58 {
59 config_file = malloc (strlen (config_home) + strlen ("/user-dirs.dirs") + 1);
60 strcpy (config_file, config_home);
61 strcat (config_file, "/user-dirs.dirs");
62 }
63
64 file = fopen (config_file, "r");
65 free (config_file);
66 if (file == NULL((void*)0))
2
Assuming 'file' is not equal to NULL
3
Taking false branch
67 goto error;
68
69 user_dir = NULL((void*)0);
70 while (fgets (buffer, sizeof (buffer), file))
4
Loop condition is true. Entering loop body
71 {
72 /* Remove newline at end */
73 size_t len = strlen (buffer);
74 if (len != 0 && buffer[len-1] == '\n')
5
Assuming 'len' is equal to 0
75 buffer[len-1] = 0;
76
77 p = buffer;
78 while (*p == ' ' || *p == '\t')
6
Assuming the condition is false
7
Assuming the condition is false
8
Loop condition is false. Execution continues on line 81
79 p++;
80
81 if (strncmp (p, "XDG_", 4) != 0)
9
Assuming the condition is false
10
Taking false branch
82 continue;
83 p += 4;
84 if (strncmp (p, type, strlen (type)) != 0)
11
Assuming the condition is false
12
Taking false branch
85 continue;
86 p += strlen (type);
87 if (strncmp (p, "_DIR", 4) != 0)
13
Assuming the condition is false
14
Taking false branch
88 continue;
89 p += 4;
90
91 while (*p == ' ' || *p == '\t')
15
Out of bound memory access (accessed memory precedes memory block)
92 p++;
93
94 if (*p != '=')
95 continue;
96 p++;
97
98 while (*p == ' ' || *p == '\t')
99 p++;
100
101 if (*p != '"')
102 continue;
103 p++;
104
105 relative = 0;
106 if (strncmp (p, "$HOME/", 6) == 0)
107 {
108 p += 6;
109 relative = 1;
110 }
111 else if (*p != '/')
112 continue;
113
114 if (relative)
115 {
116 user_dir = malloc (strlen (home_dir) + 1 + strlen (p) + 1);
117 strcpy (user_dir, home_dir);
118 strcat (user_dir, "/");
119 }
120 else
121 {
122 user_dir = malloc (strlen (p) + 1);
123 *user_dir = 0;
124 }
125
126 d = user_dir + strlen (user_dir);
127 while (*p && *p != '"')
128 {
129 if ((*p == '\\') && (*(p+1) != 0))
130 p++;
131 *d++ = *p++;
132 }
133 *d = 0;
134 }
135 fclose (file);
136
137 if (user_dir)
138 return user_dir;
139
140error:
141 /* Special case desktop for historical compatibility */
142 if (strcmp (type, "DESKTOP") == 0)
143 {
144 user_dir = malloc (strlen (home_dir) + strlen ("/Desktop") + 1);
145 strcpy (user_dir, home_dir);
146 strcat (user_dir, "/Desktop");
147 return user_dir;
148 }
149 else
150 return strdup (home_dir);
151}
152
153#ifdef STANDALONE
154
155int
156main (int argc, char *argv[])
157{
158 if (argc != 2)
159 {
160 fprintf (stderrstderr, "Usage %s <dir-type>\n", argv[0]);
161 exit (1);
162 }
163
164 printf ("%s\n", xdg_user_dir_lookup (argv[1]));
165 return 0;
166}
167
168#endif
diff --git a/2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-24761d.html b/2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-24761d.html new file mode 100644 index 0000000..c7969ed --- /dev/null +++ b/2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-24761d.html @@ -0,0 +1,1355 @@ + + + +gs-watcher-x11.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rc/gs-watcher-x11.c
Warning:line 599, column 2
Value stored to 'desired_allow_exp' is never read
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name gs-watcher-x11.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/14.0.5 -D HAVE_CONFIG_H -I . -I .. -I . -I . -D MATEMENU_I_KNOW_THIS_IS_UNSTABLE -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/dconf -I /usr/include/mate-menus -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/dconf -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/dconf -I /usr/include/mate-menus -D PREFIX="/usr/local" -D BINDIR="/usr/local/bin" -D LIBDIR="/usr/local/lib" -D LIBEXECDIR="/usr/local/libexec" -D DATADIR="/usr/local/share" -D SYSCONFDIR="/usr/local/etc" -D MATELOCALEDIR="/usr/local/share/locale" -D PKGLIBEXECDIR="/usr/local/libexec/mate-screensaver" -D SAVERDIR="/usr/local/libexec/mate-screensaver" -D THEMESDIR="/usr/local/share/mate-screensaver/themes" -D GTKBUILDERDIR="/usr/local/share/mate-screensaver" -D MATE_SCREENSAVER_GL_HELPER_PATH="/usr/local/libexec/mate-screensaver-gl-helper" -D PAM_SERVICE_NAME="mate-screensaver" -D G_DISABLE_ASSERT -D G_DISABLE_CHECKS -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -internal-isystem /usr/lib64/clang/14.0.5/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/12/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2022-11-11-203102-6531-1 -x c gs-watcher-x11.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
2 *
3 * Copyright (C) 2004-2006 William Jon McCann <mccann@jhu.edu>
4 * Copyright (C) 2008 Red Hat, Inc.
5 * Copyright (C) 2012-2021 MATE Developers
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
20 *
21 * Authors: William Jon McCann <mccann@jhu.edu>
22 *
23 */
24
25#include "config.h"
26#include <stdlib.h>
27#include <stdio.h>
28#include <time.h>
29#include <errno(*__errno_location ()).h>
30
31#include <string.h>
32#include <gdk/gdkx.h>
33
34#include <dbus/dbus.h>
35#include <dbus/dbus-glib.h>
36
37#include "gs-watcher.h"
38#include "gs-marshal.h"
39#include "gs-debug.h"
40
41static void gs_watcher_finalize (GObject *object);
42
43static gboolean watchdog_timer (GSWatcher *watcher);
44
45struct GSWatcherPrivate
46{
47 /* settings */
48 guint enabled : 1;
49 guint delta_notice_timeout;
50
51 /* state */
52 guint active : 1;
53 guint idle : 1;
54 guint idle_notice : 1;
55
56 guint idle_id;
57 char *status_message;
58
59 DBusGProxy *presence_proxy;
60 guint watchdog_timer_id;
61};
62
63enum
64{
65 PROP_0,
66 PROP_STATUS_MESSAGE
67};
68
69enum
70{
71 IDLE_CHANGED,
72 IDLE_NOTICE_CHANGED,
73 LAST_SIGNAL
74};
75
76static guint signals [LAST_SIGNAL] = { 0, };
77
78G_DEFINE_TYPE_WITH_PRIVATE (GSWatcher, gs_watcher, G_TYPE_OBJECT)static void gs_watcher_init (GSWatcher *self); static void gs_watcher_class_init
(GSWatcherClass *klass); static GType gs_watcher_get_type_once
(void); static gpointer gs_watcher_parent_class = ((void*)0)
; static gint GSWatcher_private_offset; static void gs_watcher_class_intern_init
(gpointer klass) { gs_watcher_parent_class = g_type_class_peek_parent
(klass); if (GSWatcher_private_offset != 0) g_type_class_adjust_private_offset
(klass, &GSWatcher_private_offset); gs_watcher_class_init
((GSWatcherClass*) klass); } __attribute__ ((__unused__)) static
inline gpointer gs_watcher_get_instance_private (GSWatcher *
self) { return (((gpointer) ((guint8*) (self) + (glong) (GSWatcher_private_offset
)))); } GType gs_watcher_get_type (void) { static gsize static_g_define_type_id
= 0; if ((__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); (void
) (0 ? (gpointer) *(&static_g_define_type_id) : ((void*)0
)); (!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
(*(&static_g_define_type_id)) gapg_temp_newval; __typeof__
((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id
); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5)
; gapg_temp_newval; })) && g_once_init_enter (&static_g_define_type_id
)); }))) { GType g_define_type_id = gs_watcher_get_type_once (
); (__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); 0 ?
(void) (*(&static_g_define_type_id) = (g_define_type_id)
) : (void) 0; g_once_init_leave ((&static_g_define_type_id
), (gsize) (g_define_type_id)); })); } return static_g_define_type_id
; } __attribute__ ((__noinline__)) static GType gs_watcher_get_type_once
(void) { GType g_define_type_id = g_type_register_static_simple
(((GType) ((20) << (2))), g_intern_static_string ("GSWatcher"
), sizeof (GSWatcherClass), (GClassInitFunc)(void (*)(void)) gs_watcher_class_intern_init
, sizeof (GSWatcher), (GInstanceInitFunc)(void (*)(void)) gs_watcher_init
, (GTypeFlags) 0); { {{ GSWatcher_private_offset = g_type_add_instance_private
(g_define_type_id, sizeof (GSWatcherPrivate)); };} } return g_define_type_id
; }
79
80static void
81remove_watchdog_timer (GSWatcher *watcher)
82{
83 if (watcher->priv->watchdog_timer_id != 0)
84 {
85 g_source_remove (watcher->priv->watchdog_timer_id);
86 watcher->priv->watchdog_timer_id = 0;
87 }
88}
89
90static void
91add_watchdog_timer (GSWatcher *watcher,
92 guint timeout)
93{
94 watcher->priv->watchdog_timer_id = g_timeout_add (timeout,
95 (GSourceFunc)watchdog_timer,
96 watcher);
97}
98
99static void
100gs_watcher_get_property (GObject *object,
101 guint prop_id,
102 GValue *value,
103 GParamSpec *pspec)
104{
105 GSWatcher *self;
106
107 self = GS_WATCHER (object)((((GSWatcher*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((gs_watcher_get_type ()))))))
;
108
109 switch (prop_id)
110 {
111 case PROP_STATUS_MESSAGE:
112 g_value_set_string (value, self->priv->status_message);
113 break;
114 default:
115 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec)do { GObject *_glib__object = (GObject*) ((object)); GParamSpec
*_glib__pspec = (GParamSpec*) ((pspec)); guint _glib__property_id
= ((prop_id)); g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'"
, "gs-watcher-x11.c", 115, ("property"), _glib__property_id, _glib__pspec
->name, g_type_name ((((((GTypeClass*) (((GTypeInstance*) (
_glib__pspec))->g_class))->g_type)))), (g_type_name (((
(((GTypeClass*) (((GTypeInstance*) (_glib__object))->g_class
))->g_type)))))); } while (0)
;
116 break;
117 }
118}
119
120static void
121set_status_text (GSWatcher *watcher,
122 const char *text)
123{
124 g_free (watcher->priv->status_message);
125
126 watcher->priv->status_message = g_strdup (text);
127 g_object_notify (G_OBJECT (watcher)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((watcher)), (((GType) ((20) << (2))))))))
, "status-message");
128}
129
130static void
131gs_watcher_set_property (GObject *object,
132 guint prop_id,
133 const GValue *value,
134 GParamSpec *pspec)
135{
136 GSWatcher *self;
137
138 self = GS_WATCHER (object)((((GSWatcher*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((gs_watcher_get_type ()))))))
;
139
140 switch (prop_id)
141 {
142 case PROP_STATUS_MESSAGE:
143 set_status_text (self, g_value_get_string (value));
144 break;
145 default:
146 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec)do { GObject *_glib__object = (GObject*) ((object)); GParamSpec
*_glib__pspec = (GParamSpec*) ((pspec)); guint _glib__property_id
= ((prop_id)); g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'"
, "gs-watcher-x11.c", 146, ("property"), _glib__property_id, _glib__pspec
->name, g_type_name ((((((GTypeClass*) (((GTypeInstance*) (
_glib__pspec))->g_class))->g_type)))), (g_type_name (((
(((GTypeClass*) (((GTypeInstance*) (_glib__object))->g_class
))->g_type)))))); } while (0)
;
147 break;
148 }
149}
150
151static void
152gs_watcher_class_init (GSWatcherClass *klass)
153{
154 GObjectClass *object_class = G_OBJECT_CLASS (klass)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((klass)), (((GType) ((20) << (2))))))))
;
155
156 object_class->finalize = gs_watcher_finalize;
157 object_class->get_property = gs_watcher_get_property;
158 object_class->set_property = gs_watcher_set_property;
159
160 g_object_class_install_property (object_class,
161 PROP_STATUS_MESSAGE,
162 g_param_spec_string ("status-message",
163 NULL((void*)0),
164 NULL((void*)0),
165 NULL((void*)0),
166 G_PARAM_READWRITE));
167
168 signals [IDLE_CHANGED] =
169 g_signal_new ("idle-changed",
170 G_TYPE_FROM_CLASS (object_class)(((GTypeClass*) (object_class))->g_type),
171 G_SIGNAL_RUN_LAST,
172 G_STRUCT_OFFSET (GSWatcherClass, idle_changed)((glong) __builtin_offsetof(GSWatcherClass, idle_changed)),
173 NULL((void*)0),
174 NULL((void*)0),
175 gs_marshal_BOOLEAN__BOOLEAN,
176 G_TYPE_BOOLEAN((GType) ((5) << (2))),
177 1, G_TYPE_BOOLEAN((GType) ((5) << (2))));
178 signals [IDLE_NOTICE_CHANGED] =
179 g_signal_new ("idle-notice-changed",
180 G_TYPE_FROM_CLASS (object_class)(((GTypeClass*) (object_class))->g_type),
181 G_SIGNAL_RUN_LAST,
182 G_STRUCT_OFFSET (GSWatcherClass, idle_notice_changed)((glong) __builtin_offsetof(GSWatcherClass, idle_notice_changed
))
,
183 NULL((void*)0),
184 NULL((void*)0),
185 gs_marshal_BOOLEAN__BOOLEAN,
186 G_TYPE_BOOLEAN((GType) ((5) << (2))),
187 1, G_TYPE_BOOLEAN((GType) ((5) << (2))));
188}
189
190static gboolean
191_gs_watcher_set_session_idle_notice (GSWatcher *watcher,
192 gboolean in_effect)
193{
194 gboolean res;
195
196 res = FALSE(0);
197
198 if (in_effect != watcher->priv->idle_notice)
199 {
200
201 g_signal_emit (watcher, signals [IDLE_NOTICE_CHANGED], 0, in_effect, &res);
202 if (res)
203 {
204 gs_debug ("Changing idle notice state: %d", in_effect)gs_debug_real (__func__, "gs-watcher-x11.c", 204, "Changing idle notice state: %d"
, in_effect)
;
205
206 watcher->priv->idle_notice = (in_effect != FALSE(0));
207 }
208 else
209 {
210 gs_debug ("Idle notice signal not handled: %d", in_effect)gs_debug_real (__func__, "gs-watcher-x11.c", 210, "Idle notice signal not handled: %d"
, in_effect)
;
211 }
212 }
213
214 return res;
215}
216
217static gboolean
218_gs_watcher_set_session_idle (GSWatcher *watcher,
219 gboolean is_idle)
220{
221 gboolean res;
222
223 res = FALSE(0);
224
225 if (is_idle != watcher->priv->idle)
226 {
227
228 g_signal_emit (watcher, signals [IDLE_CHANGED], 0, is_idle, &res);
229 if (res)
230 {
231 gs_debug ("Changing idle state: %d", is_idle)gs_debug_real (__func__, "gs-watcher-x11.c", 231, "Changing idle state: %d"
, is_idle)
;
232
233 watcher->priv->idle = (is_idle != FALSE(0));
234 }
235 else
236 {
237 gs_debug ("Idle changed signal not handled: %d", is_idle)gs_debug_real (__func__, "gs-watcher-x11.c", 237, "Idle changed signal not handled: %d"
, is_idle)
;
238 }
239 }
240
241 return res;
242}
243
244gboolean
245gs_watcher_get_active (GSWatcher *watcher)
246{
247 gboolean active;
248
249 g_return_val_if_fail (GS_IS_WATCHER (watcher), FALSE)do{ (void)0; }while (0);
250
251 active = watcher->priv->active;
252
253 return active;
254}
255
256static void
257_gs_watcher_reset_state (GSWatcher *watcher)
258{
259 watcher->priv->idle = FALSE(0);
260 watcher->priv->idle_notice = FALSE(0);
261}
262
263static gboolean
264_gs_watcher_set_active_internal (GSWatcher *watcher,
265 gboolean active)
266{
267 if (active != watcher->priv->active)
268 {
269 /* reset state */
270 _gs_watcher_reset_state (watcher);
271
272 watcher->priv->active = (active != FALSE(0));
273 }
274
275 return TRUE(!(0));
276}
277
278gboolean
279gs_watcher_set_active (GSWatcher *watcher,
280 gboolean active)
281{
282 g_return_val_if_fail (GS_IS_WATCHER (watcher), FALSE)do{ (void)0; }while (0);
283
284 gs_debug ("turning watcher: %s", active ? "ON" : "OFF")gs_debug_real (__func__, "gs-watcher-x11.c", 284, "turning watcher: %s"
, active ? "ON" : "OFF")
;
285
286 if (watcher->priv->active == active)
287 {
288 gs_debug ("Idle detection is already %s",gs_debug_real (__func__, "gs-watcher-x11.c", 289, "Idle detection is already %s"
, active ? "active" : "inactive")
289 active ? "active" : "inactive")gs_debug_real (__func__, "gs-watcher-x11.c", 289, "Idle detection is already %s"
, active ? "active" : "inactive")
;
290 return FALSE(0);
291 }
292
293 if (! watcher->priv->enabled)
294 {
295 gs_debug ("Idle detection is disabled, cannot activate")gs_debug_real (__func__, "gs-watcher-x11.c", 295, "Idle detection is disabled, cannot activate"
)
;
296 return FALSE(0);
297 }
298
299 return _gs_watcher_set_active_internal (watcher, active);
300}
301
302gboolean
303gs_watcher_set_enabled (GSWatcher *watcher,
304 gboolean enabled)
305{
306 g_return_val_if_fail (GS_IS_WATCHER (watcher), FALSE)do{ (void)0; }while (0);
307
308 if (watcher->priv->enabled != enabled)
309 {
310 gboolean is_active = gs_watcher_get_active (watcher);
311
312 watcher->priv->enabled = (enabled != FALSE(0));
313
314 /* if we are disabling the watcher and we are
315 active shut it down */
316 if (! enabled && is_active)
317 {
318 _gs_watcher_set_active_internal (watcher, FALSE(0));
319 }
320 }
321
322 return TRUE(!(0));
323}
324
325gboolean
326gs_watcher_get_enabled (GSWatcher *watcher)
327{
328 gboolean enabled;
329
330 g_return_val_if_fail (GS_IS_WATCHER (watcher), FALSE)do{ (void)0; }while (0);
331
332 enabled = watcher->priv->enabled;
333
334 return enabled;
335}
336
337static gboolean
338on_idle_timeout (GSWatcher *watcher)
339{
340 gboolean res;
341
342 res = _gs_watcher_set_session_idle (watcher, TRUE(!(0)));
343
344 _gs_watcher_set_session_idle_notice (watcher, FALSE(0));
345
346 /* try again if we failed i guess */
347 return !res;
348}
349
350static void
351set_status (GSWatcher *watcher,
352 guint status)
353{
354 gboolean is_idle;
355
356 if (! watcher->priv->active)
357 {
358 gs_debug ("GSWatcher: not active, ignoring status changes")gs_debug_real (__func__, "gs-watcher-x11.c", 358, "GSWatcher: not active, ignoring status changes"
)
;
359 return;
360 }
361
362 is_idle = (status == 3);
363
364 if (!is_idle && !watcher->priv->idle_notice)
365 {
366 /* no change in idleness */
367 return;
368 }
369
370 if (is_idle)
371 {
372 _gs_watcher_set_session_idle_notice (watcher, is_idle);
373 /* queue an activation */
374 if (watcher->priv->idle_id > 0)
375 {
376 g_source_remove (watcher->priv->idle_id);
377 }
378 watcher->priv->idle_id = g_timeout_add (watcher->priv->delta_notice_timeout,
379 (GSourceFunc)on_idle_timeout,
380 watcher);
381 }
382 else
383 {
384 /* cancel notice too */
385 if (watcher->priv->idle_id > 0)
386 {
387 g_source_remove (watcher->priv->idle_id);
388 watcher->priv->idle_id = 0;
389 }
390 _gs_watcher_set_session_idle (watcher, FALSE(0));
391 _gs_watcher_set_session_idle_notice (watcher, FALSE(0));
392 }
393}
394
395static void
396on_presence_status_changed (DBusGProxy *presence_proxy,
397 guint status,
398 GSWatcher *watcher)
399{
400 set_status (watcher, status);
401}
402
403static void
404on_presence_status_text_changed (DBusGProxy *presence_proxy,
405 const char *status_text,
406 GSWatcher *watcher)
407{
408 set_status_text (watcher, status_text);
409}
410
411static gboolean
412connect_presence_watcher (GSWatcher *watcher)
413{
414 DBusGConnection *bus;
415 GError *error;
416 gboolean ret;
417
418 ret = FALSE(0);
419
420 error = NULL((void*)0);
421 bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
422 if (bus == NULL((void*)0))
423 {
424 g_warning ("Unable to get session bus: %s", error->message);
425 g_error_free (error);
426 goto done;
427 }
428
429 error = NULL((void*)0);
430 watcher->priv->presence_proxy = dbus_g_proxy_new_for_name_owner (bus,
431 "org.gnome.SessionManager",
432 "/org/gnome/SessionManager/Presence",
433 "org.gnome.SessionManager.Presence",
434 &error);
435 if (watcher->priv->presence_proxy != NULL((void*)0))
436 {
437 DBusGProxy *proxy;
438
439 dbus_g_proxy_add_signal (watcher->priv->presence_proxy,
440 "StatusChanged",
441 G_TYPE_UINT((GType) ((7) << (2))),
442 G_TYPE_INVALID((GType) ((0) << (2))));
443 dbus_g_proxy_connect_signal (watcher->priv->presence_proxy,
444 "StatusChanged",
445 G_CALLBACK (on_presence_status_changed)((GCallback) (on_presence_status_changed)),
446 watcher,
447 NULL((void*)0));
448 dbus_g_proxy_add_signal (watcher->priv->presence_proxy,
449 "StatusTextChanged",
450 G_TYPE_STRING((GType) ((16) << (2))),
451 G_TYPE_INVALID((GType) ((0) << (2))));
452 dbus_g_proxy_connect_signal (watcher->priv->presence_proxy,
453 "StatusTextChanged",
454 G_CALLBACK (on_presence_status_text_changed)((GCallback) (on_presence_status_text_changed)),
455 watcher,
456 NULL((void*)0));
457
458 proxy = dbus_g_proxy_new_from_proxy (watcher->priv->presence_proxy,
459 "org.freedesktop.DBus.Properties",
460 "/org/gnome/SessionManager/Presence");
461 if (proxy != NULL((void*)0))
462 {
463 guint status;
464 const char *status_text;
465 GValue value = { 0, };
466
467 status = 0;
468 status_text = NULL((void*)0);
469
470 error = NULL((void*)0);
471 dbus_g_proxy_call (proxy,
472 "Get",
473 &error,
474 G_TYPE_STRING((GType) ((16) << (2))), "org.gnome.SessionManager.Presence",
475 G_TYPE_STRING((GType) ((16) << (2))), "status",
476 G_TYPE_INVALID((GType) ((0) << (2))),
477 G_TYPE_VALUE(g_value_get_type ()), &value,
478 G_TYPE_INVALID((GType) ((0) << (2))));
479
480 if (error != NULL((void*)0))
481 {
482 g_warning ("Couldn't get presence status: %s", error->message);
483 g_error_free (error);
484 goto done;
485 }
486 else
487 {
488 status = g_value_get_uint (&value);
489 }
490
491 g_value_unset (&value);
492
493 error = NULL((void*)0);
494 dbus_g_proxy_call (proxy,
495 "Get",
496 &error,
497 G_TYPE_STRING((GType) ((16) << (2))), "org.gnome.SessionManager.Presence",
498 G_TYPE_STRING((GType) ((16) << (2))), "status-text",
499 G_TYPE_INVALID((GType) ((0) << (2))),
500 G_TYPE_VALUE(g_value_get_type ()), &value,
501 G_TYPE_INVALID((GType) ((0) << (2))));
502
503 if (error != NULL((void*)0))
504 {
505 g_warning ("Couldn't get presence status text: %s", error->message);
506 g_error_free (error);
507 }
508 else
509 {
510 status_text = g_value_get_string (&value);
511 }
512
513 set_status (watcher, status);
514 set_status_text (watcher, status_text);
515 }
516 }
517 else
518 {
519 g_warning ("Failed to get session presence proxy: %s", error->message);
520 g_error_free (error);
521 goto done;
522 }
523
524 ret = TRUE(!(0));
525
526done:
527 return ret;
528}
529
530static void
531gs_watcher_init (GSWatcher *watcher)
532{
533 watcher->priv = gs_watcher_get_instance_private (watcher);
534
535 watcher->priv->enabled = TRUE(!(0));
536 watcher->priv->active = FALSE(0);
537
538 connect_presence_watcher (watcher);
539
540 /* time before idle signal to send notice signal */
541 watcher->priv->delta_notice_timeout = 10000;
542
543 add_watchdog_timer (watcher, 600000);
544}
545
546static void
547gs_watcher_finalize (GObject *object)
548{
549 GSWatcher *watcher;
550
551 g_return_if_fail (object != NULL)do{ (void)0; }while (0);
552 g_return_if_fail (GS_IS_WATCHER (object))do{ (void)0; }while (0);
553
554 watcher = GS_WATCHER (object)((((GSWatcher*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((gs_watcher_get_type ()))))))
;
555
556 g_return_if_fail (watcher->priv != NULL)do{ (void)0; }while (0);
557
558 remove_watchdog_timer (watcher);
559
560 if (watcher->priv->idle_id > 0)
561 {
562 g_source_remove (watcher->priv->idle_id);
563 watcher->priv->idle_id = 0;
564 }
565
566 watcher->priv->active = FALSE(0);
567
568 if (watcher->priv->presence_proxy != NULL((void*)0))
569 {
570 g_object_unref (watcher->priv->presence_proxy);
571 }
572
573 g_free (watcher->priv->status_message);
574
575 G_OBJECT_CLASS (gs_watcher_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((gs_watcher_parent_class)), (((GType) ((20) << (2))
))))))
->finalize (object);
576}
577
578/* Figuring out what the appropriate XSetScreenSaver() parameters are
579 (one wouldn't expect this to be rocket science.)
580*/
581static void
582disable_builtin_screensaver (GSWatcher *watcher,
583 gboolean unblank_screen)
584{
585 int current_server_timeout, current_server_interval;
586 int current_prefer_blank, current_allow_exp;
587 int desired_server_timeout, desired_server_interval;
588 int desired_prefer_blank, desired_allow_exp;
589
590 XGetScreenSaver (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ())(gdk_x11_display_get_xdisplay (gdk_display_get_default ())),
591 &current_server_timeout,
592 &current_server_interval,
593 &current_prefer_blank,
594 &current_allow_exp);
595
596 desired_server_timeout = current_server_timeout;
597 desired_server_interval = current_server_interval;
598 desired_prefer_blank = current_prefer_blank;
599 desired_allow_exp = current_allow_exp;
Value stored to 'desired_allow_exp' is never read
600
601 desired_server_interval = 0;
602
603 /* I suspect (but am not sure) that DontAllowExposures might have
604 something to do with powering off the monitor as well, at least
605 on some systems that don't support XDPMS? Who know... */
606 desired_allow_exp = AllowExposures1;
607
608 /* When we're not using an extension, set the server-side timeout to 0,
609 so that the server never gets involved with screen blanking, and we
610 do it all ourselves. (However, when we *are* using an extension,
611 we tell the server when to notify us, and rather than blanking the
612 screen, the server will send us an X event telling us to blank.)
613 */
614 desired_server_timeout = 0;
615
616 if (desired_server_timeout != current_server_timeout
617 || desired_server_interval != current_server_interval
618 || desired_prefer_blank != current_prefer_blank
619 || desired_allow_exp != current_allow_exp)
620 {
621
622 gs_debug ("disabling server builtin screensaver:"gs_debug_real (__func__, "gs-watcher-x11.c", 627, "disabling server builtin screensaver:"
" (xset s %d %d; xset s %s; xset s %s)", desired_server_timeout
, desired_server_interval, (desired_prefer_blank ? "blank" : "noblank"
), (desired_allow_exp ? "expose" : "noexpose"))
623 " (xset s %d %d; xset s %s; xset s %s)",gs_debug_real (__func__, "gs-watcher-x11.c", 627, "disabling server builtin screensaver:"
" (xset s %d %d; xset s %s; xset s %s)", desired_server_timeout
, desired_server_interval, (desired_prefer_blank ? "blank" : "noblank"
), (desired_allow_exp ? "expose" : "noexpose"))
624 desired_server_timeout,gs_debug_real (__func__, "gs-watcher-x11.c", 627, "disabling server builtin screensaver:"
" (xset s %d %d; xset s %s; xset s %s)", desired_server_timeout
, desired_server_interval, (desired_prefer_blank ? "blank" : "noblank"
), (desired_allow_exp ? "expose" : "noexpose"))
625 desired_server_interval,gs_debug_real (__func__, "gs-watcher-x11.c", 627, "disabling server builtin screensaver:"
" (xset s %d %d; xset s %s; xset s %s)", desired_server_timeout
, desired_server_interval, (desired_prefer_blank ? "blank" : "noblank"
), (desired_allow_exp ? "expose" : "noexpose"))
626 (desired_prefer_blank ? "blank" : "noblank"),gs_debug_real (__func__, "gs-watcher-x11.c", 627, "disabling server builtin screensaver:"
" (xset s %d %d; xset s %s; xset s %s)", desired_server_timeout
, desired_server_interval, (desired_prefer_blank ? "blank" : "noblank"
), (desired_allow_exp ? "expose" : "noexpose"))
627 (desired_allow_exp ? "expose" : "noexpose"))gs_debug_real (__func__, "gs-watcher-x11.c", 627, "disabling server builtin screensaver:"
" (xset s %d %d; xset s %s; xset s %s)", desired_server_timeout
, desired_server_interval, (desired_prefer_blank ? "blank" : "noblank"
), (desired_allow_exp ? "expose" : "noexpose"))
;
628
629 XSetScreenSaver (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ())(gdk_x11_display_get_xdisplay (gdk_display_get_default ())),
630 desired_server_timeout,
631 desired_server_interval,
632 desired_prefer_blank,
633 desired_allow_exp);
634
635 XSync (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ())(gdk_x11_display_get_xdisplay (gdk_display_get_default ())), FALSE(0));
636 }
637
638 if (unblank_screen)
639 {
640 /* Turn off the server builtin saver if it is now running. */
641 XForceScreenSaver (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ())(gdk_x11_display_get_xdisplay (gdk_display_get_default ())), ScreenSaverReset0);
642 }
643}
644
645/* This timer goes off every few minutes, whether the user is idle or not,
646 to try and clean up anything that has gone wrong.
647
648 It calls disable_builtin_screensaver() so that if xset has been used,
649 or some other program (like xlock) has messed with the XSetScreenSaver()
650 settings, they will be set back to sensible values (if a server extension
651 is in use, messing with xlock can cause the screensaver to never get a wakeup
652 event, and could cause monitor power-saving to occur, and all manner of
653 heinousness.)
654
655 */
656
657static gboolean
658watchdog_timer (GSWatcher *watcher)
659{
660
661 disable_builtin_screensaver (watcher, FALSE(0));
662
663 return TRUE(!(0));
664}
665
666GSWatcher *
667gs_watcher_new (void)
668{
669 GSWatcher *watcher;
670
671 watcher = g_object_new (GS_TYPE_WATCHER(gs_watcher_get_type ()),
672 NULL((void*)0));
673
674 return GS_WATCHER (watcher)((((GSWatcher*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((watcher)), ((gs_watcher_get_type ()))))))
;
675}
diff --git a/2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-2dd8bc.html b/2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-2dd8bc.html new file mode 100644 index 0000000..c527c7e --- /dev/null +++ b/2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-2dd8bc.html @@ -0,0 +1,1355 @@ + + + +gs-watcher-x11.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rc/gs-watcher-x11.c
Warning:line 596, column 2
Value stored to 'desired_server_timeout' is never read
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name gs-watcher-x11.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/14.0.5 -D HAVE_CONFIG_H -I . -I .. -I . -I . -D MATEMENU_I_KNOW_THIS_IS_UNSTABLE -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/dconf -I /usr/include/mate-menus -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/dconf -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/dconf -I /usr/include/mate-menus -D PREFIX="/usr/local" -D BINDIR="/usr/local/bin" -D LIBDIR="/usr/local/lib" -D LIBEXECDIR="/usr/local/libexec" -D DATADIR="/usr/local/share" -D SYSCONFDIR="/usr/local/etc" -D MATELOCALEDIR="/usr/local/share/locale" -D PKGLIBEXECDIR="/usr/local/libexec/mate-screensaver" -D SAVERDIR="/usr/local/libexec/mate-screensaver" -D THEMESDIR="/usr/local/share/mate-screensaver/themes" -D GTKBUILDERDIR="/usr/local/share/mate-screensaver" -D MATE_SCREENSAVER_GL_HELPER_PATH="/usr/local/libexec/mate-screensaver-gl-helper" -D PAM_SERVICE_NAME="mate-screensaver" -D G_DISABLE_ASSERT -D G_DISABLE_CHECKS -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -internal-isystem /usr/lib64/clang/14.0.5/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/12/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2022-11-11-203102-6531-1 -x c gs-watcher-x11.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
2 *
3 * Copyright (C) 2004-2006 William Jon McCann <mccann@jhu.edu>
4 * Copyright (C) 2008 Red Hat, Inc.
5 * Copyright (C) 2012-2021 MATE Developers
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
20 *
21 * Authors: William Jon McCann <mccann@jhu.edu>
22 *
23 */
24
25#include "config.h"
26#include <stdlib.h>
27#include <stdio.h>
28#include <time.h>
29#include <errno(*__errno_location ()).h>
30
31#include <string.h>
32#include <gdk/gdkx.h>
33
34#include <dbus/dbus.h>
35#include <dbus/dbus-glib.h>
36
37#include "gs-watcher.h"
38#include "gs-marshal.h"
39#include "gs-debug.h"
40
41static void gs_watcher_finalize (GObject *object);
42
43static gboolean watchdog_timer (GSWatcher *watcher);
44
45struct GSWatcherPrivate
46{
47 /* settings */
48 guint enabled : 1;
49 guint delta_notice_timeout;
50
51 /* state */
52 guint active : 1;
53 guint idle : 1;
54 guint idle_notice : 1;
55
56 guint idle_id;
57 char *status_message;
58
59 DBusGProxy *presence_proxy;
60 guint watchdog_timer_id;
61};
62
63enum
64{
65 PROP_0,
66 PROP_STATUS_MESSAGE
67};
68
69enum
70{
71 IDLE_CHANGED,
72 IDLE_NOTICE_CHANGED,
73 LAST_SIGNAL
74};
75
76static guint signals [LAST_SIGNAL] = { 0, };
77
78G_DEFINE_TYPE_WITH_PRIVATE (GSWatcher, gs_watcher, G_TYPE_OBJECT)static void gs_watcher_init (GSWatcher *self); static void gs_watcher_class_init
(GSWatcherClass *klass); static GType gs_watcher_get_type_once
(void); static gpointer gs_watcher_parent_class = ((void*)0)
; static gint GSWatcher_private_offset; static void gs_watcher_class_intern_init
(gpointer klass) { gs_watcher_parent_class = g_type_class_peek_parent
(klass); if (GSWatcher_private_offset != 0) g_type_class_adjust_private_offset
(klass, &GSWatcher_private_offset); gs_watcher_class_init
((GSWatcherClass*) klass); } __attribute__ ((__unused__)) static
inline gpointer gs_watcher_get_instance_private (GSWatcher *
self) { return (((gpointer) ((guint8*) (self) + (glong) (GSWatcher_private_offset
)))); } GType gs_watcher_get_type (void) { static gsize static_g_define_type_id
= 0; if ((__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); (void
) (0 ? (gpointer) *(&static_g_define_type_id) : ((void*)0
)); (!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
(*(&static_g_define_type_id)) gapg_temp_newval; __typeof__
((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id
); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5)
; gapg_temp_newval; })) && g_once_init_enter (&static_g_define_type_id
)); }))) { GType g_define_type_id = gs_watcher_get_type_once (
); (__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); 0 ?
(void) (*(&static_g_define_type_id) = (g_define_type_id)
) : (void) 0; g_once_init_leave ((&static_g_define_type_id
), (gsize) (g_define_type_id)); })); } return static_g_define_type_id
; } __attribute__ ((__noinline__)) static GType gs_watcher_get_type_once
(void) { GType g_define_type_id = g_type_register_static_simple
(((GType) ((20) << (2))), g_intern_static_string ("GSWatcher"
), sizeof (GSWatcherClass), (GClassInitFunc)(void (*)(void)) gs_watcher_class_intern_init
, sizeof (GSWatcher), (GInstanceInitFunc)(void (*)(void)) gs_watcher_init
, (GTypeFlags) 0); { {{ GSWatcher_private_offset = g_type_add_instance_private
(g_define_type_id, sizeof (GSWatcherPrivate)); };} } return g_define_type_id
; }
79
80static void
81remove_watchdog_timer (GSWatcher *watcher)
82{
83 if (watcher->priv->watchdog_timer_id != 0)
84 {
85 g_source_remove (watcher->priv->watchdog_timer_id);
86 watcher->priv->watchdog_timer_id = 0;
87 }
88}
89
90static void
91add_watchdog_timer (GSWatcher *watcher,
92 guint timeout)
93{
94 watcher->priv->watchdog_timer_id = g_timeout_add (timeout,
95 (GSourceFunc)watchdog_timer,
96 watcher);
97}
98
99static void
100gs_watcher_get_property (GObject *object,
101 guint prop_id,
102 GValue *value,
103 GParamSpec *pspec)
104{
105 GSWatcher *self;
106
107 self = GS_WATCHER (object)((((GSWatcher*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((gs_watcher_get_type ()))))))
;
108
109 switch (prop_id)
110 {
111 case PROP_STATUS_MESSAGE:
112 g_value_set_string (value, self->priv->status_message);
113 break;
114 default:
115 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec)do { GObject *_glib__object = (GObject*) ((object)); GParamSpec
*_glib__pspec = (GParamSpec*) ((pspec)); guint _glib__property_id
= ((prop_id)); g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'"
, "gs-watcher-x11.c", 115, ("property"), _glib__property_id, _glib__pspec
->name, g_type_name ((((((GTypeClass*) (((GTypeInstance*) (
_glib__pspec))->g_class))->g_type)))), (g_type_name (((
(((GTypeClass*) (((GTypeInstance*) (_glib__object))->g_class
))->g_type)))))); } while (0)
;
116 break;
117 }
118}
119
120static void
121set_status_text (GSWatcher *watcher,
122 const char *text)
123{
124 g_free (watcher->priv->status_message);
125
126 watcher->priv->status_message = g_strdup (text);
127 g_object_notify (G_OBJECT (watcher)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((watcher)), (((GType) ((20) << (2))))))))
, "status-message");
128}
129
130static void
131gs_watcher_set_property (GObject *object,
132 guint prop_id,
133 const GValue *value,
134 GParamSpec *pspec)
135{
136 GSWatcher *self;
137
138 self = GS_WATCHER (object)((((GSWatcher*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((gs_watcher_get_type ()))))))
;
139
140 switch (prop_id)
141 {
142 case PROP_STATUS_MESSAGE:
143 set_status_text (self, g_value_get_string (value));
144 break;
145 default:
146 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec)do { GObject *_glib__object = (GObject*) ((object)); GParamSpec
*_glib__pspec = (GParamSpec*) ((pspec)); guint _glib__property_id
= ((prop_id)); g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'"
, "gs-watcher-x11.c", 146, ("property"), _glib__property_id, _glib__pspec
->name, g_type_name ((((((GTypeClass*) (((GTypeInstance*) (
_glib__pspec))->g_class))->g_type)))), (g_type_name (((
(((GTypeClass*) (((GTypeInstance*) (_glib__object))->g_class
))->g_type)))))); } while (0)
;
147 break;
148 }
149}
150
151static void
152gs_watcher_class_init (GSWatcherClass *klass)
153{
154 GObjectClass *object_class = G_OBJECT_CLASS (klass)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((klass)), (((GType) ((20) << (2))))))))
;
155
156 object_class->finalize = gs_watcher_finalize;
157 object_class->get_property = gs_watcher_get_property;
158 object_class->set_property = gs_watcher_set_property;
159
160 g_object_class_install_property (object_class,
161 PROP_STATUS_MESSAGE,
162 g_param_spec_string ("status-message",
163 NULL((void*)0),
164 NULL((void*)0),
165 NULL((void*)0),
166 G_PARAM_READWRITE));
167
168 signals [IDLE_CHANGED] =
169 g_signal_new ("idle-changed",
170 G_TYPE_FROM_CLASS (object_class)(((GTypeClass*) (object_class))->g_type),
171 G_SIGNAL_RUN_LAST,
172 G_STRUCT_OFFSET (GSWatcherClass, idle_changed)((glong) __builtin_offsetof(GSWatcherClass, idle_changed)),
173 NULL((void*)0),
174 NULL((void*)0),
175 gs_marshal_BOOLEAN__BOOLEAN,
176 G_TYPE_BOOLEAN((GType) ((5) << (2))),
177 1, G_TYPE_BOOLEAN((GType) ((5) << (2))));
178 signals [IDLE_NOTICE_CHANGED] =
179 g_signal_new ("idle-notice-changed",
180 G_TYPE_FROM_CLASS (object_class)(((GTypeClass*) (object_class))->g_type),
181 G_SIGNAL_RUN_LAST,
182 G_STRUCT_OFFSET (GSWatcherClass, idle_notice_changed)((glong) __builtin_offsetof(GSWatcherClass, idle_notice_changed
))
,
183 NULL((void*)0),
184 NULL((void*)0),
185 gs_marshal_BOOLEAN__BOOLEAN,
186 G_TYPE_BOOLEAN((GType) ((5) << (2))),
187 1, G_TYPE_BOOLEAN((GType) ((5) << (2))));
188}
189
190static gboolean
191_gs_watcher_set_session_idle_notice (GSWatcher *watcher,
192 gboolean in_effect)
193{
194 gboolean res;
195
196 res = FALSE(0);
197
198 if (in_effect != watcher->priv->idle_notice)
199 {
200
201 g_signal_emit (watcher, signals [IDLE_NOTICE_CHANGED], 0, in_effect, &res);
202 if (res)
203 {
204 gs_debug ("Changing idle notice state: %d", in_effect)gs_debug_real (__func__, "gs-watcher-x11.c", 204, "Changing idle notice state: %d"
, in_effect)
;
205
206 watcher->priv->idle_notice = (in_effect != FALSE(0));
207 }
208 else
209 {
210 gs_debug ("Idle notice signal not handled: %d", in_effect)gs_debug_real (__func__, "gs-watcher-x11.c", 210, "Idle notice signal not handled: %d"
, in_effect)
;
211 }
212 }
213
214 return res;
215}
216
217static gboolean
218_gs_watcher_set_session_idle (GSWatcher *watcher,
219 gboolean is_idle)
220{
221 gboolean res;
222
223 res = FALSE(0);
224
225 if (is_idle != watcher->priv->idle)
226 {
227
228 g_signal_emit (watcher, signals [IDLE_CHANGED], 0, is_idle, &res);
229 if (res)
230 {
231 gs_debug ("Changing idle state: %d", is_idle)gs_debug_real (__func__, "gs-watcher-x11.c", 231, "Changing idle state: %d"
, is_idle)
;
232
233 watcher->priv->idle = (is_idle != FALSE(0));
234 }
235 else
236 {
237 gs_debug ("Idle changed signal not handled: %d", is_idle)gs_debug_real (__func__, "gs-watcher-x11.c", 237, "Idle changed signal not handled: %d"
, is_idle)
;
238 }
239 }
240
241 return res;
242}
243
244gboolean
245gs_watcher_get_active (GSWatcher *watcher)
246{
247 gboolean active;
248
249 g_return_val_if_fail (GS_IS_WATCHER (watcher), FALSE)do{ (void)0; }while (0);
250
251 active = watcher->priv->active;
252
253 return active;
254}
255
256static void
257_gs_watcher_reset_state (GSWatcher *watcher)
258{
259 watcher->priv->idle = FALSE(0);
260 watcher->priv->idle_notice = FALSE(0);
261}
262
263static gboolean
264_gs_watcher_set_active_internal (GSWatcher *watcher,
265 gboolean active)
266{
267 if (active != watcher->priv->active)
268 {
269 /* reset state */
270 _gs_watcher_reset_state (watcher);
271
272 watcher->priv->active = (active != FALSE(0));
273 }
274
275 return TRUE(!(0));
276}
277
278gboolean
279gs_watcher_set_active (GSWatcher *watcher,
280 gboolean active)
281{
282 g_return_val_if_fail (GS_IS_WATCHER (watcher), FALSE)do{ (void)0; }while (0);
283
284 gs_debug ("turning watcher: %s", active ? "ON" : "OFF")gs_debug_real (__func__, "gs-watcher-x11.c", 284, "turning watcher: %s"
, active ? "ON" : "OFF")
;
285
286 if (watcher->priv->active == active)
287 {
288 gs_debug ("Idle detection is already %s",gs_debug_real (__func__, "gs-watcher-x11.c", 289, "Idle detection is already %s"
, active ? "active" : "inactive")
289 active ? "active" : "inactive")gs_debug_real (__func__, "gs-watcher-x11.c", 289, "Idle detection is already %s"
, active ? "active" : "inactive")
;
290 return FALSE(0);
291 }
292
293 if (! watcher->priv->enabled)
294 {
295 gs_debug ("Idle detection is disabled, cannot activate")gs_debug_real (__func__, "gs-watcher-x11.c", 295, "Idle detection is disabled, cannot activate"
)
;
296 return FALSE(0);
297 }
298
299 return _gs_watcher_set_active_internal (watcher, active);
300}
301
302gboolean
303gs_watcher_set_enabled (GSWatcher *watcher,
304 gboolean enabled)
305{
306 g_return_val_if_fail (GS_IS_WATCHER (watcher), FALSE)do{ (void)0; }while (0);
307
308 if (watcher->priv->enabled != enabled)
309 {
310 gboolean is_active = gs_watcher_get_active (watcher);
311
312 watcher->priv->enabled = (enabled != FALSE(0));
313
314 /* if we are disabling the watcher and we are
315 active shut it down */
316 if (! enabled && is_active)
317 {
318 _gs_watcher_set_active_internal (watcher, FALSE(0));
319 }
320 }
321
322 return TRUE(!(0));
323}
324
325gboolean
326gs_watcher_get_enabled (GSWatcher *watcher)
327{
328 gboolean enabled;
329
330 g_return_val_if_fail (GS_IS_WATCHER (watcher), FALSE)do{ (void)0; }while (0);
331
332 enabled = watcher->priv->enabled;
333
334 return enabled;
335}
336
337static gboolean
338on_idle_timeout (GSWatcher *watcher)
339{
340 gboolean res;
341
342 res = _gs_watcher_set_session_idle (watcher, TRUE(!(0)));
343
344 _gs_watcher_set_session_idle_notice (watcher, FALSE(0));
345
346 /* try again if we failed i guess */
347 return !res;
348}
349
350static void
351set_status (GSWatcher *watcher,
352 guint status)
353{
354 gboolean is_idle;
355
356 if (! watcher->priv->active)
357 {
358 gs_debug ("GSWatcher: not active, ignoring status changes")gs_debug_real (__func__, "gs-watcher-x11.c", 358, "GSWatcher: not active, ignoring status changes"
)
;
359 return;
360 }
361
362 is_idle = (status == 3);
363
364 if (!is_idle && !watcher->priv->idle_notice)
365 {
366 /* no change in idleness */
367 return;
368 }
369
370 if (is_idle)
371 {
372 _gs_watcher_set_session_idle_notice (watcher, is_idle);
373 /* queue an activation */
374 if (watcher->priv->idle_id > 0)
375 {
376 g_source_remove (watcher->priv->idle_id);
377 }
378 watcher->priv->idle_id = g_timeout_add (watcher->priv->delta_notice_timeout,
379 (GSourceFunc)on_idle_timeout,
380 watcher);
381 }
382 else
383 {
384 /* cancel notice too */
385 if (watcher->priv->idle_id > 0)
386 {
387 g_source_remove (watcher->priv->idle_id);
388 watcher->priv->idle_id = 0;
389 }
390 _gs_watcher_set_session_idle (watcher, FALSE(0));
391 _gs_watcher_set_session_idle_notice (watcher, FALSE(0));
392 }
393}
394
395static void
396on_presence_status_changed (DBusGProxy *presence_proxy,
397 guint status,
398 GSWatcher *watcher)
399{
400 set_status (watcher, status);
401}
402
403static void
404on_presence_status_text_changed (DBusGProxy *presence_proxy,
405 const char *status_text,
406 GSWatcher *watcher)
407{
408 set_status_text (watcher, status_text);
409}
410
411static gboolean
412connect_presence_watcher (GSWatcher *watcher)
413{
414 DBusGConnection *bus;
415 GError *error;
416 gboolean ret;
417
418 ret = FALSE(0);
419
420 error = NULL((void*)0);
421 bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
422 if (bus == NULL((void*)0))
423 {
424 g_warning ("Unable to get session bus: %s", error->message);
425 g_error_free (error);
426 goto done;
427 }
428
429 error = NULL((void*)0);
430 watcher->priv->presence_proxy = dbus_g_proxy_new_for_name_owner (bus,
431 "org.gnome.SessionManager",
432 "/org/gnome/SessionManager/Presence",
433 "org.gnome.SessionManager.Presence",
434 &error);
435 if (watcher->priv->presence_proxy != NULL((void*)0))
436 {
437 DBusGProxy *proxy;
438
439 dbus_g_proxy_add_signal (watcher->priv->presence_proxy,
440 "StatusChanged",
441 G_TYPE_UINT((GType) ((7) << (2))),
442 G_TYPE_INVALID((GType) ((0) << (2))));
443 dbus_g_proxy_connect_signal (watcher->priv->presence_proxy,
444 "StatusChanged",
445 G_CALLBACK (on_presence_status_changed)((GCallback) (on_presence_status_changed)),
446 watcher,
447 NULL((void*)0));
448 dbus_g_proxy_add_signal (watcher->priv->presence_proxy,
449 "StatusTextChanged",
450 G_TYPE_STRING((GType) ((16) << (2))),
451 G_TYPE_INVALID((GType) ((0) << (2))));
452 dbus_g_proxy_connect_signal (watcher->priv->presence_proxy,
453 "StatusTextChanged",
454 G_CALLBACK (on_presence_status_text_changed)((GCallback) (on_presence_status_text_changed)),
455 watcher,
456 NULL((void*)0));
457
458 proxy = dbus_g_proxy_new_from_proxy (watcher->priv->presence_proxy,
459 "org.freedesktop.DBus.Properties",
460 "/org/gnome/SessionManager/Presence");
461 if (proxy != NULL((void*)0))
462 {
463 guint status;
464 const char *status_text;
465 GValue value = { 0, };
466
467 status = 0;
468 status_text = NULL((void*)0);
469
470 error = NULL((void*)0);
471 dbus_g_proxy_call (proxy,
472 "Get",
473 &error,
474 G_TYPE_STRING((GType) ((16) << (2))), "org.gnome.SessionManager.Presence",
475 G_TYPE_STRING((GType) ((16) << (2))), "status",
476 G_TYPE_INVALID((GType) ((0) << (2))),
477 G_TYPE_VALUE(g_value_get_type ()), &value,
478 G_TYPE_INVALID((GType) ((0) << (2))));
479
480 if (error != NULL((void*)0))
481 {
482 g_warning ("Couldn't get presence status: %s", error->message);
483 g_error_free (error);
484 goto done;
485 }
486 else
487 {
488 status = g_value_get_uint (&value);
489 }
490
491 g_value_unset (&value);
492
493 error = NULL((void*)0);
494 dbus_g_proxy_call (proxy,
495 "Get",
496 &error,
497 G_TYPE_STRING((GType) ((16) << (2))), "org.gnome.SessionManager.Presence",
498 G_TYPE_STRING((GType) ((16) << (2))), "status-text",
499 G_TYPE_INVALID((GType) ((0) << (2))),
500 G_TYPE_VALUE(g_value_get_type ()), &value,
501 G_TYPE_INVALID((GType) ((0) << (2))));
502
503 if (error != NULL((void*)0))
504 {
505 g_warning ("Couldn't get presence status text: %s", error->message);
506 g_error_free (error);
507 }
508 else
509 {
510 status_text = g_value_get_string (&value);
511 }
512
513 set_status (watcher, status);
514 set_status_text (watcher, status_text);
515 }
516 }
517 else
518 {
519 g_warning ("Failed to get session presence proxy: %s", error->message);
520 g_error_free (error);
521 goto done;
522 }
523
524 ret = TRUE(!(0));
525
526done:
527 return ret;
528}
529
530static void
531gs_watcher_init (GSWatcher *watcher)
532{
533 watcher->priv = gs_watcher_get_instance_private (watcher);
534
535 watcher->priv->enabled = TRUE(!(0));
536 watcher->priv->active = FALSE(0);
537
538 connect_presence_watcher (watcher);
539
540 /* time before idle signal to send notice signal */
541 watcher->priv->delta_notice_timeout = 10000;
542
543 add_watchdog_timer (watcher, 600000);
544}
545
546static void
547gs_watcher_finalize (GObject *object)
548{
549 GSWatcher *watcher;
550
551 g_return_if_fail (object != NULL)do{ (void)0; }while (0);
552 g_return_if_fail (GS_IS_WATCHER (object))do{ (void)0; }while (0);
553
554 watcher = GS_WATCHER (object)((((GSWatcher*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((gs_watcher_get_type ()))))))
;
555
556 g_return_if_fail (watcher->priv != NULL)do{ (void)0; }while (0);
557
558 remove_watchdog_timer (watcher);
559
560 if (watcher->priv->idle_id > 0)
561 {
562 g_source_remove (watcher->priv->idle_id);
563 watcher->priv->idle_id = 0;
564 }
565
566 watcher->priv->active = FALSE(0);
567
568 if (watcher->priv->presence_proxy != NULL((void*)0))
569 {
570 g_object_unref (watcher->priv->presence_proxy);
571 }
572
573 g_free (watcher->priv->status_message);
574
575 G_OBJECT_CLASS (gs_watcher_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((gs_watcher_parent_class)), (((GType) ((20) << (2))
))))))
->finalize (object);
576}
577
578/* Figuring out what the appropriate XSetScreenSaver() parameters are
579 (one wouldn't expect this to be rocket science.)
580*/
581static void
582disable_builtin_screensaver (GSWatcher *watcher,
583 gboolean unblank_screen)
584{
585 int current_server_timeout, current_server_interval;
586 int current_prefer_blank, current_allow_exp;
587 int desired_server_timeout, desired_server_interval;
588 int desired_prefer_blank, desired_allow_exp;
589
590 XGetScreenSaver (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ())(gdk_x11_display_get_xdisplay (gdk_display_get_default ())),
591 &current_server_timeout,
592 &current_server_interval,
593 &current_prefer_blank,
594 &current_allow_exp);
595
596 desired_server_timeout = current_server_timeout;
Value stored to 'desired_server_timeout' is never read
597 desired_server_interval = current_server_interval;
598 desired_prefer_blank = current_prefer_blank;
599 desired_allow_exp = current_allow_exp;
600
601 desired_server_interval = 0;
602
603 /* I suspect (but am not sure) that DontAllowExposures might have
604 something to do with powering off the monitor as well, at least
605 on some systems that don't support XDPMS? Who know... */
606 desired_allow_exp = AllowExposures1;
607
608 /* When we're not using an extension, set the server-side timeout to 0,
609 so that the server never gets involved with screen blanking, and we
610 do it all ourselves. (However, when we *are* using an extension,
611 we tell the server when to notify us, and rather than blanking the
612 screen, the server will send us an X event telling us to blank.)
613 */
614 desired_server_timeout = 0;
615
616 if (desired_server_timeout != current_server_timeout
617 || desired_server_interval != current_server_interval
618 || desired_prefer_blank != current_prefer_blank
619 || desired_allow_exp != current_allow_exp)
620 {
621
622 gs_debug ("disabling server builtin screensaver:"gs_debug_real (__func__, "gs-watcher-x11.c", 627, "disabling server builtin screensaver:"
" (xset s %d %d; xset s %s; xset s %s)", desired_server_timeout
, desired_server_interval, (desired_prefer_blank ? "blank" : "noblank"
), (desired_allow_exp ? "expose" : "noexpose"))
623 " (xset s %d %d; xset s %s; xset s %s)",gs_debug_real (__func__, "gs-watcher-x11.c", 627, "disabling server builtin screensaver:"
" (xset s %d %d; xset s %s; xset s %s)", desired_server_timeout
, desired_server_interval, (desired_prefer_blank ? "blank" : "noblank"
), (desired_allow_exp ? "expose" : "noexpose"))
624 desired_server_timeout,gs_debug_real (__func__, "gs-watcher-x11.c", 627, "disabling server builtin screensaver:"
" (xset s %d %d; xset s %s; xset s %s)", desired_server_timeout
, desired_server_interval, (desired_prefer_blank ? "blank" : "noblank"
), (desired_allow_exp ? "expose" : "noexpose"))
625 desired_server_interval,gs_debug_real (__func__, "gs-watcher-x11.c", 627, "disabling server builtin screensaver:"
" (xset s %d %d; xset s %s; xset s %s)", desired_server_timeout
, desired_server_interval, (desired_prefer_blank ? "blank" : "noblank"
), (desired_allow_exp ? "expose" : "noexpose"))
626 (desired_prefer_blank ? "blank" : "noblank"),gs_debug_real (__func__, "gs-watcher-x11.c", 627, "disabling server builtin screensaver:"
" (xset s %d %d; xset s %s; xset s %s)", desired_server_timeout
, desired_server_interval, (desired_prefer_blank ? "blank" : "noblank"
), (desired_allow_exp ? "expose" : "noexpose"))
627 (desired_allow_exp ? "expose" : "noexpose"))gs_debug_real (__func__, "gs-watcher-x11.c", 627, "disabling server builtin screensaver:"
" (xset s %d %d; xset s %s; xset s %s)", desired_server_timeout
, desired_server_interval, (desired_prefer_blank ? "blank" : "noblank"
), (desired_allow_exp ? "expose" : "noexpose"))
;
628
629 XSetScreenSaver (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ())(gdk_x11_display_get_xdisplay (gdk_display_get_default ())),
630 desired_server_timeout,
631 desired_server_interval,
632 desired_prefer_blank,
633 desired_allow_exp);
634
635 XSync (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ())(gdk_x11_display_get_xdisplay (gdk_display_get_default ())), FALSE(0));
636 }
637
638 if (unblank_screen)
639 {
640 /* Turn off the server builtin saver if it is now running. */
641 XForceScreenSaver (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ())(gdk_x11_display_get_xdisplay (gdk_display_get_default ())), ScreenSaverReset0);
642 }
643}
644
645/* This timer goes off every few minutes, whether the user is idle or not,
646 to try and clean up anything that has gone wrong.
647
648 It calls disable_builtin_screensaver() so that if xset has been used,
649 or some other program (like xlock) has messed with the XSetScreenSaver()
650 settings, they will be set back to sensible values (if a server extension
651 is in use, messing with xlock can cause the screensaver to never get a wakeup
652 event, and could cause monitor power-saving to occur, and all manner of
653 heinousness.)
654
655 */
656
657static gboolean
658watchdog_timer (GSWatcher *watcher)
659{
660
661 disable_builtin_screensaver (watcher, FALSE(0));
662
663 return TRUE(!(0));
664}
665
666GSWatcher *
667gs_watcher_new (void)
668{
669 GSWatcher *watcher;
670
671 watcher = g_object_new (GS_TYPE_WATCHER(gs_watcher_get_type ()),
672 NULL((void*)0));
673
674 return GS_WATCHER (watcher)((((GSWatcher*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((watcher)), ((gs_watcher_get_type ()))))))
;
675}
diff --git a/2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-489c44.html b/2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-489c44.html new file mode 100644 index 0000000..89e40ce --- /dev/null +++ b/2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-489c44.html @@ -0,0 +1,848 @@ + + + +xdg-user-dir-lookup.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:avers/xdg-user-dir-lookup.c
Warning:line 55, column 3
Call to function 'strcat' is insecure as it does not provide bounding of the memory buffer. Replace unbounded copy functions with analogous functions that support length arguments such as 'strlcat'. CWE-119
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name xdg-user-dir-lookup.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/savers -resource-dir /usr/lib64/clang/14.0.5 -D HAVE_CONFIG_H -I . -I .. -I . -I . -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -D LIBEXECDIR="/usr/local/libexec" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -internal-isystem /usr/lib64/clang/14.0.5/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/12/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdebug-compilation-dir=/rootdir/savers -ferror-limit 19 -fgnuc-version=4.2.1 -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2022-11-11-203102-6531-1 -x c xdg-user-dir-lookup.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/*
2 This file is not licenced under the GPL like the rest of the code.
3 Its is under the MIT license, to encourage reuse by cut-and-paste.
4
5 Copyright (c) 2007 Red Hat, inc
6 Copyright (C) 2012-2021 MATE Developers
7
8 Permission is hereby granted, free of charge, to any person
9 obtaining a copy of this software and associated documentation files
10 (the "Software"), to deal in the Software without restriction,
11 including without limitation the rights to use, copy, modify, merge,
12 publish, distribute, sublicense, and/or sell copies of the Software,
13 and to permit persons to whom the Software is furnished to do so,
14 subject to the following conditions:
15
16 The above copyright notice and this permission notice shall be
17 included in all copies or substantial portions of the Software.
18
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
23 BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
24 ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
25 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26 SOFTWARE.
27*/
28
29#include <stdio.h>
30#include <stdlib.h>
31#include <string.h>
32
33#include "xdg-user-dir-lookup.h"
34
35char *
36xdg_user_dir_lookup (const char *type)
37{
38 FILE *file;
39 char *home_dir, *config_home, *config_file;
40 char buffer[512];
41 char *user_dir;
42 char *p, *d;
43 int relative;
44
45 home_dir = getenv ("HOME");
46
47 if (home_dir == NULL((void*)0))
48 return strdup ("/tmp");
49
50 config_home = getenv ("XDG_CONFIG_HOME");
51 if (config_home == NULL((void*)0) || config_home[0] == 0)
52 {
53 config_file = malloc (strlen (home_dir) + strlen ("/.config/user-dirs.dirs") + 1);
54 strcpy (config_file, home_dir);
55 strcat (config_file, "/.config/user-dirs.dirs");
Call to function 'strcat' is insecure as it does not provide bounding of the memory buffer. Replace unbounded copy functions with analogous functions that support length arguments such as 'strlcat'. CWE-119
56 }
57 else
58 {
59 config_file = malloc (strlen (config_home) + strlen ("/user-dirs.dirs") + 1);
60 strcpy (config_file, config_home);
61 strcat (config_file, "/user-dirs.dirs");
62 }
63
64 file = fopen (config_file, "r");
65 free (config_file);
66 if (file == NULL((void*)0))
67 goto error;
68
69 user_dir = NULL((void*)0);
70 while (fgets (buffer, sizeof (buffer), file))
71 {
72 /* Remove newline at end */
73 size_t len = strlen (buffer);
74 if (len != 0 && buffer[len-1] == '\n')
75 buffer[len-1] = 0;
76
77 p = buffer;
78 while (*p == ' ' || *p == '\t')
79 p++;
80
81 if (strncmp (p, "XDG_", 4) != 0)
82 continue;
83 p += 4;
84 if (strncmp (p, type, strlen (type)) != 0)
85 continue;
86 p += strlen (type);
87 if (strncmp (p, "_DIR", 4) != 0)
88 continue;
89 p += 4;
90
91 while (*p == ' ' || *p == '\t')
92 p++;
93
94 if (*p != '=')
95 continue;
96 p++;
97
98 while (*p == ' ' || *p == '\t')
99 p++;
100
101 if (*p != '"')
102 continue;
103 p++;
104
105 relative = 0;
106 if (strncmp (p, "$HOME/", 6) == 0)
107 {
108 p += 6;
109 relative = 1;
110 }
111 else if (*p != '/')
112 continue;
113
114 if (relative)
115 {
116 user_dir = malloc (strlen (home_dir) + 1 + strlen (p) + 1);
117 strcpy (user_dir, home_dir);
118 strcat (user_dir, "/");
119 }
120 else
121 {
122 user_dir = malloc (strlen (p) + 1);
123 *user_dir = 0;
124 }
125
126 d = user_dir + strlen (user_dir);
127 while (*p && *p != '"')
128 {
129 if ((*p == '\\') && (*(p+1) != 0))
130 p++;
131 *d++ = *p++;
132 }
133 *d = 0;
134 }
135 fclose (file);
136
137 if (user_dir)
138 return user_dir;
139
140error:
141 /* Special case desktop for historical compatibility */
142 if (strcmp (type, "DESKTOP") == 0)
143 {
144 user_dir = malloc (strlen (home_dir) + strlen ("/Desktop") + 1);
145 strcpy (user_dir, home_dir);
146 strcat (user_dir, "/Desktop");
147 return user_dir;
148 }
149 else
150 return strdup (home_dir);
151}
152
153#ifdef STANDALONE
154
155int
156main (int argc, char *argv[])
157{
158 if (argc != 2)
159 {
160 fprintf (stderrstderr, "Usage %s <dir-type>\n", argv[0]);
161 exit (1);
162 }
163
164 printf ("%s\n", xdg_user_dir_lookup (argv[1]));
165 return 0;
166}
167
168#endif
diff --git a/2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-4b9cac.html b/2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-4b9cac.html new file mode 100644 index 0000000..4ac4c98 --- /dev/null +++ b/2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-4b9cac.html @@ -0,0 +1,848 @@ + + + +xdg-user-dir-lookup.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:avers/xdg-user-dir-lookup.c
Warning:line 118, column 4
Call to function 'strcat' is insecure as it does not provide bounding of the memory buffer. Replace unbounded copy functions with analogous functions that support length arguments such as 'strlcat'. CWE-119
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name xdg-user-dir-lookup.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/savers -resource-dir /usr/lib64/clang/14.0.5 -D HAVE_CONFIG_H -I . -I .. -I . -I . -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -D LIBEXECDIR="/usr/local/libexec" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -internal-isystem /usr/lib64/clang/14.0.5/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/12/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdebug-compilation-dir=/rootdir/savers -ferror-limit 19 -fgnuc-version=4.2.1 -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2022-11-11-203102-6531-1 -x c xdg-user-dir-lookup.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/*
2 This file is not licenced under the GPL like the rest of the code.
3 Its is under the MIT license, to encourage reuse by cut-and-paste.
4
5 Copyright (c) 2007 Red Hat, inc
6 Copyright (C) 2012-2021 MATE Developers
7
8 Permission is hereby granted, free of charge, to any person
9 obtaining a copy of this software and associated documentation files
10 (the "Software"), to deal in the Software without restriction,
11 including without limitation the rights to use, copy, modify, merge,
12 publish, distribute, sublicense, and/or sell copies of the Software,
13 and to permit persons to whom the Software is furnished to do so,
14 subject to the following conditions:
15
16 The above copyright notice and this permission notice shall be
17 included in all copies or substantial portions of the Software.
18
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
23 BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
24 ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
25 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26 SOFTWARE.
27*/
28
29#include <stdio.h>
30#include <stdlib.h>
31#include <string.h>
32
33#include "xdg-user-dir-lookup.h"
34
35char *
36xdg_user_dir_lookup (const char *type)
37{
38 FILE *file;
39 char *home_dir, *config_home, *config_file;
40 char buffer[512];
41 char *user_dir;
42 char *p, *d;
43 int relative;
44
45 home_dir = getenv ("HOME");
46
47 if (home_dir == NULL((void*)0))
48 return strdup ("/tmp");
49
50 config_home = getenv ("XDG_CONFIG_HOME");
51 if (config_home == NULL((void*)0) || config_home[0] == 0)
52 {
53 config_file = malloc (strlen (home_dir) + strlen ("/.config/user-dirs.dirs") + 1);
54 strcpy (config_file, home_dir);
55 strcat (config_file, "/.config/user-dirs.dirs");
56 }
57 else
58 {
59 config_file = malloc (strlen (config_home) + strlen ("/user-dirs.dirs") + 1);
60 strcpy (config_file, config_home);
61 strcat (config_file, "/user-dirs.dirs");
62 }
63
64 file = fopen (config_file, "r");
65 free (config_file);
66 if (file == NULL((void*)0))
67 goto error;
68
69 user_dir = NULL((void*)0);
70 while (fgets (buffer, sizeof (buffer), file))
71 {
72 /* Remove newline at end */
73 size_t len = strlen (buffer);
74 if (len != 0 && buffer[len-1] == '\n')
75 buffer[len-1] = 0;
76
77 p = buffer;
78 while (*p == ' ' || *p == '\t')
79 p++;
80
81 if (strncmp (p, "XDG_", 4) != 0)
82 continue;
83 p += 4;
84 if (strncmp (p, type, strlen (type)) != 0)
85 continue;
86 p += strlen (type);
87 if (strncmp (p, "_DIR", 4) != 0)
88 continue;
89 p += 4;
90
91 while (*p == ' ' || *p == '\t')
92 p++;
93
94 if (*p != '=')
95 continue;
96 p++;
97
98 while (*p == ' ' || *p == '\t')
99 p++;
100
101 if (*p != '"')
102 continue;
103 p++;
104
105 relative = 0;
106 if (strncmp (p, "$HOME/", 6) == 0)
107 {
108 p += 6;
109 relative = 1;
110 }
111 else if (*p != '/')
112 continue;
113
114 if (relative)
115 {
116 user_dir = malloc (strlen (home_dir) + 1 + strlen (p) + 1);
117 strcpy (user_dir, home_dir);
118 strcat (user_dir, "/");
Call to function 'strcat' is insecure as it does not provide bounding of the memory buffer. Replace unbounded copy functions with analogous functions that support length arguments such as 'strlcat'. CWE-119
119 }
120 else
121 {
122 user_dir = malloc (strlen (p) + 1);
123 *user_dir = 0;
124 }
125
126 d = user_dir + strlen (user_dir);
127 while (*p && *p != '"')
128 {
129 if ((*p == '\\') && (*(p+1) != 0))
130 p++;
131 *d++ = *p++;
132 }
133 *d = 0;
134 }
135 fclose (file);
136
137 if (user_dir)
138 return user_dir;
139
140error:
141 /* Special case desktop for historical compatibility */
142 if (strcmp (type, "DESKTOP") == 0)
143 {
144 user_dir = malloc (strlen (home_dir) + strlen ("/Desktop") + 1);
145 strcpy (user_dir, home_dir);
146 strcat (user_dir, "/Desktop");
147 return user_dir;
148 }
149 else
150 return strdup (home_dir);
151}
152
153#ifdef STANDALONE
154
155int
156main (int argc, char *argv[])
157{
158 if (argc != 2)
159 {
160 fprintf (stderrstderr, "Usage %s <dir-type>\n", argv[0]);
161 exit (1);
162 }
163
164 printf ("%s\n", xdg_user_dir_lookup (argv[1]));
165 return 0;
166}
167
168#endif
diff --git a/2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-534ad8.html b/2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-534ad8.html new file mode 100644 index 0000000..b21ad52 --- /dev/null +++ b/2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-534ad8.html @@ -0,0 +1,1490 @@ + + + +gs-auth-pam.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rc/gs-auth-pam.c
Warning:line 380, column 2
Value stored to 'status' is never read
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name gs-auth-pam.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/14.0.5 -D HAVE_CONFIG_H -I . -I .. -I . -I . -D MATEMENU_I_KNOW_THIS_IS_UNSTABLE -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/dconf -I /usr/include/mate-menus -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/dconf -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/dconf -I /usr/include/mate-menus -D PREFIX="/usr/local" -D BINDIR="/usr/local/bin" -D LIBDIR="/usr/local/lib" -D LIBEXECDIR="/usr/local/libexec" -D DATADIR="/usr/local/share" -D SYSCONFDIR="/usr/local/etc" -D MATELOCALEDIR="/usr/local/share/locale" -D PKGLIBEXECDIR="/usr/local/libexec/mate-screensaver" -D SAVERDIR="/usr/local/libexec/mate-screensaver" -D THEMESDIR="/usr/local/share/mate-screensaver/themes" -D GTKBUILDERDIR="/usr/local/share/mate-screensaver" -D MATE_SCREENSAVER_GL_HELPER_PATH="/usr/local/libexec/mate-screensaver-gl-helper" -D PAM_SERVICE_NAME="mate-screensaver" -D G_DISABLE_ASSERT -D G_DISABLE_CHECKS -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -internal-isystem /usr/lib64/clang/14.0.5/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/12/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2022-11-11-203102-6531-1 -x c gs-auth-pam.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
2 *
3 * Copyright (C) 2006 William Jon McCann <mccann@jhu.edu>
4 * Copyright (C) 2006 Ray Strode <rstrode@redhat.com>
5 * Copyright (C) 2003 Bill Nottingham <notting@redhat.com>
6 * Copyright (c) 1993-2003 Jamie Zawinski <jwz@jwz.org>
7 * Copyright (C) 2012-2021 MATE Developers
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License as
11 * published by the Free Software Foundation; either version 2 of the
12 * License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
22 * 02110-1301, USA.
23 *
24 */
25
26#include "config.h"
27
28#include <stdlib.h>
29#ifdef HAVE_UNISTD_H1
30# include <unistd.h>
31#endif
32
33#include <fcntl.h>
34#include <stdio.h>
35#include <string.h>
36#include <sys/types.h>
37#include <pwd.h>
38#include <grp.h>
39#include <security/pam_appl.h>
40#include <signal.h>
41#include <errno(*__errno_location ()).h>
42
43#include <glib.h>
44#include <glib/gstdio.h>
45#include <glib/gi18n.h>
46#include <gtk/gtk.h>
47
48#include "gs-auth.h"
49#include "gs-auth-pam.h"
50
51#include "subprocs.h"
52
53/* Some time between Red Hat 4.2 and 7.0, the words were transposed
54 in the various PAM_x_CRED macro names. Yay!
55*/
56#ifndef PAM_REFRESH_CRED0x0010U
57# define PAM_REFRESH_CRED0x0010U PAM_CRED_REFRESH
58#endif
59
60#ifdef HAVE_PAM_FAIL_DELAY
61/* We handle delays ourself.*/
62/* Don't set this to 0 (Linux bug workaround.) */
63# define PAM_NO_DELAY(pamh)pam_fail_delay ((pamh), 1) pam_fail_delay ((pamh), 1)
64#else /* !HAVE_PAM_FAIL_DELAY */
65# define PAM_NO_DELAY(pamh)pam_fail_delay ((pamh), 1) /* */
66#endif /* !HAVE_PAM_FAIL_DELAY */
67
68/* On SunOS 5.6, and on Linux with PAM 0.64, pam_strerror() takes two args.
69 On some other Linux systems with some other version of PAM (e.g.,
70 whichever Debian release comes with a 2.2.5 kernel) it takes one arg.
71 I can't tell which is more "recent" or "correct" behavior, so configure
72 figures out which is in use for us. Shoot me!
73*/
74#ifdef PAM_STRERROR_TWO_ARGS1
75# define PAM_STRERROR(pamh, status)pam_strerror((pamh), (status)) pam_strerror((pamh), (status))
76#else /* !PAM_STRERROR_TWO_ARGS */
77# define PAM_STRERROR(pamh, status)pam_strerror((pamh), (status)) pam_strerror((status))
78#endif /* !PAM_STRERROR_TWO_ARGS */
79
80static gboolean verbose_enabled = FALSE(0);
81static pam_handle_t *pam_handle = NULL((void*)0);
82static gboolean did_we_ask_for_password = FALSE(0);
83
84struct pam_closure
85{
86 const char *username;
87 GSAuthMessageFunc cb_func;
88 gpointer cb_data;
89 int signal_fd;
90 int result;
91};
92
93typedef struct
94{
95 struct pam_closure *closure;
96 GSAuthMessageStyle style;
97 const char *msg;
98 char **resp;
99 gboolean should_interrupt_stack;
100} GsAuthMessageHandlerData;
101
102static GCond message_handled_condition;
103static GMutex message_handler_mutex;
104
105GQuark
106gs_auth_error_quark (void)
107{
108 static GQuark quark = 0;
109 if (! quark)
110 {
111 quark = g_quark_from_static_string ("gs_auth_error");
112 }
113
114 return quark;
115}
116
117void
118gs_auth_set_verbose (gboolean enabled)
119{
120 verbose_enabled = enabled;
121}
122
123gboolean
124gs_auth_get_verbose (void)
125{
126 return verbose_enabled;
127}
128
129static gboolean
130auth_message_handler (GSAuthMessageStyle style,
131 const char *msg,
132 char **response,
133 gpointer data)
134{
135 gboolean ret;
136
137 ret = TRUE(!(0));
138 *response = NULL((void*)0);
139
140 switch (style)
141 {
142 case GS_AUTH_MESSAGE_PROMPT_ECHO_ON:
143 break;
144 case GS_AUTH_MESSAGE_PROMPT_ECHO_OFF:
145 if (msg != NULL((void*)0) && g_str_has_prefix (msg, _("Password:")gettext ("Password:")))
146 {
147 did_we_ask_for_password = TRUE(!(0));
148 }
149 break;
150 case GS_AUTH_MESSAGE_ERROR_MSG:
151 break;
152 case GS_AUTH_MESSAGE_TEXT_INFO:
153 break;
154 default:
155 g_assert_not_reached ()do { (void) 0; __builtin_unreachable (); } while (0);
156 }
157
158 return ret;
159}
160
161static gboolean
162gs_auth_queued_message_handler (gpointer user_data)
163{
164 GsAuthMessageHandlerData *data = user_data;
165 gboolean res;
166
167 if (gs_auth_get_verbose ())
168 {
169 g_message ("Waiting for lock");
170 }
171
172 g_mutex_lock (&message_handler_mutex);
173
174 if (gs_auth_get_verbose ())
175 {
176 g_message ("Waiting for response");
177 }
178
179 res = data->closure->cb_func (data->style,
180 data->msg,
181 data->resp,
182 data->closure->cb_data);
183
184 data->should_interrupt_stack = res == FALSE(0);
185
186 g_cond_signal (&message_handled_condition);
187 g_mutex_unlock (&message_handler_mutex);
188
189 if (gs_auth_get_verbose ())
190 {
191 g_message ("Got response");
192 }
193
194 return FALSE(0);
195}
196
197static gboolean
198gs_auth_run_message_handler (struct pam_closure *c,
199 GSAuthMessageStyle style,
200 const char *msg,
201 char **resp)
202{
203 GsAuthMessageHandlerData data;
204
205 data.closure = c;
206 data.style = style;
207 data.msg = msg;
208 data.resp = resp;
209 data.should_interrupt_stack = TRUE(!(0));
210
211 g_mutex_lock (&message_handler_mutex);
212
213 /* Queue the callback in the gui (the main) thread
214 */
215 g_idle_add (gs_auth_queued_message_handler, &data);
216
217 if (gs_auth_get_verbose ())
218 {
219 g_message ("Waiting for respose to message style %d: '%s'", style, msg);
220 }
221
222 /* Wait for the response
223 */
224 g_cond_wait (&message_handled_condition,
225 &message_handler_mutex);
226 g_mutex_unlock (&message_handler_mutex);
227
228 if (gs_auth_get_verbose ())
229 {
230 g_message ("Got respose to message style %d: interrupt:%d", style, data.should_interrupt_stack);
231 }
232
233 return data.should_interrupt_stack == FALSE(0);
234}
235
236static int
237pam_conversation (int nmsgs,
238 const struct pam_message **msg,
239 struct pam_response **resp,
240 void *closure)
241{
242 int replies = 0;
243 struct pam_response *reply = NULL((void*)0);
244 struct pam_closure *c = (struct pam_closure *) closure;
245 gboolean res;
246 int ret;
247
248 reply = (struct pam_response *) calloc (nmsgs, sizeof (*reply));
249
250 if (reply == NULL((void*)0))
251 {
252 return PAM_CONV_ERR19;
253 }
254
255 res = TRUE(!(0));
256 ret = PAM_SUCCESS0;
257
258 for (replies = 0; replies < nmsgs && ret == PAM_SUCCESS0; replies++)
259 {
260 GSAuthMessageStyle style;
261 char *utf8_msg;
262
263 style = pam_style_to_gs_style (msg [replies]->msg_style);
264
265 utf8_msg = g_locale_to_utf8 (msg [replies]->msg,
266 -1,
267 NULL((void*)0),
268 NULL((void*)0),
269 NULL((void*)0));
270
271 /* if we couldn't convert text from locale then
272 * assume utf-8 and hope for the best */
273 if (utf8_msg == NULL((void*)0))
274 {
275 char *p;
276 char *q;
277
278 utf8_msg = g_strdup (msg [replies]->msg);
279
280 p = utf8_msg;
281 while (*p != '\0' && !g_utf8_validate ((const char *)p, -1, (const char **)&q))
282 {
283 *q = '?';
284 p = q + 1;
285 }
286 }
287
288 /* handle message locally first */
289 auth_message_handler (style,
290 utf8_msg,
291 &reply [replies].resp,
292 NULL((void*)0));
293
294 if (c->cb_func != NULL((void*)0))
295 {
296 if (gs_auth_get_verbose ())
297 {
298 g_message ("Handling message style %d: '%s'", style, utf8_msg);
299 }
300
301 /* blocks until the gui responds
302 */
303 res = gs_auth_run_message_handler (c,
304 style,
305 utf8_msg,
306 &reply [replies].resp);
307
308 if (gs_auth_get_verbose ())
309 {
310 g_message ("Msg handler returned %d", res);
311 }
312
313 /* If the handler returns FALSE - interrupt the PAM stack */
314 if (res)
315 {
316 reply [replies].resp_retcode = PAM_SUCCESS0;
317 }
318 else
319 {
320 int i;
321 for (i = 0; i <= replies; i++)
322 {
323 free (reply [i].resp);
324 }
325 free (reply);
326 reply = NULL((void*)0);
327 ret = PAM_CONV_ERR19;
328 }
329 }
330
331 g_free (utf8_msg);
332 }
333
334 *resp = reply;
335
336 return ret;
337}
338
339static gboolean
340close_pam_handle (int status)
341{
342
343 if (pam_handle != NULL((void*)0))
344 {
345 int status2;
346
347 status2 = pam_end (pam_handle, status);
348 pam_handle = NULL((void*)0);
349
350 if (gs_auth_get_verbose ())
351 {
352 g_message (" pam_end (...) ==> %d (%s)",
353 status2,
354 (status2 == PAM_SUCCESS0 ? "Success" : "Failure"));
355 }
356 }
357
358 return TRUE(!(0));
359}
360
361static gboolean
362create_pam_handle (const char *username,
363 const char *display,
364 struct pam_conv *conv,
365 int *status_code)
366{
367 int status;
368 const char *service = PAM_SERVICE_NAME"mate-screensaver";
369 char *disp;
370 gboolean ret;
371
372 if (pam_handle != NULL((void*)0))
373 {
374 g_warning ("create_pam_handle: Stale pam handle around, cleaning up");
375 close_pam_handle (PAM_SUCCESS0);
376 }
377
378 /* init things */
379 pam_handle = NULL((void*)0);
380 status = -1;
Value stored to 'status' is never read
381 disp = NULL((void*)0);
382 ret = TRUE(!(0));
383
384 /* Initialize a PAM session for the user */
385 if ((status = pam_start (service, username, conv, &pam_handle)) != PAM_SUCCESS0)
386 {
387 pam_handle = NULL((void*)0);
388 g_warning (_("Unable to establish service %s: %s\n")gettext ("Unable to establish service %s: %s\n"),
389 service,
390 PAM_STRERROR (NULL, status)pam_strerror((((void*)0)), (status)));
391
392 if (status_code != NULL((void*)0))
393 {
394 *status_code = status;
395 }
396
397 ret = FALSE(0);
398 goto out;
399 }
400
401 if (gs_auth_get_verbose ())
402 {
403 g_message ("pam_start (\"%s\", \"%s\", ...) ==> %d (%s)",
404 service,
405 username,
406 status,
407 PAM_STRERROR (pam_handle, status)pam_strerror((pam_handle), (status)));
408 }
409
410 disp = g_strdup (display);
411 if (disp == NULL((void*)0))
412 {
413 disp = g_strdup (":0.0");
414 }
415
416 if ((status = pam_set_item (pam_handle, PAM_TTY3, disp)) != PAM_SUCCESS0)
417 {
418 g_warning (_("Can't set PAM_TTY=%s")gettext ("Can't set PAM_TTY=%s"), display);
419
420 if (status_code != NULL((void*)0))
421 {
422 *status_code = status;
423 }
424
425 ret = FALSE(0);
426 goto out;
427 }
428
429 ret = TRUE(!(0));
430 g_cond_init (&message_handled_condition);
431 g_mutex_init (&message_handler_mutex);
432
433out:
434 if (status_code != NULL((void*)0))
435 {
436 *status_code = status;
437 }
438
439 g_free (disp);
440
441 return ret;
442}
443
444static void
445set_pam_error (GError **error,
446 int status)
447{
448 if (status == PAM_AUTH_ERR7 || status == PAM_USER_UNKNOWN10)
449 {
450 char *msg;
451
452 if (did_we_ask_for_password)
453 {
454 msg = g_strdup (_("Incorrect password.")gettext ("Incorrect password."));
455 }
456 else
457 {
458 msg = g_strdup (_("Authentication failed.")gettext ("Authentication failed."));
459 }
460
461 g_set_error (error,
462 GS_AUTH_ERRORgs_auth_error_quark (),
463 GS_AUTH_ERROR_AUTH_ERROR,
464 "%s",
465 msg);
466 g_free (msg);
467 }
468 else if (status == PAM_PERM_DENIED6)
469 {
470 g_set_error (error,
471 GS_AUTH_ERRORgs_auth_error_quark (),
472 GS_AUTH_ERROR_AUTH_DENIED,
473 "%s",
474 _("Not permitted to gain access at this time.")gettext ("Not permitted to gain access at this time."));
475 }
476 else if (status == PAM_ACCT_EXPIRED13)
477 {
478 g_set_error (error,
479 GS_AUTH_ERRORgs_auth_error_quark (),
480 GS_AUTH_ERROR_AUTH_DENIED,
481 "%s",
482 _("No longer permitted to access the system.")gettext ("No longer permitted to access the system."));
483 }
484
485}
486
487static gpointer
488gs_auth_thread_func (gpointer data)
489{
490 int auth_operation_fd;
491 static const int flags = 0;
492 int status;
493 int status2;
494 struct timespec timeout;
495 sigset_t set;
496 const void *p;
497
498 auth_operation_fd = GPOINTER_TO_INT (data)((gint) (glong) (data));
499
500 timeout.tv_sec = 0;
501 timeout.tv_nsec = 1;
502
503 set = block_sigchld ();
504
505 status = pam_authenticate (pam_handle, flags);
506
507 sigtimedwait (&set, NULL((void*)0), &timeout);
508 unblock_sigchld ();
509
510 if (gs_auth_get_verbose ())
511 {
512 g_message (" pam_authenticate (...) ==> %d (%s)",
513 status,
514 PAM_STRERROR (pam_handle, status)pam_strerror((pam_handle), (status)));
515 }
516
517 if (status != PAM_SUCCESS0)
518 {
519 goto done;
520 }
521
522 if ((status = pam_get_item (pam_handle, PAM_USER2, &p)) != PAM_SUCCESS0)
523 {
524 /* is not really an auth problem, but it will
525 pretty much look as such, it shouldn't really
526 happen */
527 goto done;
528 }
529
530 /* We don't actually care if the account modules fail or succeed,
531 * but we need to run them anyway because certain pam modules
532 * depend on side effects of the account modules getting run.
533 */
534 status2 = pam_acct_mgmt (pam_handle, 0);
535
536 if (gs_auth_get_verbose ())
537 {
538 g_message ("pam_acct_mgmt (...) ==> %d (%s)\n",
539 status2,
540 PAM_STRERROR (pam_handle, status2)pam_strerror((pam_handle), (status2)));
541 }
542
543 /* FIXME: should we handle these? */
544 switch (status2)
545 {
546 case PAM_SUCCESS0:
547 break;
548 case PAM_NEW_AUTHTOK_REQD12:
549 break;
550 case PAM_AUTHINFO_UNAVAIL9:
551 break;
552 case PAM_ACCT_EXPIRED13:
553 break;
554 case PAM_PERM_DENIED6:
555 break;
556 default :
557 break;
558 }
559
560 /* Each time we successfully authenticate, refresh credentials,
561 for Kerberos/AFS/DCE/etc. If this fails, just ignore that
562 failure and blunder along; it shouldn't matter.
563
564 Note: this used to be PAM_REFRESH_CRED instead of
565 PAM_REINITIALIZE_CRED, but Jason Heiss <jheiss@ee.washington.edu>
566 says that the Linux PAM library ignores that one, and only refreshes
567 credentials when using PAM_REINITIALIZE_CRED.
568 */
569 status2 = pam_setcred (pam_handle, PAM_REINITIALIZE_CRED0x0008U);
570 if (gs_auth_get_verbose ())
571 {
572 g_message (" pam_setcred (...) ==> %d (%s)",
573 status2,
574 PAM_STRERROR (pam_handle, status2)pam_strerror((pam_handle), (status2)));
575 }
576
577done:
578 /* we're done, close the fd and wake up the main
579 * loop
580 */
581 close (auth_operation_fd);
582
583 return GINT_TO_POINTER (status)((gpointer) (glong) (status));
584}
585
586static gboolean
587gs_auth_loop_quit (GIOChannel *source,
588 GIOCondition condition,
589 gboolean *thread_done)
590{
591 *thread_done = TRUE(!(0));
592 gtk_main_quit ();
593 return FALSE(0);
594}
595
596static gboolean
597gs_auth_pam_verify_user (pam_handle_t *handle,
598 int *status)
599{
600 GThread *auth_thread;
601 GIOChannel *channel;
602 guint watch_id;
603 int auth_operation_fds[2];
604 int auth_status;
605 gboolean thread_done;
606
607 channel = NULL((void*)0);
608 watch_id = 0;
609 auth_status = PAM_AUTH_ERR7;
610
611 /* This pipe gives us a set of fds we can hook into
612 * the event loop to be notified when our helper thread
613 * is ready to be reaped.
614 */
615 if (pipe (auth_operation_fds) < 0)
616 {
617 goto out;
618 }
619
620 if (fcntl (auth_operation_fds[0], F_SETFD2, FD_CLOEXEC1) < 0)
621 {
622 close (auth_operation_fds[0]);
623 close (auth_operation_fds[1]);
624 goto out;
625 }
626
627 if (fcntl (auth_operation_fds[1], F_SETFD2, FD_CLOEXEC1) < 0)
628 {
629 close (auth_operation_fds[0]);
630 close (auth_operation_fds[1]);
631 goto out;
632 }
633
634 channel = g_io_channel_unix_new (auth_operation_fds[0]);
635
636 /* we use a recursive main loop to process ui events
637 * while we wait on a thread to handle the blocking parts
638 * of pam authentication.
639 */
640 thread_done = FALSE(0);
641 watch_id = g_io_add_watch (channel, G_IO_ERR | G_IO_HUP,
642 (GIOFunc) gs_auth_loop_quit, &thread_done);
643
644 auth_thread = g_thread_new ("auththread",
645 gs_auth_thread_func,
646 GINT_TO_POINTER (auth_operation_fds[1])((gpointer) (glong) (auth_operation_fds[1])));
647
648 if (auth_thread == NULL((void*)0))
649 {
650 goto out;
651 }
652
653 gtk_main ();
654
655 /* if the event loop was quit before the thread is done then we can't
656 * reap the thread without blocking on it finishing. The
657 * thread may not ever finish though if the pam module is blocking.
658 *
659 * The only time the event loop is going to stop when the thread isn't
660 * done, however, is if the dialog quits early (from, e.g., "cancel"),
661 * so we can just exit. An alternative option would be to switch to
662 * using pthreads directly and calling pthread_cancel.
663 */
664 if (!thread_done)
665 {
666 raise (SIGTERM15);
667 }
668
669 auth_status = GPOINTER_TO_INT (g_thread_join (auth_thread))((gint) (glong) (g_thread_join (auth_thread)));
670
671out:
672 if (watch_id != 0)
673 {
674 g_source_remove (watch_id);
675 watch_id = 0;
676 }
677
678 if (channel != NULL((void*)0))
679 {
680 g_io_channel_unref (channel);
681 }
682
683 if (status)
684 {
685 *status = auth_status;
686 }
687
688 return auth_status == PAM_SUCCESS0;
689}
690
691gboolean
692gs_auth_verify_user (const char *username,
693 const char *display,
694 GSAuthMessageFunc func,
695 gpointer data,
696 GError **error)
697{
698 int status = -1;
699 struct pam_conv conv;
700 struct pam_closure c;
701 struct passwd *pwent;
702
703 pwent = getpwnam (username);
704 if (pwent == NULL((void*)0))
705 {
706 return FALSE(0);
707 }
708
709 c.username = username;
710 c.cb_func = func;
711 c.cb_data = data;
712
713 conv.conv = &pam_conversation;
714 conv.appdata_ptr = (void *) &c;
715
716 /* Initialize PAM. */
717 create_pam_handle (username, display, &conv, &status);
718 if (status != PAM_SUCCESS0)
719 {
720 goto done;
721 }
722
723 pam_set_item (pam_handle, PAM_USER_PROMPT9, _("Username:")gettext ("Username:"));
724
725 PAM_NO_DELAY(pam_handle)pam_fail_delay ((pam_handle), 1);
726
727 did_we_ask_for_password = FALSE(0);
728 if (! gs_auth_pam_verify_user (pam_handle, &status))
729 {
730 goto done;
731 }
732
733done:
734 if (status != PAM_SUCCESS0)
735 {
736 set_pam_error (error, status);
737 }
738
739 close_pam_handle (status);
740
741 return (status == PAM_SUCCESS0 ? TRUE(!(0)) : FALSE(0));
742}
743
744gboolean
745gs_auth_init (void)
746{
747 return TRUE(!(0));
748}
749
750gboolean
751gs_auth_priv_init (void)
752{
753 /* We have nothing to do at init-time.
754 However, we might as well do some error checking.
755 If "/etc/pam.d" exists and is a directory, but "/etc/pam.d/xlock"
756 does not exist, warn that PAM probably isn't going to work.
757
758 This is a priv-init instead of a non-priv init in case the directory
759 is unreadable or something (don't know if that actually happens.)
760 */
761 const char dir [] = "/etc/pam.d";
762 const char file [] = "/etc/pam.d/" PAM_SERVICE_NAME"mate-screensaver";
763 const char file2 [] = "/etc/pam.conf";
764 struct stat st;
765
766 if (g_statstat (dir, &st) == 0 && st.st_mode & S_IFDIR0040000)
767 {
768 if (g_statstat (file, &st) != 0)
769 {
770 g_warning ("%s does not exist.\n"
771 "Authentication via PAM is unlikely to work.",
772 file);
773 }
774 }
775 else if (g_statstat (file2, &st) == 0)
776 {
777 FILE *f = g_fopenfopen (file2, "r");
778 if (f)
779 {
780 gboolean ok = FALSE(0);
781 char buf[255];
782 while (fgets (buf, sizeof(buf), f))
783 {
784 if (strstr (buf, PAM_SERVICE_NAME"mate-screensaver"))
785 {
786 ok = TRUE(!(0));
787 break;
788 }
789 }
790
791 fclose (f);
792 if (!ok)
793 {
794 g_warning ("%s does not list the `%s' service.\n"
795 "Authentication via PAM is unlikely to work.",
796 file2, PAM_SERVICE_NAME"mate-screensaver");
797 }
798 }
799 /* else warn about file2 existing but being unreadable? */
800 }
801 else
802 {
803 g_warning ("Neither %s nor %s exist.\n"
804 "Authentication via PAM is unlikely to work.",
805 file2, file);
806 }
807
808 /* Return true anyway, just in case. */
809 return TRUE(!(0));
810}
diff --git a/2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-57e5d7.html b/2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-57e5d7.html new file mode 100644 index 0000000..db7bcc0 --- /dev/null +++ b/2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-57e5d7.html @@ -0,0 +1,1236 @@ + + + +mate-screensaver-command.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rc/mate-screensaver-command.c
Warning:line 440, column 3
Value stored to 'reply' is never read
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name mate-screensaver-command.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/14.0.5 -D HAVE_CONFIG_H -I . -I .. -I . -I . -D MATEMENU_I_KNOW_THIS_IS_UNSTABLE -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/dconf -I /usr/include/mate-menus -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/dconf -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/dconf -I /usr/include/mate-menus -D PREFIX="/usr/local" -D BINDIR="/usr/local/bin" -D LIBDIR="/usr/local/lib" -D LIBEXECDIR="/usr/local/libexec" -D DATADIR="/usr/local/share" -D SYSCONFDIR="/usr/local/etc" -D MATELOCALEDIR="/usr/local/share/locale" -D PKGLIBEXECDIR="/usr/local/libexec/mate-screensaver" -D SAVERDIR="/usr/local/libexec/mate-screensaver" -D THEMESDIR="/usr/local/share/mate-screensaver/themes" -D GTKBUILDERDIR="/usr/local/share/mate-screensaver" -D MATE_SCREENSAVER_GL_HELPER_PATH="/usr/local/libexec/mate-screensaver-gl-helper" -D PAM_SERVICE_NAME="mate-screensaver" -D G_DISABLE_ASSERT -D G_DISABLE_CHECKS -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -internal-isystem /usr/lib64/clang/14.0.5/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/12/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2022-11-11-203102-6531-1 -x c mate-screensaver-command.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
2 *
3 * Copyright (C) 2004-2006 William Jon McCann <mccann@jhu.edu>
4 * Copyright (C) 2012-2021 MATE Developers
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; either version 2 of the
9 * License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
19 * 02110-1301, USA.
20 *
21 * Authors: William Jon McCann <mccann@jhu.edu>
22 *
23 */
24
25#include "config.h"
26
27#include <stdlib.h>
28#include <locale.h>
29#include <glib.h>
30#include <glib/gi18n.h>
31
32#define DBUS_API_SUBJECT_TO_CHANGE
33#include <dbus/dbus.h>
34#include <dbus/dbus-glib.h>
35#include <dbus/dbus-glib-lowlevel.h>
36
37#define GS_SERVICE"org.mate.ScreenSaver" "org.mate.ScreenSaver"
38#define GS_PATH"/org/mate/ScreenSaver" "/org/mate/ScreenSaver"
39#define GS_INTERFACE"org.mate.ScreenSaver" "org.mate.ScreenSaver"
40
41static gboolean do_quit = FALSE(0);
42static gboolean do_lock = FALSE(0);
43static gboolean do_unlock = FALSE(0);
44static gboolean do_cycle = FALSE(0);
45static gboolean do_activate = FALSE(0);
46static gboolean do_deactivate = FALSE(0);
47static gboolean do_version = FALSE(0);
48static gboolean do_poke = FALSE(0);
49static gboolean do_inhibit = FALSE(0);
50
51static gboolean do_query = FALSE(0);
52static gboolean do_time = FALSE(0);
53
54static char *inhibit_reason = NULL((void*)0);
55static char *inhibit_application = NULL((void*)0);
56
57static GOptionEntry entries [] =
58{
59 {
60 "exit", 0, 0, G_OPTION_ARG_NONE, &do_quit,
61 N_("Causes the screensaver to exit gracefully")("Causes the screensaver to exit gracefully"), NULL((void*)0)
62 },
63 {
64 "query", 'q', 0, G_OPTION_ARG_NONE, &do_query,
65 N_("Query the state of the screensaver")("Query the state of the screensaver"), NULL((void*)0)
66 },
67 {
68 "time", 't', 0, G_OPTION_ARG_NONE, &do_time,
69 N_("Query the length of time the screensaver has been active")("Query the length of time the screensaver has been active"), NULL((void*)0)
70 },
71 {
72 "lock", 'l', 0, G_OPTION_ARG_NONE, &do_lock,
73 N_("Tells the running screensaver process to lock the screen immediately")("Tells the running screensaver process to lock the screen immediately"
)
, NULL((void*)0)
74 },
75 {
76 "unlock", 'u', 0, G_OPTION_ARG_NONE, &do_unlock,
77 N_("Tells the running screensaver process to unlock the screen immediately")("Tells the running screensaver process to unlock the screen immediately"
)
, NULL((void*)0)
78 },
79 {
80 "cycle", 'c', 0, G_OPTION_ARG_NONE, &do_cycle,
81 N_("If the screensaver is active then switch to another graphics demo")("If the screensaver is active then switch to another graphics demo"
)
, NULL((void*)0)
82 },
83 {
84 "activate", 'a', 0, G_OPTION_ARG_NONE, &do_activate,
85 N_("Turn the screensaver on (blank the screen)")("Turn the screensaver on (blank the screen)"), NULL((void*)0)
86 },
87 {
88 "deactivate", 'd', 0, G_OPTION_ARG_NONE, &do_deactivate,
89 N_("If the screensaver is active then deactivate it (un-blank the screen)")("If the screensaver is active then deactivate it (un-blank the screen)"
)
, NULL((void*)0)
90 },
91 {
92 "poke", 'p', 0, G_OPTION_ARG_NONE, &do_poke,
93 N_("Poke the running screensaver to simulate user activity")("Poke the running screensaver to simulate user activity"), NULL((void*)0)
94 },
95 {
96 "inhibit", 'i', 0, G_OPTION_ARG_NONE, &do_inhibit,
97 N_("Inhibit the screensaver from activating. Command blocks while inhibit is active.")("Inhibit the screensaver from activating. Command blocks while inhibit is active."
)
, NULL((void*)0)
98 },
99 {
100 "application-name", 'n', 0, G_OPTION_ARG_STRING, &inhibit_application,
101 N_("The calling application that is inhibiting the screensaver")("The calling application that is inhibiting the screensaver"
)
, NULL((void*)0)
102 },
103 {
104 "reason", 'r', 0, G_OPTION_ARG_STRING, &inhibit_reason,
105 N_("The reason for inhibiting the screensaver")("The reason for inhibiting the screensaver"), NULL((void*)0)
106 },
107 {
108 "version", 'V', 0, G_OPTION_ARG_NONE, &do_version,
109 N_("Version of this application")("Version of this application"), NULL((void*)0)
110 },
111 { NULL((void*)0), 0, 0, G_OPTION_ARG_NONE, NULL((void*)0), NULL((void*)0), NULL((void*)0) }
112};
113
114static GMainLoop *loop = NULL((void*)0);
115
116static gboolean
117screensaver_is_running (DBusConnection *connection)
118{
119 DBusError error;
120 gboolean exists;
121
122 g_return_val_if_fail (connection != NULL, FALSE)do{ (void)0; }while (0);
123
124 dbus_error_init (&error);
125 exists = dbus_bus_name_has_owner (connection, GS_SERVICE"org.mate.ScreenSaver", &error);
126 if (dbus_error_is_set (&error))
127 dbus_error_free (&error);
128
129 return exists;
130}
131
132static DBusMessage *
133screensaver_send_message_inhibit (DBusConnection *connection,
134 const char *application,
135 const char *reason)
136{
137 DBusMessage *message;
138 DBusMessage *reply;
139 DBusError error;
140 DBusMessageIter iter;
141
142 g_return_val_if_fail (connection != NULL, NULL)do{ (void)0; }while (0);
143
144 dbus_error_init (&error);
145
146 message = dbus_message_new_method_call (GS_SERVICE"org.mate.ScreenSaver", GS_PATH"/org/mate/ScreenSaver", GS_INTERFACE"org.mate.ScreenSaver", "Inhibit");
147 if (message == NULL((void*)0))
148 {
149 g_warning ("Couldn't allocate the dbus message");
150 return NULL((void*)0);
151 }
152
153 dbus_message_iter_init_append (message, &iter);
154 dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING((int) 's'), &application);
155 dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING((int) 's'), &reason);
156
157 reply = dbus_connection_send_with_reply_and_block (connection,
158 message,
159 -1, &error);
160 if (dbus_error_is_set (&error))
161 {
162 g_warning ("%s raised:\n %s\n\n", error.name, error.message);
163 reply = NULL((void*)0);
164 }
165
166 dbus_connection_flush (connection);
167
168 dbus_message_unref (message);
169 dbus_error_free (&error);
170
171 return reply;
172}
173
174static DBusMessage *
175screensaver_send_message_bool (DBusConnection *connection,
176 const char *name,
177 gboolean value)
178{
179 DBusMessage *message;
180 DBusMessage *reply;
181 DBusError error;
182 DBusMessageIter iter;
183
184 g_return_val_if_fail (connection != NULL, NULL)do{ (void)0; }while (0);
185 g_return_val_if_fail (name != NULL, NULL)do{ (void)0; }while (0);
186
187 dbus_error_init (&error);
188
189 message = dbus_message_new_method_call (GS_SERVICE"org.mate.ScreenSaver", GS_PATH"/org/mate/ScreenSaver", GS_INTERFACE"org.mate.ScreenSaver", name);
190 if (message == NULL((void*)0))
191 {
192 g_warning ("Couldn't allocate the dbus message");
193 return NULL((void*)0);
194 }
195
196 dbus_message_iter_init_append (message, &iter);
197 dbus_message_iter_append_basic (&iter, DBUS_TYPE_BOOLEAN((int) 'b'), &value);
198
199 reply = dbus_connection_send_with_reply_and_block (connection,
200 message,
201 -1, &error);
202 if (dbus_error_is_set (&error))
203 {
204 g_warning ("%s raised:\n %s\n\n", error.name, error.message);
205 reply = NULL((void*)0);
206 }
207
208 dbus_connection_flush (connection);
209
210 dbus_message_unref (message);
211 dbus_error_free (&error);
212
213 return reply;
214}
215
216static DBusMessage *
217screensaver_send_message_void (DBusConnection *connection,
218 const char *name,
219 gboolean expect_reply)
220{
221 DBusMessage *message;
222 DBusMessage *reply;
223 DBusError error;
224
225 g_return_val_if_fail (connection != NULL, NULL)do{ (void)0; }while (0);
226 g_return_val_if_fail (name != NULL, NULL)do{ (void)0; }while (0);
227
228 dbus_error_init (&error);
229
230 message = dbus_message_new_method_call (GS_SERVICE"org.mate.ScreenSaver", GS_PATH"/org/mate/ScreenSaver", GS_INTERFACE"org.mate.ScreenSaver", name);
231 if (message == NULL((void*)0))
232 {
233 g_warning ("Couldn't allocate the dbus message");
234 return NULL((void*)0);
235 }
236
237 if (! expect_reply)
238 {
239 if (!dbus_connection_send (connection, message, NULL((void*)0)))
240 g_warning ("could not send message");
241 reply = NULL((void*)0);
242 }
243 else
244 {
245 reply = dbus_connection_send_with_reply_and_block (connection,
246 message,
247 -1, &error);
248 if (dbus_error_is_set (&error))
249 {
250 g_warning ("%s raised:\n %s\n\n", error.name, error.message);
251 reply = NULL((void*)0);
252 }
253 }
254 dbus_connection_flush (connection);
255
256 dbus_message_unref (message);
257 dbus_error_free (&error);
258
259 return reply;
260}
261
262static char **
263get_string_from_iter (DBusMessageIter *iter,
264 int *num_elements)
265{
266 int count;
267 char **buffer;
268
269 if (num_elements != NULL((void*)0))
270 {
271 *num_elements = 0;
272 }
273
274 count = 0;
275 buffer = (char **)malloc (sizeof (char *) * 8);
276
277 if (buffer == NULL((void*)0))
278 {
279 goto oom;
280 }
281
282 buffer[0] = NULL((void*)0);
283 while (dbus_message_iter_get_arg_type (iter) == DBUS_TYPE_STRING((int) 's'))
284 {
285 const char *value;
286 char *str;
287
288 if ((count % 8) == 0 && count != 0)
289 {
290 buffer = realloc (buffer, sizeof (char *) * (count + 8));
291 if (buffer == NULL((void*)0))
292 {
293 goto oom;
294 }
295 }
296
297 dbus_message_iter_get_basic (iter, &value);
298 str = strdup (value);
299 if (str == NULL((void*)0))
300 {
301 goto oom;
302 }
303
304 buffer[count] = str;
305
306 dbus_message_iter_next (iter);
307 count++;
308 }
309
310 if ((count % 8) == 0)
311 {
312 buffer = realloc (buffer, sizeof (char *) * (count + 1));
313 if (buffer == NULL((void*)0))
314 {
315 goto oom;
316 }
317 }
318
319 buffer[count] = NULL((void*)0);
320 if (num_elements != NULL((void*)0))
321 {
322 *num_elements = count;
323 }
324 return buffer;
325
326oom:
327 g_debug ("%s %d : error allocating memory\n", __FILE__"mate-screensaver-command.c", __LINE__327);
328 return NULL((void*)0);
329
330}
331
332static gboolean
333do_command (gpointer data)
334{
335 DBusConnection *connection = data;
336 DBusMessage *reply;
337
338 if (do_quit)
339 {
340 reply = screensaver_send_message_void (connection, "Quit", FALSE(0));
341 goto done;
342 }
343
344 if (do_query)
345 {
346 DBusMessageIter iter;
347 DBusMessageIter array;
348 dbus_bool_t v;
349
350 reply = screensaver_send_message_void (connection, "GetActive", TRUE(!(0)));
351 if (! reply)
352 {
353 g_message ("Did not receive a reply from the screensaver.");
354 goto done;
355 }
356
357 dbus_message_iter_init (reply, &iter);
358 dbus_message_iter_get_basic (&iter, &v);
359 g_print (_("The screensaver is %s\n")gettext ("The screensaver is %s\n"), v ? _("active")gettext ("active") : _("inactive")gettext ("inactive"));
360
361 dbus_message_unref (reply);
362
363 reply = screensaver_send_message_void (connection, "GetInhibitors", TRUE(!(0)));
364 if (! reply)
365 {
366 g_message ("Did not receive a reply from screensaver.");
367 goto done;
368 }
369
370 dbus_message_iter_init (reply, &iter);
371 dbus_message_iter_recurse (&iter, &array);
372
373 if (dbus_message_iter_get_arg_type (&array) == DBUS_TYPE_INVALID((int) '\0'))
374 {
375 g_print (_("The screensaver is not inhibited\n")gettext ("The screensaver is not inhibited\n"));
376 }
377 else
378 {
379 char **inhibitors;
380 int i;
381 int num;
382
383 g_print (_("The screensaver is being inhibited by:\n")gettext ("The screensaver is being inhibited by:\n"));
384 inhibitors = get_string_from_iter (&array, &num);
385 for (i = 0; i < num; i++)
386 {
387 g_print ("\t%s\n", inhibitors[i]);
388 }
389 g_strfreev (inhibitors);
390 }
391
392 dbus_message_unref (reply);
393 }
394
395 if (do_time)
396 {
397 DBusMessageIter iter;
398 dbus_bool_t v;
399 dbus_int32_t t;
400
401 reply = screensaver_send_message_void (connection, "GetActive", TRUE(!(0)));
402 if (! reply)
403 {
404 g_message ("Did not receive a reply from the screensaver.");
405 goto done;
406 }
407
408 dbus_message_iter_init (reply, &iter);
409 dbus_message_iter_get_basic (&iter, &v);
410 dbus_message_unref (reply);
411
412 if (v)
413 {
414
415 reply = screensaver_send_message_void (connection, "GetActiveTime", TRUE(!(0)));
416 dbus_message_iter_init (reply, &iter);
417 dbus_message_iter_get_basic (&iter, &t);
418 g_print (_("The screensaver has been active for %d seconds.\n")gettext ("The screensaver has been active for %d seconds.\n"), t);
419
420 dbus_message_unref (reply);
421 }
422 else
423 {
424 g_print (_("The screensaver is not currently active.\n")gettext ("The screensaver is not currently active.\n"));
425 }
426 }
427
428 if (do_lock)
429 {
430 reply = screensaver_send_message_void (connection, "Lock", FALSE(0));
431 }
432
433 if (do_unlock)
434 {
435 reply = screensaver_send_message_void (connection, "Unlock", FALSE(0));
436 }
437
438 if (do_cycle)
439 {
440 reply = screensaver_send_message_void (connection, "Cycle", FALSE(0));
Value stored to 'reply' is never read
441 }
442
443 if (do_poke)
444 {
445 reply = screensaver_send_message_void (connection, "SimulateUserActivity", FALSE(0));
446 }
447
448 if (do_activate)
449 {
450 reply = screensaver_send_message_bool (connection, "SetActive", TRUE(!(0)));
451 if (! reply)
452 {
453 g_message ("Did not receive a reply from the screensaver.");
454 goto done;
455 }
456 dbus_message_unref (reply);
457 }
458
459 if (do_deactivate)
460 {
461 reply = screensaver_send_message_bool (connection, "SetActive", FALSE(0));
462 if (! reply)
463 {
464 g_message ("Did not receive a reply from the screensaver.");
465 goto done;
466 }
467 dbus_message_unref (reply);
468 }
469
470 if (do_inhibit)
471 {
472 reply = screensaver_send_message_inhibit (connection,
473 inhibit_application ? inhibit_application : "Unknown",
474 inhibit_reason ? inhibit_reason : "Unknown");
475 if (! reply)
476 {
477 g_message ("Did not receive a reply from the screensaver.");
478 goto done;
479 }
480 dbus_message_unref (reply);
481
482 return FALSE(0);
483 }
484
485done:
486 g_main_loop_quit (loop);
487
488 return FALSE(0);
489}
490
491int
492main (int argc,
493 char **argv)
494{
495 DBusConnection *connection;
496 DBusError dbus_error;
497 GOptionContext *context;
498 gboolean retval;
499 GError *error = NULL((void*)0);
500
501#ifdef ENABLE_NLS1
502 bindtextdomain (GETTEXT_PACKAGE"mate-screensaver", MATELOCALEDIR"/usr/local/share/locale");
503# ifdef HAVE_BIND_TEXTDOMAIN_CODESET
504 bind_textdomain_codeset (GETTEXT_PACKAGE"mate-screensaver", "UTF-8");
505# endif
506 textdomain (GETTEXT_PACKAGE"mate-screensaver");
507#endif
508
509 g_set_prgname (argv[0]);
510
511 if (setlocale (LC_ALL6, "") == NULL((void*)0))
512 g_warning ("Locale not understood by C library, internationalization will not work\n");
513
514 context = g_option_context_new (NULL((void*)0));
515 g_option_context_add_main_entries (context, entries, NULL((void*)0));
516 retval = g_option_context_parse (context, &argc, &argv, &error);
517
518 g_option_context_free (context);
519
520 if (! retval)
521 {
522 g_warning ("%s", error->message);
523 g_error_free (error);
524 exit (1);
525 }
526
527 if (do_version)
528 {
529 g_print ("%s %s\n", argv [0], VERSION"1.27.0");
530 exit (1);
531 }
532
533 dbus_error_init (&dbus_error);
534 connection = dbus_bus_get (DBUS_BUS_SESSION, &dbus_error);
535 if (! connection)
536 {
537 g_message ("Failed to connect to the D-BUS daemon: %s", dbus_error.message);
538 dbus_error_free (&dbus_error);
539 exit (1);
540 }
541
542 dbus_connection_setup_with_g_main (connection, NULL((void*)0));
543
544 if (! screensaver_is_running (connection))
545 {
546 g_message ("Screensaver is not running!");
547 exit (1);
548 }
549
550 g_idle_add (do_command, connection);
551
552 loop = g_main_loop_new (NULL((void*)0), FALSE(0));
553 g_main_loop_run (loop);
554
555 return 0;
556}
diff --git a/2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-5a3c1b.html b/2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-5a3c1b.html new file mode 100644 index 0000000..4e0afe5 --- /dev/null +++ b/2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-5a3c1b.html @@ -0,0 +1,848 @@ + + + +xdg-user-dir-lookup.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:avers/xdg-user-dir-lookup.c
Warning:line 146, column 3
Call to function 'strcat' is insecure as it does not provide bounding of the memory buffer. Replace unbounded copy functions with analogous functions that support length arguments such as 'strlcat'. CWE-119
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name xdg-user-dir-lookup.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/savers -resource-dir /usr/lib64/clang/14.0.5 -D HAVE_CONFIG_H -I . -I .. -I . -I . -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -D LIBEXECDIR="/usr/local/libexec" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -internal-isystem /usr/lib64/clang/14.0.5/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/12/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdebug-compilation-dir=/rootdir/savers -ferror-limit 19 -fgnuc-version=4.2.1 -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2022-11-11-203102-6531-1 -x c xdg-user-dir-lookup.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/*
2 This file is not licenced under the GPL like the rest of the code.
3 Its is under the MIT license, to encourage reuse by cut-and-paste.
4
5 Copyright (c) 2007 Red Hat, inc
6 Copyright (C) 2012-2021 MATE Developers
7
8 Permission is hereby granted, free of charge, to any person
9 obtaining a copy of this software and associated documentation files
10 (the "Software"), to deal in the Software without restriction,
11 including without limitation the rights to use, copy, modify, merge,
12 publish, distribute, sublicense, and/or sell copies of the Software,
13 and to permit persons to whom the Software is furnished to do so,
14 subject to the following conditions:
15
16 The above copyright notice and this permission notice shall be
17 included in all copies or substantial portions of the Software.
18
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
23 BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
24 ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
25 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26 SOFTWARE.
27*/
28
29#include <stdio.h>
30#include <stdlib.h>
31#include <string.h>
32
33#include "xdg-user-dir-lookup.h"
34
35char *
36xdg_user_dir_lookup (const char *type)
37{
38 FILE *file;
39 char *home_dir, *config_home, *config_file;
40 char buffer[512];
41 char *user_dir;
42 char *p, *d;
43 int relative;
44
45 home_dir = getenv ("HOME");
46
47 if (home_dir == NULL((void*)0))
48 return strdup ("/tmp");
49
50 config_home = getenv ("XDG_CONFIG_HOME");
51 if (config_home == NULL((void*)0) || config_home[0] == 0)
52 {
53 config_file = malloc (strlen (home_dir) + strlen ("/.config/user-dirs.dirs") + 1);
54 strcpy (config_file, home_dir);
55 strcat (config_file, "/.config/user-dirs.dirs");
56 }
57 else
58 {
59 config_file = malloc (strlen (config_home) + strlen ("/user-dirs.dirs") + 1);
60 strcpy (config_file, config_home);
61 strcat (config_file, "/user-dirs.dirs");
62 }
63
64 file = fopen (config_file, "r");
65 free (config_file);
66 if (file == NULL((void*)0))
67 goto error;
68
69 user_dir = NULL((void*)0);
70 while (fgets (buffer, sizeof (buffer), file))
71 {
72 /* Remove newline at end */
73 size_t len = strlen (buffer);
74 if (len != 0 && buffer[len-1] == '\n')
75 buffer[len-1] = 0;
76
77 p = buffer;
78 while (*p == ' ' || *p == '\t')
79 p++;
80
81 if (strncmp (p, "XDG_", 4) != 0)
82 continue;
83 p += 4;
84 if (strncmp (p, type, strlen (type)) != 0)
85 continue;
86 p += strlen (type);
87 if (strncmp (p, "_DIR", 4) != 0)
88 continue;
89 p += 4;
90
91 while (*p == ' ' || *p == '\t')
92 p++;
93
94 if (*p != '=')
95 continue;
96 p++;
97
98 while (*p == ' ' || *p == '\t')
99 p++;
100
101 if (*p != '"')
102 continue;
103 p++;
104
105 relative = 0;
106 if (strncmp (p, "$HOME/", 6) == 0)
107 {
108 p += 6;
109 relative = 1;
110 }
111 else if (*p != '/')
112 continue;
113
114 if (relative)
115 {
116 user_dir = malloc (strlen (home_dir) + 1 + strlen (p) + 1);
117 strcpy (user_dir, home_dir);
118 strcat (user_dir, "/");
119 }
120 else
121 {
122 user_dir = malloc (strlen (p) + 1);
123 *user_dir = 0;
124 }
125
126 d = user_dir + strlen (user_dir);
127 while (*p && *p != '"')
128 {
129 if ((*p == '\\') && (*(p+1) != 0))
130 p++;
131 *d++ = *p++;
132 }
133 *d = 0;
134 }
135 fclose (file);
136
137 if (user_dir)
138 return user_dir;
139
140error:
141 /* Special case desktop for historical compatibility */
142 if (strcmp (type, "DESKTOP") == 0)
143 {
144 user_dir = malloc (strlen (home_dir) + strlen ("/Desktop") + 1);
145 strcpy (user_dir, home_dir);
146 strcat (user_dir, "/Desktop");
Call to function 'strcat' is insecure as it does not provide bounding of the memory buffer. Replace unbounded copy functions with analogous functions that support length arguments such as 'strlcat'. CWE-119
147 return user_dir;
148 }
149 else
150 return strdup (home_dir);
151}
152
153#ifdef STANDALONE
154
155int
156main (int argc, char *argv[])
157{
158 if (argc != 2)
159 {
160 fprintf (stderrstderr, "Usage %s <dir-type>\n", argv[0]);
161 exit (1);
162 }
163
164 printf ("%s\n", xdg_user_dir_lookup (argv[1]));
165 return 0;
166}
167
168#endif
diff --git a/2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-68e8c1.html b/2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-68e8c1.html new file mode 100644 index 0000000..825f996 --- /dev/null +++ b/2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-68e8c1.html @@ -0,0 +1,1490 @@ + + + +gs-auth-pam.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rc/gs-auth-pam.c
Warning:line 675, column 3
Value stored to 'watch_id' is never read
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name gs-auth-pam.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/14.0.5 -D HAVE_CONFIG_H -I . -I .. -I . -I . -D MATEMENU_I_KNOW_THIS_IS_UNSTABLE -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/dconf -I /usr/include/mate-menus -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/dconf -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/dconf -I /usr/include/mate-menus -D PREFIX="/usr/local" -D BINDIR="/usr/local/bin" -D LIBDIR="/usr/local/lib" -D LIBEXECDIR="/usr/local/libexec" -D DATADIR="/usr/local/share" -D SYSCONFDIR="/usr/local/etc" -D MATELOCALEDIR="/usr/local/share/locale" -D PKGLIBEXECDIR="/usr/local/libexec/mate-screensaver" -D SAVERDIR="/usr/local/libexec/mate-screensaver" -D THEMESDIR="/usr/local/share/mate-screensaver/themes" -D GTKBUILDERDIR="/usr/local/share/mate-screensaver" -D MATE_SCREENSAVER_GL_HELPER_PATH="/usr/local/libexec/mate-screensaver-gl-helper" -D PAM_SERVICE_NAME="mate-screensaver" -D G_DISABLE_ASSERT -D G_DISABLE_CHECKS -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -internal-isystem /usr/lib64/clang/14.0.5/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/12/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2022-11-11-203102-6531-1 -x c gs-auth-pam.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
2 *
3 * Copyright (C) 2006 William Jon McCann <mccann@jhu.edu>
4 * Copyright (C) 2006 Ray Strode <rstrode@redhat.com>
5 * Copyright (C) 2003 Bill Nottingham <notting@redhat.com>
6 * Copyright (c) 1993-2003 Jamie Zawinski <jwz@jwz.org>
7 * Copyright (C) 2012-2021 MATE Developers
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License as
11 * published by the Free Software Foundation; either version 2 of the
12 * License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
22 * 02110-1301, USA.
23 *
24 */
25
26#include "config.h"
27
28#include <stdlib.h>
29#ifdef HAVE_UNISTD_H1
30# include <unistd.h>
31#endif
32
33#include <fcntl.h>
34#include <stdio.h>
35#include <string.h>
36#include <sys/types.h>
37#include <pwd.h>
38#include <grp.h>
39#include <security/pam_appl.h>
40#include <signal.h>
41#include <errno(*__errno_location ()).h>
42
43#include <glib.h>
44#include <glib/gstdio.h>
45#include <glib/gi18n.h>
46#include <gtk/gtk.h>
47
48#include "gs-auth.h"
49#include "gs-auth-pam.h"
50
51#include "subprocs.h"
52
53/* Some time between Red Hat 4.2 and 7.0, the words were transposed
54 in the various PAM_x_CRED macro names. Yay!
55*/
56#ifndef PAM_REFRESH_CRED0x0010U
57# define PAM_REFRESH_CRED0x0010U PAM_CRED_REFRESH
58#endif
59
60#ifdef HAVE_PAM_FAIL_DELAY
61/* We handle delays ourself.*/
62/* Don't set this to 0 (Linux bug workaround.) */
63# define PAM_NO_DELAY(pamh)pam_fail_delay ((pamh), 1) pam_fail_delay ((pamh), 1)
64#else /* !HAVE_PAM_FAIL_DELAY */
65# define PAM_NO_DELAY(pamh)pam_fail_delay ((pamh), 1) /* */
66#endif /* !HAVE_PAM_FAIL_DELAY */
67
68/* On SunOS 5.6, and on Linux with PAM 0.64, pam_strerror() takes two args.
69 On some other Linux systems with some other version of PAM (e.g.,
70 whichever Debian release comes with a 2.2.5 kernel) it takes one arg.
71 I can't tell which is more "recent" or "correct" behavior, so configure
72 figures out which is in use for us. Shoot me!
73*/
74#ifdef PAM_STRERROR_TWO_ARGS1
75# define PAM_STRERROR(pamh, status)pam_strerror((pamh), (status)) pam_strerror((pamh), (status))
76#else /* !PAM_STRERROR_TWO_ARGS */
77# define PAM_STRERROR(pamh, status)pam_strerror((pamh), (status)) pam_strerror((status))
78#endif /* !PAM_STRERROR_TWO_ARGS */
79
80static gboolean verbose_enabled = FALSE(0);
81static pam_handle_t *pam_handle = NULL((void*)0);
82static gboolean did_we_ask_for_password = FALSE(0);
83
84struct pam_closure
85{
86 const char *username;
87 GSAuthMessageFunc cb_func;
88 gpointer cb_data;
89 int signal_fd;
90 int result;
91};
92
93typedef struct
94{
95 struct pam_closure *closure;
96 GSAuthMessageStyle style;
97 const char *msg;
98 char **resp;
99 gboolean should_interrupt_stack;
100} GsAuthMessageHandlerData;
101
102static GCond message_handled_condition;
103static GMutex message_handler_mutex;
104
105GQuark
106gs_auth_error_quark (void)
107{
108 static GQuark quark = 0;
109 if (! quark)
110 {
111 quark = g_quark_from_static_string ("gs_auth_error");
112 }
113
114 return quark;
115}
116
117void
118gs_auth_set_verbose (gboolean enabled)
119{
120 verbose_enabled = enabled;
121}
122
123gboolean
124gs_auth_get_verbose (void)
125{
126 return verbose_enabled;
127}
128
129static gboolean
130auth_message_handler (GSAuthMessageStyle style,
131 const char *msg,
132 char **response,
133 gpointer data)
134{
135 gboolean ret;
136
137 ret = TRUE(!(0));
138 *response = NULL((void*)0);
139
140 switch (style)
141 {
142 case GS_AUTH_MESSAGE_PROMPT_ECHO_ON:
143 break;
144 case GS_AUTH_MESSAGE_PROMPT_ECHO_OFF:
145 if (msg != NULL((void*)0) && g_str_has_prefix (msg, _("Password:")gettext ("Password:")))
146 {
147 did_we_ask_for_password = TRUE(!(0));
148 }
149 break;
150 case GS_AUTH_MESSAGE_ERROR_MSG:
151 break;
152 case GS_AUTH_MESSAGE_TEXT_INFO:
153 break;
154 default:
155 g_assert_not_reached ()do { (void) 0; __builtin_unreachable (); } while (0);
156 }
157
158 return ret;
159}
160
161static gboolean
162gs_auth_queued_message_handler (gpointer user_data)
163{
164 GsAuthMessageHandlerData *data = user_data;
165 gboolean res;
166
167 if (gs_auth_get_verbose ())
168 {
169 g_message ("Waiting for lock");
170 }
171
172 g_mutex_lock (&message_handler_mutex);
173
174 if (gs_auth_get_verbose ())
175 {
176 g_message ("Waiting for response");
177 }
178
179 res = data->closure->cb_func (data->style,
180 data->msg,
181 data->resp,
182 data->closure->cb_data);
183
184 data->should_interrupt_stack = res == FALSE(0);
185
186 g_cond_signal (&message_handled_condition);
187 g_mutex_unlock (&message_handler_mutex);
188
189 if (gs_auth_get_verbose ())
190 {
191 g_message ("Got response");
192 }
193
194 return FALSE(0);
195}
196
197static gboolean
198gs_auth_run_message_handler (struct pam_closure *c,
199 GSAuthMessageStyle style,
200 const char *msg,
201 char **resp)
202{
203 GsAuthMessageHandlerData data;
204
205 data.closure = c;
206 data.style = style;
207 data.msg = msg;
208 data.resp = resp;
209 data.should_interrupt_stack = TRUE(!(0));
210
211 g_mutex_lock (&message_handler_mutex);
212
213 /* Queue the callback in the gui (the main) thread
214 */
215 g_idle_add (gs_auth_queued_message_handler, &data);
216
217 if (gs_auth_get_verbose ())
218 {
219 g_message ("Waiting for respose to message style %d: '%s'", style, msg);
220 }
221
222 /* Wait for the response
223 */
224 g_cond_wait (&message_handled_condition,
225 &message_handler_mutex);
226 g_mutex_unlock (&message_handler_mutex);
227
228 if (gs_auth_get_verbose ())
229 {
230 g_message ("Got respose to message style %d: interrupt:%d", style, data.should_interrupt_stack);
231 }
232
233 return data.should_interrupt_stack == FALSE(0);
234}
235
236static int
237pam_conversation (int nmsgs,
238 const struct pam_message **msg,
239 struct pam_response **resp,
240 void *closure)
241{
242 int replies = 0;
243 struct pam_response *reply = NULL((void*)0);
244 struct pam_closure *c = (struct pam_closure *) closure;
245 gboolean res;
246 int ret;
247
248 reply = (struct pam_response *) calloc (nmsgs, sizeof (*reply));
249
250 if (reply == NULL((void*)0))
251 {
252 return PAM_CONV_ERR19;
253 }
254
255 res = TRUE(!(0));
256 ret = PAM_SUCCESS0;
257
258 for (replies = 0; replies < nmsgs && ret == PAM_SUCCESS0; replies++)
259 {
260 GSAuthMessageStyle style;
261 char *utf8_msg;
262
263 style = pam_style_to_gs_style (msg [replies]->msg_style);
264
265 utf8_msg = g_locale_to_utf8 (msg [replies]->msg,
266 -1,
267 NULL((void*)0),
268 NULL((void*)0),
269 NULL((void*)0));
270
271 /* if we couldn't convert text from locale then
272 * assume utf-8 and hope for the best */
273 if (utf8_msg == NULL((void*)0))
274 {
275 char *p;
276 char *q;
277
278 utf8_msg = g_strdup (msg [replies]->msg);
279
280 p = utf8_msg;
281 while (*p != '\0' && !g_utf8_validate ((const char *)p, -1, (const char **)&q))
282 {
283 *q = '?';
284 p = q + 1;
285 }
286 }
287
288 /* handle message locally first */
289 auth_message_handler (style,
290 utf8_msg,
291 &reply [replies].resp,
292 NULL((void*)0));
293
294 if (c->cb_func != NULL((void*)0))
295 {
296 if (gs_auth_get_verbose ())
297 {
298 g_message ("Handling message style %d: '%s'", style, utf8_msg);
299 }
300
301 /* blocks until the gui responds
302 */
303 res = gs_auth_run_message_handler (c,
304 style,
305 utf8_msg,
306 &reply [replies].resp);
307
308 if (gs_auth_get_verbose ())
309 {
310 g_message ("Msg handler returned %d", res);
311 }
312
313 /* If the handler returns FALSE - interrupt the PAM stack */
314 if (res)
315 {
316 reply [replies].resp_retcode = PAM_SUCCESS0;
317 }
318 else
319 {
320 int i;
321 for (i = 0; i <= replies; i++)
322 {
323 free (reply [i].resp);
324 }
325 free (reply);
326 reply = NULL((void*)0);
327 ret = PAM_CONV_ERR19;
328 }
329 }
330
331 g_free (utf8_msg);
332 }
333
334 *resp = reply;
335
336 return ret;
337}
338
339static gboolean
340close_pam_handle (int status)
341{
342
343 if (pam_handle != NULL((void*)0))
344 {
345 int status2;
346
347 status2 = pam_end (pam_handle, status);
348 pam_handle = NULL((void*)0);
349
350 if (gs_auth_get_verbose ())
351 {
352 g_message (" pam_end (...) ==> %d (%s)",
353 status2,
354 (status2 == PAM_SUCCESS0 ? "Success" : "Failure"));
355 }
356 }
357
358 return TRUE(!(0));
359}
360
361static gboolean
362create_pam_handle (const char *username,
363 const char *display,
364 struct pam_conv *conv,
365 int *status_code)
366{
367 int status;
368 const char *service = PAM_SERVICE_NAME"mate-screensaver";
369 char *disp;
370 gboolean ret;
371
372 if (pam_handle != NULL((void*)0))
373 {
374 g_warning ("create_pam_handle: Stale pam handle around, cleaning up");
375 close_pam_handle (PAM_SUCCESS0);
376 }
377
378 /* init things */
379 pam_handle = NULL((void*)0);
380 status = -1;
381 disp = NULL((void*)0);
382 ret = TRUE(!(0));
383
384 /* Initialize a PAM session for the user */
385 if ((status = pam_start (service, username, conv, &pam_handle)) != PAM_SUCCESS0)
386 {
387 pam_handle = NULL((void*)0);
388 g_warning (_("Unable to establish service %s: %s\n")gettext ("Unable to establish service %s: %s\n"),
389 service,
390 PAM_STRERROR (NULL, status)pam_strerror((((void*)0)), (status)));
391
392 if (status_code != NULL((void*)0))
393 {
394 *status_code = status;
395 }
396
397 ret = FALSE(0);
398 goto out;
399 }
400
401 if (gs_auth_get_verbose ())
402 {
403 g_message ("pam_start (\"%s\", \"%s\", ...) ==> %d (%s)",
404 service,
405 username,
406 status,
407 PAM_STRERROR (pam_handle, status)pam_strerror((pam_handle), (status)));
408 }
409
410 disp = g_strdup (display);
411 if (disp == NULL((void*)0))
412 {
413 disp = g_strdup (":0.0");
414 }
415
416 if ((status = pam_set_item (pam_handle, PAM_TTY3, disp)) != PAM_SUCCESS0)
417 {
418 g_warning (_("Can't set PAM_TTY=%s")gettext ("Can't set PAM_TTY=%s"), display);
419
420 if (status_code != NULL((void*)0))
421 {
422 *status_code = status;
423 }
424
425 ret = FALSE(0);
426 goto out;
427 }
428
429 ret = TRUE(!(0));
430 g_cond_init (&message_handled_condition);
431 g_mutex_init (&message_handler_mutex);
432
433out:
434 if (status_code != NULL((void*)0))
435 {
436 *status_code = status;
437 }
438
439 g_free (disp);
440
441 return ret;
442}
443
444static void
445set_pam_error (GError **error,
446 int status)
447{
448 if (status == PAM_AUTH_ERR7 || status == PAM_USER_UNKNOWN10)
449 {
450 char *msg;
451
452 if (did_we_ask_for_password)
453 {
454 msg = g_strdup (_("Incorrect password.")gettext ("Incorrect password."));
455 }
456 else
457 {
458 msg = g_strdup (_("Authentication failed.")gettext ("Authentication failed."));
459 }
460
461 g_set_error (error,
462 GS_AUTH_ERRORgs_auth_error_quark (),
463 GS_AUTH_ERROR_AUTH_ERROR,
464 "%s",
465 msg);
466 g_free (msg);
467 }
468 else if (status == PAM_PERM_DENIED6)
469 {
470 g_set_error (error,
471 GS_AUTH_ERRORgs_auth_error_quark (),
472 GS_AUTH_ERROR_AUTH_DENIED,
473 "%s",
474 _("Not permitted to gain access at this time.")gettext ("Not permitted to gain access at this time."));
475 }
476 else if (status == PAM_ACCT_EXPIRED13)
477 {
478 g_set_error (error,
479 GS_AUTH_ERRORgs_auth_error_quark (),
480 GS_AUTH_ERROR_AUTH_DENIED,
481 "%s",
482 _("No longer permitted to access the system.")gettext ("No longer permitted to access the system."));
483 }
484
485}
486
487static gpointer
488gs_auth_thread_func (gpointer data)
489{
490 int auth_operation_fd;
491 static const int flags = 0;
492 int status;
493 int status2;
494 struct timespec timeout;
495 sigset_t set;
496 const void *p;
497
498 auth_operation_fd = GPOINTER_TO_INT (data)((gint) (glong) (data));
499
500 timeout.tv_sec = 0;
501 timeout.tv_nsec = 1;
502
503 set = block_sigchld ();
504
505 status = pam_authenticate (pam_handle, flags);
506
507 sigtimedwait (&set, NULL((void*)0), &timeout);
508 unblock_sigchld ();
509
510 if (gs_auth_get_verbose ())
511 {
512 g_message (" pam_authenticate (...) ==> %d (%s)",
513 status,
514 PAM_STRERROR (pam_handle, status)pam_strerror((pam_handle), (status)));
515 }
516
517 if (status != PAM_SUCCESS0)
518 {
519 goto done;
520 }
521
522 if ((status = pam_get_item (pam_handle, PAM_USER2, &p)) != PAM_SUCCESS0)
523 {
524 /* is not really an auth problem, but it will
525 pretty much look as such, it shouldn't really
526 happen */
527 goto done;
528 }
529
530 /* We don't actually care if the account modules fail or succeed,
531 * but we need to run them anyway because certain pam modules
532 * depend on side effects of the account modules getting run.
533 */
534 status2 = pam_acct_mgmt (pam_handle, 0);
535
536 if (gs_auth_get_verbose ())
537 {
538 g_message ("pam_acct_mgmt (...) ==> %d (%s)\n",
539 status2,
540 PAM_STRERROR (pam_handle, status2)pam_strerror((pam_handle), (status2)));
541 }
542
543 /* FIXME: should we handle these? */
544 switch (status2)
545 {
546 case PAM_SUCCESS0:
547 break;
548 case PAM_NEW_AUTHTOK_REQD12:
549 break;
550 case PAM_AUTHINFO_UNAVAIL9:
551 break;
552 case PAM_ACCT_EXPIRED13:
553 break;
554 case PAM_PERM_DENIED6:
555 break;
556 default :
557 break;
558 }
559
560 /* Each time we successfully authenticate, refresh credentials,
561 for Kerberos/AFS/DCE/etc. If this fails, just ignore that
562 failure and blunder along; it shouldn't matter.
563
564 Note: this used to be PAM_REFRESH_CRED instead of
565 PAM_REINITIALIZE_CRED, but Jason Heiss <jheiss@ee.washington.edu>
566 says that the Linux PAM library ignores that one, and only refreshes
567 credentials when using PAM_REINITIALIZE_CRED.
568 */
569 status2 = pam_setcred (pam_handle, PAM_REINITIALIZE_CRED0x0008U);
570 if (gs_auth_get_verbose ())
571 {
572 g_message (" pam_setcred (...) ==> %d (%s)",
573 status2,
574 PAM_STRERROR (pam_handle, status2)pam_strerror((pam_handle), (status2)));
575 }
576
577done:
578 /* we're done, close the fd and wake up the main
579 * loop
580 */
581 close (auth_operation_fd);
582
583 return GINT_TO_POINTER (status)((gpointer) (glong) (status));
584}
585
586static gboolean
587gs_auth_loop_quit (GIOChannel *source,
588 GIOCondition condition,
589 gboolean *thread_done)
590{
591 *thread_done = TRUE(!(0));
592 gtk_main_quit ();
593 return FALSE(0);
594}
595
596static gboolean
597gs_auth_pam_verify_user (pam_handle_t *handle,
598 int *status)
599{
600 GThread *auth_thread;
601 GIOChannel *channel;
602 guint watch_id;
603 int auth_operation_fds[2];
604 int auth_status;
605 gboolean thread_done;
606
607 channel = NULL((void*)0);
608 watch_id = 0;
609 auth_status = PAM_AUTH_ERR7;
610
611 /* This pipe gives us a set of fds we can hook into
612 * the event loop to be notified when our helper thread
613 * is ready to be reaped.
614 */
615 if (pipe (auth_operation_fds) < 0)
616 {
617 goto out;
618 }
619
620 if (fcntl (auth_operation_fds[0], F_SETFD2, FD_CLOEXEC1) < 0)
621 {
622 close (auth_operation_fds[0]);
623 close (auth_operation_fds[1]);
624 goto out;
625 }
626
627 if (fcntl (auth_operation_fds[1], F_SETFD2, FD_CLOEXEC1) < 0)
628 {
629 close (auth_operation_fds[0]);
630 close (auth_operation_fds[1]);
631 goto out;
632 }
633
634 channel = g_io_channel_unix_new (auth_operation_fds[0]);
635
636 /* we use a recursive main loop to process ui events
637 * while we wait on a thread to handle the blocking parts
638 * of pam authentication.
639 */
640 thread_done = FALSE(0);
641 watch_id = g_io_add_watch (channel, G_IO_ERR | G_IO_HUP,
642 (GIOFunc) gs_auth_loop_quit, &thread_done);
643
644 auth_thread = g_thread_new ("auththread",
645 gs_auth_thread_func,
646 GINT_TO_POINTER (auth_operation_fds[1])((gpointer) (glong) (auth_operation_fds[1])));
647
648 if (auth_thread == NULL((void*)0))
649 {
650 goto out;
651 }
652
653 gtk_main ();
654
655 /* if the event loop was quit before the thread is done then we can't
656 * reap the thread without blocking on it finishing. The
657 * thread may not ever finish though if the pam module is blocking.
658 *
659 * The only time the event loop is going to stop when the thread isn't
660 * done, however, is if the dialog quits early (from, e.g., "cancel"),
661 * so we can just exit. An alternative option would be to switch to
662 * using pthreads directly and calling pthread_cancel.
663 */
664 if (!thread_done)
665 {
666 raise (SIGTERM15);
667 }
668
669 auth_status = GPOINTER_TO_INT (g_thread_join (auth_thread))((gint) (glong) (g_thread_join (auth_thread)));
670
671out:
672 if (watch_id != 0)
673 {
674 g_source_remove (watch_id);
675 watch_id = 0;
Value stored to 'watch_id' is never read
676 }
677
678 if (channel != NULL((void*)0))
679 {
680 g_io_channel_unref (channel);
681 }
682
683 if (status)
684 {
685 *status = auth_status;
686 }
687
688 return auth_status == PAM_SUCCESS0;
689}
690
691gboolean
692gs_auth_verify_user (const char *username,
693 const char *display,
694 GSAuthMessageFunc func,
695 gpointer data,
696 GError **error)
697{
698 int status = -1;
699 struct pam_conv conv;
700 struct pam_closure c;
701 struct passwd *pwent;
702
703 pwent = getpwnam (username);
704 if (pwent == NULL((void*)0))
705 {
706 return FALSE(0);
707 }
708
709 c.username = username;
710 c.cb_func = func;
711 c.cb_data = data;
712
713 conv.conv = &pam_conversation;
714 conv.appdata_ptr = (void *) &c;
715
716 /* Initialize PAM. */
717 create_pam_handle (username, display, &conv, &status);
718 if (status != PAM_SUCCESS0)
719 {
720 goto done;
721 }
722
723 pam_set_item (pam_handle, PAM_USER_PROMPT9, _("Username:")gettext ("Username:"));
724
725 PAM_NO_DELAY(pam_handle)pam_fail_delay ((pam_handle), 1);
726
727 did_we_ask_for_password = FALSE(0);
728 if (! gs_auth_pam_verify_user (pam_handle, &status))
729 {
730 goto done;
731 }
732
733done:
734 if (status != PAM_SUCCESS0)
735 {
736 set_pam_error (error, status);
737 }
738
739 close_pam_handle (status);
740
741 return (status == PAM_SUCCESS0 ? TRUE(!(0)) : FALSE(0));
742}
743
744gboolean
745gs_auth_init (void)
746{
747 return TRUE(!(0));
748}
749
750gboolean
751gs_auth_priv_init (void)
752{
753 /* We have nothing to do at init-time.
754 However, we might as well do some error checking.
755 If "/etc/pam.d" exists and is a directory, but "/etc/pam.d/xlock"
756 does not exist, warn that PAM probably isn't going to work.
757
758 This is a priv-init instead of a non-priv init in case the directory
759 is unreadable or something (don't know if that actually happens.)
760 */
761 const char dir [] = "/etc/pam.d";
762 const char file [] = "/etc/pam.d/" PAM_SERVICE_NAME"mate-screensaver";
763 const char file2 [] = "/etc/pam.conf";
764 struct stat st;
765
766 if (g_statstat (dir, &st) == 0 && st.st_mode & S_IFDIR0040000)
767 {
768 if (g_statstat (file, &st) != 0)
769 {
770 g_warning ("%s does not exist.\n"
771 "Authentication via PAM is unlikely to work.",
772 file);
773 }
774 }
775 else if (g_statstat (file2, &st) == 0)
776 {
777 FILE *f = g_fopenfopen (file2, "r");
778 if (f)
779 {
780 gboolean ok = FALSE(0);
781 char buf[255];
782 while (fgets (buf, sizeof(buf), f))
783 {
784 if (strstr (buf, PAM_SERVICE_NAME"mate-screensaver"))
785 {
786 ok = TRUE(!(0));
787 break;
788 }
789 }
790
791 fclose (f);
792 if (!ok)
793 {
794 g_warning ("%s does not list the `%s' service.\n"
795 "Authentication via PAM is unlikely to work.",
796 file2, PAM_SERVICE_NAME"mate-screensaver");
797 }
798 }
799 /* else warn about file2 existing but being unreadable? */
800 }
801 else
802 {
803 g_warning ("Neither %s nor %s exist.\n"
804 "Authentication via PAM is unlikely to work.",
805 file2, file);
806 }
807
808 /* Return true anyway, just in case. */
809 return TRUE(!(0));
810}
diff --git a/2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-86b9eb.html b/2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-86b9eb.html new file mode 100644 index 0000000..0f07512 --- /dev/null +++ b/2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-86b9eb.html @@ -0,0 +1,1490 @@ + + + +gs-auth-pam.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rc/gs-auth-pam.c
Warning:line 255, column 2
Value stored to 'res' is never read
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name gs-auth-pam.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/14.0.5 -D HAVE_CONFIG_H -I . -I .. -I . -I . -D MATEMENU_I_KNOW_THIS_IS_UNSTABLE -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/dconf -I /usr/include/mate-menus -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/dconf -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/dconf -I /usr/include/mate-menus -D PREFIX="/usr/local" -D BINDIR="/usr/local/bin" -D LIBDIR="/usr/local/lib" -D LIBEXECDIR="/usr/local/libexec" -D DATADIR="/usr/local/share" -D SYSCONFDIR="/usr/local/etc" -D MATELOCALEDIR="/usr/local/share/locale" -D PKGLIBEXECDIR="/usr/local/libexec/mate-screensaver" -D SAVERDIR="/usr/local/libexec/mate-screensaver" -D THEMESDIR="/usr/local/share/mate-screensaver/themes" -D GTKBUILDERDIR="/usr/local/share/mate-screensaver" -D MATE_SCREENSAVER_GL_HELPER_PATH="/usr/local/libexec/mate-screensaver-gl-helper" -D PAM_SERVICE_NAME="mate-screensaver" -D G_DISABLE_ASSERT -D G_DISABLE_CHECKS -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -internal-isystem /usr/lib64/clang/14.0.5/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/12/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2022-11-11-203102-6531-1 -x c gs-auth-pam.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
2 *
3 * Copyright (C) 2006 William Jon McCann <mccann@jhu.edu>
4 * Copyright (C) 2006 Ray Strode <rstrode@redhat.com>
5 * Copyright (C) 2003 Bill Nottingham <notting@redhat.com>
6 * Copyright (c) 1993-2003 Jamie Zawinski <jwz@jwz.org>
7 * Copyright (C) 2012-2021 MATE Developers
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License as
11 * published by the Free Software Foundation; either version 2 of the
12 * License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
22 * 02110-1301, USA.
23 *
24 */
25
26#include "config.h"
27
28#include <stdlib.h>
29#ifdef HAVE_UNISTD_H1
30# include <unistd.h>
31#endif
32
33#include <fcntl.h>
34#include <stdio.h>
35#include <string.h>
36#include <sys/types.h>
37#include <pwd.h>
38#include <grp.h>
39#include <security/pam_appl.h>
40#include <signal.h>
41#include <errno(*__errno_location ()).h>
42
43#include <glib.h>
44#include <glib/gstdio.h>
45#include <glib/gi18n.h>
46#include <gtk/gtk.h>
47
48#include "gs-auth.h"
49#include "gs-auth-pam.h"
50
51#include "subprocs.h"
52
53/* Some time between Red Hat 4.2 and 7.0, the words were transposed
54 in the various PAM_x_CRED macro names. Yay!
55*/
56#ifndef PAM_REFRESH_CRED0x0010U
57# define PAM_REFRESH_CRED0x0010U PAM_CRED_REFRESH
58#endif
59
60#ifdef HAVE_PAM_FAIL_DELAY
61/* We handle delays ourself.*/
62/* Don't set this to 0 (Linux bug workaround.) */
63# define PAM_NO_DELAY(pamh)pam_fail_delay ((pamh), 1) pam_fail_delay ((pamh), 1)
64#else /* !HAVE_PAM_FAIL_DELAY */
65# define PAM_NO_DELAY(pamh)pam_fail_delay ((pamh), 1) /* */
66#endif /* !HAVE_PAM_FAIL_DELAY */
67
68/* On SunOS 5.6, and on Linux with PAM 0.64, pam_strerror() takes two args.
69 On some other Linux systems with some other version of PAM (e.g.,
70 whichever Debian release comes with a 2.2.5 kernel) it takes one arg.
71 I can't tell which is more "recent" or "correct" behavior, so configure
72 figures out which is in use for us. Shoot me!
73*/
74#ifdef PAM_STRERROR_TWO_ARGS1
75# define PAM_STRERROR(pamh, status)pam_strerror((pamh), (status)) pam_strerror((pamh), (status))
76#else /* !PAM_STRERROR_TWO_ARGS */
77# define PAM_STRERROR(pamh, status)pam_strerror((pamh), (status)) pam_strerror((status))
78#endif /* !PAM_STRERROR_TWO_ARGS */
79
80static gboolean verbose_enabled = FALSE(0);
81static pam_handle_t *pam_handle = NULL((void*)0);
82static gboolean did_we_ask_for_password = FALSE(0);
83
84struct pam_closure
85{
86 const char *username;
87 GSAuthMessageFunc cb_func;
88 gpointer cb_data;
89 int signal_fd;
90 int result;
91};
92
93typedef struct
94{
95 struct pam_closure *closure;
96 GSAuthMessageStyle style;
97 const char *msg;
98 char **resp;
99 gboolean should_interrupt_stack;
100} GsAuthMessageHandlerData;
101
102static GCond message_handled_condition;
103static GMutex message_handler_mutex;
104
105GQuark
106gs_auth_error_quark (void)
107{
108 static GQuark quark = 0;
109 if (! quark)
110 {
111 quark = g_quark_from_static_string ("gs_auth_error");
112 }
113
114 return quark;
115}
116
117void
118gs_auth_set_verbose (gboolean enabled)
119{
120 verbose_enabled = enabled;
121}
122
123gboolean
124gs_auth_get_verbose (void)
125{
126 return verbose_enabled;
127}
128
129static gboolean
130auth_message_handler (GSAuthMessageStyle style,
131 const char *msg,
132 char **response,
133 gpointer data)
134{
135 gboolean ret;
136
137 ret = TRUE(!(0));
138 *response = NULL((void*)0);
139
140 switch (style)
141 {
142 case GS_AUTH_MESSAGE_PROMPT_ECHO_ON:
143 break;
144 case GS_AUTH_MESSAGE_PROMPT_ECHO_OFF:
145 if (msg != NULL((void*)0) && g_str_has_prefix (msg, _("Password:")gettext ("Password:")))
146 {
147 did_we_ask_for_password = TRUE(!(0));
148 }
149 break;
150 case GS_AUTH_MESSAGE_ERROR_MSG:
151 break;
152 case GS_AUTH_MESSAGE_TEXT_INFO:
153 break;
154 default:
155 g_assert_not_reached ()do { (void) 0; __builtin_unreachable (); } while (0);
156 }
157
158 return ret;
159}
160
161static gboolean
162gs_auth_queued_message_handler (gpointer user_data)
163{
164 GsAuthMessageHandlerData *data = user_data;
165 gboolean res;
166
167 if (gs_auth_get_verbose ())
168 {
169 g_message ("Waiting for lock");
170 }
171
172 g_mutex_lock (&message_handler_mutex);
173
174 if (gs_auth_get_verbose ())
175 {
176 g_message ("Waiting for response");
177 }
178
179 res = data->closure->cb_func (data->style,
180 data->msg,
181 data->resp,
182 data->closure->cb_data);
183
184 data->should_interrupt_stack = res == FALSE(0);
185
186 g_cond_signal (&message_handled_condition);
187 g_mutex_unlock (&message_handler_mutex);
188
189 if (gs_auth_get_verbose ())
190 {
191 g_message ("Got response");
192 }
193
194 return FALSE(0);
195}
196
197static gboolean
198gs_auth_run_message_handler (struct pam_closure *c,
199 GSAuthMessageStyle style,
200 const char *msg,
201 char **resp)
202{
203 GsAuthMessageHandlerData data;
204
205 data.closure = c;
206 data.style = style;
207 data.msg = msg;
208 data.resp = resp;
209 data.should_interrupt_stack = TRUE(!(0));
210
211 g_mutex_lock (&message_handler_mutex);
212
213 /* Queue the callback in the gui (the main) thread
214 */
215 g_idle_add (gs_auth_queued_message_handler, &data);
216
217 if (gs_auth_get_verbose ())
218 {
219 g_message ("Waiting for respose to message style %d: '%s'", style, msg);
220 }
221
222 /* Wait for the response
223 */
224 g_cond_wait (&message_handled_condition,
225 &message_handler_mutex);
226 g_mutex_unlock (&message_handler_mutex);
227
228 if (gs_auth_get_verbose ())
229 {
230 g_message ("Got respose to message style %d: interrupt:%d", style, data.should_interrupt_stack);
231 }
232
233 return data.should_interrupt_stack == FALSE(0);
234}
235
236static int
237pam_conversation (int nmsgs,
238 const struct pam_message **msg,
239 struct pam_response **resp,
240 void *closure)
241{
242 int replies = 0;
243 struct pam_response *reply = NULL((void*)0);
244 struct pam_closure *c = (struct pam_closure *) closure;
245 gboolean res;
246 int ret;
247
248 reply = (struct pam_response *) calloc (nmsgs, sizeof (*reply));
249
250 if (reply == NULL((void*)0))
251 {
252 return PAM_CONV_ERR19;
253 }
254
255 res = TRUE(!(0));
Value stored to 'res' is never read
256 ret = PAM_SUCCESS0;
257
258 for (replies = 0; replies < nmsgs && ret == PAM_SUCCESS0; replies++)
259 {
260 GSAuthMessageStyle style;
261 char *utf8_msg;
262
263 style = pam_style_to_gs_style (msg [replies]->msg_style);
264
265 utf8_msg = g_locale_to_utf8 (msg [replies]->msg,
266 -1,
267 NULL((void*)0),
268 NULL((void*)0),
269 NULL((void*)0));
270
271 /* if we couldn't convert text from locale then
272 * assume utf-8 and hope for the best */
273 if (utf8_msg == NULL((void*)0))
274 {
275 char *p;
276 char *q;
277
278 utf8_msg = g_strdup (msg [replies]->msg);
279
280 p = utf8_msg;
281 while (*p != '\0' && !g_utf8_validate ((const char *)p, -1, (const char **)&q))
282 {
283 *q = '?';
284 p = q + 1;
285 }
286 }
287
288 /* handle message locally first */
289 auth_message_handler (style,
290 utf8_msg,
291 &reply [replies].resp,
292 NULL((void*)0));
293
294 if (c->cb_func != NULL((void*)0))
295 {
296 if (gs_auth_get_verbose ())
297 {
298 g_message ("Handling message style %d: '%s'", style, utf8_msg);
299 }
300
301 /* blocks until the gui responds
302 */
303 res = gs_auth_run_message_handler (c,
304 style,
305 utf8_msg,
306 &reply [replies].resp);
307
308 if (gs_auth_get_verbose ())
309 {
310 g_message ("Msg handler returned %d", res);
311 }
312
313 /* If the handler returns FALSE - interrupt the PAM stack */
314 if (res)
315 {
316 reply [replies].resp_retcode = PAM_SUCCESS0;
317 }
318 else
319 {
320 int i;
321 for (i = 0; i <= replies; i++)
322 {
323 free (reply [i].resp);
324 }
325 free (reply);
326 reply = NULL((void*)0);
327 ret = PAM_CONV_ERR19;
328 }
329 }
330
331 g_free (utf8_msg);
332 }
333
334 *resp = reply;
335
336 return ret;
337}
338
339static gboolean
340close_pam_handle (int status)
341{
342
343 if (pam_handle != NULL((void*)0))
344 {
345 int status2;
346
347 status2 = pam_end (pam_handle, status);
348 pam_handle = NULL((void*)0);
349
350 if (gs_auth_get_verbose ())
351 {
352 g_message (" pam_end (...) ==> %d (%s)",
353 status2,
354 (status2 == PAM_SUCCESS0 ? "Success" : "Failure"));
355 }
356 }
357
358 return TRUE(!(0));
359}
360
361static gboolean
362create_pam_handle (const char *username,
363 const char *display,
364 struct pam_conv *conv,
365 int *status_code)
366{
367 int status;
368 const char *service = PAM_SERVICE_NAME"mate-screensaver";
369 char *disp;
370 gboolean ret;
371
372 if (pam_handle != NULL((void*)0))
373 {
374 g_warning ("create_pam_handle: Stale pam handle around, cleaning up");
375 close_pam_handle (PAM_SUCCESS0);
376 }
377
378 /* init things */
379 pam_handle = NULL((void*)0);
380 status = -1;
381 disp = NULL((void*)0);
382 ret = TRUE(!(0));
383
384 /* Initialize a PAM session for the user */
385 if ((status = pam_start (service, username, conv, &pam_handle)) != PAM_SUCCESS0)
386 {
387 pam_handle = NULL((void*)0);
388 g_warning (_("Unable to establish service %s: %s\n")gettext ("Unable to establish service %s: %s\n"),
389 service,
390 PAM_STRERROR (NULL, status)pam_strerror((((void*)0)), (status)));
391
392 if (status_code != NULL((void*)0))
393 {
394 *status_code = status;
395 }
396
397 ret = FALSE(0);
398 goto out;
399 }
400
401 if (gs_auth_get_verbose ())
402 {
403 g_message ("pam_start (\"%s\", \"%s\", ...) ==> %d (%s)",
404 service,
405 username,
406 status,
407 PAM_STRERROR (pam_handle, status)pam_strerror((pam_handle), (status)));
408 }
409
410 disp = g_strdup (display);
411 if (disp == NULL((void*)0))
412 {
413 disp = g_strdup (":0.0");
414 }
415
416 if ((status = pam_set_item (pam_handle, PAM_TTY3, disp)) != PAM_SUCCESS0)
417 {
418 g_warning (_("Can't set PAM_TTY=%s")gettext ("Can't set PAM_TTY=%s"), display);
419
420 if (status_code != NULL((void*)0))
421 {
422 *status_code = status;
423 }
424
425 ret = FALSE(0);
426 goto out;
427 }
428
429 ret = TRUE(!(0));
430 g_cond_init (&message_handled_condition);
431 g_mutex_init (&message_handler_mutex);
432
433out:
434 if (status_code != NULL((void*)0))
435 {
436 *status_code = status;
437 }
438
439 g_free (disp);
440
441 return ret;
442}
443
444static void
445set_pam_error (GError **error,
446 int status)
447{
448 if (status == PAM_AUTH_ERR7 || status == PAM_USER_UNKNOWN10)
449 {
450 char *msg;
451
452 if (did_we_ask_for_password)
453 {
454 msg = g_strdup (_("Incorrect password.")gettext ("Incorrect password."));
455 }
456 else
457 {
458 msg = g_strdup (_("Authentication failed.")gettext ("Authentication failed."));
459 }
460
461 g_set_error (error,
462 GS_AUTH_ERRORgs_auth_error_quark (),
463 GS_AUTH_ERROR_AUTH_ERROR,
464 "%s",
465 msg);
466 g_free (msg);
467 }
468 else if (status == PAM_PERM_DENIED6)
469 {
470 g_set_error (error,
471 GS_AUTH_ERRORgs_auth_error_quark (),
472 GS_AUTH_ERROR_AUTH_DENIED,
473 "%s",
474 _("Not permitted to gain access at this time.")gettext ("Not permitted to gain access at this time."));
475 }
476 else if (status == PAM_ACCT_EXPIRED13)
477 {
478 g_set_error (error,
479 GS_AUTH_ERRORgs_auth_error_quark (),
480 GS_AUTH_ERROR_AUTH_DENIED,
481 "%s",
482 _("No longer permitted to access the system.")gettext ("No longer permitted to access the system."));
483 }
484
485}
486
487static gpointer
488gs_auth_thread_func (gpointer data)
489{
490 int auth_operation_fd;
491 static const int flags = 0;
492 int status;
493 int status2;
494 struct timespec timeout;
495 sigset_t set;
496 const void *p;
497
498 auth_operation_fd = GPOINTER_TO_INT (data)((gint) (glong) (data));
499
500 timeout.tv_sec = 0;
501 timeout.tv_nsec = 1;
502
503 set = block_sigchld ();
504
505 status = pam_authenticate (pam_handle, flags);
506
507 sigtimedwait (&set, NULL((void*)0), &timeout);
508 unblock_sigchld ();
509
510 if (gs_auth_get_verbose ())
511 {
512 g_message (" pam_authenticate (...) ==> %d (%s)",
513 status,
514 PAM_STRERROR (pam_handle, status)pam_strerror((pam_handle), (status)));
515 }
516
517 if (status != PAM_SUCCESS0)
518 {
519 goto done;
520 }
521
522 if ((status = pam_get_item (pam_handle, PAM_USER2, &p)) != PAM_SUCCESS0)
523 {
524 /* is not really an auth problem, but it will
525 pretty much look as such, it shouldn't really
526 happen */
527 goto done;
528 }
529
530 /* We don't actually care if the account modules fail or succeed,
531 * but we need to run them anyway because certain pam modules
532 * depend on side effects of the account modules getting run.
533 */
534 status2 = pam_acct_mgmt (pam_handle, 0);
535
536 if (gs_auth_get_verbose ())
537 {
538 g_message ("pam_acct_mgmt (...) ==> %d (%s)\n",
539 status2,
540 PAM_STRERROR (pam_handle, status2)pam_strerror((pam_handle), (status2)));
541 }
542
543 /* FIXME: should we handle these? */
544 switch (status2)
545 {
546 case PAM_SUCCESS0:
547 break;
548 case PAM_NEW_AUTHTOK_REQD12:
549 break;
550 case PAM_AUTHINFO_UNAVAIL9:
551 break;
552 case PAM_ACCT_EXPIRED13:
553 break;
554 case PAM_PERM_DENIED6:
555 break;
556 default :
557 break;
558 }
559
560 /* Each time we successfully authenticate, refresh credentials,
561 for Kerberos/AFS/DCE/etc. If this fails, just ignore that
562 failure and blunder along; it shouldn't matter.
563
564 Note: this used to be PAM_REFRESH_CRED instead of
565 PAM_REINITIALIZE_CRED, but Jason Heiss <jheiss@ee.washington.edu>
566 says that the Linux PAM library ignores that one, and only refreshes
567 credentials when using PAM_REINITIALIZE_CRED.
568 */
569 status2 = pam_setcred (pam_handle, PAM_REINITIALIZE_CRED0x0008U);
570 if (gs_auth_get_verbose ())
571 {
572 g_message (" pam_setcred (...) ==> %d (%s)",
573 status2,
574 PAM_STRERROR (pam_handle, status2)pam_strerror((pam_handle), (status2)));
575 }
576
577done:
578 /* we're done, close the fd and wake up the main
579 * loop
580 */
581 close (auth_operation_fd);
582
583 return GINT_TO_POINTER (status)((gpointer) (glong) (status));
584}
585
586static gboolean
587gs_auth_loop_quit (GIOChannel *source,
588 GIOCondition condition,
589 gboolean *thread_done)
590{
591 *thread_done = TRUE(!(0));
592 gtk_main_quit ();
593 return FALSE(0);
594}
595
596static gboolean
597gs_auth_pam_verify_user (pam_handle_t *handle,
598 int *status)
599{
600 GThread *auth_thread;
601 GIOChannel *channel;
602 guint watch_id;
603 int auth_operation_fds[2];
604 int auth_status;
605 gboolean thread_done;
606
607 channel = NULL((void*)0);
608 watch_id = 0;
609 auth_status = PAM_AUTH_ERR7;
610
611 /* This pipe gives us a set of fds we can hook into
612 * the event loop to be notified when our helper thread
613 * is ready to be reaped.
614 */
615 if (pipe (auth_operation_fds) < 0)
616 {
617 goto out;
618 }
619
620 if (fcntl (auth_operation_fds[0], F_SETFD2, FD_CLOEXEC1) < 0)
621 {
622 close (auth_operation_fds[0]);
623 close (auth_operation_fds[1]);
624 goto out;
625 }
626
627 if (fcntl (auth_operation_fds[1], F_SETFD2, FD_CLOEXEC1) < 0)
628 {
629 close (auth_operation_fds[0]);
630 close (auth_operation_fds[1]);
631 goto out;
632 }
633
634 channel = g_io_channel_unix_new (auth_operation_fds[0]);
635
636 /* we use a recursive main loop to process ui events
637 * while we wait on a thread to handle the blocking parts
638 * of pam authentication.
639 */
640 thread_done = FALSE(0);
641 watch_id = g_io_add_watch (channel, G_IO_ERR | G_IO_HUP,
642 (GIOFunc) gs_auth_loop_quit, &thread_done);
643
644 auth_thread = g_thread_new ("auththread",
645 gs_auth_thread_func,
646 GINT_TO_POINTER (auth_operation_fds[1])((gpointer) (glong) (auth_operation_fds[1])));
647
648 if (auth_thread == NULL((void*)0))
649 {
650 goto out;
651 }
652
653 gtk_main ();
654
655 /* if the event loop was quit before the thread is done then we can't
656 * reap the thread without blocking on it finishing. The
657 * thread may not ever finish though if the pam module is blocking.
658 *
659 * The only time the event loop is going to stop when the thread isn't
660 * done, however, is if the dialog quits early (from, e.g., "cancel"),
661 * so we can just exit. An alternative option would be to switch to
662 * using pthreads directly and calling pthread_cancel.
663 */
664 if (!thread_done)
665 {
666 raise (SIGTERM15);
667 }
668
669 auth_status = GPOINTER_TO_INT (g_thread_join (auth_thread))((gint) (glong) (g_thread_join (auth_thread)));
670
671out:
672 if (watch_id != 0)
673 {
674 g_source_remove (watch_id);
675 watch_id = 0;
676 }
677
678 if (channel != NULL((void*)0))
679 {
680 g_io_channel_unref (channel);
681 }
682
683 if (status)
684 {
685 *status = auth_status;
686 }
687
688 return auth_status == PAM_SUCCESS0;
689}
690
691gboolean
692gs_auth_verify_user (const char *username,
693 const char *display,
694 GSAuthMessageFunc func,
695 gpointer data,
696 GError **error)
697{
698 int status = -1;
699 struct pam_conv conv;
700 struct pam_closure c;
701 struct passwd *pwent;
702
703 pwent = getpwnam (username);
704 if (pwent == NULL((void*)0))
705 {
706 return FALSE(0);
707 }
708
709 c.username = username;
710 c.cb_func = func;
711 c.cb_data = data;
712
713 conv.conv = &pam_conversation;
714 conv.appdata_ptr = (void *) &c;
715
716 /* Initialize PAM. */
717 create_pam_handle (username, display, &conv, &status);
718 if (status != PAM_SUCCESS0)
719 {
720 goto done;
721 }
722
723 pam_set_item (pam_handle, PAM_USER_PROMPT9, _("Username:")gettext ("Username:"));
724
725 PAM_NO_DELAY(pam_handle)pam_fail_delay ((pam_handle), 1);
726
727 did_we_ask_for_password = FALSE(0);
728 if (! gs_auth_pam_verify_user (pam_handle, &status))
729 {
730 goto done;
731 }
732
733done:
734 if (status != PAM_SUCCESS0)
735 {
736 set_pam_error (error, status);
737 }
738
739 close_pam_handle (status);
740
741 return (status == PAM_SUCCESS0 ? TRUE(!(0)) : FALSE(0));
742}
743
744gboolean
745gs_auth_init (void)
746{
747 return TRUE(!(0));
748}
749
750gboolean
751gs_auth_priv_init (void)
752{
753 /* We have nothing to do at init-time.
754 However, we might as well do some error checking.
755 If "/etc/pam.d" exists and is a directory, but "/etc/pam.d/xlock"
756 does not exist, warn that PAM probably isn't going to work.
757
758 This is a priv-init instead of a non-priv init in case the directory
759 is unreadable or something (don't know if that actually happens.)
760 */
761 const char dir [] = "/etc/pam.d";
762 const char file [] = "/etc/pam.d/" PAM_SERVICE_NAME"mate-screensaver";
763 const char file2 [] = "/etc/pam.conf";
764 struct stat st;
765
766 if (g_statstat (dir, &st) == 0 && st.st_mode & S_IFDIR0040000)
767 {
768 if (g_statstat (file, &st) != 0)
769 {
770 g_warning ("%s does not exist.\n"
771 "Authentication via PAM is unlikely to work.",
772 file);
773 }
774 }
775 else if (g_statstat (file2, &st) == 0)
776 {
777 FILE *f = g_fopenfopen (file2, "r");
778 if (f)
779 {
780 gboolean ok = FALSE(0);
781 char buf[255];
782 while (fgets (buf, sizeof(buf), f))
783 {
784 if (strstr (buf, PAM_SERVICE_NAME"mate-screensaver"))
785 {
786 ok = TRUE(!(0));
787 break;
788 }
789 }
790
791 fclose (f);
792 if (!ok)
793 {
794 g_warning ("%s does not list the `%s' service.\n"
795 "Authentication via PAM is unlikely to work.",
796 file2, PAM_SERVICE_NAME"mate-screensaver");
797 }
798 }
799 /* else warn about file2 existing but being unreadable? */
800 }
801 else
802 {
803 g_warning ("Neither %s nor %s exist.\n"
804 "Authentication via PAM is unlikely to work.",
805 file2, file);
806 }
807
808 /* Return true anyway, just in case. */
809 return TRUE(!(0));
810}
diff --git a/2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-88c30c.html b/2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-88c30c.html new file mode 100644 index 0000000..c01c884 --- /dev/null +++ b/2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-88c30c.html @@ -0,0 +1,1236 @@ + + + +mate-screensaver-command.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rc/mate-screensaver-command.c
Warning:line 340, column 3
Value stored to 'reply' is never read
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name mate-screensaver-command.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/14.0.5 -D HAVE_CONFIG_H -I . -I .. -I . -I . -D MATEMENU_I_KNOW_THIS_IS_UNSTABLE -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/dconf -I /usr/include/mate-menus -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/dconf -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/dconf -I /usr/include/mate-menus -D PREFIX="/usr/local" -D BINDIR="/usr/local/bin" -D LIBDIR="/usr/local/lib" -D LIBEXECDIR="/usr/local/libexec" -D DATADIR="/usr/local/share" -D SYSCONFDIR="/usr/local/etc" -D MATELOCALEDIR="/usr/local/share/locale" -D PKGLIBEXECDIR="/usr/local/libexec/mate-screensaver" -D SAVERDIR="/usr/local/libexec/mate-screensaver" -D THEMESDIR="/usr/local/share/mate-screensaver/themes" -D GTKBUILDERDIR="/usr/local/share/mate-screensaver" -D MATE_SCREENSAVER_GL_HELPER_PATH="/usr/local/libexec/mate-screensaver-gl-helper" -D PAM_SERVICE_NAME="mate-screensaver" -D G_DISABLE_ASSERT -D G_DISABLE_CHECKS -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -internal-isystem /usr/lib64/clang/14.0.5/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/12/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2022-11-11-203102-6531-1 -x c mate-screensaver-command.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
2 *
3 * Copyright (C) 2004-2006 William Jon McCann <mccann@jhu.edu>
4 * Copyright (C) 2012-2021 MATE Developers
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; either version 2 of the
9 * License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
19 * 02110-1301, USA.
20 *
21 * Authors: William Jon McCann <mccann@jhu.edu>
22 *
23 */
24
25#include "config.h"
26
27#include <stdlib.h>
28#include <locale.h>
29#include <glib.h>
30#include <glib/gi18n.h>
31
32#define DBUS_API_SUBJECT_TO_CHANGE
33#include <dbus/dbus.h>
34#include <dbus/dbus-glib.h>
35#include <dbus/dbus-glib-lowlevel.h>
36
37#define GS_SERVICE"org.mate.ScreenSaver" "org.mate.ScreenSaver"
38#define GS_PATH"/org/mate/ScreenSaver" "/org/mate/ScreenSaver"
39#define GS_INTERFACE"org.mate.ScreenSaver" "org.mate.ScreenSaver"
40
41static gboolean do_quit = FALSE(0);
42static gboolean do_lock = FALSE(0);
43static gboolean do_unlock = FALSE(0);
44static gboolean do_cycle = FALSE(0);
45static gboolean do_activate = FALSE(0);
46static gboolean do_deactivate = FALSE(0);
47static gboolean do_version = FALSE(0);
48static gboolean do_poke = FALSE(0);
49static gboolean do_inhibit = FALSE(0);
50
51static gboolean do_query = FALSE(0);
52static gboolean do_time = FALSE(0);
53
54static char *inhibit_reason = NULL((void*)0);
55static char *inhibit_application = NULL((void*)0);
56
57static GOptionEntry entries [] =
58{
59 {
60 "exit", 0, 0, G_OPTION_ARG_NONE, &do_quit,
61 N_("Causes the screensaver to exit gracefully")("Causes the screensaver to exit gracefully"), NULL((void*)0)
62 },
63 {
64 "query", 'q', 0, G_OPTION_ARG_NONE, &do_query,
65 N_("Query the state of the screensaver")("Query the state of the screensaver"), NULL((void*)0)
66 },
67 {
68 "time", 't', 0, G_OPTION_ARG_NONE, &do_time,
69 N_("Query the length of time the screensaver has been active")("Query the length of time the screensaver has been active"), NULL((void*)0)
70 },
71 {
72 "lock", 'l', 0, G_OPTION_ARG_NONE, &do_lock,
73 N_("Tells the running screensaver process to lock the screen immediately")("Tells the running screensaver process to lock the screen immediately"
)
, NULL((void*)0)
74 },
75 {
76 "unlock", 'u', 0, G_OPTION_ARG_NONE, &do_unlock,
77 N_("Tells the running screensaver process to unlock the screen immediately")("Tells the running screensaver process to unlock the screen immediately"
)
, NULL((void*)0)
78 },
79 {
80 "cycle", 'c', 0, G_OPTION_ARG_NONE, &do_cycle,
81 N_("If the screensaver is active then switch to another graphics demo")("If the screensaver is active then switch to another graphics demo"
)
, NULL((void*)0)
82 },
83 {
84 "activate", 'a', 0, G_OPTION_ARG_NONE, &do_activate,
85 N_("Turn the screensaver on (blank the screen)")("Turn the screensaver on (blank the screen)"), NULL((void*)0)
86 },
87 {
88 "deactivate", 'd', 0, G_OPTION_ARG_NONE, &do_deactivate,
89 N_("If the screensaver is active then deactivate it (un-blank the screen)")("If the screensaver is active then deactivate it (un-blank the screen)"
)
, NULL((void*)0)
90 },
91 {
92 "poke", 'p', 0, G_OPTION_ARG_NONE, &do_poke,
93 N_("Poke the running screensaver to simulate user activity")("Poke the running screensaver to simulate user activity"), NULL((void*)0)
94 },
95 {
96 "inhibit", 'i', 0, G_OPTION_ARG_NONE, &do_inhibit,
97 N_("Inhibit the screensaver from activating. Command blocks while inhibit is active.")("Inhibit the screensaver from activating. Command blocks while inhibit is active."
)
, NULL((void*)0)
98 },
99 {
100 "application-name", 'n', 0, G_OPTION_ARG_STRING, &inhibit_application,
101 N_("The calling application that is inhibiting the screensaver")("The calling application that is inhibiting the screensaver"
)
, NULL((void*)0)
102 },
103 {
104 "reason", 'r', 0, G_OPTION_ARG_STRING, &inhibit_reason,
105 N_("The reason for inhibiting the screensaver")("The reason for inhibiting the screensaver"), NULL((void*)0)
106 },
107 {
108 "version", 'V', 0, G_OPTION_ARG_NONE, &do_version,
109 N_("Version of this application")("Version of this application"), NULL((void*)0)
110 },
111 { NULL((void*)0), 0, 0, G_OPTION_ARG_NONE, NULL((void*)0), NULL((void*)0), NULL((void*)0) }
112};
113
114static GMainLoop *loop = NULL((void*)0);
115
116static gboolean
117screensaver_is_running (DBusConnection *connection)
118{
119 DBusError error;
120 gboolean exists;
121
122 g_return_val_if_fail (connection != NULL, FALSE)do{ (void)0; }while (0);
123
124 dbus_error_init (&error);
125 exists = dbus_bus_name_has_owner (connection, GS_SERVICE"org.mate.ScreenSaver", &error);
126 if (dbus_error_is_set (&error))
127 dbus_error_free (&error);
128
129 return exists;
130}
131
132static DBusMessage *
133screensaver_send_message_inhibit (DBusConnection *connection,
134 const char *application,
135 const char *reason)
136{
137 DBusMessage *message;
138 DBusMessage *reply;
139 DBusError error;
140 DBusMessageIter iter;
141
142 g_return_val_if_fail (connection != NULL, NULL)do{ (void)0; }while (0);
143
144 dbus_error_init (&error);
145
146 message = dbus_message_new_method_call (GS_SERVICE"org.mate.ScreenSaver", GS_PATH"/org/mate/ScreenSaver", GS_INTERFACE"org.mate.ScreenSaver", "Inhibit");
147 if (message == NULL((void*)0))
148 {
149 g_warning ("Couldn't allocate the dbus message");
150 return NULL((void*)0);
151 }
152
153 dbus_message_iter_init_append (message, &iter);
154 dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING((int) 's'), &application);
155 dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING((int) 's'), &reason);
156
157 reply = dbus_connection_send_with_reply_and_block (connection,
158 message,
159 -1, &error);
160 if (dbus_error_is_set (&error))
161 {
162 g_warning ("%s raised:\n %s\n\n", error.name, error.message);
163 reply = NULL((void*)0);
164 }
165
166 dbus_connection_flush (connection);
167
168 dbus_message_unref (message);
169 dbus_error_free (&error);
170
171 return reply;
172}
173
174static DBusMessage *
175screensaver_send_message_bool (DBusConnection *connection,
176 const char *name,
177 gboolean value)
178{
179 DBusMessage *message;
180 DBusMessage *reply;
181 DBusError error;
182 DBusMessageIter iter;
183
184 g_return_val_if_fail (connection != NULL, NULL)do{ (void)0; }while (0);
185 g_return_val_if_fail (name != NULL, NULL)do{ (void)0; }while (0);
186
187 dbus_error_init (&error);
188
189 message = dbus_message_new_method_call (GS_SERVICE"org.mate.ScreenSaver", GS_PATH"/org/mate/ScreenSaver", GS_INTERFACE"org.mate.ScreenSaver", name);
190 if (message == NULL((void*)0))
191 {
192 g_warning ("Couldn't allocate the dbus message");
193 return NULL((void*)0);
194 }
195
196 dbus_message_iter_init_append (message, &iter);
197 dbus_message_iter_append_basic (&iter, DBUS_TYPE_BOOLEAN((int) 'b'), &value);
198
199 reply = dbus_connection_send_with_reply_and_block (connection,
200 message,
201 -1, &error);
202 if (dbus_error_is_set (&error))
203 {
204 g_warning ("%s raised:\n %s\n\n", error.name, error.message);
205 reply = NULL((void*)0);
206 }
207
208 dbus_connection_flush (connection);
209
210 dbus_message_unref (message);
211 dbus_error_free (&error);
212
213 return reply;
214}
215
216static DBusMessage *
217screensaver_send_message_void (DBusConnection *connection,
218 const char *name,
219 gboolean expect_reply)
220{
221 DBusMessage *message;
222 DBusMessage *reply;
223 DBusError error;
224
225 g_return_val_if_fail (connection != NULL, NULL)do{ (void)0; }while (0);
226 g_return_val_if_fail (name != NULL, NULL)do{ (void)0; }while (0);
227
228 dbus_error_init (&error);
229
230 message = dbus_message_new_method_call (GS_SERVICE"org.mate.ScreenSaver", GS_PATH"/org/mate/ScreenSaver", GS_INTERFACE"org.mate.ScreenSaver", name);
231 if (message == NULL((void*)0))
232 {
233 g_warning ("Couldn't allocate the dbus message");
234 return NULL((void*)0);
235 }
236
237 if (! expect_reply)
238 {
239 if (!dbus_connection_send (connection, message, NULL((void*)0)))
240 g_warning ("could not send message");
241 reply = NULL((void*)0);
242 }
243 else
244 {
245 reply = dbus_connection_send_with_reply_and_block (connection,
246 message,
247 -1, &error);
248 if (dbus_error_is_set (&error))
249 {
250 g_warning ("%s raised:\n %s\n\n", error.name, error.message);
251 reply = NULL((void*)0);
252 }
253 }
254 dbus_connection_flush (connection);
255
256 dbus_message_unref (message);
257 dbus_error_free (&error);
258
259 return reply;
260}
261
262static char **
263get_string_from_iter (DBusMessageIter *iter,
264 int *num_elements)
265{
266 int count;
267 char **buffer;
268
269 if (num_elements != NULL((void*)0))
270 {
271 *num_elements = 0;
272 }
273
274 count = 0;
275 buffer = (char **)malloc (sizeof (char *) * 8);
276
277 if (buffer == NULL((void*)0))
278 {
279 goto oom;
280 }
281
282 buffer[0] = NULL((void*)0);
283 while (dbus_message_iter_get_arg_type (iter) == DBUS_TYPE_STRING((int) 's'))
284 {
285 const char *value;
286 char *str;
287
288 if ((count % 8) == 0 && count != 0)
289 {
290 buffer = realloc (buffer, sizeof (char *) * (count + 8));
291 if (buffer == NULL((void*)0))
292 {
293 goto oom;
294 }
295 }
296
297 dbus_message_iter_get_basic (iter, &value);
298 str = strdup (value);
299 if (str == NULL((void*)0))
300 {
301 goto oom;
302 }
303
304 buffer[count] = str;
305
306 dbus_message_iter_next (iter);
307 count++;
308 }
309
310 if ((count % 8) == 0)
311 {
312 buffer = realloc (buffer, sizeof (char *) * (count + 1));
313 if (buffer == NULL((void*)0))
314 {
315 goto oom;
316 }
317 }
318
319 buffer[count] = NULL((void*)0);
320 if (num_elements != NULL((void*)0))
321 {
322 *num_elements = count;
323 }
324 return buffer;
325
326oom:
327 g_debug ("%s %d : error allocating memory\n", __FILE__"mate-screensaver-command.c", __LINE__327);
328 return NULL((void*)0);
329
330}
331
332static gboolean
333do_command (gpointer data)
334{
335 DBusConnection *connection = data;
336 DBusMessage *reply;
337
338 if (do_quit)
339 {
340 reply = screensaver_send_message_void (connection, "Quit", FALSE(0));
Value stored to 'reply' is never read
341 goto done;
342 }
343
344 if (do_query)
345 {
346 DBusMessageIter iter;
347 DBusMessageIter array;
348 dbus_bool_t v;
349
350 reply = screensaver_send_message_void (connection, "GetActive", TRUE(!(0)));
351 if (! reply)
352 {
353 g_message ("Did not receive a reply from the screensaver.");
354 goto done;
355 }
356
357 dbus_message_iter_init (reply, &iter);
358 dbus_message_iter_get_basic (&iter, &v);
359 g_print (_("The screensaver is %s\n")gettext ("The screensaver is %s\n"), v ? _("active")gettext ("active") : _("inactive")gettext ("inactive"));
360
361 dbus_message_unref (reply);
362
363 reply = screensaver_send_message_void (connection, "GetInhibitors", TRUE(!(0)));
364 if (! reply)
365 {
366 g_message ("Did not receive a reply from screensaver.");
367 goto done;
368 }
369
370 dbus_message_iter_init (reply, &iter);
371 dbus_message_iter_recurse (&iter, &array);
372
373 if (dbus_message_iter_get_arg_type (&array) == DBUS_TYPE_INVALID((int) '\0'))
374 {
375 g_print (_("The screensaver is not inhibited\n")gettext ("The screensaver is not inhibited\n"));
376 }
377 else
378 {
379 char **inhibitors;
380 int i;
381 int num;
382
383 g_print (_("The screensaver is being inhibited by:\n")gettext ("The screensaver is being inhibited by:\n"));
384 inhibitors = get_string_from_iter (&array, &num);
385 for (i = 0; i < num; i++)
386 {
387 g_print ("\t%s\n", inhibitors[i]);
388 }
389 g_strfreev (inhibitors);
390 }
391
392 dbus_message_unref (reply);
393 }
394
395 if (do_time)
396 {
397 DBusMessageIter iter;
398 dbus_bool_t v;
399 dbus_int32_t t;
400
401 reply = screensaver_send_message_void (connection, "GetActive", TRUE(!(0)));
402 if (! reply)
403 {
404 g_message ("Did not receive a reply from the screensaver.");
405 goto done;
406 }
407
408 dbus_message_iter_init (reply, &iter);
409 dbus_message_iter_get_basic (&iter, &v);
410 dbus_message_unref (reply);
411
412 if (v)
413 {
414
415 reply = screensaver_send_message_void (connection, "GetActiveTime", TRUE(!(0)));
416 dbus_message_iter_init (reply, &iter);
417 dbus_message_iter_get_basic (&iter, &t);
418 g_print (_("The screensaver has been active for %d seconds.\n")gettext ("The screensaver has been active for %d seconds.\n"), t);
419
420 dbus_message_unref (reply);
421 }
422 else
423 {
424 g_print (_("The screensaver is not currently active.\n")gettext ("The screensaver is not currently active.\n"));
425 }
426 }
427
428 if (do_lock)
429 {
430 reply = screensaver_send_message_void (connection, "Lock", FALSE(0));
431 }
432
433 if (do_unlock)
434 {
435 reply = screensaver_send_message_void (connection, "Unlock", FALSE(0));
436 }
437
438 if (do_cycle)
439 {
440 reply = screensaver_send_message_void (connection, "Cycle", FALSE(0));
441 }
442
443 if (do_poke)
444 {
445 reply = screensaver_send_message_void (connection, "SimulateUserActivity", FALSE(0));
446 }
447
448 if (do_activate)
449 {
450 reply = screensaver_send_message_bool (connection, "SetActive", TRUE(!(0)));
451 if (! reply)
452 {
453 g_message ("Did not receive a reply from the screensaver.");
454 goto done;
455 }
456 dbus_message_unref (reply);
457 }
458
459 if (do_deactivate)
460 {
461 reply = screensaver_send_message_bool (connection, "SetActive", FALSE(0));
462 if (! reply)
463 {
464 g_message ("Did not receive a reply from the screensaver.");
465 goto done;
466 }
467 dbus_message_unref (reply);
468 }
469
470 if (do_inhibit)
471 {
472 reply = screensaver_send_message_inhibit (connection,
473 inhibit_application ? inhibit_application : "Unknown",
474 inhibit_reason ? inhibit_reason : "Unknown");
475 if (! reply)
476 {
477 g_message ("Did not receive a reply from the screensaver.");
478 goto done;
479 }
480 dbus_message_unref (reply);
481
482 return FALSE(0);
483 }
484
485done:
486 g_main_loop_quit (loop);
487
488 return FALSE(0);
489}
490
491int
492main (int argc,
493 char **argv)
494{
495 DBusConnection *connection;
496 DBusError dbus_error;
497 GOptionContext *context;
498 gboolean retval;
499 GError *error = NULL((void*)0);
500
501#ifdef ENABLE_NLS1
502 bindtextdomain (GETTEXT_PACKAGE"mate-screensaver", MATELOCALEDIR"/usr/local/share/locale");
503# ifdef HAVE_BIND_TEXTDOMAIN_CODESET
504 bind_textdomain_codeset (GETTEXT_PACKAGE"mate-screensaver", "UTF-8");
505# endif
506 textdomain (GETTEXT_PACKAGE"mate-screensaver");
507#endif
508
509 g_set_prgname (argv[0]);
510
511 if (setlocale (LC_ALL6, "") == NULL((void*)0))
512 g_warning ("Locale not understood by C library, internationalization will not work\n");
513
514 context = g_option_context_new (NULL((void*)0));
515 g_option_context_add_main_entries (context, entries, NULL((void*)0));
516 retval = g_option_context_parse (context, &argc, &argv, &error);
517
518 g_option_context_free (context);
519
520 if (! retval)
521 {
522 g_warning ("%s", error->message);
523 g_error_free (error);
524 exit (1);
525 }
526
527 if (do_version)
528 {
529 g_print ("%s %s\n", argv [0], VERSION"1.27.0");
530 exit (1);
531 }
532
533 dbus_error_init (&dbus_error);
534 connection = dbus_bus_get (DBUS_BUS_SESSION, &dbus_error);
535 if (! connection)
536 {
537 g_message ("Failed to connect to the D-BUS daemon: %s", dbus_error.message);
538 dbus_error_free (&dbus_error);
539 exit (1);
540 }
541
542 dbus_connection_setup_with_g_main (connection, NULL((void*)0));
543
544 if (! screensaver_is_running (connection))
545 {
546 g_message ("Screensaver is not running!");
547 exit (1);
548 }
549
550 g_idle_add (do_command, connection);
551
552 loop = g_main_loop_new (NULL((void*)0), FALSE(0));
553 g_main_loop_run (loop);
554
555 return 0;
556}
diff --git a/2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-8aee73.html b/2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-8aee73.html new file mode 100644 index 0000000..c362a99 --- /dev/null +++ b/2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-8aee73.html @@ -0,0 +1,848 @@ + + + +xdg-user-dir-lookup.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:avers/xdg-user-dir-lookup.c
Warning:line 145, column 3
Call to function 'strcpy' is insecure as it does not provide bounding of the memory buffer. Replace unbounded copy functions with analogous functions that support length arguments such as 'strlcpy'. CWE-119
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name xdg-user-dir-lookup.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/savers -resource-dir /usr/lib64/clang/14.0.5 -D HAVE_CONFIG_H -I . -I .. -I . -I . -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -D LIBEXECDIR="/usr/local/libexec" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -internal-isystem /usr/lib64/clang/14.0.5/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/12/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdebug-compilation-dir=/rootdir/savers -ferror-limit 19 -fgnuc-version=4.2.1 -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2022-11-11-203102-6531-1 -x c xdg-user-dir-lookup.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/*
2 This file is not licenced under the GPL like the rest of the code.
3 Its is under the MIT license, to encourage reuse by cut-and-paste.
4
5 Copyright (c) 2007 Red Hat, inc
6 Copyright (C) 2012-2021 MATE Developers
7
8 Permission is hereby granted, free of charge, to any person
9 obtaining a copy of this software and associated documentation files
10 (the "Software"), to deal in the Software without restriction,
11 including without limitation the rights to use, copy, modify, merge,
12 publish, distribute, sublicense, and/or sell copies of the Software,
13 and to permit persons to whom the Software is furnished to do so,
14 subject to the following conditions:
15
16 The above copyright notice and this permission notice shall be
17 included in all copies or substantial portions of the Software.
18
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
23 BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
24 ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
25 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26 SOFTWARE.
27*/
28
29#include <stdio.h>
30#include <stdlib.h>
31#include <string.h>
32
33#include "xdg-user-dir-lookup.h"
34
35char *
36xdg_user_dir_lookup (const char *type)
37{
38 FILE *file;
39 char *home_dir, *config_home, *config_file;
40 char buffer[512];
41 char *user_dir;
42 char *p, *d;
43 int relative;
44
45 home_dir = getenv ("HOME");
46
47 if (home_dir == NULL((void*)0))
48 return strdup ("/tmp");
49
50 config_home = getenv ("XDG_CONFIG_HOME");
51 if (config_home == NULL((void*)0) || config_home[0] == 0)
52 {
53 config_file = malloc (strlen (home_dir) + strlen ("/.config/user-dirs.dirs") + 1);
54 strcpy (config_file, home_dir);
55 strcat (config_file, "/.config/user-dirs.dirs");
56 }
57 else
58 {
59 config_file = malloc (strlen (config_home) + strlen ("/user-dirs.dirs") + 1);
60 strcpy (config_file, config_home);
61 strcat (config_file, "/user-dirs.dirs");
62 }
63
64 file = fopen (config_file, "r");
65 free (config_file);
66 if (file == NULL((void*)0))
67 goto error;
68
69 user_dir = NULL((void*)0);
70 while (fgets (buffer, sizeof (buffer), file))
71 {
72 /* Remove newline at end */
73 size_t len = strlen (buffer);
74 if (len != 0 && buffer[len-1] == '\n')
75 buffer[len-1] = 0;
76
77 p = buffer;
78 while (*p == ' ' || *p == '\t')
79 p++;
80
81 if (strncmp (p, "XDG_", 4) != 0)
82 continue;
83 p += 4;
84 if (strncmp (p, type, strlen (type)) != 0)
85 continue;
86 p += strlen (type);
87 if (strncmp (p, "_DIR", 4) != 0)
88 continue;
89 p += 4;
90
91 while (*p == ' ' || *p == '\t')
92 p++;
93
94 if (*p != '=')
95 continue;
96 p++;
97
98 while (*p == ' ' || *p == '\t')
99 p++;
100
101 if (*p != '"')
102 continue;
103 p++;
104
105 relative = 0;
106 if (strncmp (p, "$HOME/", 6) == 0)
107 {
108 p += 6;
109 relative = 1;
110 }
111 else if (*p != '/')
112 continue;
113
114 if (relative)
115 {
116 user_dir = malloc (strlen (home_dir) + 1 + strlen (p) + 1);
117 strcpy (user_dir, home_dir);
118 strcat (user_dir, "/");
119 }
120 else
121 {
122 user_dir = malloc (strlen (p) + 1);
123 *user_dir = 0;
124 }
125
126 d = user_dir + strlen (user_dir);
127 while (*p && *p != '"')
128 {
129 if ((*p == '\\') && (*(p+1) != 0))
130 p++;
131 *d++ = *p++;
132 }
133 *d = 0;
134 }
135 fclose (file);
136
137 if (user_dir)
138 return user_dir;
139
140error:
141 /* Special case desktop for historical compatibility */
142 if (strcmp (type, "DESKTOP") == 0)
143 {
144 user_dir = malloc (strlen (home_dir) + strlen ("/Desktop") + 1);
145 strcpy (user_dir, home_dir);
Call to function 'strcpy' is insecure as it does not provide bounding of the memory buffer. Replace unbounded copy functions with analogous functions that support length arguments such as 'strlcpy'. CWE-119
146 strcat (user_dir, "/Desktop");
147 return user_dir;
148 }
149 else
150 return strdup (home_dir);
151}
152
153#ifdef STANDALONE
154
155int
156main (int argc, char *argv[])
157{
158 if (argc != 2)
159 {
160 fprintf (stderrstderr, "Usage %s <dir-type>\n", argv[0]);
161 exit (1);
162 }
163
164 printf ("%s\n", xdg_user_dir_lookup (argv[1]));
165 return 0;
166}
167
168#endif
diff --git a/2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-958ab4.html b/2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-958ab4.html new file mode 100644 index 0000000..69d1101 --- /dev/null +++ b/2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-958ab4.html @@ -0,0 +1,1236 @@ + + + +mate-screensaver-command.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rc/mate-screensaver-command.c
Warning:line 430, column 3
Value stored to 'reply' is never read
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name mate-screensaver-command.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/14.0.5 -D HAVE_CONFIG_H -I . -I .. -I . -I . -D MATEMENU_I_KNOW_THIS_IS_UNSTABLE -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/dconf -I /usr/include/mate-menus -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/dconf -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/dconf -I /usr/include/mate-menus -D PREFIX="/usr/local" -D BINDIR="/usr/local/bin" -D LIBDIR="/usr/local/lib" -D LIBEXECDIR="/usr/local/libexec" -D DATADIR="/usr/local/share" -D SYSCONFDIR="/usr/local/etc" -D MATELOCALEDIR="/usr/local/share/locale" -D PKGLIBEXECDIR="/usr/local/libexec/mate-screensaver" -D SAVERDIR="/usr/local/libexec/mate-screensaver" -D THEMESDIR="/usr/local/share/mate-screensaver/themes" -D GTKBUILDERDIR="/usr/local/share/mate-screensaver" -D MATE_SCREENSAVER_GL_HELPER_PATH="/usr/local/libexec/mate-screensaver-gl-helper" -D PAM_SERVICE_NAME="mate-screensaver" -D G_DISABLE_ASSERT -D G_DISABLE_CHECKS -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -internal-isystem /usr/lib64/clang/14.0.5/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/12/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2022-11-11-203102-6531-1 -x c mate-screensaver-command.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
2 *
3 * Copyright (C) 2004-2006 William Jon McCann <mccann@jhu.edu>
4 * Copyright (C) 2012-2021 MATE Developers
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; either version 2 of the
9 * License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
19 * 02110-1301, USA.
20 *
21 * Authors: William Jon McCann <mccann@jhu.edu>
22 *
23 */
24
25#include "config.h"
26
27#include <stdlib.h>
28#include <locale.h>
29#include <glib.h>
30#include <glib/gi18n.h>
31
32#define DBUS_API_SUBJECT_TO_CHANGE
33#include <dbus/dbus.h>
34#include <dbus/dbus-glib.h>
35#include <dbus/dbus-glib-lowlevel.h>
36
37#define GS_SERVICE"org.mate.ScreenSaver" "org.mate.ScreenSaver"
38#define GS_PATH"/org/mate/ScreenSaver" "/org/mate/ScreenSaver"
39#define GS_INTERFACE"org.mate.ScreenSaver" "org.mate.ScreenSaver"
40
41static gboolean do_quit = FALSE(0);
42static gboolean do_lock = FALSE(0);
43static gboolean do_unlock = FALSE(0);
44static gboolean do_cycle = FALSE(0);
45static gboolean do_activate = FALSE(0);
46static gboolean do_deactivate = FALSE(0);
47static gboolean do_version = FALSE(0);
48static gboolean do_poke = FALSE(0);
49static gboolean do_inhibit = FALSE(0);
50
51static gboolean do_query = FALSE(0);
52static gboolean do_time = FALSE(0);
53
54static char *inhibit_reason = NULL((void*)0);
55static char *inhibit_application = NULL((void*)0);
56
57static GOptionEntry entries [] =
58{
59 {
60 "exit", 0, 0, G_OPTION_ARG_NONE, &do_quit,
61 N_("Causes the screensaver to exit gracefully")("Causes the screensaver to exit gracefully"), NULL((void*)0)
62 },
63 {
64 "query", 'q', 0, G_OPTION_ARG_NONE, &do_query,
65 N_("Query the state of the screensaver")("Query the state of the screensaver"), NULL((void*)0)
66 },
67 {
68 "time", 't', 0, G_OPTION_ARG_NONE, &do_time,
69 N_("Query the length of time the screensaver has been active")("Query the length of time the screensaver has been active"), NULL((void*)0)
70 },
71 {
72 "lock", 'l', 0, G_OPTION_ARG_NONE, &do_lock,
73 N_("Tells the running screensaver process to lock the screen immediately")("Tells the running screensaver process to lock the screen immediately"
)
, NULL((void*)0)
74 },
75 {
76 "unlock", 'u', 0, G_OPTION_ARG_NONE, &do_unlock,
77 N_("Tells the running screensaver process to unlock the screen immediately")("Tells the running screensaver process to unlock the screen immediately"
)
, NULL((void*)0)
78 },
79 {
80 "cycle", 'c', 0, G_OPTION_ARG_NONE, &do_cycle,
81 N_("If the screensaver is active then switch to another graphics demo")("If the screensaver is active then switch to another graphics demo"
)
, NULL((void*)0)
82 },
83 {
84 "activate", 'a', 0, G_OPTION_ARG_NONE, &do_activate,
85 N_("Turn the screensaver on (blank the screen)")("Turn the screensaver on (blank the screen)"), NULL((void*)0)
86 },
87 {
88 "deactivate", 'd', 0, G_OPTION_ARG_NONE, &do_deactivate,
89 N_("If the screensaver is active then deactivate it (un-blank the screen)")("If the screensaver is active then deactivate it (un-blank the screen)"
)
, NULL((void*)0)
90 },
91 {
92 "poke", 'p', 0, G_OPTION_ARG_NONE, &do_poke,
93 N_("Poke the running screensaver to simulate user activity")("Poke the running screensaver to simulate user activity"), NULL((void*)0)
94 },
95 {
96 "inhibit", 'i', 0, G_OPTION_ARG_NONE, &do_inhibit,
97 N_("Inhibit the screensaver from activating. Command blocks while inhibit is active.")("Inhibit the screensaver from activating. Command blocks while inhibit is active."
)
, NULL((void*)0)
98 },
99 {
100 "application-name", 'n', 0, G_OPTION_ARG_STRING, &inhibit_application,
101 N_("The calling application that is inhibiting the screensaver")("The calling application that is inhibiting the screensaver"
)
, NULL((void*)0)
102 },
103 {
104 "reason", 'r', 0, G_OPTION_ARG_STRING, &inhibit_reason,
105 N_("The reason for inhibiting the screensaver")("The reason for inhibiting the screensaver"), NULL((void*)0)
106 },
107 {
108 "version", 'V', 0, G_OPTION_ARG_NONE, &do_version,
109 N_("Version of this application")("Version of this application"), NULL((void*)0)
110 },
111 { NULL((void*)0), 0, 0, G_OPTION_ARG_NONE, NULL((void*)0), NULL((void*)0), NULL((void*)0) }
112};
113
114static GMainLoop *loop = NULL((void*)0);
115
116static gboolean
117screensaver_is_running (DBusConnection *connection)
118{
119 DBusError error;
120 gboolean exists;
121
122 g_return_val_if_fail (connection != NULL, FALSE)do{ (void)0; }while (0);
123
124 dbus_error_init (&error);
125 exists = dbus_bus_name_has_owner (connection, GS_SERVICE"org.mate.ScreenSaver", &error);
126 if (dbus_error_is_set (&error))
127 dbus_error_free (&error);
128
129 return exists;
130}
131
132static DBusMessage *
133screensaver_send_message_inhibit (DBusConnection *connection,
134 const char *application,
135 const char *reason)
136{
137 DBusMessage *message;
138 DBusMessage *reply;
139 DBusError error;
140 DBusMessageIter iter;
141
142 g_return_val_if_fail (connection != NULL, NULL)do{ (void)0; }while (0);
143
144 dbus_error_init (&error);
145
146 message = dbus_message_new_method_call (GS_SERVICE"org.mate.ScreenSaver", GS_PATH"/org/mate/ScreenSaver", GS_INTERFACE"org.mate.ScreenSaver", "Inhibit");
147 if (message == NULL((void*)0))
148 {
149 g_warning ("Couldn't allocate the dbus message");
150 return NULL((void*)0);
151 }
152
153 dbus_message_iter_init_append (message, &iter);
154 dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING((int) 's'), &application);
155 dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING((int) 's'), &reason);
156
157 reply = dbus_connection_send_with_reply_and_block (connection,
158 message,
159 -1, &error);
160 if (dbus_error_is_set (&error))
161 {
162 g_warning ("%s raised:\n %s\n\n", error.name, error.message);
163 reply = NULL((void*)0);
164 }
165
166 dbus_connection_flush (connection);
167
168 dbus_message_unref (message);
169 dbus_error_free (&error);
170
171 return reply;
172}
173
174static DBusMessage *
175screensaver_send_message_bool (DBusConnection *connection,
176 const char *name,
177 gboolean value)
178{
179 DBusMessage *message;
180 DBusMessage *reply;
181 DBusError error;
182 DBusMessageIter iter;
183
184 g_return_val_if_fail (connection != NULL, NULL)do{ (void)0; }while (0);
185 g_return_val_if_fail (name != NULL, NULL)do{ (void)0; }while (0);
186
187 dbus_error_init (&error);
188
189 message = dbus_message_new_method_call (GS_SERVICE"org.mate.ScreenSaver", GS_PATH"/org/mate/ScreenSaver", GS_INTERFACE"org.mate.ScreenSaver", name);
190 if (message == NULL((void*)0))
191 {
192 g_warning ("Couldn't allocate the dbus message");
193 return NULL((void*)0);
194 }
195
196 dbus_message_iter_init_append (message, &iter);
197 dbus_message_iter_append_basic (&iter, DBUS_TYPE_BOOLEAN((int) 'b'), &value);
198
199 reply = dbus_connection_send_with_reply_and_block (connection,
200 message,
201 -1, &error);
202 if (dbus_error_is_set (&error))
203 {
204 g_warning ("%s raised:\n %s\n\n", error.name, error.message);
205 reply = NULL((void*)0);
206 }
207
208 dbus_connection_flush (connection);
209
210 dbus_message_unref (message);
211 dbus_error_free (&error);
212
213 return reply;
214}
215
216static DBusMessage *
217screensaver_send_message_void (DBusConnection *connection,
218 const char *name,
219 gboolean expect_reply)
220{
221 DBusMessage *message;
222 DBusMessage *reply;
223 DBusError error;
224
225 g_return_val_if_fail (connection != NULL, NULL)do{ (void)0; }while (0);
226 g_return_val_if_fail (name != NULL, NULL)do{ (void)0; }while (0);
227
228 dbus_error_init (&error);
229
230 message = dbus_message_new_method_call (GS_SERVICE"org.mate.ScreenSaver", GS_PATH"/org/mate/ScreenSaver", GS_INTERFACE"org.mate.ScreenSaver", name);
231 if (message == NULL((void*)0))
232 {
233 g_warning ("Couldn't allocate the dbus message");
234 return NULL((void*)0);
235 }
236
237 if (! expect_reply)
238 {
239 if (!dbus_connection_send (connection, message, NULL((void*)0)))
240 g_warning ("could not send message");
241 reply = NULL((void*)0);
242 }
243 else
244 {
245 reply = dbus_connection_send_with_reply_and_block (connection,
246 message,
247 -1, &error);
248 if (dbus_error_is_set (&error))
249 {
250 g_warning ("%s raised:\n %s\n\n", error.name, error.message);
251 reply = NULL((void*)0);
252 }
253 }
254 dbus_connection_flush (connection);
255
256 dbus_message_unref (message);
257 dbus_error_free (&error);
258
259 return reply;
260}
261
262static char **
263get_string_from_iter (DBusMessageIter *iter,
264 int *num_elements)
265{
266 int count;
267 char **buffer;
268
269 if (num_elements != NULL((void*)0))
270 {
271 *num_elements = 0;
272 }
273
274 count = 0;
275 buffer = (char **)malloc (sizeof (char *) * 8);
276
277 if (buffer == NULL((void*)0))
278 {
279 goto oom;
280 }
281
282 buffer[0] = NULL((void*)0);
283 while (dbus_message_iter_get_arg_type (iter) == DBUS_TYPE_STRING((int) 's'))
284 {
285 const char *value;
286 char *str;
287
288 if ((count % 8) == 0 && count != 0)
289 {
290 buffer = realloc (buffer, sizeof (char *) * (count + 8));
291 if (buffer == NULL((void*)0))
292 {
293 goto oom;
294 }
295 }
296
297 dbus_message_iter_get_basic (iter, &value);
298 str = strdup (value);
299 if (str == NULL((void*)0))
300 {
301 goto oom;
302 }
303
304 buffer[count] = str;
305
306 dbus_message_iter_next (iter);
307 count++;
308 }
309
310 if ((count % 8) == 0)
311 {
312 buffer = realloc (buffer, sizeof (char *) * (count + 1));
313 if (buffer == NULL((void*)0))
314 {
315 goto oom;
316 }
317 }
318
319 buffer[count] = NULL((void*)0);
320 if (num_elements != NULL((void*)0))
321 {
322 *num_elements = count;
323 }
324 return buffer;
325
326oom:
327 g_debug ("%s %d : error allocating memory\n", __FILE__"mate-screensaver-command.c", __LINE__327);
328 return NULL((void*)0);
329
330}
331
332static gboolean
333do_command (gpointer data)
334{
335 DBusConnection *connection = data;
336 DBusMessage *reply;
337
338 if (do_quit)
339 {
340 reply = screensaver_send_message_void (connection, "Quit", FALSE(0));
341 goto done;
342 }
343
344 if (do_query)
345 {
346 DBusMessageIter iter;
347 DBusMessageIter array;
348 dbus_bool_t v;
349
350 reply = screensaver_send_message_void (connection, "GetActive", TRUE(!(0)));
351 if (! reply)
352 {
353 g_message ("Did not receive a reply from the screensaver.");
354 goto done;
355 }
356
357 dbus_message_iter_init (reply, &iter);
358 dbus_message_iter_get_basic (&iter, &v);
359 g_print (_("The screensaver is %s\n")gettext ("The screensaver is %s\n"), v ? _("active")gettext ("active") : _("inactive")gettext ("inactive"));
360
361 dbus_message_unref (reply);
362
363 reply = screensaver_send_message_void (connection, "GetInhibitors", TRUE(!(0)));
364 if (! reply)
365 {
366 g_message ("Did not receive a reply from screensaver.");
367 goto done;
368 }
369
370 dbus_message_iter_init (reply, &iter);
371 dbus_message_iter_recurse (&iter, &array);
372
373 if (dbus_message_iter_get_arg_type (&array) == DBUS_TYPE_INVALID((int) '\0'))
374 {
375 g_print (_("The screensaver is not inhibited\n")gettext ("The screensaver is not inhibited\n"));
376 }
377 else
378 {
379 char **inhibitors;
380 int i;
381 int num;
382
383 g_print (_("The screensaver is being inhibited by:\n")gettext ("The screensaver is being inhibited by:\n"));
384 inhibitors = get_string_from_iter (&array, &num);
385 for (i = 0; i < num; i++)
386 {
387 g_print ("\t%s\n", inhibitors[i]);
388 }
389 g_strfreev (inhibitors);
390 }
391
392 dbus_message_unref (reply);
393 }
394
395 if (do_time)
396 {
397 DBusMessageIter iter;
398 dbus_bool_t v;
399 dbus_int32_t t;
400
401 reply = screensaver_send_message_void (connection, "GetActive", TRUE(!(0)));
402 if (! reply)
403 {
404 g_message ("Did not receive a reply from the screensaver.");
405 goto done;
406 }
407
408 dbus_message_iter_init (reply, &iter);
409 dbus_message_iter_get_basic (&iter, &v);
410 dbus_message_unref (reply);
411
412 if (v)
413 {
414
415 reply = screensaver_send_message_void (connection, "GetActiveTime", TRUE(!(0)));
416 dbus_message_iter_init (reply, &iter);
417 dbus_message_iter_get_basic (&iter, &t);
418 g_print (_("The screensaver has been active for %d seconds.\n")gettext ("The screensaver has been active for %d seconds.\n"), t);
419
420 dbus_message_unref (reply);
421 }
422 else
423 {
424 g_print (_("The screensaver is not currently active.\n")gettext ("The screensaver is not currently active.\n"));
425 }
426 }
427
428 if (do_lock)
429 {
430 reply = screensaver_send_message_void (connection, "Lock", FALSE(0));
Value stored to 'reply' is never read
431 }
432
433 if (do_unlock)
434 {
435 reply = screensaver_send_message_void (connection, "Unlock", FALSE(0));
436 }
437
438 if (do_cycle)
439 {
440 reply = screensaver_send_message_void (connection, "Cycle", FALSE(0));
441 }
442
443 if (do_poke)
444 {
445 reply = screensaver_send_message_void (connection, "SimulateUserActivity", FALSE(0));
446 }
447
448 if (do_activate)
449 {
450 reply = screensaver_send_message_bool (connection, "SetActive", TRUE(!(0)));
451 if (! reply)
452 {
453 g_message ("Did not receive a reply from the screensaver.");
454 goto done;
455 }
456 dbus_message_unref (reply);
457 }
458
459 if (do_deactivate)
460 {
461 reply = screensaver_send_message_bool (connection, "SetActive", FALSE(0));
462 if (! reply)
463 {
464 g_message ("Did not receive a reply from the screensaver.");
465 goto done;
466 }
467 dbus_message_unref (reply);
468 }
469
470 if (do_inhibit)
471 {
472 reply = screensaver_send_message_inhibit (connection,
473 inhibit_application ? inhibit_application : "Unknown",
474 inhibit_reason ? inhibit_reason : "Unknown");
475 if (! reply)
476 {
477 g_message ("Did not receive a reply from the screensaver.");
478 goto done;
479 }
480 dbus_message_unref (reply);
481
482 return FALSE(0);
483 }
484
485done:
486 g_main_loop_quit (loop);
487
488 return FALSE(0);
489}
490
491int
492main (int argc,
493 char **argv)
494{
495 DBusConnection *connection;
496 DBusError dbus_error;
497 GOptionContext *context;
498 gboolean retval;
499 GError *error = NULL((void*)0);
500
501#ifdef ENABLE_NLS1
502 bindtextdomain (GETTEXT_PACKAGE"mate-screensaver", MATELOCALEDIR"/usr/local/share/locale");
503# ifdef HAVE_BIND_TEXTDOMAIN_CODESET
504 bind_textdomain_codeset (GETTEXT_PACKAGE"mate-screensaver", "UTF-8");
505# endif
506 textdomain (GETTEXT_PACKAGE"mate-screensaver");
507#endif
508
509 g_set_prgname (argv[0]);
510
511 if (setlocale (LC_ALL6, "") == NULL((void*)0))
512 g_warning ("Locale not understood by C library, internationalization will not work\n");
513
514 context = g_option_context_new (NULL((void*)0));
515 g_option_context_add_main_entries (context, entries, NULL((void*)0));
516 retval = g_option_context_parse (context, &argc, &argv, &error);
517
518 g_option_context_free (context);
519
520 if (! retval)
521 {
522 g_warning ("%s", error->message);
523 g_error_free (error);
524 exit (1);
525 }
526
527 if (do_version)
528 {
529 g_print ("%s %s\n", argv [0], VERSION"1.27.0");
530 exit (1);
531 }
532
533 dbus_error_init (&dbus_error);
534 connection = dbus_bus_get (DBUS_BUS_SESSION, &dbus_error);
535 if (! connection)
536 {
537 g_message ("Failed to connect to the D-BUS daemon: %s", dbus_error.message);
538 dbus_error_free (&dbus_error);
539 exit (1);
540 }
541
542 dbus_connection_setup_with_g_main (connection, NULL((void*)0));
543
544 if (! screensaver_is_running (connection))
545 {
546 g_message ("Screensaver is not running!");
547 exit (1);
548 }
549
550 g_idle_add (do_command, connection);
551
552 loop = g_main_loop_new (NULL((void*)0), FALSE(0));
553 g_main_loop_run (loop);
554
555 return 0;
556}
diff --git a/2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-a25f69.html b/2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-a25f69.html new file mode 100644 index 0000000..9d939fc --- /dev/null +++ b/2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-a25f69.html @@ -0,0 +1,1236 @@ + + + +mate-screensaver-command.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rc/mate-screensaver-command.c
Warning:line 435, column 3
Value stored to 'reply' is never read
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name mate-screensaver-command.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/14.0.5 -D HAVE_CONFIG_H -I . -I .. -I . -I . -D MATEMENU_I_KNOW_THIS_IS_UNSTABLE -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/dconf -I /usr/include/mate-menus -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/dconf -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/dconf -I /usr/include/mate-menus -D PREFIX="/usr/local" -D BINDIR="/usr/local/bin" -D LIBDIR="/usr/local/lib" -D LIBEXECDIR="/usr/local/libexec" -D DATADIR="/usr/local/share" -D SYSCONFDIR="/usr/local/etc" -D MATELOCALEDIR="/usr/local/share/locale" -D PKGLIBEXECDIR="/usr/local/libexec/mate-screensaver" -D SAVERDIR="/usr/local/libexec/mate-screensaver" -D THEMESDIR="/usr/local/share/mate-screensaver/themes" -D GTKBUILDERDIR="/usr/local/share/mate-screensaver" -D MATE_SCREENSAVER_GL_HELPER_PATH="/usr/local/libexec/mate-screensaver-gl-helper" -D PAM_SERVICE_NAME="mate-screensaver" -D G_DISABLE_ASSERT -D G_DISABLE_CHECKS -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -internal-isystem /usr/lib64/clang/14.0.5/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/12/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2022-11-11-203102-6531-1 -x c mate-screensaver-command.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
2 *
3 * Copyright (C) 2004-2006 William Jon McCann <mccann@jhu.edu>
4 * Copyright (C) 2012-2021 MATE Developers
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; either version 2 of the
9 * License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
19 * 02110-1301, USA.
20 *
21 * Authors: William Jon McCann <mccann@jhu.edu>
22 *
23 */
24
25#include "config.h"
26
27#include <stdlib.h>
28#include <locale.h>
29#include <glib.h>
30#include <glib/gi18n.h>
31
32#define DBUS_API_SUBJECT_TO_CHANGE
33#include <dbus/dbus.h>
34#include <dbus/dbus-glib.h>
35#include <dbus/dbus-glib-lowlevel.h>
36
37#define GS_SERVICE"org.mate.ScreenSaver" "org.mate.ScreenSaver"
38#define GS_PATH"/org/mate/ScreenSaver" "/org/mate/ScreenSaver"
39#define GS_INTERFACE"org.mate.ScreenSaver" "org.mate.ScreenSaver"
40
41static gboolean do_quit = FALSE(0);
42static gboolean do_lock = FALSE(0);
43static gboolean do_unlock = FALSE(0);
44static gboolean do_cycle = FALSE(0);
45static gboolean do_activate = FALSE(0);
46static gboolean do_deactivate = FALSE(0);
47static gboolean do_version = FALSE(0);
48static gboolean do_poke = FALSE(0);
49static gboolean do_inhibit = FALSE(0);
50
51static gboolean do_query = FALSE(0);
52static gboolean do_time = FALSE(0);
53
54static char *inhibit_reason = NULL((void*)0);
55static char *inhibit_application = NULL((void*)0);
56
57static GOptionEntry entries [] =
58{
59 {
60 "exit", 0, 0, G_OPTION_ARG_NONE, &do_quit,
61 N_("Causes the screensaver to exit gracefully")("Causes the screensaver to exit gracefully"), NULL((void*)0)
62 },
63 {
64 "query", 'q', 0, G_OPTION_ARG_NONE, &do_query,
65 N_("Query the state of the screensaver")("Query the state of the screensaver"), NULL((void*)0)
66 },
67 {
68 "time", 't', 0, G_OPTION_ARG_NONE, &do_time,
69 N_("Query the length of time the screensaver has been active")("Query the length of time the screensaver has been active"), NULL((void*)0)
70 },
71 {
72 "lock", 'l', 0, G_OPTION_ARG_NONE, &do_lock,
73 N_("Tells the running screensaver process to lock the screen immediately")("Tells the running screensaver process to lock the screen immediately"
)
, NULL((void*)0)
74 },
75 {
76 "unlock", 'u', 0, G_OPTION_ARG_NONE, &do_unlock,
77 N_("Tells the running screensaver process to unlock the screen immediately")("Tells the running screensaver process to unlock the screen immediately"
)
, NULL((void*)0)
78 },
79 {
80 "cycle", 'c', 0, G_OPTION_ARG_NONE, &do_cycle,
81 N_("If the screensaver is active then switch to another graphics demo")("If the screensaver is active then switch to another graphics demo"
)
, NULL((void*)0)
82 },
83 {
84 "activate", 'a', 0, G_OPTION_ARG_NONE, &do_activate,
85 N_("Turn the screensaver on (blank the screen)")("Turn the screensaver on (blank the screen)"), NULL((void*)0)
86 },
87 {
88 "deactivate", 'd', 0, G_OPTION_ARG_NONE, &do_deactivate,
89 N_("If the screensaver is active then deactivate it (un-blank the screen)")("If the screensaver is active then deactivate it (un-blank the screen)"
)
, NULL((void*)0)
90 },
91 {
92 "poke", 'p', 0, G_OPTION_ARG_NONE, &do_poke,
93 N_("Poke the running screensaver to simulate user activity")("Poke the running screensaver to simulate user activity"), NULL((void*)0)
94 },
95 {
96 "inhibit", 'i', 0, G_OPTION_ARG_NONE, &do_inhibit,
97 N_("Inhibit the screensaver from activating. Command blocks while inhibit is active.")("Inhibit the screensaver from activating. Command blocks while inhibit is active."
)
, NULL((void*)0)
98 },
99 {
100 "application-name", 'n', 0, G_OPTION_ARG_STRING, &inhibit_application,
101 N_("The calling application that is inhibiting the screensaver")("The calling application that is inhibiting the screensaver"
)
, NULL((void*)0)
102 },
103 {
104 "reason", 'r', 0, G_OPTION_ARG_STRING, &inhibit_reason,
105 N_("The reason for inhibiting the screensaver")("The reason for inhibiting the screensaver"), NULL((void*)0)
106 },
107 {
108 "version", 'V', 0, G_OPTION_ARG_NONE, &do_version,
109 N_("Version of this application")("Version of this application"), NULL((void*)0)
110 },
111 { NULL((void*)0), 0, 0, G_OPTION_ARG_NONE, NULL((void*)0), NULL((void*)0), NULL((void*)0) }
112};
113
114static GMainLoop *loop = NULL((void*)0);
115
116static gboolean
117screensaver_is_running (DBusConnection *connection)
118{
119 DBusError error;
120 gboolean exists;
121
122 g_return_val_if_fail (connection != NULL, FALSE)do{ (void)0; }while (0);
123
124 dbus_error_init (&error);
125 exists = dbus_bus_name_has_owner (connection, GS_SERVICE"org.mate.ScreenSaver", &error);
126 if (dbus_error_is_set (&error))
127 dbus_error_free (&error);
128
129 return exists;
130}
131
132static DBusMessage *
133screensaver_send_message_inhibit (DBusConnection *connection,
134 const char *application,
135 const char *reason)
136{
137 DBusMessage *message;
138 DBusMessage *reply;
139 DBusError error;
140 DBusMessageIter iter;
141
142 g_return_val_if_fail (connection != NULL, NULL)do{ (void)0; }while (0);
143
144 dbus_error_init (&error);
145
146 message = dbus_message_new_method_call (GS_SERVICE"org.mate.ScreenSaver", GS_PATH"/org/mate/ScreenSaver", GS_INTERFACE"org.mate.ScreenSaver", "Inhibit");
147 if (message == NULL((void*)0))
148 {
149 g_warning ("Couldn't allocate the dbus message");
150 return NULL((void*)0);
151 }
152
153 dbus_message_iter_init_append (message, &iter);
154 dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING((int) 's'), &application);
155 dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING((int) 's'), &reason);
156
157 reply = dbus_connection_send_with_reply_and_block (connection,
158 message,
159 -1, &error);
160 if (dbus_error_is_set (&error))
161 {
162 g_warning ("%s raised:\n %s\n\n", error.name, error.message);
163 reply = NULL((void*)0);
164 }
165
166 dbus_connection_flush (connection);
167
168 dbus_message_unref (message);
169 dbus_error_free (&error);
170
171 return reply;
172}
173
174static DBusMessage *
175screensaver_send_message_bool (DBusConnection *connection,
176 const char *name,
177 gboolean value)
178{
179 DBusMessage *message;
180 DBusMessage *reply;
181 DBusError error;
182 DBusMessageIter iter;
183
184 g_return_val_if_fail (connection != NULL, NULL)do{ (void)0; }while (0);
185 g_return_val_if_fail (name != NULL, NULL)do{ (void)0; }while (0);
186
187 dbus_error_init (&error);
188
189 message = dbus_message_new_method_call (GS_SERVICE"org.mate.ScreenSaver", GS_PATH"/org/mate/ScreenSaver", GS_INTERFACE"org.mate.ScreenSaver", name);
190 if (message == NULL((void*)0))
191 {
192 g_warning ("Couldn't allocate the dbus message");
193 return NULL((void*)0);
194 }
195
196 dbus_message_iter_init_append (message, &iter);
197 dbus_message_iter_append_basic (&iter, DBUS_TYPE_BOOLEAN((int) 'b'), &value);
198
199 reply = dbus_connection_send_with_reply_and_block (connection,
200 message,
201 -1, &error);
202 if (dbus_error_is_set (&error))
203 {
204 g_warning ("%s raised:\n %s\n\n", error.name, error.message);
205 reply = NULL((void*)0);
206 }
207
208 dbus_connection_flush (connection);
209
210 dbus_message_unref (message);
211 dbus_error_free (&error);
212
213 return reply;
214}
215
216static DBusMessage *
217screensaver_send_message_void (DBusConnection *connection,
218 const char *name,
219 gboolean expect_reply)
220{
221 DBusMessage *message;
222 DBusMessage *reply;
223 DBusError error;
224
225 g_return_val_if_fail (connection != NULL, NULL)do{ (void)0; }while (0);
226 g_return_val_if_fail (name != NULL, NULL)do{ (void)0; }while (0);
227
228 dbus_error_init (&error);
229
230 message = dbus_message_new_method_call (GS_SERVICE"org.mate.ScreenSaver", GS_PATH"/org/mate/ScreenSaver", GS_INTERFACE"org.mate.ScreenSaver", name);
231 if (message == NULL((void*)0))
232 {
233 g_warning ("Couldn't allocate the dbus message");
234 return NULL((void*)0);
235 }
236
237 if (! expect_reply)
238 {
239 if (!dbus_connection_send (connection, message, NULL((void*)0)))
240 g_warning ("could not send message");
241 reply = NULL((void*)0);
242 }
243 else
244 {
245 reply = dbus_connection_send_with_reply_and_block (connection,
246 message,
247 -1, &error);
248 if (dbus_error_is_set (&error))
249 {
250 g_warning ("%s raised:\n %s\n\n", error.name, error.message);
251 reply = NULL((void*)0);
252 }
253 }
254 dbus_connection_flush (connection);
255
256 dbus_message_unref (message);
257 dbus_error_free (&error);
258
259 return reply;
260}
261
262static char **
263get_string_from_iter (DBusMessageIter *iter,
264 int *num_elements)
265{
266 int count;
267 char **buffer;
268
269 if (num_elements != NULL((void*)0))
270 {
271 *num_elements = 0;
272 }
273
274 count = 0;
275 buffer = (char **)malloc (sizeof (char *) * 8);
276
277 if (buffer == NULL((void*)0))
278 {
279 goto oom;
280 }
281
282 buffer[0] = NULL((void*)0);
283 while (dbus_message_iter_get_arg_type (iter) == DBUS_TYPE_STRING((int) 's'))
284 {
285 const char *value;
286 char *str;
287
288 if ((count % 8) == 0 && count != 0)
289 {
290 buffer = realloc (buffer, sizeof (char *) * (count + 8));
291 if (buffer == NULL((void*)0))
292 {
293 goto oom;
294 }
295 }
296
297 dbus_message_iter_get_basic (iter, &value);
298 str = strdup (value);
299 if (str == NULL((void*)0))
300 {
301 goto oom;
302 }
303
304 buffer[count] = str;
305
306 dbus_message_iter_next (iter);
307 count++;
308 }
309
310 if ((count % 8) == 0)
311 {
312 buffer = realloc (buffer, sizeof (char *) * (count + 1));
313 if (buffer == NULL((void*)0))
314 {
315 goto oom;
316 }
317 }
318
319 buffer[count] = NULL((void*)0);
320 if (num_elements != NULL((void*)0))
321 {
322 *num_elements = count;
323 }
324 return buffer;
325
326oom:
327 g_debug ("%s %d : error allocating memory\n", __FILE__"mate-screensaver-command.c", __LINE__327);
328 return NULL((void*)0);
329
330}
331
332static gboolean
333do_command (gpointer data)
334{
335 DBusConnection *connection = data;
336 DBusMessage *reply;
337
338 if (do_quit)
339 {
340 reply = screensaver_send_message_void (connection, "Quit", FALSE(0));
341 goto done;
342 }
343
344 if (do_query)
345 {
346 DBusMessageIter iter;
347 DBusMessageIter array;
348 dbus_bool_t v;
349
350 reply = screensaver_send_message_void (connection, "GetActive", TRUE(!(0)));
351 if (! reply)
352 {
353 g_message ("Did not receive a reply from the screensaver.");
354 goto done;
355 }
356
357 dbus_message_iter_init (reply, &iter);
358 dbus_message_iter_get_basic (&iter, &v);
359 g_print (_("The screensaver is %s\n")gettext ("The screensaver is %s\n"), v ? _("active")gettext ("active") : _("inactive")gettext ("inactive"));
360
361 dbus_message_unref (reply);
362
363 reply = screensaver_send_message_void (connection, "GetInhibitors", TRUE(!(0)));
364 if (! reply)
365 {
366 g_message ("Did not receive a reply from screensaver.");
367 goto done;
368 }
369
370 dbus_message_iter_init (reply, &iter);
371 dbus_message_iter_recurse (&iter, &array);
372
373 if (dbus_message_iter_get_arg_type (&array) == DBUS_TYPE_INVALID((int) '\0'))
374 {
375 g_print (_("The screensaver is not inhibited\n")gettext ("The screensaver is not inhibited\n"));
376 }
377 else
378 {
379 char **inhibitors;
380 int i;
381 int num;
382
383 g_print (_("The screensaver is being inhibited by:\n")gettext ("The screensaver is being inhibited by:\n"));
384 inhibitors = get_string_from_iter (&array, &num);
385 for (i = 0; i < num; i++)
386 {
387 g_print ("\t%s\n", inhibitors[i]);
388 }
389 g_strfreev (inhibitors);
390 }
391
392 dbus_message_unref (reply);
393 }
394
395 if (do_time)
396 {
397 DBusMessageIter iter;
398 dbus_bool_t v;
399 dbus_int32_t t;
400
401 reply = screensaver_send_message_void (connection, "GetActive", TRUE(!(0)));
402 if (! reply)
403 {
404 g_message ("Did not receive a reply from the screensaver.");
405 goto done;
406 }
407
408 dbus_message_iter_init (reply, &iter);
409 dbus_message_iter_get_basic (&iter, &v);
410 dbus_message_unref (reply);
411
412 if (v)
413 {
414
415 reply = screensaver_send_message_void (connection, "GetActiveTime", TRUE(!(0)));
416 dbus_message_iter_init (reply, &iter);
417 dbus_message_iter_get_basic (&iter, &t);
418 g_print (_("The screensaver has been active for %d seconds.\n")gettext ("The screensaver has been active for %d seconds.\n"), t);
419
420 dbus_message_unref (reply);
421 }
422 else
423 {
424 g_print (_("The screensaver is not currently active.\n")gettext ("The screensaver is not currently active.\n"));
425 }
426 }
427
428 if (do_lock)
429 {
430 reply = screensaver_send_message_void (connection, "Lock", FALSE(0));
431 }
432
433 if (do_unlock)
434 {
435 reply = screensaver_send_message_void (connection, "Unlock", FALSE(0));
Value stored to 'reply' is never read
436 }
437
438 if (do_cycle)
439 {
440 reply = screensaver_send_message_void (connection, "Cycle", FALSE(0));
441 }
442
443 if (do_poke)
444 {
445 reply = screensaver_send_message_void (connection, "SimulateUserActivity", FALSE(0));
446 }
447
448 if (do_activate)
449 {
450 reply = screensaver_send_message_bool (connection, "SetActive", TRUE(!(0)));
451 if (! reply)
452 {
453 g_message ("Did not receive a reply from the screensaver.");
454 goto done;
455 }
456 dbus_message_unref (reply);
457 }
458
459 if (do_deactivate)
460 {
461 reply = screensaver_send_message_bool (connection, "SetActive", FALSE(0));
462 if (! reply)
463 {
464 g_message ("Did not receive a reply from the screensaver.");
465 goto done;
466 }
467 dbus_message_unref (reply);
468 }
469
470 if (do_inhibit)
471 {
472 reply = screensaver_send_message_inhibit (connection,
473 inhibit_application ? inhibit_application : "Unknown",
474 inhibit_reason ? inhibit_reason : "Unknown");
475 if (! reply)
476 {
477 g_message ("Did not receive a reply from the screensaver.");
478 goto done;
479 }
480 dbus_message_unref (reply);
481
482 return FALSE(0);
483 }
484
485done:
486 g_main_loop_quit (loop);
487
488 return FALSE(0);
489}
490
491int
492main (int argc,
493 char **argv)
494{
495 DBusConnection *connection;
496 DBusError dbus_error;
497 GOptionContext *context;
498 gboolean retval;
499 GError *error = NULL((void*)0);
500
501#ifdef ENABLE_NLS1
502 bindtextdomain (GETTEXT_PACKAGE"mate-screensaver", MATELOCALEDIR"/usr/local/share/locale");
503# ifdef HAVE_BIND_TEXTDOMAIN_CODESET
504 bind_textdomain_codeset (GETTEXT_PACKAGE"mate-screensaver", "UTF-8");
505# endif
506 textdomain (GETTEXT_PACKAGE"mate-screensaver");
507#endif
508
509 g_set_prgname (argv[0]);
510
511 if (setlocale (LC_ALL6, "") == NULL((void*)0))
512 g_warning ("Locale not understood by C library, internationalization will not work\n");
513
514 context = g_option_context_new (NULL((void*)0));
515 g_option_context_add_main_entries (context, entries, NULL((void*)0));
516 retval = g_option_context_parse (context, &argc, &argv, &error);
517
518 g_option_context_free (context);
519
520 if (! retval)
521 {
522 g_warning ("%s", error->message);
523 g_error_free (error);
524 exit (1);
525 }
526
527 if (do_version)
528 {
529 g_print ("%s %s\n", argv [0], VERSION"1.27.0");
530 exit (1);
531 }
532
533 dbus_error_init (&dbus_error);
534 connection = dbus_bus_get (DBUS_BUS_SESSION, &dbus_error);
535 if (! connection)
536 {
537 g_message ("Failed to connect to the D-BUS daemon: %s", dbus_error.message);
538 dbus_error_free (&dbus_error);
539 exit (1);
540 }
541
542 dbus_connection_setup_with_g_main (connection, NULL((void*)0));
543
544 if (! screensaver_is_running (connection))
545 {
546 g_message ("Screensaver is not running!");
547 exit (1);
548 }
549
550 g_idle_add (do_command, connection);
551
552 loop = g_main_loop_new (NULL((void*)0), FALSE(0));
553 g_main_loop_run (loop);
554
555 return 0;
556}
diff --git a/2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-ac5343.html b/2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-ac5343.html new file mode 100644 index 0000000..8943246 --- /dev/null +++ b/2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-ac5343.html @@ -0,0 +1,3250 @@ + + + +gs-window-x11.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rc/gs-window-x11.c
Warning:line 1026, column 4
Value stored to 'finished' is never read
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name gs-window-x11.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/14.0.5 -D HAVE_CONFIG_H -I . -I .. -I . -I . -D MATEMENU_I_KNOW_THIS_IS_UNSTABLE -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/dconf -I /usr/include/mate-menus -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/dconf -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/dconf -I /usr/include/mate-menus -D PREFIX="/usr/local" -D BINDIR="/usr/local/bin" -D LIBDIR="/usr/local/lib" -D LIBEXECDIR="/usr/local/libexec" -D DATADIR="/usr/local/share" -D SYSCONFDIR="/usr/local/etc" -D MATELOCALEDIR="/usr/local/share/locale" -D PKGLIBEXECDIR="/usr/local/libexec/mate-screensaver" -D SAVERDIR="/usr/local/libexec/mate-screensaver" -D THEMESDIR="/usr/local/share/mate-screensaver/themes" -D GTKBUILDERDIR="/usr/local/share/mate-screensaver" -D MATE_SCREENSAVER_GL_HELPER_PATH="/usr/local/libexec/mate-screensaver-gl-helper" -D PAM_SERVICE_NAME="mate-screensaver" -D G_DISABLE_ASSERT -D G_DISABLE_CHECKS -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -internal-isystem /usr/lib64/clang/14.0.5/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/12/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2022-11-11-203102-6531-1 -x c gs-window-x11.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
2 *
3 * Copyright (C) 2004-2008 William Jon McCann <mccann@jhu.edu>
4 * Copyright (C) 2012-2021 MATE Developers
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
19 *
20 * Authors: William Jon McCann <mccann@jhu.edu>
21 *
22 */
23
24#include "config.h"
25
26#include <sys/types.h>
27#include <errno(*__errno_location ()).h>
28#include <sys/wait.h>
29#include <string.h>
30
31#include <gdk/gdkx.h>
32#include <gdk/gdkkeysyms.h>
33#include <gtk/gtk.h>
34#include <gtk/gtkx.h>
35
36#include "gs-window.h"
37#include "gs-marshal.h"
38#include "subprocs.h"
39#include "gs-debug.h"
40
41#ifdef HAVE_SHAPE_EXT1
42#include <X11/extensions/shape.h>
43#endif
44
45static void gs_window_finalize (GObject *object);
46
47static gboolean popup_dialog_idle (gpointer data);
48static void gs_window_dialog_finish (GSWindow *window);
49static void remove_command_watches (GSWindow *window);
50
51enum
52{
53 DIALOG_RESPONSE_CANCEL,
54 DIALOG_RESPONSE_OK
55};
56
57#define MAX_QUEUED_EVENTS16 16
58#define INFO_BAR_SECONDS30 30
59#define MATE_SCREENSAVER_DIALOG_PATH"/usr/local/libexec" "/mate-screensaver-dialog" LIBEXECDIR"/usr/local/libexec" "/mate-screensaver-dialog"
60
61struct GSWindowPrivate
62{
63 GdkMonitor *monitor;
64
65 GdkRectangle geometry;
66 guint obscured : 1;
67 guint dialog_up : 1;
68
69 guint lock_enabled : 1;
70 guint user_switch_enabled : 1;
71 guint logout_enabled : 1;
72 guint keyboard_enabled : 1;
73
74 guint64 logout_timeout;
75 char *logout_command;
76 char *keyboard_command;
77 char *status_message;
78
79 GtkWidget *vbox;
80 GtkWidget *drawing_area;
81 GtkWidget *lock_box;
82 GtkWidget *lock_socket;
83 GtkWidget *keyboard_socket;
84 GtkWidget *info_bar;
85 GtkWidget *info_content;
86
87 cairo_surface_t *background_surface;
88
89 guint popup_dialog_idle_id;
90
91 guint dialog_map_signal_id;
92 guint dialog_unmap_signal_id;
93 guint dialog_response_signal_id;
94
95 guint watchdog_timer_id;
96 guint info_bar_timer_id;
97
98 gint lock_pid;
99 gint lock_watch_id;
100 gint dialog_response;
101 gboolean dialog_quit_requested;
102 gboolean dialog_shake_in_progress;
103
104 gint keyboard_pid;
105 gint keyboard_watch_id;
106
107 GList *key_events;
108
109 gdouble last_x;
110 gdouble last_y;
111
112 GTimer *timer;
113
114#ifdef HAVE_SHAPE_EXT1
115 int shape_event_base;
116#endif
117};
118
119enum
120{
121 ACTIVITY,
122 DEACTIVATED,
123 LAST_SIGNAL
124};
125
126enum
127{
128 PROP_0,
129 PROP_OBSCURED,
130 PROP_DIALOG_UP,
131 PROP_LOCK_ENABLED,
132 PROP_LOGOUT_ENABLED,
133 PROP_KEYBOARD_ENABLED,
134 PROP_KEYBOARD_COMMAND,
135 PROP_LOGOUT_COMMAND,
136 PROP_LOGOUT_TIMEOUT,
137 PROP_MONITOR,
138 PROP_STATUS_MESSAGE
139};
140
141static guint signals [LAST_SIGNAL] = { 0, };
142
143G_DEFINE_TYPE_WITH_PRIVATE (GSWindow, gs_window, GTK_TYPE_WINDOW)static void gs_window_init (GSWindow *self); static void gs_window_class_init
(GSWindowClass *klass); static GType gs_window_get_type_once
(void); static gpointer gs_window_parent_class = ((void*)0);
static gint GSWindow_private_offset; static void gs_window_class_intern_init
(gpointer klass) { gs_window_parent_class = g_type_class_peek_parent
(klass); if (GSWindow_private_offset != 0) g_type_class_adjust_private_offset
(klass, &GSWindow_private_offset); gs_window_class_init (
(GSWindowClass*) klass); } __attribute__ ((__unused__)) static
inline gpointer gs_window_get_instance_private (GSWindow *self
) { return (((gpointer) ((guint8*) (self) + (glong) (GSWindow_private_offset
)))); } GType gs_window_get_type (void) { static gsize static_g_define_type_id
= 0; if ((__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); (void
) (0 ? (gpointer) *(&static_g_define_type_id) : ((void*)0
)); (!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
(*(&static_g_define_type_id)) gapg_temp_newval; __typeof__
((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id
); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5)
; gapg_temp_newval; })) && g_once_init_enter (&static_g_define_type_id
)); }))) { GType g_define_type_id = gs_window_get_type_once (
); (__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); 0 ?
(void) (*(&static_g_define_type_id) = (g_define_type_id)
) : (void) 0; g_once_init_leave ((&static_g_define_type_id
), (gsize) (g_define_type_id)); })); } return static_g_define_type_id
; } __attribute__ ((__noinline__)) static GType gs_window_get_type_once
(void) { GType g_define_type_id = g_type_register_static_simple
((gtk_window_get_type ()), g_intern_static_string ("GSWindow"
), sizeof (GSWindowClass), (GClassInitFunc)(void (*)(void)) gs_window_class_intern_init
, sizeof (GSWindow), (GInstanceInitFunc)(void (*)(void)) gs_window_init
, (GTypeFlags) 0); { {{ GSWindow_private_offset = g_type_add_instance_private
(g_define_type_id, sizeof (GSWindowPrivate)); };} } return g_define_type_id
; }
144
145static void
146set_invisible_cursor (GdkWindow *window,
147 gboolean invisible)
148{
149 GdkDisplay *display;
150 GdkCursor *cursor = NULL((void*)0);
151
152 if (invisible)
153 {
154 display = gdk_window_get_display (window);
155 cursor = gdk_cursor_new_for_display (display, GDK_BLANK_CURSOR);
156 }
157
158 gdk_window_set_cursor (window, cursor);
159
160 if (cursor)
161 {
162 g_object_unref (cursor);
163 }
164}
165
166/* derived from tomboy */
167static void
168gs_window_override_user_time (GSWindow *window)
169{
170 guint32 ev_time = gtk_get_current_event_time ();
171
172 if (ev_time == 0)
173 {
174 gint ev_mask = gtk_widget_get_events (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
);
175 if (!(ev_mask & GDK_PROPERTY_CHANGE_MASK))
176 {
177 gtk_widget_add_events (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
,
178 GDK_PROPERTY_CHANGE_MASK);
179 }
180
181 /*
182 * NOTE: Last resort for D-BUS or other non-interactive
183 * openings. Causes roundtrip to server. Lame.
184 */
185 ev_time = gdk_x11_get_server_time (gtk_widget_get_window (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
));
186 }
187
188 gdk_x11_window_set_user_time (gtk_widget_get_window (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
), ev_time);
189}
190
191static void
192clear_children (Window window)
193{
194 Window root;
195 Window parent;
196 Window *children;
197 unsigned int n_children;
198 int status;
199
200 children = NULL((void*)0);
201 status = XQueryTree (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ())(gdk_x11_display_get_xdisplay (gdk_display_get_default ())), window, &root, &parent, &children, &n_children);
202
203 if (status == 0)
204 {
205 if (children)
206 {
207 XFree (children);
208 }
209 return;
210 }
211
212 if (children)
213 {
214 while (n_children)
215 {
216 Window child;
217
218 child = children [--n_children];
219
220 XClearWindow (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ())(gdk_x11_display_get_xdisplay (gdk_display_get_default ())), child);
221
222 clear_children (child);
223 }
224
225 XFree (children);
226 }
227}
228
229static void
230widget_clear_all_children (GtkWidget *widget)
231{
232 GdkWindow *w;
233 GdkDisplay *display;
234
235 gs_debug ("Clearing all child windows")gs_debug_real (__func__, "gs-window-x11.c", 235, "Clearing all child windows"
)
;
236 display = gtk_widget_get_display (widget);
237
238 gdk_x11_display_error_trap_push (display);
239
240 w = gtk_widget_get_window (widget);
241
242 clear_children (GDK_WINDOW_XID (w)(gdk_x11_window_get_xid (w)));
243
244 gdk_x11_display_error_trap_pop_ignored (display);
245
246}
247
248void
249gs_window_set_background_surface (GSWindow *window,
250 cairo_surface_t *surface)
251{
252 g_return_if_fail (GS_IS_WINDOW (window))do{ (void)0; }while (0);
253
254 if (window->priv->background_surface != NULL((void*)0))
255 {
256 cairo_surface_destroy (window->priv->background_surface);
257 }
258 window->priv->background_surface = NULL((void*)0);
259
260 if (surface != NULL((void*)0))
261 {
262 window->priv->background_surface = cairo_surface_reference (surface);
263 }
264
265 gtk_widget_queue_draw (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
);
266}
267
268void
269gs_window_clear (GSWindow *window)
270{
271 GdkDisplay *display;
272 g_return_if_fail (GS_IS_WINDOW (window))do{ (void)0; }while (0);
273
274 gs_debug ("Clearing widgets")gs_debug_real (__func__, "gs-window-x11.c", 274, "Clearing widgets"
)
;
275
276 if (gtk_widget_get_realized (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
))
277 {
278 gtk_widget_queue_draw (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
);
279 /* If a screensaver theme adds child windows
280 we need to clear them too */
281 widget_clear_all_children (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
);
282 }
283
284 if (gtk_widget_get_realized (window->priv->drawing_area))
285 {
286 gtk_widget_queue_draw (window->priv->drawing_area);
287 widget_clear_all_children (window->priv->drawing_area);
288 }
289
290 display = gtk_widget_get_display (GTK_WIDGET(window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
);
291 gdk_display_flush (display);
292}
293
294static cairo_region_t *
295get_outside_region (GSWindow *window)
296{
297 GdkDisplay *display;
298 int i;
299 int num_monitors;
300 cairo_region_t *region;
301
302 display = gtk_widget_get_display (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
);
303
304 region = cairo_region_create ();
305
306 num_monitors = gdk_display_get_n_monitors (display);
307 for (i = 0; i < num_monitors; i++)
308 {
309 GdkMonitor *mon = gdk_display_get_monitor (display, i);
310
311 if (mon != window->priv->monitor)
312 {
313 GdkRectangle geometry;
314 cairo_rectangle_int_t rectangle;
315
316 gdk_monitor_get_geometry (mon, &geometry);
317 rectangle.x = geometry.x;
318 rectangle.y = geometry.y;
319 rectangle.width = geometry.width;
320 rectangle.height = geometry.height;
321 cairo_region_union_rectangle (region, &rectangle);
322 }
323 else
324 {
325 break;
326 }
327 }
328
329 return region;
330}
331
332static void
333update_geometry (GSWindow *window)
334{
335 GdkRectangle geometry;
336 cairo_region_t *outside_region;
337 cairo_region_t *monitor_region;
338
339 outside_region = get_outside_region (window);
340
341 gdk_monitor_get_geometry (window->priv->monitor, &geometry);
342 gs_debug ("got geometry for monitor: x=%d y=%d w=%d h=%d",gs_debug_real (__func__, "gs-window-x11.c", 346, "got geometry for monitor: x=%d y=%d w=%d h=%d"
, geometry.x, geometry.y, geometry.width, geometry.height)
343 geometry.x,gs_debug_real (__func__, "gs-window-x11.c", 346, "got geometry for monitor: x=%d y=%d w=%d h=%d"
, geometry.x, geometry.y, geometry.width, geometry.height)
344 geometry.y,gs_debug_real (__func__, "gs-window-x11.c", 346, "got geometry for monitor: x=%d y=%d w=%d h=%d"
, geometry.x, geometry.y, geometry.width, geometry.height)
345 geometry.width,gs_debug_real (__func__, "gs-window-x11.c", 346, "got geometry for monitor: x=%d y=%d w=%d h=%d"
, geometry.x, geometry.y, geometry.width, geometry.height)
346 geometry.height)gs_debug_real (__func__, "gs-window-x11.c", 346, "got geometry for monitor: x=%d y=%d w=%d h=%d"
, geometry.x, geometry.y, geometry.width, geometry.height)
;
347 monitor_region = cairo_region_create_rectangle ((const cairo_rectangle_int_t *)&geometry);
348 cairo_region_subtract (monitor_region, outside_region);
349 cairo_region_destroy (outside_region);
350
351 cairo_region_get_extents (monitor_region, (cairo_rectangle_int_t *)&geometry);
352 cairo_region_destroy (monitor_region);
353
354 gs_debug ("using geometry for monitor: x=%d y=%d w=%d h=%d",gs_debug_real (__func__, "gs-window-x11.c", 358, "using geometry for monitor: x=%d y=%d w=%d h=%d"
, geometry.x, geometry.y, geometry.width, geometry.height)
355 geometry.x,gs_debug_real (__func__, "gs-window-x11.c", 358, "using geometry for monitor: x=%d y=%d w=%d h=%d"
, geometry.x, geometry.y, geometry.width, geometry.height)
356 geometry.y,gs_debug_real (__func__, "gs-window-x11.c", 358, "using geometry for monitor: x=%d y=%d w=%d h=%d"
, geometry.x, geometry.y, geometry.width, geometry.height)
357 geometry.width,gs_debug_real (__func__, "gs-window-x11.c", 358, "using geometry for monitor: x=%d y=%d w=%d h=%d"
, geometry.x, geometry.y, geometry.width, geometry.height)
358 geometry.height)gs_debug_real (__func__, "gs-window-x11.c", 358, "using geometry for monitor: x=%d y=%d w=%d h=%d"
, geometry.x, geometry.y, geometry.width, geometry.height)
;
359
360 window->priv->geometry.x = geometry.x;
361 window->priv->geometry.y = geometry.y;
362 window->priv->geometry.width = geometry.width;
363 window->priv->geometry.height = geometry.height;
364}
365
366static void
367monitor_geometry_notify (GdkMonitor *monitor,
368 GParamSpec *pspec,
369 GSWindow *window)
370{
371 gs_debug ("Got monitor geometry notify signal")gs_debug_real (__func__, "gs-window-x11.c", 371, "Got monitor geometry notify signal"
)
;
372 gtk_widget_queue_resize (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
);
373}
374
375/* copied from panel-toplevel.c */
376static void
377gs_window_move_resize_window (GSWindow *window,
378 gboolean move,
379 gboolean resize)
380{
381 GtkWidget *widget;
382 GdkWindow *gdkwindow;
383
384 widget = GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
;
385 gdkwindow = gtk_widget_get_window (widget);
386
387 g_assert (gtk_widget_get_realized (widget))do { (void) 0; } while (0);
388
389 gs_debug ("Move and/or resize window: x=%d y=%d w=%d h=%d",gs_debug_real (__func__, "gs-window-x11.c", 393, "Move and/or resize window: x=%d y=%d w=%d h=%d"
, window->priv->geometry.x, window->priv->geometry
.y, window->priv->geometry.width, window->priv->geometry
.height)
390 window->priv->geometry.x,gs_debug_real (__func__, "gs-window-x11.c", 393, "Move and/or resize window: x=%d y=%d w=%d h=%d"
, window->priv->geometry.x, window->priv->geometry
.y, window->priv->geometry.width, window->priv->geometry
.height)
391 window->priv->geometry.y,gs_debug_real (__func__, "gs-window-x11.c", 393, "Move and/or resize window: x=%d y=%d w=%d h=%d"
, window->priv->geometry.x, window->priv->geometry
.y, window->priv->geometry.width, window->priv->geometry
.height)
392 window->priv->geometry.width,gs_debug_real (__func__, "gs-window-x11.c", 393, "Move and/or resize window: x=%d y=%d w=%d h=%d"
, window->priv->geometry.x, window->priv->geometry
.y, window->priv->geometry.width, window->priv->geometry
.height)
393 window->priv->geometry.height)gs_debug_real (__func__, "gs-window-x11.c", 393, "Move and/or resize window: x=%d y=%d w=%d h=%d"
, window->priv->geometry.x, window->priv->geometry
.y, window->priv->geometry.width, window->priv->geometry
.height)
;
394
395 if (move && resize)
396 {
397 gdk_window_move_resize (gdkwindow,
398 window->priv->geometry.x,
399 window->priv->geometry.y,
400 window->priv->geometry.width,
401 window->priv->geometry.height);
402 }
403 else if (move)
404 {
405 gdk_window_move (gdkwindow,
406 window->priv->geometry.x,
407 window->priv->geometry.y);
408 }
409 else if (resize)
410 {
411 gdk_window_resize (gdkwindow,
412 window->priv->geometry.width,
413 window->priv->geometry.height);
414 }
415}
416
417static void
418gs_window_real_unrealize (GtkWidget *widget)
419{
420 GdkMonitor *monitor = GS_WINDOW (widget)((((GSWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gs_window_get_type ()))))))
->priv->monitor;
421
422 g_signal_handlers_disconnect_by_func (monitor, monitor_geometry_notify,g_signal_handlers_disconnect_matched ((monitor), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (monitor_geometry_notify), (widget))
423 widget)g_signal_handlers_disconnect_matched ((monitor), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (monitor_geometry_notify), (widget))
;
424
425 if (GTK_WIDGET_CLASS (gs_window_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((gs_window_parent_class)), ((gtk_widget_get_type ()))))))
->unrealize)
426 {
427 GTK_WIDGET_CLASS (gs_window_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((gs_window_parent_class)), ((gtk_widget_get_type ()))))))
->unrealize (widget);
428 }
429}
430
431/* copied from gdk */
432extern char **environ;
433
434static gchar **
435spawn_make_environment_for_display (GdkDisplay *display,
436 gchar **envp)
437{
438 gchar **retval = NULL((void*)0);
439 const gchar *display_name;
440 gint display_index = -1;
441 gint i, env_len;
442
443 g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL)do{ (void)0; }while (0);
444
445 if (envp == NULL((void*)0))
446 envp = environ;
447
448 for (env_len = 0; envp[env_len]; env_len++)
449 if (strncmp (envp[env_len], "DISPLAY", strlen ("DISPLAY")) == 0)
450 display_index = env_len;
451
452 retval = g_new (char *, env_len + 1)((char * *) g_malloc_n ((env_len + 1), sizeof (char *)));
453 retval[env_len] = NULL((void*)0);
454
455 display_name = gdk_display_get_name (display);
456
457 for (i = 0; i < env_len; i++)
458 if (i == display_index)
459 retval[i] = g_strconcat ("DISPLAY=", display_name, NULL((void*)0));
460 else
461 retval[i] = g_strdup (envp[i]);
462
463 g_assert (i == env_len)do { (void) 0; } while (0);
464
465 return retval;
466}
467
468static gboolean
469spawn_command_line_on_display_sync (GdkDisplay *display,
470 const gchar *command_line,
471 char **standard_output,
472 char **standard_error,
473 int *exit_status,
474 GError **error)
475{
476 char **argv = NULL((void*)0);
477 char **envp = NULL((void*)0);
478 gboolean retval;
479
480 g_return_val_if_fail (command_line != NULL, FALSE)do{ (void)0; }while (0);
481
482 if (! g_shell_parse_argv (command_line, NULL((void*)0), &argv, error))
483 {
484 return FALSE(0);
485 }
486
487 envp = spawn_make_environment_for_display (display, NULL((void*)0));
488
489 retval = g_spawn_sync (NULL((void*)0),
490 argv,
491 envp,
492 G_SPAWN_SEARCH_PATH,
493 NULL((void*)0),
494 NULL((void*)0),
495 standard_output,
496 standard_error,
497 exit_status,
498 error);
499
500 g_strfreev (argv);
501 g_strfreev (envp);
502
503 return retval;
504}
505
506static GdkVisual *
507get_best_visual_for_display (GdkDisplay *display)
508{
509 GdkScreen *screen;
510 char *std_output;
511 int exit_status;
512 GError *error;
513 unsigned long v;
514 char c;
515 GdkVisual *visual;
516 gboolean res;
517
518 visual = NULL((void*)0);
519 screen = gdk_display_get_default_screen (display);
520
521 error = NULL((void*)0);
522 std_output = NULL((void*)0);
523 res = spawn_command_line_on_display_sync (display,
524 MATE_SCREENSAVER_GL_HELPER_PATH"/usr/local/libexec/mate-screensaver-gl-helper",
525 &std_output,
526 NULL((void*)0),
527 &exit_status,
528 &error);
529 if (! res)
530 {
531 gs_debug ("Could not run command '%s': %s",gs_debug_real (__func__, "gs-window-x11.c", 532, "Could not run command '%s': %s"
, "/usr/local/libexec/mate-screensaver-gl-helper", error->
message)
532 MATE_SCREENSAVER_GL_HELPER_PATH, error->message)gs_debug_real (__func__, "gs-window-x11.c", 532, "Could not run command '%s': %s"
, "/usr/local/libexec/mate-screensaver-gl-helper", error->
message)
;
533 g_error_free (error);
534 goto out;
535 }
536
537 if (1 == sscanf (std_output, "0x%lx %c", &v, &c))
538 {
539 if (v != 0)
540 {
541 VisualID visual_id;
542
543 visual_id = (VisualID) v;
544 visual = gdk_x11_screen_lookup_visual (screen, visual_id);
545
546 gs_debug ("Found best GL visual for display %s: 0x%x",gs_debug_real (__func__, "gs-window-x11.c", 548, "Found best GL visual for display %s: 0x%x"
, gdk_display_get_name (display), (unsigned int) visual_id)
547 gdk_display_get_name (display),gs_debug_real (__func__, "gs-window-x11.c", 548, "Found best GL visual for display %s: 0x%x"
, gdk_display_get_name (display), (unsigned int) visual_id)
548 (unsigned int) visual_id)gs_debug_real (__func__, "gs-window-x11.c", 548, "Found best GL visual for display %s: 0x%x"
, gdk_display_get_name (display), (unsigned int) visual_id)
;
549 }
550 }
551out:
552 g_free (std_output);
553
554 return g_object_ref (visual)((__typeof__ (visual)) (g_object_ref) (visual));
555}
556
557static void
558widget_set_best_visual (GtkWidget *widget)
559{
560 GdkVisual *visual;
561
562 g_return_if_fail (widget != NULL)do{ (void)0; }while (0);
563
564 visual = get_best_visual_for_display (gtk_widget_get_display (widget));
565 if (visual != NULL((void*)0))
566 {
567 gtk_widget_set_visual (widget, visual);
568 g_object_unref (visual);
569 }
570}
571
572static void
573gs_window_real_realize (GtkWidget *widget)
574{
575 GdkMonitor *monitor = GS_WINDOW (widget)((((GSWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gs_window_get_type ()))))))
->priv->monitor;
576
577 widget_set_best_visual (widget);
578
579 if (GTK_WIDGET_CLASS (gs_window_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((gs_window_parent_class)), ((gtk_widget_get_type ()))))))
->realize)
580 {
581 GTK_WIDGET_CLASS (gs_window_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((gs_window_parent_class)), ((gtk_widget_get_type ()))))))
->realize (widget);
582 }
583
584 gs_window_override_user_time (GS_WINDOW (widget)((((GSWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gs_window_get_type ()))))))
);
585
586 gs_window_move_resize_window (GS_WINDOW (widget)((((GSWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gs_window_get_type ()))))))
, TRUE(!(0)), TRUE(!(0)));
587
588 g_signal_connect (monitor,g_signal_connect_data ((monitor), ("notify::geometry"), (((GCallback
) (monitor_geometry_notify))), (widget), ((void*)0), (GConnectFlags
) 0)
589 "notify::geometry",g_signal_connect_data ((monitor), ("notify::geometry"), (((GCallback
) (monitor_geometry_notify))), (widget), ((void*)0), (GConnectFlags
) 0)
590 G_CALLBACK (monitor_geometry_notify),g_signal_connect_data ((monitor), ("notify::geometry"), (((GCallback
) (monitor_geometry_notify))), (widget), ((void*)0), (GConnectFlags
) 0)
591 widget)g_signal_connect_data ((monitor), ("notify::geometry"), (((GCallback
) (monitor_geometry_notify))), (widget), ((void*)0), (GConnectFlags
) 0)
;
592}
593
594/* every so often we should raise the window in case
595 another window has somehow gotten on top */
596static gboolean
597watchdog_timer (GSWindow *window)
598{
599 GtkWidget *widget = GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
;
600
601 gdk_window_focus (gtk_widget_get_window (widget), GDK_CURRENT_TIME0L);
602
603 return TRUE(!(0));
604}
605
606static void
607remove_watchdog_timer (GSWindow *window)
608{
609 if (window->priv->watchdog_timer_id != 0)
610 {
611 g_source_remove (window->priv->watchdog_timer_id);
612 window->priv->watchdog_timer_id = 0;
613 }
614}
615
616static void
617add_watchdog_timer (GSWindow *window,
618 guint timeout)
619{
620 window->priv->watchdog_timer_id = g_timeout_add (timeout,
621 (GSourceFunc)watchdog_timer,
622 window);
623}
624
625static void
626remove_popup_dialog_idle (GSWindow *window)
627{
628 if (window->priv->popup_dialog_idle_id != 0)
629 {
630 g_source_remove (window->priv->popup_dialog_idle_id);
631 window->priv->popup_dialog_idle_id = 0;
632 }
633}
634
635static void
636add_popup_dialog_idle (GSWindow *window)
637{
638 window->priv->popup_dialog_idle_id = g_idle_add (popup_dialog_idle, window);
639}
640
641static gboolean
642emit_deactivated_idle (GSWindow *window)
643{
644 g_signal_emit (window, signals [DEACTIVATED], 0);
645
646 return FALSE(0);
647}
648
649static void
650add_emit_deactivated_idle (GSWindow *window)
651{
652 g_idle_add ((GSourceFunc)emit_deactivated_idle, window);
653}
654
655static void
656gs_window_raise (GSWindow *window)
657{
658 GdkWindow *win;
659
660 g_return_if_fail (GS_IS_WINDOW (window))do{ (void)0; }while (0);
661
662 gs_debug ("Raising screensaver window")gs_debug_real (__func__, "gs-window-x11.c", 662, "Raising screensaver window"
)
;
663
664 win = gtk_widget_get_window (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
);
665
666 gdk_window_raise (win);
667}
668
669static gboolean
670x11_window_is_ours (Window window)
671{
672 GdkWindow *gwindow;
673 gboolean ret;
674
675 ret = FALSE(0);
676
677 gwindow = gdk_x11_window_lookup_for_display (gdk_display_get_default (), window);
678 if (gwindow && (window != GDK_ROOT_WINDOW ()(gdk_x11_get_default_root_xwindow ())))
679 {
680 ret = TRUE(!(0));
681 }
682
683 return ret;
684}
685
686#ifdef HAVE_SHAPE_EXT1
687static void
688unshape_window (GSWindow *window)
689{
690 gdk_window_shape_combine_region (gtk_widget_get_window (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
),
691 NULL((void*)0),
692 0,
693 0);
694}
695#endif
696
697static void
698gs_window_xevent (GSWindow *window,
699 GdkXEvent *xevent)
700{
701 XEvent *ev;
702
703 ev = xevent;
704
705 /* MapNotify is used to tell us when new windows are mapped.
706 ConfigureNofify is used to tell us when windows are raised. */
707 switch (ev->xany.type)
708 {
709 case MapNotify19:
710 {
711 XMapEvent *xme = &ev->xmap;
712
713 if (! x11_window_is_ours (xme->window))
714 {
715 gs_window_raise (window);
716 }
717 else
718 {
719 gs_debug ("not raising our windows")gs_debug_real (__func__, "gs-window-x11.c", 719, "not raising our windows"
)
;
720 }
721
722 break;
723 }
724 case ConfigureNotify22:
725 {
726 XConfigureEvent *xce = &ev->xconfigure;
727
728 if (! x11_window_is_ours (xce->window))
729 {
730 gs_window_raise (window);
731 }
732 else
733 {
734 gs_debug ("not raising our windows")gs_debug_real (__func__, "gs-window-x11.c", 734, "not raising our windows"
)
;
735 }
736
737 break;
738 }
739 default:
740 /* extension events */
741#ifdef HAVE_SHAPE_EXT1
742 if (ev->xany.type == (window->priv->shape_event_base + ShapeNotify0))
743 {
744 /*XShapeEvent *xse = (XShapeEvent *) ev;*/
745 unshape_window (window);
746 gs_debug ("Window was reshaped!")gs_debug_real (__func__, "gs-window-x11.c", 746, "Window was reshaped!"
)
;
747 }
748#endif
749
750 break;
751 }
752
753}
754
755static GdkFilterReturn
756xevent_filter (GdkXEvent *xevent,
757 GdkEvent *event,
758 GSWindow *window)
759{
760 gs_window_xevent (window, xevent);
761
762 return GDK_FILTER_CONTINUE;
763}
764
765static void
766select_popup_events (void)
767{
768 XWindowAttributes attr;
769 unsigned long events;
770 GdkDisplay *display;
771
772 display = gdk_display_get_default ();
773
774 gdk_x11_display_error_trap_push (display);
775
776 memset (&attr, 0, sizeof (attr));
777 XGetWindowAttributes (GDK_DISPLAY_XDISPLAY (display)(gdk_x11_display_get_xdisplay (display)), GDK_ROOT_WINDOW ()(gdk_x11_get_default_root_xwindow ()), &attr);
778
779 events = SubstructureNotifyMask(1L<<19) | attr.your_event_mask;
780 XSelectInput (GDK_DISPLAY_XDISPLAY (display)(gdk_x11_display_get_xdisplay (display)), GDK_ROOT_WINDOW ()(gdk_x11_get_default_root_xwindow ()), events);
781
782 gdk_x11_display_error_trap_pop_ignored (display);
783}
784
785static void
786window_select_shape_events (GSWindow *window)
787{
788#ifdef HAVE_SHAPE_EXT1
789 unsigned long events;
790 int shape_error_base;
791 GdkDisplay *display;
792
793 display = gtk_widget_get_display (GTK_WIDGET(window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
);
794
795 gdk_x11_display_error_trap_push (display);
796
797 if (XShapeQueryExtension (GDK_DISPLAY_XDISPLAY (display)(gdk_x11_display_get_xdisplay (display)), &window->priv->shape_event_base, &shape_error_base)) {
798 events = ShapeNotifyMask(1L << 0);
799 XShapeSelectInput (GDK_DISPLAY_XDISPLAY (display)(gdk_x11_display_get_xdisplay (display)), GDK_WINDOW_XID (gtk_widget_get_window (GTK_WIDGET (window)))(gdk_x11_window_get_xid (gtk_widget_get_window (((((GtkWidget
*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window
)), ((gtk_widget_get_type ())))))))))
, events);
800 }
801
802 gdk_x11_display_error_trap_pop_ignored (display);
803#endif
804}
805
806static gboolean
807gs_window_real_draw (GtkWidget *widget,
808 cairo_t *cr)
809{
810 GSWindow *window = GS_WINDOW (widget)((((GSWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gs_window_get_type ()))))))
;
811 cairo_surface_t *bg_surface = window->priv->background_surface;
812
813 cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
814 if (bg_surface != NULL((void*)0))
815 {
816 cairo_set_source_surface (cr, bg_surface, 0, 0);
817 }
818 else
819 {
820 cairo_set_source_rgb (cr, 0, 0, 0);
821 }
822 cairo_paint (cr);
823
824 return FALSE(0);
825}
826
827static void
828gs_window_real_show (GtkWidget *widget)
829{
830 GSWindow *window;
831
832 if (GTK_WIDGET_CLASS (gs_window_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((gs_window_parent_class)), ((gtk_widget_get_type ()))))))
->show)
833 {
834 GTK_WIDGET_CLASS (gs_window_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((gs_window_parent_class)), ((gtk_widget_get_type ()))))))
->show (widget);
835 }
836
837 gs_window_clear (GS_WINDOW (widget)((((GSWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gs_window_get_type ()))))))
);
838
839 set_invisible_cursor (gtk_widget_get_window (widget), TRUE(!(0)));
840
841 window = GS_WINDOW (widget)((((GSWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gs_window_get_type ()))))))
;
842 if (window->priv->timer)
843 {
844 g_timer_destroy (window->priv->timer);
845 }
846 window->priv->timer = g_timer_new ();
847
848 remove_watchdog_timer (window);
849 add_watchdog_timer (window, 30000);
850
851 select_popup_events ();
852 window_select_shape_events (window);
853 gdk_window_add_filter (NULL((void*)0), (GdkFilterFunc)xevent_filter, window);
854}
855
856static void
857set_info_text_and_icon (GSWindow *window,
858 const char *icon_name,
859 const char *primary_text,
860 const char *secondary_text)
861{
862 GtkWidget *content_area;
863 GtkWidget *hbox_content;
864 GtkWidget *image;
865 GtkWidget *vbox;
866 gchar *primary_markup;
867 gchar *secondary_markup;
868 GtkWidget *primary_label;
869 GtkWidget *secondary_label;
870
871 hbox_content = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 8);
872 gtk_widget_show (hbox_content);
873
874 image = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_DIALOG);
875 gtk_widget_show (image);
876 gtk_box_pack_start (GTK_BOX (hbox_content)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((hbox_content)), ((gtk_box_get_type ()))))))
, image, FALSE(0), FALSE(0), 0);
877 gtk_widget_set_valign (image, GTK_ALIGN_START);
878
879 vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
880 gtk_widget_show (vbox);
881 gtk_box_pack_start (GTK_BOX (hbox_content)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((hbox_content)), ((gtk_box_get_type ()))))))
, vbox, FALSE(0), FALSE(0), 0);
882
883 primary_markup = g_strdup_printf ("<b>%s</b>", primary_text);
884 primary_label = gtk_label_new (primary_markup);
885 g_free (primary_markup);
886 gtk_widget_show (primary_label);
887 gtk_box_pack_start (GTK_BOX (vbox)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((vbox)), ((gtk_box_get_type ()))))))
, primary_label, TRUE(!(0)), TRUE(!(0)), 0);
888 gtk_label_set_use_markup (GTK_LABEL (primary_label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((primary_label)), ((gtk_label_get_type ()))))))
, TRUE(!(0)));
889 gtk_label_set_line_wrap (GTK_LABEL (primary_label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((primary_label)), ((gtk_label_get_type ()))))))
, TRUE(!(0)));
890 gtk_widget_set_halign (primary_label, GTK_ALIGN_START);
891
892 if (secondary_text != NULL((void*)0))
893 {
894 secondary_markup = g_strdup_printf ("<small>%s</small>",
895 secondary_text);
896 secondary_label = gtk_label_new (secondary_markup);
897 g_free (secondary_markup);
898 gtk_widget_show (secondary_label);
899 gtk_box_pack_start (GTK_BOX (vbox)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((vbox)), ((gtk_box_get_type ()))))))
, secondary_label, TRUE(!(0)), TRUE(!(0)), 0);
900 gtk_label_set_use_markup (GTK_LABEL (secondary_label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((secondary_label)), ((gtk_label_get_type ()))))))
, TRUE(!(0)));
901 gtk_label_set_line_wrap (GTK_LABEL (secondary_label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((secondary_label)), ((gtk_label_get_type ()))))))
, TRUE(!(0)));
902 gtk_widget_set_halign (secondary_label, GTK_ALIGN_START);
903 }
904
905 /* remove old content */
906 content_area = gtk_info_bar_get_content_area (GTK_INFO_BAR (window->priv->info_bar)((((GtkInfoBar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->info_bar)), ((gtk_info_bar_get_type(
)))))))
);
907 if (window->priv->info_content != NULL((void*)0))
908 {
909 gtk_container_remove (GTK_CONTAINER (content_area)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((content_area)), ((gtk_container_get_type ()))))))
, window->priv->info_content);
910 }
911 gtk_box_pack_start (GTK_BOX (content_area)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((content_area)), ((gtk_box_get_type ()))))))
,
912 hbox_content,
913 TRUE(!(0)), FALSE(0), 0);
914 window->priv->info_content = hbox_content;
915}
916
917static gboolean
918info_bar_timeout (GSWindow *window)
919{
920 window->priv->info_bar_timer_id = 0;
921 gtk_widget_hide (window->priv->info_bar);
922 return FALSE(0);
923}
924
925void
926gs_window_show_message (GSWindow *window,
927 const char *summary,
928 const char *body,
929 const char *icon)
930{
931 g_return_if_fail (GS_IS_WINDOW (window))do{ (void)0; }while (0);
932
933 set_info_text_and_icon (window,
934 icon,
935 summary,
936 body);
937 gtk_widget_show (window->priv->info_bar);
938
939 if (window->priv->info_bar_timer_id > 0)
940 {
941 g_source_remove (window->priv->info_bar_timer_id);
942 }
943
944 window->priv->info_bar_timer_id = g_timeout_add_seconds (INFO_BAR_SECONDS30,
945 (GSourceFunc)info_bar_timeout,
946 window);
947}
948
949void
950gs_window_show (GSWindow *window)
951{
952 g_return_if_fail (GS_IS_WINDOW (window))do{ (void)0; }while (0);
953
954 gtk_widget_show (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
);
955}
956
957static void
958gs_window_real_hide (GtkWidget *widget)
959{
960 GSWindow *window;
961
962 window = GS_WINDOW (widget)((((GSWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gs_window_get_type ()))))))
;
963
964 gdk_window_remove_filter (NULL((void*)0), (GdkFilterFunc)xevent_filter, window);
965
966 remove_watchdog_timer (window);
967
968 if (GTK_WIDGET_CLASS (gs_window_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((gs_window_parent_class)), ((gtk_widget_get_type ()))))))
->hide)
969 {
970 GTK_WIDGET_CLASS (gs_window_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((gs_window_parent_class)), ((gtk_widget_get_type ()))))))
->hide (widget);
971 }
972}
973
974void
975gs_window_destroy (GSWindow *window)
976{
977 g_return_if_fail (GS_IS_WINDOW (window))do{ (void)0; }while (0);
978
979 gs_window_cancel_unlock_request (window);
980
981 gtk_widget_destroy (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
);
982}
983
984GdkWindow *
985gs_window_get_gdk_window (GSWindow *window)
986{
987 g_return_val_if_fail (GS_IS_WINDOW (window), NULL)do{ (void)0; }while (0);
988
989 return gtk_widget_get_window (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
);
990}
991
992GtkWidget *
993gs_window_get_drawing_area (GSWindow *window)
994{
995 g_return_val_if_fail (GS_IS_WINDOW (window), NULL)do{ (void)0; }while (0);
996
997 return window->priv->drawing_area;
998}
999
1000/* just for debugging */
1001static gboolean
1002error_watch (GIOChannel *source,
1003 GIOCondition condition,
1004 gpointer data)
1005{
1006 gboolean finished = FALSE(0);
1007
1008 if (condition & G_IO_IN)
1009 {
1010 GIOStatus status;
1011 GError *error = NULL((void*)0);
1012 char *line;
1013
1014 line = NULL((void*)0);
1015 status = g_io_channel_read_line (source, &line, NULL((void*)0), NULL((void*)0), &error);
1016
1017 switch (status)
1018 {
1019 case G_IO_STATUS_NORMAL:
1020 gs_debug ("command error output: %s", line)gs_debug_real (__func__, "gs-window-x11.c", 1020, "command error output: %s"
, line)
;
1021 break;
1022 case G_IO_STATUS_EOF:
1023 finished = TRUE(!(0));
1024 break;
1025 case G_IO_STATUS_ERROR:
1026 finished = TRUE(!(0));
Value stored to 'finished' is never read
1027 gs_debug ("Error reading from child: %s\n", error->message)gs_debug_real (__func__, "gs-window-x11.c", 1027, "Error reading from child: %s\n"
, error->message)
;
1028 g_error_free (error);
1029 return FALSE(0);
1030 case G_IO_STATUS_AGAIN:
1031 default:
1032 break;
1033 }
1034 g_free (line);
1035 }
1036 else if (condition & G_IO_HUP)
1037 {
1038 finished = TRUE(!(0));
1039 }
1040
1041 if (finished)
1042 {
1043 return FALSE(0);
1044 }
1045
1046 return TRUE(!(0));
1047}
1048
1049static gboolean
1050spawn_on_window (GSWindow *window,
1051 char *command,
1052 int *pid,
1053 GIOFunc watch_func,
1054 gpointer user_data,
1055 gint *watch_id)
1056{
1057 int argc;
1058 char **argv;
1059 char **envp;
1060 GError *error;
1061 gboolean result;
1062 GIOChannel *channel;
1063 int standard_output;
1064 int standard_error;
1065 int child_pid;
1066 int id;
1067
1068 error = NULL((void*)0);
1069 if (! g_shell_parse_argv (command, &argc, &argv, &error))
1070 {
1071 gs_debug ("Could not parse command: %s", error->message)gs_debug_real (__func__, "gs-window-x11.c", 1071, "Could not parse command: %s"
, error->message)
;
1072 g_error_free (error);
1073 return FALSE(0);
1074 }
1075
1076 error = NULL((void*)0);
1077 envp = spawn_make_environment_for_display (gtk_widget_get_display (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
), NULL((void*)0));
1078 result = g_spawn_async_with_pipes (NULL((void*)0),
1079 argv,
1080 envp,
1081 G_SPAWN_DO_NOT_REAP_CHILD | G_SPAWN_SEARCH_PATH,
1082 NULL((void*)0),
1083 NULL((void*)0),
1084 &child_pid,
1085 NULL((void*)0),
1086 &standard_output,
1087 &standard_error,
1088 &error);
1089
1090 if (! result)
1091 {
1092 gs_debug ("Could not start command '%s': %s", command, error->message)gs_debug_real (__func__, "gs-window-x11.c", 1092, "Could not start command '%s': %s"
, command, error->message)
;
1093 g_error_free (error);
1094 g_strfreev (argv);
1095 return FALSE(0);
1096 }
1097
1098 if (pid != NULL((void*)0))
1099 {
1100 *pid = child_pid;
1101 }
1102 else
1103 {
1104 g_spawn_close_pid (child_pid);
1105 }
1106
1107 /* output channel */
1108 channel = g_io_channel_unix_new (standard_output);
1109 g_io_channel_set_close_on_unref (channel, TRUE(!(0)));
1110 g_io_channel_set_flags (channel,
1111 g_io_channel_get_flags (channel) | G_IO_FLAG_NONBLOCK,
1112 NULL((void*)0));
1113 id = g_io_add_watch (channel,
1114 G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL,
1115 watch_func,
1116 user_data);
1117 if (watch_id != NULL((void*)0))
1118 {
1119 *watch_id = id;
1120 }
1121 g_io_channel_unref (channel);
1122
1123 /* error channel */
1124 channel = g_io_channel_unix_new (standard_error);
1125 g_io_channel_set_close_on_unref (channel, TRUE(!(0)));
1126 g_io_channel_set_flags (channel,
1127 g_io_channel_get_flags (channel) | G_IO_FLAG_NONBLOCK,
1128 NULL((void*)0));
1129 id = g_io_add_watch (channel,
1130 G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL,
1131 error_watch,
1132 NULL((void*)0));
1133 g_io_channel_unref (channel);
1134
1135 g_strfreev (argv);
1136 g_strfreev (envp);
1137
1138 return result;
1139}
1140
1141static void
1142lock_plug_added (GtkWidget *widget,
1143 GSWindow *window)
1144{
1145 gtk_widget_show (widget);
1146}
1147
1148static gboolean
1149lock_plug_removed (GtkWidget *widget,
1150 GSWindow *window)
1151{
1152 gtk_widget_hide (widget);
1153 gtk_container_remove (GTK_CONTAINER (window->priv->vbox)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->vbox)), ((gtk_container_get_type ())
)))))
, GTK_WIDGET (window->priv->lock_box)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->lock_box)), ((gtk_widget_get_type ()
))))))
);
1154 window->priv->lock_box = NULL((void*)0);
1155
1156 return TRUE(!(0));
1157}
1158
1159static void
1160keyboard_plug_added (GtkWidget *widget,
1161 GSWindow *window)
1162{
1163 gtk_widget_show (widget);
1164}
1165
1166static gboolean
1167keyboard_plug_removed (GtkWidget *widget,
1168 GSWindow *window)
1169{
1170 gtk_widget_hide (widget);
1171 gtk_container_remove (GTK_CONTAINER (window->priv->vbox)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->vbox)), ((gtk_container_get_type ())
)))))
, GTK_WIDGET (window->priv->keyboard_socket)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->keyboard_socket)), ((gtk_widget_get_type
()))))))
);
1172
1173 return TRUE(!(0));
1174}
1175
1176static void
1177keyboard_socket_destroyed (GtkWidget *widget,
1178 GSWindow *window)
1179{
1180 g_signal_handlers_disconnect_by_func (widget, keyboard_socket_destroyed, window)g_signal_handlers_disconnect_matched ((widget), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (keyboard_socket_destroyed), (window))
;
1181 g_signal_handlers_disconnect_by_func (widget, keyboard_plug_added, window)g_signal_handlers_disconnect_matched ((widget), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (keyboard_plug_added), (window))
;
1182 g_signal_handlers_disconnect_by_func (widget, keyboard_plug_removed, window)g_signal_handlers_disconnect_matched ((widget), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (keyboard_plug_removed), (window))
;
1183
1184 window->priv->keyboard_socket = NULL((void*)0);
1185}
1186
1187static void
1188forward_key_events (GSWindow *window)
1189{
1190 window->priv->key_events = g_list_reverse (window->priv->key_events);
1191
1192 while (window->priv->key_events != NULL((void*)0))
1193 {
1194 GdkEventKey *event = window->priv->key_events->data;
1195
1196 gtk_window_propagate_key_event (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
, event);
1197
1198 gdk_event_free ((GdkEvent *)event);
1199 window->priv->key_events = g_list_delete_link (window->priv->key_events,
1200 window->priv->key_events);
1201 }
1202}
1203
1204static void
1205remove_key_events (GSWindow *window)
1206{
1207 window->priv->key_events = g_list_reverse (window->priv->key_events);
1208
1209 while (window->priv->key_events)
1210 {
1211 GdkEventKey *event = window->priv->key_events->data;
1212
1213 gdk_event_free ((GdkEvent *)event);
1214 window->priv->key_events = g_list_delete_link (window->priv->key_events,
1215 window->priv->key_events);
1216 }
1217}
1218
1219static void
1220lock_socket_show (GtkWidget *widget,
1221 GSWindow *window)
1222{
1223 gtk_widget_child_focus (window->priv->lock_socket, GTK_DIR_TAB_FORWARD);
1224
1225 /* send queued events to the dialog */
1226 forward_key_events (window);
1227}
1228
1229static void
1230lock_socket_destroyed (GtkWidget *widget,
1231 GSWindow *window)
1232{
1233 g_signal_handlers_disconnect_by_func (widget, lock_socket_show, window)g_signal_handlers_disconnect_matched ((widget), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (lock_socket_show), (window))
;
1234 g_signal_handlers_disconnect_by_func (widget, lock_socket_destroyed, window)g_signal_handlers_disconnect_matched ((widget), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (lock_socket_destroyed), (window))
;
1235 g_signal_handlers_disconnect_by_func (widget, lock_plug_added, window)g_signal_handlers_disconnect_matched ((widget), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (lock_plug_added), (window))
;
1236 g_signal_handlers_disconnect_by_func (widget, lock_plug_removed, window)g_signal_handlers_disconnect_matched ((widget), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (lock_plug_removed), (window))
;
1237
1238 window->priv->lock_socket = NULL((void*)0);
1239}
1240
1241static void
1242create_keyboard_socket (GSWindow *window,
1243 guint32 id)
1244{
1245 int height;
1246
1247 height = (HeightOfScreen (gdk_x11_screen_get_xscreen (gtk_widget_get_screen (GTK_WIDGET (window))))((gdk_x11_screen_get_xscreen (gtk_widget_get_screen (((((GtkWidget
*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window
)), ((gtk_widget_get_type ())))))))))->height)
) / 4;
1248
1249 window->priv->keyboard_socket = gtk_socket_new ();
1250 gtk_widget_set_size_request (window->priv->keyboard_socket, -1, height);
1251
1252 g_signal_connect (window->priv->keyboard_socket, "destroy",g_signal_connect_data ((window->priv->keyboard_socket),
("destroy"), (((GCallback) (keyboard_socket_destroyed))), (window
), ((void*)0), (GConnectFlags) 0)
1253 G_CALLBACK (keyboard_socket_destroyed), window)g_signal_connect_data ((window->priv->keyboard_socket),
("destroy"), (((GCallback) (keyboard_socket_destroyed))), (window
), ((void*)0), (GConnectFlags) 0)
;
1254 g_signal_connect (window->priv->keyboard_socket, "plug_added",g_signal_connect_data ((window->priv->keyboard_socket),
("plug_added"), (((GCallback) (keyboard_plug_added))), (window
), ((void*)0), (GConnectFlags) 0)
1255 G_CALLBACK (keyboard_plug_added), window)g_signal_connect_data ((window->priv->keyboard_socket),
("plug_added"), (((GCallback) (keyboard_plug_added))), (window
), ((void*)0), (GConnectFlags) 0)
;
1256 g_signal_connect (window->priv->keyboard_socket, "plug_removed",g_signal_connect_data ((window->priv->keyboard_socket),
("plug_removed"), (((GCallback) (keyboard_plug_removed))), (
window), ((void*)0), (GConnectFlags) 0)
1257 G_CALLBACK (keyboard_plug_removed), window)g_signal_connect_data ((window->priv->keyboard_socket),
("plug_removed"), (((GCallback) (keyboard_plug_removed))), (
window), ((void*)0), (GConnectFlags) 0)
;
1258 gtk_box_pack_start (GTK_BOX (window->priv->vbox)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->vbox)), ((gtk_box_get_type ()))))))
, window->priv->keyboard_socket, FALSE(0), FALSE(0), 0);
1259 gtk_socket_add_id (GTK_SOCKET (window->priv->keyboard_socket)((((GtkSocket*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->keyboard_socket)), ((gtk_socket_get_type
()))))))
, id);
1260}
1261
1262/* adapted from gspawn.c */
1263static int
1264wait_on_child (int pid)
1265{
1266 int status;
1267
1268wait_again:
1269 if (waitpid (pid, &status, 0) < 0)
1270 {
1271 if (errno(*__errno_location ()) == EINTR4)
1272 {
1273 goto wait_again;
1274 }
1275 else if (errno(*__errno_location ()) == ECHILD10)
1276 {
1277 ; /* do nothing, child already reaped */
1278 }
1279 else
1280 {
1281 gs_debug ("waitpid () should not fail in 'GSWindow'")gs_debug_real (__func__, "gs-window-x11.c", 1281, "waitpid () should not fail in 'GSWindow'"
)
;
1282 }
1283 }
1284
1285 return status;
1286}
1287
1288static void
1289kill_keyboard_command (GSWindow *window)
1290{
1291 if (window->priv->keyboard_pid > 0)
1292 {
1293 signal_pid (window->priv->keyboard_pid, SIGTERM15);
1294 }
1295}
1296
1297static void
1298kill_dialog_command (GSWindow *window)
1299{
1300 /* If a dialog is up we need to signal it
1301 and wait on it */
1302 if (window->priv->lock_pid > 0)
1303 {
1304 signal_pid (window->priv->lock_pid, SIGTERM15);
1305 }
1306}
1307
1308static void
1309keyboard_command_finish (GSWindow *window)
1310{
1311 g_return_if_fail (GS_IS_WINDOW (window))do{ (void)0; }while (0);
1312
1313 /* send a signal just in case */
1314 kill_keyboard_command (window);
1315
1316 gs_debug ("Keyboard finished")gs_debug_real (__func__, "gs-window-x11.c", 1316, "Keyboard finished"
)
;
1317
1318 if (window->priv->keyboard_pid > 0)
1319 {
1320 wait_on_child (window->priv->keyboard_pid);
1321
1322 g_spawn_close_pid (window->priv->keyboard_pid);
1323 window->priv->keyboard_pid = 0;
1324 }
1325}
1326
1327static gboolean
1328keyboard_command_watch (GIOChannel *source,
1329 GIOCondition condition,
1330 GSWindow *window)
1331{
1332 gboolean finished = FALSE(0);
1333
1334 g_return_val_if_fail (GS_IS_WINDOW (window), FALSE)do{ (void)0; }while (0);
1335
1336 if (condition & G_IO_IN)
1337 {
1338 GIOStatus status;
1339 GError *error = NULL((void*)0);
1340 char *line;
1341
1342 line = NULL((void*)0);
1343 status = g_io_channel_read_line (source, &line, NULL((void*)0), NULL((void*)0), &error);
1344
1345 switch (status)
1346 {
1347 case G_IO_STATUS_NORMAL:
1348 {
1349 guint32 id;
1350 char c;
1351 gs_debug ("keyboard command output: %s", line)gs_debug_real (__func__, "gs-window-x11.c", 1351, "keyboard command output: %s"
, line)
;
1352 if (1 == sscanf (line, " %" G_GUINT32_FORMAT"u" " %c", &id, &c))
1353 {
1354 create_keyboard_socket (window, id);
1355 }
1356 }
1357 break;
1358 case G_IO_STATUS_EOF:
1359 finished = TRUE(!(0));
1360 break;
1361 case G_IO_STATUS_ERROR:
1362 finished = TRUE(!(0));
1363 gs_debug ("Error reading from child: %s\n", error->message)gs_debug_real (__func__, "gs-window-x11.c", 1363, "Error reading from child: %s\n"
, error->message)
;
1364 g_error_free (error);
1365 return FALSE(0);
1366 case G_IO_STATUS_AGAIN:
1367 default:
1368 break;
1369 }
1370
1371 g_free (line);
1372 }
1373 else if (condition & G_IO_HUP)
1374 {
1375 finished = TRUE(!(0));
1376 }
1377
1378 if (finished)
1379 {
1380 window->priv->keyboard_watch_id = 0;
1381 keyboard_command_finish (window);
1382 return FALSE(0);
1383 }
1384
1385 return TRUE(!(0));
1386}
1387
1388static void
1389embed_keyboard (GSWindow *window)
1390{
1391 gboolean res;
1392
1393 if (! window->priv->keyboard_enabled
1394 || window->priv->keyboard_command == NULL((void*)0))
1395 return;
1396
1397 gs_debug ("Adding embedded keyboard widget")gs_debug_real (__func__, "gs-window-x11.c", 1397, "Adding embedded keyboard widget"
)
;
1398
1399 /* FIXME: verify command is safe */
1400
1401 gs_debug ("Running command: %s", window->priv->keyboard_command)gs_debug_real (__func__, "gs-window-x11.c", 1401, "Running command: %s"
, window->priv->keyboard_command)
;
1402
1403 res = spawn_on_window (window,
1404 window->priv->keyboard_command,
1405 &window->priv->keyboard_pid,
1406 (GIOFunc)keyboard_command_watch,
1407 window,
1408 &window->priv->keyboard_watch_id);
1409 if (! res)
1410 {
1411 gs_debug ("Could not start command: %s", window->priv->keyboard_command)gs_debug_real (__func__, "gs-window-x11.c", 1411, "Could not start command: %s"
, window->priv->keyboard_command)
;
1412 }
1413}
1414
1415static void
1416create_lock_socket (GSWindow *window,
1417 guint32 id)
1418{
1419 window->priv->lock_socket = gtk_socket_new ();
1420 window->priv->lock_box = gtk_grid_new ();
1421 gtk_widget_set_halign (GTK_WIDGET (window->priv->lock_box)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->lock_box)), ((gtk_widget_get_type ()
))))))
,
1422 GTK_ALIGN_CENTER);
1423 gtk_widget_set_valign (GTK_WIDGET (window->priv->lock_box)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->lock_box)), ((gtk_widget_get_type ()
))))))
,
1424 GTK_ALIGN_CENTER);
1425 gtk_widget_show (window->priv->lock_box);
1426 gtk_box_pack_start (GTK_BOX (window->priv->vbox)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->vbox)), ((gtk_box_get_type ()))))))
, window->priv->lock_box, TRUE(!(0)), TRUE(!(0)), 0);
1427
1428 gtk_container_add (GTK_CONTAINER (window->priv->lock_box)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->lock_box)), ((gtk_container_get_type
()))))))
, window->priv->lock_socket);
1429
1430 g_signal_connect (window->priv->lock_socket, "show",g_signal_connect_data ((window->priv->lock_socket), ("show"
), (((GCallback) (lock_socket_show))), (window), ((void*)0), (
GConnectFlags) 0)
1431 G_CALLBACK (lock_socket_show), window)g_signal_connect_data ((window->priv->lock_socket), ("show"
), (((GCallback) (lock_socket_show))), (window), ((void*)0), (
GConnectFlags) 0)
;
1432 g_signal_connect (window->priv->lock_socket, "destroy",g_signal_connect_data ((window->priv->lock_socket), ("destroy"
), (((GCallback) (lock_socket_destroyed))), (window), ((void*
)0), (GConnectFlags) 0)
1433 G_CALLBACK (lock_socket_destroyed), window)g_signal_connect_data ((window->priv->lock_socket), ("destroy"
), (((GCallback) (lock_socket_destroyed))), (window), ((void*
)0), (GConnectFlags) 0)
;
1434 g_signal_connect (window->priv->lock_socket, "plug_added",g_signal_connect_data ((window->priv->lock_socket), ("plug_added"
), (((GCallback) (lock_plug_added))), (window), ((void*)0), (
GConnectFlags) 0)
1435 G_CALLBACK (lock_plug_added), window)g_signal_connect_data ((window->priv->lock_socket), ("plug_added"
), (((GCallback) (lock_plug_added))), (window), ((void*)0), (
GConnectFlags) 0)
;
1436 g_signal_connect (window->priv->lock_socket, "plug_removed",g_signal_connect_data ((window->priv->lock_socket), ("plug_removed"
), (((GCallback) (lock_plug_removed))), (window), ((void*)0),
(GConnectFlags) 0)
1437 G_CALLBACK (lock_plug_removed), window)g_signal_connect_data ((window->priv->lock_socket), ("plug_removed"
), (((GCallback) (lock_plug_removed))), (window), ((void*)0),
(GConnectFlags) 0)
;
1438
1439 gtk_socket_add_id (GTK_SOCKET (window->priv->lock_socket)((((GtkSocket*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->lock_socket)), ((gtk_socket_get_type
()))))))
, id);
1440
1441 if (window->priv->keyboard_enabled)
1442 {
1443 embed_keyboard (window);
1444 }
1445}
1446
1447static void
1448gs_window_dialog_finish (GSWindow *window)
1449{
1450 g_return_if_fail (GS_IS_WINDOW (window))do{ (void)0; }while (0);
1451
1452 gs_debug ("Dialog finished")gs_debug_real (__func__, "gs-window-x11.c", 1452, "Dialog finished"
)
;
1453
1454 /* make sure we finish the keyboard thing too */
1455 keyboard_command_finish (window);
1456
1457 /* send a signal just in case */
1458 kill_dialog_command (window);
1459
1460 if (window->priv->lock_pid > 0)
1461 {
1462 wait_on_child (window->priv->lock_pid);
1463
1464 g_spawn_close_pid (window->priv->lock_pid);
1465 window->priv->lock_pid = 0;
1466 }
1467
1468 /* remove events for the case were we failed to show socket */
1469 remove_key_events (window);
1470}
1471
1472static void
1473maybe_kill_dialog (GSWindow *window)
1474{
1475 if (!window->priv->dialog_shake_in_progress
1476 && window->priv->dialog_quit_requested
1477 && window->priv->lock_pid > 0)
1478 {
1479 kill (window->priv->lock_pid, SIGTERM15);
1480 }
1481}
1482
1483/* very rudimentary animation for indicating an auth failure */
1484static void
1485shake_dialog (GSWindow *window)
1486{
1487 int i;
1488 guint start, end;
1489
1490 window->priv->dialog_shake_in_progress = TRUE(!(0));
1491
1492 for (i = 0; i < 8; i++)
1493 {
1494 if (i % 2 == 0)
1495 {
1496 start = 30;
1497 end = 0;
1498 }
1499 else
1500 {
1501 start = 0;
1502 end = 30;
1503 }
1504
1505 if (! window->priv->lock_box)
1506 {
1507 break;
1508 }
1509
1510 gtk_widget_set_margin_start (GTK_WIDGET (window->priv->lock_box)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->lock_box)), ((gtk_widget_get_type ()
))))))
,
1511 start);
1512 gtk_widget_set_margin_end (GTK_WIDGET (window->priv->lock_box)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->lock_box)), ((gtk_widget_get_type ()
))))))
,
1513 end);
1514
1515 while (gtk_events_pending ())
1516 {
1517 gtk_main_iteration ();
1518 }
1519
1520 g_usleep (10000);
1521 }
1522
1523 window->priv->dialog_shake_in_progress = FALSE(0);
1524 maybe_kill_dialog (window);
1525}
1526
1527static void
1528window_set_dialog_up (GSWindow *window,
1529 gboolean dialog_up)
1530{
1531 if (window->priv->dialog_up == dialog_up)
1532 {
1533 return;
1534 }
1535
1536 window->priv->dialog_up = (dialog_up != FALSE(0));
1537 g_object_notify (G_OBJECT (window)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), (((GType) ((20) << (2))))))))
, "dialog-up");
1538}
1539
1540static void
1541popdown_dialog (GSWindow *window)
1542{
1543 gs_window_dialog_finish (window);
1544
1545 gtk_widget_show (window->priv->drawing_area);
1546
1547 gs_window_clear (window);
1548 set_invisible_cursor (gtk_widget_get_window (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
), TRUE(!(0)));
1549
1550 window_set_dialog_up (window, FALSE(0));
1551
1552 /* reset the pointer positions */
1553 window->priv->last_x = -1;
1554 window->priv->last_y = -1;
1555
1556 if (window->priv->lock_box != NULL((void*)0))
1557 {
1558 gtk_container_remove (GTK_CONTAINER (window->priv->vbox)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->vbox)), ((gtk_container_get_type ())
)))))
, GTK_WIDGET (window->priv->lock_box)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->lock_box)), ((gtk_widget_get_type ()
))))))
);
1559 window->priv->lock_box = NULL((void*)0);
1560 }
1561
1562 remove_popup_dialog_idle (window);
1563 remove_command_watches (window);
1564}
1565
1566static gboolean
1567lock_command_watch (GIOChannel *source,
1568 GIOCondition condition,
1569 GSWindow *window)
1570{
1571 gboolean finished = FALSE(0);
1572
1573 g_return_val_if_fail (GS_IS_WINDOW (window), FALSE)do{ (void)0; }while (0);
1574
1575 if (condition & G_IO_IN)
1576 {
1577 GIOStatus status;
1578 GError *error = NULL((void*)0);
1579 char *line;
1580
1581 line = NULL((void*)0);
1582 status = g_io_channel_read_line (source, &line, NULL((void*)0), NULL((void*)0), &error);
1583
1584 switch (status)
1585 {
1586 case G_IO_STATUS_NORMAL:
1587 gs_debug ("command output: %s", line)gs_debug_real (__func__, "gs-window-x11.c", 1587, "command output: %s"
, line)
;
1588
1589 if (strstr (line, "WINDOW ID=") != NULL((void*)0))
1590 {
1591 guint32 id;
1592 char c;
1593 if (1 == sscanf (line, " WINDOW ID= %" G_GUINT32_FORMAT"u" " %c", &id, &c))
1594 {
1595 create_lock_socket (window, id);
1596 }
1597 }
1598 else if (strstr (line, "NOTICE=") != NULL((void*)0))
1599 {
1600 if (strstr (line, "NOTICE=AUTH FAILED") != NULL((void*)0))
1601 {
1602 shake_dialog (window);
1603 }
1604 }
1605 else if (strstr (line, "RESPONSE=") != NULL((void*)0))
1606 {
1607 if (strstr (line, "RESPONSE=OK") != NULL((void*)0))
1608 {
1609 gs_debug ("Got OK response")gs_debug_real (__func__, "gs-window-x11.c", 1609, "Got OK response"
)
;
1610 window->priv->dialog_response = DIALOG_RESPONSE_OK;
1611 }
1612 else
1613 {
1614 gs_debug ("Got CANCEL response")gs_debug_real (__func__, "gs-window-x11.c", 1614, "Got CANCEL response"
)
;
1615 window->priv->dialog_response = DIALOG_RESPONSE_CANCEL;
1616 }
1617 finished = TRUE(!(0));
1618 }
1619 else if (strstr (line, "REQUEST QUIT") != NULL((void*)0))
1620 {
1621 gs_debug ("Got request for quit")gs_debug_real (__func__, "gs-window-x11.c", 1621, "Got request for quit"
)
;
1622 window->priv->dialog_quit_requested = TRUE(!(0));
1623 maybe_kill_dialog (window);
1624 }
1625 break;
1626 case G_IO_STATUS_EOF:
1627 finished = TRUE(!(0));
1628 break;
1629 case G_IO_STATUS_ERROR:
1630 finished = TRUE(!(0));
1631 gs_debug ("Error reading from child: %s\n", error->message)gs_debug_real (__func__, "gs-window-x11.c", 1631, "Error reading from child: %s\n"
, error->message)
;
1632 g_error_free (error);
1633 return FALSE(0);
1634 case G_IO_STATUS_AGAIN:
1635 default:
1636 break;
1637 }
1638
1639 g_free (line);
1640 }
1641 else if (condition & G_IO_HUP)
1642 {
1643 finished = TRUE(!(0));
1644 }
1645
1646 if (finished)
1647 {
1648 popdown_dialog (window);
1649
1650 if (window->priv->dialog_response == DIALOG_RESPONSE_OK)
1651 {
1652 add_emit_deactivated_idle (window);
1653 }
1654
1655 window->priv->lock_watch_id = 0;
1656
1657 return FALSE(0);
1658 }
1659
1660 return TRUE(!(0));
1661}
1662
1663static gboolean
1664is_logout_enabled (GSWindow *window)
1665{
1666 double elapsed;
1667
1668 if (! window->priv->logout_enabled)
1669 {
1670 return FALSE(0);
1671 }
1672
1673 if (! window->priv->logout_command)
1674 {
1675 return FALSE(0);
1676 }
1677
1678 elapsed = g_timer_elapsed (window->priv->timer, NULL((void*)0));
1679
1680 if (window->priv->logout_timeout < (elapsed * 1000))
1681 {
1682 return TRUE(!(0));
1683 }
1684
1685 return FALSE(0);
1686}
1687
1688static gboolean
1689is_user_switch_enabled (GSWindow *window)
1690{
1691 return window->priv->user_switch_enabled;
1692}
1693
1694static void
1695popup_dialog (GSWindow *window)
1696{
1697 gboolean result;
1698 GString *command;
1699
1700 gs_debug ("Popping up dialog")gs_debug_real (__func__, "gs-window-x11.c", 1700, "Popping up dialog"
)
;
1701
1702 command = g_string_new (MATE_SCREENSAVER_DIALOG_PATH"/usr/local/libexec" "/mate-screensaver-dialog");
1703
1704 if (is_logout_enabled (window))
1705 {
1706 command = g_string_append (command, " --enable-logout");
1707 g_string_append_printf (command, " --logout-command='%s'", window->priv->logout_command);
1708 }
1709
1710 if (window->priv->status_message)
1711 {
1712 char *quoted;
1713
1714 quoted = g_shell_quote (window->priv->status_message);
1715 g_string_append_printf (command, " --status-message=%s", quoted);
1716 g_free (quoted);
1717 }
1718
1719 if (is_user_switch_enabled (window))
1720 {
1721 command = g_string_append (command, " --enable-switch");
1722 }
1723
1724 if (gs_debug_enabled ())
1725 {
1726 command = g_string_append (command, " --verbose");
1727 }
1728
1729 gtk_widget_hide (window->priv->drawing_area);
1730
1731 gtk_widget_queue_draw (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
);
1732 set_invisible_cursor (gtk_widget_get_window (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
), FALSE(0));
1733
1734 window->priv->dialog_quit_requested = FALSE(0);
1735 window->priv->dialog_shake_in_progress = FALSE(0);
1736
1737 result = spawn_on_window (window,
1738 command->str,
1739 &window->priv->lock_pid,
1740 (GIOFunc)lock_command_watch,
1741 window,
1742 &window->priv->lock_watch_id);
1743 if (! result)
1744 {
1745 gs_debug ("Could not start command: %s", command->str)gs_debug_real (__func__, "gs-window-x11.c", 1745, "Could not start command: %s"
, command->str)
;
1746 }
1747
1748 g_string_free (command, TRUE(!(0)));
1749}
1750
1751static gboolean
1752popup_dialog_idle (gpointer data)
1753{
1754 GSWindow *window = data;
1755
1756 popup_dialog (window);
1757 window->priv->popup_dialog_idle_id = 0;
1758 return FALSE(0);
1759}
1760
1761void
1762gs_window_request_unlock (GSWindow *window)
1763{
1764 g_return_if_fail (GS_IS_WINDOW (window))do{ (void)0; }while (0);
1765
1766 gs_debug ("Requesting unlock")gs_debug_real (__func__, "gs-window-x11.c", 1766, "Requesting unlock"
)
;
1767
1768 if (! gtk_widget_get_visible (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
))
1769 {
1770 gs_debug ("Request unlock but window is not visible!")gs_debug_real (__func__, "gs-window-x11.c", 1770, "Request unlock but window is not visible!"
)
;
1771 return;
1772 }
1773
1774 if (window->priv->lock_watch_id > 0)
1775 {
1776 return;
1777 }
1778
1779 if (! window->priv->lock_enabled)
1780 {
1781 add_emit_deactivated_idle (window);
1782
1783 return;
1784 }
1785
1786 if (window->priv->popup_dialog_idle_id == 0)
1787 {
1788 add_popup_dialog_idle (window);
1789 }
1790
1791 window_set_dialog_up (window, TRUE(!(0)));
1792}
1793
1794void
1795gs_window_cancel_unlock_request (GSWindow *window)
1796{
1797 /* FIXME: This is a bit of a hammer approach...
1798 * Maybe we should send a delete-event to
1799 * the plug?
1800 */
1801 g_return_if_fail (GS_IS_WINDOW (window))do{ (void)0; }while (0);
1802
1803 popdown_dialog (window);
1804}
1805
1806void
1807gs_window_set_lock_enabled (GSWindow *window,
1808 gboolean lock_enabled)
1809{
1810 g_return_if_fail (GS_IS_WINDOW (window))do{ (void)0; }while (0);
1811
1812 if (window->priv->lock_enabled == lock_enabled)
1813 {
1814 return;
1815 }
1816
1817 window->priv->lock_enabled = (lock_enabled != FALSE(0));
1818 g_object_notify (G_OBJECT (window)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), (((GType) ((20) << (2))))))))
, "lock-enabled");
1819}
1820
1821GdkDisplay *
1822gs_window_get_display (GSWindow *window)
1823{
1824 g_return_val_if_fail (GS_IS_WINDOW (window), NULL)do{ (void)0; }while (0);
1825
1826 return gtk_widget_get_display (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
);
1827}
1828
1829void
1830gs_window_set_keyboard_enabled (GSWindow *window,
1831 gboolean enabled)
1832{
1833 g_return_if_fail (GS_IS_WINDOW (window))do{ (void)0; }while (0);
1834
1835 window->priv->keyboard_enabled = (enabled != FALSE(0));
1836}
1837
1838void
1839gs_window_set_keyboard_command (GSWindow *window,
1840 const char *command)
1841{
1842 g_return_if_fail (GS_IS_WINDOW (window))do{ (void)0; }while (0);
1843
1844 g_free (window->priv->keyboard_command);
1845
1846 if (command != NULL((void*)0))
1847 {
1848 window->priv->keyboard_command = g_strdup (command);
1849 }
1850 else
1851 {
1852 window->priv->keyboard_command = NULL((void*)0);
1853 }
1854}
1855
1856void
1857gs_window_set_logout_enabled (GSWindow *window,
1858 gboolean logout_enabled)
1859{
1860 g_return_if_fail (GS_IS_WINDOW (window))do{ (void)0; }while (0);
1861
1862 window->priv->logout_enabled = (logout_enabled != FALSE(0));
1863}
1864
1865void
1866gs_window_set_user_switch_enabled (GSWindow *window,
1867 gboolean user_switch_enabled)
1868{
1869 g_return_if_fail (GS_IS_WINDOW (window))do{ (void)0; }while (0);
1870
1871 window->priv->user_switch_enabled = (user_switch_enabled != FALSE(0));
1872}
1873
1874void
1875gs_window_set_logout_timeout (GSWindow *window,
1876 glong logout_timeout)
1877{
1878 g_return_if_fail (GS_IS_WINDOW (window))do{ (void)0; }while (0);
1879
1880 if (logout_timeout < 0)
1881 {
1882 window->priv->logout_timeout = 0;
1883 }
1884 else
1885 {
1886 window->priv->logout_timeout = logout_timeout;
1887 }
1888}
1889
1890void
1891gs_window_set_logout_command (GSWindow *window,
1892 const char *command)
1893{
1894 g_return_if_fail (GS_IS_WINDOW (window))do{ (void)0; }while (0);
1895
1896 g_free (window->priv->logout_command);
1897
1898 if (command)
1899 {
1900 window->priv->logout_command = g_strdup (command);
1901 }
1902 else
1903 {
1904 window->priv->logout_command = NULL((void*)0);
1905 }
1906}
1907
1908void
1909gs_window_set_status_message (GSWindow *window,
1910 const char *status_message)
1911{
1912 g_return_if_fail (GS_IS_WINDOW (window))do{ (void)0; }while (0);
1913
1914 g_free (window->priv->status_message);
1915 window->priv->status_message = g_strdup (status_message);
1916}
1917
1918void
1919gs_window_set_monitor (GSWindow *window,
1920 GdkMonitor *monitor)
1921{
1922 g_return_if_fail (GS_IS_WINDOW (window))do{ (void)0; }while (0);
1923
1924 if (window->priv->monitor == monitor)
1925 {
1926 return;
1927 }
1928
1929 window->priv->monitor = monitor;
1930
1931 gtk_widget_queue_resize (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
);
1932
1933 g_object_notify (G_OBJECT (window)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), (((GType) ((20) << (2))))))))
, "monitor");
1934}
1935
1936GdkMonitor *
1937gs_window_get_monitor (GSWindow *window)
1938{
1939 g_return_val_if_fail (GS_IS_WINDOW (window), NULL)do{ (void)0; }while (0);
1940
1941 return window->priv->monitor;
1942}
1943
1944static void
1945gs_window_set_property (GObject *object,
1946 guint prop_id,
1947 const GValue *value,
1948 GParamSpec *pspec)
1949{
1950 GSWindow *self;
1951
1952 self = GS_WINDOW (object)((((GSWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((gs_window_get_type ()))))))
;
1953
1954 switch (prop_id)
1955 {
1956 case PROP_LOCK_ENABLED:
1957 gs_window_set_lock_enabled (self, g_value_get_boolean (value));
1958 break;
1959 case PROP_KEYBOARD_ENABLED:
1960 gs_window_set_keyboard_enabled (self, g_value_get_boolean (value));
1961 break;
1962 case PROP_KEYBOARD_COMMAND:
1963 gs_window_set_keyboard_command (self, g_value_get_string (value));
1964 break;
1965 case PROP_LOGOUT_ENABLED:
1966 gs_window_set_logout_enabled (self, g_value_get_boolean (value));
1967 break;
1968 case PROP_LOGOUT_COMMAND:
1969 gs_window_set_logout_command (self, g_value_get_string (value));
1970 break;
1971 case PROP_STATUS_MESSAGE:
1972 gs_window_set_status_message (self, g_value_get_string (value));
1973 break;
1974 case PROP_LOGOUT_TIMEOUT:
1975 gs_window_set_logout_timeout (self, g_value_get_long (value));
1976 break;
1977 case PROP_MONITOR:
1978 gs_window_set_monitor (self, g_value_get_pointer (value));
1979 break;
1980 default:
1981 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec)do { GObject *_glib__object = (GObject*) ((object)); GParamSpec
*_glib__pspec = (GParamSpec*) ((pspec)); guint _glib__property_id
= ((prop_id)); g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'"
, "gs-window-x11.c", 1981, ("property"), _glib__property_id, _glib__pspec
->name, g_type_name ((((((GTypeClass*) (((GTypeInstance*) (
_glib__pspec))->g_class))->g_type)))), (g_type_name (((
(((GTypeClass*) (((GTypeInstance*) (_glib__object))->g_class
))->g_type)))))); } while (0)
;
1982 break;
1983 }
1984}
1985
1986static void
1987gs_window_get_property (GObject *object,
1988 guint prop_id,
1989 GValue *value,
1990 GParamSpec *pspec)
1991{
1992 GSWindow *self;
1993
1994 self = GS_WINDOW (object)((((GSWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((gs_window_get_type ()))))))
;
1995
1996 switch (prop_id)
1997 {
1998 case PROP_LOCK_ENABLED:
1999 g_value_set_boolean (value, self->priv->lock_enabled);
2000 break;
2001 case PROP_KEYBOARD_ENABLED:
2002 g_value_set_boolean (value, self->priv->keyboard_enabled);
2003 break;
2004 case PROP_KEYBOARD_COMMAND:
2005 g_value_set_string (value, self->priv->keyboard_command);
2006 break;
2007 case PROP_LOGOUT_ENABLED:
2008 g_value_set_boolean (value, self->priv->logout_enabled);
2009 break;
2010 case PROP_LOGOUT_COMMAND:
2011 g_value_set_string (value, self->priv->logout_command);
2012 break;
2013 case PROP_STATUS_MESSAGE:
2014 g_value_set_string (value, self->priv->status_message);
2015 break;
2016 case PROP_LOGOUT_TIMEOUT:
2017 g_value_set_long (value, self->priv->logout_timeout);
2018 break;
2019 case PROP_MONITOR:
2020 g_value_set_pointer (value, (gpointer) self->priv->monitor);
2021 break;
2022 case PROP_OBSCURED:
2023 g_value_set_boolean (value, self->priv->obscured);
2024 break;
2025 case PROP_DIALOG_UP:
2026 g_value_set_boolean (value, self->priv->dialog_up);
2027 break;
2028 default:
2029 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec)do { GObject *_glib__object = (GObject*) ((object)); GParamSpec
*_glib__pspec = (GParamSpec*) ((pspec)); guint _glib__property_id
= ((prop_id)); g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'"
, "gs-window-x11.c", 2029, ("property"), _glib__property_id, _glib__pspec
->name, g_type_name ((((((GTypeClass*) (((GTypeInstance*) (
_glib__pspec))->g_class))->g_type)))), (g_type_name (((
(((GTypeClass*) (((GTypeInstance*) (_glib__object))->g_class
))->g_type)))))); } while (0)
;
2030 break;
2031 }
2032}
2033
2034static void
2035queue_key_event (GSWindow *window,
2036 GdkEventKey *event)
2037{
2038 /* Eat the first return, enter, escape, or space */
2039 if (window->priv->key_events == NULL((void*)0)
2040 && (event->keyval == GDK_KEY_Return0xff0d
2041 || event->keyval == GDK_KEY_KP_Enter0xff8d
2042 || event->keyval == GDK_KEY_Escape0xff1b
2043 || event->keyval == GDK_KEY_space0x020))
2044 {
2045 return;
2046 }
2047
2048 /* Only cache MAX_QUEUED_EVENTS key events. If there are any more than this then
2049 something is wrong */
2050 /* Don't queue keys that may cause focus navigation in the dialog */
2051 if (g_list_length (window->priv->key_events) < MAX_QUEUED_EVENTS16
2052 && event->keyval != GDK_KEY_Tab0xff09
2053 && event->keyval != GDK_KEY_Up0xff52
2054 && event->keyval != GDK_KEY_Down0xff54)
2055 {
2056 window->priv->key_events = g_list_prepend (window->priv->key_events,
2057 gdk_event_copy ((GdkEvent *)event));
2058 }
2059}
2060
2061static gboolean
2062maybe_handle_activity (GSWindow *window)
2063{
2064 gboolean handled;
2065
2066 handled = FALSE(0);
2067
2068 /* if we already have a socket then don't bother */
2069 if (! window->priv->lock_socket
2070 && gtk_widget_get_sensitive (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
))
2071 {
2072 g_signal_emit (window, signals [ACTIVITY], 0, &handled);
2073 }
2074
2075 return handled;
2076}
2077
2078static gboolean
2079gs_window_real_key_press_event (GtkWidget *widget,
2080 GdkEventKey *event)
2081{
2082 /*g_message ("KEY PRESS state: %u keyval %u", event->state, event->keyval);*/
2083
2084 /* Ignore brightness keys */
2085 if (event->hardware_keycode == 101 || event->hardware_keycode == 212)
2086 {
2087 gs_debug ("Ignoring brightness keys")gs_debug_real (__func__, "gs-window-x11.c", 2087, "Ignoring brightness keys"
)
;
2088 return TRUE(!(0));
2089 }
2090
2091 maybe_handle_activity (GS_WINDOW (widget)((((GSWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gs_window_get_type ()))))))
);
2092
2093 queue_key_event (GS_WINDOW (widget)((((GSWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gs_window_get_type ()))))))
, event);
2094
2095 if (GTK_WIDGET_CLASS (gs_window_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((gs_window_parent_class)), ((gtk_widget_get_type ()))))))
->key_press_event)
2096 {
2097 GTK_WIDGET_CLASS (gs_window_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((gs_window_parent_class)), ((gtk_widget_get_type ()))))))
->key_press_event (widget, event);
2098 }
2099
2100 return TRUE(!(0));
2101}
2102
2103static gboolean
2104gs_window_real_motion_notify_event (GtkWidget *widget,
2105 GdkEventMotion *event)
2106{
2107 GSWindow *window;
2108 gdouble distance;
2109 gdouble min_distance;
2110 gdouble min_percentage = 0.1;
2111 GdkDisplay *display;
2112 GdkScreen *screen;
2113
2114 window = GS_WINDOW (widget)((((GSWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gs_window_get_type ()))))))
;
2115
2116 display = gs_window_get_display (window);
2117 screen = gdk_display_get_default_screen (display);
2118 min_distance = WidthOfScreen (gdk_x11_screen_get_xscreen (screen))((gdk_x11_screen_get_xscreen (screen))->width) * min_percentage;
2119
2120 /* if the last position was not set then don't detect motion */
2121 if (window->priv->last_x < 0 || window->priv->last_y < 0)
2122 {
2123 window->priv->last_x = event->x;
2124 window->priv->last_y = event->y;
2125
2126 return FALSE(0);
2127 }
2128
2129 /* just an approximate distance */
2130 distance = MAX (ABS (window->priv->last_x - event->x),((((((window->priv->last_x - event->x) < 0) ? -(window
->priv->last_x - event->x) : (window->priv->last_x
- event->x))) > ((((window->priv->last_y - event
->y) < 0) ? -(window->priv->last_y - event->y)
: (window->priv->last_y - event->y)))) ? ((((window
->priv->last_x - event->x) < 0) ? -(window->priv
->last_x - event->x) : (window->priv->last_x - event
->x))) : ((((window->priv->last_y - event->y) <
0) ? -(window->priv->last_y - event->y) : (window->
priv->last_y - event->y))))
2131 ABS (window->priv->last_y - event->y))((((((window->priv->last_x - event->x) < 0) ? -(window
->priv->last_x - event->x) : (window->priv->last_x
- event->x))) > ((((window->priv->last_y - event
->y) < 0) ? -(window->priv->last_y - event->y)
: (window->priv->last_y - event->y)))) ? ((((window
->priv->last_x - event->x) < 0) ? -(window->priv
->last_x - event->x) : (window->priv->last_x - event
->x))) : ((((window->priv->last_y - event->y) <
0) ? -(window->priv->last_y - event->y) : (window->
priv->last_y - event->y))))
;
2132
2133 if (distance > min_distance)
2134 {
2135 maybe_handle_activity (window);
2136
2137 window->priv->last_x = -1;
2138 window->priv->last_y = -1;
2139 }
2140
2141 return FALSE(0);
2142}
2143
2144static gboolean
2145gs_window_real_button_press_event (GtkWidget *widget,
2146 GdkEventButton *event)
2147{
2148 GSWindow *window;
2149
2150 window = GS_WINDOW (widget)((((GSWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gs_window_get_type ()))))))
;
2151 maybe_handle_activity (window);
2152
2153 return FALSE(0);
2154}
2155
2156static gboolean
2157gs_window_real_scroll_event (GtkWidget *widget,
2158 GdkEventScroll *event)
2159{
2160 GSWindow *window;
2161
2162 window = GS_WINDOW (widget)((((GSWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gs_window_get_type ()))))))
;
2163 maybe_handle_activity (window);
2164
2165 return FALSE(0);
2166}
2167
2168static void
2169gs_window_real_size_request (GtkWidget *widget,
2170 GtkRequisition *requisition)
2171{
2172 GSWindow *window;
2173 GtkBin *bin;
2174 GtkWidget *child;
2175 GdkRectangle old_geometry;
2176 int position_changed = FALSE(0);
2177 int size_changed = FALSE(0);
2178
2179 window = GS_WINDOW (widget)((((GSWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gs_window_get_type ()))))))
;
2180 bin = GTK_BIN (widget)((((GtkBin*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_bin_get_type ()))))))
;
2181 child = gtk_bin_get_child (bin);
2182
2183 if (child && gtk_widget_get_visible (child))
2184 {
2185 gtk_widget_get_preferred_size (child, requisition, NULL((void*)0));
2186 }
2187
2188 old_geometry = window->priv->geometry;
2189
2190 update_geometry (window);
2191
2192 requisition->width = window->priv->geometry.width;
2193 requisition->height = window->priv->geometry.height;
2194
2195 if (! gtk_widget_get_realized (widget))
2196 {
2197 return;
2198 }
2199
2200 if (old_geometry.width != window->priv->geometry.width ||
2201 old_geometry.height != window->priv->geometry.height)
2202 {
2203 size_changed = TRUE(!(0));
2204 }
2205
2206 if (old_geometry.x != window->priv->geometry.x ||
2207 old_geometry.y != window->priv->geometry.y)
2208 {
2209 position_changed = TRUE(!(0));
2210 }
2211
2212 gs_window_move_resize_window (window, position_changed, size_changed);
2213}
2214
2215static void
2216gs_window_real_get_preferred_width (GtkWidget *widget,
2217 gint *minimal_width,
2218 gint *natural_width)
2219{
2220 GtkRequisition requisition;
2221 gs_window_real_size_request (widget, &requisition);
2222 *minimal_width = *natural_width = requisition.width;
2223}
2224
2225static void
2226gs_window_real_get_preferred_height (GtkWidget *widget,
2227 gint *minimal_height,
2228 gint *natural_height)
2229{
2230 GtkRequisition requisition;
2231 gs_window_real_size_request (widget, &requisition);
2232 *minimal_height = *natural_height = requisition.height;
2233}
2234
2235static gboolean
2236gs_window_real_grab_broken (GtkWidget *widget,
2237 GdkEventGrabBroken *event)
2238{
2239 if (event->grab_window != NULL((void*)0))
2240 {
2241 gs_debug ("Grab broken on window %X %s, new grab on window %X",gs_debug_real (__func__, "gs-window-x11.c", 2244, "Grab broken on window %X %s, new grab on window %X"
, (guint32) (gdk_x11_window_get_xid (event->window)), event
->keyboard ? "keyboard" : "pointer", (guint32) (gdk_x11_window_get_xid
(event->grab_window)))
2242 (guint32) GDK_WINDOW_XID (event->window),gs_debug_real (__func__, "gs-window-x11.c", 2244, "Grab broken on window %X %s, new grab on window %X"
, (guint32) (gdk_x11_window_get_xid (event->window)), event
->keyboard ? "keyboard" : "pointer", (guint32) (gdk_x11_window_get_xid
(event->grab_window)))
2243 event->keyboard ? "keyboard" : "pointer",gs_debug_real (__func__, "gs-window-x11.c", 2244, "Grab broken on window %X %s, new grab on window %X"
, (guint32) (gdk_x11_window_get_xid (event->window)), event
->keyboard ? "keyboard" : "pointer", (guint32) (gdk_x11_window_get_xid
(event->grab_window)))
2244 (guint32) GDK_WINDOW_XID (event->grab_window))gs_debug_real (__func__, "gs-window-x11.c", 2244, "Grab broken on window %X %s, new grab on window %X"
, (guint32) (gdk_x11_window_get_xid (event->window)), event
->keyboard ? "keyboard" : "pointer", (guint32) (gdk_x11_window_get_xid
(event->grab_window)))
;
2245 }
2246 else
2247 {
2248 gs_debug ("Grab broken on window %X %s, new grab is outside application",gs_debug_real (__func__, "gs-window-x11.c", 2250, "Grab broken on window %X %s, new grab is outside application"
, (guint32) (gdk_x11_window_get_xid (event->window)), event
->keyboard ? "keyboard" : "pointer")
2249 (guint32) GDK_WINDOW_XID (event->window),gs_debug_real (__func__, "gs-window-x11.c", 2250, "Grab broken on window %X %s, new grab is outside application"
, (guint32) (gdk_x11_window_get_xid (event->window)), event
->keyboard ? "keyboard" : "pointer")
2250 event->keyboard ? "keyboard" : "pointer")gs_debug_real (__func__, "gs-window-x11.c", 2250, "Grab broken on window %X %s, new grab is outside application"
, (guint32) (gdk_x11_window_get_xid (event->window)), event
->keyboard ? "keyboard" : "pointer")
;
2251 }
2252
2253 return FALSE(0);
2254}
2255
2256gboolean
2257gs_window_is_obscured (GSWindow *window)
2258{
2259 g_return_val_if_fail (GS_IS_WINDOW (window), FALSE)do{ (void)0; }while (0);
2260
2261 return window->priv->obscured;
2262}
2263
2264gboolean
2265gs_window_is_dialog_up (GSWindow *window)
2266{
2267 g_return_val_if_fail (GS_IS_WINDOW (window), FALSE)do{ (void)0; }while (0);
2268
2269 return window->priv->dialog_up;
2270}
2271
2272static void
2273window_set_obscured (GSWindow *window,
2274 gboolean obscured)
2275{
2276 if (window->priv->obscured == obscured)
2277 {
2278 return;
2279 }
2280
2281 window->priv->obscured = (obscured != FALSE(0));
2282 g_object_notify (G_OBJECT (window)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), (((GType) ((20) << (2))))))))
, "obscured");
2283}
2284
2285static gboolean
2286gs_window_real_visibility_notify_event (GtkWidget *widget,
2287 GdkEventVisibility *event)
2288{
2289 switch (event->state)
2290 {
2291 case GDK_VISIBILITY_FULLY_OBSCURED:
2292 window_set_obscured (GS_WINDOW (widget)((((GSWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gs_window_get_type ()))))))
, TRUE(!(0)));
2293 break;
2294 case GDK_VISIBILITY_PARTIAL:
2295 break;
2296 case GDK_VISIBILITY_UNOBSCURED:
2297 window_set_obscured (GS_WINDOW (widget)((((GSWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gs_window_get_type ()))))))
, FALSE(0));
2298 break;
2299 default:
2300 break;
2301 }
2302
2303 return FALSE(0);
2304}
2305
2306static void
2307gs_window_class_init (GSWindowClass *klass)
2308{
2309 GObjectClass *object_class = G_OBJECT_CLASS (klass)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((klass)), (((GType) ((20) << (2))))))))
;
2310 GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((klass)), ((gtk_widget_get_type ()))))))
;
2311
2312 object_class->finalize = gs_window_finalize;
2313 object_class->get_property = gs_window_get_property;
2314 object_class->set_property = gs_window_set_property;
2315
2316 widget_class->show = gs_window_real_show;
2317 widget_class->hide = gs_window_real_hide;
2318 widget_class->draw = gs_window_real_draw;
2319 widget_class->realize = gs_window_real_realize;
2320 widget_class->unrealize = gs_window_real_unrealize;
2321 widget_class->key_press_event = gs_window_real_key_press_event;
2322 widget_class->motion_notify_event = gs_window_real_motion_notify_event;
2323 widget_class->button_press_event = gs_window_real_button_press_event;
2324 widget_class->scroll_event = gs_window_real_scroll_event;
2325 widget_class->get_preferred_width = gs_window_real_get_preferred_width;
2326 widget_class->get_preferred_height = gs_window_real_get_preferred_height;
2327 widget_class->grab_broken_event = gs_window_real_grab_broken;
2328 widget_class->visibility_notify_event = gs_window_real_visibility_notify_event;
2329
2330 signals [ACTIVITY] =
2331 g_signal_new ("activity",
2332 G_TYPE_FROM_CLASS (object_class)(((GTypeClass*) (object_class))->g_type),
2333 G_SIGNAL_RUN_LAST,
2334 G_STRUCT_OFFSET (GSWindowClass, activity)((glong) __builtin_offsetof(GSWindowClass, activity)),
2335 NULL((void*)0),
2336 NULL((void*)0),
2337 gs_marshal_BOOLEAN__VOID,
2338 G_TYPE_BOOLEAN((GType) ((5) << (2))),
2339 0);
2340 signals [DEACTIVATED] =
2341 g_signal_new ("deactivated",
2342 G_TYPE_FROM_CLASS (object_class)(((GTypeClass*) (object_class))->g_type),
2343 G_SIGNAL_RUN_LAST,
2344 G_STRUCT_OFFSET (GSWindowClass, deactivated)((glong) __builtin_offsetof(GSWindowClass, deactivated)),
2345 NULL((void*)0),
2346 NULL((void*)0),
2347 g_cclosure_marshal_VOID__VOID,
2348 G_TYPE_NONE((GType) ((1) << (2))),
2349 0);
2350
2351 g_object_class_install_property (object_class,
2352 PROP_OBSCURED,
2353 g_param_spec_boolean ("obscured",
2354 NULL((void*)0),
2355 NULL((void*)0),
2356 FALSE(0),
2357 G_PARAM_READABLE));
2358 g_object_class_install_property (object_class,
2359 PROP_DIALOG_UP,
2360 g_param_spec_boolean ("dialog-up",
2361 NULL((void*)0),
2362 NULL((void*)0),
2363 FALSE(0),
2364 G_PARAM_READABLE));
2365 g_object_class_install_property (object_class,
2366 PROP_LOCK_ENABLED,
2367 g_param_spec_boolean ("lock-enabled",
2368 NULL((void*)0),
2369 NULL((void*)0),
2370 FALSE(0),
2371 G_PARAM_READWRITE));
2372 g_object_class_install_property (object_class,
2373 PROP_LOGOUT_ENABLED,
2374 g_param_spec_boolean ("logout-enabled",
2375 NULL((void*)0),
2376 NULL((void*)0),
2377 FALSE(0),
2378 G_PARAM_READWRITE));
2379 g_object_class_install_property (object_class,
2380 PROP_LOGOUT_TIMEOUT,
2381 g_param_spec_long ("logout-timeout",
2382 NULL((void*)0),
2383 NULL((void*)0),
2384 -1,
2385 G_MAXLONG9223372036854775807L,
2386 0,
2387 G_PARAM_READWRITE));
2388 g_object_class_install_property (object_class,
2389 PROP_LOGOUT_COMMAND,
2390 g_param_spec_string ("logout-command",
2391 NULL((void*)0),
2392 NULL((void*)0),
2393 NULL((void*)0),
2394 G_PARAM_READWRITE));
2395 g_object_class_install_property (object_class,
2396 PROP_STATUS_MESSAGE,
2397 g_param_spec_string ("status-message",
2398 NULL((void*)0),
2399 NULL((void*)0),
2400 NULL((void*)0),
2401 G_PARAM_READWRITE));
2402 g_object_class_install_property (object_class,
2403 PROP_KEYBOARD_ENABLED,
2404 g_param_spec_boolean ("keyboard-enabled",
2405 NULL((void*)0),
2406 NULL((void*)0),
2407 FALSE(0),
2408 G_PARAM_READWRITE));
2409 g_object_class_install_property (object_class,
2410 PROP_KEYBOARD_COMMAND,
2411 g_param_spec_string ("keyboard-command",
2412 NULL((void*)0),
2413 NULL((void*)0),
2414 NULL((void*)0),
2415 G_PARAM_READWRITE));
2416
2417 g_object_class_install_property (object_class,
2418 PROP_MONITOR,
2419 g_param_spec_pointer ("monitor",
2420 "Gdk monitor",
2421 "The monitor (in terms of Gdk) which the window is on",
2422 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
2423}
2424
2425static void
2426create_info_bar (GSWindow *window)
2427{
2428 window->priv->info_bar = gtk_info_bar_new ();
2429 gtk_widget_set_no_show_all (window->priv->info_bar, TRUE(!(0)));
2430 gtk_box_pack_end (GTK_BOX (window->priv->vbox)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->vbox)), ((gtk_box_get_type ()))))))
, window->priv->info_bar, FALSE(0), FALSE(0), 0);
2431}
2432
2433static gboolean
2434on_drawing_area_draw (GtkWidget *widget,
2435 cairo_t *cr)
2436{
2437 cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
2438 cairo_set_source_rgb (cr, 0, 0, 0);
2439 cairo_paint (cr);
2440
2441 return FALSE(0);
2442}
2443
2444static void
2445gs_window_init (GSWindow *window)
2446{
2447 window->priv = gs_window_get_instance_private (window);
2448
2449 window->priv->geometry.x = -1;
2450 window->priv->geometry.y = -1;
2451 window->priv->geometry.width = -1;
2452 window->priv->geometry.height = -1;
2453
2454 window->priv->last_x = -1;
2455 window->priv->last_y = -1;
2456
2457 gtk_window_set_decorated (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
, FALSE(0));
2458
2459 gtk_window_set_skip_taskbar_hint (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
, TRUE(!(0)));
2460 gtk_window_set_skip_pager_hint (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
, TRUE(!(0)));
2461
2462 gtk_window_set_keep_above (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
, TRUE(!(0)));
2463
2464 gtk_window_fullscreen (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
);
2465
2466 gtk_widget_set_events (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
,
2467 gtk_widget_get_events (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
)
2468 | GDK_POINTER_MOTION_MASK
2469 | GDK_BUTTON_PRESS_MASK
2470 | GDK_BUTTON_RELEASE_MASK
2471 | GDK_KEY_PRESS_MASK
2472 | GDK_KEY_RELEASE_MASK
2473 | GDK_EXPOSURE_MASK
2474 | GDK_VISIBILITY_NOTIFY_MASK
2475 | GDK_ENTER_NOTIFY_MASK
2476 | GDK_LEAVE_NOTIFY_MASK);
2477
2478 window->priv->vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
2479 gtk_widget_show (window->priv->vbox);
2480 gtk_container_add (GTK_CONTAINER (window)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_container_get_type ()))))))
, window->priv->vbox);
2481
2482 window->priv->drawing_area = gtk_drawing_area_new ();
2483 gtk_widget_show (window->priv->drawing_area);
2484 gtk_widget_set_app_paintable (window->priv->drawing_area, TRUE(!(0)));
2485 gtk_box_pack_start (GTK_BOX (window->priv->vbox)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->vbox)), ((gtk_box_get_type ()))))))
,
2486 window->priv->drawing_area, TRUE(!(0)), TRUE(!(0)), 0);
2487 g_signal_connect (window->priv->drawing_area,g_signal_connect_data ((window->priv->drawing_area), ("draw"
), (((GCallback) (on_drawing_area_draw))), (((void*)0)), ((void
*)0), (GConnectFlags) 0)
2488 "draw",g_signal_connect_data ((window->priv->drawing_area), ("draw"
), (((GCallback) (on_drawing_area_draw))), (((void*)0)), ((void
*)0), (GConnectFlags) 0)
2489 G_CALLBACK (on_drawing_area_draw),g_signal_connect_data ((window->priv->drawing_area), ("draw"
), (((GCallback) (on_drawing_area_draw))), (((void*)0)), ((void
*)0), (GConnectFlags) 0)
2490 NULL)g_signal_connect_data ((window->priv->drawing_area), ("draw"
), (((GCallback) (on_drawing_area_draw))), (((void*)0)), ((void
*)0), (GConnectFlags) 0)
;
2491 create_info_bar (window);
2492
2493}
2494
2495static void
2496remove_command_watches (GSWindow *window)
2497{
2498 if (window->priv->lock_watch_id != 0)
2499 {
2500 g_source_remove (window->priv->lock_watch_id);
2501 window->priv->lock_watch_id = 0;
2502 }
2503 if (window->priv->keyboard_watch_id != 0)
2504 {
2505 g_source_remove (window->priv->keyboard_watch_id);
2506 window->priv->keyboard_watch_id = 0;
2507 }
2508}
2509
2510static void
2511gs_window_finalize (GObject *object)
2512{
2513 GSWindow *window;
2514
2515 g_return_if_fail (object != NULL)do{ (void)0; }while (0);
2516 g_return_if_fail (GS_IS_WINDOW (object))do{ (void)0; }while (0);
2517
2518 window = GS_WINDOW (object)((((GSWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((gs_window_get_type ()))))))
;
2519
2520 g_return_if_fail (window->priv != NULL)do{ (void)0; }while (0);
2521
2522 g_free (window->priv->logout_command);
2523 g_free (window->priv->keyboard_command);
2524
2525 if (window->priv->info_bar_timer_id > 0)
2526 {
2527 g_source_remove (window->priv->info_bar_timer_id);
2528 window->priv->info_bar_timer_id = 0;
2529 }
2530
2531 remove_watchdog_timer (window);
2532 remove_popup_dialog_idle (window);
2533
2534 if (window->priv->timer)
2535 {
2536 g_timer_destroy (window->priv->timer);
2537 }
2538
2539 remove_key_events (window);
2540
2541 remove_command_watches (window);
2542
2543 gs_window_dialog_finish (window);
2544
2545 if (window->priv->background_surface)
2546 {
2547 cairo_surface_destroy (window->priv->background_surface);
2548 }
2549
2550 G_OBJECT_CLASS (gs_window_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((gs_window_parent_class)), (((GType) ((20) << (2)))
)))))
->finalize (object);
2551}
2552
2553GSWindow *
2554gs_window_new (GdkMonitor *monitor,
2555 gboolean lock_enabled)
2556{
2557 GObject *result;
2558 GdkDisplay *display = gdk_monitor_get_display (monitor);
2559 GdkScreen *screen = gdk_display_get_default_screen (display);
2560
2561 result = g_object_new (GS_TYPE_WINDOW(gs_window_get_type ()),
2562 "type", GTK_WINDOW_POPUP,
2563 "screen", screen,
2564 "monitor", monitor,
2565 "lock-enabled", lock_enabled,
2566 "app-paintable", TRUE(!(0)),
2567 NULL((void*)0));
2568
2569 return GS_WINDOW (result)((((GSWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((result)), ((gs_window_get_type ()))))))
;
2570}
diff --git a/2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-b0e322.html b/2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-b0e322.html new file mode 100644 index 0000000..8e258e3 --- /dev/null +++ b/2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-b0e322.html @@ -0,0 +1,1236 @@ + + + +mate-screensaver-command.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rc/mate-screensaver-command.c
Warning:line 445, column 3
Value stored to 'reply' is never read
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name mate-screensaver-command.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/14.0.5 -D HAVE_CONFIG_H -I . -I .. -I . -I . -D MATEMENU_I_KNOW_THIS_IS_UNSTABLE -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/dconf -I /usr/include/mate-menus -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/dconf -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/dconf -I /usr/include/mate-menus -D PREFIX="/usr/local" -D BINDIR="/usr/local/bin" -D LIBDIR="/usr/local/lib" -D LIBEXECDIR="/usr/local/libexec" -D DATADIR="/usr/local/share" -D SYSCONFDIR="/usr/local/etc" -D MATELOCALEDIR="/usr/local/share/locale" -D PKGLIBEXECDIR="/usr/local/libexec/mate-screensaver" -D SAVERDIR="/usr/local/libexec/mate-screensaver" -D THEMESDIR="/usr/local/share/mate-screensaver/themes" -D GTKBUILDERDIR="/usr/local/share/mate-screensaver" -D MATE_SCREENSAVER_GL_HELPER_PATH="/usr/local/libexec/mate-screensaver-gl-helper" -D PAM_SERVICE_NAME="mate-screensaver" -D G_DISABLE_ASSERT -D G_DISABLE_CHECKS -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -internal-isystem /usr/lib64/clang/14.0.5/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/12/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2022-11-11-203102-6531-1 -x c mate-screensaver-command.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
2 *
3 * Copyright (C) 2004-2006 William Jon McCann <mccann@jhu.edu>
4 * Copyright (C) 2012-2021 MATE Developers
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; either version 2 of the
9 * License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
19 * 02110-1301, USA.
20 *
21 * Authors: William Jon McCann <mccann@jhu.edu>
22 *
23 */
24
25#include "config.h"
26
27#include <stdlib.h>
28#include <locale.h>
29#include <glib.h>
30#include <glib/gi18n.h>
31
32#define DBUS_API_SUBJECT_TO_CHANGE
33#include <dbus/dbus.h>
34#include <dbus/dbus-glib.h>
35#include <dbus/dbus-glib-lowlevel.h>
36
37#define GS_SERVICE"org.mate.ScreenSaver" "org.mate.ScreenSaver"
38#define GS_PATH"/org/mate/ScreenSaver" "/org/mate/ScreenSaver"
39#define GS_INTERFACE"org.mate.ScreenSaver" "org.mate.ScreenSaver"
40
41static gboolean do_quit = FALSE(0);
42static gboolean do_lock = FALSE(0);
43static gboolean do_unlock = FALSE(0);
44static gboolean do_cycle = FALSE(0);
45static gboolean do_activate = FALSE(0);
46static gboolean do_deactivate = FALSE(0);
47static gboolean do_version = FALSE(0);
48static gboolean do_poke = FALSE(0);
49static gboolean do_inhibit = FALSE(0);
50
51static gboolean do_query = FALSE(0);
52static gboolean do_time = FALSE(0);
53
54static char *inhibit_reason = NULL((void*)0);
55static char *inhibit_application = NULL((void*)0);
56
57static GOptionEntry entries [] =
58{
59 {
60 "exit", 0, 0, G_OPTION_ARG_NONE, &do_quit,
61 N_("Causes the screensaver to exit gracefully")("Causes the screensaver to exit gracefully"), NULL((void*)0)
62 },
63 {
64 "query", 'q', 0, G_OPTION_ARG_NONE, &do_query,
65 N_("Query the state of the screensaver")("Query the state of the screensaver"), NULL((void*)0)
66 },
67 {
68 "time", 't', 0, G_OPTION_ARG_NONE, &do_time,
69 N_("Query the length of time the screensaver has been active")("Query the length of time the screensaver has been active"), NULL((void*)0)
70 },
71 {
72 "lock", 'l', 0, G_OPTION_ARG_NONE, &do_lock,
73 N_("Tells the running screensaver process to lock the screen immediately")("Tells the running screensaver process to lock the screen immediately"
)
, NULL((void*)0)
74 },
75 {
76 "unlock", 'u', 0, G_OPTION_ARG_NONE, &do_unlock,
77 N_("Tells the running screensaver process to unlock the screen immediately")("Tells the running screensaver process to unlock the screen immediately"
)
, NULL((void*)0)
78 },
79 {
80 "cycle", 'c', 0, G_OPTION_ARG_NONE, &do_cycle,
81 N_("If the screensaver is active then switch to another graphics demo")("If the screensaver is active then switch to another graphics demo"
)
, NULL((void*)0)
82 },
83 {
84 "activate", 'a', 0, G_OPTION_ARG_NONE, &do_activate,
85 N_("Turn the screensaver on (blank the screen)")("Turn the screensaver on (blank the screen)"), NULL((void*)0)
86 },
87 {
88 "deactivate", 'd', 0, G_OPTION_ARG_NONE, &do_deactivate,
89 N_("If the screensaver is active then deactivate it (un-blank the screen)")("If the screensaver is active then deactivate it (un-blank the screen)"
)
, NULL((void*)0)
90 },
91 {
92 "poke", 'p', 0, G_OPTION_ARG_NONE, &do_poke,
93 N_("Poke the running screensaver to simulate user activity")("Poke the running screensaver to simulate user activity"), NULL((void*)0)
94 },
95 {
96 "inhibit", 'i', 0, G_OPTION_ARG_NONE, &do_inhibit,
97 N_("Inhibit the screensaver from activating. Command blocks while inhibit is active.")("Inhibit the screensaver from activating. Command blocks while inhibit is active."
)
, NULL((void*)0)
98 },
99 {
100 "application-name", 'n', 0, G_OPTION_ARG_STRING, &inhibit_application,
101 N_("The calling application that is inhibiting the screensaver")("The calling application that is inhibiting the screensaver"
)
, NULL((void*)0)
102 },
103 {
104 "reason", 'r', 0, G_OPTION_ARG_STRING, &inhibit_reason,
105 N_("The reason for inhibiting the screensaver")("The reason for inhibiting the screensaver"), NULL((void*)0)
106 },
107 {
108 "version", 'V', 0, G_OPTION_ARG_NONE, &do_version,
109 N_("Version of this application")("Version of this application"), NULL((void*)0)
110 },
111 { NULL((void*)0), 0, 0, G_OPTION_ARG_NONE, NULL((void*)0), NULL((void*)0), NULL((void*)0) }
112};
113
114static GMainLoop *loop = NULL((void*)0);
115
116static gboolean
117screensaver_is_running (DBusConnection *connection)
118{
119 DBusError error;
120 gboolean exists;
121
122 g_return_val_if_fail (connection != NULL, FALSE)do{ (void)0; }while (0);
123
124 dbus_error_init (&error);
125 exists = dbus_bus_name_has_owner (connection, GS_SERVICE"org.mate.ScreenSaver", &error);
126 if (dbus_error_is_set (&error))
127 dbus_error_free (&error);
128
129 return exists;
130}
131
132static DBusMessage *
133screensaver_send_message_inhibit (DBusConnection *connection,
134 const char *application,
135 const char *reason)
136{
137 DBusMessage *message;
138 DBusMessage *reply;
139 DBusError error;
140 DBusMessageIter iter;
141
142 g_return_val_if_fail (connection != NULL, NULL)do{ (void)0; }while (0);
143
144 dbus_error_init (&error);
145
146 message = dbus_message_new_method_call (GS_SERVICE"org.mate.ScreenSaver", GS_PATH"/org/mate/ScreenSaver", GS_INTERFACE"org.mate.ScreenSaver", "Inhibit");
147 if (message == NULL((void*)0))
148 {
149 g_warning ("Couldn't allocate the dbus message");
150 return NULL((void*)0);
151 }
152
153 dbus_message_iter_init_append (message, &iter);
154 dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING((int) 's'), &application);
155 dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING((int) 's'), &reason);
156
157 reply = dbus_connection_send_with_reply_and_block (connection,
158 message,
159 -1, &error);
160 if (dbus_error_is_set (&error))
161 {
162 g_warning ("%s raised:\n %s\n\n", error.name, error.message);
163 reply = NULL((void*)0);
164 }
165
166 dbus_connection_flush (connection);
167
168 dbus_message_unref (message);
169 dbus_error_free (&error);
170
171 return reply;
172}
173
174static DBusMessage *
175screensaver_send_message_bool (DBusConnection *connection,
176 const char *name,
177 gboolean value)
178{
179 DBusMessage *message;
180 DBusMessage *reply;
181 DBusError error;
182 DBusMessageIter iter;
183
184 g_return_val_if_fail (connection != NULL, NULL)do{ (void)0; }while (0);
185 g_return_val_if_fail (name != NULL, NULL)do{ (void)0; }while (0);
186
187 dbus_error_init (&error);
188
189 message = dbus_message_new_method_call (GS_SERVICE"org.mate.ScreenSaver", GS_PATH"/org/mate/ScreenSaver", GS_INTERFACE"org.mate.ScreenSaver", name);
190 if (message == NULL((void*)0))
191 {
192 g_warning ("Couldn't allocate the dbus message");
193 return NULL((void*)0);
194 }
195
196 dbus_message_iter_init_append (message, &iter);
197 dbus_message_iter_append_basic (&iter, DBUS_TYPE_BOOLEAN((int) 'b'), &value);
198
199 reply = dbus_connection_send_with_reply_and_block (connection,
200 message,
201 -1, &error);
202 if (dbus_error_is_set (&error))
203 {
204 g_warning ("%s raised:\n %s\n\n", error.name, error.message);
205 reply = NULL((void*)0);
206 }
207
208 dbus_connection_flush (connection);
209
210 dbus_message_unref (message);
211 dbus_error_free (&error);
212
213 return reply;
214}
215
216static DBusMessage *
217screensaver_send_message_void (DBusConnection *connection,
218 const char *name,
219 gboolean expect_reply)
220{
221 DBusMessage *message;
222 DBusMessage *reply;
223 DBusError error;
224
225 g_return_val_if_fail (connection != NULL, NULL)do{ (void)0; }while (0);
226 g_return_val_if_fail (name != NULL, NULL)do{ (void)0; }while (0);
227
228 dbus_error_init (&error);
229
230 message = dbus_message_new_method_call (GS_SERVICE"org.mate.ScreenSaver", GS_PATH"/org/mate/ScreenSaver", GS_INTERFACE"org.mate.ScreenSaver", name);
231 if (message == NULL((void*)0))
232 {
233 g_warning ("Couldn't allocate the dbus message");
234 return NULL((void*)0);
235 }
236
237 if (! expect_reply)
238 {
239 if (!dbus_connection_send (connection, message, NULL((void*)0)))
240 g_warning ("could not send message");
241 reply = NULL((void*)0);
242 }
243 else
244 {
245 reply = dbus_connection_send_with_reply_and_block (connection,
246 message,
247 -1, &error);
248 if (dbus_error_is_set (&error))
249 {
250 g_warning ("%s raised:\n %s\n\n", error.name, error.message);
251 reply = NULL((void*)0);
252 }
253 }
254 dbus_connection_flush (connection);
255
256 dbus_message_unref (message);
257 dbus_error_free (&error);
258
259 return reply;
260}
261
262static char **
263get_string_from_iter (DBusMessageIter *iter,
264 int *num_elements)
265{
266 int count;
267 char **buffer;
268
269 if (num_elements != NULL((void*)0))
270 {
271 *num_elements = 0;
272 }
273
274 count = 0;
275 buffer = (char **)malloc (sizeof (char *) * 8);
276
277 if (buffer == NULL((void*)0))
278 {
279 goto oom;
280 }
281
282 buffer[0] = NULL((void*)0);
283 while (dbus_message_iter_get_arg_type (iter) == DBUS_TYPE_STRING((int) 's'))
284 {
285 const char *value;
286 char *str;
287
288 if ((count % 8) == 0 && count != 0)
289 {
290 buffer = realloc (buffer, sizeof (char *) * (count + 8));
291 if (buffer == NULL((void*)0))
292 {
293 goto oom;
294 }
295 }
296
297 dbus_message_iter_get_basic (iter, &value);
298 str = strdup (value);
299 if (str == NULL((void*)0))
300 {
301 goto oom;
302 }
303
304 buffer[count] = str;
305
306 dbus_message_iter_next (iter);
307 count++;
308 }
309
310 if ((count % 8) == 0)
311 {
312 buffer = realloc (buffer, sizeof (char *) * (count + 1));
313 if (buffer == NULL((void*)0))
314 {
315 goto oom;
316 }
317 }
318
319 buffer[count] = NULL((void*)0);
320 if (num_elements != NULL((void*)0))
321 {
322 *num_elements = count;
323 }
324 return buffer;
325
326oom:
327 g_debug ("%s %d : error allocating memory\n", __FILE__"mate-screensaver-command.c", __LINE__327);
328 return NULL((void*)0);
329
330}
331
332static gboolean
333do_command (gpointer data)
334{
335 DBusConnection *connection = data;
336 DBusMessage *reply;
337
338 if (do_quit)
339 {
340 reply = screensaver_send_message_void (connection, "Quit", FALSE(0));
341 goto done;
342 }
343
344 if (do_query)
345 {
346 DBusMessageIter iter;
347 DBusMessageIter array;
348 dbus_bool_t v;
349
350 reply = screensaver_send_message_void (connection, "GetActive", TRUE(!(0)));
351 if (! reply)
352 {
353 g_message ("Did not receive a reply from the screensaver.");
354 goto done;
355 }
356
357 dbus_message_iter_init (reply, &iter);
358 dbus_message_iter_get_basic (&iter, &v);
359 g_print (_("The screensaver is %s\n")gettext ("The screensaver is %s\n"), v ? _("active")gettext ("active") : _("inactive")gettext ("inactive"));
360
361 dbus_message_unref (reply);
362
363 reply = screensaver_send_message_void (connection, "GetInhibitors", TRUE(!(0)));
364 if (! reply)
365 {
366 g_message ("Did not receive a reply from screensaver.");
367 goto done;
368 }
369
370 dbus_message_iter_init (reply, &iter);
371 dbus_message_iter_recurse (&iter, &array);
372
373 if (dbus_message_iter_get_arg_type (&array) == DBUS_TYPE_INVALID((int) '\0'))
374 {
375 g_print (_("The screensaver is not inhibited\n")gettext ("The screensaver is not inhibited\n"));
376 }
377 else
378 {
379 char **inhibitors;
380 int i;
381 int num;
382
383 g_print (_("The screensaver is being inhibited by:\n")gettext ("The screensaver is being inhibited by:\n"));
384 inhibitors = get_string_from_iter (&array, &num);
385 for (i = 0; i < num; i++)
386 {
387 g_print ("\t%s\n", inhibitors[i]);
388 }
389 g_strfreev (inhibitors);
390 }
391
392 dbus_message_unref (reply);
393 }
394
395 if (do_time)
396 {
397 DBusMessageIter iter;
398 dbus_bool_t v;
399 dbus_int32_t t;
400
401 reply = screensaver_send_message_void (connection, "GetActive", TRUE(!(0)));
402 if (! reply)
403 {
404 g_message ("Did not receive a reply from the screensaver.");
405 goto done;
406 }
407
408 dbus_message_iter_init (reply, &iter);
409 dbus_message_iter_get_basic (&iter, &v);
410 dbus_message_unref (reply);
411
412 if (v)
413 {
414
415 reply = screensaver_send_message_void (connection, "GetActiveTime", TRUE(!(0)));
416 dbus_message_iter_init (reply, &iter);
417 dbus_message_iter_get_basic (&iter, &t);
418 g_print (_("The screensaver has been active for %d seconds.\n")gettext ("The screensaver has been active for %d seconds.\n"), t);
419
420 dbus_message_unref (reply);
421 }
422 else
423 {
424 g_print (_("The screensaver is not currently active.\n")gettext ("The screensaver is not currently active.\n"));
425 }
426 }
427
428 if (do_lock)
429 {
430 reply = screensaver_send_message_void (connection, "Lock", FALSE(0));
431 }
432
433 if (do_unlock)
434 {
435 reply = screensaver_send_message_void (connection, "Unlock", FALSE(0));
436 }
437
438 if (do_cycle)
439 {
440 reply = screensaver_send_message_void (connection, "Cycle", FALSE(0));
441 }
442
443 if (do_poke)
444 {
445 reply = screensaver_send_message_void (connection, "SimulateUserActivity", FALSE(0));
Value stored to 'reply' is never read
446 }
447
448 if (do_activate)
449 {
450 reply = screensaver_send_message_bool (connection, "SetActive", TRUE(!(0)));
451 if (! reply)
452 {
453 g_message ("Did not receive a reply from the screensaver.");
454 goto done;
455 }
456 dbus_message_unref (reply);
457 }
458
459 if (do_deactivate)
460 {
461 reply = screensaver_send_message_bool (connection, "SetActive", FALSE(0));
462 if (! reply)
463 {
464 g_message ("Did not receive a reply from the screensaver.");
465 goto done;
466 }
467 dbus_message_unref (reply);
468 }
469
470 if (do_inhibit)
471 {
472 reply = screensaver_send_message_inhibit (connection,
473 inhibit_application ? inhibit_application : "Unknown",
474 inhibit_reason ? inhibit_reason : "Unknown");
475 if (! reply)
476 {
477 g_message ("Did not receive a reply from the screensaver.");
478 goto done;
479 }
480 dbus_message_unref (reply);
481
482 return FALSE(0);
483 }
484
485done:
486 g_main_loop_quit (loop);
487
488 return FALSE(0);
489}
490
491int
492main (int argc,
493 char **argv)
494{
495 DBusConnection *connection;
496 DBusError dbus_error;
497 GOptionContext *context;
498 gboolean retval;
499 GError *error = NULL((void*)0);
500
501#ifdef ENABLE_NLS1
502 bindtextdomain (GETTEXT_PACKAGE"mate-screensaver", MATELOCALEDIR"/usr/local/share/locale");
503# ifdef HAVE_BIND_TEXTDOMAIN_CODESET
504 bind_textdomain_codeset (GETTEXT_PACKAGE"mate-screensaver", "UTF-8");
505# endif
506 textdomain (GETTEXT_PACKAGE"mate-screensaver");
507#endif
508
509 g_set_prgname (argv[0]);
510
511 if (setlocale (LC_ALL6, "") == NULL((void*)0))
512 g_warning ("Locale not understood by C library, internationalization will not work\n");
513
514 context = g_option_context_new (NULL((void*)0));
515 g_option_context_add_main_entries (context, entries, NULL((void*)0));
516 retval = g_option_context_parse (context, &argc, &argv, &error);
517
518 g_option_context_free (context);
519
520 if (! retval)
521 {
522 g_warning ("%s", error->message);
523 g_error_free (error);
524 exit (1);
525 }
526
527 if (do_version)
528 {
529 g_print ("%s %s\n", argv [0], VERSION"1.27.0");
530 exit (1);
531 }
532
533 dbus_error_init (&dbus_error);
534 connection = dbus_bus_get (DBUS_BUS_SESSION, &dbus_error);
535 if (! connection)
536 {
537 g_message ("Failed to connect to the D-BUS daemon: %s", dbus_error.message);
538 dbus_error_free (&dbus_error);
539 exit (1);
540 }
541
542 dbus_connection_setup_with_g_main (connection, NULL((void*)0));
543
544 if (! screensaver_is_running (connection))
545 {
546 g_message ("Screensaver is not running!");
547 exit (1);
548 }
549
550 g_idle_add (do_command, connection);
551
552 loop = g_main_loop_new (NULL((void*)0), FALSE(0));
553 g_main_loop_run (loop);
554
555 return 0;
556}
diff --git a/2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-ba3e4e.html b/2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-ba3e4e.html new file mode 100644 index 0000000..f2204f3 --- /dev/null +++ b/2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-ba3e4e.html @@ -0,0 +1,1309 @@ + + + +mate-screensaver-command.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rc/mate-screensaver-command.c
Warning:line 327, column 2
Potential leak of memory pointed to by 'buffer'
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name mate-screensaver-command.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/14.0.5 -D HAVE_CONFIG_H -I . -I .. -I . -I . -D MATEMENU_I_KNOW_THIS_IS_UNSTABLE -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/dconf -I /usr/include/mate-menus -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/dconf -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/dconf -I /usr/include/mate-menus -D PREFIX="/usr/local" -D BINDIR="/usr/local/bin" -D LIBDIR="/usr/local/lib" -D LIBEXECDIR="/usr/local/libexec" -D DATADIR="/usr/local/share" -D SYSCONFDIR="/usr/local/etc" -D MATELOCALEDIR="/usr/local/share/locale" -D PKGLIBEXECDIR="/usr/local/libexec/mate-screensaver" -D SAVERDIR="/usr/local/libexec/mate-screensaver" -D THEMESDIR="/usr/local/share/mate-screensaver/themes" -D GTKBUILDERDIR="/usr/local/share/mate-screensaver" -D MATE_SCREENSAVER_GL_HELPER_PATH="/usr/local/libexec/mate-screensaver-gl-helper" -D PAM_SERVICE_NAME="mate-screensaver" -D G_DISABLE_ASSERT -D G_DISABLE_CHECKS -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -internal-isystem /usr/lib64/clang/14.0.5/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/12/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2022-11-11-203102-6531-1 -x c mate-screensaver-command.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
2 *
3 * Copyright (C) 2004-2006 William Jon McCann <mccann@jhu.edu>
4 * Copyright (C) 2012-2021 MATE Developers
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; either version 2 of the
9 * License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
19 * 02110-1301, USA.
20 *
21 * Authors: William Jon McCann <mccann@jhu.edu>
22 *
23 */
24
25#include "config.h"
26
27#include <stdlib.h>
28#include <locale.h>
29#include <glib.h>
30#include <glib/gi18n.h>
31
32#define DBUS_API_SUBJECT_TO_CHANGE
33#include <dbus/dbus.h>
34#include <dbus/dbus-glib.h>
35#include <dbus/dbus-glib-lowlevel.h>
36
37#define GS_SERVICE"org.mate.ScreenSaver" "org.mate.ScreenSaver"
38#define GS_PATH"/org/mate/ScreenSaver" "/org/mate/ScreenSaver"
39#define GS_INTERFACE"org.mate.ScreenSaver" "org.mate.ScreenSaver"
40
41static gboolean do_quit = FALSE(0);
42static gboolean do_lock = FALSE(0);
43static gboolean do_unlock = FALSE(0);
44static gboolean do_cycle = FALSE(0);
45static gboolean do_activate = FALSE(0);
46static gboolean do_deactivate = FALSE(0);
47static gboolean do_version = FALSE(0);
48static gboolean do_poke = FALSE(0);
49static gboolean do_inhibit = FALSE(0);
50
51static gboolean do_query = FALSE(0);
52static gboolean do_time = FALSE(0);
53
54static char *inhibit_reason = NULL((void*)0);
55static char *inhibit_application = NULL((void*)0);
56
57static GOptionEntry entries [] =
58{
59 {
60 "exit", 0, 0, G_OPTION_ARG_NONE, &do_quit,
61 N_("Causes the screensaver to exit gracefully")("Causes the screensaver to exit gracefully"), NULL((void*)0)
62 },
63 {
64 "query", 'q', 0, G_OPTION_ARG_NONE, &do_query,
65 N_("Query the state of the screensaver")("Query the state of the screensaver"), NULL((void*)0)
66 },
67 {
68 "time", 't', 0, G_OPTION_ARG_NONE, &do_time,
69 N_("Query the length of time the screensaver has been active")("Query the length of time the screensaver has been active"), NULL((void*)0)
70 },
71 {
72 "lock", 'l', 0, G_OPTION_ARG_NONE, &do_lock,
73 N_("Tells the running screensaver process to lock the screen immediately")("Tells the running screensaver process to lock the screen immediately"
)
, NULL((void*)0)
74 },
75 {
76 "unlock", 'u', 0, G_OPTION_ARG_NONE, &do_unlock,
77 N_("Tells the running screensaver process to unlock the screen immediately")("Tells the running screensaver process to unlock the screen immediately"
)
, NULL((void*)0)
78 },
79 {
80 "cycle", 'c', 0, G_OPTION_ARG_NONE, &do_cycle,
81 N_("If the screensaver is active then switch to another graphics demo")("If the screensaver is active then switch to another graphics demo"
)
, NULL((void*)0)
82 },
83 {
84 "activate", 'a', 0, G_OPTION_ARG_NONE, &do_activate,
85 N_("Turn the screensaver on (blank the screen)")("Turn the screensaver on (blank the screen)"), NULL((void*)0)
86 },
87 {
88 "deactivate", 'd', 0, G_OPTION_ARG_NONE, &do_deactivate,
89 N_("If the screensaver is active then deactivate it (un-blank the screen)")("If the screensaver is active then deactivate it (un-blank the screen)"
)
, NULL((void*)0)
90 },
91 {
92 "poke", 'p', 0, G_OPTION_ARG_NONE, &do_poke,
93 N_("Poke the running screensaver to simulate user activity")("Poke the running screensaver to simulate user activity"), NULL((void*)0)
94 },
95 {
96 "inhibit", 'i', 0, G_OPTION_ARG_NONE, &do_inhibit,
97 N_("Inhibit the screensaver from activating. Command blocks while inhibit is active.")("Inhibit the screensaver from activating. Command blocks while inhibit is active."
)
, NULL((void*)0)
98 },
99 {
100 "application-name", 'n', 0, G_OPTION_ARG_STRING, &inhibit_application,
101 N_("The calling application that is inhibiting the screensaver")("The calling application that is inhibiting the screensaver"
)
, NULL((void*)0)
102 },
103 {
104 "reason", 'r', 0, G_OPTION_ARG_STRING, &inhibit_reason,
105 N_("The reason for inhibiting the screensaver")("The reason for inhibiting the screensaver"), NULL((void*)0)
106 },
107 {
108 "version", 'V', 0, G_OPTION_ARG_NONE, &do_version,
109 N_("Version of this application")("Version of this application"), NULL((void*)0)
110 },
111 { NULL((void*)0), 0, 0, G_OPTION_ARG_NONE, NULL((void*)0), NULL((void*)0), NULL((void*)0) }
112};
113
114static GMainLoop *loop = NULL((void*)0);
115
116static gboolean
117screensaver_is_running (DBusConnection *connection)
118{
119 DBusError error;
120 gboolean exists;
121
122 g_return_val_if_fail (connection != NULL, FALSE)do{ (void)0; }while (0);
123
124 dbus_error_init (&error);
125 exists = dbus_bus_name_has_owner (connection, GS_SERVICE"org.mate.ScreenSaver", &error);
126 if (dbus_error_is_set (&error))
127 dbus_error_free (&error);
128
129 return exists;
130}
131
132static DBusMessage *
133screensaver_send_message_inhibit (DBusConnection *connection,
134 const char *application,
135 const char *reason)
136{
137 DBusMessage *message;
138 DBusMessage *reply;
139 DBusError error;
140 DBusMessageIter iter;
141
142 g_return_val_if_fail (connection != NULL, NULL)do{ (void)0; }while (0);
143
144 dbus_error_init (&error);
145
146 message = dbus_message_new_method_call (GS_SERVICE"org.mate.ScreenSaver", GS_PATH"/org/mate/ScreenSaver", GS_INTERFACE"org.mate.ScreenSaver", "Inhibit");
147 if (message == NULL((void*)0))
148 {
149 g_warning ("Couldn't allocate the dbus message");
150 return NULL((void*)0);
151 }
152
153 dbus_message_iter_init_append (message, &iter);
154 dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING((int) 's'), &application);
155 dbus_message_iter_append_basic (&iter, DBUS_TYPE_STRING((int) 's'), &reason);
156
157 reply = dbus_connection_send_with_reply_and_block (connection,
158 message,
159 -1, &error);
160 if (dbus_error_is_set (&error))
161 {
162 g_warning ("%s raised:\n %s\n\n", error.name, error.message);
163 reply = NULL((void*)0);
164 }
165
166 dbus_connection_flush (connection);
167
168 dbus_message_unref (message);
169 dbus_error_free (&error);
170
171 return reply;
172}
173
174static DBusMessage *
175screensaver_send_message_bool (DBusConnection *connection,
176 const char *name,
177 gboolean value)
178{
179 DBusMessage *message;
180 DBusMessage *reply;
181 DBusError error;
182 DBusMessageIter iter;
183
184 g_return_val_if_fail (connection != NULL, NULL)do{ (void)0; }while (0);
185 g_return_val_if_fail (name != NULL, NULL)do{ (void)0; }while (0);
186
187 dbus_error_init (&error);
188
189 message = dbus_message_new_method_call (GS_SERVICE"org.mate.ScreenSaver", GS_PATH"/org/mate/ScreenSaver", GS_INTERFACE"org.mate.ScreenSaver", name);
190 if (message == NULL((void*)0))
191 {
192 g_warning ("Couldn't allocate the dbus message");
193 return NULL((void*)0);
194 }
195
196 dbus_message_iter_init_append (message, &iter);
197 dbus_message_iter_append_basic (&iter, DBUS_TYPE_BOOLEAN((int) 'b'), &value);
198
199 reply = dbus_connection_send_with_reply_and_block (connection,
200 message,
201 -1, &error);
202 if (dbus_error_is_set (&error))
203 {
204 g_warning ("%s raised:\n %s\n\n", error.name, error.message);
205 reply = NULL((void*)0);
206 }
207
208 dbus_connection_flush (connection);
209
210 dbus_message_unref (message);
211 dbus_error_free (&error);
212
213 return reply;
214}
215
216static DBusMessage *
217screensaver_send_message_void (DBusConnection *connection,
218 const char *name,
219 gboolean expect_reply)
220{
221 DBusMessage *message;
222 DBusMessage *reply;
223 DBusError error;
224
225 g_return_val_if_fail (connection != NULL, NULL)do{ (void)0; }while (0);
226 g_return_val_if_fail (name != NULL, NULL)do{ (void)0; }while (0);
227
228 dbus_error_init (&error);
229
230 message = dbus_message_new_method_call (GS_SERVICE"org.mate.ScreenSaver", GS_PATH"/org/mate/ScreenSaver", GS_INTERFACE"org.mate.ScreenSaver", name);
231 if (message == NULL((void*)0))
232 {
233 g_warning ("Couldn't allocate the dbus message");
234 return NULL((void*)0);
235 }
236
237 if (! expect_reply)
238 {
239 if (!dbus_connection_send (connection, message, NULL((void*)0)))
240 g_warning ("could not send message");
241 reply = NULL((void*)0);
242 }
243 else
244 {
245 reply = dbus_connection_send_with_reply_and_block (connection,
246 message,
247 -1, &error);
248 if (dbus_error_is_set (&error))
249 {
250 g_warning ("%s raised:\n %s\n\n", error.name, error.message);
251 reply = NULL((void*)0);
252 }
253 }
254 dbus_connection_flush (connection);
255
256 dbus_message_unref (message);
257 dbus_error_free (&error);
258
259 return reply;
260}
261
262static char **
263get_string_from_iter (DBusMessageIter *iter,
264 int *num_elements)
265{
266 int count;
267 char **buffer;
268
269 if (num_elements
13.1
'num_elements' is not equal to NULL
!= NULL((void*)0))
14
Taking true branch
270 {
271 *num_elements = 0;
272 }
273
274 count = 0;
275 buffer = (char **)malloc (sizeof (char *) * 8);
15
Memory is allocated
276
277 if (buffer == NULL((void*)0))
16
Assuming 'buffer' is not equal to NULL
17
Taking false branch
278 {
279 goto oom;
280 }
281
282 buffer[0] = NULL((void*)0);
283 while (dbus_message_iter_get_arg_type (iter) == DBUS_TYPE_STRING((int) 's'))
18
Assuming the condition is false
19
Loop condition is false. Execution continues on line 310
284 {
285 const char *value;
286 char *str;
287
288 if ((count % 8) == 0 && count != 0)
289 {
290 buffer = realloc (buffer, sizeof (char *) * (count + 8));
291 if (buffer == NULL((void*)0))
292 {
293 goto oom;
294 }
295 }
296
297 dbus_message_iter_get_basic (iter, &value);
298 str = strdup (value);
299 if (str == NULL((void*)0))
300 {
301 goto oom;
302 }
303
304 buffer[count] = str;
305
306 dbus_message_iter_next (iter);
307 count++;
308 }
309
310 if ((count % 8) == 0)
20
Taking true branch
311 {
312 buffer = realloc (buffer, sizeof (char *) * (count + 1));
21
Attempt to reallocate memory
313 if (buffer == NULL((void*)0))
22
Assuming 'buffer' is equal to NULL
23
Reallocation failed
24
Taking true branch
314 {
315 goto oom;
25
Control jumps to line 327
316 }
317 }
318
319 buffer[count] = NULL((void*)0);
320 if (num_elements != NULL((void*)0))
321 {
322 *num_elements = count;
323 }
324 return buffer;
325
326oom:
327 g_debug ("%s %d : error allocating memory\n", __FILE__"mate-screensaver-command.c", __LINE__327);
26
Potential leak of memory pointed to by 'buffer'
328 return NULL((void*)0);
329
330}
331
332static gboolean
333do_command (gpointer data)
334{
335 DBusConnection *connection = data;
336 DBusMessage *reply;
337
338 if (do_quit)
1
Assuming 'do_quit' is 0
2
Taking false branch
339 {
340 reply = screensaver_send_message_void (connection, "Quit", FALSE(0));
341 goto done;
342 }
343
344 if (do_query)
3
Assuming 'do_query' is not equal to 0
4
Taking true branch
345 {
346 DBusMessageIter iter;
347 DBusMessageIter array;
348 dbus_bool_t v;
349
350 reply = screensaver_send_message_void (connection, "GetActive", TRUE(!(0)));
351 if (! reply)
5
Assuming 'reply' is non-null
6
Taking false branch
352 {
353 g_message ("Did not receive a reply from the screensaver.");
354 goto done;
355 }
356
357 dbus_message_iter_init (reply, &iter);
358 dbus_message_iter_get_basic (&iter, &v);
359 g_print (_("The screensaver is %s\n")gettext ("The screensaver is %s\n"), v ? _("active")gettext ("active") : _("inactive")gettext ("inactive"));
7
Assuming 'v' is 0
8
'?' condition is false
360
361 dbus_message_unref (reply);
362
363 reply = screensaver_send_message_void (connection, "GetInhibitors", TRUE(!(0)));
364 if (! reply)
9
Assuming 'reply' is non-null
10
Taking false branch
365 {
366 g_message ("Did not receive a reply from screensaver.");
367 goto done;
368 }
369
370 dbus_message_iter_init (reply, &iter);
371 dbus_message_iter_recurse (&iter, &array);
372
373 if (dbus_message_iter_get_arg_type (&array) == DBUS_TYPE_INVALID((int) '\0'))
11
Assuming the condition is false
12
Taking false branch
374 {
375 g_print (_("The screensaver is not inhibited\n")gettext ("The screensaver is not inhibited\n"));
376 }
377 else
378 {
379 char **inhibitors;
380 int i;
381 int num;
382
383 g_print (_("The screensaver is being inhibited by:\n")gettext ("The screensaver is being inhibited by:\n"));
384 inhibitors = get_string_from_iter (&array, &num);
13
Calling 'get_string_from_iter'
385 for (i = 0; i < num; i++)
386 {
387 g_print ("\t%s\n", inhibitors[i]);
388 }
389 g_strfreev (inhibitors);
390 }
391
392 dbus_message_unref (reply);
393 }
394
395 if (do_time)
396 {
397 DBusMessageIter iter;
398 dbus_bool_t v;
399 dbus_int32_t t;
400
401 reply = screensaver_send_message_void (connection, "GetActive", TRUE(!(0)));
402 if (! reply)
403 {
404 g_message ("Did not receive a reply from the screensaver.");
405 goto done;
406 }
407
408 dbus_message_iter_init (reply, &iter);
409 dbus_message_iter_get_basic (&iter, &v);
410 dbus_message_unref (reply);
411
412 if (v)
413 {
414
415 reply = screensaver_send_message_void (connection, "GetActiveTime", TRUE(!(0)));
416 dbus_message_iter_init (reply, &iter);
417 dbus_message_iter_get_basic (&iter, &t);
418 g_print (_("The screensaver has been active for %d seconds.\n")gettext ("The screensaver has been active for %d seconds.\n"), t);
419
420 dbus_message_unref (reply);
421 }
422 else
423 {
424 g_print (_("The screensaver is not currently active.\n")gettext ("The screensaver is not currently active.\n"));
425 }
426 }
427
428 if (do_lock)
429 {
430 reply = screensaver_send_message_void (connection, "Lock", FALSE(0));
431 }
432
433 if (do_unlock)
434 {
435 reply = screensaver_send_message_void (connection, "Unlock", FALSE(0));
436 }
437
438 if (do_cycle)
439 {
440 reply = screensaver_send_message_void (connection, "Cycle", FALSE(0));
441 }
442
443 if (do_poke)
444 {
445 reply = screensaver_send_message_void (connection, "SimulateUserActivity", FALSE(0));
446 }
447
448 if (do_activate)
449 {
450 reply = screensaver_send_message_bool (connection, "SetActive", TRUE(!(0)));
451 if (! reply)
452 {
453 g_message ("Did not receive a reply from the screensaver.");
454 goto done;
455 }
456 dbus_message_unref (reply);
457 }
458
459 if (do_deactivate)
460 {
461 reply = screensaver_send_message_bool (connection, "SetActive", FALSE(0));
462 if (! reply)
463 {
464 g_message ("Did not receive a reply from the screensaver.");
465 goto done;
466 }
467 dbus_message_unref (reply);
468 }
469
470 if (do_inhibit)
471 {
472 reply = screensaver_send_message_inhibit (connection,
473 inhibit_application ? inhibit_application : "Unknown",
474 inhibit_reason ? inhibit_reason : "Unknown");
475 if (! reply)
476 {
477 g_message ("Did not receive a reply from the screensaver.");
478 goto done;
479 }
480 dbus_message_unref (reply);
481
482 return FALSE(0);
483 }
484
485done:
486 g_main_loop_quit (loop);
487
488 return FALSE(0);
489}
490
491int
492main (int argc,
493 char **argv)
494{
495 DBusConnection *connection;
496 DBusError dbus_error;
497 GOptionContext *context;
498 gboolean retval;
499 GError *error = NULL((void*)0);
500
501#ifdef ENABLE_NLS1
502 bindtextdomain (GETTEXT_PACKAGE"mate-screensaver", MATELOCALEDIR"/usr/local/share/locale");
503# ifdef HAVE_BIND_TEXTDOMAIN_CODESET
504 bind_textdomain_codeset (GETTEXT_PACKAGE"mate-screensaver", "UTF-8");
505# endif
506 textdomain (GETTEXT_PACKAGE"mate-screensaver");
507#endif
508
509 g_set_prgname (argv[0]);
510
511 if (setlocale (LC_ALL6, "") == NULL((void*)0))
512 g_warning ("Locale not understood by C library, internationalization will not work\n");
513
514 context = g_option_context_new (NULL((void*)0));
515 g_option_context_add_main_entries (context, entries, NULL((void*)0));
516 retval = g_option_context_parse (context, &argc, &argv, &error);
517
518 g_option_context_free (context);
519
520 if (! retval)
521 {
522 g_warning ("%s", error->message);
523 g_error_free (error);
524 exit (1);
525 }
526
527 if (do_version)
528 {
529 g_print ("%s %s\n", argv [0], VERSION"1.27.0");
530 exit (1);
531 }
532
533 dbus_error_init (&dbus_error);
534 connection = dbus_bus_get (DBUS_BUS_SESSION, &dbus_error);
535 if (! connection)
536 {
537 g_message ("Failed to connect to the D-BUS daemon: %s", dbus_error.message);
538 dbus_error_free (&dbus_error);
539 exit (1);
540 }
541
542 dbus_connection_setup_with_g_main (connection, NULL((void*)0));
543
544 if (! screensaver_is_running (connection))
545 {
546 g_message ("Screensaver is not running!");
547 exit (1);
548 }
549
550 g_idle_add (do_command, connection);
551
552 loop = g_main_loop_new (NULL((void*)0), FALSE(0));
553 g_main_loop_run (loop);
554
555 return 0;
556}
diff --git a/2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-bdd56f.html b/2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-bdd56f.html new file mode 100644 index 0000000..3ca31fe --- /dev/null +++ b/2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-bdd56f.html @@ -0,0 +1,848 @@ + + + +xdg-user-dir-lookup.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:avers/xdg-user-dir-lookup.c
Warning:line 61, column 3
Call to function 'strcat' is insecure as it does not provide bounding of the memory buffer. Replace unbounded copy functions with analogous functions that support length arguments such as 'strlcat'. CWE-119
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name xdg-user-dir-lookup.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/savers -resource-dir /usr/lib64/clang/14.0.5 -D HAVE_CONFIG_H -I . -I .. -I . -I . -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -D LIBEXECDIR="/usr/local/libexec" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -internal-isystem /usr/lib64/clang/14.0.5/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/12/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdebug-compilation-dir=/rootdir/savers -ferror-limit 19 -fgnuc-version=4.2.1 -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2022-11-11-203102-6531-1 -x c xdg-user-dir-lookup.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/*
2 This file is not licenced under the GPL like the rest of the code.
3 Its is under the MIT license, to encourage reuse by cut-and-paste.
4
5 Copyright (c) 2007 Red Hat, inc
6 Copyright (C) 2012-2021 MATE Developers
7
8 Permission is hereby granted, free of charge, to any person
9 obtaining a copy of this software and associated documentation files
10 (the "Software"), to deal in the Software without restriction,
11 including without limitation the rights to use, copy, modify, merge,
12 publish, distribute, sublicense, and/or sell copies of the Software,
13 and to permit persons to whom the Software is furnished to do so,
14 subject to the following conditions:
15
16 The above copyright notice and this permission notice shall be
17 included in all copies or substantial portions of the Software.
18
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
23 BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
24 ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
25 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26 SOFTWARE.
27*/
28
29#include <stdio.h>
30#include <stdlib.h>
31#include <string.h>
32
33#include "xdg-user-dir-lookup.h"
34
35char *
36xdg_user_dir_lookup (const char *type)
37{
38 FILE *file;
39 char *home_dir, *config_home, *config_file;
40 char buffer[512];
41 char *user_dir;
42 char *p, *d;
43 int relative;
44
45 home_dir = getenv ("HOME");
46
47 if (home_dir == NULL((void*)0))
48 return strdup ("/tmp");
49
50 config_home = getenv ("XDG_CONFIG_HOME");
51 if (config_home == NULL((void*)0) || config_home[0] == 0)
52 {
53 config_file = malloc (strlen (home_dir) + strlen ("/.config/user-dirs.dirs") + 1);
54 strcpy (config_file, home_dir);
55 strcat (config_file, "/.config/user-dirs.dirs");
56 }
57 else
58 {
59 config_file = malloc (strlen (config_home) + strlen ("/user-dirs.dirs") + 1);
60 strcpy (config_file, config_home);
61 strcat (config_file, "/user-dirs.dirs");
Call to function 'strcat' is insecure as it does not provide bounding of the memory buffer. Replace unbounded copy functions with analogous functions that support length arguments such as 'strlcat'. CWE-119
62 }
63
64 file = fopen (config_file, "r");
65 free (config_file);
66 if (file == NULL((void*)0))
67 goto error;
68
69 user_dir = NULL((void*)0);
70 while (fgets (buffer, sizeof (buffer), file))
71 {
72 /* Remove newline at end */
73 size_t len = strlen (buffer);
74 if (len != 0 && buffer[len-1] == '\n')
75 buffer[len-1] = 0;
76
77 p = buffer;
78 while (*p == ' ' || *p == '\t')
79 p++;
80
81 if (strncmp (p, "XDG_", 4) != 0)
82 continue;
83 p += 4;
84 if (strncmp (p, type, strlen (type)) != 0)
85 continue;
86 p += strlen (type);
87 if (strncmp (p, "_DIR", 4) != 0)
88 continue;
89 p += 4;
90
91 while (*p == ' ' || *p == '\t')
92 p++;
93
94 if (*p != '=')
95 continue;
96 p++;
97
98 while (*p == ' ' || *p == '\t')
99 p++;
100
101 if (*p != '"')
102 continue;
103 p++;
104
105 relative = 0;
106 if (strncmp (p, "$HOME/", 6) == 0)
107 {
108 p += 6;
109 relative = 1;
110 }
111 else if (*p != '/')
112 continue;
113
114 if (relative)
115 {
116 user_dir = malloc (strlen (home_dir) + 1 + strlen (p) + 1);
117 strcpy (user_dir, home_dir);
118 strcat (user_dir, "/");
119 }
120 else
121 {
122 user_dir = malloc (strlen (p) + 1);
123 *user_dir = 0;
124 }
125
126 d = user_dir + strlen (user_dir);
127 while (*p && *p != '"')
128 {
129 if ((*p == '\\') && (*(p+1) != 0))
130 p++;
131 *d++ = *p++;
132 }
133 *d = 0;
134 }
135 fclose (file);
136
137 if (user_dir)
138 return user_dir;
139
140error:
141 /* Special case desktop for historical compatibility */
142 if (strcmp (type, "DESKTOP") == 0)
143 {
144 user_dir = malloc (strlen (home_dir) + strlen ("/Desktop") + 1);
145 strcpy (user_dir, home_dir);
146 strcat (user_dir, "/Desktop");
147 return user_dir;
148 }
149 else
150 return strdup (home_dir);
151}
152
153#ifdef STANDALONE
154
155int
156main (int argc, char *argv[])
157{
158 if (argc != 2)
159 {
160 fprintf (stderrstderr, "Usage %s <dir-type>\n", argv[0]);
161 exit (1);
162 }
163
164 printf ("%s\n", xdg_user_dir_lookup (argv[1]));
165 return 0;
166}
167
168#endif
diff --git a/2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-be2741.html b/2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-be2741.html new file mode 100644 index 0000000..55421c5 --- /dev/null +++ b/2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-be2741.html @@ -0,0 +1,1355 @@ + + + +gs-watcher-x11.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rc/gs-watcher-x11.c
Warning:line 597, column 2
Value stored to 'desired_server_interval' is never read
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name gs-watcher-x11.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/14.0.5 -D HAVE_CONFIG_H -I . -I .. -I . -I . -D MATEMENU_I_KNOW_THIS_IS_UNSTABLE -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/dconf -I /usr/include/mate-menus -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/dconf -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/dconf -I /usr/include/mate-menus -D PREFIX="/usr/local" -D BINDIR="/usr/local/bin" -D LIBDIR="/usr/local/lib" -D LIBEXECDIR="/usr/local/libexec" -D DATADIR="/usr/local/share" -D SYSCONFDIR="/usr/local/etc" -D MATELOCALEDIR="/usr/local/share/locale" -D PKGLIBEXECDIR="/usr/local/libexec/mate-screensaver" -D SAVERDIR="/usr/local/libexec/mate-screensaver" -D THEMESDIR="/usr/local/share/mate-screensaver/themes" -D GTKBUILDERDIR="/usr/local/share/mate-screensaver" -D MATE_SCREENSAVER_GL_HELPER_PATH="/usr/local/libexec/mate-screensaver-gl-helper" -D PAM_SERVICE_NAME="mate-screensaver" -D G_DISABLE_ASSERT -D G_DISABLE_CHECKS -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -internal-isystem /usr/lib64/clang/14.0.5/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/12/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2022-11-11-203102-6531-1 -x c gs-watcher-x11.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
2 *
3 * Copyright (C) 2004-2006 William Jon McCann <mccann@jhu.edu>
4 * Copyright (C) 2008 Red Hat, Inc.
5 * Copyright (C) 2012-2021 MATE Developers
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
20 *
21 * Authors: William Jon McCann <mccann@jhu.edu>
22 *
23 */
24
25#include "config.h"
26#include <stdlib.h>
27#include <stdio.h>
28#include <time.h>
29#include <errno(*__errno_location ()).h>
30
31#include <string.h>
32#include <gdk/gdkx.h>
33
34#include <dbus/dbus.h>
35#include <dbus/dbus-glib.h>
36
37#include "gs-watcher.h"
38#include "gs-marshal.h"
39#include "gs-debug.h"
40
41static void gs_watcher_finalize (GObject *object);
42
43static gboolean watchdog_timer (GSWatcher *watcher);
44
45struct GSWatcherPrivate
46{
47 /* settings */
48 guint enabled : 1;
49 guint delta_notice_timeout;
50
51 /* state */
52 guint active : 1;
53 guint idle : 1;
54 guint idle_notice : 1;
55
56 guint idle_id;
57 char *status_message;
58
59 DBusGProxy *presence_proxy;
60 guint watchdog_timer_id;
61};
62
63enum
64{
65 PROP_0,
66 PROP_STATUS_MESSAGE
67};
68
69enum
70{
71 IDLE_CHANGED,
72 IDLE_NOTICE_CHANGED,
73 LAST_SIGNAL
74};
75
76static guint signals [LAST_SIGNAL] = { 0, };
77
78G_DEFINE_TYPE_WITH_PRIVATE (GSWatcher, gs_watcher, G_TYPE_OBJECT)static void gs_watcher_init (GSWatcher *self); static void gs_watcher_class_init
(GSWatcherClass *klass); static GType gs_watcher_get_type_once
(void); static gpointer gs_watcher_parent_class = ((void*)0)
; static gint GSWatcher_private_offset; static void gs_watcher_class_intern_init
(gpointer klass) { gs_watcher_parent_class = g_type_class_peek_parent
(klass); if (GSWatcher_private_offset != 0) g_type_class_adjust_private_offset
(klass, &GSWatcher_private_offset); gs_watcher_class_init
((GSWatcherClass*) klass); } __attribute__ ((__unused__)) static
inline gpointer gs_watcher_get_instance_private (GSWatcher *
self) { return (((gpointer) ((guint8*) (self) + (glong) (GSWatcher_private_offset
)))); } GType gs_watcher_get_type (void) { static gsize static_g_define_type_id
= 0; if ((__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); (void
) (0 ? (gpointer) *(&static_g_define_type_id) : ((void*)0
)); (!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
(*(&static_g_define_type_id)) gapg_temp_newval; __typeof__
((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id
); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5)
; gapg_temp_newval; })) && g_once_init_enter (&static_g_define_type_id
)); }))) { GType g_define_type_id = gs_watcher_get_type_once (
); (__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); 0 ?
(void) (*(&static_g_define_type_id) = (g_define_type_id)
) : (void) 0; g_once_init_leave ((&static_g_define_type_id
), (gsize) (g_define_type_id)); })); } return static_g_define_type_id
; } __attribute__ ((__noinline__)) static GType gs_watcher_get_type_once
(void) { GType g_define_type_id = g_type_register_static_simple
(((GType) ((20) << (2))), g_intern_static_string ("GSWatcher"
), sizeof (GSWatcherClass), (GClassInitFunc)(void (*)(void)) gs_watcher_class_intern_init
, sizeof (GSWatcher), (GInstanceInitFunc)(void (*)(void)) gs_watcher_init
, (GTypeFlags) 0); { {{ GSWatcher_private_offset = g_type_add_instance_private
(g_define_type_id, sizeof (GSWatcherPrivate)); };} } return g_define_type_id
; }
79
80static void
81remove_watchdog_timer (GSWatcher *watcher)
82{
83 if (watcher->priv->watchdog_timer_id != 0)
84 {
85 g_source_remove (watcher->priv->watchdog_timer_id);
86 watcher->priv->watchdog_timer_id = 0;
87 }
88}
89
90static void
91add_watchdog_timer (GSWatcher *watcher,
92 guint timeout)
93{
94 watcher->priv->watchdog_timer_id = g_timeout_add (timeout,
95 (GSourceFunc)watchdog_timer,
96 watcher);
97}
98
99static void
100gs_watcher_get_property (GObject *object,
101 guint prop_id,
102 GValue *value,
103 GParamSpec *pspec)
104{
105 GSWatcher *self;
106
107 self = GS_WATCHER (object)((((GSWatcher*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((gs_watcher_get_type ()))))))
;
108
109 switch (prop_id)
110 {
111 case PROP_STATUS_MESSAGE:
112 g_value_set_string (value, self->priv->status_message);
113 break;
114 default:
115 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec)do { GObject *_glib__object = (GObject*) ((object)); GParamSpec
*_glib__pspec = (GParamSpec*) ((pspec)); guint _glib__property_id
= ((prop_id)); g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'"
, "gs-watcher-x11.c", 115, ("property"), _glib__property_id, _glib__pspec
->name, g_type_name ((((((GTypeClass*) (((GTypeInstance*) (
_glib__pspec))->g_class))->g_type)))), (g_type_name (((
(((GTypeClass*) (((GTypeInstance*) (_glib__object))->g_class
))->g_type)))))); } while (0)
;
116 break;
117 }
118}
119
120static void
121set_status_text (GSWatcher *watcher,
122 const char *text)
123{
124 g_free (watcher->priv->status_message);
125
126 watcher->priv->status_message = g_strdup (text);
127 g_object_notify (G_OBJECT (watcher)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((watcher)), (((GType) ((20) << (2))))))))
, "status-message");
128}
129
130static void
131gs_watcher_set_property (GObject *object,
132 guint prop_id,
133 const GValue *value,
134 GParamSpec *pspec)
135{
136 GSWatcher *self;
137
138 self = GS_WATCHER (object)((((GSWatcher*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((gs_watcher_get_type ()))))))
;
139
140 switch (prop_id)
141 {
142 case PROP_STATUS_MESSAGE:
143 set_status_text (self, g_value_get_string (value));
144 break;
145 default:
146 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec)do { GObject *_glib__object = (GObject*) ((object)); GParamSpec
*_glib__pspec = (GParamSpec*) ((pspec)); guint _glib__property_id
= ((prop_id)); g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'"
, "gs-watcher-x11.c", 146, ("property"), _glib__property_id, _glib__pspec
->name, g_type_name ((((((GTypeClass*) (((GTypeInstance*) (
_glib__pspec))->g_class))->g_type)))), (g_type_name (((
(((GTypeClass*) (((GTypeInstance*) (_glib__object))->g_class
))->g_type)))))); } while (0)
;
147 break;
148 }
149}
150
151static void
152gs_watcher_class_init (GSWatcherClass *klass)
153{
154 GObjectClass *object_class = G_OBJECT_CLASS (klass)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((klass)), (((GType) ((20) << (2))))))))
;
155
156 object_class->finalize = gs_watcher_finalize;
157 object_class->get_property = gs_watcher_get_property;
158 object_class->set_property = gs_watcher_set_property;
159
160 g_object_class_install_property (object_class,
161 PROP_STATUS_MESSAGE,
162 g_param_spec_string ("status-message",
163 NULL((void*)0),
164 NULL((void*)0),
165 NULL((void*)0),
166 G_PARAM_READWRITE));
167
168 signals [IDLE_CHANGED] =
169 g_signal_new ("idle-changed",
170 G_TYPE_FROM_CLASS (object_class)(((GTypeClass*) (object_class))->g_type),
171 G_SIGNAL_RUN_LAST,
172 G_STRUCT_OFFSET (GSWatcherClass, idle_changed)((glong) __builtin_offsetof(GSWatcherClass, idle_changed)),
173 NULL((void*)0),
174 NULL((void*)0),
175 gs_marshal_BOOLEAN__BOOLEAN,
176 G_TYPE_BOOLEAN((GType) ((5) << (2))),
177 1, G_TYPE_BOOLEAN((GType) ((5) << (2))));
178 signals [IDLE_NOTICE_CHANGED] =
179 g_signal_new ("idle-notice-changed",
180 G_TYPE_FROM_CLASS (object_class)(((GTypeClass*) (object_class))->g_type),
181 G_SIGNAL_RUN_LAST,
182 G_STRUCT_OFFSET (GSWatcherClass, idle_notice_changed)((glong) __builtin_offsetof(GSWatcherClass, idle_notice_changed
))
,
183 NULL((void*)0),
184 NULL((void*)0),
185 gs_marshal_BOOLEAN__BOOLEAN,
186 G_TYPE_BOOLEAN((GType) ((5) << (2))),
187 1, G_TYPE_BOOLEAN((GType) ((5) << (2))));
188}
189
190static gboolean
191_gs_watcher_set_session_idle_notice (GSWatcher *watcher,
192 gboolean in_effect)
193{
194 gboolean res;
195
196 res = FALSE(0);
197
198 if (in_effect != watcher->priv->idle_notice)
199 {
200
201 g_signal_emit (watcher, signals [IDLE_NOTICE_CHANGED], 0, in_effect, &res);
202 if (res)
203 {
204 gs_debug ("Changing idle notice state: %d", in_effect)gs_debug_real (__func__, "gs-watcher-x11.c", 204, "Changing idle notice state: %d"
, in_effect)
;
205
206 watcher->priv->idle_notice = (in_effect != FALSE(0));
207 }
208 else
209 {
210 gs_debug ("Idle notice signal not handled: %d", in_effect)gs_debug_real (__func__, "gs-watcher-x11.c", 210, "Idle notice signal not handled: %d"
, in_effect)
;
211 }
212 }
213
214 return res;
215}
216
217static gboolean
218_gs_watcher_set_session_idle (GSWatcher *watcher,
219 gboolean is_idle)
220{
221 gboolean res;
222
223 res = FALSE(0);
224
225 if (is_idle != watcher->priv->idle)
226 {
227
228 g_signal_emit (watcher, signals [IDLE_CHANGED], 0, is_idle, &res);
229 if (res)
230 {
231 gs_debug ("Changing idle state: %d", is_idle)gs_debug_real (__func__, "gs-watcher-x11.c", 231, "Changing idle state: %d"
, is_idle)
;
232
233 watcher->priv->idle = (is_idle != FALSE(0));
234 }
235 else
236 {
237 gs_debug ("Idle changed signal not handled: %d", is_idle)gs_debug_real (__func__, "gs-watcher-x11.c", 237, "Idle changed signal not handled: %d"
, is_idle)
;
238 }
239 }
240
241 return res;
242}
243
244gboolean
245gs_watcher_get_active (GSWatcher *watcher)
246{
247 gboolean active;
248
249 g_return_val_if_fail (GS_IS_WATCHER (watcher), FALSE)do{ (void)0; }while (0);
250
251 active = watcher->priv->active;
252
253 return active;
254}
255
256static void
257_gs_watcher_reset_state (GSWatcher *watcher)
258{
259 watcher->priv->idle = FALSE(0);
260 watcher->priv->idle_notice = FALSE(0);
261}
262
263static gboolean
264_gs_watcher_set_active_internal (GSWatcher *watcher,
265 gboolean active)
266{
267 if (active != watcher->priv->active)
268 {
269 /* reset state */
270 _gs_watcher_reset_state (watcher);
271
272 watcher->priv->active = (active != FALSE(0));
273 }
274
275 return TRUE(!(0));
276}
277
278gboolean
279gs_watcher_set_active (GSWatcher *watcher,
280 gboolean active)
281{
282 g_return_val_if_fail (GS_IS_WATCHER (watcher), FALSE)do{ (void)0; }while (0);
283
284 gs_debug ("turning watcher: %s", active ? "ON" : "OFF")gs_debug_real (__func__, "gs-watcher-x11.c", 284, "turning watcher: %s"
, active ? "ON" : "OFF")
;
285
286 if (watcher->priv->active == active)
287 {
288 gs_debug ("Idle detection is already %s",gs_debug_real (__func__, "gs-watcher-x11.c", 289, "Idle detection is already %s"
, active ? "active" : "inactive")
289 active ? "active" : "inactive")gs_debug_real (__func__, "gs-watcher-x11.c", 289, "Idle detection is already %s"
, active ? "active" : "inactive")
;
290 return FALSE(0);
291 }
292
293 if (! watcher->priv->enabled)
294 {
295 gs_debug ("Idle detection is disabled, cannot activate")gs_debug_real (__func__, "gs-watcher-x11.c", 295, "Idle detection is disabled, cannot activate"
)
;
296 return FALSE(0);
297 }
298
299 return _gs_watcher_set_active_internal (watcher, active);
300}
301
302gboolean
303gs_watcher_set_enabled (GSWatcher *watcher,
304 gboolean enabled)
305{
306 g_return_val_if_fail (GS_IS_WATCHER (watcher), FALSE)do{ (void)0; }while (0);
307
308 if (watcher->priv->enabled != enabled)
309 {
310 gboolean is_active = gs_watcher_get_active (watcher);
311
312 watcher->priv->enabled = (enabled != FALSE(0));
313
314 /* if we are disabling the watcher and we are
315 active shut it down */
316 if (! enabled && is_active)
317 {
318 _gs_watcher_set_active_internal (watcher, FALSE(0));
319 }
320 }
321
322 return TRUE(!(0));
323}
324
325gboolean
326gs_watcher_get_enabled (GSWatcher *watcher)
327{
328 gboolean enabled;
329
330 g_return_val_if_fail (GS_IS_WATCHER (watcher), FALSE)do{ (void)0; }while (0);
331
332 enabled = watcher->priv->enabled;
333
334 return enabled;
335}
336
337static gboolean
338on_idle_timeout (GSWatcher *watcher)
339{
340 gboolean res;
341
342 res = _gs_watcher_set_session_idle (watcher, TRUE(!(0)));
343
344 _gs_watcher_set_session_idle_notice (watcher, FALSE(0));
345
346 /* try again if we failed i guess */
347 return !res;
348}
349
350static void
351set_status (GSWatcher *watcher,
352 guint status)
353{
354 gboolean is_idle;
355
356 if (! watcher->priv->active)
357 {
358 gs_debug ("GSWatcher: not active, ignoring status changes")gs_debug_real (__func__, "gs-watcher-x11.c", 358, "GSWatcher: not active, ignoring status changes"
)
;
359 return;
360 }
361
362 is_idle = (status == 3);
363
364 if (!is_idle && !watcher->priv->idle_notice)
365 {
366 /* no change in idleness */
367 return;
368 }
369
370 if (is_idle)
371 {
372 _gs_watcher_set_session_idle_notice (watcher, is_idle);
373 /* queue an activation */
374 if (watcher->priv->idle_id > 0)
375 {
376 g_source_remove (watcher->priv->idle_id);
377 }
378 watcher->priv->idle_id = g_timeout_add (watcher->priv->delta_notice_timeout,
379 (GSourceFunc)on_idle_timeout,
380 watcher);
381 }
382 else
383 {
384 /* cancel notice too */
385 if (watcher->priv->idle_id > 0)
386 {
387 g_source_remove (watcher->priv->idle_id);
388 watcher->priv->idle_id = 0;
389 }
390 _gs_watcher_set_session_idle (watcher, FALSE(0));
391 _gs_watcher_set_session_idle_notice (watcher, FALSE(0));
392 }
393}
394
395static void
396on_presence_status_changed (DBusGProxy *presence_proxy,
397 guint status,
398 GSWatcher *watcher)
399{
400 set_status (watcher, status);
401}
402
403static void
404on_presence_status_text_changed (DBusGProxy *presence_proxy,
405 const char *status_text,
406 GSWatcher *watcher)
407{
408 set_status_text (watcher, status_text);
409}
410
411static gboolean
412connect_presence_watcher (GSWatcher *watcher)
413{
414 DBusGConnection *bus;
415 GError *error;
416 gboolean ret;
417
418 ret = FALSE(0);
419
420 error = NULL((void*)0);
421 bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
422 if (bus == NULL((void*)0))
423 {
424 g_warning ("Unable to get session bus: %s", error->message);
425 g_error_free (error);
426 goto done;
427 }
428
429 error = NULL((void*)0);
430 watcher->priv->presence_proxy = dbus_g_proxy_new_for_name_owner (bus,
431 "org.gnome.SessionManager",
432 "/org/gnome/SessionManager/Presence",
433 "org.gnome.SessionManager.Presence",
434 &error);
435 if (watcher->priv->presence_proxy != NULL((void*)0))
436 {
437 DBusGProxy *proxy;
438
439 dbus_g_proxy_add_signal (watcher->priv->presence_proxy,
440 "StatusChanged",
441 G_TYPE_UINT((GType) ((7) << (2))),
442 G_TYPE_INVALID((GType) ((0) << (2))));
443 dbus_g_proxy_connect_signal (watcher->priv->presence_proxy,
444 "StatusChanged",
445 G_CALLBACK (on_presence_status_changed)((GCallback) (on_presence_status_changed)),
446 watcher,
447 NULL((void*)0));
448 dbus_g_proxy_add_signal (watcher->priv->presence_proxy,
449 "StatusTextChanged",
450 G_TYPE_STRING((GType) ((16) << (2))),
451 G_TYPE_INVALID((GType) ((0) << (2))));
452 dbus_g_proxy_connect_signal (watcher->priv->presence_proxy,
453 "StatusTextChanged",
454 G_CALLBACK (on_presence_status_text_changed)((GCallback) (on_presence_status_text_changed)),
455 watcher,
456 NULL((void*)0));
457
458 proxy = dbus_g_proxy_new_from_proxy (watcher->priv->presence_proxy,
459 "org.freedesktop.DBus.Properties",
460 "/org/gnome/SessionManager/Presence");
461 if (proxy != NULL((void*)0))
462 {
463 guint status;
464 const char *status_text;
465 GValue value = { 0, };
466
467 status = 0;
468 status_text = NULL((void*)0);
469
470 error = NULL((void*)0);
471 dbus_g_proxy_call (proxy,
472 "Get",
473 &error,
474 G_TYPE_STRING((GType) ((16) << (2))), "org.gnome.SessionManager.Presence",
475 G_TYPE_STRING((GType) ((16) << (2))), "status",
476 G_TYPE_INVALID((GType) ((0) << (2))),
477 G_TYPE_VALUE(g_value_get_type ()), &value,
478 G_TYPE_INVALID((GType) ((0) << (2))));
479
480 if (error != NULL((void*)0))
481 {
482 g_warning ("Couldn't get presence status: %s", error->message);
483 g_error_free (error);
484 goto done;
485 }
486 else
487 {
488 status = g_value_get_uint (&value);
489 }
490
491 g_value_unset (&value);
492
493 error = NULL((void*)0);
494 dbus_g_proxy_call (proxy,
495 "Get",
496 &error,
497 G_TYPE_STRING((GType) ((16) << (2))), "org.gnome.SessionManager.Presence",
498 G_TYPE_STRING((GType) ((16) << (2))), "status-text",
499 G_TYPE_INVALID((GType) ((0) << (2))),
500 G_TYPE_VALUE(g_value_get_type ()), &value,
501 G_TYPE_INVALID((GType) ((0) << (2))));
502
503 if (error != NULL((void*)0))
504 {
505 g_warning ("Couldn't get presence status text: %s", error->message);
506 g_error_free (error);
507 }
508 else
509 {
510 status_text = g_value_get_string (&value);
511 }
512
513 set_status (watcher, status);
514 set_status_text (watcher, status_text);
515 }
516 }
517 else
518 {
519 g_warning ("Failed to get session presence proxy: %s", error->message);
520 g_error_free (error);
521 goto done;
522 }
523
524 ret = TRUE(!(0));
525
526done:
527 return ret;
528}
529
530static void
531gs_watcher_init (GSWatcher *watcher)
532{
533 watcher->priv = gs_watcher_get_instance_private (watcher);
534
535 watcher->priv->enabled = TRUE(!(0));
536 watcher->priv->active = FALSE(0);
537
538 connect_presence_watcher (watcher);
539
540 /* time before idle signal to send notice signal */
541 watcher->priv->delta_notice_timeout = 10000;
542
543 add_watchdog_timer (watcher, 600000);
544}
545
546static void
547gs_watcher_finalize (GObject *object)
548{
549 GSWatcher *watcher;
550
551 g_return_if_fail (object != NULL)do{ (void)0; }while (0);
552 g_return_if_fail (GS_IS_WATCHER (object))do{ (void)0; }while (0);
553
554 watcher = GS_WATCHER (object)((((GSWatcher*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((gs_watcher_get_type ()))))))
;
555
556 g_return_if_fail (watcher->priv != NULL)do{ (void)0; }while (0);
557
558 remove_watchdog_timer (watcher);
559
560 if (watcher->priv->idle_id > 0)
561 {
562 g_source_remove (watcher->priv->idle_id);
563 watcher->priv->idle_id = 0;
564 }
565
566 watcher->priv->active = FALSE(0);
567
568 if (watcher->priv->presence_proxy != NULL((void*)0))
569 {
570 g_object_unref (watcher->priv->presence_proxy);
571 }
572
573 g_free (watcher->priv->status_message);
574
575 G_OBJECT_CLASS (gs_watcher_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((gs_watcher_parent_class)), (((GType) ((20) << (2))
))))))
->finalize (object);
576}
577
578/* Figuring out what the appropriate XSetScreenSaver() parameters are
579 (one wouldn't expect this to be rocket science.)
580*/
581static void
582disable_builtin_screensaver (GSWatcher *watcher,
583 gboolean unblank_screen)
584{
585 int current_server_timeout, current_server_interval;
586 int current_prefer_blank, current_allow_exp;
587 int desired_server_timeout, desired_server_interval;
588 int desired_prefer_blank, desired_allow_exp;
589
590 XGetScreenSaver (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ())(gdk_x11_display_get_xdisplay (gdk_display_get_default ())),
591 &current_server_timeout,
592 &current_server_interval,
593 &current_prefer_blank,
594 &current_allow_exp);
595
596 desired_server_timeout = current_server_timeout;
597 desired_server_interval = current_server_interval;
Value stored to 'desired_server_interval' is never read
598 desired_prefer_blank = current_prefer_blank;
599 desired_allow_exp = current_allow_exp;
600
601 desired_server_interval = 0;
602
603 /* I suspect (but am not sure) that DontAllowExposures might have
604 something to do with powering off the monitor as well, at least
605 on some systems that don't support XDPMS? Who know... */
606 desired_allow_exp = AllowExposures1;
607
608 /* When we're not using an extension, set the server-side timeout to 0,
609 so that the server never gets involved with screen blanking, and we
610 do it all ourselves. (However, when we *are* using an extension,
611 we tell the server when to notify us, and rather than blanking the
612 screen, the server will send us an X event telling us to blank.)
613 */
614 desired_server_timeout = 0;
615
616 if (desired_server_timeout != current_server_timeout
617 || desired_server_interval != current_server_interval
618 || desired_prefer_blank != current_prefer_blank
619 || desired_allow_exp != current_allow_exp)
620 {
621
622 gs_debug ("disabling server builtin screensaver:"gs_debug_real (__func__, "gs-watcher-x11.c", 627, "disabling server builtin screensaver:"
" (xset s %d %d; xset s %s; xset s %s)", desired_server_timeout
, desired_server_interval, (desired_prefer_blank ? "blank" : "noblank"
), (desired_allow_exp ? "expose" : "noexpose"))
623 " (xset s %d %d; xset s %s; xset s %s)",gs_debug_real (__func__, "gs-watcher-x11.c", 627, "disabling server builtin screensaver:"
" (xset s %d %d; xset s %s; xset s %s)", desired_server_timeout
, desired_server_interval, (desired_prefer_blank ? "blank" : "noblank"
), (desired_allow_exp ? "expose" : "noexpose"))
624 desired_server_timeout,gs_debug_real (__func__, "gs-watcher-x11.c", 627, "disabling server builtin screensaver:"
" (xset s %d %d; xset s %s; xset s %s)", desired_server_timeout
, desired_server_interval, (desired_prefer_blank ? "blank" : "noblank"
), (desired_allow_exp ? "expose" : "noexpose"))
625 desired_server_interval,gs_debug_real (__func__, "gs-watcher-x11.c", 627, "disabling server builtin screensaver:"
" (xset s %d %d; xset s %s; xset s %s)", desired_server_timeout
, desired_server_interval, (desired_prefer_blank ? "blank" : "noblank"
), (desired_allow_exp ? "expose" : "noexpose"))
626 (desired_prefer_blank ? "blank" : "noblank"),gs_debug_real (__func__, "gs-watcher-x11.c", 627, "disabling server builtin screensaver:"
" (xset s %d %d; xset s %s; xset s %s)", desired_server_timeout
, desired_server_interval, (desired_prefer_blank ? "blank" : "noblank"
), (desired_allow_exp ? "expose" : "noexpose"))
627 (desired_allow_exp ? "expose" : "noexpose"))gs_debug_real (__func__, "gs-watcher-x11.c", 627, "disabling server builtin screensaver:"
" (xset s %d %d; xset s %s; xset s %s)", desired_server_timeout
, desired_server_interval, (desired_prefer_blank ? "blank" : "noblank"
), (desired_allow_exp ? "expose" : "noexpose"))
;
628
629 XSetScreenSaver (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ())(gdk_x11_display_get_xdisplay (gdk_display_get_default ())),
630 desired_server_timeout,
631 desired_server_interval,
632 desired_prefer_blank,
633 desired_allow_exp);
634
635 XSync (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ())(gdk_x11_display_get_xdisplay (gdk_display_get_default ())), FALSE(0));
636 }
637
638 if (unblank_screen)
639 {
640 /* Turn off the server builtin saver if it is now running. */
641 XForceScreenSaver (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ())(gdk_x11_display_get_xdisplay (gdk_display_get_default ())), ScreenSaverReset0);
642 }
643}
644
645/* This timer goes off every few minutes, whether the user is idle or not,
646 to try and clean up anything that has gone wrong.
647
648 It calls disable_builtin_screensaver() so that if xset has been used,
649 or some other program (like xlock) has messed with the XSetScreenSaver()
650 settings, they will be set back to sensible values (if a server extension
651 is in use, messing with xlock can cause the screensaver to never get a wakeup
652 event, and could cause monitor power-saving to occur, and all manner of
653 heinousness.)
654
655 */
656
657static gboolean
658watchdog_timer (GSWatcher *watcher)
659{
660
661 disable_builtin_screensaver (watcher, FALSE(0));
662
663 return TRUE(!(0));
664}
665
666GSWatcher *
667gs_watcher_new (void)
668{
669 GSWatcher *watcher;
670
671 watcher = g_object_new (GS_TYPE_WATCHER(gs_watcher_get_type ()),
672 NULL((void*)0));
673
674 return GS_WATCHER (watcher)((((GSWatcher*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((watcher)), ((gs_watcher_get_type ()))))))
;
675}
diff --git a/2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-c2b391.html b/2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-c2b391.html new file mode 100644 index 0000000..7268f91 --- /dev/null +++ b/2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-c2b391.html @@ -0,0 +1,3250 @@ + + + +gs-window-x11.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rc/gs-window-x11.c
Warning:line 1362, column 4
Value stored to 'finished' is never read
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name gs-window-x11.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/14.0.5 -D HAVE_CONFIG_H -I . -I .. -I . -I . -D MATEMENU_I_KNOW_THIS_IS_UNSTABLE -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/dconf -I /usr/include/mate-menus -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/dconf -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/dconf -I /usr/include/mate-menus -D PREFIX="/usr/local" -D BINDIR="/usr/local/bin" -D LIBDIR="/usr/local/lib" -D LIBEXECDIR="/usr/local/libexec" -D DATADIR="/usr/local/share" -D SYSCONFDIR="/usr/local/etc" -D MATELOCALEDIR="/usr/local/share/locale" -D PKGLIBEXECDIR="/usr/local/libexec/mate-screensaver" -D SAVERDIR="/usr/local/libexec/mate-screensaver" -D THEMESDIR="/usr/local/share/mate-screensaver/themes" -D GTKBUILDERDIR="/usr/local/share/mate-screensaver" -D MATE_SCREENSAVER_GL_HELPER_PATH="/usr/local/libexec/mate-screensaver-gl-helper" -D PAM_SERVICE_NAME="mate-screensaver" -D G_DISABLE_ASSERT -D G_DISABLE_CHECKS -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -internal-isystem /usr/lib64/clang/14.0.5/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/12/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2022-11-11-203102-6531-1 -x c gs-window-x11.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
2 *
3 * Copyright (C) 2004-2008 William Jon McCann <mccann@jhu.edu>
4 * Copyright (C) 2012-2021 MATE Developers
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
19 *
20 * Authors: William Jon McCann <mccann@jhu.edu>
21 *
22 */
23
24#include "config.h"
25
26#include <sys/types.h>
27#include <errno(*__errno_location ()).h>
28#include <sys/wait.h>
29#include <string.h>
30
31#include <gdk/gdkx.h>
32#include <gdk/gdkkeysyms.h>
33#include <gtk/gtk.h>
34#include <gtk/gtkx.h>
35
36#include "gs-window.h"
37#include "gs-marshal.h"
38#include "subprocs.h"
39#include "gs-debug.h"
40
41#ifdef HAVE_SHAPE_EXT1
42#include <X11/extensions/shape.h>
43#endif
44
45static void gs_window_finalize (GObject *object);
46
47static gboolean popup_dialog_idle (gpointer data);
48static void gs_window_dialog_finish (GSWindow *window);
49static void remove_command_watches (GSWindow *window);
50
51enum
52{
53 DIALOG_RESPONSE_CANCEL,
54 DIALOG_RESPONSE_OK
55};
56
57#define MAX_QUEUED_EVENTS16 16
58#define INFO_BAR_SECONDS30 30
59#define MATE_SCREENSAVER_DIALOG_PATH"/usr/local/libexec" "/mate-screensaver-dialog" LIBEXECDIR"/usr/local/libexec" "/mate-screensaver-dialog"
60
61struct GSWindowPrivate
62{
63 GdkMonitor *monitor;
64
65 GdkRectangle geometry;
66 guint obscured : 1;
67 guint dialog_up : 1;
68
69 guint lock_enabled : 1;
70 guint user_switch_enabled : 1;
71 guint logout_enabled : 1;
72 guint keyboard_enabled : 1;
73
74 guint64 logout_timeout;
75 char *logout_command;
76 char *keyboard_command;
77 char *status_message;
78
79 GtkWidget *vbox;
80 GtkWidget *drawing_area;
81 GtkWidget *lock_box;
82 GtkWidget *lock_socket;
83 GtkWidget *keyboard_socket;
84 GtkWidget *info_bar;
85 GtkWidget *info_content;
86
87 cairo_surface_t *background_surface;
88
89 guint popup_dialog_idle_id;
90
91 guint dialog_map_signal_id;
92 guint dialog_unmap_signal_id;
93 guint dialog_response_signal_id;
94
95 guint watchdog_timer_id;
96 guint info_bar_timer_id;
97
98 gint lock_pid;
99 gint lock_watch_id;
100 gint dialog_response;
101 gboolean dialog_quit_requested;
102 gboolean dialog_shake_in_progress;
103
104 gint keyboard_pid;
105 gint keyboard_watch_id;
106
107 GList *key_events;
108
109 gdouble last_x;
110 gdouble last_y;
111
112 GTimer *timer;
113
114#ifdef HAVE_SHAPE_EXT1
115 int shape_event_base;
116#endif
117};
118
119enum
120{
121 ACTIVITY,
122 DEACTIVATED,
123 LAST_SIGNAL
124};
125
126enum
127{
128 PROP_0,
129 PROP_OBSCURED,
130 PROP_DIALOG_UP,
131 PROP_LOCK_ENABLED,
132 PROP_LOGOUT_ENABLED,
133 PROP_KEYBOARD_ENABLED,
134 PROP_KEYBOARD_COMMAND,
135 PROP_LOGOUT_COMMAND,
136 PROP_LOGOUT_TIMEOUT,
137 PROP_MONITOR,
138 PROP_STATUS_MESSAGE
139};
140
141static guint signals [LAST_SIGNAL] = { 0, };
142
143G_DEFINE_TYPE_WITH_PRIVATE (GSWindow, gs_window, GTK_TYPE_WINDOW)static void gs_window_init (GSWindow *self); static void gs_window_class_init
(GSWindowClass *klass); static GType gs_window_get_type_once
(void); static gpointer gs_window_parent_class = ((void*)0);
static gint GSWindow_private_offset; static void gs_window_class_intern_init
(gpointer klass) { gs_window_parent_class = g_type_class_peek_parent
(klass); if (GSWindow_private_offset != 0) g_type_class_adjust_private_offset
(klass, &GSWindow_private_offset); gs_window_class_init (
(GSWindowClass*) klass); } __attribute__ ((__unused__)) static
inline gpointer gs_window_get_instance_private (GSWindow *self
) { return (((gpointer) ((guint8*) (self) + (glong) (GSWindow_private_offset
)))); } GType gs_window_get_type (void) { static gsize static_g_define_type_id
= 0; if ((__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); (void
) (0 ? (gpointer) *(&static_g_define_type_id) : ((void*)0
)); (!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
(*(&static_g_define_type_id)) gapg_temp_newval; __typeof__
((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id
); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5)
; gapg_temp_newval; })) && g_once_init_enter (&static_g_define_type_id
)); }))) { GType g_define_type_id = gs_window_get_type_once (
); (__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); 0 ?
(void) (*(&static_g_define_type_id) = (g_define_type_id)
) : (void) 0; g_once_init_leave ((&static_g_define_type_id
), (gsize) (g_define_type_id)); })); } return static_g_define_type_id
; } __attribute__ ((__noinline__)) static GType gs_window_get_type_once
(void) { GType g_define_type_id = g_type_register_static_simple
((gtk_window_get_type ()), g_intern_static_string ("GSWindow"
), sizeof (GSWindowClass), (GClassInitFunc)(void (*)(void)) gs_window_class_intern_init
, sizeof (GSWindow), (GInstanceInitFunc)(void (*)(void)) gs_window_init
, (GTypeFlags) 0); { {{ GSWindow_private_offset = g_type_add_instance_private
(g_define_type_id, sizeof (GSWindowPrivate)); };} } return g_define_type_id
; }
144
145static void
146set_invisible_cursor (GdkWindow *window,
147 gboolean invisible)
148{
149 GdkDisplay *display;
150 GdkCursor *cursor = NULL((void*)0);
151
152 if (invisible)
153 {
154 display = gdk_window_get_display (window);
155 cursor = gdk_cursor_new_for_display (display, GDK_BLANK_CURSOR);
156 }
157
158 gdk_window_set_cursor (window, cursor);
159
160 if (cursor)
161 {
162 g_object_unref (cursor);
163 }
164}
165
166/* derived from tomboy */
167static void
168gs_window_override_user_time (GSWindow *window)
169{
170 guint32 ev_time = gtk_get_current_event_time ();
171
172 if (ev_time == 0)
173 {
174 gint ev_mask = gtk_widget_get_events (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
);
175 if (!(ev_mask & GDK_PROPERTY_CHANGE_MASK))
176 {
177 gtk_widget_add_events (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
,
178 GDK_PROPERTY_CHANGE_MASK);
179 }
180
181 /*
182 * NOTE: Last resort for D-BUS or other non-interactive
183 * openings. Causes roundtrip to server. Lame.
184 */
185 ev_time = gdk_x11_get_server_time (gtk_widget_get_window (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
));
186 }
187
188 gdk_x11_window_set_user_time (gtk_widget_get_window (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
), ev_time);
189}
190
191static void
192clear_children (Window window)
193{
194 Window root;
195 Window parent;
196 Window *children;
197 unsigned int n_children;
198 int status;
199
200 children = NULL((void*)0);
201 status = XQueryTree (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ())(gdk_x11_display_get_xdisplay (gdk_display_get_default ())), window, &root, &parent, &children, &n_children);
202
203 if (status == 0)
204 {
205 if (children)
206 {
207 XFree (children);
208 }
209 return;
210 }
211
212 if (children)
213 {
214 while (n_children)
215 {
216 Window child;
217
218 child = children [--n_children];
219
220 XClearWindow (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ())(gdk_x11_display_get_xdisplay (gdk_display_get_default ())), child);
221
222 clear_children (child);
223 }
224
225 XFree (children);
226 }
227}
228
229static void
230widget_clear_all_children (GtkWidget *widget)
231{
232 GdkWindow *w;
233 GdkDisplay *display;
234
235 gs_debug ("Clearing all child windows")gs_debug_real (__func__, "gs-window-x11.c", 235, "Clearing all child windows"
)
;
236 display = gtk_widget_get_display (widget);
237
238 gdk_x11_display_error_trap_push (display);
239
240 w = gtk_widget_get_window (widget);
241
242 clear_children (GDK_WINDOW_XID (w)(gdk_x11_window_get_xid (w)));
243
244 gdk_x11_display_error_trap_pop_ignored (display);
245
246}
247
248void
249gs_window_set_background_surface (GSWindow *window,
250 cairo_surface_t *surface)
251{
252 g_return_if_fail (GS_IS_WINDOW (window))do{ (void)0; }while (0);
253
254 if (window->priv->background_surface != NULL((void*)0))
255 {
256 cairo_surface_destroy (window->priv->background_surface);
257 }
258 window->priv->background_surface = NULL((void*)0);
259
260 if (surface != NULL((void*)0))
261 {
262 window->priv->background_surface = cairo_surface_reference (surface);
263 }
264
265 gtk_widget_queue_draw (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
);
266}
267
268void
269gs_window_clear (GSWindow *window)
270{
271 GdkDisplay *display;
272 g_return_if_fail (GS_IS_WINDOW (window))do{ (void)0; }while (0);
273
274 gs_debug ("Clearing widgets")gs_debug_real (__func__, "gs-window-x11.c", 274, "Clearing widgets"
)
;
275
276 if (gtk_widget_get_realized (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
))
277 {
278 gtk_widget_queue_draw (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
);
279 /* If a screensaver theme adds child windows
280 we need to clear them too */
281 widget_clear_all_children (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
);
282 }
283
284 if (gtk_widget_get_realized (window->priv->drawing_area))
285 {
286 gtk_widget_queue_draw (window->priv->drawing_area);
287 widget_clear_all_children (window->priv->drawing_area);
288 }
289
290 display = gtk_widget_get_display (GTK_WIDGET(window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
);
291 gdk_display_flush (display);
292}
293
294static cairo_region_t *
295get_outside_region (GSWindow *window)
296{
297 GdkDisplay *display;
298 int i;
299 int num_monitors;
300 cairo_region_t *region;
301
302 display = gtk_widget_get_display (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
);
303
304 region = cairo_region_create ();
305
306 num_monitors = gdk_display_get_n_monitors (display);
307 for (i = 0; i < num_monitors; i++)
308 {
309 GdkMonitor *mon = gdk_display_get_monitor (display, i);
310
311 if (mon != window->priv->monitor)
312 {
313 GdkRectangle geometry;
314 cairo_rectangle_int_t rectangle;
315
316 gdk_monitor_get_geometry (mon, &geometry);
317 rectangle.x = geometry.x;
318 rectangle.y = geometry.y;
319 rectangle.width = geometry.width;
320 rectangle.height = geometry.height;
321 cairo_region_union_rectangle (region, &rectangle);
322 }
323 else
324 {
325 break;
326 }
327 }
328
329 return region;
330}
331
332static void
333update_geometry (GSWindow *window)
334{
335 GdkRectangle geometry;
336 cairo_region_t *outside_region;
337 cairo_region_t *monitor_region;
338
339 outside_region = get_outside_region (window);
340
341 gdk_monitor_get_geometry (window->priv->monitor, &geometry);
342 gs_debug ("got geometry for monitor: x=%d y=%d w=%d h=%d",gs_debug_real (__func__, "gs-window-x11.c", 346, "got geometry for monitor: x=%d y=%d w=%d h=%d"
, geometry.x, geometry.y, geometry.width, geometry.height)
343 geometry.x,gs_debug_real (__func__, "gs-window-x11.c", 346, "got geometry for monitor: x=%d y=%d w=%d h=%d"
, geometry.x, geometry.y, geometry.width, geometry.height)
344 geometry.y,gs_debug_real (__func__, "gs-window-x11.c", 346, "got geometry for monitor: x=%d y=%d w=%d h=%d"
, geometry.x, geometry.y, geometry.width, geometry.height)
345 geometry.width,gs_debug_real (__func__, "gs-window-x11.c", 346, "got geometry for monitor: x=%d y=%d w=%d h=%d"
, geometry.x, geometry.y, geometry.width, geometry.height)
346 geometry.height)gs_debug_real (__func__, "gs-window-x11.c", 346, "got geometry for monitor: x=%d y=%d w=%d h=%d"
, geometry.x, geometry.y, geometry.width, geometry.height)
;
347 monitor_region = cairo_region_create_rectangle ((const cairo_rectangle_int_t *)&geometry);
348 cairo_region_subtract (monitor_region, outside_region);
349 cairo_region_destroy (outside_region);
350
351 cairo_region_get_extents (monitor_region, (cairo_rectangle_int_t *)&geometry);
352 cairo_region_destroy (monitor_region);
353
354 gs_debug ("using geometry for monitor: x=%d y=%d w=%d h=%d",gs_debug_real (__func__, "gs-window-x11.c", 358, "using geometry for monitor: x=%d y=%d w=%d h=%d"
, geometry.x, geometry.y, geometry.width, geometry.height)
355 geometry.x,gs_debug_real (__func__, "gs-window-x11.c", 358, "using geometry for monitor: x=%d y=%d w=%d h=%d"
, geometry.x, geometry.y, geometry.width, geometry.height)
356 geometry.y,gs_debug_real (__func__, "gs-window-x11.c", 358, "using geometry for monitor: x=%d y=%d w=%d h=%d"
, geometry.x, geometry.y, geometry.width, geometry.height)
357 geometry.width,gs_debug_real (__func__, "gs-window-x11.c", 358, "using geometry for monitor: x=%d y=%d w=%d h=%d"
, geometry.x, geometry.y, geometry.width, geometry.height)
358 geometry.height)gs_debug_real (__func__, "gs-window-x11.c", 358, "using geometry for monitor: x=%d y=%d w=%d h=%d"
, geometry.x, geometry.y, geometry.width, geometry.height)
;
359
360 window->priv->geometry.x = geometry.x;
361 window->priv->geometry.y = geometry.y;
362 window->priv->geometry.width = geometry.width;
363 window->priv->geometry.height = geometry.height;
364}
365
366static void
367monitor_geometry_notify (GdkMonitor *monitor,
368 GParamSpec *pspec,
369 GSWindow *window)
370{
371 gs_debug ("Got monitor geometry notify signal")gs_debug_real (__func__, "gs-window-x11.c", 371, "Got monitor geometry notify signal"
)
;
372 gtk_widget_queue_resize (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
);
373}
374
375/* copied from panel-toplevel.c */
376static void
377gs_window_move_resize_window (GSWindow *window,
378 gboolean move,
379 gboolean resize)
380{
381 GtkWidget *widget;
382 GdkWindow *gdkwindow;
383
384 widget = GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
;
385 gdkwindow = gtk_widget_get_window (widget);
386
387 g_assert (gtk_widget_get_realized (widget))do { (void) 0; } while (0);
388
389 gs_debug ("Move and/or resize window: x=%d y=%d w=%d h=%d",gs_debug_real (__func__, "gs-window-x11.c", 393, "Move and/or resize window: x=%d y=%d w=%d h=%d"
, window->priv->geometry.x, window->priv->geometry
.y, window->priv->geometry.width, window->priv->geometry
.height)
390 window->priv->geometry.x,gs_debug_real (__func__, "gs-window-x11.c", 393, "Move and/or resize window: x=%d y=%d w=%d h=%d"
, window->priv->geometry.x, window->priv->geometry
.y, window->priv->geometry.width, window->priv->geometry
.height)
391 window->priv->geometry.y,gs_debug_real (__func__, "gs-window-x11.c", 393, "Move and/or resize window: x=%d y=%d w=%d h=%d"
, window->priv->geometry.x, window->priv->geometry
.y, window->priv->geometry.width, window->priv->geometry
.height)
392 window->priv->geometry.width,gs_debug_real (__func__, "gs-window-x11.c", 393, "Move and/or resize window: x=%d y=%d w=%d h=%d"
, window->priv->geometry.x, window->priv->geometry
.y, window->priv->geometry.width, window->priv->geometry
.height)
393 window->priv->geometry.height)gs_debug_real (__func__, "gs-window-x11.c", 393, "Move and/or resize window: x=%d y=%d w=%d h=%d"
, window->priv->geometry.x, window->priv->geometry
.y, window->priv->geometry.width, window->priv->geometry
.height)
;
394
395 if (move && resize)
396 {
397 gdk_window_move_resize (gdkwindow,
398 window->priv->geometry.x,
399 window->priv->geometry.y,
400 window->priv->geometry.width,
401 window->priv->geometry.height);
402 }
403 else if (move)
404 {
405 gdk_window_move (gdkwindow,
406 window->priv->geometry.x,
407 window->priv->geometry.y);
408 }
409 else if (resize)
410 {
411 gdk_window_resize (gdkwindow,
412 window->priv->geometry.width,
413 window->priv->geometry.height);
414 }
415}
416
417static void
418gs_window_real_unrealize (GtkWidget *widget)
419{
420 GdkMonitor *monitor = GS_WINDOW (widget)((((GSWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gs_window_get_type ()))))))
->priv->monitor;
421
422 g_signal_handlers_disconnect_by_func (monitor, monitor_geometry_notify,g_signal_handlers_disconnect_matched ((monitor), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (monitor_geometry_notify), (widget))
423 widget)g_signal_handlers_disconnect_matched ((monitor), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (monitor_geometry_notify), (widget))
;
424
425 if (GTK_WIDGET_CLASS (gs_window_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((gs_window_parent_class)), ((gtk_widget_get_type ()))))))
->unrealize)
426 {
427 GTK_WIDGET_CLASS (gs_window_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((gs_window_parent_class)), ((gtk_widget_get_type ()))))))
->unrealize (widget);
428 }
429}
430
431/* copied from gdk */
432extern char **environ;
433
434static gchar **
435spawn_make_environment_for_display (GdkDisplay *display,
436 gchar **envp)
437{
438 gchar **retval = NULL((void*)0);
439 const gchar *display_name;
440 gint display_index = -1;
441 gint i, env_len;
442
443 g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL)do{ (void)0; }while (0);
444
445 if (envp == NULL((void*)0))
446 envp = environ;
447
448 for (env_len = 0; envp[env_len]; env_len++)
449 if (strncmp (envp[env_len], "DISPLAY", strlen ("DISPLAY")) == 0)
450 display_index = env_len;
451
452 retval = g_new (char *, env_len + 1)((char * *) g_malloc_n ((env_len + 1), sizeof (char *)));
453 retval[env_len] = NULL((void*)0);
454
455 display_name = gdk_display_get_name (display);
456
457 for (i = 0; i < env_len; i++)
458 if (i == display_index)
459 retval[i] = g_strconcat ("DISPLAY=", display_name, NULL((void*)0));
460 else
461 retval[i] = g_strdup (envp[i]);
462
463 g_assert (i == env_len)do { (void) 0; } while (0);
464
465 return retval;
466}
467
468static gboolean
469spawn_command_line_on_display_sync (GdkDisplay *display,
470 const gchar *command_line,
471 char **standard_output,
472 char **standard_error,
473 int *exit_status,
474 GError **error)
475{
476 char **argv = NULL((void*)0);
477 char **envp = NULL((void*)0);
478 gboolean retval;
479
480 g_return_val_if_fail (command_line != NULL, FALSE)do{ (void)0; }while (0);
481
482 if (! g_shell_parse_argv (command_line, NULL((void*)0), &argv, error))
483 {
484 return FALSE(0);
485 }
486
487 envp = spawn_make_environment_for_display (display, NULL((void*)0));
488
489 retval = g_spawn_sync (NULL((void*)0),
490 argv,
491 envp,
492 G_SPAWN_SEARCH_PATH,
493 NULL((void*)0),
494 NULL((void*)0),
495 standard_output,
496 standard_error,
497 exit_status,
498 error);
499
500 g_strfreev (argv);
501 g_strfreev (envp);
502
503 return retval;
504}
505
506static GdkVisual *
507get_best_visual_for_display (GdkDisplay *display)
508{
509 GdkScreen *screen;
510 char *std_output;
511 int exit_status;
512 GError *error;
513 unsigned long v;
514 char c;
515 GdkVisual *visual;
516 gboolean res;
517
518 visual = NULL((void*)0);
519 screen = gdk_display_get_default_screen (display);
520
521 error = NULL((void*)0);
522 std_output = NULL((void*)0);
523 res = spawn_command_line_on_display_sync (display,
524 MATE_SCREENSAVER_GL_HELPER_PATH"/usr/local/libexec/mate-screensaver-gl-helper",
525 &std_output,
526 NULL((void*)0),
527 &exit_status,
528 &error);
529 if (! res)
530 {
531 gs_debug ("Could not run command '%s': %s",gs_debug_real (__func__, "gs-window-x11.c", 532, "Could not run command '%s': %s"
, "/usr/local/libexec/mate-screensaver-gl-helper", error->
message)
532 MATE_SCREENSAVER_GL_HELPER_PATH, error->message)gs_debug_real (__func__, "gs-window-x11.c", 532, "Could not run command '%s': %s"
, "/usr/local/libexec/mate-screensaver-gl-helper", error->
message)
;
533 g_error_free (error);
534 goto out;
535 }
536
537 if (1 == sscanf (std_output, "0x%lx %c", &v, &c))
538 {
539 if (v != 0)
540 {
541 VisualID visual_id;
542
543 visual_id = (VisualID) v;
544 visual = gdk_x11_screen_lookup_visual (screen, visual_id);
545
546 gs_debug ("Found best GL visual for display %s: 0x%x",gs_debug_real (__func__, "gs-window-x11.c", 548, "Found best GL visual for display %s: 0x%x"
, gdk_display_get_name (display), (unsigned int) visual_id)
547 gdk_display_get_name (display),gs_debug_real (__func__, "gs-window-x11.c", 548, "Found best GL visual for display %s: 0x%x"
, gdk_display_get_name (display), (unsigned int) visual_id)
548 (unsigned int) visual_id)gs_debug_real (__func__, "gs-window-x11.c", 548, "Found best GL visual for display %s: 0x%x"
, gdk_display_get_name (display), (unsigned int) visual_id)
;
549 }
550 }
551out:
552 g_free (std_output);
553
554 return g_object_ref (visual)((__typeof__ (visual)) (g_object_ref) (visual));
555}
556
557static void
558widget_set_best_visual (GtkWidget *widget)
559{
560 GdkVisual *visual;
561
562 g_return_if_fail (widget != NULL)do{ (void)0; }while (0);
563
564 visual = get_best_visual_for_display (gtk_widget_get_display (widget));
565 if (visual != NULL((void*)0))
566 {
567 gtk_widget_set_visual (widget, visual);
568 g_object_unref (visual);
569 }
570}
571
572static void
573gs_window_real_realize (GtkWidget *widget)
574{
575 GdkMonitor *monitor = GS_WINDOW (widget)((((GSWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gs_window_get_type ()))))))
->priv->monitor;
576
577 widget_set_best_visual (widget);
578
579 if (GTK_WIDGET_CLASS (gs_window_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((gs_window_parent_class)), ((gtk_widget_get_type ()))))))
->realize)
580 {
581 GTK_WIDGET_CLASS (gs_window_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((gs_window_parent_class)), ((gtk_widget_get_type ()))))))
->realize (widget);
582 }
583
584 gs_window_override_user_time (GS_WINDOW (widget)((((GSWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gs_window_get_type ()))))))
);
585
586 gs_window_move_resize_window (GS_WINDOW (widget)((((GSWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gs_window_get_type ()))))))
, TRUE(!(0)), TRUE(!(0)));
587
588 g_signal_connect (monitor,g_signal_connect_data ((monitor), ("notify::geometry"), (((GCallback
) (monitor_geometry_notify))), (widget), ((void*)0), (GConnectFlags
) 0)
589 "notify::geometry",g_signal_connect_data ((monitor), ("notify::geometry"), (((GCallback
) (monitor_geometry_notify))), (widget), ((void*)0), (GConnectFlags
) 0)
590 G_CALLBACK (monitor_geometry_notify),g_signal_connect_data ((monitor), ("notify::geometry"), (((GCallback
) (monitor_geometry_notify))), (widget), ((void*)0), (GConnectFlags
) 0)
591 widget)g_signal_connect_data ((monitor), ("notify::geometry"), (((GCallback
) (monitor_geometry_notify))), (widget), ((void*)0), (GConnectFlags
) 0)
;
592}
593
594/* every so often we should raise the window in case
595 another window has somehow gotten on top */
596static gboolean
597watchdog_timer (GSWindow *window)
598{
599 GtkWidget *widget = GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
;
600
601 gdk_window_focus (gtk_widget_get_window (widget), GDK_CURRENT_TIME0L);
602
603 return TRUE(!(0));
604}
605
606static void
607remove_watchdog_timer (GSWindow *window)
608{
609 if (window->priv->watchdog_timer_id != 0)
610 {
611 g_source_remove (window->priv->watchdog_timer_id);
612 window->priv->watchdog_timer_id = 0;
613 }
614}
615
616static void
617add_watchdog_timer (GSWindow *window,
618 guint timeout)
619{
620 window->priv->watchdog_timer_id = g_timeout_add (timeout,
621 (GSourceFunc)watchdog_timer,
622 window);
623}
624
625static void
626remove_popup_dialog_idle (GSWindow *window)
627{
628 if (window->priv->popup_dialog_idle_id != 0)
629 {
630 g_source_remove (window->priv->popup_dialog_idle_id);
631 window->priv->popup_dialog_idle_id = 0;
632 }
633}
634
635static void
636add_popup_dialog_idle (GSWindow *window)
637{
638 window->priv->popup_dialog_idle_id = g_idle_add (popup_dialog_idle, window);
639}
640
641static gboolean
642emit_deactivated_idle (GSWindow *window)
643{
644 g_signal_emit (window, signals [DEACTIVATED], 0);
645
646 return FALSE(0);
647}
648
649static void
650add_emit_deactivated_idle (GSWindow *window)
651{
652 g_idle_add ((GSourceFunc)emit_deactivated_idle, window);
653}
654
655static void
656gs_window_raise (GSWindow *window)
657{
658 GdkWindow *win;
659
660 g_return_if_fail (GS_IS_WINDOW (window))do{ (void)0; }while (0);
661
662 gs_debug ("Raising screensaver window")gs_debug_real (__func__, "gs-window-x11.c", 662, "Raising screensaver window"
)
;
663
664 win = gtk_widget_get_window (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
);
665
666 gdk_window_raise (win);
667}
668
669static gboolean
670x11_window_is_ours (Window window)
671{
672 GdkWindow *gwindow;
673 gboolean ret;
674
675 ret = FALSE(0);
676
677 gwindow = gdk_x11_window_lookup_for_display (gdk_display_get_default (), window);
678 if (gwindow && (window != GDK_ROOT_WINDOW ()(gdk_x11_get_default_root_xwindow ())))
679 {
680 ret = TRUE(!(0));
681 }
682
683 return ret;
684}
685
686#ifdef HAVE_SHAPE_EXT1
687static void
688unshape_window (GSWindow *window)
689{
690 gdk_window_shape_combine_region (gtk_widget_get_window (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
),
691 NULL((void*)0),
692 0,
693 0);
694}
695#endif
696
697static void
698gs_window_xevent (GSWindow *window,
699 GdkXEvent *xevent)
700{
701 XEvent *ev;
702
703 ev = xevent;
704
705 /* MapNotify is used to tell us when new windows are mapped.
706 ConfigureNofify is used to tell us when windows are raised. */
707 switch (ev->xany.type)
708 {
709 case MapNotify19:
710 {
711 XMapEvent *xme = &ev->xmap;
712
713 if (! x11_window_is_ours (xme->window))
714 {
715 gs_window_raise (window);
716 }
717 else
718 {
719 gs_debug ("not raising our windows")gs_debug_real (__func__, "gs-window-x11.c", 719, "not raising our windows"
)
;
720 }
721
722 break;
723 }
724 case ConfigureNotify22:
725 {
726 XConfigureEvent *xce = &ev->xconfigure;
727
728 if (! x11_window_is_ours (xce->window))
729 {
730 gs_window_raise (window);
731 }
732 else
733 {
734 gs_debug ("not raising our windows")gs_debug_real (__func__, "gs-window-x11.c", 734, "not raising our windows"
)
;
735 }
736
737 break;
738 }
739 default:
740 /* extension events */
741#ifdef HAVE_SHAPE_EXT1
742 if (ev->xany.type == (window->priv->shape_event_base + ShapeNotify0))
743 {
744 /*XShapeEvent *xse = (XShapeEvent *) ev;*/
745 unshape_window (window);
746 gs_debug ("Window was reshaped!")gs_debug_real (__func__, "gs-window-x11.c", 746, "Window was reshaped!"
)
;
747 }
748#endif
749
750 break;
751 }
752
753}
754
755static GdkFilterReturn
756xevent_filter (GdkXEvent *xevent,
757 GdkEvent *event,
758 GSWindow *window)
759{
760 gs_window_xevent (window, xevent);
761
762 return GDK_FILTER_CONTINUE;
763}
764
765static void
766select_popup_events (void)
767{
768 XWindowAttributes attr;
769 unsigned long events;
770 GdkDisplay *display;
771
772 display = gdk_display_get_default ();
773
774 gdk_x11_display_error_trap_push (display);
775
776 memset (&attr, 0, sizeof (attr));
777 XGetWindowAttributes (GDK_DISPLAY_XDISPLAY (display)(gdk_x11_display_get_xdisplay (display)), GDK_ROOT_WINDOW ()(gdk_x11_get_default_root_xwindow ()), &attr);
778
779 events = SubstructureNotifyMask(1L<<19) | attr.your_event_mask;
780 XSelectInput (GDK_DISPLAY_XDISPLAY (display)(gdk_x11_display_get_xdisplay (display)), GDK_ROOT_WINDOW ()(gdk_x11_get_default_root_xwindow ()), events);
781
782 gdk_x11_display_error_trap_pop_ignored (display);
783}
784
785static void
786window_select_shape_events (GSWindow *window)
787{
788#ifdef HAVE_SHAPE_EXT1
789 unsigned long events;
790 int shape_error_base;
791 GdkDisplay *display;
792
793 display = gtk_widget_get_display (GTK_WIDGET(window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
);
794
795 gdk_x11_display_error_trap_push (display);
796
797 if (XShapeQueryExtension (GDK_DISPLAY_XDISPLAY (display)(gdk_x11_display_get_xdisplay (display)), &window->priv->shape_event_base, &shape_error_base)) {
798 events = ShapeNotifyMask(1L << 0);
799 XShapeSelectInput (GDK_DISPLAY_XDISPLAY (display)(gdk_x11_display_get_xdisplay (display)), GDK_WINDOW_XID (gtk_widget_get_window (GTK_WIDGET (window)))(gdk_x11_window_get_xid (gtk_widget_get_window (((((GtkWidget
*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window
)), ((gtk_widget_get_type ())))))))))
, events);
800 }
801
802 gdk_x11_display_error_trap_pop_ignored (display);
803#endif
804}
805
806static gboolean
807gs_window_real_draw (GtkWidget *widget,
808 cairo_t *cr)
809{
810 GSWindow *window = GS_WINDOW (widget)((((GSWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gs_window_get_type ()))))))
;
811 cairo_surface_t *bg_surface = window->priv->background_surface;
812
813 cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
814 if (bg_surface != NULL((void*)0))
815 {
816 cairo_set_source_surface (cr, bg_surface, 0, 0);
817 }
818 else
819 {
820 cairo_set_source_rgb (cr, 0, 0, 0);
821 }
822 cairo_paint (cr);
823
824 return FALSE(0);
825}
826
827static void
828gs_window_real_show (GtkWidget *widget)
829{
830 GSWindow *window;
831
832 if (GTK_WIDGET_CLASS (gs_window_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((gs_window_parent_class)), ((gtk_widget_get_type ()))))))
->show)
833 {
834 GTK_WIDGET_CLASS (gs_window_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((gs_window_parent_class)), ((gtk_widget_get_type ()))))))
->show (widget);
835 }
836
837 gs_window_clear (GS_WINDOW (widget)((((GSWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gs_window_get_type ()))))))
);
838
839 set_invisible_cursor (gtk_widget_get_window (widget), TRUE(!(0)));
840
841 window = GS_WINDOW (widget)((((GSWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gs_window_get_type ()))))))
;
842 if (window->priv->timer)
843 {
844 g_timer_destroy (window->priv->timer);
845 }
846 window->priv->timer = g_timer_new ();
847
848 remove_watchdog_timer (window);
849 add_watchdog_timer (window, 30000);
850
851 select_popup_events ();
852 window_select_shape_events (window);
853 gdk_window_add_filter (NULL((void*)0), (GdkFilterFunc)xevent_filter, window);
854}
855
856static void
857set_info_text_and_icon (GSWindow *window,
858 const char *icon_name,
859 const char *primary_text,
860 const char *secondary_text)
861{
862 GtkWidget *content_area;
863 GtkWidget *hbox_content;
864 GtkWidget *image;
865 GtkWidget *vbox;
866 gchar *primary_markup;
867 gchar *secondary_markup;
868 GtkWidget *primary_label;
869 GtkWidget *secondary_label;
870
871 hbox_content = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 8);
872 gtk_widget_show (hbox_content);
873
874 image = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_DIALOG);
875 gtk_widget_show (image);
876 gtk_box_pack_start (GTK_BOX (hbox_content)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((hbox_content)), ((gtk_box_get_type ()))))))
, image, FALSE(0), FALSE(0), 0);
877 gtk_widget_set_valign (image, GTK_ALIGN_START);
878
879 vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
880 gtk_widget_show (vbox);
881 gtk_box_pack_start (GTK_BOX (hbox_content)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((hbox_content)), ((gtk_box_get_type ()))))))
, vbox, FALSE(0), FALSE(0), 0);
882
883 primary_markup = g_strdup_printf ("<b>%s</b>", primary_text);
884 primary_label = gtk_label_new (primary_markup);
885 g_free (primary_markup);
886 gtk_widget_show (primary_label);
887 gtk_box_pack_start (GTK_BOX (vbox)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((vbox)), ((gtk_box_get_type ()))))))
, primary_label, TRUE(!(0)), TRUE(!(0)), 0);
888 gtk_label_set_use_markup (GTK_LABEL (primary_label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((primary_label)), ((gtk_label_get_type ()))))))
, TRUE(!(0)));
889 gtk_label_set_line_wrap (GTK_LABEL (primary_label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((primary_label)), ((gtk_label_get_type ()))))))
, TRUE(!(0)));
890 gtk_widget_set_halign (primary_label, GTK_ALIGN_START);
891
892 if (secondary_text != NULL((void*)0))
893 {
894 secondary_markup = g_strdup_printf ("<small>%s</small>",
895 secondary_text);
896 secondary_label = gtk_label_new (secondary_markup);
897 g_free (secondary_markup);
898 gtk_widget_show (secondary_label);
899 gtk_box_pack_start (GTK_BOX (vbox)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((vbox)), ((gtk_box_get_type ()))))))
, secondary_label, TRUE(!(0)), TRUE(!(0)), 0);
900 gtk_label_set_use_markup (GTK_LABEL (secondary_label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((secondary_label)), ((gtk_label_get_type ()))))))
, TRUE(!(0)));
901 gtk_label_set_line_wrap (GTK_LABEL (secondary_label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((secondary_label)), ((gtk_label_get_type ()))))))
, TRUE(!(0)));
902 gtk_widget_set_halign (secondary_label, GTK_ALIGN_START);
903 }
904
905 /* remove old content */
906 content_area = gtk_info_bar_get_content_area (GTK_INFO_BAR (window->priv->info_bar)((((GtkInfoBar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->info_bar)), ((gtk_info_bar_get_type(
)))))))
);
907 if (window->priv->info_content != NULL((void*)0))
908 {
909 gtk_container_remove (GTK_CONTAINER (content_area)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((content_area)), ((gtk_container_get_type ()))))))
, window->priv->info_content);
910 }
911 gtk_box_pack_start (GTK_BOX (content_area)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((content_area)), ((gtk_box_get_type ()))))))
,
912 hbox_content,
913 TRUE(!(0)), FALSE(0), 0);
914 window->priv->info_content = hbox_content;
915}
916
917static gboolean
918info_bar_timeout (GSWindow *window)
919{
920 window->priv->info_bar_timer_id = 0;
921 gtk_widget_hide (window->priv->info_bar);
922 return FALSE(0);
923}
924
925void
926gs_window_show_message (GSWindow *window,
927 const char *summary,
928 const char *body,
929 const char *icon)
930{
931 g_return_if_fail (GS_IS_WINDOW (window))do{ (void)0; }while (0);
932
933 set_info_text_and_icon (window,
934 icon,
935 summary,
936 body);
937 gtk_widget_show (window->priv->info_bar);
938
939 if (window->priv->info_bar_timer_id > 0)
940 {
941 g_source_remove (window->priv->info_bar_timer_id);
942 }
943
944 window->priv->info_bar_timer_id = g_timeout_add_seconds (INFO_BAR_SECONDS30,
945 (GSourceFunc)info_bar_timeout,
946 window);
947}
948
949void
950gs_window_show (GSWindow *window)
951{
952 g_return_if_fail (GS_IS_WINDOW (window))do{ (void)0; }while (0);
953
954 gtk_widget_show (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
);
955}
956
957static void
958gs_window_real_hide (GtkWidget *widget)
959{
960 GSWindow *window;
961
962 window = GS_WINDOW (widget)((((GSWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gs_window_get_type ()))))))
;
963
964 gdk_window_remove_filter (NULL((void*)0), (GdkFilterFunc)xevent_filter, window);
965
966 remove_watchdog_timer (window);
967
968 if (GTK_WIDGET_CLASS (gs_window_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((gs_window_parent_class)), ((gtk_widget_get_type ()))))))
->hide)
969 {
970 GTK_WIDGET_CLASS (gs_window_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((gs_window_parent_class)), ((gtk_widget_get_type ()))))))
->hide (widget);
971 }
972}
973
974void
975gs_window_destroy (GSWindow *window)
976{
977 g_return_if_fail (GS_IS_WINDOW (window))do{ (void)0; }while (0);
978
979 gs_window_cancel_unlock_request (window);
980
981 gtk_widget_destroy (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
);
982}
983
984GdkWindow *
985gs_window_get_gdk_window (GSWindow *window)
986{
987 g_return_val_if_fail (GS_IS_WINDOW (window), NULL)do{ (void)0; }while (0);
988
989 return gtk_widget_get_window (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
);
990}
991
992GtkWidget *
993gs_window_get_drawing_area (GSWindow *window)
994{
995 g_return_val_if_fail (GS_IS_WINDOW (window), NULL)do{ (void)0; }while (0);
996
997 return window->priv->drawing_area;
998}
999
1000/* just for debugging */
1001static gboolean
1002error_watch (GIOChannel *source,
1003 GIOCondition condition,
1004 gpointer data)
1005{
1006 gboolean finished = FALSE(0);
1007
1008 if (condition & G_IO_IN)
1009 {
1010 GIOStatus status;
1011 GError *error = NULL((void*)0);
1012 char *line;
1013
1014 line = NULL((void*)0);
1015 status = g_io_channel_read_line (source, &line, NULL((void*)0), NULL((void*)0), &error);
1016
1017 switch (status)
1018 {
1019 case G_IO_STATUS_NORMAL:
1020 gs_debug ("command error output: %s", line)gs_debug_real (__func__, "gs-window-x11.c", 1020, "command error output: %s"
, line)
;
1021 break;
1022 case G_IO_STATUS_EOF:
1023 finished = TRUE(!(0));
1024 break;
1025 case G_IO_STATUS_ERROR:
1026 finished = TRUE(!(0));
1027 gs_debug ("Error reading from child: %s\n", error->message)gs_debug_real (__func__, "gs-window-x11.c", 1027, "Error reading from child: %s\n"
, error->message)
;
1028 g_error_free (error);
1029 return FALSE(0);
1030 case G_IO_STATUS_AGAIN:
1031 default:
1032 break;
1033 }
1034 g_free (line);
1035 }
1036 else if (condition & G_IO_HUP)
1037 {
1038 finished = TRUE(!(0));
1039 }
1040
1041 if (finished)
1042 {
1043 return FALSE(0);
1044 }
1045
1046 return TRUE(!(0));
1047}
1048
1049static gboolean
1050spawn_on_window (GSWindow *window,
1051 char *command,
1052 int *pid,
1053 GIOFunc watch_func,
1054 gpointer user_data,
1055 gint *watch_id)
1056{
1057 int argc;
1058 char **argv;
1059 char **envp;
1060 GError *error;
1061 gboolean result;
1062 GIOChannel *channel;
1063 int standard_output;
1064 int standard_error;
1065 int child_pid;
1066 int id;
1067
1068 error = NULL((void*)0);
1069 if (! g_shell_parse_argv (command, &argc, &argv, &error))
1070 {
1071 gs_debug ("Could not parse command: %s", error->message)gs_debug_real (__func__, "gs-window-x11.c", 1071, "Could not parse command: %s"
, error->message)
;
1072 g_error_free (error);
1073 return FALSE(0);
1074 }
1075
1076 error = NULL((void*)0);
1077 envp = spawn_make_environment_for_display (gtk_widget_get_display (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
), NULL((void*)0));
1078 result = g_spawn_async_with_pipes (NULL((void*)0),
1079 argv,
1080 envp,
1081 G_SPAWN_DO_NOT_REAP_CHILD | G_SPAWN_SEARCH_PATH,
1082 NULL((void*)0),
1083 NULL((void*)0),
1084 &child_pid,
1085 NULL((void*)0),
1086 &standard_output,
1087 &standard_error,
1088 &error);
1089
1090 if (! result)
1091 {
1092 gs_debug ("Could not start command '%s': %s", command, error->message)gs_debug_real (__func__, "gs-window-x11.c", 1092, "Could not start command '%s': %s"
, command, error->message)
;
1093 g_error_free (error);
1094 g_strfreev (argv);
1095 return FALSE(0);
1096 }
1097
1098 if (pid != NULL((void*)0))
1099 {
1100 *pid = child_pid;
1101 }
1102 else
1103 {
1104 g_spawn_close_pid (child_pid);
1105 }
1106
1107 /* output channel */
1108 channel = g_io_channel_unix_new (standard_output);
1109 g_io_channel_set_close_on_unref (channel, TRUE(!(0)));
1110 g_io_channel_set_flags (channel,
1111 g_io_channel_get_flags (channel) | G_IO_FLAG_NONBLOCK,
1112 NULL((void*)0));
1113 id = g_io_add_watch (channel,
1114 G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL,
1115 watch_func,
1116 user_data);
1117 if (watch_id != NULL((void*)0))
1118 {
1119 *watch_id = id;
1120 }
1121 g_io_channel_unref (channel);
1122
1123 /* error channel */
1124 channel = g_io_channel_unix_new (standard_error);
1125 g_io_channel_set_close_on_unref (channel, TRUE(!(0)));
1126 g_io_channel_set_flags (channel,
1127 g_io_channel_get_flags (channel) | G_IO_FLAG_NONBLOCK,
1128 NULL((void*)0));
1129 id = g_io_add_watch (channel,
1130 G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL,
1131 error_watch,
1132 NULL((void*)0));
1133 g_io_channel_unref (channel);
1134
1135 g_strfreev (argv);
1136 g_strfreev (envp);
1137
1138 return result;
1139}
1140
1141static void
1142lock_plug_added (GtkWidget *widget,
1143 GSWindow *window)
1144{
1145 gtk_widget_show (widget);
1146}
1147
1148static gboolean
1149lock_plug_removed (GtkWidget *widget,
1150 GSWindow *window)
1151{
1152 gtk_widget_hide (widget);
1153 gtk_container_remove (GTK_CONTAINER (window->priv->vbox)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->vbox)), ((gtk_container_get_type ())
)))))
, GTK_WIDGET (window->priv->lock_box)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->lock_box)), ((gtk_widget_get_type ()
))))))
);
1154 window->priv->lock_box = NULL((void*)0);
1155
1156 return TRUE(!(0));
1157}
1158
1159static void
1160keyboard_plug_added (GtkWidget *widget,
1161 GSWindow *window)
1162{
1163 gtk_widget_show (widget);
1164}
1165
1166static gboolean
1167keyboard_plug_removed (GtkWidget *widget,
1168 GSWindow *window)
1169{
1170 gtk_widget_hide (widget);
1171 gtk_container_remove (GTK_CONTAINER (window->priv->vbox)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->vbox)), ((gtk_container_get_type ())
)))))
, GTK_WIDGET (window->priv->keyboard_socket)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->keyboard_socket)), ((gtk_widget_get_type
()))))))
);
1172
1173 return TRUE(!(0));
1174}
1175
1176static void
1177keyboard_socket_destroyed (GtkWidget *widget,
1178 GSWindow *window)
1179{
1180 g_signal_handlers_disconnect_by_func (widget, keyboard_socket_destroyed, window)g_signal_handlers_disconnect_matched ((widget), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (keyboard_socket_destroyed), (window))
;
1181 g_signal_handlers_disconnect_by_func (widget, keyboard_plug_added, window)g_signal_handlers_disconnect_matched ((widget), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (keyboard_plug_added), (window))
;
1182 g_signal_handlers_disconnect_by_func (widget, keyboard_plug_removed, window)g_signal_handlers_disconnect_matched ((widget), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (keyboard_plug_removed), (window))
;
1183
1184 window->priv->keyboard_socket = NULL((void*)0);
1185}
1186
1187static void
1188forward_key_events (GSWindow *window)
1189{
1190 window->priv->key_events = g_list_reverse (window->priv->key_events);
1191
1192 while (window->priv->key_events != NULL((void*)0))
1193 {
1194 GdkEventKey *event = window->priv->key_events->data;
1195
1196 gtk_window_propagate_key_event (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
, event);
1197
1198 gdk_event_free ((GdkEvent *)event);
1199 window->priv->key_events = g_list_delete_link (window->priv->key_events,
1200 window->priv->key_events);
1201 }
1202}
1203
1204static void
1205remove_key_events (GSWindow *window)
1206{
1207 window->priv->key_events = g_list_reverse (window->priv->key_events);
1208
1209 while (window->priv->key_events)
1210 {
1211 GdkEventKey *event = window->priv->key_events->data;
1212
1213 gdk_event_free ((GdkEvent *)event);
1214 window->priv->key_events = g_list_delete_link (window->priv->key_events,
1215 window->priv->key_events);
1216 }
1217}
1218
1219static void
1220lock_socket_show (GtkWidget *widget,
1221 GSWindow *window)
1222{
1223 gtk_widget_child_focus (window->priv->lock_socket, GTK_DIR_TAB_FORWARD);
1224
1225 /* send queued events to the dialog */
1226 forward_key_events (window);
1227}
1228
1229static void
1230lock_socket_destroyed (GtkWidget *widget,
1231 GSWindow *window)
1232{
1233 g_signal_handlers_disconnect_by_func (widget, lock_socket_show, window)g_signal_handlers_disconnect_matched ((widget), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (lock_socket_show), (window))
;
1234 g_signal_handlers_disconnect_by_func (widget, lock_socket_destroyed, window)g_signal_handlers_disconnect_matched ((widget), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (lock_socket_destroyed), (window))
;
1235 g_signal_handlers_disconnect_by_func (widget, lock_plug_added, window)g_signal_handlers_disconnect_matched ((widget), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (lock_plug_added), (window))
;
1236 g_signal_handlers_disconnect_by_func (widget, lock_plug_removed, window)g_signal_handlers_disconnect_matched ((widget), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (lock_plug_removed), (window))
;
1237
1238 window->priv->lock_socket = NULL((void*)0);
1239}
1240
1241static void
1242create_keyboard_socket (GSWindow *window,
1243 guint32 id)
1244{
1245 int height;
1246
1247 height = (HeightOfScreen (gdk_x11_screen_get_xscreen (gtk_widget_get_screen (GTK_WIDGET (window))))((gdk_x11_screen_get_xscreen (gtk_widget_get_screen (((((GtkWidget
*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window
)), ((gtk_widget_get_type ())))))))))->height)
) / 4;
1248
1249 window->priv->keyboard_socket = gtk_socket_new ();
1250 gtk_widget_set_size_request (window->priv->keyboard_socket, -1, height);
1251
1252 g_signal_connect (window->priv->keyboard_socket, "destroy",g_signal_connect_data ((window->priv->keyboard_socket),
("destroy"), (((GCallback) (keyboard_socket_destroyed))), (window
), ((void*)0), (GConnectFlags) 0)
1253 G_CALLBACK (keyboard_socket_destroyed), window)g_signal_connect_data ((window->priv->keyboard_socket),
("destroy"), (((GCallback) (keyboard_socket_destroyed))), (window
), ((void*)0), (GConnectFlags) 0)
;
1254 g_signal_connect (window->priv->keyboard_socket, "plug_added",g_signal_connect_data ((window->priv->keyboard_socket),
("plug_added"), (((GCallback) (keyboard_plug_added))), (window
), ((void*)0), (GConnectFlags) 0)
1255 G_CALLBACK (keyboard_plug_added), window)g_signal_connect_data ((window->priv->keyboard_socket),
("plug_added"), (((GCallback) (keyboard_plug_added))), (window
), ((void*)0), (GConnectFlags) 0)
;
1256 g_signal_connect (window->priv->keyboard_socket, "plug_removed",g_signal_connect_data ((window->priv->keyboard_socket),
("plug_removed"), (((GCallback) (keyboard_plug_removed))), (
window), ((void*)0), (GConnectFlags) 0)
1257 G_CALLBACK (keyboard_plug_removed), window)g_signal_connect_data ((window->priv->keyboard_socket),
("plug_removed"), (((GCallback) (keyboard_plug_removed))), (
window), ((void*)0), (GConnectFlags) 0)
;
1258 gtk_box_pack_start (GTK_BOX (window->priv->vbox)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->vbox)), ((gtk_box_get_type ()))))))
, window->priv->keyboard_socket, FALSE(0), FALSE(0), 0);
1259 gtk_socket_add_id (GTK_SOCKET (window->priv->keyboard_socket)((((GtkSocket*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->keyboard_socket)), ((gtk_socket_get_type
()))))))
, id);
1260}
1261
1262/* adapted from gspawn.c */
1263static int
1264wait_on_child (int pid)
1265{
1266 int status;
1267
1268wait_again:
1269 if (waitpid (pid, &status, 0) < 0)
1270 {
1271 if (errno(*__errno_location ()) == EINTR4)
1272 {
1273 goto wait_again;
1274 }
1275 else if (errno(*__errno_location ()) == ECHILD10)
1276 {
1277 ; /* do nothing, child already reaped */
1278 }
1279 else
1280 {
1281 gs_debug ("waitpid () should not fail in 'GSWindow'")gs_debug_real (__func__, "gs-window-x11.c", 1281, "waitpid () should not fail in 'GSWindow'"
)
;
1282 }
1283 }
1284
1285 return status;
1286}
1287
1288static void
1289kill_keyboard_command (GSWindow *window)
1290{
1291 if (window->priv->keyboard_pid > 0)
1292 {
1293 signal_pid (window->priv->keyboard_pid, SIGTERM15);
1294 }
1295}
1296
1297static void
1298kill_dialog_command (GSWindow *window)
1299{
1300 /* If a dialog is up we need to signal it
1301 and wait on it */
1302 if (window->priv->lock_pid > 0)
1303 {
1304 signal_pid (window->priv->lock_pid, SIGTERM15);
1305 }
1306}
1307
1308static void
1309keyboard_command_finish (GSWindow *window)
1310{
1311 g_return_if_fail (GS_IS_WINDOW (window))do{ (void)0; }while (0);
1312
1313 /* send a signal just in case */
1314 kill_keyboard_command (window);
1315
1316 gs_debug ("Keyboard finished")gs_debug_real (__func__, "gs-window-x11.c", 1316, "Keyboard finished"
)
;
1317
1318 if (window->priv->keyboard_pid > 0)
1319 {
1320 wait_on_child (window->priv->keyboard_pid);
1321
1322 g_spawn_close_pid (window->priv->keyboard_pid);
1323 window->priv->keyboard_pid = 0;
1324 }
1325}
1326
1327static gboolean
1328keyboard_command_watch (GIOChannel *source,
1329 GIOCondition condition,
1330 GSWindow *window)
1331{
1332 gboolean finished = FALSE(0);
1333
1334 g_return_val_if_fail (GS_IS_WINDOW (window), FALSE)do{ (void)0; }while (0);
1335
1336 if (condition & G_IO_IN)
1337 {
1338 GIOStatus status;
1339 GError *error = NULL((void*)0);
1340 char *line;
1341
1342 line = NULL((void*)0);
1343 status = g_io_channel_read_line (source, &line, NULL((void*)0), NULL((void*)0), &error);
1344
1345 switch (status)
1346 {
1347 case G_IO_STATUS_NORMAL:
1348 {
1349 guint32 id;
1350 char c;
1351 gs_debug ("keyboard command output: %s", line)gs_debug_real (__func__, "gs-window-x11.c", 1351, "keyboard command output: %s"
, line)
;
1352 if (1 == sscanf (line, " %" G_GUINT32_FORMAT"u" " %c", &id, &c))
1353 {
1354 create_keyboard_socket (window, id);
1355 }
1356 }
1357 break;
1358 case G_IO_STATUS_EOF:
1359 finished = TRUE(!(0));
1360 break;
1361 case G_IO_STATUS_ERROR:
1362 finished = TRUE(!(0));
Value stored to 'finished' is never read
1363 gs_debug ("Error reading from child: %s\n", error->message)gs_debug_real (__func__, "gs-window-x11.c", 1363, "Error reading from child: %s\n"
, error->message)
;
1364 g_error_free (error);
1365 return FALSE(0);
1366 case G_IO_STATUS_AGAIN:
1367 default:
1368 break;
1369 }
1370
1371 g_free (line);
1372 }
1373 else if (condition & G_IO_HUP)
1374 {
1375 finished = TRUE(!(0));
1376 }
1377
1378 if (finished)
1379 {
1380 window->priv->keyboard_watch_id = 0;
1381 keyboard_command_finish (window);
1382 return FALSE(0);
1383 }
1384
1385 return TRUE(!(0));
1386}
1387
1388static void
1389embed_keyboard (GSWindow *window)
1390{
1391 gboolean res;
1392
1393 if (! window->priv->keyboard_enabled
1394 || window->priv->keyboard_command == NULL((void*)0))
1395 return;
1396
1397 gs_debug ("Adding embedded keyboard widget")gs_debug_real (__func__, "gs-window-x11.c", 1397, "Adding embedded keyboard widget"
)
;
1398
1399 /* FIXME: verify command is safe */
1400
1401 gs_debug ("Running command: %s", window->priv->keyboard_command)gs_debug_real (__func__, "gs-window-x11.c", 1401, "Running command: %s"
, window->priv->keyboard_command)
;
1402
1403 res = spawn_on_window (window,
1404 window->priv->keyboard_command,
1405 &window->priv->keyboard_pid,
1406 (GIOFunc)keyboard_command_watch,
1407 window,
1408 &window->priv->keyboard_watch_id);
1409 if (! res)
1410 {
1411 gs_debug ("Could not start command: %s", window->priv->keyboard_command)gs_debug_real (__func__, "gs-window-x11.c", 1411, "Could not start command: %s"
, window->priv->keyboard_command)
;
1412 }
1413}
1414
1415static void
1416create_lock_socket (GSWindow *window,
1417 guint32 id)
1418{
1419 window->priv->lock_socket = gtk_socket_new ();
1420 window->priv->lock_box = gtk_grid_new ();
1421 gtk_widget_set_halign (GTK_WIDGET (window->priv->lock_box)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->lock_box)), ((gtk_widget_get_type ()
))))))
,
1422 GTK_ALIGN_CENTER);
1423 gtk_widget_set_valign (GTK_WIDGET (window->priv->lock_box)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->lock_box)), ((gtk_widget_get_type ()
))))))
,
1424 GTK_ALIGN_CENTER);
1425 gtk_widget_show (window->priv->lock_box);
1426 gtk_box_pack_start (GTK_BOX (window->priv->vbox)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->vbox)), ((gtk_box_get_type ()))))))
, window->priv->lock_box, TRUE(!(0)), TRUE(!(0)), 0);
1427
1428 gtk_container_add (GTK_CONTAINER (window->priv->lock_box)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->lock_box)), ((gtk_container_get_type
()))))))
, window->priv->lock_socket);
1429
1430 g_signal_connect (window->priv->lock_socket, "show",g_signal_connect_data ((window->priv->lock_socket), ("show"
), (((GCallback) (lock_socket_show))), (window), ((void*)0), (
GConnectFlags) 0)
1431 G_CALLBACK (lock_socket_show), window)g_signal_connect_data ((window->priv->lock_socket), ("show"
), (((GCallback) (lock_socket_show))), (window), ((void*)0), (
GConnectFlags) 0)
;
1432 g_signal_connect (window->priv->lock_socket, "destroy",g_signal_connect_data ((window->priv->lock_socket), ("destroy"
), (((GCallback) (lock_socket_destroyed))), (window), ((void*
)0), (GConnectFlags) 0)
1433 G_CALLBACK (lock_socket_destroyed), window)g_signal_connect_data ((window->priv->lock_socket), ("destroy"
), (((GCallback) (lock_socket_destroyed))), (window), ((void*
)0), (GConnectFlags) 0)
;
1434 g_signal_connect (window->priv->lock_socket, "plug_added",g_signal_connect_data ((window->priv->lock_socket), ("plug_added"
), (((GCallback) (lock_plug_added))), (window), ((void*)0), (
GConnectFlags) 0)
1435 G_CALLBACK (lock_plug_added), window)g_signal_connect_data ((window->priv->lock_socket), ("plug_added"
), (((GCallback) (lock_plug_added))), (window), ((void*)0), (
GConnectFlags) 0)
;
1436 g_signal_connect (window->priv->lock_socket, "plug_removed",g_signal_connect_data ((window->priv->lock_socket), ("plug_removed"
), (((GCallback) (lock_plug_removed))), (window), ((void*)0),
(GConnectFlags) 0)
1437 G_CALLBACK (lock_plug_removed), window)g_signal_connect_data ((window->priv->lock_socket), ("plug_removed"
), (((GCallback) (lock_plug_removed))), (window), ((void*)0),
(GConnectFlags) 0)
;
1438
1439 gtk_socket_add_id (GTK_SOCKET (window->priv->lock_socket)((((GtkSocket*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->lock_socket)), ((gtk_socket_get_type
()))))))
, id);
1440
1441 if (window->priv->keyboard_enabled)
1442 {
1443 embed_keyboard (window);
1444 }
1445}
1446
1447static void
1448gs_window_dialog_finish (GSWindow *window)
1449{
1450 g_return_if_fail (GS_IS_WINDOW (window))do{ (void)0; }while (0);
1451
1452 gs_debug ("Dialog finished")gs_debug_real (__func__, "gs-window-x11.c", 1452, "Dialog finished"
)
;
1453
1454 /* make sure we finish the keyboard thing too */
1455 keyboard_command_finish (window);
1456
1457 /* send a signal just in case */
1458 kill_dialog_command (window);
1459
1460 if (window->priv->lock_pid > 0)
1461 {
1462 wait_on_child (window->priv->lock_pid);
1463
1464 g_spawn_close_pid (window->priv->lock_pid);
1465 window->priv->lock_pid = 0;
1466 }
1467
1468 /* remove events for the case were we failed to show socket */
1469 remove_key_events (window);
1470}
1471
1472static void
1473maybe_kill_dialog (GSWindow *window)
1474{
1475 if (!window->priv->dialog_shake_in_progress
1476 && window->priv->dialog_quit_requested
1477 && window->priv->lock_pid > 0)
1478 {
1479 kill (window->priv->lock_pid, SIGTERM15);
1480 }
1481}
1482
1483/* very rudimentary animation for indicating an auth failure */
1484static void
1485shake_dialog (GSWindow *window)
1486{
1487 int i;
1488 guint start, end;
1489
1490 window->priv->dialog_shake_in_progress = TRUE(!(0));
1491
1492 for (i = 0; i < 8; i++)
1493 {
1494 if (i % 2 == 0)
1495 {
1496 start = 30;
1497 end = 0;
1498 }
1499 else
1500 {
1501 start = 0;
1502 end = 30;
1503 }
1504
1505 if (! window->priv->lock_box)
1506 {
1507 break;
1508 }
1509
1510 gtk_widget_set_margin_start (GTK_WIDGET (window->priv->lock_box)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->lock_box)), ((gtk_widget_get_type ()
))))))
,
1511 start);
1512 gtk_widget_set_margin_end (GTK_WIDGET (window->priv->lock_box)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->lock_box)), ((gtk_widget_get_type ()
))))))
,
1513 end);
1514
1515 while (gtk_events_pending ())
1516 {
1517 gtk_main_iteration ();
1518 }
1519
1520 g_usleep (10000);
1521 }
1522
1523 window->priv->dialog_shake_in_progress = FALSE(0);
1524 maybe_kill_dialog (window);
1525}
1526
1527static void
1528window_set_dialog_up (GSWindow *window,
1529 gboolean dialog_up)
1530{
1531 if (window->priv->dialog_up == dialog_up)
1532 {
1533 return;
1534 }
1535
1536 window->priv->dialog_up = (dialog_up != FALSE(0));
1537 g_object_notify (G_OBJECT (window)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), (((GType) ((20) << (2))))))))
, "dialog-up");
1538}
1539
1540static void
1541popdown_dialog (GSWindow *window)
1542{
1543 gs_window_dialog_finish (window);
1544
1545 gtk_widget_show (window->priv->drawing_area);
1546
1547 gs_window_clear (window);
1548 set_invisible_cursor (gtk_widget_get_window (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
), TRUE(!(0)));
1549
1550 window_set_dialog_up (window, FALSE(0));
1551
1552 /* reset the pointer positions */
1553 window->priv->last_x = -1;
1554 window->priv->last_y = -1;
1555
1556 if (window->priv->lock_box != NULL((void*)0))
1557 {
1558 gtk_container_remove (GTK_CONTAINER (window->priv->vbox)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->vbox)), ((gtk_container_get_type ())
)))))
, GTK_WIDGET (window->priv->lock_box)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->lock_box)), ((gtk_widget_get_type ()
))))))
);
1559 window->priv->lock_box = NULL((void*)0);
1560 }
1561
1562 remove_popup_dialog_idle (window);
1563 remove_command_watches (window);
1564}
1565
1566static gboolean
1567lock_command_watch (GIOChannel *source,
1568 GIOCondition condition,
1569 GSWindow *window)
1570{
1571 gboolean finished = FALSE(0);
1572
1573 g_return_val_if_fail (GS_IS_WINDOW (window), FALSE)do{ (void)0; }while (0);
1574
1575 if (condition & G_IO_IN)
1576 {
1577 GIOStatus status;
1578 GError *error = NULL((void*)0);
1579 char *line;
1580
1581 line = NULL((void*)0);
1582 status = g_io_channel_read_line (source, &line, NULL((void*)0), NULL((void*)0), &error);
1583
1584 switch (status)
1585 {
1586 case G_IO_STATUS_NORMAL:
1587 gs_debug ("command output: %s", line)gs_debug_real (__func__, "gs-window-x11.c", 1587, "command output: %s"
, line)
;
1588
1589 if (strstr (line, "WINDOW ID=") != NULL((void*)0))
1590 {
1591 guint32 id;
1592 char c;
1593 if (1 == sscanf (line, " WINDOW ID= %" G_GUINT32_FORMAT"u" " %c", &id, &c))
1594 {
1595 create_lock_socket (window, id);
1596 }
1597 }
1598 else if (strstr (line, "NOTICE=") != NULL((void*)0))
1599 {
1600 if (strstr (line, "NOTICE=AUTH FAILED") != NULL((void*)0))
1601 {
1602 shake_dialog (window);
1603 }
1604 }
1605 else if (strstr (line, "RESPONSE=") != NULL((void*)0))
1606 {
1607 if (strstr (line, "RESPONSE=OK") != NULL((void*)0))
1608 {
1609 gs_debug ("Got OK response")gs_debug_real (__func__, "gs-window-x11.c", 1609, "Got OK response"
)
;
1610 window->priv->dialog_response = DIALOG_RESPONSE_OK;
1611 }
1612 else
1613 {
1614 gs_debug ("Got CANCEL response")gs_debug_real (__func__, "gs-window-x11.c", 1614, "Got CANCEL response"
)
;
1615 window->priv->dialog_response = DIALOG_RESPONSE_CANCEL;
1616 }
1617 finished = TRUE(!(0));
1618 }
1619 else if (strstr (line, "REQUEST QUIT") != NULL((void*)0))
1620 {
1621 gs_debug ("Got request for quit")gs_debug_real (__func__, "gs-window-x11.c", 1621, "Got request for quit"
)
;
1622 window->priv->dialog_quit_requested = TRUE(!(0));
1623 maybe_kill_dialog (window);
1624 }
1625 break;
1626 case G_IO_STATUS_EOF:
1627 finished = TRUE(!(0));
1628 break;
1629 case G_IO_STATUS_ERROR:
1630 finished = TRUE(!(0));
1631 gs_debug ("Error reading from child: %s\n", error->message)gs_debug_real (__func__, "gs-window-x11.c", 1631, "Error reading from child: %s\n"
, error->message)
;
1632 g_error_free (error);
1633 return FALSE(0);
1634 case G_IO_STATUS_AGAIN:
1635 default:
1636 break;
1637 }
1638
1639 g_free (line);
1640 }
1641 else if (condition & G_IO_HUP)
1642 {
1643 finished = TRUE(!(0));
1644 }
1645
1646 if (finished)
1647 {
1648 popdown_dialog (window);
1649
1650 if (window->priv->dialog_response == DIALOG_RESPONSE_OK)
1651 {
1652 add_emit_deactivated_idle (window);
1653 }
1654
1655 window->priv->lock_watch_id = 0;
1656
1657 return FALSE(0);
1658 }
1659
1660 return TRUE(!(0));
1661}
1662
1663static gboolean
1664is_logout_enabled (GSWindow *window)
1665{
1666 double elapsed;
1667
1668 if (! window->priv->logout_enabled)
1669 {
1670 return FALSE(0);
1671 }
1672
1673 if (! window->priv->logout_command)
1674 {
1675 return FALSE(0);
1676 }
1677
1678 elapsed = g_timer_elapsed (window->priv->timer, NULL((void*)0));
1679
1680 if (window->priv->logout_timeout < (elapsed * 1000))
1681 {
1682 return TRUE(!(0));
1683 }
1684
1685 return FALSE(0);
1686}
1687
1688static gboolean
1689is_user_switch_enabled (GSWindow *window)
1690{
1691 return window->priv->user_switch_enabled;
1692}
1693
1694static void
1695popup_dialog (GSWindow *window)
1696{
1697 gboolean result;
1698 GString *command;
1699
1700 gs_debug ("Popping up dialog")gs_debug_real (__func__, "gs-window-x11.c", 1700, "Popping up dialog"
)
;
1701
1702 command = g_string_new (MATE_SCREENSAVER_DIALOG_PATH"/usr/local/libexec" "/mate-screensaver-dialog");
1703
1704 if (is_logout_enabled (window))
1705 {
1706 command = g_string_append (command, " --enable-logout");
1707 g_string_append_printf (command, " --logout-command='%s'", window->priv->logout_command);
1708 }
1709
1710 if (window->priv->status_message)
1711 {
1712 char *quoted;
1713
1714 quoted = g_shell_quote (window->priv->status_message);
1715 g_string_append_printf (command, " --status-message=%s", quoted);
1716 g_free (quoted);
1717 }
1718
1719 if (is_user_switch_enabled (window))
1720 {
1721 command = g_string_append (command, " --enable-switch");
1722 }
1723
1724 if (gs_debug_enabled ())
1725 {
1726 command = g_string_append (command, " --verbose");
1727 }
1728
1729 gtk_widget_hide (window->priv->drawing_area);
1730
1731 gtk_widget_queue_draw (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
);
1732 set_invisible_cursor (gtk_widget_get_window (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
), FALSE(0));
1733
1734 window->priv->dialog_quit_requested = FALSE(0);
1735 window->priv->dialog_shake_in_progress = FALSE(0);
1736
1737 result = spawn_on_window (window,
1738 command->str,
1739 &window->priv->lock_pid,
1740 (GIOFunc)lock_command_watch,
1741 window,
1742 &window->priv->lock_watch_id);
1743 if (! result)
1744 {
1745 gs_debug ("Could not start command: %s", command->str)gs_debug_real (__func__, "gs-window-x11.c", 1745, "Could not start command: %s"
, command->str)
;
1746 }
1747
1748 g_string_free (command, TRUE(!(0)));
1749}
1750
1751static gboolean
1752popup_dialog_idle (gpointer data)
1753{
1754 GSWindow *window = data;
1755
1756 popup_dialog (window);
1757 window->priv->popup_dialog_idle_id = 0;
1758 return FALSE(0);
1759}
1760
1761void
1762gs_window_request_unlock (GSWindow *window)
1763{
1764 g_return_if_fail (GS_IS_WINDOW (window))do{ (void)0; }while (0);
1765
1766 gs_debug ("Requesting unlock")gs_debug_real (__func__, "gs-window-x11.c", 1766, "Requesting unlock"
)
;
1767
1768 if (! gtk_widget_get_visible (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
))
1769 {
1770 gs_debug ("Request unlock but window is not visible!")gs_debug_real (__func__, "gs-window-x11.c", 1770, "Request unlock but window is not visible!"
)
;
1771 return;
1772 }
1773
1774 if (window->priv->lock_watch_id > 0)
1775 {
1776 return;
1777 }
1778
1779 if (! window->priv->lock_enabled)
1780 {
1781 add_emit_deactivated_idle (window);
1782
1783 return;
1784 }
1785
1786 if (window->priv->popup_dialog_idle_id == 0)
1787 {
1788 add_popup_dialog_idle (window);
1789 }
1790
1791 window_set_dialog_up (window, TRUE(!(0)));
1792}
1793
1794void
1795gs_window_cancel_unlock_request (GSWindow *window)
1796{
1797 /* FIXME: This is a bit of a hammer approach...
1798 * Maybe we should send a delete-event to
1799 * the plug?
1800 */
1801 g_return_if_fail (GS_IS_WINDOW (window))do{ (void)0; }while (0);
1802
1803 popdown_dialog (window);
1804}
1805
1806void
1807gs_window_set_lock_enabled (GSWindow *window,
1808 gboolean lock_enabled)
1809{
1810 g_return_if_fail (GS_IS_WINDOW (window))do{ (void)0; }while (0);
1811
1812 if (window->priv->lock_enabled == lock_enabled)
1813 {
1814 return;
1815 }
1816
1817 window->priv->lock_enabled = (lock_enabled != FALSE(0));
1818 g_object_notify (G_OBJECT (window)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), (((GType) ((20) << (2))))))))
, "lock-enabled");
1819}
1820
1821GdkDisplay *
1822gs_window_get_display (GSWindow *window)
1823{
1824 g_return_val_if_fail (GS_IS_WINDOW (window), NULL)do{ (void)0; }while (0);
1825
1826 return gtk_widget_get_display (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
);
1827}
1828
1829void
1830gs_window_set_keyboard_enabled (GSWindow *window,
1831 gboolean enabled)
1832{
1833 g_return_if_fail (GS_IS_WINDOW (window))do{ (void)0; }while (0);
1834
1835 window->priv->keyboard_enabled = (enabled != FALSE(0));
1836}
1837
1838void
1839gs_window_set_keyboard_command (GSWindow *window,
1840 const char *command)
1841{
1842 g_return_if_fail (GS_IS_WINDOW (window))do{ (void)0; }while (0);
1843
1844 g_free (window->priv->keyboard_command);
1845
1846 if (command != NULL((void*)0))
1847 {
1848 window->priv->keyboard_command = g_strdup (command);
1849 }
1850 else
1851 {
1852 window->priv->keyboard_command = NULL((void*)0);
1853 }
1854}
1855
1856void
1857gs_window_set_logout_enabled (GSWindow *window,
1858 gboolean logout_enabled)
1859{
1860 g_return_if_fail (GS_IS_WINDOW (window))do{ (void)0; }while (0);
1861
1862 window->priv->logout_enabled = (logout_enabled != FALSE(0));
1863}
1864
1865void
1866gs_window_set_user_switch_enabled (GSWindow *window,
1867 gboolean user_switch_enabled)
1868{
1869 g_return_if_fail (GS_IS_WINDOW (window))do{ (void)0; }while (0);
1870
1871 window->priv->user_switch_enabled = (user_switch_enabled != FALSE(0));
1872}
1873
1874void
1875gs_window_set_logout_timeout (GSWindow *window,
1876 glong logout_timeout)
1877{
1878 g_return_if_fail (GS_IS_WINDOW (window))do{ (void)0; }while (0);
1879
1880 if (logout_timeout < 0)
1881 {
1882 window->priv->logout_timeout = 0;
1883 }
1884 else
1885 {
1886 window->priv->logout_timeout = logout_timeout;
1887 }
1888}
1889
1890void
1891gs_window_set_logout_command (GSWindow *window,
1892 const char *command)
1893{
1894 g_return_if_fail (GS_IS_WINDOW (window))do{ (void)0; }while (0);
1895
1896 g_free (window->priv->logout_command);
1897
1898 if (command)
1899 {
1900 window->priv->logout_command = g_strdup (command);
1901 }
1902 else
1903 {
1904 window->priv->logout_command = NULL((void*)0);
1905 }
1906}
1907
1908void
1909gs_window_set_status_message (GSWindow *window,
1910 const char *status_message)
1911{
1912 g_return_if_fail (GS_IS_WINDOW (window))do{ (void)0; }while (0);
1913
1914 g_free (window->priv->status_message);
1915 window->priv->status_message = g_strdup (status_message);
1916}
1917
1918void
1919gs_window_set_monitor (GSWindow *window,
1920 GdkMonitor *monitor)
1921{
1922 g_return_if_fail (GS_IS_WINDOW (window))do{ (void)0; }while (0);
1923
1924 if (window->priv->monitor == monitor)
1925 {
1926 return;
1927 }
1928
1929 window->priv->monitor = monitor;
1930
1931 gtk_widget_queue_resize (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
);
1932
1933 g_object_notify (G_OBJECT (window)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), (((GType) ((20) << (2))))))))
, "monitor");
1934}
1935
1936GdkMonitor *
1937gs_window_get_monitor (GSWindow *window)
1938{
1939 g_return_val_if_fail (GS_IS_WINDOW (window), NULL)do{ (void)0; }while (0);
1940
1941 return window->priv->monitor;
1942}
1943
1944static void
1945gs_window_set_property (GObject *object,
1946 guint prop_id,
1947 const GValue *value,
1948 GParamSpec *pspec)
1949{
1950 GSWindow *self;
1951
1952 self = GS_WINDOW (object)((((GSWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((gs_window_get_type ()))))))
;
1953
1954 switch (prop_id)
1955 {
1956 case PROP_LOCK_ENABLED:
1957 gs_window_set_lock_enabled (self, g_value_get_boolean (value));
1958 break;
1959 case PROP_KEYBOARD_ENABLED:
1960 gs_window_set_keyboard_enabled (self, g_value_get_boolean (value));
1961 break;
1962 case PROP_KEYBOARD_COMMAND:
1963 gs_window_set_keyboard_command (self, g_value_get_string (value));
1964 break;
1965 case PROP_LOGOUT_ENABLED:
1966 gs_window_set_logout_enabled (self, g_value_get_boolean (value));
1967 break;
1968 case PROP_LOGOUT_COMMAND:
1969 gs_window_set_logout_command (self, g_value_get_string (value));
1970 break;
1971 case PROP_STATUS_MESSAGE:
1972 gs_window_set_status_message (self, g_value_get_string (value));
1973 break;
1974 case PROP_LOGOUT_TIMEOUT:
1975 gs_window_set_logout_timeout (self, g_value_get_long (value));
1976 break;
1977 case PROP_MONITOR:
1978 gs_window_set_monitor (self, g_value_get_pointer (value));
1979 break;
1980 default:
1981 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec)do { GObject *_glib__object = (GObject*) ((object)); GParamSpec
*_glib__pspec = (GParamSpec*) ((pspec)); guint _glib__property_id
= ((prop_id)); g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'"
, "gs-window-x11.c", 1981, ("property"), _glib__property_id, _glib__pspec
->name, g_type_name ((((((GTypeClass*) (((GTypeInstance*) (
_glib__pspec))->g_class))->g_type)))), (g_type_name (((
(((GTypeClass*) (((GTypeInstance*) (_glib__object))->g_class
))->g_type)))))); } while (0)
;
1982 break;
1983 }
1984}
1985
1986static void
1987gs_window_get_property (GObject *object,
1988 guint prop_id,
1989 GValue *value,
1990 GParamSpec *pspec)
1991{
1992 GSWindow *self;
1993
1994 self = GS_WINDOW (object)((((GSWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((gs_window_get_type ()))))))
;
1995
1996 switch (prop_id)
1997 {
1998 case PROP_LOCK_ENABLED:
1999 g_value_set_boolean (value, self->priv->lock_enabled);
2000 break;
2001 case PROP_KEYBOARD_ENABLED:
2002 g_value_set_boolean (value, self->priv->keyboard_enabled);
2003 break;
2004 case PROP_KEYBOARD_COMMAND:
2005 g_value_set_string (value, self->priv->keyboard_command);
2006 break;
2007 case PROP_LOGOUT_ENABLED:
2008 g_value_set_boolean (value, self->priv->logout_enabled);
2009 break;
2010 case PROP_LOGOUT_COMMAND:
2011 g_value_set_string (value, self->priv->logout_command);
2012 break;
2013 case PROP_STATUS_MESSAGE:
2014 g_value_set_string (value, self->priv->status_message);
2015 break;
2016 case PROP_LOGOUT_TIMEOUT:
2017 g_value_set_long (value, self->priv->logout_timeout);
2018 break;
2019 case PROP_MONITOR:
2020 g_value_set_pointer (value, (gpointer) self->priv->monitor);
2021 break;
2022 case PROP_OBSCURED:
2023 g_value_set_boolean (value, self->priv->obscured);
2024 break;
2025 case PROP_DIALOG_UP:
2026 g_value_set_boolean (value, self->priv->dialog_up);
2027 break;
2028 default:
2029 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec)do { GObject *_glib__object = (GObject*) ((object)); GParamSpec
*_glib__pspec = (GParamSpec*) ((pspec)); guint _glib__property_id
= ((prop_id)); g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'"
, "gs-window-x11.c", 2029, ("property"), _glib__property_id, _glib__pspec
->name, g_type_name ((((((GTypeClass*) (((GTypeInstance*) (
_glib__pspec))->g_class))->g_type)))), (g_type_name (((
(((GTypeClass*) (((GTypeInstance*) (_glib__object))->g_class
))->g_type)))))); } while (0)
;
2030 break;
2031 }
2032}
2033
2034static void
2035queue_key_event (GSWindow *window,
2036 GdkEventKey *event)
2037{
2038 /* Eat the first return, enter, escape, or space */
2039 if (window->priv->key_events == NULL((void*)0)
2040 && (event->keyval == GDK_KEY_Return0xff0d
2041 || event->keyval == GDK_KEY_KP_Enter0xff8d
2042 || event->keyval == GDK_KEY_Escape0xff1b
2043 || event->keyval == GDK_KEY_space0x020))
2044 {
2045 return;
2046 }
2047
2048 /* Only cache MAX_QUEUED_EVENTS key events. If there are any more than this then
2049 something is wrong */
2050 /* Don't queue keys that may cause focus navigation in the dialog */
2051 if (g_list_length (window->priv->key_events) < MAX_QUEUED_EVENTS16
2052 && event->keyval != GDK_KEY_Tab0xff09
2053 && event->keyval != GDK_KEY_Up0xff52
2054 && event->keyval != GDK_KEY_Down0xff54)
2055 {
2056 window->priv->key_events = g_list_prepend (window->priv->key_events,
2057 gdk_event_copy ((GdkEvent *)event));
2058 }
2059}
2060
2061static gboolean
2062maybe_handle_activity (GSWindow *window)
2063{
2064 gboolean handled;
2065
2066 handled = FALSE(0);
2067
2068 /* if we already have a socket then don't bother */
2069 if (! window->priv->lock_socket
2070 && gtk_widget_get_sensitive (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
))
2071 {
2072 g_signal_emit (window, signals [ACTIVITY], 0, &handled);
2073 }
2074
2075 return handled;
2076}
2077
2078static gboolean
2079gs_window_real_key_press_event (GtkWidget *widget,
2080 GdkEventKey *event)
2081{
2082 /*g_message ("KEY PRESS state: %u keyval %u", event->state, event->keyval);*/
2083
2084 /* Ignore brightness keys */
2085 if (event->hardware_keycode == 101 || event->hardware_keycode == 212)
2086 {
2087 gs_debug ("Ignoring brightness keys")gs_debug_real (__func__, "gs-window-x11.c", 2087, "Ignoring brightness keys"
)
;
2088 return TRUE(!(0));
2089 }
2090
2091 maybe_handle_activity (GS_WINDOW (widget)((((GSWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gs_window_get_type ()))))))
);
2092
2093 queue_key_event (GS_WINDOW (widget)((((GSWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gs_window_get_type ()))))))
, event);
2094
2095 if (GTK_WIDGET_CLASS (gs_window_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((gs_window_parent_class)), ((gtk_widget_get_type ()))))))
->key_press_event)
2096 {
2097 GTK_WIDGET_CLASS (gs_window_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((gs_window_parent_class)), ((gtk_widget_get_type ()))))))
->key_press_event (widget, event);
2098 }
2099
2100 return TRUE(!(0));
2101}
2102
2103static gboolean
2104gs_window_real_motion_notify_event (GtkWidget *widget,
2105 GdkEventMotion *event)
2106{
2107 GSWindow *window;
2108 gdouble distance;
2109 gdouble min_distance;
2110 gdouble min_percentage = 0.1;
2111 GdkDisplay *display;
2112 GdkScreen *screen;
2113
2114 window = GS_WINDOW (widget)((((GSWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gs_window_get_type ()))))))
;
2115
2116 display = gs_window_get_display (window);
2117 screen = gdk_display_get_default_screen (display);
2118 min_distance = WidthOfScreen (gdk_x11_screen_get_xscreen (screen))((gdk_x11_screen_get_xscreen (screen))->width) * min_percentage;
2119
2120 /* if the last position was not set then don't detect motion */
2121 if (window->priv->last_x < 0 || window->priv->last_y < 0)
2122 {
2123 window->priv->last_x = event->x;
2124 window->priv->last_y = event->y;
2125
2126 return FALSE(0);
2127 }
2128
2129 /* just an approximate distance */
2130 distance = MAX (ABS (window->priv->last_x - event->x),((((((window->priv->last_x - event->x) < 0) ? -(window
->priv->last_x - event->x) : (window->priv->last_x
- event->x))) > ((((window->priv->last_y - event
->y) < 0) ? -(window->priv->last_y - event->y)
: (window->priv->last_y - event->y)))) ? ((((window
->priv->last_x - event->x) < 0) ? -(window->priv
->last_x - event->x) : (window->priv->last_x - event
->x))) : ((((window->priv->last_y - event->y) <
0) ? -(window->priv->last_y - event->y) : (window->
priv->last_y - event->y))))
2131 ABS (window->priv->last_y - event->y))((((((window->priv->last_x - event->x) < 0) ? -(window
->priv->last_x - event->x) : (window->priv->last_x
- event->x))) > ((((window->priv->last_y - event
->y) < 0) ? -(window->priv->last_y - event->y)
: (window->priv->last_y - event->y)))) ? ((((window
->priv->last_x - event->x) < 0) ? -(window->priv
->last_x - event->x) : (window->priv->last_x - event
->x))) : ((((window->priv->last_y - event->y) <
0) ? -(window->priv->last_y - event->y) : (window->
priv->last_y - event->y))))
;
2132
2133 if (distance > min_distance)
2134 {
2135 maybe_handle_activity (window);
2136
2137 window->priv->last_x = -1;
2138 window->priv->last_y = -1;
2139 }
2140
2141 return FALSE(0);
2142}
2143
2144static gboolean
2145gs_window_real_button_press_event (GtkWidget *widget,
2146 GdkEventButton *event)
2147{
2148 GSWindow *window;
2149
2150 window = GS_WINDOW (widget)((((GSWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gs_window_get_type ()))))))
;
2151 maybe_handle_activity (window);
2152
2153 return FALSE(0);
2154}
2155
2156static gboolean
2157gs_window_real_scroll_event (GtkWidget *widget,
2158 GdkEventScroll *event)
2159{
2160 GSWindow *window;
2161
2162 window = GS_WINDOW (widget)((((GSWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gs_window_get_type ()))))))
;
2163 maybe_handle_activity (window);
2164
2165 return FALSE(0);
2166}
2167
2168static void
2169gs_window_real_size_request (GtkWidget *widget,
2170 GtkRequisition *requisition)
2171{
2172 GSWindow *window;
2173 GtkBin *bin;
2174 GtkWidget *child;
2175 GdkRectangle old_geometry;
2176 int position_changed = FALSE(0);
2177 int size_changed = FALSE(0);
2178
2179 window = GS_WINDOW (widget)((((GSWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gs_window_get_type ()))))))
;
2180 bin = GTK_BIN (widget)((((GtkBin*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_bin_get_type ()))))))
;
2181 child = gtk_bin_get_child (bin);
2182
2183 if (child && gtk_widget_get_visible (child))
2184 {
2185 gtk_widget_get_preferred_size (child, requisition, NULL((void*)0));
2186 }
2187
2188 old_geometry = window->priv->geometry;
2189
2190 update_geometry (window);
2191
2192 requisition->width = window->priv->geometry.width;
2193 requisition->height = window->priv->geometry.height;
2194
2195 if (! gtk_widget_get_realized (widget))
2196 {
2197 return;
2198 }
2199
2200 if (old_geometry.width != window->priv->geometry.width ||
2201 old_geometry.height != window->priv->geometry.height)
2202 {
2203 size_changed = TRUE(!(0));
2204 }
2205
2206 if (old_geometry.x != window->priv->geometry.x ||
2207 old_geometry.y != window->priv->geometry.y)
2208 {
2209 position_changed = TRUE(!(0));
2210 }
2211
2212 gs_window_move_resize_window (window, position_changed, size_changed);
2213}
2214
2215static void
2216gs_window_real_get_preferred_width (GtkWidget *widget,
2217 gint *minimal_width,
2218 gint *natural_width)
2219{
2220 GtkRequisition requisition;
2221 gs_window_real_size_request (widget, &requisition);
2222 *minimal_width = *natural_width = requisition.width;
2223}
2224
2225static void
2226gs_window_real_get_preferred_height (GtkWidget *widget,
2227 gint *minimal_height,
2228 gint *natural_height)
2229{
2230 GtkRequisition requisition;
2231 gs_window_real_size_request (widget, &requisition);
2232 *minimal_height = *natural_height = requisition.height;
2233}
2234
2235static gboolean
2236gs_window_real_grab_broken (GtkWidget *widget,
2237 GdkEventGrabBroken *event)
2238{
2239 if (event->grab_window != NULL((void*)0))
2240 {
2241 gs_debug ("Grab broken on window %X %s, new grab on window %X",gs_debug_real (__func__, "gs-window-x11.c", 2244, "Grab broken on window %X %s, new grab on window %X"
, (guint32) (gdk_x11_window_get_xid (event->window)), event
->keyboard ? "keyboard" : "pointer", (guint32) (gdk_x11_window_get_xid
(event->grab_window)))
2242 (guint32) GDK_WINDOW_XID (event->window),gs_debug_real (__func__, "gs-window-x11.c", 2244, "Grab broken on window %X %s, new grab on window %X"
, (guint32) (gdk_x11_window_get_xid (event->window)), event
->keyboard ? "keyboard" : "pointer", (guint32) (gdk_x11_window_get_xid
(event->grab_window)))
2243 event->keyboard ? "keyboard" : "pointer",gs_debug_real (__func__, "gs-window-x11.c", 2244, "Grab broken on window %X %s, new grab on window %X"
, (guint32) (gdk_x11_window_get_xid (event->window)), event
->keyboard ? "keyboard" : "pointer", (guint32) (gdk_x11_window_get_xid
(event->grab_window)))
2244 (guint32) GDK_WINDOW_XID (event->grab_window))gs_debug_real (__func__, "gs-window-x11.c", 2244, "Grab broken on window %X %s, new grab on window %X"
, (guint32) (gdk_x11_window_get_xid (event->window)), event
->keyboard ? "keyboard" : "pointer", (guint32) (gdk_x11_window_get_xid
(event->grab_window)))
;
2245 }
2246 else
2247 {
2248 gs_debug ("Grab broken on window %X %s, new grab is outside application",gs_debug_real (__func__, "gs-window-x11.c", 2250, "Grab broken on window %X %s, new grab is outside application"
, (guint32) (gdk_x11_window_get_xid (event->window)), event
->keyboard ? "keyboard" : "pointer")
2249 (guint32) GDK_WINDOW_XID (event->window),gs_debug_real (__func__, "gs-window-x11.c", 2250, "Grab broken on window %X %s, new grab is outside application"
, (guint32) (gdk_x11_window_get_xid (event->window)), event
->keyboard ? "keyboard" : "pointer")
2250 event->keyboard ? "keyboard" : "pointer")gs_debug_real (__func__, "gs-window-x11.c", 2250, "Grab broken on window %X %s, new grab is outside application"
, (guint32) (gdk_x11_window_get_xid (event->window)), event
->keyboard ? "keyboard" : "pointer")
;
2251 }
2252
2253 return FALSE(0);
2254}
2255
2256gboolean
2257gs_window_is_obscured (GSWindow *window)
2258{
2259 g_return_val_if_fail (GS_IS_WINDOW (window), FALSE)do{ (void)0; }while (0);
2260
2261 return window->priv->obscured;
2262}
2263
2264gboolean
2265gs_window_is_dialog_up (GSWindow *window)
2266{
2267 g_return_val_if_fail (GS_IS_WINDOW (window), FALSE)do{ (void)0; }while (0);
2268
2269 return window->priv->dialog_up;
2270}
2271
2272static void
2273window_set_obscured (GSWindow *window,
2274 gboolean obscured)
2275{
2276 if (window->priv->obscured == obscured)
2277 {
2278 return;
2279 }
2280
2281 window->priv->obscured = (obscured != FALSE(0));
2282 g_object_notify (G_OBJECT (window)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), (((GType) ((20) << (2))))))))
, "obscured");
2283}
2284
2285static gboolean
2286gs_window_real_visibility_notify_event (GtkWidget *widget,
2287 GdkEventVisibility *event)
2288{
2289 switch (event->state)
2290 {
2291 case GDK_VISIBILITY_FULLY_OBSCURED:
2292 window_set_obscured (GS_WINDOW (widget)((((GSWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gs_window_get_type ()))))))
, TRUE(!(0)));
2293 break;
2294 case GDK_VISIBILITY_PARTIAL:
2295 break;
2296 case GDK_VISIBILITY_UNOBSCURED:
2297 window_set_obscured (GS_WINDOW (widget)((((GSWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gs_window_get_type ()))))))
, FALSE(0));
2298 break;
2299 default:
2300 break;
2301 }
2302
2303 return FALSE(0);
2304}
2305
2306static void
2307gs_window_class_init (GSWindowClass *klass)
2308{
2309 GObjectClass *object_class = G_OBJECT_CLASS (klass)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((klass)), (((GType) ((20) << (2))))))))
;
2310 GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((klass)), ((gtk_widget_get_type ()))))))
;
2311
2312 object_class->finalize = gs_window_finalize;
2313 object_class->get_property = gs_window_get_property;
2314 object_class->set_property = gs_window_set_property;
2315
2316 widget_class->show = gs_window_real_show;
2317 widget_class->hide = gs_window_real_hide;
2318 widget_class->draw = gs_window_real_draw;
2319 widget_class->realize = gs_window_real_realize;
2320 widget_class->unrealize = gs_window_real_unrealize;
2321 widget_class->key_press_event = gs_window_real_key_press_event;
2322 widget_class->motion_notify_event = gs_window_real_motion_notify_event;
2323 widget_class->button_press_event = gs_window_real_button_press_event;
2324 widget_class->scroll_event = gs_window_real_scroll_event;
2325 widget_class->get_preferred_width = gs_window_real_get_preferred_width;
2326 widget_class->get_preferred_height = gs_window_real_get_preferred_height;
2327 widget_class->grab_broken_event = gs_window_real_grab_broken;
2328 widget_class->visibility_notify_event = gs_window_real_visibility_notify_event;
2329
2330 signals [ACTIVITY] =
2331 g_signal_new ("activity",
2332 G_TYPE_FROM_CLASS (object_class)(((GTypeClass*) (object_class))->g_type),
2333 G_SIGNAL_RUN_LAST,
2334 G_STRUCT_OFFSET (GSWindowClass, activity)((glong) __builtin_offsetof(GSWindowClass, activity)),
2335 NULL((void*)0),
2336 NULL((void*)0),
2337 gs_marshal_BOOLEAN__VOID,
2338 G_TYPE_BOOLEAN((GType) ((5) << (2))),
2339 0);
2340 signals [DEACTIVATED] =
2341 g_signal_new ("deactivated",
2342 G_TYPE_FROM_CLASS (object_class)(((GTypeClass*) (object_class))->g_type),
2343 G_SIGNAL_RUN_LAST,
2344 G_STRUCT_OFFSET (GSWindowClass, deactivated)((glong) __builtin_offsetof(GSWindowClass, deactivated)),
2345 NULL((void*)0),
2346 NULL((void*)0),
2347 g_cclosure_marshal_VOID__VOID,
2348 G_TYPE_NONE((GType) ((1) << (2))),
2349 0);
2350
2351 g_object_class_install_property (object_class,
2352 PROP_OBSCURED,
2353 g_param_spec_boolean ("obscured",
2354 NULL((void*)0),
2355 NULL((void*)0),
2356 FALSE(0),
2357 G_PARAM_READABLE));
2358 g_object_class_install_property (object_class,
2359 PROP_DIALOG_UP,
2360 g_param_spec_boolean ("dialog-up",
2361 NULL((void*)0),
2362 NULL((void*)0),
2363 FALSE(0),
2364 G_PARAM_READABLE));
2365 g_object_class_install_property (object_class,
2366 PROP_LOCK_ENABLED,
2367 g_param_spec_boolean ("lock-enabled",
2368 NULL((void*)0),
2369 NULL((void*)0),
2370 FALSE(0),
2371 G_PARAM_READWRITE));
2372 g_object_class_install_property (object_class,
2373 PROP_LOGOUT_ENABLED,
2374 g_param_spec_boolean ("logout-enabled",
2375 NULL((void*)0),
2376 NULL((void*)0),
2377 FALSE(0),
2378 G_PARAM_READWRITE));
2379 g_object_class_install_property (object_class,
2380 PROP_LOGOUT_TIMEOUT,
2381 g_param_spec_long ("logout-timeout",
2382 NULL((void*)0),
2383 NULL((void*)0),
2384 -1,
2385 G_MAXLONG9223372036854775807L,
2386 0,
2387 G_PARAM_READWRITE));
2388 g_object_class_install_property (object_class,
2389 PROP_LOGOUT_COMMAND,
2390 g_param_spec_string ("logout-command",
2391 NULL((void*)0),
2392 NULL((void*)0),
2393 NULL((void*)0),
2394 G_PARAM_READWRITE));
2395 g_object_class_install_property (object_class,
2396 PROP_STATUS_MESSAGE,
2397 g_param_spec_string ("status-message",
2398 NULL((void*)0),
2399 NULL((void*)0),
2400 NULL((void*)0),
2401 G_PARAM_READWRITE));
2402 g_object_class_install_property (object_class,
2403 PROP_KEYBOARD_ENABLED,
2404 g_param_spec_boolean ("keyboard-enabled",
2405 NULL((void*)0),
2406 NULL((void*)0),
2407 FALSE(0),
2408 G_PARAM_READWRITE));
2409 g_object_class_install_property (object_class,
2410 PROP_KEYBOARD_COMMAND,
2411 g_param_spec_string ("keyboard-command",
2412 NULL((void*)0),
2413 NULL((void*)0),
2414 NULL((void*)0),
2415 G_PARAM_READWRITE));
2416
2417 g_object_class_install_property (object_class,
2418 PROP_MONITOR,
2419 g_param_spec_pointer ("monitor",
2420 "Gdk monitor",
2421 "The monitor (in terms of Gdk) which the window is on",
2422 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
2423}
2424
2425static void
2426create_info_bar (GSWindow *window)
2427{
2428 window->priv->info_bar = gtk_info_bar_new ();
2429 gtk_widget_set_no_show_all (window->priv->info_bar, TRUE(!(0)));
2430 gtk_box_pack_end (GTK_BOX (window->priv->vbox)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->vbox)), ((gtk_box_get_type ()))))))
, window->priv->info_bar, FALSE(0), FALSE(0), 0);
2431}
2432
2433static gboolean
2434on_drawing_area_draw (GtkWidget *widget,
2435 cairo_t *cr)
2436{
2437 cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
2438 cairo_set_source_rgb (cr, 0, 0, 0);
2439 cairo_paint (cr);
2440
2441 return FALSE(0);
2442}
2443
2444static void
2445gs_window_init (GSWindow *window)
2446{
2447 window->priv = gs_window_get_instance_private (window);
2448
2449 window->priv->geometry.x = -1;
2450 window->priv->geometry.y = -1;
2451 window->priv->geometry.width = -1;
2452 window->priv->geometry.height = -1;
2453
2454 window->priv->last_x = -1;
2455 window->priv->last_y = -1;
2456
2457 gtk_window_set_decorated (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
, FALSE(0));
2458
2459 gtk_window_set_skip_taskbar_hint (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
, TRUE(!(0)));
2460 gtk_window_set_skip_pager_hint (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
, TRUE(!(0)));
2461
2462 gtk_window_set_keep_above (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
, TRUE(!(0)));
2463
2464 gtk_window_fullscreen (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
);
2465
2466 gtk_widget_set_events (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
,
2467 gtk_widget_get_events (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
)
2468 | GDK_POINTER_MOTION_MASK
2469 | GDK_BUTTON_PRESS_MASK
2470 | GDK_BUTTON_RELEASE_MASK
2471 | GDK_KEY_PRESS_MASK
2472 | GDK_KEY_RELEASE_MASK
2473 | GDK_EXPOSURE_MASK
2474 | GDK_VISIBILITY_NOTIFY_MASK
2475 | GDK_ENTER_NOTIFY_MASK
2476 | GDK_LEAVE_NOTIFY_MASK);
2477
2478 window->priv->vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
2479 gtk_widget_show (window->priv->vbox);
2480 gtk_container_add (GTK_CONTAINER (window)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_container_get_type ()))))))
, window->priv->vbox);
2481
2482 window->priv->drawing_area = gtk_drawing_area_new ();
2483 gtk_widget_show (window->priv->drawing_area);
2484 gtk_widget_set_app_paintable (window->priv->drawing_area, TRUE(!(0)));
2485 gtk_box_pack_start (GTK_BOX (window->priv->vbox)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->vbox)), ((gtk_box_get_type ()))))))
,
2486 window->priv->drawing_area, TRUE(!(0)), TRUE(!(0)), 0);
2487 g_signal_connect (window->priv->drawing_area,g_signal_connect_data ((window->priv->drawing_area), ("draw"
), (((GCallback) (on_drawing_area_draw))), (((void*)0)), ((void
*)0), (GConnectFlags) 0)
2488 "draw",g_signal_connect_data ((window->priv->drawing_area), ("draw"
), (((GCallback) (on_drawing_area_draw))), (((void*)0)), ((void
*)0), (GConnectFlags) 0)
2489 G_CALLBACK (on_drawing_area_draw),g_signal_connect_data ((window->priv->drawing_area), ("draw"
), (((GCallback) (on_drawing_area_draw))), (((void*)0)), ((void
*)0), (GConnectFlags) 0)
2490 NULL)g_signal_connect_data ((window->priv->drawing_area), ("draw"
), (((GCallback) (on_drawing_area_draw))), (((void*)0)), ((void
*)0), (GConnectFlags) 0)
;
2491 create_info_bar (window);
2492
2493}
2494
2495static void
2496remove_command_watches (GSWindow *window)
2497{
2498 if (window->priv->lock_watch_id != 0)
2499 {
2500 g_source_remove (window->priv->lock_watch_id);
2501 window->priv->lock_watch_id = 0;
2502 }
2503 if (window->priv->keyboard_watch_id != 0)
2504 {
2505 g_source_remove (window->priv->keyboard_watch_id);
2506 window->priv->keyboard_watch_id = 0;
2507 }
2508}
2509
2510static void
2511gs_window_finalize (GObject *object)
2512{
2513 GSWindow *window;
2514
2515 g_return_if_fail (object != NULL)do{ (void)0; }while (0);
2516 g_return_if_fail (GS_IS_WINDOW (object))do{ (void)0; }while (0);
2517
2518 window = GS_WINDOW (object)((((GSWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((gs_window_get_type ()))))))
;
2519
2520 g_return_if_fail (window->priv != NULL)do{ (void)0; }while (0);
2521
2522 g_free (window->priv->logout_command);
2523 g_free (window->priv->keyboard_command);
2524
2525 if (window->priv->info_bar_timer_id > 0)
2526 {
2527 g_source_remove (window->priv->info_bar_timer_id);
2528 window->priv->info_bar_timer_id = 0;
2529 }
2530
2531 remove_watchdog_timer (window);
2532 remove_popup_dialog_idle (window);
2533
2534 if (window->priv->timer)
2535 {
2536 g_timer_destroy (window->priv->timer);
2537 }
2538
2539 remove_key_events (window);
2540
2541 remove_command_watches (window);
2542
2543 gs_window_dialog_finish (window);
2544
2545 if (window->priv->background_surface)
2546 {
2547 cairo_surface_destroy (window->priv->background_surface);
2548 }
2549
2550 G_OBJECT_CLASS (gs_window_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((gs_window_parent_class)), (((GType) ((20) << (2)))
)))))
->finalize (object);
2551}
2552
2553GSWindow *
2554gs_window_new (GdkMonitor *monitor,
2555 gboolean lock_enabled)
2556{
2557 GObject *result;
2558 GdkDisplay *display = gdk_monitor_get_display (monitor);
2559 GdkScreen *screen = gdk_display_get_default_screen (display);
2560
2561 result = g_object_new (GS_TYPE_WINDOW(gs_window_get_type ()),
2562 "type", GTK_WINDOW_POPUP,
2563 "screen", screen,
2564 "monitor", monitor,
2565 "lock-enabled", lock_enabled,
2566 "app-paintable", TRUE(!(0)),
2567 NULL((void*)0));
2568
2569 return GS_WINDOW (result)((((GSWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((result)), ((gs_window_get_type ()))))))
;
2570}
diff --git a/2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-e0169c.html b/2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-e0169c.html new file mode 100644 index 0000000..b859680 --- /dev/null +++ b/2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-e0169c.html @@ -0,0 +1,3250 @@ + + + +gs-window-x11.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rc/gs-window-x11.c
Warning:line 1630, column 4
Value stored to 'finished' is never read
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name gs-window-x11.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/14.0.5 -D HAVE_CONFIG_H -I . -I .. -I . -I . -D MATEMENU_I_KNOW_THIS_IS_UNSTABLE -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/dconf -I /usr/include/mate-menus -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/dconf -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/dconf -I /usr/include/mate-menus -D PREFIX="/usr/local" -D BINDIR="/usr/local/bin" -D LIBDIR="/usr/local/lib" -D LIBEXECDIR="/usr/local/libexec" -D DATADIR="/usr/local/share" -D SYSCONFDIR="/usr/local/etc" -D MATELOCALEDIR="/usr/local/share/locale" -D PKGLIBEXECDIR="/usr/local/libexec/mate-screensaver" -D SAVERDIR="/usr/local/libexec/mate-screensaver" -D THEMESDIR="/usr/local/share/mate-screensaver/themes" -D GTKBUILDERDIR="/usr/local/share/mate-screensaver" -D MATE_SCREENSAVER_GL_HELPER_PATH="/usr/local/libexec/mate-screensaver-gl-helper" -D PAM_SERVICE_NAME="mate-screensaver" -D G_DISABLE_ASSERT -D G_DISABLE_CHECKS -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -internal-isystem /usr/lib64/clang/14.0.5/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/12/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2022-11-11-203102-6531-1 -x c gs-window-x11.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
2 *
3 * Copyright (C) 2004-2008 William Jon McCann <mccann@jhu.edu>
4 * Copyright (C) 2012-2021 MATE Developers
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
19 *
20 * Authors: William Jon McCann <mccann@jhu.edu>
21 *
22 */
23
24#include "config.h"
25
26#include <sys/types.h>
27#include <errno(*__errno_location ()).h>
28#include <sys/wait.h>
29#include <string.h>
30
31#include <gdk/gdkx.h>
32#include <gdk/gdkkeysyms.h>
33#include <gtk/gtk.h>
34#include <gtk/gtkx.h>
35
36#include "gs-window.h"
37#include "gs-marshal.h"
38#include "subprocs.h"
39#include "gs-debug.h"
40
41#ifdef HAVE_SHAPE_EXT1
42#include <X11/extensions/shape.h>
43#endif
44
45static void gs_window_finalize (GObject *object);
46
47static gboolean popup_dialog_idle (gpointer data);
48static void gs_window_dialog_finish (GSWindow *window);
49static void remove_command_watches (GSWindow *window);
50
51enum
52{
53 DIALOG_RESPONSE_CANCEL,
54 DIALOG_RESPONSE_OK
55};
56
57#define MAX_QUEUED_EVENTS16 16
58#define INFO_BAR_SECONDS30 30
59#define MATE_SCREENSAVER_DIALOG_PATH"/usr/local/libexec" "/mate-screensaver-dialog" LIBEXECDIR"/usr/local/libexec" "/mate-screensaver-dialog"
60
61struct GSWindowPrivate
62{
63 GdkMonitor *monitor;
64
65 GdkRectangle geometry;
66 guint obscured : 1;
67 guint dialog_up : 1;
68
69 guint lock_enabled : 1;
70 guint user_switch_enabled : 1;
71 guint logout_enabled : 1;
72 guint keyboard_enabled : 1;
73
74 guint64 logout_timeout;
75 char *logout_command;
76 char *keyboard_command;
77 char *status_message;
78
79 GtkWidget *vbox;
80 GtkWidget *drawing_area;
81 GtkWidget *lock_box;
82 GtkWidget *lock_socket;
83 GtkWidget *keyboard_socket;
84 GtkWidget *info_bar;
85 GtkWidget *info_content;
86
87 cairo_surface_t *background_surface;
88
89 guint popup_dialog_idle_id;
90
91 guint dialog_map_signal_id;
92 guint dialog_unmap_signal_id;
93 guint dialog_response_signal_id;
94
95 guint watchdog_timer_id;
96 guint info_bar_timer_id;
97
98 gint lock_pid;
99 gint lock_watch_id;
100 gint dialog_response;
101 gboolean dialog_quit_requested;
102 gboolean dialog_shake_in_progress;
103
104 gint keyboard_pid;
105 gint keyboard_watch_id;
106
107 GList *key_events;
108
109 gdouble last_x;
110 gdouble last_y;
111
112 GTimer *timer;
113
114#ifdef HAVE_SHAPE_EXT1
115 int shape_event_base;
116#endif
117};
118
119enum
120{
121 ACTIVITY,
122 DEACTIVATED,
123 LAST_SIGNAL
124};
125
126enum
127{
128 PROP_0,
129 PROP_OBSCURED,
130 PROP_DIALOG_UP,
131 PROP_LOCK_ENABLED,
132 PROP_LOGOUT_ENABLED,
133 PROP_KEYBOARD_ENABLED,
134 PROP_KEYBOARD_COMMAND,
135 PROP_LOGOUT_COMMAND,
136 PROP_LOGOUT_TIMEOUT,
137 PROP_MONITOR,
138 PROP_STATUS_MESSAGE
139};
140
141static guint signals [LAST_SIGNAL] = { 0, };
142
143G_DEFINE_TYPE_WITH_PRIVATE (GSWindow, gs_window, GTK_TYPE_WINDOW)static void gs_window_init (GSWindow *self); static void gs_window_class_init
(GSWindowClass *klass); static GType gs_window_get_type_once
(void); static gpointer gs_window_parent_class = ((void*)0);
static gint GSWindow_private_offset; static void gs_window_class_intern_init
(gpointer klass) { gs_window_parent_class = g_type_class_peek_parent
(klass); if (GSWindow_private_offset != 0) g_type_class_adjust_private_offset
(klass, &GSWindow_private_offset); gs_window_class_init (
(GSWindowClass*) klass); } __attribute__ ((__unused__)) static
inline gpointer gs_window_get_instance_private (GSWindow *self
) { return (((gpointer) ((guint8*) (self) + (glong) (GSWindow_private_offset
)))); } GType gs_window_get_type (void) { static gsize static_g_define_type_id
= 0; if ((__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); (void
) (0 ? (gpointer) *(&static_g_define_type_id) : ((void*)0
)); (!(__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); __typeof__
(*(&static_g_define_type_id)) gapg_temp_newval; __typeof__
((&static_g_define_type_id)) gapg_temp_atomic = (&static_g_define_type_id
); __atomic_load (gapg_temp_atomic, &gapg_temp_newval, 5)
; gapg_temp_newval; })) && g_once_init_enter (&static_g_define_type_id
)); }))) { GType g_define_type_id = gs_window_get_type_once (
); (__extension__ ({ _Static_assert (sizeof *(&static_g_define_type_id
) == sizeof (gpointer), "Expression evaluates to false"); 0 ?
(void) (*(&static_g_define_type_id) = (g_define_type_id)
) : (void) 0; g_once_init_leave ((&static_g_define_type_id
), (gsize) (g_define_type_id)); })); } return static_g_define_type_id
; } __attribute__ ((__noinline__)) static GType gs_window_get_type_once
(void) { GType g_define_type_id = g_type_register_static_simple
((gtk_window_get_type ()), g_intern_static_string ("GSWindow"
), sizeof (GSWindowClass), (GClassInitFunc)(void (*)(void)) gs_window_class_intern_init
, sizeof (GSWindow), (GInstanceInitFunc)(void (*)(void)) gs_window_init
, (GTypeFlags) 0); { {{ GSWindow_private_offset = g_type_add_instance_private
(g_define_type_id, sizeof (GSWindowPrivate)); };} } return g_define_type_id
; }
144
145static void
146set_invisible_cursor (GdkWindow *window,
147 gboolean invisible)
148{
149 GdkDisplay *display;
150 GdkCursor *cursor = NULL((void*)0);
151
152 if (invisible)
153 {
154 display = gdk_window_get_display (window);
155 cursor = gdk_cursor_new_for_display (display, GDK_BLANK_CURSOR);
156 }
157
158 gdk_window_set_cursor (window, cursor);
159
160 if (cursor)
161 {
162 g_object_unref (cursor);
163 }
164}
165
166/* derived from tomboy */
167static void
168gs_window_override_user_time (GSWindow *window)
169{
170 guint32 ev_time = gtk_get_current_event_time ();
171
172 if (ev_time == 0)
173 {
174 gint ev_mask = gtk_widget_get_events (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
);
175 if (!(ev_mask & GDK_PROPERTY_CHANGE_MASK))
176 {
177 gtk_widget_add_events (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
,
178 GDK_PROPERTY_CHANGE_MASK);
179 }
180
181 /*
182 * NOTE: Last resort for D-BUS or other non-interactive
183 * openings. Causes roundtrip to server. Lame.
184 */
185 ev_time = gdk_x11_get_server_time (gtk_widget_get_window (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
));
186 }
187
188 gdk_x11_window_set_user_time (gtk_widget_get_window (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
), ev_time);
189}
190
191static void
192clear_children (Window window)
193{
194 Window root;
195 Window parent;
196 Window *children;
197 unsigned int n_children;
198 int status;
199
200 children = NULL((void*)0);
201 status = XQueryTree (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ())(gdk_x11_display_get_xdisplay (gdk_display_get_default ())), window, &root, &parent, &children, &n_children);
202
203 if (status == 0)
204 {
205 if (children)
206 {
207 XFree (children);
208 }
209 return;
210 }
211
212 if (children)
213 {
214 while (n_children)
215 {
216 Window child;
217
218 child = children [--n_children];
219
220 XClearWindow (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ())(gdk_x11_display_get_xdisplay (gdk_display_get_default ())), child);
221
222 clear_children (child);
223 }
224
225 XFree (children);
226 }
227}
228
229static void
230widget_clear_all_children (GtkWidget *widget)
231{
232 GdkWindow *w;
233 GdkDisplay *display;
234
235 gs_debug ("Clearing all child windows")gs_debug_real (__func__, "gs-window-x11.c", 235, "Clearing all child windows"
)
;
236 display = gtk_widget_get_display (widget);
237
238 gdk_x11_display_error_trap_push (display);
239
240 w = gtk_widget_get_window (widget);
241
242 clear_children (GDK_WINDOW_XID (w)(gdk_x11_window_get_xid (w)));
243
244 gdk_x11_display_error_trap_pop_ignored (display);
245
246}
247
248void
249gs_window_set_background_surface (GSWindow *window,
250 cairo_surface_t *surface)
251{
252 g_return_if_fail (GS_IS_WINDOW (window))do{ (void)0; }while (0);
253
254 if (window->priv->background_surface != NULL((void*)0))
255 {
256 cairo_surface_destroy (window->priv->background_surface);
257 }
258 window->priv->background_surface = NULL((void*)0);
259
260 if (surface != NULL((void*)0))
261 {
262 window->priv->background_surface = cairo_surface_reference (surface);
263 }
264
265 gtk_widget_queue_draw (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
);
266}
267
268void
269gs_window_clear (GSWindow *window)
270{
271 GdkDisplay *display;
272 g_return_if_fail (GS_IS_WINDOW (window))do{ (void)0; }while (0);
273
274 gs_debug ("Clearing widgets")gs_debug_real (__func__, "gs-window-x11.c", 274, "Clearing widgets"
)
;
275
276 if (gtk_widget_get_realized (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
))
277 {
278 gtk_widget_queue_draw (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
);
279 /* If a screensaver theme adds child windows
280 we need to clear them too */
281 widget_clear_all_children (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
);
282 }
283
284 if (gtk_widget_get_realized (window->priv->drawing_area))
285 {
286 gtk_widget_queue_draw (window->priv->drawing_area);
287 widget_clear_all_children (window->priv->drawing_area);
288 }
289
290 display = gtk_widget_get_display (GTK_WIDGET(window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
);
291 gdk_display_flush (display);
292}
293
294static cairo_region_t *
295get_outside_region (GSWindow *window)
296{
297 GdkDisplay *display;
298 int i;
299 int num_monitors;
300 cairo_region_t *region;
301
302 display = gtk_widget_get_display (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
);
303
304 region = cairo_region_create ();
305
306 num_monitors = gdk_display_get_n_monitors (display);
307 for (i = 0; i < num_monitors; i++)
308 {
309 GdkMonitor *mon = gdk_display_get_monitor (display, i);
310
311 if (mon != window->priv->monitor)
312 {
313 GdkRectangle geometry;
314 cairo_rectangle_int_t rectangle;
315
316 gdk_monitor_get_geometry (mon, &geometry);
317 rectangle.x = geometry.x;
318 rectangle.y = geometry.y;
319 rectangle.width = geometry.width;
320 rectangle.height = geometry.height;
321 cairo_region_union_rectangle (region, &rectangle);
322 }
323 else
324 {
325 break;
326 }
327 }
328
329 return region;
330}
331
332static void
333update_geometry (GSWindow *window)
334{
335 GdkRectangle geometry;
336 cairo_region_t *outside_region;
337 cairo_region_t *monitor_region;
338
339 outside_region = get_outside_region (window);
340
341 gdk_monitor_get_geometry (window->priv->monitor, &geometry);
342 gs_debug ("got geometry for monitor: x=%d y=%d w=%d h=%d",gs_debug_real (__func__, "gs-window-x11.c", 346, "got geometry for monitor: x=%d y=%d w=%d h=%d"
, geometry.x, geometry.y, geometry.width, geometry.height)
343 geometry.x,gs_debug_real (__func__, "gs-window-x11.c", 346, "got geometry for monitor: x=%d y=%d w=%d h=%d"
, geometry.x, geometry.y, geometry.width, geometry.height)
344 geometry.y,gs_debug_real (__func__, "gs-window-x11.c", 346, "got geometry for monitor: x=%d y=%d w=%d h=%d"
, geometry.x, geometry.y, geometry.width, geometry.height)
345 geometry.width,gs_debug_real (__func__, "gs-window-x11.c", 346, "got geometry for monitor: x=%d y=%d w=%d h=%d"
, geometry.x, geometry.y, geometry.width, geometry.height)
346 geometry.height)gs_debug_real (__func__, "gs-window-x11.c", 346, "got geometry for monitor: x=%d y=%d w=%d h=%d"
, geometry.x, geometry.y, geometry.width, geometry.height)
;
347 monitor_region = cairo_region_create_rectangle ((const cairo_rectangle_int_t *)&geometry);
348 cairo_region_subtract (monitor_region, outside_region);
349 cairo_region_destroy (outside_region);
350
351 cairo_region_get_extents (monitor_region, (cairo_rectangle_int_t *)&geometry);
352 cairo_region_destroy (monitor_region);
353
354 gs_debug ("using geometry for monitor: x=%d y=%d w=%d h=%d",gs_debug_real (__func__, "gs-window-x11.c", 358, "using geometry for monitor: x=%d y=%d w=%d h=%d"
, geometry.x, geometry.y, geometry.width, geometry.height)
355 geometry.x,gs_debug_real (__func__, "gs-window-x11.c", 358, "using geometry for monitor: x=%d y=%d w=%d h=%d"
, geometry.x, geometry.y, geometry.width, geometry.height)
356 geometry.y,gs_debug_real (__func__, "gs-window-x11.c", 358, "using geometry for monitor: x=%d y=%d w=%d h=%d"
, geometry.x, geometry.y, geometry.width, geometry.height)
357 geometry.width,gs_debug_real (__func__, "gs-window-x11.c", 358, "using geometry for monitor: x=%d y=%d w=%d h=%d"
, geometry.x, geometry.y, geometry.width, geometry.height)
358 geometry.height)gs_debug_real (__func__, "gs-window-x11.c", 358, "using geometry for monitor: x=%d y=%d w=%d h=%d"
, geometry.x, geometry.y, geometry.width, geometry.height)
;
359
360 window->priv->geometry.x = geometry.x;
361 window->priv->geometry.y = geometry.y;
362 window->priv->geometry.width = geometry.width;
363 window->priv->geometry.height = geometry.height;
364}
365
366static void
367monitor_geometry_notify (GdkMonitor *monitor,
368 GParamSpec *pspec,
369 GSWindow *window)
370{
371 gs_debug ("Got monitor geometry notify signal")gs_debug_real (__func__, "gs-window-x11.c", 371, "Got monitor geometry notify signal"
)
;
372 gtk_widget_queue_resize (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
);
373}
374
375/* copied from panel-toplevel.c */
376static void
377gs_window_move_resize_window (GSWindow *window,
378 gboolean move,
379 gboolean resize)
380{
381 GtkWidget *widget;
382 GdkWindow *gdkwindow;
383
384 widget = GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
;
385 gdkwindow = gtk_widget_get_window (widget);
386
387 g_assert (gtk_widget_get_realized (widget))do { (void) 0; } while (0);
388
389 gs_debug ("Move and/or resize window: x=%d y=%d w=%d h=%d",gs_debug_real (__func__, "gs-window-x11.c", 393, "Move and/or resize window: x=%d y=%d w=%d h=%d"
, window->priv->geometry.x, window->priv->geometry
.y, window->priv->geometry.width, window->priv->geometry
.height)
390 window->priv->geometry.x,gs_debug_real (__func__, "gs-window-x11.c", 393, "Move and/or resize window: x=%d y=%d w=%d h=%d"
, window->priv->geometry.x, window->priv->geometry
.y, window->priv->geometry.width, window->priv->geometry
.height)
391 window->priv->geometry.y,gs_debug_real (__func__, "gs-window-x11.c", 393, "Move and/or resize window: x=%d y=%d w=%d h=%d"
, window->priv->geometry.x, window->priv->geometry
.y, window->priv->geometry.width, window->priv->geometry
.height)
392 window->priv->geometry.width,gs_debug_real (__func__, "gs-window-x11.c", 393, "Move and/or resize window: x=%d y=%d w=%d h=%d"
, window->priv->geometry.x, window->priv->geometry
.y, window->priv->geometry.width, window->priv->geometry
.height)
393 window->priv->geometry.height)gs_debug_real (__func__, "gs-window-x11.c", 393, "Move and/or resize window: x=%d y=%d w=%d h=%d"
, window->priv->geometry.x, window->priv->geometry
.y, window->priv->geometry.width, window->priv->geometry
.height)
;
394
395 if (move && resize)
396 {
397 gdk_window_move_resize (gdkwindow,
398 window->priv->geometry.x,
399 window->priv->geometry.y,
400 window->priv->geometry.width,
401 window->priv->geometry.height);
402 }
403 else if (move)
404 {
405 gdk_window_move (gdkwindow,
406 window->priv->geometry.x,
407 window->priv->geometry.y);
408 }
409 else if (resize)
410 {
411 gdk_window_resize (gdkwindow,
412 window->priv->geometry.width,
413 window->priv->geometry.height);
414 }
415}
416
417static void
418gs_window_real_unrealize (GtkWidget *widget)
419{
420 GdkMonitor *monitor = GS_WINDOW (widget)((((GSWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gs_window_get_type ()))))))
->priv->monitor;
421
422 g_signal_handlers_disconnect_by_func (monitor, monitor_geometry_notify,g_signal_handlers_disconnect_matched ((monitor), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (monitor_geometry_notify), (widget))
423 widget)g_signal_handlers_disconnect_matched ((monitor), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (monitor_geometry_notify), (widget))
;
424
425 if (GTK_WIDGET_CLASS (gs_window_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((gs_window_parent_class)), ((gtk_widget_get_type ()))))))
->unrealize)
426 {
427 GTK_WIDGET_CLASS (gs_window_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((gs_window_parent_class)), ((gtk_widget_get_type ()))))))
->unrealize (widget);
428 }
429}
430
431/* copied from gdk */
432extern char **environ;
433
434static gchar **
435spawn_make_environment_for_display (GdkDisplay *display,
436 gchar **envp)
437{
438 gchar **retval = NULL((void*)0);
439 const gchar *display_name;
440 gint display_index = -1;
441 gint i, env_len;
442
443 g_return_val_if_fail (GDK_IS_DISPLAY (display), NULL)do{ (void)0; }while (0);
444
445 if (envp == NULL((void*)0))
446 envp = environ;
447
448 for (env_len = 0; envp[env_len]; env_len++)
449 if (strncmp (envp[env_len], "DISPLAY", strlen ("DISPLAY")) == 0)
450 display_index = env_len;
451
452 retval = g_new (char *, env_len + 1)((char * *) g_malloc_n ((env_len + 1), sizeof (char *)));
453 retval[env_len] = NULL((void*)0);
454
455 display_name = gdk_display_get_name (display);
456
457 for (i = 0; i < env_len; i++)
458 if (i == display_index)
459 retval[i] = g_strconcat ("DISPLAY=", display_name, NULL((void*)0));
460 else
461 retval[i] = g_strdup (envp[i]);
462
463 g_assert (i == env_len)do { (void) 0; } while (0);
464
465 return retval;
466}
467
468static gboolean
469spawn_command_line_on_display_sync (GdkDisplay *display,
470 const gchar *command_line,
471 char **standard_output,
472 char **standard_error,
473 int *exit_status,
474 GError **error)
475{
476 char **argv = NULL((void*)0);
477 char **envp = NULL((void*)0);
478 gboolean retval;
479
480 g_return_val_if_fail (command_line != NULL, FALSE)do{ (void)0; }while (0);
481
482 if (! g_shell_parse_argv (command_line, NULL((void*)0), &argv, error))
483 {
484 return FALSE(0);
485 }
486
487 envp = spawn_make_environment_for_display (display, NULL((void*)0));
488
489 retval = g_spawn_sync (NULL((void*)0),
490 argv,
491 envp,
492 G_SPAWN_SEARCH_PATH,
493 NULL((void*)0),
494 NULL((void*)0),
495 standard_output,
496 standard_error,
497 exit_status,
498 error);
499
500 g_strfreev (argv);
501 g_strfreev (envp);
502
503 return retval;
504}
505
506static GdkVisual *
507get_best_visual_for_display (GdkDisplay *display)
508{
509 GdkScreen *screen;
510 char *std_output;
511 int exit_status;
512 GError *error;
513 unsigned long v;
514 char c;
515 GdkVisual *visual;
516 gboolean res;
517
518 visual = NULL((void*)0);
519 screen = gdk_display_get_default_screen (display);
520
521 error = NULL((void*)0);
522 std_output = NULL((void*)0);
523 res = spawn_command_line_on_display_sync (display,
524 MATE_SCREENSAVER_GL_HELPER_PATH"/usr/local/libexec/mate-screensaver-gl-helper",
525 &std_output,
526 NULL((void*)0),
527 &exit_status,
528 &error);
529 if (! res)
530 {
531 gs_debug ("Could not run command '%s': %s",gs_debug_real (__func__, "gs-window-x11.c", 532, "Could not run command '%s': %s"
, "/usr/local/libexec/mate-screensaver-gl-helper", error->
message)
532 MATE_SCREENSAVER_GL_HELPER_PATH, error->message)gs_debug_real (__func__, "gs-window-x11.c", 532, "Could not run command '%s': %s"
, "/usr/local/libexec/mate-screensaver-gl-helper", error->
message)
;
533 g_error_free (error);
534 goto out;
535 }
536
537 if (1 == sscanf (std_output, "0x%lx %c", &v, &c))
538 {
539 if (v != 0)
540 {
541 VisualID visual_id;
542
543 visual_id = (VisualID) v;
544 visual = gdk_x11_screen_lookup_visual (screen, visual_id);
545
546 gs_debug ("Found best GL visual for display %s: 0x%x",gs_debug_real (__func__, "gs-window-x11.c", 548, "Found best GL visual for display %s: 0x%x"
, gdk_display_get_name (display), (unsigned int) visual_id)
547 gdk_display_get_name (display),gs_debug_real (__func__, "gs-window-x11.c", 548, "Found best GL visual for display %s: 0x%x"
, gdk_display_get_name (display), (unsigned int) visual_id)
548 (unsigned int) visual_id)gs_debug_real (__func__, "gs-window-x11.c", 548, "Found best GL visual for display %s: 0x%x"
, gdk_display_get_name (display), (unsigned int) visual_id)
;
549 }
550 }
551out:
552 g_free (std_output);
553
554 return g_object_ref (visual)((__typeof__ (visual)) (g_object_ref) (visual));
555}
556
557static void
558widget_set_best_visual (GtkWidget *widget)
559{
560 GdkVisual *visual;
561
562 g_return_if_fail (widget != NULL)do{ (void)0; }while (0);
563
564 visual = get_best_visual_for_display (gtk_widget_get_display (widget));
565 if (visual != NULL((void*)0))
566 {
567 gtk_widget_set_visual (widget, visual);
568 g_object_unref (visual);
569 }
570}
571
572static void
573gs_window_real_realize (GtkWidget *widget)
574{
575 GdkMonitor *monitor = GS_WINDOW (widget)((((GSWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gs_window_get_type ()))))))
->priv->monitor;
576
577 widget_set_best_visual (widget);
578
579 if (GTK_WIDGET_CLASS (gs_window_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((gs_window_parent_class)), ((gtk_widget_get_type ()))))))
->realize)
580 {
581 GTK_WIDGET_CLASS (gs_window_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((gs_window_parent_class)), ((gtk_widget_get_type ()))))))
->realize (widget);
582 }
583
584 gs_window_override_user_time (GS_WINDOW (widget)((((GSWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gs_window_get_type ()))))))
);
585
586 gs_window_move_resize_window (GS_WINDOW (widget)((((GSWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gs_window_get_type ()))))))
, TRUE(!(0)), TRUE(!(0)));
587
588 g_signal_connect (monitor,g_signal_connect_data ((monitor), ("notify::geometry"), (((GCallback
) (monitor_geometry_notify))), (widget), ((void*)0), (GConnectFlags
) 0)
589 "notify::geometry",g_signal_connect_data ((monitor), ("notify::geometry"), (((GCallback
) (monitor_geometry_notify))), (widget), ((void*)0), (GConnectFlags
) 0)
590 G_CALLBACK (monitor_geometry_notify),g_signal_connect_data ((monitor), ("notify::geometry"), (((GCallback
) (monitor_geometry_notify))), (widget), ((void*)0), (GConnectFlags
) 0)
591 widget)g_signal_connect_data ((monitor), ("notify::geometry"), (((GCallback
) (monitor_geometry_notify))), (widget), ((void*)0), (GConnectFlags
) 0)
;
592}
593
594/* every so often we should raise the window in case
595 another window has somehow gotten on top */
596static gboolean
597watchdog_timer (GSWindow *window)
598{
599 GtkWidget *widget = GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
;
600
601 gdk_window_focus (gtk_widget_get_window (widget), GDK_CURRENT_TIME0L);
602
603 return TRUE(!(0));
604}
605
606static void
607remove_watchdog_timer (GSWindow *window)
608{
609 if (window->priv->watchdog_timer_id != 0)
610 {
611 g_source_remove (window->priv->watchdog_timer_id);
612 window->priv->watchdog_timer_id = 0;
613 }
614}
615
616static void
617add_watchdog_timer (GSWindow *window,
618 guint timeout)
619{
620 window->priv->watchdog_timer_id = g_timeout_add (timeout,
621 (GSourceFunc)watchdog_timer,
622 window);
623}
624
625static void
626remove_popup_dialog_idle (GSWindow *window)
627{
628 if (window->priv->popup_dialog_idle_id != 0)
629 {
630 g_source_remove (window->priv->popup_dialog_idle_id);
631 window->priv->popup_dialog_idle_id = 0;
632 }
633}
634
635static void
636add_popup_dialog_idle (GSWindow *window)
637{
638 window->priv->popup_dialog_idle_id = g_idle_add (popup_dialog_idle, window);
639}
640
641static gboolean
642emit_deactivated_idle (GSWindow *window)
643{
644 g_signal_emit (window, signals [DEACTIVATED], 0);
645
646 return FALSE(0);
647}
648
649static void
650add_emit_deactivated_idle (GSWindow *window)
651{
652 g_idle_add ((GSourceFunc)emit_deactivated_idle, window);
653}
654
655static void
656gs_window_raise (GSWindow *window)
657{
658 GdkWindow *win;
659
660 g_return_if_fail (GS_IS_WINDOW (window))do{ (void)0; }while (0);
661
662 gs_debug ("Raising screensaver window")gs_debug_real (__func__, "gs-window-x11.c", 662, "Raising screensaver window"
)
;
663
664 win = gtk_widget_get_window (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
);
665
666 gdk_window_raise (win);
667}
668
669static gboolean
670x11_window_is_ours (Window window)
671{
672 GdkWindow *gwindow;
673 gboolean ret;
674
675 ret = FALSE(0);
676
677 gwindow = gdk_x11_window_lookup_for_display (gdk_display_get_default (), window);
678 if (gwindow && (window != GDK_ROOT_WINDOW ()(gdk_x11_get_default_root_xwindow ())))
679 {
680 ret = TRUE(!(0));
681 }
682
683 return ret;
684}
685
686#ifdef HAVE_SHAPE_EXT1
687static void
688unshape_window (GSWindow *window)
689{
690 gdk_window_shape_combine_region (gtk_widget_get_window (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
),
691 NULL((void*)0),
692 0,
693 0);
694}
695#endif
696
697static void
698gs_window_xevent (GSWindow *window,
699 GdkXEvent *xevent)
700{
701 XEvent *ev;
702
703 ev = xevent;
704
705 /* MapNotify is used to tell us when new windows are mapped.
706 ConfigureNofify is used to tell us when windows are raised. */
707 switch (ev->xany.type)
708 {
709 case MapNotify19:
710 {
711 XMapEvent *xme = &ev->xmap;
712
713 if (! x11_window_is_ours (xme->window))
714 {
715 gs_window_raise (window);
716 }
717 else
718 {
719 gs_debug ("not raising our windows")gs_debug_real (__func__, "gs-window-x11.c", 719, "not raising our windows"
)
;
720 }
721
722 break;
723 }
724 case ConfigureNotify22:
725 {
726 XConfigureEvent *xce = &ev->xconfigure;
727
728 if (! x11_window_is_ours (xce->window))
729 {
730 gs_window_raise (window);
731 }
732 else
733 {
734 gs_debug ("not raising our windows")gs_debug_real (__func__, "gs-window-x11.c", 734, "not raising our windows"
)
;
735 }
736
737 break;
738 }
739 default:
740 /* extension events */
741#ifdef HAVE_SHAPE_EXT1
742 if (ev->xany.type == (window->priv->shape_event_base + ShapeNotify0))
743 {
744 /*XShapeEvent *xse = (XShapeEvent *) ev;*/
745 unshape_window (window);
746 gs_debug ("Window was reshaped!")gs_debug_real (__func__, "gs-window-x11.c", 746, "Window was reshaped!"
)
;
747 }
748#endif
749
750 break;
751 }
752
753}
754
755static GdkFilterReturn
756xevent_filter (GdkXEvent *xevent,
757 GdkEvent *event,
758 GSWindow *window)
759{
760 gs_window_xevent (window, xevent);
761
762 return GDK_FILTER_CONTINUE;
763}
764
765static void
766select_popup_events (void)
767{
768 XWindowAttributes attr;
769 unsigned long events;
770 GdkDisplay *display;
771
772 display = gdk_display_get_default ();
773
774 gdk_x11_display_error_trap_push (display);
775
776 memset (&attr, 0, sizeof (attr));
777 XGetWindowAttributes (GDK_DISPLAY_XDISPLAY (display)(gdk_x11_display_get_xdisplay (display)), GDK_ROOT_WINDOW ()(gdk_x11_get_default_root_xwindow ()), &attr);
778
779 events = SubstructureNotifyMask(1L<<19) | attr.your_event_mask;
780 XSelectInput (GDK_DISPLAY_XDISPLAY (display)(gdk_x11_display_get_xdisplay (display)), GDK_ROOT_WINDOW ()(gdk_x11_get_default_root_xwindow ()), events);
781
782 gdk_x11_display_error_trap_pop_ignored (display);
783}
784
785static void
786window_select_shape_events (GSWindow *window)
787{
788#ifdef HAVE_SHAPE_EXT1
789 unsigned long events;
790 int shape_error_base;
791 GdkDisplay *display;
792
793 display = gtk_widget_get_display (GTK_WIDGET(window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
);
794
795 gdk_x11_display_error_trap_push (display);
796
797 if (XShapeQueryExtension (GDK_DISPLAY_XDISPLAY (display)(gdk_x11_display_get_xdisplay (display)), &window->priv->shape_event_base, &shape_error_base)) {
798 events = ShapeNotifyMask(1L << 0);
799 XShapeSelectInput (GDK_DISPLAY_XDISPLAY (display)(gdk_x11_display_get_xdisplay (display)), GDK_WINDOW_XID (gtk_widget_get_window (GTK_WIDGET (window)))(gdk_x11_window_get_xid (gtk_widget_get_window (((((GtkWidget
*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window
)), ((gtk_widget_get_type ())))))))))
, events);
800 }
801
802 gdk_x11_display_error_trap_pop_ignored (display);
803#endif
804}
805
806static gboolean
807gs_window_real_draw (GtkWidget *widget,
808 cairo_t *cr)
809{
810 GSWindow *window = GS_WINDOW (widget)((((GSWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gs_window_get_type ()))))))
;
811 cairo_surface_t *bg_surface = window->priv->background_surface;
812
813 cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
814 if (bg_surface != NULL((void*)0))
815 {
816 cairo_set_source_surface (cr, bg_surface, 0, 0);
817 }
818 else
819 {
820 cairo_set_source_rgb (cr, 0, 0, 0);
821 }
822 cairo_paint (cr);
823
824 return FALSE(0);
825}
826
827static void
828gs_window_real_show (GtkWidget *widget)
829{
830 GSWindow *window;
831
832 if (GTK_WIDGET_CLASS (gs_window_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((gs_window_parent_class)), ((gtk_widget_get_type ()))))))
->show)
833 {
834 GTK_WIDGET_CLASS (gs_window_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((gs_window_parent_class)), ((gtk_widget_get_type ()))))))
->show (widget);
835 }
836
837 gs_window_clear (GS_WINDOW (widget)((((GSWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gs_window_get_type ()))))))
);
838
839 set_invisible_cursor (gtk_widget_get_window (widget), TRUE(!(0)));
840
841 window = GS_WINDOW (widget)((((GSWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gs_window_get_type ()))))))
;
842 if (window->priv->timer)
843 {
844 g_timer_destroy (window->priv->timer);
845 }
846 window->priv->timer = g_timer_new ();
847
848 remove_watchdog_timer (window);
849 add_watchdog_timer (window, 30000);
850
851 select_popup_events ();
852 window_select_shape_events (window);
853 gdk_window_add_filter (NULL((void*)0), (GdkFilterFunc)xevent_filter, window);
854}
855
856static void
857set_info_text_and_icon (GSWindow *window,
858 const char *icon_name,
859 const char *primary_text,
860 const char *secondary_text)
861{
862 GtkWidget *content_area;
863 GtkWidget *hbox_content;
864 GtkWidget *image;
865 GtkWidget *vbox;
866 gchar *primary_markup;
867 gchar *secondary_markup;
868 GtkWidget *primary_label;
869 GtkWidget *secondary_label;
870
871 hbox_content = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 8);
872 gtk_widget_show (hbox_content);
873
874 image = gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_DIALOG);
875 gtk_widget_show (image);
876 gtk_box_pack_start (GTK_BOX (hbox_content)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((hbox_content)), ((gtk_box_get_type ()))))))
, image, FALSE(0), FALSE(0), 0);
877 gtk_widget_set_valign (image, GTK_ALIGN_START);
878
879 vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
880 gtk_widget_show (vbox);
881 gtk_box_pack_start (GTK_BOX (hbox_content)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((hbox_content)), ((gtk_box_get_type ()))))))
, vbox, FALSE(0), FALSE(0), 0);
882
883 primary_markup = g_strdup_printf ("<b>%s</b>", primary_text);
884 primary_label = gtk_label_new (primary_markup);
885 g_free (primary_markup);
886 gtk_widget_show (primary_label);
887 gtk_box_pack_start (GTK_BOX (vbox)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((vbox)), ((gtk_box_get_type ()))))))
, primary_label, TRUE(!(0)), TRUE(!(0)), 0);
888 gtk_label_set_use_markup (GTK_LABEL (primary_label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((primary_label)), ((gtk_label_get_type ()))))))
, TRUE(!(0)));
889 gtk_label_set_line_wrap (GTK_LABEL (primary_label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((primary_label)), ((gtk_label_get_type ()))))))
, TRUE(!(0)));
890 gtk_widget_set_halign (primary_label, GTK_ALIGN_START);
891
892 if (secondary_text != NULL((void*)0))
893 {
894 secondary_markup = g_strdup_printf ("<small>%s</small>",
895 secondary_text);
896 secondary_label = gtk_label_new (secondary_markup);
897 g_free (secondary_markup);
898 gtk_widget_show (secondary_label);
899 gtk_box_pack_start (GTK_BOX (vbox)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((vbox)), ((gtk_box_get_type ()))))))
, secondary_label, TRUE(!(0)), TRUE(!(0)), 0);
900 gtk_label_set_use_markup (GTK_LABEL (secondary_label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((secondary_label)), ((gtk_label_get_type ()))))))
, TRUE(!(0)));
901 gtk_label_set_line_wrap (GTK_LABEL (secondary_label)((((GtkLabel*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((secondary_label)), ((gtk_label_get_type ()))))))
, TRUE(!(0)));
902 gtk_widget_set_halign (secondary_label, GTK_ALIGN_START);
903 }
904
905 /* remove old content */
906 content_area = gtk_info_bar_get_content_area (GTK_INFO_BAR (window->priv->info_bar)((((GtkInfoBar*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->info_bar)), ((gtk_info_bar_get_type(
)))))))
);
907 if (window->priv->info_content != NULL((void*)0))
908 {
909 gtk_container_remove (GTK_CONTAINER (content_area)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((content_area)), ((gtk_container_get_type ()))))))
, window->priv->info_content);
910 }
911 gtk_box_pack_start (GTK_BOX (content_area)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((content_area)), ((gtk_box_get_type ()))))))
,
912 hbox_content,
913 TRUE(!(0)), FALSE(0), 0);
914 window->priv->info_content = hbox_content;
915}
916
917static gboolean
918info_bar_timeout (GSWindow *window)
919{
920 window->priv->info_bar_timer_id = 0;
921 gtk_widget_hide (window->priv->info_bar);
922 return FALSE(0);
923}
924
925void
926gs_window_show_message (GSWindow *window,
927 const char *summary,
928 const char *body,
929 const char *icon)
930{
931 g_return_if_fail (GS_IS_WINDOW (window))do{ (void)0; }while (0);
932
933 set_info_text_and_icon (window,
934 icon,
935 summary,
936 body);
937 gtk_widget_show (window->priv->info_bar);
938
939 if (window->priv->info_bar_timer_id > 0)
940 {
941 g_source_remove (window->priv->info_bar_timer_id);
942 }
943
944 window->priv->info_bar_timer_id = g_timeout_add_seconds (INFO_BAR_SECONDS30,
945 (GSourceFunc)info_bar_timeout,
946 window);
947}
948
949void
950gs_window_show (GSWindow *window)
951{
952 g_return_if_fail (GS_IS_WINDOW (window))do{ (void)0; }while (0);
953
954 gtk_widget_show (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
);
955}
956
957static void
958gs_window_real_hide (GtkWidget *widget)
959{
960 GSWindow *window;
961
962 window = GS_WINDOW (widget)((((GSWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gs_window_get_type ()))))))
;
963
964 gdk_window_remove_filter (NULL((void*)0), (GdkFilterFunc)xevent_filter, window);
965
966 remove_watchdog_timer (window);
967
968 if (GTK_WIDGET_CLASS (gs_window_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((gs_window_parent_class)), ((gtk_widget_get_type ()))))))
->hide)
969 {
970 GTK_WIDGET_CLASS (gs_window_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((gs_window_parent_class)), ((gtk_widget_get_type ()))))))
->hide (widget);
971 }
972}
973
974void
975gs_window_destroy (GSWindow *window)
976{
977 g_return_if_fail (GS_IS_WINDOW (window))do{ (void)0; }while (0);
978
979 gs_window_cancel_unlock_request (window);
980
981 gtk_widget_destroy (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
);
982}
983
984GdkWindow *
985gs_window_get_gdk_window (GSWindow *window)
986{
987 g_return_val_if_fail (GS_IS_WINDOW (window), NULL)do{ (void)0; }while (0);
988
989 return gtk_widget_get_window (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
);
990}
991
992GtkWidget *
993gs_window_get_drawing_area (GSWindow *window)
994{
995 g_return_val_if_fail (GS_IS_WINDOW (window), NULL)do{ (void)0; }while (0);
996
997 return window->priv->drawing_area;
998}
999
1000/* just for debugging */
1001static gboolean
1002error_watch (GIOChannel *source,
1003 GIOCondition condition,
1004 gpointer data)
1005{
1006 gboolean finished = FALSE(0);
1007
1008 if (condition & G_IO_IN)
1009 {
1010 GIOStatus status;
1011 GError *error = NULL((void*)0);
1012 char *line;
1013
1014 line = NULL((void*)0);
1015 status = g_io_channel_read_line (source, &line, NULL((void*)0), NULL((void*)0), &error);
1016
1017 switch (status)
1018 {
1019 case G_IO_STATUS_NORMAL:
1020 gs_debug ("command error output: %s", line)gs_debug_real (__func__, "gs-window-x11.c", 1020, "command error output: %s"
, line)
;
1021 break;
1022 case G_IO_STATUS_EOF:
1023 finished = TRUE(!(0));
1024 break;
1025 case G_IO_STATUS_ERROR:
1026 finished = TRUE(!(0));
1027 gs_debug ("Error reading from child: %s\n", error->message)gs_debug_real (__func__, "gs-window-x11.c", 1027, "Error reading from child: %s\n"
, error->message)
;
1028 g_error_free (error);
1029 return FALSE(0);
1030 case G_IO_STATUS_AGAIN:
1031 default:
1032 break;
1033 }
1034 g_free (line);
1035 }
1036 else if (condition & G_IO_HUP)
1037 {
1038 finished = TRUE(!(0));
1039 }
1040
1041 if (finished)
1042 {
1043 return FALSE(0);
1044 }
1045
1046 return TRUE(!(0));
1047}
1048
1049static gboolean
1050spawn_on_window (GSWindow *window,
1051 char *command,
1052 int *pid,
1053 GIOFunc watch_func,
1054 gpointer user_data,
1055 gint *watch_id)
1056{
1057 int argc;
1058 char **argv;
1059 char **envp;
1060 GError *error;
1061 gboolean result;
1062 GIOChannel *channel;
1063 int standard_output;
1064 int standard_error;
1065 int child_pid;
1066 int id;
1067
1068 error = NULL((void*)0);
1069 if (! g_shell_parse_argv (command, &argc, &argv, &error))
1070 {
1071 gs_debug ("Could not parse command: %s", error->message)gs_debug_real (__func__, "gs-window-x11.c", 1071, "Could not parse command: %s"
, error->message)
;
1072 g_error_free (error);
1073 return FALSE(0);
1074 }
1075
1076 error = NULL((void*)0);
1077 envp = spawn_make_environment_for_display (gtk_widget_get_display (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
), NULL((void*)0));
1078 result = g_spawn_async_with_pipes (NULL((void*)0),
1079 argv,
1080 envp,
1081 G_SPAWN_DO_NOT_REAP_CHILD | G_SPAWN_SEARCH_PATH,
1082 NULL((void*)0),
1083 NULL((void*)0),
1084 &child_pid,
1085 NULL((void*)0),
1086 &standard_output,
1087 &standard_error,
1088 &error);
1089
1090 if (! result)
1091 {
1092 gs_debug ("Could not start command '%s': %s", command, error->message)gs_debug_real (__func__, "gs-window-x11.c", 1092, "Could not start command '%s': %s"
, command, error->message)
;
1093 g_error_free (error);
1094 g_strfreev (argv);
1095 return FALSE(0);
1096 }
1097
1098 if (pid != NULL((void*)0))
1099 {
1100 *pid = child_pid;
1101 }
1102 else
1103 {
1104 g_spawn_close_pid (child_pid);
1105 }
1106
1107 /* output channel */
1108 channel = g_io_channel_unix_new (standard_output);
1109 g_io_channel_set_close_on_unref (channel, TRUE(!(0)));
1110 g_io_channel_set_flags (channel,
1111 g_io_channel_get_flags (channel) | G_IO_FLAG_NONBLOCK,
1112 NULL((void*)0));
1113 id = g_io_add_watch (channel,
1114 G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL,
1115 watch_func,
1116 user_data);
1117 if (watch_id != NULL((void*)0))
1118 {
1119 *watch_id = id;
1120 }
1121 g_io_channel_unref (channel);
1122
1123 /* error channel */
1124 channel = g_io_channel_unix_new (standard_error);
1125 g_io_channel_set_close_on_unref (channel, TRUE(!(0)));
1126 g_io_channel_set_flags (channel,
1127 g_io_channel_get_flags (channel) | G_IO_FLAG_NONBLOCK,
1128 NULL((void*)0));
1129 id = g_io_add_watch (channel,
1130 G_IO_IN | G_IO_HUP | G_IO_ERR | G_IO_NVAL,
1131 error_watch,
1132 NULL((void*)0));
1133 g_io_channel_unref (channel);
1134
1135 g_strfreev (argv);
1136 g_strfreev (envp);
1137
1138 return result;
1139}
1140
1141static void
1142lock_plug_added (GtkWidget *widget,
1143 GSWindow *window)
1144{
1145 gtk_widget_show (widget);
1146}
1147
1148static gboolean
1149lock_plug_removed (GtkWidget *widget,
1150 GSWindow *window)
1151{
1152 gtk_widget_hide (widget);
1153 gtk_container_remove (GTK_CONTAINER (window->priv->vbox)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->vbox)), ((gtk_container_get_type ())
)))))
, GTK_WIDGET (window->priv->lock_box)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->lock_box)), ((gtk_widget_get_type ()
))))))
);
1154 window->priv->lock_box = NULL((void*)0);
1155
1156 return TRUE(!(0));
1157}
1158
1159static void
1160keyboard_plug_added (GtkWidget *widget,
1161 GSWindow *window)
1162{
1163 gtk_widget_show (widget);
1164}
1165
1166static gboolean
1167keyboard_plug_removed (GtkWidget *widget,
1168 GSWindow *window)
1169{
1170 gtk_widget_hide (widget);
1171 gtk_container_remove (GTK_CONTAINER (window->priv->vbox)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->vbox)), ((gtk_container_get_type ())
)))))
, GTK_WIDGET (window->priv->keyboard_socket)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->keyboard_socket)), ((gtk_widget_get_type
()))))))
);
1172
1173 return TRUE(!(0));
1174}
1175
1176static void
1177keyboard_socket_destroyed (GtkWidget *widget,
1178 GSWindow *window)
1179{
1180 g_signal_handlers_disconnect_by_func (widget, keyboard_socket_destroyed, window)g_signal_handlers_disconnect_matched ((widget), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (keyboard_socket_destroyed), (window))
;
1181 g_signal_handlers_disconnect_by_func (widget, keyboard_plug_added, window)g_signal_handlers_disconnect_matched ((widget), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (keyboard_plug_added), (window))
;
1182 g_signal_handlers_disconnect_by_func (widget, keyboard_plug_removed, window)g_signal_handlers_disconnect_matched ((widget), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (keyboard_plug_removed), (window))
;
1183
1184 window->priv->keyboard_socket = NULL((void*)0);
1185}
1186
1187static void
1188forward_key_events (GSWindow *window)
1189{
1190 window->priv->key_events = g_list_reverse (window->priv->key_events);
1191
1192 while (window->priv->key_events != NULL((void*)0))
1193 {
1194 GdkEventKey *event = window->priv->key_events->data;
1195
1196 gtk_window_propagate_key_event (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
, event);
1197
1198 gdk_event_free ((GdkEvent *)event);
1199 window->priv->key_events = g_list_delete_link (window->priv->key_events,
1200 window->priv->key_events);
1201 }
1202}
1203
1204static void
1205remove_key_events (GSWindow *window)
1206{
1207 window->priv->key_events = g_list_reverse (window->priv->key_events);
1208
1209 while (window->priv->key_events)
1210 {
1211 GdkEventKey *event = window->priv->key_events->data;
1212
1213 gdk_event_free ((GdkEvent *)event);
1214 window->priv->key_events = g_list_delete_link (window->priv->key_events,
1215 window->priv->key_events);
1216 }
1217}
1218
1219static void
1220lock_socket_show (GtkWidget *widget,
1221 GSWindow *window)
1222{
1223 gtk_widget_child_focus (window->priv->lock_socket, GTK_DIR_TAB_FORWARD);
1224
1225 /* send queued events to the dialog */
1226 forward_key_events (window);
1227}
1228
1229static void
1230lock_socket_destroyed (GtkWidget *widget,
1231 GSWindow *window)
1232{
1233 g_signal_handlers_disconnect_by_func (widget, lock_socket_show, window)g_signal_handlers_disconnect_matched ((widget), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (lock_socket_show), (window))
;
1234 g_signal_handlers_disconnect_by_func (widget, lock_socket_destroyed, window)g_signal_handlers_disconnect_matched ((widget), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (lock_socket_destroyed), (window))
;
1235 g_signal_handlers_disconnect_by_func (widget, lock_plug_added, window)g_signal_handlers_disconnect_matched ((widget), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (lock_plug_added), (window))
;
1236 g_signal_handlers_disconnect_by_func (widget, lock_plug_removed, window)g_signal_handlers_disconnect_matched ((widget), (GSignalMatchType
) (G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_DATA), 0, 0, ((void*)
0), (lock_plug_removed), (window))
;
1237
1238 window->priv->lock_socket = NULL((void*)0);
1239}
1240
1241static void
1242create_keyboard_socket (GSWindow *window,
1243 guint32 id)
1244{
1245 int height;
1246
1247 height = (HeightOfScreen (gdk_x11_screen_get_xscreen (gtk_widget_get_screen (GTK_WIDGET (window))))((gdk_x11_screen_get_xscreen (gtk_widget_get_screen (((((GtkWidget
*) (void *) g_type_check_instance_cast ((GTypeInstance*) ((window
)), ((gtk_widget_get_type ())))))))))->height)
) / 4;
1248
1249 window->priv->keyboard_socket = gtk_socket_new ();
1250 gtk_widget_set_size_request (window->priv->keyboard_socket, -1, height);
1251
1252 g_signal_connect (window->priv->keyboard_socket, "destroy",g_signal_connect_data ((window->priv->keyboard_socket),
("destroy"), (((GCallback) (keyboard_socket_destroyed))), (window
), ((void*)0), (GConnectFlags) 0)
1253 G_CALLBACK (keyboard_socket_destroyed), window)g_signal_connect_data ((window->priv->keyboard_socket),
("destroy"), (((GCallback) (keyboard_socket_destroyed))), (window
), ((void*)0), (GConnectFlags) 0)
;
1254 g_signal_connect (window->priv->keyboard_socket, "plug_added",g_signal_connect_data ((window->priv->keyboard_socket),
("plug_added"), (((GCallback) (keyboard_plug_added))), (window
), ((void*)0), (GConnectFlags) 0)
1255 G_CALLBACK (keyboard_plug_added), window)g_signal_connect_data ((window->priv->keyboard_socket),
("plug_added"), (((GCallback) (keyboard_plug_added))), (window
), ((void*)0), (GConnectFlags) 0)
;
1256 g_signal_connect (window->priv->keyboard_socket, "plug_removed",g_signal_connect_data ((window->priv->keyboard_socket),
("plug_removed"), (((GCallback) (keyboard_plug_removed))), (
window), ((void*)0), (GConnectFlags) 0)
1257 G_CALLBACK (keyboard_plug_removed), window)g_signal_connect_data ((window->priv->keyboard_socket),
("plug_removed"), (((GCallback) (keyboard_plug_removed))), (
window), ((void*)0), (GConnectFlags) 0)
;
1258 gtk_box_pack_start (GTK_BOX (window->priv->vbox)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->vbox)), ((gtk_box_get_type ()))))))
, window->priv->keyboard_socket, FALSE(0), FALSE(0), 0);
1259 gtk_socket_add_id (GTK_SOCKET (window->priv->keyboard_socket)((((GtkSocket*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->keyboard_socket)), ((gtk_socket_get_type
()))))))
, id);
1260}
1261
1262/* adapted from gspawn.c */
1263static int
1264wait_on_child (int pid)
1265{
1266 int status;
1267
1268wait_again:
1269 if (waitpid (pid, &status, 0) < 0)
1270 {
1271 if (errno(*__errno_location ()) == EINTR4)
1272 {
1273 goto wait_again;
1274 }
1275 else if (errno(*__errno_location ()) == ECHILD10)
1276 {
1277 ; /* do nothing, child already reaped */
1278 }
1279 else
1280 {
1281 gs_debug ("waitpid () should not fail in 'GSWindow'")gs_debug_real (__func__, "gs-window-x11.c", 1281, "waitpid () should not fail in 'GSWindow'"
)
;
1282 }
1283 }
1284
1285 return status;
1286}
1287
1288static void
1289kill_keyboard_command (GSWindow *window)
1290{
1291 if (window->priv->keyboard_pid > 0)
1292 {
1293 signal_pid (window->priv->keyboard_pid, SIGTERM15);
1294 }
1295}
1296
1297static void
1298kill_dialog_command (GSWindow *window)
1299{
1300 /* If a dialog is up we need to signal it
1301 and wait on it */
1302 if (window->priv->lock_pid > 0)
1303 {
1304 signal_pid (window->priv->lock_pid, SIGTERM15);
1305 }
1306}
1307
1308static void
1309keyboard_command_finish (GSWindow *window)
1310{
1311 g_return_if_fail (GS_IS_WINDOW (window))do{ (void)0; }while (0);
1312
1313 /* send a signal just in case */
1314 kill_keyboard_command (window);
1315
1316 gs_debug ("Keyboard finished")gs_debug_real (__func__, "gs-window-x11.c", 1316, "Keyboard finished"
)
;
1317
1318 if (window->priv->keyboard_pid > 0)
1319 {
1320 wait_on_child (window->priv->keyboard_pid);
1321
1322 g_spawn_close_pid (window->priv->keyboard_pid);
1323 window->priv->keyboard_pid = 0;
1324 }
1325}
1326
1327static gboolean
1328keyboard_command_watch (GIOChannel *source,
1329 GIOCondition condition,
1330 GSWindow *window)
1331{
1332 gboolean finished = FALSE(0);
1333
1334 g_return_val_if_fail (GS_IS_WINDOW (window), FALSE)do{ (void)0; }while (0);
1335
1336 if (condition & G_IO_IN)
1337 {
1338 GIOStatus status;
1339 GError *error = NULL((void*)0);
1340 char *line;
1341
1342 line = NULL((void*)0);
1343 status = g_io_channel_read_line (source, &line, NULL((void*)0), NULL((void*)0), &error);
1344
1345 switch (status)
1346 {
1347 case G_IO_STATUS_NORMAL:
1348 {
1349 guint32 id;
1350 char c;
1351 gs_debug ("keyboard command output: %s", line)gs_debug_real (__func__, "gs-window-x11.c", 1351, "keyboard command output: %s"
, line)
;
1352 if (1 == sscanf (line, " %" G_GUINT32_FORMAT"u" " %c", &id, &c))
1353 {
1354 create_keyboard_socket (window, id);
1355 }
1356 }
1357 break;
1358 case G_IO_STATUS_EOF:
1359 finished = TRUE(!(0));
1360 break;
1361 case G_IO_STATUS_ERROR:
1362 finished = TRUE(!(0));
1363 gs_debug ("Error reading from child: %s\n", error->message)gs_debug_real (__func__, "gs-window-x11.c", 1363, "Error reading from child: %s\n"
, error->message)
;
1364 g_error_free (error);
1365 return FALSE(0);
1366 case G_IO_STATUS_AGAIN:
1367 default:
1368 break;
1369 }
1370
1371 g_free (line);
1372 }
1373 else if (condition & G_IO_HUP)
1374 {
1375 finished = TRUE(!(0));
1376 }
1377
1378 if (finished)
1379 {
1380 window->priv->keyboard_watch_id = 0;
1381 keyboard_command_finish (window);
1382 return FALSE(0);
1383 }
1384
1385 return TRUE(!(0));
1386}
1387
1388static void
1389embed_keyboard (GSWindow *window)
1390{
1391 gboolean res;
1392
1393 if (! window->priv->keyboard_enabled
1394 || window->priv->keyboard_command == NULL((void*)0))
1395 return;
1396
1397 gs_debug ("Adding embedded keyboard widget")gs_debug_real (__func__, "gs-window-x11.c", 1397, "Adding embedded keyboard widget"
)
;
1398
1399 /* FIXME: verify command is safe */
1400
1401 gs_debug ("Running command: %s", window->priv->keyboard_command)gs_debug_real (__func__, "gs-window-x11.c", 1401, "Running command: %s"
, window->priv->keyboard_command)
;
1402
1403 res = spawn_on_window (window,
1404 window->priv->keyboard_command,
1405 &window->priv->keyboard_pid,
1406 (GIOFunc)keyboard_command_watch,
1407 window,
1408 &window->priv->keyboard_watch_id);
1409 if (! res)
1410 {
1411 gs_debug ("Could not start command: %s", window->priv->keyboard_command)gs_debug_real (__func__, "gs-window-x11.c", 1411, "Could not start command: %s"
, window->priv->keyboard_command)
;
1412 }
1413}
1414
1415static void
1416create_lock_socket (GSWindow *window,
1417 guint32 id)
1418{
1419 window->priv->lock_socket = gtk_socket_new ();
1420 window->priv->lock_box = gtk_grid_new ();
1421 gtk_widget_set_halign (GTK_WIDGET (window->priv->lock_box)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->lock_box)), ((gtk_widget_get_type ()
))))))
,
1422 GTK_ALIGN_CENTER);
1423 gtk_widget_set_valign (GTK_WIDGET (window->priv->lock_box)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->lock_box)), ((gtk_widget_get_type ()
))))))
,
1424 GTK_ALIGN_CENTER);
1425 gtk_widget_show (window->priv->lock_box);
1426 gtk_box_pack_start (GTK_BOX (window->priv->vbox)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->vbox)), ((gtk_box_get_type ()))))))
, window->priv->lock_box, TRUE(!(0)), TRUE(!(0)), 0);
1427
1428 gtk_container_add (GTK_CONTAINER (window->priv->lock_box)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->lock_box)), ((gtk_container_get_type
()))))))
, window->priv->lock_socket);
1429
1430 g_signal_connect (window->priv->lock_socket, "show",g_signal_connect_data ((window->priv->lock_socket), ("show"
), (((GCallback) (lock_socket_show))), (window), ((void*)0), (
GConnectFlags) 0)
1431 G_CALLBACK (lock_socket_show), window)g_signal_connect_data ((window->priv->lock_socket), ("show"
), (((GCallback) (lock_socket_show))), (window), ((void*)0), (
GConnectFlags) 0)
;
1432 g_signal_connect (window->priv->lock_socket, "destroy",g_signal_connect_data ((window->priv->lock_socket), ("destroy"
), (((GCallback) (lock_socket_destroyed))), (window), ((void*
)0), (GConnectFlags) 0)
1433 G_CALLBACK (lock_socket_destroyed), window)g_signal_connect_data ((window->priv->lock_socket), ("destroy"
), (((GCallback) (lock_socket_destroyed))), (window), ((void*
)0), (GConnectFlags) 0)
;
1434 g_signal_connect (window->priv->lock_socket, "plug_added",g_signal_connect_data ((window->priv->lock_socket), ("plug_added"
), (((GCallback) (lock_plug_added))), (window), ((void*)0), (
GConnectFlags) 0)
1435 G_CALLBACK (lock_plug_added), window)g_signal_connect_data ((window->priv->lock_socket), ("plug_added"
), (((GCallback) (lock_plug_added))), (window), ((void*)0), (
GConnectFlags) 0)
;
1436 g_signal_connect (window->priv->lock_socket, "plug_removed",g_signal_connect_data ((window->priv->lock_socket), ("plug_removed"
), (((GCallback) (lock_plug_removed))), (window), ((void*)0),
(GConnectFlags) 0)
1437 G_CALLBACK (lock_plug_removed), window)g_signal_connect_data ((window->priv->lock_socket), ("plug_removed"
), (((GCallback) (lock_plug_removed))), (window), ((void*)0),
(GConnectFlags) 0)
;
1438
1439 gtk_socket_add_id (GTK_SOCKET (window->priv->lock_socket)((((GtkSocket*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->lock_socket)), ((gtk_socket_get_type
()))))))
, id);
1440
1441 if (window->priv->keyboard_enabled)
1442 {
1443 embed_keyboard (window);
1444 }
1445}
1446
1447static void
1448gs_window_dialog_finish (GSWindow *window)
1449{
1450 g_return_if_fail (GS_IS_WINDOW (window))do{ (void)0; }while (0);
1451
1452 gs_debug ("Dialog finished")gs_debug_real (__func__, "gs-window-x11.c", 1452, "Dialog finished"
)
;
1453
1454 /* make sure we finish the keyboard thing too */
1455 keyboard_command_finish (window);
1456
1457 /* send a signal just in case */
1458 kill_dialog_command (window);
1459
1460 if (window->priv->lock_pid > 0)
1461 {
1462 wait_on_child (window->priv->lock_pid);
1463
1464 g_spawn_close_pid (window->priv->lock_pid);
1465 window->priv->lock_pid = 0;
1466 }
1467
1468 /* remove events for the case were we failed to show socket */
1469 remove_key_events (window);
1470}
1471
1472static void
1473maybe_kill_dialog (GSWindow *window)
1474{
1475 if (!window->priv->dialog_shake_in_progress
1476 && window->priv->dialog_quit_requested
1477 && window->priv->lock_pid > 0)
1478 {
1479 kill (window->priv->lock_pid, SIGTERM15);
1480 }
1481}
1482
1483/* very rudimentary animation for indicating an auth failure */
1484static void
1485shake_dialog (GSWindow *window)
1486{
1487 int i;
1488 guint start, end;
1489
1490 window->priv->dialog_shake_in_progress = TRUE(!(0));
1491
1492 for (i = 0; i < 8; i++)
1493 {
1494 if (i % 2 == 0)
1495 {
1496 start = 30;
1497 end = 0;
1498 }
1499 else
1500 {
1501 start = 0;
1502 end = 30;
1503 }
1504
1505 if (! window->priv->lock_box)
1506 {
1507 break;
1508 }
1509
1510 gtk_widget_set_margin_start (GTK_WIDGET (window->priv->lock_box)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->lock_box)), ((gtk_widget_get_type ()
))))))
,
1511 start);
1512 gtk_widget_set_margin_end (GTK_WIDGET (window->priv->lock_box)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->lock_box)), ((gtk_widget_get_type ()
))))))
,
1513 end);
1514
1515 while (gtk_events_pending ())
1516 {
1517 gtk_main_iteration ();
1518 }
1519
1520 g_usleep (10000);
1521 }
1522
1523 window->priv->dialog_shake_in_progress = FALSE(0);
1524 maybe_kill_dialog (window);
1525}
1526
1527static void
1528window_set_dialog_up (GSWindow *window,
1529 gboolean dialog_up)
1530{
1531 if (window->priv->dialog_up == dialog_up)
1532 {
1533 return;
1534 }
1535
1536 window->priv->dialog_up = (dialog_up != FALSE(0));
1537 g_object_notify (G_OBJECT (window)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), (((GType) ((20) << (2))))))))
, "dialog-up");
1538}
1539
1540static void
1541popdown_dialog (GSWindow *window)
1542{
1543 gs_window_dialog_finish (window);
1544
1545 gtk_widget_show (window->priv->drawing_area);
1546
1547 gs_window_clear (window);
1548 set_invisible_cursor (gtk_widget_get_window (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
), TRUE(!(0)));
1549
1550 window_set_dialog_up (window, FALSE(0));
1551
1552 /* reset the pointer positions */
1553 window->priv->last_x = -1;
1554 window->priv->last_y = -1;
1555
1556 if (window->priv->lock_box != NULL((void*)0))
1557 {
1558 gtk_container_remove (GTK_CONTAINER (window->priv->vbox)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->vbox)), ((gtk_container_get_type ())
)))))
, GTK_WIDGET (window->priv->lock_box)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->lock_box)), ((gtk_widget_get_type ()
))))))
);
1559 window->priv->lock_box = NULL((void*)0);
1560 }
1561
1562 remove_popup_dialog_idle (window);
1563 remove_command_watches (window);
1564}
1565
1566static gboolean
1567lock_command_watch (GIOChannel *source,
1568 GIOCondition condition,
1569 GSWindow *window)
1570{
1571 gboolean finished = FALSE(0);
1572
1573 g_return_val_if_fail (GS_IS_WINDOW (window), FALSE)do{ (void)0; }while (0);
1574
1575 if (condition & G_IO_IN)
1576 {
1577 GIOStatus status;
1578 GError *error = NULL((void*)0);
1579 char *line;
1580
1581 line = NULL((void*)0);
1582 status = g_io_channel_read_line (source, &line, NULL((void*)0), NULL((void*)0), &error);
1583
1584 switch (status)
1585 {
1586 case G_IO_STATUS_NORMAL:
1587 gs_debug ("command output: %s", line)gs_debug_real (__func__, "gs-window-x11.c", 1587, "command output: %s"
, line)
;
1588
1589 if (strstr (line, "WINDOW ID=") != NULL((void*)0))
1590 {
1591 guint32 id;
1592 char c;
1593 if (1 == sscanf (line, " WINDOW ID= %" G_GUINT32_FORMAT"u" " %c", &id, &c))
1594 {
1595 create_lock_socket (window, id);
1596 }
1597 }
1598 else if (strstr (line, "NOTICE=") != NULL((void*)0))
1599 {
1600 if (strstr (line, "NOTICE=AUTH FAILED") != NULL((void*)0))
1601 {
1602 shake_dialog (window);
1603 }
1604 }
1605 else if (strstr (line, "RESPONSE=") != NULL((void*)0))
1606 {
1607 if (strstr (line, "RESPONSE=OK") != NULL((void*)0))
1608 {
1609 gs_debug ("Got OK response")gs_debug_real (__func__, "gs-window-x11.c", 1609, "Got OK response"
)
;
1610 window->priv->dialog_response = DIALOG_RESPONSE_OK;
1611 }
1612 else
1613 {
1614 gs_debug ("Got CANCEL response")gs_debug_real (__func__, "gs-window-x11.c", 1614, "Got CANCEL response"
)
;
1615 window->priv->dialog_response = DIALOG_RESPONSE_CANCEL;
1616 }
1617 finished = TRUE(!(0));
1618 }
1619 else if (strstr (line, "REQUEST QUIT") != NULL((void*)0))
1620 {
1621 gs_debug ("Got request for quit")gs_debug_real (__func__, "gs-window-x11.c", 1621, "Got request for quit"
)
;
1622 window->priv->dialog_quit_requested = TRUE(!(0));
1623 maybe_kill_dialog (window);
1624 }
1625 break;
1626 case G_IO_STATUS_EOF:
1627 finished = TRUE(!(0));
1628 break;
1629 case G_IO_STATUS_ERROR:
1630 finished = TRUE(!(0));
Value stored to 'finished' is never read
1631 gs_debug ("Error reading from child: %s\n", error->message)gs_debug_real (__func__, "gs-window-x11.c", 1631, "Error reading from child: %s\n"
, error->message)
;
1632 g_error_free (error);
1633 return FALSE(0);
1634 case G_IO_STATUS_AGAIN:
1635 default:
1636 break;
1637 }
1638
1639 g_free (line);
1640 }
1641 else if (condition & G_IO_HUP)
1642 {
1643 finished = TRUE(!(0));
1644 }
1645
1646 if (finished)
1647 {
1648 popdown_dialog (window);
1649
1650 if (window->priv->dialog_response == DIALOG_RESPONSE_OK)
1651 {
1652 add_emit_deactivated_idle (window);
1653 }
1654
1655 window->priv->lock_watch_id = 0;
1656
1657 return FALSE(0);
1658 }
1659
1660 return TRUE(!(0));
1661}
1662
1663static gboolean
1664is_logout_enabled (GSWindow *window)
1665{
1666 double elapsed;
1667
1668 if (! window->priv->logout_enabled)
1669 {
1670 return FALSE(0);
1671 }
1672
1673 if (! window->priv->logout_command)
1674 {
1675 return FALSE(0);
1676 }
1677
1678 elapsed = g_timer_elapsed (window->priv->timer, NULL((void*)0));
1679
1680 if (window->priv->logout_timeout < (elapsed * 1000))
1681 {
1682 return TRUE(!(0));
1683 }
1684
1685 return FALSE(0);
1686}
1687
1688static gboolean
1689is_user_switch_enabled (GSWindow *window)
1690{
1691 return window->priv->user_switch_enabled;
1692}
1693
1694static void
1695popup_dialog (GSWindow *window)
1696{
1697 gboolean result;
1698 GString *command;
1699
1700 gs_debug ("Popping up dialog")gs_debug_real (__func__, "gs-window-x11.c", 1700, "Popping up dialog"
)
;
1701
1702 command = g_string_new (MATE_SCREENSAVER_DIALOG_PATH"/usr/local/libexec" "/mate-screensaver-dialog");
1703
1704 if (is_logout_enabled (window))
1705 {
1706 command = g_string_append (command, " --enable-logout");
1707 g_string_append_printf (command, " --logout-command='%s'", window->priv->logout_command);
1708 }
1709
1710 if (window->priv->status_message)
1711 {
1712 char *quoted;
1713
1714 quoted = g_shell_quote (window->priv->status_message);
1715 g_string_append_printf (command, " --status-message=%s", quoted);
1716 g_free (quoted);
1717 }
1718
1719 if (is_user_switch_enabled (window))
1720 {
1721 command = g_string_append (command, " --enable-switch");
1722 }
1723
1724 if (gs_debug_enabled ())
1725 {
1726 command = g_string_append (command, " --verbose");
1727 }
1728
1729 gtk_widget_hide (window->priv->drawing_area);
1730
1731 gtk_widget_queue_draw (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
);
1732 set_invisible_cursor (gtk_widget_get_window (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
), FALSE(0));
1733
1734 window->priv->dialog_quit_requested = FALSE(0);
1735 window->priv->dialog_shake_in_progress = FALSE(0);
1736
1737 result = spawn_on_window (window,
1738 command->str,
1739 &window->priv->lock_pid,
1740 (GIOFunc)lock_command_watch,
1741 window,
1742 &window->priv->lock_watch_id);
1743 if (! result)
1744 {
1745 gs_debug ("Could not start command: %s", command->str)gs_debug_real (__func__, "gs-window-x11.c", 1745, "Could not start command: %s"
, command->str)
;
1746 }
1747
1748 g_string_free (command, TRUE(!(0)));
1749}
1750
1751static gboolean
1752popup_dialog_idle (gpointer data)
1753{
1754 GSWindow *window = data;
1755
1756 popup_dialog (window);
1757 window->priv->popup_dialog_idle_id = 0;
1758 return FALSE(0);
1759}
1760
1761void
1762gs_window_request_unlock (GSWindow *window)
1763{
1764 g_return_if_fail (GS_IS_WINDOW (window))do{ (void)0; }while (0);
1765
1766 gs_debug ("Requesting unlock")gs_debug_real (__func__, "gs-window-x11.c", 1766, "Requesting unlock"
)
;
1767
1768 if (! gtk_widget_get_visible (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
))
1769 {
1770 gs_debug ("Request unlock but window is not visible!")gs_debug_real (__func__, "gs-window-x11.c", 1770, "Request unlock but window is not visible!"
)
;
1771 return;
1772 }
1773
1774 if (window->priv->lock_watch_id > 0)
1775 {
1776 return;
1777 }
1778
1779 if (! window->priv->lock_enabled)
1780 {
1781 add_emit_deactivated_idle (window);
1782
1783 return;
1784 }
1785
1786 if (window->priv->popup_dialog_idle_id == 0)
1787 {
1788 add_popup_dialog_idle (window);
1789 }
1790
1791 window_set_dialog_up (window, TRUE(!(0)));
1792}
1793
1794void
1795gs_window_cancel_unlock_request (GSWindow *window)
1796{
1797 /* FIXME: This is a bit of a hammer approach...
1798 * Maybe we should send a delete-event to
1799 * the plug?
1800 */
1801 g_return_if_fail (GS_IS_WINDOW (window))do{ (void)0; }while (0);
1802
1803 popdown_dialog (window);
1804}
1805
1806void
1807gs_window_set_lock_enabled (GSWindow *window,
1808 gboolean lock_enabled)
1809{
1810 g_return_if_fail (GS_IS_WINDOW (window))do{ (void)0; }while (0);
1811
1812 if (window->priv->lock_enabled == lock_enabled)
1813 {
1814 return;
1815 }
1816
1817 window->priv->lock_enabled = (lock_enabled != FALSE(0));
1818 g_object_notify (G_OBJECT (window)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), (((GType) ((20) << (2))))))))
, "lock-enabled");
1819}
1820
1821GdkDisplay *
1822gs_window_get_display (GSWindow *window)
1823{
1824 g_return_val_if_fail (GS_IS_WINDOW (window), NULL)do{ (void)0; }while (0);
1825
1826 return gtk_widget_get_display (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
);
1827}
1828
1829void
1830gs_window_set_keyboard_enabled (GSWindow *window,
1831 gboolean enabled)
1832{
1833 g_return_if_fail (GS_IS_WINDOW (window))do{ (void)0; }while (0);
1834
1835 window->priv->keyboard_enabled = (enabled != FALSE(0));
1836}
1837
1838void
1839gs_window_set_keyboard_command (GSWindow *window,
1840 const char *command)
1841{
1842 g_return_if_fail (GS_IS_WINDOW (window))do{ (void)0; }while (0);
1843
1844 g_free (window->priv->keyboard_command);
1845
1846 if (command != NULL((void*)0))
1847 {
1848 window->priv->keyboard_command = g_strdup (command);
1849 }
1850 else
1851 {
1852 window->priv->keyboard_command = NULL((void*)0);
1853 }
1854}
1855
1856void
1857gs_window_set_logout_enabled (GSWindow *window,
1858 gboolean logout_enabled)
1859{
1860 g_return_if_fail (GS_IS_WINDOW (window))do{ (void)0; }while (0);
1861
1862 window->priv->logout_enabled = (logout_enabled != FALSE(0));
1863}
1864
1865void
1866gs_window_set_user_switch_enabled (GSWindow *window,
1867 gboolean user_switch_enabled)
1868{
1869 g_return_if_fail (GS_IS_WINDOW (window))do{ (void)0; }while (0);
1870
1871 window->priv->user_switch_enabled = (user_switch_enabled != FALSE(0));
1872}
1873
1874void
1875gs_window_set_logout_timeout (GSWindow *window,
1876 glong logout_timeout)
1877{
1878 g_return_if_fail (GS_IS_WINDOW (window))do{ (void)0; }while (0);
1879
1880 if (logout_timeout < 0)
1881 {
1882 window->priv->logout_timeout = 0;
1883 }
1884 else
1885 {
1886 window->priv->logout_timeout = logout_timeout;
1887 }
1888}
1889
1890void
1891gs_window_set_logout_command (GSWindow *window,
1892 const char *command)
1893{
1894 g_return_if_fail (GS_IS_WINDOW (window))do{ (void)0; }while (0);
1895
1896 g_free (window->priv->logout_command);
1897
1898 if (command)
1899 {
1900 window->priv->logout_command = g_strdup (command);
1901 }
1902 else
1903 {
1904 window->priv->logout_command = NULL((void*)0);
1905 }
1906}
1907
1908void
1909gs_window_set_status_message (GSWindow *window,
1910 const char *status_message)
1911{
1912 g_return_if_fail (GS_IS_WINDOW (window))do{ (void)0; }while (0);
1913
1914 g_free (window->priv->status_message);
1915 window->priv->status_message = g_strdup (status_message);
1916}
1917
1918void
1919gs_window_set_monitor (GSWindow *window,
1920 GdkMonitor *monitor)
1921{
1922 g_return_if_fail (GS_IS_WINDOW (window))do{ (void)0; }while (0);
1923
1924 if (window->priv->monitor == monitor)
1925 {
1926 return;
1927 }
1928
1929 window->priv->monitor = monitor;
1930
1931 gtk_widget_queue_resize (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
);
1932
1933 g_object_notify (G_OBJECT (window)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), (((GType) ((20) << (2))))))))
, "monitor");
1934}
1935
1936GdkMonitor *
1937gs_window_get_monitor (GSWindow *window)
1938{
1939 g_return_val_if_fail (GS_IS_WINDOW (window), NULL)do{ (void)0; }while (0);
1940
1941 return window->priv->monitor;
1942}
1943
1944static void
1945gs_window_set_property (GObject *object,
1946 guint prop_id,
1947 const GValue *value,
1948 GParamSpec *pspec)
1949{
1950 GSWindow *self;
1951
1952 self = GS_WINDOW (object)((((GSWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((gs_window_get_type ()))))))
;
1953
1954 switch (prop_id)
1955 {
1956 case PROP_LOCK_ENABLED:
1957 gs_window_set_lock_enabled (self, g_value_get_boolean (value));
1958 break;
1959 case PROP_KEYBOARD_ENABLED:
1960 gs_window_set_keyboard_enabled (self, g_value_get_boolean (value));
1961 break;
1962 case PROP_KEYBOARD_COMMAND:
1963 gs_window_set_keyboard_command (self, g_value_get_string (value));
1964 break;
1965 case PROP_LOGOUT_ENABLED:
1966 gs_window_set_logout_enabled (self, g_value_get_boolean (value));
1967 break;
1968 case PROP_LOGOUT_COMMAND:
1969 gs_window_set_logout_command (self, g_value_get_string (value));
1970 break;
1971 case PROP_STATUS_MESSAGE:
1972 gs_window_set_status_message (self, g_value_get_string (value));
1973 break;
1974 case PROP_LOGOUT_TIMEOUT:
1975 gs_window_set_logout_timeout (self, g_value_get_long (value));
1976 break;
1977 case PROP_MONITOR:
1978 gs_window_set_monitor (self, g_value_get_pointer (value));
1979 break;
1980 default:
1981 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec)do { GObject *_glib__object = (GObject*) ((object)); GParamSpec
*_glib__pspec = (GParamSpec*) ((pspec)); guint _glib__property_id
= ((prop_id)); g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'"
, "gs-window-x11.c", 1981, ("property"), _glib__property_id, _glib__pspec
->name, g_type_name ((((((GTypeClass*) (((GTypeInstance*) (
_glib__pspec))->g_class))->g_type)))), (g_type_name (((
(((GTypeClass*) (((GTypeInstance*) (_glib__object))->g_class
))->g_type)))))); } while (0)
;
1982 break;
1983 }
1984}
1985
1986static void
1987gs_window_get_property (GObject *object,
1988 guint prop_id,
1989 GValue *value,
1990 GParamSpec *pspec)
1991{
1992 GSWindow *self;
1993
1994 self = GS_WINDOW (object)((((GSWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((gs_window_get_type ()))))))
;
1995
1996 switch (prop_id)
1997 {
1998 case PROP_LOCK_ENABLED:
1999 g_value_set_boolean (value, self->priv->lock_enabled);
2000 break;
2001 case PROP_KEYBOARD_ENABLED:
2002 g_value_set_boolean (value, self->priv->keyboard_enabled);
2003 break;
2004 case PROP_KEYBOARD_COMMAND:
2005 g_value_set_string (value, self->priv->keyboard_command);
2006 break;
2007 case PROP_LOGOUT_ENABLED:
2008 g_value_set_boolean (value, self->priv->logout_enabled);
2009 break;
2010 case PROP_LOGOUT_COMMAND:
2011 g_value_set_string (value, self->priv->logout_command);
2012 break;
2013 case PROP_STATUS_MESSAGE:
2014 g_value_set_string (value, self->priv->status_message);
2015 break;
2016 case PROP_LOGOUT_TIMEOUT:
2017 g_value_set_long (value, self->priv->logout_timeout);
2018 break;
2019 case PROP_MONITOR:
2020 g_value_set_pointer (value, (gpointer) self->priv->monitor);
2021 break;
2022 case PROP_OBSCURED:
2023 g_value_set_boolean (value, self->priv->obscured);
2024 break;
2025 case PROP_DIALOG_UP:
2026 g_value_set_boolean (value, self->priv->dialog_up);
2027 break;
2028 default:
2029 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec)do { GObject *_glib__object = (GObject*) ((object)); GParamSpec
*_glib__pspec = (GParamSpec*) ((pspec)); guint _glib__property_id
= ((prop_id)); g_warning ("%s:%d: invalid %s id %u for \"%s\" of type '%s' in '%s'"
, "gs-window-x11.c", 2029, ("property"), _glib__property_id, _glib__pspec
->name, g_type_name ((((((GTypeClass*) (((GTypeInstance*) (
_glib__pspec))->g_class))->g_type)))), (g_type_name (((
(((GTypeClass*) (((GTypeInstance*) (_glib__object))->g_class
))->g_type)))))); } while (0)
;
2030 break;
2031 }
2032}
2033
2034static void
2035queue_key_event (GSWindow *window,
2036 GdkEventKey *event)
2037{
2038 /* Eat the first return, enter, escape, or space */
2039 if (window->priv->key_events == NULL((void*)0)
2040 && (event->keyval == GDK_KEY_Return0xff0d
2041 || event->keyval == GDK_KEY_KP_Enter0xff8d
2042 || event->keyval == GDK_KEY_Escape0xff1b
2043 || event->keyval == GDK_KEY_space0x020))
2044 {
2045 return;
2046 }
2047
2048 /* Only cache MAX_QUEUED_EVENTS key events. If there are any more than this then
2049 something is wrong */
2050 /* Don't queue keys that may cause focus navigation in the dialog */
2051 if (g_list_length (window->priv->key_events) < MAX_QUEUED_EVENTS16
2052 && event->keyval != GDK_KEY_Tab0xff09
2053 && event->keyval != GDK_KEY_Up0xff52
2054 && event->keyval != GDK_KEY_Down0xff54)
2055 {
2056 window->priv->key_events = g_list_prepend (window->priv->key_events,
2057 gdk_event_copy ((GdkEvent *)event));
2058 }
2059}
2060
2061static gboolean
2062maybe_handle_activity (GSWindow *window)
2063{
2064 gboolean handled;
2065
2066 handled = FALSE(0);
2067
2068 /* if we already have a socket then don't bother */
2069 if (! window->priv->lock_socket
2070 && gtk_widget_get_sensitive (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
))
2071 {
2072 g_signal_emit (window, signals [ACTIVITY], 0, &handled);
2073 }
2074
2075 return handled;
2076}
2077
2078static gboolean
2079gs_window_real_key_press_event (GtkWidget *widget,
2080 GdkEventKey *event)
2081{
2082 /*g_message ("KEY PRESS state: %u keyval %u", event->state, event->keyval);*/
2083
2084 /* Ignore brightness keys */
2085 if (event->hardware_keycode == 101 || event->hardware_keycode == 212)
2086 {
2087 gs_debug ("Ignoring brightness keys")gs_debug_real (__func__, "gs-window-x11.c", 2087, "Ignoring brightness keys"
)
;
2088 return TRUE(!(0));
2089 }
2090
2091 maybe_handle_activity (GS_WINDOW (widget)((((GSWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gs_window_get_type ()))))))
);
2092
2093 queue_key_event (GS_WINDOW (widget)((((GSWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gs_window_get_type ()))))))
, event);
2094
2095 if (GTK_WIDGET_CLASS (gs_window_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((gs_window_parent_class)), ((gtk_widget_get_type ()))))))
->key_press_event)
2096 {
2097 GTK_WIDGET_CLASS (gs_window_parent_class)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((gs_window_parent_class)), ((gtk_widget_get_type ()))))))
->key_press_event (widget, event);
2098 }
2099
2100 return TRUE(!(0));
2101}
2102
2103static gboolean
2104gs_window_real_motion_notify_event (GtkWidget *widget,
2105 GdkEventMotion *event)
2106{
2107 GSWindow *window;
2108 gdouble distance;
2109 gdouble min_distance;
2110 gdouble min_percentage = 0.1;
2111 GdkDisplay *display;
2112 GdkScreen *screen;
2113
2114 window = GS_WINDOW (widget)((((GSWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gs_window_get_type ()))))))
;
2115
2116 display = gs_window_get_display (window);
2117 screen = gdk_display_get_default_screen (display);
2118 min_distance = WidthOfScreen (gdk_x11_screen_get_xscreen (screen))((gdk_x11_screen_get_xscreen (screen))->width) * min_percentage;
2119
2120 /* if the last position was not set then don't detect motion */
2121 if (window->priv->last_x < 0 || window->priv->last_y < 0)
2122 {
2123 window->priv->last_x = event->x;
2124 window->priv->last_y = event->y;
2125
2126 return FALSE(0);
2127 }
2128
2129 /* just an approximate distance */
2130 distance = MAX (ABS (window->priv->last_x - event->x),((((((window->priv->last_x - event->x) < 0) ? -(window
->priv->last_x - event->x) : (window->priv->last_x
- event->x))) > ((((window->priv->last_y - event
->y) < 0) ? -(window->priv->last_y - event->y)
: (window->priv->last_y - event->y)))) ? ((((window
->priv->last_x - event->x) < 0) ? -(window->priv
->last_x - event->x) : (window->priv->last_x - event
->x))) : ((((window->priv->last_y - event->y) <
0) ? -(window->priv->last_y - event->y) : (window->
priv->last_y - event->y))))
2131 ABS (window->priv->last_y - event->y))((((((window->priv->last_x - event->x) < 0) ? -(window
->priv->last_x - event->x) : (window->priv->last_x
- event->x))) > ((((window->priv->last_y - event
->y) < 0) ? -(window->priv->last_y - event->y)
: (window->priv->last_y - event->y)))) ? ((((window
->priv->last_x - event->x) < 0) ? -(window->priv
->last_x - event->x) : (window->priv->last_x - event
->x))) : ((((window->priv->last_y - event->y) <
0) ? -(window->priv->last_y - event->y) : (window->
priv->last_y - event->y))))
;
2132
2133 if (distance > min_distance)
2134 {
2135 maybe_handle_activity (window);
2136
2137 window->priv->last_x = -1;
2138 window->priv->last_y = -1;
2139 }
2140
2141 return FALSE(0);
2142}
2143
2144static gboolean
2145gs_window_real_button_press_event (GtkWidget *widget,
2146 GdkEventButton *event)
2147{
2148 GSWindow *window;
2149
2150 window = GS_WINDOW (widget)((((GSWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gs_window_get_type ()))))))
;
2151 maybe_handle_activity (window);
2152
2153 return FALSE(0);
2154}
2155
2156static gboolean
2157gs_window_real_scroll_event (GtkWidget *widget,
2158 GdkEventScroll *event)
2159{
2160 GSWindow *window;
2161
2162 window = GS_WINDOW (widget)((((GSWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gs_window_get_type ()))))))
;
2163 maybe_handle_activity (window);
2164
2165 return FALSE(0);
2166}
2167
2168static void
2169gs_window_real_size_request (GtkWidget *widget,
2170 GtkRequisition *requisition)
2171{
2172 GSWindow *window;
2173 GtkBin *bin;
2174 GtkWidget *child;
2175 GdkRectangle old_geometry;
2176 int position_changed = FALSE(0);
2177 int size_changed = FALSE(0);
2178
2179 window = GS_WINDOW (widget)((((GSWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gs_window_get_type ()))))))
;
2180 bin = GTK_BIN (widget)((((GtkBin*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gtk_bin_get_type ()))))))
;
2181 child = gtk_bin_get_child (bin);
2182
2183 if (child && gtk_widget_get_visible (child))
2184 {
2185 gtk_widget_get_preferred_size (child, requisition, NULL((void*)0));
2186 }
2187
2188 old_geometry = window->priv->geometry;
2189
2190 update_geometry (window);
2191
2192 requisition->width = window->priv->geometry.width;
2193 requisition->height = window->priv->geometry.height;
2194
2195 if (! gtk_widget_get_realized (widget))
2196 {
2197 return;
2198 }
2199
2200 if (old_geometry.width != window->priv->geometry.width ||
2201 old_geometry.height != window->priv->geometry.height)
2202 {
2203 size_changed = TRUE(!(0));
2204 }
2205
2206 if (old_geometry.x != window->priv->geometry.x ||
2207 old_geometry.y != window->priv->geometry.y)
2208 {
2209 position_changed = TRUE(!(0));
2210 }
2211
2212 gs_window_move_resize_window (window, position_changed, size_changed);
2213}
2214
2215static void
2216gs_window_real_get_preferred_width (GtkWidget *widget,
2217 gint *minimal_width,
2218 gint *natural_width)
2219{
2220 GtkRequisition requisition;
2221 gs_window_real_size_request (widget, &requisition);
2222 *minimal_width = *natural_width = requisition.width;
2223}
2224
2225static void
2226gs_window_real_get_preferred_height (GtkWidget *widget,
2227 gint *minimal_height,
2228 gint *natural_height)
2229{
2230 GtkRequisition requisition;
2231 gs_window_real_size_request (widget, &requisition);
2232 *minimal_height = *natural_height = requisition.height;
2233}
2234
2235static gboolean
2236gs_window_real_grab_broken (GtkWidget *widget,
2237 GdkEventGrabBroken *event)
2238{
2239 if (event->grab_window != NULL((void*)0))
2240 {
2241 gs_debug ("Grab broken on window %X %s, new grab on window %X",gs_debug_real (__func__, "gs-window-x11.c", 2244, "Grab broken on window %X %s, new grab on window %X"
, (guint32) (gdk_x11_window_get_xid (event->window)), event
->keyboard ? "keyboard" : "pointer", (guint32) (gdk_x11_window_get_xid
(event->grab_window)))
2242 (guint32) GDK_WINDOW_XID (event->window),gs_debug_real (__func__, "gs-window-x11.c", 2244, "Grab broken on window %X %s, new grab on window %X"
, (guint32) (gdk_x11_window_get_xid (event->window)), event
->keyboard ? "keyboard" : "pointer", (guint32) (gdk_x11_window_get_xid
(event->grab_window)))
2243 event->keyboard ? "keyboard" : "pointer",gs_debug_real (__func__, "gs-window-x11.c", 2244, "Grab broken on window %X %s, new grab on window %X"
, (guint32) (gdk_x11_window_get_xid (event->window)), event
->keyboard ? "keyboard" : "pointer", (guint32) (gdk_x11_window_get_xid
(event->grab_window)))
2244 (guint32) GDK_WINDOW_XID (event->grab_window))gs_debug_real (__func__, "gs-window-x11.c", 2244, "Grab broken on window %X %s, new grab on window %X"
, (guint32) (gdk_x11_window_get_xid (event->window)), event
->keyboard ? "keyboard" : "pointer", (guint32) (gdk_x11_window_get_xid
(event->grab_window)))
;
2245 }
2246 else
2247 {
2248 gs_debug ("Grab broken on window %X %s, new grab is outside application",gs_debug_real (__func__, "gs-window-x11.c", 2250, "Grab broken on window %X %s, new grab is outside application"
, (guint32) (gdk_x11_window_get_xid (event->window)), event
->keyboard ? "keyboard" : "pointer")
2249 (guint32) GDK_WINDOW_XID (event->window),gs_debug_real (__func__, "gs-window-x11.c", 2250, "Grab broken on window %X %s, new grab is outside application"
, (guint32) (gdk_x11_window_get_xid (event->window)), event
->keyboard ? "keyboard" : "pointer")
2250 event->keyboard ? "keyboard" : "pointer")gs_debug_real (__func__, "gs-window-x11.c", 2250, "Grab broken on window %X %s, new grab is outside application"
, (guint32) (gdk_x11_window_get_xid (event->window)), event
->keyboard ? "keyboard" : "pointer")
;
2251 }
2252
2253 return FALSE(0);
2254}
2255
2256gboolean
2257gs_window_is_obscured (GSWindow *window)
2258{
2259 g_return_val_if_fail (GS_IS_WINDOW (window), FALSE)do{ (void)0; }while (0);
2260
2261 return window->priv->obscured;
2262}
2263
2264gboolean
2265gs_window_is_dialog_up (GSWindow *window)
2266{
2267 g_return_val_if_fail (GS_IS_WINDOW (window), FALSE)do{ (void)0; }while (0);
2268
2269 return window->priv->dialog_up;
2270}
2271
2272static void
2273window_set_obscured (GSWindow *window,
2274 gboolean obscured)
2275{
2276 if (window->priv->obscured == obscured)
2277 {
2278 return;
2279 }
2280
2281 window->priv->obscured = (obscured != FALSE(0));
2282 g_object_notify (G_OBJECT (window)((((GObject*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), (((GType) ((20) << (2))))))))
, "obscured");
2283}
2284
2285static gboolean
2286gs_window_real_visibility_notify_event (GtkWidget *widget,
2287 GdkEventVisibility *event)
2288{
2289 switch (event->state)
2290 {
2291 case GDK_VISIBILITY_FULLY_OBSCURED:
2292 window_set_obscured (GS_WINDOW (widget)((((GSWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gs_window_get_type ()))))))
, TRUE(!(0)));
2293 break;
2294 case GDK_VISIBILITY_PARTIAL:
2295 break;
2296 case GDK_VISIBILITY_UNOBSCURED:
2297 window_set_obscured (GS_WINDOW (widget)((((GSWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((widget)), ((gs_window_get_type ()))))))
, FALSE(0));
2298 break;
2299 default:
2300 break;
2301 }
2302
2303 return FALSE(0);
2304}
2305
2306static void
2307gs_window_class_init (GSWindowClass *klass)
2308{
2309 GObjectClass *object_class = G_OBJECT_CLASS (klass)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((klass)), (((GType) ((20) << (2))))))))
;
2310 GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass)((((GtkWidgetClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((klass)), ((gtk_widget_get_type ()))))))
;
2311
2312 object_class->finalize = gs_window_finalize;
2313 object_class->get_property = gs_window_get_property;
2314 object_class->set_property = gs_window_set_property;
2315
2316 widget_class->show = gs_window_real_show;
2317 widget_class->hide = gs_window_real_hide;
2318 widget_class->draw = gs_window_real_draw;
2319 widget_class->realize = gs_window_real_realize;
2320 widget_class->unrealize = gs_window_real_unrealize;
2321 widget_class->key_press_event = gs_window_real_key_press_event;
2322 widget_class->motion_notify_event = gs_window_real_motion_notify_event;
2323 widget_class->button_press_event = gs_window_real_button_press_event;
2324 widget_class->scroll_event = gs_window_real_scroll_event;
2325 widget_class->get_preferred_width = gs_window_real_get_preferred_width;
2326 widget_class->get_preferred_height = gs_window_real_get_preferred_height;
2327 widget_class->grab_broken_event = gs_window_real_grab_broken;
2328 widget_class->visibility_notify_event = gs_window_real_visibility_notify_event;
2329
2330 signals [ACTIVITY] =
2331 g_signal_new ("activity",
2332 G_TYPE_FROM_CLASS (object_class)(((GTypeClass*) (object_class))->g_type),
2333 G_SIGNAL_RUN_LAST,
2334 G_STRUCT_OFFSET (GSWindowClass, activity)((glong) __builtin_offsetof(GSWindowClass, activity)),
2335 NULL((void*)0),
2336 NULL((void*)0),
2337 gs_marshal_BOOLEAN__VOID,
2338 G_TYPE_BOOLEAN((GType) ((5) << (2))),
2339 0);
2340 signals [DEACTIVATED] =
2341 g_signal_new ("deactivated",
2342 G_TYPE_FROM_CLASS (object_class)(((GTypeClass*) (object_class))->g_type),
2343 G_SIGNAL_RUN_LAST,
2344 G_STRUCT_OFFSET (GSWindowClass, deactivated)((glong) __builtin_offsetof(GSWindowClass, deactivated)),
2345 NULL((void*)0),
2346 NULL((void*)0),
2347 g_cclosure_marshal_VOID__VOID,
2348 G_TYPE_NONE((GType) ((1) << (2))),
2349 0);
2350
2351 g_object_class_install_property (object_class,
2352 PROP_OBSCURED,
2353 g_param_spec_boolean ("obscured",
2354 NULL((void*)0),
2355 NULL((void*)0),
2356 FALSE(0),
2357 G_PARAM_READABLE));
2358 g_object_class_install_property (object_class,
2359 PROP_DIALOG_UP,
2360 g_param_spec_boolean ("dialog-up",
2361 NULL((void*)0),
2362 NULL((void*)0),
2363 FALSE(0),
2364 G_PARAM_READABLE));
2365 g_object_class_install_property (object_class,
2366 PROP_LOCK_ENABLED,
2367 g_param_spec_boolean ("lock-enabled",
2368 NULL((void*)0),
2369 NULL((void*)0),
2370 FALSE(0),
2371 G_PARAM_READWRITE));
2372 g_object_class_install_property (object_class,
2373 PROP_LOGOUT_ENABLED,
2374 g_param_spec_boolean ("logout-enabled",
2375 NULL((void*)0),
2376 NULL((void*)0),
2377 FALSE(0),
2378 G_PARAM_READWRITE));
2379 g_object_class_install_property (object_class,
2380 PROP_LOGOUT_TIMEOUT,
2381 g_param_spec_long ("logout-timeout",
2382 NULL((void*)0),
2383 NULL((void*)0),
2384 -1,
2385 G_MAXLONG9223372036854775807L,
2386 0,
2387 G_PARAM_READWRITE));
2388 g_object_class_install_property (object_class,
2389 PROP_LOGOUT_COMMAND,
2390 g_param_spec_string ("logout-command",
2391 NULL((void*)0),
2392 NULL((void*)0),
2393 NULL((void*)0),
2394 G_PARAM_READWRITE));
2395 g_object_class_install_property (object_class,
2396 PROP_STATUS_MESSAGE,
2397 g_param_spec_string ("status-message",
2398 NULL((void*)0),
2399 NULL((void*)0),
2400 NULL((void*)0),
2401 G_PARAM_READWRITE));
2402 g_object_class_install_property (object_class,
2403 PROP_KEYBOARD_ENABLED,
2404 g_param_spec_boolean ("keyboard-enabled",
2405 NULL((void*)0),
2406 NULL((void*)0),
2407 FALSE(0),
2408 G_PARAM_READWRITE));
2409 g_object_class_install_property (object_class,
2410 PROP_KEYBOARD_COMMAND,
2411 g_param_spec_string ("keyboard-command",
2412 NULL((void*)0),
2413 NULL((void*)0),
2414 NULL((void*)0),
2415 G_PARAM_READWRITE));
2416
2417 g_object_class_install_property (object_class,
2418 PROP_MONITOR,
2419 g_param_spec_pointer ("monitor",
2420 "Gdk monitor",
2421 "The monitor (in terms of Gdk) which the window is on",
2422 G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
2423}
2424
2425static void
2426create_info_bar (GSWindow *window)
2427{
2428 window->priv->info_bar = gtk_info_bar_new ();
2429 gtk_widget_set_no_show_all (window->priv->info_bar, TRUE(!(0)));
2430 gtk_box_pack_end (GTK_BOX (window->priv->vbox)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->vbox)), ((gtk_box_get_type ()))))))
, window->priv->info_bar, FALSE(0), FALSE(0), 0);
2431}
2432
2433static gboolean
2434on_drawing_area_draw (GtkWidget *widget,
2435 cairo_t *cr)
2436{
2437 cairo_set_operator (cr, CAIRO_OPERATOR_OVER);
2438 cairo_set_source_rgb (cr, 0, 0, 0);
2439 cairo_paint (cr);
2440
2441 return FALSE(0);
2442}
2443
2444static void
2445gs_window_init (GSWindow *window)
2446{
2447 window->priv = gs_window_get_instance_private (window);
2448
2449 window->priv->geometry.x = -1;
2450 window->priv->geometry.y = -1;
2451 window->priv->geometry.width = -1;
2452 window->priv->geometry.height = -1;
2453
2454 window->priv->last_x = -1;
2455 window->priv->last_y = -1;
2456
2457 gtk_window_set_decorated (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
, FALSE(0));
2458
2459 gtk_window_set_skip_taskbar_hint (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
, TRUE(!(0)));
2460 gtk_window_set_skip_pager_hint (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
, TRUE(!(0)));
2461
2462 gtk_window_set_keep_above (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
, TRUE(!(0)));
2463
2464 gtk_window_fullscreen (GTK_WINDOW (window)((((GtkWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_window_get_type ()))))))
);
2465
2466 gtk_widget_set_events (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
,
2467 gtk_widget_get_events (GTK_WIDGET (window)((((GtkWidget*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_widget_get_type ()))))))
)
2468 | GDK_POINTER_MOTION_MASK
2469 | GDK_BUTTON_PRESS_MASK
2470 | GDK_BUTTON_RELEASE_MASK
2471 | GDK_KEY_PRESS_MASK
2472 | GDK_KEY_RELEASE_MASK
2473 | GDK_EXPOSURE_MASK
2474 | GDK_VISIBILITY_NOTIFY_MASK
2475 | GDK_ENTER_NOTIFY_MASK
2476 | GDK_LEAVE_NOTIFY_MASK);
2477
2478 window->priv->vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
2479 gtk_widget_show (window->priv->vbox);
2480 gtk_container_add (GTK_CONTAINER (window)((((GtkContainer*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window)), ((gtk_container_get_type ()))))))
, window->priv->vbox);
2481
2482 window->priv->drawing_area = gtk_drawing_area_new ();
2483 gtk_widget_show (window->priv->drawing_area);
2484 gtk_widget_set_app_paintable (window->priv->drawing_area, TRUE(!(0)));
2485 gtk_box_pack_start (GTK_BOX (window->priv->vbox)((((GtkBox*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((window->priv->vbox)), ((gtk_box_get_type ()))))))
,
2486 window->priv->drawing_area, TRUE(!(0)), TRUE(!(0)), 0);
2487 g_signal_connect (window->priv->drawing_area,g_signal_connect_data ((window->priv->drawing_area), ("draw"
), (((GCallback) (on_drawing_area_draw))), (((void*)0)), ((void
*)0), (GConnectFlags) 0)
2488 "draw",g_signal_connect_data ((window->priv->drawing_area), ("draw"
), (((GCallback) (on_drawing_area_draw))), (((void*)0)), ((void
*)0), (GConnectFlags) 0)
2489 G_CALLBACK (on_drawing_area_draw),g_signal_connect_data ((window->priv->drawing_area), ("draw"
), (((GCallback) (on_drawing_area_draw))), (((void*)0)), ((void
*)0), (GConnectFlags) 0)
2490 NULL)g_signal_connect_data ((window->priv->drawing_area), ("draw"
), (((GCallback) (on_drawing_area_draw))), (((void*)0)), ((void
*)0), (GConnectFlags) 0)
;
2491 create_info_bar (window);
2492
2493}
2494
2495static void
2496remove_command_watches (GSWindow *window)
2497{
2498 if (window->priv->lock_watch_id != 0)
2499 {
2500 g_source_remove (window->priv->lock_watch_id);
2501 window->priv->lock_watch_id = 0;
2502 }
2503 if (window->priv->keyboard_watch_id != 0)
2504 {
2505 g_source_remove (window->priv->keyboard_watch_id);
2506 window->priv->keyboard_watch_id = 0;
2507 }
2508}
2509
2510static void
2511gs_window_finalize (GObject *object)
2512{
2513 GSWindow *window;
2514
2515 g_return_if_fail (object != NULL)do{ (void)0; }while (0);
2516 g_return_if_fail (GS_IS_WINDOW (object))do{ (void)0; }while (0);
2517
2518 window = GS_WINDOW (object)((((GSWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((object)), ((gs_window_get_type ()))))))
;
2519
2520 g_return_if_fail (window->priv != NULL)do{ (void)0; }while (0);
2521
2522 g_free (window->priv->logout_command);
2523 g_free (window->priv->keyboard_command);
2524
2525 if (window->priv->info_bar_timer_id > 0)
2526 {
2527 g_source_remove (window->priv->info_bar_timer_id);
2528 window->priv->info_bar_timer_id = 0;
2529 }
2530
2531 remove_watchdog_timer (window);
2532 remove_popup_dialog_idle (window);
2533
2534 if (window->priv->timer)
2535 {
2536 g_timer_destroy (window->priv->timer);
2537 }
2538
2539 remove_key_events (window);
2540
2541 remove_command_watches (window);
2542
2543 gs_window_dialog_finish (window);
2544
2545 if (window->priv->background_surface)
2546 {
2547 cairo_surface_destroy (window->priv->background_surface);
2548 }
2549
2550 G_OBJECT_CLASS (gs_window_parent_class)((((GObjectClass*) (void *) g_type_check_class_cast ((GTypeClass
*) ((gs_window_parent_class)), (((GType) ((20) << (2)))
)))))
->finalize (object);
2551}
2552
2553GSWindow *
2554gs_window_new (GdkMonitor *monitor,
2555 gboolean lock_enabled)
2556{
2557 GObject *result;
2558 GdkDisplay *display = gdk_monitor_get_display (monitor);
2559 GdkScreen *screen = gdk_display_get_default_screen (display);
2560
2561 result = g_object_new (GS_TYPE_WINDOW(gs_window_get_type ()),
2562 "type", GTK_WINDOW_POPUP,
2563 "screen", screen,
2564 "monitor", monitor,
2565 "lock-enabled", lock_enabled,
2566 "app-paintable", TRUE(!(0)),
2567 NULL((void*)0));
2568
2569 return GS_WINDOW (result)((((GSWindow*) (void *) g_type_check_instance_cast ((GTypeInstance
*) ((result)), ((gs_window_get_type ()))))))
;
2570}
diff --git a/2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-e73a25.html b/2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-e73a25.html new file mode 100644 index 0000000..77b6e79 --- /dev/null +++ b/2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-e73a25.html @@ -0,0 +1,848 @@ + + + +xdg-user-dir-lookup.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:avers/xdg-user-dir-lookup.c
Warning:line 54, column 3
Call to function 'strcpy' is insecure as it does not provide bounding of the memory buffer. Replace unbounded copy functions with analogous functions that support length arguments such as 'strlcpy'. CWE-119
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name xdg-user-dir-lookup.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/savers -resource-dir /usr/lib64/clang/14.0.5 -D HAVE_CONFIG_H -I . -I .. -I . -I . -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -D LIBEXECDIR="/usr/local/libexec" -D MATELOCALEDIR="/usr/local/share/locale" -D DATADIR="/usr/local/share" -internal-isystem /usr/lib64/clang/14.0.5/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/12/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdebug-compilation-dir=/rootdir/savers -ferror-limit 19 -fgnuc-version=4.2.1 -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2022-11-11-203102-6531-1 -x c xdg-user-dir-lookup.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/*
2 This file is not licenced under the GPL like the rest of the code.
3 Its is under the MIT license, to encourage reuse by cut-and-paste.
4
5 Copyright (c) 2007 Red Hat, inc
6 Copyright (C) 2012-2021 MATE Developers
7
8 Permission is hereby granted, free of charge, to any person
9 obtaining a copy of this software and associated documentation files
10 (the "Software"), to deal in the Software without restriction,
11 including without limitation the rights to use, copy, modify, merge,
12 publish, distribute, sublicense, and/or sell copies of the Software,
13 and to permit persons to whom the Software is furnished to do so,
14 subject to the following conditions:
15
16 The above copyright notice and this permission notice shall be
17 included in all copies or substantial portions of the Software.
18
19 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20 EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22 NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
23 BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
24 ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
25 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26 SOFTWARE.
27*/
28
29#include <stdio.h>
30#include <stdlib.h>
31#include <string.h>
32
33#include "xdg-user-dir-lookup.h"
34
35char *
36xdg_user_dir_lookup (const char *type)
37{
38 FILE *file;
39 char *home_dir, *config_home, *config_file;
40 char buffer[512];
41 char *user_dir;
42 char *p, *d;
43 int relative;
44
45 home_dir = getenv ("HOME");
46
47 if (home_dir == NULL((void*)0))
48 return strdup ("/tmp");
49
50 config_home = getenv ("XDG_CONFIG_HOME");
51 if (config_home == NULL((void*)0) || config_home[0] == 0)
52 {
53 config_file = malloc (strlen (home_dir) + strlen ("/.config/user-dirs.dirs") + 1);
54 strcpy (config_file, home_dir);
Call to function 'strcpy' is insecure as it does not provide bounding of the memory buffer. Replace unbounded copy functions with analogous functions that support length arguments such as 'strlcpy'. CWE-119
55 strcat (config_file, "/.config/user-dirs.dirs");
56 }
57 else
58 {
59 config_file = malloc (strlen (config_home) + strlen ("/user-dirs.dirs") + 1);
60 strcpy (config_file, config_home);
61 strcat (config_file, "/user-dirs.dirs");
62 }
63
64 file = fopen (config_file, "r");
65 free (config_file);
66 if (file == NULL((void*)0))
67 goto error;
68
69 user_dir = NULL((void*)0);
70 while (fgets (buffer, sizeof (buffer), file))
71 {
72 /* Remove newline at end */
73 size_t len = strlen (buffer);
74 if (len != 0 && buffer[len-1] == '\n')
75 buffer[len-1] = 0;
76
77 p = buffer;
78 while (*p == ' ' || *p == '\t')
79 p++;
80
81 if (strncmp (p, "XDG_", 4) != 0)
82 continue;
83 p += 4;
84 if (strncmp (p, type, strlen (type)) != 0)
85 continue;
86 p += strlen (type);
87 if (strncmp (p, "_DIR", 4) != 0)
88 continue;
89 p += 4;
90
91 while (*p == ' ' || *p == '\t')
92 p++;
93
94 if (*p != '=')
95 continue;
96 p++;
97
98 while (*p == ' ' || *p == '\t')
99 p++;
100
101 if (*p != '"')
102 continue;
103 p++;
104
105 relative = 0;
106 if (strncmp (p, "$HOME/", 6) == 0)
107 {
108 p += 6;
109 relative = 1;
110 }
111 else if (*p != '/')
112 continue;
113
114 if (relative)
115 {
116 user_dir = malloc (strlen (home_dir) + 1 + strlen (p) + 1);
117 strcpy (user_dir, home_dir);
118 strcat (user_dir, "/");
119 }
120 else
121 {
122 user_dir = malloc (strlen (p) + 1);
123 *user_dir = 0;
124 }
125
126 d = user_dir + strlen (user_dir);
127 while (*p && *p != '"')
128 {
129 if ((*p == '\\') && (*(p+1) != 0))
130 p++;
131 *d++ = *p++;
132 }
133 *d = 0;
134 }
135 fclose (file);
136
137 if (user_dir)
138 return user_dir;
139
140error:
141 /* Special case desktop for historical compatibility */
142 if (strcmp (type, "DESKTOP") == 0)
143 {
144 user_dir = malloc (strlen (home_dir) + strlen ("/Desktop") + 1);
145 strcpy (user_dir, home_dir);
146 strcat (user_dir, "/Desktop");
147 return user_dir;
148 }
149 else
150 return strdup (home_dir);
151}
152
153#ifdef STANDALONE
154
155int
156main (int argc, char *argv[])
157{
158 if (argc != 2)
159 {
160 fprintf (stderrstderr, "Usage %s <dir-type>\n", argv[0]);
161 exit (1);
162 }
163
164 printf ("%s\n", xdg_user_dir_lookup (argv[1]));
165 return 0;
166}
167
168#endif
diff --git a/2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-fa48d9.html b/2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-fa48d9.html new file mode 100644 index 0000000..7e17c25 --- /dev/null +++ b/2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-fa48d9.html @@ -0,0 +1,1490 @@ + + + +gs-auth-pam.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rc/gs-auth-pam.c
Warning:line 382, column 2
Value stored to 'ret' is never read
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name gs-auth-pam.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/14.0.5 -D HAVE_CONFIG_H -I . -I .. -I . -I . -D MATEMENU_I_KNOW_THIS_IS_UNSTABLE -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/dconf -I /usr/include/mate-menus -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/dconf -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/dconf -I /usr/include/mate-menus -D PREFIX="/usr/local" -D BINDIR="/usr/local/bin" -D LIBDIR="/usr/local/lib" -D LIBEXECDIR="/usr/local/libexec" -D DATADIR="/usr/local/share" -D SYSCONFDIR="/usr/local/etc" -D MATELOCALEDIR="/usr/local/share/locale" -D PKGLIBEXECDIR="/usr/local/libexec/mate-screensaver" -D SAVERDIR="/usr/local/libexec/mate-screensaver" -D THEMESDIR="/usr/local/share/mate-screensaver/themes" -D GTKBUILDERDIR="/usr/local/share/mate-screensaver" -D MATE_SCREENSAVER_GL_HELPER_PATH="/usr/local/libexec/mate-screensaver-gl-helper" -D PAM_SERVICE_NAME="mate-screensaver" -D G_DISABLE_ASSERT -D G_DISABLE_CHECKS -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -internal-isystem /usr/lib64/clang/14.0.5/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/12/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2022-11-11-203102-6531-1 -x c gs-auth-pam.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
2 *
3 * Copyright (C) 2006 William Jon McCann <mccann@jhu.edu>
4 * Copyright (C) 2006 Ray Strode <rstrode@redhat.com>
5 * Copyright (C) 2003 Bill Nottingham <notting@redhat.com>
6 * Copyright (c) 1993-2003 Jamie Zawinski <jwz@jwz.org>
7 * Copyright (C) 2012-2021 MATE Developers
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License as
11 * published by the Free Software Foundation; either version 2 of the
12 * License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful, but
15 * WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
22 * 02110-1301, USA.
23 *
24 */
25
26#include "config.h"
27
28#include <stdlib.h>
29#ifdef HAVE_UNISTD_H1
30# include <unistd.h>
31#endif
32
33#include <fcntl.h>
34#include <stdio.h>
35#include <string.h>
36#include <sys/types.h>
37#include <pwd.h>
38#include <grp.h>
39#include <security/pam_appl.h>
40#include <signal.h>
41#include <errno(*__errno_location ()).h>
42
43#include <glib.h>
44#include <glib/gstdio.h>
45#include <glib/gi18n.h>
46#include <gtk/gtk.h>
47
48#include "gs-auth.h"
49#include "gs-auth-pam.h"
50
51#include "subprocs.h"
52
53/* Some time between Red Hat 4.2 and 7.0, the words were transposed
54 in the various PAM_x_CRED macro names. Yay!
55*/
56#ifndef PAM_REFRESH_CRED0x0010U
57# define PAM_REFRESH_CRED0x0010U PAM_CRED_REFRESH
58#endif
59
60#ifdef HAVE_PAM_FAIL_DELAY
61/* We handle delays ourself.*/
62/* Don't set this to 0 (Linux bug workaround.) */
63# define PAM_NO_DELAY(pamh)pam_fail_delay ((pamh), 1) pam_fail_delay ((pamh), 1)
64#else /* !HAVE_PAM_FAIL_DELAY */
65# define PAM_NO_DELAY(pamh)pam_fail_delay ((pamh), 1) /* */
66#endif /* !HAVE_PAM_FAIL_DELAY */
67
68/* On SunOS 5.6, and on Linux with PAM 0.64, pam_strerror() takes two args.
69 On some other Linux systems with some other version of PAM (e.g.,
70 whichever Debian release comes with a 2.2.5 kernel) it takes one arg.
71 I can't tell which is more "recent" or "correct" behavior, so configure
72 figures out which is in use for us. Shoot me!
73*/
74#ifdef PAM_STRERROR_TWO_ARGS1
75# define PAM_STRERROR(pamh, status)pam_strerror((pamh), (status)) pam_strerror((pamh), (status))
76#else /* !PAM_STRERROR_TWO_ARGS */
77# define PAM_STRERROR(pamh, status)pam_strerror((pamh), (status)) pam_strerror((status))
78#endif /* !PAM_STRERROR_TWO_ARGS */
79
80static gboolean verbose_enabled = FALSE(0);
81static pam_handle_t *pam_handle = NULL((void*)0);
82static gboolean did_we_ask_for_password = FALSE(0);
83
84struct pam_closure
85{
86 const char *username;
87 GSAuthMessageFunc cb_func;
88 gpointer cb_data;
89 int signal_fd;
90 int result;
91};
92
93typedef struct
94{
95 struct pam_closure *closure;
96 GSAuthMessageStyle style;
97 const char *msg;
98 char **resp;
99 gboolean should_interrupt_stack;
100} GsAuthMessageHandlerData;
101
102static GCond message_handled_condition;
103static GMutex message_handler_mutex;
104
105GQuark
106gs_auth_error_quark (void)
107{
108 static GQuark quark = 0;
109 if (! quark)
110 {
111 quark = g_quark_from_static_string ("gs_auth_error");
112 }
113
114 return quark;
115}
116
117void
118gs_auth_set_verbose (gboolean enabled)
119{
120 verbose_enabled = enabled;
121}
122
123gboolean
124gs_auth_get_verbose (void)
125{
126 return verbose_enabled;
127}
128
129static gboolean
130auth_message_handler (GSAuthMessageStyle style,
131 const char *msg,
132 char **response,
133 gpointer data)
134{
135 gboolean ret;
136
137 ret = TRUE(!(0));
138 *response = NULL((void*)0);
139
140 switch (style)
141 {
142 case GS_AUTH_MESSAGE_PROMPT_ECHO_ON:
143 break;
144 case GS_AUTH_MESSAGE_PROMPT_ECHO_OFF:
145 if (msg != NULL((void*)0) && g_str_has_prefix (msg, _("Password:")gettext ("Password:")))
146 {
147 did_we_ask_for_password = TRUE(!(0));
148 }
149 break;
150 case GS_AUTH_MESSAGE_ERROR_MSG:
151 break;
152 case GS_AUTH_MESSAGE_TEXT_INFO:
153 break;
154 default:
155 g_assert_not_reached ()do { (void) 0; __builtin_unreachable (); } while (0);
156 }
157
158 return ret;
159}
160
161static gboolean
162gs_auth_queued_message_handler (gpointer user_data)
163{
164 GsAuthMessageHandlerData *data = user_data;
165 gboolean res;
166
167 if (gs_auth_get_verbose ())
168 {
169 g_message ("Waiting for lock");
170 }
171
172 g_mutex_lock (&message_handler_mutex);
173
174 if (gs_auth_get_verbose ())
175 {
176 g_message ("Waiting for response");
177 }
178
179 res = data->closure->cb_func (data->style,
180 data->msg,
181 data->resp,
182 data->closure->cb_data);
183
184 data->should_interrupt_stack = res == FALSE(0);
185
186 g_cond_signal (&message_handled_condition);
187 g_mutex_unlock (&message_handler_mutex);
188
189 if (gs_auth_get_verbose ())
190 {
191 g_message ("Got response");
192 }
193
194 return FALSE(0);
195}
196
197static gboolean
198gs_auth_run_message_handler (struct pam_closure *c,
199 GSAuthMessageStyle style,
200 const char *msg,
201 char **resp)
202{
203 GsAuthMessageHandlerData data;
204
205 data.closure = c;
206 data.style = style;
207 data.msg = msg;
208 data.resp = resp;
209 data.should_interrupt_stack = TRUE(!(0));
210
211 g_mutex_lock (&message_handler_mutex);
212
213 /* Queue the callback in the gui (the main) thread
214 */
215 g_idle_add (gs_auth_queued_message_handler, &data);
216
217 if (gs_auth_get_verbose ())
218 {
219 g_message ("Waiting for respose to message style %d: '%s'", style, msg);
220 }
221
222 /* Wait for the response
223 */
224 g_cond_wait (&message_handled_condition,
225 &message_handler_mutex);
226 g_mutex_unlock (&message_handler_mutex);
227
228 if (gs_auth_get_verbose ())
229 {
230 g_message ("Got respose to message style %d: interrupt:%d", style, data.should_interrupt_stack);
231 }
232
233 return data.should_interrupt_stack == FALSE(0);
234}
235
236static int
237pam_conversation (int nmsgs,
238 const struct pam_message **msg,
239 struct pam_response **resp,
240 void *closure)
241{
242 int replies = 0;
243 struct pam_response *reply = NULL((void*)0);
244 struct pam_closure *c = (struct pam_closure *) closure;
245 gboolean res;
246 int ret;
247
248 reply = (struct pam_response *) calloc (nmsgs, sizeof (*reply));
249
250 if (reply == NULL((void*)0))
251 {
252 return PAM_CONV_ERR19;
253 }
254
255 res = TRUE(!(0));
256 ret = PAM_SUCCESS0;
257
258 for (replies = 0; replies < nmsgs && ret == PAM_SUCCESS0; replies++)
259 {
260 GSAuthMessageStyle style;
261 char *utf8_msg;
262
263 style = pam_style_to_gs_style (msg [replies]->msg_style);
264
265 utf8_msg = g_locale_to_utf8 (msg [replies]->msg,
266 -1,
267 NULL((void*)0),
268 NULL((void*)0),
269 NULL((void*)0));
270
271 /* if we couldn't convert text from locale then
272 * assume utf-8 and hope for the best */
273 if (utf8_msg == NULL((void*)0))
274 {
275 char *p;
276 char *q;
277
278 utf8_msg = g_strdup (msg [replies]->msg);
279
280 p = utf8_msg;
281 while (*p != '\0' && !g_utf8_validate ((const char *)p, -1, (const char **)&q))
282 {
283 *q = '?';
284 p = q + 1;
285 }
286 }
287
288 /* handle message locally first */
289 auth_message_handler (style,
290 utf8_msg,
291 &reply [replies].resp,
292 NULL((void*)0));
293
294 if (c->cb_func != NULL((void*)0))
295 {
296 if (gs_auth_get_verbose ())
297 {
298 g_message ("Handling message style %d: '%s'", style, utf8_msg);
299 }
300
301 /* blocks until the gui responds
302 */
303 res = gs_auth_run_message_handler (c,
304 style,
305 utf8_msg,
306 &reply [replies].resp);
307
308 if (gs_auth_get_verbose ())
309 {
310 g_message ("Msg handler returned %d", res);
311 }
312
313 /* If the handler returns FALSE - interrupt the PAM stack */
314 if (res)
315 {
316 reply [replies].resp_retcode = PAM_SUCCESS0;
317 }
318 else
319 {
320 int i;
321 for (i = 0; i <= replies; i++)
322 {
323 free (reply [i].resp);
324 }
325 free (reply);
326 reply = NULL((void*)0);
327 ret = PAM_CONV_ERR19;
328 }
329 }
330
331 g_free (utf8_msg);
332 }
333
334 *resp = reply;
335
336 return ret;
337}
338
339static gboolean
340close_pam_handle (int status)
341{
342
343 if (pam_handle != NULL((void*)0))
344 {
345 int status2;
346
347 status2 = pam_end (pam_handle, status);
348 pam_handle = NULL((void*)0);
349
350 if (gs_auth_get_verbose ())
351 {
352 g_message (" pam_end (...) ==> %d (%s)",
353 status2,
354 (status2 == PAM_SUCCESS0 ? "Success" : "Failure"));
355 }
356 }
357
358 return TRUE(!(0));
359}
360
361static gboolean
362create_pam_handle (const char *username,
363 const char *display,
364 struct pam_conv *conv,
365 int *status_code)
366{
367 int status;
368 const char *service = PAM_SERVICE_NAME"mate-screensaver";
369 char *disp;
370 gboolean ret;
371
372 if (pam_handle != NULL((void*)0))
373 {
374 g_warning ("create_pam_handle: Stale pam handle around, cleaning up");
375 close_pam_handle (PAM_SUCCESS0);
376 }
377
378 /* init things */
379 pam_handle = NULL((void*)0);
380 status = -1;
381 disp = NULL((void*)0);
382 ret = TRUE(!(0));
Value stored to 'ret' is never read
383
384 /* Initialize a PAM session for the user */
385 if ((status = pam_start (service, username, conv, &pam_handle)) != PAM_SUCCESS0)
386 {
387 pam_handle = NULL((void*)0);
388 g_warning (_("Unable to establish service %s: %s\n")gettext ("Unable to establish service %s: %s\n"),
389 service,
390 PAM_STRERROR (NULL, status)pam_strerror((((void*)0)), (status)));
391
392 if (status_code != NULL((void*)0))
393 {
394 *status_code = status;
395 }
396
397 ret = FALSE(0);
398 goto out;
399 }
400
401 if (gs_auth_get_verbose ())
402 {
403 g_message ("pam_start (\"%s\", \"%s\", ...) ==> %d (%s)",
404 service,
405 username,
406 status,
407 PAM_STRERROR (pam_handle, status)pam_strerror((pam_handle), (status)));
408 }
409
410 disp = g_strdup (display);
411 if (disp == NULL((void*)0))
412 {
413 disp = g_strdup (":0.0");
414 }
415
416 if ((status = pam_set_item (pam_handle, PAM_TTY3, disp)) != PAM_SUCCESS0)
417 {
418 g_warning (_("Can't set PAM_TTY=%s")gettext ("Can't set PAM_TTY=%s"), display);
419
420 if (status_code != NULL((void*)0))
421 {
422 *status_code = status;
423 }
424
425 ret = FALSE(0);
426 goto out;
427 }
428
429 ret = TRUE(!(0));
430 g_cond_init (&message_handled_condition);
431 g_mutex_init (&message_handler_mutex);
432
433out:
434 if (status_code != NULL((void*)0))
435 {
436 *status_code = status;
437 }
438
439 g_free (disp);
440
441 return ret;
442}
443
444static void
445set_pam_error (GError **error,
446 int status)
447{
448 if (status == PAM_AUTH_ERR7 || status == PAM_USER_UNKNOWN10)
449 {
450 char *msg;
451
452 if (did_we_ask_for_password)
453 {
454 msg = g_strdup (_("Incorrect password.")gettext ("Incorrect password."));
455 }
456 else
457 {
458 msg = g_strdup (_("Authentication failed.")gettext ("Authentication failed."));
459 }
460
461 g_set_error (error,
462 GS_AUTH_ERRORgs_auth_error_quark (),
463 GS_AUTH_ERROR_AUTH_ERROR,
464 "%s",
465 msg);
466 g_free (msg);
467 }
468 else if (status == PAM_PERM_DENIED6)
469 {
470 g_set_error (error,
471 GS_AUTH_ERRORgs_auth_error_quark (),
472 GS_AUTH_ERROR_AUTH_DENIED,
473 "%s",
474 _("Not permitted to gain access at this time.")gettext ("Not permitted to gain access at this time."));
475 }
476 else if (status == PAM_ACCT_EXPIRED13)
477 {
478 g_set_error (error,
479 GS_AUTH_ERRORgs_auth_error_quark (),
480 GS_AUTH_ERROR_AUTH_DENIED,
481 "%s",
482 _("No longer permitted to access the system.")gettext ("No longer permitted to access the system."));
483 }
484
485}
486
487static gpointer
488gs_auth_thread_func (gpointer data)
489{
490 int auth_operation_fd;
491 static const int flags = 0;
492 int status;
493 int status2;
494 struct timespec timeout;
495 sigset_t set;
496 const void *p;
497
498 auth_operation_fd = GPOINTER_TO_INT (data)((gint) (glong) (data));
499
500 timeout.tv_sec = 0;
501 timeout.tv_nsec = 1;
502
503 set = block_sigchld ();
504
505 status = pam_authenticate (pam_handle, flags);
506
507 sigtimedwait (&set, NULL((void*)0), &timeout);
508 unblock_sigchld ();
509
510 if (gs_auth_get_verbose ())
511 {
512 g_message (" pam_authenticate (...) ==> %d (%s)",
513 status,
514 PAM_STRERROR (pam_handle, status)pam_strerror((pam_handle), (status)));
515 }
516
517 if (status != PAM_SUCCESS0)
518 {
519 goto done;
520 }
521
522 if ((status = pam_get_item (pam_handle, PAM_USER2, &p)) != PAM_SUCCESS0)
523 {
524 /* is not really an auth problem, but it will
525 pretty much look as such, it shouldn't really
526 happen */
527 goto done;
528 }
529
530 /* We don't actually care if the account modules fail or succeed,
531 * but we need to run them anyway because certain pam modules
532 * depend on side effects of the account modules getting run.
533 */
534 status2 = pam_acct_mgmt (pam_handle, 0);
535
536 if (gs_auth_get_verbose ())
537 {
538 g_message ("pam_acct_mgmt (...) ==> %d (%s)\n",
539 status2,
540 PAM_STRERROR (pam_handle, status2)pam_strerror((pam_handle), (status2)));
541 }
542
543 /* FIXME: should we handle these? */
544 switch (status2)
545 {
546 case PAM_SUCCESS0:
547 break;
548 case PAM_NEW_AUTHTOK_REQD12:
549 break;
550 case PAM_AUTHINFO_UNAVAIL9:
551 break;
552 case PAM_ACCT_EXPIRED13:
553 break;
554 case PAM_PERM_DENIED6:
555 break;
556 default :
557 break;
558 }
559
560 /* Each time we successfully authenticate, refresh credentials,
561 for Kerberos/AFS/DCE/etc. If this fails, just ignore that
562 failure and blunder along; it shouldn't matter.
563
564 Note: this used to be PAM_REFRESH_CRED instead of
565 PAM_REINITIALIZE_CRED, but Jason Heiss <jheiss@ee.washington.edu>
566 says that the Linux PAM library ignores that one, and only refreshes
567 credentials when using PAM_REINITIALIZE_CRED.
568 */
569 status2 = pam_setcred (pam_handle, PAM_REINITIALIZE_CRED0x0008U);
570 if (gs_auth_get_verbose ())
571 {
572 g_message (" pam_setcred (...) ==> %d (%s)",
573 status2,
574 PAM_STRERROR (pam_handle, status2)pam_strerror((pam_handle), (status2)));
575 }
576
577done:
578 /* we're done, close the fd and wake up the main
579 * loop
580 */
581 close (auth_operation_fd);
582
583 return GINT_TO_POINTER (status)((gpointer) (glong) (status));
584}
585
586static gboolean
587gs_auth_loop_quit (GIOChannel *source,
588 GIOCondition condition,
589 gboolean *thread_done)
590{
591 *thread_done = TRUE(!(0));
592 gtk_main_quit ();
593 return FALSE(0);
594}
595
596static gboolean
597gs_auth_pam_verify_user (pam_handle_t *handle,
598 int *status)
599{
600 GThread *auth_thread;
601 GIOChannel *channel;
602 guint watch_id;
603 int auth_operation_fds[2];
604 int auth_status;
605 gboolean thread_done;
606
607 channel = NULL((void*)0);
608 watch_id = 0;
609 auth_status = PAM_AUTH_ERR7;
610
611 /* This pipe gives us a set of fds we can hook into
612 * the event loop to be notified when our helper thread
613 * is ready to be reaped.
614 */
615 if (pipe (auth_operation_fds) < 0)
616 {
617 goto out;
618 }
619
620 if (fcntl (auth_operation_fds[0], F_SETFD2, FD_CLOEXEC1) < 0)
621 {
622 close (auth_operation_fds[0]);
623 close (auth_operation_fds[1]);
624 goto out;
625 }
626
627 if (fcntl (auth_operation_fds[1], F_SETFD2, FD_CLOEXEC1) < 0)
628 {
629 close (auth_operation_fds[0]);
630 close (auth_operation_fds[1]);
631 goto out;
632 }
633
634 channel = g_io_channel_unix_new (auth_operation_fds[0]);
635
636 /* we use a recursive main loop to process ui events
637 * while we wait on a thread to handle the blocking parts
638 * of pam authentication.
639 */
640 thread_done = FALSE(0);
641 watch_id = g_io_add_watch (channel, G_IO_ERR | G_IO_HUP,
642 (GIOFunc) gs_auth_loop_quit, &thread_done);
643
644 auth_thread = g_thread_new ("auththread",
645 gs_auth_thread_func,
646 GINT_TO_POINTER (auth_operation_fds[1])((gpointer) (glong) (auth_operation_fds[1])));
647
648 if (auth_thread == NULL((void*)0))
649 {
650 goto out;
651 }
652
653 gtk_main ();
654
655 /* if the event loop was quit before the thread is done then we can't
656 * reap the thread without blocking on it finishing. The
657 * thread may not ever finish though if the pam module is blocking.
658 *
659 * The only time the event loop is going to stop when the thread isn't
660 * done, however, is if the dialog quits early (from, e.g., "cancel"),
661 * so we can just exit. An alternative option would be to switch to
662 * using pthreads directly and calling pthread_cancel.
663 */
664 if (!thread_done)
665 {
666 raise (SIGTERM15);
667 }
668
669 auth_status = GPOINTER_TO_INT (g_thread_join (auth_thread))((gint) (glong) (g_thread_join (auth_thread)));
670
671out:
672 if (watch_id != 0)
673 {
674 g_source_remove (watch_id);
675 watch_id = 0;
676 }
677
678 if (channel != NULL((void*)0))
679 {
680 g_io_channel_unref (channel);
681 }
682
683 if (status)
684 {
685 *status = auth_status;
686 }
687
688 return auth_status == PAM_SUCCESS0;
689}
690
691gboolean
692gs_auth_verify_user (const char *username,
693 const char *display,
694 GSAuthMessageFunc func,
695 gpointer data,
696 GError **error)
697{
698 int status = -1;
699 struct pam_conv conv;
700 struct pam_closure c;
701 struct passwd *pwent;
702
703 pwent = getpwnam (username);
704 if (pwent == NULL((void*)0))
705 {
706 return FALSE(0);
707 }
708
709 c.username = username;
710 c.cb_func = func;
711 c.cb_data = data;
712
713 conv.conv = &pam_conversation;
714 conv.appdata_ptr = (void *) &c;
715
716 /* Initialize PAM. */
717 create_pam_handle (username, display, &conv, &status);
718 if (status != PAM_SUCCESS0)
719 {
720 goto done;
721 }
722
723 pam_set_item (pam_handle, PAM_USER_PROMPT9, _("Username:")gettext ("Username:"));
724
725 PAM_NO_DELAY(pam_handle)pam_fail_delay ((pam_handle), 1);
726
727 did_we_ask_for_password = FALSE(0);
728 if (! gs_auth_pam_verify_user (pam_handle, &status))
729 {
730 goto done;
731 }
732
733done:
734 if (status != PAM_SUCCESS0)
735 {
736 set_pam_error (error, status);
737 }
738
739 close_pam_handle (status);
740
741 return (status == PAM_SUCCESS0 ? TRUE(!(0)) : FALSE(0));
742}
743
744gboolean
745gs_auth_init (void)
746{
747 return TRUE(!(0));
748}
749
750gboolean
751gs_auth_priv_init (void)
752{
753 /* We have nothing to do at init-time.
754 However, we might as well do some error checking.
755 If "/etc/pam.d" exists and is a directory, but "/etc/pam.d/xlock"
756 does not exist, warn that PAM probably isn't going to work.
757
758 This is a priv-init instead of a non-priv init in case the directory
759 is unreadable or something (don't know if that actually happens.)
760 */
761 const char dir [] = "/etc/pam.d";
762 const char file [] = "/etc/pam.d/" PAM_SERVICE_NAME"mate-screensaver";
763 const char file2 [] = "/etc/pam.conf";
764 struct stat st;
765
766 if (g_statstat (dir, &st) == 0 && st.st_mode & S_IFDIR0040000)
767 {
768 if (g_statstat (file, &st) != 0)
769 {
770 g_warning ("%s does not exist.\n"
771 "Authentication via PAM is unlikely to work.",
772 file);
773 }
774 }
775 else if (g_statstat (file2, &st) == 0)
776 {
777 FILE *f = g_fopenfopen (file2, "r");
778 if (f)
779 {
780 gboolean ok = FALSE(0);
781 char buf[255];
782 while (fgets (buf, sizeof(buf), f))
783 {
784 if (strstr (buf, PAM_SERVICE_NAME"mate-screensaver"))
785 {
786 ok = TRUE(!(0));
787 break;
788 }
789 }
790
791 fclose (f);
792 if (!ok)
793 {
794 g_warning ("%s does not list the `%s' service.\n"
795 "Authentication via PAM is unlikely to work.",
796 file2, PAM_SERVICE_NAME"mate-screensaver");
797 }
798 }
799 /* else warn about file2 existing but being unreadable? */
800 }
801 else
802 {
803 g_warning ("Neither %s nor %s exist.\n"
804 "Authentication via PAM is unlikely to work.",
805 file2, file);
806 }
807
808 /* Return true anyway, just in case. */
809 return TRUE(!(0));
810}
diff --git a/2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-fc5910.html b/2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-fc5910.html new file mode 100644 index 0000000..234f75b --- /dev/null +++ b/2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/report-fc5910.html @@ -0,0 +1,815 @@ + + + +test-fade.c + + + + + + + + + + + + + + + + + + + + + + + + + + +

Bug Summary

+ + + + +
File:rc/test-fade.c
Warning:line 94, column 3
This statement is never executed
+ +

Annotated Source Code

+

Press '?' + to see keyboard shortcuts

+ + +
clang -cc1 -cc1 -triple x86_64-redhat-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name test-fade.c -analyzer-store=region -analyzer-opt-analyze-nested-blocks -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model static -mframe-pointer=all -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fcoverage-compilation-dir=/rootdir/src -resource-dir /usr/lib64/clang/14.0.5 -D HAVE_CONFIG_H -I . -I .. -I . -I . -D MATEMENU_I_KNOW_THIS_IS_UNSTABLE -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/dconf -I /usr/include/mate-menus -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/dconf -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/atk-1.0 -I /usr/include/at-spi2-atk/2.0 -I /usr/include/dbus-1.0 -I /usr/lib64/dbus-1.0/include -I /usr/include/at-spi-2.0 -I /usr/include/mate-desktop-2.0 -I /usr/include/startup-notification-1.0 -I /usr/include/dconf -I /usr/include/mate-menus -D PREFIX="/usr/local" -D BINDIR="/usr/local/bin" -D LIBDIR="/usr/local/lib" -D LIBEXECDIR="/usr/local/libexec" -D DATADIR="/usr/local/share" -D SYSCONFDIR="/usr/local/etc" -D MATELOCALEDIR="/usr/local/share/locale" -D PKGLIBEXECDIR="/usr/local/libexec/mate-screensaver" -D SAVERDIR="/usr/local/libexec/mate-screensaver" -D THEMESDIR="/usr/local/share/mate-screensaver/themes" -D GTKBUILDERDIR="/usr/local/share/mate-screensaver" -D MATE_SCREENSAVER_GL_HELPER_PATH="/usr/local/libexec/mate-screensaver-gl-helper" -D PAM_SERVICE_NAME="mate-screensaver" -D G_DISABLE_ASSERT -D G_DISABLE_CHECKS -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/gtk-3.0 -I /usr/include/pango-1.0 -I /usr/include/harfbuzz -I /usr/include/freetype2 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -I /usr/include/fribidi -I /usr/include/libxml2 -I /usr/include/cairo -I /usr/include/pixman-1 -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/gio-unix-2.0 -I /usr/include/cloudproviders -I /usr/include/gdk-pixbuf-2.0 -I /usr/include/glib-2.0 -I /usr/lib64/glib-2.0/include -I /usr/include/sysprof-4 -I /usr/include/libpng16 -I /usr/include/libmount -I /usr/include/blkid -internal-isystem /usr/lib64/clang/14.0.5/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-redhat-linux/12/../../../../x86_64-redhat-linux/include -internal-externc-isystem /include -internal-externc-isystem /usr/include -Wno-unused-parameter -fdebug-compilation-dir=/rootdir/src -ferror-limit 19 -fgnuc-version=4.2.1 -analyzer-checker deadcode.DeadStores -analyzer-checker alpha.deadcode.UnreachableCode -analyzer-checker alpha.core.CastSize -analyzer-checker alpha.core.CastToStruct -analyzer-checker alpha.core.IdenticalExpr -analyzer-checker alpha.core.SizeofPtr -analyzer-checker alpha.security.ArrayBoundV2 -analyzer-checker alpha.security.MallocOverflow -analyzer-checker alpha.security.ReturnPtrRange -analyzer-checker alpha.unix.SimpleStream -analyzer-checker alpha.unix.cstring.BufferOverlap -analyzer-checker alpha.unix.cstring.NotNullTerminated -analyzer-checker alpha.unix.cstring.OutOfBounds -analyzer-checker alpha.core.FixedAddr -analyzer-checker security.insecureAPI.strcpy -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /rootdir/html-report/2022-11-11-203102-6531-1 -x c test-fade.c +
+ + + +
+ + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
1/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*-
2 *
3 * Copyright (C) 2005 William Jon McCann <mccann@jhu.edu>
4 * Copyright (C) 2012-2021 MATE Developers
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License as
8 * published by the Free Software Foundation; either version 2 of the
9 * License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
19 * 02110-1301, USA.
20 *
21 * Authors: William Jon McCann <mccann@jhu.edu>
22 *
23 */
24
25#include "config.h"
26
27#include <stdlib.h>
28#include <string.h>
29#include <sys/time.h>
30#include <sys/types.h>
31#include <sys/wait.h>
32#include <termios.h>
33#include <unistd.h>
34
35#include <glib/gi18n.h>
36#include <gdk/gdkx.h>
37#include <gtk/gtk.h>
38
39#include "gs-fade.h"
40#include "gs-debug.h"
41
42#ifdef HAVE_XF86VMODE_GAMMA1
43# include <X11/extensions/xf86vmode.h>
44#endif
45
46#define XF86_VIDMODE_NAME"XFree86-VidModeExtension" "XFree86-VidModeExtension"
47
48static void
49test_fade (void)
50{
51 GSFade *fade;
52 int reps = 2;
53 int delay = 2;
54
55 fade = gs_fade_new ();
56
57 while (reps-- > 0)
58 {
59
60 g_print ("fading out...");
61 gs_fade_sync (fade, 1000);
62 g_print ("done.\n");
63
64 g_print ("fading in...");
65 gs_fade_reset (fade);
66 g_print ("done.\n");
67
68 if (delay)
69 {
70 sleep (delay);
71 }
72 }
73
74 g_object_unref (fade);
75}
76
77int
78main (int argc,
79 char **argv)
80{
81 GError *error = NULL((void*)0);
82 int op, event, err;
83
84#ifdef ENABLE_NLS1
85 bindtextdomain (GETTEXT_PACKAGE"mate-screensaver", MATELOCALEDIR"/usr/local/share/locale");
86# ifdef HAVE_BIND_TEXTDOMAIN_CODESET
87 bind_textdomain_codeset (GETTEXT_PACKAGE"mate-screensaver", "UTF-8");
88# endif
89 textdomain (GETTEXT_PACKAGE"mate-screensaver");
90#endif
91
92 if (error)
93 {
94 fprintf (stderrstderr, "%s\n", error->message);
This statement is never executed
95 exit (1);
96 }
97
98 if (! gtk_init_with_args (&argc, &argv, NULL((void*)0), NULL((void*)0), NULL((void*)0), &error))
99 {
100 fprintf (stderrstderr, "%s", error->message);
101 g_error_free (error);
102 exit (1);
103 }
104
105 if (! XQueryExtension (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ())(gdk_x11_display_get_xdisplay (gdk_display_get_default ())), XF86_VIDMODE_NAME"XFree86-VidModeExtension", &op, &event, &err))
106 {
107 g_message ("no " XF86_VIDMODE_NAME"XFree86-VidModeExtension" " extension");
108 }
109 else
110 {
111# ifdef HAVE_XF86VMODE_GAMMA1
112 int major;
113 int minor;
114
115 if (! XF86VidModeQueryVersion (GDK_DISPLAY_XDISPLAY (gdk_display_get_default ())(gdk_x11_display_get_xdisplay (gdk_display_get_default ())), &major, &minor))
116 {
117 g_message ("unable to get " XF86_VIDMODE_NAME"XFree86-VidModeExtension" " version");
118 }
119 else
120 {
121 g_message (XF86_VIDMODE_NAME"XFree86-VidModeExtension" " version %d.%d", major, minor);
122 }
123# else /* !HAVE_XF86VMODE_GAMMA */
124 g_message ("no support for display's " XF86_VIDMODE_NAME"XFree86-VidModeExtension" " extension");
125# endif /* !HAVE_XF86VMODE_GAMMA */
126 }
127
128 gs_debug_init (TRUE(!(0)), FALSE(0));
129
130 test_fade ();
131
132 gs_debug_shutdown ();
133
134 return 0;
135}
diff --git a/2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/scanview.css b/2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/scanview.css new file mode 100644 index 0000000..cf8a5a6 --- /dev/null +++ b/2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/scanview.css @@ -0,0 +1,62 @@ +body { color:#000000; background-color:#ffffff } +body { font-family: Helvetica, sans-serif; font-size:9pt } +h1 { font-size: 14pt; } +h2 { font-size: 12pt; } +table { font-size:9pt } +table { border-spacing: 0px; border: 1px solid black } +th, table thead { + background-color:#eee; color:#666666; + font-weight: bold; cursor: default; + text-align:center; + font-weight: bold; font-family: Verdana; + white-space:nowrap; +} +.W { font-size:0px } +th, td { padding:5px; padding-left:8px; text-align:left } +td.SUMM_DESC { padding-left:12px } +td.DESC { white-space:pre } +td.Q { text-align:right } +td { text-align:left } +tbody.scrollContent { overflow:auto } + +table.form_group { + background-color: #ccc; + border: 1px solid #333; + padding: 2px; +} + +table.form_inner_group { + background-color: #ccc; + border: 1px solid #333; + padding: 0px; +} + +table.form { + background-color: #999; + border: 1px solid #333; + padding: 2px; +} + +td.form_label { + text-align: right; + vertical-align: top; +} +/* For one line entires */ +td.form_clabel { + text-align: right; + vertical-align: center; +} +td.form_value { + text-align: left; + vertical-align: top; +} +td.form_submit { + text-align: right; + vertical-align: top; +} + +h1.SubmitFail { + color: #f00; +} +h1.SubmitOk { +} diff --git a/2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/sorttable.js b/2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/sorttable.js new file mode 100644 index 0000000..32faa07 --- /dev/null +++ b/2022-11-11-203102-6531-1@d85b90eff925_v1.27.0/sorttable.js @@ -0,0 +1,492 @@ +/* + SortTable + version 2 + 7th April 2007 + Stuart Langridge, http://www.kryogenix.org/code/browser/sorttable/ + + Instructions: + Download this file + Add to your HTML + Add class="sortable" to any table you'd like to make sortable + Click on the headers to sort + + Thanks to many, many people for contributions and suggestions. + Licenced as X11: http://www.kryogenix.org/code/browser/licence.html + This basically means: do what you want with it. +*/ + + +var stIsIE = /*@cc_on!@*/false; + +sorttable = { + init: function() { + // quit if this function has already been called + if (arguments.callee.done) return; + // flag this function so we don't do the same thing twice + arguments.callee.done = true; + // kill the timer + if (_timer) clearInterval(_timer); + + if (!document.createElement || !document.getElementsByTagName) return; + + sorttable.DATE_RE = /^(\d\d?)[\/\.-](\d\d?)[\/\.-]((\d\d)?\d\d)$/; + + forEach(document.getElementsByTagName('table'), function(table) { + if (table.className.search(/\bsortable\b/) != -1) { + sorttable.makeSortable(table); + } + }); + + }, + + makeSortable: function(table) { + if (table.getElementsByTagName('thead').length == 0) { + // table doesn't have a tHead. Since it should have, create one and + // put the first table row in it. + the = document.createElement('thead'); + the.appendChild(table.rows[0]); + table.insertBefore(the,table.firstChild); + } + // Safari doesn't support table.tHead, sigh + if (table.tHead == null) table.tHead = table.getElementsByTagName('thead')[0]; + + if (table.tHead.rows.length != 1) return; // can't cope with two header rows + + // Sorttable v1 put rows with a class of "sortbottom" at the bottom (as + // "total" rows, for example). This is B&R, since what you're supposed + // to do is put them in a tfoot. So, if there are sortbottom rows, + // for backward compatibility, move them to tfoot (creating it if needed). + sortbottomrows = []; + for (var i=0; i5' : ' ▴'; + this.appendChild(sortrevind); + return; + } + if (this.className.search(/\bsorttable_sorted_reverse\b/) != -1) { + // if we're already sorted by this column in reverse, just + // re-reverse the table, which is quicker + sorttable.reverse(this.sorttable_tbody); + this.className = this.className.replace('sorttable_sorted_reverse', + 'sorttable_sorted'); + this.removeChild(document.getElementById('sorttable_sortrevind')); + sortfwdind = document.createElement('span'); + sortfwdind.id = "sorttable_sortfwdind"; + sortfwdind.innerHTML = stIsIE ? ' 6' : ' ▾'; + this.appendChild(sortfwdind); + return; + } + + // remove sorttable_sorted classes + theadrow = this.parentNode; + forEach(theadrow.childNodes, function(cell) { + if (cell.nodeType == 1) { // an element + cell.className = cell.className.replace('sorttable_sorted_reverse',''); + cell.className = cell.className.replace('sorttable_sorted',''); + } + }); + sortfwdind = document.getElementById('sorttable_sortfwdind'); + if (sortfwdind) { sortfwdind.parentNode.removeChild(sortfwdind); } + sortrevind = document.getElementById('sorttable_sortrevind'); + if (sortrevind) { sortrevind.parentNode.removeChild(sortrevind); } + + this.className += ' sorttable_sorted'; + sortfwdind = document.createElement('span'); + sortfwdind.id = "sorttable_sortfwdind"; + sortfwdind.innerHTML = stIsIE ? ' 6' : ' ▾'; + this.appendChild(sortfwdind); + + // build an array to sort. This is a Schwartzian transform thing, + // i.e., we "decorate" each row with the actual sort key, + // sort based on the sort keys, and then put the rows back in order + // which is a lot faster because you only do getInnerText once per row + row_array = []; + col = this.sorttable_columnindex; + rows = this.sorttable_tbody.rows; + for (var j=0; j 12) { + // definitely dd/mm + return sorttable.sort_ddmm; + } else if (second > 12) { + return sorttable.sort_mmdd; + } else { + // looks like a date, but we can't tell which, so assume + // that it's dd/mm (English imperialism!) and keep looking + sortfn = sorttable.sort_ddmm; + } + } + } + } + return sortfn; + }, + + getInnerText: function(node) { + // gets the text we want to use for sorting for a cell. + // strips leading and trailing whitespace. + // this is *not* a generic getInnerText function; it's special to sorttable. + // for example, you can override the cell text with a customkey attribute. + // it also gets .value for fields. + + hasInputs = (typeof node.getElementsByTagName == 'function') && + node.getElementsByTagName('input').length; + + if (node.getAttribute("sorttable_customkey") != null) { + return node.getAttribute("sorttable_customkey"); + } + else if (typeof node.textContent != 'undefined' && !hasInputs) { + return node.textContent.replace(/^\s+|\s+$/g, ''); + } + else if (typeof node.innerText != 'undefined' && !hasInputs) { + return node.innerText.replace(/^\s+|\s+$/g, ''); + } + else if (typeof node.text != 'undefined' && !hasInputs) { + return node.text.replace(/^\s+|\s+$/g, ''); + } + else { + switch (node.nodeType) { + case 3: + if (node.nodeName.toLowerCase() == 'input') { + return node.value.replace(/^\s+|\s+$/g, ''); + } + case 4: + return node.nodeValue.replace(/^\s+|\s+$/g, ''); + break; + case 1: + case 11: + var innerText = ''; + for (var i = 0; i < node.childNodes.length; i++) { + innerText += sorttable.getInnerText(node.childNodes[i]); + } + return innerText.replace(/^\s+|\s+$/g, ''); + break; + default: + return ''; + } + } + }, + + reverse: function(tbody) { + // reverse the rows in a tbody + newrows = []; + for (var i=0; i=0; i--) { + tbody.appendChild(newrows[i]); + } + delete newrows; + }, + + /* sort functions + each sort function takes two parameters, a and b + you are comparing a[0] and b[0] */ + sort_numeric: function(a,b) { + aa = parseFloat(a[0].replace(/[^0-9.-]/g,'')); + if (isNaN(aa)) aa = 0; + bb = parseFloat(b[0].replace(/[^0-9.-]/g,'')); + if (isNaN(bb)) bb = 0; + return aa-bb; + }, + sort_alpha: function(a,b) { + if (a[0]==b[0]) return 0; + if (a[0] 0 ) { + var q = list[i]; list[i] = list[i+1]; list[i+1] = q; + swap = true; + } + } // for + t--; + + if (!swap) break; + + for(var i = t; i > b; --i) { + if ( comp_func(list[i], list[i-1]) < 0 ) { + var q = list[i]; list[i] = list[i-1]; list[i-1] = q; + swap = true; + } + } // for + b++; + + } // while(swap) + } +} + +/* ****************************************************************** + Supporting functions: bundled here to avoid depending on a library + ****************************************************************** */ + +// Dean Edwards/Matthias Miller/John Resig + +/* for Mozilla/Opera9 */ +if (document.addEventListener) { + document.addEventListener("DOMContentLoaded", sorttable.init, false); +} + +/* for Internet Explorer */ +/*@cc_on @*/ +/*@if (@_win32) + document.write("