From ca1f41bad2c5506ab42a82990fb396d0b6bb42cb Mon Sep 17 00:00:00 2001 From: "raveit65 (via Travis CI)" Date: Mon, 26 Feb 2024 10:59:04 +0000 Subject: Deploy mate-desktop/mate-polkit to github.com/mate-desktop/mate-polkit.git:gh-pages --- .../index.html | 193 ++ .../stats.html | 164 ++ .../style.css | 177 ++ .../0.html | 1191 +++++++++ .../index.html | 197 ++ .../stats.html | 167 ++ .../style.css | 177 ++ .../0.html | 1191 +++++++++ .../index.html | 197 ++ .../stats.html | 167 ++ .../style.css | 177 ++ .../0.html | 1189 +++++++++ .../index.html | 197 ++ .../stats.html | 167 ++ .../style.css | 177 ++ .../0.html | 1189 +++++++++ .../index.html | 197 ++ .../stats.html | 167 ++ .../style.css | 177 ++ .../0.html | 1189 +++++++++ .../index.html | 197 ++ .../stats.html | 167 ++ .../style.css | 177 ++ .../0.html | 1189 +++++++++ .../index.html | 197 ++ .../stats.html | 167 ++ .../style.css | 177 ++ .../0.html | 1189 +++++++++ .../index.html | 197 ++ .../stats.html | 167 ++ .../style.css | 177 ++ .../0.html | 1189 +++++++++ .../index.html | 197 ++ .../stats.html | 167 ++ .../style.css | 177 ++ .../0.html | 1189 +++++++++ .../index.html | 197 ++ .../stats.html | 167 ++ .../style.css | 177 ++ .../0.html | 1189 +++++++++ .../index.html | 197 ++ .../stats.html | 167 ++ .../style.css | 177 ++ .../0.html | 1189 +++++++++ .../index.html | 197 ++ .../stats.html | 167 ++ .../style.css | 177 ++ .../0.html | 1189 +++++++++ .../index.html | 197 ++ .../stats.html | 167 ++ .../style.css | 177 ++ .../0.html | 1189 +++++++++ .../index.html | 197 ++ .../stats.html | 167 ++ .../style.css | 177 ++ .../0.html | 1189 +++++++++ .../1.html | 335 +++ .../2.html | 2639 ++++++++++++++++++++ .../3.html | 393 +++ .../4.html | 1269 ++++++++++ .../5.html | 351 +++ .../6.html | 761 ++++++ .../index.html | 252 ++ .../stats.html | 178 ++ .../style.css | 177 ++ .../0.html | 1189 +++++++++ .../1.html | 335 +++ .../2.html | 2639 ++++++++++++++++++++ .../3.html | 393 +++ .../4.html | 1269 ++++++++++ .../5.html | 351 +++ .../6.html | 761 ++++++ .../index.html | 252 ++ .../stats.html | 178 ++ .../style.css | 177 ++ .../0.html | 1189 +++++++++ .../1.html | 335 +++ .../2.html | 2639 ++++++++++++++++++++ .../3.html | 393 +++ .../4.html | 1269 ++++++++++ .../5.html | 351 +++ .../6.html | 761 ++++++ .../index.html | 252 ++ .../stats.html | 178 ++ .../style.css | 177 ++ .../0.html | 1189 +++++++++ .../1.html | 335 +++ .../2.html | 2639 ++++++++++++++++++++ .../3.html | 393 +++ .../4.html | 1269 ++++++++++ .../5.html | 351 +++ .../6.html | 761 ++++++ .../index.html | 252 ++ .../stats.html | 178 ++ .../style.css | 177 ++ .../0.html | 1189 +++++++++ .../1.html | 335 +++ .../2.html | 2639 ++++++++++++++++++++ .../3.html | 393 +++ .../4.html | 1269 ++++++++++ .../5.html | 351 +++ .../6.html | 761 ++++++ .../index.html | 252 ++ .../stats.html | 178 ++ .../style.css | 177 ++ .../0.html | 1189 +++++++++ .../1.html | 335 +++ .../2.html | 2639 ++++++++++++++++++++ .../3.html | 393 +++ .../4.html | 1269 ++++++++++ .../5.html | 351 +++ .../6.html | 761 ++++++ .../index.html | 252 ++ .../stats.html | 178 ++ .../style.css | 177 ++ CNAME | 1 + index.html | 46 + 117 files changed, 68339 insertions(+) create mode 100644 2022-11-11-213722-0509-cppcheck@f6c2c37d31d3_master/index.html create mode 100644 2022-11-11-213722-0509-cppcheck@f6c2c37d31d3_master/stats.html create mode 100644 2022-11-11-213722-0509-cppcheck@f6c2c37d31d3_master/style.css create mode 100644 2023-01-31-063753-4832-cppcheck@e8a458a75274_ayatana-indicators2/0.html create mode 100644 2023-01-31-063753-4832-cppcheck@e8a458a75274_ayatana-indicators2/index.html create mode 100644 2023-01-31-063753-4832-cppcheck@e8a458a75274_ayatana-indicators2/stats.html create mode 100644 2023-01-31-063753-4832-cppcheck@e8a458a75274_ayatana-indicators2/style.css create mode 100644 2023-01-31-064338-0666-cppcheck@121a9aba9d75_ayatana-indicators2/0.html create mode 100644 2023-01-31-064338-0666-cppcheck@121a9aba9d75_ayatana-indicators2/index.html create mode 100644 2023-01-31-064338-0666-cppcheck@121a9aba9d75_ayatana-indicators2/stats.html create mode 100644 2023-01-31-064338-0666-cppcheck@121a9aba9d75_ayatana-indicators2/style.css create mode 100644 2023-02-10-194140-4152-cppcheck@484831434984_ayatana-indicators2/0.html create mode 100644 2023-02-10-194140-4152-cppcheck@484831434984_ayatana-indicators2/index.html create mode 100644 2023-02-10-194140-4152-cppcheck@484831434984_ayatana-indicators2/stats.html create mode 100644 2023-02-10-194140-4152-cppcheck@484831434984_ayatana-indicators2/style.css create mode 100644 2023-02-10-194918-4414-cppcheck@65a6c367e28e_master/0.html create mode 100644 2023-02-10-194918-4414-cppcheck@65a6c367e28e_master/index.html create mode 100644 2023-02-10-194918-4414-cppcheck@65a6c367e28e_master/stats.html create mode 100644 2023-02-10-194918-4414-cppcheck@65a6c367e28e_master/style.css create mode 100644 2023-05-23-093151-5604-cppcheck@13874beaa074_meson/0.html create mode 100644 2023-05-23-093151-5604-cppcheck@13874beaa074_meson/index.html create mode 100644 2023-05-23-093151-5604-cppcheck@13874beaa074_meson/stats.html create mode 100644 2023-05-23-093151-5604-cppcheck@13874beaa074_meson/style.css create mode 100644 2023-05-25-161821-0349-cppcheck@a3f91214bc68_master/0.html create mode 100644 2023-05-25-161821-0349-cppcheck@a3f91214bc68_master/index.html create mode 100644 2023-05-25-161821-0349-cppcheck@a3f91214bc68_master/stats.html create mode 100644 2023-05-25-161821-0349-cppcheck@a3f91214bc68_master/style.css create mode 100644 2023-08-30-131815-8382-cppcheck@5851bb1e1c2c_master/0.html create mode 100644 2023-08-30-131815-8382-cppcheck@5851bb1e1c2c_master/index.html create mode 100644 2023-08-30-131815-8382-cppcheck@5851bb1e1c2c_master/stats.html create mode 100644 2023-08-30-131815-8382-cppcheck@5851bb1e1c2c_master/style.css create mode 100644 2023-08-30-131932-1666-cppcheck@5851bb1e1c2c_v1.27.1/0.html create mode 100644 2023-08-30-131932-1666-cppcheck@5851bb1e1c2c_v1.27.1/index.html create mode 100644 2023-08-30-131932-1666-cppcheck@5851bb1e1c2c_v1.27.1/stats.html create mode 100644 2023-08-30-131932-1666-cppcheck@5851bb1e1c2c_v1.27.1/style.css create mode 100644 2023-08-30-132313-6863-cppcheck@3799abd873ae_desktop-file/0.html create mode 100644 2023-08-30-132313-6863-cppcheck@3799abd873ae_desktop-file/index.html create mode 100644 2023-08-30-132313-6863-cppcheck@3799abd873ae_desktop-file/stats.html create mode 100644 2023-08-30-132313-6863-cppcheck@3799abd873ae_desktop-file/style.css create mode 100644 2023-08-31-195451-3891-cppcheck@015207383e78_master/0.html create mode 100644 2023-08-31-195451-3891-cppcheck@015207383e78_master/index.html create mode 100644 2023-08-31-195451-3891-cppcheck@015207383e78_master/stats.html create mode 100644 2023-08-31-195451-3891-cppcheck@015207383e78_master/style.css create mode 100644 2023-09-02-184611-1622-cppcheck@4b078a16e961_master/0.html create mode 100644 2023-09-02-184611-1622-cppcheck@4b078a16e961_master/index.html create mode 100644 2023-09-02-184611-1622-cppcheck@4b078a16e961_master/stats.html create mode 100644 2023-09-02-184611-1622-cppcheck@4b078a16e961_master/style.css create mode 100644 2023-09-03-024610-6129-cppcheck@abf957c6a5e9_fix-meson/0.html create mode 100644 2023-09-03-024610-6129-cppcheck@abf957c6a5e9_fix-meson/index.html create mode 100644 2023-09-03-024610-6129-cppcheck@abf957c6a5e9_fix-meson/stats.html create mode 100644 2023-09-03-024610-6129-cppcheck@abf957c6a5e9_fix-meson/style.css create mode 100644 2023-09-03-043043-5605-cppcheck@6fbf55c280e5_master/0.html create mode 100644 2023-09-03-043043-5605-cppcheck@6fbf55c280e5_master/index.html create mode 100644 2023-09-03-043043-5605-cppcheck@6fbf55c280e5_master/stats.html create mode 100644 2023-09-03-043043-5605-cppcheck@6fbf55c280e5_master/style.css create mode 100644 2024-02-15-172653-3023-cppcheck@256d08c4a418_travis/0.html create mode 100644 2024-02-15-172653-3023-cppcheck@256d08c4a418_travis/1.html create mode 100644 2024-02-15-172653-3023-cppcheck@256d08c4a418_travis/2.html create mode 100644 2024-02-15-172653-3023-cppcheck@256d08c4a418_travis/3.html create mode 100644 2024-02-15-172653-3023-cppcheck@256d08c4a418_travis/4.html create mode 100644 2024-02-15-172653-3023-cppcheck@256d08c4a418_travis/5.html create mode 100644 2024-02-15-172653-3023-cppcheck@256d08c4a418_travis/6.html create mode 100644 2024-02-15-172653-3023-cppcheck@256d08c4a418_travis/index.html create mode 100644 2024-02-15-172653-3023-cppcheck@256d08c4a418_travis/stats.html create mode 100644 2024-02-15-172653-3023-cppcheck@256d08c4a418_travis/style.css create mode 100644 2024-02-15-173245-9368-cppcheck@aacfb22a55ce_master/0.html create mode 100644 2024-02-15-173245-9368-cppcheck@aacfb22a55ce_master/1.html create mode 100644 2024-02-15-173245-9368-cppcheck@aacfb22a55ce_master/2.html create mode 100644 2024-02-15-173245-9368-cppcheck@aacfb22a55ce_master/3.html create mode 100644 2024-02-15-173245-9368-cppcheck@aacfb22a55ce_master/4.html create mode 100644 2024-02-15-173245-9368-cppcheck@aacfb22a55ce_master/5.html create mode 100644 2024-02-15-173245-9368-cppcheck@aacfb22a55ce_master/6.html create mode 100644 2024-02-15-173245-9368-cppcheck@aacfb22a55ce_master/index.html create mode 100644 2024-02-15-173245-9368-cppcheck@aacfb22a55ce_master/stats.html create mode 100644 2024-02-15-173245-9368-cppcheck@aacfb22a55ce_master/style.css create mode 100644 2024-02-24-205454-0706-cppcheck@1d41ea003763_shiti-meson/0.html create mode 100644 2024-02-24-205454-0706-cppcheck@1d41ea003763_shiti-meson/1.html create mode 100644 2024-02-24-205454-0706-cppcheck@1d41ea003763_shiti-meson/2.html create mode 100644 2024-02-24-205454-0706-cppcheck@1d41ea003763_shiti-meson/3.html create mode 100644 2024-02-24-205454-0706-cppcheck@1d41ea003763_shiti-meson/4.html create mode 100644 2024-02-24-205454-0706-cppcheck@1d41ea003763_shiti-meson/5.html create mode 100644 2024-02-24-205454-0706-cppcheck@1d41ea003763_shiti-meson/6.html create mode 100644 2024-02-24-205454-0706-cppcheck@1d41ea003763_shiti-meson/index.html create mode 100644 2024-02-24-205454-0706-cppcheck@1d41ea003763_shiti-meson/stats.html create mode 100644 2024-02-24-205454-0706-cppcheck@1d41ea003763_shiti-meson/style.css create mode 100644 2024-02-26-105052-9928-cppcheck@ad6d40200d0a_master/0.html create mode 100644 2024-02-26-105052-9928-cppcheck@ad6d40200d0a_master/1.html create mode 100644 2024-02-26-105052-9928-cppcheck@ad6d40200d0a_master/2.html create mode 100644 2024-02-26-105052-9928-cppcheck@ad6d40200d0a_master/3.html create mode 100644 2024-02-26-105052-9928-cppcheck@ad6d40200d0a_master/4.html create mode 100644 2024-02-26-105052-9928-cppcheck@ad6d40200d0a_master/5.html create mode 100644 2024-02-26-105052-9928-cppcheck@ad6d40200d0a_master/6.html create mode 100644 2024-02-26-105052-9928-cppcheck@ad6d40200d0a_master/index.html create mode 100644 2024-02-26-105052-9928-cppcheck@ad6d40200d0a_master/stats.html create mode 100644 2024-02-26-105052-9928-cppcheck@ad6d40200d0a_master/style.css create mode 100644 2024-02-26-105642-9744-cppcheck@c2df8de7c7b1_v1.28.1/0.html create mode 100644 2024-02-26-105642-9744-cppcheck@c2df8de7c7b1_v1.28.1/1.html create mode 100644 2024-02-26-105642-9744-cppcheck@c2df8de7c7b1_v1.28.1/2.html create mode 100644 2024-02-26-105642-9744-cppcheck@c2df8de7c7b1_v1.28.1/3.html create mode 100644 2024-02-26-105642-9744-cppcheck@c2df8de7c7b1_v1.28.1/4.html create mode 100644 2024-02-26-105642-9744-cppcheck@c2df8de7c7b1_v1.28.1/5.html create mode 100644 2024-02-26-105642-9744-cppcheck@c2df8de7c7b1_v1.28.1/6.html create mode 100644 2024-02-26-105642-9744-cppcheck@c2df8de7c7b1_v1.28.1/index.html create mode 100644 2024-02-26-105642-9744-cppcheck@c2df8de7c7b1_v1.28.1/stats.html create mode 100644 2024-02-26-105642-9744-cppcheck@c2df8de7c7b1_v1.28.1/style.css create mode 100644 2024-02-26-105807-9780-cppcheck@c2df8de7c7b1_master/0.html create mode 100644 2024-02-26-105807-9780-cppcheck@c2df8de7c7b1_master/1.html create mode 100644 2024-02-26-105807-9780-cppcheck@c2df8de7c7b1_master/2.html create mode 100644 2024-02-26-105807-9780-cppcheck@c2df8de7c7b1_master/3.html create mode 100644 2024-02-26-105807-9780-cppcheck@c2df8de7c7b1_master/4.html create mode 100644 2024-02-26-105807-9780-cppcheck@c2df8de7c7b1_master/5.html create mode 100644 2024-02-26-105807-9780-cppcheck@c2df8de7c7b1_master/6.html create mode 100644 2024-02-26-105807-9780-cppcheck@c2df8de7c7b1_master/index.html create mode 100644 2024-02-26-105807-9780-cppcheck@c2df8de7c7b1_master/stats.html create mode 100644 2024-02-26-105807-9780-cppcheck@c2df8de7c7b1_master/style.css create mode 100644 CNAME create mode 100644 index.html diff --git a/2022-11-11-213722-0509-cppcheck@f6c2c37d31d3_master/index.html b/2022-11-11-213722-0509-cppcheck@f6c2c37d31d3_master/index.html new file mode 100644 index 0000000..b23ea0f --- /dev/null +++ b/2022-11-11-213722-0509-cppcheck@f6c2c37d31d3_master/index.html @@ -0,0 +1,193 @@ + + + + + + Cppcheck - HTML report - mate-polkit + + + + + +
+ + + +
+ + + + + + + +
LineIdCWESeverityMessage
missingIncludeinformationCppcheck cannot find all the include files (use --check-config for details)
+
+ +
+ + diff --git a/2022-11-11-213722-0509-cppcheck@f6c2c37d31d3_master/stats.html b/2022-11-11-213722-0509-cppcheck@f6c2c37d31d3_master/stats.html new file mode 100644 index 0000000..c65c129 --- /dev/null +++ b/2022-11-11-213722-0509-cppcheck@f6c2c37d31d3_master/stats.html @@ -0,0 +1,164 @@ + + + + + + Cppcheck - HTML report - mate-polkit + + + + + +
+ + + +
+ +
+ +
+ + diff --git a/2022-11-11-213722-0509-cppcheck@f6c2c37d31d3_master/style.css b/2022-11-11-213722-0509-cppcheck@f6c2c37d31d3_master/style.css new file mode 100644 index 0000000..3897bfa --- /dev/null +++ b/2022-11-11-213722-0509-cppcheck@f6c2c37d31d3_master/style.css @@ -0,0 +1,177 @@ + +body { + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif; + font-size: 13px; + line-height: 1.5; + height: 100%; + margin: 0; +} + +#wrapper { + position: fixed; + height: 100vh; + width: 100vw; + display: grid; + grid-template-rows: fit-content(8rem) auto fit-content(8rem); + grid-template-columns: fit-content(25%) 1fr; + grid-template-areas: + "header header" + "menu content" + "footer footer"; +} + +h1 { + margin: 0 0 8px -2px; + font-size: 175%; +} + +.header { + padding: 0 0 5px 15px; + grid-area: header; + border-bottom: thin solid #aaa; +} + +.footer { + grid-area: footer; + border-top: thin solid #aaa; + font-size: 85%; + +} + +.footer > p { + margin: 4px; +} + +#menu, +#menu_index { + grid-area: menu; + text-align: left; + overflow: auto; + padding: 0 23px 15px 15px; + border-right: thin solid #aaa; + min-width: 200px; +} + +#menu > a { + display: block; + margin-left: 10px; + font-size: 12px; +} + +#content, +#content_index { + grid-area: content; + padding: 0px 5px 15px 15px; + overflow: auto; +} + +label { + white-space: nowrap; +} + +label.checkBtn.disabled { + color: #606060; + background: #e0e0e0; + font-style: italic; +} + +label.checkBtn, input[type="text"] { + border: 1px solid grey; + border-radius: 4px; + box-shadow: 1px 1px inset; + padding: 1px 5px; +} + +label.checkBtn { + white-space: nowrap; + background: #ccddff; +} + +label.unchecked { + background: #eff8ff; + box-shadow: 1px 1px 1px; +} + +label.checkBtn:hover, label.unchecked:hover{ + box-shadow: 0 0 2px; +} + +label.disabled:hover { + box-shadow: 1px 1px inset; +} + +label.checkBtn > input { + display:none; +} + +.summaryTable { + width: 100%; +} + +table.summaryTable td { padding: 0 5px 0 5px; } + +.statHeader, .severityHeader { + font-weight: bold; +} + +.warning { + background-color: #ffffa7; +} + +.error { + background-color: #ffb7b7; +} + +.error2 { + background-color: #faa; + display: inline-block; + margin-left: 4px; +} + +.inconclusive { + background-color: #b6b6b4; +} + +.inconclusive2 { + background-color: #b6b6b4; + display: inline-block; + margin-left: 4px; +} + +.verbose { + display: inline-block; + vertical-align: top; + cursor: help; +} + +.verbose .content { + display: none; + position: absolute; + padding: 10px; + margin: 4px; + max-width: 40%; + white-space: pre-wrap; + border: 1px solid #000; + background-color: #ffffcc; + cursor: auto; +} + +.highlight .hll { + padding: 1px; +} + +.highlighttable { + background-color: #fff; + position: relative; + margin: -10px; +} + +.linenos { + border-right: thin solid #aaa; + color: #d3d3d3; + padding-right: 6px; +} + +.id-filtered, .severity-filtered, .file-filtered, .tool-filtered, .text-filtered { + visibility: collapse; +} diff --git a/2023-01-31-063753-4832-cppcheck@e8a458a75274_ayatana-indicators2/0.html b/2023-01-31-063753-4832-cppcheck@e8a458a75274_ayatana-indicators2/0.html new file mode 100644 index 0000000..a3b65cc --- /dev/null +++ b/2023-01-31-063753-4832-cppcheck@e8a458a75274_ayatana-indicators2/0.html @@ -0,0 +1,1191 @@ + + + + + + Cppcheck - HTML report - mate-polkit + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
/*
+ * Copyright (C) 2009 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ * Author: David Zeuthen <davidz@redhat.com>
+ */
+
+#ifdef HAVE_CONFIG_H
+#  include "config.h"
+#endif
+
+#include <string.h>
+#include <gtk/gtk.h>
+#include <gio/gio.h>
+#include <glib/gi18n.h>
+#include <polkitagent/polkitagent.h>
+
+#if defined(HAVE_AYATANA_APPINDICATOR)
+# include <libayatana-appindicator/app-indicator.h>
+#elif defined(HAVE_UBUNTU_APPINDICATOR)
+# include <libappindicator/app-indicator.h>
+#endif
+
+#include "polkitmatelistener.h"
+
+/* session management support for auto-restart */
+#define SM_DBUS_NAME      "org.gnome.SessionManager"
+#define SM_DBUS_PATH      "/org/gnome/SessionManager"
+#define SM_DBUS_INTERFACE "org.gnome.SessionManager"
+#define SM_CLIENT_DBUS_INTERFACE "org.gnome.SessionManager.ClientPrivate"
+
+
+/* the Authority */
+static PolkitAuthority *authority = NULL;<--- Shadowed declaration
+
+/* the session we are servicing */
+static PolkitSubject *session = NULL;
+
+/* the current set of temporary authorizations */
+static GList *current_temporary_authorizations = NULL;
+
+#if defined(HAVE_AYATANA_APPINDICATOR) || defined(HAVE_UBUNTU_APPINDICATOR)
+static AppIndicator *app_indicator = NULL;
+#else
+static GtkStatusIcon *status_icon = NULL;
+#endif
+
+static GDBusProxy      *sm_proxy;
+static GDBusProxy      *client_proxy = NULL;
+
+static  GMainLoop *loop;
+
+static void
+revoke_tmp_authz_cb (GObject      *source_object,
+                     GAsyncResult *res,
+                     gpointer      user_data)
+{
+  GError *error;
+
+  error = NULL;
+  polkit_authority_revoke_temporary_authorizations_finish (POLKIT_AUTHORITY (source_object),
+                                                           res,
+                                                           &error);
+  if (error != NULL)
+    {
+      g_warning ("Error revoking temporary authorizations: %s", error->message);
+      g_error_free (error);
+    }
+}
+
+static void
+revoke_tmp_authz (void)
+{
+  polkit_authority_revoke_temporary_authorizations (authority,
+                                                    session,
+                                                    NULL,
+                                                    revoke_tmp_authz_cb,
+                                                    NULL);
+}
+
+#if defined(HAVE_AYATANA_APPINDICATOR) || defined(HAVE_UBUNTU_APPINDICATOR)
+static void
+on_menu_item_activate (GtkMenuItem *menu_item,
+                       gpointer     user_data)
+{
+  revoke_tmp_authz ();
+}
+#else
+static void
+on_status_icon_activate (GtkStatusIcon *status_icon,
+                         gpointer       user_data)
+{
+  revoke_tmp_authz ();
+}
+
+static void
+on_status_icon_popup_menu (GtkStatusIcon *status_icon,
+                           guint          button,
+                           guint          activate_time,
+                           gpointer       user_data)
+{
+  revoke_tmp_authz ();
+}
+#endif
+
+static void
+update_temporary_authorization_icon_real (void)
+{
+
+#if 0
+  GList *l;
+  g_debug ("have %d tmp authorizations", g_list_length (current_temporary_authorizations));
+  for (l = current_temporary_authorizations; l != NULL; l = l->next)
+    {
+      PolkitTemporaryAuthorization *authz = POLKIT_TEMPORARY_AUTHORIZATION (l->data);
+
+      g_debug ("have tmp authz for action %s (subject %s) with id %s (obtained %d, expires %d)",
+               polkit_temporary_authorization_get_action_id (authz),
+               polkit_subject_to_string (polkit_temporary_authorization_get_subject (authz)),
+               polkit_temporary_authorization_get_id (authz),
+               (gint) polkit_temporary_authorization_get_time_obtained (authz),
+               (gint) polkit_temporary_authorization_get_time_expires (authz));
+    }
+#endif
+
+  /* TODO:
+   *
+   * - we could do something fancy like displaying a window with the tmp authz
+   *   when the icon is clicked...
+   *
+   * - we could do some work using polkit_subject_exists() to ignore tmp authz
+   *   for subjects that no longer exists.. this is because temporary authorizations
+   *   are only valid for the subject that trigger the authentication dialog.
+   *
+   *   Maybe the authority could do this, would probably involve some polling, but
+   *   it seems cleaner to do this server side.
+   */
+
+  if (current_temporary_authorizations != NULL)
+    {
+      /* show icon */
+#if defined(HAVE_AYATANA_APPINDICATOR) || defined(HAVE_UBUNTU_APPINDICATOR)
+      if (app_indicator == NULL)
+        {
+          GtkWidget *item, *menu;
+
+          app_indicator = app_indicator_new ("mate-polkit",
+                                             "dialog-password",
+                                             APP_INDICATOR_CATEGORY_SYSTEM_SERVICES);
+
+          item = gtk_menu_item_new_with_label (_("Drop all elevated privileges"));
+          g_signal_connect (item,
+                            "activate",
+                            G_CALLBACK (on_menu_item_activate),
+                            NULL);
+          menu = gtk_menu_new ();
+          gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+          gtk_widget_show_all (menu);
+
+          app_indicator_set_menu (app_indicator,
+                                  GTK_MENU (menu));
+          app_indicator_set_status (app_indicator,
+                                    APP_INDICATOR_STATUS_ACTIVE);
+        }
+      else
+        /*Reshow icon from existing appindicator */
+        app_indicator_set_status (app_indicator,
+				    APP_INDICATOR_STATUS_ACTIVE);
+
+#else
+      if (status_icon == NULL)
+        {
+          status_icon = gtk_status_icon_new_from_icon_name ("dialog-password");
+          gtk_status_icon_set_tooltip_text (status_icon,
+                                            _("Click the icon to drop all elevated privileges"));
+          g_signal_connect (status_icon,
+                            "activate",
+                            G_CALLBACK (on_status_icon_activate),
+                            NULL);
+          g_signal_connect (status_icon,
+                            "popup-menu",
+                            G_CALLBACK (on_status_icon_popup_menu),
+                            NULL);
+        }
+#endif
+    }
+  else
+    {
+      /* hide icon */
+#if defined(HAVE_AYATANA_APPINDICATOR) || defined(HAVE_UBUNTU_APPINDICATOR)
+      if (app_indicator != NULL)
+        {
+          /* keep the app_indicator, hide the icon or it won't come back*/
+          app_indicator_set_status (app_indicator,
+				    APP_INDICATOR_STATUS_PASSIVE);
+        }
+#else
+      if (status_icon != NULL)
+        {
+          gtk_status_icon_set_visible (status_icon, FALSE);
+          g_object_unref (status_icon);
+          status_icon = NULL;
+        }
+#endif
+    }
+}
+
+static void
+enumerate_temporary_authorizations_cb (GObject      *source_object,
+                                       GAsyncResult *res,
+                                       gpointer      user_data)
+{
+  PolkitAuthority *authority = POLKIT_AUTHORITY (source_object);<--- Shadow variable
+  GList *temporary_authorizations;
+  GError *error;
+
+  temporary_authorizations = NULL;
+
+  error = NULL;
+  temporary_authorizations = polkit_authority_enumerate_temporary_authorizations_finish (authority,
+                                                                                         res,
+                                                                                         &error);
+  if (error != NULL)
+    {
+      g_warning ("Error enumerating temporary authorizations: %s", error->message);
+      g_error_free (error);
+      goto out;
+    }
+
+  g_list_foreach (current_temporary_authorizations, (GFunc) g_object_unref, NULL);
+  g_list_free (current_temporary_authorizations);
+
+  current_temporary_authorizations = temporary_authorizations;
+
+  update_temporary_authorization_icon_real ();
+
+ out:
+  ;
+}
+
+static void
+update_temporary_authorization_icon (PolkitAuthority *authority)
+{
+  polkit_authority_enumerate_temporary_authorizations (authority,
+                                                       session,
+                                                       NULL,
+                                                       enumerate_temporary_authorizations_cb,
+                                                       NULL);
+}
+
+static void
+on_authority_changed (PolkitAuthority *authority,
+                      gpointer         user_data)
+{
+  update_temporary_authorization_icon (authority);
+}
+
+static void
+stop_cb (void)
+{
+        g_main_loop_quit (loop);
+}
+
+static gboolean
+end_session_response (gboolean is_okay, const gchar *reason)
+{
+        GVariant *res;
+        GError *error = NULL;
+
+        res = g_dbus_proxy_call_sync (client_proxy,
+                                      "EndSessionResponse",
+                                      g_variant_new ("(bs)",
+                                                     is_okay,
+                                                     reason),
+                                      G_DBUS_CALL_FLAGS_NONE,
+                                      -1, /* timeout */
+                                      NULL, /* GCancellable */
+                                      &error);
+        if (! res) {
+                g_warning ("Failed to call EndSessionResponse: %s", error->message);
+                g_error_free (error);
+                return FALSE;
+        }
+
+        g_variant_unref (res);
+        return TRUE;
+}
+
+static void
+query_end_session_cb (void)
+{
+        end_session_response (TRUE, "");
+}
+
+static void
+end_session_cb (void)
+{
+        end_session_response (TRUE, "");
+        g_main_loop_quit (loop);
+}
+
+static void
+signal_cb (GDBusProxy *proxy, gchar *sender_name, gchar *signal_name,
+           GVariant *parameters, gpointer user_data)
+{
+        if (strcmp (signal_name, "Stop") == 0) {
+                stop_cb ();
+        } else if (strcmp (signal_name, "QueryEndSession") == 0) {
+                query_end_session_cb ();
+        } else if (strcmp (signal_name, "EndSession") == 0) {
+                end_session_cb ();
+        }
+}
+
+static gboolean
+register_client_to_gnome_session (void)
+{
+        GError     *error = NULL;
+        GVariant   *res;
+        const char *startup_id;
+        const char *app_id;
+        char       *client_id;
+
+        startup_id = g_getenv ("DESKTOP_AUTOSTART_ID");
+        app_id = "polkit-mate-authentication-agent-1.desktop";
+
+        sm_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
+                                                  G_DBUS_PROXY_FLAGS_NONE,
+                                                  NULL, /* GDBusInterfaceInfo */
+                                                  SM_DBUS_NAME,
+                                                  SM_DBUS_PATH,
+                                                  SM_DBUS_INTERFACE,
+                                                  NULL, /* GCancellable */
+                                                  &error);
+        if (sm_proxy == NULL) {
+                g_message("Failed to get session manager: %s", error->message);
+                g_error_free (error);
+                return FALSE;
+        }
+
+        res = g_dbus_proxy_call_sync (sm_proxy,
+                                      "RegisterClient",
+                                      g_variant_new ("(ss)",
+                                                     app_id,
+                                                     startup_id),
+                                      G_DBUS_CALL_FLAGS_NONE,
+                                      -1, /* timeout */
+                                      NULL, /* GCancellable */
+                                      &error);
+        if (! res) {
+                g_warning ("Failed to register client: %s", error->message);
+                g_error_free (error);
+                return FALSE;
+        }
+
+        if (! g_variant_is_of_type (res, G_VARIANT_TYPE ("(o)"))) {
+                g_warning ("RegisterClient returned unexpected type %s",
+                           g_variant_get_type_string (res));
+                return FALSE;
+        }
+
+        g_variant_get (res, "(&o)", &client_id);
+
+        client_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
+                                                      G_DBUS_PROXY_FLAGS_NONE,
+                                                      NULL, /* GDBusInterfaceInfo */
+                                                      SM_DBUS_NAME,
+                                                      client_id,
+                                                      SM_CLIENT_DBUS_INTERFACE,
+                                                      NULL, /* GCancellable */
+                                                      &error);
+        g_variant_unref (res);
+        if (client_proxy == NULL) {
+                g_message("Failed to get client proxy: %s", error->message);
+                g_error_free (error);
+                return FALSE;
+        }
+
+        g_signal_connect (client_proxy, "g-signal", G_CALLBACK (signal_cb), NULL);
+
+        return TRUE;
+}
+
+int
+main (int argc, char **argv)
+{
+  gint ret;
+  PolkitAgentListener *listener;
+  GError *error;
+
+  gtk_init (&argc, &argv);
+
+  loop = NULL;
+  authority = NULL;
+  listener = NULL;
+  session = NULL;
+  ret = 1;
+
+  bindtextdomain (GETTEXT_PACKAGE, MATELOCALEDIR);
+#if HAVE_BIND_TEXTDOMAIN_CODESET
+  bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+#endif
+  textdomain (GETTEXT_PACKAGE);
+
+  loop = g_main_loop_new (NULL, FALSE);
+
+  error = NULL;
+  authority = polkit_authority_get_sync (NULL /* GCancellable* */, &error);
+  if (authority == NULL)
+    {
+      g_warning ("Error getting authority: %s", error->message);
+      g_error_free (error);
+      goto out;
+    }
+  g_signal_connect (authority,
+                    "changed",
+                    G_CALLBACK (on_authority_changed),
+                    NULL);
+
+  listener = polkit_mate_listener_new ();
+
+  error = NULL;
+  session = polkit_unix_session_new_for_process_sync (getpid (), NULL, &error);
+  if (error != NULL)
+    {
+      g_warning ("Unable to determine the session we are in: %s", error->message);
+      g_error_free (error);
+      goto out;
+    }
+
+  error = NULL;
+  if (!polkit_agent_listener_register (listener,
+				       POLKIT_AGENT_REGISTER_FLAGS_NONE,
+                                       session,
+                                       "/org/mate/PolicyKit1/AuthenticationAgent",
+				       NULL,
+                                       &error))
+    {
+      g_printerr ("Cannot register authentication agent: %s\n", error->message);
+      g_error_free (error);
+      goto out;
+    }
+
+  update_temporary_authorization_icon (authority);
+
+  register_client_to_gnome_session();
+
+  g_main_loop_run (loop);
+
+  ret = 0;
+
+ out:
+  if (authority != NULL)
+    g_object_unref (authority);
+  if (session != NULL)
+    g_object_unref (session);
+  if (listener != NULL)
+    g_object_unref (listener);
+  if (loop != NULL)
+    g_main_loop_unref (loop);
+
+  return ret;
+}
+
+ +
+ +
+ + diff --git a/2023-01-31-063753-4832-cppcheck@e8a458a75274_ayatana-indicators2/index.html b/2023-01-31-063753-4832-cppcheck@e8a458a75274_ayatana-indicators2/index.html new file mode 100644 index 0000000..a940c0e --- /dev/null +++ b/2023-01-31-063753-4832-cppcheck@e8a458a75274_ayatana-indicators2/index.html @@ -0,0 +1,197 @@ + + + + + + Cppcheck - HTML report - mate-polkit + + + + + +
+ + + +
+ + + + + + + + + + +
LineIdCWESeverityMessage
missingIncludeinformationCppcheck cannot find all the include files (use --check-config for details)
src/main.c
227shadowVariable398styleLocal variable 'authority' shadows outer variable
+
+ +
+ + diff --git a/2023-01-31-063753-4832-cppcheck@e8a458a75274_ayatana-indicators2/stats.html b/2023-01-31-063753-4832-cppcheck@e8a458a75274_ayatana-indicators2/stats.html new file mode 100644 index 0000000..8f9eaf7 --- /dev/null +++ b/2023-01-31-063753-4832-cppcheck@e8a458a75274_ayatana-indicators2/stats.html @@ -0,0 +1,167 @@ + + + + + + Cppcheck - HTML report - mate-polkit + + + + + +
+ + + +
+

Top 10 files for style severity, total findings: 1
+   1  src/main.c
+

+ +
+ +
+ + diff --git a/2023-01-31-063753-4832-cppcheck@e8a458a75274_ayatana-indicators2/style.css b/2023-01-31-063753-4832-cppcheck@e8a458a75274_ayatana-indicators2/style.css new file mode 100644 index 0000000..3897bfa --- /dev/null +++ b/2023-01-31-063753-4832-cppcheck@e8a458a75274_ayatana-indicators2/style.css @@ -0,0 +1,177 @@ + +body { + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif; + font-size: 13px; + line-height: 1.5; + height: 100%; + margin: 0; +} + +#wrapper { + position: fixed; + height: 100vh; + width: 100vw; + display: grid; + grid-template-rows: fit-content(8rem) auto fit-content(8rem); + grid-template-columns: fit-content(25%) 1fr; + grid-template-areas: + "header header" + "menu content" + "footer footer"; +} + +h1 { + margin: 0 0 8px -2px; + font-size: 175%; +} + +.header { + padding: 0 0 5px 15px; + grid-area: header; + border-bottom: thin solid #aaa; +} + +.footer { + grid-area: footer; + border-top: thin solid #aaa; + font-size: 85%; + +} + +.footer > p { + margin: 4px; +} + +#menu, +#menu_index { + grid-area: menu; + text-align: left; + overflow: auto; + padding: 0 23px 15px 15px; + border-right: thin solid #aaa; + min-width: 200px; +} + +#menu > a { + display: block; + margin-left: 10px; + font-size: 12px; +} + +#content, +#content_index { + grid-area: content; + padding: 0px 5px 15px 15px; + overflow: auto; +} + +label { + white-space: nowrap; +} + +label.checkBtn.disabled { + color: #606060; + background: #e0e0e0; + font-style: italic; +} + +label.checkBtn, input[type="text"] { + border: 1px solid grey; + border-radius: 4px; + box-shadow: 1px 1px inset; + padding: 1px 5px; +} + +label.checkBtn { + white-space: nowrap; + background: #ccddff; +} + +label.unchecked { + background: #eff8ff; + box-shadow: 1px 1px 1px; +} + +label.checkBtn:hover, label.unchecked:hover{ + box-shadow: 0 0 2px; +} + +label.disabled:hover { + box-shadow: 1px 1px inset; +} + +label.checkBtn > input { + display:none; +} + +.summaryTable { + width: 100%; +} + +table.summaryTable td { padding: 0 5px 0 5px; } + +.statHeader, .severityHeader { + font-weight: bold; +} + +.warning { + background-color: #ffffa7; +} + +.error { + background-color: #ffb7b7; +} + +.error2 { + background-color: #faa; + display: inline-block; + margin-left: 4px; +} + +.inconclusive { + background-color: #b6b6b4; +} + +.inconclusive2 { + background-color: #b6b6b4; + display: inline-block; + margin-left: 4px; +} + +.verbose { + display: inline-block; + vertical-align: top; + cursor: help; +} + +.verbose .content { + display: none; + position: absolute; + padding: 10px; + margin: 4px; + max-width: 40%; + white-space: pre-wrap; + border: 1px solid #000; + background-color: #ffffcc; + cursor: auto; +} + +.highlight .hll { + padding: 1px; +} + +.highlighttable { + background-color: #fff; + position: relative; + margin: -10px; +} + +.linenos { + border-right: thin solid #aaa; + color: #d3d3d3; + padding-right: 6px; +} + +.id-filtered, .severity-filtered, .file-filtered, .tool-filtered, .text-filtered { + visibility: collapse; +} diff --git a/2023-01-31-064338-0666-cppcheck@121a9aba9d75_ayatana-indicators2/0.html b/2023-01-31-064338-0666-cppcheck@121a9aba9d75_ayatana-indicators2/0.html new file mode 100644 index 0000000..a3b65cc --- /dev/null +++ b/2023-01-31-064338-0666-cppcheck@121a9aba9d75_ayatana-indicators2/0.html @@ -0,0 +1,1191 @@ + + + + + + Cppcheck - HTML report - mate-polkit + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
/*
+ * Copyright (C) 2009 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ * Author: David Zeuthen <davidz@redhat.com>
+ */
+
+#ifdef HAVE_CONFIG_H
+#  include "config.h"
+#endif
+
+#include <string.h>
+#include <gtk/gtk.h>
+#include <gio/gio.h>
+#include <glib/gi18n.h>
+#include <polkitagent/polkitagent.h>
+
+#if defined(HAVE_AYATANA_APPINDICATOR)
+# include <libayatana-appindicator/app-indicator.h>
+#elif defined(HAVE_UBUNTU_APPINDICATOR)
+# include <libappindicator/app-indicator.h>
+#endif
+
+#include "polkitmatelistener.h"
+
+/* session management support for auto-restart */
+#define SM_DBUS_NAME      "org.gnome.SessionManager"
+#define SM_DBUS_PATH      "/org/gnome/SessionManager"
+#define SM_DBUS_INTERFACE "org.gnome.SessionManager"
+#define SM_CLIENT_DBUS_INTERFACE "org.gnome.SessionManager.ClientPrivate"
+
+
+/* the Authority */
+static PolkitAuthority *authority = NULL;<--- Shadowed declaration
+
+/* the session we are servicing */
+static PolkitSubject *session = NULL;
+
+/* the current set of temporary authorizations */
+static GList *current_temporary_authorizations = NULL;
+
+#if defined(HAVE_AYATANA_APPINDICATOR) || defined(HAVE_UBUNTU_APPINDICATOR)
+static AppIndicator *app_indicator = NULL;
+#else
+static GtkStatusIcon *status_icon = NULL;
+#endif
+
+static GDBusProxy      *sm_proxy;
+static GDBusProxy      *client_proxy = NULL;
+
+static  GMainLoop *loop;
+
+static void
+revoke_tmp_authz_cb (GObject      *source_object,
+                     GAsyncResult *res,
+                     gpointer      user_data)
+{
+  GError *error;
+
+  error = NULL;
+  polkit_authority_revoke_temporary_authorizations_finish (POLKIT_AUTHORITY (source_object),
+                                                           res,
+                                                           &error);
+  if (error != NULL)
+    {
+      g_warning ("Error revoking temporary authorizations: %s", error->message);
+      g_error_free (error);
+    }
+}
+
+static void
+revoke_tmp_authz (void)
+{
+  polkit_authority_revoke_temporary_authorizations (authority,
+                                                    session,
+                                                    NULL,
+                                                    revoke_tmp_authz_cb,
+                                                    NULL);
+}
+
+#if defined(HAVE_AYATANA_APPINDICATOR) || defined(HAVE_UBUNTU_APPINDICATOR)
+static void
+on_menu_item_activate (GtkMenuItem *menu_item,
+                       gpointer     user_data)
+{
+  revoke_tmp_authz ();
+}
+#else
+static void
+on_status_icon_activate (GtkStatusIcon *status_icon,
+                         gpointer       user_data)
+{
+  revoke_tmp_authz ();
+}
+
+static void
+on_status_icon_popup_menu (GtkStatusIcon *status_icon,
+                           guint          button,
+                           guint          activate_time,
+                           gpointer       user_data)
+{
+  revoke_tmp_authz ();
+}
+#endif
+
+static void
+update_temporary_authorization_icon_real (void)
+{
+
+#if 0
+  GList *l;
+  g_debug ("have %d tmp authorizations", g_list_length (current_temporary_authorizations));
+  for (l = current_temporary_authorizations; l != NULL; l = l->next)
+    {
+      PolkitTemporaryAuthorization *authz = POLKIT_TEMPORARY_AUTHORIZATION (l->data);
+
+      g_debug ("have tmp authz for action %s (subject %s) with id %s (obtained %d, expires %d)",
+               polkit_temporary_authorization_get_action_id (authz),
+               polkit_subject_to_string (polkit_temporary_authorization_get_subject (authz)),
+               polkit_temporary_authorization_get_id (authz),
+               (gint) polkit_temporary_authorization_get_time_obtained (authz),
+               (gint) polkit_temporary_authorization_get_time_expires (authz));
+    }
+#endif
+
+  /* TODO:
+   *
+   * - we could do something fancy like displaying a window with the tmp authz
+   *   when the icon is clicked...
+   *
+   * - we could do some work using polkit_subject_exists() to ignore tmp authz
+   *   for subjects that no longer exists.. this is because temporary authorizations
+   *   are only valid for the subject that trigger the authentication dialog.
+   *
+   *   Maybe the authority could do this, would probably involve some polling, but
+   *   it seems cleaner to do this server side.
+   */
+
+  if (current_temporary_authorizations != NULL)
+    {
+      /* show icon */
+#if defined(HAVE_AYATANA_APPINDICATOR) || defined(HAVE_UBUNTU_APPINDICATOR)
+      if (app_indicator == NULL)
+        {
+          GtkWidget *item, *menu;
+
+          app_indicator = app_indicator_new ("mate-polkit",
+                                             "dialog-password",
+                                             APP_INDICATOR_CATEGORY_SYSTEM_SERVICES);
+
+          item = gtk_menu_item_new_with_label (_("Drop all elevated privileges"));
+          g_signal_connect (item,
+                            "activate",
+                            G_CALLBACK (on_menu_item_activate),
+                            NULL);
+          menu = gtk_menu_new ();
+          gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+          gtk_widget_show_all (menu);
+
+          app_indicator_set_menu (app_indicator,
+                                  GTK_MENU (menu));
+          app_indicator_set_status (app_indicator,
+                                    APP_INDICATOR_STATUS_ACTIVE);
+        }
+      else
+        /*Reshow icon from existing appindicator */
+        app_indicator_set_status (app_indicator,
+				    APP_INDICATOR_STATUS_ACTIVE);
+
+#else
+      if (status_icon == NULL)
+        {
+          status_icon = gtk_status_icon_new_from_icon_name ("dialog-password");
+          gtk_status_icon_set_tooltip_text (status_icon,
+                                            _("Click the icon to drop all elevated privileges"));
+          g_signal_connect (status_icon,
+                            "activate",
+                            G_CALLBACK (on_status_icon_activate),
+                            NULL);
+          g_signal_connect (status_icon,
+                            "popup-menu",
+                            G_CALLBACK (on_status_icon_popup_menu),
+                            NULL);
+        }
+#endif
+    }
+  else
+    {
+      /* hide icon */
+#if defined(HAVE_AYATANA_APPINDICATOR) || defined(HAVE_UBUNTU_APPINDICATOR)
+      if (app_indicator != NULL)
+        {
+          /* keep the app_indicator, hide the icon or it won't come back*/
+          app_indicator_set_status (app_indicator,
+				    APP_INDICATOR_STATUS_PASSIVE);
+        }
+#else
+      if (status_icon != NULL)
+        {
+          gtk_status_icon_set_visible (status_icon, FALSE);
+          g_object_unref (status_icon);
+          status_icon = NULL;
+        }
+#endif
+    }
+}
+
+static void
+enumerate_temporary_authorizations_cb (GObject      *source_object,
+                                       GAsyncResult *res,
+                                       gpointer      user_data)
+{
+  PolkitAuthority *authority = POLKIT_AUTHORITY (source_object);<--- Shadow variable
+  GList *temporary_authorizations;
+  GError *error;
+
+  temporary_authorizations = NULL;
+
+  error = NULL;
+  temporary_authorizations = polkit_authority_enumerate_temporary_authorizations_finish (authority,
+                                                                                         res,
+                                                                                         &error);
+  if (error != NULL)
+    {
+      g_warning ("Error enumerating temporary authorizations: %s", error->message);
+      g_error_free (error);
+      goto out;
+    }
+
+  g_list_foreach (current_temporary_authorizations, (GFunc) g_object_unref, NULL);
+  g_list_free (current_temporary_authorizations);
+
+  current_temporary_authorizations = temporary_authorizations;
+
+  update_temporary_authorization_icon_real ();
+
+ out:
+  ;
+}
+
+static void
+update_temporary_authorization_icon (PolkitAuthority *authority)
+{
+  polkit_authority_enumerate_temporary_authorizations (authority,
+                                                       session,
+                                                       NULL,
+                                                       enumerate_temporary_authorizations_cb,
+                                                       NULL);
+}
+
+static void
+on_authority_changed (PolkitAuthority *authority,
+                      gpointer         user_data)
+{
+  update_temporary_authorization_icon (authority);
+}
+
+static void
+stop_cb (void)
+{
+        g_main_loop_quit (loop);
+}
+
+static gboolean
+end_session_response (gboolean is_okay, const gchar *reason)
+{
+        GVariant *res;
+        GError *error = NULL;
+
+        res = g_dbus_proxy_call_sync (client_proxy,
+                                      "EndSessionResponse",
+                                      g_variant_new ("(bs)",
+                                                     is_okay,
+                                                     reason),
+                                      G_DBUS_CALL_FLAGS_NONE,
+                                      -1, /* timeout */
+                                      NULL, /* GCancellable */
+                                      &error);
+        if (! res) {
+                g_warning ("Failed to call EndSessionResponse: %s", error->message);
+                g_error_free (error);
+                return FALSE;
+        }
+
+        g_variant_unref (res);
+        return TRUE;
+}
+
+static void
+query_end_session_cb (void)
+{
+        end_session_response (TRUE, "");
+}
+
+static void
+end_session_cb (void)
+{
+        end_session_response (TRUE, "");
+        g_main_loop_quit (loop);
+}
+
+static void
+signal_cb (GDBusProxy *proxy, gchar *sender_name, gchar *signal_name,
+           GVariant *parameters, gpointer user_data)
+{
+        if (strcmp (signal_name, "Stop") == 0) {
+                stop_cb ();
+        } else if (strcmp (signal_name, "QueryEndSession") == 0) {
+                query_end_session_cb ();
+        } else if (strcmp (signal_name, "EndSession") == 0) {
+                end_session_cb ();
+        }
+}
+
+static gboolean
+register_client_to_gnome_session (void)
+{
+        GError     *error = NULL;
+        GVariant   *res;
+        const char *startup_id;
+        const char *app_id;
+        char       *client_id;
+
+        startup_id = g_getenv ("DESKTOP_AUTOSTART_ID");
+        app_id = "polkit-mate-authentication-agent-1.desktop";
+
+        sm_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
+                                                  G_DBUS_PROXY_FLAGS_NONE,
+                                                  NULL, /* GDBusInterfaceInfo */
+                                                  SM_DBUS_NAME,
+                                                  SM_DBUS_PATH,
+                                                  SM_DBUS_INTERFACE,
+                                                  NULL, /* GCancellable */
+                                                  &error);
+        if (sm_proxy == NULL) {
+                g_message("Failed to get session manager: %s", error->message);
+                g_error_free (error);
+                return FALSE;
+        }
+
+        res = g_dbus_proxy_call_sync (sm_proxy,
+                                      "RegisterClient",
+                                      g_variant_new ("(ss)",
+                                                     app_id,
+                                                     startup_id),
+                                      G_DBUS_CALL_FLAGS_NONE,
+                                      -1, /* timeout */
+                                      NULL, /* GCancellable */
+                                      &error);
+        if (! res) {
+                g_warning ("Failed to register client: %s", error->message);
+                g_error_free (error);
+                return FALSE;
+        }
+
+        if (! g_variant_is_of_type (res, G_VARIANT_TYPE ("(o)"))) {
+                g_warning ("RegisterClient returned unexpected type %s",
+                           g_variant_get_type_string (res));
+                return FALSE;
+        }
+
+        g_variant_get (res, "(&o)", &client_id);
+
+        client_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
+                                                      G_DBUS_PROXY_FLAGS_NONE,
+                                                      NULL, /* GDBusInterfaceInfo */
+                                                      SM_DBUS_NAME,
+                                                      client_id,
+                                                      SM_CLIENT_DBUS_INTERFACE,
+                                                      NULL, /* GCancellable */
+                                                      &error);
+        g_variant_unref (res);
+        if (client_proxy == NULL) {
+                g_message("Failed to get client proxy: %s", error->message);
+                g_error_free (error);
+                return FALSE;
+        }
+
+        g_signal_connect (client_proxy, "g-signal", G_CALLBACK (signal_cb), NULL);
+
+        return TRUE;
+}
+
+int
+main (int argc, char **argv)
+{
+  gint ret;
+  PolkitAgentListener *listener;
+  GError *error;
+
+  gtk_init (&argc, &argv);
+
+  loop = NULL;
+  authority = NULL;
+  listener = NULL;
+  session = NULL;
+  ret = 1;
+
+  bindtextdomain (GETTEXT_PACKAGE, MATELOCALEDIR);
+#if HAVE_BIND_TEXTDOMAIN_CODESET
+  bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+#endif
+  textdomain (GETTEXT_PACKAGE);
+
+  loop = g_main_loop_new (NULL, FALSE);
+
+  error = NULL;
+  authority = polkit_authority_get_sync (NULL /* GCancellable* */, &error);
+  if (authority == NULL)
+    {
+      g_warning ("Error getting authority: %s", error->message);
+      g_error_free (error);
+      goto out;
+    }
+  g_signal_connect (authority,
+                    "changed",
+                    G_CALLBACK (on_authority_changed),
+                    NULL);
+
+  listener = polkit_mate_listener_new ();
+
+  error = NULL;
+  session = polkit_unix_session_new_for_process_sync (getpid (), NULL, &error);
+  if (error != NULL)
+    {
+      g_warning ("Unable to determine the session we are in: %s", error->message);
+      g_error_free (error);
+      goto out;
+    }
+
+  error = NULL;
+  if (!polkit_agent_listener_register (listener,
+				       POLKIT_AGENT_REGISTER_FLAGS_NONE,
+                                       session,
+                                       "/org/mate/PolicyKit1/AuthenticationAgent",
+				       NULL,
+                                       &error))
+    {
+      g_printerr ("Cannot register authentication agent: %s\n", error->message);
+      g_error_free (error);
+      goto out;
+    }
+
+  update_temporary_authorization_icon (authority);
+
+  register_client_to_gnome_session();
+
+  g_main_loop_run (loop);
+
+  ret = 0;
+
+ out:
+  if (authority != NULL)
+    g_object_unref (authority);
+  if (session != NULL)
+    g_object_unref (session);
+  if (listener != NULL)
+    g_object_unref (listener);
+  if (loop != NULL)
+    g_main_loop_unref (loop);
+
+  return ret;
+}
+
+ +
+ +
+ + diff --git a/2023-01-31-064338-0666-cppcheck@121a9aba9d75_ayatana-indicators2/index.html b/2023-01-31-064338-0666-cppcheck@121a9aba9d75_ayatana-indicators2/index.html new file mode 100644 index 0000000..a940c0e --- /dev/null +++ b/2023-01-31-064338-0666-cppcheck@121a9aba9d75_ayatana-indicators2/index.html @@ -0,0 +1,197 @@ + + + + + + Cppcheck - HTML report - mate-polkit + + + + + +
+ + + +
+ + + + + + + + + + +
LineIdCWESeverityMessage
missingIncludeinformationCppcheck cannot find all the include files (use --check-config for details)
src/main.c
227shadowVariable398styleLocal variable 'authority' shadows outer variable
+
+ +
+ + diff --git a/2023-01-31-064338-0666-cppcheck@121a9aba9d75_ayatana-indicators2/stats.html b/2023-01-31-064338-0666-cppcheck@121a9aba9d75_ayatana-indicators2/stats.html new file mode 100644 index 0000000..8f9eaf7 --- /dev/null +++ b/2023-01-31-064338-0666-cppcheck@121a9aba9d75_ayatana-indicators2/stats.html @@ -0,0 +1,167 @@ + + + + + + Cppcheck - HTML report - mate-polkit + + + + + +
+ + + +
+

Top 10 files for style severity, total findings: 1
+   1  src/main.c
+

+ +
+ +
+ + diff --git a/2023-01-31-064338-0666-cppcheck@121a9aba9d75_ayatana-indicators2/style.css b/2023-01-31-064338-0666-cppcheck@121a9aba9d75_ayatana-indicators2/style.css new file mode 100644 index 0000000..3897bfa --- /dev/null +++ b/2023-01-31-064338-0666-cppcheck@121a9aba9d75_ayatana-indicators2/style.css @@ -0,0 +1,177 @@ + +body { + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif; + font-size: 13px; + line-height: 1.5; + height: 100%; + margin: 0; +} + +#wrapper { + position: fixed; + height: 100vh; + width: 100vw; + display: grid; + grid-template-rows: fit-content(8rem) auto fit-content(8rem); + grid-template-columns: fit-content(25%) 1fr; + grid-template-areas: + "header header" + "menu content" + "footer footer"; +} + +h1 { + margin: 0 0 8px -2px; + font-size: 175%; +} + +.header { + padding: 0 0 5px 15px; + grid-area: header; + border-bottom: thin solid #aaa; +} + +.footer { + grid-area: footer; + border-top: thin solid #aaa; + font-size: 85%; + +} + +.footer > p { + margin: 4px; +} + +#menu, +#menu_index { + grid-area: menu; + text-align: left; + overflow: auto; + padding: 0 23px 15px 15px; + border-right: thin solid #aaa; + min-width: 200px; +} + +#menu > a { + display: block; + margin-left: 10px; + font-size: 12px; +} + +#content, +#content_index { + grid-area: content; + padding: 0px 5px 15px 15px; + overflow: auto; +} + +label { + white-space: nowrap; +} + +label.checkBtn.disabled { + color: #606060; + background: #e0e0e0; + font-style: italic; +} + +label.checkBtn, input[type="text"] { + border: 1px solid grey; + border-radius: 4px; + box-shadow: 1px 1px inset; + padding: 1px 5px; +} + +label.checkBtn { + white-space: nowrap; + background: #ccddff; +} + +label.unchecked { + background: #eff8ff; + box-shadow: 1px 1px 1px; +} + +label.checkBtn:hover, label.unchecked:hover{ + box-shadow: 0 0 2px; +} + +label.disabled:hover { + box-shadow: 1px 1px inset; +} + +label.checkBtn > input { + display:none; +} + +.summaryTable { + width: 100%; +} + +table.summaryTable td { padding: 0 5px 0 5px; } + +.statHeader, .severityHeader { + font-weight: bold; +} + +.warning { + background-color: #ffffa7; +} + +.error { + background-color: #ffb7b7; +} + +.error2 { + background-color: #faa; + display: inline-block; + margin-left: 4px; +} + +.inconclusive { + background-color: #b6b6b4; +} + +.inconclusive2 { + background-color: #b6b6b4; + display: inline-block; + margin-left: 4px; +} + +.verbose { + display: inline-block; + vertical-align: top; + cursor: help; +} + +.verbose .content { + display: none; + position: absolute; + padding: 10px; + margin: 4px; + max-width: 40%; + white-space: pre-wrap; + border: 1px solid #000; + background-color: #ffffcc; + cursor: auto; +} + +.highlight .hll { + padding: 1px; +} + +.highlighttable { + background-color: #fff; + position: relative; + margin: -10px; +} + +.linenos { + border-right: thin solid #aaa; + color: #d3d3d3; + padding-right: 6px; +} + +.id-filtered, .severity-filtered, .file-filtered, .tool-filtered, .text-filtered { + visibility: collapse; +} diff --git a/2023-02-10-194140-4152-cppcheck@484831434984_ayatana-indicators2/0.html b/2023-02-10-194140-4152-cppcheck@484831434984_ayatana-indicators2/0.html new file mode 100644 index 0000000..2b46300 --- /dev/null +++ b/2023-02-10-194140-4152-cppcheck@484831434984_ayatana-indicators2/0.html @@ -0,0 +1,1189 @@ + + + + + + Cppcheck - HTML report - mate-polkit + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
/*
+ * Copyright (C) 2009 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ * Author: David Zeuthen <davidz@redhat.com>
+ */
+
+#ifdef HAVE_CONFIG_H
+#  include "config.h"
+#endif
+
+#include <string.h>
+#include <gtk/gtk.h>
+#include <gio/gio.h>
+#include <glib/gi18n.h>
+#include <polkitagent/polkitagent.h>
+
+#if defined(HAVE_AYATANA_APPINDICATOR)
+# include <libayatana-appindicator/app-indicator.h>
+#elif defined(HAVE_UBUNTU_APPINDICATOR)
+# include <libappindicator/app-indicator.h>
+#endif
+
+#include "polkitmatelistener.h"
+
+/* session management support for auto-restart */
+#define SM_DBUS_NAME      "org.gnome.SessionManager"
+#define SM_DBUS_PATH      "/org/gnome/SessionManager"
+#define SM_DBUS_INTERFACE "org.gnome.SessionManager"
+#define SM_CLIENT_DBUS_INTERFACE "org.gnome.SessionManager.ClientPrivate"
+
+/* the Authority */
+static PolkitAuthority *authority = NULL;<--- Shadowed declaration
+
+/* the session we are servicing */
+static PolkitSubject *session = NULL;
+
+/* the current set of temporary authorizations */
+static GList *current_temporary_authorizations = NULL;
+
+#if defined(HAVE_AYATANA_APPINDICATOR) || defined(HAVE_UBUNTU_APPINDICATOR)
+static AppIndicator *app_indicator = NULL;
+#else
+static GtkStatusIcon *status_icon = NULL;
+#endif
+
+static GDBusProxy      *sm_proxy;
+static GDBusProxy      *client_proxy = NULL;
+
+static  GMainLoop *loop;
+
+static void
+revoke_tmp_authz_cb (GObject      *source_object,
+                     GAsyncResult *res,
+                     gpointer      user_data)
+{
+  GError *error;
+
+  error = NULL;
+  polkit_authority_revoke_temporary_authorizations_finish (POLKIT_AUTHORITY (source_object),
+                                                           res,
+                                                           &error);
+  if (error != NULL)
+    {
+      g_warning ("Error revoking temporary authorizations: %s", error->message);
+      g_error_free (error);
+    }
+}
+
+static void
+revoke_tmp_authz (void)
+{
+  polkit_authority_revoke_temporary_authorizations (authority,
+                                                    session,
+                                                    NULL,
+                                                    revoke_tmp_authz_cb,
+                                                    NULL);
+}
+
+#if defined(HAVE_AYATANA_APPINDICATOR) || defined(HAVE_UBUNTU_APPINDICATOR)
+static void
+on_menu_item_activate (GtkMenuItem *menu_item,
+                       gpointer     user_data)
+{
+  revoke_tmp_authz ();
+}
+#else
+static void
+on_status_icon_activate (GtkStatusIcon *status_icon,
+                         gpointer       user_data)
+{
+  revoke_tmp_authz ();
+}
+
+static void
+on_status_icon_popup_menu (GtkStatusIcon *status_icon,
+                           guint          button,
+                           guint          activate_time,
+                           gpointer       user_data)
+{
+  revoke_tmp_authz ();
+}
+#endif
+
+static void
+update_temporary_authorization_icon_real (void)
+{
+
+#if 0
+  GList *l;
+  g_debug ("have %d tmp authorizations", g_list_length (current_temporary_authorizations));
+  for (l = current_temporary_authorizations; l != NULL; l = l->next)
+    {
+      PolkitTemporaryAuthorization *authz = POLKIT_TEMPORARY_AUTHORIZATION (l->data);
+
+      g_debug ("have tmp authz for action %s (subject %s) with id %s (obtained %d, expires %d)",
+               polkit_temporary_authorization_get_action_id (authz),
+               polkit_subject_to_string (polkit_temporary_authorization_get_subject (authz)),
+               polkit_temporary_authorization_get_id (authz),
+               (gint) polkit_temporary_authorization_get_time_obtained (authz),
+               (gint) polkit_temporary_authorization_get_time_expires (authz));
+    }
+#endif
+
+  /* TODO:
+   *
+   * - we could do something fancy like displaying a window with the tmp authz
+   *   when the icon is clicked...
+   *
+   * - we could do some work using polkit_subject_exists() to ignore tmp authz
+   *   for subjects that no longer exists.. this is because temporary authorizations
+   *   are only valid for the subject that trigger the authentication dialog.
+   *
+   *   Maybe the authority could do this, would probably involve some polling, but
+   *   it seems cleaner to do this server side.
+   */
+
+  if (current_temporary_authorizations != NULL)
+    {
+      /* show icon */
+#if defined(HAVE_AYATANA_APPINDICATOR) || defined(HAVE_UBUNTU_APPINDICATOR)
+      if (app_indicator == NULL)
+        {
+          GtkWidget *item, *menu;
+
+          app_indicator = app_indicator_new ("mate-polkit",
+                                             "dialog-password",
+                                             APP_INDICATOR_CATEGORY_SYSTEM_SERVICES);
+
+          item = gtk_menu_item_new_with_label (_("Drop all elevated privileges"));
+          g_signal_connect (item,
+                            "activate",
+                            G_CALLBACK (on_menu_item_activate),
+                            NULL);
+          menu = gtk_menu_new ();
+          gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+          gtk_widget_show_all (menu);
+
+          app_indicator_set_menu (app_indicator,
+                                  GTK_MENU (menu));
+          app_indicator_set_status (app_indicator,
+                                    APP_INDICATOR_STATUS_ACTIVE);
+        }
+      else
+        /*Reshow icon from existing appindicator */
+        app_indicator_set_status (app_indicator,
+				    APP_INDICATOR_STATUS_ACTIVE);
+
+#else
+      if (status_icon == NULL)
+        {
+          status_icon = gtk_status_icon_new_from_icon_name ("dialog-password");
+          gtk_status_icon_set_tooltip_text (status_icon,
+                                            _("Click the icon to drop all elevated privileges"));
+          g_signal_connect (status_icon,
+                            "activate",
+                            G_CALLBACK (on_status_icon_activate),
+                            NULL);
+          g_signal_connect (status_icon,
+                            "popup-menu",
+                            G_CALLBACK (on_status_icon_popup_menu),
+                            NULL);
+        }
+#endif
+    }
+  else
+    {
+      /* hide icon */
+#if defined(HAVE_AYATANA_APPINDICATOR) || defined(HAVE_UBUNTU_APPINDICATOR)
+      if (app_indicator != NULL)
+        {
+          /* keep the app_indicator, hide the icon or it won't come back*/
+          app_indicator_set_status (app_indicator,
+				    APP_INDICATOR_STATUS_PASSIVE);
+        }
+#else
+      if (status_icon != NULL)
+        {
+          gtk_status_icon_set_visible (status_icon, FALSE);
+          g_object_unref (status_icon);
+          status_icon = NULL;
+        }
+#endif
+    }
+}
+
+static void
+enumerate_temporary_authorizations_cb (GObject      *source_object,
+                                       GAsyncResult *res,
+                                       gpointer      user_data)
+{
+  PolkitAuthority *authority = POLKIT_AUTHORITY (source_object);<--- Shadow variable
+  GList *temporary_authorizations;
+  GError *error;
+
+  temporary_authorizations = NULL;
+
+  error = NULL;
+  temporary_authorizations = polkit_authority_enumerate_temporary_authorizations_finish (authority,
+                                                                                         res,
+                                                                                         &error);
+  if (error != NULL)
+    {
+      g_warning ("Error enumerating temporary authorizations: %s", error->message);
+      g_error_free (error);
+      goto out;
+    }
+
+  g_list_foreach (current_temporary_authorizations, (GFunc) g_object_unref, NULL);
+  g_list_free (current_temporary_authorizations);
+
+  current_temporary_authorizations = temporary_authorizations;
+
+  update_temporary_authorization_icon_real ();
+
+ out:
+  ;
+}
+
+static void
+update_temporary_authorization_icon (PolkitAuthority *authority)
+{
+  polkit_authority_enumerate_temporary_authorizations (authority,
+                                                       session,
+                                                       NULL,
+                                                       enumerate_temporary_authorizations_cb,
+                                                       NULL);
+}
+
+static void
+on_authority_changed (PolkitAuthority *authority,
+                      gpointer         user_data)
+{
+  update_temporary_authorization_icon (authority);
+}
+
+static void
+stop_cb (void)
+{
+        g_main_loop_quit (loop);
+}
+
+static gboolean
+end_session_response (gboolean is_okay, const gchar *reason)
+{
+        GVariant *res;
+        GError *error = NULL;
+
+        res = g_dbus_proxy_call_sync (client_proxy,
+                                      "EndSessionResponse",
+                                      g_variant_new ("(bs)",
+                                                     is_okay,
+                                                     reason),
+                                      G_DBUS_CALL_FLAGS_NONE,
+                                      -1, /* timeout */
+                                      NULL, /* GCancellable */
+                                      &error);
+        if (! res) {
+                g_warning ("Failed to call EndSessionResponse: %s", error->message);
+                g_error_free (error);
+                return FALSE;
+        }
+
+        g_variant_unref (res);
+        return TRUE;
+}
+
+static void
+query_end_session_cb (void)
+{
+        end_session_response (TRUE, "");
+}
+
+static void
+end_session_cb (void)
+{
+        end_session_response (TRUE, "");
+        g_main_loop_quit (loop);
+}
+
+static void
+signal_cb (GDBusProxy *proxy, gchar *sender_name, gchar *signal_name,
+           GVariant *parameters, gpointer user_data)
+{
+        if (strcmp (signal_name, "Stop") == 0) {
+                stop_cb ();
+        } else if (strcmp (signal_name, "QueryEndSession") == 0) {
+                query_end_session_cb ();
+        } else if (strcmp (signal_name, "EndSession") == 0) {
+                end_session_cb ();
+        }
+}
+
+static gboolean
+register_client_to_gnome_session (void)
+{
+        GError     *error = NULL;
+        GVariant   *res;
+        const char *startup_id;
+        const char *app_id;
+        char       *client_id;
+
+        startup_id = g_getenv ("DESKTOP_AUTOSTART_ID");
+        app_id = "polkit-mate-authentication-agent-1.desktop";
+
+        sm_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
+                                                  G_DBUS_PROXY_FLAGS_NONE,
+                                                  NULL, /* GDBusInterfaceInfo */
+                                                  SM_DBUS_NAME,
+                                                  SM_DBUS_PATH,
+                                                  SM_DBUS_INTERFACE,
+                                                  NULL, /* GCancellable */
+                                                  &error);
+        if (sm_proxy == NULL) {
+                g_message("Failed to get session manager: %s", error->message);
+                g_error_free (error);
+                return FALSE;
+        }
+
+        res = g_dbus_proxy_call_sync (sm_proxy,
+                                      "RegisterClient",
+                                      g_variant_new ("(ss)",
+                                                     app_id,
+                                                     startup_id),
+                                      G_DBUS_CALL_FLAGS_NONE,
+                                      -1, /* timeout */
+                                      NULL, /* GCancellable */
+                                      &error);
+        if (! res) {
+                g_warning ("Failed to register client: %s", error->message);
+                g_error_free (error);
+                return FALSE;
+        }
+
+        if (! g_variant_is_of_type (res, G_VARIANT_TYPE ("(o)"))) {
+                g_warning ("RegisterClient returned unexpected type %s",
+                           g_variant_get_type_string (res));
+                return FALSE;
+        }
+
+        g_variant_get (res, "(&o)", &client_id);
+
+        client_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
+                                                      G_DBUS_PROXY_FLAGS_NONE,
+                                                      NULL, /* GDBusInterfaceInfo */
+                                                      SM_DBUS_NAME,
+                                                      client_id,
+                                                      SM_CLIENT_DBUS_INTERFACE,
+                                                      NULL, /* GCancellable */
+                                                      &error);
+        g_variant_unref (res);
+        if (client_proxy == NULL) {
+                g_message("Failed to get client proxy: %s", error->message);
+                g_error_free (error);
+                return FALSE;
+        }
+
+        g_signal_connect (client_proxy, "g-signal", G_CALLBACK (signal_cb), NULL);
+
+        return TRUE;
+}
+
+int
+main (int argc, char **argv)
+{
+  gint ret;
+  PolkitAgentListener *listener;
+  GError *error;
+
+  gtk_init (&argc, &argv);
+
+  loop = NULL;
+  authority = NULL;
+  listener = NULL;
+  session = NULL;
+  ret = 1;
+
+  bindtextdomain (GETTEXT_PACKAGE, MATELOCALEDIR);
+#if HAVE_BIND_TEXTDOMAIN_CODESET
+  bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+#endif
+  textdomain (GETTEXT_PACKAGE);
+
+  loop = g_main_loop_new (NULL, FALSE);
+
+  error = NULL;
+  authority = polkit_authority_get_sync (NULL /* GCancellable* */, &error);
+  if (authority == NULL)
+    {
+      g_warning ("Error getting authority: %s", error->message);
+      g_error_free (error);
+      goto out;
+    }
+  g_signal_connect (authority,
+                    "changed",
+                    G_CALLBACK (on_authority_changed),
+                    NULL);
+
+  listener = polkit_mate_listener_new ();
+
+  error = NULL;
+  session = polkit_unix_session_new_for_process_sync (getpid (), NULL, &error);
+  if (error != NULL)
+    {
+      g_warning ("Unable to determine the session we are in: %s", error->message);
+      g_error_free (error);
+      goto out;
+    }
+
+  error = NULL;
+  if (!polkit_agent_listener_register (listener,
+				       POLKIT_AGENT_REGISTER_FLAGS_NONE,
+                                       session,
+                                       "/org/mate/PolicyKit1/AuthenticationAgent",
+				       NULL,
+                                       &error))
+    {
+      g_printerr ("Cannot register authentication agent: %s\n", error->message);
+      g_error_free (error);
+      goto out;
+    }
+
+  update_temporary_authorization_icon (authority);
+
+  register_client_to_gnome_session();
+
+  g_main_loop_run (loop);
+
+  ret = 0;
+
+ out:
+  if (authority != NULL)
+    g_object_unref (authority);
+  if (session != NULL)
+    g_object_unref (session);
+  if (listener != NULL)
+    g_object_unref (listener);
+  if (loop != NULL)
+    g_main_loop_unref (loop);
+
+  return ret;
+}
+
+ +
+ +
+ + diff --git a/2023-02-10-194140-4152-cppcheck@484831434984_ayatana-indicators2/index.html b/2023-02-10-194140-4152-cppcheck@484831434984_ayatana-indicators2/index.html new file mode 100644 index 0000000..e6e1402 --- /dev/null +++ b/2023-02-10-194140-4152-cppcheck@484831434984_ayatana-indicators2/index.html @@ -0,0 +1,197 @@ + + + + + + Cppcheck - HTML report - mate-polkit + + + + + +
+ + + +
+ + + + + + + + + + +
LineIdCWESeverityMessage
missingIncludeinformationCppcheck cannot find all the include files (use --check-config for details)
src/main.c
226shadowVariable398styleLocal variable 'authority' shadows outer variable
+
+ +
+ + diff --git a/2023-02-10-194140-4152-cppcheck@484831434984_ayatana-indicators2/stats.html b/2023-02-10-194140-4152-cppcheck@484831434984_ayatana-indicators2/stats.html new file mode 100644 index 0000000..8f9eaf7 --- /dev/null +++ b/2023-02-10-194140-4152-cppcheck@484831434984_ayatana-indicators2/stats.html @@ -0,0 +1,167 @@ + + + + + + Cppcheck - HTML report - mate-polkit + + + + + +
+ + + +
+

Top 10 files for style severity, total findings: 1
+   1  src/main.c
+

+ +
+ +
+ + diff --git a/2023-02-10-194140-4152-cppcheck@484831434984_ayatana-indicators2/style.css b/2023-02-10-194140-4152-cppcheck@484831434984_ayatana-indicators2/style.css new file mode 100644 index 0000000..3897bfa --- /dev/null +++ b/2023-02-10-194140-4152-cppcheck@484831434984_ayatana-indicators2/style.css @@ -0,0 +1,177 @@ + +body { + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif; + font-size: 13px; + line-height: 1.5; + height: 100%; + margin: 0; +} + +#wrapper { + position: fixed; + height: 100vh; + width: 100vw; + display: grid; + grid-template-rows: fit-content(8rem) auto fit-content(8rem); + grid-template-columns: fit-content(25%) 1fr; + grid-template-areas: + "header header" + "menu content" + "footer footer"; +} + +h1 { + margin: 0 0 8px -2px; + font-size: 175%; +} + +.header { + padding: 0 0 5px 15px; + grid-area: header; + border-bottom: thin solid #aaa; +} + +.footer { + grid-area: footer; + border-top: thin solid #aaa; + font-size: 85%; + +} + +.footer > p { + margin: 4px; +} + +#menu, +#menu_index { + grid-area: menu; + text-align: left; + overflow: auto; + padding: 0 23px 15px 15px; + border-right: thin solid #aaa; + min-width: 200px; +} + +#menu > a { + display: block; + margin-left: 10px; + font-size: 12px; +} + +#content, +#content_index { + grid-area: content; + padding: 0px 5px 15px 15px; + overflow: auto; +} + +label { + white-space: nowrap; +} + +label.checkBtn.disabled { + color: #606060; + background: #e0e0e0; + font-style: italic; +} + +label.checkBtn, input[type="text"] { + border: 1px solid grey; + border-radius: 4px; + box-shadow: 1px 1px inset; + padding: 1px 5px; +} + +label.checkBtn { + white-space: nowrap; + background: #ccddff; +} + +label.unchecked { + background: #eff8ff; + box-shadow: 1px 1px 1px; +} + +label.checkBtn:hover, label.unchecked:hover{ + box-shadow: 0 0 2px; +} + +label.disabled:hover { + box-shadow: 1px 1px inset; +} + +label.checkBtn > input { + display:none; +} + +.summaryTable { + width: 100%; +} + +table.summaryTable td { padding: 0 5px 0 5px; } + +.statHeader, .severityHeader { + font-weight: bold; +} + +.warning { + background-color: #ffffa7; +} + +.error { + background-color: #ffb7b7; +} + +.error2 { + background-color: #faa; + display: inline-block; + margin-left: 4px; +} + +.inconclusive { + background-color: #b6b6b4; +} + +.inconclusive2 { + background-color: #b6b6b4; + display: inline-block; + margin-left: 4px; +} + +.verbose { + display: inline-block; + vertical-align: top; + cursor: help; +} + +.verbose .content { + display: none; + position: absolute; + padding: 10px; + margin: 4px; + max-width: 40%; + white-space: pre-wrap; + border: 1px solid #000; + background-color: #ffffcc; + cursor: auto; +} + +.highlight .hll { + padding: 1px; +} + +.highlighttable { + background-color: #fff; + position: relative; + margin: -10px; +} + +.linenos { + border-right: thin solid #aaa; + color: #d3d3d3; + padding-right: 6px; +} + +.id-filtered, .severity-filtered, .file-filtered, .tool-filtered, .text-filtered { + visibility: collapse; +} diff --git a/2023-02-10-194918-4414-cppcheck@65a6c367e28e_master/0.html b/2023-02-10-194918-4414-cppcheck@65a6c367e28e_master/0.html new file mode 100644 index 0000000..2b46300 --- /dev/null +++ b/2023-02-10-194918-4414-cppcheck@65a6c367e28e_master/0.html @@ -0,0 +1,1189 @@ + + + + + + Cppcheck - HTML report - mate-polkit + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
/*
+ * Copyright (C) 2009 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ * Author: David Zeuthen <davidz@redhat.com>
+ */
+
+#ifdef HAVE_CONFIG_H
+#  include "config.h"
+#endif
+
+#include <string.h>
+#include <gtk/gtk.h>
+#include <gio/gio.h>
+#include <glib/gi18n.h>
+#include <polkitagent/polkitagent.h>
+
+#if defined(HAVE_AYATANA_APPINDICATOR)
+# include <libayatana-appindicator/app-indicator.h>
+#elif defined(HAVE_UBUNTU_APPINDICATOR)
+# include <libappindicator/app-indicator.h>
+#endif
+
+#include "polkitmatelistener.h"
+
+/* session management support for auto-restart */
+#define SM_DBUS_NAME      "org.gnome.SessionManager"
+#define SM_DBUS_PATH      "/org/gnome/SessionManager"
+#define SM_DBUS_INTERFACE "org.gnome.SessionManager"
+#define SM_CLIENT_DBUS_INTERFACE "org.gnome.SessionManager.ClientPrivate"
+
+/* the Authority */
+static PolkitAuthority *authority = NULL;<--- Shadowed declaration
+
+/* the session we are servicing */
+static PolkitSubject *session = NULL;
+
+/* the current set of temporary authorizations */
+static GList *current_temporary_authorizations = NULL;
+
+#if defined(HAVE_AYATANA_APPINDICATOR) || defined(HAVE_UBUNTU_APPINDICATOR)
+static AppIndicator *app_indicator = NULL;
+#else
+static GtkStatusIcon *status_icon = NULL;
+#endif
+
+static GDBusProxy      *sm_proxy;
+static GDBusProxy      *client_proxy = NULL;
+
+static  GMainLoop *loop;
+
+static void
+revoke_tmp_authz_cb (GObject      *source_object,
+                     GAsyncResult *res,
+                     gpointer      user_data)
+{
+  GError *error;
+
+  error = NULL;
+  polkit_authority_revoke_temporary_authorizations_finish (POLKIT_AUTHORITY (source_object),
+                                                           res,
+                                                           &error);
+  if (error != NULL)
+    {
+      g_warning ("Error revoking temporary authorizations: %s", error->message);
+      g_error_free (error);
+    }
+}
+
+static void
+revoke_tmp_authz (void)
+{
+  polkit_authority_revoke_temporary_authorizations (authority,
+                                                    session,
+                                                    NULL,
+                                                    revoke_tmp_authz_cb,
+                                                    NULL);
+}
+
+#if defined(HAVE_AYATANA_APPINDICATOR) || defined(HAVE_UBUNTU_APPINDICATOR)
+static void
+on_menu_item_activate (GtkMenuItem *menu_item,
+                       gpointer     user_data)
+{
+  revoke_tmp_authz ();
+}
+#else
+static void
+on_status_icon_activate (GtkStatusIcon *status_icon,
+                         gpointer       user_data)
+{
+  revoke_tmp_authz ();
+}
+
+static void
+on_status_icon_popup_menu (GtkStatusIcon *status_icon,
+                           guint          button,
+                           guint          activate_time,
+                           gpointer       user_data)
+{
+  revoke_tmp_authz ();
+}
+#endif
+
+static void
+update_temporary_authorization_icon_real (void)
+{
+
+#if 0
+  GList *l;
+  g_debug ("have %d tmp authorizations", g_list_length (current_temporary_authorizations));
+  for (l = current_temporary_authorizations; l != NULL; l = l->next)
+    {
+      PolkitTemporaryAuthorization *authz = POLKIT_TEMPORARY_AUTHORIZATION (l->data);
+
+      g_debug ("have tmp authz for action %s (subject %s) with id %s (obtained %d, expires %d)",
+               polkit_temporary_authorization_get_action_id (authz),
+               polkit_subject_to_string (polkit_temporary_authorization_get_subject (authz)),
+               polkit_temporary_authorization_get_id (authz),
+               (gint) polkit_temporary_authorization_get_time_obtained (authz),
+               (gint) polkit_temporary_authorization_get_time_expires (authz));
+    }
+#endif
+
+  /* TODO:
+   *
+   * - we could do something fancy like displaying a window with the tmp authz
+   *   when the icon is clicked...
+   *
+   * - we could do some work using polkit_subject_exists() to ignore tmp authz
+   *   for subjects that no longer exists.. this is because temporary authorizations
+   *   are only valid for the subject that trigger the authentication dialog.
+   *
+   *   Maybe the authority could do this, would probably involve some polling, but
+   *   it seems cleaner to do this server side.
+   */
+
+  if (current_temporary_authorizations != NULL)
+    {
+      /* show icon */
+#if defined(HAVE_AYATANA_APPINDICATOR) || defined(HAVE_UBUNTU_APPINDICATOR)
+      if (app_indicator == NULL)
+        {
+          GtkWidget *item, *menu;
+
+          app_indicator = app_indicator_new ("mate-polkit",
+                                             "dialog-password",
+                                             APP_INDICATOR_CATEGORY_SYSTEM_SERVICES);
+
+          item = gtk_menu_item_new_with_label (_("Drop all elevated privileges"));
+          g_signal_connect (item,
+                            "activate",
+                            G_CALLBACK (on_menu_item_activate),
+                            NULL);
+          menu = gtk_menu_new ();
+          gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+          gtk_widget_show_all (menu);
+
+          app_indicator_set_menu (app_indicator,
+                                  GTK_MENU (menu));
+          app_indicator_set_status (app_indicator,
+                                    APP_INDICATOR_STATUS_ACTIVE);
+        }
+      else
+        /*Reshow icon from existing appindicator */
+        app_indicator_set_status (app_indicator,
+				    APP_INDICATOR_STATUS_ACTIVE);
+
+#else
+      if (status_icon == NULL)
+        {
+          status_icon = gtk_status_icon_new_from_icon_name ("dialog-password");
+          gtk_status_icon_set_tooltip_text (status_icon,
+                                            _("Click the icon to drop all elevated privileges"));
+          g_signal_connect (status_icon,
+                            "activate",
+                            G_CALLBACK (on_status_icon_activate),
+                            NULL);
+          g_signal_connect (status_icon,
+                            "popup-menu",
+                            G_CALLBACK (on_status_icon_popup_menu),
+                            NULL);
+        }
+#endif
+    }
+  else
+    {
+      /* hide icon */
+#if defined(HAVE_AYATANA_APPINDICATOR) || defined(HAVE_UBUNTU_APPINDICATOR)
+      if (app_indicator != NULL)
+        {
+          /* keep the app_indicator, hide the icon or it won't come back*/
+          app_indicator_set_status (app_indicator,
+				    APP_INDICATOR_STATUS_PASSIVE);
+        }
+#else
+      if (status_icon != NULL)
+        {
+          gtk_status_icon_set_visible (status_icon, FALSE);
+          g_object_unref (status_icon);
+          status_icon = NULL;
+        }
+#endif
+    }
+}
+
+static void
+enumerate_temporary_authorizations_cb (GObject      *source_object,
+                                       GAsyncResult *res,
+                                       gpointer      user_data)
+{
+  PolkitAuthority *authority = POLKIT_AUTHORITY (source_object);<--- Shadow variable
+  GList *temporary_authorizations;
+  GError *error;
+
+  temporary_authorizations = NULL;
+
+  error = NULL;
+  temporary_authorizations = polkit_authority_enumerate_temporary_authorizations_finish (authority,
+                                                                                         res,
+                                                                                         &error);
+  if (error != NULL)
+    {
+      g_warning ("Error enumerating temporary authorizations: %s", error->message);
+      g_error_free (error);
+      goto out;
+    }
+
+  g_list_foreach (current_temporary_authorizations, (GFunc) g_object_unref, NULL);
+  g_list_free (current_temporary_authorizations);
+
+  current_temporary_authorizations = temporary_authorizations;
+
+  update_temporary_authorization_icon_real ();
+
+ out:
+  ;
+}
+
+static void
+update_temporary_authorization_icon (PolkitAuthority *authority)
+{
+  polkit_authority_enumerate_temporary_authorizations (authority,
+                                                       session,
+                                                       NULL,
+                                                       enumerate_temporary_authorizations_cb,
+                                                       NULL);
+}
+
+static void
+on_authority_changed (PolkitAuthority *authority,
+                      gpointer         user_data)
+{
+  update_temporary_authorization_icon (authority);
+}
+
+static void
+stop_cb (void)
+{
+        g_main_loop_quit (loop);
+}
+
+static gboolean
+end_session_response (gboolean is_okay, const gchar *reason)
+{
+        GVariant *res;
+        GError *error = NULL;
+
+        res = g_dbus_proxy_call_sync (client_proxy,
+                                      "EndSessionResponse",
+                                      g_variant_new ("(bs)",
+                                                     is_okay,
+                                                     reason),
+                                      G_DBUS_CALL_FLAGS_NONE,
+                                      -1, /* timeout */
+                                      NULL, /* GCancellable */
+                                      &error);
+        if (! res) {
+                g_warning ("Failed to call EndSessionResponse: %s", error->message);
+                g_error_free (error);
+                return FALSE;
+        }
+
+        g_variant_unref (res);
+        return TRUE;
+}
+
+static void
+query_end_session_cb (void)
+{
+        end_session_response (TRUE, "");
+}
+
+static void
+end_session_cb (void)
+{
+        end_session_response (TRUE, "");
+        g_main_loop_quit (loop);
+}
+
+static void
+signal_cb (GDBusProxy *proxy, gchar *sender_name, gchar *signal_name,
+           GVariant *parameters, gpointer user_data)
+{
+        if (strcmp (signal_name, "Stop") == 0) {
+                stop_cb ();
+        } else if (strcmp (signal_name, "QueryEndSession") == 0) {
+                query_end_session_cb ();
+        } else if (strcmp (signal_name, "EndSession") == 0) {
+                end_session_cb ();
+        }
+}
+
+static gboolean
+register_client_to_gnome_session (void)
+{
+        GError     *error = NULL;
+        GVariant   *res;
+        const char *startup_id;
+        const char *app_id;
+        char       *client_id;
+
+        startup_id = g_getenv ("DESKTOP_AUTOSTART_ID");
+        app_id = "polkit-mate-authentication-agent-1.desktop";
+
+        sm_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
+                                                  G_DBUS_PROXY_FLAGS_NONE,
+                                                  NULL, /* GDBusInterfaceInfo */
+                                                  SM_DBUS_NAME,
+                                                  SM_DBUS_PATH,
+                                                  SM_DBUS_INTERFACE,
+                                                  NULL, /* GCancellable */
+                                                  &error);
+        if (sm_proxy == NULL) {
+                g_message("Failed to get session manager: %s", error->message);
+                g_error_free (error);
+                return FALSE;
+        }
+
+        res = g_dbus_proxy_call_sync (sm_proxy,
+                                      "RegisterClient",
+                                      g_variant_new ("(ss)",
+                                                     app_id,
+                                                     startup_id),
+                                      G_DBUS_CALL_FLAGS_NONE,
+                                      -1, /* timeout */
+                                      NULL, /* GCancellable */
+                                      &error);
+        if (! res) {
+                g_warning ("Failed to register client: %s", error->message);
+                g_error_free (error);
+                return FALSE;
+        }
+
+        if (! g_variant_is_of_type (res, G_VARIANT_TYPE ("(o)"))) {
+                g_warning ("RegisterClient returned unexpected type %s",
+                           g_variant_get_type_string (res));
+                return FALSE;
+        }
+
+        g_variant_get (res, "(&o)", &client_id);
+
+        client_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
+                                                      G_DBUS_PROXY_FLAGS_NONE,
+                                                      NULL, /* GDBusInterfaceInfo */
+                                                      SM_DBUS_NAME,
+                                                      client_id,
+                                                      SM_CLIENT_DBUS_INTERFACE,
+                                                      NULL, /* GCancellable */
+                                                      &error);
+        g_variant_unref (res);
+        if (client_proxy == NULL) {
+                g_message("Failed to get client proxy: %s", error->message);
+                g_error_free (error);
+                return FALSE;
+        }
+
+        g_signal_connect (client_proxy, "g-signal", G_CALLBACK (signal_cb), NULL);
+
+        return TRUE;
+}
+
+int
+main (int argc, char **argv)
+{
+  gint ret;
+  PolkitAgentListener *listener;
+  GError *error;
+
+  gtk_init (&argc, &argv);
+
+  loop = NULL;
+  authority = NULL;
+  listener = NULL;
+  session = NULL;
+  ret = 1;
+
+  bindtextdomain (GETTEXT_PACKAGE, MATELOCALEDIR);
+#if HAVE_BIND_TEXTDOMAIN_CODESET
+  bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+#endif
+  textdomain (GETTEXT_PACKAGE);
+
+  loop = g_main_loop_new (NULL, FALSE);
+
+  error = NULL;
+  authority = polkit_authority_get_sync (NULL /* GCancellable* */, &error);
+  if (authority == NULL)
+    {
+      g_warning ("Error getting authority: %s", error->message);
+      g_error_free (error);
+      goto out;
+    }
+  g_signal_connect (authority,
+                    "changed",
+                    G_CALLBACK (on_authority_changed),
+                    NULL);
+
+  listener = polkit_mate_listener_new ();
+
+  error = NULL;
+  session = polkit_unix_session_new_for_process_sync (getpid (), NULL, &error);
+  if (error != NULL)
+    {
+      g_warning ("Unable to determine the session we are in: %s", error->message);
+      g_error_free (error);
+      goto out;
+    }
+
+  error = NULL;
+  if (!polkit_agent_listener_register (listener,
+				       POLKIT_AGENT_REGISTER_FLAGS_NONE,
+                                       session,
+                                       "/org/mate/PolicyKit1/AuthenticationAgent",
+				       NULL,
+                                       &error))
+    {
+      g_printerr ("Cannot register authentication agent: %s\n", error->message);
+      g_error_free (error);
+      goto out;
+    }
+
+  update_temporary_authorization_icon (authority);
+
+  register_client_to_gnome_session();
+
+  g_main_loop_run (loop);
+
+  ret = 0;
+
+ out:
+  if (authority != NULL)
+    g_object_unref (authority);
+  if (session != NULL)
+    g_object_unref (session);
+  if (listener != NULL)
+    g_object_unref (listener);
+  if (loop != NULL)
+    g_main_loop_unref (loop);
+
+  return ret;
+}
+
+ +
+ +
+ + diff --git a/2023-02-10-194918-4414-cppcheck@65a6c367e28e_master/index.html b/2023-02-10-194918-4414-cppcheck@65a6c367e28e_master/index.html new file mode 100644 index 0000000..e6e1402 --- /dev/null +++ b/2023-02-10-194918-4414-cppcheck@65a6c367e28e_master/index.html @@ -0,0 +1,197 @@ + + + + + + Cppcheck - HTML report - mate-polkit + + + + + +
+ + + +
+ + + + + + + + + + +
LineIdCWESeverityMessage
missingIncludeinformationCppcheck cannot find all the include files (use --check-config for details)
src/main.c
226shadowVariable398styleLocal variable 'authority' shadows outer variable
+
+ +
+ + diff --git a/2023-02-10-194918-4414-cppcheck@65a6c367e28e_master/stats.html b/2023-02-10-194918-4414-cppcheck@65a6c367e28e_master/stats.html new file mode 100644 index 0000000..8f9eaf7 --- /dev/null +++ b/2023-02-10-194918-4414-cppcheck@65a6c367e28e_master/stats.html @@ -0,0 +1,167 @@ + + + + + + Cppcheck - HTML report - mate-polkit + + + + + +
+ + + +
+

Top 10 files for style severity, total findings: 1
+   1  src/main.c
+

+ +
+ +
+ + diff --git a/2023-02-10-194918-4414-cppcheck@65a6c367e28e_master/style.css b/2023-02-10-194918-4414-cppcheck@65a6c367e28e_master/style.css new file mode 100644 index 0000000..3897bfa --- /dev/null +++ b/2023-02-10-194918-4414-cppcheck@65a6c367e28e_master/style.css @@ -0,0 +1,177 @@ + +body { + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif; + font-size: 13px; + line-height: 1.5; + height: 100%; + margin: 0; +} + +#wrapper { + position: fixed; + height: 100vh; + width: 100vw; + display: grid; + grid-template-rows: fit-content(8rem) auto fit-content(8rem); + grid-template-columns: fit-content(25%) 1fr; + grid-template-areas: + "header header" + "menu content" + "footer footer"; +} + +h1 { + margin: 0 0 8px -2px; + font-size: 175%; +} + +.header { + padding: 0 0 5px 15px; + grid-area: header; + border-bottom: thin solid #aaa; +} + +.footer { + grid-area: footer; + border-top: thin solid #aaa; + font-size: 85%; + +} + +.footer > p { + margin: 4px; +} + +#menu, +#menu_index { + grid-area: menu; + text-align: left; + overflow: auto; + padding: 0 23px 15px 15px; + border-right: thin solid #aaa; + min-width: 200px; +} + +#menu > a { + display: block; + margin-left: 10px; + font-size: 12px; +} + +#content, +#content_index { + grid-area: content; + padding: 0px 5px 15px 15px; + overflow: auto; +} + +label { + white-space: nowrap; +} + +label.checkBtn.disabled { + color: #606060; + background: #e0e0e0; + font-style: italic; +} + +label.checkBtn, input[type="text"] { + border: 1px solid grey; + border-radius: 4px; + box-shadow: 1px 1px inset; + padding: 1px 5px; +} + +label.checkBtn { + white-space: nowrap; + background: #ccddff; +} + +label.unchecked { + background: #eff8ff; + box-shadow: 1px 1px 1px; +} + +label.checkBtn:hover, label.unchecked:hover{ + box-shadow: 0 0 2px; +} + +label.disabled:hover { + box-shadow: 1px 1px inset; +} + +label.checkBtn > input { + display:none; +} + +.summaryTable { + width: 100%; +} + +table.summaryTable td { padding: 0 5px 0 5px; } + +.statHeader, .severityHeader { + font-weight: bold; +} + +.warning { + background-color: #ffffa7; +} + +.error { + background-color: #ffb7b7; +} + +.error2 { + background-color: #faa; + display: inline-block; + margin-left: 4px; +} + +.inconclusive { + background-color: #b6b6b4; +} + +.inconclusive2 { + background-color: #b6b6b4; + display: inline-block; + margin-left: 4px; +} + +.verbose { + display: inline-block; + vertical-align: top; + cursor: help; +} + +.verbose .content { + display: none; + position: absolute; + padding: 10px; + margin: 4px; + max-width: 40%; + white-space: pre-wrap; + border: 1px solid #000; + background-color: #ffffcc; + cursor: auto; +} + +.highlight .hll { + padding: 1px; +} + +.highlighttable { + background-color: #fff; + position: relative; + margin: -10px; +} + +.linenos { + border-right: thin solid #aaa; + color: #d3d3d3; + padding-right: 6px; +} + +.id-filtered, .severity-filtered, .file-filtered, .tool-filtered, .text-filtered { + visibility: collapse; +} diff --git a/2023-05-23-093151-5604-cppcheck@13874beaa074_meson/0.html b/2023-05-23-093151-5604-cppcheck@13874beaa074_meson/0.html new file mode 100644 index 0000000..b179177 --- /dev/null +++ b/2023-05-23-093151-5604-cppcheck@13874beaa074_meson/0.html @@ -0,0 +1,1189 @@ + + + + + + Cppcheck - HTML report - mate-polkit + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
/*
+ * Copyright (C) 2009 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ * Author: David Zeuthen <davidz@redhat.com>
+ */
+
+#ifdef HAVE_CONFIG_H
+#  include "config.h"
+#endif
+
+#include <string.h>
+#include <gtk/gtk.h>
+#include <gio/gio.h>
+#include <glib/gi18n.h>
+#include <polkitagent/polkitagent.h>
+
+#if defined(HAVE_AYATANA_APPINDICATOR)
+# include <libayatana-appindicator/app-indicator.h>
+#elif defined(HAVE_UBUNTU_APPINDICATOR)
+# include <libappindicator/app-indicator.h>
+#endif
+
+#include "polkitmatelistener.h"
+
+/* session management support for auto-restart */
+#define SM_DBUS_NAME      "org.gnome.SessionManager"
+#define SM_DBUS_PATH      "/org/gnome/SessionManager"
+#define SM_DBUS_INTERFACE "org.gnome.SessionManager"
+#define SM_CLIENT_DBUS_INTERFACE "org.gnome.SessionManager.ClientPrivate"
+
+/* the Authority */
+static PolkitAuthority *authority = NULL;<--- Shadowed declaration
+
+/* the session we are servicing */
+static PolkitSubject *session = NULL;
+
+/* the current set of temporary authorizations */
+static GList *current_temporary_authorizations = NULL;
+
+#if defined(HAVE_AYATANA_APPINDICATOR) || defined(HAVE_UBUNTU_APPINDICATOR)
+static AppIndicator *app_indicator = NULL;
+#else
+static GtkStatusIcon *status_icon = NULL;
+#endif
+
+static GDBusProxy      *sm_proxy;
+static GDBusProxy      *client_proxy = NULL;
+
+static  GMainLoop *loop;
+
+static void
+revoke_tmp_authz_cb (GObject      *source_object,
+                     GAsyncResult *res,
+                     gpointer      user_data)
+{
+  GError *error;
+
+  error = NULL;
+  polkit_authority_revoke_temporary_authorizations_finish (POLKIT_AUTHORITY (source_object),
+                                                           res,
+                                                           &error);
+  if (error != NULL)
+    {
+      g_warning ("Error revoking temporary authorizations: %s", error->message);
+      g_error_free (error);
+    }
+}
+
+static void
+revoke_tmp_authz (void)
+{
+  polkit_authority_revoke_temporary_authorizations (authority,
+                                                    session,
+                                                    NULL,
+                                                    revoke_tmp_authz_cb,
+                                                    NULL);
+}
+
+#if defined(HAVE_AYATANA_APPINDICATOR) || defined(HAVE_UBUNTU_APPINDICATOR)
+static void
+on_menu_item_activate (GtkMenuItem *menu_item,
+                       gpointer     user_data)
+{
+  revoke_tmp_authz ();
+}
+#else
+static void
+on_status_icon_activate (GtkStatusIcon *status_icon,
+                         gpointer       user_data)
+{
+  revoke_tmp_authz ();
+}
+
+static void
+on_status_icon_popup_menu (GtkStatusIcon *status_icon,
+                           guint          button,
+                           guint          activate_time,
+                           gpointer       user_data)
+{
+  revoke_tmp_authz ();
+}
+#endif
+
+static void
+update_temporary_authorization_icon_real (void)
+{
+
+#if 0
+  GList *l;
+  g_debug ("have %d tmp authorizations", g_list_length (current_temporary_authorizations));
+  for (l = current_temporary_authorizations; l != NULL; l = l->next)
+    {
+      PolkitTemporaryAuthorization *authz = POLKIT_TEMPORARY_AUTHORIZATION (l->data);
+
+      g_debug ("have tmp authz for action %s (subject %s) with id %s (obtained %d, expires %d)",
+               polkit_temporary_authorization_get_action_id (authz),
+               polkit_subject_to_string (polkit_temporary_authorization_get_subject (authz)),
+               polkit_temporary_authorization_get_id (authz),
+               (gint) polkit_temporary_authorization_get_time_obtained (authz),
+               (gint) polkit_temporary_authorization_get_time_expires (authz));
+    }
+#endif
+
+  /* TODO:
+   *
+   * - we could do something fancy like displaying a window with the tmp authz
+   *   when the icon is clicked...
+   *
+   * - we could do some work using polkit_subject_exists() to ignore tmp authz
+   *   for subjects that no longer exists.. this is because temporary authorizations
+   *   are only valid for the subject that trigger the authentication dialog.
+   *
+   *   Maybe the authority could do this, would probably involve some polling, but
+   *   it seems cleaner to do this server side.
+   */
+
+  if (current_temporary_authorizations != NULL)
+    {
+      /* show icon */
+#if defined(HAVE_AYATANA_APPINDICATOR) || defined(HAVE_UBUNTU_APPINDICATOR)
+      if (app_indicator == NULL)
+        {
+          GtkWidget *item, *menu;
+
+          app_indicator = app_indicator_new ("mate-polkit",
+                                             "dialog-password",
+                                             APP_INDICATOR_CATEGORY_SYSTEM_SERVICES);
+
+          item = gtk_menu_item_new_with_label (_("Drop all elevated privileges"));
+          g_signal_connect (item,
+                            "activate",
+                            G_CALLBACK (on_menu_item_activate),
+                            NULL);
+          menu = gtk_menu_new ();
+          gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+          gtk_widget_show_all (menu);
+
+          app_indicator_set_menu (app_indicator,
+                                  GTK_MENU (menu));
+          app_indicator_set_status (app_indicator,
+                                    APP_INDICATOR_STATUS_ACTIVE);
+        }
+      else
+        /*Reshow icon from existing appindicator */
+        app_indicator_set_status (app_indicator,
+				    APP_INDICATOR_STATUS_ACTIVE);
+
+#else
+      if (status_icon == NULL)
+        {
+          status_icon = gtk_status_icon_new_from_icon_name ("dialog-password");
+          gtk_status_icon_set_tooltip_text (status_icon,
+                                            _("Click the icon to drop all elevated privileges"));
+          g_signal_connect (status_icon,
+                            "activate",
+                            G_CALLBACK (on_status_icon_activate),
+                            NULL);
+          g_signal_connect (status_icon,
+                            "popup-menu",
+                            G_CALLBACK (on_status_icon_popup_menu),
+                            NULL);
+        }
+#endif
+    }
+  else
+    {
+      /* hide icon */
+#if defined(HAVE_AYATANA_APPINDICATOR) || defined(HAVE_UBUNTU_APPINDICATOR)
+      if (app_indicator != NULL)
+        {
+          /* keep the app_indicator, hide the icon or it won't come back*/
+          app_indicator_set_status (app_indicator,
+				    APP_INDICATOR_STATUS_PASSIVE);
+        }
+#else
+      if (status_icon != NULL)
+        {
+          gtk_status_icon_set_visible (status_icon, FALSE);
+          g_object_unref (status_icon);
+          status_icon = NULL;
+        }
+#endif
+    }
+}
+
+static void
+enumerate_temporary_authorizations_cb (GObject      *source_object,
+                                       GAsyncResult *res,
+                                       gpointer      user_data)
+{
+  PolkitAuthority *authority = POLKIT_AUTHORITY (source_object);<--- Shadow variable
+  GList *temporary_authorizations;
+  GError *error;
+
+  temporary_authorizations = NULL;
+
+  error = NULL;
+  temporary_authorizations = polkit_authority_enumerate_temporary_authorizations_finish (authority,
+                                                                                         res,
+                                                                                         &error);
+  if (error != NULL)
+    {
+      g_warning ("Error enumerating temporary authorizations: %s", error->message);
+      g_error_free (error);
+      goto out;
+    }
+
+  g_list_foreach (current_temporary_authorizations, (GFunc) g_object_unref, NULL);
+  g_list_free (current_temporary_authorizations);
+
+  current_temporary_authorizations = temporary_authorizations;
+
+  update_temporary_authorization_icon_real ();
+
+ out:
+  ;
+}
+
+static void
+update_temporary_authorization_icon (PolkitAuthority *authority)
+{
+  polkit_authority_enumerate_temporary_authorizations (authority,
+                                                       session,
+                                                       NULL,
+                                                       enumerate_temporary_authorizations_cb,
+                                                       NULL);
+}
+
+static void
+on_authority_changed (PolkitAuthority *authority,
+                      gpointer         user_data)
+{
+  update_temporary_authorization_icon (authority);
+}
+
+static void
+stop_cb (void)
+{
+        g_main_loop_quit (loop);
+}
+
+static gboolean
+end_session_response (gboolean is_okay, const gchar *reason)
+{
+        GVariant *res;
+        GError *error = NULL;
+
+        res = g_dbus_proxy_call_sync (client_proxy,
+                                      "EndSessionResponse",
+                                      g_variant_new ("(bs)",
+                                                     is_okay,
+                                                     reason),
+                                      G_DBUS_CALL_FLAGS_NONE,
+                                      -1, /* timeout */
+                                      NULL, /* GCancellable */
+                                      &error);
+        if (! res) {
+                g_warning ("Failed to call EndSessionResponse: %s", error->message);
+                g_error_free (error);
+                return FALSE;
+        }
+
+        g_variant_unref (res);
+        return TRUE;
+}
+
+static void
+query_end_session_cb (void)
+{
+        end_session_response (TRUE, "");
+}
+
+static void
+end_session_cb (void)
+{
+        end_session_response (TRUE, "");
+        g_main_loop_quit (loop);
+}
+
+static void
+signal_cb (GDBusProxy *proxy, gchar *sender_name, gchar *signal_name,
+           GVariant *parameters, gpointer user_data)
+{
+        if (strcmp (signal_name, "Stop") == 0) {
+                stop_cb ();
+        } else if (strcmp (signal_name, "QueryEndSession") == 0) {
+                query_end_session_cb ();
+        } else if (strcmp (signal_name, "EndSession") == 0) {
+                end_session_cb ();
+        }
+}
+
+static gboolean
+register_client_to_gnome_session (void)
+{
+        GError     *error = NULL;
+        GVariant   *res;
+        const char *startup_id;
+        const char *app_id;
+        char       *client_id;
+
+        startup_id = g_getenv ("DESKTOP_AUTOSTART_ID");
+        app_id = "polkit-mate-authentication-agent-1.desktop";
+
+        sm_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
+                                                  G_DBUS_PROXY_FLAGS_NONE,
+                                                  NULL, /* GDBusInterfaceInfo */
+                                                  SM_DBUS_NAME,
+                                                  SM_DBUS_PATH,
+                                                  SM_DBUS_INTERFACE,
+                                                  NULL, /* GCancellable */
+                                                  &error);
+        if (sm_proxy == NULL) {
+                g_message("Failed to get session manager: %s", error->message);
+                g_error_free (error);
+                return FALSE;
+        }
+
+        res = g_dbus_proxy_call_sync (sm_proxy,
+                                      "RegisterClient",
+                                      g_variant_new ("(ss)",
+                                                     app_id,
+                                                     startup_id),
+                                      G_DBUS_CALL_FLAGS_NONE,
+                                      -1, /* timeout */
+                                      NULL, /* GCancellable */
+                                      &error);
+        if (! res) {
+                g_warning ("Failed to register client: %s", error->message);
+                g_error_free (error);
+                return FALSE;
+        }
+
+        if (! g_variant_is_of_type (res, G_VARIANT_TYPE ("(o)"))) {
+                g_warning ("RegisterClient returned unexpected type %s",
+                           g_variant_get_type_string (res));
+                return FALSE;
+        }
+
+        g_variant_get (res, "(&o)", &client_id);
+
+        client_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
+                                                      G_DBUS_PROXY_FLAGS_NONE,
+                                                      NULL, /* GDBusInterfaceInfo */
+                                                      SM_DBUS_NAME,
+                                                      client_id,
+                                                      SM_CLIENT_DBUS_INTERFACE,
+                                                      NULL, /* GCancellable */
+                                                      &error);
+        g_variant_unref (res);
+        if (client_proxy == NULL) {
+                g_message("Failed to get client proxy: %s", error->message);
+                g_error_free (error);
+                return FALSE;
+        }
+
+        g_signal_connect (client_proxy, "g-signal", G_CALLBACK (signal_cb), NULL);
+
+        return TRUE;
+}
+
+int
+main (int argc, char **argv)
+{
+  gint ret;
+  PolkitAgentListener *listener;
+  GError *error;
+
+  gtk_init (&argc, &argv);
+
+  loop = NULL;
+  authority = NULL;
+  listener = NULL;
+  session = NULL;
+  ret = 1;
+
+  bindtextdomain (GETTEXT_PACKAGE, MATELOCALEDIR);
+#if HAVE_BIND_TEXTDOMAIN_CODESET
+  bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+#endif
+  textdomain (GETTEXT_PACKAGE);
+
+  loop = g_main_loop_new (NULL, FALSE);
+
+  error = NULL;
+  authority = polkit_authority_get_sync (NULL /* GCancellable* */, &error);
+  if (authority == NULL)
+    {
+      g_warning ("Error getting authority: %s", error->message);
+      g_error_free (error);
+      goto out;
+    }
+  g_signal_connect (authority,
+                    "changed",
+                    G_CALLBACK (on_authority_changed),
+                    NULL);
+
+  listener = polkit_mate_listener_new ();
+
+  error = NULL;
+  session = polkit_unix_session_new_for_process_sync (getpid (), NULL, &error);
+  if (error != NULL)
+    {
+      g_warning ("Unable to determine the session we are in: %s", error->message);
+      g_error_free (error);
+      goto out;
+    }
+
+  error = NULL;
+  if (!polkit_agent_listener_register (listener,
+				       POLKIT_AGENT_REGISTER_FLAGS_NONE,
+                                       session,
+                                       "/org/mate/PolicyKit1/AuthenticationAgent",
+				       NULL,
+                                       &error))
+    {
+      g_printerr ("Cannot register authentication agent: %s\n", error->message);
+      g_error_free (error);
+      goto out;
+    }
+
+  update_temporary_authorization_icon (authority);
+
+  register_client_to_gnome_session();
+
+  g_main_loop_run (loop);
+
+  ret = 0;
+
+ out:
+  if (authority != NULL)
+    g_object_unref (authority);
+  if (session != NULL)
+    g_object_unref (session);
+  if (listener != NULL)
+    g_object_unref (listener);
+  if (loop != NULL)
+    g_main_loop_unref (loop);
+
+  return ret;
+}
+
+ +
+ +
+ + diff --git a/2023-05-23-093151-5604-cppcheck@13874beaa074_meson/index.html b/2023-05-23-093151-5604-cppcheck@13874beaa074_meson/index.html new file mode 100644 index 0000000..e6e1402 --- /dev/null +++ b/2023-05-23-093151-5604-cppcheck@13874beaa074_meson/index.html @@ -0,0 +1,197 @@ + + + + + + Cppcheck - HTML report - mate-polkit + + + + + +
+ + + +
+ + + + + + + + + + +
LineIdCWESeverityMessage
missingIncludeinformationCppcheck cannot find all the include files (use --check-config for details)
src/main.c
226shadowVariable398styleLocal variable 'authority' shadows outer variable
+
+ +
+ + diff --git a/2023-05-23-093151-5604-cppcheck@13874beaa074_meson/stats.html b/2023-05-23-093151-5604-cppcheck@13874beaa074_meson/stats.html new file mode 100644 index 0000000..8f9eaf7 --- /dev/null +++ b/2023-05-23-093151-5604-cppcheck@13874beaa074_meson/stats.html @@ -0,0 +1,167 @@ + + + + + + Cppcheck - HTML report - mate-polkit + + + + + +
+ + + +
+

Top 10 files for style severity, total findings: 1
+   1  src/main.c
+

+ +
+ +
+ + diff --git a/2023-05-23-093151-5604-cppcheck@13874beaa074_meson/style.css b/2023-05-23-093151-5604-cppcheck@13874beaa074_meson/style.css new file mode 100644 index 0000000..3897bfa --- /dev/null +++ b/2023-05-23-093151-5604-cppcheck@13874beaa074_meson/style.css @@ -0,0 +1,177 @@ + +body { + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif; + font-size: 13px; + line-height: 1.5; + height: 100%; + margin: 0; +} + +#wrapper { + position: fixed; + height: 100vh; + width: 100vw; + display: grid; + grid-template-rows: fit-content(8rem) auto fit-content(8rem); + grid-template-columns: fit-content(25%) 1fr; + grid-template-areas: + "header header" + "menu content" + "footer footer"; +} + +h1 { + margin: 0 0 8px -2px; + font-size: 175%; +} + +.header { + padding: 0 0 5px 15px; + grid-area: header; + border-bottom: thin solid #aaa; +} + +.footer { + grid-area: footer; + border-top: thin solid #aaa; + font-size: 85%; + +} + +.footer > p { + margin: 4px; +} + +#menu, +#menu_index { + grid-area: menu; + text-align: left; + overflow: auto; + padding: 0 23px 15px 15px; + border-right: thin solid #aaa; + min-width: 200px; +} + +#menu > a { + display: block; + margin-left: 10px; + font-size: 12px; +} + +#content, +#content_index { + grid-area: content; + padding: 0px 5px 15px 15px; + overflow: auto; +} + +label { + white-space: nowrap; +} + +label.checkBtn.disabled { + color: #606060; + background: #e0e0e0; + font-style: italic; +} + +label.checkBtn, input[type="text"] { + border: 1px solid grey; + border-radius: 4px; + box-shadow: 1px 1px inset; + padding: 1px 5px; +} + +label.checkBtn { + white-space: nowrap; + background: #ccddff; +} + +label.unchecked { + background: #eff8ff; + box-shadow: 1px 1px 1px; +} + +label.checkBtn:hover, label.unchecked:hover{ + box-shadow: 0 0 2px; +} + +label.disabled:hover { + box-shadow: 1px 1px inset; +} + +label.checkBtn > input { + display:none; +} + +.summaryTable { + width: 100%; +} + +table.summaryTable td { padding: 0 5px 0 5px; } + +.statHeader, .severityHeader { + font-weight: bold; +} + +.warning { + background-color: #ffffa7; +} + +.error { + background-color: #ffb7b7; +} + +.error2 { + background-color: #faa; + display: inline-block; + margin-left: 4px; +} + +.inconclusive { + background-color: #b6b6b4; +} + +.inconclusive2 { + background-color: #b6b6b4; + display: inline-block; + margin-left: 4px; +} + +.verbose { + display: inline-block; + vertical-align: top; + cursor: help; +} + +.verbose .content { + display: none; + position: absolute; + padding: 10px; + margin: 4px; + max-width: 40%; + white-space: pre-wrap; + border: 1px solid #000; + background-color: #ffffcc; + cursor: auto; +} + +.highlight .hll { + padding: 1px; +} + +.highlighttable { + background-color: #fff; + position: relative; + margin: -10px; +} + +.linenos { + border-right: thin solid #aaa; + color: #d3d3d3; + padding-right: 6px; +} + +.id-filtered, .severity-filtered, .file-filtered, .tool-filtered, .text-filtered { + visibility: collapse; +} diff --git a/2023-05-25-161821-0349-cppcheck@a3f91214bc68_master/0.html b/2023-05-25-161821-0349-cppcheck@a3f91214bc68_master/0.html new file mode 100644 index 0000000..b179177 --- /dev/null +++ b/2023-05-25-161821-0349-cppcheck@a3f91214bc68_master/0.html @@ -0,0 +1,1189 @@ + + + + + + Cppcheck - HTML report - mate-polkit + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
/*
+ * Copyright (C) 2009 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ * Author: David Zeuthen <davidz@redhat.com>
+ */
+
+#ifdef HAVE_CONFIG_H
+#  include "config.h"
+#endif
+
+#include <string.h>
+#include <gtk/gtk.h>
+#include <gio/gio.h>
+#include <glib/gi18n.h>
+#include <polkitagent/polkitagent.h>
+
+#if defined(HAVE_AYATANA_APPINDICATOR)
+# include <libayatana-appindicator/app-indicator.h>
+#elif defined(HAVE_UBUNTU_APPINDICATOR)
+# include <libappindicator/app-indicator.h>
+#endif
+
+#include "polkitmatelistener.h"
+
+/* session management support for auto-restart */
+#define SM_DBUS_NAME      "org.gnome.SessionManager"
+#define SM_DBUS_PATH      "/org/gnome/SessionManager"
+#define SM_DBUS_INTERFACE "org.gnome.SessionManager"
+#define SM_CLIENT_DBUS_INTERFACE "org.gnome.SessionManager.ClientPrivate"
+
+/* the Authority */
+static PolkitAuthority *authority = NULL;<--- Shadowed declaration
+
+/* the session we are servicing */
+static PolkitSubject *session = NULL;
+
+/* the current set of temporary authorizations */
+static GList *current_temporary_authorizations = NULL;
+
+#if defined(HAVE_AYATANA_APPINDICATOR) || defined(HAVE_UBUNTU_APPINDICATOR)
+static AppIndicator *app_indicator = NULL;
+#else
+static GtkStatusIcon *status_icon = NULL;
+#endif
+
+static GDBusProxy      *sm_proxy;
+static GDBusProxy      *client_proxy = NULL;
+
+static  GMainLoop *loop;
+
+static void
+revoke_tmp_authz_cb (GObject      *source_object,
+                     GAsyncResult *res,
+                     gpointer      user_data)
+{
+  GError *error;
+
+  error = NULL;
+  polkit_authority_revoke_temporary_authorizations_finish (POLKIT_AUTHORITY (source_object),
+                                                           res,
+                                                           &error);
+  if (error != NULL)
+    {
+      g_warning ("Error revoking temporary authorizations: %s", error->message);
+      g_error_free (error);
+    }
+}
+
+static void
+revoke_tmp_authz (void)
+{
+  polkit_authority_revoke_temporary_authorizations (authority,
+                                                    session,
+                                                    NULL,
+                                                    revoke_tmp_authz_cb,
+                                                    NULL);
+}
+
+#if defined(HAVE_AYATANA_APPINDICATOR) || defined(HAVE_UBUNTU_APPINDICATOR)
+static void
+on_menu_item_activate (GtkMenuItem *menu_item,
+                       gpointer     user_data)
+{
+  revoke_tmp_authz ();
+}
+#else
+static void
+on_status_icon_activate (GtkStatusIcon *status_icon,
+                         gpointer       user_data)
+{
+  revoke_tmp_authz ();
+}
+
+static void
+on_status_icon_popup_menu (GtkStatusIcon *status_icon,
+                           guint          button,
+                           guint          activate_time,
+                           gpointer       user_data)
+{
+  revoke_tmp_authz ();
+}
+#endif
+
+static void
+update_temporary_authorization_icon_real (void)
+{
+
+#if 0
+  GList *l;
+  g_debug ("have %d tmp authorizations", g_list_length (current_temporary_authorizations));
+  for (l = current_temporary_authorizations; l != NULL; l = l->next)
+    {
+      PolkitTemporaryAuthorization *authz = POLKIT_TEMPORARY_AUTHORIZATION (l->data);
+
+      g_debug ("have tmp authz for action %s (subject %s) with id %s (obtained %d, expires %d)",
+               polkit_temporary_authorization_get_action_id (authz),
+               polkit_subject_to_string (polkit_temporary_authorization_get_subject (authz)),
+               polkit_temporary_authorization_get_id (authz),
+               (gint) polkit_temporary_authorization_get_time_obtained (authz),
+               (gint) polkit_temporary_authorization_get_time_expires (authz));
+    }
+#endif
+
+  /* TODO:
+   *
+   * - we could do something fancy like displaying a window with the tmp authz
+   *   when the icon is clicked...
+   *
+   * - we could do some work using polkit_subject_exists() to ignore tmp authz
+   *   for subjects that no longer exists.. this is because temporary authorizations
+   *   are only valid for the subject that trigger the authentication dialog.
+   *
+   *   Maybe the authority could do this, would probably involve some polling, but
+   *   it seems cleaner to do this server side.
+   */
+
+  if (current_temporary_authorizations != NULL)
+    {
+      /* show icon */
+#if defined(HAVE_AYATANA_APPINDICATOR) || defined(HAVE_UBUNTU_APPINDICATOR)
+      if (app_indicator == NULL)
+        {
+          GtkWidget *item, *menu;
+
+          app_indicator = app_indicator_new ("mate-polkit",
+                                             "dialog-password",
+                                             APP_INDICATOR_CATEGORY_SYSTEM_SERVICES);
+
+          item = gtk_menu_item_new_with_label (_("Drop all elevated privileges"));
+          g_signal_connect (item,
+                            "activate",
+                            G_CALLBACK (on_menu_item_activate),
+                            NULL);
+          menu = gtk_menu_new ();
+          gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+          gtk_widget_show_all (menu);
+
+          app_indicator_set_menu (app_indicator,
+                                  GTK_MENU (menu));
+          app_indicator_set_status (app_indicator,
+                                    APP_INDICATOR_STATUS_ACTIVE);
+        }
+      else
+        /*Reshow icon from existing appindicator */
+        app_indicator_set_status (app_indicator,
+				    APP_INDICATOR_STATUS_ACTIVE);
+
+#else
+      if (status_icon == NULL)
+        {
+          status_icon = gtk_status_icon_new_from_icon_name ("dialog-password");
+          gtk_status_icon_set_tooltip_text (status_icon,
+                                            _("Click the icon to drop all elevated privileges"));
+          g_signal_connect (status_icon,
+                            "activate",
+                            G_CALLBACK (on_status_icon_activate),
+                            NULL);
+          g_signal_connect (status_icon,
+                            "popup-menu",
+                            G_CALLBACK (on_status_icon_popup_menu),
+                            NULL);
+        }
+#endif
+    }
+  else
+    {
+      /* hide icon */
+#if defined(HAVE_AYATANA_APPINDICATOR) || defined(HAVE_UBUNTU_APPINDICATOR)
+      if (app_indicator != NULL)
+        {
+          /* keep the app_indicator, hide the icon or it won't come back*/
+          app_indicator_set_status (app_indicator,
+				    APP_INDICATOR_STATUS_PASSIVE);
+        }
+#else
+      if (status_icon != NULL)
+        {
+          gtk_status_icon_set_visible (status_icon, FALSE);
+          g_object_unref (status_icon);
+          status_icon = NULL;
+        }
+#endif
+    }
+}
+
+static void
+enumerate_temporary_authorizations_cb (GObject      *source_object,
+                                       GAsyncResult *res,
+                                       gpointer      user_data)
+{
+  PolkitAuthority *authority = POLKIT_AUTHORITY (source_object);<--- Shadow variable
+  GList *temporary_authorizations;
+  GError *error;
+
+  temporary_authorizations = NULL;
+
+  error = NULL;
+  temporary_authorizations = polkit_authority_enumerate_temporary_authorizations_finish (authority,
+                                                                                         res,
+                                                                                         &error);
+  if (error != NULL)
+    {
+      g_warning ("Error enumerating temporary authorizations: %s", error->message);
+      g_error_free (error);
+      goto out;
+    }
+
+  g_list_foreach (current_temporary_authorizations, (GFunc) g_object_unref, NULL);
+  g_list_free (current_temporary_authorizations);
+
+  current_temporary_authorizations = temporary_authorizations;
+
+  update_temporary_authorization_icon_real ();
+
+ out:
+  ;
+}
+
+static void
+update_temporary_authorization_icon (PolkitAuthority *authority)
+{
+  polkit_authority_enumerate_temporary_authorizations (authority,
+                                                       session,
+                                                       NULL,
+                                                       enumerate_temporary_authorizations_cb,
+                                                       NULL);
+}
+
+static void
+on_authority_changed (PolkitAuthority *authority,
+                      gpointer         user_data)
+{
+  update_temporary_authorization_icon (authority);
+}
+
+static void
+stop_cb (void)
+{
+        g_main_loop_quit (loop);
+}
+
+static gboolean
+end_session_response (gboolean is_okay, const gchar *reason)
+{
+        GVariant *res;
+        GError *error = NULL;
+
+        res = g_dbus_proxy_call_sync (client_proxy,
+                                      "EndSessionResponse",
+                                      g_variant_new ("(bs)",
+                                                     is_okay,
+                                                     reason),
+                                      G_DBUS_CALL_FLAGS_NONE,
+                                      -1, /* timeout */
+                                      NULL, /* GCancellable */
+                                      &error);
+        if (! res) {
+                g_warning ("Failed to call EndSessionResponse: %s", error->message);
+                g_error_free (error);
+                return FALSE;
+        }
+
+        g_variant_unref (res);
+        return TRUE;
+}
+
+static void
+query_end_session_cb (void)
+{
+        end_session_response (TRUE, "");
+}
+
+static void
+end_session_cb (void)
+{
+        end_session_response (TRUE, "");
+        g_main_loop_quit (loop);
+}
+
+static void
+signal_cb (GDBusProxy *proxy, gchar *sender_name, gchar *signal_name,
+           GVariant *parameters, gpointer user_data)
+{
+        if (strcmp (signal_name, "Stop") == 0) {
+                stop_cb ();
+        } else if (strcmp (signal_name, "QueryEndSession") == 0) {
+                query_end_session_cb ();
+        } else if (strcmp (signal_name, "EndSession") == 0) {
+                end_session_cb ();
+        }
+}
+
+static gboolean
+register_client_to_gnome_session (void)
+{
+        GError     *error = NULL;
+        GVariant   *res;
+        const char *startup_id;
+        const char *app_id;
+        char       *client_id;
+
+        startup_id = g_getenv ("DESKTOP_AUTOSTART_ID");
+        app_id = "polkit-mate-authentication-agent-1.desktop";
+
+        sm_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
+                                                  G_DBUS_PROXY_FLAGS_NONE,
+                                                  NULL, /* GDBusInterfaceInfo */
+                                                  SM_DBUS_NAME,
+                                                  SM_DBUS_PATH,
+                                                  SM_DBUS_INTERFACE,
+                                                  NULL, /* GCancellable */
+                                                  &error);
+        if (sm_proxy == NULL) {
+                g_message("Failed to get session manager: %s", error->message);
+                g_error_free (error);
+                return FALSE;
+        }
+
+        res = g_dbus_proxy_call_sync (sm_proxy,
+                                      "RegisterClient",
+                                      g_variant_new ("(ss)",
+                                                     app_id,
+                                                     startup_id),
+                                      G_DBUS_CALL_FLAGS_NONE,
+                                      -1, /* timeout */
+                                      NULL, /* GCancellable */
+                                      &error);
+        if (! res) {
+                g_warning ("Failed to register client: %s", error->message);
+                g_error_free (error);
+                return FALSE;
+        }
+
+        if (! g_variant_is_of_type (res, G_VARIANT_TYPE ("(o)"))) {
+                g_warning ("RegisterClient returned unexpected type %s",
+                           g_variant_get_type_string (res));
+                return FALSE;
+        }
+
+        g_variant_get (res, "(&o)", &client_id);
+
+        client_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
+                                                      G_DBUS_PROXY_FLAGS_NONE,
+                                                      NULL, /* GDBusInterfaceInfo */
+                                                      SM_DBUS_NAME,
+                                                      client_id,
+                                                      SM_CLIENT_DBUS_INTERFACE,
+                                                      NULL, /* GCancellable */
+                                                      &error);
+        g_variant_unref (res);
+        if (client_proxy == NULL) {
+                g_message("Failed to get client proxy: %s", error->message);
+                g_error_free (error);
+                return FALSE;
+        }
+
+        g_signal_connect (client_proxy, "g-signal", G_CALLBACK (signal_cb), NULL);
+
+        return TRUE;
+}
+
+int
+main (int argc, char **argv)
+{
+  gint ret;
+  PolkitAgentListener *listener;
+  GError *error;
+
+  gtk_init (&argc, &argv);
+
+  loop = NULL;
+  authority = NULL;
+  listener = NULL;
+  session = NULL;
+  ret = 1;
+
+  bindtextdomain (GETTEXT_PACKAGE, MATELOCALEDIR);
+#if HAVE_BIND_TEXTDOMAIN_CODESET
+  bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+#endif
+  textdomain (GETTEXT_PACKAGE);
+
+  loop = g_main_loop_new (NULL, FALSE);
+
+  error = NULL;
+  authority = polkit_authority_get_sync (NULL /* GCancellable* */, &error);
+  if (authority == NULL)
+    {
+      g_warning ("Error getting authority: %s", error->message);
+      g_error_free (error);
+      goto out;
+    }
+  g_signal_connect (authority,
+                    "changed",
+                    G_CALLBACK (on_authority_changed),
+                    NULL);
+
+  listener = polkit_mate_listener_new ();
+
+  error = NULL;
+  session = polkit_unix_session_new_for_process_sync (getpid (), NULL, &error);
+  if (error != NULL)
+    {
+      g_warning ("Unable to determine the session we are in: %s", error->message);
+      g_error_free (error);
+      goto out;
+    }
+
+  error = NULL;
+  if (!polkit_agent_listener_register (listener,
+				       POLKIT_AGENT_REGISTER_FLAGS_NONE,
+                                       session,
+                                       "/org/mate/PolicyKit1/AuthenticationAgent",
+				       NULL,
+                                       &error))
+    {
+      g_printerr ("Cannot register authentication agent: %s\n", error->message);
+      g_error_free (error);
+      goto out;
+    }
+
+  update_temporary_authorization_icon (authority);
+
+  register_client_to_gnome_session();
+
+  g_main_loop_run (loop);
+
+  ret = 0;
+
+ out:
+  if (authority != NULL)
+    g_object_unref (authority);
+  if (session != NULL)
+    g_object_unref (session);
+  if (listener != NULL)
+    g_object_unref (listener);
+  if (loop != NULL)
+    g_main_loop_unref (loop);
+
+  return ret;
+}
+
+ +
+ +
+ + diff --git a/2023-05-25-161821-0349-cppcheck@a3f91214bc68_master/index.html b/2023-05-25-161821-0349-cppcheck@a3f91214bc68_master/index.html new file mode 100644 index 0000000..e6e1402 --- /dev/null +++ b/2023-05-25-161821-0349-cppcheck@a3f91214bc68_master/index.html @@ -0,0 +1,197 @@ + + + + + + Cppcheck - HTML report - mate-polkit + + + + + +
+ + + +
+ + + + + + + + + + +
LineIdCWESeverityMessage
missingIncludeinformationCppcheck cannot find all the include files (use --check-config for details)
src/main.c
226shadowVariable398styleLocal variable 'authority' shadows outer variable
+
+ +
+ + diff --git a/2023-05-25-161821-0349-cppcheck@a3f91214bc68_master/stats.html b/2023-05-25-161821-0349-cppcheck@a3f91214bc68_master/stats.html new file mode 100644 index 0000000..8f9eaf7 --- /dev/null +++ b/2023-05-25-161821-0349-cppcheck@a3f91214bc68_master/stats.html @@ -0,0 +1,167 @@ + + + + + + Cppcheck - HTML report - mate-polkit + + + + + +
+ + + +
+

Top 10 files for style severity, total findings: 1
+   1  src/main.c
+

+ +
+ +
+ + diff --git a/2023-05-25-161821-0349-cppcheck@a3f91214bc68_master/style.css b/2023-05-25-161821-0349-cppcheck@a3f91214bc68_master/style.css new file mode 100644 index 0000000..3897bfa --- /dev/null +++ b/2023-05-25-161821-0349-cppcheck@a3f91214bc68_master/style.css @@ -0,0 +1,177 @@ + +body { + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif; + font-size: 13px; + line-height: 1.5; + height: 100%; + margin: 0; +} + +#wrapper { + position: fixed; + height: 100vh; + width: 100vw; + display: grid; + grid-template-rows: fit-content(8rem) auto fit-content(8rem); + grid-template-columns: fit-content(25%) 1fr; + grid-template-areas: + "header header" + "menu content" + "footer footer"; +} + +h1 { + margin: 0 0 8px -2px; + font-size: 175%; +} + +.header { + padding: 0 0 5px 15px; + grid-area: header; + border-bottom: thin solid #aaa; +} + +.footer { + grid-area: footer; + border-top: thin solid #aaa; + font-size: 85%; + +} + +.footer > p { + margin: 4px; +} + +#menu, +#menu_index { + grid-area: menu; + text-align: left; + overflow: auto; + padding: 0 23px 15px 15px; + border-right: thin solid #aaa; + min-width: 200px; +} + +#menu > a { + display: block; + margin-left: 10px; + font-size: 12px; +} + +#content, +#content_index { + grid-area: content; + padding: 0px 5px 15px 15px; + overflow: auto; +} + +label { + white-space: nowrap; +} + +label.checkBtn.disabled { + color: #606060; + background: #e0e0e0; + font-style: italic; +} + +label.checkBtn, input[type="text"] { + border: 1px solid grey; + border-radius: 4px; + box-shadow: 1px 1px inset; + padding: 1px 5px; +} + +label.checkBtn { + white-space: nowrap; + background: #ccddff; +} + +label.unchecked { + background: #eff8ff; + box-shadow: 1px 1px 1px; +} + +label.checkBtn:hover, label.unchecked:hover{ + box-shadow: 0 0 2px; +} + +label.disabled:hover { + box-shadow: 1px 1px inset; +} + +label.checkBtn > input { + display:none; +} + +.summaryTable { + width: 100%; +} + +table.summaryTable td { padding: 0 5px 0 5px; } + +.statHeader, .severityHeader { + font-weight: bold; +} + +.warning { + background-color: #ffffa7; +} + +.error { + background-color: #ffb7b7; +} + +.error2 { + background-color: #faa; + display: inline-block; + margin-left: 4px; +} + +.inconclusive { + background-color: #b6b6b4; +} + +.inconclusive2 { + background-color: #b6b6b4; + display: inline-block; + margin-left: 4px; +} + +.verbose { + display: inline-block; + vertical-align: top; + cursor: help; +} + +.verbose .content { + display: none; + position: absolute; + padding: 10px; + margin: 4px; + max-width: 40%; + white-space: pre-wrap; + border: 1px solid #000; + background-color: #ffffcc; + cursor: auto; +} + +.highlight .hll { + padding: 1px; +} + +.highlighttable { + background-color: #fff; + position: relative; + margin: -10px; +} + +.linenos { + border-right: thin solid #aaa; + color: #d3d3d3; + padding-right: 6px; +} + +.id-filtered, .severity-filtered, .file-filtered, .tool-filtered, .text-filtered { + visibility: collapse; +} diff --git a/2023-08-30-131815-8382-cppcheck@5851bb1e1c2c_master/0.html b/2023-08-30-131815-8382-cppcheck@5851bb1e1c2c_master/0.html new file mode 100644 index 0000000..b179177 --- /dev/null +++ b/2023-08-30-131815-8382-cppcheck@5851bb1e1c2c_master/0.html @@ -0,0 +1,1189 @@ + + + + + + Cppcheck - HTML report - mate-polkit + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
/*
+ * Copyright (C) 2009 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ * Author: David Zeuthen <davidz@redhat.com>
+ */
+
+#ifdef HAVE_CONFIG_H
+#  include "config.h"
+#endif
+
+#include <string.h>
+#include <gtk/gtk.h>
+#include <gio/gio.h>
+#include <glib/gi18n.h>
+#include <polkitagent/polkitagent.h>
+
+#if defined(HAVE_AYATANA_APPINDICATOR)
+# include <libayatana-appindicator/app-indicator.h>
+#elif defined(HAVE_UBUNTU_APPINDICATOR)
+# include <libappindicator/app-indicator.h>
+#endif
+
+#include "polkitmatelistener.h"
+
+/* session management support for auto-restart */
+#define SM_DBUS_NAME      "org.gnome.SessionManager"
+#define SM_DBUS_PATH      "/org/gnome/SessionManager"
+#define SM_DBUS_INTERFACE "org.gnome.SessionManager"
+#define SM_CLIENT_DBUS_INTERFACE "org.gnome.SessionManager.ClientPrivate"
+
+/* the Authority */
+static PolkitAuthority *authority = NULL;<--- Shadowed declaration
+
+/* the session we are servicing */
+static PolkitSubject *session = NULL;
+
+/* the current set of temporary authorizations */
+static GList *current_temporary_authorizations = NULL;
+
+#if defined(HAVE_AYATANA_APPINDICATOR) || defined(HAVE_UBUNTU_APPINDICATOR)
+static AppIndicator *app_indicator = NULL;
+#else
+static GtkStatusIcon *status_icon = NULL;
+#endif
+
+static GDBusProxy      *sm_proxy;
+static GDBusProxy      *client_proxy = NULL;
+
+static  GMainLoop *loop;
+
+static void
+revoke_tmp_authz_cb (GObject      *source_object,
+                     GAsyncResult *res,
+                     gpointer      user_data)
+{
+  GError *error;
+
+  error = NULL;
+  polkit_authority_revoke_temporary_authorizations_finish (POLKIT_AUTHORITY (source_object),
+                                                           res,
+                                                           &error);
+  if (error != NULL)
+    {
+      g_warning ("Error revoking temporary authorizations: %s", error->message);
+      g_error_free (error);
+    }
+}
+
+static void
+revoke_tmp_authz (void)
+{
+  polkit_authority_revoke_temporary_authorizations (authority,
+                                                    session,
+                                                    NULL,
+                                                    revoke_tmp_authz_cb,
+                                                    NULL);
+}
+
+#if defined(HAVE_AYATANA_APPINDICATOR) || defined(HAVE_UBUNTU_APPINDICATOR)
+static void
+on_menu_item_activate (GtkMenuItem *menu_item,
+                       gpointer     user_data)
+{
+  revoke_tmp_authz ();
+}
+#else
+static void
+on_status_icon_activate (GtkStatusIcon *status_icon,
+                         gpointer       user_data)
+{
+  revoke_tmp_authz ();
+}
+
+static void
+on_status_icon_popup_menu (GtkStatusIcon *status_icon,
+                           guint          button,
+                           guint          activate_time,
+                           gpointer       user_data)
+{
+  revoke_tmp_authz ();
+}
+#endif
+
+static void
+update_temporary_authorization_icon_real (void)
+{
+
+#if 0
+  GList *l;
+  g_debug ("have %d tmp authorizations", g_list_length (current_temporary_authorizations));
+  for (l = current_temporary_authorizations; l != NULL; l = l->next)
+    {
+      PolkitTemporaryAuthorization *authz = POLKIT_TEMPORARY_AUTHORIZATION (l->data);
+
+      g_debug ("have tmp authz for action %s (subject %s) with id %s (obtained %d, expires %d)",
+               polkit_temporary_authorization_get_action_id (authz),
+               polkit_subject_to_string (polkit_temporary_authorization_get_subject (authz)),
+               polkit_temporary_authorization_get_id (authz),
+               (gint) polkit_temporary_authorization_get_time_obtained (authz),
+               (gint) polkit_temporary_authorization_get_time_expires (authz));
+    }
+#endif
+
+  /* TODO:
+   *
+   * - we could do something fancy like displaying a window with the tmp authz
+   *   when the icon is clicked...
+   *
+   * - we could do some work using polkit_subject_exists() to ignore tmp authz
+   *   for subjects that no longer exists.. this is because temporary authorizations
+   *   are only valid for the subject that trigger the authentication dialog.
+   *
+   *   Maybe the authority could do this, would probably involve some polling, but
+   *   it seems cleaner to do this server side.
+   */
+
+  if (current_temporary_authorizations != NULL)
+    {
+      /* show icon */
+#if defined(HAVE_AYATANA_APPINDICATOR) || defined(HAVE_UBUNTU_APPINDICATOR)
+      if (app_indicator == NULL)
+        {
+          GtkWidget *item, *menu;
+
+          app_indicator = app_indicator_new ("mate-polkit",
+                                             "dialog-password",
+                                             APP_INDICATOR_CATEGORY_SYSTEM_SERVICES);
+
+          item = gtk_menu_item_new_with_label (_("Drop all elevated privileges"));
+          g_signal_connect (item,
+                            "activate",
+                            G_CALLBACK (on_menu_item_activate),
+                            NULL);
+          menu = gtk_menu_new ();
+          gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+          gtk_widget_show_all (menu);
+
+          app_indicator_set_menu (app_indicator,
+                                  GTK_MENU (menu));
+          app_indicator_set_status (app_indicator,
+                                    APP_INDICATOR_STATUS_ACTIVE);
+        }
+      else
+        /*Reshow icon from existing appindicator */
+        app_indicator_set_status (app_indicator,
+				    APP_INDICATOR_STATUS_ACTIVE);
+
+#else
+      if (status_icon == NULL)
+        {
+          status_icon = gtk_status_icon_new_from_icon_name ("dialog-password");
+          gtk_status_icon_set_tooltip_text (status_icon,
+                                            _("Click the icon to drop all elevated privileges"));
+          g_signal_connect (status_icon,
+                            "activate",
+                            G_CALLBACK (on_status_icon_activate),
+                            NULL);
+          g_signal_connect (status_icon,
+                            "popup-menu",
+                            G_CALLBACK (on_status_icon_popup_menu),
+                            NULL);
+        }
+#endif
+    }
+  else
+    {
+      /* hide icon */
+#if defined(HAVE_AYATANA_APPINDICATOR) || defined(HAVE_UBUNTU_APPINDICATOR)
+      if (app_indicator != NULL)
+        {
+          /* keep the app_indicator, hide the icon or it won't come back*/
+          app_indicator_set_status (app_indicator,
+				    APP_INDICATOR_STATUS_PASSIVE);
+        }
+#else
+      if (status_icon != NULL)
+        {
+          gtk_status_icon_set_visible (status_icon, FALSE);
+          g_object_unref (status_icon);
+          status_icon = NULL;
+        }
+#endif
+    }
+}
+
+static void
+enumerate_temporary_authorizations_cb (GObject      *source_object,
+                                       GAsyncResult *res,
+                                       gpointer      user_data)
+{
+  PolkitAuthority *authority = POLKIT_AUTHORITY (source_object);<--- Shadow variable
+  GList *temporary_authorizations;
+  GError *error;
+
+  temporary_authorizations = NULL;
+
+  error = NULL;
+  temporary_authorizations = polkit_authority_enumerate_temporary_authorizations_finish (authority,
+                                                                                         res,
+                                                                                         &error);
+  if (error != NULL)
+    {
+      g_warning ("Error enumerating temporary authorizations: %s", error->message);
+      g_error_free (error);
+      goto out;
+    }
+
+  g_list_foreach (current_temporary_authorizations, (GFunc) g_object_unref, NULL);
+  g_list_free (current_temporary_authorizations);
+
+  current_temporary_authorizations = temporary_authorizations;
+
+  update_temporary_authorization_icon_real ();
+
+ out:
+  ;
+}
+
+static void
+update_temporary_authorization_icon (PolkitAuthority *authority)
+{
+  polkit_authority_enumerate_temporary_authorizations (authority,
+                                                       session,
+                                                       NULL,
+                                                       enumerate_temporary_authorizations_cb,
+                                                       NULL);
+}
+
+static void
+on_authority_changed (PolkitAuthority *authority,
+                      gpointer         user_data)
+{
+  update_temporary_authorization_icon (authority);
+}
+
+static void
+stop_cb (void)
+{
+        g_main_loop_quit (loop);
+}
+
+static gboolean
+end_session_response (gboolean is_okay, const gchar *reason)
+{
+        GVariant *res;
+        GError *error = NULL;
+
+        res = g_dbus_proxy_call_sync (client_proxy,
+                                      "EndSessionResponse",
+                                      g_variant_new ("(bs)",
+                                                     is_okay,
+                                                     reason),
+                                      G_DBUS_CALL_FLAGS_NONE,
+                                      -1, /* timeout */
+                                      NULL, /* GCancellable */
+                                      &error);
+        if (! res) {
+                g_warning ("Failed to call EndSessionResponse: %s", error->message);
+                g_error_free (error);
+                return FALSE;
+        }
+
+        g_variant_unref (res);
+        return TRUE;
+}
+
+static void
+query_end_session_cb (void)
+{
+        end_session_response (TRUE, "");
+}
+
+static void
+end_session_cb (void)
+{
+        end_session_response (TRUE, "");
+        g_main_loop_quit (loop);
+}
+
+static void
+signal_cb (GDBusProxy *proxy, gchar *sender_name, gchar *signal_name,
+           GVariant *parameters, gpointer user_data)
+{
+        if (strcmp (signal_name, "Stop") == 0) {
+                stop_cb ();
+        } else if (strcmp (signal_name, "QueryEndSession") == 0) {
+                query_end_session_cb ();
+        } else if (strcmp (signal_name, "EndSession") == 0) {
+                end_session_cb ();
+        }
+}
+
+static gboolean
+register_client_to_gnome_session (void)
+{
+        GError     *error = NULL;
+        GVariant   *res;
+        const char *startup_id;
+        const char *app_id;
+        char       *client_id;
+
+        startup_id = g_getenv ("DESKTOP_AUTOSTART_ID");
+        app_id = "polkit-mate-authentication-agent-1.desktop";
+
+        sm_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
+                                                  G_DBUS_PROXY_FLAGS_NONE,
+                                                  NULL, /* GDBusInterfaceInfo */
+                                                  SM_DBUS_NAME,
+                                                  SM_DBUS_PATH,
+                                                  SM_DBUS_INTERFACE,
+                                                  NULL, /* GCancellable */
+                                                  &error);
+        if (sm_proxy == NULL) {
+                g_message("Failed to get session manager: %s", error->message);
+                g_error_free (error);
+                return FALSE;
+        }
+
+        res = g_dbus_proxy_call_sync (sm_proxy,
+                                      "RegisterClient",
+                                      g_variant_new ("(ss)",
+                                                     app_id,
+                                                     startup_id),
+                                      G_DBUS_CALL_FLAGS_NONE,
+                                      -1, /* timeout */
+                                      NULL, /* GCancellable */
+                                      &error);
+        if (! res) {
+                g_warning ("Failed to register client: %s", error->message);
+                g_error_free (error);
+                return FALSE;
+        }
+
+        if (! g_variant_is_of_type (res, G_VARIANT_TYPE ("(o)"))) {
+                g_warning ("RegisterClient returned unexpected type %s",
+                           g_variant_get_type_string (res));
+                return FALSE;
+        }
+
+        g_variant_get (res, "(&o)", &client_id);
+
+        client_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
+                                                      G_DBUS_PROXY_FLAGS_NONE,
+                                                      NULL, /* GDBusInterfaceInfo */
+                                                      SM_DBUS_NAME,
+                                                      client_id,
+                                                      SM_CLIENT_DBUS_INTERFACE,
+                                                      NULL, /* GCancellable */
+                                                      &error);
+        g_variant_unref (res);
+        if (client_proxy == NULL) {
+                g_message("Failed to get client proxy: %s", error->message);
+                g_error_free (error);
+                return FALSE;
+        }
+
+        g_signal_connect (client_proxy, "g-signal", G_CALLBACK (signal_cb), NULL);
+
+        return TRUE;
+}
+
+int
+main (int argc, char **argv)
+{
+  gint ret;
+  PolkitAgentListener *listener;
+  GError *error;
+
+  gtk_init (&argc, &argv);
+
+  loop = NULL;
+  authority = NULL;
+  listener = NULL;
+  session = NULL;
+  ret = 1;
+
+  bindtextdomain (GETTEXT_PACKAGE, MATELOCALEDIR);
+#if HAVE_BIND_TEXTDOMAIN_CODESET
+  bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+#endif
+  textdomain (GETTEXT_PACKAGE);
+
+  loop = g_main_loop_new (NULL, FALSE);
+
+  error = NULL;
+  authority = polkit_authority_get_sync (NULL /* GCancellable* */, &error);
+  if (authority == NULL)
+    {
+      g_warning ("Error getting authority: %s", error->message);
+      g_error_free (error);
+      goto out;
+    }
+  g_signal_connect (authority,
+                    "changed",
+                    G_CALLBACK (on_authority_changed),
+                    NULL);
+
+  listener = polkit_mate_listener_new ();
+
+  error = NULL;
+  session = polkit_unix_session_new_for_process_sync (getpid (), NULL, &error);
+  if (error != NULL)
+    {
+      g_warning ("Unable to determine the session we are in: %s", error->message);
+      g_error_free (error);
+      goto out;
+    }
+
+  error = NULL;
+  if (!polkit_agent_listener_register (listener,
+				       POLKIT_AGENT_REGISTER_FLAGS_NONE,
+                                       session,
+                                       "/org/mate/PolicyKit1/AuthenticationAgent",
+				       NULL,
+                                       &error))
+    {
+      g_printerr ("Cannot register authentication agent: %s\n", error->message);
+      g_error_free (error);
+      goto out;
+    }
+
+  update_temporary_authorization_icon (authority);
+
+  register_client_to_gnome_session();
+
+  g_main_loop_run (loop);
+
+  ret = 0;
+
+ out:
+  if (authority != NULL)
+    g_object_unref (authority);
+  if (session != NULL)
+    g_object_unref (session);
+  if (listener != NULL)
+    g_object_unref (listener);
+  if (loop != NULL)
+    g_main_loop_unref (loop);
+
+  return ret;
+}
+
+ +
+ +
+ + diff --git a/2023-08-30-131815-8382-cppcheck@5851bb1e1c2c_master/index.html b/2023-08-30-131815-8382-cppcheck@5851bb1e1c2c_master/index.html new file mode 100644 index 0000000..e6e1402 --- /dev/null +++ b/2023-08-30-131815-8382-cppcheck@5851bb1e1c2c_master/index.html @@ -0,0 +1,197 @@ + + + + + + Cppcheck - HTML report - mate-polkit + + + + + +
+ + + +
+ + + + + + + + + + +
LineIdCWESeverityMessage
missingIncludeinformationCppcheck cannot find all the include files (use --check-config for details)
src/main.c
226shadowVariable398styleLocal variable 'authority' shadows outer variable
+
+ +
+ + diff --git a/2023-08-30-131815-8382-cppcheck@5851bb1e1c2c_master/stats.html b/2023-08-30-131815-8382-cppcheck@5851bb1e1c2c_master/stats.html new file mode 100644 index 0000000..8f9eaf7 --- /dev/null +++ b/2023-08-30-131815-8382-cppcheck@5851bb1e1c2c_master/stats.html @@ -0,0 +1,167 @@ + + + + + + Cppcheck - HTML report - mate-polkit + + + + + +
+ + + +
+

Top 10 files for style severity, total findings: 1
+   1  src/main.c
+

+ +
+ +
+ + diff --git a/2023-08-30-131815-8382-cppcheck@5851bb1e1c2c_master/style.css b/2023-08-30-131815-8382-cppcheck@5851bb1e1c2c_master/style.css new file mode 100644 index 0000000..3897bfa --- /dev/null +++ b/2023-08-30-131815-8382-cppcheck@5851bb1e1c2c_master/style.css @@ -0,0 +1,177 @@ + +body { + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif; + font-size: 13px; + line-height: 1.5; + height: 100%; + margin: 0; +} + +#wrapper { + position: fixed; + height: 100vh; + width: 100vw; + display: grid; + grid-template-rows: fit-content(8rem) auto fit-content(8rem); + grid-template-columns: fit-content(25%) 1fr; + grid-template-areas: + "header header" + "menu content" + "footer footer"; +} + +h1 { + margin: 0 0 8px -2px; + font-size: 175%; +} + +.header { + padding: 0 0 5px 15px; + grid-area: header; + border-bottom: thin solid #aaa; +} + +.footer { + grid-area: footer; + border-top: thin solid #aaa; + font-size: 85%; + +} + +.footer > p { + margin: 4px; +} + +#menu, +#menu_index { + grid-area: menu; + text-align: left; + overflow: auto; + padding: 0 23px 15px 15px; + border-right: thin solid #aaa; + min-width: 200px; +} + +#menu > a { + display: block; + margin-left: 10px; + font-size: 12px; +} + +#content, +#content_index { + grid-area: content; + padding: 0px 5px 15px 15px; + overflow: auto; +} + +label { + white-space: nowrap; +} + +label.checkBtn.disabled { + color: #606060; + background: #e0e0e0; + font-style: italic; +} + +label.checkBtn, input[type="text"] { + border: 1px solid grey; + border-radius: 4px; + box-shadow: 1px 1px inset; + padding: 1px 5px; +} + +label.checkBtn { + white-space: nowrap; + background: #ccddff; +} + +label.unchecked { + background: #eff8ff; + box-shadow: 1px 1px 1px; +} + +label.checkBtn:hover, label.unchecked:hover{ + box-shadow: 0 0 2px; +} + +label.disabled:hover { + box-shadow: 1px 1px inset; +} + +label.checkBtn > input { + display:none; +} + +.summaryTable { + width: 100%; +} + +table.summaryTable td { padding: 0 5px 0 5px; } + +.statHeader, .severityHeader { + font-weight: bold; +} + +.warning { + background-color: #ffffa7; +} + +.error { + background-color: #ffb7b7; +} + +.error2 { + background-color: #faa; + display: inline-block; + margin-left: 4px; +} + +.inconclusive { + background-color: #b6b6b4; +} + +.inconclusive2 { + background-color: #b6b6b4; + display: inline-block; + margin-left: 4px; +} + +.verbose { + display: inline-block; + vertical-align: top; + cursor: help; +} + +.verbose .content { + display: none; + position: absolute; + padding: 10px; + margin: 4px; + max-width: 40%; + white-space: pre-wrap; + border: 1px solid #000; + background-color: #ffffcc; + cursor: auto; +} + +.highlight .hll { + padding: 1px; +} + +.highlighttable { + background-color: #fff; + position: relative; + margin: -10px; +} + +.linenos { + border-right: thin solid #aaa; + color: #d3d3d3; + padding-right: 6px; +} + +.id-filtered, .severity-filtered, .file-filtered, .tool-filtered, .text-filtered { + visibility: collapse; +} diff --git a/2023-08-30-131932-1666-cppcheck@5851bb1e1c2c_v1.27.1/0.html b/2023-08-30-131932-1666-cppcheck@5851bb1e1c2c_v1.27.1/0.html new file mode 100644 index 0000000..b179177 --- /dev/null +++ b/2023-08-30-131932-1666-cppcheck@5851bb1e1c2c_v1.27.1/0.html @@ -0,0 +1,1189 @@ + + + + + + Cppcheck - HTML report - mate-polkit + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
/*
+ * Copyright (C) 2009 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ * Author: David Zeuthen <davidz@redhat.com>
+ */
+
+#ifdef HAVE_CONFIG_H
+#  include "config.h"
+#endif
+
+#include <string.h>
+#include <gtk/gtk.h>
+#include <gio/gio.h>
+#include <glib/gi18n.h>
+#include <polkitagent/polkitagent.h>
+
+#if defined(HAVE_AYATANA_APPINDICATOR)
+# include <libayatana-appindicator/app-indicator.h>
+#elif defined(HAVE_UBUNTU_APPINDICATOR)
+# include <libappindicator/app-indicator.h>
+#endif
+
+#include "polkitmatelistener.h"
+
+/* session management support for auto-restart */
+#define SM_DBUS_NAME      "org.gnome.SessionManager"
+#define SM_DBUS_PATH      "/org/gnome/SessionManager"
+#define SM_DBUS_INTERFACE "org.gnome.SessionManager"
+#define SM_CLIENT_DBUS_INTERFACE "org.gnome.SessionManager.ClientPrivate"
+
+/* the Authority */
+static PolkitAuthority *authority = NULL;<--- Shadowed declaration
+
+/* the session we are servicing */
+static PolkitSubject *session = NULL;
+
+/* the current set of temporary authorizations */
+static GList *current_temporary_authorizations = NULL;
+
+#if defined(HAVE_AYATANA_APPINDICATOR) || defined(HAVE_UBUNTU_APPINDICATOR)
+static AppIndicator *app_indicator = NULL;
+#else
+static GtkStatusIcon *status_icon = NULL;
+#endif
+
+static GDBusProxy      *sm_proxy;
+static GDBusProxy      *client_proxy = NULL;
+
+static  GMainLoop *loop;
+
+static void
+revoke_tmp_authz_cb (GObject      *source_object,
+                     GAsyncResult *res,
+                     gpointer      user_data)
+{
+  GError *error;
+
+  error = NULL;
+  polkit_authority_revoke_temporary_authorizations_finish (POLKIT_AUTHORITY (source_object),
+                                                           res,
+                                                           &error);
+  if (error != NULL)
+    {
+      g_warning ("Error revoking temporary authorizations: %s", error->message);
+      g_error_free (error);
+    }
+}
+
+static void
+revoke_tmp_authz (void)
+{
+  polkit_authority_revoke_temporary_authorizations (authority,
+                                                    session,
+                                                    NULL,
+                                                    revoke_tmp_authz_cb,
+                                                    NULL);
+}
+
+#if defined(HAVE_AYATANA_APPINDICATOR) || defined(HAVE_UBUNTU_APPINDICATOR)
+static void
+on_menu_item_activate (GtkMenuItem *menu_item,
+                       gpointer     user_data)
+{
+  revoke_tmp_authz ();
+}
+#else
+static void
+on_status_icon_activate (GtkStatusIcon *status_icon,
+                         gpointer       user_data)
+{
+  revoke_tmp_authz ();
+}
+
+static void
+on_status_icon_popup_menu (GtkStatusIcon *status_icon,
+                           guint          button,
+                           guint          activate_time,
+                           gpointer       user_data)
+{
+  revoke_tmp_authz ();
+}
+#endif
+
+static void
+update_temporary_authorization_icon_real (void)
+{
+
+#if 0
+  GList *l;
+  g_debug ("have %d tmp authorizations", g_list_length (current_temporary_authorizations));
+  for (l = current_temporary_authorizations; l != NULL; l = l->next)
+    {
+      PolkitTemporaryAuthorization *authz = POLKIT_TEMPORARY_AUTHORIZATION (l->data);
+
+      g_debug ("have tmp authz for action %s (subject %s) with id %s (obtained %d, expires %d)",
+               polkit_temporary_authorization_get_action_id (authz),
+               polkit_subject_to_string (polkit_temporary_authorization_get_subject (authz)),
+               polkit_temporary_authorization_get_id (authz),
+               (gint) polkit_temporary_authorization_get_time_obtained (authz),
+               (gint) polkit_temporary_authorization_get_time_expires (authz));
+    }
+#endif
+
+  /* TODO:
+   *
+   * - we could do something fancy like displaying a window with the tmp authz
+   *   when the icon is clicked...
+   *
+   * - we could do some work using polkit_subject_exists() to ignore tmp authz
+   *   for subjects that no longer exists.. this is because temporary authorizations
+   *   are only valid for the subject that trigger the authentication dialog.
+   *
+   *   Maybe the authority could do this, would probably involve some polling, but
+   *   it seems cleaner to do this server side.
+   */
+
+  if (current_temporary_authorizations != NULL)
+    {
+      /* show icon */
+#if defined(HAVE_AYATANA_APPINDICATOR) || defined(HAVE_UBUNTU_APPINDICATOR)
+      if (app_indicator == NULL)
+        {
+          GtkWidget *item, *menu;
+
+          app_indicator = app_indicator_new ("mate-polkit",
+                                             "dialog-password",
+                                             APP_INDICATOR_CATEGORY_SYSTEM_SERVICES);
+
+          item = gtk_menu_item_new_with_label (_("Drop all elevated privileges"));
+          g_signal_connect (item,
+                            "activate",
+                            G_CALLBACK (on_menu_item_activate),
+                            NULL);
+          menu = gtk_menu_new ();
+          gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+          gtk_widget_show_all (menu);
+
+          app_indicator_set_menu (app_indicator,
+                                  GTK_MENU (menu));
+          app_indicator_set_status (app_indicator,
+                                    APP_INDICATOR_STATUS_ACTIVE);
+        }
+      else
+        /*Reshow icon from existing appindicator */
+        app_indicator_set_status (app_indicator,
+				    APP_INDICATOR_STATUS_ACTIVE);
+
+#else
+      if (status_icon == NULL)
+        {
+          status_icon = gtk_status_icon_new_from_icon_name ("dialog-password");
+          gtk_status_icon_set_tooltip_text (status_icon,
+                                            _("Click the icon to drop all elevated privileges"));
+          g_signal_connect (status_icon,
+                            "activate",
+                            G_CALLBACK (on_status_icon_activate),
+                            NULL);
+          g_signal_connect (status_icon,
+                            "popup-menu",
+                            G_CALLBACK (on_status_icon_popup_menu),
+                            NULL);
+        }
+#endif
+    }
+  else
+    {
+      /* hide icon */
+#if defined(HAVE_AYATANA_APPINDICATOR) || defined(HAVE_UBUNTU_APPINDICATOR)
+      if (app_indicator != NULL)
+        {
+          /* keep the app_indicator, hide the icon or it won't come back*/
+          app_indicator_set_status (app_indicator,
+				    APP_INDICATOR_STATUS_PASSIVE);
+        }
+#else
+      if (status_icon != NULL)
+        {
+          gtk_status_icon_set_visible (status_icon, FALSE);
+          g_object_unref (status_icon);
+          status_icon = NULL;
+        }
+#endif
+    }
+}
+
+static void
+enumerate_temporary_authorizations_cb (GObject      *source_object,
+                                       GAsyncResult *res,
+                                       gpointer      user_data)
+{
+  PolkitAuthority *authority = POLKIT_AUTHORITY (source_object);<--- Shadow variable
+  GList *temporary_authorizations;
+  GError *error;
+
+  temporary_authorizations = NULL;
+
+  error = NULL;
+  temporary_authorizations = polkit_authority_enumerate_temporary_authorizations_finish (authority,
+                                                                                         res,
+                                                                                         &error);
+  if (error != NULL)
+    {
+      g_warning ("Error enumerating temporary authorizations: %s", error->message);
+      g_error_free (error);
+      goto out;
+    }
+
+  g_list_foreach (current_temporary_authorizations, (GFunc) g_object_unref, NULL);
+  g_list_free (current_temporary_authorizations);
+
+  current_temporary_authorizations = temporary_authorizations;
+
+  update_temporary_authorization_icon_real ();
+
+ out:
+  ;
+}
+
+static void
+update_temporary_authorization_icon (PolkitAuthority *authority)
+{
+  polkit_authority_enumerate_temporary_authorizations (authority,
+                                                       session,
+                                                       NULL,
+                                                       enumerate_temporary_authorizations_cb,
+                                                       NULL);
+}
+
+static void
+on_authority_changed (PolkitAuthority *authority,
+                      gpointer         user_data)
+{
+  update_temporary_authorization_icon (authority);
+}
+
+static void
+stop_cb (void)
+{
+        g_main_loop_quit (loop);
+}
+
+static gboolean
+end_session_response (gboolean is_okay, const gchar *reason)
+{
+        GVariant *res;
+        GError *error = NULL;
+
+        res = g_dbus_proxy_call_sync (client_proxy,
+                                      "EndSessionResponse",
+                                      g_variant_new ("(bs)",
+                                                     is_okay,
+                                                     reason),
+                                      G_DBUS_CALL_FLAGS_NONE,
+                                      -1, /* timeout */
+                                      NULL, /* GCancellable */
+                                      &error);
+        if (! res) {
+                g_warning ("Failed to call EndSessionResponse: %s", error->message);
+                g_error_free (error);
+                return FALSE;
+        }
+
+        g_variant_unref (res);
+        return TRUE;
+}
+
+static void
+query_end_session_cb (void)
+{
+        end_session_response (TRUE, "");
+}
+
+static void
+end_session_cb (void)
+{
+        end_session_response (TRUE, "");
+        g_main_loop_quit (loop);
+}
+
+static void
+signal_cb (GDBusProxy *proxy, gchar *sender_name, gchar *signal_name,
+           GVariant *parameters, gpointer user_data)
+{
+        if (strcmp (signal_name, "Stop") == 0) {
+                stop_cb ();
+        } else if (strcmp (signal_name, "QueryEndSession") == 0) {
+                query_end_session_cb ();
+        } else if (strcmp (signal_name, "EndSession") == 0) {
+                end_session_cb ();
+        }
+}
+
+static gboolean
+register_client_to_gnome_session (void)
+{
+        GError     *error = NULL;
+        GVariant   *res;
+        const char *startup_id;
+        const char *app_id;
+        char       *client_id;
+
+        startup_id = g_getenv ("DESKTOP_AUTOSTART_ID");
+        app_id = "polkit-mate-authentication-agent-1.desktop";
+
+        sm_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
+                                                  G_DBUS_PROXY_FLAGS_NONE,
+                                                  NULL, /* GDBusInterfaceInfo */
+                                                  SM_DBUS_NAME,
+                                                  SM_DBUS_PATH,
+                                                  SM_DBUS_INTERFACE,
+                                                  NULL, /* GCancellable */
+                                                  &error);
+        if (sm_proxy == NULL) {
+                g_message("Failed to get session manager: %s", error->message);
+                g_error_free (error);
+                return FALSE;
+        }
+
+        res = g_dbus_proxy_call_sync (sm_proxy,
+                                      "RegisterClient",
+                                      g_variant_new ("(ss)",
+                                                     app_id,
+                                                     startup_id),
+                                      G_DBUS_CALL_FLAGS_NONE,
+                                      -1, /* timeout */
+                                      NULL, /* GCancellable */
+                                      &error);
+        if (! res) {
+                g_warning ("Failed to register client: %s", error->message);
+                g_error_free (error);
+                return FALSE;
+        }
+
+        if (! g_variant_is_of_type (res, G_VARIANT_TYPE ("(o)"))) {
+                g_warning ("RegisterClient returned unexpected type %s",
+                           g_variant_get_type_string (res));
+                return FALSE;
+        }
+
+        g_variant_get (res, "(&o)", &client_id);
+
+        client_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
+                                                      G_DBUS_PROXY_FLAGS_NONE,
+                                                      NULL, /* GDBusInterfaceInfo */
+                                                      SM_DBUS_NAME,
+                                                      client_id,
+                                                      SM_CLIENT_DBUS_INTERFACE,
+                                                      NULL, /* GCancellable */
+                                                      &error);
+        g_variant_unref (res);
+        if (client_proxy == NULL) {
+                g_message("Failed to get client proxy: %s", error->message);
+                g_error_free (error);
+                return FALSE;
+        }
+
+        g_signal_connect (client_proxy, "g-signal", G_CALLBACK (signal_cb), NULL);
+
+        return TRUE;
+}
+
+int
+main (int argc, char **argv)
+{
+  gint ret;
+  PolkitAgentListener *listener;
+  GError *error;
+
+  gtk_init (&argc, &argv);
+
+  loop = NULL;
+  authority = NULL;
+  listener = NULL;
+  session = NULL;
+  ret = 1;
+
+  bindtextdomain (GETTEXT_PACKAGE, MATELOCALEDIR);
+#if HAVE_BIND_TEXTDOMAIN_CODESET
+  bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+#endif
+  textdomain (GETTEXT_PACKAGE);
+
+  loop = g_main_loop_new (NULL, FALSE);
+
+  error = NULL;
+  authority = polkit_authority_get_sync (NULL /* GCancellable* */, &error);
+  if (authority == NULL)
+    {
+      g_warning ("Error getting authority: %s", error->message);
+      g_error_free (error);
+      goto out;
+    }
+  g_signal_connect (authority,
+                    "changed",
+                    G_CALLBACK (on_authority_changed),
+                    NULL);
+
+  listener = polkit_mate_listener_new ();
+
+  error = NULL;
+  session = polkit_unix_session_new_for_process_sync (getpid (), NULL, &error);
+  if (error != NULL)
+    {
+      g_warning ("Unable to determine the session we are in: %s", error->message);
+      g_error_free (error);
+      goto out;
+    }
+
+  error = NULL;
+  if (!polkit_agent_listener_register (listener,
+				       POLKIT_AGENT_REGISTER_FLAGS_NONE,
+                                       session,
+                                       "/org/mate/PolicyKit1/AuthenticationAgent",
+				       NULL,
+                                       &error))
+    {
+      g_printerr ("Cannot register authentication agent: %s\n", error->message);
+      g_error_free (error);
+      goto out;
+    }
+
+  update_temporary_authorization_icon (authority);
+
+  register_client_to_gnome_session();
+
+  g_main_loop_run (loop);
+
+  ret = 0;
+
+ out:
+  if (authority != NULL)
+    g_object_unref (authority);
+  if (session != NULL)
+    g_object_unref (session);
+  if (listener != NULL)
+    g_object_unref (listener);
+  if (loop != NULL)
+    g_main_loop_unref (loop);
+
+  return ret;
+}
+
+ +
+ +
+ + diff --git a/2023-08-30-131932-1666-cppcheck@5851bb1e1c2c_v1.27.1/index.html b/2023-08-30-131932-1666-cppcheck@5851bb1e1c2c_v1.27.1/index.html new file mode 100644 index 0000000..e6e1402 --- /dev/null +++ b/2023-08-30-131932-1666-cppcheck@5851bb1e1c2c_v1.27.1/index.html @@ -0,0 +1,197 @@ + + + + + + Cppcheck - HTML report - mate-polkit + + + + + +
+ + + +
+ + + + + + + + + + +
LineIdCWESeverityMessage
missingIncludeinformationCppcheck cannot find all the include files (use --check-config for details)
src/main.c
226shadowVariable398styleLocal variable 'authority' shadows outer variable
+
+ +
+ + diff --git a/2023-08-30-131932-1666-cppcheck@5851bb1e1c2c_v1.27.1/stats.html b/2023-08-30-131932-1666-cppcheck@5851bb1e1c2c_v1.27.1/stats.html new file mode 100644 index 0000000..8f9eaf7 --- /dev/null +++ b/2023-08-30-131932-1666-cppcheck@5851bb1e1c2c_v1.27.1/stats.html @@ -0,0 +1,167 @@ + + + + + + Cppcheck - HTML report - mate-polkit + + + + + +
+ + + +
+

Top 10 files for style severity, total findings: 1
+   1  src/main.c
+

+ +
+ +
+ + diff --git a/2023-08-30-131932-1666-cppcheck@5851bb1e1c2c_v1.27.1/style.css b/2023-08-30-131932-1666-cppcheck@5851bb1e1c2c_v1.27.1/style.css new file mode 100644 index 0000000..3897bfa --- /dev/null +++ b/2023-08-30-131932-1666-cppcheck@5851bb1e1c2c_v1.27.1/style.css @@ -0,0 +1,177 @@ + +body { + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif; + font-size: 13px; + line-height: 1.5; + height: 100%; + margin: 0; +} + +#wrapper { + position: fixed; + height: 100vh; + width: 100vw; + display: grid; + grid-template-rows: fit-content(8rem) auto fit-content(8rem); + grid-template-columns: fit-content(25%) 1fr; + grid-template-areas: + "header header" + "menu content" + "footer footer"; +} + +h1 { + margin: 0 0 8px -2px; + font-size: 175%; +} + +.header { + padding: 0 0 5px 15px; + grid-area: header; + border-bottom: thin solid #aaa; +} + +.footer { + grid-area: footer; + border-top: thin solid #aaa; + font-size: 85%; + +} + +.footer > p { + margin: 4px; +} + +#menu, +#menu_index { + grid-area: menu; + text-align: left; + overflow: auto; + padding: 0 23px 15px 15px; + border-right: thin solid #aaa; + min-width: 200px; +} + +#menu > a { + display: block; + margin-left: 10px; + font-size: 12px; +} + +#content, +#content_index { + grid-area: content; + padding: 0px 5px 15px 15px; + overflow: auto; +} + +label { + white-space: nowrap; +} + +label.checkBtn.disabled { + color: #606060; + background: #e0e0e0; + font-style: italic; +} + +label.checkBtn, input[type="text"] { + border: 1px solid grey; + border-radius: 4px; + box-shadow: 1px 1px inset; + padding: 1px 5px; +} + +label.checkBtn { + white-space: nowrap; + background: #ccddff; +} + +label.unchecked { + background: #eff8ff; + box-shadow: 1px 1px 1px; +} + +label.checkBtn:hover, label.unchecked:hover{ + box-shadow: 0 0 2px; +} + +label.disabled:hover { + box-shadow: 1px 1px inset; +} + +label.checkBtn > input { + display:none; +} + +.summaryTable { + width: 100%; +} + +table.summaryTable td { padding: 0 5px 0 5px; } + +.statHeader, .severityHeader { + font-weight: bold; +} + +.warning { + background-color: #ffffa7; +} + +.error { + background-color: #ffb7b7; +} + +.error2 { + background-color: #faa; + display: inline-block; + margin-left: 4px; +} + +.inconclusive { + background-color: #b6b6b4; +} + +.inconclusive2 { + background-color: #b6b6b4; + display: inline-block; + margin-left: 4px; +} + +.verbose { + display: inline-block; + vertical-align: top; + cursor: help; +} + +.verbose .content { + display: none; + position: absolute; + padding: 10px; + margin: 4px; + max-width: 40%; + white-space: pre-wrap; + border: 1px solid #000; + background-color: #ffffcc; + cursor: auto; +} + +.highlight .hll { + padding: 1px; +} + +.highlighttable { + background-color: #fff; + position: relative; + margin: -10px; +} + +.linenos { + border-right: thin solid #aaa; + color: #d3d3d3; + padding-right: 6px; +} + +.id-filtered, .severity-filtered, .file-filtered, .tool-filtered, .text-filtered { + visibility: collapse; +} diff --git a/2023-08-30-132313-6863-cppcheck@3799abd873ae_desktop-file/0.html b/2023-08-30-132313-6863-cppcheck@3799abd873ae_desktop-file/0.html new file mode 100644 index 0000000..b179177 --- /dev/null +++ b/2023-08-30-132313-6863-cppcheck@3799abd873ae_desktop-file/0.html @@ -0,0 +1,1189 @@ + + + + + + Cppcheck - HTML report - mate-polkit + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
/*
+ * Copyright (C) 2009 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ * Author: David Zeuthen <davidz@redhat.com>
+ */
+
+#ifdef HAVE_CONFIG_H
+#  include "config.h"
+#endif
+
+#include <string.h>
+#include <gtk/gtk.h>
+#include <gio/gio.h>
+#include <glib/gi18n.h>
+#include <polkitagent/polkitagent.h>
+
+#if defined(HAVE_AYATANA_APPINDICATOR)
+# include <libayatana-appindicator/app-indicator.h>
+#elif defined(HAVE_UBUNTU_APPINDICATOR)
+# include <libappindicator/app-indicator.h>
+#endif
+
+#include "polkitmatelistener.h"
+
+/* session management support for auto-restart */
+#define SM_DBUS_NAME      "org.gnome.SessionManager"
+#define SM_DBUS_PATH      "/org/gnome/SessionManager"
+#define SM_DBUS_INTERFACE "org.gnome.SessionManager"
+#define SM_CLIENT_DBUS_INTERFACE "org.gnome.SessionManager.ClientPrivate"
+
+/* the Authority */
+static PolkitAuthority *authority = NULL;<--- Shadowed declaration
+
+/* the session we are servicing */
+static PolkitSubject *session = NULL;
+
+/* the current set of temporary authorizations */
+static GList *current_temporary_authorizations = NULL;
+
+#if defined(HAVE_AYATANA_APPINDICATOR) || defined(HAVE_UBUNTU_APPINDICATOR)
+static AppIndicator *app_indicator = NULL;
+#else
+static GtkStatusIcon *status_icon = NULL;
+#endif
+
+static GDBusProxy      *sm_proxy;
+static GDBusProxy      *client_proxy = NULL;
+
+static  GMainLoop *loop;
+
+static void
+revoke_tmp_authz_cb (GObject      *source_object,
+                     GAsyncResult *res,
+                     gpointer      user_data)
+{
+  GError *error;
+
+  error = NULL;
+  polkit_authority_revoke_temporary_authorizations_finish (POLKIT_AUTHORITY (source_object),
+                                                           res,
+                                                           &error);
+  if (error != NULL)
+    {
+      g_warning ("Error revoking temporary authorizations: %s", error->message);
+      g_error_free (error);
+    }
+}
+
+static void
+revoke_tmp_authz (void)
+{
+  polkit_authority_revoke_temporary_authorizations (authority,
+                                                    session,
+                                                    NULL,
+                                                    revoke_tmp_authz_cb,
+                                                    NULL);
+}
+
+#if defined(HAVE_AYATANA_APPINDICATOR) || defined(HAVE_UBUNTU_APPINDICATOR)
+static void
+on_menu_item_activate (GtkMenuItem *menu_item,
+                       gpointer     user_data)
+{
+  revoke_tmp_authz ();
+}
+#else
+static void
+on_status_icon_activate (GtkStatusIcon *status_icon,
+                         gpointer       user_data)
+{
+  revoke_tmp_authz ();
+}
+
+static void
+on_status_icon_popup_menu (GtkStatusIcon *status_icon,
+                           guint          button,
+                           guint          activate_time,
+                           gpointer       user_data)
+{
+  revoke_tmp_authz ();
+}
+#endif
+
+static void
+update_temporary_authorization_icon_real (void)
+{
+
+#if 0
+  GList *l;
+  g_debug ("have %d tmp authorizations", g_list_length (current_temporary_authorizations));
+  for (l = current_temporary_authorizations; l != NULL; l = l->next)
+    {
+      PolkitTemporaryAuthorization *authz = POLKIT_TEMPORARY_AUTHORIZATION (l->data);
+
+      g_debug ("have tmp authz for action %s (subject %s) with id %s (obtained %d, expires %d)",
+               polkit_temporary_authorization_get_action_id (authz),
+               polkit_subject_to_string (polkit_temporary_authorization_get_subject (authz)),
+               polkit_temporary_authorization_get_id (authz),
+               (gint) polkit_temporary_authorization_get_time_obtained (authz),
+               (gint) polkit_temporary_authorization_get_time_expires (authz));
+    }
+#endif
+
+  /* TODO:
+   *
+   * - we could do something fancy like displaying a window with the tmp authz
+   *   when the icon is clicked...
+   *
+   * - we could do some work using polkit_subject_exists() to ignore tmp authz
+   *   for subjects that no longer exists.. this is because temporary authorizations
+   *   are only valid for the subject that trigger the authentication dialog.
+   *
+   *   Maybe the authority could do this, would probably involve some polling, but
+   *   it seems cleaner to do this server side.
+   */
+
+  if (current_temporary_authorizations != NULL)
+    {
+      /* show icon */
+#if defined(HAVE_AYATANA_APPINDICATOR) || defined(HAVE_UBUNTU_APPINDICATOR)
+      if (app_indicator == NULL)
+        {
+          GtkWidget *item, *menu;
+
+          app_indicator = app_indicator_new ("mate-polkit",
+                                             "dialog-password",
+                                             APP_INDICATOR_CATEGORY_SYSTEM_SERVICES);
+
+          item = gtk_menu_item_new_with_label (_("Drop all elevated privileges"));
+          g_signal_connect (item,
+                            "activate",
+                            G_CALLBACK (on_menu_item_activate),
+                            NULL);
+          menu = gtk_menu_new ();
+          gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+          gtk_widget_show_all (menu);
+
+          app_indicator_set_menu (app_indicator,
+                                  GTK_MENU (menu));
+          app_indicator_set_status (app_indicator,
+                                    APP_INDICATOR_STATUS_ACTIVE);
+        }
+      else
+        /*Reshow icon from existing appindicator */
+        app_indicator_set_status (app_indicator,
+				    APP_INDICATOR_STATUS_ACTIVE);
+
+#else
+      if (status_icon == NULL)
+        {
+          status_icon = gtk_status_icon_new_from_icon_name ("dialog-password");
+          gtk_status_icon_set_tooltip_text (status_icon,
+                                            _("Click the icon to drop all elevated privileges"));
+          g_signal_connect (status_icon,
+                            "activate",
+                            G_CALLBACK (on_status_icon_activate),
+                            NULL);
+          g_signal_connect (status_icon,
+                            "popup-menu",
+                            G_CALLBACK (on_status_icon_popup_menu),
+                            NULL);
+        }
+#endif
+    }
+  else
+    {
+      /* hide icon */
+#if defined(HAVE_AYATANA_APPINDICATOR) || defined(HAVE_UBUNTU_APPINDICATOR)
+      if (app_indicator != NULL)
+        {
+          /* keep the app_indicator, hide the icon or it won't come back*/
+          app_indicator_set_status (app_indicator,
+				    APP_INDICATOR_STATUS_PASSIVE);
+        }
+#else
+      if (status_icon != NULL)
+        {
+          gtk_status_icon_set_visible (status_icon, FALSE);
+          g_object_unref (status_icon);
+          status_icon = NULL;
+        }
+#endif
+    }
+}
+
+static void
+enumerate_temporary_authorizations_cb (GObject      *source_object,
+                                       GAsyncResult *res,
+                                       gpointer      user_data)
+{
+  PolkitAuthority *authority = POLKIT_AUTHORITY (source_object);<--- Shadow variable
+  GList *temporary_authorizations;
+  GError *error;
+
+  temporary_authorizations = NULL;
+
+  error = NULL;
+  temporary_authorizations = polkit_authority_enumerate_temporary_authorizations_finish (authority,
+                                                                                         res,
+                                                                                         &error);
+  if (error != NULL)
+    {
+      g_warning ("Error enumerating temporary authorizations: %s", error->message);
+      g_error_free (error);
+      goto out;
+    }
+
+  g_list_foreach (current_temporary_authorizations, (GFunc) g_object_unref, NULL);
+  g_list_free (current_temporary_authorizations);
+
+  current_temporary_authorizations = temporary_authorizations;
+
+  update_temporary_authorization_icon_real ();
+
+ out:
+  ;
+}
+
+static void
+update_temporary_authorization_icon (PolkitAuthority *authority)
+{
+  polkit_authority_enumerate_temporary_authorizations (authority,
+                                                       session,
+                                                       NULL,
+                                                       enumerate_temporary_authorizations_cb,
+                                                       NULL);
+}
+
+static void
+on_authority_changed (PolkitAuthority *authority,
+                      gpointer         user_data)
+{
+  update_temporary_authorization_icon (authority);
+}
+
+static void
+stop_cb (void)
+{
+        g_main_loop_quit (loop);
+}
+
+static gboolean
+end_session_response (gboolean is_okay, const gchar *reason)
+{
+        GVariant *res;
+        GError *error = NULL;
+
+        res = g_dbus_proxy_call_sync (client_proxy,
+                                      "EndSessionResponse",
+                                      g_variant_new ("(bs)",
+                                                     is_okay,
+                                                     reason),
+                                      G_DBUS_CALL_FLAGS_NONE,
+                                      -1, /* timeout */
+                                      NULL, /* GCancellable */
+                                      &error);
+        if (! res) {
+                g_warning ("Failed to call EndSessionResponse: %s", error->message);
+                g_error_free (error);
+                return FALSE;
+        }
+
+        g_variant_unref (res);
+        return TRUE;
+}
+
+static void
+query_end_session_cb (void)
+{
+        end_session_response (TRUE, "");
+}
+
+static void
+end_session_cb (void)
+{
+        end_session_response (TRUE, "");
+        g_main_loop_quit (loop);
+}
+
+static void
+signal_cb (GDBusProxy *proxy, gchar *sender_name, gchar *signal_name,
+           GVariant *parameters, gpointer user_data)
+{
+        if (strcmp (signal_name, "Stop") == 0) {
+                stop_cb ();
+        } else if (strcmp (signal_name, "QueryEndSession") == 0) {
+                query_end_session_cb ();
+        } else if (strcmp (signal_name, "EndSession") == 0) {
+                end_session_cb ();
+        }
+}
+
+static gboolean
+register_client_to_gnome_session (void)
+{
+        GError     *error = NULL;
+        GVariant   *res;
+        const char *startup_id;
+        const char *app_id;
+        char       *client_id;
+
+        startup_id = g_getenv ("DESKTOP_AUTOSTART_ID");
+        app_id = "polkit-mate-authentication-agent-1.desktop";
+
+        sm_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
+                                                  G_DBUS_PROXY_FLAGS_NONE,
+                                                  NULL, /* GDBusInterfaceInfo */
+                                                  SM_DBUS_NAME,
+                                                  SM_DBUS_PATH,
+                                                  SM_DBUS_INTERFACE,
+                                                  NULL, /* GCancellable */
+                                                  &error);
+        if (sm_proxy == NULL) {
+                g_message("Failed to get session manager: %s", error->message);
+                g_error_free (error);
+                return FALSE;
+        }
+
+        res = g_dbus_proxy_call_sync (sm_proxy,
+                                      "RegisterClient",
+                                      g_variant_new ("(ss)",
+                                                     app_id,
+                                                     startup_id),
+                                      G_DBUS_CALL_FLAGS_NONE,
+                                      -1, /* timeout */
+                                      NULL, /* GCancellable */
+                                      &error);
+        if (! res) {
+                g_warning ("Failed to register client: %s", error->message);
+                g_error_free (error);
+                return FALSE;
+        }
+
+        if (! g_variant_is_of_type (res, G_VARIANT_TYPE ("(o)"))) {
+                g_warning ("RegisterClient returned unexpected type %s",
+                           g_variant_get_type_string (res));
+                return FALSE;
+        }
+
+        g_variant_get (res, "(&o)", &client_id);
+
+        client_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
+                                                      G_DBUS_PROXY_FLAGS_NONE,
+                                                      NULL, /* GDBusInterfaceInfo */
+                                                      SM_DBUS_NAME,
+                                                      client_id,
+                                                      SM_CLIENT_DBUS_INTERFACE,
+                                                      NULL, /* GCancellable */
+                                                      &error);
+        g_variant_unref (res);
+        if (client_proxy == NULL) {
+                g_message("Failed to get client proxy: %s", error->message);
+                g_error_free (error);
+                return FALSE;
+        }
+
+        g_signal_connect (client_proxy, "g-signal", G_CALLBACK (signal_cb), NULL);
+
+        return TRUE;
+}
+
+int
+main (int argc, char **argv)
+{
+  gint ret;
+  PolkitAgentListener *listener;
+  GError *error;
+
+  gtk_init (&argc, &argv);
+
+  loop = NULL;
+  authority = NULL;
+  listener = NULL;
+  session = NULL;
+  ret = 1;
+
+  bindtextdomain (GETTEXT_PACKAGE, MATELOCALEDIR);
+#if HAVE_BIND_TEXTDOMAIN_CODESET
+  bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+#endif
+  textdomain (GETTEXT_PACKAGE);
+
+  loop = g_main_loop_new (NULL, FALSE);
+
+  error = NULL;
+  authority = polkit_authority_get_sync (NULL /* GCancellable* */, &error);
+  if (authority == NULL)
+    {
+      g_warning ("Error getting authority: %s", error->message);
+      g_error_free (error);
+      goto out;
+    }
+  g_signal_connect (authority,
+                    "changed",
+                    G_CALLBACK (on_authority_changed),
+                    NULL);
+
+  listener = polkit_mate_listener_new ();
+
+  error = NULL;
+  session = polkit_unix_session_new_for_process_sync (getpid (), NULL, &error);
+  if (error != NULL)
+    {
+      g_warning ("Unable to determine the session we are in: %s", error->message);
+      g_error_free (error);
+      goto out;
+    }
+
+  error = NULL;
+  if (!polkit_agent_listener_register (listener,
+				       POLKIT_AGENT_REGISTER_FLAGS_NONE,
+                                       session,
+                                       "/org/mate/PolicyKit1/AuthenticationAgent",
+				       NULL,
+                                       &error))
+    {
+      g_printerr ("Cannot register authentication agent: %s\n", error->message);
+      g_error_free (error);
+      goto out;
+    }
+
+  update_temporary_authorization_icon (authority);
+
+  register_client_to_gnome_session();
+
+  g_main_loop_run (loop);
+
+  ret = 0;
+
+ out:
+  if (authority != NULL)
+    g_object_unref (authority);
+  if (session != NULL)
+    g_object_unref (session);
+  if (listener != NULL)
+    g_object_unref (listener);
+  if (loop != NULL)
+    g_main_loop_unref (loop);
+
+  return ret;
+}
+
+ +
+ +
+ + diff --git a/2023-08-30-132313-6863-cppcheck@3799abd873ae_desktop-file/index.html b/2023-08-30-132313-6863-cppcheck@3799abd873ae_desktop-file/index.html new file mode 100644 index 0000000..e6e1402 --- /dev/null +++ b/2023-08-30-132313-6863-cppcheck@3799abd873ae_desktop-file/index.html @@ -0,0 +1,197 @@ + + + + + + Cppcheck - HTML report - mate-polkit + + + + + +
+ + + +
+ + + + + + + + + + +
LineIdCWESeverityMessage
missingIncludeinformationCppcheck cannot find all the include files (use --check-config for details)
src/main.c
226shadowVariable398styleLocal variable 'authority' shadows outer variable
+
+ +
+ + diff --git a/2023-08-30-132313-6863-cppcheck@3799abd873ae_desktop-file/stats.html b/2023-08-30-132313-6863-cppcheck@3799abd873ae_desktop-file/stats.html new file mode 100644 index 0000000..8f9eaf7 --- /dev/null +++ b/2023-08-30-132313-6863-cppcheck@3799abd873ae_desktop-file/stats.html @@ -0,0 +1,167 @@ + + + + + + Cppcheck - HTML report - mate-polkit + + + + + +
+ + + +
+

Top 10 files for style severity, total findings: 1
+   1  src/main.c
+

+ +
+ +
+ + diff --git a/2023-08-30-132313-6863-cppcheck@3799abd873ae_desktop-file/style.css b/2023-08-30-132313-6863-cppcheck@3799abd873ae_desktop-file/style.css new file mode 100644 index 0000000..3897bfa --- /dev/null +++ b/2023-08-30-132313-6863-cppcheck@3799abd873ae_desktop-file/style.css @@ -0,0 +1,177 @@ + +body { + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif; + font-size: 13px; + line-height: 1.5; + height: 100%; + margin: 0; +} + +#wrapper { + position: fixed; + height: 100vh; + width: 100vw; + display: grid; + grid-template-rows: fit-content(8rem) auto fit-content(8rem); + grid-template-columns: fit-content(25%) 1fr; + grid-template-areas: + "header header" + "menu content" + "footer footer"; +} + +h1 { + margin: 0 0 8px -2px; + font-size: 175%; +} + +.header { + padding: 0 0 5px 15px; + grid-area: header; + border-bottom: thin solid #aaa; +} + +.footer { + grid-area: footer; + border-top: thin solid #aaa; + font-size: 85%; + +} + +.footer > p { + margin: 4px; +} + +#menu, +#menu_index { + grid-area: menu; + text-align: left; + overflow: auto; + padding: 0 23px 15px 15px; + border-right: thin solid #aaa; + min-width: 200px; +} + +#menu > a { + display: block; + margin-left: 10px; + font-size: 12px; +} + +#content, +#content_index { + grid-area: content; + padding: 0px 5px 15px 15px; + overflow: auto; +} + +label { + white-space: nowrap; +} + +label.checkBtn.disabled { + color: #606060; + background: #e0e0e0; + font-style: italic; +} + +label.checkBtn, input[type="text"] { + border: 1px solid grey; + border-radius: 4px; + box-shadow: 1px 1px inset; + padding: 1px 5px; +} + +label.checkBtn { + white-space: nowrap; + background: #ccddff; +} + +label.unchecked { + background: #eff8ff; + box-shadow: 1px 1px 1px; +} + +label.checkBtn:hover, label.unchecked:hover{ + box-shadow: 0 0 2px; +} + +label.disabled:hover { + box-shadow: 1px 1px inset; +} + +label.checkBtn > input { + display:none; +} + +.summaryTable { + width: 100%; +} + +table.summaryTable td { padding: 0 5px 0 5px; } + +.statHeader, .severityHeader { + font-weight: bold; +} + +.warning { + background-color: #ffffa7; +} + +.error { + background-color: #ffb7b7; +} + +.error2 { + background-color: #faa; + display: inline-block; + margin-left: 4px; +} + +.inconclusive { + background-color: #b6b6b4; +} + +.inconclusive2 { + background-color: #b6b6b4; + display: inline-block; + margin-left: 4px; +} + +.verbose { + display: inline-block; + vertical-align: top; + cursor: help; +} + +.verbose .content { + display: none; + position: absolute; + padding: 10px; + margin: 4px; + max-width: 40%; + white-space: pre-wrap; + border: 1px solid #000; + background-color: #ffffcc; + cursor: auto; +} + +.highlight .hll { + padding: 1px; +} + +.highlighttable { + background-color: #fff; + position: relative; + margin: -10px; +} + +.linenos { + border-right: thin solid #aaa; + color: #d3d3d3; + padding-right: 6px; +} + +.id-filtered, .severity-filtered, .file-filtered, .tool-filtered, .text-filtered { + visibility: collapse; +} diff --git a/2023-08-31-195451-3891-cppcheck@015207383e78_master/0.html b/2023-08-31-195451-3891-cppcheck@015207383e78_master/0.html new file mode 100644 index 0000000..b179177 --- /dev/null +++ b/2023-08-31-195451-3891-cppcheck@015207383e78_master/0.html @@ -0,0 +1,1189 @@ + + + + + + Cppcheck - HTML report - mate-polkit + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
/*
+ * Copyright (C) 2009 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ * Author: David Zeuthen <davidz@redhat.com>
+ */
+
+#ifdef HAVE_CONFIG_H
+#  include "config.h"
+#endif
+
+#include <string.h>
+#include <gtk/gtk.h>
+#include <gio/gio.h>
+#include <glib/gi18n.h>
+#include <polkitagent/polkitagent.h>
+
+#if defined(HAVE_AYATANA_APPINDICATOR)
+# include <libayatana-appindicator/app-indicator.h>
+#elif defined(HAVE_UBUNTU_APPINDICATOR)
+# include <libappindicator/app-indicator.h>
+#endif
+
+#include "polkitmatelistener.h"
+
+/* session management support for auto-restart */
+#define SM_DBUS_NAME      "org.gnome.SessionManager"
+#define SM_DBUS_PATH      "/org/gnome/SessionManager"
+#define SM_DBUS_INTERFACE "org.gnome.SessionManager"
+#define SM_CLIENT_DBUS_INTERFACE "org.gnome.SessionManager.ClientPrivate"
+
+/* the Authority */
+static PolkitAuthority *authority = NULL;<--- Shadowed declaration
+
+/* the session we are servicing */
+static PolkitSubject *session = NULL;
+
+/* the current set of temporary authorizations */
+static GList *current_temporary_authorizations = NULL;
+
+#if defined(HAVE_AYATANA_APPINDICATOR) || defined(HAVE_UBUNTU_APPINDICATOR)
+static AppIndicator *app_indicator = NULL;
+#else
+static GtkStatusIcon *status_icon = NULL;
+#endif
+
+static GDBusProxy      *sm_proxy;
+static GDBusProxy      *client_proxy = NULL;
+
+static  GMainLoop *loop;
+
+static void
+revoke_tmp_authz_cb (GObject      *source_object,
+                     GAsyncResult *res,
+                     gpointer      user_data)
+{
+  GError *error;
+
+  error = NULL;
+  polkit_authority_revoke_temporary_authorizations_finish (POLKIT_AUTHORITY (source_object),
+                                                           res,
+                                                           &error);
+  if (error != NULL)
+    {
+      g_warning ("Error revoking temporary authorizations: %s", error->message);
+      g_error_free (error);
+    }
+}
+
+static void
+revoke_tmp_authz (void)
+{
+  polkit_authority_revoke_temporary_authorizations (authority,
+                                                    session,
+                                                    NULL,
+                                                    revoke_tmp_authz_cb,
+                                                    NULL);
+}
+
+#if defined(HAVE_AYATANA_APPINDICATOR) || defined(HAVE_UBUNTU_APPINDICATOR)
+static void
+on_menu_item_activate (GtkMenuItem *menu_item,
+                       gpointer     user_data)
+{
+  revoke_tmp_authz ();
+}
+#else
+static void
+on_status_icon_activate (GtkStatusIcon *status_icon,
+                         gpointer       user_data)
+{
+  revoke_tmp_authz ();
+}
+
+static void
+on_status_icon_popup_menu (GtkStatusIcon *status_icon,
+                           guint          button,
+                           guint          activate_time,
+                           gpointer       user_data)
+{
+  revoke_tmp_authz ();
+}
+#endif
+
+static void
+update_temporary_authorization_icon_real (void)
+{
+
+#if 0
+  GList *l;
+  g_debug ("have %d tmp authorizations", g_list_length (current_temporary_authorizations));
+  for (l = current_temporary_authorizations; l != NULL; l = l->next)
+    {
+      PolkitTemporaryAuthorization *authz = POLKIT_TEMPORARY_AUTHORIZATION (l->data);
+
+      g_debug ("have tmp authz for action %s (subject %s) with id %s (obtained %d, expires %d)",
+               polkit_temporary_authorization_get_action_id (authz),
+               polkit_subject_to_string (polkit_temporary_authorization_get_subject (authz)),
+               polkit_temporary_authorization_get_id (authz),
+               (gint) polkit_temporary_authorization_get_time_obtained (authz),
+               (gint) polkit_temporary_authorization_get_time_expires (authz));
+    }
+#endif
+
+  /* TODO:
+   *
+   * - we could do something fancy like displaying a window with the tmp authz
+   *   when the icon is clicked...
+   *
+   * - we could do some work using polkit_subject_exists() to ignore tmp authz
+   *   for subjects that no longer exists.. this is because temporary authorizations
+   *   are only valid for the subject that trigger the authentication dialog.
+   *
+   *   Maybe the authority could do this, would probably involve some polling, but
+   *   it seems cleaner to do this server side.
+   */
+
+  if (current_temporary_authorizations != NULL)
+    {
+      /* show icon */
+#if defined(HAVE_AYATANA_APPINDICATOR) || defined(HAVE_UBUNTU_APPINDICATOR)
+      if (app_indicator == NULL)
+        {
+          GtkWidget *item, *menu;
+
+          app_indicator = app_indicator_new ("mate-polkit",
+                                             "dialog-password",
+                                             APP_INDICATOR_CATEGORY_SYSTEM_SERVICES);
+
+          item = gtk_menu_item_new_with_label (_("Drop all elevated privileges"));
+          g_signal_connect (item,
+                            "activate",
+                            G_CALLBACK (on_menu_item_activate),
+                            NULL);
+          menu = gtk_menu_new ();
+          gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+          gtk_widget_show_all (menu);
+
+          app_indicator_set_menu (app_indicator,
+                                  GTK_MENU (menu));
+          app_indicator_set_status (app_indicator,
+                                    APP_INDICATOR_STATUS_ACTIVE);
+        }
+      else
+        /*Reshow icon from existing appindicator */
+        app_indicator_set_status (app_indicator,
+				    APP_INDICATOR_STATUS_ACTIVE);
+
+#else
+      if (status_icon == NULL)
+        {
+          status_icon = gtk_status_icon_new_from_icon_name ("dialog-password");
+          gtk_status_icon_set_tooltip_text (status_icon,
+                                            _("Click the icon to drop all elevated privileges"));
+          g_signal_connect (status_icon,
+                            "activate",
+                            G_CALLBACK (on_status_icon_activate),
+                            NULL);
+          g_signal_connect (status_icon,
+                            "popup-menu",
+                            G_CALLBACK (on_status_icon_popup_menu),
+                            NULL);
+        }
+#endif
+    }
+  else
+    {
+      /* hide icon */
+#if defined(HAVE_AYATANA_APPINDICATOR) || defined(HAVE_UBUNTU_APPINDICATOR)
+      if (app_indicator != NULL)
+        {
+          /* keep the app_indicator, hide the icon or it won't come back*/
+          app_indicator_set_status (app_indicator,
+				    APP_INDICATOR_STATUS_PASSIVE);
+        }
+#else
+      if (status_icon != NULL)
+        {
+          gtk_status_icon_set_visible (status_icon, FALSE);
+          g_object_unref (status_icon);
+          status_icon = NULL;
+        }
+#endif
+    }
+}
+
+static void
+enumerate_temporary_authorizations_cb (GObject      *source_object,
+                                       GAsyncResult *res,
+                                       gpointer      user_data)
+{
+  PolkitAuthority *authority = POLKIT_AUTHORITY (source_object);<--- Shadow variable
+  GList *temporary_authorizations;
+  GError *error;
+
+  temporary_authorizations = NULL;
+
+  error = NULL;
+  temporary_authorizations = polkit_authority_enumerate_temporary_authorizations_finish (authority,
+                                                                                         res,
+                                                                                         &error);
+  if (error != NULL)
+    {
+      g_warning ("Error enumerating temporary authorizations: %s", error->message);
+      g_error_free (error);
+      goto out;
+    }
+
+  g_list_foreach (current_temporary_authorizations, (GFunc) g_object_unref, NULL);
+  g_list_free (current_temporary_authorizations);
+
+  current_temporary_authorizations = temporary_authorizations;
+
+  update_temporary_authorization_icon_real ();
+
+ out:
+  ;
+}
+
+static void
+update_temporary_authorization_icon (PolkitAuthority *authority)
+{
+  polkit_authority_enumerate_temporary_authorizations (authority,
+                                                       session,
+                                                       NULL,
+                                                       enumerate_temporary_authorizations_cb,
+                                                       NULL);
+}
+
+static void
+on_authority_changed (PolkitAuthority *authority,
+                      gpointer         user_data)
+{
+  update_temporary_authorization_icon (authority);
+}
+
+static void
+stop_cb (void)
+{
+        g_main_loop_quit (loop);
+}
+
+static gboolean
+end_session_response (gboolean is_okay, const gchar *reason)
+{
+        GVariant *res;
+        GError *error = NULL;
+
+        res = g_dbus_proxy_call_sync (client_proxy,
+                                      "EndSessionResponse",
+                                      g_variant_new ("(bs)",
+                                                     is_okay,
+                                                     reason),
+                                      G_DBUS_CALL_FLAGS_NONE,
+                                      -1, /* timeout */
+                                      NULL, /* GCancellable */
+                                      &error);
+        if (! res) {
+                g_warning ("Failed to call EndSessionResponse: %s", error->message);
+                g_error_free (error);
+                return FALSE;
+        }
+
+        g_variant_unref (res);
+        return TRUE;
+}
+
+static void
+query_end_session_cb (void)
+{
+        end_session_response (TRUE, "");
+}
+
+static void
+end_session_cb (void)
+{
+        end_session_response (TRUE, "");
+        g_main_loop_quit (loop);
+}
+
+static void
+signal_cb (GDBusProxy *proxy, gchar *sender_name, gchar *signal_name,
+           GVariant *parameters, gpointer user_data)
+{
+        if (strcmp (signal_name, "Stop") == 0) {
+                stop_cb ();
+        } else if (strcmp (signal_name, "QueryEndSession") == 0) {
+                query_end_session_cb ();
+        } else if (strcmp (signal_name, "EndSession") == 0) {
+                end_session_cb ();
+        }
+}
+
+static gboolean
+register_client_to_gnome_session (void)
+{
+        GError     *error = NULL;
+        GVariant   *res;
+        const char *startup_id;
+        const char *app_id;
+        char       *client_id;
+
+        startup_id = g_getenv ("DESKTOP_AUTOSTART_ID");
+        app_id = "polkit-mate-authentication-agent-1.desktop";
+
+        sm_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
+                                                  G_DBUS_PROXY_FLAGS_NONE,
+                                                  NULL, /* GDBusInterfaceInfo */
+                                                  SM_DBUS_NAME,
+                                                  SM_DBUS_PATH,
+                                                  SM_DBUS_INTERFACE,
+                                                  NULL, /* GCancellable */
+                                                  &error);
+        if (sm_proxy == NULL) {
+                g_message("Failed to get session manager: %s", error->message);
+                g_error_free (error);
+                return FALSE;
+        }
+
+        res = g_dbus_proxy_call_sync (sm_proxy,
+                                      "RegisterClient",
+                                      g_variant_new ("(ss)",
+                                                     app_id,
+                                                     startup_id),
+                                      G_DBUS_CALL_FLAGS_NONE,
+                                      -1, /* timeout */
+                                      NULL, /* GCancellable */
+                                      &error);
+        if (! res) {
+                g_warning ("Failed to register client: %s", error->message);
+                g_error_free (error);
+                return FALSE;
+        }
+
+        if (! g_variant_is_of_type (res, G_VARIANT_TYPE ("(o)"))) {
+                g_warning ("RegisterClient returned unexpected type %s",
+                           g_variant_get_type_string (res));
+                return FALSE;
+        }
+
+        g_variant_get (res, "(&o)", &client_id);
+
+        client_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
+                                                      G_DBUS_PROXY_FLAGS_NONE,
+                                                      NULL, /* GDBusInterfaceInfo */
+                                                      SM_DBUS_NAME,
+                                                      client_id,
+                                                      SM_CLIENT_DBUS_INTERFACE,
+                                                      NULL, /* GCancellable */
+                                                      &error);
+        g_variant_unref (res);
+        if (client_proxy == NULL) {
+                g_message("Failed to get client proxy: %s", error->message);
+                g_error_free (error);
+                return FALSE;
+        }
+
+        g_signal_connect (client_proxy, "g-signal", G_CALLBACK (signal_cb), NULL);
+
+        return TRUE;
+}
+
+int
+main (int argc, char **argv)
+{
+  gint ret;
+  PolkitAgentListener *listener;
+  GError *error;
+
+  gtk_init (&argc, &argv);
+
+  loop = NULL;
+  authority = NULL;
+  listener = NULL;
+  session = NULL;
+  ret = 1;
+
+  bindtextdomain (GETTEXT_PACKAGE, MATELOCALEDIR);
+#if HAVE_BIND_TEXTDOMAIN_CODESET
+  bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+#endif
+  textdomain (GETTEXT_PACKAGE);
+
+  loop = g_main_loop_new (NULL, FALSE);
+
+  error = NULL;
+  authority = polkit_authority_get_sync (NULL /* GCancellable* */, &error);
+  if (authority == NULL)
+    {
+      g_warning ("Error getting authority: %s", error->message);
+      g_error_free (error);
+      goto out;
+    }
+  g_signal_connect (authority,
+                    "changed",
+                    G_CALLBACK (on_authority_changed),
+                    NULL);
+
+  listener = polkit_mate_listener_new ();
+
+  error = NULL;
+  session = polkit_unix_session_new_for_process_sync (getpid (), NULL, &error);
+  if (error != NULL)
+    {
+      g_warning ("Unable to determine the session we are in: %s", error->message);
+      g_error_free (error);
+      goto out;
+    }
+
+  error = NULL;
+  if (!polkit_agent_listener_register (listener,
+				       POLKIT_AGENT_REGISTER_FLAGS_NONE,
+                                       session,
+                                       "/org/mate/PolicyKit1/AuthenticationAgent",
+				       NULL,
+                                       &error))
+    {
+      g_printerr ("Cannot register authentication agent: %s\n", error->message);
+      g_error_free (error);
+      goto out;
+    }
+
+  update_temporary_authorization_icon (authority);
+
+  register_client_to_gnome_session();
+
+  g_main_loop_run (loop);
+
+  ret = 0;
+
+ out:
+  if (authority != NULL)
+    g_object_unref (authority);
+  if (session != NULL)
+    g_object_unref (session);
+  if (listener != NULL)
+    g_object_unref (listener);
+  if (loop != NULL)
+    g_main_loop_unref (loop);
+
+  return ret;
+}
+
+ +
+ +
+ + diff --git a/2023-08-31-195451-3891-cppcheck@015207383e78_master/index.html b/2023-08-31-195451-3891-cppcheck@015207383e78_master/index.html new file mode 100644 index 0000000..e6e1402 --- /dev/null +++ b/2023-08-31-195451-3891-cppcheck@015207383e78_master/index.html @@ -0,0 +1,197 @@ + + + + + + Cppcheck - HTML report - mate-polkit + + + + + +
+ + + +
+ + + + + + + + + + +
LineIdCWESeverityMessage
missingIncludeinformationCppcheck cannot find all the include files (use --check-config for details)
src/main.c
226shadowVariable398styleLocal variable 'authority' shadows outer variable
+
+ +
+ + diff --git a/2023-08-31-195451-3891-cppcheck@015207383e78_master/stats.html b/2023-08-31-195451-3891-cppcheck@015207383e78_master/stats.html new file mode 100644 index 0000000..8f9eaf7 --- /dev/null +++ b/2023-08-31-195451-3891-cppcheck@015207383e78_master/stats.html @@ -0,0 +1,167 @@ + + + + + + Cppcheck - HTML report - mate-polkit + + + + + +
+ + + +
+

Top 10 files for style severity, total findings: 1
+   1  src/main.c
+

+ +
+ +
+ + diff --git a/2023-08-31-195451-3891-cppcheck@015207383e78_master/style.css b/2023-08-31-195451-3891-cppcheck@015207383e78_master/style.css new file mode 100644 index 0000000..3897bfa --- /dev/null +++ b/2023-08-31-195451-3891-cppcheck@015207383e78_master/style.css @@ -0,0 +1,177 @@ + +body { + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif; + font-size: 13px; + line-height: 1.5; + height: 100%; + margin: 0; +} + +#wrapper { + position: fixed; + height: 100vh; + width: 100vw; + display: grid; + grid-template-rows: fit-content(8rem) auto fit-content(8rem); + grid-template-columns: fit-content(25%) 1fr; + grid-template-areas: + "header header" + "menu content" + "footer footer"; +} + +h1 { + margin: 0 0 8px -2px; + font-size: 175%; +} + +.header { + padding: 0 0 5px 15px; + grid-area: header; + border-bottom: thin solid #aaa; +} + +.footer { + grid-area: footer; + border-top: thin solid #aaa; + font-size: 85%; + +} + +.footer > p { + margin: 4px; +} + +#menu, +#menu_index { + grid-area: menu; + text-align: left; + overflow: auto; + padding: 0 23px 15px 15px; + border-right: thin solid #aaa; + min-width: 200px; +} + +#menu > a { + display: block; + margin-left: 10px; + font-size: 12px; +} + +#content, +#content_index { + grid-area: content; + padding: 0px 5px 15px 15px; + overflow: auto; +} + +label { + white-space: nowrap; +} + +label.checkBtn.disabled { + color: #606060; + background: #e0e0e0; + font-style: italic; +} + +label.checkBtn, input[type="text"] { + border: 1px solid grey; + border-radius: 4px; + box-shadow: 1px 1px inset; + padding: 1px 5px; +} + +label.checkBtn { + white-space: nowrap; + background: #ccddff; +} + +label.unchecked { + background: #eff8ff; + box-shadow: 1px 1px 1px; +} + +label.checkBtn:hover, label.unchecked:hover{ + box-shadow: 0 0 2px; +} + +label.disabled:hover { + box-shadow: 1px 1px inset; +} + +label.checkBtn > input { + display:none; +} + +.summaryTable { + width: 100%; +} + +table.summaryTable td { padding: 0 5px 0 5px; } + +.statHeader, .severityHeader { + font-weight: bold; +} + +.warning { + background-color: #ffffa7; +} + +.error { + background-color: #ffb7b7; +} + +.error2 { + background-color: #faa; + display: inline-block; + margin-left: 4px; +} + +.inconclusive { + background-color: #b6b6b4; +} + +.inconclusive2 { + background-color: #b6b6b4; + display: inline-block; + margin-left: 4px; +} + +.verbose { + display: inline-block; + vertical-align: top; + cursor: help; +} + +.verbose .content { + display: none; + position: absolute; + padding: 10px; + margin: 4px; + max-width: 40%; + white-space: pre-wrap; + border: 1px solid #000; + background-color: #ffffcc; + cursor: auto; +} + +.highlight .hll { + padding: 1px; +} + +.highlighttable { + background-color: #fff; + position: relative; + margin: -10px; +} + +.linenos { + border-right: thin solid #aaa; + color: #d3d3d3; + padding-right: 6px; +} + +.id-filtered, .severity-filtered, .file-filtered, .tool-filtered, .text-filtered { + visibility: collapse; +} diff --git a/2023-09-02-184611-1622-cppcheck@4b078a16e961_master/0.html b/2023-09-02-184611-1622-cppcheck@4b078a16e961_master/0.html new file mode 100644 index 0000000..b179177 --- /dev/null +++ b/2023-09-02-184611-1622-cppcheck@4b078a16e961_master/0.html @@ -0,0 +1,1189 @@ + + + + + + Cppcheck - HTML report - mate-polkit + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
/*
+ * Copyright (C) 2009 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ * Author: David Zeuthen <davidz@redhat.com>
+ */
+
+#ifdef HAVE_CONFIG_H
+#  include "config.h"
+#endif
+
+#include <string.h>
+#include <gtk/gtk.h>
+#include <gio/gio.h>
+#include <glib/gi18n.h>
+#include <polkitagent/polkitagent.h>
+
+#if defined(HAVE_AYATANA_APPINDICATOR)
+# include <libayatana-appindicator/app-indicator.h>
+#elif defined(HAVE_UBUNTU_APPINDICATOR)
+# include <libappindicator/app-indicator.h>
+#endif
+
+#include "polkitmatelistener.h"
+
+/* session management support for auto-restart */
+#define SM_DBUS_NAME      "org.gnome.SessionManager"
+#define SM_DBUS_PATH      "/org/gnome/SessionManager"
+#define SM_DBUS_INTERFACE "org.gnome.SessionManager"
+#define SM_CLIENT_DBUS_INTERFACE "org.gnome.SessionManager.ClientPrivate"
+
+/* the Authority */
+static PolkitAuthority *authority = NULL;<--- Shadowed declaration
+
+/* the session we are servicing */
+static PolkitSubject *session = NULL;
+
+/* the current set of temporary authorizations */
+static GList *current_temporary_authorizations = NULL;
+
+#if defined(HAVE_AYATANA_APPINDICATOR) || defined(HAVE_UBUNTU_APPINDICATOR)
+static AppIndicator *app_indicator = NULL;
+#else
+static GtkStatusIcon *status_icon = NULL;
+#endif
+
+static GDBusProxy      *sm_proxy;
+static GDBusProxy      *client_proxy = NULL;
+
+static  GMainLoop *loop;
+
+static void
+revoke_tmp_authz_cb (GObject      *source_object,
+                     GAsyncResult *res,
+                     gpointer      user_data)
+{
+  GError *error;
+
+  error = NULL;
+  polkit_authority_revoke_temporary_authorizations_finish (POLKIT_AUTHORITY (source_object),
+                                                           res,
+                                                           &error);
+  if (error != NULL)
+    {
+      g_warning ("Error revoking temporary authorizations: %s", error->message);
+      g_error_free (error);
+    }
+}
+
+static void
+revoke_tmp_authz (void)
+{
+  polkit_authority_revoke_temporary_authorizations (authority,
+                                                    session,
+                                                    NULL,
+                                                    revoke_tmp_authz_cb,
+                                                    NULL);
+}
+
+#if defined(HAVE_AYATANA_APPINDICATOR) || defined(HAVE_UBUNTU_APPINDICATOR)
+static void
+on_menu_item_activate (GtkMenuItem *menu_item,
+                       gpointer     user_data)
+{
+  revoke_tmp_authz ();
+}
+#else
+static void
+on_status_icon_activate (GtkStatusIcon *status_icon,
+                         gpointer       user_data)
+{
+  revoke_tmp_authz ();
+}
+
+static void
+on_status_icon_popup_menu (GtkStatusIcon *status_icon,
+                           guint          button,
+                           guint          activate_time,
+                           gpointer       user_data)
+{
+  revoke_tmp_authz ();
+}
+#endif
+
+static void
+update_temporary_authorization_icon_real (void)
+{
+
+#if 0
+  GList *l;
+  g_debug ("have %d tmp authorizations", g_list_length (current_temporary_authorizations));
+  for (l = current_temporary_authorizations; l != NULL; l = l->next)
+    {
+      PolkitTemporaryAuthorization *authz = POLKIT_TEMPORARY_AUTHORIZATION (l->data);
+
+      g_debug ("have tmp authz for action %s (subject %s) with id %s (obtained %d, expires %d)",
+               polkit_temporary_authorization_get_action_id (authz),
+               polkit_subject_to_string (polkit_temporary_authorization_get_subject (authz)),
+               polkit_temporary_authorization_get_id (authz),
+               (gint) polkit_temporary_authorization_get_time_obtained (authz),
+               (gint) polkit_temporary_authorization_get_time_expires (authz));
+    }
+#endif
+
+  /* TODO:
+   *
+   * - we could do something fancy like displaying a window with the tmp authz
+   *   when the icon is clicked...
+   *
+   * - we could do some work using polkit_subject_exists() to ignore tmp authz
+   *   for subjects that no longer exists.. this is because temporary authorizations
+   *   are only valid for the subject that trigger the authentication dialog.
+   *
+   *   Maybe the authority could do this, would probably involve some polling, but
+   *   it seems cleaner to do this server side.
+   */
+
+  if (current_temporary_authorizations != NULL)
+    {
+      /* show icon */
+#if defined(HAVE_AYATANA_APPINDICATOR) || defined(HAVE_UBUNTU_APPINDICATOR)
+      if (app_indicator == NULL)
+        {
+          GtkWidget *item, *menu;
+
+          app_indicator = app_indicator_new ("mate-polkit",
+                                             "dialog-password",
+                                             APP_INDICATOR_CATEGORY_SYSTEM_SERVICES);
+
+          item = gtk_menu_item_new_with_label (_("Drop all elevated privileges"));
+          g_signal_connect (item,
+                            "activate",
+                            G_CALLBACK (on_menu_item_activate),
+                            NULL);
+          menu = gtk_menu_new ();
+          gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+          gtk_widget_show_all (menu);
+
+          app_indicator_set_menu (app_indicator,
+                                  GTK_MENU (menu));
+          app_indicator_set_status (app_indicator,
+                                    APP_INDICATOR_STATUS_ACTIVE);
+        }
+      else
+        /*Reshow icon from existing appindicator */
+        app_indicator_set_status (app_indicator,
+				    APP_INDICATOR_STATUS_ACTIVE);
+
+#else
+      if (status_icon == NULL)
+        {
+          status_icon = gtk_status_icon_new_from_icon_name ("dialog-password");
+          gtk_status_icon_set_tooltip_text (status_icon,
+                                            _("Click the icon to drop all elevated privileges"));
+          g_signal_connect (status_icon,
+                            "activate",
+                            G_CALLBACK (on_status_icon_activate),
+                            NULL);
+          g_signal_connect (status_icon,
+                            "popup-menu",
+                            G_CALLBACK (on_status_icon_popup_menu),
+                            NULL);
+        }
+#endif
+    }
+  else
+    {
+      /* hide icon */
+#if defined(HAVE_AYATANA_APPINDICATOR) || defined(HAVE_UBUNTU_APPINDICATOR)
+      if (app_indicator != NULL)
+        {
+          /* keep the app_indicator, hide the icon or it won't come back*/
+          app_indicator_set_status (app_indicator,
+				    APP_INDICATOR_STATUS_PASSIVE);
+        }
+#else
+      if (status_icon != NULL)
+        {
+          gtk_status_icon_set_visible (status_icon, FALSE);
+          g_object_unref (status_icon);
+          status_icon = NULL;
+        }
+#endif
+    }
+}
+
+static void
+enumerate_temporary_authorizations_cb (GObject      *source_object,
+                                       GAsyncResult *res,
+                                       gpointer      user_data)
+{
+  PolkitAuthority *authority = POLKIT_AUTHORITY (source_object);<--- Shadow variable
+  GList *temporary_authorizations;
+  GError *error;
+
+  temporary_authorizations = NULL;
+
+  error = NULL;
+  temporary_authorizations = polkit_authority_enumerate_temporary_authorizations_finish (authority,
+                                                                                         res,
+                                                                                         &error);
+  if (error != NULL)
+    {
+      g_warning ("Error enumerating temporary authorizations: %s", error->message);
+      g_error_free (error);
+      goto out;
+    }
+
+  g_list_foreach (current_temporary_authorizations, (GFunc) g_object_unref, NULL);
+  g_list_free (current_temporary_authorizations);
+
+  current_temporary_authorizations = temporary_authorizations;
+
+  update_temporary_authorization_icon_real ();
+
+ out:
+  ;
+}
+
+static void
+update_temporary_authorization_icon (PolkitAuthority *authority)
+{
+  polkit_authority_enumerate_temporary_authorizations (authority,
+                                                       session,
+                                                       NULL,
+                                                       enumerate_temporary_authorizations_cb,
+                                                       NULL);
+}
+
+static void
+on_authority_changed (PolkitAuthority *authority,
+                      gpointer         user_data)
+{
+  update_temporary_authorization_icon (authority);
+}
+
+static void
+stop_cb (void)
+{
+        g_main_loop_quit (loop);
+}
+
+static gboolean
+end_session_response (gboolean is_okay, const gchar *reason)
+{
+        GVariant *res;
+        GError *error = NULL;
+
+        res = g_dbus_proxy_call_sync (client_proxy,
+                                      "EndSessionResponse",
+                                      g_variant_new ("(bs)",
+                                                     is_okay,
+                                                     reason),
+                                      G_DBUS_CALL_FLAGS_NONE,
+                                      -1, /* timeout */
+                                      NULL, /* GCancellable */
+                                      &error);
+        if (! res) {
+                g_warning ("Failed to call EndSessionResponse: %s", error->message);
+                g_error_free (error);
+                return FALSE;
+        }
+
+        g_variant_unref (res);
+        return TRUE;
+}
+
+static void
+query_end_session_cb (void)
+{
+        end_session_response (TRUE, "");
+}
+
+static void
+end_session_cb (void)
+{
+        end_session_response (TRUE, "");
+        g_main_loop_quit (loop);
+}
+
+static void
+signal_cb (GDBusProxy *proxy, gchar *sender_name, gchar *signal_name,
+           GVariant *parameters, gpointer user_data)
+{
+        if (strcmp (signal_name, "Stop") == 0) {
+                stop_cb ();
+        } else if (strcmp (signal_name, "QueryEndSession") == 0) {
+                query_end_session_cb ();
+        } else if (strcmp (signal_name, "EndSession") == 0) {
+                end_session_cb ();
+        }
+}
+
+static gboolean
+register_client_to_gnome_session (void)
+{
+        GError     *error = NULL;
+        GVariant   *res;
+        const char *startup_id;
+        const char *app_id;
+        char       *client_id;
+
+        startup_id = g_getenv ("DESKTOP_AUTOSTART_ID");
+        app_id = "polkit-mate-authentication-agent-1.desktop";
+
+        sm_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
+                                                  G_DBUS_PROXY_FLAGS_NONE,
+                                                  NULL, /* GDBusInterfaceInfo */
+                                                  SM_DBUS_NAME,
+                                                  SM_DBUS_PATH,
+                                                  SM_DBUS_INTERFACE,
+                                                  NULL, /* GCancellable */
+                                                  &error);
+        if (sm_proxy == NULL) {
+                g_message("Failed to get session manager: %s", error->message);
+                g_error_free (error);
+                return FALSE;
+        }
+
+        res = g_dbus_proxy_call_sync (sm_proxy,
+                                      "RegisterClient",
+                                      g_variant_new ("(ss)",
+                                                     app_id,
+                                                     startup_id),
+                                      G_DBUS_CALL_FLAGS_NONE,
+                                      -1, /* timeout */
+                                      NULL, /* GCancellable */
+                                      &error);
+        if (! res) {
+                g_warning ("Failed to register client: %s", error->message);
+                g_error_free (error);
+                return FALSE;
+        }
+
+        if (! g_variant_is_of_type (res, G_VARIANT_TYPE ("(o)"))) {
+                g_warning ("RegisterClient returned unexpected type %s",
+                           g_variant_get_type_string (res));
+                return FALSE;
+        }
+
+        g_variant_get (res, "(&o)", &client_id);
+
+        client_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
+                                                      G_DBUS_PROXY_FLAGS_NONE,
+                                                      NULL, /* GDBusInterfaceInfo */
+                                                      SM_DBUS_NAME,
+                                                      client_id,
+                                                      SM_CLIENT_DBUS_INTERFACE,
+                                                      NULL, /* GCancellable */
+                                                      &error);
+        g_variant_unref (res);
+        if (client_proxy == NULL) {
+                g_message("Failed to get client proxy: %s", error->message);
+                g_error_free (error);
+                return FALSE;
+        }
+
+        g_signal_connect (client_proxy, "g-signal", G_CALLBACK (signal_cb), NULL);
+
+        return TRUE;
+}
+
+int
+main (int argc, char **argv)
+{
+  gint ret;
+  PolkitAgentListener *listener;
+  GError *error;
+
+  gtk_init (&argc, &argv);
+
+  loop = NULL;
+  authority = NULL;
+  listener = NULL;
+  session = NULL;
+  ret = 1;
+
+  bindtextdomain (GETTEXT_PACKAGE, MATELOCALEDIR);
+#if HAVE_BIND_TEXTDOMAIN_CODESET
+  bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+#endif
+  textdomain (GETTEXT_PACKAGE);
+
+  loop = g_main_loop_new (NULL, FALSE);
+
+  error = NULL;
+  authority = polkit_authority_get_sync (NULL /* GCancellable* */, &error);
+  if (authority == NULL)
+    {
+      g_warning ("Error getting authority: %s", error->message);
+      g_error_free (error);
+      goto out;
+    }
+  g_signal_connect (authority,
+                    "changed",
+                    G_CALLBACK (on_authority_changed),
+                    NULL);
+
+  listener = polkit_mate_listener_new ();
+
+  error = NULL;
+  session = polkit_unix_session_new_for_process_sync (getpid (), NULL, &error);
+  if (error != NULL)
+    {
+      g_warning ("Unable to determine the session we are in: %s", error->message);
+      g_error_free (error);
+      goto out;
+    }
+
+  error = NULL;
+  if (!polkit_agent_listener_register (listener,
+				       POLKIT_AGENT_REGISTER_FLAGS_NONE,
+                                       session,
+                                       "/org/mate/PolicyKit1/AuthenticationAgent",
+				       NULL,
+                                       &error))
+    {
+      g_printerr ("Cannot register authentication agent: %s\n", error->message);
+      g_error_free (error);
+      goto out;
+    }
+
+  update_temporary_authorization_icon (authority);
+
+  register_client_to_gnome_session();
+
+  g_main_loop_run (loop);
+
+  ret = 0;
+
+ out:
+  if (authority != NULL)
+    g_object_unref (authority);
+  if (session != NULL)
+    g_object_unref (session);
+  if (listener != NULL)
+    g_object_unref (listener);
+  if (loop != NULL)
+    g_main_loop_unref (loop);
+
+  return ret;
+}
+
+ +
+ +
+ + diff --git a/2023-09-02-184611-1622-cppcheck@4b078a16e961_master/index.html b/2023-09-02-184611-1622-cppcheck@4b078a16e961_master/index.html new file mode 100644 index 0000000..e6e1402 --- /dev/null +++ b/2023-09-02-184611-1622-cppcheck@4b078a16e961_master/index.html @@ -0,0 +1,197 @@ + + + + + + Cppcheck - HTML report - mate-polkit + + + + + +
+ + + +
+ + + + + + + + + + +
LineIdCWESeverityMessage
missingIncludeinformationCppcheck cannot find all the include files (use --check-config for details)
src/main.c
226shadowVariable398styleLocal variable 'authority' shadows outer variable
+
+ +
+ + diff --git a/2023-09-02-184611-1622-cppcheck@4b078a16e961_master/stats.html b/2023-09-02-184611-1622-cppcheck@4b078a16e961_master/stats.html new file mode 100644 index 0000000..8f9eaf7 --- /dev/null +++ b/2023-09-02-184611-1622-cppcheck@4b078a16e961_master/stats.html @@ -0,0 +1,167 @@ + + + + + + Cppcheck - HTML report - mate-polkit + + + + + +
+ + + +
+

Top 10 files for style severity, total findings: 1
+   1  src/main.c
+

+ +
+ +
+ + diff --git a/2023-09-02-184611-1622-cppcheck@4b078a16e961_master/style.css b/2023-09-02-184611-1622-cppcheck@4b078a16e961_master/style.css new file mode 100644 index 0000000..3897bfa --- /dev/null +++ b/2023-09-02-184611-1622-cppcheck@4b078a16e961_master/style.css @@ -0,0 +1,177 @@ + +body { + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif; + font-size: 13px; + line-height: 1.5; + height: 100%; + margin: 0; +} + +#wrapper { + position: fixed; + height: 100vh; + width: 100vw; + display: grid; + grid-template-rows: fit-content(8rem) auto fit-content(8rem); + grid-template-columns: fit-content(25%) 1fr; + grid-template-areas: + "header header" + "menu content" + "footer footer"; +} + +h1 { + margin: 0 0 8px -2px; + font-size: 175%; +} + +.header { + padding: 0 0 5px 15px; + grid-area: header; + border-bottom: thin solid #aaa; +} + +.footer { + grid-area: footer; + border-top: thin solid #aaa; + font-size: 85%; + +} + +.footer > p { + margin: 4px; +} + +#menu, +#menu_index { + grid-area: menu; + text-align: left; + overflow: auto; + padding: 0 23px 15px 15px; + border-right: thin solid #aaa; + min-width: 200px; +} + +#menu > a { + display: block; + margin-left: 10px; + font-size: 12px; +} + +#content, +#content_index { + grid-area: content; + padding: 0px 5px 15px 15px; + overflow: auto; +} + +label { + white-space: nowrap; +} + +label.checkBtn.disabled { + color: #606060; + background: #e0e0e0; + font-style: italic; +} + +label.checkBtn, input[type="text"] { + border: 1px solid grey; + border-radius: 4px; + box-shadow: 1px 1px inset; + padding: 1px 5px; +} + +label.checkBtn { + white-space: nowrap; + background: #ccddff; +} + +label.unchecked { + background: #eff8ff; + box-shadow: 1px 1px 1px; +} + +label.checkBtn:hover, label.unchecked:hover{ + box-shadow: 0 0 2px; +} + +label.disabled:hover { + box-shadow: 1px 1px inset; +} + +label.checkBtn > input { + display:none; +} + +.summaryTable { + width: 100%; +} + +table.summaryTable td { padding: 0 5px 0 5px; } + +.statHeader, .severityHeader { + font-weight: bold; +} + +.warning { + background-color: #ffffa7; +} + +.error { + background-color: #ffb7b7; +} + +.error2 { + background-color: #faa; + display: inline-block; + margin-left: 4px; +} + +.inconclusive { + background-color: #b6b6b4; +} + +.inconclusive2 { + background-color: #b6b6b4; + display: inline-block; + margin-left: 4px; +} + +.verbose { + display: inline-block; + vertical-align: top; + cursor: help; +} + +.verbose .content { + display: none; + position: absolute; + padding: 10px; + margin: 4px; + max-width: 40%; + white-space: pre-wrap; + border: 1px solid #000; + background-color: #ffffcc; + cursor: auto; +} + +.highlight .hll { + padding: 1px; +} + +.highlighttable { + background-color: #fff; + position: relative; + margin: -10px; +} + +.linenos { + border-right: thin solid #aaa; + color: #d3d3d3; + padding-right: 6px; +} + +.id-filtered, .severity-filtered, .file-filtered, .tool-filtered, .text-filtered { + visibility: collapse; +} diff --git a/2023-09-03-024610-6129-cppcheck@abf957c6a5e9_fix-meson/0.html b/2023-09-03-024610-6129-cppcheck@abf957c6a5e9_fix-meson/0.html new file mode 100644 index 0000000..b179177 --- /dev/null +++ b/2023-09-03-024610-6129-cppcheck@abf957c6a5e9_fix-meson/0.html @@ -0,0 +1,1189 @@ + + + + + + Cppcheck - HTML report - mate-polkit + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
/*
+ * Copyright (C) 2009 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ * Author: David Zeuthen <davidz@redhat.com>
+ */
+
+#ifdef HAVE_CONFIG_H
+#  include "config.h"
+#endif
+
+#include <string.h>
+#include <gtk/gtk.h>
+#include <gio/gio.h>
+#include <glib/gi18n.h>
+#include <polkitagent/polkitagent.h>
+
+#if defined(HAVE_AYATANA_APPINDICATOR)
+# include <libayatana-appindicator/app-indicator.h>
+#elif defined(HAVE_UBUNTU_APPINDICATOR)
+# include <libappindicator/app-indicator.h>
+#endif
+
+#include "polkitmatelistener.h"
+
+/* session management support for auto-restart */
+#define SM_DBUS_NAME      "org.gnome.SessionManager"
+#define SM_DBUS_PATH      "/org/gnome/SessionManager"
+#define SM_DBUS_INTERFACE "org.gnome.SessionManager"
+#define SM_CLIENT_DBUS_INTERFACE "org.gnome.SessionManager.ClientPrivate"
+
+/* the Authority */
+static PolkitAuthority *authority = NULL;<--- Shadowed declaration
+
+/* the session we are servicing */
+static PolkitSubject *session = NULL;
+
+/* the current set of temporary authorizations */
+static GList *current_temporary_authorizations = NULL;
+
+#if defined(HAVE_AYATANA_APPINDICATOR) || defined(HAVE_UBUNTU_APPINDICATOR)
+static AppIndicator *app_indicator = NULL;
+#else
+static GtkStatusIcon *status_icon = NULL;
+#endif
+
+static GDBusProxy      *sm_proxy;
+static GDBusProxy      *client_proxy = NULL;
+
+static  GMainLoop *loop;
+
+static void
+revoke_tmp_authz_cb (GObject      *source_object,
+                     GAsyncResult *res,
+                     gpointer      user_data)
+{
+  GError *error;
+
+  error = NULL;
+  polkit_authority_revoke_temporary_authorizations_finish (POLKIT_AUTHORITY (source_object),
+                                                           res,
+                                                           &error);
+  if (error != NULL)
+    {
+      g_warning ("Error revoking temporary authorizations: %s", error->message);
+      g_error_free (error);
+    }
+}
+
+static void
+revoke_tmp_authz (void)
+{
+  polkit_authority_revoke_temporary_authorizations (authority,
+                                                    session,
+                                                    NULL,
+                                                    revoke_tmp_authz_cb,
+                                                    NULL);
+}
+
+#if defined(HAVE_AYATANA_APPINDICATOR) || defined(HAVE_UBUNTU_APPINDICATOR)
+static void
+on_menu_item_activate (GtkMenuItem *menu_item,
+                       gpointer     user_data)
+{
+  revoke_tmp_authz ();
+}
+#else
+static void
+on_status_icon_activate (GtkStatusIcon *status_icon,
+                         gpointer       user_data)
+{
+  revoke_tmp_authz ();
+}
+
+static void
+on_status_icon_popup_menu (GtkStatusIcon *status_icon,
+                           guint          button,
+                           guint          activate_time,
+                           gpointer       user_data)
+{
+  revoke_tmp_authz ();
+}
+#endif
+
+static void
+update_temporary_authorization_icon_real (void)
+{
+
+#if 0
+  GList *l;
+  g_debug ("have %d tmp authorizations", g_list_length (current_temporary_authorizations));
+  for (l = current_temporary_authorizations; l != NULL; l = l->next)
+    {
+      PolkitTemporaryAuthorization *authz = POLKIT_TEMPORARY_AUTHORIZATION (l->data);
+
+      g_debug ("have tmp authz for action %s (subject %s) with id %s (obtained %d, expires %d)",
+               polkit_temporary_authorization_get_action_id (authz),
+               polkit_subject_to_string (polkit_temporary_authorization_get_subject (authz)),
+               polkit_temporary_authorization_get_id (authz),
+               (gint) polkit_temporary_authorization_get_time_obtained (authz),
+               (gint) polkit_temporary_authorization_get_time_expires (authz));
+    }
+#endif
+
+  /* TODO:
+   *
+   * - we could do something fancy like displaying a window with the tmp authz
+   *   when the icon is clicked...
+   *
+   * - we could do some work using polkit_subject_exists() to ignore tmp authz
+   *   for subjects that no longer exists.. this is because temporary authorizations
+   *   are only valid for the subject that trigger the authentication dialog.
+   *
+   *   Maybe the authority could do this, would probably involve some polling, but
+   *   it seems cleaner to do this server side.
+   */
+
+  if (current_temporary_authorizations != NULL)
+    {
+      /* show icon */
+#if defined(HAVE_AYATANA_APPINDICATOR) || defined(HAVE_UBUNTU_APPINDICATOR)
+      if (app_indicator == NULL)
+        {
+          GtkWidget *item, *menu;
+
+          app_indicator = app_indicator_new ("mate-polkit",
+                                             "dialog-password",
+                                             APP_INDICATOR_CATEGORY_SYSTEM_SERVICES);
+
+          item = gtk_menu_item_new_with_label (_("Drop all elevated privileges"));
+          g_signal_connect (item,
+                            "activate",
+                            G_CALLBACK (on_menu_item_activate),
+                            NULL);
+          menu = gtk_menu_new ();
+          gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+          gtk_widget_show_all (menu);
+
+          app_indicator_set_menu (app_indicator,
+                                  GTK_MENU (menu));
+          app_indicator_set_status (app_indicator,
+                                    APP_INDICATOR_STATUS_ACTIVE);
+        }
+      else
+        /*Reshow icon from existing appindicator */
+        app_indicator_set_status (app_indicator,
+				    APP_INDICATOR_STATUS_ACTIVE);
+
+#else
+      if (status_icon == NULL)
+        {
+          status_icon = gtk_status_icon_new_from_icon_name ("dialog-password");
+          gtk_status_icon_set_tooltip_text (status_icon,
+                                            _("Click the icon to drop all elevated privileges"));
+          g_signal_connect (status_icon,
+                            "activate",
+                            G_CALLBACK (on_status_icon_activate),
+                            NULL);
+          g_signal_connect (status_icon,
+                            "popup-menu",
+                            G_CALLBACK (on_status_icon_popup_menu),
+                            NULL);
+        }
+#endif
+    }
+  else
+    {
+      /* hide icon */
+#if defined(HAVE_AYATANA_APPINDICATOR) || defined(HAVE_UBUNTU_APPINDICATOR)
+      if (app_indicator != NULL)
+        {
+          /* keep the app_indicator, hide the icon or it won't come back*/
+          app_indicator_set_status (app_indicator,
+				    APP_INDICATOR_STATUS_PASSIVE);
+        }
+#else
+      if (status_icon != NULL)
+        {
+          gtk_status_icon_set_visible (status_icon, FALSE);
+          g_object_unref (status_icon);
+          status_icon = NULL;
+        }
+#endif
+    }
+}
+
+static void
+enumerate_temporary_authorizations_cb (GObject      *source_object,
+                                       GAsyncResult *res,
+                                       gpointer      user_data)
+{
+  PolkitAuthority *authority = POLKIT_AUTHORITY (source_object);<--- Shadow variable
+  GList *temporary_authorizations;
+  GError *error;
+
+  temporary_authorizations = NULL;
+
+  error = NULL;
+  temporary_authorizations = polkit_authority_enumerate_temporary_authorizations_finish (authority,
+                                                                                         res,
+                                                                                         &error);
+  if (error != NULL)
+    {
+      g_warning ("Error enumerating temporary authorizations: %s", error->message);
+      g_error_free (error);
+      goto out;
+    }
+
+  g_list_foreach (current_temporary_authorizations, (GFunc) g_object_unref, NULL);
+  g_list_free (current_temporary_authorizations);
+
+  current_temporary_authorizations = temporary_authorizations;
+
+  update_temporary_authorization_icon_real ();
+
+ out:
+  ;
+}
+
+static void
+update_temporary_authorization_icon (PolkitAuthority *authority)
+{
+  polkit_authority_enumerate_temporary_authorizations (authority,
+                                                       session,
+                                                       NULL,
+                                                       enumerate_temporary_authorizations_cb,
+                                                       NULL);
+}
+
+static void
+on_authority_changed (PolkitAuthority *authority,
+                      gpointer         user_data)
+{
+  update_temporary_authorization_icon (authority);
+}
+
+static void
+stop_cb (void)
+{
+        g_main_loop_quit (loop);
+}
+
+static gboolean
+end_session_response (gboolean is_okay, const gchar *reason)
+{
+        GVariant *res;
+        GError *error = NULL;
+
+        res = g_dbus_proxy_call_sync (client_proxy,
+                                      "EndSessionResponse",
+                                      g_variant_new ("(bs)",
+                                                     is_okay,
+                                                     reason),
+                                      G_DBUS_CALL_FLAGS_NONE,
+                                      -1, /* timeout */
+                                      NULL, /* GCancellable */
+                                      &error);
+        if (! res) {
+                g_warning ("Failed to call EndSessionResponse: %s", error->message);
+                g_error_free (error);
+                return FALSE;
+        }
+
+        g_variant_unref (res);
+        return TRUE;
+}
+
+static void
+query_end_session_cb (void)
+{
+        end_session_response (TRUE, "");
+}
+
+static void
+end_session_cb (void)
+{
+        end_session_response (TRUE, "");
+        g_main_loop_quit (loop);
+}
+
+static void
+signal_cb (GDBusProxy *proxy, gchar *sender_name, gchar *signal_name,
+           GVariant *parameters, gpointer user_data)
+{
+        if (strcmp (signal_name, "Stop") == 0) {
+                stop_cb ();
+        } else if (strcmp (signal_name, "QueryEndSession") == 0) {
+                query_end_session_cb ();
+        } else if (strcmp (signal_name, "EndSession") == 0) {
+                end_session_cb ();
+        }
+}
+
+static gboolean
+register_client_to_gnome_session (void)
+{
+        GError     *error = NULL;
+        GVariant   *res;
+        const char *startup_id;
+        const char *app_id;
+        char       *client_id;
+
+        startup_id = g_getenv ("DESKTOP_AUTOSTART_ID");
+        app_id = "polkit-mate-authentication-agent-1.desktop";
+
+        sm_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
+                                                  G_DBUS_PROXY_FLAGS_NONE,
+                                                  NULL, /* GDBusInterfaceInfo */
+                                                  SM_DBUS_NAME,
+                                                  SM_DBUS_PATH,
+                                                  SM_DBUS_INTERFACE,
+                                                  NULL, /* GCancellable */
+                                                  &error);
+        if (sm_proxy == NULL) {
+                g_message("Failed to get session manager: %s", error->message);
+                g_error_free (error);
+                return FALSE;
+        }
+
+        res = g_dbus_proxy_call_sync (sm_proxy,
+                                      "RegisterClient",
+                                      g_variant_new ("(ss)",
+                                                     app_id,
+                                                     startup_id),
+                                      G_DBUS_CALL_FLAGS_NONE,
+                                      -1, /* timeout */
+                                      NULL, /* GCancellable */
+                                      &error);
+        if (! res) {
+                g_warning ("Failed to register client: %s", error->message);
+                g_error_free (error);
+                return FALSE;
+        }
+
+        if (! g_variant_is_of_type (res, G_VARIANT_TYPE ("(o)"))) {
+                g_warning ("RegisterClient returned unexpected type %s",
+                           g_variant_get_type_string (res));
+                return FALSE;
+        }
+
+        g_variant_get (res, "(&o)", &client_id);
+
+        client_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
+                                                      G_DBUS_PROXY_FLAGS_NONE,
+                                                      NULL, /* GDBusInterfaceInfo */
+                                                      SM_DBUS_NAME,
+                                                      client_id,
+                                                      SM_CLIENT_DBUS_INTERFACE,
+                                                      NULL, /* GCancellable */
+                                                      &error);
+        g_variant_unref (res);
+        if (client_proxy == NULL) {
+                g_message("Failed to get client proxy: %s", error->message);
+                g_error_free (error);
+                return FALSE;
+        }
+
+        g_signal_connect (client_proxy, "g-signal", G_CALLBACK (signal_cb), NULL);
+
+        return TRUE;
+}
+
+int
+main (int argc, char **argv)
+{
+  gint ret;
+  PolkitAgentListener *listener;
+  GError *error;
+
+  gtk_init (&argc, &argv);
+
+  loop = NULL;
+  authority = NULL;
+  listener = NULL;
+  session = NULL;
+  ret = 1;
+
+  bindtextdomain (GETTEXT_PACKAGE, MATELOCALEDIR);
+#if HAVE_BIND_TEXTDOMAIN_CODESET
+  bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+#endif
+  textdomain (GETTEXT_PACKAGE);
+
+  loop = g_main_loop_new (NULL, FALSE);
+
+  error = NULL;
+  authority = polkit_authority_get_sync (NULL /* GCancellable* */, &error);
+  if (authority == NULL)
+    {
+      g_warning ("Error getting authority: %s", error->message);
+      g_error_free (error);
+      goto out;
+    }
+  g_signal_connect (authority,
+                    "changed",
+                    G_CALLBACK (on_authority_changed),
+                    NULL);
+
+  listener = polkit_mate_listener_new ();
+
+  error = NULL;
+  session = polkit_unix_session_new_for_process_sync (getpid (), NULL, &error);
+  if (error != NULL)
+    {
+      g_warning ("Unable to determine the session we are in: %s", error->message);
+      g_error_free (error);
+      goto out;
+    }
+
+  error = NULL;
+  if (!polkit_agent_listener_register (listener,
+				       POLKIT_AGENT_REGISTER_FLAGS_NONE,
+                                       session,
+                                       "/org/mate/PolicyKit1/AuthenticationAgent",
+				       NULL,
+                                       &error))
+    {
+      g_printerr ("Cannot register authentication agent: %s\n", error->message);
+      g_error_free (error);
+      goto out;
+    }
+
+  update_temporary_authorization_icon (authority);
+
+  register_client_to_gnome_session();
+
+  g_main_loop_run (loop);
+
+  ret = 0;
+
+ out:
+  if (authority != NULL)
+    g_object_unref (authority);
+  if (session != NULL)
+    g_object_unref (session);
+  if (listener != NULL)
+    g_object_unref (listener);
+  if (loop != NULL)
+    g_main_loop_unref (loop);
+
+  return ret;
+}
+
+ +
+ +
+ + diff --git a/2023-09-03-024610-6129-cppcheck@abf957c6a5e9_fix-meson/index.html b/2023-09-03-024610-6129-cppcheck@abf957c6a5e9_fix-meson/index.html new file mode 100644 index 0000000..e6e1402 --- /dev/null +++ b/2023-09-03-024610-6129-cppcheck@abf957c6a5e9_fix-meson/index.html @@ -0,0 +1,197 @@ + + + + + + Cppcheck - HTML report - mate-polkit + + + + + +
+ + + +
+ + + + + + + + + + +
LineIdCWESeverityMessage
missingIncludeinformationCppcheck cannot find all the include files (use --check-config for details)
src/main.c
226shadowVariable398styleLocal variable 'authority' shadows outer variable
+
+ +
+ + diff --git a/2023-09-03-024610-6129-cppcheck@abf957c6a5e9_fix-meson/stats.html b/2023-09-03-024610-6129-cppcheck@abf957c6a5e9_fix-meson/stats.html new file mode 100644 index 0000000..8f9eaf7 --- /dev/null +++ b/2023-09-03-024610-6129-cppcheck@abf957c6a5e9_fix-meson/stats.html @@ -0,0 +1,167 @@ + + + + + + Cppcheck - HTML report - mate-polkit + + + + + +
+ + + +
+

Top 10 files for style severity, total findings: 1
+   1  src/main.c
+

+ +
+ +
+ + diff --git a/2023-09-03-024610-6129-cppcheck@abf957c6a5e9_fix-meson/style.css b/2023-09-03-024610-6129-cppcheck@abf957c6a5e9_fix-meson/style.css new file mode 100644 index 0000000..3897bfa --- /dev/null +++ b/2023-09-03-024610-6129-cppcheck@abf957c6a5e9_fix-meson/style.css @@ -0,0 +1,177 @@ + +body { + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif; + font-size: 13px; + line-height: 1.5; + height: 100%; + margin: 0; +} + +#wrapper { + position: fixed; + height: 100vh; + width: 100vw; + display: grid; + grid-template-rows: fit-content(8rem) auto fit-content(8rem); + grid-template-columns: fit-content(25%) 1fr; + grid-template-areas: + "header header" + "menu content" + "footer footer"; +} + +h1 { + margin: 0 0 8px -2px; + font-size: 175%; +} + +.header { + padding: 0 0 5px 15px; + grid-area: header; + border-bottom: thin solid #aaa; +} + +.footer { + grid-area: footer; + border-top: thin solid #aaa; + font-size: 85%; + +} + +.footer > p { + margin: 4px; +} + +#menu, +#menu_index { + grid-area: menu; + text-align: left; + overflow: auto; + padding: 0 23px 15px 15px; + border-right: thin solid #aaa; + min-width: 200px; +} + +#menu > a { + display: block; + margin-left: 10px; + font-size: 12px; +} + +#content, +#content_index { + grid-area: content; + padding: 0px 5px 15px 15px; + overflow: auto; +} + +label { + white-space: nowrap; +} + +label.checkBtn.disabled { + color: #606060; + background: #e0e0e0; + font-style: italic; +} + +label.checkBtn, input[type="text"] { + border: 1px solid grey; + border-radius: 4px; + box-shadow: 1px 1px inset; + padding: 1px 5px; +} + +label.checkBtn { + white-space: nowrap; + background: #ccddff; +} + +label.unchecked { + background: #eff8ff; + box-shadow: 1px 1px 1px; +} + +label.checkBtn:hover, label.unchecked:hover{ + box-shadow: 0 0 2px; +} + +label.disabled:hover { + box-shadow: 1px 1px inset; +} + +label.checkBtn > input { + display:none; +} + +.summaryTable { + width: 100%; +} + +table.summaryTable td { padding: 0 5px 0 5px; } + +.statHeader, .severityHeader { + font-weight: bold; +} + +.warning { + background-color: #ffffa7; +} + +.error { + background-color: #ffb7b7; +} + +.error2 { + background-color: #faa; + display: inline-block; + margin-left: 4px; +} + +.inconclusive { + background-color: #b6b6b4; +} + +.inconclusive2 { + background-color: #b6b6b4; + display: inline-block; + margin-left: 4px; +} + +.verbose { + display: inline-block; + vertical-align: top; + cursor: help; +} + +.verbose .content { + display: none; + position: absolute; + padding: 10px; + margin: 4px; + max-width: 40%; + white-space: pre-wrap; + border: 1px solid #000; + background-color: #ffffcc; + cursor: auto; +} + +.highlight .hll { + padding: 1px; +} + +.highlighttable { + background-color: #fff; + position: relative; + margin: -10px; +} + +.linenos { + border-right: thin solid #aaa; + color: #d3d3d3; + padding-right: 6px; +} + +.id-filtered, .severity-filtered, .file-filtered, .tool-filtered, .text-filtered { + visibility: collapse; +} diff --git a/2023-09-03-043043-5605-cppcheck@6fbf55c280e5_master/0.html b/2023-09-03-043043-5605-cppcheck@6fbf55c280e5_master/0.html new file mode 100644 index 0000000..b179177 --- /dev/null +++ b/2023-09-03-043043-5605-cppcheck@6fbf55c280e5_master/0.html @@ -0,0 +1,1189 @@ + + + + + + Cppcheck - HTML report - mate-polkit + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
/*
+ * Copyright (C) 2009 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ * Author: David Zeuthen <davidz@redhat.com>
+ */
+
+#ifdef HAVE_CONFIG_H
+#  include "config.h"
+#endif
+
+#include <string.h>
+#include <gtk/gtk.h>
+#include <gio/gio.h>
+#include <glib/gi18n.h>
+#include <polkitagent/polkitagent.h>
+
+#if defined(HAVE_AYATANA_APPINDICATOR)
+# include <libayatana-appindicator/app-indicator.h>
+#elif defined(HAVE_UBUNTU_APPINDICATOR)
+# include <libappindicator/app-indicator.h>
+#endif
+
+#include "polkitmatelistener.h"
+
+/* session management support for auto-restart */
+#define SM_DBUS_NAME      "org.gnome.SessionManager"
+#define SM_DBUS_PATH      "/org/gnome/SessionManager"
+#define SM_DBUS_INTERFACE "org.gnome.SessionManager"
+#define SM_CLIENT_DBUS_INTERFACE "org.gnome.SessionManager.ClientPrivate"
+
+/* the Authority */
+static PolkitAuthority *authority = NULL;<--- Shadowed declaration
+
+/* the session we are servicing */
+static PolkitSubject *session = NULL;
+
+/* the current set of temporary authorizations */
+static GList *current_temporary_authorizations = NULL;
+
+#if defined(HAVE_AYATANA_APPINDICATOR) || defined(HAVE_UBUNTU_APPINDICATOR)
+static AppIndicator *app_indicator = NULL;
+#else
+static GtkStatusIcon *status_icon = NULL;
+#endif
+
+static GDBusProxy      *sm_proxy;
+static GDBusProxy      *client_proxy = NULL;
+
+static  GMainLoop *loop;
+
+static void
+revoke_tmp_authz_cb (GObject      *source_object,
+                     GAsyncResult *res,
+                     gpointer      user_data)
+{
+  GError *error;
+
+  error = NULL;
+  polkit_authority_revoke_temporary_authorizations_finish (POLKIT_AUTHORITY (source_object),
+                                                           res,
+                                                           &error);
+  if (error != NULL)
+    {
+      g_warning ("Error revoking temporary authorizations: %s", error->message);
+      g_error_free (error);
+    }
+}
+
+static void
+revoke_tmp_authz (void)
+{
+  polkit_authority_revoke_temporary_authorizations (authority,
+                                                    session,
+                                                    NULL,
+                                                    revoke_tmp_authz_cb,
+                                                    NULL);
+}
+
+#if defined(HAVE_AYATANA_APPINDICATOR) || defined(HAVE_UBUNTU_APPINDICATOR)
+static void
+on_menu_item_activate (GtkMenuItem *menu_item,
+                       gpointer     user_data)
+{
+  revoke_tmp_authz ();
+}
+#else
+static void
+on_status_icon_activate (GtkStatusIcon *status_icon,
+                         gpointer       user_data)
+{
+  revoke_tmp_authz ();
+}
+
+static void
+on_status_icon_popup_menu (GtkStatusIcon *status_icon,
+                           guint          button,
+                           guint          activate_time,
+                           gpointer       user_data)
+{
+  revoke_tmp_authz ();
+}
+#endif
+
+static void
+update_temporary_authorization_icon_real (void)
+{
+
+#if 0
+  GList *l;
+  g_debug ("have %d tmp authorizations", g_list_length (current_temporary_authorizations));
+  for (l = current_temporary_authorizations; l != NULL; l = l->next)
+    {
+      PolkitTemporaryAuthorization *authz = POLKIT_TEMPORARY_AUTHORIZATION (l->data);
+
+      g_debug ("have tmp authz for action %s (subject %s) with id %s (obtained %d, expires %d)",
+               polkit_temporary_authorization_get_action_id (authz),
+               polkit_subject_to_string (polkit_temporary_authorization_get_subject (authz)),
+               polkit_temporary_authorization_get_id (authz),
+               (gint) polkit_temporary_authorization_get_time_obtained (authz),
+               (gint) polkit_temporary_authorization_get_time_expires (authz));
+    }
+#endif
+
+  /* TODO:
+   *
+   * - we could do something fancy like displaying a window with the tmp authz
+   *   when the icon is clicked...
+   *
+   * - we could do some work using polkit_subject_exists() to ignore tmp authz
+   *   for subjects that no longer exists.. this is because temporary authorizations
+   *   are only valid for the subject that trigger the authentication dialog.
+   *
+   *   Maybe the authority could do this, would probably involve some polling, but
+   *   it seems cleaner to do this server side.
+   */
+
+  if (current_temporary_authorizations != NULL)
+    {
+      /* show icon */
+#if defined(HAVE_AYATANA_APPINDICATOR) || defined(HAVE_UBUNTU_APPINDICATOR)
+      if (app_indicator == NULL)
+        {
+          GtkWidget *item, *menu;
+
+          app_indicator = app_indicator_new ("mate-polkit",
+                                             "dialog-password",
+                                             APP_INDICATOR_CATEGORY_SYSTEM_SERVICES);
+
+          item = gtk_menu_item_new_with_label (_("Drop all elevated privileges"));
+          g_signal_connect (item,
+                            "activate",
+                            G_CALLBACK (on_menu_item_activate),
+                            NULL);
+          menu = gtk_menu_new ();
+          gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+          gtk_widget_show_all (menu);
+
+          app_indicator_set_menu (app_indicator,
+                                  GTK_MENU (menu));
+          app_indicator_set_status (app_indicator,
+                                    APP_INDICATOR_STATUS_ACTIVE);
+        }
+      else
+        /*Reshow icon from existing appindicator */
+        app_indicator_set_status (app_indicator,
+				    APP_INDICATOR_STATUS_ACTIVE);
+
+#else
+      if (status_icon == NULL)
+        {
+          status_icon = gtk_status_icon_new_from_icon_name ("dialog-password");
+          gtk_status_icon_set_tooltip_text (status_icon,
+                                            _("Click the icon to drop all elevated privileges"));
+          g_signal_connect (status_icon,
+                            "activate",
+                            G_CALLBACK (on_status_icon_activate),
+                            NULL);
+          g_signal_connect (status_icon,
+                            "popup-menu",
+                            G_CALLBACK (on_status_icon_popup_menu),
+                            NULL);
+        }
+#endif
+    }
+  else
+    {
+      /* hide icon */
+#if defined(HAVE_AYATANA_APPINDICATOR) || defined(HAVE_UBUNTU_APPINDICATOR)
+      if (app_indicator != NULL)
+        {
+          /* keep the app_indicator, hide the icon or it won't come back*/
+          app_indicator_set_status (app_indicator,
+				    APP_INDICATOR_STATUS_PASSIVE);
+        }
+#else
+      if (status_icon != NULL)
+        {
+          gtk_status_icon_set_visible (status_icon, FALSE);
+          g_object_unref (status_icon);
+          status_icon = NULL;
+        }
+#endif
+    }
+}
+
+static void
+enumerate_temporary_authorizations_cb (GObject      *source_object,
+                                       GAsyncResult *res,
+                                       gpointer      user_data)
+{
+  PolkitAuthority *authority = POLKIT_AUTHORITY (source_object);<--- Shadow variable
+  GList *temporary_authorizations;
+  GError *error;
+
+  temporary_authorizations = NULL;
+
+  error = NULL;
+  temporary_authorizations = polkit_authority_enumerate_temporary_authorizations_finish (authority,
+                                                                                         res,
+                                                                                         &error);
+  if (error != NULL)
+    {
+      g_warning ("Error enumerating temporary authorizations: %s", error->message);
+      g_error_free (error);
+      goto out;
+    }
+
+  g_list_foreach (current_temporary_authorizations, (GFunc) g_object_unref, NULL);
+  g_list_free (current_temporary_authorizations);
+
+  current_temporary_authorizations = temporary_authorizations;
+
+  update_temporary_authorization_icon_real ();
+
+ out:
+  ;
+}
+
+static void
+update_temporary_authorization_icon (PolkitAuthority *authority)
+{
+  polkit_authority_enumerate_temporary_authorizations (authority,
+                                                       session,
+                                                       NULL,
+                                                       enumerate_temporary_authorizations_cb,
+                                                       NULL);
+}
+
+static void
+on_authority_changed (PolkitAuthority *authority,
+                      gpointer         user_data)
+{
+  update_temporary_authorization_icon (authority);
+}
+
+static void
+stop_cb (void)
+{
+        g_main_loop_quit (loop);
+}
+
+static gboolean
+end_session_response (gboolean is_okay, const gchar *reason)
+{
+        GVariant *res;
+        GError *error = NULL;
+
+        res = g_dbus_proxy_call_sync (client_proxy,
+                                      "EndSessionResponse",
+                                      g_variant_new ("(bs)",
+                                                     is_okay,
+                                                     reason),
+                                      G_DBUS_CALL_FLAGS_NONE,
+                                      -1, /* timeout */
+                                      NULL, /* GCancellable */
+                                      &error);
+        if (! res) {
+                g_warning ("Failed to call EndSessionResponse: %s", error->message);
+                g_error_free (error);
+                return FALSE;
+        }
+
+        g_variant_unref (res);
+        return TRUE;
+}
+
+static void
+query_end_session_cb (void)
+{
+        end_session_response (TRUE, "");
+}
+
+static void
+end_session_cb (void)
+{
+        end_session_response (TRUE, "");
+        g_main_loop_quit (loop);
+}
+
+static void
+signal_cb (GDBusProxy *proxy, gchar *sender_name, gchar *signal_name,
+           GVariant *parameters, gpointer user_data)
+{
+        if (strcmp (signal_name, "Stop") == 0) {
+                stop_cb ();
+        } else if (strcmp (signal_name, "QueryEndSession") == 0) {
+                query_end_session_cb ();
+        } else if (strcmp (signal_name, "EndSession") == 0) {
+                end_session_cb ();
+        }
+}
+
+static gboolean
+register_client_to_gnome_session (void)
+{
+        GError     *error = NULL;
+        GVariant   *res;
+        const char *startup_id;
+        const char *app_id;
+        char       *client_id;
+
+        startup_id = g_getenv ("DESKTOP_AUTOSTART_ID");
+        app_id = "polkit-mate-authentication-agent-1.desktop";
+
+        sm_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
+                                                  G_DBUS_PROXY_FLAGS_NONE,
+                                                  NULL, /* GDBusInterfaceInfo */
+                                                  SM_DBUS_NAME,
+                                                  SM_DBUS_PATH,
+                                                  SM_DBUS_INTERFACE,
+                                                  NULL, /* GCancellable */
+                                                  &error);
+        if (sm_proxy == NULL) {
+                g_message("Failed to get session manager: %s", error->message);
+                g_error_free (error);
+                return FALSE;
+        }
+
+        res = g_dbus_proxy_call_sync (sm_proxy,
+                                      "RegisterClient",
+                                      g_variant_new ("(ss)",
+                                                     app_id,
+                                                     startup_id),
+                                      G_DBUS_CALL_FLAGS_NONE,
+                                      -1, /* timeout */
+                                      NULL, /* GCancellable */
+                                      &error);
+        if (! res) {
+                g_warning ("Failed to register client: %s", error->message);
+                g_error_free (error);
+                return FALSE;
+        }
+
+        if (! g_variant_is_of_type (res, G_VARIANT_TYPE ("(o)"))) {
+                g_warning ("RegisterClient returned unexpected type %s",
+                           g_variant_get_type_string (res));
+                return FALSE;
+        }
+
+        g_variant_get (res, "(&o)", &client_id);
+
+        client_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
+                                                      G_DBUS_PROXY_FLAGS_NONE,
+                                                      NULL, /* GDBusInterfaceInfo */
+                                                      SM_DBUS_NAME,
+                                                      client_id,
+                                                      SM_CLIENT_DBUS_INTERFACE,
+                                                      NULL, /* GCancellable */
+                                                      &error);
+        g_variant_unref (res);
+        if (client_proxy == NULL) {
+                g_message("Failed to get client proxy: %s", error->message);
+                g_error_free (error);
+                return FALSE;
+        }
+
+        g_signal_connect (client_proxy, "g-signal", G_CALLBACK (signal_cb), NULL);
+
+        return TRUE;
+}
+
+int
+main (int argc, char **argv)
+{
+  gint ret;
+  PolkitAgentListener *listener;
+  GError *error;
+
+  gtk_init (&argc, &argv);
+
+  loop = NULL;
+  authority = NULL;
+  listener = NULL;
+  session = NULL;
+  ret = 1;
+
+  bindtextdomain (GETTEXT_PACKAGE, MATELOCALEDIR);
+#if HAVE_BIND_TEXTDOMAIN_CODESET
+  bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+#endif
+  textdomain (GETTEXT_PACKAGE);
+
+  loop = g_main_loop_new (NULL, FALSE);
+
+  error = NULL;
+  authority = polkit_authority_get_sync (NULL /* GCancellable* */, &error);
+  if (authority == NULL)
+    {
+      g_warning ("Error getting authority: %s", error->message);
+      g_error_free (error);
+      goto out;
+    }
+  g_signal_connect (authority,
+                    "changed",
+                    G_CALLBACK (on_authority_changed),
+                    NULL);
+
+  listener = polkit_mate_listener_new ();
+
+  error = NULL;
+  session = polkit_unix_session_new_for_process_sync (getpid (), NULL, &error);
+  if (error != NULL)
+    {
+      g_warning ("Unable to determine the session we are in: %s", error->message);
+      g_error_free (error);
+      goto out;
+    }
+
+  error = NULL;
+  if (!polkit_agent_listener_register (listener,
+				       POLKIT_AGENT_REGISTER_FLAGS_NONE,
+                                       session,
+                                       "/org/mate/PolicyKit1/AuthenticationAgent",
+				       NULL,
+                                       &error))
+    {
+      g_printerr ("Cannot register authentication agent: %s\n", error->message);
+      g_error_free (error);
+      goto out;
+    }
+
+  update_temporary_authorization_icon (authority);
+
+  register_client_to_gnome_session();
+
+  g_main_loop_run (loop);
+
+  ret = 0;
+
+ out:
+  if (authority != NULL)
+    g_object_unref (authority);
+  if (session != NULL)
+    g_object_unref (session);
+  if (listener != NULL)
+    g_object_unref (listener);
+  if (loop != NULL)
+    g_main_loop_unref (loop);
+
+  return ret;
+}
+
+ +
+ +
+ + diff --git a/2023-09-03-043043-5605-cppcheck@6fbf55c280e5_master/index.html b/2023-09-03-043043-5605-cppcheck@6fbf55c280e5_master/index.html new file mode 100644 index 0000000..e6e1402 --- /dev/null +++ b/2023-09-03-043043-5605-cppcheck@6fbf55c280e5_master/index.html @@ -0,0 +1,197 @@ + + + + + + Cppcheck - HTML report - mate-polkit + + + + + +
+ + + +
+ + + + + + + + + + +
LineIdCWESeverityMessage
missingIncludeinformationCppcheck cannot find all the include files (use --check-config for details)
src/main.c
226shadowVariable398styleLocal variable 'authority' shadows outer variable
+
+ +
+ + diff --git a/2023-09-03-043043-5605-cppcheck@6fbf55c280e5_master/stats.html b/2023-09-03-043043-5605-cppcheck@6fbf55c280e5_master/stats.html new file mode 100644 index 0000000..8f9eaf7 --- /dev/null +++ b/2023-09-03-043043-5605-cppcheck@6fbf55c280e5_master/stats.html @@ -0,0 +1,167 @@ + + + + + + Cppcheck - HTML report - mate-polkit + + + + + +
+ + + +
+

Top 10 files for style severity, total findings: 1
+   1  src/main.c
+

+ +
+ +
+ + diff --git a/2023-09-03-043043-5605-cppcheck@6fbf55c280e5_master/style.css b/2023-09-03-043043-5605-cppcheck@6fbf55c280e5_master/style.css new file mode 100644 index 0000000..3897bfa --- /dev/null +++ b/2023-09-03-043043-5605-cppcheck@6fbf55c280e5_master/style.css @@ -0,0 +1,177 @@ + +body { + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif; + font-size: 13px; + line-height: 1.5; + height: 100%; + margin: 0; +} + +#wrapper { + position: fixed; + height: 100vh; + width: 100vw; + display: grid; + grid-template-rows: fit-content(8rem) auto fit-content(8rem); + grid-template-columns: fit-content(25%) 1fr; + grid-template-areas: + "header header" + "menu content" + "footer footer"; +} + +h1 { + margin: 0 0 8px -2px; + font-size: 175%; +} + +.header { + padding: 0 0 5px 15px; + grid-area: header; + border-bottom: thin solid #aaa; +} + +.footer { + grid-area: footer; + border-top: thin solid #aaa; + font-size: 85%; + +} + +.footer > p { + margin: 4px; +} + +#menu, +#menu_index { + grid-area: menu; + text-align: left; + overflow: auto; + padding: 0 23px 15px 15px; + border-right: thin solid #aaa; + min-width: 200px; +} + +#menu > a { + display: block; + margin-left: 10px; + font-size: 12px; +} + +#content, +#content_index { + grid-area: content; + padding: 0px 5px 15px 15px; + overflow: auto; +} + +label { + white-space: nowrap; +} + +label.checkBtn.disabled { + color: #606060; + background: #e0e0e0; + font-style: italic; +} + +label.checkBtn, input[type="text"] { + border: 1px solid grey; + border-radius: 4px; + box-shadow: 1px 1px inset; + padding: 1px 5px; +} + +label.checkBtn { + white-space: nowrap; + background: #ccddff; +} + +label.unchecked { + background: #eff8ff; + box-shadow: 1px 1px 1px; +} + +label.checkBtn:hover, label.unchecked:hover{ + box-shadow: 0 0 2px; +} + +label.disabled:hover { + box-shadow: 1px 1px inset; +} + +label.checkBtn > input { + display:none; +} + +.summaryTable { + width: 100%; +} + +table.summaryTable td { padding: 0 5px 0 5px; } + +.statHeader, .severityHeader { + font-weight: bold; +} + +.warning { + background-color: #ffffa7; +} + +.error { + background-color: #ffb7b7; +} + +.error2 { + background-color: #faa; + display: inline-block; + margin-left: 4px; +} + +.inconclusive { + background-color: #b6b6b4; +} + +.inconclusive2 { + background-color: #b6b6b4; + display: inline-block; + margin-left: 4px; +} + +.verbose { + display: inline-block; + vertical-align: top; + cursor: help; +} + +.verbose .content { + display: none; + position: absolute; + padding: 10px; + margin: 4px; + max-width: 40%; + white-space: pre-wrap; + border: 1px solid #000; + background-color: #ffffcc; + cursor: auto; +} + +.highlight .hll { + padding: 1px; +} + +.highlighttable { + background-color: #fff; + position: relative; + margin: -10px; +} + +.linenos { + border-right: thin solid #aaa; + color: #d3d3d3; + padding-right: 6px; +} + +.id-filtered, .severity-filtered, .file-filtered, .tool-filtered, .text-filtered { + visibility: collapse; +} diff --git a/2024-02-15-172653-3023-cppcheck@256d08c4a418_travis/0.html b/2024-02-15-172653-3023-cppcheck@256d08c4a418_travis/0.html new file mode 100644 index 0000000..95e5dbc --- /dev/null +++ b/2024-02-15-172653-3023-cppcheck@256d08c4a418_travis/0.html @@ -0,0 +1,1189 @@ + + + + + + Cppcheck - HTML report - mate-polkit + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
/*
+ * Copyright (C) 2009 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ * Author: David Zeuthen <davidz@redhat.com>
+ */
+
+#ifdef HAVE_CONFIG_H
+#  include "config.h"<--- Include file: "config.h" not found.
+#endif
+
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gio/gio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <polkitagent/polkitagent.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#if defined(HAVE_AYATANA_APPINDICATOR)
+# include <libayatana-appindicator/app-indicator.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#elif defined(HAVE_UBUNTU_APPINDICATOR)
+# include <libappindicator/app-indicator.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#endif
+
+#include "polkitmatelistener.h"
+
+/* session management support for auto-restart */
+#define SM_DBUS_NAME      "org.gnome.SessionManager"
+#define SM_DBUS_PATH      "/org/gnome/SessionManager"
+#define SM_DBUS_INTERFACE "org.gnome.SessionManager"
+#define SM_CLIENT_DBUS_INTERFACE "org.gnome.SessionManager.ClientPrivate"
+
+/* the Authority */
+static PolkitAuthority *authority = NULL;<--- Shadowed declaration
+
+/* the session we are servicing */
+static PolkitSubject *session = NULL;
+
+/* the current set of temporary authorizations */
+static GList *current_temporary_authorizations = NULL;
+
+#if defined(HAVE_AYATANA_APPINDICATOR) || defined(HAVE_UBUNTU_APPINDICATOR)
+static AppIndicator *app_indicator = NULL;
+#else
+static GtkStatusIcon *status_icon = NULL;
+#endif
+
+static GDBusProxy      *sm_proxy;
+static GDBusProxy      *client_proxy = NULL;
+
+static  GMainLoop *loop;
+
+static void
+revoke_tmp_authz_cb (GObject      *source_object,
+                     GAsyncResult *res,
+                     gpointer      user_data)
+{
+  GError *error;
+
+  error = NULL;
+  polkit_authority_revoke_temporary_authorizations_finish (POLKIT_AUTHORITY (source_object),
+                                                           res,
+                                                           &error);
+  if (error != NULL)
+    {
+      g_warning ("Error revoking temporary authorizations: %s", error->message);
+      g_error_free (error);
+    }
+}
+
+static void
+revoke_tmp_authz (void)
+{
+  polkit_authority_revoke_temporary_authorizations (authority,
+                                                    session,
+                                                    NULL,
+                                                    revoke_tmp_authz_cb,
+                                                    NULL);
+}
+
+#if defined(HAVE_AYATANA_APPINDICATOR) || defined(HAVE_UBUNTU_APPINDICATOR)
+static void
+on_menu_item_activate (GtkMenuItem *menu_item,
+                       gpointer     user_data)
+{
+  revoke_tmp_authz ();
+}
+#else
+static void
+on_status_icon_activate (GtkStatusIcon *status_icon,
+                         gpointer       user_data)
+{
+  revoke_tmp_authz ();
+}
+
+static void
+on_status_icon_popup_menu (GtkStatusIcon *status_icon,
+                           guint          button,
+                           guint          activate_time,
+                           gpointer       user_data)
+{
+  revoke_tmp_authz ();
+}
+#endif
+
+static void
+update_temporary_authorization_icon_real (void)
+{
+
+#if 0
+  GList *l;
+  g_debug ("have %d tmp authorizations", g_list_length (current_temporary_authorizations));
+  for (l = current_temporary_authorizations; l != NULL; l = l->next)
+    {
+      PolkitTemporaryAuthorization *authz = POLKIT_TEMPORARY_AUTHORIZATION (l->data);
+
+      g_debug ("have tmp authz for action %s (subject %s) with id %s (obtained %d, expires %d)",
+               polkit_temporary_authorization_get_action_id (authz),
+               polkit_subject_to_string (polkit_temporary_authorization_get_subject (authz)),
+               polkit_temporary_authorization_get_id (authz),
+               (gint) polkit_temporary_authorization_get_time_obtained (authz),
+               (gint) polkit_temporary_authorization_get_time_expires (authz));
+    }
+#endif
+
+  /* TODO:
+   *
+   * - we could do something fancy like displaying a window with the tmp authz
+   *   when the icon is clicked...
+   *
+   * - we could do some work using polkit_subject_exists() to ignore tmp authz
+   *   for subjects that no longer exists.. this is because temporary authorizations
+   *   are only valid for the subject that trigger the authentication dialog.
+   *
+   *   Maybe the authority could do this, would probably involve some polling, but
+   *   it seems cleaner to do this server side.
+   */
+
+  if (current_temporary_authorizations != NULL)
+    {
+      /* show icon */
+#if defined(HAVE_AYATANA_APPINDICATOR) || defined(HAVE_UBUNTU_APPINDICATOR)
+      if (app_indicator == NULL)
+        {
+          GtkWidget *item, *menu;
+
+          app_indicator = app_indicator_new ("mate-polkit",
+                                             "dialog-password",
+                                             APP_INDICATOR_CATEGORY_SYSTEM_SERVICES);
+
+          item = gtk_menu_item_new_with_label (_("Drop all elevated privileges"));
+          g_signal_connect (item,
+                            "activate",
+                            G_CALLBACK (on_menu_item_activate),
+                            NULL);
+          menu = gtk_menu_new ();
+          gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+          gtk_widget_show_all (menu);
+
+          app_indicator_set_menu (app_indicator,
+                                  GTK_MENU (menu));
+          app_indicator_set_status (app_indicator,
+                                    APP_INDICATOR_STATUS_ACTIVE);
+        }
+      else
+        /*Reshow icon from existing appindicator */
+        app_indicator_set_status (app_indicator,
+				    APP_INDICATOR_STATUS_ACTIVE);
+
+#else
+      if (status_icon == NULL)
+        {
+          status_icon = gtk_status_icon_new_from_icon_name ("dialog-password");
+          gtk_status_icon_set_tooltip_text (status_icon,
+                                            _("Click the icon to drop all elevated privileges"));
+          g_signal_connect (status_icon,
+                            "activate",
+                            G_CALLBACK (on_status_icon_activate),
+                            NULL);
+          g_signal_connect (status_icon,
+                            "popup-menu",
+                            G_CALLBACK (on_status_icon_popup_menu),
+                            NULL);
+        }
+#endif
+    }
+  else
+    {
+      /* hide icon */
+#if defined(HAVE_AYATANA_APPINDICATOR) || defined(HAVE_UBUNTU_APPINDICATOR)
+      if (app_indicator != NULL)
+        {
+          /* keep the app_indicator, hide the icon or it won't come back*/
+          app_indicator_set_status (app_indicator,
+				    APP_INDICATOR_STATUS_PASSIVE);
+        }
+#else
+      if (status_icon != NULL)
+        {
+          gtk_status_icon_set_visible (status_icon, FALSE);
+          g_object_unref (status_icon);
+          status_icon = NULL;
+        }
+#endif
+    }
+}
+
+static void
+enumerate_temporary_authorizations_cb (GObject      *source_object,
+                                       GAsyncResult *res,
+                                       gpointer      user_data)
+{
+  PolkitAuthority *authority = POLKIT_AUTHORITY (source_object);<--- Shadow variable
+  GList *temporary_authorizations;
+  GError *error;
+
+  temporary_authorizations = NULL;
+
+  error = NULL;
+  temporary_authorizations = polkit_authority_enumerate_temporary_authorizations_finish (authority,
+                                                                                         res,
+                                                                                         &error);
+  if (error != NULL)
+    {
+      g_warning ("Error enumerating temporary authorizations: %s", error->message);
+      g_error_free (error);
+      goto out;
+    }
+
+  g_list_foreach (current_temporary_authorizations, (GFunc) g_object_unref, NULL);
+  g_list_free (current_temporary_authorizations);
+
+  current_temporary_authorizations = temporary_authorizations;
+
+  update_temporary_authorization_icon_real ();
+
+ out:
+  ;
+}
+
+static void
+update_temporary_authorization_icon (PolkitAuthority *authority)
+{
+  polkit_authority_enumerate_temporary_authorizations (authority,
+                                                       session,
+                                                       NULL,
+                                                       enumerate_temporary_authorizations_cb,
+                                                       NULL);
+}
+
+static void
+on_authority_changed (PolkitAuthority *authority,
+                      gpointer         user_data)
+{
+  update_temporary_authorization_icon (authority);
+}
+
+static void
+stop_cb (void)
+{
+        g_main_loop_quit (loop);
+}
+
+static gboolean
+end_session_response (gboolean is_okay, const gchar *reason)
+{
+        GVariant *res;
+        GError *error = NULL;
+
+        res = g_dbus_proxy_call_sync (client_proxy,
+                                      "EndSessionResponse",
+                                      g_variant_new ("(bs)",
+                                                     is_okay,
+                                                     reason),
+                                      G_DBUS_CALL_FLAGS_NONE,
+                                      -1, /* timeout */
+                                      NULL, /* GCancellable */
+                                      &error);
+        if (! res) {
+                g_warning ("Failed to call EndSessionResponse: %s", error->message);
+                g_error_free (error);
+                return FALSE;
+        }
+
+        g_variant_unref (res);
+        return TRUE;
+}
+
+static void
+query_end_session_cb (void)
+{
+        end_session_response (TRUE, "");
+}
+
+static void
+end_session_cb (void)
+{
+        end_session_response (TRUE, "");
+        g_main_loop_quit (loop);
+}
+
+static void
+signal_cb (GDBusProxy *proxy, gchar *sender_name, gchar *signal_name,<--- Parameter 'signal_name' can be declared as pointer to const
+           GVariant *parameters, gpointer user_data)
+{
+        if (strcmp (signal_name, "Stop") == 0) {
+                stop_cb ();
+        } else if (strcmp (signal_name, "QueryEndSession") == 0) {
+                query_end_session_cb ();
+        } else if (strcmp (signal_name, "EndSession") == 0) {
+                end_session_cb ();
+        }
+}
+
+static gboolean
+register_client_to_gnome_session (void)
+{
+        GError     *error = NULL;
+        GVariant   *res;
+        const char *startup_id;
+        const char *app_id;
+        char       *client_id;
+
+        startup_id = g_getenv ("DESKTOP_AUTOSTART_ID");
+        app_id = "polkit-mate-authentication-agent-1.desktop";
+
+        sm_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
+                                                  G_DBUS_PROXY_FLAGS_NONE,
+                                                  NULL, /* GDBusInterfaceInfo */
+                                                  SM_DBUS_NAME,
+                                                  SM_DBUS_PATH,
+                                                  SM_DBUS_INTERFACE,
+                                                  NULL, /* GCancellable */
+                                                  &error);
+        if (sm_proxy == NULL) {
+                g_message("Failed to get session manager: %s", error->message);
+                g_error_free (error);
+                return FALSE;
+        }
+
+        res = g_dbus_proxy_call_sync (sm_proxy,
+                                      "RegisterClient",
+                                      g_variant_new ("(ss)",
+                                                     app_id,
+                                                     startup_id),
+                                      G_DBUS_CALL_FLAGS_NONE,
+                                      -1, /* timeout */
+                                      NULL, /* GCancellable */
+                                      &error);
+        if (! res) {
+                g_warning ("Failed to register client: %s", error->message);
+                g_error_free (error);
+                return FALSE;
+        }
+
+        if (! g_variant_is_of_type (res, G_VARIANT_TYPE ("(o)"))) {
+                g_warning ("RegisterClient returned unexpected type %s",
+                           g_variant_get_type_string (res));
+                return FALSE;
+        }
+
+        g_variant_get (res, "(&o)", &client_id);
+
+        client_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
+                                                      G_DBUS_PROXY_FLAGS_NONE,
+                                                      NULL, /* GDBusInterfaceInfo */
+                                                      SM_DBUS_NAME,
+                                                      client_id,
+                                                      SM_CLIENT_DBUS_INTERFACE,
+                                                      NULL, /* GCancellable */
+                                                      &error);
+        g_variant_unref (res);
+        if (client_proxy == NULL) {
+                g_message("Failed to get client proxy: %s", error->message);
+                g_error_free (error);
+                return FALSE;
+        }
+
+        g_signal_connect (client_proxy, "g-signal", G_CALLBACK (signal_cb), NULL);<--- You might need to cast the function pointer here
+
+        return TRUE;
+}
+
+int
+main (int argc, char **argv)
+{
+  gint ret;
+  PolkitAgentListener *listener;
+  GError *error;
+
+  gtk_init (&argc, &argv);
+
+  loop = NULL;
+  authority = NULL;
+  listener = NULL;
+  session = NULL;
+  ret = 1;
+
+  bindtextdomain (GETTEXT_PACKAGE, MATELOCALEDIR);
+#if HAVE_BIND_TEXTDOMAIN_CODESET
+  bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+#endif
+  textdomain (GETTEXT_PACKAGE);
+
+  loop = g_main_loop_new (NULL, FALSE);
+
+  error = NULL;
+  authority = polkit_authority_get_sync (NULL /* GCancellable* */, &error);
+  if (authority == NULL)
+    {
+      g_warning ("Error getting authority: %s", error->message);
+      g_error_free (error);
+      goto out;
+    }
+  g_signal_connect (authority,
+                    "changed",
+                    G_CALLBACK (on_authority_changed),
+                    NULL);
+
+  listener = polkit_mate_listener_new ();
+
+  error = NULL;
+  session = polkit_unix_session_new_for_process_sync (getpid (), NULL, &error);
+  if (error != NULL)
+    {
+      g_warning ("Unable to determine the session we are in: %s", error->message);
+      g_error_free (error);
+      goto out;
+    }
+
+  error = NULL;
+  if (!polkit_agent_listener_register (listener,
+				       POLKIT_AGENT_REGISTER_FLAGS_NONE,
+                                       session,
+                                       "/org/mate/PolicyKit1/AuthenticationAgent",
+				       NULL,
+                                       &error))
+    {
+      g_printerr ("Cannot register authentication agent: %s\n", error->message);
+      g_error_free (error);
+      goto out;
+    }
+
+  update_temporary_authorization_icon (authority);
+
+  register_client_to_gnome_session();
+
+  g_main_loop_run (loop);
+
+  ret = 0;
+
+ out:
+  if (authority != NULL)
+    g_object_unref (authority);
+  if (session != NULL)
+    g_object_unref (session);
+  if (listener != NULL)
+    g_object_unref (listener);
+  if (loop != NULL)
+    g_main_loop_unref (loop);
+
+  return ret;
+}
+
+ +
+ +
+ + diff --git a/2024-02-15-172653-3023-cppcheck@256d08c4a418_travis/1.html b/2024-02-15-172653-3023-cppcheck@256d08c4a418_travis/1.html new file mode 100644 index 0000000..bf8ec00 --- /dev/null +++ b/2024-02-15-172653-3023-cppcheck@256d08c4a418_travis/1.html @@ -0,0 +1,335 @@ + + + + + + Cppcheck - HTML report - mate-polkit + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
/*
+ * Copyright (C) 2009 Red Hat, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ * Author: David Zeuthen <davidz@redhat.com>
+ */
+
+#ifndef __POLKIT_MATE_LISTENER_H
+#define __POLKIT_MATE_LISTENER_H
+
+#include <polkitagent/polkitagent.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define POLKIT_MATE_TYPE_LISTENER          (polkit_mate_listener_get_type())
+#define POLKIT_MATE_LISTENER(o)            (G_TYPE_CHECK_INSTANCE_CAST ((o), POLKIT_MATE_TYPE_LISTENER, PolkitMateListener))
+#define POLKIT_MATE_LISTENER_CLASS(k)      (G_TYPE_CHECK_CLASS_CAST((k), POLKIT_MATE_TYPE_LISTENER, PolkitMateListenerClass))
+#define POLKIT_MATE_LISTENER_GET_CLASS(o)  (G_TYPE_INSTANCE_GET_CLASS ((o), POLKIT_MATE_TYPE_LISTENER, PolkitMateListenerClass))
+#define POLKIT_MATE_IS_LISTENER(o)         (G_TYPE_CHECK_INSTANCE_TYPE ((o), POLKIT_MATE_TYPE_LISTENER))
+#define POLKIT_MATE_IS_LISTENER_CLASS(k)   (G_TYPE_CHECK_CLASS_TYPE ((k), POLKIT_MATE_TYPE_LISTENER))
+
+typedef struct _PolkitMateListener PolkitMateListener;
+typedef struct _PolkitMateListenerClass PolkitMateListenerClass;
+
+GType                 polkit_mate_listener_get_type   (void) G_GNUC_CONST;
+PolkitAgentListener  *polkit_mate_listener_new        (void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __POLKIT_MATE_LISTENER_H */
+
+ +
+ +
+ + diff --git a/2024-02-15-172653-3023-cppcheck@256d08c4a418_travis/2.html b/2024-02-15-172653-3023-cppcheck@256d08c4a418_travis/2.html new file mode 100644 index 0000000..bce6d3f --- /dev/null +++ b/2024-02-15-172653-3023-cppcheck@256d08c4a418_travis/2.html @@ -0,0 +1,2639 @@ + + + + + + Cppcheck - HTML report - mate-polkit + + + + + +
+ + + +
+
   1
+   2
+   3
+   4
+   5
+   6
+   7
+   8
+   9
+  10
+  11
+  12
+  13
+  14
+  15
+  16
+  17
+  18
+  19
+  20
+  21
+  22
+  23
+  24
+  25
+  26
+  27
+  28
+  29
+  30
+  31
+  32
+  33
+  34
+  35
+  36
+  37
+  38
+  39
+  40
+  41
+  42
+  43
+  44
+  45
+  46
+  47
+  48
+  49
+  50
+  51
+  52
+  53
+  54
+  55
+  56
+  57
+  58
+  59
+  60
+  61
+  62
+  63
+  64
+  65
+  66
+  67
+  68
+  69
+  70
+  71
+  72
+  73
+  74
+  75
+  76
+  77
+  78
+  79
+  80
+  81
+  82
+  83
+  84
+  85
+  86
+  87
+  88
+  89
+  90
+  91
+  92
+  93
+  94
+  95
+  96
+  97
+  98
+  99
+ 100
+ 101
+ 102
+ 103
+ 104
+ 105
+ 106
+ 107
+ 108
+ 109
+ 110
+ 111
+ 112
+ 113
+ 114
+ 115
+ 116
+ 117
+ 118
+ 119
+ 120
+ 121
+ 122
+ 123
+ 124
+ 125
+ 126
+ 127
+ 128
+ 129
+ 130
+ 131
+ 132
+ 133
+ 134
+ 135
+ 136
+ 137
+ 138
+ 139
+ 140
+ 141
+ 142
+ 143
+ 144
+ 145
+ 146
+ 147
+ 148
+ 149
+ 150
+ 151
+ 152
+ 153
+ 154
+ 155
+ 156
+ 157
+ 158
+ 159
+ 160
+ 161
+ 162
+ 163
+ 164
+ 165
+ 166
+ 167
+ 168
+ 169
+ 170
+ 171
+ 172
+ 173
+ 174
+ 175
+ 176
+ 177
+ 178
+ 179
+ 180
+ 181
+ 182
+ 183
+ 184
+ 185
+ 186
+ 187
+ 188
+ 189
+ 190
+ 191
+ 192
+ 193
+ 194
+ 195
+ 196
+ 197
+ 198
+ 199
+ 200
+ 201
+ 202
+ 203
+ 204
+ 205
+ 206
+ 207
+ 208
+ 209
+ 210
+ 211
+ 212
+ 213
+ 214
+ 215
+ 216
+ 217
+ 218
+ 219
+ 220
+ 221
+ 222
+ 223
+ 224
+ 225
+ 226
+ 227
+ 228
+ 229
+ 230
+ 231
+ 232
+ 233
+ 234
+ 235
+ 236
+ 237
+ 238
+ 239
+ 240
+ 241
+ 242
+ 243
+ 244
+ 245
+ 246
+ 247
+ 248
+ 249
+ 250
+ 251
+ 252
+ 253
+ 254
+ 255
+ 256
+ 257
+ 258
+ 259
+ 260
+ 261
+ 262
+ 263
+ 264
+ 265
+ 266
+ 267
+ 268
+ 269
+ 270
+ 271
+ 272
+ 273
+ 274
+ 275
+ 276
+ 277
+ 278
+ 279
+ 280
+ 281
+ 282
+ 283
+ 284
+ 285
+ 286
+ 287
+ 288
+ 289
+ 290
+ 291
+ 292
+ 293
+ 294
+ 295
+ 296
+ 297
+ 298
+ 299
+ 300
+ 301
+ 302
+ 303
+ 304
+ 305
+ 306
+ 307
+ 308
+ 309
+ 310
+ 311
+ 312
+ 313
+ 314
+ 315
+ 316
+ 317
+ 318
+ 319
+ 320
+ 321
+ 322
+ 323
+ 324
+ 325
+ 326
+ 327
+ 328
+ 329
+ 330
+ 331
+ 332
+ 333
+ 334
+ 335
+ 336
+ 337
+ 338
+ 339
+ 340
+ 341
+ 342
+ 343
+ 344
+ 345
+ 346
+ 347
+ 348
+ 349
+ 350
+ 351
+ 352
+ 353
+ 354
+ 355
+ 356
+ 357
+ 358
+ 359
+ 360
+ 361
+ 362
+ 363
+ 364
+ 365
+ 366
+ 367
+ 368
+ 369
+ 370
+ 371
+ 372
+ 373
+ 374
+ 375
+ 376
+ 377
+ 378
+ 379
+ 380
+ 381
+ 382
+ 383
+ 384
+ 385
+ 386
+ 387
+ 388
+ 389
+ 390
+ 391
+ 392
+ 393
+ 394
+ 395
+ 396
+ 397
+ 398
+ 399
+ 400
+ 401
+ 402
+ 403
+ 404
+ 405
+ 406
+ 407
+ 408
+ 409
+ 410
+ 411
+ 412
+ 413
+ 414
+ 415
+ 416
+ 417
+ 418
+ 419
+ 420
+ 421
+ 422
+ 423
+ 424
+ 425
+ 426
+ 427
+ 428
+ 429
+ 430
+ 431
+ 432
+ 433
+ 434
+ 435
+ 436
+ 437
+ 438
+ 439
+ 440
+ 441
+ 442
+ 443
+ 444
+ 445
+ 446
+ 447
+ 448
+ 449
+ 450
+ 451
+ 452
+ 453
+ 454
+ 455
+ 456
+ 457
+ 458
+ 459
+ 460
+ 461
+ 462
+ 463
+ 464
+ 465
+ 466
+ 467
+ 468
+ 469
+ 470
+ 471
+ 472
+ 473
+ 474
+ 475
+ 476
+ 477
+ 478
+ 479
+ 480
+ 481
+ 482
+ 483
+ 484
+ 485
+ 486
+ 487
+ 488
+ 489
+ 490
+ 491
+ 492
+ 493
+ 494
+ 495
+ 496
+ 497
+ 498
+ 499
+ 500
+ 501
+ 502
+ 503
+ 504
+ 505
+ 506
+ 507
+ 508
+ 509
+ 510
+ 511
+ 512
+ 513
+ 514
+ 515
+ 516
+ 517
+ 518
+ 519
+ 520
+ 521
+ 522
+ 523
+ 524
+ 525
+ 526
+ 527
+ 528
+ 529
+ 530
+ 531
+ 532
+ 533
+ 534
+ 535
+ 536
+ 537
+ 538
+ 539
+ 540
+ 541
+ 542
+ 543
+ 544
+ 545
+ 546
+ 547
+ 548
+ 549
+ 550
+ 551
+ 552
+ 553
+ 554
+ 555
+ 556
+ 557
+ 558
+ 559
+ 560
+ 561
+ 562
+ 563
+ 564
+ 565
+ 566
+ 567
+ 568
+ 569
+ 570
+ 571
+ 572
+ 573
+ 574
+ 575
+ 576
+ 577
+ 578
+ 579
+ 580
+ 581
+ 582
+ 583
+ 584
+ 585
+ 586
+ 587
+ 588
+ 589
+ 590
+ 591
+ 592
+ 593
+ 594
+ 595
+ 596
+ 597
+ 598
+ 599
+ 600
+ 601
+ 602
+ 603
+ 604
+ 605
+ 606
+ 607
+ 608
+ 609
+ 610
+ 611
+ 612
+ 613
+ 614
+ 615
+ 616
+ 617
+ 618
+ 619
+ 620
+ 621
+ 622
+ 623
+ 624
+ 625
+ 626
+ 627
+ 628
+ 629
+ 630
+ 631
+ 632
+ 633
+ 634
+ 635
+ 636
+ 637
+ 638
+ 639
+ 640
+ 641
+ 642
+ 643
+ 644
+ 645
+ 646
+ 647
+ 648
+ 649
+ 650
+ 651
+ 652
+ 653
+ 654
+ 655
+ 656
+ 657
+ 658
+ 659
+ 660
+ 661
+ 662
+ 663
+ 664
+ 665
+ 666
+ 667
+ 668
+ 669
+ 670
+ 671
+ 672
+ 673
+ 674
+ 675
+ 676
+ 677
+ 678
+ 679
+ 680
+ 681
+ 682
+ 683
+ 684
+ 685
+ 686
+ 687
+ 688
+ 689
+ 690
+ 691
+ 692
+ 693
+ 694
+ 695
+ 696
+ 697
+ 698
+ 699
+ 700
+ 701
+ 702
+ 703
+ 704
+ 705
+ 706
+ 707
+ 708
+ 709
+ 710
+ 711
+ 712
+ 713
+ 714
+ 715
+ 716
+ 717
+ 718
+ 719
+ 720
+ 721
+ 722
+ 723
+ 724
+ 725
+ 726
+ 727
+ 728
+ 729
+ 730
+ 731
+ 732
+ 733
+ 734
+ 735
+ 736
+ 737
+ 738
+ 739
+ 740
+ 741
+ 742
+ 743
+ 744
+ 745
+ 746
+ 747
+ 748
+ 749
+ 750
+ 751
+ 752
+ 753
+ 754
+ 755
+ 756
+ 757
+ 758
+ 759
+ 760
+ 761
+ 762
+ 763
+ 764
+ 765
+ 766
+ 767
+ 768
+ 769
+ 770
+ 771
+ 772
+ 773
+ 774
+ 775
+ 776
+ 777
+ 778
+ 779
+ 780
+ 781
+ 782
+ 783
+ 784
+ 785
+ 786
+ 787
+ 788
+ 789
+ 790
+ 791
+ 792
+ 793
+ 794
+ 795
+ 796
+ 797
+ 798
+ 799
+ 800
+ 801
+ 802
+ 803
+ 804
+ 805
+ 806
+ 807
+ 808
+ 809
+ 810
+ 811
+ 812
+ 813
+ 814
+ 815
+ 816
+ 817
+ 818
+ 819
+ 820
+ 821
+ 822
+ 823
+ 824
+ 825
+ 826
+ 827
+ 828
+ 829
+ 830
+ 831
+ 832
+ 833
+ 834
+ 835
+ 836
+ 837
+ 838
+ 839
+ 840
+ 841
+ 842
+ 843
+ 844
+ 845
+ 846
+ 847
+ 848
+ 849
+ 850
+ 851
+ 852
+ 853
+ 854
+ 855
+ 856
+ 857
+ 858
+ 859
+ 860
+ 861
+ 862
+ 863
+ 864
+ 865
+ 866
+ 867
+ 868
+ 869
+ 870
+ 871
+ 872
+ 873
+ 874
+ 875
+ 876
+ 877
+ 878
+ 879
+ 880
+ 881
+ 882
+ 883
+ 884
+ 885
+ 886
+ 887
+ 888
+ 889
+ 890
+ 891
+ 892
+ 893
+ 894
+ 895
+ 896
+ 897
+ 898
+ 899
+ 900
+ 901
+ 902
+ 903
+ 904
+ 905
+ 906
+ 907
+ 908
+ 909
+ 910
+ 911
+ 912
+ 913
+ 914
+ 915
+ 916
+ 917
+ 918
+ 919
+ 920
+ 921
+ 922
+ 923
+ 924
+ 925
+ 926
+ 927
+ 928
+ 929
+ 930
+ 931
+ 932
+ 933
+ 934
+ 935
+ 936
+ 937
+ 938
+ 939
+ 940
+ 941
+ 942
+ 943
+ 944
+ 945
+ 946
+ 947
+ 948
+ 949
+ 950
+ 951
+ 952
+ 953
+ 954
+ 955
+ 956
+ 957
+ 958
+ 959
+ 960
+ 961
+ 962
+ 963
+ 964
+ 965
+ 966
+ 967
+ 968
+ 969
+ 970
+ 971
+ 972
+ 973
+ 974
+ 975
+ 976
+ 977
+ 978
+ 979
+ 980
+ 981
+ 982
+ 983
+ 984
+ 985
+ 986
+ 987
+ 988
+ 989
+ 990
+ 991
+ 992
+ 993
+ 994
+ 995
+ 996
+ 997
+ 998
+ 999
+1000
+1001
+1002
+1003
+1004
+1005
+1006
+1007
+1008
+1009
+1010
+1011
+1012
+1013
+1014
+1015
+1016
+1017
+1018
+1019
+1020
+1021
+1022
+1023
+1024
+1025
+1026
+1027
+1028
+1029
+1030
+1031
+1032
+1033
+1034
+1035
+1036
+1037
+1038
+1039
+1040
+1041
+1042
+1043
+1044
+1045
+1046
+1047
+1048
+1049
+1050
+1051
+1052
+1053
+1054
+1055
+1056
+1057
+1058
+1059
+1060
+1061
+1062
+1063
+1064
+1065
+1066
+1067
+1068
+1069
+1070
+1071
+1072
+1073
+1074
+1075
+1076
+1077
+1078
+1079
+1080
+1081
+1082
+1083
+1084
+1085
+1086
+1087
+1088
+1089
+1090
+1091
+1092
+1093
+1094
+1095
+1096
+1097
+1098
+1099
+1100
+1101
+1102
+1103
+1104
+1105
+1106
+1107
+1108
+1109
+1110
+1111
+1112
+1113
+1114
+1115
+1116
+1117
+1118
+1119
+1120
+1121
+1122
+1123
+1124
+1125
+1126
+1127
+1128
+1129
+1130
+1131
+1132
+1133
+1134
+1135
+1136
+1137
+1138
+1139
+1140
+1141
+1142
+1143
+1144
+1145
+1146
+1147
+1148
+1149
+1150
+1151
+1152
+1153
+1154
+1155
+1156
+1157
+1158
+1159
+1160
+1161
+1162
+1163
+1164
+1165
+1166
+1167
+1168
+1169
+1170
+1171
+1172
+1173
+1174
+1175
+1176
+1177
+1178
+1179
+1180
+1181
+1182
+1183
+1184
+1185
+1186
+1187
+1188
+1189
+1190
+1191
+1192
+1193
+1194
+1195
+1196
+1197
+1198
+1199
+1200
+1201
/*
+ * Copyright (C) 2009 Red Hat, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ * Author: David Zeuthen <davidz@redhat.com>
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"<--- Include file: "config.h" not found.
+#endif
+
+#define _GNU_SOURCE
+#include <unistd.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/types.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/stat.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <fcntl.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <stdio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <stdlib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <pwd.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <errno.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <glib/gi18n-lib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "polkitmateauthenticationdialog.h"
+
+#define RESPONSE_USER_SELECTED 1001
+
+struct _PolkitMateAuthenticationDialogPrivate
+{
+  GtkWidget *user_combobox;
+  GtkWidget *prompt_label;
+  GtkWidget *password_entry;
+  GtkWidget *auth_button;
+  GtkWidget *cancel_button;
+  GtkWidget *info_label;
+  GtkWidget *grid_password;
+
+  gchar *message;
+  gchar *action_id;
+  gchar *vendor;
+  gchar *vendor_url;
+  gchar *icon_name;
+  PolkitDetails *details;
+
+  gchar **users;
+  gchar *selected_user;
+
+  gboolean is_running;
+
+  GtkListStore *store;
+};
+
+G_DEFINE_TYPE_WITH_PRIVATE (PolkitMateAuthenticationDialog, polkit_mate_authentication_dialog, GTK_TYPE_DIALOG);
+
+enum {
+  PROP_0,
+  PROP_ACTION_ID,
+  PROP_VENDOR,
+  PROP_VENDOR_URL,
+  PROP_ICON_NAME,
+  PROP_MESSAGE,
+  PROP_DETAILS,
+  PROP_USERS,
+  PROP_SELECTED_USER,
+};
+
+enum {
+  PIXBUF_COL,
+  TEXT_COL,
+  USERNAME_COL,
+  N_COL
+};
+
+static void
+user_combobox_set_sensitive (GtkCellLayout   *cell_layout,
+                             GtkCellRenderer *cell,
+                             GtkTreeModel    *tree_model,
+                             GtkTreeIter     *iter,
+                             gpointer         user_data)
+{
+  GtkTreePath *path;
+  gint *indices;<--- Variable 'indices' can be declared as pointer to const
+  gboolean sensitive;
+
+  path = gtk_tree_model_get_path (tree_model, iter);
+  indices = gtk_tree_path_get_indices (path);
+  if (indices[0] == 0)
+    sensitive = FALSE;
+  else
+    sensitive = TRUE;
+  gtk_tree_path_free (path);
+
+  g_object_set (cell, "sensitive", sensitive, NULL);
+}
+
+static void
+user_combobox_changed (GtkComboBox *widget,
+                       gpointer     user_data)
+{
+  PolkitMateAuthenticationDialog *dialog = POLKIT_MATE_AUTHENTICATION_DIALOG (user_data);
+  GtkTreeIter iter;
+  gchar *user_name;
+
+  if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (widget), &iter))
+    {
+      gtk_tree_model_get (GTK_TREE_MODEL (dialog->priv->store), &iter, USERNAME_COL, &user_name, -1);
+
+      g_free (dialog->priv->selected_user);
+      dialog->priv->selected_user = user_name;
+
+      g_object_notify (G_OBJECT (dialog), "selected-user");
+
+      gtk_dialog_response (GTK_DIALOG (dialog), RESPONSE_USER_SELECTED);
+
+      /* make the password entry and Authenticate button sensitive again */
+      gtk_widget_set_sensitive (dialog->priv->prompt_label, TRUE);
+      gtk_widget_set_sensitive (dialog->priv->password_entry, TRUE);
+      gtk_widget_set_sensitive (dialog->priv->auth_button, TRUE);
+    }
+}
+
+#if HAVE_ACCOUNTSSERVICE
+static GdkPixbuf *
+get_user_icon (char *username)
+{
+  GError *error;
+  GDBusConnection *connection;
+  GVariant *find_user_result;
+  GVariant *get_icon_result;
+  GVariant *icon_result_variant;
+  const gchar *user_path;
+  const gchar *icon_filename;
+  GdkPixbuf *pixbuf = NULL;
+
+  error = NULL;
+  connection = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
+
+  if (connection == NULL)
+    {
+      g_warning ("Unable to connect to system bus: %s", error->message);
+      g_error_free (error);
+      return NULL;
+    }
+
+  find_user_result = g_dbus_connection_call_sync (connection,
+                                          "org.freedesktop.Accounts",
+                                          "/org/freedesktop/Accounts",
+                                          "org.freedesktop.Accounts",
+                                          "FindUserByName",
+                                          g_variant_new ("(s)",
+                                          username),
+                                          G_VARIANT_TYPE ("(o)"),
+                                          G_DBUS_CALL_FLAGS_NONE,
+                                          -1,
+                                          NULL,
+                                          &error);
+
+  if (find_user_result == NULL)
+    {
+      g_warning ("Accounts couldn't find user: %s", error->message);
+      g_error_free (error);
+      return NULL;
+    }
+
+  user_path = g_variant_get_string (g_variant_get_child_value (find_user_result, 0),
+                                    NULL);
+
+  get_icon_result = g_dbus_connection_call_sync (connection,
+                                                 "org.freedesktop.Accounts",
+                                                 user_path,
+                                                 "org.freedesktop.DBus.Properties",
+                                                 "Get",
+                                                 g_variant_new ("(ss)",
+                                                                "org.freedesktop.Accounts.User",
+                                                                "IconFile"),
+                                                 G_VARIANT_TYPE ("(v)"),
+                                                 G_DBUS_CALL_FLAGS_NONE,
+                                                 -1,
+                                                 NULL,
+                                                 &error);
+
+  g_variant_unref (find_user_result);
+
+  if (get_icon_result == NULL)
+    {
+      g_warning ("Accounts couldn't find user icon: %s", error->message);
+      g_error_free (error);
+      return NULL;
+    }
+
+  g_variant_get_child (get_icon_result, 0, "v", &icon_result_variant);
+  icon_filename = g_variant_get_string (icon_result_variant, NULL);
+
+  if (icon_filename == NULL)
+    {
+      g_warning ("Accounts didn't return a valid filename for user icon");
+    }
+  else
+    {
+      /* TODO: we probably shouldn't hard-code the size to 16x16 */
+      pixbuf = gdk_pixbuf_new_from_file_at_size (icon_filename,
+                                                 16,
+                                                 16,
+                                                 &error);
+      if (pixbuf == NULL)
+        {
+          g_warning ("Couldn't open user icon: %s", error->message);
+          g_error_free (error);
+        }
+    }
+
+  g_variant_unref (icon_result_variant);
+  g_variant_unref (get_icon_result);
+
+  return pixbuf;
+}
+#else
+static GdkPixbuf *
+get_user_icon (char *username)
+{
+  GdkPixbuf *pixbuf = NULL;
+  struct passwd *passwd;
+
+  passwd = getpwnam (username);
+  if (passwd->pw_dir != NULL)
+    {
+      gchar *path;
+      path = g_strdup_printf ("%s/.face", passwd->pw_dir);
+      /* TODO: we probably shouldn't hard-code the size to 16x16 */
+      pixbuf = gdk_pixbuf_new_from_file_at_scale (path, 16, 16, TRUE, NULL);
+      g_free (path);
+    }
+
+  return pixbuf;
+}
+#endif /* HAVE_ACCOUNTSSERVICE */
+
+static void
+create_user_combobox (PolkitMateAuthenticationDialog *dialog)
+{
+  int n, i, selected_index = 0;
+  GtkComboBox *combo;
+  GtkTreeIter iter;
+  GtkCellRenderer *renderer;
+
+  /* if we've already built the list of admin users once, then avoid
+   * doing it again.. (this is mainly used when the user entered the
+   * wrong password and the dialog is recycled)
+   */
+  if (dialog->priv->store != NULL)
+    return;
+
+  combo = GTK_COMBO_BOX (dialog->priv->user_combobox);
+  dialog->priv->store = gtk_list_store_new (3, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING);
+
+  gtk_list_store_append (dialog->priv->store, &iter);
+  gtk_list_store_set (dialog->priv->store, &iter,
+                      PIXBUF_COL, NULL,
+                      TEXT_COL, _("Select user..."),
+                      USERNAME_COL, NULL,
+                      -1);
+
+  /* For each user */
+  for (i = 0, n = 0; dialog->priv->users[n] != NULL; n++)
+  {
+      gchar *gecos;
+      gchar *real_name;
+      GdkPixbuf *pixbuf = NULL;
+      struct passwd *passwd;
+
+      /* we're single threaded so this is fine */
+      errno = 0;
+      passwd = getpwnam (dialog->priv->users[n]);
+      if (passwd == NULL)
+        {
+          g_warning ("Error doing getpwnam(\"%s\"): %s", dialog->priv->users[n], strerror (errno));
+          continue;
+        }
+
+      if (passwd->pw_gecos != NULL)
+        gecos = g_locale_to_utf8 (passwd->pw_gecos, -1, NULL, NULL, NULL);
+      else
+        gecos = NULL;
+
+      if (gecos != NULL && strlen (gecos) > 0)
+        {
+          gchar *first_comma;
+          first_comma = strchr (gecos, ',');
+          if (first_comma != NULL)
+            *first_comma = '\0';
+        }
+      if (gecos != NULL && strlen (gecos) > 0 && strcmp (gecos, dialog->priv->users[n]) != 0)
+        real_name = g_strdup_printf (_("%s (%s)"), gecos, dialog->priv->users[n]);
+       else
+         real_name = g_strdup (dialog->priv->users[n]);
+      g_free (gecos);
+
+      /* Load users face */
+      pixbuf = get_user_icon (dialog->priv->users[n]);
+
+      /* fall back to stock_person icon */
+      if (pixbuf == NULL)
+        {
+          pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
+                                             "stock_person",
+                                             GTK_ICON_SIZE_MENU,
+                                             0,
+                                             NULL);
+        }
+
+      gtk_list_store_append (dialog->priv->store, &iter);
+      gtk_list_store_set (dialog->priv->store, &iter,
+                          PIXBUF_COL, pixbuf,
+                          TEXT_COL, real_name,
+                          USERNAME_COL, dialog->priv->users[n],
+                          -1);
+
+      i++;
+      if (passwd->pw_uid == getuid ())
+        {
+          selected_index = i;
+          g_free (dialog->priv->selected_user);
+          dialog->priv->selected_user = g_strdup (dialog->priv->users[n]);
+        }
+
+      g_free (real_name);
+      g_object_unref (pixbuf);
+    }
+
+  gtk_combo_box_set_model (combo, GTK_TREE_MODEL (dialog->priv->store));
+
+  renderer = gtk_cell_renderer_pixbuf_new ();
+  gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), renderer, FALSE);
+  gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo),
+                                  renderer,
+                                  "pixbuf", PIXBUF_COL,
+                                  NULL);
+  gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (combo),
+                                      renderer,
+                                      user_combobox_set_sensitive,
+                                      NULL, NULL);
+
+  renderer = gtk_cell_renderer_text_new ();
+  gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), renderer, TRUE);
+  gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo),
+                                  renderer,
+                                  "text", TEXT_COL,
+                                  NULL);
+  gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (combo),
+                                      renderer,
+                                      user_combobox_set_sensitive,
+                                      NULL, NULL);
+
+  /* Select the default user */
+  gtk_combo_box_set_active (GTK_COMBO_BOX (combo), selected_index);
+
+  /* Listen when a new user is selected */
+  g_signal_connect (GTK_WIDGET (combo),
+                    "changed",
+                    G_CALLBACK (user_combobox_changed),
+                    dialog);
+}
+
+static GtkWidget *
+get_image (PolkitMateAuthenticationDialog *dialog)
+{
+  GdkPixbuf *pixbuf;
+  GdkPixbuf *copy_pixbuf;
+  GdkPixbuf *vendor_pixbuf;
+  GtkWidget *image;
+
+  pixbuf = NULL;
+  copy_pixbuf = NULL;
+  vendor_pixbuf = NULL;
+  image = NULL;
+
+  if (dialog->priv->icon_name == NULL || strlen (dialog->priv->icon_name) == 0)
+    {
+      image = gtk_image_new_from_icon_name ("dialog-password", GTK_ICON_SIZE_DIALOG);
+      goto out;
+    }
+
+  vendor_pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
+                                            dialog->priv->icon_name,
+                                            48,
+                                            0,
+                                            NULL);
+  if (vendor_pixbuf == NULL)
+    {
+      g_warning ("No icon for themed icon with name '%s'", dialog->priv->icon_name);
+      image = gtk_image_new_from_icon_name ("dialog-password", GTK_ICON_SIZE_DIALOG);
+      goto out;
+    }
+
+  pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
+                                     "dialog-password",
+                                     48,
+                                     0,
+                                     NULL);
+  if (pixbuf == NULL)
+    goto out;
+
+  /* need to copy the pixbuf since we're modifying it */
+  copy_pixbuf = gdk_pixbuf_copy (pixbuf);
+  if (copy_pixbuf == NULL)
+    goto out;
+
+  /* blend the vendor icon in the bottom right quarter */
+  gdk_pixbuf_composite (vendor_pixbuf,
+                        copy_pixbuf,
+                        24, 24, 24, 24,
+                        24, 24, 0.5, 0.5,
+                        GDK_INTERP_BILINEAR,
+                        255);
+
+  image = gtk_image_new_from_pixbuf (copy_pixbuf);
+
+out:
+  if (pixbuf != NULL)
+    g_object_unref (pixbuf);
+
+  if (copy_pixbuf != NULL)
+    g_object_unref (copy_pixbuf);
+
+  if (vendor_pixbuf != NULL)
+    g_object_unref (vendor_pixbuf);
+
+  return image;
+}
+
+static void
+polkit_mate_authentication_dialog_set_property (GObject      *object,
+                                                 guint         prop_id,
+                                                 const GValue *value,
+                                                 GParamSpec   *pspec)
+{
+  PolkitMateAuthenticationDialog *dialog = POLKIT_MATE_AUTHENTICATION_DIALOG (object);
+
+  switch (prop_id)
+    {
+    case PROP_DETAILS:
+      dialog->priv->details = g_value_dup_object (value);
+      break;
+
+    case PROP_ACTION_ID:
+      dialog->priv->action_id = g_value_dup_string (value);
+      break;
+
+    case PROP_VENDOR:
+      dialog->priv->vendor = g_value_dup_string (value);
+      break;
+
+    case PROP_VENDOR_URL:
+      dialog->priv->vendor_url = g_value_dup_string (value);
+      break;
+
+    case PROP_ICON_NAME:
+      dialog->priv->icon_name = g_value_dup_string (value);
+      break;
+
+    case PROP_MESSAGE:
+      dialog->priv->message = g_value_dup_string (value);
+      break;
+
+    case PROP_USERS:
+      dialog->priv->users = g_value_dup_boxed (value);
+      break;
+
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+    }
+}
+
+static void
+polkit_mate_authentication_dialog_get_property (GObject    *object,
+                                                 guint       prop_id,
+                                                 GValue     *value,
+                                                 GParamSpec *pspec)
+{
+  PolkitMateAuthenticationDialog *dialog = POLKIT_MATE_AUTHENTICATION_DIALOG (object);
+
+  switch (prop_id)
+    {
+    case PROP_MESSAGE:
+      g_value_set_string (value, dialog->priv->message);
+      break;
+
+    /* TODO: rest of the properties */
+
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+    }
+}
+
+static GtkWidget *
+add_row (GtkWidget *grid, int row, const char *label_text, GtkWidget *entry)
+{
+  GtkWidget *label;
+
+  label = gtk_label_new_with_mnemonic (label_text);
+  gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
+  gtk_label_set_xalign (GTK_LABEL (label), 1.0);
+  gtk_label_set_yalign (GTK_LABEL (label), 0.5);
+
+  gtk_widget_set_hexpand (label, FALSE);
+  gtk_grid_attach (GTK_GRID (grid), label,
+                   0, row, 1, 1);
+  gtk_widget_set_hexpand (entry, TRUE);
+  gtk_grid_attach (GTK_GRID (grid), entry,
+                   1, row, 1, 1);
+  gtk_label_set_mnemonic_widget (GTK_LABEL (label), entry);
+
+  return label;
+}
+
+static void
+action_id_activated (GtkLabel *url_label, gpointer user_data)
+{
+#if 0
+  GError *error;
+  DBusGConnection *bus;
+  DBusGProxy *manager_proxy;
+
+  error = NULL;
+  bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
+  if (bus == NULL)
+    {
+      g_warning ("Couldn't connect to session bus: %s", error->message);
+      g_error_free (error);
+      goto out;
+    }
+
+  manager_proxy = dbus_g_proxy_new_for_name (bus,
+                                             "org.mate.PolicyKit.AuthorizationManager",
+                                             "/",
+                                             "org.mate.PolicyKit.AuthorizationManager.SingleInstance");
+  if (manager_proxy == NULL)
+    {
+      g_warning ("Could not construct manager_proxy object; bailing out");
+      goto out;
+    }
+
+  if (!dbus_g_proxy_call (manager_proxy,
+                          "ShowAction",
+                          &error,
+                          G_TYPE_STRING, gtk_label_get_current_uri (GTK_LABEL (url_label)),
+                          G_TYPE_INVALID,
+                          G_TYPE_INVALID))
+    {
+      if (error != NULL)
+        {
+          g_warning ("Failed to call into manager: %s", error->message);
+          g_error_free (error);
+        }
+      else
+        {
+          g_warning ("Failed to call into manager");
+        }
+      goto out;
+    }
+
+out:
+        ;
+#endif
+}
+
+static void
+polkit_mate_authentication_dialog_init (PolkitMateAuthenticationDialog *dialog)
+{
+  dialog->priv = polkit_mate_authentication_dialog_get_instance_private (dialog);
+}
+
+static void
+polkit_mate_authentication_dialog_finalize (GObject *object)
+{
+  PolkitMateAuthenticationDialog *dialog;
+
+  dialog = POLKIT_MATE_AUTHENTICATION_DIALOG (object);
+
+  g_free (dialog->priv->message);
+  g_free (dialog->priv->action_id);
+  g_free (dialog->priv->vendor);
+  g_free (dialog->priv->vendor_url);
+  g_free (dialog->priv->icon_name);
+  if (dialog->priv->details != NULL)
+    g_object_unref (dialog->priv->details);
+
+  g_strfreev (dialog->priv->users);
+  g_free (dialog->priv->selected_user);
+
+  if (dialog->priv->store != NULL)
+    g_object_unref (dialog->priv->store);
+
+  if (G_OBJECT_CLASS (polkit_mate_authentication_dialog_parent_class)->finalize != NULL)
+    G_OBJECT_CLASS (polkit_mate_authentication_dialog_parent_class)->finalize (object);
+}
+
+static GtkWidget*
+polkit_mate_dialog_add_button (GtkDialog   *dialog,
+                               const gchar *button_text,
+                               const gchar *icon_name,
+                                     gint   response_id)
+{
+  GtkWidget *button;
+
+  button = gtk_button_new_with_mnemonic (button_text);
+  gtk_button_set_image (GTK_BUTTON (button), gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_BUTTON));
+
+  gtk_button_set_use_underline (GTK_BUTTON (button), TRUE);
+  gtk_style_context_add_class (gtk_widget_get_style_context (button), "text-button");
+  gtk_widget_set_can_default (button, TRUE);
+  gtk_widget_show (button);
+  gtk_dialog_add_action_widget (GTK_DIALOG (dialog), button, response_id);
+
+  return button;
+}
+
+static void
+polkit_mate_authentication_dialog_constructed (GObject *object)
+{
+  PolkitMateAuthenticationDialog *dialog;
+  GtkWidget *hbox;
+  GtkWidget *main_vbox;
+  GtkWidget *vbox;
+  GtkWidget *grid_password;
+  GtkWidget *details_expander;
+  GtkWidget *details_vbox;
+  GtkWidget *grid;
+  GtkWidget *label;
+  GtkWidget *image;
+  GtkWidget *content_area;
+  gboolean have_user_combobox;
+  gchar *s;
+  guint rows;
+
+  dialog = POLKIT_MATE_AUTHENTICATION_DIALOG (object);
+
+  if (G_OBJECT_CLASS (polkit_mate_authentication_dialog_parent_class)->constructed != NULL)
+    G_OBJECT_CLASS (polkit_mate_authentication_dialog_parent_class)->constructed (object);
+
+  have_user_combobox = FALSE;
+
+  dialog->priv->cancel_button = polkit_mate_dialog_add_button (GTK_DIALOG (dialog),
+                                                               _("_Cancel"),
+                                                               "process-stop",
+                                                               GTK_RESPONSE_CANCEL);
+
+  dialog->priv->auth_button = gtk_dialog_add_button (GTK_DIALOG (dialog),
+                                                     _("_Authenticate"),
+                                                     GTK_RESPONSE_OK);
+
+  gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
+
+  content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
+
+  gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
+  gtk_box_set_spacing (GTK_BOX (content_area), 2); /* 2 * 5 + 2 = 12 */
+  gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
+  gtk_window_set_icon_name (GTK_WINDOW (dialog), "dialog-password");
+
+  hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
+  gtk_container_set_border_width (GTK_CONTAINER (hbox), 5);
+  gtk_box_pack_start (GTK_BOX (content_area), hbox, TRUE, TRUE, 0);
+
+  image = get_image (dialog);
+  gtk_widget_set_halign (image, GTK_ALIGN_CENTER);
+  gtk_widget_set_valign (image, GTK_ALIGN_START);
+  gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0);
+
+  main_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 10);
+  gtk_box_pack_start (GTK_BOX (hbox), main_vbox, TRUE, TRUE, 0);
+
+  /* main message */
+  label = gtk_label_new (NULL);
+  s = g_strdup_printf ("<big><b>%s</b></big>", dialog->priv->message);
+  gtk_label_set_markup (GTK_LABEL (label), s);
+  g_free (s);
+
+  gtk_label_set_xalign (GTK_LABEL (label), 0.0);
+  gtk_label_set_yalign (GTK_LABEL (label), 0.5);
+  gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
+  gtk_label_set_max_width_chars (GTK_LABEL (label), 50);
+  gtk_box_pack_start (GTK_BOX (main_vbox), label, FALSE, FALSE, 0);
+
+  /* secondary message */
+  label = gtk_label_new (NULL);
+  if (g_strv_length (dialog->priv->users) > 1)
+    {
+          gtk_label_set_markup (GTK_LABEL (label),
+                                _("An application is attempting to perform an action that requires privileges. "
+                                  "Authentication as one of the users below is required to perform this action."));
+    }
+  else
+    {
+      if (strcmp (g_get_user_name (), dialog->priv->users[0]) == 0)
+        {
+          gtk_label_set_markup (GTK_LABEL (label),
+                                _("An application is attempting to perform an action that requires privileges. "
+                                  "Authentication is required to perform this action."));
+        }
+      else
+        {
+          gtk_label_set_markup (GTK_LABEL (label),
+                                _("An application is attempting to perform an action that requires privileges. "
+                                  "Authentication as the super user is required to perform this action."));
+        }
+    }
+
+  gtk_label_set_xalign (GTK_LABEL (label), 0.0);
+  gtk_label_set_yalign (GTK_LABEL (label), 0.5);
+  gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
+  gtk_label_set_max_width_chars (GTK_LABEL (label), 50);
+  gtk_box_pack_start (GTK_BOX (main_vbox), label, FALSE, FALSE, 0);
+
+  /* user combobox */
+  if (g_strv_length (dialog->priv->users) > 1)
+    {
+      dialog->priv->user_combobox = gtk_combo_box_new ();
+      gtk_box_pack_start (GTK_BOX (main_vbox), GTK_WIDGET (dialog->priv->user_combobox), FALSE, FALSE, 0);
+
+      create_user_combobox (dialog);
+
+      have_user_combobox = TRUE;
+    }
+  else
+    {
+      dialog->priv->selected_user = g_strdup (dialog->priv->users[0]);
+    }
+
+  /* password entry */
+  vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
+  gtk_box_pack_start (GTK_BOX (main_vbox), vbox, FALSE, FALSE, 0);
+
+  grid_password = gtk_grid_new ();
+  gtk_grid_set_column_spacing (GTK_GRID (grid_password), 12);
+  gtk_grid_set_row_spacing (GTK_GRID (grid_password), 6);
+  gtk_box_pack_start (GTK_BOX (vbox), grid_password, FALSE, FALSE, 0);
+  dialog->priv->password_entry = gtk_entry_new ();
+  gtk_entry_set_visibility (GTK_ENTRY (dialog->priv->password_entry), FALSE);
+  dialog->priv->prompt_label = add_row (grid_password, 0, _("_Password:"), dialog->priv->password_entry);
+
+  g_signal_connect_swapped (dialog->priv->password_entry, "activate",
+                            G_CALLBACK (gtk_window_activate_default),
+                            dialog);
+
+  dialog->priv->grid_password = grid_password;
+  /* initially never show the password entry stuff; we'll toggle it on/off so it's
+   * only shown when prompting for a password */
+  gtk_widget_set_no_show_all (dialog->priv->grid_password, TRUE);
+
+  /* A label for showing PAM_TEXT_INFO and PAM_TEXT_ERROR messages */
+  label = gtk_label_new (NULL);
+  gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
+  gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
+  dialog->priv->info_label = label;
+
+  /* Details */
+  details_expander = gtk_expander_new_with_mnemonic (_("<small><b>_Details</b></small>"));
+  gtk_expander_set_use_markup (GTK_EXPANDER (details_expander), TRUE);
+  gtk_box_pack_start (GTK_BOX (content_area), details_expander, FALSE, FALSE, 0);
+
+  details_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 10);
+  gtk_container_add (GTK_CONTAINER (details_expander), details_vbox);
+
+  grid = gtk_grid_new ();
+  gtk_widget_set_margin_start (grid, 20);
+  gtk_grid_set_column_spacing (GTK_GRID (grid), 12);
+  gtk_grid_set_row_spacing (GTK_GRID (grid), 6);
+  gtk_box_pack_start (GTK_BOX (details_vbox), grid, FALSE, FALSE, 0);
+
+  /* TODO: sort keys? */
+  rows = 0;
+  if (dialog->priv->details != NULL)
+    {
+      guint n;
+      gchar **keys;
+
+      keys = polkit_details_get_keys (dialog->priv->details);
+      for (n = 0; keys[n] != NULL; n++)
+        {
+          const gchar *key = keys[n];
+          const gchar *value;
+
+          value = polkit_details_lookup (dialog->priv->details, key);
+
+          label = gtk_label_new (NULL);
+          s = g_strdup_printf ("<small>%s</small>", value);
+          gtk_label_set_markup (GTK_LABEL (label), s);
+          g_free (s);
+
+          gtk_label_set_xalign (GTK_LABEL (label), 0.0);
+          gtk_label_set_yalign (GTK_LABEL (label), 1.0);
+
+          s = g_strdup_printf ("<small><b>%s:</b></small>", key);
+          add_row (grid, rows, s, label);
+          g_free (s);
+
+          rows++;
+        }
+      g_strfreev (keys);
+    }
+
+  /* --- */
+
+  label = gtk_label_new (NULL);
+  gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
+  s = g_strdup_printf ("<small><a href=\"%s\">%s</a></small>",
+                       dialog->priv->action_id,
+                       dialog->priv->action_id);
+  gtk_label_set_markup (GTK_LABEL (label), s);
+  g_free (s);
+
+  gtk_label_set_xalign (GTK_LABEL (label), 0.0);
+  gtk_label_set_yalign (GTK_LABEL (label), 1.0);
+
+  add_row (grid, rows++, _("<small><b>Action:</b></small>"), label);
+  g_signal_connect (label, "activate-link", G_CALLBACK (action_id_activated), NULL);
+
+  s = g_strdup_printf (_("Click to edit %s"), dialog->priv->action_id);
+  gtk_widget_set_tooltip_markup (label, s);
+  g_free (s);
+
+  /* --- */
+
+  label = gtk_label_new (NULL);
+  gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
+  s = g_strdup_printf ("<small><a href=\"%s\">%s</a></small>",
+                       dialog->priv->vendor_url,
+                       dialog->priv->vendor);
+  gtk_label_set_markup (GTK_LABEL (label), s);
+  g_free (s);
+
+  gtk_label_set_xalign (GTK_LABEL (label), 0.0);
+  gtk_label_set_yalign (GTK_LABEL (label), 1.0);
+
+  add_row (grid, rows++, _("<small><b>Vendor:</b></small>"), label);
+
+  s = g_strdup_printf (_("Click to open %s"), dialog->priv->vendor_url);
+  gtk_widget_set_tooltip_markup (label, s);
+  g_free (s);
+
+  /* Disable password entry and authenticate until have a user selected */
+  if (have_user_combobox && gtk_combo_box_get_active (GTK_COMBO_BOX (dialog->priv->user_combobox)) == 0)
+    {
+      gtk_widget_set_sensitive (dialog->priv->prompt_label, FALSE);
+      gtk_widget_set_sensitive (dialog->priv->password_entry, FALSE);
+      gtk_widget_set_sensitive (dialog->priv->auth_button, FALSE);
+    }
+
+  gtk_widget_realize (GTK_WIDGET (dialog));
+
+}
+
+static void
+polkit_mate_authentication_dialog_class_init (PolkitMateAuthenticationDialogClass *klass)
+{
+  GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+
+  gobject_class->finalize = polkit_mate_authentication_dialog_finalize;
+  gobject_class->get_property = polkit_mate_authentication_dialog_get_property;
+  gobject_class->set_property = polkit_mate_authentication_dialog_set_property;
+  gobject_class->constructed  = polkit_mate_authentication_dialog_constructed;
+
+  g_object_class_install_property (gobject_class,
+                                   PROP_DETAILS,
+                                   g_param_spec_object ("details",
+                                                        NULL,
+                                                        NULL,
+                                                        POLKIT_TYPE_DETAILS,
+                                                        G_PARAM_READWRITE |
+                                                        G_PARAM_CONSTRUCT_ONLY |
+                                                        G_PARAM_STATIC_NAME |
+                                                        G_PARAM_STATIC_NICK |
+                                                        G_PARAM_STATIC_BLURB));
+
+  g_object_class_install_property (gobject_class,
+                                   PROP_ACTION_ID,
+                                   g_param_spec_string ("action-id",
+                                                        NULL,
+                                                        NULL,
+                                                        NULL,
+                                                        G_PARAM_READWRITE |
+                                                        G_PARAM_CONSTRUCT_ONLY |
+                                                        G_PARAM_STATIC_NAME |
+                                                        G_PARAM_STATIC_NICK |
+                                                        G_PARAM_STATIC_BLURB));
+
+  g_object_class_install_property (gobject_class,
+                                   PROP_VENDOR,
+                                   g_param_spec_string ("vendor",
+                                                        NULL,
+                                                        NULL,
+                                                        NULL,
+                                                        G_PARAM_READWRITE |
+                                                        G_PARAM_CONSTRUCT_ONLY |
+                                                        G_PARAM_STATIC_NAME |
+                                                        G_PARAM_STATIC_NICK |
+                                                        G_PARAM_STATIC_BLURB));
+
+  g_object_class_install_property (gobject_class,
+                                   PROP_VENDOR_URL,
+                                   g_param_spec_string ("vendor-url",
+                                                        NULL,
+                                                        NULL,
+                                                        NULL,
+                                                        G_PARAM_READWRITE |
+                                                        G_PARAM_CONSTRUCT_ONLY |
+                                                        G_PARAM_STATIC_NAME |
+                                                        G_PARAM_STATIC_NICK |
+                                                        G_PARAM_STATIC_BLURB));
+
+  g_object_class_install_property (gobject_class,
+                                   PROP_ICON_NAME,
+                                   g_param_spec_string ("icon-name",
+                                                        NULL,
+                                                        NULL,
+                                                        NULL,
+                                                        G_PARAM_READWRITE |
+                                                        G_PARAM_CONSTRUCT_ONLY |
+                                                        G_PARAM_STATIC_NAME |
+                                                        G_PARAM_STATIC_NICK |
+                                                        G_PARAM_STATIC_BLURB));
+
+  g_object_class_install_property (gobject_class,
+                                   PROP_MESSAGE,
+                                   g_param_spec_string ("message",
+                                                        NULL,
+                                                        NULL,
+                                                        NULL,
+                                                        G_PARAM_READWRITE |
+                                                        G_PARAM_CONSTRUCT_ONLY |
+                                                        G_PARAM_STATIC_NAME |
+                                                        G_PARAM_STATIC_NICK |
+                                                        G_PARAM_STATIC_BLURB));
+
+  g_object_class_install_property (gobject_class,
+                                   PROP_USERS,
+                                   g_param_spec_boxed ("users",
+                                                       NULL,
+                                                       NULL,
+                                                       G_TYPE_STRV,
+                                                       G_PARAM_READWRITE |
+                                                       G_PARAM_CONSTRUCT_ONLY |
+                                                       G_PARAM_STATIC_NAME |
+                                                       G_PARAM_STATIC_NICK |
+                                                       G_PARAM_STATIC_BLURB));
+
+  g_object_class_install_property (gobject_class,
+                                   PROP_SELECTED_USER,
+                                   g_param_spec_string ("selected-user",
+                                                        NULL,
+                                                        NULL,
+                                                        NULL,
+                                                        G_PARAM_READABLE |
+                                                        G_PARAM_STATIC_NAME |
+                                                        G_PARAM_STATIC_NICK |
+                                                        G_PARAM_STATIC_BLURB));
+}
+
+/**
+ * polkit_mate_authentication_dialog_new:
+ *
+ * Yada yada yada...
+ *
+ * Returns: A new password dialog.
+ **/
+GtkWidget *
+polkit_mate_authentication_dialog_new (const gchar    *action_id,
+                                        const gchar    *vendor,
+                                        const gchar    *vendor_url,
+                                        const gchar    *icon_name,
+                                        const gchar    *message_markup,
+                                        PolkitDetails  *details,
+                                        gchar         **users)
+{
+  PolkitMateAuthenticationDialog *dialog;
+  GtkWindow *window;
+
+  dialog = g_object_new (POLKIT_MATE_TYPE_AUTHENTICATION_DIALOG,
+                         "action-id", action_id,
+                         "vendor", vendor,
+                         "vendor-url", vendor_url,
+                         "icon-name", icon_name,
+                         "message", message_markup,
+                         "details", details,
+                         "users", users,
+                         NULL);
+
+  window = GTK_WINDOW (dialog);
+
+  gtk_window_set_position (window, GTK_WIN_POS_CENTER);
+  gtk_window_set_modal (window, TRUE);
+  gtk_window_set_resizable (window, FALSE);
+  gtk_window_set_keep_above (window, TRUE);
+  gtk_window_set_title (window, _("Authenticate"));
+  g_signal_connect (dialog, "close", G_CALLBACK (gtk_widget_hide), NULL);
+
+  return GTK_WIDGET (dialog);
+}
+
+/**
+ * polkit_mate_authentication_dialog_indicate_error:
+ * @dialog: the auth dialog
+ *
+ * Call this function to indicate an authentication error; typically shakes the window
+ **/
+void
+polkit_mate_authentication_dialog_indicate_error (PolkitMateAuthenticationDialog *dialog)
+{
+  int x, y;
+  int n;
+  int diff;
+
+  /* TODO: detect compositing manager and do fancy stuff here */
+
+  gtk_window_get_position (GTK_WINDOW (dialog), &x, &y);
+
+  for (n = 0; n < 10; n++)
+    {
+      if (n % 2 == 0)
+        diff = -15;
+      else
+        diff = 15;
+
+      gtk_window_move (GTK_WINDOW (dialog), x + diff, y);
+
+      while (gtk_events_pending ())
+        {
+          gtk_main_iteration ();
+        }
+
+      g_usleep (10000);
+    }
+
+  gtk_window_move (GTK_WINDOW (dialog), x, y);
+}
+
+/**
+ * polkit_mate_authentication_dialog_run_until_user_is_selected:
+ * @dialog: A #PolkitMateAuthenticationDialog.
+ *
+ * Runs @dialog in a recursive main loop until a user have been selected.
+ *
+ * If there is only one element in the the users array (which is set upon construction) or
+ * an user has already been selected, this function returns immediately with the return
+ * value %TRUE.
+ *
+ * Returns: %TRUE if a user is selected (use polkit_mate_dialog_get_selected_user() to obtain the user) or
+ *          %FALSE if the dialog was cancelled.
+ **/
+gboolean
+polkit_mate_authentication_dialog_run_until_user_is_selected (PolkitMateAuthenticationDialog *dialog)
+{
+  gboolean ret;
+  gint response;
+
+  ret = FALSE;
+
+  if (dialog->priv->selected_user != NULL)
+    {
+      ret = TRUE;
+      goto out;
+    }
+
+  dialog->priv->is_running = TRUE;
+
+  response = gtk_dialog_run (GTK_DIALOG (dialog));
+
+  dialog->priv->is_running = FALSE;
+
+  if (response == RESPONSE_USER_SELECTED)
+    ret = TRUE;
+
+ out:
+  return ret;
+}
+
+/**
+ * polkit_mate_authentication_dialog_run_until_response_for_prompt:
+ * @dialog: A #PolkitMateAuthenticationDialog.
+ * @prompt: The prompt to present the user with.
+ * @echo_chars: Whether characters should be echoed in the password entry box.
+ * @was_cancelled: Set to %TRUE if the dialog was cancelled.
+ * @new_user_selected: Set to %TRUE if another user was selected.
+ *
+ * Runs @dialog in a recursive main loop until a response to @prompt have been obtained from the user.
+ *
+ * Returns: The response (free with g_free()) or %NULL if one of @was_cancelled or @new_user_selected
+ *          has been set to %TRUE.
+ **/
+gchar *
+polkit_mate_authentication_dialog_run_until_response_for_prompt (PolkitMateAuthenticationDialog *dialog,
+                                                                  const gchar           *prompt,
+                                                                  gboolean               echo_chars,
+                                                                  gboolean              *was_cancelled,
+                                                                  gboolean              *new_user_selected)
+{
+  gint response;
+  gchar *ret;
+
+  gtk_label_set_text_with_mnemonic (GTK_LABEL (dialog->priv->prompt_label), prompt);
+  gtk_entry_set_visibility (GTK_ENTRY (dialog->priv->password_entry), echo_chars);
+  gtk_entry_set_text (GTK_ENTRY (dialog->priv->password_entry), "");
+  gtk_widget_grab_focus (dialog->priv->password_entry);
+
+  ret = NULL;
+
+  if (was_cancelled != NULL)
+    *was_cancelled = FALSE;
+
+  if (new_user_selected != NULL)
+    *new_user_selected = FALSE;
+
+  dialog->priv->is_running = TRUE;
+
+  gtk_widget_set_no_show_all (dialog->priv->grid_password, FALSE);
+  gtk_widget_show_all (dialog->priv->grid_password);
+
+  response = gtk_dialog_run (GTK_DIALOG (dialog));
+
+  gtk_widget_hide (dialog->priv->grid_password);
+  gtk_widget_set_no_show_all (dialog->priv->grid_password, TRUE);
+
+  dialog->priv->is_running = FALSE;
+
+  if (response == GTK_RESPONSE_OK)
+    {
+      ret = g_strdup (gtk_entry_get_text (GTK_ENTRY (dialog->priv->password_entry)));
+    }
+  else if (response == RESPONSE_USER_SELECTED)
+    {
+      if (new_user_selected != NULL)
+        *new_user_selected = TRUE;
+    }
+  else
+    {
+      if (was_cancelled != NULL)
+        *was_cancelled = TRUE;
+    }
+
+  return ret;
+}
+
+/**
+ * polkit_mate_authentication_dialog_get_selected_user:
+ * @dialog: A #PolkitMateAuthenticationDialog.
+ *
+ * Gets the currently selected user.
+ *
+ * Returns: The currently selected user (free with g_free()) or %NULL if no user is currently selected.
+ **/
+gchar *
+polkit_mate_authentication_dialog_get_selected_user (PolkitMateAuthenticationDialog *dialog)
+{
+  return g_strdup (dialog->priv->selected_user);
+}
+
+void
+polkit_mate_authentication_dialog_set_info_message (PolkitMateAuthenticationDialog *dialog,
+                                                     const gchar                     *info_markup)
+{
+  gtk_label_set_markup (GTK_LABEL (dialog->priv->info_label), info_markup);
+}
+
+/**
+ * polkit_mate_authentication_dialog_cancel:
+ * @dialog: A #PolkitMateAuthenticationDialog.
+ *
+ * Cancels the dialog if it is currenlty running.
+ *
+ * Returns: %TRUE if the dialog was running.
+ **/
+gboolean
+polkit_mate_authentication_dialog_cancel (PolkitMateAuthenticationDialog *dialog)
+{
+  if (!dialog->priv->is_running)
+    return FALSE;
+
+  gtk_dialog_response (GTK_DIALOG (dialog), GTK_RESPONSE_CANCEL);
+
+  return TRUE;
+}
+
+ +
+ +
+ + diff --git a/2024-02-15-172653-3023-cppcheck@256d08c4a418_travis/3.html b/2024-02-15-172653-3023-cppcheck@256d08c4a418_travis/3.html new file mode 100644 index 0000000..6ad06dd --- /dev/null +++ b/2024-02-15-172653-3023-cppcheck@256d08c4a418_travis/3.html @@ -0,0 +1,393 @@ + + + + + + Cppcheck - HTML report - mate-polkit + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
+78
/*
+ * Copyright (C) 2009 Red Hat, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ * Author: David Zeuthen <davidz@redhat.com>
+ */
+
+#ifndef __POLKIT_MATE_AUTHENTICATION_DIALOG_H
+#define __POLKIT_MATE_AUTHENTICATION_DIALOG_H
+
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <polkit/polkit.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define POLKIT_MATE_TYPE_AUTHENTICATION_DIALOG            (polkit_mate_authentication_dialog_get_type ())
+#define POLKIT_MATE_AUTHENTICATION_DIALOG(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), POLKIT_MATE_TYPE_AUTHENTICATION_DIALOG, PolkitMateAuthenticationDialog))
+#define POLKIT_MATE_AUTHENTICATION_DIALOG_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), POLKIT_MATE_TYPE_AUTHENTICATION_DIALOG, PolkitMateAuthenticationDialogClass))
+#define POLKIT_MATE_IS_AUTHENTICATION_DIALOG(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), POLKIT_MATE_TYPE_AUTHENTICATION_DIALOG))
+#define POLKIT_MATE_IS_AUTHENTICATION_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), POLKIT_MATE_TYPE_AUTHENTICATION_DIALOG))
+
+typedef struct _PolkitMateAuthenticationDialog        PolkitMateAuthenticationDialog;
+typedef struct _PolkitMateAuthenticationDialogClass   PolkitMateAuthenticationDialogClass;
+typedef struct _PolkitMateAuthenticationDialogPrivate PolkitMateAuthenticationDialogPrivate;
+
+struct _PolkitMateAuthenticationDialog
+{
+  GtkDialog parent_instance;
+  PolkitMateAuthenticationDialogPrivate *priv;
+};
+
+struct _PolkitMateAuthenticationDialogClass
+{
+  GtkDialogClass parent_class;
+};
+
+GType      polkit_mate_authentication_dialog_get_type                      (void);
+GtkWidget *polkit_mate_authentication_dialog_new                           (const gchar    *action_id,
+                                                                             const gchar    *vendor,
+                                                                             const gchar    *vendor_url,
+                                                                             const gchar    *icon_name,
+                                                                             const gchar    *message_markup,
+                                                                             PolkitDetails  *details,
+                                                                             gchar         **users);
+gchar     *polkit_mate_authentication_dialog_get_selected_user             (PolkitMateAuthenticationDialog *dialog);
+gboolean   polkit_mate_authentication_dialog_run_until_user_is_selected    (PolkitMateAuthenticationDialog *dialog);
+gchar     *polkit_mate_authentication_dialog_run_until_response_for_prompt (PolkitMateAuthenticationDialog *dialog,
+                                                                             const gchar                     *prompt,
+                                                                             gboolean                         echo_chars,
+                                                                             gboolean                        *was_cancelled,
+                                                                             gboolean                        *new_user_selected);
+gboolean   polkit_mate_authentication_dialog_cancel                        (PolkitMateAuthenticationDialog *dialog);
+void       polkit_mate_authentication_dialog_indicate_error                (PolkitMateAuthenticationDialog *dialog);
+void       polkit_mate_authentication_dialog_set_info_message              (PolkitMateAuthenticationDialog *dialog,
+                                                                             const gchar                     *info_markup);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __POLKIT_MATE_AUTHENTICATION_DIALOG_H */
+
+ +
+ +
+ + diff --git a/2024-02-15-172653-3023-cppcheck@256d08c4a418_travis/4.html b/2024-02-15-172653-3023-cppcheck@256d08c4a418_travis/4.html new file mode 100644 index 0000000..67c8d37 --- /dev/null +++ b/2024-02-15-172653-3023-cppcheck@256d08c4a418_travis/4.html @@ -0,0 +1,1269 @@ + + + + + + Cppcheck - HTML report - mate-polkit + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
/*
+ * Copyright (C) 2009 Red Hat, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ * Author: David Zeuthen <davidz@redhat.com>
+ */
+
+#include "config.h"<--- Include file: "config.h" not found.
+
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/types.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <pwd.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gdk/gdkx.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <polkit/polkit.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <polkitagent/polkitagent.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "polkitmateauthenticator.h"
+#include "polkitmateauthenticationdialog.h"
+
+struct _PolkitMateAuthenticator
+{
+  GObject parent_instance;
+
+  PolkitAuthority *authority;
+  gchar *action_id;
+  gchar *message;
+  gchar *icon_name;
+  PolkitDetails *details;
+  gchar *cookie;
+  GList *identities;
+
+  PolkitActionDescription *action_desc;
+  gchar **users;
+
+  gboolean gained_authorization;
+  gboolean was_cancelled;
+  gboolean new_user_selected;
+  gchar *selected_user;
+
+  PolkitAgentSession *session;
+  GtkWidget *dialog;
+  GMainLoop *loop;
+};
+
+struct _PolkitMateAuthenticatorClass
+{
+  GObjectClass parent_class;
+
+};
+
+enum
+{
+  COMPLETED_SIGNAL,
+  LAST_SIGNAL,
+};
+
+static guint signals[LAST_SIGNAL] = {0};
+
+G_DEFINE_TYPE (PolkitMateAuthenticator, polkit_mate_authenticator, G_TYPE_OBJECT);
+
+static void
+polkit_mate_authenticator_init (PolkitMateAuthenticator *authenticator)
+{
+}
+
+static void
+polkit_mate_authenticator_finalize (GObject *object)
+{
+  PolkitMateAuthenticator *authenticator;
+
+  authenticator = POLKIT_MATE_AUTHENTICATOR (object);
+
+  if (authenticator->authority != NULL)
+    g_object_unref (authenticator->authority);
+  g_free (authenticator->action_id);
+  g_free (authenticator->message);
+  g_free (authenticator->icon_name);
+  if (authenticator->details != NULL)
+    g_object_unref (authenticator->details);
+  g_free (authenticator->cookie);
+  g_list_foreach (authenticator->identities, (GFunc) g_object_unref, NULL);
+  g_list_free (authenticator->identities);
+
+  if (authenticator->action_desc != NULL)
+    g_object_unref (authenticator->action_desc);
+  g_strfreev (authenticator->users);
+
+  g_free (authenticator->selected_user);
+  if (authenticator->session != NULL)
+    g_object_unref (authenticator->session);
+  if (authenticator->dialog != NULL)
+    gtk_widget_destroy (authenticator->dialog);
+  if (authenticator->loop != NULL)
+    g_main_loop_unref (authenticator->loop);
+
+  if (G_OBJECT_CLASS (polkit_mate_authenticator_parent_class)->finalize != NULL)
+    G_OBJECT_CLASS (polkit_mate_authenticator_parent_class)->finalize (object);
+}
+
+static void
+polkit_mate_authenticator_class_init (PolkitMateAuthenticatorClass *klass)
+{
+  GObjectClass *gobject_class;
+
+  gobject_class = G_OBJECT_CLASS (klass);
+
+  gobject_class->finalize = polkit_mate_authenticator_finalize;
+
+  /**
+   * PolkitMateAuthenticator::completed:
+   * @authenticator: A #PolkitMateAuthenticator.
+   * @gained_authorization: Whether the authorization was gained.
+   * @dismissed: Whether the dialog was dismissed.
+   *
+   * Emitted when the authentication is completed. The user is supposed to dispose of @authenticator
+   * upon receiving this signal.
+   **/
+  signals[COMPLETED_SIGNAL] = g_signal_new ("completed",
+                                            POLKIT_MATE_TYPE_AUTHENTICATOR,
+                                            G_SIGNAL_RUN_LAST,
+                                            0,                      /* class offset     */
+                                            NULL,                   /* accumulator      */
+                                            NULL,                   /* accumulator data */
+                                            g_cclosure_marshal_generic,
+                                            G_TYPE_NONE,
+                                            2,
+					    G_TYPE_BOOLEAN,
+                                            G_TYPE_BOOLEAN);
+}
+
+static PolkitActionDescription *
+get_desc_for_action (PolkitAuthority *authority,
+                     const gchar     *action_id)
+{
+  GList *action_descs;
+  GList *l;
+  PolkitActionDescription *result;
+
+  result = NULL;
+
+  action_descs = polkit_authority_enumerate_actions_sync (authority,
+                                                          NULL,
+                                                          NULL);
+  for (l = action_descs; l != NULL; l = l->next)
+    {
+      PolkitActionDescription *action_desc = POLKIT_ACTION_DESCRIPTION (l->data);
+
+      if (strcmp (polkit_action_description_get_action_id (action_desc), action_id) == 0)
+        {
+          result = g_object_ref (action_desc);
+          goto out;
+        }
+    }
+
+ out:
+
+  g_list_foreach (action_descs, (GFunc) g_object_unref, NULL);
+  g_list_free (action_descs);
+
+  return result;
+}
+
+static void
+on_dialog_deleted (GtkWidget *widget,
+                   GdkEvent  *event,
+                   gpointer   user_data)
+{
+  PolkitMateAuthenticator *authenticator = POLKIT_MATE_AUTHENTICATOR (user_data);
+
+  polkit_mate_authenticator_cancel (authenticator);
+}
+
+static void
+on_user_selected (GObject    *object,
+                  GParamSpec *pspec,
+                  gpointer    user_data)
+{
+  PolkitMateAuthenticator *authenticator = POLKIT_MATE_AUTHENTICATOR (user_data);
+
+  /* clear any previous messages */
+  polkit_mate_authentication_dialog_set_info_message (POLKIT_MATE_AUTHENTICATION_DIALOG (authenticator->dialog), "");
+
+  polkit_mate_authenticator_cancel (authenticator);
+  authenticator->new_user_selected = TRUE;
+}
+
+PolkitMateAuthenticator *
+polkit_mate_authenticator_new (const gchar     *action_id,
+                                const gchar     *message,
+                                const gchar     *icon_name,
+                                PolkitDetails   *details,
+                                const gchar     *cookie,
+                                GList           *identities)
+{
+  PolkitMateAuthenticator *authenticator;
+  GList *l;
+  guint n;
+  GError *error;
+
+  authenticator = POLKIT_MATE_AUTHENTICATOR (g_object_new (POLKIT_MATE_TYPE_AUTHENTICATOR, NULL));
+
+  error = NULL;
+  authenticator->authority = polkit_authority_get_sync (NULL /* GCancellable* */, &error);
+  if (authenticator->authority == NULL)
+    {
+      g_critical ("Error getting authority: %s", error->message);
+      g_error_free (error);
+      goto error;
+    }
+
+  authenticator->action_id = g_strdup (action_id);
+  authenticator->message = g_strdup (message);
+  authenticator->icon_name = g_strdup (icon_name);
+  if (details != NULL)
+    authenticator->details = g_object_ref (details);
+  authenticator->cookie = g_strdup (cookie);
+  authenticator->identities = g_list_copy (identities);
+  g_list_foreach (authenticator->identities, (GFunc) g_object_ref, NULL);
+
+  authenticator->action_desc = get_desc_for_action (authenticator->authority,
+                                                    authenticator->action_id);
+  if (authenticator->action_desc == NULL)
+    goto error;
+
+  authenticator->users = g_new0 (gchar *, g_list_length (authenticator->identities) + 1);
+  for (l = authenticator->identities, n = 0; l != NULL; l = l->next, n++)
+    {
+      PolkitUnixUser *user = POLKIT_UNIX_USER (l->data);
+      uid_t uid;
+      struct passwd *passwd;
+
+      uid = polkit_unix_user_get_uid (user);
+      passwd = getpwuid (uid);
+      authenticator->users[n] = g_strdup (passwd->pw_name);
+    }
+
+  authenticator->dialog = polkit_mate_authentication_dialog_new
+                            (authenticator->action_id,
+                             polkit_action_description_get_vendor_name (authenticator->action_desc),
+                             polkit_action_description_get_vendor_url (authenticator->action_desc),
+                             authenticator->icon_name,
+                             authenticator->message,
+                             authenticator->details,
+                             authenticator->users);
+  g_signal_connect (authenticator->dialog,
+                    "delete-event",
+                    G_CALLBACK (on_dialog_deleted),
+                    authenticator);
+  g_signal_connect (authenticator->dialog,
+                    "notify::selected-user",
+                    G_CALLBACK (on_user_selected),
+                    authenticator);
+
+  return authenticator;
+
+ error:
+  g_object_unref (authenticator);
+  return NULL;
+}
+
+static void
+session_request (PolkitAgentSession *session,
+                 const char         *request,
+                 gboolean            echo_on,
+                 gpointer            user_data)
+{
+  PolkitMateAuthenticator *authenticator = POLKIT_MATE_AUTHENTICATOR (user_data);
+  gchar *password;
+  gchar *modified_request;
+
+  password = NULL;
+
+  //g_debug ("in conversation_pam_prompt, request='%s', echo_on=%d", request, echo_on);
+
+  /* Fix up, and localize, password prompt if it's password auth */
+  if (g_ascii_strncasecmp (request, "password:", 9) == 0)
+    {
+      if (strcmp (g_get_user_name (), authenticator->selected_user) != 0)
+        {
+          modified_request = g_strdup_printf (_("_Password for %s:"), authenticator->selected_user);
+        }
+      else
+        {
+          modified_request = g_strdup (_("_Password:"));
+        }
+    }
+  else
+    {
+      modified_request = g_strdup (request);
+    }
+
+  gtk_widget_show_all (GTK_WIDGET (authenticator->dialog));
+  if (GDK_IS_X11_WINDOW (gtk_widget_get_window (GTK_WIDGET (authenticator->dialog))))
+    gtk_window_present_with_time (GTK_WINDOW (authenticator->dialog),
+                                  gdk_x11_get_server_time (gtk_widget_get_window (GTK_WIDGET (authenticator->dialog))));
+  else
+    gtk_window_present (GTK_WINDOW (authenticator->dialog));
+
+  password = polkit_mate_authentication_dialog_run_until_response_for_prompt (POLKIT_MATE_AUTHENTICATION_DIALOG (authenticator->dialog),
+                                                                               modified_request,
+                                                                               echo_on,
+                                                                               &authenticator->was_cancelled,
+                                                                               &authenticator->new_user_selected);
+
+  /* cancel auth unless user provided a password */
+  if (password == NULL)
+    {
+      polkit_mate_authenticator_cancel (authenticator);
+      goto out;
+    }
+  else
+    {
+      polkit_agent_session_response (authenticator->session, password);
+      g_free (password);
+    }
+
+out:
+  g_free (modified_request);
+}
+
+static void
+session_show_error (PolkitAgentSession *session,
+                    const gchar        *msg,
+                    gpointer            user_data)
+{
+  PolkitMateAuthenticator *authenticator = POLKIT_MATE_AUTHENTICATOR (user_data);
+  gchar *s;
+
+  s = g_strconcat ("<b>", msg, "</b>", NULL);
+  polkit_mate_authentication_dialog_set_info_message (POLKIT_MATE_AUTHENTICATION_DIALOG (authenticator->dialog), s);
+  g_free (s);
+}
+
+static void
+session_show_info (PolkitAgentSession *session,
+                   const gchar        *msg,
+                   gpointer            user_data)
+{
+  PolkitMateAuthenticator *authenticator = POLKIT_MATE_AUTHENTICATOR (user_data);
+  gchar *s;
+
+  s = g_strconcat ("<b>", msg, "</b>", NULL);
+  polkit_mate_authentication_dialog_set_info_message (POLKIT_MATE_AUTHENTICATION_DIALOG (authenticator->dialog), s);
+  g_free (s);
+
+  gtk_widget_show_all (GTK_WIDGET (authenticator->dialog));
+  gtk_window_present (GTK_WINDOW (authenticator->dialog));
+}
+
+static void
+session_completed (PolkitAgentSession *session,
+                   gboolean            gained_authorization,
+                   gpointer            user_data)
+{
+  PolkitMateAuthenticator *authenticator = POLKIT_MATE_AUTHENTICATOR (user_data);
+
+  authenticator->gained_authorization = gained_authorization;
+
+  //g_debug ("in conversation_done gained=%d", gained_authorization);
+
+  g_main_loop_quit (authenticator->loop);
+}
+
+static gboolean
+do_initiate (gpointer user_data)
+{
+  PolkitMateAuthenticator *authenticator = POLKIT_MATE_AUTHENTICATOR (user_data);
+  PolkitIdentity *identity;
+  gint num_tries;
+
+  gtk_widget_show_all (GTK_WIDGET (authenticator->dialog));
+  gtk_window_present (GTK_WINDOW (authenticator->dialog));
+  if (!polkit_mate_authentication_dialog_run_until_user_is_selected (POLKIT_MATE_AUTHENTICATION_DIALOG (authenticator->dialog)))
+    {
+      /* user cancelled the dialog */
+      /*g_debug ("User cancelled before selecting a user");*/
+      authenticator->was_cancelled = TRUE;
+      goto out;
+    }
+
+  authenticator->loop = g_main_loop_new (NULL, TRUE);
+
+  num_tries = 0;
+
+ try_again:
+
+  g_free (authenticator->selected_user);
+  authenticator->selected_user = polkit_mate_authentication_dialog_get_selected_user (POLKIT_MATE_AUTHENTICATION_DIALOG (authenticator->dialog));
+
+  /*g_debug ("Authenticating user %s", authenticator->selected_user);*/
+  identity = polkit_unix_user_new_for_name (authenticator->selected_user, NULL);
+
+  authenticator->session = polkit_agent_session_new (identity, authenticator->cookie);
+
+  g_object_unref (identity);
+
+  g_signal_connect (authenticator->session,
+                    "request",
+                    G_CALLBACK (session_request),
+                    authenticator);
+
+  g_signal_connect (authenticator->session,
+                    "show-info",
+                    G_CALLBACK (session_show_info),
+                    authenticator);
+
+  g_signal_connect (authenticator->session,
+                    "show-error",
+                    G_CALLBACK (session_show_error),
+                    authenticator);
+
+  g_signal_connect (authenticator->session,
+                    "completed",
+                    G_CALLBACK (session_completed),
+                    authenticator);
+
+  polkit_agent_session_initiate (authenticator->session);
+
+  g_main_loop_run (authenticator->loop);
+
+  /*g_debug ("gained_authorization=%d was_cancelled=%d new_user_selected=%d.",
+           authenticator->gained_authorization,
+           authenticator->was_cancelled,
+           authenticator->new_user_selected);*/
+
+  if (authenticator->new_user_selected)
+    {
+      /*g_debug ("New user selected");*/
+      authenticator->new_user_selected = FALSE;
+      g_object_unref (authenticator->session);
+      authenticator->session = NULL;
+      goto try_again;
+    }
+
+  num_tries++;
+
+  if (!authenticator->gained_authorization && !authenticator->was_cancelled)
+    {
+      if (authenticator->dialog != NULL)
+        {
+          gchar *s;
+
+          s = g_strconcat ("<b>", _("Your authentication attempt was unsuccessful. Please try again."), "</b>", NULL);
+          polkit_mate_authentication_dialog_set_info_message (
+                                  POLKIT_MATE_AUTHENTICATION_DIALOG (authenticator->dialog),
+                                  s);
+          g_free (s);
+          gtk_widget_queue_draw (authenticator->dialog);
+
+          /* shake the dialog to indicate error */
+          polkit_mate_authentication_dialog_indicate_error (POLKIT_MATE_AUTHENTICATION_DIALOG (authenticator->dialog));
+
+          if (num_tries < 3)
+            {
+              g_object_unref (authenticator->session);
+              authenticator->session = NULL;
+              goto try_again;
+            }
+        }
+    }
+
+ out:
+  g_signal_emit_by_name (authenticator,
+                         "completed",
+                         authenticator->gained_authorization,
+                         authenticator->was_cancelled);
+
+  g_object_unref (authenticator);
+
+  return FALSE;
+}
+
+void
+polkit_mate_authenticator_initiate (PolkitMateAuthenticator *authenticator)
+{
+  /* run from idle since we're going to block the main loop in the dialog (which has a recursive mainloop) */
+  g_idle_add (do_initiate, g_object_ref (authenticator));
+}
+
+void
+polkit_mate_authenticator_cancel (PolkitMateAuthenticator *authenticator)
+{
+  if (authenticator->dialog != NULL)
+    polkit_mate_authentication_dialog_cancel (POLKIT_MATE_AUTHENTICATION_DIALOG (authenticator->dialog));
+
+  authenticator->was_cancelled = TRUE;
+
+  if (authenticator->session != NULL)
+    {
+      polkit_agent_session_cancel (authenticator->session);
+    }
+}
+
+const gchar *
+polkit_mate_authenticator_get_cookie (PolkitMateAuthenticator *authenticator)<--- Parameter 'authenticator' can be declared as pointer to const
+{
+  return authenticator->cookie;
+}
+
+
+ +
+ +
+ + diff --git a/2024-02-15-172653-3023-cppcheck@256d08c4a418_travis/5.html b/2024-02-15-172653-3023-cppcheck@256d08c4a418_travis/5.html new file mode 100644 index 0000000..b1c66d2 --- /dev/null +++ b/2024-02-15-172653-3023-cppcheck@256d08c4a418_travis/5.html @@ -0,0 +1,351 @@ + + + + + + Cppcheck - HTML report - mate-polkit + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
/*
+ * Copyright (C) 2009 Red Hat, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ * Author: David Zeuthen <davidz@redhat.com>
+ */
+
+#ifndef __POLKIT_MATE_AUTHENTICATOR_H
+#define __POLKIT_MATE_AUTHENTICATOR_H
+
+#include <glib-object.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define POLKIT_MATE_TYPE_AUTHENTICATOR          (polkit_mate_authenticator_get_type())
+#define POLKIT_MATE_AUTHENTICATOR(o)            (G_TYPE_CHECK_INSTANCE_CAST ((o), POLKIT_MATE_TYPE_AUTHENTICATOR, PolkitMateAuthenticator))
+#define POLKIT_MATE_AUTHENTICATOR_CLASS(k)      (G_TYPE_CHECK_CLASS_CAST((k), POLKIT_MATE_TYPE_AUTHENTICATOR, PolkitMateAuthenticatorClass))
+#define POLKIT_MATE_AUTHENTICATOR_GET_CLASS(o)  (G_TYPE_INSTANCE_GET_CLASS ((o), POLKIT_MATE_TYPE_AUTHENTICATOR, PolkitMateAuthenticatorClass))
+#define POLKIT_MATE_IS_AUTHENTICATOR(o)         (G_TYPE_CHECK_INSTANCE_TYPE ((o), POLKIT_MATE_TYPE_AUTHENTICATOR))
+#define POLKIT_MATE_IS_AUTHENTICATOR_CLASS(k)   (G_TYPE_CHECK_CLASS_TYPE ((k), POLKIT_MATE_TYPE_AUTHENTICATOR))
+
+typedef struct _PolkitMateAuthenticator PolkitMateAuthenticator;
+typedef struct _PolkitMateAuthenticatorClass PolkitMateAuthenticatorClass;
+
+GType                      polkit_mate_authenticator_get_type   (void) G_GNUC_CONST;
+PolkitMateAuthenticator  *polkit_mate_authenticator_new        (const gchar              *action_id,
+                                                                  const gchar              *message,
+                                                                  const gchar              *icon_name,
+                                                                  PolkitDetails            *details,
+                                                                  const gchar              *cookie,
+                                                                  GList                    *identities);
+void                       polkit_mate_authenticator_initiate   (PolkitMateAuthenticator *authenticator);
+void                       polkit_mate_authenticator_cancel     (PolkitMateAuthenticator *authenticator);
+const gchar               *polkit_mate_authenticator_get_cookie (PolkitMateAuthenticator *authenticator);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __POLKIT_MATE_AUTHENTICATOR_H */
+
+ +
+ +
+ + diff --git a/2024-02-15-172653-3023-cppcheck@256d08c4a418_travis/6.html b/2024-02-15-172653-3023-cppcheck@256d08c4a418_travis/6.html new file mode 100644 index 0000000..79a947d --- /dev/null +++ b/2024-02-15-172653-3023-cppcheck@256d08c4a418_travis/6.html @@ -0,0 +1,761 @@ + + + + + + Cppcheck - HTML report - mate-polkit + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
/*
+ * Copyright (C) 2009 Red Hat, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ * Author: David Zeuthen <davidz@redhat.com>
+ */
+
+#include "config.h"<--- Include file: "config.h" not found.
+
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "polkitmatelistener.h"
+#include "polkitmateauthenticator.h"
+
+struct _PolkitMateListener
+{
+  PolkitAgentListener parent_instance;
+
+  /* we support multiple authenticators - they are simply queued up */
+  GList *authenticators;
+
+  PolkitMateAuthenticator *active_authenticator;
+};
+
+struct _PolkitMateListenerClass
+{
+  PolkitAgentListenerClass parent_class;
+};
+
+static void polkit_mate_listener_initiate_authentication (PolkitAgentListener  *listener,
+                                                           const gchar          *action_id,
+                                                           const gchar          *message,
+                                                           const gchar          *icon_name,
+                                                           PolkitDetails        *details,
+                                                           const gchar          *cookie,
+                                                           GList                *identities,
+                                                           GCancellable         *cancellable,
+                                                           GAsyncReadyCallback   callback,
+                                                           gpointer              user_data);
+
+static gboolean polkit_mate_listener_initiate_authentication_finish (PolkitAgentListener  *listener,
+                                                                      GAsyncResult         *res,
+                                                                      GError              **error);
+
+G_DEFINE_TYPE (PolkitMateListener, polkit_mate_listener, POLKIT_AGENT_TYPE_LISTENER);
+
+static void
+polkit_mate_listener_init (PolkitMateListener *listener)
+{
+}
+
+static void
+polkit_mate_listener_finalize (GObject *object)
+{
+  if (G_OBJECT_CLASS (polkit_mate_listener_parent_class)->finalize != NULL)
+    G_OBJECT_CLASS (polkit_mate_listener_parent_class)->finalize (object);
+}
+
+static void
+polkit_mate_listener_class_init (PolkitMateListenerClass *klass)
+{
+  GObjectClass *gobject_class;
+  PolkitAgentListenerClass *listener_class;
+
+  gobject_class = G_OBJECT_CLASS (klass);
+  listener_class = POLKIT_AGENT_LISTENER_CLASS (klass);
+
+  gobject_class->finalize = polkit_mate_listener_finalize;
+
+  listener_class->initiate_authentication          = polkit_mate_listener_initiate_authentication;
+  listener_class->initiate_authentication_finish   = polkit_mate_listener_initiate_authentication_finish;
+}
+
+PolkitAgentListener *
+polkit_mate_listener_new (void)
+{
+  return POLKIT_AGENT_LISTENER (g_object_new (POLKIT_MATE_TYPE_LISTENER, NULL));
+}
+
+typedef struct
+{
+  PolkitMateListener *listener;
+  PolkitMateAuthenticator *authenticator;
+
+  GTask        *task;
+  GCancellable *cancellable;
+
+  gulong cancel_id;
+} AuthData;
+
+static AuthData *
+auth_data_new (PolkitMateListener *listener,
+               PolkitMateAuthenticator *authenticator,
+               GTask *task,
+               GCancellable *cancellable)
+{
+  AuthData *data;
+
+  data = g_new0 (AuthData, 1);
+  data->listener = g_object_ref (listener);
+  data->authenticator = g_object_ref (authenticator);
+  data->task = g_object_ref (task);
+  data->cancellable = g_object_ref (cancellable);
+  return data;
+}
+
+static void
+auth_data_free (AuthData *data)
+{
+  g_object_unref (data->listener);
+  g_object_unref (data->authenticator);
+  g_object_unref (data->task);
+  if (data->cancellable != NULL && data->cancel_id > 0)
+    g_signal_handler_disconnect (data->cancellable, data->cancel_id);
+  g_object_unref (data->cancellable);
+  g_free (data);
+}
+
+static void
+maybe_initiate_next_authenticator (PolkitMateListener *listener)
+{
+  if (listener->active_authenticator == NULL && listener->authenticators != NULL)
+    {
+      polkit_mate_authenticator_initiate (POLKIT_MATE_AUTHENTICATOR (listener->authenticators->data));
+      listener->active_authenticator = listener->authenticators->data;
+    }
+}
+
+static void
+authenticator_completed (PolkitMateAuthenticator *authenticator,
+                         gboolean                 gained_authorization,
+                         gboolean                 dismissed,
+                         gpointer                 user_data)
+{
+  AuthData *data = user_data;
+
+  data->listener->authenticators = g_list_remove (data->listener->authenticators, authenticator);
+  if (authenticator == data->listener->active_authenticator)
+    data->listener->active_authenticator = NULL;
+
+  g_object_unref (authenticator);
+
+  if (dismissed)
+    {
+      g_task_return_new_error (data->task,
+                               POLKIT_ERROR,
+                               POLKIT_ERROR_CANCELLED,
+                               _("Authentication dialog was dismissed by the user"));
+    }
+
+  g_task_return_boolean (data->task, TRUE);
+  g_object_unref (data->task);
+
+  maybe_initiate_next_authenticator (data->listener);
+
+  auth_data_free (data);
+}
+
+static void
+cancelled_cb (GCancellable *cancellable,
+              gpointer user_data)
+{
+  AuthData *data = user_data;
+
+  polkit_mate_authenticator_cancel (data->authenticator);
+}
+
+static void
+polkit_mate_listener_initiate_authentication (PolkitAgentListener  *agent_listener,
+                                               const gchar          *action_id,
+                                               const gchar          *message,
+                                               const gchar          *icon_name,
+                                               PolkitDetails        *details,
+                                               const gchar          *cookie,
+                                               GList                *identities,
+                                               GCancellable         *cancellable,
+                                               GAsyncReadyCallback   callback,
+                                               gpointer              user_data)
+{
+  PolkitMateListener *listener = POLKIT_MATE_LISTENER (agent_listener);
+  GTask *task;
+  PolkitMateAuthenticator *authenticator;
+  AuthData *data;
+
+  task = g_task_new (G_OBJECT (listener),
+                     NULL,
+                     callback,
+                     user_data);
+  g_task_set_source_tag (task,
+                         polkit_mate_listener_initiate_authentication);
+
+  authenticator = polkit_mate_authenticator_new (action_id,
+                                                  message,
+                                                  icon_name,
+                                                  details,
+                                                  cookie,
+                                                  identities);
+  if (authenticator == NULL)
+    {
+      g_task_return_new_error (task,
+                               POLKIT_ERROR,
+                               POLKIT_ERROR_FAILED,
+                               "Error creating authentication object");
+      g_object_unref (task);
+      goto out;
+    }
+
+  data = auth_data_new (listener, authenticator, task, cancellable);
+
+  g_signal_connect (authenticator,
+                    "completed",
+                    G_CALLBACK (authenticator_completed),
+                    data);
+
+  if (cancellable != NULL)
+    {
+      data->cancel_id = g_signal_connect (cancellable,
+                                          "cancelled",
+                                          G_CALLBACK (cancelled_cb),
+                                          data);
+    }
+
+  listener->authenticators = g_list_append (listener->authenticators, authenticator);
+
+  maybe_initiate_next_authenticator (listener);
+
+ out:
+  ;
+}
+
+static gboolean
+polkit_mate_listener_initiate_authentication_finish (PolkitAgentListener  *listener,
+                                                      GAsyncResult         *res,
+                                                      GError              **error)
+{
+  GTask *task = G_TASK (res);
+
+  g_warn_if_fail (g_task_get_source_tag (task) == polkit_mate_listener_initiate_authentication);
+
+  if (g_task_propagate_pointer (task, error) == NULL) {
+    return FALSE;
+  }
+
+  return TRUE;
+}
+
+
+ +
+ +
+ + diff --git a/2024-02-15-172653-3023-cppcheck@256d08c4a418_travis/index.html b/2024-02-15-172653-3023-cppcheck@256d08c4a418_travis/index.html new file mode 100644 index 0000000..35f12cd --- /dev/null +++ b/2024-02-15-172653-3023-cppcheck@256d08c4a418_travis/index.html @@ -0,0 +1,252 @@ + + + + + + Cppcheck - HTML report - mate-polkit + + + + + +
+ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
LineIdCWESeverityMessage
checkersReportinformationActive checkers: 106/592 (use --checkers-report=<filename> to see details)
src/main.c
23missingIncludeinformationInclude file: "config.h" not found.
26missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <gio/gio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
29missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
30missingIncludeSysteminformationInclude file: <polkitagent/polkitagent.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
33missingIncludeSysteminformationInclude file: <libayatana-appindicator/app-indicator.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
35missingIncludeSysteminformationInclude file: <libappindicator/app-indicator.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
226shadowVariable398styleLocal variable 'authority' shadows outer variable
316constParameterCallback398styleParameter 'signal_name' can be declared as pointer to const. However it seems that 'signal_cb' is a callback function, if 'signal_name' is declared with const you might also need to cast function pointer(s).
src/polkitmateauthenticationdialog.c
24missingIncludeinformationInclude file: "config.h" not found.
28missingIncludeSysteminformationInclude file: <unistd.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
29missingIncludeSysteminformationInclude file: <sys/types.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
30missingIncludeSysteminformationInclude file: <sys/stat.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
31missingIncludeSysteminformationInclude file: <fcntl.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
32missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
33missingIncludeSysteminformationInclude file: <stdio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
34missingIncludeSysteminformationInclude file: <stdlib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
35missingIncludeSysteminformationInclude file: <pwd.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
36missingIncludeSysteminformationInclude file: <errno.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
38missingIncludeSysteminformationInclude file: <glib/gi18n-lib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
39missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
99constVariablePointer398styleVariable 'indices' can be declared as pointer to const
src/polkitmateauthenticationdialog.h
26missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <polkit/polkit.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/polkitmateauthenticator.c
23missingIncludeinformationInclude file: "config.h" not found.
25missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <sys/types.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <pwd.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
29missingIncludeSysteminformationInclude file: <gdk/gdkx.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
31missingIncludeSysteminformationInclude file: <polkit/polkit.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
32missingIncludeSysteminformationInclude file: <polkitagent/polkitagent.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
512constParameterPointer398styleParameter 'authenticator' can be declared as pointer to const
src/polkitmateauthenticator.h
26missingIncludeSysteminformationInclude file: <glib-object.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/polkitmatelistener.c
23missingIncludeinformationInclude file: "config.h" not found.
25missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/polkitmatelistener.h
26missingIncludeSysteminformationInclude file: <polkitagent/polkitagent.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+ +
+ + diff --git a/2024-02-15-172653-3023-cppcheck@256d08c4a418_travis/stats.html b/2024-02-15-172653-3023-cppcheck@256d08c4a418_travis/stats.html new file mode 100644 index 0000000..5c5881a --- /dev/null +++ b/2024-02-15-172653-3023-cppcheck@256d08c4a418_travis/stats.html @@ -0,0 +1,178 @@ + + + + + + Cppcheck - HTML report - mate-polkit + + + + + +
+ + + +
+

Top 10 files for style severity, total findings: 4
+   2  src/main.c
+   1  src/polkitmateauthenticator.c
+   1  src/polkitmateauthenticationdialog.c
+

+

Top 10 files for information severity, total findings: 35
+   12  src/polkitmateauthenticationdialog.c
+   8   src/polkitmateauthenticator.c
+   8   src/main.c
+   3   src/polkitmatelistener.c
+   2   src/polkitmateauthenticationdialog.h
+   1   src/polkitmatelistener.h
+   1   src/polkitmateauthenticator.h
+

+ +
+ +
+ + diff --git a/2024-02-15-172653-3023-cppcheck@256d08c4a418_travis/style.css b/2024-02-15-172653-3023-cppcheck@256d08c4a418_travis/style.css new file mode 100644 index 0000000..3897bfa --- /dev/null +++ b/2024-02-15-172653-3023-cppcheck@256d08c4a418_travis/style.css @@ -0,0 +1,177 @@ + +body { + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif; + font-size: 13px; + line-height: 1.5; + height: 100%; + margin: 0; +} + +#wrapper { + position: fixed; + height: 100vh; + width: 100vw; + display: grid; + grid-template-rows: fit-content(8rem) auto fit-content(8rem); + grid-template-columns: fit-content(25%) 1fr; + grid-template-areas: + "header header" + "menu content" + "footer footer"; +} + +h1 { + margin: 0 0 8px -2px; + font-size: 175%; +} + +.header { + padding: 0 0 5px 15px; + grid-area: header; + border-bottom: thin solid #aaa; +} + +.footer { + grid-area: footer; + border-top: thin solid #aaa; + font-size: 85%; + +} + +.footer > p { + margin: 4px; +} + +#menu, +#menu_index { + grid-area: menu; + text-align: left; + overflow: auto; + padding: 0 23px 15px 15px; + border-right: thin solid #aaa; + min-width: 200px; +} + +#menu > a { + display: block; + margin-left: 10px; + font-size: 12px; +} + +#content, +#content_index { + grid-area: content; + padding: 0px 5px 15px 15px; + overflow: auto; +} + +label { + white-space: nowrap; +} + +label.checkBtn.disabled { + color: #606060; + background: #e0e0e0; + font-style: italic; +} + +label.checkBtn, input[type="text"] { + border: 1px solid grey; + border-radius: 4px; + box-shadow: 1px 1px inset; + padding: 1px 5px; +} + +label.checkBtn { + white-space: nowrap; + background: #ccddff; +} + +label.unchecked { + background: #eff8ff; + box-shadow: 1px 1px 1px; +} + +label.checkBtn:hover, label.unchecked:hover{ + box-shadow: 0 0 2px; +} + +label.disabled:hover { + box-shadow: 1px 1px inset; +} + +label.checkBtn > input { + display:none; +} + +.summaryTable { + width: 100%; +} + +table.summaryTable td { padding: 0 5px 0 5px; } + +.statHeader, .severityHeader { + font-weight: bold; +} + +.warning { + background-color: #ffffa7; +} + +.error { + background-color: #ffb7b7; +} + +.error2 { + background-color: #faa; + display: inline-block; + margin-left: 4px; +} + +.inconclusive { + background-color: #b6b6b4; +} + +.inconclusive2 { + background-color: #b6b6b4; + display: inline-block; + margin-left: 4px; +} + +.verbose { + display: inline-block; + vertical-align: top; + cursor: help; +} + +.verbose .content { + display: none; + position: absolute; + padding: 10px; + margin: 4px; + max-width: 40%; + white-space: pre-wrap; + border: 1px solid #000; + background-color: #ffffcc; + cursor: auto; +} + +.highlight .hll { + padding: 1px; +} + +.highlighttable { + background-color: #fff; + position: relative; + margin: -10px; +} + +.linenos { + border-right: thin solid #aaa; + color: #d3d3d3; + padding-right: 6px; +} + +.id-filtered, .severity-filtered, .file-filtered, .tool-filtered, .text-filtered { + visibility: collapse; +} diff --git a/2024-02-15-173245-9368-cppcheck@aacfb22a55ce_master/0.html b/2024-02-15-173245-9368-cppcheck@aacfb22a55ce_master/0.html new file mode 100644 index 0000000..95e5dbc --- /dev/null +++ b/2024-02-15-173245-9368-cppcheck@aacfb22a55ce_master/0.html @@ -0,0 +1,1189 @@ + + + + + + Cppcheck - HTML report - mate-polkit + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
/*
+ * Copyright (C) 2009 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ * Author: David Zeuthen <davidz@redhat.com>
+ */
+
+#ifdef HAVE_CONFIG_H
+#  include "config.h"<--- Include file: "config.h" not found.
+#endif
+
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gio/gio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <polkitagent/polkitagent.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#if defined(HAVE_AYATANA_APPINDICATOR)
+# include <libayatana-appindicator/app-indicator.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#elif defined(HAVE_UBUNTU_APPINDICATOR)
+# include <libappindicator/app-indicator.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#endif
+
+#include "polkitmatelistener.h"
+
+/* session management support for auto-restart */
+#define SM_DBUS_NAME      "org.gnome.SessionManager"
+#define SM_DBUS_PATH      "/org/gnome/SessionManager"
+#define SM_DBUS_INTERFACE "org.gnome.SessionManager"
+#define SM_CLIENT_DBUS_INTERFACE "org.gnome.SessionManager.ClientPrivate"
+
+/* the Authority */
+static PolkitAuthority *authority = NULL;<--- Shadowed declaration
+
+/* the session we are servicing */
+static PolkitSubject *session = NULL;
+
+/* the current set of temporary authorizations */
+static GList *current_temporary_authorizations = NULL;
+
+#if defined(HAVE_AYATANA_APPINDICATOR) || defined(HAVE_UBUNTU_APPINDICATOR)
+static AppIndicator *app_indicator = NULL;
+#else
+static GtkStatusIcon *status_icon = NULL;
+#endif
+
+static GDBusProxy      *sm_proxy;
+static GDBusProxy      *client_proxy = NULL;
+
+static  GMainLoop *loop;
+
+static void
+revoke_tmp_authz_cb (GObject      *source_object,
+                     GAsyncResult *res,
+                     gpointer      user_data)
+{
+  GError *error;
+
+  error = NULL;
+  polkit_authority_revoke_temporary_authorizations_finish (POLKIT_AUTHORITY (source_object),
+                                                           res,
+                                                           &error);
+  if (error != NULL)
+    {
+      g_warning ("Error revoking temporary authorizations: %s", error->message);
+      g_error_free (error);
+    }
+}
+
+static void
+revoke_tmp_authz (void)
+{
+  polkit_authority_revoke_temporary_authorizations (authority,
+                                                    session,
+                                                    NULL,
+                                                    revoke_tmp_authz_cb,
+                                                    NULL);
+}
+
+#if defined(HAVE_AYATANA_APPINDICATOR) || defined(HAVE_UBUNTU_APPINDICATOR)
+static void
+on_menu_item_activate (GtkMenuItem *menu_item,
+                       gpointer     user_data)
+{
+  revoke_tmp_authz ();
+}
+#else
+static void
+on_status_icon_activate (GtkStatusIcon *status_icon,
+                         gpointer       user_data)
+{
+  revoke_tmp_authz ();
+}
+
+static void
+on_status_icon_popup_menu (GtkStatusIcon *status_icon,
+                           guint          button,
+                           guint          activate_time,
+                           gpointer       user_data)
+{
+  revoke_tmp_authz ();
+}
+#endif
+
+static void
+update_temporary_authorization_icon_real (void)
+{
+
+#if 0
+  GList *l;
+  g_debug ("have %d tmp authorizations", g_list_length (current_temporary_authorizations));
+  for (l = current_temporary_authorizations; l != NULL; l = l->next)
+    {
+      PolkitTemporaryAuthorization *authz = POLKIT_TEMPORARY_AUTHORIZATION (l->data);
+
+      g_debug ("have tmp authz for action %s (subject %s) with id %s (obtained %d, expires %d)",
+               polkit_temporary_authorization_get_action_id (authz),
+               polkit_subject_to_string (polkit_temporary_authorization_get_subject (authz)),
+               polkit_temporary_authorization_get_id (authz),
+               (gint) polkit_temporary_authorization_get_time_obtained (authz),
+               (gint) polkit_temporary_authorization_get_time_expires (authz));
+    }
+#endif
+
+  /* TODO:
+   *
+   * - we could do something fancy like displaying a window with the tmp authz
+   *   when the icon is clicked...
+   *
+   * - we could do some work using polkit_subject_exists() to ignore tmp authz
+   *   for subjects that no longer exists.. this is because temporary authorizations
+   *   are only valid for the subject that trigger the authentication dialog.
+   *
+   *   Maybe the authority could do this, would probably involve some polling, but
+   *   it seems cleaner to do this server side.
+   */
+
+  if (current_temporary_authorizations != NULL)
+    {
+      /* show icon */
+#if defined(HAVE_AYATANA_APPINDICATOR) || defined(HAVE_UBUNTU_APPINDICATOR)
+      if (app_indicator == NULL)
+        {
+          GtkWidget *item, *menu;
+
+          app_indicator = app_indicator_new ("mate-polkit",
+                                             "dialog-password",
+                                             APP_INDICATOR_CATEGORY_SYSTEM_SERVICES);
+
+          item = gtk_menu_item_new_with_label (_("Drop all elevated privileges"));
+          g_signal_connect (item,
+                            "activate",
+                            G_CALLBACK (on_menu_item_activate),
+                            NULL);
+          menu = gtk_menu_new ();
+          gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+          gtk_widget_show_all (menu);
+
+          app_indicator_set_menu (app_indicator,
+                                  GTK_MENU (menu));
+          app_indicator_set_status (app_indicator,
+                                    APP_INDICATOR_STATUS_ACTIVE);
+        }
+      else
+        /*Reshow icon from existing appindicator */
+        app_indicator_set_status (app_indicator,
+				    APP_INDICATOR_STATUS_ACTIVE);
+
+#else
+      if (status_icon == NULL)
+        {
+          status_icon = gtk_status_icon_new_from_icon_name ("dialog-password");
+          gtk_status_icon_set_tooltip_text (status_icon,
+                                            _("Click the icon to drop all elevated privileges"));
+          g_signal_connect (status_icon,
+                            "activate",
+                            G_CALLBACK (on_status_icon_activate),
+                            NULL);
+          g_signal_connect (status_icon,
+                            "popup-menu",
+                            G_CALLBACK (on_status_icon_popup_menu),
+                            NULL);
+        }
+#endif
+    }
+  else
+    {
+      /* hide icon */
+#if defined(HAVE_AYATANA_APPINDICATOR) || defined(HAVE_UBUNTU_APPINDICATOR)
+      if (app_indicator != NULL)
+        {
+          /* keep the app_indicator, hide the icon or it won't come back*/
+          app_indicator_set_status (app_indicator,
+				    APP_INDICATOR_STATUS_PASSIVE);
+        }
+#else
+      if (status_icon != NULL)
+        {
+          gtk_status_icon_set_visible (status_icon, FALSE);
+          g_object_unref (status_icon);
+          status_icon = NULL;
+        }
+#endif
+    }
+}
+
+static void
+enumerate_temporary_authorizations_cb (GObject      *source_object,
+                                       GAsyncResult *res,
+                                       gpointer      user_data)
+{
+  PolkitAuthority *authority = POLKIT_AUTHORITY (source_object);<--- Shadow variable
+  GList *temporary_authorizations;
+  GError *error;
+
+  temporary_authorizations = NULL;
+
+  error = NULL;
+  temporary_authorizations = polkit_authority_enumerate_temporary_authorizations_finish (authority,
+                                                                                         res,
+                                                                                         &error);
+  if (error != NULL)
+    {
+      g_warning ("Error enumerating temporary authorizations: %s", error->message);
+      g_error_free (error);
+      goto out;
+    }
+
+  g_list_foreach (current_temporary_authorizations, (GFunc) g_object_unref, NULL);
+  g_list_free (current_temporary_authorizations);
+
+  current_temporary_authorizations = temporary_authorizations;
+
+  update_temporary_authorization_icon_real ();
+
+ out:
+  ;
+}
+
+static void
+update_temporary_authorization_icon (PolkitAuthority *authority)
+{
+  polkit_authority_enumerate_temporary_authorizations (authority,
+                                                       session,
+                                                       NULL,
+                                                       enumerate_temporary_authorizations_cb,
+                                                       NULL);
+}
+
+static void
+on_authority_changed (PolkitAuthority *authority,
+                      gpointer         user_data)
+{
+  update_temporary_authorization_icon (authority);
+}
+
+static void
+stop_cb (void)
+{
+        g_main_loop_quit (loop);
+}
+
+static gboolean
+end_session_response (gboolean is_okay, const gchar *reason)
+{
+        GVariant *res;
+        GError *error = NULL;
+
+        res = g_dbus_proxy_call_sync (client_proxy,
+                                      "EndSessionResponse",
+                                      g_variant_new ("(bs)",
+                                                     is_okay,
+                                                     reason),
+                                      G_DBUS_CALL_FLAGS_NONE,
+                                      -1, /* timeout */
+                                      NULL, /* GCancellable */
+                                      &error);
+        if (! res) {
+                g_warning ("Failed to call EndSessionResponse: %s", error->message);
+                g_error_free (error);
+                return FALSE;
+        }
+
+        g_variant_unref (res);
+        return TRUE;
+}
+
+static void
+query_end_session_cb (void)
+{
+        end_session_response (TRUE, "");
+}
+
+static void
+end_session_cb (void)
+{
+        end_session_response (TRUE, "");
+        g_main_loop_quit (loop);
+}
+
+static void
+signal_cb (GDBusProxy *proxy, gchar *sender_name, gchar *signal_name,<--- Parameter 'signal_name' can be declared as pointer to const
+           GVariant *parameters, gpointer user_data)
+{
+        if (strcmp (signal_name, "Stop") == 0) {
+                stop_cb ();
+        } else if (strcmp (signal_name, "QueryEndSession") == 0) {
+                query_end_session_cb ();
+        } else if (strcmp (signal_name, "EndSession") == 0) {
+                end_session_cb ();
+        }
+}
+
+static gboolean
+register_client_to_gnome_session (void)
+{
+        GError     *error = NULL;
+        GVariant   *res;
+        const char *startup_id;
+        const char *app_id;
+        char       *client_id;
+
+        startup_id = g_getenv ("DESKTOP_AUTOSTART_ID");
+        app_id = "polkit-mate-authentication-agent-1.desktop";
+
+        sm_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
+                                                  G_DBUS_PROXY_FLAGS_NONE,
+                                                  NULL, /* GDBusInterfaceInfo */
+                                                  SM_DBUS_NAME,
+                                                  SM_DBUS_PATH,
+                                                  SM_DBUS_INTERFACE,
+                                                  NULL, /* GCancellable */
+                                                  &error);
+        if (sm_proxy == NULL) {
+                g_message("Failed to get session manager: %s", error->message);
+                g_error_free (error);
+                return FALSE;
+        }
+
+        res = g_dbus_proxy_call_sync (sm_proxy,
+                                      "RegisterClient",
+                                      g_variant_new ("(ss)",
+                                                     app_id,
+                                                     startup_id),
+                                      G_DBUS_CALL_FLAGS_NONE,
+                                      -1, /* timeout */
+                                      NULL, /* GCancellable */
+                                      &error);
+        if (! res) {
+                g_warning ("Failed to register client: %s", error->message);
+                g_error_free (error);
+                return FALSE;
+        }
+
+        if (! g_variant_is_of_type (res, G_VARIANT_TYPE ("(o)"))) {
+                g_warning ("RegisterClient returned unexpected type %s",
+                           g_variant_get_type_string (res));
+                return FALSE;
+        }
+
+        g_variant_get (res, "(&o)", &client_id);
+
+        client_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
+                                                      G_DBUS_PROXY_FLAGS_NONE,
+                                                      NULL, /* GDBusInterfaceInfo */
+                                                      SM_DBUS_NAME,
+                                                      client_id,
+                                                      SM_CLIENT_DBUS_INTERFACE,
+                                                      NULL, /* GCancellable */
+                                                      &error);
+        g_variant_unref (res);
+        if (client_proxy == NULL) {
+                g_message("Failed to get client proxy: %s", error->message);
+                g_error_free (error);
+                return FALSE;
+        }
+
+        g_signal_connect (client_proxy, "g-signal", G_CALLBACK (signal_cb), NULL);<--- You might need to cast the function pointer here
+
+        return TRUE;
+}
+
+int
+main (int argc, char **argv)
+{
+  gint ret;
+  PolkitAgentListener *listener;
+  GError *error;
+
+  gtk_init (&argc, &argv);
+
+  loop = NULL;
+  authority = NULL;
+  listener = NULL;
+  session = NULL;
+  ret = 1;
+
+  bindtextdomain (GETTEXT_PACKAGE, MATELOCALEDIR);
+#if HAVE_BIND_TEXTDOMAIN_CODESET
+  bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+#endif
+  textdomain (GETTEXT_PACKAGE);
+
+  loop = g_main_loop_new (NULL, FALSE);
+
+  error = NULL;
+  authority = polkit_authority_get_sync (NULL /* GCancellable* */, &error);
+  if (authority == NULL)
+    {
+      g_warning ("Error getting authority: %s", error->message);
+      g_error_free (error);
+      goto out;
+    }
+  g_signal_connect (authority,
+                    "changed",
+                    G_CALLBACK (on_authority_changed),
+                    NULL);
+
+  listener = polkit_mate_listener_new ();
+
+  error = NULL;
+  session = polkit_unix_session_new_for_process_sync (getpid (), NULL, &error);
+  if (error != NULL)
+    {
+      g_warning ("Unable to determine the session we are in: %s", error->message);
+      g_error_free (error);
+      goto out;
+    }
+
+  error = NULL;
+  if (!polkit_agent_listener_register (listener,
+				       POLKIT_AGENT_REGISTER_FLAGS_NONE,
+                                       session,
+                                       "/org/mate/PolicyKit1/AuthenticationAgent",
+				       NULL,
+                                       &error))
+    {
+      g_printerr ("Cannot register authentication agent: %s\n", error->message);
+      g_error_free (error);
+      goto out;
+    }
+
+  update_temporary_authorization_icon (authority);
+
+  register_client_to_gnome_session();
+
+  g_main_loop_run (loop);
+
+  ret = 0;
+
+ out:
+  if (authority != NULL)
+    g_object_unref (authority);
+  if (session != NULL)
+    g_object_unref (session);
+  if (listener != NULL)
+    g_object_unref (listener);
+  if (loop != NULL)
+    g_main_loop_unref (loop);
+
+  return ret;
+}
+
+ +
+ +
+ + diff --git a/2024-02-15-173245-9368-cppcheck@aacfb22a55ce_master/1.html b/2024-02-15-173245-9368-cppcheck@aacfb22a55ce_master/1.html new file mode 100644 index 0000000..bf8ec00 --- /dev/null +++ b/2024-02-15-173245-9368-cppcheck@aacfb22a55ce_master/1.html @@ -0,0 +1,335 @@ + + + + + + Cppcheck - HTML report - mate-polkit + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
/*
+ * Copyright (C) 2009 Red Hat, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ * Author: David Zeuthen <davidz@redhat.com>
+ */
+
+#ifndef __POLKIT_MATE_LISTENER_H
+#define __POLKIT_MATE_LISTENER_H
+
+#include <polkitagent/polkitagent.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define POLKIT_MATE_TYPE_LISTENER          (polkit_mate_listener_get_type())
+#define POLKIT_MATE_LISTENER(o)            (G_TYPE_CHECK_INSTANCE_CAST ((o), POLKIT_MATE_TYPE_LISTENER, PolkitMateListener))
+#define POLKIT_MATE_LISTENER_CLASS(k)      (G_TYPE_CHECK_CLASS_CAST((k), POLKIT_MATE_TYPE_LISTENER, PolkitMateListenerClass))
+#define POLKIT_MATE_LISTENER_GET_CLASS(o)  (G_TYPE_INSTANCE_GET_CLASS ((o), POLKIT_MATE_TYPE_LISTENER, PolkitMateListenerClass))
+#define POLKIT_MATE_IS_LISTENER(o)         (G_TYPE_CHECK_INSTANCE_TYPE ((o), POLKIT_MATE_TYPE_LISTENER))
+#define POLKIT_MATE_IS_LISTENER_CLASS(k)   (G_TYPE_CHECK_CLASS_TYPE ((k), POLKIT_MATE_TYPE_LISTENER))
+
+typedef struct _PolkitMateListener PolkitMateListener;
+typedef struct _PolkitMateListenerClass PolkitMateListenerClass;
+
+GType                 polkit_mate_listener_get_type   (void) G_GNUC_CONST;
+PolkitAgentListener  *polkit_mate_listener_new        (void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __POLKIT_MATE_LISTENER_H */
+
+ +
+ +
+ + diff --git a/2024-02-15-173245-9368-cppcheck@aacfb22a55ce_master/2.html b/2024-02-15-173245-9368-cppcheck@aacfb22a55ce_master/2.html new file mode 100644 index 0000000..bce6d3f --- /dev/null +++ b/2024-02-15-173245-9368-cppcheck@aacfb22a55ce_master/2.html @@ -0,0 +1,2639 @@ + + + + + + Cppcheck - HTML report - mate-polkit + + + + + +
+ + + +
+
   1
+   2
+   3
+   4
+   5
+   6
+   7
+   8
+   9
+  10
+  11
+  12
+  13
+  14
+  15
+  16
+  17
+  18
+  19
+  20
+  21
+  22
+  23
+  24
+  25
+  26
+  27
+  28
+  29
+  30
+  31
+  32
+  33
+  34
+  35
+  36
+  37
+  38
+  39
+  40
+  41
+  42
+  43
+  44
+  45
+  46
+  47
+  48
+  49
+  50
+  51
+  52
+  53
+  54
+  55
+  56
+  57
+  58
+  59
+  60
+  61
+  62
+  63
+  64
+  65
+  66
+  67
+  68
+  69
+  70
+  71
+  72
+  73
+  74
+  75
+  76
+  77
+  78
+  79
+  80
+  81
+  82
+  83
+  84
+  85
+  86
+  87
+  88
+  89
+  90
+  91
+  92
+  93
+  94
+  95
+  96
+  97
+  98
+  99
+ 100
+ 101
+ 102
+ 103
+ 104
+ 105
+ 106
+ 107
+ 108
+ 109
+ 110
+ 111
+ 112
+ 113
+ 114
+ 115
+ 116
+ 117
+ 118
+ 119
+ 120
+ 121
+ 122
+ 123
+ 124
+ 125
+ 126
+ 127
+ 128
+ 129
+ 130
+ 131
+ 132
+ 133
+ 134
+ 135
+ 136
+ 137
+ 138
+ 139
+ 140
+ 141
+ 142
+ 143
+ 144
+ 145
+ 146
+ 147
+ 148
+ 149
+ 150
+ 151
+ 152
+ 153
+ 154
+ 155
+ 156
+ 157
+ 158
+ 159
+ 160
+ 161
+ 162
+ 163
+ 164
+ 165
+ 166
+ 167
+ 168
+ 169
+ 170
+ 171
+ 172
+ 173
+ 174
+ 175
+ 176
+ 177
+ 178
+ 179
+ 180
+ 181
+ 182
+ 183
+ 184
+ 185
+ 186
+ 187
+ 188
+ 189
+ 190
+ 191
+ 192
+ 193
+ 194
+ 195
+ 196
+ 197
+ 198
+ 199
+ 200
+ 201
+ 202
+ 203
+ 204
+ 205
+ 206
+ 207
+ 208
+ 209
+ 210
+ 211
+ 212
+ 213
+ 214
+ 215
+ 216
+ 217
+ 218
+ 219
+ 220
+ 221
+ 222
+ 223
+ 224
+ 225
+ 226
+ 227
+ 228
+ 229
+ 230
+ 231
+ 232
+ 233
+ 234
+ 235
+ 236
+ 237
+ 238
+ 239
+ 240
+ 241
+ 242
+ 243
+ 244
+ 245
+ 246
+ 247
+ 248
+ 249
+ 250
+ 251
+ 252
+ 253
+ 254
+ 255
+ 256
+ 257
+ 258
+ 259
+ 260
+ 261
+ 262
+ 263
+ 264
+ 265
+ 266
+ 267
+ 268
+ 269
+ 270
+ 271
+ 272
+ 273
+ 274
+ 275
+ 276
+ 277
+ 278
+ 279
+ 280
+ 281
+ 282
+ 283
+ 284
+ 285
+ 286
+ 287
+ 288
+ 289
+ 290
+ 291
+ 292
+ 293
+ 294
+ 295
+ 296
+ 297
+ 298
+ 299
+ 300
+ 301
+ 302
+ 303
+ 304
+ 305
+ 306
+ 307
+ 308
+ 309
+ 310
+ 311
+ 312
+ 313
+ 314
+ 315
+ 316
+ 317
+ 318
+ 319
+ 320
+ 321
+ 322
+ 323
+ 324
+ 325
+ 326
+ 327
+ 328
+ 329
+ 330
+ 331
+ 332
+ 333
+ 334
+ 335
+ 336
+ 337
+ 338
+ 339
+ 340
+ 341
+ 342
+ 343
+ 344
+ 345
+ 346
+ 347
+ 348
+ 349
+ 350
+ 351
+ 352
+ 353
+ 354
+ 355
+ 356
+ 357
+ 358
+ 359
+ 360
+ 361
+ 362
+ 363
+ 364
+ 365
+ 366
+ 367
+ 368
+ 369
+ 370
+ 371
+ 372
+ 373
+ 374
+ 375
+ 376
+ 377
+ 378
+ 379
+ 380
+ 381
+ 382
+ 383
+ 384
+ 385
+ 386
+ 387
+ 388
+ 389
+ 390
+ 391
+ 392
+ 393
+ 394
+ 395
+ 396
+ 397
+ 398
+ 399
+ 400
+ 401
+ 402
+ 403
+ 404
+ 405
+ 406
+ 407
+ 408
+ 409
+ 410
+ 411
+ 412
+ 413
+ 414
+ 415
+ 416
+ 417
+ 418
+ 419
+ 420
+ 421
+ 422
+ 423
+ 424
+ 425
+ 426
+ 427
+ 428
+ 429
+ 430
+ 431
+ 432
+ 433
+ 434
+ 435
+ 436
+ 437
+ 438
+ 439
+ 440
+ 441
+ 442
+ 443
+ 444
+ 445
+ 446
+ 447
+ 448
+ 449
+ 450
+ 451
+ 452
+ 453
+ 454
+ 455
+ 456
+ 457
+ 458
+ 459
+ 460
+ 461
+ 462
+ 463
+ 464
+ 465
+ 466
+ 467
+ 468
+ 469
+ 470
+ 471
+ 472
+ 473
+ 474
+ 475
+ 476
+ 477
+ 478
+ 479
+ 480
+ 481
+ 482
+ 483
+ 484
+ 485
+ 486
+ 487
+ 488
+ 489
+ 490
+ 491
+ 492
+ 493
+ 494
+ 495
+ 496
+ 497
+ 498
+ 499
+ 500
+ 501
+ 502
+ 503
+ 504
+ 505
+ 506
+ 507
+ 508
+ 509
+ 510
+ 511
+ 512
+ 513
+ 514
+ 515
+ 516
+ 517
+ 518
+ 519
+ 520
+ 521
+ 522
+ 523
+ 524
+ 525
+ 526
+ 527
+ 528
+ 529
+ 530
+ 531
+ 532
+ 533
+ 534
+ 535
+ 536
+ 537
+ 538
+ 539
+ 540
+ 541
+ 542
+ 543
+ 544
+ 545
+ 546
+ 547
+ 548
+ 549
+ 550
+ 551
+ 552
+ 553
+ 554
+ 555
+ 556
+ 557
+ 558
+ 559
+ 560
+ 561
+ 562
+ 563
+ 564
+ 565
+ 566
+ 567
+ 568
+ 569
+ 570
+ 571
+ 572
+ 573
+ 574
+ 575
+ 576
+ 577
+ 578
+ 579
+ 580
+ 581
+ 582
+ 583
+ 584
+ 585
+ 586
+ 587
+ 588
+ 589
+ 590
+ 591
+ 592
+ 593
+ 594
+ 595
+ 596
+ 597
+ 598
+ 599
+ 600
+ 601
+ 602
+ 603
+ 604
+ 605
+ 606
+ 607
+ 608
+ 609
+ 610
+ 611
+ 612
+ 613
+ 614
+ 615
+ 616
+ 617
+ 618
+ 619
+ 620
+ 621
+ 622
+ 623
+ 624
+ 625
+ 626
+ 627
+ 628
+ 629
+ 630
+ 631
+ 632
+ 633
+ 634
+ 635
+ 636
+ 637
+ 638
+ 639
+ 640
+ 641
+ 642
+ 643
+ 644
+ 645
+ 646
+ 647
+ 648
+ 649
+ 650
+ 651
+ 652
+ 653
+ 654
+ 655
+ 656
+ 657
+ 658
+ 659
+ 660
+ 661
+ 662
+ 663
+ 664
+ 665
+ 666
+ 667
+ 668
+ 669
+ 670
+ 671
+ 672
+ 673
+ 674
+ 675
+ 676
+ 677
+ 678
+ 679
+ 680
+ 681
+ 682
+ 683
+ 684
+ 685
+ 686
+ 687
+ 688
+ 689
+ 690
+ 691
+ 692
+ 693
+ 694
+ 695
+ 696
+ 697
+ 698
+ 699
+ 700
+ 701
+ 702
+ 703
+ 704
+ 705
+ 706
+ 707
+ 708
+ 709
+ 710
+ 711
+ 712
+ 713
+ 714
+ 715
+ 716
+ 717
+ 718
+ 719
+ 720
+ 721
+ 722
+ 723
+ 724
+ 725
+ 726
+ 727
+ 728
+ 729
+ 730
+ 731
+ 732
+ 733
+ 734
+ 735
+ 736
+ 737
+ 738
+ 739
+ 740
+ 741
+ 742
+ 743
+ 744
+ 745
+ 746
+ 747
+ 748
+ 749
+ 750
+ 751
+ 752
+ 753
+ 754
+ 755
+ 756
+ 757
+ 758
+ 759
+ 760
+ 761
+ 762
+ 763
+ 764
+ 765
+ 766
+ 767
+ 768
+ 769
+ 770
+ 771
+ 772
+ 773
+ 774
+ 775
+ 776
+ 777
+ 778
+ 779
+ 780
+ 781
+ 782
+ 783
+ 784
+ 785
+ 786
+ 787
+ 788
+ 789
+ 790
+ 791
+ 792
+ 793
+ 794
+ 795
+ 796
+ 797
+ 798
+ 799
+ 800
+ 801
+ 802
+ 803
+ 804
+ 805
+ 806
+ 807
+ 808
+ 809
+ 810
+ 811
+ 812
+ 813
+ 814
+ 815
+ 816
+ 817
+ 818
+ 819
+ 820
+ 821
+ 822
+ 823
+ 824
+ 825
+ 826
+ 827
+ 828
+ 829
+ 830
+ 831
+ 832
+ 833
+ 834
+ 835
+ 836
+ 837
+ 838
+ 839
+ 840
+ 841
+ 842
+ 843
+ 844
+ 845
+ 846
+ 847
+ 848
+ 849
+ 850
+ 851
+ 852
+ 853
+ 854
+ 855
+ 856
+ 857
+ 858
+ 859
+ 860
+ 861
+ 862
+ 863
+ 864
+ 865
+ 866
+ 867
+ 868
+ 869
+ 870
+ 871
+ 872
+ 873
+ 874
+ 875
+ 876
+ 877
+ 878
+ 879
+ 880
+ 881
+ 882
+ 883
+ 884
+ 885
+ 886
+ 887
+ 888
+ 889
+ 890
+ 891
+ 892
+ 893
+ 894
+ 895
+ 896
+ 897
+ 898
+ 899
+ 900
+ 901
+ 902
+ 903
+ 904
+ 905
+ 906
+ 907
+ 908
+ 909
+ 910
+ 911
+ 912
+ 913
+ 914
+ 915
+ 916
+ 917
+ 918
+ 919
+ 920
+ 921
+ 922
+ 923
+ 924
+ 925
+ 926
+ 927
+ 928
+ 929
+ 930
+ 931
+ 932
+ 933
+ 934
+ 935
+ 936
+ 937
+ 938
+ 939
+ 940
+ 941
+ 942
+ 943
+ 944
+ 945
+ 946
+ 947
+ 948
+ 949
+ 950
+ 951
+ 952
+ 953
+ 954
+ 955
+ 956
+ 957
+ 958
+ 959
+ 960
+ 961
+ 962
+ 963
+ 964
+ 965
+ 966
+ 967
+ 968
+ 969
+ 970
+ 971
+ 972
+ 973
+ 974
+ 975
+ 976
+ 977
+ 978
+ 979
+ 980
+ 981
+ 982
+ 983
+ 984
+ 985
+ 986
+ 987
+ 988
+ 989
+ 990
+ 991
+ 992
+ 993
+ 994
+ 995
+ 996
+ 997
+ 998
+ 999
+1000
+1001
+1002
+1003
+1004
+1005
+1006
+1007
+1008
+1009
+1010
+1011
+1012
+1013
+1014
+1015
+1016
+1017
+1018
+1019
+1020
+1021
+1022
+1023
+1024
+1025
+1026
+1027
+1028
+1029
+1030
+1031
+1032
+1033
+1034
+1035
+1036
+1037
+1038
+1039
+1040
+1041
+1042
+1043
+1044
+1045
+1046
+1047
+1048
+1049
+1050
+1051
+1052
+1053
+1054
+1055
+1056
+1057
+1058
+1059
+1060
+1061
+1062
+1063
+1064
+1065
+1066
+1067
+1068
+1069
+1070
+1071
+1072
+1073
+1074
+1075
+1076
+1077
+1078
+1079
+1080
+1081
+1082
+1083
+1084
+1085
+1086
+1087
+1088
+1089
+1090
+1091
+1092
+1093
+1094
+1095
+1096
+1097
+1098
+1099
+1100
+1101
+1102
+1103
+1104
+1105
+1106
+1107
+1108
+1109
+1110
+1111
+1112
+1113
+1114
+1115
+1116
+1117
+1118
+1119
+1120
+1121
+1122
+1123
+1124
+1125
+1126
+1127
+1128
+1129
+1130
+1131
+1132
+1133
+1134
+1135
+1136
+1137
+1138
+1139
+1140
+1141
+1142
+1143
+1144
+1145
+1146
+1147
+1148
+1149
+1150
+1151
+1152
+1153
+1154
+1155
+1156
+1157
+1158
+1159
+1160
+1161
+1162
+1163
+1164
+1165
+1166
+1167
+1168
+1169
+1170
+1171
+1172
+1173
+1174
+1175
+1176
+1177
+1178
+1179
+1180
+1181
+1182
+1183
+1184
+1185
+1186
+1187
+1188
+1189
+1190
+1191
+1192
+1193
+1194
+1195
+1196
+1197
+1198
+1199
+1200
+1201
/*
+ * Copyright (C) 2009 Red Hat, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ * Author: David Zeuthen <davidz@redhat.com>
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"<--- Include file: "config.h" not found.
+#endif
+
+#define _GNU_SOURCE
+#include <unistd.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/types.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/stat.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <fcntl.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <stdio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <stdlib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <pwd.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <errno.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <glib/gi18n-lib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "polkitmateauthenticationdialog.h"
+
+#define RESPONSE_USER_SELECTED 1001
+
+struct _PolkitMateAuthenticationDialogPrivate
+{
+  GtkWidget *user_combobox;
+  GtkWidget *prompt_label;
+  GtkWidget *password_entry;
+  GtkWidget *auth_button;
+  GtkWidget *cancel_button;
+  GtkWidget *info_label;
+  GtkWidget *grid_password;
+
+  gchar *message;
+  gchar *action_id;
+  gchar *vendor;
+  gchar *vendor_url;
+  gchar *icon_name;
+  PolkitDetails *details;
+
+  gchar **users;
+  gchar *selected_user;
+
+  gboolean is_running;
+
+  GtkListStore *store;
+};
+
+G_DEFINE_TYPE_WITH_PRIVATE (PolkitMateAuthenticationDialog, polkit_mate_authentication_dialog, GTK_TYPE_DIALOG);
+
+enum {
+  PROP_0,
+  PROP_ACTION_ID,
+  PROP_VENDOR,
+  PROP_VENDOR_URL,
+  PROP_ICON_NAME,
+  PROP_MESSAGE,
+  PROP_DETAILS,
+  PROP_USERS,
+  PROP_SELECTED_USER,
+};
+
+enum {
+  PIXBUF_COL,
+  TEXT_COL,
+  USERNAME_COL,
+  N_COL
+};
+
+static void
+user_combobox_set_sensitive (GtkCellLayout   *cell_layout,
+                             GtkCellRenderer *cell,
+                             GtkTreeModel    *tree_model,
+                             GtkTreeIter     *iter,
+                             gpointer         user_data)
+{
+  GtkTreePath *path;
+  gint *indices;<--- Variable 'indices' can be declared as pointer to const
+  gboolean sensitive;
+
+  path = gtk_tree_model_get_path (tree_model, iter);
+  indices = gtk_tree_path_get_indices (path);
+  if (indices[0] == 0)
+    sensitive = FALSE;
+  else
+    sensitive = TRUE;
+  gtk_tree_path_free (path);
+
+  g_object_set (cell, "sensitive", sensitive, NULL);
+}
+
+static void
+user_combobox_changed (GtkComboBox *widget,
+                       gpointer     user_data)
+{
+  PolkitMateAuthenticationDialog *dialog = POLKIT_MATE_AUTHENTICATION_DIALOG (user_data);
+  GtkTreeIter iter;
+  gchar *user_name;
+
+  if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (widget), &iter))
+    {
+      gtk_tree_model_get (GTK_TREE_MODEL (dialog->priv->store), &iter, USERNAME_COL, &user_name, -1);
+
+      g_free (dialog->priv->selected_user);
+      dialog->priv->selected_user = user_name;
+
+      g_object_notify (G_OBJECT (dialog), "selected-user");
+
+      gtk_dialog_response (GTK_DIALOG (dialog), RESPONSE_USER_SELECTED);
+
+      /* make the password entry and Authenticate button sensitive again */
+      gtk_widget_set_sensitive (dialog->priv->prompt_label, TRUE);
+      gtk_widget_set_sensitive (dialog->priv->password_entry, TRUE);
+      gtk_widget_set_sensitive (dialog->priv->auth_button, TRUE);
+    }
+}
+
+#if HAVE_ACCOUNTSSERVICE
+static GdkPixbuf *
+get_user_icon (char *username)
+{
+  GError *error;
+  GDBusConnection *connection;
+  GVariant *find_user_result;
+  GVariant *get_icon_result;
+  GVariant *icon_result_variant;
+  const gchar *user_path;
+  const gchar *icon_filename;
+  GdkPixbuf *pixbuf = NULL;
+
+  error = NULL;
+  connection = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
+
+  if (connection == NULL)
+    {
+      g_warning ("Unable to connect to system bus: %s", error->message);
+      g_error_free (error);
+      return NULL;
+    }
+
+  find_user_result = g_dbus_connection_call_sync (connection,
+                                          "org.freedesktop.Accounts",
+                                          "/org/freedesktop/Accounts",
+                                          "org.freedesktop.Accounts",
+                                          "FindUserByName",
+                                          g_variant_new ("(s)",
+                                          username),
+                                          G_VARIANT_TYPE ("(o)"),
+                                          G_DBUS_CALL_FLAGS_NONE,
+                                          -1,
+                                          NULL,
+                                          &error);
+
+  if (find_user_result == NULL)
+    {
+      g_warning ("Accounts couldn't find user: %s", error->message);
+      g_error_free (error);
+      return NULL;
+    }
+
+  user_path = g_variant_get_string (g_variant_get_child_value (find_user_result, 0),
+                                    NULL);
+
+  get_icon_result = g_dbus_connection_call_sync (connection,
+                                                 "org.freedesktop.Accounts",
+                                                 user_path,
+                                                 "org.freedesktop.DBus.Properties",
+                                                 "Get",
+                                                 g_variant_new ("(ss)",
+                                                                "org.freedesktop.Accounts.User",
+                                                                "IconFile"),
+                                                 G_VARIANT_TYPE ("(v)"),
+                                                 G_DBUS_CALL_FLAGS_NONE,
+                                                 -1,
+                                                 NULL,
+                                                 &error);
+
+  g_variant_unref (find_user_result);
+
+  if (get_icon_result == NULL)
+    {
+      g_warning ("Accounts couldn't find user icon: %s", error->message);
+      g_error_free (error);
+      return NULL;
+    }
+
+  g_variant_get_child (get_icon_result, 0, "v", &icon_result_variant);
+  icon_filename = g_variant_get_string (icon_result_variant, NULL);
+
+  if (icon_filename == NULL)
+    {
+      g_warning ("Accounts didn't return a valid filename for user icon");
+    }
+  else
+    {
+      /* TODO: we probably shouldn't hard-code the size to 16x16 */
+      pixbuf = gdk_pixbuf_new_from_file_at_size (icon_filename,
+                                                 16,
+                                                 16,
+                                                 &error);
+      if (pixbuf == NULL)
+        {
+          g_warning ("Couldn't open user icon: %s", error->message);
+          g_error_free (error);
+        }
+    }
+
+  g_variant_unref (icon_result_variant);
+  g_variant_unref (get_icon_result);
+
+  return pixbuf;
+}
+#else
+static GdkPixbuf *
+get_user_icon (char *username)
+{
+  GdkPixbuf *pixbuf = NULL;
+  struct passwd *passwd;
+
+  passwd = getpwnam (username);
+  if (passwd->pw_dir != NULL)
+    {
+      gchar *path;
+      path = g_strdup_printf ("%s/.face", passwd->pw_dir);
+      /* TODO: we probably shouldn't hard-code the size to 16x16 */
+      pixbuf = gdk_pixbuf_new_from_file_at_scale (path, 16, 16, TRUE, NULL);
+      g_free (path);
+    }
+
+  return pixbuf;
+}
+#endif /* HAVE_ACCOUNTSSERVICE */
+
+static void
+create_user_combobox (PolkitMateAuthenticationDialog *dialog)
+{
+  int n, i, selected_index = 0;
+  GtkComboBox *combo;
+  GtkTreeIter iter;
+  GtkCellRenderer *renderer;
+
+  /* if we've already built the list of admin users once, then avoid
+   * doing it again.. (this is mainly used when the user entered the
+   * wrong password and the dialog is recycled)
+   */
+  if (dialog->priv->store != NULL)
+    return;
+
+  combo = GTK_COMBO_BOX (dialog->priv->user_combobox);
+  dialog->priv->store = gtk_list_store_new (3, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING);
+
+  gtk_list_store_append (dialog->priv->store, &iter);
+  gtk_list_store_set (dialog->priv->store, &iter,
+                      PIXBUF_COL, NULL,
+                      TEXT_COL, _("Select user..."),
+                      USERNAME_COL, NULL,
+                      -1);
+
+  /* For each user */
+  for (i = 0, n = 0; dialog->priv->users[n] != NULL; n++)
+  {
+      gchar *gecos;
+      gchar *real_name;
+      GdkPixbuf *pixbuf = NULL;
+      struct passwd *passwd;
+
+      /* we're single threaded so this is fine */
+      errno = 0;
+      passwd = getpwnam (dialog->priv->users[n]);
+      if (passwd == NULL)
+        {
+          g_warning ("Error doing getpwnam(\"%s\"): %s", dialog->priv->users[n], strerror (errno));
+          continue;
+        }
+
+      if (passwd->pw_gecos != NULL)
+        gecos = g_locale_to_utf8 (passwd->pw_gecos, -1, NULL, NULL, NULL);
+      else
+        gecos = NULL;
+
+      if (gecos != NULL && strlen (gecos) > 0)
+        {
+          gchar *first_comma;
+          first_comma = strchr (gecos, ',');
+          if (first_comma != NULL)
+            *first_comma = '\0';
+        }
+      if (gecos != NULL && strlen (gecos) > 0 && strcmp (gecos, dialog->priv->users[n]) != 0)
+        real_name = g_strdup_printf (_("%s (%s)"), gecos, dialog->priv->users[n]);
+       else
+         real_name = g_strdup (dialog->priv->users[n]);
+      g_free (gecos);
+
+      /* Load users face */
+      pixbuf = get_user_icon (dialog->priv->users[n]);
+
+      /* fall back to stock_person icon */
+      if (pixbuf == NULL)
+        {
+          pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
+                                             "stock_person",
+                                             GTK_ICON_SIZE_MENU,
+                                             0,
+                                             NULL);
+        }
+
+      gtk_list_store_append (dialog->priv->store, &iter);
+      gtk_list_store_set (dialog->priv->store, &iter,
+                          PIXBUF_COL, pixbuf,
+                          TEXT_COL, real_name,
+                          USERNAME_COL, dialog->priv->users[n],
+                          -1);
+
+      i++;
+      if (passwd->pw_uid == getuid ())
+        {
+          selected_index = i;
+          g_free (dialog->priv->selected_user);
+          dialog->priv->selected_user = g_strdup (dialog->priv->users[n]);
+        }
+
+      g_free (real_name);
+      g_object_unref (pixbuf);
+    }
+
+  gtk_combo_box_set_model (combo, GTK_TREE_MODEL (dialog->priv->store));
+
+  renderer = gtk_cell_renderer_pixbuf_new ();
+  gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), renderer, FALSE);
+  gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo),
+                                  renderer,
+                                  "pixbuf", PIXBUF_COL,
+                                  NULL);
+  gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (combo),
+                                      renderer,
+                                      user_combobox_set_sensitive,
+                                      NULL, NULL);
+
+  renderer = gtk_cell_renderer_text_new ();
+  gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), renderer, TRUE);
+  gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo),
+                                  renderer,
+                                  "text", TEXT_COL,
+                                  NULL);
+  gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (combo),
+                                      renderer,
+                                      user_combobox_set_sensitive,
+                                      NULL, NULL);
+
+  /* Select the default user */
+  gtk_combo_box_set_active (GTK_COMBO_BOX (combo), selected_index);
+
+  /* Listen when a new user is selected */
+  g_signal_connect (GTK_WIDGET (combo),
+                    "changed",
+                    G_CALLBACK (user_combobox_changed),
+                    dialog);
+}
+
+static GtkWidget *
+get_image (PolkitMateAuthenticationDialog *dialog)
+{
+  GdkPixbuf *pixbuf;
+  GdkPixbuf *copy_pixbuf;
+  GdkPixbuf *vendor_pixbuf;
+  GtkWidget *image;
+
+  pixbuf = NULL;
+  copy_pixbuf = NULL;
+  vendor_pixbuf = NULL;
+  image = NULL;
+
+  if (dialog->priv->icon_name == NULL || strlen (dialog->priv->icon_name) == 0)
+    {
+      image = gtk_image_new_from_icon_name ("dialog-password", GTK_ICON_SIZE_DIALOG);
+      goto out;
+    }
+
+  vendor_pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
+                                            dialog->priv->icon_name,
+                                            48,
+                                            0,
+                                            NULL);
+  if (vendor_pixbuf == NULL)
+    {
+      g_warning ("No icon for themed icon with name '%s'", dialog->priv->icon_name);
+      image = gtk_image_new_from_icon_name ("dialog-password", GTK_ICON_SIZE_DIALOG);
+      goto out;
+    }
+
+  pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
+                                     "dialog-password",
+                                     48,
+                                     0,
+                                     NULL);
+  if (pixbuf == NULL)
+    goto out;
+
+  /* need to copy the pixbuf since we're modifying it */
+  copy_pixbuf = gdk_pixbuf_copy (pixbuf);
+  if (copy_pixbuf == NULL)
+    goto out;
+
+  /* blend the vendor icon in the bottom right quarter */
+  gdk_pixbuf_composite (vendor_pixbuf,
+                        copy_pixbuf,
+                        24, 24, 24, 24,
+                        24, 24, 0.5, 0.5,
+                        GDK_INTERP_BILINEAR,
+                        255);
+
+  image = gtk_image_new_from_pixbuf (copy_pixbuf);
+
+out:
+  if (pixbuf != NULL)
+    g_object_unref (pixbuf);
+
+  if (copy_pixbuf != NULL)
+    g_object_unref (copy_pixbuf);
+
+  if (vendor_pixbuf != NULL)
+    g_object_unref (vendor_pixbuf);
+
+  return image;
+}
+
+static void
+polkit_mate_authentication_dialog_set_property (GObject      *object,
+                                                 guint         prop_id,
+                                                 const GValue *value,
+                                                 GParamSpec   *pspec)
+{
+  PolkitMateAuthenticationDialog *dialog = POLKIT_MATE_AUTHENTICATION_DIALOG (object);
+
+  switch (prop_id)
+    {
+    case PROP_DETAILS:
+      dialog->priv->details = g_value_dup_object (value);
+      break;
+
+    case PROP_ACTION_ID:
+      dialog->priv->action_id = g_value_dup_string (value);
+      break;
+
+    case PROP_VENDOR:
+      dialog->priv->vendor = g_value_dup_string (value);
+      break;
+
+    case PROP_VENDOR_URL:
+      dialog->priv->vendor_url = g_value_dup_string (value);
+      break;
+
+    case PROP_ICON_NAME:
+      dialog->priv->icon_name = g_value_dup_string (value);
+      break;
+
+    case PROP_MESSAGE:
+      dialog->priv->message = g_value_dup_string (value);
+      break;
+
+    case PROP_USERS:
+      dialog->priv->users = g_value_dup_boxed (value);
+      break;
+
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+    }
+}
+
+static void
+polkit_mate_authentication_dialog_get_property (GObject    *object,
+                                                 guint       prop_id,
+                                                 GValue     *value,
+                                                 GParamSpec *pspec)
+{
+  PolkitMateAuthenticationDialog *dialog = POLKIT_MATE_AUTHENTICATION_DIALOG (object);
+
+  switch (prop_id)
+    {
+    case PROP_MESSAGE:
+      g_value_set_string (value, dialog->priv->message);
+      break;
+
+    /* TODO: rest of the properties */
+
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+    }
+}
+
+static GtkWidget *
+add_row (GtkWidget *grid, int row, const char *label_text, GtkWidget *entry)
+{
+  GtkWidget *label;
+
+  label = gtk_label_new_with_mnemonic (label_text);
+  gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
+  gtk_label_set_xalign (GTK_LABEL (label), 1.0);
+  gtk_label_set_yalign (GTK_LABEL (label), 0.5);
+
+  gtk_widget_set_hexpand (label, FALSE);
+  gtk_grid_attach (GTK_GRID (grid), label,
+                   0, row, 1, 1);
+  gtk_widget_set_hexpand (entry, TRUE);
+  gtk_grid_attach (GTK_GRID (grid), entry,
+                   1, row, 1, 1);
+  gtk_label_set_mnemonic_widget (GTK_LABEL (label), entry);
+
+  return label;
+}
+
+static void
+action_id_activated (GtkLabel *url_label, gpointer user_data)
+{
+#if 0
+  GError *error;
+  DBusGConnection *bus;
+  DBusGProxy *manager_proxy;
+
+  error = NULL;
+  bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
+  if (bus == NULL)
+    {
+      g_warning ("Couldn't connect to session bus: %s", error->message);
+      g_error_free (error);
+      goto out;
+    }
+
+  manager_proxy = dbus_g_proxy_new_for_name (bus,
+                                             "org.mate.PolicyKit.AuthorizationManager",
+                                             "/",
+                                             "org.mate.PolicyKit.AuthorizationManager.SingleInstance");
+  if (manager_proxy == NULL)
+    {
+      g_warning ("Could not construct manager_proxy object; bailing out");
+      goto out;
+    }
+
+  if (!dbus_g_proxy_call (manager_proxy,
+                          "ShowAction",
+                          &error,
+                          G_TYPE_STRING, gtk_label_get_current_uri (GTK_LABEL (url_label)),
+                          G_TYPE_INVALID,
+                          G_TYPE_INVALID))
+    {
+      if (error != NULL)
+        {
+          g_warning ("Failed to call into manager: %s", error->message);
+          g_error_free (error);
+        }
+      else
+        {
+          g_warning ("Failed to call into manager");
+        }
+      goto out;
+    }
+
+out:
+        ;
+#endif
+}
+
+static void
+polkit_mate_authentication_dialog_init (PolkitMateAuthenticationDialog *dialog)
+{
+  dialog->priv = polkit_mate_authentication_dialog_get_instance_private (dialog);
+}
+
+static void
+polkit_mate_authentication_dialog_finalize (GObject *object)
+{
+  PolkitMateAuthenticationDialog *dialog;
+
+  dialog = POLKIT_MATE_AUTHENTICATION_DIALOG (object);
+
+  g_free (dialog->priv->message);
+  g_free (dialog->priv->action_id);
+  g_free (dialog->priv->vendor);
+  g_free (dialog->priv->vendor_url);
+  g_free (dialog->priv->icon_name);
+  if (dialog->priv->details != NULL)
+    g_object_unref (dialog->priv->details);
+
+  g_strfreev (dialog->priv->users);
+  g_free (dialog->priv->selected_user);
+
+  if (dialog->priv->store != NULL)
+    g_object_unref (dialog->priv->store);
+
+  if (G_OBJECT_CLASS (polkit_mate_authentication_dialog_parent_class)->finalize != NULL)
+    G_OBJECT_CLASS (polkit_mate_authentication_dialog_parent_class)->finalize (object);
+}
+
+static GtkWidget*
+polkit_mate_dialog_add_button (GtkDialog   *dialog,
+                               const gchar *button_text,
+                               const gchar *icon_name,
+                                     gint   response_id)
+{
+  GtkWidget *button;
+
+  button = gtk_button_new_with_mnemonic (button_text);
+  gtk_button_set_image (GTK_BUTTON (button), gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_BUTTON));
+
+  gtk_button_set_use_underline (GTK_BUTTON (button), TRUE);
+  gtk_style_context_add_class (gtk_widget_get_style_context (button), "text-button");
+  gtk_widget_set_can_default (button, TRUE);
+  gtk_widget_show (button);
+  gtk_dialog_add_action_widget (GTK_DIALOG (dialog), button, response_id);
+
+  return button;
+}
+
+static void
+polkit_mate_authentication_dialog_constructed (GObject *object)
+{
+  PolkitMateAuthenticationDialog *dialog;
+  GtkWidget *hbox;
+  GtkWidget *main_vbox;
+  GtkWidget *vbox;
+  GtkWidget *grid_password;
+  GtkWidget *details_expander;
+  GtkWidget *details_vbox;
+  GtkWidget *grid;
+  GtkWidget *label;
+  GtkWidget *image;
+  GtkWidget *content_area;
+  gboolean have_user_combobox;
+  gchar *s;
+  guint rows;
+
+  dialog = POLKIT_MATE_AUTHENTICATION_DIALOG (object);
+
+  if (G_OBJECT_CLASS (polkit_mate_authentication_dialog_parent_class)->constructed != NULL)
+    G_OBJECT_CLASS (polkit_mate_authentication_dialog_parent_class)->constructed (object);
+
+  have_user_combobox = FALSE;
+
+  dialog->priv->cancel_button = polkit_mate_dialog_add_button (GTK_DIALOG (dialog),
+                                                               _("_Cancel"),
+                                                               "process-stop",
+                                                               GTK_RESPONSE_CANCEL);
+
+  dialog->priv->auth_button = gtk_dialog_add_button (GTK_DIALOG (dialog),
+                                                     _("_Authenticate"),
+                                                     GTK_RESPONSE_OK);
+
+  gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
+
+  content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
+
+  gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
+  gtk_box_set_spacing (GTK_BOX (content_area), 2); /* 2 * 5 + 2 = 12 */
+  gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
+  gtk_window_set_icon_name (GTK_WINDOW (dialog), "dialog-password");
+
+  hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
+  gtk_container_set_border_width (GTK_CONTAINER (hbox), 5);
+  gtk_box_pack_start (GTK_BOX (content_area), hbox, TRUE, TRUE, 0);
+
+  image = get_image (dialog);
+  gtk_widget_set_halign (image, GTK_ALIGN_CENTER);
+  gtk_widget_set_valign (image, GTK_ALIGN_START);
+  gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0);
+
+  main_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 10);
+  gtk_box_pack_start (GTK_BOX (hbox), main_vbox, TRUE, TRUE, 0);
+
+  /* main message */
+  label = gtk_label_new (NULL);
+  s = g_strdup_printf ("<big><b>%s</b></big>", dialog->priv->message);
+  gtk_label_set_markup (GTK_LABEL (label), s);
+  g_free (s);
+
+  gtk_label_set_xalign (GTK_LABEL (label), 0.0);
+  gtk_label_set_yalign (GTK_LABEL (label), 0.5);
+  gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
+  gtk_label_set_max_width_chars (GTK_LABEL (label), 50);
+  gtk_box_pack_start (GTK_BOX (main_vbox), label, FALSE, FALSE, 0);
+
+  /* secondary message */
+  label = gtk_label_new (NULL);
+  if (g_strv_length (dialog->priv->users) > 1)
+    {
+          gtk_label_set_markup (GTK_LABEL (label),
+                                _("An application is attempting to perform an action that requires privileges. "
+                                  "Authentication as one of the users below is required to perform this action."));
+    }
+  else
+    {
+      if (strcmp (g_get_user_name (), dialog->priv->users[0]) == 0)
+        {
+          gtk_label_set_markup (GTK_LABEL (label),
+                                _("An application is attempting to perform an action that requires privileges. "
+                                  "Authentication is required to perform this action."));
+        }
+      else
+        {
+          gtk_label_set_markup (GTK_LABEL (label),
+                                _("An application is attempting to perform an action that requires privileges. "
+                                  "Authentication as the super user is required to perform this action."));
+        }
+    }
+
+  gtk_label_set_xalign (GTK_LABEL (label), 0.0);
+  gtk_label_set_yalign (GTK_LABEL (label), 0.5);
+  gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
+  gtk_label_set_max_width_chars (GTK_LABEL (label), 50);
+  gtk_box_pack_start (GTK_BOX (main_vbox), label, FALSE, FALSE, 0);
+
+  /* user combobox */
+  if (g_strv_length (dialog->priv->users) > 1)
+    {
+      dialog->priv->user_combobox = gtk_combo_box_new ();
+      gtk_box_pack_start (GTK_BOX (main_vbox), GTK_WIDGET (dialog->priv->user_combobox), FALSE, FALSE, 0);
+
+      create_user_combobox (dialog);
+
+      have_user_combobox = TRUE;
+    }
+  else
+    {
+      dialog->priv->selected_user = g_strdup (dialog->priv->users[0]);
+    }
+
+  /* password entry */
+  vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
+  gtk_box_pack_start (GTK_BOX (main_vbox), vbox, FALSE, FALSE, 0);
+
+  grid_password = gtk_grid_new ();
+  gtk_grid_set_column_spacing (GTK_GRID (grid_password), 12);
+  gtk_grid_set_row_spacing (GTK_GRID (grid_password), 6);
+  gtk_box_pack_start (GTK_BOX (vbox), grid_password, FALSE, FALSE, 0);
+  dialog->priv->password_entry = gtk_entry_new ();
+  gtk_entry_set_visibility (GTK_ENTRY (dialog->priv->password_entry), FALSE);
+  dialog->priv->prompt_label = add_row (grid_password, 0, _("_Password:"), dialog->priv->password_entry);
+
+  g_signal_connect_swapped (dialog->priv->password_entry, "activate",
+                            G_CALLBACK (gtk_window_activate_default),
+                            dialog);
+
+  dialog->priv->grid_password = grid_password;
+  /* initially never show the password entry stuff; we'll toggle it on/off so it's
+   * only shown when prompting for a password */
+  gtk_widget_set_no_show_all (dialog->priv->grid_password, TRUE);
+
+  /* A label for showing PAM_TEXT_INFO and PAM_TEXT_ERROR messages */
+  label = gtk_label_new (NULL);
+  gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
+  gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
+  dialog->priv->info_label = label;
+
+  /* Details */
+  details_expander = gtk_expander_new_with_mnemonic (_("<small><b>_Details</b></small>"));
+  gtk_expander_set_use_markup (GTK_EXPANDER (details_expander), TRUE);
+  gtk_box_pack_start (GTK_BOX (content_area), details_expander, FALSE, FALSE, 0);
+
+  details_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 10);
+  gtk_container_add (GTK_CONTAINER (details_expander), details_vbox);
+
+  grid = gtk_grid_new ();
+  gtk_widget_set_margin_start (grid, 20);
+  gtk_grid_set_column_spacing (GTK_GRID (grid), 12);
+  gtk_grid_set_row_spacing (GTK_GRID (grid), 6);
+  gtk_box_pack_start (GTK_BOX (details_vbox), grid, FALSE, FALSE, 0);
+
+  /* TODO: sort keys? */
+  rows = 0;
+  if (dialog->priv->details != NULL)
+    {
+      guint n;
+      gchar **keys;
+
+      keys = polkit_details_get_keys (dialog->priv->details);
+      for (n = 0; keys[n] != NULL; n++)
+        {
+          const gchar *key = keys[n];
+          const gchar *value;
+
+          value = polkit_details_lookup (dialog->priv->details, key);
+
+          label = gtk_label_new (NULL);
+          s = g_strdup_printf ("<small>%s</small>", value);
+          gtk_label_set_markup (GTK_LABEL (label), s);
+          g_free (s);
+
+          gtk_label_set_xalign (GTK_LABEL (label), 0.0);
+          gtk_label_set_yalign (GTK_LABEL (label), 1.0);
+
+          s = g_strdup_printf ("<small><b>%s:</b></small>", key);
+          add_row (grid, rows, s, label);
+          g_free (s);
+
+          rows++;
+        }
+      g_strfreev (keys);
+    }
+
+  /* --- */
+
+  label = gtk_label_new (NULL);
+  gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
+  s = g_strdup_printf ("<small><a href=\"%s\">%s</a></small>",
+                       dialog->priv->action_id,
+                       dialog->priv->action_id);
+  gtk_label_set_markup (GTK_LABEL (label), s);
+  g_free (s);
+
+  gtk_label_set_xalign (GTK_LABEL (label), 0.0);
+  gtk_label_set_yalign (GTK_LABEL (label), 1.0);
+
+  add_row (grid, rows++, _("<small><b>Action:</b></small>"), label);
+  g_signal_connect (label, "activate-link", G_CALLBACK (action_id_activated), NULL);
+
+  s = g_strdup_printf (_("Click to edit %s"), dialog->priv->action_id);
+  gtk_widget_set_tooltip_markup (label, s);
+  g_free (s);
+
+  /* --- */
+
+  label = gtk_label_new (NULL);
+  gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
+  s = g_strdup_printf ("<small><a href=\"%s\">%s</a></small>",
+                       dialog->priv->vendor_url,
+                       dialog->priv->vendor);
+  gtk_label_set_markup (GTK_LABEL (label), s);
+  g_free (s);
+
+  gtk_label_set_xalign (GTK_LABEL (label), 0.0);
+  gtk_label_set_yalign (GTK_LABEL (label), 1.0);
+
+  add_row (grid, rows++, _("<small><b>Vendor:</b></small>"), label);
+
+  s = g_strdup_printf (_("Click to open %s"), dialog->priv->vendor_url);
+  gtk_widget_set_tooltip_markup (label, s);
+  g_free (s);
+
+  /* Disable password entry and authenticate until have a user selected */
+  if (have_user_combobox && gtk_combo_box_get_active (GTK_COMBO_BOX (dialog->priv->user_combobox)) == 0)
+    {
+      gtk_widget_set_sensitive (dialog->priv->prompt_label, FALSE);
+      gtk_widget_set_sensitive (dialog->priv->password_entry, FALSE);
+      gtk_widget_set_sensitive (dialog->priv->auth_button, FALSE);
+    }
+
+  gtk_widget_realize (GTK_WIDGET (dialog));
+
+}
+
+static void
+polkit_mate_authentication_dialog_class_init (PolkitMateAuthenticationDialogClass *klass)
+{
+  GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+
+  gobject_class->finalize = polkit_mate_authentication_dialog_finalize;
+  gobject_class->get_property = polkit_mate_authentication_dialog_get_property;
+  gobject_class->set_property = polkit_mate_authentication_dialog_set_property;
+  gobject_class->constructed  = polkit_mate_authentication_dialog_constructed;
+
+  g_object_class_install_property (gobject_class,
+                                   PROP_DETAILS,
+                                   g_param_spec_object ("details",
+                                                        NULL,
+                                                        NULL,
+                                                        POLKIT_TYPE_DETAILS,
+                                                        G_PARAM_READWRITE |
+                                                        G_PARAM_CONSTRUCT_ONLY |
+                                                        G_PARAM_STATIC_NAME |
+                                                        G_PARAM_STATIC_NICK |
+                                                        G_PARAM_STATIC_BLURB));
+
+  g_object_class_install_property (gobject_class,
+                                   PROP_ACTION_ID,
+                                   g_param_spec_string ("action-id",
+                                                        NULL,
+                                                        NULL,
+                                                        NULL,
+                                                        G_PARAM_READWRITE |
+                                                        G_PARAM_CONSTRUCT_ONLY |
+                                                        G_PARAM_STATIC_NAME |
+                                                        G_PARAM_STATIC_NICK |
+                                                        G_PARAM_STATIC_BLURB));
+
+  g_object_class_install_property (gobject_class,
+                                   PROP_VENDOR,
+                                   g_param_spec_string ("vendor",
+                                                        NULL,
+                                                        NULL,
+                                                        NULL,
+                                                        G_PARAM_READWRITE |
+                                                        G_PARAM_CONSTRUCT_ONLY |
+                                                        G_PARAM_STATIC_NAME |
+                                                        G_PARAM_STATIC_NICK |
+                                                        G_PARAM_STATIC_BLURB));
+
+  g_object_class_install_property (gobject_class,
+                                   PROP_VENDOR_URL,
+                                   g_param_spec_string ("vendor-url",
+                                                        NULL,
+                                                        NULL,
+                                                        NULL,
+                                                        G_PARAM_READWRITE |
+                                                        G_PARAM_CONSTRUCT_ONLY |
+                                                        G_PARAM_STATIC_NAME |
+                                                        G_PARAM_STATIC_NICK |
+                                                        G_PARAM_STATIC_BLURB));
+
+  g_object_class_install_property (gobject_class,
+                                   PROP_ICON_NAME,
+                                   g_param_spec_string ("icon-name",
+                                                        NULL,
+                                                        NULL,
+                                                        NULL,
+                                                        G_PARAM_READWRITE |
+                                                        G_PARAM_CONSTRUCT_ONLY |
+                                                        G_PARAM_STATIC_NAME |
+                                                        G_PARAM_STATIC_NICK |
+                                                        G_PARAM_STATIC_BLURB));
+
+  g_object_class_install_property (gobject_class,
+                                   PROP_MESSAGE,
+                                   g_param_spec_string ("message",
+                                                        NULL,
+                                                        NULL,
+                                                        NULL,
+                                                        G_PARAM_READWRITE |
+                                                        G_PARAM_CONSTRUCT_ONLY |
+                                                        G_PARAM_STATIC_NAME |
+                                                        G_PARAM_STATIC_NICK |
+                                                        G_PARAM_STATIC_BLURB));
+
+  g_object_class_install_property (gobject_class,
+                                   PROP_USERS,
+                                   g_param_spec_boxed ("users",
+                                                       NULL,
+                                                       NULL,
+                                                       G_TYPE_STRV,
+                                                       G_PARAM_READWRITE |
+                                                       G_PARAM_CONSTRUCT_ONLY |
+                                                       G_PARAM_STATIC_NAME |
+                                                       G_PARAM_STATIC_NICK |
+                                                       G_PARAM_STATIC_BLURB));
+
+  g_object_class_install_property (gobject_class,
+                                   PROP_SELECTED_USER,
+                                   g_param_spec_string ("selected-user",
+                                                        NULL,
+                                                        NULL,
+                                                        NULL,
+                                                        G_PARAM_READABLE |
+                                                        G_PARAM_STATIC_NAME |
+                                                        G_PARAM_STATIC_NICK |
+                                                        G_PARAM_STATIC_BLURB));
+}
+
+/**
+ * polkit_mate_authentication_dialog_new:
+ *
+ * Yada yada yada...
+ *
+ * Returns: A new password dialog.
+ **/
+GtkWidget *
+polkit_mate_authentication_dialog_new (const gchar    *action_id,
+                                        const gchar    *vendor,
+                                        const gchar    *vendor_url,
+                                        const gchar    *icon_name,
+                                        const gchar    *message_markup,
+                                        PolkitDetails  *details,
+                                        gchar         **users)
+{
+  PolkitMateAuthenticationDialog *dialog;
+  GtkWindow *window;
+
+  dialog = g_object_new (POLKIT_MATE_TYPE_AUTHENTICATION_DIALOG,
+                         "action-id", action_id,
+                         "vendor", vendor,
+                         "vendor-url", vendor_url,
+                         "icon-name", icon_name,
+                         "message", message_markup,
+                         "details", details,
+                         "users", users,
+                         NULL);
+
+  window = GTK_WINDOW (dialog);
+
+  gtk_window_set_position (window, GTK_WIN_POS_CENTER);
+  gtk_window_set_modal (window, TRUE);
+  gtk_window_set_resizable (window, FALSE);
+  gtk_window_set_keep_above (window, TRUE);
+  gtk_window_set_title (window, _("Authenticate"));
+  g_signal_connect (dialog, "close", G_CALLBACK (gtk_widget_hide), NULL);
+
+  return GTK_WIDGET (dialog);
+}
+
+/**
+ * polkit_mate_authentication_dialog_indicate_error:
+ * @dialog: the auth dialog
+ *
+ * Call this function to indicate an authentication error; typically shakes the window
+ **/
+void
+polkit_mate_authentication_dialog_indicate_error (PolkitMateAuthenticationDialog *dialog)
+{
+  int x, y;
+  int n;
+  int diff;
+
+  /* TODO: detect compositing manager and do fancy stuff here */
+
+  gtk_window_get_position (GTK_WINDOW (dialog), &x, &y);
+
+  for (n = 0; n < 10; n++)
+    {
+      if (n % 2 == 0)
+        diff = -15;
+      else
+        diff = 15;
+
+      gtk_window_move (GTK_WINDOW (dialog), x + diff, y);
+
+      while (gtk_events_pending ())
+        {
+          gtk_main_iteration ();
+        }
+
+      g_usleep (10000);
+    }
+
+  gtk_window_move (GTK_WINDOW (dialog), x, y);
+}
+
+/**
+ * polkit_mate_authentication_dialog_run_until_user_is_selected:
+ * @dialog: A #PolkitMateAuthenticationDialog.
+ *
+ * Runs @dialog in a recursive main loop until a user have been selected.
+ *
+ * If there is only one element in the the users array (which is set upon construction) or
+ * an user has already been selected, this function returns immediately with the return
+ * value %TRUE.
+ *
+ * Returns: %TRUE if a user is selected (use polkit_mate_dialog_get_selected_user() to obtain the user) or
+ *          %FALSE if the dialog was cancelled.
+ **/
+gboolean
+polkit_mate_authentication_dialog_run_until_user_is_selected (PolkitMateAuthenticationDialog *dialog)
+{
+  gboolean ret;
+  gint response;
+
+  ret = FALSE;
+
+  if (dialog->priv->selected_user != NULL)
+    {
+      ret = TRUE;
+      goto out;
+    }
+
+  dialog->priv->is_running = TRUE;
+
+  response = gtk_dialog_run (GTK_DIALOG (dialog));
+
+  dialog->priv->is_running = FALSE;
+
+  if (response == RESPONSE_USER_SELECTED)
+    ret = TRUE;
+
+ out:
+  return ret;
+}
+
+/**
+ * polkit_mate_authentication_dialog_run_until_response_for_prompt:
+ * @dialog: A #PolkitMateAuthenticationDialog.
+ * @prompt: The prompt to present the user with.
+ * @echo_chars: Whether characters should be echoed in the password entry box.
+ * @was_cancelled: Set to %TRUE if the dialog was cancelled.
+ * @new_user_selected: Set to %TRUE if another user was selected.
+ *
+ * Runs @dialog in a recursive main loop until a response to @prompt have been obtained from the user.
+ *
+ * Returns: The response (free with g_free()) or %NULL if one of @was_cancelled or @new_user_selected
+ *          has been set to %TRUE.
+ **/
+gchar *
+polkit_mate_authentication_dialog_run_until_response_for_prompt (PolkitMateAuthenticationDialog *dialog,
+                                                                  const gchar           *prompt,
+                                                                  gboolean               echo_chars,
+                                                                  gboolean              *was_cancelled,
+                                                                  gboolean              *new_user_selected)
+{
+  gint response;
+  gchar *ret;
+
+  gtk_label_set_text_with_mnemonic (GTK_LABEL (dialog->priv->prompt_label), prompt);
+  gtk_entry_set_visibility (GTK_ENTRY (dialog->priv->password_entry), echo_chars);
+  gtk_entry_set_text (GTK_ENTRY (dialog->priv->password_entry), "");
+  gtk_widget_grab_focus (dialog->priv->password_entry);
+
+  ret = NULL;
+
+  if (was_cancelled != NULL)
+    *was_cancelled = FALSE;
+
+  if (new_user_selected != NULL)
+    *new_user_selected = FALSE;
+
+  dialog->priv->is_running = TRUE;
+
+  gtk_widget_set_no_show_all (dialog->priv->grid_password, FALSE);
+  gtk_widget_show_all (dialog->priv->grid_password);
+
+  response = gtk_dialog_run (GTK_DIALOG (dialog));
+
+  gtk_widget_hide (dialog->priv->grid_password);
+  gtk_widget_set_no_show_all (dialog->priv->grid_password, TRUE);
+
+  dialog->priv->is_running = FALSE;
+
+  if (response == GTK_RESPONSE_OK)
+    {
+      ret = g_strdup (gtk_entry_get_text (GTK_ENTRY (dialog->priv->password_entry)));
+    }
+  else if (response == RESPONSE_USER_SELECTED)
+    {
+      if (new_user_selected != NULL)
+        *new_user_selected = TRUE;
+    }
+  else
+    {
+      if (was_cancelled != NULL)
+        *was_cancelled = TRUE;
+    }
+
+  return ret;
+}
+
+/**
+ * polkit_mate_authentication_dialog_get_selected_user:
+ * @dialog: A #PolkitMateAuthenticationDialog.
+ *
+ * Gets the currently selected user.
+ *
+ * Returns: The currently selected user (free with g_free()) or %NULL if no user is currently selected.
+ **/
+gchar *
+polkit_mate_authentication_dialog_get_selected_user (PolkitMateAuthenticationDialog *dialog)
+{
+  return g_strdup (dialog->priv->selected_user);
+}
+
+void
+polkit_mate_authentication_dialog_set_info_message (PolkitMateAuthenticationDialog *dialog,
+                                                     const gchar                     *info_markup)
+{
+  gtk_label_set_markup (GTK_LABEL (dialog->priv->info_label), info_markup);
+}
+
+/**
+ * polkit_mate_authentication_dialog_cancel:
+ * @dialog: A #PolkitMateAuthenticationDialog.
+ *
+ * Cancels the dialog if it is currenlty running.
+ *
+ * Returns: %TRUE if the dialog was running.
+ **/
+gboolean
+polkit_mate_authentication_dialog_cancel (PolkitMateAuthenticationDialog *dialog)
+{
+  if (!dialog->priv->is_running)
+    return FALSE;
+
+  gtk_dialog_response (GTK_DIALOG (dialog), GTK_RESPONSE_CANCEL);
+
+  return TRUE;
+}
+
+ +
+ +
+ + diff --git a/2024-02-15-173245-9368-cppcheck@aacfb22a55ce_master/3.html b/2024-02-15-173245-9368-cppcheck@aacfb22a55ce_master/3.html new file mode 100644 index 0000000..6ad06dd --- /dev/null +++ b/2024-02-15-173245-9368-cppcheck@aacfb22a55ce_master/3.html @@ -0,0 +1,393 @@ + + + + + + Cppcheck - HTML report - mate-polkit + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
+78
/*
+ * Copyright (C) 2009 Red Hat, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ * Author: David Zeuthen <davidz@redhat.com>
+ */
+
+#ifndef __POLKIT_MATE_AUTHENTICATION_DIALOG_H
+#define __POLKIT_MATE_AUTHENTICATION_DIALOG_H
+
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <polkit/polkit.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define POLKIT_MATE_TYPE_AUTHENTICATION_DIALOG            (polkit_mate_authentication_dialog_get_type ())
+#define POLKIT_MATE_AUTHENTICATION_DIALOG(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), POLKIT_MATE_TYPE_AUTHENTICATION_DIALOG, PolkitMateAuthenticationDialog))
+#define POLKIT_MATE_AUTHENTICATION_DIALOG_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), POLKIT_MATE_TYPE_AUTHENTICATION_DIALOG, PolkitMateAuthenticationDialogClass))
+#define POLKIT_MATE_IS_AUTHENTICATION_DIALOG(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), POLKIT_MATE_TYPE_AUTHENTICATION_DIALOG))
+#define POLKIT_MATE_IS_AUTHENTICATION_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), POLKIT_MATE_TYPE_AUTHENTICATION_DIALOG))
+
+typedef struct _PolkitMateAuthenticationDialog        PolkitMateAuthenticationDialog;
+typedef struct _PolkitMateAuthenticationDialogClass   PolkitMateAuthenticationDialogClass;
+typedef struct _PolkitMateAuthenticationDialogPrivate PolkitMateAuthenticationDialogPrivate;
+
+struct _PolkitMateAuthenticationDialog
+{
+  GtkDialog parent_instance;
+  PolkitMateAuthenticationDialogPrivate *priv;
+};
+
+struct _PolkitMateAuthenticationDialogClass
+{
+  GtkDialogClass parent_class;
+};
+
+GType      polkit_mate_authentication_dialog_get_type                      (void);
+GtkWidget *polkit_mate_authentication_dialog_new                           (const gchar    *action_id,
+                                                                             const gchar    *vendor,
+                                                                             const gchar    *vendor_url,
+                                                                             const gchar    *icon_name,
+                                                                             const gchar    *message_markup,
+                                                                             PolkitDetails  *details,
+                                                                             gchar         **users);
+gchar     *polkit_mate_authentication_dialog_get_selected_user             (PolkitMateAuthenticationDialog *dialog);
+gboolean   polkit_mate_authentication_dialog_run_until_user_is_selected    (PolkitMateAuthenticationDialog *dialog);
+gchar     *polkit_mate_authentication_dialog_run_until_response_for_prompt (PolkitMateAuthenticationDialog *dialog,
+                                                                             const gchar                     *prompt,
+                                                                             gboolean                         echo_chars,
+                                                                             gboolean                        *was_cancelled,
+                                                                             gboolean                        *new_user_selected);
+gboolean   polkit_mate_authentication_dialog_cancel                        (PolkitMateAuthenticationDialog *dialog);
+void       polkit_mate_authentication_dialog_indicate_error                (PolkitMateAuthenticationDialog *dialog);
+void       polkit_mate_authentication_dialog_set_info_message              (PolkitMateAuthenticationDialog *dialog,
+                                                                             const gchar                     *info_markup);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __POLKIT_MATE_AUTHENTICATION_DIALOG_H */
+
+ +
+ +
+ + diff --git a/2024-02-15-173245-9368-cppcheck@aacfb22a55ce_master/4.html b/2024-02-15-173245-9368-cppcheck@aacfb22a55ce_master/4.html new file mode 100644 index 0000000..67c8d37 --- /dev/null +++ b/2024-02-15-173245-9368-cppcheck@aacfb22a55ce_master/4.html @@ -0,0 +1,1269 @@ + + + + + + Cppcheck - HTML report - mate-polkit + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
/*
+ * Copyright (C) 2009 Red Hat, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ * Author: David Zeuthen <davidz@redhat.com>
+ */
+
+#include "config.h"<--- Include file: "config.h" not found.
+
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/types.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <pwd.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gdk/gdkx.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <polkit/polkit.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <polkitagent/polkitagent.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "polkitmateauthenticator.h"
+#include "polkitmateauthenticationdialog.h"
+
+struct _PolkitMateAuthenticator
+{
+  GObject parent_instance;
+
+  PolkitAuthority *authority;
+  gchar *action_id;
+  gchar *message;
+  gchar *icon_name;
+  PolkitDetails *details;
+  gchar *cookie;
+  GList *identities;
+
+  PolkitActionDescription *action_desc;
+  gchar **users;
+
+  gboolean gained_authorization;
+  gboolean was_cancelled;
+  gboolean new_user_selected;
+  gchar *selected_user;
+
+  PolkitAgentSession *session;
+  GtkWidget *dialog;
+  GMainLoop *loop;
+};
+
+struct _PolkitMateAuthenticatorClass
+{
+  GObjectClass parent_class;
+
+};
+
+enum
+{
+  COMPLETED_SIGNAL,
+  LAST_SIGNAL,
+};
+
+static guint signals[LAST_SIGNAL] = {0};
+
+G_DEFINE_TYPE (PolkitMateAuthenticator, polkit_mate_authenticator, G_TYPE_OBJECT);
+
+static void
+polkit_mate_authenticator_init (PolkitMateAuthenticator *authenticator)
+{
+}
+
+static void
+polkit_mate_authenticator_finalize (GObject *object)
+{
+  PolkitMateAuthenticator *authenticator;
+
+  authenticator = POLKIT_MATE_AUTHENTICATOR (object);
+
+  if (authenticator->authority != NULL)
+    g_object_unref (authenticator->authority);
+  g_free (authenticator->action_id);
+  g_free (authenticator->message);
+  g_free (authenticator->icon_name);
+  if (authenticator->details != NULL)
+    g_object_unref (authenticator->details);
+  g_free (authenticator->cookie);
+  g_list_foreach (authenticator->identities, (GFunc) g_object_unref, NULL);
+  g_list_free (authenticator->identities);
+
+  if (authenticator->action_desc != NULL)
+    g_object_unref (authenticator->action_desc);
+  g_strfreev (authenticator->users);
+
+  g_free (authenticator->selected_user);
+  if (authenticator->session != NULL)
+    g_object_unref (authenticator->session);
+  if (authenticator->dialog != NULL)
+    gtk_widget_destroy (authenticator->dialog);
+  if (authenticator->loop != NULL)
+    g_main_loop_unref (authenticator->loop);
+
+  if (G_OBJECT_CLASS (polkit_mate_authenticator_parent_class)->finalize != NULL)
+    G_OBJECT_CLASS (polkit_mate_authenticator_parent_class)->finalize (object);
+}
+
+static void
+polkit_mate_authenticator_class_init (PolkitMateAuthenticatorClass *klass)
+{
+  GObjectClass *gobject_class;
+
+  gobject_class = G_OBJECT_CLASS (klass);
+
+  gobject_class->finalize = polkit_mate_authenticator_finalize;
+
+  /**
+   * PolkitMateAuthenticator::completed:
+   * @authenticator: A #PolkitMateAuthenticator.
+   * @gained_authorization: Whether the authorization was gained.
+   * @dismissed: Whether the dialog was dismissed.
+   *
+   * Emitted when the authentication is completed. The user is supposed to dispose of @authenticator
+   * upon receiving this signal.
+   **/
+  signals[COMPLETED_SIGNAL] = g_signal_new ("completed",
+                                            POLKIT_MATE_TYPE_AUTHENTICATOR,
+                                            G_SIGNAL_RUN_LAST,
+                                            0,                      /* class offset     */
+                                            NULL,                   /* accumulator      */
+                                            NULL,                   /* accumulator data */
+                                            g_cclosure_marshal_generic,
+                                            G_TYPE_NONE,
+                                            2,
+					    G_TYPE_BOOLEAN,
+                                            G_TYPE_BOOLEAN);
+}
+
+static PolkitActionDescription *
+get_desc_for_action (PolkitAuthority *authority,
+                     const gchar     *action_id)
+{
+  GList *action_descs;
+  GList *l;
+  PolkitActionDescription *result;
+
+  result = NULL;
+
+  action_descs = polkit_authority_enumerate_actions_sync (authority,
+                                                          NULL,
+                                                          NULL);
+  for (l = action_descs; l != NULL; l = l->next)
+    {
+      PolkitActionDescription *action_desc = POLKIT_ACTION_DESCRIPTION (l->data);
+
+      if (strcmp (polkit_action_description_get_action_id (action_desc), action_id) == 0)
+        {
+          result = g_object_ref (action_desc);
+          goto out;
+        }
+    }
+
+ out:
+
+  g_list_foreach (action_descs, (GFunc) g_object_unref, NULL);
+  g_list_free (action_descs);
+
+  return result;
+}
+
+static void
+on_dialog_deleted (GtkWidget *widget,
+                   GdkEvent  *event,
+                   gpointer   user_data)
+{
+  PolkitMateAuthenticator *authenticator = POLKIT_MATE_AUTHENTICATOR (user_data);
+
+  polkit_mate_authenticator_cancel (authenticator);
+}
+
+static void
+on_user_selected (GObject    *object,
+                  GParamSpec *pspec,
+                  gpointer    user_data)
+{
+  PolkitMateAuthenticator *authenticator = POLKIT_MATE_AUTHENTICATOR (user_data);
+
+  /* clear any previous messages */
+  polkit_mate_authentication_dialog_set_info_message (POLKIT_MATE_AUTHENTICATION_DIALOG (authenticator->dialog), "");
+
+  polkit_mate_authenticator_cancel (authenticator);
+  authenticator->new_user_selected = TRUE;
+}
+
+PolkitMateAuthenticator *
+polkit_mate_authenticator_new (const gchar     *action_id,
+                                const gchar     *message,
+                                const gchar     *icon_name,
+                                PolkitDetails   *details,
+                                const gchar     *cookie,
+                                GList           *identities)
+{
+  PolkitMateAuthenticator *authenticator;
+  GList *l;
+  guint n;
+  GError *error;
+
+  authenticator = POLKIT_MATE_AUTHENTICATOR (g_object_new (POLKIT_MATE_TYPE_AUTHENTICATOR, NULL));
+
+  error = NULL;
+  authenticator->authority = polkit_authority_get_sync (NULL /* GCancellable* */, &error);
+  if (authenticator->authority == NULL)
+    {
+      g_critical ("Error getting authority: %s", error->message);
+      g_error_free (error);
+      goto error;
+    }
+
+  authenticator->action_id = g_strdup (action_id);
+  authenticator->message = g_strdup (message);
+  authenticator->icon_name = g_strdup (icon_name);
+  if (details != NULL)
+    authenticator->details = g_object_ref (details);
+  authenticator->cookie = g_strdup (cookie);
+  authenticator->identities = g_list_copy (identities);
+  g_list_foreach (authenticator->identities, (GFunc) g_object_ref, NULL);
+
+  authenticator->action_desc = get_desc_for_action (authenticator->authority,
+                                                    authenticator->action_id);
+  if (authenticator->action_desc == NULL)
+    goto error;
+
+  authenticator->users = g_new0 (gchar *, g_list_length (authenticator->identities) + 1);
+  for (l = authenticator->identities, n = 0; l != NULL; l = l->next, n++)
+    {
+      PolkitUnixUser *user = POLKIT_UNIX_USER (l->data);
+      uid_t uid;
+      struct passwd *passwd;
+
+      uid = polkit_unix_user_get_uid (user);
+      passwd = getpwuid (uid);
+      authenticator->users[n] = g_strdup (passwd->pw_name);
+    }
+
+  authenticator->dialog = polkit_mate_authentication_dialog_new
+                            (authenticator->action_id,
+                             polkit_action_description_get_vendor_name (authenticator->action_desc),
+                             polkit_action_description_get_vendor_url (authenticator->action_desc),
+                             authenticator->icon_name,
+                             authenticator->message,
+                             authenticator->details,
+                             authenticator->users);
+  g_signal_connect (authenticator->dialog,
+                    "delete-event",
+                    G_CALLBACK (on_dialog_deleted),
+                    authenticator);
+  g_signal_connect (authenticator->dialog,
+                    "notify::selected-user",
+                    G_CALLBACK (on_user_selected),
+                    authenticator);
+
+  return authenticator;
+
+ error:
+  g_object_unref (authenticator);
+  return NULL;
+}
+
+static void
+session_request (PolkitAgentSession *session,
+                 const char         *request,
+                 gboolean            echo_on,
+                 gpointer            user_data)
+{
+  PolkitMateAuthenticator *authenticator = POLKIT_MATE_AUTHENTICATOR (user_data);
+  gchar *password;
+  gchar *modified_request;
+
+  password = NULL;
+
+  //g_debug ("in conversation_pam_prompt, request='%s', echo_on=%d", request, echo_on);
+
+  /* Fix up, and localize, password prompt if it's password auth */
+  if (g_ascii_strncasecmp (request, "password:", 9) == 0)
+    {
+      if (strcmp (g_get_user_name (), authenticator->selected_user) != 0)
+        {
+          modified_request = g_strdup_printf (_("_Password for %s:"), authenticator->selected_user);
+        }
+      else
+        {
+          modified_request = g_strdup (_("_Password:"));
+        }
+    }
+  else
+    {
+      modified_request = g_strdup (request);
+    }
+
+  gtk_widget_show_all (GTK_WIDGET (authenticator->dialog));
+  if (GDK_IS_X11_WINDOW (gtk_widget_get_window (GTK_WIDGET (authenticator->dialog))))
+    gtk_window_present_with_time (GTK_WINDOW (authenticator->dialog),
+                                  gdk_x11_get_server_time (gtk_widget_get_window (GTK_WIDGET (authenticator->dialog))));
+  else
+    gtk_window_present (GTK_WINDOW (authenticator->dialog));
+
+  password = polkit_mate_authentication_dialog_run_until_response_for_prompt (POLKIT_MATE_AUTHENTICATION_DIALOG (authenticator->dialog),
+                                                                               modified_request,
+                                                                               echo_on,
+                                                                               &authenticator->was_cancelled,
+                                                                               &authenticator->new_user_selected);
+
+  /* cancel auth unless user provided a password */
+  if (password == NULL)
+    {
+      polkit_mate_authenticator_cancel (authenticator);
+      goto out;
+    }
+  else
+    {
+      polkit_agent_session_response (authenticator->session, password);
+      g_free (password);
+    }
+
+out:
+  g_free (modified_request);
+}
+
+static void
+session_show_error (PolkitAgentSession *session,
+                    const gchar        *msg,
+                    gpointer            user_data)
+{
+  PolkitMateAuthenticator *authenticator = POLKIT_MATE_AUTHENTICATOR (user_data);
+  gchar *s;
+
+  s = g_strconcat ("<b>", msg, "</b>", NULL);
+  polkit_mate_authentication_dialog_set_info_message (POLKIT_MATE_AUTHENTICATION_DIALOG (authenticator->dialog), s);
+  g_free (s);
+}
+
+static void
+session_show_info (PolkitAgentSession *session,
+                   const gchar        *msg,
+                   gpointer            user_data)
+{
+  PolkitMateAuthenticator *authenticator = POLKIT_MATE_AUTHENTICATOR (user_data);
+  gchar *s;
+
+  s = g_strconcat ("<b>", msg, "</b>", NULL);
+  polkit_mate_authentication_dialog_set_info_message (POLKIT_MATE_AUTHENTICATION_DIALOG (authenticator->dialog), s);
+  g_free (s);
+
+  gtk_widget_show_all (GTK_WIDGET (authenticator->dialog));
+  gtk_window_present (GTK_WINDOW (authenticator->dialog));
+}
+
+static void
+session_completed (PolkitAgentSession *session,
+                   gboolean            gained_authorization,
+                   gpointer            user_data)
+{
+  PolkitMateAuthenticator *authenticator = POLKIT_MATE_AUTHENTICATOR (user_data);
+
+  authenticator->gained_authorization = gained_authorization;
+
+  //g_debug ("in conversation_done gained=%d", gained_authorization);
+
+  g_main_loop_quit (authenticator->loop);
+}
+
+static gboolean
+do_initiate (gpointer user_data)
+{
+  PolkitMateAuthenticator *authenticator = POLKIT_MATE_AUTHENTICATOR (user_data);
+  PolkitIdentity *identity;
+  gint num_tries;
+
+  gtk_widget_show_all (GTK_WIDGET (authenticator->dialog));
+  gtk_window_present (GTK_WINDOW (authenticator->dialog));
+  if (!polkit_mate_authentication_dialog_run_until_user_is_selected (POLKIT_MATE_AUTHENTICATION_DIALOG (authenticator->dialog)))
+    {
+      /* user cancelled the dialog */
+      /*g_debug ("User cancelled before selecting a user");*/
+      authenticator->was_cancelled = TRUE;
+      goto out;
+    }
+
+  authenticator->loop = g_main_loop_new (NULL, TRUE);
+
+  num_tries = 0;
+
+ try_again:
+
+  g_free (authenticator->selected_user);
+  authenticator->selected_user = polkit_mate_authentication_dialog_get_selected_user (POLKIT_MATE_AUTHENTICATION_DIALOG (authenticator->dialog));
+
+  /*g_debug ("Authenticating user %s", authenticator->selected_user);*/
+  identity = polkit_unix_user_new_for_name (authenticator->selected_user, NULL);
+
+  authenticator->session = polkit_agent_session_new (identity, authenticator->cookie);
+
+  g_object_unref (identity);
+
+  g_signal_connect (authenticator->session,
+                    "request",
+                    G_CALLBACK (session_request),
+                    authenticator);
+
+  g_signal_connect (authenticator->session,
+                    "show-info",
+                    G_CALLBACK (session_show_info),
+                    authenticator);
+
+  g_signal_connect (authenticator->session,
+                    "show-error",
+                    G_CALLBACK (session_show_error),
+                    authenticator);
+
+  g_signal_connect (authenticator->session,
+                    "completed",
+                    G_CALLBACK (session_completed),
+                    authenticator);
+
+  polkit_agent_session_initiate (authenticator->session);
+
+  g_main_loop_run (authenticator->loop);
+
+  /*g_debug ("gained_authorization=%d was_cancelled=%d new_user_selected=%d.",
+           authenticator->gained_authorization,
+           authenticator->was_cancelled,
+           authenticator->new_user_selected);*/
+
+  if (authenticator->new_user_selected)
+    {
+      /*g_debug ("New user selected");*/
+      authenticator->new_user_selected = FALSE;
+      g_object_unref (authenticator->session);
+      authenticator->session = NULL;
+      goto try_again;
+    }
+
+  num_tries++;
+
+  if (!authenticator->gained_authorization && !authenticator->was_cancelled)
+    {
+      if (authenticator->dialog != NULL)
+        {
+          gchar *s;
+
+          s = g_strconcat ("<b>", _("Your authentication attempt was unsuccessful. Please try again."), "</b>", NULL);
+          polkit_mate_authentication_dialog_set_info_message (
+                                  POLKIT_MATE_AUTHENTICATION_DIALOG (authenticator->dialog),
+                                  s);
+          g_free (s);
+          gtk_widget_queue_draw (authenticator->dialog);
+
+          /* shake the dialog to indicate error */
+          polkit_mate_authentication_dialog_indicate_error (POLKIT_MATE_AUTHENTICATION_DIALOG (authenticator->dialog));
+
+          if (num_tries < 3)
+            {
+              g_object_unref (authenticator->session);
+              authenticator->session = NULL;
+              goto try_again;
+            }
+        }
+    }
+
+ out:
+  g_signal_emit_by_name (authenticator,
+                         "completed",
+                         authenticator->gained_authorization,
+                         authenticator->was_cancelled);
+
+  g_object_unref (authenticator);
+
+  return FALSE;
+}
+
+void
+polkit_mate_authenticator_initiate (PolkitMateAuthenticator *authenticator)
+{
+  /* run from idle since we're going to block the main loop in the dialog (which has a recursive mainloop) */
+  g_idle_add (do_initiate, g_object_ref (authenticator));
+}
+
+void
+polkit_mate_authenticator_cancel (PolkitMateAuthenticator *authenticator)
+{
+  if (authenticator->dialog != NULL)
+    polkit_mate_authentication_dialog_cancel (POLKIT_MATE_AUTHENTICATION_DIALOG (authenticator->dialog));
+
+  authenticator->was_cancelled = TRUE;
+
+  if (authenticator->session != NULL)
+    {
+      polkit_agent_session_cancel (authenticator->session);
+    }
+}
+
+const gchar *
+polkit_mate_authenticator_get_cookie (PolkitMateAuthenticator *authenticator)<--- Parameter 'authenticator' can be declared as pointer to const
+{
+  return authenticator->cookie;
+}
+
+
+ +
+ +
+ + diff --git a/2024-02-15-173245-9368-cppcheck@aacfb22a55ce_master/5.html b/2024-02-15-173245-9368-cppcheck@aacfb22a55ce_master/5.html new file mode 100644 index 0000000..b1c66d2 --- /dev/null +++ b/2024-02-15-173245-9368-cppcheck@aacfb22a55ce_master/5.html @@ -0,0 +1,351 @@ + + + + + + Cppcheck - HTML report - mate-polkit + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
/*
+ * Copyright (C) 2009 Red Hat, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ * Author: David Zeuthen <davidz@redhat.com>
+ */
+
+#ifndef __POLKIT_MATE_AUTHENTICATOR_H
+#define __POLKIT_MATE_AUTHENTICATOR_H
+
+#include <glib-object.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define POLKIT_MATE_TYPE_AUTHENTICATOR          (polkit_mate_authenticator_get_type())
+#define POLKIT_MATE_AUTHENTICATOR(o)            (G_TYPE_CHECK_INSTANCE_CAST ((o), POLKIT_MATE_TYPE_AUTHENTICATOR, PolkitMateAuthenticator))
+#define POLKIT_MATE_AUTHENTICATOR_CLASS(k)      (G_TYPE_CHECK_CLASS_CAST((k), POLKIT_MATE_TYPE_AUTHENTICATOR, PolkitMateAuthenticatorClass))
+#define POLKIT_MATE_AUTHENTICATOR_GET_CLASS(o)  (G_TYPE_INSTANCE_GET_CLASS ((o), POLKIT_MATE_TYPE_AUTHENTICATOR, PolkitMateAuthenticatorClass))
+#define POLKIT_MATE_IS_AUTHENTICATOR(o)         (G_TYPE_CHECK_INSTANCE_TYPE ((o), POLKIT_MATE_TYPE_AUTHENTICATOR))
+#define POLKIT_MATE_IS_AUTHENTICATOR_CLASS(k)   (G_TYPE_CHECK_CLASS_TYPE ((k), POLKIT_MATE_TYPE_AUTHENTICATOR))
+
+typedef struct _PolkitMateAuthenticator PolkitMateAuthenticator;
+typedef struct _PolkitMateAuthenticatorClass PolkitMateAuthenticatorClass;
+
+GType                      polkit_mate_authenticator_get_type   (void) G_GNUC_CONST;
+PolkitMateAuthenticator  *polkit_mate_authenticator_new        (const gchar              *action_id,
+                                                                  const gchar              *message,
+                                                                  const gchar              *icon_name,
+                                                                  PolkitDetails            *details,
+                                                                  const gchar              *cookie,
+                                                                  GList                    *identities);
+void                       polkit_mate_authenticator_initiate   (PolkitMateAuthenticator *authenticator);
+void                       polkit_mate_authenticator_cancel     (PolkitMateAuthenticator *authenticator);
+const gchar               *polkit_mate_authenticator_get_cookie (PolkitMateAuthenticator *authenticator);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __POLKIT_MATE_AUTHENTICATOR_H */
+
+ +
+ +
+ + diff --git a/2024-02-15-173245-9368-cppcheck@aacfb22a55ce_master/6.html b/2024-02-15-173245-9368-cppcheck@aacfb22a55ce_master/6.html new file mode 100644 index 0000000..79a947d --- /dev/null +++ b/2024-02-15-173245-9368-cppcheck@aacfb22a55ce_master/6.html @@ -0,0 +1,761 @@ + + + + + + Cppcheck - HTML report - mate-polkit + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
/*
+ * Copyright (C) 2009 Red Hat, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ * Author: David Zeuthen <davidz@redhat.com>
+ */
+
+#include "config.h"<--- Include file: "config.h" not found.
+
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "polkitmatelistener.h"
+#include "polkitmateauthenticator.h"
+
+struct _PolkitMateListener
+{
+  PolkitAgentListener parent_instance;
+
+  /* we support multiple authenticators - they are simply queued up */
+  GList *authenticators;
+
+  PolkitMateAuthenticator *active_authenticator;
+};
+
+struct _PolkitMateListenerClass
+{
+  PolkitAgentListenerClass parent_class;
+};
+
+static void polkit_mate_listener_initiate_authentication (PolkitAgentListener  *listener,
+                                                           const gchar          *action_id,
+                                                           const gchar          *message,
+                                                           const gchar          *icon_name,
+                                                           PolkitDetails        *details,
+                                                           const gchar          *cookie,
+                                                           GList                *identities,
+                                                           GCancellable         *cancellable,
+                                                           GAsyncReadyCallback   callback,
+                                                           gpointer              user_data);
+
+static gboolean polkit_mate_listener_initiate_authentication_finish (PolkitAgentListener  *listener,
+                                                                      GAsyncResult         *res,
+                                                                      GError              **error);
+
+G_DEFINE_TYPE (PolkitMateListener, polkit_mate_listener, POLKIT_AGENT_TYPE_LISTENER);
+
+static void
+polkit_mate_listener_init (PolkitMateListener *listener)
+{
+}
+
+static void
+polkit_mate_listener_finalize (GObject *object)
+{
+  if (G_OBJECT_CLASS (polkit_mate_listener_parent_class)->finalize != NULL)
+    G_OBJECT_CLASS (polkit_mate_listener_parent_class)->finalize (object);
+}
+
+static void
+polkit_mate_listener_class_init (PolkitMateListenerClass *klass)
+{
+  GObjectClass *gobject_class;
+  PolkitAgentListenerClass *listener_class;
+
+  gobject_class = G_OBJECT_CLASS (klass);
+  listener_class = POLKIT_AGENT_LISTENER_CLASS (klass);
+
+  gobject_class->finalize = polkit_mate_listener_finalize;
+
+  listener_class->initiate_authentication          = polkit_mate_listener_initiate_authentication;
+  listener_class->initiate_authentication_finish   = polkit_mate_listener_initiate_authentication_finish;
+}
+
+PolkitAgentListener *
+polkit_mate_listener_new (void)
+{
+  return POLKIT_AGENT_LISTENER (g_object_new (POLKIT_MATE_TYPE_LISTENER, NULL));
+}
+
+typedef struct
+{
+  PolkitMateListener *listener;
+  PolkitMateAuthenticator *authenticator;
+
+  GTask        *task;
+  GCancellable *cancellable;
+
+  gulong cancel_id;
+} AuthData;
+
+static AuthData *
+auth_data_new (PolkitMateListener *listener,
+               PolkitMateAuthenticator *authenticator,
+               GTask *task,
+               GCancellable *cancellable)
+{
+  AuthData *data;
+
+  data = g_new0 (AuthData, 1);
+  data->listener = g_object_ref (listener);
+  data->authenticator = g_object_ref (authenticator);
+  data->task = g_object_ref (task);
+  data->cancellable = g_object_ref (cancellable);
+  return data;
+}
+
+static void
+auth_data_free (AuthData *data)
+{
+  g_object_unref (data->listener);
+  g_object_unref (data->authenticator);
+  g_object_unref (data->task);
+  if (data->cancellable != NULL && data->cancel_id > 0)
+    g_signal_handler_disconnect (data->cancellable, data->cancel_id);
+  g_object_unref (data->cancellable);
+  g_free (data);
+}
+
+static void
+maybe_initiate_next_authenticator (PolkitMateListener *listener)
+{
+  if (listener->active_authenticator == NULL && listener->authenticators != NULL)
+    {
+      polkit_mate_authenticator_initiate (POLKIT_MATE_AUTHENTICATOR (listener->authenticators->data));
+      listener->active_authenticator = listener->authenticators->data;
+    }
+}
+
+static void
+authenticator_completed (PolkitMateAuthenticator *authenticator,
+                         gboolean                 gained_authorization,
+                         gboolean                 dismissed,
+                         gpointer                 user_data)
+{
+  AuthData *data = user_data;
+
+  data->listener->authenticators = g_list_remove (data->listener->authenticators, authenticator);
+  if (authenticator == data->listener->active_authenticator)
+    data->listener->active_authenticator = NULL;
+
+  g_object_unref (authenticator);
+
+  if (dismissed)
+    {
+      g_task_return_new_error (data->task,
+                               POLKIT_ERROR,
+                               POLKIT_ERROR_CANCELLED,
+                               _("Authentication dialog was dismissed by the user"));
+    }
+
+  g_task_return_boolean (data->task, TRUE);
+  g_object_unref (data->task);
+
+  maybe_initiate_next_authenticator (data->listener);
+
+  auth_data_free (data);
+}
+
+static void
+cancelled_cb (GCancellable *cancellable,
+              gpointer user_data)
+{
+  AuthData *data = user_data;
+
+  polkit_mate_authenticator_cancel (data->authenticator);
+}
+
+static void
+polkit_mate_listener_initiate_authentication (PolkitAgentListener  *agent_listener,
+                                               const gchar          *action_id,
+                                               const gchar          *message,
+                                               const gchar          *icon_name,
+                                               PolkitDetails        *details,
+                                               const gchar          *cookie,
+                                               GList                *identities,
+                                               GCancellable         *cancellable,
+                                               GAsyncReadyCallback   callback,
+                                               gpointer              user_data)
+{
+  PolkitMateListener *listener = POLKIT_MATE_LISTENER (agent_listener);
+  GTask *task;
+  PolkitMateAuthenticator *authenticator;
+  AuthData *data;
+
+  task = g_task_new (G_OBJECT (listener),
+                     NULL,
+                     callback,
+                     user_data);
+  g_task_set_source_tag (task,
+                         polkit_mate_listener_initiate_authentication);
+
+  authenticator = polkit_mate_authenticator_new (action_id,
+                                                  message,
+                                                  icon_name,
+                                                  details,
+                                                  cookie,
+                                                  identities);
+  if (authenticator == NULL)
+    {
+      g_task_return_new_error (task,
+                               POLKIT_ERROR,
+                               POLKIT_ERROR_FAILED,
+                               "Error creating authentication object");
+      g_object_unref (task);
+      goto out;
+    }
+
+  data = auth_data_new (listener, authenticator, task, cancellable);
+
+  g_signal_connect (authenticator,
+                    "completed",
+                    G_CALLBACK (authenticator_completed),
+                    data);
+
+  if (cancellable != NULL)
+    {
+      data->cancel_id = g_signal_connect (cancellable,
+                                          "cancelled",
+                                          G_CALLBACK (cancelled_cb),
+                                          data);
+    }
+
+  listener->authenticators = g_list_append (listener->authenticators, authenticator);
+
+  maybe_initiate_next_authenticator (listener);
+
+ out:
+  ;
+}
+
+static gboolean
+polkit_mate_listener_initiate_authentication_finish (PolkitAgentListener  *listener,
+                                                      GAsyncResult         *res,
+                                                      GError              **error)
+{
+  GTask *task = G_TASK (res);
+
+  g_warn_if_fail (g_task_get_source_tag (task) == polkit_mate_listener_initiate_authentication);
+
+  if (g_task_propagate_pointer (task, error) == NULL) {
+    return FALSE;
+  }
+
+  return TRUE;
+}
+
+
+ +
+ +
+ + diff --git a/2024-02-15-173245-9368-cppcheck@aacfb22a55ce_master/index.html b/2024-02-15-173245-9368-cppcheck@aacfb22a55ce_master/index.html new file mode 100644 index 0000000..35f12cd --- /dev/null +++ b/2024-02-15-173245-9368-cppcheck@aacfb22a55ce_master/index.html @@ -0,0 +1,252 @@ + + + + + + Cppcheck - HTML report - mate-polkit + + + + + +
+ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
LineIdCWESeverityMessage
checkersReportinformationActive checkers: 106/592 (use --checkers-report=<filename> to see details)
src/main.c
23missingIncludeinformationInclude file: "config.h" not found.
26missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <gio/gio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
29missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
30missingIncludeSysteminformationInclude file: <polkitagent/polkitagent.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
33missingIncludeSysteminformationInclude file: <libayatana-appindicator/app-indicator.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
35missingIncludeSysteminformationInclude file: <libappindicator/app-indicator.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
226shadowVariable398styleLocal variable 'authority' shadows outer variable
316constParameterCallback398styleParameter 'signal_name' can be declared as pointer to const. However it seems that 'signal_cb' is a callback function, if 'signal_name' is declared with const you might also need to cast function pointer(s).
src/polkitmateauthenticationdialog.c
24missingIncludeinformationInclude file: "config.h" not found.
28missingIncludeSysteminformationInclude file: <unistd.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
29missingIncludeSysteminformationInclude file: <sys/types.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
30missingIncludeSysteminformationInclude file: <sys/stat.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
31missingIncludeSysteminformationInclude file: <fcntl.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
32missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
33missingIncludeSysteminformationInclude file: <stdio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
34missingIncludeSysteminformationInclude file: <stdlib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
35missingIncludeSysteminformationInclude file: <pwd.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
36missingIncludeSysteminformationInclude file: <errno.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
38missingIncludeSysteminformationInclude file: <glib/gi18n-lib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
39missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
99constVariablePointer398styleVariable 'indices' can be declared as pointer to const
src/polkitmateauthenticationdialog.h
26missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <polkit/polkit.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/polkitmateauthenticator.c
23missingIncludeinformationInclude file: "config.h" not found.
25missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <sys/types.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <pwd.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
29missingIncludeSysteminformationInclude file: <gdk/gdkx.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
31missingIncludeSysteminformationInclude file: <polkit/polkit.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
32missingIncludeSysteminformationInclude file: <polkitagent/polkitagent.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
512constParameterPointer398styleParameter 'authenticator' can be declared as pointer to const
src/polkitmateauthenticator.h
26missingIncludeSysteminformationInclude file: <glib-object.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/polkitmatelistener.c
23missingIncludeinformationInclude file: "config.h" not found.
25missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/polkitmatelistener.h
26missingIncludeSysteminformationInclude file: <polkitagent/polkitagent.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+ +
+ + diff --git a/2024-02-15-173245-9368-cppcheck@aacfb22a55ce_master/stats.html b/2024-02-15-173245-9368-cppcheck@aacfb22a55ce_master/stats.html new file mode 100644 index 0000000..5c5881a --- /dev/null +++ b/2024-02-15-173245-9368-cppcheck@aacfb22a55ce_master/stats.html @@ -0,0 +1,178 @@ + + + + + + Cppcheck - HTML report - mate-polkit + + + + + +
+ + + +
+

Top 10 files for style severity, total findings: 4
+   2  src/main.c
+   1  src/polkitmateauthenticator.c
+   1  src/polkitmateauthenticationdialog.c
+

+

Top 10 files for information severity, total findings: 35
+   12  src/polkitmateauthenticationdialog.c
+   8   src/polkitmateauthenticator.c
+   8   src/main.c
+   3   src/polkitmatelistener.c
+   2   src/polkitmateauthenticationdialog.h
+   1   src/polkitmatelistener.h
+   1   src/polkitmateauthenticator.h
+

+ +
+ +
+ + diff --git a/2024-02-15-173245-9368-cppcheck@aacfb22a55ce_master/style.css b/2024-02-15-173245-9368-cppcheck@aacfb22a55ce_master/style.css new file mode 100644 index 0000000..3897bfa --- /dev/null +++ b/2024-02-15-173245-9368-cppcheck@aacfb22a55ce_master/style.css @@ -0,0 +1,177 @@ + +body { + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif; + font-size: 13px; + line-height: 1.5; + height: 100%; + margin: 0; +} + +#wrapper { + position: fixed; + height: 100vh; + width: 100vw; + display: grid; + grid-template-rows: fit-content(8rem) auto fit-content(8rem); + grid-template-columns: fit-content(25%) 1fr; + grid-template-areas: + "header header" + "menu content" + "footer footer"; +} + +h1 { + margin: 0 0 8px -2px; + font-size: 175%; +} + +.header { + padding: 0 0 5px 15px; + grid-area: header; + border-bottom: thin solid #aaa; +} + +.footer { + grid-area: footer; + border-top: thin solid #aaa; + font-size: 85%; + +} + +.footer > p { + margin: 4px; +} + +#menu, +#menu_index { + grid-area: menu; + text-align: left; + overflow: auto; + padding: 0 23px 15px 15px; + border-right: thin solid #aaa; + min-width: 200px; +} + +#menu > a { + display: block; + margin-left: 10px; + font-size: 12px; +} + +#content, +#content_index { + grid-area: content; + padding: 0px 5px 15px 15px; + overflow: auto; +} + +label { + white-space: nowrap; +} + +label.checkBtn.disabled { + color: #606060; + background: #e0e0e0; + font-style: italic; +} + +label.checkBtn, input[type="text"] { + border: 1px solid grey; + border-radius: 4px; + box-shadow: 1px 1px inset; + padding: 1px 5px; +} + +label.checkBtn { + white-space: nowrap; + background: #ccddff; +} + +label.unchecked { + background: #eff8ff; + box-shadow: 1px 1px 1px; +} + +label.checkBtn:hover, label.unchecked:hover{ + box-shadow: 0 0 2px; +} + +label.disabled:hover { + box-shadow: 1px 1px inset; +} + +label.checkBtn > input { + display:none; +} + +.summaryTable { + width: 100%; +} + +table.summaryTable td { padding: 0 5px 0 5px; } + +.statHeader, .severityHeader { + font-weight: bold; +} + +.warning { + background-color: #ffffa7; +} + +.error { + background-color: #ffb7b7; +} + +.error2 { + background-color: #faa; + display: inline-block; + margin-left: 4px; +} + +.inconclusive { + background-color: #b6b6b4; +} + +.inconclusive2 { + background-color: #b6b6b4; + display: inline-block; + margin-left: 4px; +} + +.verbose { + display: inline-block; + vertical-align: top; + cursor: help; +} + +.verbose .content { + display: none; + position: absolute; + padding: 10px; + margin: 4px; + max-width: 40%; + white-space: pre-wrap; + border: 1px solid #000; + background-color: #ffffcc; + cursor: auto; +} + +.highlight .hll { + padding: 1px; +} + +.highlighttable { + background-color: #fff; + position: relative; + margin: -10px; +} + +.linenos { + border-right: thin solid #aaa; + color: #d3d3d3; + padding-right: 6px; +} + +.id-filtered, .severity-filtered, .file-filtered, .tool-filtered, .text-filtered { + visibility: collapse; +} diff --git a/2024-02-24-205454-0706-cppcheck@1d41ea003763_shiti-meson/0.html b/2024-02-24-205454-0706-cppcheck@1d41ea003763_shiti-meson/0.html new file mode 100644 index 0000000..95e5dbc --- /dev/null +++ b/2024-02-24-205454-0706-cppcheck@1d41ea003763_shiti-meson/0.html @@ -0,0 +1,1189 @@ + + + + + + Cppcheck - HTML report - mate-polkit + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
/*
+ * Copyright (C) 2009 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ * Author: David Zeuthen <davidz@redhat.com>
+ */
+
+#ifdef HAVE_CONFIG_H
+#  include "config.h"<--- Include file: "config.h" not found.
+#endif
+
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gio/gio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <polkitagent/polkitagent.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#if defined(HAVE_AYATANA_APPINDICATOR)
+# include <libayatana-appindicator/app-indicator.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#elif defined(HAVE_UBUNTU_APPINDICATOR)
+# include <libappindicator/app-indicator.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#endif
+
+#include "polkitmatelistener.h"
+
+/* session management support for auto-restart */
+#define SM_DBUS_NAME      "org.gnome.SessionManager"
+#define SM_DBUS_PATH      "/org/gnome/SessionManager"
+#define SM_DBUS_INTERFACE "org.gnome.SessionManager"
+#define SM_CLIENT_DBUS_INTERFACE "org.gnome.SessionManager.ClientPrivate"
+
+/* the Authority */
+static PolkitAuthority *authority = NULL;<--- Shadowed declaration
+
+/* the session we are servicing */
+static PolkitSubject *session = NULL;
+
+/* the current set of temporary authorizations */
+static GList *current_temporary_authorizations = NULL;
+
+#if defined(HAVE_AYATANA_APPINDICATOR) || defined(HAVE_UBUNTU_APPINDICATOR)
+static AppIndicator *app_indicator = NULL;
+#else
+static GtkStatusIcon *status_icon = NULL;
+#endif
+
+static GDBusProxy      *sm_proxy;
+static GDBusProxy      *client_proxy = NULL;
+
+static  GMainLoop *loop;
+
+static void
+revoke_tmp_authz_cb (GObject      *source_object,
+                     GAsyncResult *res,
+                     gpointer      user_data)
+{
+  GError *error;
+
+  error = NULL;
+  polkit_authority_revoke_temporary_authorizations_finish (POLKIT_AUTHORITY (source_object),
+                                                           res,
+                                                           &error);
+  if (error != NULL)
+    {
+      g_warning ("Error revoking temporary authorizations: %s", error->message);
+      g_error_free (error);
+    }
+}
+
+static void
+revoke_tmp_authz (void)
+{
+  polkit_authority_revoke_temporary_authorizations (authority,
+                                                    session,
+                                                    NULL,
+                                                    revoke_tmp_authz_cb,
+                                                    NULL);
+}
+
+#if defined(HAVE_AYATANA_APPINDICATOR) || defined(HAVE_UBUNTU_APPINDICATOR)
+static void
+on_menu_item_activate (GtkMenuItem *menu_item,
+                       gpointer     user_data)
+{
+  revoke_tmp_authz ();
+}
+#else
+static void
+on_status_icon_activate (GtkStatusIcon *status_icon,
+                         gpointer       user_data)
+{
+  revoke_tmp_authz ();
+}
+
+static void
+on_status_icon_popup_menu (GtkStatusIcon *status_icon,
+                           guint          button,
+                           guint          activate_time,
+                           gpointer       user_data)
+{
+  revoke_tmp_authz ();
+}
+#endif
+
+static void
+update_temporary_authorization_icon_real (void)
+{
+
+#if 0
+  GList *l;
+  g_debug ("have %d tmp authorizations", g_list_length (current_temporary_authorizations));
+  for (l = current_temporary_authorizations; l != NULL; l = l->next)
+    {
+      PolkitTemporaryAuthorization *authz = POLKIT_TEMPORARY_AUTHORIZATION (l->data);
+
+      g_debug ("have tmp authz for action %s (subject %s) with id %s (obtained %d, expires %d)",
+               polkit_temporary_authorization_get_action_id (authz),
+               polkit_subject_to_string (polkit_temporary_authorization_get_subject (authz)),
+               polkit_temporary_authorization_get_id (authz),
+               (gint) polkit_temporary_authorization_get_time_obtained (authz),
+               (gint) polkit_temporary_authorization_get_time_expires (authz));
+    }
+#endif
+
+  /* TODO:
+   *
+   * - we could do something fancy like displaying a window with the tmp authz
+   *   when the icon is clicked...
+   *
+   * - we could do some work using polkit_subject_exists() to ignore tmp authz
+   *   for subjects that no longer exists.. this is because temporary authorizations
+   *   are only valid for the subject that trigger the authentication dialog.
+   *
+   *   Maybe the authority could do this, would probably involve some polling, but
+   *   it seems cleaner to do this server side.
+   */
+
+  if (current_temporary_authorizations != NULL)
+    {
+      /* show icon */
+#if defined(HAVE_AYATANA_APPINDICATOR) || defined(HAVE_UBUNTU_APPINDICATOR)
+      if (app_indicator == NULL)
+        {
+          GtkWidget *item, *menu;
+
+          app_indicator = app_indicator_new ("mate-polkit",
+                                             "dialog-password",
+                                             APP_INDICATOR_CATEGORY_SYSTEM_SERVICES);
+
+          item = gtk_menu_item_new_with_label (_("Drop all elevated privileges"));
+          g_signal_connect (item,
+                            "activate",
+                            G_CALLBACK (on_menu_item_activate),
+                            NULL);
+          menu = gtk_menu_new ();
+          gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+          gtk_widget_show_all (menu);
+
+          app_indicator_set_menu (app_indicator,
+                                  GTK_MENU (menu));
+          app_indicator_set_status (app_indicator,
+                                    APP_INDICATOR_STATUS_ACTIVE);
+        }
+      else
+        /*Reshow icon from existing appindicator */
+        app_indicator_set_status (app_indicator,
+				    APP_INDICATOR_STATUS_ACTIVE);
+
+#else
+      if (status_icon == NULL)
+        {
+          status_icon = gtk_status_icon_new_from_icon_name ("dialog-password");
+          gtk_status_icon_set_tooltip_text (status_icon,
+                                            _("Click the icon to drop all elevated privileges"));
+          g_signal_connect (status_icon,
+                            "activate",
+                            G_CALLBACK (on_status_icon_activate),
+                            NULL);
+          g_signal_connect (status_icon,
+                            "popup-menu",
+                            G_CALLBACK (on_status_icon_popup_menu),
+                            NULL);
+        }
+#endif
+    }
+  else
+    {
+      /* hide icon */
+#if defined(HAVE_AYATANA_APPINDICATOR) || defined(HAVE_UBUNTU_APPINDICATOR)
+      if (app_indicator != NULL)
+        {
+          /* keep the app_indicator, hide the icon or it won't come back*/
+          app_indicator_set_status (app_indicator,
+				    APP_INDICATOR_STATUS_PASSIVE);
+        }
+#else
+      if (status_icon != NULL)
+        {
+          gtk_status_icon_set_visible (status_icon, FALSE);
+          g_object_unref (status_icon);
+          status_icon = NULL;
+        }
+#endif
+    }
+}
+
+static void
+enumerate_temporary_authorizations_cb (GObject      *source_object,
+                                       GAsyncResult *res,
+                                       gpointer      user_data)
+{
+  PolkitAuthority *authority = POLKIT_AUTHORITY (source_object);<--- Shadow variable
+  GList *temporary_authorizations;
+  GError *error;
+
+  temporary_authorizations = NULL;
+
+  error = NULL;
+  temporary_authorizations = polkit_authority_enumerate_temporary_authorizations_finish (authority,
+                                                                                         res,
+                                                                                         &error);
+  if (error != NULL)
+    {
+      g_warning ("Error enumerating temporary authorizations: %s", error->message);
+      g_error_free (error);
+      goto out;
+    }
+
+  g_list_foreach (current_temporary_authorizations, (GFunc) g_object_unref, NULL);
+  g_list_free (current_temporary_authorizations);
+
+  current_temporary_authorizations = temporary_authorizations;
+
+  update_temporary_authorization_icon_real ();
+
+ out:
+  ;
+}
+
+static void
+update_temporary_authorization_icon (PolkitAuthority *authority)
+{
+  polkit_authority_enumerate_temporary_authorizations (authority,
+                                                       session,
+                                                       NULL,
+                                                       enumerate_temporary_authorizations_cb,
+                                                       NULL);
+}
+
+static void
+on_authority_changed (PolkitAuthority *authority,
+                      gpointer         user_data)
+{
+  update_temporary_authorization_icon (authority);
+}
+
+static void
+stop_cb (void)
+{
+        g_main_loop_quit (loop);
+}
+
+static gboolean
+end_session_response (gboolean is_okay, const gchar *reason)
+{
+        GVariant *res;
+        GError *error = NULL;
+
+        res = g_dbus_proxy_call_sync (client_proxy,
+                                      "EndSessionResponse",
+                                      g_variant_new ("(bs)",
+                                                     is_okay,
+                                                     reason),
+                                      G_DBUS_CALL_FLAGS_NONE,
+                                      -1, /* timeout */
+                                      NULL, /* GCancellable */
+                                      &error);
+        if (! res) {
+                g_warning ("Failed to call EndSessionResponse: %s", error->message);
+                g_error_free (error);
+                return FALSE;
+        }
+
+        g_variant_unref (res);
+        return TRUE;
+}
+
+static void
+query_end_session_cb (void)
+{
+        end_session_response (TRUE, "");
+}
+
+static void
+end_session_cb (void)
+{
+        end_session_response (TRUE, "");
+        g_main_loop_quit (loop);
+}
+
+static void
+signal_cb (GDBusProxy *proxy, gchar *sender_name, gchar *signal_name,<--- Parameter 'signal_name' can be declared as pointer to const
+           GVariant *parameters, gpointer user_data)
+{
+        if (strcmp (signal_name, "Stop") == 0) {
+                stop_cb ();
+        } else if (strcmp (signal_name, "QueryEndSession") == 0) {
+                query_end_session_cb ();
+        } else if (strcmp (signal_name, "EndSession") == 0) {
+                end_session_cb ();
+        }
+}
+
+static gboolean
+register_client_to_gnome_session (void)
+{
+        GError     *error = NULL;
+        GVariant   *res;
+        const char *startup_id;
+        const char *app_id;
+        char       *client_id;
+
+        startup_id = g_getenv ("DESKTOP_AUTOSTART_ID");
+        app_id = "polkit-mate-authentication-agent-1.desktop";
+
+        sm_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
+                                                  G_DBUS_PROXY_FLAGS_NONE,
+                                                  NULL, /* GDBusInterfaceInfo */
+                                                  SM_DBUS_NAME,
+                                                  SM_DBUS_PATH,
+                                                  SM_DBUS_INTERFACE,
+                                                  NULL, /* GCancellable */
+                                                  &error);
+        if (sm_proxy == NULL) {
+                g_message("Failed to get session manager: %s", error->message);
+                g_error_free (error);
+                return FALSE;
+        }
+
+        res = g_dbus_proxy_call_sync (sm_proxy,
+                                      "RegisterClient",
+                                      g_variant_new ("(ss)",
+                                                     app_id,
+                                                     startup_id),
+                                      G_DBUS_CALL_FLAGS_NONE,
+                                      -1, /* timeout */
+                                      NULL, /* GCancellable */
+                                      &error);
+        if (! res) {
+                g_warning ("Failed to register client: %s", error->message);
+                g_error_free (error);
+                return FALSE;
+        }
+
+        if (! g_variant_is_of_type (res, G_VARIANT_TYPE ("(o)"))) {
+                g_warning ("RegisterClient returned unexpected type %s",
+                           g_variant_get_type_string (res));
+                return FALSE;
+        }
+
+        g_variant_get (res, "(&o)", &client_id);
+
+        client_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
+                                                      G_DBUS_PROXY_FLAGS_NONE,
+                                                      NULL, /* GDBusInterfaceInfo */
+                                                      SM_DBUS_NAME,
+                                                      client_id,
+                                                      SM_CLIENT_DBUS_INTERFACE,
+                                                      NULL, /* GCancellable */
+                                                      &error);
+        g_variant_unref (res);
+        if (client_proxy == NULL) {
+                g_message("Failed to get client proxy: %s", error->message);
+                g_error_free (error);
+                return FALSE;
+        }
+
+        g_signal_connect (client_proxy, "g-signal", G_CALLBACK (signal_cb), NULL);<--- You might need to cast the function pointer here
+
+        return TRUE;
+}
+
+int
+main (int argc, char **argv)
+{
+  gint ret;
+  PolkitAgentListener *listener;
+  GError *error;
+
+  gtk_init (&argc, &argv);
+
+  loop = NULL;
+  authority = NULL;
+  listener = NULL;
+  session = NULL;
+  ret = 1;
+
+  bindtextdomain (GETTEXT_PACKAGE, MATELOCALEDIR);
+#if HAVE_BIND_TEXTDOMAIN_CODESET
+  bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+#endif
+  textdomain (GETTEXT_PACKAGE);
+
+  loop = g_main_loop_new (NULL, FALSE);
+
+  error = NULL;
+  authority = polkit_authority_get_sync (NULL /* GCancellable* */, &error);
+  if (authority == NULL)
+    {
+      g_warning ("Error getting authority: %s", error->message);
+      g_error_free (error);
+      goto out;
+    }
+  g_signal_connect (authority,
+                    "changed",
+                    G_CALLBACK (on_authority_changed),
+                    NULL);
+
+  listener = polkit_mate_listener_new ();
+
+  error = NULL;
+  session = polkit_unix_session_new_for_process_sync (getpid (), NULL, &error);
+  if (error != NULL)
+    {
+      g_warning ("Unable to determine the session we are in: %s", error->message);
+      g_error_free (error);
+      goto out;
+    }
+
+  error = NULL;
+  if (!polkit_agent_listener_register (listener,
+				       POLKIT_AGENT_REGISTER_FLAGS_NONE,
+                                       session,
+                                       "/org/mate/PolicyKit1/AuthenticationAgent",
+				       NULL,
+                                       &error))
+    {
+      g_printerr ("Cannot register authentication agent: %s\n", error->message);
+      g_error_free (error);
+      goto out;
+    }
+
+  update_temporary_authorization_icon (authority);
+
+  register_client_to_gnome_session();
+
+  g_main_loop_run (loop);
+
+  ret = 0;
+
+ out:
+  if (authority != NULL)
+    g_object_unref (authority);
+  if (session != NULL)
+    g_object_unref (session);
+  if (listener != NULL)
+    g_object_unref (listener);
+  if (loop != NULL)
+    g_main_loop_unref (loop);
+
+  return ret;
+}
+
+ +
+ +
+ + diff --git a/2024-02-24-205454-0706-cppcheck@1d41ea003763_shiti-meson/1.html b/2024-02-24-205454-0706-cppcheck@1d41ea003763_shiti-meson/1.html new file mode 100644 index 0000000..bf8ec00 --- /dev/null +++ b/2024-02-24-205454-0706-cppcheck@1d41ea003763_shiti-meson/1.html @@ -0,0 +1,335 @@ + + + + + + Cppcheck - HTML report - mate-polkit + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
/*
+ * Copyright (C) 2009 Red Hat, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ * Author: David Zeuthen <davidz@redhat.com>
+ */
+
+#ifndef __POLKIT_MATE_LISTENER_H
+#define __POLKIT_MATE_LISTENER_H
+
+#include <polkitagent/polkitagent.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define POLKIT_MATE_TYPE_LISTENER          (polkit_mate_listener_get_type())
+#define POLKIT_MATE_LISTENER(o)            (G_TYPE_CHECK_INSTANCE_CAST ((o), POLKIT_MATE_TYPE_LISTENER, PolkitMateListener))
+#define POLKIT_MATE_LISTENER_CLASS(k)      (G_TYPE_CHECK_CLASS_CAST((k), POLKIT_MATE_TYPE_LISTENER, PolkitMateListenerClass))
+#define POLKIT_MATE_LISTENER_GET_CLASS(o)  (G_TYPE_INSTANCE_GET_CLASS ((o), POLKIT_MATE_TYPE_LISTENER, PolkitMateListenerClass))
+#define POLKIT_MATE_IS_LISTENER(o)         (G_TYPE_CHECK_INSTANCE_TYPE ((o), POLKIT_MATE_TYPE_LISTENER))
+#define POLKIT_MATE_IS_LISTENER_CLASS(k)   (G_TYPE_CHECK_CLASS_TYPE ((k), POLKIT_MATE_TYPE_LISTENER))
+
+typedef struct _PolkitMateListener PolkitMateListener;
+typedef struct _PolkitMateListenerClass PolkitMateListenerClass;
+
+GType                 polkit_mate_listener_get_type   (void) G_GNUC_CONST;
+PolkitAgentListener  *polkit_mate_listener_new        (void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __POLKIT_MATE_LISTENER_H */
+
+ +
+ +
+ + diff --git a/2024-02-24-205454-0706-cppcheck@1d41ea003763_shiti-meson/2.html b/2024-02-24-205454-0706-cppcheck@1d41ea003763_shiti-meson/2.html new file mode 100644 index 0000000..bce6d3f --- /dev/null +++ b/2024-02-24-205454-0706-cppcheck@1d41ea003763_shiti-meson/2.html @@ -0,0 +1,2639 @@ + + + + + + Cppcheck - HTML report - mate-polkit + + + + + +
+ + + +
+
   1
+   2
+   3
+   4
+   5
+   6
+   7
+   8
+   9
+  10
+  11
+  12
+  13
+  14
+  15
+  16
+  17
+  18
+  19
+  20
+  21
+  22
+  23
+  24
+  25
+  26
+  27
+  28
+  29
+  30
+  31
+  32
+  33
+  34
+  35
+  36
+  37
+  38
+  39
+  40
+  41
+  42
+  43
+  44
+  45
+  46
+  47
+  48
+  49
+  50
+  51
+  52
+  53
+  54
+  55
+  56
+  57
+  58
+  59
+  60
+  61
+  62
+  63
+  64
+  65
+  66
+  67
+  68
+  69
+  70
+  71
+  72
+  73
+  74
+  75
+  76
+  77
+  78
+  79
+  80
+  81
+  82
+  83
+  84
+  85
+  86
+  87
+  88
+  89
+  90
+  91
+  92
+  93
+  94
+  95
+  96
+  97
+  98
+  99
+ 100
+ 101
+ 102
+ 103
+ 104
+ 105
+ 106
+ 107
+ 108
+ 109
+ 110
+ 111
+ 112
+ 113
+ 114
+ 115
+ 116
+ 117
+ 118
+ 119
+ 120
+ 121
+ 122
+ 123
+ 124
+ 125
+ 126
+ 127
+ 128
+ 129
+ 130
+ 131
+ 132
+ 133
+ 134
+ 135
+ 136
+ 137
+ 138
+ 139
+ 140
+ 141
+ 142
+ 143
+ 144
+ 145
+ 146
+ 147
+ 148
+ 149
+ 150
+ 151
+ 152
+ 153
+ 154
+ 155
+ 156
+ 157
+ 158
+ 159
+ 160
+ 161
+ 162
+ 163
+ 164
+ 165
+ 166
+ 167
+ 168
+ 169
+ 170
+ 171
+ 172
+ 173
+ 174
+ 175
+ 176
+ 177
+ 178
+ 179
+ 180
+ 181
+ 182
+ 183
+ 184
+ 185
+ 186
+ 187
+ 188
+ 189
+ 190
+ 191
+ 192
+ 193
+ 194
+ 195
+ 196
+ 197
+ 198
+ 199
+ 200
+ 201
+ 202
+ 203
+ 204
+ 205
+ 206
+ 207
+ 208
+ 209
+ 210
+ 211
+ 212
+ 213
+ 214
+ 215
+ 216
+ 217
+ 218
+ 219
+ 220
+ 221
+ 222
+ 223
+ 224
+ 225
+ 226
+ 227
+ 228
+ 229
+ 230
+ 231
+ 232
+ 233
+ 234
+ 235
+ 236
+ 237
+ 238
+ 239
+ 240
+ 241
+ 242
+ 243
+ 244
+ 245
+ 246
+ 247
+ 248
+ 249
+ 250
+ 251
+ 252
+ 253
+ 254
+ 255
+ 256
+ 257
+ 258
+ 259
+ 260
+ 261
+ 262
+ 263
+ 264
+ 265
+ 266
+ 267
+ 268
+ 269
+ 270
+ 271
+ 272
+ 273
+ 274
+ 275
+ 276
+ 277
+ 278
+ 279
+ 280
+ 281
+ 282
+ 283
+ 284
+ 285
+ 286
+ 287
+ 288
+ 289
+ 290
+ 291
+ 292
+ 293
+ 294
+ 295
+ 296
+ 297
+ 298
+ 299
+ 300
+ 301
+ 302
+ 303
+ 304
+ 305
+ 306
+ 307
+ 308
+ 309
+ 310
+ 311
+ 312
+ 313
+ 314
+ 315
+ 316
+ 317
+ 318
+ 319
+ 320
+ 321
+ 322
+ 323
+ 324
+ 325
+ 326
+ 327
+ 328
+ 329
+ 330
+ 331
+ 332
+ 333
+ 334
+ 335
+ 336
+ 337
+ 338
+ 339
+ 340
+ 341
+ 342
+ 343
+ 344
+ 345
+ 346
+ 347
+ 348
+ 349
+ 350
+ 351
+ 352
+ 353
+ 354
+ 355
+ 356
+ 357
+ 358
+ 359
+ 360
+ 361
+ 362
+ 363
+ 364
+ 365
+ 366
+ 367
+ 368
+ 369
+ 370
+ 371
+ 372
+ 373
+ 374
+ 375
+ 376
+ 377
+ 378
+ 379
+ 380
+ 381
+ 382
+ 383
+ 384
+ 385
+ 386
+ 387
+ 388
+ 389
+ 390
+ 391
+ 392
+ 393
+ 394
+ 395
+ 396
+ 397
+ 398
+ 399
+ 400
+ 401
+ 402
+ 403
+ 404
+ 405
+ 406
+ 407
+ 408
+ 409
+ 410
+ 411
+ 412
+ 413
+ 414
+ 415
+ 416
+ 417
+ 418
+ 419
+ 420
+ 421
+ 422
+ 423
+ 424
+ 425
+ 426
+ 427
+ 428
+ 429
+ 430
+ 431
+ 432
+ 433
+ 434
+ 435
+ 436
+ 437
+ 438
+ 439
+ 440
+ 441
+ 442
+ 443
+ 444
+ 445
+ 446
+ 447
+ 448
+ 449
+ 450
+ 451
+ 452
+ 453
+ 454
+ 455
+ 456
+ 457
+ 458
+ 459
+ 460
+ 461
+ 462
+ 463
+ 464
+ 465
+ 466
+ 467
+ 468
+ 469
+ 470
+ 471
+ 472
+ 473
+ 474
+ 475
+ 476
+ 477
+ 478
+ 479
+ 480
+ 481
+ 482
+ 483
+ 484
+ 485
+ 486
+ 487
+ 488
+ 489
+ 490
+ 491
+ 492
+ 493
+ 494
+ 495
+ 496
+ 497
+ 498
+ 499
+ 500
+ 501
+ 502
+ 503
+ 504
+ 505
+ 506
+ 507
+ 508
+ 509
+ 510
+ 511
+ 512
+ 513
+ 514
+ 515
+ 516
+ 517
+ 518
+ 519
+ 520
+ 521
+ 522
+ 523
+ 524
+ 525
+ 526
+ 527
+ 528
+ 529
+ 530
+ 531
+ 532
+ 533
+ 534
+ 535
+ 536
+ 537
+ 538
+ 539
+ 540
+ 541
+ 542
+ 543
+ 544
+ 545
+ 546
+ 547
+ 548
+ 549
+ 550
+ 551
+ 552
+ 553
+ 554
+ 555
+ 556
+ 557
+ 558
+ 559
+ 560
+ 561
+ 562
+ 563
+ 564
+ 565
+ 566
+ 567
+ 568
+ 569
+ 570
+ 571
+ 572
+ 573
+ 574
+ 575
+ 576
+ 577
+ 578
+ 579
+ 580
+ 581
+ 582
+ 583
+ 584
+ 585
+ 586
+ 587
+ 588
+ 589
+ 590
+ 591
+ 592
+ 593
+ 594
+ 595
+ 596
+ 597
+ 598
+ 599
+ 600
+ 601
+ 602
+ 603
+ 604
+ 605
+ 606
+ 607
+ 608
+ 609
+ 610
+ 611
+ 612
+ 613
+ 614
+ 615
+ 616
+ 617
+ 618
+ 619
+ 620
+ 621
+ 622
+ 623
+ 624
+ 625
+ 626
+ 627
+ 628
+ 629
+ 630
+ 631
+ 632
+ 633
+ 634
+ 635
+ 636
+ 637
+ 638
+ 639
+ 640
+ 641
+ 642
+ 643
+ 644
+ 645
+ 646
+ 647
+ 648
+ 649
+ 650
+ 651
+ 652
+ 653
+ 654
+ 655
+ 656
+ 657
+ 658
+ 659
+ 660
+ 661
+ 662
+ 663
+ 664
+ 665
+ 666
+ 667
+ 668
+ 669
+ 670
+ 671
+ 672
+ 673
+ 674
+ 675
+ 676
+ 677
+ 678
+ 679
+ 680
+ 681
+ 682
+ 683
+ 684
+ 685
+ 686
+ 687
+ 688
+ 689
+ 690
+ 691
+ 692
+ 693
+ 694
+ 695
+ 696
+ 697
+ 698
+ 699
+ 700
+ 701
+ 702
+ 703
+ 704
+ 705
+ 706
+ 707
+ 708
+ 709
+ 710
+ 711
+ 712
+ 713
+ 714
+ 715
+ 716
+ 717
+ 718
+ 719
+ 720
+ 721
+ 722
+ 723
+ 724
+ 725
+ 726
+ 727
+ 728
+ 729
+ 730
+ 731
+ 732
+ 733
+ 734
+ 735
+ 736
+ 737
+ 738
+ 739
+ 740
+ 741
+ 742
+ 743
+ 744
+ 745
+ 746
+ 747
+ 748
+ 749
+ 750
+ 751
+ 752
+ 753
+ 754
+ 755
+ 756
+ 757
+ 758
+ 759
+ 760
+ 761
+ 762
+ 763
+ 764
+ 765
+ 766
+ 767
+ 768
+ 769
+ 770
+ 771
+ 772
+ 773
+ 774
+ 775
+ 776
+ 777
+ 778
+ 779
+ 780
+ 781
+ 782
+ 783
+ 784
+ 785
+ 786
+ 787
+ 788
+ 789
+ 790
+ 791
+ 792
+ 793
+ 794
+ 795
+ 796
+ 797
+ 798
+ 799
+ 800
+ 801
+ 802
+ 803
+ 804
+ 805
+ 806
+ 807
+ 808
+ 809
+ 810
+ 811
+ 812
+ 813
+ 814
+ 815
+ 816
+ 817
+ 818
+ 819
+ 820
+ 821
+ 822
+ 823
+ 824
+ 825
+ 826
+ 827
+ 828
+ 829
+ 830
+ 831
+ 832
+ 833
+ 834
+ 835
+ 836
+ 837
+ 838
+ 839
+ 840
+ 841
+ 842
+ 843
+ 844
+ 845
+ 846
+ 847
+ 848
+ 849
+ 850
+ 851
+ 852
+ 853
+ 854
+ 855
+ 856
+ 857
+ 858
+ 859
+ 860
+ 861
+ 862
+ 863
+ 864
+ 865
+ 866
+ 867
+ 868
+ 869
+ 870
+ 871
+ 872
+ 873
+ 874
+ 875
+ 876
+ 877
+ 878
+ 879
+ 880
+ 881
+ 882
+ 883
+ 884
+ 885
+ 886
+ 887
+ 888
+ 889
+ 890
+ 891
+ 892
+ 893
+ 894
+ 895
+ 896
+ 897
+ 898
+ 899
+ 900
+ 901
+ 902
+ 903
+ 904
+ 905
+ 906
+ 907
+ 908
+ 909
+ 910
+ 911
+ 912
+ 913
+ 914
+ 915
+ 916
+ 917
+ 918
+ 919
+ 920
+ 921
+ 922
+ 923
+ 924
+ 925
+ 926
+ 927
+ 928
+ 929
+ 930
+ 931
+ 932
+ 933
+ 934
+ 935
+ 936
+ 937
+ 938
+ 939
+ 940
+ 941
+ 942
+ 943
+ 944
+ 945
+ 946
+ 947
+ 948
+ 949
+ 950
+ 951
+ 952
+ 953
+ 954
+ 955
+ 956
+ 957
+ 958
+ 959
+ 960
+ 961
+ 962
+ 963
+ 964
+ 965
+ 966
+ 967
+ 968
+ 969
+ 970
+ 971
+ 972
+ 973
+ 974
+ 975
+ 976
+ 977
+ 978
+ 979
+ 980
+ 981
+ 982
+ 983
+ 984
+ 985
+ 986
+ 987
+ 988
+ 989
+ 990
+ 991
+ 992
+ 993
+ 994
+ 995
+ 996
+ 997
+ 998
+ 999
+1000
+1001
+1002
+1003
+1004
+1005
+1006
+1007
+1008
+1009
+1010
+1011
+1012
+1013
+1014
+1015
+1016
+1017
+1018
+1019
+1020
+1021
+1022
+1023
+1024
+1025
+1026
+1027
+1028
+1029
+1030
+1031
+1032
+1033
+1034
+1035
+1036
+1037
+1038
+1039
+1040
+1041
+1042
+1043
+1044
+1045
+1046
+1047
+1048
+1049
+1050
+1051
+1052
+1053
+1054
+1055
+1056
+1057
+1058
+1059
+1060
+1061
+1062
+1063
+1064
+1065
+1066
+1067
+1068
+1069
+1070
+1071
+1072
+1073
+1074
+1075
+1076
+1077
+1078
+1079
+1080
+1081
+1082
+1083
+1084
+1085
+1086
+1087
+1088
+1089
+1090
+1091
+1092
+1093
+1094
+1095
+1096
+1097
+1098
+1099
+1100
+1101
+1102
+1103
+1104
+1105
+1106
+1107
+1108
+1109
+1110
+1111
+1112
+1113
+1114
+1115
+1116
+1117
+1118
+1119
+1120
+1121
+1122
+1123
+1124
+1125
+1126
+1127
+1128
+1129
+1130
+1131
+1132
+1133
+1134
+1135
+1136
+1137
+1138
+1139
+1140
+1141
+1142
+1143
+1144
+1145
+1146
+1147
+1148
+1149
+1150
+1151
+1152
+1153
+1154
+1155
+1156
+1157
+1158
+1159
+1160
+1161
+1162
+1163
+1164
+1165
+1166
+1167
+1168
+1169
+1170
+1171
+1172
+1173
+1174
+1175
+1176
+1177
+1178
+1179
+1180
+1181
+1182
+1183
+1184
+1185
+1186
+1187
+1188
+1189
+1190
+1191
+1192
+1193
+1194
+1195
+1196
+1197
+1198
+1199
+1200
+1201
/*
+ * Copyright (C) 2009 Red Hat, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ * Author: David Zeuthen <davidz@redhat.com>
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"<--- Include file: "config.h" not found.
+#endif
+
+#define _GNU_SOURCE
+#include <unistd.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/types.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/stat.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <fcntl.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <stdio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <stdlib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <pwd.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <errno.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <glib/gi18n-lib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "polkitmateauthenticationdialog.h"
+
+#define RESPONSE_USER_SELECTED 1001
+
+struct _PolkitMateAuthenticationDialogPrivate
+{
+  GtkWidget *user_combobox;
+  GtkWidget *prompt_label;
+  GtkWidget *password_entry;
+  GtkWidget *auth_button;
+  GtkWidget *cancel_button;
+  GtkWidget *info_label;
+  GtkWidget *grid_password;
+
+  gchar *message;
+  gchar *action_id;
+  gchar *vendor;
+  gchar *vendor_url;
+  gchar *icon_name;
+  PolkitDetails *details;
+
+  gchar **users;
+  gchar *selected_user;
+
+  gboolean is_running;
+
+  GtkListStore *store;
+};
+
+G_DEFINE_TYPE_WITH_PRIVATE (PolkitMateAuthenticationDialog, polkit_mate_authentication_dialog, GTK_TYPE_DIALOG);
+
+enum {
+  PROP_0,
+  PROP_ACTION_ID,
+  PROP_VENDOR,
+  PROP_VENDOR_URL,
+  PROP_ICON_NAME,
+  PROP_MESSAGE,
+  PROP_DETAILS,
+  PROP_USERS,
+  PROP_SELECTED_USER,
+};
+
+enum {
+  PIXBUF_COL,
+  TEXT_COL,
+  USERNAME_COL,
+  N_COL
+};
+
+static void
+user_combobox_set_sensitive (GtkCellLayout   *cell_layout,
+                             GtkCellRenderer *cell,
+                             GtkTreeModel    *tree_model,
+                             GtkTreeIter     *iter,
+                             gpointer         user_data)
+{
+  GtkTreePath *path;
+  gint *indices;<--- Variable 'indices' can be declared as pointer to const
+  gboolean sensitive;
+
+  path = gtk_tree_model_get_path (tree_model, iter);
+  indices = gtk_tree_path_get_indices (path);
+  if (indices[0] == 0)
+    sensitive = FALSE;
+  else
+    sensitive = TRUE;
+  gtk_tree_path_free (path);
+
+  g_object_set (cell, "sensitive", sensitive, NULL);
+}
+
+static void
+user_combobox_changed (GtkComboBox *widget,
+                       gpointer     user_data)
+{
+  PolkitMateAuthenticationDialog *dialog = POLKIT_MATE_AUTHENTICATION_DIALOG (user_data);
+  GtkTreeIter iter;
+  gchar *user_name;
+
+  if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (widget), &iter))
+    {
+      gtk_tree_model_get (GTK_TREE_MODEL (dialog->priv->store), &iter, USERNAME_COL, &user_name, -1);
+
+      g_free (dialog->priv->selected_user);
+      dialog->priv->selected_user = user_name;
+
+      g_object_notify (G_OBJECT (dialog), "selected-user");
+
+      gtk_dialog_response (GTK_DIALOG (dialog), RESPONSE_USER_SELECTED);
+
+      /* make the password entry and Authenticate button sensitive again */
+      gtk_widget_set_sensitive (dialog->priv->prompt_label, TRUE);
+      gtk_widget_set_sensitive (dialog->priv->password_entry, TRUE);
+      gtk_widget_set_sensitive (dialog->priv->auth_button, TRUE);
+    }
+}
+
+#if HAVE_ACCOUNTSSERVICE
+static GdkPixbuf *
+get_user_icon (char *username)
+{
+  GError *error;
+  GDBusConnection *connection;
+  GVariant *find_user_result;
+  GVariant *get_icon_result;
+  GVariant *icon_result_variant;
+  const gchar *user_path;
+  const gchar *icon_filename;
+  GdkPixbuf *pixbuf = NULL;
+
+  error = NULL;
+  connection = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
+
+  if (connection == NULL)
+    {
+      g_warning ("Unable to connect to system bus: %s", error->message);
+      g_error_free (error);
+      return NULL;
+    }
+
+  find_user_result = g_dbus_connection_call_sync (connection,
+                                          "org.freedesktop.Accounts",
+                                          "/org/freedesktop/Accounts",
+                                          "org.freedesktop.Accounts",
+                                          "FindUserByName",
+                                          g_variant_new ("(s)",
+                                          username),
+                                          G_VARIANT_TYPE ("(o)"),
+                                          G_DBUS_CALL_FLAGS_NONE,
+                                          -1,
+                                          NULL,
+                                          &error);
+
+  if (find_user_result == NULL)
+    {
+      g_warning ("Accounts couldn't find user: %s", error->message);
+      g_error_free (error);
+      return NULL;
+    }
+
+  user_path = g_variant_get_string (g_variant_get_child_value (find_user_result, 0),
+                                    NULL);
+
+  get_icon_result = g_dbus_connection_call_sync (connection,
+                                                 "org.freedesktop.Accounts",
+                                                 user_path,
+                                                 "org.freedesktop.DBus.Properties",
+                                                 "Get",
+                                                 g_variant_new ("(ss)",
+                                                                "org.freedesktop.Accounts.User",
+                                                                "IconFile"),
+                                                 G_VARIANT_TYPE ("(v)"),
+                                                 G_DBUS_CALL_FLAGS_NONE,
+                                                 -1,
+                                                 NULL,
+                                                 &error);
+
+  g_variant_unref (find_user_result);
+
+  if (get_icon_result == NULL)
+    {
+      g_warning ("Accounts couldn't find user icon: %s", error->message);
+      g_error_free (error);
+      return NULL;
+    }
+
+  g_variant_get_child (get_icon_result, 0, "v", &icon_result_variant);
+  icon_filename = g_variant_get_string (icon_result_variant, NULL);
+
+  if (icon_filename == NULL)
+    {
+      g_warning ("Accounts didn't return a valid filename for user icon");
+    }
+  else
+    {
+      /* TODO: we probably shouldn't hard-code the size to 16x16 */
+      pixbuf = gdk_pixbuf_new_from_file_at_size (icon_filename,
+                                                 16,
+                                                 16,
+                                                 &error);
+      if (pixbuf == NULL)
+        {
+          g_warning ("Couldn't open user icon: %s", error->message);
+          g_error_free (error);
+        }
+    }
+
+  g_variant_unref (icon_result_variant);
+  g_variant_unref (get_icon_result);
+
+  return pixbuf;
+}
+#else
+static GdkPixbuf *
+get_user_icon (char *username)
+{
+  GdkPixbuf *pixbuf = NULL;
+  struct passwd *passwd;
+
+  passwd = getpwnam (username);
+  if (passwd->pw_dir != NULL)
+    {
+      gchar *path;
+      path = g_strdup_printf ("%s/.face", passwd->pw_dir);
+      /* TODO: we probably shouldn't hard-code the size to 16x16 */
+      pixbuf = gdk_pixbuf_new_from_file_at_scale (path, 16, 16, TRUE, NULL);
+      g_free (path);
+    }
+
+  return pixbuf;
+}
+#endif /* HAVE_ACCOUNTSSERVICE */
+
+static void
+create_user_combobox (PolkitMateAuthenticationDialog *dialog)
+{
+  int n, i, selected_index = 0;
+  GtkComboBox *combo;
+  GtkTreeIter iter;
+  GtkCellRenderer *renderer;
+
+  /* if we've already built the list of admin users once, then avoid
+   * doing it again.. (this is mainly used when the user entered the
+   * wrong password and the dialog is recycled)
+   */
+  if (dialog->priv->store != NULL)
+    return;
+
+  combo = GTK_COMBO_BOX (dialog->priv->user_combobox);
+  dialog->priv->store = gtk_list_store_new (3, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING);
+
+  gtk_list_store_append (dialog->priv->store, &iter);
+  gtk_list_store_set (dialog->priv->store, &iter,
+                      PIXBUF_COL, NULL,
+                      TEXT_COL, _("Select user..."),
+                      USERNAME_COL, NULL,
+                      -1);
+
+  /* For each user */
+  for (i = 0, n = 0; dialog->priv->users[n] != NULL; n++)
+  {
+      gchar *gecos;
+      gchar *real_name;
+      GdkPixbuf *pixbuf = NULL;
+      struct passwd *passwd;
+
+      /* we're single threaded so this is fine */
+      errno = 0;
+      passwd = getpwnam (dialog->priv->users[n]);
+      if (passwd == NULL)
+        {
+          g_warning ("Error doing getpwnam(\"%s\"): %s", dialog->priv->users[n], strerror (errno));
+          continue;
+        }
+
+      if (passwd->pw_gecos != NULL)
+        gecos = g_locale_to_utf8 (passwd->pw_gecos, -1, NULL, NULL, NULL);
+      else
+        gecos = NULL;
+
+      if (gecos != NULL && strlen (gecos) > 0)
+        {
+          gchar *first_comma;
+          first_comma = strchr (gecos, ',');
+          if (first_comma != NULL)
+            *first_comma = '\0';
+        }
+      if (gecos != NULL && strlen (gecos) > 0 && strcmp (gecos, dialog->priv->users[n]) != 0)
+        real_name = g_strdup_printf (_("%s (%s)"), gecos, dialog->priv->users[n]);
+       else
+         real_name = g_strdup (dialog->priv->users[n]);
+      g_free (gecos);
+
+      /* Load users face */
+      pixbuf = get_user_icon (dialog->priv->users[n]);
+
+      /* fall back to stock_person icon */
+      if (pixbuf == NULL)
+        {
+          pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
+                                             "stock_person",
+                                             GTK_ICON_SIZE_MENU,
+                                             0,
+                                             NULL);
+        }
+
+      gtk_list_store_append (dialog->priv->store, &iter);
+      gtk_list_store_set (dialog->priv->store, &iter,
+                          PIXBUF_COL, pixbuf,
+                          TEXT_COL, real_name,
+                          USERNAME_COL, dialog->priv->users[n],
+                          -1);
+
+      i++;
+      if (passwd->pw_uid == getuid ())
+        {
+          selected_index = i;
+          g_free (dialog->priv->selected_user);
+          dialog->priv->selected_user = g_strdup (dialog->priv->users[n]);
+        }
+
+      g_free (real_name);
+      g_object_unref (pixbuf);
+    }
+
+  gtk_combo_box_set_model (combo, GTK_TREE_MODEL (dialog->priv->store));
+
+  renderer = gtk_cell_renderer_pixbuf_new ();
+  gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), renderer, FALSE);
+  gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo),
+                                  renderer,
+                                  "pixbuf", PIXBUF_COL,
+                                  NULL);
+  gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (combo),
+                                      renderer,
+                                      user_combobox_set_sensitive,
+                                      NULL, NULL);
+
+  renderer = gtk_cell_renderer_text_new ();
+  gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), renderer, TRUE);
+  gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo),
+                                  renderer,
+                                  "text", TEXT_COL,
+                                  NULL);
+  gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (combo),
+                                      renderer,
+                                      user_combobox_set_sensitive,
+                                      NULL, NULL);
+
+  /* Select the default user */
+  gtk_combo_box_set_active (GTK_COMBO_BOX (combo), selected_index);
+
+  /* Listen when a new user is selected */
+  g_signal_connect (GTK_WIDGET (combo),
+                    "changed",
+                    G_CALLBACK (user_combobox_changed),
+                    dialog);
+}
+
+static GtkWidget *
+get_image (PolkitMateAuthenticationDialog *dialog)
+{
+  GdkPixbuf *pixbuf;
+  GdkPixbuf *copy_pixbuf;
+  GdkPixbuf *vendor_pixbuf;
+  GtkWidget *image;
+
+  pixbuf = NULL;
+  copy_pixbuf = NULL;
+  vendor_pixbuf = NULL;
+  image = NULL;
+
+  if (dialog->priv->icon_name == NULL || strlen (dialog->priv->icon_name) == 0)
+    {
+      image = gtk_image_new_from_icon_name ("dialog-password", GTK_ICON_SIZE_DIALOG);
+      goto out;
+    }
+
+  vendor_pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
+                                            dialog->priv->icon_name,
+                                            48,
+                                            0,
+                                            NULL);
+  if (vendor_pixbuf == NULL)
+    {
+      g_warning ("No icon for themed icon with name '%s'", dialog->priv->icon_name);
+      image = gtk_image_new_from_icon_name ("dialog-password", GTK_ICON_SIZE_DIALOG);
+      goto out;
+    }
+
+  pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
+                                     "dialog-password",
+                                     48,
+                                     0,
+                                     NULL);
+  if (pixbuf == NULL)
+    goto out;
+
+  /* need to copy the pixbuf since we're modifying it */
+  copy_pixbuf = gdk_pixbuf_copy (pixbuf);
+  if (copy_pixbuf == NULL)
+    goto out;
+
+  /* blend the vendor icon in the bottom right quarter */
+  gdk_pixbuf_composite (vendor_pixbuf,
+                        copy_pixbuf,
+                        24, 24, 24, 24,
+                        24, 24, 0.5, 0.5,
+                        GDK_INTERP_BILINEAR,
+                        255);
+
+  image = gtk_image_new_from_pixbuf (copy_pixbuf);
+
+out:
+  if (pixbuf != NULL)
+    g_object_unref (pixbuf);
+
+  if (copy_pixbuf != NULL)
+    g_object_unref (copy_pixbuf);
+
+  if (vendor_pixbuf != NULL)
+    g_object_unref (vendor_pixbuf);
+
+  return image;
+}
+
+static void
+polkit_mate_authentication_dialog_set_property (GObject      *object,
+                                                 guint         prop_id,
+                                                 const GValue *value,
+                                                 GParamSpec   *pspec)
+{
+  PolkitMateAuthenticationDialog *dialog = POLKIT_MATE_AUTHENTICATION_DIALOG (object);
+
+  switch (prop_id)
+    {
+    case PROP_DETAILS:
+      dialog->priv->details = g_value_dup_object (value);
+      break;
+
+    case PROP_ACTION_ID:
+      dialog->priv->action_id = g_value_dup_string (value);
+      break;
+
+    case PROP_VENDOR:
+      dialog->priv->vendor = g_value_dup_string (value);
+      break;
+
+    case PROP_VENDOR_URL:
+      dialog->priv->vendor_url = g_value_dup_string (value);
+      break;
+
+    case PROP_ICON_NAME:
+      dialog->priv->icon_name = g_value_dup_string (value);
+      break;
+
+    case PROP_MESSAGE:
+      dialog->priv->message = g_value_dup_string (value);
+      break;
+
+    case PROP_USERS:
+      dialog->priv->users = g_value_dup_boxed (value);
+      break;
+
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+    }
+}
+
+static void
+polkit_mate_authentication_dialog_get_property (GObject    *object,
+                                                 guint       prop_id,
+                                                 GValue     *value,
+                                                 GParamSpec *pspec)
+{
+  PolkitMateAuthenticationDialog *dialog = POLKIT_MATE_AUTHENTICATION_DIALOG (object);
+
+  switch (prop_id)
+    {
+    case PROP_MESSAGE:
+      g_value_set_string (value, dialog->priv->message);
+      break;
+
+    /* TODO: rest of the properties */
+
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+    }
+}
+
+static GtkWidget *
+add_row (GtkWidget *grid, int row, const char *label_text, GtkWidget *entry)
+{
+  GtkWidget *label;
+
+  label = gtk_label_new_with_mnemonic (label_text);
+  gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
+  gtk_label_set_xalign (GTK_LABEL (label), 1.0);
+  gtk_label_set_yalign (GTK_LABEL (label), 0.5);
+
+  gtk_widget_set_hexpand (label, FALSE);
+  gtk_grid_attach (GTK_GRID (grid), label,
+                   0, row, 1, 1);
+  gtk_widget_set_hexpand (entry, TRUE);
+  gtk_grid_attach (GTK_GRID (grid), entry,
+                   1, row, 1, 1);
+  gtk_label_set_mnemonic_widget (GTK_LABEL (label), entry);
+
+  return label;
+}
+
+static void
+action_id_activated (GtkLabel *url_label, gpointer user_data)
+{
+#if 0
+  GError *error;
+  DBusGConnection *bus;
+  DBusGProxy *manager_proxy;
+
+  error = NULL;
+  bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
+  if (bus == NULL)
+    {
+      g_warning ("Couldn't connect to session bus: %s", error->message);
+      g_error_free (error);
+      goto out;
+    }
+
+  manager_proxy = dbus_g_proxy_new_for_name (bus,
+                                             "org.mate.PolicyKit.AuthorizationManager",
+                                             "/",
+                                             "org.mate.PolicyKit.AuthorizationManager.SingleInstance");
+  if (manager_proxy == NULL)
+    {
+      g_warning ("Could not construct manager_proxy object; bailing out");
+      goto out;
+    }
+
+  if (!dbus_g_proxy_call (manager_proxy,
+                          "ShowAction",
+                          &error,
+                          G_TYPE_STRING, gtk_label_get_current_uri (GTK_LABEL (url_label)),
+                          G_TYPE_INVALID,
+                          G_TYPE_INVALID))
+    {
+      if (error != NULL)
+        {
+          g_warning ("Failed to call into manager: %s", error->message);
+          g_error_free (error);
+        }
+      else
+        {
+          g_warning ("Failed to call into manager");
+        }
+      goto out;
+    }
+
+out:
+        ;
+#endif
+}
+
+static void
+polkit_mate_authentication_dialog_init (PolkitMateAuthenticationDialog *dialog)
+{
+  dialog->priv = polkit_mate_authentication_dialog_get_instance_private (dialog);
+}
+
+static void
+polkit_mate_authentication_dialog_finalize (GObject *object)
+{
+  PolkitMateAuthenticationDialog *dialog;
+
+  dialog = POLKIT_MATE_AUTHENTICATION_DIALOG (object);
+
+  g_free (dialog->priv->message);
+  g_free (dialog->priv->action_id);
+  g_free (dialog->priv->vendor);
+  g_free (dialog->priv->vendor_url);
+  g_free (dialog->priv->icon_name);
+  if (dialog->priv->details != NULL)
+    g_object_unref (dialog->priv->details);
+
+  g_strfreev (dialog->priv->users);
+  g_free (dialog->priv->selected_user);
+
+  if (dialog->priv->store != NULL)
+    g_object_unref (dialog->priv->store);
+
+  if (G_OBJECT_CLASS (polkit_mate_authentication_dialog_parent_class)->finalize != NULL)
+    G_OBJECT_CLASS (polkit_mate_authentication_dialog_parent_class)->finalize (object);
+}
+
+static GtkWidget*
+polkit_mate_dialog_add_button (GtkDialog   *dialog,
+                               const gchar *button_text,
+                               const gchar *icon_name,
+                                     gint   response_id)
+{
+  GtkWidget *button;
+
+  button = gtk_button_new_with_mnemonic (button_text);
+  gtk_button_set_image (GTK_BUTTON (button), gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_BUTTON));
+
+  gtk_button_set_use_underline (GTK_BUTTON (button), TRUE);
+  gtk_style_context_add_class (gtk_widget_get_style_context (button), "text-button");
+  gtk_widget_set_can_default (button, TRUE);
+  gtk_widget_show (button);
+  gtk_dialog_add_action_widget (GTK_DIALOG (dialog), button, response_id);
+
+  return button;
+}
+
+static void
+polkit_mate_authentication_dialog_constructed (GObject *object)
+{
+  PolkitMateAuthenticationDialog *dialog;
+  GtkWidget *hbox;
+  GtkWidget *main_vbox;
+  GtkWidget *vbox;
+  GtkWidget *grid_password;
+  GtkWidget *details_expander;
+  GtkWidget *details_vbox;
+  GtkWidget *grid;
+  GtkWidget *label;
+  GtkWidget *image;
+  GtkWidget *content_area;
+  gboolean have_user_combobox;
+  gchar *s;
+  guint rows;
+
+  dialog = POLKIT_MATE_AUTHENTICATION_DIALOG (object);
+
+  if (G_OBJECT_CLASS (polkit_mate_authentication_dialog_parent_class)->constructed != NULL)
+    G_OBJECT_CLASS (polkit_mate_authentication_dialog_parent_class)->constructed (object);
+
+  have_user_combobox = FALSE;
+
+  dialog->priv->cancel_button = polkit_mate_dialog_add_button (GTK_DIALOG (dialog),
+                                                               _("_Cancel"),
+                                                               "process-stop",
+                                                               GTK_RESPONSE_CANCEL);
+
+  dialog->priv->auth_button = gtk_dialog_add_button (GTK_DIALOG (dialog),
+                                                     _("_Authenticate"),
+                                                     GTK_RESPONSE_OK);
+
+  gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
+
+  content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
+
+  gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
+  gtk_box_set_spacing (GTK_BOX (content_area), 2); /* 2 * 5 + 2 = 12 */
+  gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
+  gtk_window_set_icon_name (GTK_WINDOW (dialog), "dialog-password");
+
+  hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
+  gtk_container_set_border_width (GTK_CONTAINER (hbox), 5);
+  gtk_box_pack_start (GTK_BOX (content_area), hbox, TRUE, TRUE, 0);
+
+  image = get_image (dialog);
+  gtk_widget_set_halign (image, GTK_ALIGN_CENTER);
+  gtk_widget_set_valign (image, GTK_ALIGN_START);
+  gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0);
+
+  main_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 10);
+  gtk_box_pack_start (GTK_BOX (hbox), main_vbox, TRUE, TRUE, 0);
+
+  /* main message */
+  label = gtk_label_new (NULL);
+  s = g_strdup_printf ("<big><b>%s</b></big>", dialog->priv->message);
+  gtk_label_set_markup (GTK_LABEL (label), s);
+  g_free (s);
+
+  gtk_label_set_xalign (GTK_LABEL (label), 0.0);
+  gtk_label_set_yalign (GTK_LABEL (label), 0.5);
+  gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
+  gtk_label_set_max_width_chars (GTK_LABEL (label), 50);
+  gtk_box_pack_start (GTK_BOX (main_vbox), label, FALSE, FALSE, 0);
+
+  /* secondary message */
+  label = gtk_label_new (NULL);
+  if (g_strv_length (dialog->priv->users) > 1)
+    {
+          gtk_label_set_markup (GTK_LABEL (label),
+                                _("An application is attempting to perform an action that requires privileges. "
+                                  "Authentication as one of the users below is required to perform this action."));
+    }
+  else
+    {
+      if (strcmp (g_get_user_name (), dialog->priv->users[0]) == 0)
+        {
+          gtk_label_set_markup (GTK_LABEL (label),
+                                _("An application is attempting to perform an action that requires privileges. "
+                                  "Authentication is required to perform this action."));
+        }
+      else
+        {
+          gtk_label_set_markup (GTK_LABEL (label),
+                                _("An application is attempting to perform an action that requires privileges. "
+                                  "Authentication as the super user is required to perform this action."));
+        }
+    }
+
+  gtk_label_set_xalign (GTK_LABEL (label), 0.0);
+  gtk_label_set_yalign (GTK_LABEL (label), 0.5);
+  gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
+  gtk_label_set_max_width_chars (GTK_LABEL (label), 50);
+  gtk_box_pack_start (GTK_BOX (main_vbox), label, FALSE, FALSE, 0);
+
+  /* user combobox */
+  if (g_strv_length (dialog->priv->users) > 1)
+    {
+      dialog->priv->user_combobox = gtk_combo_box_new ();
+      gtk_box_pack_start (GTK_BOX (main_vbox), GTK_WIDGET (dialog->priv->user_combobox), FALSE, FALSE, 0);
+
+      create_user_combobox (dialog);
+
+      have_user_combobox = TRUE;
+    }
+  else
+    {
+      dialog->priv->selected_user = g_strdup (dialog->priv->users[0]);
+    }
+
+  /* password entry */
+  vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
+  gtk_box_pack_start (GTK_BOX (main_vbox), vbox, FALSE, FALSE, 0);
+
+  grid_password = gtk_grid_new ();
+  gtk_grid_set_column_spacing (GTK_GRID (grid_password), 12);
+  gtk_grid_set_row_spacing (GTK_GRID (grid_password), 6);
+  gtk_box_pack_start (GTK_BOX (vbox), grid_password, FALSE, FALSE, 0);
+  dialog->priv->password_entry = gtk_entry_new ();
+  gtk_entry_set_visibility (GTK_ENTRY (dialog->priv->password_entry), FALSE);
+  dialog->priv->prompt_label = add_row (grid_password, 0, _("_Password:"), dialog->priv->password_entry);
+
+  g_signal_connect_swapped (dialog->priv->password_entry, "activate",
+                            G_CALLBACK (gtk_window_activate_default),
+                            dialog);
+
+  dialog->priv->grid_password = grid_password;
+  /* initially never show the password entry stuff; we'll toggle it on/off so it's
+   * only shown when prompting for a password */
+  gtk_widget_set_no_show_all (dialog->priv->grid_password, TRUE);
+
+  /* A label for showing PAM_TEXT_INFO and PAM_TEXT_ERROR messages */
+  label = gtk_label_new (NULL);
+  gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
+  gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
+  dialog->priv->info_label = label;
+
+  /* Details */
+  details_expander = gtk_expander_new_with_mnemonic (_("<small><b>_Details</b></small>"));
+  gtk_expander_set_use_markup (GTK_EXPANDER (details_expander), TRUE);
+  gtk_box_pack_start (GTK_BOX (content_area), details_expander, FALSE, FALSE, 0);
+
+  details_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 10);
+  gtk_container_add (GTK_CONTAINER (details_expander), details_vbox);
+
+  grid = gtk_grid_new ();
+  gtk_widget_set_margin_start (grid, 20);
+  gtk_grid_set_column_spacing (GTK_GRID (grid), 12);
+  gtk_grid_set_row_spacing (GTK_GRID (grid), 6);
+  gtk_box_pack_start (GTK_BOX (details_vbox), grid, FALSE, FALSE, 0);
+
+  /* TODO: sort keys? */
+  rows = 0;
+  if (dialog->priv->details != NULL)
+    {
+      guint n;
+      gchar **keys;
+
+      keys = polkit_details_get_keys (dialog->priv->details);
+      for (n = 0; keys[n] != NULL; n++)
+        {
+          const gchar *key = keys[n];
+          const gchar *value;
+
+          value = polkit_details_lookup (dialog->priv->details, key);
+
+          label = gtk_label_new (NULL);
+          s = g_strdup_printf ("<small>%s</small>", value);
+          gtk_label_set_markup (GTK_LABEL (label), s);
+          g_free (s);
+
+          gtk_label_set_xalign (GTK_LABEL (label), 0.0);
+          gtk_label_set_yalign (GTK_LABEL (label), 1.0);
+
+          s = g_strdup_printf ("<small><b>%s:</b></small>", key);
+          add_row (grid, rows, s, label);
+          g_free (s);
+
+          rows++;
+        }
+      g_strfreev (keys);
+    }
+
+  /* --- */
+
+  label = gtk_label_new (NULL);
+  gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
+  s = g_strdup_printf ("<small><a href=\"%s\">%s</a></small>",
+                       dialog->priv->action_id,
+                       dialog->priv->action_id);
+  gtk_label_set_markup (GTK_LABEL (label), s);
+  g_free (s);
+
+  gtk_label_set_xalign (GTK_LABEL (label), 0.0);
+  gtk_label_set_yalign (GTK_LABEL (label), 1.0);
+
+  add_row (grid, rows++, _("<small><b>Action:</b></small>"), label);
+  g_signal_connect (label, "activate-link", G_CALLBACK (action_id_activated), NULL);
+
+  s = g_strdup_printf (_("Click to edit %s"), dialog->priv->action_id);
+  gtk_widget_set_tooltip_markup (label, s);
+  g_free (s);
+
+  /* --- */
+
+  label = gtk_label_new (NULL);
+  gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
+  s = g_strdup_printf ("<small><a href=\"%s\">%s</a></small>",
+                       dialog->priv->vendor_url,
+                       dialog->priv->vendor);
+  gtk_label_set_markup (GTK_LABEL (label), s);
+  g_free (s);
+
+  gtk_label_set_xalign (GTK_LABEL (label), 0.0);
+  gtk_label_set_yalign (GTK_LABEL (label), 1.0);
+
+  add_row (grid, rows++, _("<small><b>Vendor:</b></small>"), label);
+
+  s = g_strdup_printf (_("Click to open %s"), dialog->priv->vendor_url);
+  gtk_widget_set_tooltip_markup (label, s);
+  g_free (s);
+
+  /* Disable password entry and authenticate until have a user selected */
+  if (have_user_combobox && gtk_combo_box_get_active (GTK_COMBO_BOX (dialog->priv->user_combobox)) == 0)
+    {
+      gtk_widget_set_sensitive (dialog->priv->prompt_label, FALSE);
+      gtk_widget_set_sensitive (dialog->priv->password_entry, FALSE);
+      gtk_widget_set_sensitive (dialog->priv->auth_button, FALSE);
+    }
+
+  gtk_widget_realize (GTK_WIDGET (dialog));
+
+}
+
+static void
+polkit_mate_authentication_dialog_class_init (PolkitMateAuthenticationDialogClass *klass)
+{
+  GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+
+  gobject_class->finalize = polkit_mate_authentication_dialog_finalize;
+  gobject_class->get_property = polkit_mate_authentication_dialog_get_property;
+  gobject_class->set_property = polkit_mate_authentication_dialog_set_property;
+  gobject_class->constructed  = polkit_mate_authentication_dialog_constructed;
+
+  g_object_class_install_property (gobject_class,
+                                   PROP_DETAILS,
+                                   g_param_spec_object ("details",
+                                                        NULL,
+                                                        NULL,
+                                                        POLKIT_TYPE_DETAILS,
+                                                        G_PARAM_READWRITE |
+                                                        G_PARAM_CONSTRUCT_ONLY |
+                                                        G_PARAM_STATIC_NAME |
+                                                        G_PARAM_STATIC_NICK |
+                                                        G_PARAM_STATIC_BLURB));
+
+  g_object_class_install_property (gobject_class,
+                                   PROP_ACTION_ID,
+                                   g_param_spec_string ("action-id",
+                                                        NULL,
+                                                        NULL,
+                                                        NULL,
+                                                        G_PARAM_READWRITE |
+                                                        G_PARAM_CONSTRUCT_ONLY |
+                                                        G_PARAM_STATIC_NAME |
+                                                        G_PARAM_STATIC_NICK |
+                                                        G_PARAM_STATIC_BLURB));
+
+  g_object_class_install_property (gobject_class,
+                                   PROP_VENDOR,
+                                   g_param_spec_string ("vendor",
+                                                        NULL,
+                                                        NULL,
+                                                        NULL,
+                                                        G_PARAM_READWRITE |
+                                                        G_PARAM_CONSTRUCT_ONLY |
+                                                        G_PARAM_STATIC_NAME |
+                                                        G_PARAM_STATIC_NICK |
+                                                        G_PARAM_STATIC_BLURB));
+
+  g_object_class_install_property (gobject_class,
+                                   PROP_VENDOR_URL,
+                                   g_param_spec_string ("vendor-url",
+                                                        NULL,
+                                                        NULL,
+                                                        NULL,
+                                                        G_PARAM_READWRITE |
+                                                        G_PARAM_CONSTRUCT_ONLY |
+                                                        G_PARAM_STATIC_NAME |
+                                                        G_PARAM_STATIC_NICK |
+                                                        G_PARAM_STATIC_BLURB));
+
+  g_object_class_install_property (gobject_class,
+                                   PROP_ICON_NAME,
+                                   g_param_spec_string ("icon-name",
+                                                        NULL,
+                                                        NULL,
+                                                        NULL,
+                                                        G_PARAM_READWRITE |
+                                                        G_PARAM_CONSTRUCT_ONLY |
+                                                        G_PARAM_STATIC_NAME |
+                                                        G_PARAM_STATIC_NICK |
+                                                        G_PARAM_STATIC_BLURB));
+
+  g_object_class_install_property (gobject_class,
+                                   PROP_MESSAGE,
+                                   g_param_spec_string ("message",
+                                                        NULL,
+                                                        NULL,
+                                                        NULL,
+                                                        G_PARAM_READWRITE |
+                                                        G_PARAM_CONSTRUCT_ONLY |
+                                                        G_PARAM_STATIC_NAME |
+                                                        G_PARAM_STATIC_NICK |
+                                                        G_PARAM_STATIC_BLURB));
+
+  g_object_class_install_property (gobject_class,
+                                   PROP_USERS,
+                                   g_param_spec_boxed ("users",
+                                                       NULL,
+                                                       NULL,
+                                                       G_TYPE_STRV,
+                                                       G_PARAM_READWRITE |
+                                                       G_PARAM_CONSTRUCT_ONLY |
+                                                       G_PARAM_STATIC_NAME |
+                                                       G_PARAM_STATIC_NICK |
+                                                       G_PARAM_STATIC_BLURB));
+
+  g_object_class_install_property (gobject_class,
+                                   PROP_SELECTED_USER,
+                                   g_param_spec_string ("selected-user",
+                                                        NULL,
+                                                        NULL,
+                                                        NULL,
+                                                        G_PARAM_READABLE |
+                                                        G_PARAM_STATIC_NAME |
+                                                        G_PARAM_STATIC_NICK |
+                                                        G_PARAM_STATIC_BLURB));
+}
+
+/**
+ * polkit_mate_authentication_dialog_new:
+ *
+ * Yada yada yada...
+ *
+ * Returns: A new password dialog.
+ **/
+GtkWidget *
+polkit_mate_authentication_dialog_new (const gchar    *action_id,
+                                        const gchar    *vendor,
+                                        const gchar    *vendor_url,
+                                        const gchar    *icon_name,
+                                        const gchar    *message_markup,
+                                        PolkitDetails  *details,
+                                        gchar         **users)
+{
+  PolkitMateAuthenticationDialog *dialog;
+  GtkWindow *window;
+
+  dialog = g_object_new (POLKIT_MATE_TYPE_AUTHENTICATION_DIALOG,
+                         "action-id", action_id,
+                         "vendor", vendor,
+                         "vendor-url", vendor_url,
+                         "icon-name", icon_name,
+                         "message", message_markup,
+                         "details", details,
+                         "users", users,
+                         NULL);
+
+  window = GTK_WINDOW (dialog);
+
+  gtk_window_set_position (window, GTK_WIN_POS_CENTER);
+  gtk_window_set_modal (window, TRUE);
+  gtk_window_set_resizable (window, FALSE);
+  gtk_window_set_keep_above (window, TRUE);
+  gtk_window_set_title (window, _("Authenticate"));
+  g_signal_connect (dialog, "close", G_CALLBACK (gtk_widget_hide), NULL);
+
+  return GTK_WIDGET (dialog);
+}
+
+/**
+ * polkit_mate_authentication_dialog_indicate_error:
+ * @dialog: the auth dialog
+ *
+ * Call this function to indicate an authentication error; typically shakes the window
+ **/
+void
+polkit_mate_authentication_dialog_indicate_error (PolkitMateAuthenticationDialog *dialog)
+{
+  int x, y;
+  int n;
+  int diff;
+
+  /* TODO: detect compositing manager and do fancy stuff here */
+
+  gtk_window_get_position (GTK_WINDOW (dialog), &x, &y);
+
+  for (n = 0; n < 10; n++)
+    {
+      if (n % 2 == 0)
+        diff = -15;
+      else
+        diff = 15;
+
+      gtk_window_move (GTK_WINDOW (dialog), x + diff, y);
+
+      while (gtk_events_pending ())
+        {
+          gtk_main_iteration ();
+        }
+
+      g_usleep (10000);
+    }
+
+  gtk_window_move (GTK_WINDOW (dialog), x, y);
+}
+
+/**
+ * polkit_mate_authentication_dialog_run_until_user_is_selected:
+ * @dialog: A #PolkitMateAuthenticationDialog.
+ *
+ * Runs @dialog in a recursive main loop until a user have been selected.
+ *
+ * If there is only one element in the the users array (which is set upon construction) or
+ * an user has already been selected, this function returns immediately with the return
+ * value %TRUE.
+ *
+ * Returns: %TRUE if a user is selected (use polkit_mate_dialog_get_selected_user() to obtain the user) or
+ *          %FALSE if the dialog was cancelled.
+ **/
+gboolean
+polkit_mate_authentication_dialog_run_until_user_is_selected (PolkitMateAuthenticationDialog *dialog)
+{
+  gboolean ret;
+  gint response;
+
+  ret = FALSE;
+
+  if (dialog->priv->selected_user != NULL)
+    {
+      ret = TRUE;
+      goto out;
+    }
+
+  dialog->priv->is_running = TRUE;
+
+  response = gtk_dialog_run (GTK_DIALOG (dialog));
+
+  dialog->priv->is_running = FALSE;
+
+  if (response == RESPONSE_USER_SELECTED)
+    ret = TRUE;
+
+ out:
+  return ret;
+}
+
+/**
+ * polkit_mate_authentication_dialog_run_until_response_for_prompt:
+ * @dialog: A #PolkitMateAuthenticationDialog.
+ * @prompt: The prompt to present the user with.
+ * @echo_chars: Whether characters should be echoed in the password entry box.
+ * @was_cancelled: Set to %TRUE if the dialog was cancelled.
+ * @new_user_selected: Set to %TRUE if another user was selected.
+ *
+ * Runs @dialog in a recursive main loop until a response to @prompt have been obtained from the user.
+ *
+ * Returns: The response (free with g_free()) or %NULL if one of @was_cancelled or @new_user_selected
+ *          has been set to %TRUE.
+ **/
+gchar *
+polkit_mate_authentication_dialog_run_until_response_for_prompt (PolkitMateAuthenticationDialog *dialog,
+                                                                  const gchar           *prompt,
+                                                                  gboolean               echo_chars,
+                                                                  gboolean              *was_cancelled,
+                                                                  gboolean              *new_user_selected)
+{
+  gint response;
+  gchar *ret;
+
+  gtk_label_set_text_with_mnemonic (GTK_LABEL (dialog->priv->prompt_label), prompt);
+  gtk_entry_set_visibility (GTK_ENTRY (dialog->priv->password_entry), echo_chars);
+  gtk_entry_set_text (GTK_ENTRY (dialog->priv->password_entry), "");
+  gtk_widget_grab_focus (dialog->priv->password_entry);
+
+  ret = NULL;
+
+  if (was_cancelled != NULL)
+    *was_cancelled = FALSE;
+
+  if (new_user_selected != NULL)
+    *new_user_selected = FALSE;
+
+  dialog->priv->is_running = TRUE;
+
+  gtk_widget_set_no_show_all (dialog->priv->grid_password, FALSE);
+  gtk_widget_show_all (dialog->priv->grid_password);
+
+  response = gtk_dialog_run (GTK_DIALOG (dialog));
+
+  gtk_widget_hide (dialog->priv->grid_password);
+  gtk_widget_set_no_show_all (dialog->priv->grid_password, TRUE);
+
+  dialog->priv->is_running = FALSE;
+
+  if (response == GTK_RESPONSE_OK)
+    {
+      ret = g_strdup (gtk_entry_get_text (GTK_ENTRY (dialog->priv->password_entry)));
+    }
+  else if (response == RESPONSE_USER_SELECTED)
+    {
+      if (new_user_selected != NULL)
+        *new_user_selected = TRUE;
+    }
+  else
+    {
+      if (was_cancelled != NULL)
+        *was_cancelled = TRUE;
+    }
+
+  return ret;
+}
+
+/**
+ * polkit_mate_authentication_dialog_get_selected_user:
+ * @dialog: A #PolkitMateAuthenticationDialog.
+ *
+ * Gets the currently selected user.
+ *
+ * Returns: The currently selected user (free with g_free()) or %NULL if no user is currently selected.
+ **/
+gchar *
+polkit_mate_authentication_dialog_get_selected_user (PolkitMateAuthenticationDialog *dialog)
+{
+  return g_strdup (dialog->priv->selected_user);
+}
+
+void
+polkit_mate_authentication_dialog_set_info_message (PolkitMateAuthenticationDialog *dialog,
+                                                     const gchar                     *info_markup)
+{
+  gtk_label_set_markup (GTK_LABEL (dialog->priv->info_label), info_markup);
+}
+
+/**
+ * polkit_mate_authentication_dialog_cancel:
+ * @dialog: A #PolkitMateAuthenticationDialog.
+ *
+ * Cancels the dialog if it is currenlty running.
+ *
+ * Returns: %TRUE if the dialog was running.
+ **/
+gboolean
+polkit_mate_authentication_dialog_cancel (PolkitMateAuthenticationDialog *dialog)
+{
+  if (!dialog->priv->is_running)
+    return FALSE;
+
+  gtk_dialog_response (GTK_DIALOG (dialog), GTK_RESPONSE_CANCEL);
+
+  return TRUE;
+}
+
+ +
+ +
+ + diff --git a/2024-02-24-205454-0706-cppcheck@1d41ea003763_shiti-meson/3.html b/2024-02-24-205454-0706-cppcheck@1d41ea003763_shiti-meson/3.html new file mode 100644 index 0000000..6ad06dd --- /dev/null +++ b/2024-02-24-205454-0706-cppcheck@1d41ea003763_shiti-meson/3.html @@ -0,0 +1,393 @@ + + + + + + Cppcheck - HTML report - mate-polkit + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
+78
/*
+ * Copyright (C) 2009 Red Hat, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ * Author: David Zeuthen <davidz@redhat.com>
+ */
+
+#ifndef __POLKIT_MATE_AUTHENTICATION_DIALOG_H
+#define __POLKIT_MATE_AUTHENTICATION_DIALOG_H
+
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <polkit/polkit.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define POLKIT_MATE_TYPE_AUTHENTICATION_DIALOG            (polkit_mate_authentication_dialog_get_type ())
+#define POLKIT_MATE_AUTHENTICATION_DIALOG(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), POLKIT_MATE_TYPE_AUTHENTICATION_DIALOG, PolkitMateAuthenticationDialog))
+#define POLKIT_MATE_AUTHENTICATION_DIALOG_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), POLKIT_MATE_TYPE_AUTHENTICATION_DIALOG, PolkitMateAuthenticationDialogClass))
+#define POLKIT_MATE_IS_AUTHENTICATION_DIALOG(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), POLKIT_MATE_TYPE_AUTHENTICATION_DIALOG))
+#define POLKIT_MATE_IS_AUTHENTICATION_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), POLKIT_MATE_TYPE_AUTHENTICATION_DIALOG))
+
+typedef struct _PolkitMateAuthenticationDialog        PolkitMateAuthenticationDialog;
+typedef struct _PolkitMateAuthenticationDialogClass   PolkitMateAuthenticationDialogClass;
+typedef struct _PolkitMateAuthenticationDialogPrivate PolkitMateAuthenticationDialogPrivate;
+
+struct _PolkitMateAuthenticationDialog
+{
+  GtkDialog parent_instance;
+  PolkitMateAuthenticationDialogPrivate *priv;
+};
+
+struct _PolkitMateAuthenticationDialogClass
+{
+  GtkDialogClass parent_class;
+};
+
+GType      polkit_mate_authentication_dialog_get_type                      (void);
+GtkWidget *polkit_mate_authentication_dialog_new                           (const gchar    *action_id,
+                                                                             const gchar    *vendor,
+                                                                             const gchar    *vendor_url,
+                                                                             const gchar    *icon_name,
+                                                                             const gchar    *message_markup,
+                                                                             PolkitDetails  *details,
+                                                                             gchar         **users);
+gchar     *polkit_mate_authentication_dialog_get_selected_user             (PolkitMateAuthenticationDialog *dialog);
+gboolean   polkit_mate_authentication_dialog_run_until_user_is_selected    (PolkitMateAuthenticationDialog *dialog);
+gchar     *polkit_mate_authentication_dialog_run_until_response_for_prompt (PolkitMateAuthenticationDialog *dialog,
+                                                                             const gchar                     *prompt,
+                                                                             gboolean                         echo_chars,
+                                                                             gboolean                        *was_cancelled,
+                                                                             gboolean                        *new_user_selected);
+gboolean   polkit_mate_authentication_dialog_cancel                        (PolkitMateAuthenticationDialog *dialog);
+void       polkit_mate_authentication_dialog_indicate_error                (PolkitMateAuthenticationDialog *dialog);
+void       polkit_mate_authentication_dialog_set_info_message              (PolkitMateAuthenticationDialog *dialog,
+                                                                             const gchar                     *info_markup);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __POLKIT_MATE_AUTHENTICATION_DIALOG_H */
+
+ +
+ +
+ + diff --git a/2024-02-24-205454-0706-cppcheck@1d41ea003763_shiti-meson/4.html b/2024-02-24-205454-0706-cppcheck@1d41ea003763_shiti-meson/4.html new file mode 100644 index 0000000..67c8d37 --- /dev/null +++ b/2024-02-24-205454-0706-cppcheck@1d41ea003763_shiti-meson/4.html @@ -0,0 +1,1269 @@ + + + + + + Cppcheck - HTML report - mate-polkit + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
/*
+ * Copyright (C) 2009 Red Hat, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ * Author: David Zeuthen <davidz@redhat.com>
+ */
+
+#include "config.h"<--- Include file: "config.h" not found.
+
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/types.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <pwd.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gdk/gdkx.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <polkit/polkit.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <polkitagent/polkitagent.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "polkitmateauthenticator.h"
+#include "polkitmateauthenticationdialog.h"
+
+struct _PolkitMateAuthenticator
+{
+  GObject parent_instance;
+
+  PolkitAuthority *authority;
+  gchar *action_id;
+  gchar *message;
+  gchar *icon_name;
+  PolkitDetails *details;
+  gchar *cookie;
+  GList *identities;
+
+  PolkitActionDescription *action_desc;
+  gchar **users;
+
+  gboolean gained_authorization;
+  gboolean was_cancelled;
+  gboolean new_user_selected;
+  gchar *selected_user;
+
+  PolkitAgentSession *session;
+  GtkWidget *dialog;
+  GMainLoop *loop;
+};
+
+struct _PolkitMateAuthenticatorClass
+{
+  GObjectClass parent_class;
+
+};
+
+enum
+{
+  COMPLETED_SIGNAL,
+  LAST_SIGNAL,
+};
+
+static guint signals[LAST_SIGNAL] = {0};
+
+G_DEFINE_TYPE (PolkitMateAuthenticator, polkit_mate_authenticator, G_TYPE_OBJECT);
+
+static void
+polkit_mate_authenticator_init (PolkitMateAuthenticator *authenticator)
+{
+}
+
+static void
+polkit_mate_authenticator_finalize (GObject *object)
+{
+  PolkitMateAuthenticator *authenticator;
+
+  authenticator = POLKIT_MATE_AUTHENTICATOR (object);
+
+  if (authenticator->authority != NULL)
+    g_object_unref (authenticator->authority);
+  g_free (authenticator->action_id);
+  g_free (authenticator->message);
+  g_free (authenticator->icon_name);
+  if (authenticator->details != NULL)
+    g_object_unref (authenticator->details);
+  g_free (authenticator->cookie);
+  g_list_foreach (authenticator->identities, (GFunc) g_object_unref, NULL);
+  g_list_free (authenticator->identities);
+
+  if (authenticator->action_desc != NULL)
+    g_object_unref (authenticator->action_desc);
+  g_strfreev (authenticator->users);
+
+  g_free (authenticator->selected_user);
+  if (authenticator->session != NULL)
+    g_object_unref (authenticator->session);
+  if (authenticator->dialog != NULL)
+    gtk_widget_destroy (authenticator->dialog);
+  if (authenticator->loop != NULL)
+    g_main_loop_unref (authenticator->loop);
+
+  if (G_OBJECT_CLASS (polkit_mate_authenticator_parent_class)->finalize != NULL)
+    G_OBJECT_CLASS (polkit_mate_authenticator_parent_class)->finalize (object);
+}
+
+static void
+polkit_mate_authenticator_class_init (PolkitMateAuthenticatorClass *klass)
+{
+  GObjectClass *gobject_class;
+
+  gobject_class = G_OBJECT_CLASS (klass);
+
+  gobject_class->finalize = polkit_mate_authenticator_finalize;
+
+  /**
+   * PolkitMateAuthenticator::completed:
+   * @authenticator: A #PolkitMateAuthenticator.
+   * @gained_authorization: Whether the authorization was gained.
+   * @dismissed: Whether the dialog was dismissed.
+   *
+   * Emitted when the authentication is completed. The user is supposed to dispose of @authenticator
+   * upon receiving this signal.
+   **/
+  signals[COMPLETED_SIGNAL] = g_signal_new ("completed",
+                                            POLKIT_MATE_TYPE_AUTHENTICATOR,
+                                            G_SIGNAL_RUN_LAST,
+                                            0,                      /* class offset     */
+                                            NULL,                   /* accumulator      */
+                                            NULL,                   /* accumulator data */
+                                            g_cclosure_marshal_generic,
+                                            G_TYPE_NONE,
+                                            2,
+					    G_TYPE_BOOLEAN,
+                                            G_TYPE_BOOLEAN);
+}
+
+static PolkitActionDescription *
+get_desc_for_action (PolkitAuthority *authority,
+                     const gchar     *action_id)
+{
+  GList *action_descs;
+  GList *l;
+  PolkitActionDescription *result;
+
+  result = NULL;
+
+  action_descs = polkit_authority_enumerate_actions_sync (authority,
+                                                          NULL,
+                                                          NULL);
+  for (l = action_descs; l != NULL; l = l->next)
+    {
+      PolkitActionDescription *action_desc = POLKIT_ACTION_DESCRIPTION (l->data);
+
+      if (strcmp (polkit_action_description_get_action_id (action_desc), action_id) == 0)
+        {
+          result = g_object_ref (action_desc);
+          goto out;
+        }
+    }
+
+ out:
+
+  g_list_foreach (action_descs, (GFunc) g_object_unref, NULL);
+  g_list_free (action_descs);
+
+  return result;
+}
+
+static void
+on_dialog_deleted (GtkWidget *widget,
+                   GdkEvent  *event,
+                   gpointer   user_data)
+{
+  PolkitMateAuthenticator *authenticator = POLKIT_MATE_AUTHENTICATOR (user_data);
+
+  polkit_mate_authenticator_cancel (authenticator);
+}
+
+static void
+on_user_selected (GObject    *object,
+                  GParamSpec *pspec,
+                  gpointer    user_data)
+{
+  PolkitMateAuthenticator *authenticator = POLKIT_MATE_AUTHENTICATOR (user_data);
+
+  /* clear any previous messages */
+  polkit_mate_authentication_dialog_set_info_message (POLKIT_MATE_AUTHENTICATION_DIALOG (authenticator->dialog), "");
+
+  polkit_mate_authenticator_cancel (authenticator);
+  authenticator->new_user_selected = TRUE;
+}
+
+PolkitMateAuthenticator *
+polkit_mate_authenticator_new (const gchar     *action_id,
+                                const gchar     *message,
+                                const gchar     *icon_name,
+                                PolkitDetails   *details,
+                                const gchar     *cookie,
+                                GList           *identities)
+{
+  PolkitMateAuthenticator *authenticator;
+  GList *l;
+  guint n;
+  GError *error;
+
+  authenticator = POLKIT_MATE_AUTHENTICATOR (g_object_new (POLKIT_MATE_TYPE_AUTHENTICATOR, NULL));
+
+  error = NULL;
+  authenticator->authority = polkit_authority_get_sync (NULL /* GCancellable* */, &error);
+  if (authenticator->authority == NULL)
+    {
+      g_critical ("Error getting authority: %s", error->message);
+      g_error_free (error);
+      goto error;
+    }
+
+  authenticator->action_id = g_strdup (action_id);
+  authenticator->message = g_strdup (message);
+  authenticator->icon_name = g_strdup (icon_name);
+  if (details != NULL)
+    authenticator->details = g_object_ref (details);
+  authenticator->cookie = g_strdup (cookie);
+  authenticator->identities = g_list_copy (identities);
+  g_list_foreach (authenticator->identities, (GFunc) g_object_ref, NULL);
+
+  authenticator->action_desc = get_desc_for_action (authenticator->authority,
+                                                    authenticator->action_id);
+  if (authenticator->action_desc == NULL)
+    goto error;
+
+  authenticator->users = g_new0 (gchar *, g_list_length (authenticator->identities) + 1);
+  for (l = authenticator->identities, n = 0; l != NULL; l = l->next, n++)
+    {
+      PolkitUnixUser *user = POLKIT_UNIX_USER (l->data);
+      uid_t uid;
+      struct passwd *passwd;
+
+      uid = polkit_unix_user_get_uid (user);
+      passwd = getpwuid (uid);
+      authenticator->users[n] = g_strdup (passwd->pw_name);
+    }
+
+  authenticator->dialog = polkit_mate_authentication_dialog_new
+                            (authenticator->action_id,
+                             polkit_action_description_get_vendor_name (authenticator->action_desc),
+                             polkit_action_description_get_vendor_url (authenticator->action_desc),
+                             authenticator->icon_name,
+                             authenticator->message,
+                             authenticator->details,
+                             authenticator->users);
+  g_signal_connect (authenticator->dialog,
+                    "delete-event",
+                    G_CALLBACK (on_dialog_deleted),
+                    authenticator);
+  g_signal_connect (authenticator->dialog,
+                    "notify::selected-user",
+                    G_CALLBACK (on_user_selected),
+                    authenticator);
+
+  return authenticator;
+
+ error:
+  g_object_unref (authenticator);
+  return NULL;
+}
+
+static void
+session_request (PolkitAgentSession *session,
+                 const char         *request,
+                 gboolean            echo_on,
+                 gpointer            user_data)
+{
+  PolkitMateAuthenticator *authenticator = POLKIT_MATE_AUTHENTICATOR (user_data);
+  gchar *password;
+  gchar *modified_request;
+
+  password = NULL;
+
+  //g_debug ("in conversation_pam_prompt, request='%s', echo_on=%d", request, echo_on);
+
+  /* Fix up, and localize, password prompt if it's password auth */
+  if (g_ascii_strncasecmp (request, "password:", 9) == 0)
+    {
+      if (strcmp (g_get_user_name (), authenticator->selected_user) != 0)
+        {
+          modified_request = g_strdup_printf (_("_Password for %s:"), authenticator->selected_user);
+        }
+      else
+        {
+          modified_request = g_strdup (_("_Password:"));
+        }
+    }
+  else
+    {
+      modified_request = g_strdup (request);
+    }
+
+  gtk_widget_show_all (GTK_WIDGET (authenticator->dialog));
+  if (GDK_IS_X11_WINDOW (gtk_widget_get_window (GTK_WIDGET (authenticator->dialog))))
+    gtk_window_present_with_time (GTK_WINDOW (authenticator->dialog),
+                                  gdk_x11_get_server_time (gtk_widget_get_window (GTK_WIDGET (authenticator->dialog))));
+  else
+    gtk_window_present (GTK_WINDOW (authenticator->dialog));
+
+  password = polkit_mate_authentication_dialog_run_until_response_for_prompt (POLKIT_MATE_AUTHENTICATION_DIALOG (authenticator->dialog),
+                                                                               modified_request,
+                                                                               echo_on,
+                                                                               &authenticator->was_cancelled,
+                                                                               &authenticator->new_user_selected);
+
+  /* cancel auth unless user provided a password */
+  if (password == NULL)
+    {
+      polkit_mate_authenticator_cancel (authenticator);
+      goto out;
+    }
+  else
+    {
+      polkit_agent_session_response (authenticator->session, password);
+      g_free (password);
+    }
+
+out:
+  g_free (modified_request);
+}
+
+static void
+session_show_error (PolkitAgentSession *session,
+                    const gchar        *msg,
+                    gpointer            user_data)
+{
+  PolkitMateAuthenticator *authenticator = POLKIT_MATE_AUTHENTICATOR (user_data);
+  gchar *s;
+
+  s = g_strconcat ("<b>", msg, "</b>", NULL);
+  polkit_mate_authentication_dialog_set_info_message (POLKIT_MATE_AUTHENTICATION_DIALOG (authenticator->dialog), s);
+  g_free (s);
+}
+
+static void
+session_show_info (PolkitAgentSession *session,
+                   const gchar        *msg,
+                   gpointer            user_data)
+{
+  PolkitMateAuthenticator *authenticator = POLKIT_MATE_AUTHENTICATOR (user_data);
+  gchar *s;
+
+  s = g_strconcat ("<b>", msg, "</b>", NULL);
+  polkit_mate_authentication_dialog_set_info_message (POLKIT_MATE_AUTHENTICATION_DIALOG (authenticator->dialog), s);
+  g_free (s);
+
+  gtk_widget_show_all (GTK_WIDGET (authenticator->dialog));
+  gtk_window_present (GTK_WINDOW (authenticator->dialog));
+}
+
+static void
+session_completed (PolkitAgentSession *session,
+                   gboolean            gained_authorization,
+                   gpointer            user_data)
+{
+  PolkitMateAuthenticator *authenticator = POLKIT_MATE_AUTHENTICATOR (user_data);
+
+  authenticator->gained_authorization = gained_authorization;
+
+  //g_debug ("in conversation_done gained=%d", gained_authorization);
+
+  g_main_loop_quit (authenticator->loop);
+}
+
+static gboolean
+do_initiate (gpointer user_data)
+{
+  PolkitMateAuthenticator *authenticator = POLKIT_MATE_AUTHENTICATOR (user_data);
+  PolkitIdentity *identity;
+  gint num_tries;
+
+  gtk_widget_show_all (GTK_WIDGET (authenticator->dialog));
+  gtk_window_present (GTK_WINDOW (authenticator->dialog));
+  if (!polkit_mate_authentication_dialog_run_until_user_is_selected (POLKIT_MATE_AUTHENTICATION_DIALOG (authenticator->dialog)))
+    {
+      /* user cancelled the dialog */
+      /*g_debug ("User cancelled before selecting a user");*/
+      authenticator->was_cancelled = TRUE;
+      goto out;
+    }
+
+  authenticator->loop = g_main_loop_new (NULL, TRUE);
+
+  num_tries = 0;
+
+ try_again:
+
+  g_free (authenticator->selected_user);
+  authenticator->selected_user = polkit_mate_authentication_dialog_get_selected_user (POLKIT_MATE_AUTHENTICATION_DIALOG (authenticator->dialog));
+
+  /*g_debug ("Authenticating user %s", authenticator->selected_user);*/
+  identity = polkit_unix_user_new_for_name (authenticator->selected_user, NULL);
+
+  authenticator->session = polkit_agent_session_new (identity, authenticator->cookie);
+
+  g_object_unref (identity);
+
+  g_signal_connect (authenticator->session,
+                    "request",
+                    G_CALLBACK (session_request),
+                    authenticator);
+
+  g_signal_connect (authenticator->session,
+                    "show-info",
+                    G_CALLBACK (session_show_info),
+                    authenticator);
+
+  g_signal_connect (authenticator->session,
+                    "show-error",
+                    G_CALLBACK (session_show_error),
+                    authenticator);
+
+  g_signal_connect (authenticator->session,
+                    "completed",
+                    G_CALLBACK (session_completed),
+                    authenticator);
+
+  polkit_agent_session_initiate (authenticator->session);
+
+  g_main_loop_run (authenticator->loop);
+
+  /*g_debug ("gained_authorization=%d was_cancelled=%d new_user_selected=%d.",
+           authenticator->gained_authorization,
+           authenticator->was_cancelled,
+           authenticator->new_user_selected);*/
+
+  if (authenticator->new_user_selected)
+    {
+      /*g_debug ("New user selected");*/
+      authenticator->new_user_selected = FALSE;
+      g_object_unref (authenticator->session);
+      authenticator->session = NULL;
+      goto try_again;
+    }
+
+  num_tries++;
+
+  if (!authenticator->gained_authorization && !authenticator->was_cancelled)
+    {
+      if (authenticator->dialog != NULL)
+        {
+          gchar *s;
+
+          s = g_strconcat ("<b>", _("Your authentication attempt was unsuccessful. Please try again."), "</b>", NULL);
+          polkit_mate_authentication_dialog_set_info_message (
+                                  POLKIT_MATE_AUTHENTICATION_DIALOG (authenticator->dialog),
+                                  s);
+          g_free (s);
+          gtk_widget_queue_draw (authenticator->dialog);
+
+          /* shake the dialog to indicate error */
+          polkit_mate_authentication_dialog_indicate_error (POLKIT_MATE_AUTHENTICATION_DIALOG (authenticator->dialog));
+
+          if (num_tries < 3)
+            {
+              g_object_unref (authenticator->session);
+              authenticator->session = NULL;
+              goto try_again;
+            }
+        }
+    }
+
+ out:
+  g_signal_emit_by_name (authenticator,
+                         "completed",
+                         authenticator->gained_authorization,
+                         authenticator->was_cancelled);
+
+  g_object_unref (authenticator);
+
+  return FALSE;
+}
+
+void
+polkit_mate_authenticator_initiate (PolkitMateAuthenticator *authenticator)
+{
+  /* run from idle since we're going to block the main loop in the dialog (which has a recursive mainloop) */
+  g_idle_add (do_initiate, g_object_ref (authenticator));
+}
+
+void
+polkit_mate_authenticator_cancel (PolkitMateAuthenticator *authenticator)
+{
+  if (authenticator->dialog != NULL)
+    polkit_mate_authentication_dialog_cancel (POLKIT_MATE_AUTHENTICATION_DIALOG (authenticator->dialog));
+
+  authenticator->was_cancelled = TRUE;
+
+  if (authenticator->session != NULL)
+    {
+      polkit_agent_session_cancel (authenticator->session);
+    }
+}
+
+const gchar *
+polkit_mate_authenticator_get_cookie (PolkitMateAuthenticator *authenticator)<--- Parameter 'authenticator' can be declared as pointer to const
+{
+  return authenticator->cookie;
+}
+
+
+ +
+ +
+ + diff --git a/2024-02-24-205454-0706-cppcheck@1d41ea003763_shiti-meson/5.html b/2024-02-24-205454-0706-cppcheck@1d41ea003763_shiti-meson/5.html new file mode 100644 index 0000000..b1c66d2 --- /dev/null +++ b/2024-02-24-205454-0706-cppcheck@1d41ea003763_shiti-meson/5.html @@ -0,0 +1,351 @@ + + + + + + Cppcheck - HTML report - mate-polkit + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
/*
+ * Copyright (C) 2009 Red Hat, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ * Author: David Zeuthen <davidz@redhat.com>
+ */
+
+#ifndef __POLKIT_MATE_AUTHENTICATOR_H
+#define __POLKIT_MATE_AUTHENTICATOR_H
+
+#include <glib-object.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define POLKIT_MATE_TYPE_AUTHENTICATOR          (polkit_mate_authenticator_get_type())
+#define POLKIT_MATE_AUTHENTICATOR(o)            (G_TYPE_CHECK_INSTANCE_CAST ((o), POLKIT_MATE_TYPE_AUTHENTICATOR, PolkitMateAuthenticator))
+#define POLKIT_MATE_AUTHENTICATOR_CLASS(k)      (G_TYPE_CHECK_CLASS_CAST((k), POLKIT_MATE_TYPE_AUTHENTICATOR, PolkitMateAuthenticatorClass))
+#define POLKIT_MATE_AUTHENTICATOR_GET_CLASS(o)  (G_TYPE_INSTANCE_GET_CLASS ((o), POLKIT_MATE_TYPE_AUTHENTICATOR, PolkitMateAuthenticatorClass))
+#define POLKIT_MATE_IS_AUTHENTICATOR(o)         (G_TYPE_CHECK_INSTANCE_TYPE ((o), POLKIT_MATE_TYPE_AUTHENTICATOR))
+#define POLKIT_MATE_IS_AUTHENTICATOR_CLASS(k)   (G_TYPE_CHECK_CLASS_TYPE ((k), POLKIT_MATE_TYPE_AUTHENTICATOR))
+
+typedef struct _PolkitMateAuthenticator PolkitMateAuthenticator;
+typedef struct _PolkitMateAuthenticatorClass PolkitMateAuthenticatorClass;
+
+GType                      polkit_mate_authenticator_get_type   (void) G_GNUC_CONST;
+PolkitMateAuthenticator  *polkit_mate_authenticator_new        (const gchar              *action_id,
+                                                                  const gchar              *message,
+                                                                  const gchar              *icon_name,
+                                                                  PolkitDetails            *details,
+                                                                  const gchar              *cookie,
+                                                                  GList                    *identities);
+void                       polkit_mate_authenticator_initiate   (PolkitMateAuthenticator *authenticator);
+void                       polkit_mate_authenticator_cancel     (PolkitMateAuthenticator *authenticator);
+const gchar               *polkit_mate_authenticator_get_cookie (PolkitMateAuthenticator *authenticator);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __POLKIT_MATE_AUTHENTICATOR_H */
+
+ +
+ +
+ + diff --git a/2024-02-24-205454-0706-cppcheck@1d41ea003763_shiti-meson/6.html b/2024-02-24-205454-0706-cppcheck@1d41ea003763_shiti-meson/6.html new file mode 100644 index 0000000..79a947d --- /dev/null +++ b/2024-02-24-205454-0706-cppcheck@1d41ea003763_shiti-meson/6.html @@ -0,0 +1,761 @@ + + + + + + Cppcheck - HTML report - mate-polkit + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
/*
+ * Copyright (C) 2009 Red Hat, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ * Author: David Zeuthen <davidz@redhat.com>
+ */
+
+#include "config.h"<--- Include file: "config.h" not found.
+
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "polkitmatelistener.h"
+#include "polkitmateauthenticator.h"
+
+struct _PolkitMateListener
+{
+  PolkitAgentListener parent_instance;
+
+  /* we support multiple authenticators - they are simply queued up */
+  GList *authenticators;
+
+  PolkitMateAuthenticator *active_authenticator;
+};
+
+struct _PolkitMateListenerClass
+{
+  PolkitAgentListenerClass parent_class;
+};
+
+static void polkit_mate_listener_initiate_authentication (PolkitAgentListener  *listener,
+                                                           const gchar          *action_id,
+                                                           const gchar          *message,
+                                                           const gchar          *icon_name,
+                                                           PolkitDetails        *details,
+                                                           const gchar          *cookie,
+                                                           GList                *identities,
+                                                           GCancellable         *cancellable,
+                                                           GAsyncReadyCallback   callback,
+                                                           gpointer              user_data);
+
+static gboolean polkit_mate_listener_initiate_authentication_finish (PolkitAgentListener  *listener,
+                                                                      GAsyncResult         *res,
+                                                                      GError              **error);
+
+G_DEFINE_TYPE (PolkitMateListener, polkit_mate_listener, POLKIT_AGENT_TYPE_LISTENER);
+
+static void
+polkit_mate_listener_init (PolkitMateListener *listener)
+{
+}
+
+static void
+polkit_mate_listener_finalize (GObject *object)
+{
+  if (G_OBJECT_CLASS (polkit_mate_listener_parent_class)->finalize != NULL)
+    G_OBJECT_CLASS (polkit_mate_listener_parent_class)->finalize (object);
+}
+
+static void
+polkit_mate_listener_class_init (PolkitMateListenerClass *klass)
+{
+  GObjectClass *gobject_class;
+  PolkitAgentListenerClass *listener_class;
+
+  gobject_class = G_OBJECT_CLASS (klass);
+  listener_class = POLKIT_AGENT_LISTENER_CLASS (klass);
+
+  gobject_class->finalize = polkit_mate_listener_finalize;
+
+  listener_class->initiate_authentication          = polkit_mate_listener_initiate_authentication;
+  listener_class->initiate_authentication_finish   = polkit_mate_listener_initiate_authentication_finish;
+}
+
+PolkitAgentListener *
+polkit_mate_listener_new (void)
+{
+  return POLKIT_AGENT_LISTENER (g_object_new (POLKIT_MATE_TYPE_LISTENER, NULL));
+}
+
+typedef struct
+{
+  PolkitMateListener *listener;
+  PolkitMateAuthenticator *authenticator;
+
+  GTask        *task;
+  GCancellable *cancellable;
+
+  gulong cancel_id;
+} AuthData;
+
+static AuthData *
+auth_data_new (PolkitMateListener *listener,
+               PolkitMateAuthenticator *authenticator,
+               GTask *task,
+               GCancellable *cancellable)
+{
+  AuthData *data;
+
+  data = g_new0 (AuthData, 1);
+  data->listener = g_object_ref (listener);
+  data->authenticator = g_object_ref (authenticator);
+  data->task = g_object_ref (task);
+  data->cancellable = g_object_ref (cancellable);
+  return data;
+}
+
+static void
+auth_data_free (AuthData *data)
+{
+  g_object_unref (data->listener);
+  g_object_unref (data->authenticator);
+  g_object_unref (data->task);
+  if (data->cancellable != NULL && data->cancel_id > 0)
+    g_signal_handler_disconnect (data->cancellable, data->cancel_id);
+  g_object_unref (data->cancellable);
+  g_free (data);
+}
+
+static void
+maybe_initiate_next_authenticator (PolkitMateListener *listener)
+{
+  if (listener->active_authenticator == NULL && listener->authenticators != NULL)
+    {
+      polkit_mate_authenticator_initiate (POLKIT_MATE_AUTHENTICATOR (listener->authenticators->data));
+      listener->active_authenticator = listener->authenticators->data;
+    }
+}
+
+static void
+authenticator_completed (PolkitMateAuthenticator *authenticator,
+                         gboolean                 gained_authorization,
+                         gboolean                 dismissed,
+                         gpointer                 user_data)
+{
+  AuthData *data = user_data;
+
+  data->listener->authenticators = g_list_remove (data->listener->authenticators, authenticator);
+  if (authenticator == data->listener->active_authenticator)
+    data->listener->active_authenticator = NULL;
+
+  g_object_unref (authenticator);
+
+  if (dismissed)
+    {
+      g_task_return_new_error (data->task,
+                               POLKIT_ERROR,
+                               POLKIT_ERROR_CANCELLED,
+                               _("Authentication dialog was dismissed by the user"));
+    }
+
+  g_task_return_boolean (data->task, TRUE);
+  g_object_unref (data->task);
+
+  maybe_initiate_next_authenticator (data->listener);
+
+  auth_data_free (data);
+}
+
+static void
+cancelled_cb (GCancellable *cancellable,
+              gpointer user_data)
+{
+  AuthData *data = user_data;
+
+  polkit_mate_authenticator_cancel (data->authenticator);
+}
+
+static void
+polkit_mate_listener_initiate_authentication (PolkitAgentListener  *agent_listener,
+                                               const gchar          *action_id,
+                                               const gchar          *message,
+                                               const gchar          *icon_name,
+                                               PolkitDetails        *details,
+                                               const gchar          *cookie,
+                                               GList                *identities,
+                                               GCancellable         *cancellable,
+                                               GAsyncReadyCallback   callback,
+                                               gpointer              user_data)
+{
+  PolkitMateListener *listener = POLKIT_MATE_LISTENER (agent_listener);
+  GTask *task;
+  PolkitMateAuthenticator *authenticator;
+  AuthData *data;
+
+  task = g_task_new (G_OBJECT (listener),
+                     NULL,
+                     callback,
+                     user_data);
+  g_task_set_source_tag (task,
+                         polkit_mate_listener_initiate_authentication);
+
+  authenticator = polkit_mate_authenticator_new (action_id,
+                                                  message,
+                                                  icon_name,
+                                                  details,
+                                                  cookie,
+                                                  identities);
+  if (authenticator == NULL)
+    {
+      g_task_return_new_error (task,
+                               POLKIT_ERROR,
+                               POLKIT_ERROR_FAILED,
+                               "Error creating authentication object");
+      g_object_unref (task);
+      goto out;
+    }
+
+  data = auth_data_new (listener, authenticator, task, cancellable);
+
+  g_signal_connect (authenticator,
+                    "completed",
+                    G_CALLBACK (authenticator_completed),
+                    data);
+
+  if (cancellable != NULL)
+    {
+      data->cancel_id = g_signal_connect (cancellable,
+                                          "cancelled",
+                                          G_CALLBACK (cancelled_cb),
+                                          data);
+    }
+
+  listener->authenticators = g_list_append (listener->authenticators, authenticator);
+
+  maybe_initiate_next_authenticator (listener);
+
+ out:
+  ;
+}
+
+static gboolean
+polkit_mate_listener_initiate_authentication_finish (PolkitAgentListener  *listener,
+                                                      GAsyncResult         *res,
+                                                      GError              **error)
+{
+  GTask *task = G_TASK (res);
+
+  g_warn_if_fail (g_task_get_source_tag (task) == polkit_mate_listener_initiate_authentication);
+
+  if (g_task_propagate_pointer (task, error) == NULL) {
+    return FALSE;
+  }
+
+  return TRUE;
+}
+
+
+ +
+ +
+ + diff --git a/2024-02-24-205454-0706-cppcheck@1d41ea003763_shiti-meson/index.html b/2024-02-24-205454-0706-cppcheck@1d41ea003763_shiti-meson/index.html new file mode 100644 index 0000000..35f12cd --- /dev/null +++ b/2024-02-24-205454-0706-cppcheck@1d41ea003763_shiti-meson/index.html @@ -0,0 +1,252 @@ + + + + + + Cppcheck - HTML report - mate-polkit + + + + + +
+ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
LineIdCWESeverityMessage
checkersReportinformationActive checkers: 106/592 (use --checkers-report=<filename> to see details)
src/main.c
23missingIncludeinformationInclude file: "config.h" not found.
26missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <gio/gio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
29missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
30missingIncludeSysteminformationInclude file: <polkitagent/polkitagent.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
33missingIncludeSysteminformationInclude file: <libayatana-appindicator/app-indicator.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
35missingIncludeSysteminformationInclude file: <libappindicator/app-indicator.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
226shadowVariable398styleLocal variable 'authority' shadows outer variable
316constParameterCallback398styleParameter 'signal_name' can be declared as pointer to const. However it seems that 'signal_cb' is a callback function, if 'signal_name' is declared with const you might also need to cast function pointer(s).
src/polkitmateauthenticationdialog.c
24missingIncludeinformationInclude file: "config.h" not found.
28missingIncludeSysteminformationInclude file: <unistd.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
29missingIncludeSysteminformationInclude file: <sys/types.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
30missingIncludeSysteminformationInclude file: <sys/stat.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
31missingIncludeSysteminformationInclude file: <fcntl.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
32missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
33missingIncludeSysteminformationInclude file: <stdio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
34missingIncludeSysteminformationInclude file: <stdlib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
35missingIncludeSysteminformationInclude file: <pwd.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
36missingIncludeSysteminformationInclude file: <errno.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
38missingIncludeSysteminformationInclude file: <glib/gi18n-lib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
39missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
99constVariablePointer398styleVariable 'indices' can be declared as pointer to const
src/polkitmateauthenticationdialog.h
26missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <polkit/polkit.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/polkitmateauthenticator.c
23missingIncludeinformationInclude file: "config.h" not found.
25missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <sys/types.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <pwd.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
29missingIncludeSysteminformationInclude file: <gdk/gdkx.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
31missingIncludeSysteminformationInclude file: <polkit/polkit.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
32missingIncludeSysteminformationInclude file: <polkitagent/polkitagent.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
512constParameterPointer398styleParameter 'authenticator' can be declared as pointer to const
src/polkitmateauthenticator.h
26missingIncludeSysteminformationInclude file: <glib-object.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/polkitmatelistener.c
23missingIncludeinformationInclude file: "config.h" not found.
25missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/polkitmatelistener.h
26missingIncludeSysteminformationInclude file: <polkitagent/polkitagent.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+ +
+ + diff --git a/2024-02-24-205454-0706-cppcheck@1d41ea003763_shiti-meson/stats.html b/2024-02-24-205454-0706-cppcheck@1d41ea003763_shiti-meson/stats.html new file mode 100644 index 0000000..5c5881a --- /dev/null +++ b/2024-02-24-205454-0706-cppcheck@1d41ea003763_shiti-meson/stats.html @@ -0,0 +1,178 @@ + + + + + + Cppcheck - HTML report - mate-polkit + + + + + +
+ + + +
+

Top 10 files for style severity, total findings: 4
+   2  src/main.c
+   1  src/polkitmateauthenticator.c
+   1  src/polkitmateauthenticationdialog.c
+

+

Top 10 files for information severity, total findings: 35
+   12  src/polkitmateauthenticationdialog.c
+   8   src/polkitmateauthenticator.c
+   8   src/main.c
+   3   src/polkitmatelistener.c
+   2   src/polkitmateauthenticationdialog.h
+   1   src/polkitmatelistener.h
+   1   src/polkitmateauthenticator.h
+

+ +
+ +
+ + diff --git a/2024-02-24-205454-0706-cppcheck@1d41ea003763_shiti-meson/style.css b/2024-02-24-205454-0706-cppcheck@1d41ea003763_shiti-meson/style.css new file mode 100644 index 0000000..3897bfa --- /dev/null +++ b/2024-02-24-205454-0706-cppcheck@1d41ea003763_shiti-meson/style.css @@ -0,0 +1,177 @@ + +body { + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif; + font-size: 13px; + line-height: 1.5; + height: 100%; + margin: 0; +} + +#wrapper { + position: fixed; + height: 100vh; + width: 100vw; + display: grid; + grid-template-rows: fit-content(8rem) auto fit-content(8rem); + grid-template-columns: fit-content(25%) 1fr; + grid-template-areas: + "header header" + "menu content" + "footer footer"; +} + +h1 { + margin: 0 0 8px -2px; + font-size: 175%; +} + +.header { + padding: 0 0 5px 15px; + grid-area: header; + border-bottom: thin solid #aaa; +} + +.footer { + grid-area: footer; + border-top: thin solid #aaa; + font-size: 85%; + +} + +.footer > p { + margin: 4px; +} + +#menu, +#menu_index { + grid-area: menu; + text-align: left; + overflow: auto; + padding: 0 23px 15px 15px; + border-right: thin solid #aaa; + min-width: 200px; +} + +#menu > a { + display: block; + margin-left: 10px; + font-size: 12px; +} + +#content, +#content_index { + grid-area: content; + padding: 0px 5px 15px 15px; + overflow: auto; +} + +label { + white-space: nowrap; +} + +label.checkBtn.disabled { + color: #606060; + background: #e0e0e0; + font-style: italic; +} + +label.checkBtn, input[type="text"] { + border: 1px solid grey; + border-radius: 4px; + box-shadow: 1px 1px inset; + padding: 1px 5px; +} + +label.checkBtn { + white-space: nowrap; + background: #ccddff; +} + +label.unchecked { + background: #eff8ff; + box-shadow: 1px 1px 1px; +} + +label.checkBtn:hover, label.unchecked:hover{ + box-shadow: 0 0 2px; +} + +label.disabled:hover { + box-shadow: 1px 1px inset; +} + +label.checkBtn > input { + display:none; +} + +.summaryTable { + width: 100%; +} + +table.summaryTable td { padding: 0 5px 0 5px; } + +.statHeader, .severityHeader { + font-weight: bold; +} + +.warning { + background-color: #ffffa7; +} + +.error { + background-color: #ffb7b7; +} + +.error2 { + background-color: #faa; + display: inline-block; + margin-left: 4px; +} + +.inconclusive { + background-color: #b6b6b4; +} + +.inconclusive2 { + background-color: #b6b6b4; + display: inline-block; + margin-left: 4px; +} + +.verbose { + display: inline-block; + vertical-align: top; + cursor: help; +} + +.verbose .content { + display: none; + position: absolute; + padding: 10px; + margin: 4px; + max-width: 40%; + white-space: pre-wrap; + border: 1px solid #000; + background-color: #ffffcc; + cursor: auto; +} + +.highlight .hll { + padding: 1px; +} + +.highlighttable { + background-color: #fff; + position: relative; + margin: -10px; +} + +.linenos { + border-right: thin solid #aaa; + color: #d3d3d3; + padding-right: 6px; +} + +.id-filtered, .severity-filtered, .file-filtered, .tool-filtered, .text-filtered { + visibility: collapse; +} diff --git a/2024-02-26-105052-9928-cppcheck@ad6d40200d0a_master/0.html b/2024-02-26-105052-9928-cppcheck@ad6d40200d0a_master/0.html new file mode 100644 index 0000000..95e5dbc --- /dev/null +++ b/2024-02-26-105052-9928-cppcheck@ad6d40200d0a_master/0.html @@ -0,0 +1,1189 @@ + + + + + + Cppcheck - HTML report - mate-polkit + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
/*
+ * Copyright (C) 2009 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ * Author: David Zeuthen <davidz@redhat.com>
+ */
+
+#ifdef HAVE_CONFIG_H
+#  include "config.h"<--- Include file: "config.h" not found.
+#endif
+
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gio/gio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <polkitagent/polkitagent.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#if defined(HAVE_AYATANA_APPINDICATOR)
+# include <libayatana-appindicator/app-indicator.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#elif defined(HAVE_UBUNTU_APPINDICATOR)
+# include <libappindicator/app-indicator.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#endif
+
+#include "polkitmatelistener.h"
+
+/* session management support for auto-restart */
+#define SM_DBUS_NAME      "org.gnome.SessionManager"
+#define SM_DBUS_PATH      "/org/gnome/SessionManager"
+#define SM_DBUS_INTERFACE "org.gnome.SessionManager"
+#define SM_CLIENT_DBUS_INTERFACE "org.gnome.SessionManager.ClientPrivate"
+
+/* the Authority */
+static PolkitAuthority *authority = NULL;<--- Shadowed declaration
+
+/* the session we are servicing */
+static PolkitSubject *session = NULL;
+
+/* the current set of temporary authorizations */
+static GList *current_temporary_authorizations = NULL;
+
+#if defined(HAVE_AYATANA_APPINDICATOR) || defined(HAVE_UBUNTU_APPINDICATOR)
+static AppIndicator *app_indicator = NULL;
+#else
+static GtkStatusIcon *status_icon = NULL;
+#endif
+
+static GDBusProxy      *sm_proxy;
+static GDBusProxy      *client_proxy = NULL;
+
+static  GMainLoop *loop;
+
+static void
+revoke_tmp_authz_cb (GObject      *source_object,
+                     GAsyncResult *res,
+                     gpointer      user_data)
+{
+  GError *error;
+
+  error = NULL;
+  polkit_authority_revoke_temporary_authorizations_finish (POLKIT_AUTHORITY (source_object),
+                                                           res,
+                                                           &error);
+  if (error != NULL)
+    {
+      g_warning ("Error revoking temporary authorizations: %s", error->message);
+      g_error_free (error);
+    }
+}
+
+static void
+revoke_tmp_authz (void)
+{
+  polkit_authority_revoke_temporary_authorizations (authority,
+                                                    session,
+                                                    NULL,
+                                                    revoke_tmp_authz_cb,
+                                                    NULL);
+}
+
+#if defined(HAVE_AYATANA_APPINDICATOR) || defined(HAVE_UBUNTU_APPINDICATOR)
+static void
+on_menu_item_activate (GtkMenuItem *menu_item,
+                       gpointer     user_data)
+{
+  revoke_tmp_authz ();
+}
+#else
+static void
+on_status_icon_activate (GtkStatusIcon *status_icon,
+                         gpointer       user_data)
+{
+  revoke_tmp_authz ();
+}
+
+static void
+on_status_icon_popup_menu (GtkStatusIcon *status_icon,
+                           guint          button,
+                           guint          activate_time,
+                           gpointer       user_data)
+{
+  revoke_tmp_authz ();
+}
+#endif
+
+static void
+update_temporary_authorization_icon_real (void)
+{
+
+#if 0
+  GList *l;
+  g_debug ("have %d tmp authorizations", g_list_length (current_temporary_authorizations));
+  for (l = current_temporary_authorizations; l != NULL; l = l->next)
+    {
+      PolkitTemporaryAuthorization *authz = POLKIT_TEMPORARY_AUTHORIZATION (l->data);
+
+      g_debug ("have tmp authz for action %s (subject %s) with id %s (obtained %d, expires %d)",
+               polkit_temporary_authorization_get_action_id (authz),
+               polkit_subject_to_string (polkit_temporary_authorization_get_subject (authz)),
+               polkit_temporary_authorization_get_id (authz),
+               (gint) polkit_temporary_authorization_get_time_obtained (authz),
+               (gint) polkit_temporary_authorization_get_time_expires (authz));
+    }
+#endif
+
+  /* TODO:
+   *
+   * - we could do something fancy like displaying a window with the tmp authz
+   *   when the icon is clicked...
+   *
+   * - we could do some work using polkit_subject_exists() to ignore tmp authz
+   *   for subjects that no longer exists.. this is because temporary authorizations
+   *   are only valid for the subject that trigger the authentication dialog.
+   *
+   *   Maybe the authority could do this, would probably involve some polling, but
+   *   it seems cleaner to do this server side.
+   */
+
+  if (current_temporary_authorizations != NULL)
+    {
+      /* show icon */
+#if defined(HAVE_AYATANA_APPINDICATOR) || defined(HAVE_UBUNTU_APPINDICATOR)
+      if (app_indicator == NULL)
+        {
+          GtkWidget *item, *menu;
+
+          app_indicator = app_indicator_new ("mate-polkit",
+                                             "dialog-password",
+                                             APP_INDICATOR_CATEGORY_SYSTEM_SERVICES);
+
+          item = gtk_menu_item_new_with_label (_("Drop all elevated privileges"));
+          g_signal_connect (item,
+                            "activate",
+                            G_CALLBACK (on_menu_item_activate),
+                            NULL);
+          menu = gtk_menu_new ();
+          gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+          gtk_widget_show_all (menu);
+
+          app_indicator_set_menu (app_indicator,
+                                  GTK_MENU (menu));
+          app_indicator_set_status (app_indicator,
+                                    APP_INDICATOR_STATUS_ACTIVE);
+        }
+      else
+        /*Reshow icon from existing appindicator */
+        app_indicator_set_status (app_indicator,
+				    APP_INDICATOR_STATUS_ACTIVE);
+
+#else
+      if (status_icon == NULL)
+        {
+          status_icon = gtk_status_icon_new_from_icon_name ("dialog-password");
+          gtk_status_icon_set_tooltip_text (status_icon,
+                                            _("Click the icon to drop all elevated privileges"));
+          g_signal_connect (status_icon,
+                            "activate",
+                            G_CALLBACK (on_status_icon_activate),
+                            NULL);
+          g_signal_connect (status_icon,
+                            "popup-menu",
+                            G_CALLBACK (on_status_icon_popup_menu),
+                            NULL);
+        }
+#endif
+    }
+  else
+    {
+      /* hide icon */
+#if defined(HAVE_AYATANA_APPINDICATOR) || defined(HAVE_UBUNTU_APPINDICATOR)
+      if (app_indicator != NULL)
+        {
+          /* keep the app_indicator, hide the icon or it won't come back*/
+          app_indicator_set_status (app_indicator,
+				    APP_INDICATOR_STATUS_PASSIVE);
+        }
+#else
+      if (status_icon != NULL)
+        {
+          gtk_status_icon_set_visible (status_icon, FALSE);
+          g_object_unref (status_icon);
+          status_icon = NULL;
+        }
+#endif
+    }
+}
+
+static void
+enumerate_temporary_authorizations_cb (GObject      *source_object,
+                                       GAsyncResult *res,
+                                       gpointer      user_data)
+{
+  PolkitAuthority *authority = POLKIT_AUTHORITY (source_object);<--- Shadow variable
+  GList *temporary_authorizations;
+  GError *error;
+
+  temporary_authorizations = NULL;
+
+  error = NULL;
+  temporary_authorizations = polkit_authority_enumerate_temporary_authorizations_finish (authority,
+                                                                                         res,
+                                                                                         &error);
+  if (error != NULL)
+    {
+      g_warning ("Error enumerating temporary authorizations: %s", error->message);
+      g_error_free (error);
+      goto out;
+    }
+
+  g_list_foreach (current_temporary_authorizations, (GFunc) g_object_unref, NULL);
+  g_list_free (current_temporary_authorizations);
+
+  current_temporary_authorizations = temporary_authorizations;
+
+  update_temporary_authorization_icon_real ();
+
+ out:
+  ;
+}
+
+static void
+update_temporary_authorization_icon (PolkitAuthority *authority)
+{
+  polkit_authority_enumerate_temporary_authorizations (authority,
+                                                       session,
+                                                       NULL,
+                                                       enumerate_temporary_authorizations_cb,
+                                                       NULL);
+}
+
+static void
+on_authority_changed (PolkitAuthority *authority,
+                      gpointer         user_data)
+{
+  update_temporary_authorization_icon (authority);
+}
+
+static void
+stop_cb (void)
+{
+        g_main_loop_quit (loop);
+}
+
+static gboolean
+end_session_response (gboolean is_okay, const gchar *reason)
+{
+        GVariant *res;
+        GError *error = NULL;
+
+        res = g_dbus_proxy_call_sync (client_proxy,
+                                      "EndSessionResponse",
+                                      g_variant_new ("(bs)",
+                                                     is_okay,
+                                                     reason),
+                                      G_DBUS_CALL_FLAGS_NONE,
+                                      -1, /* timeout */
+                                      NULL, /* GCancellable */
+                                      &error);
+        if (! res) {
+                g_warning ("Failed to call EndSessionResponse: %s", error->message);
+                g_error_free (error);
+                return FALSE;
+        }
+
+        g_variant_unref (res);
+        return TRUE;
+}
+
+static void
+query_end_session_cb (void)
+{
+        end_session_response (TRUE, "");
+}
+
+static void
+end_session_cb (void)
+{
+        end_session_response (TRUE, "");
+        g_main_loop_quit (loop);
+}
+
+static void
+signal_cb (GDBusProxy *proxy, gchar *sender_name, gchar *signal_name,<--- Parameter 'signal_name' can be declared as pointer to const
+           GVariant *parameters, gpointer user_data)
+{
+        if (strcmp (signal_name, "Stop") == 0) {
+                stop_cb ();
+        } else if (strcmp (signal_name, "QueryEndSession") == 0) {
+                query_end_session_cb ();
+        } else if (strcmp (signal_name, "EndSession") == 0) {
+                end_session_cb ();
+        }
+}
+
+static gboolean
+register_client_to_gnome_session (void)
+{
+        GError     *error = NULL;
+        GVariant   *res;
+        const char *startup_id;
+        const char *app_id;
+        char       *client_id;
+
+        startup_id = g_getenv ("DESKTOP_AUTOSTART_ID");
+        app_id = "polkit-mate-authentication-agent-1.desktop";
+
+        sm_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
+                                                  G_DBUS_PROXY_FLAGS_NONE,
+                                                  NULL, /* GDBusInterfaceInfo */
+                                                  SM_DBUS_NAME,
+                                                  SM_DBUS_PATH,
+                                                  SM_DBUS_INTERFACE,
+                                                  NULL, /* GCancellable */
+                                                  &error);
+        if (sm_proxy == NULL) {
+                g_message("Failed to get session manager: %s", error->message);
+                g_error_free (error);
+                return FALSE;
+        }
+
+        res = g_dbus_proxy_call_sync (sm_proxy,
+                                      "RegisterClient",
+                                      g_variant_new ("(ss)",
+                                                     app_id,
+                                                     startup_id),
+                                      G_DBUS_CALL_FLAGS_NONE,
+                                      -1, /* timeout */
+                                      NULL, /* GCancellable */
+                                      &error);
+        if (! res) {
+                g_warning ("Failed to register client: %s", error->message);
+                g_error_free (error);
+                return FALSE;
+        }
+
+        if (! g_variant_is_of_type (res, G_VARIANT_TYPE ("(o)"))) {
+                g_warning ("RegisterClient returned unexpected type %s",
+                           g_variant_get_type_string (res));
+                return FALSE;
+        }
+
+        g_variant_get (res, "(&o)", &client_id);
+
+        client_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
+                                                      G_DBUS_PROXY_FLAGS_NONE,
+                                                      NULL, /* GDBusInterfaceInfo */
+                                                      SM_DBUS_NAME,
+                                                      client_id,
+                                                      SM_CLIENT_DBUS_INTERFACE,
+                                                      NULL, /* GCancellable */
+                                                      &error);
+        g_variant_unref (res);
+        if (client_proxy == NULL) {
+                g_message("Failed to get client proxy: %s", error->message);
+                g_error_free (error);
+                return FALSE;
+        }
+
+        g_signal_connect (client_proxy, "g-signal", G_CALLBACK (signal_cb), NULL);<--- You might need to cast the function pointer here
+
+        return TRUE;
+}
+
+int
+main (int argc, char **argv)
+{
+  gint ret;
+  PolkitAgentListener *listener;
+  GError *error;
+
+  gtk_init (&argc, &argv);
+
+  loop = NULL;
+  authority = NULL;
+  listener = NULL;
+  session = NULL;
+  ret = 1;
+
+  bindtextdomain (GETTEXT_PACKAGE, MATELOCALEDIR);
+#if HAVE_BIND_TEXTDOMAIN_CODESET
+  bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+#endif
+  textdomain (GETTEXT_PACKAGE);
+
+  loop = g_main_loop_new (NULL, FALSE);
+
+  error = NULL;
+  authority = polkit_authority_get_sync (NULL /* GCancellable* */, &error);
+  if (authority == NULL)
+    {
+      g_warning ("Error getting authority: %s", error->message);
+      g_error_free (error);
+      goto out;
+    }
+  g_signal_connect (authority,
+                    "changed",
+                    G_CALLBACK (on_authority_changed),
+                    NULL);
+
+  listener = polkit_mate_listener_new ();
+
+  error = NULL;
+  session = polkit_unix_session_new_for_process_sync (getpid (), NULL, &error);
+  if (error != NULL)
+    {
+      g_warning ("Unable to determine the session we are in: %s", error->message);
+      g_error_free (error);
+      goto out;
+    }
+
+  error = NULL;
+  if (!polkit_agent_listener_register (listener,
+				       POLKIT_AGENT_REGISTER_FLAGS_NONE,
+                                       session,
+                                       "/org/mate/PolicyKit1/AuthenticationAgent",
+				       NULL,
+                                       &error))
+    {
+      g_printerr ("Cannot register authentication agent: %s\n", error->message);
+      g_error_free (error);
+      goto out;
+    }
+
+  update_temporary_authorization_icon (authority);
+
+  register_client_to_gnome_session();
+
+  g_main_loop_run (loop);
+
+  ret = 0;
+
+ out:
+  if (authority != NULL)
+    g_object_unref (authority);
+  if (session != NULL)
+    g_object_unref (session);
+  if (listener != NULL)
+    g_object_unref (listener);
+  if (loop != NULL)
+    g_main_loop_unref (loop);
+
+  return ret;
+}
+
+ +
+ +
+ + diff --git a/2024-02-26-105052-9928-cppcheck@ad6d40200d0a_master/1.html b/2024-02-26-105052-9928-cppcheck@ad6d40200d0a_master/1.html new file mode 100644 index 0000000..bf8ec00 --- /dev/null +++ b/2024-02-26-105052-9928-cppcheck@ad6d40200d0a_master/1.html @@ -0,0 +1,335 @@ + + + + + + Cppcheck - HTML report - mate-polkit + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
/*
+ * Copyright (C) 2009 Red Hat, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ * Author: David Zeuthen <davidz@redhat.com>
+ */
+
+#ifndef __POLKIT_MATE_LISTENER_H
+#define __POLKIT_MATE_LISTENER_H
+
+#include <polkitagent/polkitagent.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define POLKIT_MATE_TYPE_LISTENER          (polkit_mate_listener_get_type())
+#define POLKIT_MATE_LISTENER(o)            (G_TYPE_CHECK_INSTANCE_CAST ((o), POLKIT_MATE_TYPE_LISTENER, PolkitMateListener))
+#define POLKIT_MATE_LISTENER_CLASS(k)      (G_TYPE_CHECK_CLASS_CAST((k), POLKIT_MATE_TYPE_LISTENER, PolkitMateListenerClass))
+#define POLKIT_MATE_LISTENER_GET_CLASS(o)  (G_TYPE_INSTANCE_GET_CLASS ((o), POLKIT_MATE_TYPE_LISTENER, PolkitMateListenerClass))
+#define POLKIT_MATE_IS_LISTENER(o)         (G_TYPE_CHECK_INSTANCE_TYPE ((o), POLKIT_MATE_TYPE_LISTENER))
+#define POLKIT_MATE_IS_LISTENER_CLASS(k)   (G_TYPE_CHECK_CLASS_TYPE ((k), POLKIT_MATE_TYPE_LISTENER))
+
+typedef struct _PolkitMateListener PolkitMateListener;
+typedef struct _PolkitMateListenerClass PolkitMateListenerClass;
+
+GType                 polkit_mate_listener_get_type   (void) G_GNUC_CONST;
+PolkitAgentListener  *polkit_mate_listener_new        (void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __POLKIT_MATE_LISTENER_H */
+
+ +
+ +
+ + diff --git a/2024-02-26-105052-9928-cppcheck@ad6d40200d0a_master/2.html b/2024-02-26-105052-9928-cppcheck@ad6d40200d0a_master/2.html new file mode 100644 index 0000000..bce6d3f --- /dev/null +++ b/2024-02-26-105052-9928-cppcheck@ad6d40200d0a_master/2.html @@ -0,0 +1,2639 @@ + + + + + + Cppcheck - HTML report - mate-polkit + + + + + +
+ + + +
+
   1
+   2
+   3
+   4
+   5
+   6
+   7
+   8
+   9
+  10
+  11
+  12
+  13
+  14
+  15
+  16
+  17
+  18
+  19
+  20
+  21
+  22
+  23
+  24
+  25
+  26
+  27
+  28
+  29
+  30
+  31
+  32
+  33
+  34
+  35
+  36
+  37
+  38
+  39
+  40
+  41
+  42
+  43
+  44
+  45
+  46
+  47
+  48
+  49
+  50
+  51
+  52
+  53
+  54
+  55
+  56
+  57
+  58
+  59
+  60
+  61
+  62
+  63
+  64
+  65
+  66
+  67
+  68
+  69
+  70
+  71
+  72
+  73
+  74
+  75
+  76
+  77
+  78
+  79
+  80
+  81
+  82
+  83
+  84
+  85
+  86
+  87
+  88
+  89
+  90
+  91
+  92
+  93
+  94
+  95
+  96
+  97
+  98
+  99
+ 100
+ 101
+ 102
+ 103
+ 104
+ 105
+ 106
+ 107
+ 108
+ 109
+ 110
+ 111
+ 112
+ 113
+ 114
+ 115
+ 116
+ 117
+ 118
+ 119
+ 120
+ 121
+ 122
+ 123
+ 124
+ 125
+ 126
+ 127
+ 128
+ 129
+ 130
+ 131
+ 132
+ 133
+ 134
+ 135
+ 136
+ 137
+ 138
+ 139
+ 140
+ 141
+ 142
+ 143
+ 144
+ 145
+ 146
+ 147
+ 148
+ 149
+ 150
+ 151
+ 152
+ 153
+ 154
+ 155
+ 156
+ 157
+ 158
+ 159
+ 160
+ 161
+ 162
+ 163
+ 164
+ 165
+ 166
+ 167
+ 168
+ 169
+ 170
+ 171
+ 172
+ 173
+ 174
+ 175
+ 176
+ 177
+ 178
+ 179
+ 180
+ 181
+ 182
+ 183
+ 184
+ 185
+ 186
+ 187
+ 188
+ 189
+ 190
+ 191
+ 192
+ 193
+ 194
+ 195
+ 196
+ 197
+ 198
+ 199
+ 200
+ 201
+ 202
+ 203
+ 204
+ 205
+ 206
+ 207
+ 208
+ 209
+ 210
+ 211
+ 212
+ 213
+ 214
+ 215
+ 216
+ 217
+ 218
+ 219
+ 220
+ 221
+ 222
+ 223
+ 224
+ 225
+ 226
+ 227
+ 228
+ 229
+ 230
+ 231
+ 232
+ 233
+ 234
+ 235
+ 236
+ 237
+ 238
+ 239
+ 240
+ 241
+ 242
+ 243
+ 244
+ 245
+ 246
+ 247
+ 248
+ 249
+ 250
+ 251
+ 252
+ 253
+ 254
+ 255
+ 256
+ 257
+ 258
+ 259
+ 260
+ 261
+ 262
+ 263
+ 264
+ 265
+ 266
+ 267
+ 268
+ 269
+ 270
+ 271
+ 272
+ 273
+ 274
+ 275
+ 276
+ 277
+ 278
+ 279
+ 280
+ 281
+ 282
+ 283
+ 284
+ 285
+ 286
+ 287
+ 288
+ 289
+ 290
+ 291
+ 292
+ 293
+ 294
+ 295
+ 296
+ 297
+ 298
+ 299
+ 300
+ 301
+ 302
+ 303
+ 304
+ 305
+ 306
+ 307
+ 308
+ 309
+ 310
+ 311
+ 312
+ 313
+ 314
+ 315
+ 316
+ 317
+ 318
+ 319
+ 320
+ 321
+ 322
+ 323
+ 324
+ 325
+ 326
+ 327
+ 328
+ 329
+ 330
+ 331
+ 332
+ 333
+ 334
+ 335
+ 336
+ 337
+ 338
+ 339
+ 340
+ 341
+ 342
+ 343
+ 344
+ 345
+ 346
+ 347
+ 348
+ 349
+ 350
+ 351
+ 352
+ 353
+ 354
+ 355
+ 356
+ 357
+ 358
+ 359
+ 360
+ 361
+ 362
+ 363
+ 364
+ 365
+ 366
+ 367
+ 368
+ 369
+ 370
+ 371
+ 372
+ 373
+ 374
+ 375
+ 376
+ 377
+ 378
+ 379
+ 380
+ 381
+ 382
+ 383
+ 384
+ 385
+ 386
+ 387
+ 388
+ 389
+ 390
+ 391
+ 392
+ 393
+ 394
+ 395
+ 396
+ 397
+ 398
+ 399
+ 400
+ 401
+ 402
+ 403
+ 404
+ 405
+ 406
+ 407
+ 408
+ 409
+ 410
+ 411
+ 412
+ 413
+ 414
+ 415
+ 416
+ 417
+ 418
+ 419
+ 420
+ 421
+ 422
+ 423
+ 424
+ 425
+ 426
+ 427
+ 428
+ 429
+ 430
+ 431
+ 432
+ 433
+ 434
+ 435
+ 436
+ 437
+ 438
+ 439
+ 440
+ 441
+ 442
+ 443
+ 444
+ 445
+ 446
+ 447
+ 448
+ 449
+ 450
+ 451
+ 452
+ 453
+ 454
+ 455
+ 456
+ 457
+ 458
+ 459
+ 460
+ 461
+ 462
+ 463
+ 464
+ 465
+ 466
+ 467
+ 468
+ 469
+ 470
+ 471
+ 472
+ 473
+ 474
+ 475
+ 476
+ 477
+ 478
+ 479
+ 480
+ 481
+ 482
+ 483
+ 484
+ 485
+ 486
+ 487
+ 488
+ 489
+ 490
+ 491
+ 492
+ 493
+ 494
+ 495
+ 496
+ 497
+ 498
+ 499
+ 500
+ 501
+ 502
+ 503
+ 504
+ 505
+ 506
+ 507
+ 508
+ 509
+ 510
+ 511
+ 512
+ 513
+ 514
+ 515
+ 516
+ 517
+ 518
+ 519
+ 520
+ 521
+ 522
+ 523
+ 524
+ 525
+ 526
+ 527
+ 528
+ 529
+ 530
+ 531
+ 532
+ 533
+ 534
+ 535
+ 536
+ 537
+ 538
+ 539
+ 540
+ 541
+ 542
+ 543
+ 544
+ 545
+ 546
+ 547
+ 548
+ 549
+ 550
+ 551
+ 552
+ 553
+ 554
+ 555
+ 556
+ 557
+ 558
+ 559
+ 560
+ 561
+ 562
+ 563
+ 564
+ 565
+ 566
+ 567
+ 568
+ 569
+ 570
+ 571
+ 572
+ 573
+ 574
+ 575
+ 576
+ 577
+ 578
+ 579
+ 580
+ 581
+ 582
+ 583
+ 584
+ 585
+ 586
+ 587
+ 588
+ 589
+ 590
+ 591
+ 592
+ 593
+ 594
+ 595
+ 596
+ 597
+ 598
+ 599
+ 600
+ 601
+ 602
+ 603
+ 604
+ 605
+ 606
+ 607
+ 608
+ 609
+ 610
+ 611
+ 612
+ 613
+ 614
+ 615
+ 616
+ 617
+ 618
+ 619
+ 620
+ 621
+ 622
+ 623
+ 624
+ 625
+ 626
+ 627
+ 628
+ 629
+ 630
+ 631
+ 632
+ 633
+ 634
+ 635
+ 636
+ 637
+ 638
+ 639
+ 640
+ 641
+ 642
+ 643
+ 644
+ 645
+ 646
+ 647
+ 648
+ 649
+ 650
+ 651
+ 652
+ 653
+ 654
+ 655
+ 656
+ 657
+ 658
+ 659
+ 660
+ 661
+ 662
+ 663
+ 664
+ 665
+ 666
+ 667
+ 668
+ 669
+ 670
+ 671
+ 672
+ 673
+ 674
+ 675
+ 676
+ 677
+ 678
+ 679
+ 680
+ 681
+ 682
+ 683
+ 684
+ 685
+ 686
+ 687
+ 688
+ 689
+ 690
+ 691
+ 692
+ 693
+ 694
+ 695
+ 696
+ 697
+ 698
+ 699
+ 700
+ 701
+ 702
+ 703
+ 704
+ 705
+ 706
+ 707
+ 708
+ 709
+ 710
+ 711
+ 712
+ 713
+ 714
+ 715
+ 716
+ 717
+ 718
+ 719
+ 720
+ 721
+ 722
+ 723
+ 724
+ 725
+ 726
+ 727
+ 728
+ 729
+ 730
+ 731
+ 732
+ 733
+ 734
+ 735
+ 736
+ 737
+ 738
+ 739
+ 740
+ 741
+ 742
+ 743
+ 744
+ 745
+ 746
+ 747
+ 748
+ 749
+ 750
+ 751
+ 752
+ 753
+ 754
+ 755
+ 756
+ 757
+ 758
+ 759
+ 760
+ 761
+ 762
+ 763
+ 764
+ 765
+ 766
+ 767
+ 768
+ 769
+ 770
+ 771
+ 772
+ 773
+ 774
+ 775
+ 776
+ 777
+ 778
+ 779
+ 780
+ 781
+ 782
+ 783
+ 784
+ 785
+ 786
+ 787
+ 788
+ 789
+ 790
+ 791
+ 792
+ 793
+ 794
+ 795
+ 796
+ 797
+ 798
+ 799
+ 800
+ 801
+ 802
+ 803
+ 804
+ 805
+ 806
+ 807
+ 808
+ 809
+ 810
+ 811
+ 812
+ 813
+ 814
+ 815
+ 816
+ 817
+ 818
+ 819
+ 820
+ 821
+ 822
+ 823
+ 824
+ 825
+ 826
+ 827
+ 828
+ 829
+ 830
+ 831
+ 832
+ 833
+ 834
+ 835
+ 836
+ 837
+ 838
+ 839
+ 840
+ 841
+ 842
+ 843
+ 844
+ 845
+ 846
+ 847
+ 848
+ 849
+ 850
+ 851
+ 852
+ 853
+ 854
+ 855
+ 856
+ 857
+ 858
+ 859
+ 860
+ 861
+ 862
+ 863
+ 864
+ 865
+ 866
+ 867
+ 868
+ 869
+ 870
+ 871
+ 872
+ 873
+ 874
+ 875
+ 876
+ 877
+ 878
+ 879
+ 880
+ 881
+ 882
+ 883
+ 884
+ 885
+ 886
+ 887
+ 888
+ 889
+ 890
+ 891
+ 892
+ 893
+ 894
+ 895
+ 896
+ 897
+ 898
+ 899
+ 900
+ 901
+ 902
+ 903
+ 904
+ 905
+ 906
+ 907
+ 908
+ 909
+ 910
+ 911
+ 912
+ 913
+ 914
+ 915
+ 916
+ 917
+ 918
+ 919
+ 920
+ 921
+ 922
+ 923
+ 924
+ 925
+ 926
+ 927
+ 928
+ 929
+ 930
+ 931
+ 932
+ 933
+ 934
+ 935
+ 936
+ 937
+ 938
+ 939
+ 940
+ 941
+ 942
+ 943
+ 944
+ 945
+ 946
+ 947
+ 948
+ 949
+ 950
+ 951
+ 952
+ 953
+ 954
+ 955
+ 956
+ 957
+ 958
+ 959
+ 960
+ 961
+ 962
+ 963
+ 964
+ 965
+ 966
+ 967
+ 968
+ 969
+ 970
+ 971
+ 972
+ 973
+ 974
+ 975
+ 976
+ 977
+ 978
+ 979
+ 980
+ 981
+ 982
+ 983
+ 984
+ 985
+ 986
+ 987
+ 988
+ 989
+ 990
+ 991
+ 992
+ 993
+ 994
+ 995
+ 996
+ 997
+ 998
+ 999
+1000
+1001
+1002
+1003
+1004
+1005
+1006
+1007
+1008
+1009
+1010
+1011
+1012
+1013
+1014
+1015
+1016
+1017
+1018
+1019
+1020
+1021
+1022
+1023
+1024
+1025
+1026
+1027
+1028
+1029
+1030
+1031
+1032
+1033
+1034
+1035
+1036
+1037
+1038
+1039
+1040
+1041
+1042
+1043
+1044
+1045
+1046
+1047
+1048
+1049
+1050
+1051
+1052
+1053
+1054
+1055
+1056
+1057
+1058
+1059
+1060
+1061
+1062
+1063
+1064
+1065
+1066
+1067
+1068
+1069
+1070
+1071
+1072
+1073
+1074
+1075
+1076
+1077
+1078
+1079
+1080
+1081
+1082
+1083
+1084
+1085
+1086
+1087
+1088
+1089
+1090
+1091
+1092
+1093
+1094
+1095
+1096
+1097
+1098
+1099
+1100
+1101
+1102
+1103
+1104
+1105
+1106
+1107
+1108
+1109
+1110
+1111
+1112
+1113
+1114
+1115
+1116
+1117
+1118
+1119
+1120
+1121
+1122
+1123
+1124
+1125
+1126
+1127
+1128
+1129
+1130
+1131
+1132
+1133
+1134
+1135
+1136
+1137
+1138
+1139
+1140
+1141
+1142
+1143
+1144
+1145
+1146
+1147
+1148
+1149
+1150
+1151
+1152
+1153
+1154
+1155
+1156
+1157
+1158
+1159
+1160
+1161
+1162
+1163
+1164
+1165
+1166
+1167
+1168
+1169
+1170
+1171
+1172
+1173
+1174
+1175
+1176
+1177
+1178
+1179
+1180
+1181
+1182
+1183
+1184
+1185
+1186
+1187
+1188
+1189
+1190
+1191
+1192
+1193
+1194
+1195
+1196
+1197
+1198
+1199
+1200
+1201
/*
+ * Copyright (C) 2009 Red Hat, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ * Author: David Zeuthen <davidz@redhat.com>
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"<--- Include file: "config.h" not found.
+#endif
+
+#define _GNU_SOURCE
+#include <unistd.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/types.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/stat.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <fcntl.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <stdio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <stdlib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <pwd.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <errno.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <glib/gi18n-lib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "polkitmateauthenticationdialog.h"
+
+#define RESPONSE_USER_SELECTED 1001
+
+struct _PolkitMateAuthenticationDialogPrivate
+{
+  GtkWidget *user_combobox;
+  GtkWidget *prompt_label;
+  GtkWidget *password_entry;
+  GtkWidget *auth_button;
+  GtkWidget *cancel_button;
+  GtkWidget *info_label;
+  GtkWidget *grid_password;
+
+  gchar *message;
+  gchar *action_id;
+  gchar *vendor;
+  gchar *vendor_url;
+  gchar *icon_name;
+  PolkitDetails *details;
+
+  gchar **users;
+  gchar *selected_user;
+
+  gboolean is_running;
+
+  GtkListStore *store;
+};
+
+G_DEFINE_TYPE_WITH_PRIVATE (PolkitMateAuthenticationDialog, polkit_mate_authentication_dialog, GTK_TYPE_DIALOG);
+
+enum {
+  PROP_0,
+  PROP_ACTION_ID,
+  PROP_VENDOR,
+  PROP_VENDOR_URL,
+  PROP_ICON_NAME,
+  PROP_MESSAGE,
+  PROP_DETAILS,
+  PROP_USERS,
+  PROP_SELECTED_USER,
+};
+
+enum {
+  PIXBUF_COL,
+  TEXT_COL,
+  USERNAME_COL,
+  N_COL
+};
+
+static void
+user_combobox_set_sensitive (GtkCellLayout   *cell_layout,
+                             GtkCellRenderer *cell,
+                             GtkTreeModel    *tree_model,
+                             GtkTreeIter     *iter,
+                             gpointer         user_data)
+{
+  GtkTreePath *path;
+  gint *indices;<--- Variable 'indices' can be declared as pointer to const
+  gboolean sensitive;
+
+  path = gtk_tree_model_get_path (tree_model, iter);
+  indices = gtk_tree_path_get_indices (path);
+  if (indices[0] == 0)
+    sensitive = FALSE;
+  else
+    sensitive = TRUE;
+  gtk_tree_path_free (path);
+
+  g_object_set (cell, "sensitive", sensitive, NULL);
+}
+
+static void
+user_combobox_changed (GtkComboBox *widget,
+                       gpointer     user_data)
+{
+  PolkitMateAuthenticationDialog *dialog = POLKIT_MATE_AUTHENTICATION_DIALOG (user_data);
+  GtkTreeIter iter;
+  gchar *user_name;
+
+  if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (widget), &iter))
+    {
+      gtk_tree_model_get (GTK_TREE_MODEL (dialog->priv->store), &iter, USERNAME_COL, &user_name, -1);
+
+      g_free (dialog->priv->selected_user);
+      dialog->priv->selected_user = user_name;
+
+      g_object_notify (G_OBJECT (dialog), "selected-user");
+
+      gtk_dialog_response (GTK_DIALOG (dialog), RESPONSE_USER_SELECTED);
+
+      /* make the password entry and Authenticate button sensitive again */
+      gtk_widget_set_sensitive (dialog->priv->prompt_label, TRUE);
+      gtk_widget_set_sensitive (dialog->priv->password_entry, TRUE);
+      gtk_widget_set_sensitive (dialog->priv->auth_button, TRUE);
+    }
+}
+
+#if HAVE_ACCOUNTSSERVICE
+static GdkPixbuf *
+get_user_icon (char *username)
+{
+  GError *error;
+  GDBusConnection *connection;
+  GVariant *find_user_result;
+  GVariant *get_icon_result;
+  GVariant *icon_result_variant;
+  const gchar *user_path;
+  const gchar *icon_filename;
+  GdkPixbuf *pixbuf = NULL;
+
+  error = NULL;
+  connection = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
+
+  if (connection == NULL)
+    {
+      g_warning ("Unable to connect to system bus: %s", error->message);
+      g_error_free (error);
+      return NULL;
+    }
+
+  find_user_result = g_dbus_connection_call_sync (connection,
+                                          "org.freedesktop.Accounts",
+                                          "/org/freedesktop/Accounts",
+                                          "org.freedesktop.Accounts",
+                                          "FindUserByName",
+                                          g_variant_new ("(s)",
+                                          username),
+                                          G_VARIANT_TYPE ("(o)"),
+                                          G_DBUS_CALL_FLAGS_NONE,
+                                          -1,
+                                          NULL,
+                                          &error);
+
+  if (find_user_result == NULL)
+    {
+      g_warning ("Accounts couldn't find user: %s", error->message);
+      g_error_free (error);
+      return NULL;
+    }
+
+  user_path = g_variant_get_string (g_variant_get_child_value (find_user_result, 0),
+                                    NULL);
+
+  get_icon_result = g_dbus_connection_call_sync (connection,
+                                                 "org.freedesktop.Accounts",
+                                                 user_path,
+                                                 "org.freedesktop.DBus.Properties",
+                                                 "Get",
+                                                 g_variant_new ("(ss)",
+                                                                "org.freedesktop.Accounts.User",
+                                                                "IconFile"),
+                                                 G_VARIANT_TYPE ("(v)"),
+                                                 G_DBUS_CALL_FLAGS_NONE,
+                                                 -1,
+                                                 NULL,
+                                                 &error);
+
+  g_variant_unref (find_user_result);
+
+  if (get_icon_result == NULL)
+    {
+      g_warning ("Accounts couldn't find user icon: %s", error->message);
+      g_error_free (error);
+      return NULL;
+    }
+
+  g_variant_get_child (get_icon_result, 0, "v", &icon_result_variant);
+  icon_filename = g_variant_get_string (icon_result_variant, NULL);
+
+  if (icon_filename == NULL)
+    {
+      g_warning ("Accounts didn't return a valid filename for user icon");
+    }
+  else
+    {
+      /* TODO: we probably shouldn't hard-code the size to 16x16 */
+      pixbuf = gdk_pixbuf_new_from_file_at_size (icon_filename,
+                                                 16,
+                                                 16,
+                                                 &error);
+      if (pixbuf == NULL)
+        {
+          g_warning ("Couldn't open user icon: %s", error->message);
+          g_error_free (error);
+        }
+    }
+
+  g_variant_unref (icon_result_variant);
+  g_variant_unref (get_icon_result);
+
+  return pixbuf;
+}
+#else
+static GdkPixbuf *
+get_user_icon (char *username)
+{
+  GdkPixbuf *pixbuf = NULL;
+  struct passwd *passwd;
+
+  passwd = getpwnam (username);
+  if (passwd->pw_dir != NULL)
+    {
+      gchar *path;
+      path = g_strdup_printf ("%s/.face", passwd->pw_dir);
+      /* TODO: we probably shouldn't hard-code the size to 16x16 */
+      pixbuf = gdk_pixbuf_new_from_file_at_scale (path, 16, 16, TRUE, NULL);
+      g_free (path);
+    }
+
+  return pixbuf;
+}
+#endif /* HAVE_ACCOUNTSSERVICE */
+
+static void
+create_user_combobox (PolkitMateAuthenticationDialog *dialog)
+{
+  int n, i, selected_index = 0;
+  GtkComboBox *combo;
+  GtkTreeIter iter;
+  GtkCellRenderer *renderer;
+
+  /* if we've already built the list of admin users once, then avoid
+   * doing it again.. (this is mainly used when the user entered the
+   * wrong password and the dialog is recycled)
+   */
+  if (dialog->priv->store != NULL)
+    return;
+
+  combo = GTK_COMBO_BOX (dialog->priv->user_combobox);
+  dialog->priv->store = gtk_list_store_new (3, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING);
+
+  gtk_list_store_append (dialog->priv->store, &iter);
+  gtk_list_store_set (dialog->priv->store, &iter,
+                      PIXBUF_COL, NULL,
+                      TEXT_COL, _("Select user..."),
+                      USERNAME_COL, NULL,
+                      -1);
+
+  /* For each user */
+  for (i = 0, n = 0; dialog->priv->users[n] != NULL; n++)
+  {
+      gchar *gecos;
+      gchar *real_name;
+      GdkPixbuf *pixbuf = NULL;
+      struct passwd *passwd;
+
+      /* we're single threaded so this is fine */
+      errno = 0;
+      passwd = getpwnam (dialog->priv->users[n]);
+      if (passwd == NULL)
+        {
+          g_warning ("Error doing getpwnam(\"%s\"): %s", dialog->priv->users[n], strerror (errno));
+          continue;
+        }
+
+      if (passwd->pw_gecos != NULL)
+        gecos = g_locale_to_utf8 (passwd->pw_gecos, -1, NULL, NULL, NULL);
+      else
+        gecos = NULL;
+
+      if (gecos != NULL && strlen (gecos) > 0)
+        {
+          gchar *first_comma;
+          first_comma = strchr (gecos, ',');
+          if (first_comma != NULL)
+            *first_comma = '\0';
+        }
+      if (gecos != NULL && strlen (gecos) > 0 && strcmp (gecos, dialog->priv->users[n]) != 0)
+        real_name = g_strdup_printf (_("%s (%s)"), gecos, dialog->priv->users[n]);
+       else
+         real_name = g_strdup (dialog->priv->users[n]);
+      g_free (gecos);
+
+      /* Load users face */
+      pixbuf = get_user_icon (dialog->priv->users[n]);
+
+      /* fall back to stock_person icon */
+      if (pixbuf == NULL)
+        {
+          pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
+                                             "stock_person",
+                                             GTK_ICON_SIZE_MENU,
+                                             0,
+                                             NULL);
+        }
+
+      gtk_list_store_append (dialog->priv->store, &iter);
+      gtk_list_store_set (dialog->priv->store, &iter,
+                          PIXBUF_COL, pixbuf,
+                          TEXT_COL, real_name,
+                          USERNAME_COL, dialog->priv->users[n],
+                          -1);
+
+      i++;
+      if (passwd->pw_uid == getuid ())
+        {
+          selected_index = i;
+          g_free (dialog->priv->selected_user);
+          dialog->priv->selected_user = g_strdup (dialog->priv->users[n]);
+        }
+
+      g_free (real_name);
+      g_object_unref (pixbuf);
+    }
+
+  gtk_combo_box_set_model (combo, GTK_TREE_MODEL (dialog->priv->store));
+
+  renderer = gtk_cell_renderer_pixbuf_new ();
+  gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), renderer, FALSE);
+  gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo),
+                                  renderer,
+                                  "pixbuf", PIXBUF_COL,
+                                  NULL);
+  gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (combo),
+                                      renderer,
+                                      user_combobox_set_sensitive,
+                                      NULL, NULL);
+
+  renderer = gtk_cell_renderer_text_new ();
+  gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), renderer, TRUE);
+  gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo),
+                                  renderer,
+                                  "text", TEXT_COL,
+                                  NULL);
+  gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (combo),
+                                      renderer,
+                                      user_combobox_set_sensitive,
+                                      NULL, NULL);
+
+  /* Select the default user */
+  gtk_combo_box_set_active (GTK_COMBO_BOX (combo), selected_index);
+
+  /* Listen when a new user is selected */
+  g_signal_connect (GTK_WIDGET (combo),
+                    "changed",
+                    G_CALLBACK (user_combobox_changed),
+                    dialog);
+}
+
+static GtkWidget *
+get_image (PolkitMateAuthenticationDialog *dialog)
+{
+  GdkPixbuf *pixbuf;
+  GdkPixbuf *copy_pixbuf;
+  GdkPixbuf *vendor_pixbuf;
+  GtkWidget *image;
+
+  pixbuf = NULL;
+  copy_pixbuf = NULL;
+  vendor_pixbuf = NULL;
+  image = NULL;
+
+  if (dialog->priv->icon_name == NULL || strlen (dialog->priv->icon_name) == 0)
+    {
+      image = gtk_image_new_from_icon_name ("dialog-password", GTK_ICON_SIZE_DIALOG);
+      goto out;
+    }
+
+  vendor_pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
+                                            dialog->priv->icon_name,
+                                            48,
+                                            0,
+                                            NULL);
+  if (vendor_pixbuf == NULL)
+    {
+      g_warning ("No icon for themed icon with name '%s'", dialog->priv->icon_name);
+      image = gtk_image_new_from_icon_name ("dialog-password", GTK_ICON_SIZE_DIALOG);
+      goto out;
+    }
+
+  pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
+                                     "dialog-password",
+                                     48,
+                                     0,
+                                     NULL);
+  if (pixbuf == NULL)
+    goto out;
+
+  /* need to copy the pixbuf since we're modifying it */
+  copy_pixbuf = gdk_pixbuf_copy (pixbuf);
+  if (copy_pixbuf == NULL)
+    goto out;
+
+  /* blend the vendor icon in the bottom right quarter */
+  gdk_pixbuf_composite (vendor_pixbuf,
+                        copy_pixbuf,
+                        24, 24, 24, 24,
+                        24, 24, 0.5, 0.5,
+                        GDK_INTERP_BILINEAR,
+                        255);
+
+  image = gtk_image_new_from_pixbuf (copy_pixbuf);
+
+out:
+  if (pixbuf != NULL)
+    g_object_unref (pixbuf);
+
+  if (copy_pixbuf != NULL)
+    g_object_unref (copy_pixbuf);
+
+  if (vendor_pixbuf != NULL)
+    g_object_unref (vendor_pixbuf);
+
+  return image;
+}
+
+static void
+polkit_mate_authentication_dialog_set_property (GObject      *object,
+                                                 guint         prop_id,
+                                                 const GValue *value,
+                                                 GParamSpec   *pspec)
+{
+  PolkitMateAuthenticationDialog *dialog = POLKIT_MATE_AUTHENTICATION_DIALOG (object);
+
+  switch (prop_id)
+    {
+    case PROP_DETAILS:
+      dialog->priv->details = g_value_dup_object (value);
+      break;
+
+    case PROP_ACTION_ID:
+      dialog->priv->action_id = g_value_dup_string (value);
+      break;
+
+    case PROP_VENDOR:
+      dialog->priv->vendor = g_value_dup_string (value);
+      break;
+
+    case PROP_VENDOR_URL:
+      dialog->priv->vendor_url = g_value_dup_string (value);
+      break;
+
+    case PROP_ICON_NAME:
+      dialog->priv->icon_name = g_value_dup_string (value);
+      break;
+
+    case PROP_MESSAGE:
+      dialog->priv->message = g_value_dup_string (value);
+      break;
+
+    case PROP_USERS:
+      dialog->priv->users = g_value_dup_boxed (value);
+      break;
+
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+    }
+}
+
+static void
+polkit_mate_authentication_dialog_get_property (GObject    *object,
+                                                 guint       prop_id,
+                                                 GValue     *value,
+                                                 GParamSpec *pspec)
+{
+  PolkitMateAuthenticationDialog *dialog = POLKIT_MATE_AUTHENTICATION_DIALOG (object);
+
+  switch (prop_id)
+    {
+    case PROP_MESSAGE:
+      g_value_set_string (value, dialog->priv->message);
+      break;
+
+    /* TODO: rest of the properties */
+
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+    }
+}
+
+static GtkWidget *
+add_row (GtkWidget *grid, int row, const char *label_text, GtkWidget *entry)
+{
+  GtkWidget *label;
+
+  label = gtk_label_new_with_mnemonic (label_text);
+  gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
+  gtk_label_set_xalign (GTK_LABEL (label), 1.0);
+  gtk_label_set_yalign (GTK_LABEL (label), 0.5);
+
+  gtk_widget_set_hexpand (label, FALSE);
+  gtk_grid_attach (GTK_GRID (grid), label,
+                   0, row, 1, 1);
+  gtk_widget_set_hexpand (entry, TRUE);
+  gtk_grid_attach (GTK_GRID (grid), entry,
+                   1, row, 1, 1);
+  gtk_label_set_mnemonic_widget (GTK_LABEL (label), entry);
+
+  return label;
+}
+
+static void
+action_id_activated (GtkLabel *url_label, gpointer user_data)
+{
+#if 0
+  GError *error;
+  DBusGConnection *bus;
+  DBusGProxy *manager_proxy;
+
+  error = NULL;
+  bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
+  if (bus == NULL)
+    {
+      g_warning ("Couldn't connect to session bus: %s", error->message);
+      g_error_free (error);
+      goto out;
+    }
+
+  manager_proxy = dbus_g_proxy_new_for_name (bus,
+                                             "org.mate.PolicyKit.AuthorizationManager",
+                                             "/",
+                                             "org.mate.PolicyKit.AuthorizationManager.SingleInstance");
+  if (manager_proxy == NULL)
+    {
+      g_warning ("Could not construct manager_proxy object; bailing out");
+      goto out;
+    }
+
+  if (!dbus_g_proxy_call (manager_proxy,
+                          "ShowAction",
+                          &error,
+                          G_TYPE_STRING, gtk_label_get_current_uri (GTK_LABEL (url_label)),
+                          G_TYPE_INVALID,
+                          G_TYPE_INVALID))
+    {
+      if (error != NULL)
+        {
+          g_warning ("Failed to call into manager: %s", error->message);
+          g_error_free (error);
+        }
+      else
+        {
+          g_warning ("Failed to call into manager");
+        }
+      goto out;
+    }
+
+out:
+        ;
+#endif
+}
+
+static void
+polkit_mate_authentication_dialog_init (PolkitMateAuthenticationDialog *dialog)
+{
+  dialog->priv = polkit_mate_authentication_dialog_get_instance_private (dialog);
+}
+
+static void
+polkit_mate_authentication_dialog_finalize (GObject *object)
+{
+  PolkitMateAuthenticationDialog *dialog;
+
+  dialog = POLKIT_MATE_AUTHENTICATION_DIALOG (object);
+
+  g_free (dialog->priv->message);
+  g_free (dialog->priv->action_id);
+  g_free (dialog->priv->vendor);
+  g_free (dialog->priv->vendor_url);
+  g_free (dialog->priv->icon_name);
+  if (dialog->priv->details != NULL)
+    g_object_unref (dialog->priv->details);
+
+  g_strfreev (dialog->priv->users);
+  g_free (dialog->priv->selected_user);
+
+  if (dialog->priv->store != NULL)
+    g_object_unref (dialog->priv->store);
+
+  if (G_OBJECT_CLASS (polkit_mate_authentication_dialog_parent_class)->finalize != NULL)
+    G_OBJECT_CLASS (polkit_mate_authentication_dialog_parent_class)->finalize (object);
+}
+
+static GtkWidget*
+polkit_mate_dialog_add_button (GtkDialog   *dialog,
+                               const gchar *button_text,
+                               const gchar *icon_name,
+                                     gint   response_id)
+{
+  GtkWidget *button;
+
+  button = gtk_button_new_with_mnemonic (button_text);
+  gtk_button_set_image (GTK_BUTTON (button), gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_BUTTON));
+
+  gtk_button_set_use_underline (GTK_BUTTON (button), TRUE);
+  gtk_style_context_add_class (gtk_widget_get_style_context (button), "text-button");
+  gtk_widget_set_can_default (button, TRUE);
+  gtk_widget_show (button);
+  gtk_dialog_add_action_widget (GTK_DIALOG (dialog), button, response_id);
+
+  return button;
+}
+
+static void
+polkit_mate_authentication_dialog_constructed (GObject *object)
+{
+  PolkitMateAuthenticationDialog *dialog;
+  GtkWidget *hbox;
+  GtkWidget *main_vbox;
+  GtkWidget *vbox;
+  GtkWidget *grid_password;
+  GtkWidget *details_expander;
+  GtkWidget *details_vbox;
+  GtkWidget *grid;
+  GtkWidget *label;
+  GtkWidget *image;
+  GtkWidget *content_area;
+  gboolean have_user_combobox;
+  gchar *s;
+  guint rows;
+
+  dialog = POLKIT_MATE_AUTHENTICATION_DIALOG (object);
+
+  if (G_OBJECT_CLASS (polkit_mate_authentication_dialog_parent_class)->constructed != NULL)
+    G_OBJECT_CLASS (polkit_mate_authentication_dialog_parent_class)->constructed (object);
+
+  have_user_combobox = FALSE;
+
+  dialog->priv->cancel_button = polkit_mate_dialog_add_button (GTK_DIALOG (dialog),
+                                                               _("_Cancel"),
+                                                               "process-stop",
+                                                               GTK_RESPONSE_CANCEL);
+
+  dialog->priv->auth_button = gtk_dialog_add_button (GTK_DIALOG (dialog),
+                                                     _("_Authenticate"),
+                                                     GTK_RESPONSE_OK);
+
+  gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
+
+  content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
+
+  gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
+  gtk_box_set_spacing (GTK_BOX (content_area), 2); /* 2 * 5 + 2 = 12 */
+  gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
+  gtk_window_set_icon_name (GTK_WINDOW (dialog), "dialog-password");
+
+  hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
+  gtk_container_set_border_width (GTK_CONTAINER (hbox), 5);
+  gtk_box_pack_start (GTK_BOX (content_area), hbox, TRUE, TRUE, 0);
+
+  image = get_image (dialog);
+  gtk_widget_set_halign (image, GTK_ALIGN_CENTER);
+  gtk_widget_set_valign (image, GTK_ALIGN_START);
+  gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0);
+
+  main_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 10);
+  gtk_box_pack_start (GTK_BOX (hbox), main_vbox, TRUE, TRUE, 0);
+
+  /* main message */
+  label = gtk_label_new (NULL);
+  s = g_strdup_printf ("<big><b>%s</b></big>", dialog->priv->message);
+  gtk_label_set_markup (GTK_LABEL (label), s);
+  g_free (s);
+
+  gtk_label_set_xalign (GTK_LABEL (label), 0.0);
+  gtk_label_set_yalign (GTK_LABEL (label), 0.5);
+  gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
+  gtk_label_set_max_width_chars (GTK_LABEL (label), 50);
+  gtk_box_pack_start (GTK_BOX (main_vbox), label, FALSE, FALSE, 0);
+
+  /* secondary message */
+  label = gtk_label_new (NULL);
+  if (g_strv_length (dialog->priv->users) > 1)
+    {
+          gtk_label_set_markup (GTK_LABEL (label),
+                                _("An application is attempting to perform an action that requires privileges. "
+                                  "Authentication as one of the users below is required to perform this action."));
+    }
+  else
+    {
+      if (strcmp (g_get_user_name (), dialog->priv->users[0]) == 0)
+        {
+          gtk_label_set_markup (GTK_LABEL (label),
+                                _("An application is attempting to perform an action that requires privileges. "
+                                  "Authentication is required to perform this action."));
+        }
+      else
+        {
+          gtk_label_set_markup (GTK_LABEL (label),
+                                _("An application is attempting to perform an action that requires privileges. "
+                                  "Authentication as the super user is required to perform this action."));
+        }
+    }
+
+  gtk_label_set_xalign (GTK_LABEL (label), 0.0);
+  gtk_label_set_yalign (GTK_LABEL (label), 0.5);
+  gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
+  gtk_label_set_max_width_chars (GTK_LABEL (label), 50);
+  gtk_box_pack_start (GTK_BOX (main_vbox), label, FALSE, FALSE, 0);
+
+  /* user combobox */
+  if (g_strv_length (dialog->priv->users) > 1)
+    {
+      dialog->priv->user_combobox = gtk_combo_box_new ();
+      gtk_box_pack_start (GTK_BOX (main_vbox), GTK_WIDGET (dialog->priv->user_combobox), FALSE, FALSE, 0);
+
+      create_user_combobox (dialog);
+
+      have_user_combobox = TRUE;
+    }
+  else
+    {
+      dialog->priv->selected_user = g_strdup (dialog->priv->users[0]);
+    }
+
+  /* password entry */
+  vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
+  gtk_box_pack_start (GTK_BOX (main_vbox), vbox, FALSE, FALSE, 0);
+
+  grid_password = gtk_grid_new ();
+  gtk_grid_set_column_spacing (GTK_GRID (grid_password), 12);
+  gtk_grid_set_row_spacing (GTK_GRID (grid_password), 6);
+  gtk_box_pack_start (GTK_BOX (vbox), grid_password, FALSE, FALSE, 0);
+  dialog->priv->password_entry = gtk_entry_new ();
+  gtk_entry_set_visibility (GTK_ENTRY (dialog->priv->password_entry), FALSE);
+  dialog->priv->prompt_label = add_row (grid_password, 0, _("_Password:"), dialog->priv->password_entry);
+
+  g_signal_connect_swapped (dialog->priv->password_entry, "activate",
+                            G_CALLBACK (gtk_window_activate_default),
+                            dialog);
+
+  dialog->priv->grid_password = grid_password;
+  /* initially never show the password entry stuff; we'll toggle it on/off so it's
+   * only shown when prompting for a password */
+  gtk_widget_set_no_show_all (dialog->priv->grid_password, TRUE);
+
+  /* A label for showing PAM_TEXT_INFO and PAM_TEXT_ERROR messages */
+  label = gtk_label_new (NULL);
+  gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
+  gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
+  dialog->priv->info_label = label;
+
+  /* Details */
+  details_expander = gtk_expander_new_with_mnemonic (_("<small><b>_Details</b></small>"));
+  gtk_expander_set_use_markup (GTK_EXPANDER (details_expander), TRUE);
+  gtk_box_pack_start (GTK_BOX (content_area), details_expander, FALSE, FALSE, 0);
+
+  details_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 10);
+  gtk_container_add (GTK_CONTAINER (details_expander), details_vbox);
+
+  grid = gtk_grid_new ();
+  gtk_widget_set_margin_start (grid, 20);
+  gtk_grid_set_column_spacing (GTK_GRID (grid), 12);
+  gtk_grid_set_row_spacing (GTK_GRID (grid), 6);
+  gtk_box_pack_start (GTK_BOX (details_vbox), grid, FALSE, FALSE, 0);
+
+  /* TODO: sort keys? */
+  rows = 0;
+  if (dialog->priv->details != NULL)
+    {
+      guint n;
+      gchar **keys;
+
+      keys = polkit_details_get_keys (dialog->priv->details);
+      for (n = 0; keys[n] != NULL; n++)
+        {
+          const gchar *key = keys[n];
+          const gchar *value;
+
+          value = polkit_details_lookup (dialog->priv->details, key);
+
+          label = gtk_label_new (NULL);
+          s = g_strdup_printf ("<small>%s</small>", value);
+          gtk_label_set_markup (GTK_LABEL (label), s);
+          g_free (s);
+
+          gtk_label_set_xalign (GTK_LABEL (label), 0.0);
+          gtk_label_set_yalign (GTK_LABEL (label), 1.0);
+
+          s = g_strdup_printf ("<small><b>%s:</b></small>", key);
+          add_row (grid, rows, s, label);
+          g_free (s);
+
+          rows++;
+        }
+      g_strfreev (keys);
+    }
+
+  /* --- */
+
+  label = gtk_label_new (NULL);
+  gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
+  s = g_strdup_printf ("<small><a href=\"%s\">%s</a></small>",
+                       dialog->priv->action_id,
+                       dialog->priv->action_id);
+  gtk_label_set_markup (GTK_LABEL (label), s);
+  g_free (s);
+
+  gtk_label_set_xalign (GTK_LABEL (label), 0.0);
+  gtk_label_set_yalign (GTK_LABEL (label), 1.0);
+
+  add_row (grid, rows++, _("<small><b>Action:</b></small>"), label);
+  g_signal_connect (label, "activate-link", G_CALLBACK (action_id_activated), NULL);
+
+  s = g_strdup_printf (_("Click to edit %s"), dialog->priv->action_id);
+  gtk_widget_set_tooltip_markup (label, s);
+  g_free (s);
+
+  /* --- */
+
+  label = gtk_label_new (NULL);
+  gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
+  s = g_strdup_printf ("<small><a href=\"%s\">%s</a></small>",
+                       dialog->priv->vendor_url,
+                       dialog->priv->vendor);
+  gtk_label_set_markup (GTK_LABEL (label), s);
+  g_free (s);
+
+  gtk_label_set_xalign (GTK_LABEL (label), 0.0);
+  gtk_label_set_yalign (GTK_LABEL (label), 1.0);
+
+  add_row (grid, rows++, _("<small><b>Vendor:</b></small>"), label);
+
+  s = g_strdup_printf (_("Click to open %s"), dialog->priv->vendor_url);
+  gtk_widget_set_tooltip_markup (label, s);
+  g_free (s);
+
+  /* Disable password entry and authenticate until have a user selected */
+  if (have_user_combobox && gtk_combo_box_get_active (GTK_COMBO_BOX (dialog->priv->user_combobox)) == 0)
+    {
+      gtk_widget_set_sensitive (dialog->priv->prompt_label, FALSE);
+      gtk_widget_set_sensitive (dialog->priv->password_entry, FALSE);
+      gtk_widget_set_sensitive (dialog->priv->auth_button, FALSE);
+    }
+
+  gtk_widget_realize (GTK_WIDGET (dialog));
+
+}
+
+static void
+polkit_mate_authentication_dialog_class_init (PolkitMateAuthenticationDialogClass *klass)
+{
+  GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+
+  gobject_class->finalize = polkit_mate_authentication_dialog_finalize;
+  gobject_class->get_property = polkit_mate_authentication_dialog_get_property;
+  gobject_class->set_property = polkit_mate_authentication_dialog_set_property;
+  gobject_class->constructed  = polkit_mate_authentication_dialog_constructed;
+
+  g_object_class_install_property (gobject_class,
+                                   PROP_DETAILS,
+                                   g_param_spec_object ("details",
+                                                        NULL,
+                                                        NULL,
+                                                        POLKIT_TYPE_DETAILS,
+                                                        G_PARAM_READWRITE |
+                                                        G_PARAM_CONSTRUCT_ONLY |
+                                                        G_PARAM_STATIC_NAME |
+                                                        G_PARAM_STATIC_NICK |
+                                                        G_PARAM_STATIC_BLURB));
+
+  g_object_class_install_property (gobject_class,
+                                   PROP_ACTION_ID,
+                                   g_param_spec_string ("action-id",
+                                                        NULL,
+                                                        NULL,
+                                                        NULL,
+                                                        G_PARAM_READWRITE |
+                                                        G_PARAM_CONSTRUCT_ONLY |
+                                                        G_PARAM_STATIC_NAME |
+                                                        G_PARAM_STATIC_NICK |
+                                                        G_PARAM_STATIC_BLURB));
+
+  g_object_class_install_property (gobject_class,
+                                   PROP_VENDOR,
+                                   g_param_spec_string ("vendor",
+                                                        NULL,
+                                                        NULL,
+                                                        NULL,
+                                                        G_PARAM_READWRITE |
+                                                        G_PARAM_CONSTRUCT_ONLY |
+                                                        G_PARAM_STATIC_NAME |
+                                                        G_PARAM_STATIC_NICK |
+                                                        G_PARAM_STATIC_BLURB));
+
+  g_object_class_install_property (gobject_class,
+                                   PROP_VENDOR_URL,
+                                   g_param_spec_string ("vendor-url",
+                                                        NULL,
+                                                        NULL,
+                                                        NULL,
+                                                        G_PARAM_READWRITE |
+                                                        G_PARAM_CONSTRUCT_ONLY |
+                                                        G_PARAM_STATIC_NAME |
+                                                        G_PARAM_STATIC_NICK |
+                                                        G_PARAM_STATIC_BLURB));
+
+  g_object_class_install_property (gobject_class,
+                                   PROP_ICON_NAME,
+                                   g_param_spec_string ("icon-name",
+                                                        NULL,
+                                                        NULL,
+                                                        NULL,
+                                                        G_PARAM_READWRITE |
+                                                        G_PARAM_CONSTRUCT_ONLY |
+                                                        G_PARAM_STATIC_NAME |
+                                                        G_PARAM_STATIC_NICK |
+                                                        G_PARAM_STATIC_BLURB));
+
+  g_object_class_install_property (gobject_class,
+                                   PROP_MESSAGE,
+                                   g_param_spec_string ("message",
+                                                        NULL,
+                                                        NULL,
+                                                        NULL,
+                                                        G_PARAM_READWRITE |
+                                                        G_PARAM_CONSTRUCT_ONLY |
+                                                        G_PARAM_STATIC_NAME |
+                                                        G_PARAM_STATIC_NICK |
+                                                        G_PARAM_STATIC_BLURB));
+
+  g_object_class_install_property (gobject_class,
+                                   PROP_USERS,
+                                   g_param_spec_boxed ("users",
+                                                       NULL,
+                                                       NULL,
+                                                       G_TYPE_STRV,
+                                                       G_PARAM_READWRITE |
+                                                       G_PARAM_CONSTRUCT_ONLY |
+                                                       G_PARAM_STATIC_NAME |
+                                                       G_PARAM_STATIC_NICK |
+                                                       G_PARAM_STATIC_BLURB));
+
+  g_object_class_install_property (gobject_class,
+                                   PROP_SELECTED_USER,
+                                   g_param_spec_string ("selected-user",
+                                                        NULL,
+                                                        NULL,
+                                                        NULL,
+                                                        G_PARAM_READABLE |
+                                                        G_PARAM_STATIC_NAME |
+                                                        G_PARAM_STATIC_NICK |
+                                                        G_PARAM_STATIC_BLURB));
+}
+
+/**
+ * polkit_mate_authentication_dialog_new:
+ *
+ * Yada yada yada...
+ *
+ * Returns: A new password dialog.
+ **/
+GtkWidget *
+polkit_mate_authentication_dialog_new (const gchar    *action_id,
+                                        const gchar    *vendor,
+                                        const gchar    *vendor_url,
+                                        const gchar    *icon_name,
+                                        const gchar    *message_markup,
+                                        PolkitDetails  *details,
+                                        gchar         **users)
+{
+  PolkitMateAuthenticationDialog *dialog;
+  GtkWindow *window;
+
+  dialog = g_object_new (POLKIT_MATE_TYPE_AUTHENTICATION_DIALOG,
+                         "action-id", action_id,
+                         "vendor", vendor,
+                         "vendor-url", vendor_url,
+                         "icon-name", icon_name,
+                         "message", message_markup,
+                         "details", details,
+                         "users", users,
+                         NULL);
+
+  window = GTK_WINDOW (dialog);
+
+  gtk_window_set_position (window, GTK_WIN_POS_CENTER);
+  gtk_window_set_modal (window, TRUE);
+  gtk_window_set_resizable (window, FALSE);
+  gtk_window_set_keep_above (window, TRUE);
+  gtk_window_set_title (window, _("Authenticate"));
+  g_signal_connect (dialog, "close", G_CALLBACK (gtk_widget_hide), NULL);
+
+  return GTK_WIDGET (dialog);
+}
+
+/**
+ * polkit_mate_authentication_dialog_indicate_error:
+ * @dialog: the auth dialog
+ *
+ * Call this function to indicate an authentication error; typically shakes the window
+ **/
+void
+polkit_mate_authentication_dialog_indicate_error (PolkitMateAuthenticationDialog *dialog)
+{
+  int x, y;
+  int n;
+  int diff;
+
+  /* TODO: detect compositing manager and do fancy stuff here */
+
+  gtk_window_get_position (GTK_WINDOW (dialog), &x, &y);
+
+  for (n = 0; n < 10; n++)
+    {
+      if (n % 2 == 0)
+        diff = -15;
+      else
+        diff = 15;
+
+      gtk_window_move (GTK_WINDOW (dialog), x + diff, y);
+
+      while (gtk_events_pending ())
+        {
+          gtk_main_iteration ();
+        }
+
+      g_usleep (10000);
+    }
+
+  gtk_window_move (GTK_WINDOW (dialog), x, y);
+}
+
+/**
+ * polkit_mate_authentication_dialog_run_until_user_is_selected:
+ * @dialog: A #PolkitMateAuthenticationDialog.
+ *
+ * Runs @dialog in a recursive main loop until a user have been selected.
+ *
+ * If there is only one element in the the users array (which is set upon construction) or
+ * an user has already been selected, this function returns immediately with the return
+ * value %TRUE.
+ *
+ * Returns: %TRUE if a user is selected (use polkit_mate_dialog_get_selected_user() to obtain the user) or
+ *          %FALSE if the dialog was cancelled.
+ **/
+gboolean
+polkit_mate_authentication_dialog_run_until_user_is_selected (PolkitMateAuthenticationDialog *dialog)
+{
+  gboolean ret;
+  gint response;
+
+  ret = FALSE;
+
+  if (dialog->priv->selected_user != NULL)
+    {
+      ret = TRUE;
+      goto out;
+    }
+
+  dialog->priv->is_running = TRUE;
+
+  response = gtk_dialog_run (GTK_DIALOG (dialog));
+
+  dialog->priv->is_running = FALSE;
+
+  if (response == RESPONSE_USER_SELECTED)
+    ret = TRUE;
+
+ out:
+  return ret;
+}
+
+/**
+ * polkit_mate_authentication_dialog_run_until_response_for_prompt:
+ * @dialog: A #PolkitMateAuthenticationDialog.
+ * @prompt: The prompt to present the user with.
+ * @echo_chars: Whether characters should be echoed in the password entry box.
+ * @was_cancelled: Set to %TRUE if the dialog was cancelled.
+ * @new_user_selected: Set to %TRUE if another user was selected.
+ *
+ * Runs @dialog in a recursive main loop until a response to @prompt have been obtained from the user.
+ *
+ * Returns: The response (free with g_free()) or %NULL if one of @was_cancelled or @new_user_selected
+ *          has been set to %TRUE.
+ **/
+gchar *
+polkit_mate_authentication_dialog_run_until_response_for_prompt (PolkitMateAuthenticationDialog *dialog,
+                                                                  const gchar           *prompt,
+                                                                  gboolean               echo_chars,
+                                                                  gboolean              *was_cancelled,
+                                                                  gboolean              *new_user_selected)
+{
+  gint response;
+  gchar *ret;
+
+  gtk_label_set_text_with_mnemonic (GTK_LABEL (dialog->priv->prompt_label), prompt);
+  gtk_entry_set_visibility (GTK_ENTRY (dialog->priv->password_entry), echo_chars);
+  gtk_entry_set_text (GTK_ENTRY (dialog->priv->password_entry), "");
+  gtk_widget_grab_focus (dialog->priv->password_entry);
+
+  ret = NULL;
+
+  if (was_cancelled != NULL)
+    *was_cancelled = FALSE;
+
+  if (new_user_selected != NULL)
+    *new_user_selected = FALSE;
+
+  dialog->priv->is_running = TRUE;
+
+  gtk_widget_set_no_show_all (dialog->priv->grid_password, FALSE);
+  gtk_widget_show_all (dialog->priv->grid_password);
+
+  response = gtk_dialog_run (GTK_DIALOG (dialog));
+
+  gtk_widget_hide (dialog->priv->grid_password);
+  gtk_widget_set_no_show_all (dialog->priv->grid_password, TRUE);
+
+  dialog->priv->is_running = FALSE;
+
+  if (response == GTK_RESPONSE_OK)
+    {
+      ret = g_strdup (gtk_entry_get_text (GTK_ENTRY (dialog->priv->password_entry)));
+    }
+  else if (response == RESPONSE_USER_SELECTED)
+    {
+      if (new_user_selected != NULL)
+        *new_user_selected = TRUE;
+    }
+  else
+    {
+      if (was_cancelled != NULL)
+        *was_cancelled = TRUE;
+    }
+
+  return ret;
+}
+
+/**
+ * polkit_mate_authentication_dialog_get_selected_user:
+ * @dialog: A #PolkitMateAuthenticationDialog.
+ *
+ * Gets the currently selected user.
+ *
+ * Returns: The currently selected user (free with g_free()) or %NULL if no user is currently selected.
+ **/
+gchar *
+polkit_mate_authentication_dialog_get_selected_user (PolkitMateAuthenticationDialog *dialog)
+{
+  return g_strdup (dialog->priv->selected_user);
+}
+
+void
+polkit_mate_authentication_dialog_set_info_message (PolkitMateAuthenticationDialog *dialog,
+                                                     const gchar                     *info_markup)
+{
+  gtk_label_set_markup (GTK_LABEL (dialog->priv->info_label), info_markup);
+}
+
+/**
+ * polkit_mate_authentication_dialog_cancel:
+ * @dialog: A #PolkitMateAuthenticationDialog.
+ *
+ * Cancels the dialog if it is currenlty running.
+ *
+ * Returns: %TRUE if the dialog was running.
+ **/
+gboolean
+polkit_mate_authentication_dialog_cancel (PolkitMateAuthenticationDialog *dialog)
+{
+  if (!dialog->priv->is_running)
+    return FALSE;
+
+  gtk_dialog_response (GTK_DIALOG (dialog), GTK_RESPONSE_CANCEL);
+
+  return TRUE;
+}
+
+ +
+ +
+ + diff --git a/2024-02-26-105052-9928-cppcheck@ad6d40200d0a_master/3.html b/2024-02-26-105052-9928-cppcheck@ad6d40200d0a_master/3.html new file mode 100644 index 0000000..6ad06dd --- /dev/null +++ b/2024-02-26-105052-9928-cppcheck@ad6d40200d0a_master/3.html @@ -0,0 +1,393 @@ + + + + + + Cppcheck - HTML report - mate-polkit + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
+78
/*
+ * Copyright (C) 2009 Red Hat, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ * Author: David Zeuthen <davidz@redhat.com>
+ */
+
+#ifndef __POLKIT_MATE_AUTHENTICATION_DIALOG_H
+#define __POLKIT_MATE_AUTHENTICATION_DIALOG_H
+
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <polkit/polkit.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define POLKIT_MATE_TYPE_AUTHENTICATION_DIALOG            (polkit_mate_authentication_dialog_get_type ())
+#define POLKIT_MATE_AUTHENTICATION_DIALOG(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), POLKIT_MATE_TYPE_AUTHENTICATION_DIALOG, PolkitMateAuthenticationDialog))
+#define POLKIT_MATE_AUTHENTICATION_DIALOG_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), POLKIT_MATE_TYPE_AUTHENTICATION_DIALOG, PolkitMateAuthenticationDialogClass))
+#define POLKIT_MATE_IS_AUTHENTICATION_DIALOG(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), POLKIT_MATE_TYPE_AUTHENTICATION_DIALOG))
+#define POLKIT_MATE_IS_AUTHENTICATION_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), POLKIT_MATE_TYPE_AUTHENTICATION_DIALOG))
+
+typedef struct _PolkitMateAuthenticationDialog        PolkitMateAuthenticationDialog;
+typedef struct _PolkitMateAuthenticationDialogClass   PolkitMateAuthenticationDialogClass;
+typedef struct _PolkitMateAuthenticationDialogPrivate PolkitMateAuthenticationDialogPrivate;
+
+struct _PolkitMateAuthenticationDialog
+{
+  GtkDialog parent_instance;
+  PolkitMateAuthenticationDialogPrivate *priv;
+};
+
+struct _PolkitMateAuthenticationDialogClass
+{
+  GtkDialogClass parent_class;
+};
+
+GType      polkit_mate_authentication_dialog_get_type                      (void);
+GtkWidget *polkit_mate_authentication_dialog_new                           (const gchar    *action_id,
+                                                                             const gchar    *vendor,
+                                                                             const gchar    *vendor_url,
+                                                                             const gchar    *icon_name,
+                                                                             const gchar    *message_markup,
+                                                                             PolkitDetails  *details,
+                                                                             gchar         **users);
+gchar     *polkit_mate_authentication_dialog_get_selected_user             (PolkitMateAuthenticationDialog *dialog);
+gboolean   polkit_mate_authentication_dialog_run_until_user_is_selected    (PolkitMateAuthenticationDialog *dialog);
+gchar     *polkit_mate_authentication_dialog_run_until_response_for_prompt (PolkitMateAuthenticationDialog *dialog,
+                                                                             const gchar                     *prompt,
+                                                                             gboolean                         echo_chars,
+                                                                             gboolean                        *was_cancelled,
+                                                                             gboolean                        *new_user_selected);
+gboolean   polkit_mate_authentication_dialog_cancel                        (PolkitMateAuthenticationDialog *dialog);
+void       polkit_mate_authentication_dialog_indicate_error                (PolkitMateAuthenticationDialog *dialog);
+void       polkit_mate_authentication_dialog_set_info_message              (PolkitMateAuthenticationDialog *dialog,
+                                                                             const gchar                     *info_markup);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __POLKIT_MATE_AUTHENTICATION_DIALOG_H */
+
+ +
+ +
+ + diff --git a/2024-02-26-105052-9928-cppcheck@ad6d40200d0a_master/4.html b/2024-02-26-105052-9928-cppcheck@ad6d40200d0a_master/4.html new file mode 100644 index 0000000..67c8d37 --- /dev/null +++ b/2024-02-26-105052-9928-cppcheck@ad6d40200d0a_master/4.html @@ -0,0 +1,1269 @@ + + + + + + Cppcheck - HTML report - mate-polkit + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
/*
+ * Copyright (C) 2009 Red Hat, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ * Author: David Zeuthen <davidz@redhat.com>
+ */
+
+#include "config.h"<--- Include file: "config.h" not found.
+
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/types.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <pwd.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gdk/gdkx.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <polkit/polkit.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <polkitagent/polkitagent.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "polkitmateauthenticator.h"
+#include "polkitmateauthenticationdialog.h"
+
+struct _PolkitMateAuthenticator
+{
+  GObject parent_instance;
+
+  PolkitAuthority *authority;
+  gchar *action_id;
+  gchar *message;
+  gchar *icon_name;
+  PolkitDetails *details;
+  gchar *cookie;
+  GList *identities;
+
+  PolkitActionDescription *action_desc;
+  gchar **users;
+
+  gboolean gained_authorization;
+  gboolean was_cancelled;
+  gboolean new_user_selected;
+  gchar *selected_user;
+
+  PolkitAgentSession *session;
+  GtkWidget *dialog;
+  GMainLoop *loop;
+};
+
+struct _PolkitMateAuthenticatorClass
+{
+  GObjectClass parent_class;
+
+};
+
+enum
+{
+  COMPLETED_SIGNAL,
+  LAST_SIGNAL,
+};
+
+static guint signals[LAST_SIGNAL] = {0};
+
+G_DEFINE_TYPE (PolkitMateAuthenticator, polkit_mate_authenticator, G_TYPE_OBJECT);
+
+static void
+polkit_mate_authenticator_init (PolkitMateAuthenticator *authenticator)
+{
+}
+
+static void
+polkit_mate_authenticator_finalize (GObject *object)
+{
+  PolkitMateAuthenticator *authenticator;
+
+  authenticator = POLKIT_MATE_AUTHENTICATOR (object);
+
+  if (authenticator->authority != NULL)
+    g_object_unref (authenticator->authority);
+  g_free (authenticator->action_id);
+  g_free (authenticator->message);
+  g_free (authenticator->icon_name);
+  if (authenticator->details != NULL)
+    g_object_unref (authenticator->details);
+  g_free (authenticator->cookie);
+  g_list_foreach (authenticator->identities, (GFunc) g_object_unref, NULL);
+  g_list_free (authenticator->identities);
+
+  if (authenticator->action_desc != NULL)
+    g_object_unref (authenticator->action_desc);
+  g_strfreev (authenticator->users);
+
+  g_free (authenticator->selected_user);
+  if (authenticator->session != NULL)
+    g_object_unref (authenticator->session);
+  if (authenticator->dialog != NULL)
+    gtk_widget_destroy (authenticator->dialog);
+  if (authenticator->loop != NULL)
+    g_main_loop_unref (authenticator->loop);
+
+  if (G_OBJECT_CLASS (polkit_mate_authenticator_parent_class)->finalize != NULL)
+    G_OBJECT_CLASS (polkit_mate_authenticator_parent_class)->finalize (object);
+}
+
+static void
+polkit_mate_authenticator_class_init (PolkitMateAuthenticatorClass *klass)
+{
+  GObjectClass *gobject_class;
+
+  gobject_class = G_OBJECT_CLASS (klass);
+
+  gobject_class->finalize = polkit_mate_authenticator_finalize;
+
+  /**
+   * PolkitMateAuthenticator::completed:
+   * @authenticator: A #PolkitMateAuthenticator.
+   * @gained_authorization: Whether the authorization was gained.
+   * @dismissed: Whether the dialog was dismissed.
+   *
+   * Emitted when the authentication is completed. The user is supposed to dispose of @authenticator
+   * upon receiving this signal.
+   **/
+  signals[COMPLETED_SIGNAL] = g_signal_new ("completed",
+                                            POLKIT_MATE_TYPE_AUTHENTICATOR,
+                                            G_SIGNAL_RUN_LAST,
+                                            0,                      /* class offset     */
+                                            NULL,                   /* accumulator      */
+                                            NULL,                   /* accumulator data */
+                                            g_cclosure_marshal_generic,
+                                            G_TYPE_NONE,
+                                            2,
+					    G_TYPE_BOOLEAN,
+                                            G_TYPE_BOOLEAN);
+}
+
+static PolkitActionDescription *
+get_desc_for_action (PolkitAuthority *authority,
+                     const gchar     *action_id)
+{
+  GList *action_descs;
+  GList *l;
+  PolkitActionDescription *result;
+
+  result = NULL;
+
+  action_descs = polkit_authority_enumerate_actions_sync (authority,
+                                                          NULL,
+                                                          NULL);
+  for (l = action_descs; l != NULL; l = l->next)
+    {
+      PolkitActionDescription *action_desc = POLKIT_ACTION_DESCRIPTION (l->data);
+
+      if (strcmp (polkit_action_description_get_action_id (action_desc), action_id) == 0)
+        {
+          result = g_object_ref (action_desc);
+          goto out;
+        }
+    }
+
+ out:
+
+  g_list_foreach (action_descs, (GFunc) g_object_unref, NULL);
+  g_list_free (action_descs);
+
+  return result;
+}
+
+static void
+on_dialog_deleted (GtkWidget *widget,
+                   GdkEvent  *event,
+                   gpointer   user_data)
+{
+  PolkitMateAuthenticator *authenticator = POLKIT_MATE_AUTHENTICATOR (user_data);
+
+  polkit_mate_authenticator_cancel (authenticator);
+}
+
+static void
+on_user_selected (GObject    *object,
+                  GParamSpec *pspec,
+                  gpointer    user_data)
+{
+  PolkitMateAuthenticator *authenticator = POLKIT_MATE_AUTHENTICATOR (user_data);
+
+  /* clear any previous messages */
+  polkit_mate_authentication_dialog_set_info_message (POLKIT_MATE_AUTHENTICATION_DIALOG (authenticator->dialog), "");
+
+  polkit_mate_authenticator_cancel (authenticator);
+  authenticator->new_user_selected = TRUE;
+}
+
+PolkitMateAuthenticator *
+polkit_mate_authenticator_new (const gchar     *action_id,
+                                const gchar     *message,
+                                const gchar     *icon_name,
+                                PolkitDetails   *details,
+                                const gchar     *cookie,
+                                GList           *identities)
+{
+  PolkitMateAuthenticator *authenticator;
+  GList *l;
+  guint n;
+  GError *error;
+
+  authenticator = POLKIT_MATE_AUTHENTICATOR (g_object_new (POLKIT_MATE_TYPE_AUTHENTICATOR, NULL));
+
+  error = NULL;
+  authenticator->authority = polkit_authority_get_sync (NULL /* GCancellable* */, &error);
+  if (authenticator->authority == NULL)
+    {
+      g_critical ("Error getting authority: %s", error->message);
+      g_error_free (error);
+      goto error;
+    }
+
+  authenticator->action_id = g_strdup (action_id);
+  authenticator->message = g_strdup (message);
+  authenticator->icon_name = g_strdup (icon_name);
+  if (details != NULL)
+    authenticator->details = g_object_ref (details);
+  authenticator->cookie = g_strdup (cookie);
+  authenticator->identities = g_list_copy (identities);
+  g_list_foreach (authenticator->identities, (GFunc) g_object_ref, NULL);
+
+  authenticator->action_desc = get_desc_for_action (authenticator->authority,
+                                                    authenticator->action_id);
+  if (authenticator->action_desc == NULL)
+    goto error;
+
+  authenticator->users = g_new0 (gchar *, g_list_length (authenticator->identities) + 1);
+  for (l = authenticator->identities, n = 0; l != NULL; l = l->next, n++)
+    {
+      PolkitUnixUser *user = POLKIT_UNIX_USER (l->data);
+      uid_t uid;
+      struct passwd *passwd;
+
+      uid = polkit_unix_user_get_uid (user);
+      passwd = getpwuid (uid);
+      authenticator->users[n] = g_strdup (passwd->pw_name);
+    }
+
+  authenticator->dialog = polkit_mate_authentication_dialog_new
+                            (authenticator->action_id,
+                             polkit_action_description_get_vendor_name (authenticator->action_desc),
+                             polkit_action_description_get_vendor_url (authenticator->action_desc),
+                             authenticator->icon_name,
+                             authenticator->message,
+                             authenticator->details,
+                             authenticator->users);
+  g_signal_connect (authenticator->dialog,
+                    "delete-event",
+                    G_CALLBACK (on_dialog_deleted),
+                    authenticator);
+  g_signal_connect (authenticator->dialog,
+                    "notify::selected-user",
+                    G_CALLBACK (on_user_selected),
+                    authenticator);
+
+  return authenticator;
+
+ error:
+  g_object_unref (authenticator);
+  return NULL;
+}
+
+static void
+session_request (PolkitAgentSession *session,
+                 const char         *request,
+                 gboolean            echo_on,
+                 gpointer            user_data)
+{
+  PolkitMateAuthenticator *authenticator = POLKIT_MATE_AUTHENTICATOR (user_data);
+  gchar *password;
+  gchar *modified_request;
+
+  password = NULL;
+
+  //g_debug ("in conversation_pam_prompt, request='%s', echo_on=%d", request, echo_on);
+
+  /* Fix up, and localize, password prompt if it's password auth */
+  if (g_ascii_strncasecmp (request, "password:", 9) == 0)
+    {
+      if (strcmp (g_get_user_name (), authenticator->selected_user) != 0)
+        {
+          modified_request = g_strdup_printf (_("_Password for %s:"), authenticator->selected_user);
+        }
+      else
+        {
+          modified_request = g_strdup (_("_Password:"));
+        }
+    }
+  else
+    {
+      modified_request = g_strdup (request);
+    }
+
+  gtk_widget_show_all (GTK_WIDGET (authenticator->dialog));
+  if (GDK_IS_X11_WINDOW (gtk_widget_get_window (GTK_WIDGET (authenticator->dialog))))
+    gtk_window_present_with_time (GTK_WINDOW (authenticator->dialog),
+                                  gdk_x11_get_server_time (gtk_widget_get_window (GTK_WIDGET (authenticator->dialog))));
+  else
+    gtk_window_present (GTK_WINDOW (authenticator->dialog));
+
+  password = polkit_mate_authentication_dialog_run_until_response_for_prompt (POLKIT_MATE_AUTHENTICATION_DIALOG (authenticator->dialog),
+                                                                               modified_request,
+                                                                               echo_on,
+                                                                               &authenticator->was_cancelled,
+                                                                               &authenticator->new_user_selected);
+
+  /* cancel auth unless user provided a password */
+  if (password == NULL)
+    {
+      polkit_mate_authenticator_cancel (authenticator);
+      goto out;
+    }
+  else
+    {
+      polkit_agent_session_response (authenticator->session, password);
+      g_free (password);
+    }
+
+out:
+  g_free (modified_request);
+}
+
+static void
+session_show_error (PolkitAgentSession *session,
+                    const gchar        *msg,
+                    gpointer            user_data)
+{
+  PolkitMateAuthenticator *authenticator = POLKIT_MATE_AUTHENTICATOR (user_data);
+  gchar *s;
+
+  s = g_strconcat ("<b>", msg, "</b>", NULL);
+  polkit_mate_authentication_dialog_set_info_message (POLKIT_MATE_AUTHENTICATION_DIALOG (authenticator->dialog), s);
+  g_free (s);
+}
+
+static void
+session_show_info (PolkitAgentSession *session,
+                   const gchar        *msg,
+                   gpointer            user_data)
+{
+  PolkitMateAuthenticator *authenticator = POLKIT_MATE_AUTHENTICATOR (user_data);
+  gchar *s;
+
+  s = g_strconcat ("<b>", msg, "</b>", NULL);
+  polkit_mate_authentication_dialog_set_info_message (POLKIT_MATE_AUTHENTICATION_DIALOG (authenticator->dialog), s);
+  g_free (s);
+
+  gtk_widget_show_all (GTK_WIDGET (authenticator->dialog));
+  gtk_window_present (GTK_WINDOW (authenticator->dialog));
+}
+
+static void
+session_completed (PolkitAgentSession *session,
+                   gboolean            gained_authorization,
+                   gpointer            user_data)
+{
+  PolkitMateAuthenticator *authenticator = POLKIT_MATE_AUTHENTICATOR (user_data);
+
+  authenticator->gained_authorization = gained_authorization;
+
+  //g_debug ("in conversation_done gained=%d", gained_authorization);
+
+  g_main_loop_quit (authenticator->loop);
+}
+
+static gboolean
+do_initiate (gpointer user_data)
+{
+  PolkitMateAuthenticator *authenticator = POLKIT_MATE_AUTHENTICATOR (user_data);
+  PolkitIdentity *identity;
+  gint num_tries;
+
+  gtk_widget_show_all (GTK_WIDGET (authenticator->dialog));
+  gtk_window_present (GTK_WINDOW (authenticator->dialog));
+  if (!polkit_mate_authentication_dialog_run_until_user_is_selected (POLKIT_MATE_AUTHENTICATION_DIALOG (authenticator->dialog)))
+    {
+      /* user cancelled the dialog */
+      /*g_debug ("User cancelled before selecting a user");*/
+      authenticator->was_cancelled = TRUE;
+      goto out;
+    }
+
+  authenticator->loop = g_main_loop_new (NULL, TRUE);
+
+  num_tries = 0;
+
+ try_again:
+
+  g_free (authenticator->selected_user);
+  authenticator->selected_user = polkit_mate_authentication_dialog_get_selected_user (POLKIT_MATE_AUTHENTICATION_DIALOG (authenticator->dialog));
+
+  /*g_debug ("Authenticating user %s", authenticator->selected_user);*/
+  identity = polkit_unix_user_new_for_name (authenticator->selected_user, NULL);
+
+  authenticator->session = polkit_agent_session_new (identity, authenticator->cookie);
+
+  g_object_unref (identity);
+
+  g_signal_connect (authenticator->session,
+                    "request",
+                    G_CALLBACK (session_request),
+                    authenticator);
+
+  g_signal_connect (authenticator->session,
+                    "show-info",
+                    G_CALLBACK (session_show_info),
+                    authenticator);
+
+  g_signal_connect (authenticator->session,
+                    "show-error",
+                    G_CALLBACK (session_show_error),
+                    authenticator);
+
+  g_signal_connect (authenticator->session,
+                    "completed",
+                    G_CALLBACK (session_completed),
+                    authenticator);
+
+  polkit_agent_session_initiate (authenticator->session);
+
+  g_main_loop_run (authenticator->loop);
+
+  /*g_debug ("gained_authorization=%d was_cancelled=%d new_user_selected=%d.",
+           authenticator->gained_authorization,
+           authenticator->was_cancelled,
+           authenticator->new_user_selected);*/
+
+  if (authenticator->new_user_selected)
+    {
+      /*g_debug ("New user selected");*/
+      authenticator->new_user_selected = FALSE;
+      g_object_unref (authenticator->session);
+      authenticator->session = NULL;
+      goto try_again;
+    }
+
+  num_tries++;
+
+  if (!authenticator->gained_authorization && !authenticator->was_cancelled)
+    {
+      if (authenticator->dialog != NULL)
+        {
+          gchar *s;
+
+          s = g_strconcat ("<b>", _("Your authentication attempt was unsuccessful. Please try again."), "</b>", NULL);
+          polkit_mate_authentication_dialog_set_info_message (
+                                  POLKIT_MATE_AUTHENTICATION_DIALOG (authenticator->dialog),
+                                  s);
+          g_free (s);
+          gtk_widget_queue_draw (authenticator->dialog);
+
+          /* shake the dialog to indicate error */
+          polkit_mate_authentication_dialog_indicate_error (POLKIT_MATE_AUTHENTICATION_DIALOG (authenticator->dialog));
+
+          if (num_tries < 3)
+            {
+              g_object_unref (authenticator->session);
+              authenticator->session = NULL;
+              goto try_again;
+            }
+        }
+    }
+
+ out:
+  g_signal_emit_by_name (authenticator,
+                         "completed",
+                         authenticator->gained_authorization,
+                         authenticator->was_cancelled);
+
+  g_object_unref (authenticator);
+
+  return FALSE;
+}
+
+void
+polkit_mate_authenticator_initiate (PolkitMateAuthenticator *authenticator)
+{
+  /* run from idle since we're going to block the main loop in the dialog (which has a recursive mainloop) */
+  g_idle_add (do_initiate, g_object_ref (authenticator));
+}
+
+void
+polkit_mate_authenticator_cancel (PolkitMateAuthenticator *authenticator)
+{
+  if (authenticator->dialog != NULL)
+    polkit_mate_authentication_dialog_cancel (POLKIT_MATE_AUTHENTICATION_DIALOG (authenticator->dialog));
+
+  authenticator->was_cancelled = TRUE;
+
+  if (authenticator->session != NULL)
+    {
+      polkit_agent_session_cancel (authenticator->session);
+    }
+}
+
+const gchar *
+polkit_mate_authenticator_get_cookie (PolkitMateAuthenticator *authenticator)<--- Parameter 'authenticator' can be declared as pointer to const
+{
+  return authenticator->cookie;
+}
+
+
+ +
+ +
+ + diff --git a/2024-02-26-105052-9928-cppcheck@ad6d40200d0a_master/5.html b/2024-02-26-105052-9928-cppcheck@ad6d40200d0a_master/5.html new file mode 100644 index 0000000..b1c66d2 --- /dev/null +++ b/2024-02-26-105052-9928-cppcheck@ad6d40200d0a_master/5.html @@ -0,0 +1,351 @@ + + + + + + Cppcheck - HTML report - mate-polkit + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
/*
+ * Copyright (C) 2009 Red Hat, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ * Author: David Zeuthen <davidz@redhat.com>
+ */
+
+#ifndef __POLKIT_MATE_AUTHENTICATOR_H
+#define __POLKIT_MATE_AUTHENTICATOR_H
+
+#include <glib-object.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define POLKIT_MATE_TYPE_AUTHENTICATOR          (polkit_mate_authenticator_get_type())
+#define POLKIT_MATE_AUTHENTICATOR(o)            (G_TYPE_CHECK_INSTANCE_CAST ((o), POLKIT_MATE_TYPE_AUTHENTICATOR, PolkitMateAuthenticator))
+#define POLKIT_MATE_AUTHENTICATOR_CLASS(k)      (G_TYPE_CHECK_CLASS_CAST((k), POLKIT_MATE_TYPE_AUTHENTICATOR, PolkitMateAuthenticatorClass))
+#define POLKIT_MATE_AUTHENTICATOR_GET_CLASS(o)  (G_TYPE_INSTANCE_GET_CLASS ((o), POLKIT_MATE_TYPE_AUTHENTICATOR, PolkitMateAuthenticatorClass))
+#define POLKIT_MATE_IS_AUTHENTICATOR(o)         (G_TYPE_CHECK_INSTANCE_TYPE ((o), POLKIT_MATE_TYPE_AUTHENTICATOR))
+#define POLKIT_MATE_IS_AUTHENTICATOR_CLASS(k)   (G_TYPE_CHECK_CLASS_TYPE ((k), POLKIT_MATE_TYPE_AUTHENTICATOR))
+
+typedef struct _PolkitMateAuthenticator PolkitMateAuthenticator;
+typedef struct _PolkitMateAuthenticatorClass PolkitMateAuthenticatorClass;
+
+GType                      polkit_mate_authenticator_get_type   (void) G_GNUC_CONST;
+PolkitMateAuthenticator  *polkit_mate_authenticator_new        (const gchar              *action_id,
+                                                                  const gchar              *message,
+                                                                  const gchar              *icon_name,
+                                                                  PolkitDetails            *details,
+                                                                  const gchar              *cookie,
+                                                                  GList                    *identities);
+void                       polkit_mate_authenticator_initiate   (PolkitMateAuthenticator *authenticator);
+void                       polkit_mate_authenticator_cancel     (PolkitMateAuthenticator *authenticator);
+const gchar               *polkit_mate_authenticator_get_cookie (PolkitMateAuthenticator *authenticator);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __POLKIT_MATE_AUTHENTICATOR_H */
+
+ +
+ +
+ + diff --git a/2024-02-26-105052-9928-cppcheck@ad6d40200d0a_master/6.html b/2024-02-26-105052-9928-cppcheck@ad6d40200d0a_master/6.html new file mode 100644 index 0000000..79a947d --- /dev/null +++ b/2024-02-26-105052-9928-cppcheck@ad6d40200d0a_master/6.html @@ -0,0 +1,761 @@ + + + + + + Cppcheck - HTML report - mate-polkit + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
/*
+ * Copyright (C) 2009 Red Hat, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ * Author: David Zeuthen <davidz@redhat.com>
+ */
+
+#include "config.h"<--- Include file: "config.h" not found.
+
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "polkitmatelistener.h"
+#include "polkitmateauthenticator.h"
+
+struct _PolkitMateListener
+{
+  PolkitAgentListener parent_instance;
+
+  /* we support multiple authenticators - they are simply queued up */
+  GList *authenticators;
+
+  PolkitMateAuthenticator *active_authenticator;
+};
+
+struct _PolkitMateListenerClass
+{
+  PolkitAgentListenerClass parent_class;
+};
+
+static void polkit_mate_listener_initiate_authentication (PolkitAgentListener  *listener,
+                                                           const gchar          *action_id,
+                                                           const gchar          *message,
+                                                           const gchar          *icon_name,
+                                                           PolkitDetails        *details,
+                                                           const gchar          *cookie,
+                                                           GList                *identities,
+                                                           GCancellable         *cancellable,
+                                                           GAsyncReadyCallback   callback,
+                                                           gpointer              user_data);
+
+static gboolean polkit_mate_listener_initiate_authentication_finish (PolkitAgentListener  *listener,
+                                                                      GAsyncResult         *res,
+                                                                      GError              **error);
+
+G_DEFINE_TYPE (PolkitMateListener, polkit_mate_listener, POLKIT_AGENT_TYPE_LISTENER);
+
+static void
+polkit_mate_listener_init (PolkitMateListener *listener)
+{
+}
+
+static void
+polkit_mate_listener_finalize (GObject *object)
+{
+  if (G_OBJECT_CLASS (polkit_mate_listener_parent_class)->finalize != NULL)
+    G_OBJECT_CLASS (polkit_mate_listener_parent_class)->finalize (object);
+}
+
+static void
+polkit_mate_listener_class_init (PolkitMateListenerClass *klass)
+{
+  GObjectClass *gobject_class;
+  PolkitAgentListenerClass *listener_class;
+
+  gobject_class = G_OBJECT_CLASS (klass);
+  listener_class = POLKIT_AGENT_LISTENER_CLASS (klass);
+
+  gobject_class->finalize = polkit_mate_listener_finalize;
+
+  listener_class->initiate_authentication          = polkit_mate_listener_initiate_authentication;
+  listener_class->initiate_authentication_finish   = polkit_mate_listener_initiate_authentication_finish;
+}
+
+PolkitAgentListener *
+polkit_mate_listener_new (void)
+{
+  return POLKIT_AGENT_LISTENER (g_object_new (POLKIT_MATE_TYPE_LISTENER, NULL));
+}
+
+typedef struct
+{
+  PolkitMateListener *listener;
+  PolkitMateAuthenticator *authenticator;
+
+  GTask        *task;
+  GCancellable *cancellable;
+
+  gulong cancel_id;
+} AuthData;
+
+static AuthData *
+auth_data_new (PolkitMateListener *listener,
+               PolkitMateAuthenticator *authenticator,
+               GTask *task,
+               GCancellable *cancellable)
+{
+  AuthData *data;
+
+  data = g_new0 (AuthData, 1);
+  data->listener = g_object_ref (listener);
+  data->authenticator = g_object_ref (authenticator);
+  data->task = g_object_ref (task);
+  data->cancellable = g_object_ref (cancellable);
+  return data;
+}
+
+static void
+auth_data_free (AuthData *data)
+{
+  g_object_unref (data->listener);
+  g_object_unref (data->authenticator);
+  g_object_unref (data->task);
+  if (data->cancellable != NULL && data->cancel_id > 0)
+    g_signal_handler_disconnect (data->cancellable, data->cancel_id);
+  g_object_unref (data->cancellable);
+  g_free (data);
+}
+
+static void
+maybe_initiate_next_authenticator (PolkitMateListener *listener)
+{
+  if (listener->active_authenticator == NULL && listener->authenticators != NULL)
+    {
+      polkit_mate_authenticator_initiate (POLKIT_MATE_AUTHENTICATOR (listener->authenticators->data));
+      listener->active_authenticator = listener->authenticators->data;
+    }
+}
+
+static void
+authenticator_completed (PolkitMateAuthenticator *authenticator,
+                         gboolean                 gained_authorization,
+                         gboolean                 dismissed,
+                         gpointer                 user_data)
+{
+  AuthData *data = user_data;
+
+  data->listener->authenticators = g_list_remove (data->listener->authenticators, authenticator);
+  if (authenticator == data->listener->active_authenticator)
+    data->listener->active_authenticator = NULL;
+
+  g_object_unref (authenticator);
+
+  if (dismissed)
+    {
+      g_task_return_new_error (data->task,
+                               POLKIT_ERROR,
+                               POLKIT_ERROR_CANCELLED,
+                               _("Authentication dialog was dismissed by the user"));
+    }
+
+  g_task_return_boolean (data->task, TRUE);
+  g_object_unref (data->task);
+
+  maybe_initiate_next_authenticator (data->listener);
+
+  auth_data_free (data);
+}
+
+static void
+cancelled_cb (GCancellable *cancellable,
+              gpointer user_data)
+{
+  AuthData *data = user_data;
+
+  polkit_mate_authenticator_cancel (data->authenticator);
+}
+
+static void
+polkit_mate_listener_initiate_authentication (PolkitAgentListener  *agent_listener,
+                                               const gchar          *action_id,
+                                               const gchar          *message,
+                                               const gchar          *icon_name,
+                                               PolkitDetails        *details,
+                                               const gchar          *cookie,
+                                               GList                *identities,
+                                               GCancellable         *cancellable,
+                                               GAsyncReadyCallback   callback,
+                                               gpointer              user_data)
+{
+  PolkitMateListener *listener = POLKIT_MATE_LISTENER (agent_listener);
+  GTask *task;
+  PolkitMateAuthenticator *authenticator;
+  AuthData *data;
+
+  task = g_task_new (G_OBJECT (listener),
+                     NULL,
+                     callback,
+                     user_data);
+  g_task_set_source_tag (task,
+                         polkit_mate_listener_initiate_authentication);
+
+  authenticator = polkit_mate_authenticator_new (action_id,
+                                                  message,
+                                                  icon_name,
+                                                  details,
+                                                  cookie,
+                                                  identities);
+  if (authenticator == NULL)
+    {
+      g_task_return_new_error (task,
+                               POLKIT_ERROR,
+                               POLKIT_ERROR_FAILED,
+                               "Error creating authentication object");
+      g_object_unref (task);
+      goto out;
+    }
+
+  data = auth_data_new (listener, authenticator, task, cancellable);
+
+  g_signal_connect (authenticator,
+                    "completed",
+                    G_CALLBACK (authenticator_completed),
+                    data);
+
+  if (cancellable != NULL)
+    {
+      data->cancel_id = g_signal_connect (cancellable,
+                                          "cancelled",
+                                          G_CALLBACK (cancelled_cb),
+                                          data);
+    }
+
+  listener->authenticators = g_list_append (listener->authenticators, authenticator);
+
+  maybe_initiate_next_authenticator (listener);
+
+ out:
+  ;
+}
+
+static gboolean
+polkit_mate_listener_initiate_authentication_finish (PolkitAgentListener  *listener,
+                                                      GAsyncResult         *res,
+                                                      GError              **error)
+{
+  GTask *task = G_TASK (res);
+
+  g_warn_if_fail (g_task_get_source_tag (task) == polkit_mate_listener_initiate_authentication);
+
+  if (g_task_propagate_pointer (task, error) == NULL) {
+    return FALSE;
+  }
+
+  return TRUE;
+}
+
+
+ +
+ +
+ + diff --git a/2024-02-26-105052-9928-cppcheck@ad6d40200d0a_master/index.html b/2024-02-26-105052-9928-cppcheck@ad6d40200d0a_master/index.html new file mode 100644 index 0000000..35f12cd --- /dev/null +++ b/2024-02-26-105052-9928-cppcheck@ad6d40200d0a_master/index.html @@ -0,0 +1,252 @@ + + + + + + Cppcheck - HTML report - mate-polkit + + + + + +
+ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
LineIdCWESeverityMessage
checkersReportinformationActive checkers: 106/592 (use --checkers-report=<filename> to see details)
src/main.c
23missingIncludeinformationInclude file: "config.h" not found.
26missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <gio/gio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
29missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
30missingIncludeSysteminformationInclude file: <polkitagent/polkitagent.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
33missingIncludeSysteminformationInclude file: <libayatana-appindicator/app-indicator.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
35missingIncludeSysteminformationInclude file: <libappindicator/app-indicator.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
226shadowVariable398styleLocal variable 'authority' shadows outer variable
316constParameterCallback398styleParameter 'signal_name' can be declared as pointer to const. However it seems that 'signal_cb' is a callback function, if 'signal_name' is declared with const you might also need to cast function pointer(s).
src/polkitmateauthenticationdialog.c
24missingIncludeinformationInclude file: "config.h" not found.
28missingIncludeSysteminformationInclude file: <unistd.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
29missingIncludeSysteminformationInclude file: <sys/types.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
30missingIncludeSysteminformationInclude file: <sys/stat.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
31missingIncludeSysteminformationInclude file: <fcntl.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
32missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
33missingIncludeSysteminformationInclude file: <stdio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
34missingIncludeSysteminformationInclude file: <stdlib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
35missingIncludeSysteminformationInclude file: <pwd.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
36missingIncludeSysteminformationInclude file: <errno.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
38missingIncludeSysteminformationInclude file: <glib/gi18n-lib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
39missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
99constVariablePointer398styleVariable 'indices' can be declared as pointer to const
src/polkitmateauthenticationdialog.h
26missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <polkit/polkit.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/polkitmateauthenticator.c
23missingIncludeinformationInclude file: "config.h" not found.
25missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <sys/types.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <pwd.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
29missingIncludeSysteminformationInclude file: <gdk/gdkx.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
31missingIncludeSysteminformationInclude file: <polkit/polkit.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
32missingIncludeSysteminformationInclude file: <polkitagent/polkitagent.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
512constParameterPointer398styleParameter 'authenticator' can be declared as pointer to const
src/polkitmateauthenticator.h
26missingIncludeSysteminformationInclude file: <glib-object.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/polkitmatelistener.c
23missingIncludeinformationInclude file: "config.h" not found.
25missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/polkitmatelistener.h
26missingIncludeSysteminformationInclude file: <polkitagent/polkitagent.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+ +
+ + diff --git a/2024-02-26-105052-9928-cppcheck@ad6d40200d0a_master/stats.html b/2024-02-26-105052-9928-cppcheck@ad6d40200d0a_master/stats.html new file mode 100644 index 0000000..5c5881a --- /dev/null +++ b/2024-02-26-105052-9928-cppcheck@ad6d40200d0a_master/stats.html @@ -0,0 +1,178 @@ + + + + + + Cppcheck - HTML report - mate-polkit + + + + + +
+ + + +
+

Top 10 files for style severity, total findings: 4
+   2  src/main.c
+   1  src/polkitmateauthenticator.c
+   1  src/polkitmateauthenticationdialog.c
+

+

Top 10 files for information severity, total findings: 35
+   12  src/polkitmateauthenticationdialog.c
+   8   src/polkitmateauthenticator.c
+   8   src/main.c
+   3   src/polkitmatelistener.c
+   2   src/polkitmateauthenticationdialog.h
+   1   src/polkitmatelistener.h
+   1   src/polkitmateauthenticator.h
+

+ +
+ +
+ + diff --git a/2024-02-26-105052-9928-cppcheck@ad6d40200d0a_master/style.css b/2024-02-26-105052-9928-cppcheck@ad6d40200d0a_master/style.css new file mode 100644 index 0000000..3897bfa --- /dev/null +++ b/2024-02-26-105052-9928-cppcheck@ad6d40200d0a_master/style.css @@ -0,0 +1,177 @@ + +body { + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif; + font-size: 13px; + line-height: 1.5; + height: 100%; + margin: 0; +} + +#wrapper { + position: fixed; + height: 100vh; + width: 100vw; + display: grid; + grid-template-rows: fit-content(8rem) auto fit-content(8rem); + grid-template-columns: fit-content(25%) 1fr; + grid-template-areas: + "header header" + "menu content" + "footer footer"; +} + +h1 { + margin: 0 0 8px -2px; + font-size: 175%; +} + +.header { + padding: 0 0 5px 15px; + grid-area: header; + border-bottom: thin solid #aaa; +} + +.footer { + grid-area: footer; + border-top: thin solid #aaa; + font-size: 85%; + +} + +.footer > p { + margin: 4px; +} + +#menu, +#menu_index { + grid-area: menu; + text-align: left; + overflow: auto; + padding: 0 23px 15px 15px; + border-right: thin solid #aaa; + min-width: 200px; +} + +#menu > a { + display: block; + margin-left: 10px; + font-size: 12px; +} + +#content, +#content_index { + grid-area: content; + padding: 0px 5px 15px 15px; + overflow: auto; +} + +label { + white-space: nowrap; +} + +label.checkBtn.disabled { + color: #606060; + background: #e0e0e0; + font-style: italic; +} + +label.checkBtn, input[type="text"] { + border: 1px solid grey; + border-radius: 4px; + box-shadow: 1px 1px inset; + padding: 1px 5px; +} + +label.checkBtn { + white-space: nowrap; + background: #ccddff; +} + +label.unchecked { + background: #eff8ff; + box-shadow: 1px 1px 1px; +} + +label.checkBtn:hover, label.unchecked:hover{ + box-shadow: 0 0 2px; +} + +label.disabled:hover { + box-shadow: 1px 1px inset; +} + +label.checkBtn > input { + display:none; +} + +.summaryTable { + width: 100%; +} + +table.summaryTable td { padding: 0 5px 0 5px; } + +.statHeader, .severityHeader { + font-weight: bold; +} + +.warning { + background-color: #ffffa7; +} + +.error { + background-color: #ffb7b7; +} + +.error2 { + background-color: #faa; + display: inline-block; + margin-left: 4px; +} + +.inconclusive { + background-color: #b6b6b4; +} + +.inconclusive2 { + background-color: #b6b6b4; + display: inline-block; + margin-left: 4px; +} + +.verbose { + display: inline-block; + vertical-align: top; + cursor: help; +} + +.verbose .content { + display: none; + position: absolute; + padding: 10px; + margin: 4px; + max-width: 40%; + white-space: pre-wrap; + border: 1px solid #000; + background-color: #ffffcc; + cursor: auto; +} + +.highlight .hll { + padding: 1px; +} + +.highlighttable { + background-color: #fff; + position: relative; + margin: -10px; +} + +.linenos { + border-right: thin solid #aaa; + color: #d3d3d3; + padding-right: 6px; +} + +.id-filtered, .severity-filtered, .file-filtered, .tool-filtered, .text-filtered { + visibility: collapse; +} diff --git a/2024-02-26-105642-9744-cppcheck@c2df8de7c7b1_v1.28.1/0.html b/2024-02-26-105642-9744-cppcheck@c2df8de7c7b1_v1.28.1/0.html new file mode 100644 index 0000000..95e5dbc --- /dev/null +++ b/2024-02-26-105642-9744-cppcheck@c2df8de7c7b1_v1.28.1/0.html @@ -0,0 +1,1189 @@ + + + + + + Cppcheck - HTML report - mate-polkit + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
/*
+ * Copyright (C) 2009 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ * Author: David Zeuthen <davidz@redhat.com>
+ */
+
+#ifdef HAVE_CONFIG_H
+#  include "config.h"<--- Include file: "config.h" not found.
+#endif
+
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gio/gio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <polkitagent/polkitagent.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#if defined(HAVE_AYATANA_APPINDICATOR)
+# include <libayatana-appindicator/app-indicator.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#elif defined(HAVE_UBUNTU_APPINDICATOR)
+# include <libappindicator/app-indicator.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#endif
+
+#include "polkitmatelistener.h"
+
+/* session management support for auto-restart */
+#define SM_DBUS_NAME      "org.gnome.SessionManager"
+#define SM_DBUS_PATH      "/org/gnome/SessionManager"
+#define SM_DBUS_INTERFACE "org.gnome.SessionManager"
+#define SM_CLIENT_DBUS_INTERFACE "org.gnome.SessionManager.ClientPrivate"
+
+/* the Authority */
+static PolkitAuthority *authority = NULL;<--- Shadowed declaration
+
+/* the session we are servicing */
+static PolkitSubject *session = NULL;
+
+/* the current set of temporary authorizations */
+static GList *current_temporary_authorizations = NULL;
+
+#if defined(HAVE_AYATANA_APPINDICATOR) || defined(HAVE_UBUNTU_APPINDICATOR)
+static AppIndicator *app_indicator = NULL;
+#else
+static GtkStatusIcon *status_icon = NULL;
+#endif
+
+static GDBusProxy      *sm_proxy;
+static GDBusProxy      *client_proxy = NULL;
+
+static  GMainLoop *loop;
+
+static void
+revoke_tmp_authz_cb (GObject      *source_object,
+                     GAsyncResult *res,
+                     gpointer      user_data)
+{
+  GError *error;
+
+  error = NULL;
+  polkit_authority_revoke_temporary_authorizations_finish (POLKIT_AUTHORITY (source_object),
+                                                           res,
+                                                           &error);
+  if (error != NULL)
+    {
+      g_warning ("Error revoking temporary authorizations: %s", error->message);
+      g_error_free (error);
+    }
+}
+
+static void
+revoke_tmp_authz (void)
+{
+  polkit_authority_revoke_temporary_authorizations (authority,
+                                                    session,
+                                                    NULL,
+                                                    revoke_tmp_authz_cb,
+                                                    NULL);
+}
+
+#if defined(HAVE_AYATANA_APPINDICATOR) || defined(HAVE_UBUNTU_APPINDICATOR)
+static void
+on_menu_item_activate (GtkMenuItem *menu_item,
+                       gpointer     user_data)
+{
+  revoke_tmp_authz ();
+}
+#else
+static void
+on_status_icon_activate (GtkStatusIcon *status_icon,
+                         gpointer       user_data)
+{
+  revoke_tmp_authz ();
+}
+
+static void
+on_status_icon_popup_menu (GtkStatusIcon *status_icon,
+                           guint          button,
+                           guint          activate_time,
+                           gpointer       user_data)
+{
+  revoke_tmp_authz ();
+}
+#endif
+
+static void
+update_temporary_authorization_icon_real (void)
+{
+
+#if 0
+  GList *l;
+  g_debug ("have %d tmp authorizations", g_list_length (current_temporary_authorizations));
+  for (l = current_temporary_authorizations; l != NULL; l = l->next)
+    {
+      PolkitTemporaryAuthorization *authz = POLKIT_TEMPORARY_AUTHORIZATION (l->data);
+
+      g_debug ("have tmp authz for action %s (subject %s) with id %s (obtained %d, expires %d)",
+               polkit_temporary_authorization_get_action_id (authz),
+               polkit_subject_to_string (polkit_temporary_authorization_get_subject (authz)),
+               polkit_temporary_authorization_get_id (authz),
+               (gint) polkit_temporary_authorization_get_time_obtained (authz),
+               (gint) polkit_temporary_authorization_get_time_expires (authz));
+    }
+#endif
+
+  /* TODO:
+   *
+   * - we could do something fancy like displaying a window with the tmp authz
+   *   when the icon is clicked...
+   *
+   * - we could do some work using polkit_subject_exists() to ignore tmp authz
+   *   for subjects that no longer exists.. this is because temporary authorizations
+   *   are only valid for the subject that trigger the authentication dialog.
+   *
+   *   Maybe the authority could do this, would probably involve some polling, but
+   *   it seems cleaner to do this server side.
+   */
+
+  if (current_temporary_authorizations != NULL)
+    {
+      /* show icon */
+#if defined(HAVE_AYATANA_APPINDICATOR) || defined(HAVE_UBUNTU_APPINDICATOR)
+      if (app_indicator == NULL)
+        {
+          GtkWidget *item, *menu;
+
+          app_indicator = app_indicator_new ("mate-polkit",
+                                             "dialog-password",
+                                             APP_INDICATOR_CATEGORY_SYSTEM_SERVICES);
+
+          item = gtk_menu_item_new_with_label (_("Drop all elevated privileges"));
+          g_signal_connect (item,
+                            "activate",
+                            G_CALLBACK (on_menu_item_activate),
+                            NULL);
+          menu = gtk_menu_new ();
+          gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+          gtk_widget_show_all (menu);
+
+          app_indicator_set_menu (app_indicator,
+                                  GTK_MENU (menu));
+          app_indicator_set_status (app_indicator,
+                                    APP_INDICATOR_STATUS_ACTIVE);
+        }
+      else
+        /*Reshow icon from existing appindicator */
+        app_indicator_set_status (app_indicator,
+				    APP_INDICATOR_STATUS_ACTIVE);
+
+#else
+      if (status_icon == NULL)
+        {
+          status_icon = gtk_status_icon_new_from_icon_name ("dialog-password");
+          gtk_status_icon_set_tooltip_text (status_icon,
+                                            _("Click the icon to drop all elevated privileges"));
+          g_signal_connect (status_icon,
+                            "activate",
+                            G_CALLBACK (on_status_icon_activate),
+                            NULL);
+          g_signal_connect (status_icon,
+                            "popup-menu",
+                            G_CALLBACK (on_status_icon_popup_menu),
+                            NULL);
+        }
+#endif
+    }
+  else
+    {
+      /* hide icon */
+#if defined(HAVE_AYATANA_APPINDICATOR) || defined(HAVE_UBUNTU_APPINDICATOR)
+      if (app_indicator != NULL)
+        {
+          /* keep the app_indicator, hide the icon or it won't come back*/
+          app_indicator_set_status (app_indicator,
+				    APP_INDICATOR_STATUS_PASSIVE);
+        }
+#else
+      if (status_icon != NULL)
+        {
+          gtk_status_icon_set_visible (status_icon, FALSE);
+          g_object_unref (status_icon);
+          status_icon = NULL;
+        }
+#endif
+    }
+}
+
+static void
+enumerate_temporary_authorizations_cb (GObject      *source_object,
+                                       GAsyncResult *res,
+                                       gpointer      user_data)
+{
+  PolkitAuthority *authority = POLKIT_AUTHORITY (source_object);<--- Shadow variable
+  GList *temporary_authorizations;
+  GError *error;
+
+  temporary_authorizations = NULL;
+
+  error = NULL;
+  temporary_authorizations = polkit_authority_enumerate_temporary_authorizations_finish (authority,
+                                                                                         res,
+                                                                                         &error);
+  if (error != NULL)
+    {
+      g_warning ("Error enumerating temporary authorizations: %s", error->message);
+      g_error_free (error);
+      goto out;
+    }
+
+  g_list_foreach (current_temporary_authorizations, (GFunc) g_object_unref, NULL);
+  g_list_free (current_temporary_authorizations);
+
+  current_temporary_authorizations = temporary_authorizations;
+
+  update_temporary_authorization_icon_real ();
+
+ out:
+  ;
+}
+
+static void
+update_temporary_authorization_icon (PolkitAuthority *authority)
+{
+  polkit_authority_enumerate_temporary_authorizations (authority,
+                                                       session,
+                                                       NULL,
+                                                       enumerate_temporary_authorizations_cb,
+                                                       NULL);
+}
+
+static void
+on_authority_changed (PolkitAuthority *authority,
+                      gpointer         user_data)
+{
+  update_temporary_authorization_icon (authority);
+}
+
+static void
+stop_cb (void)
+{
+        g_main_loop_quit (loop);
+}
+
+static gboolean
+end_session_response (gboolean is_okay, const gchar *reason)
+{
+        GVariant *res;
+        GError *error = NULL;
+
+        res = g_dbus_proxy_call_sync (client_proxy,
+                                      "EndSessionResponse",
+                                      g_variant_new ("(bs)",
+                                                     is_okay,
+                                                     reason),
+                                      G_DBUS_CALL_FLAGS_NONE,
+                                      -1, /* timeout */
+                                      NULL, /* GCancellable */
+                                      &error);
+        if (! res) {
+                g_warning ("Failed to call EndSessionResponse: %s", error->message);
+                g_error_free (error);
+                return FALSE;
+        }
+
+        g_variant_unref (res);
+        return TRUE;
+}
+
+static void
+query_end_session_cb (void)
+{
+        end_session_response (TRUE, "");
+}
+
+static void
+end_session_cb (void)
+{
+        end_session_response (TRUE, "");
+        g_main_loop_quit (loop);
+}
+
+static void
+signal_cb (GDBusProxy *proxy, gchar *sender_name, gchar *signal_name,<--- Parameter 'signal_name' can be declared as pointer to const
+           GVariant *parameters, gpointer user_data)
+{
+        if (strcmp (signal_name, "Stop") == 0) {
+                stop_cb ();
+        } else if (strcmp (signal_name, "QueryEndSession") == 0) {
+                query_end_session_cb ();
+        } else if (strcmp (signal_name, "EndSession") == 0) {
+                end_session_cb ();
+        }
+}
+
+static gboolean
+register_client_to_gnome_session (void)
+{
+        GError     *error = NULL;
+        GVariant   *res;
+        const char *startup_id;
+        const char *app_id;
+        char       *client_id;
+
+        startup_id = g_getenv ("DESKTOP_AUTOSTART_ID");
+        app_id = "polkit-mate-authentication-agent-1.desktop";
+
+        sm_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
+                                                  G_DBUS_PROXY_FLAGS_NONE,
+                                                  NULL, /* GDBusInterfaceInfo */
+                                                  SM_DBUS_NAME,
+                                                  SM_DBUS_PATH,
+                                                  SM_DBUS_INTERFACE,
+                                                  NULL, /* GCancellable */
+                                                  &error);
+        if (sm_proxy == NULL) {
+                g_message("Failed to get session manager: %s", error->message);
+                g_error_free (error);
+                return FALSE;
+        }
+
+        res = g_dbus_proxy_call_sync (sm_proxy,
+                                      "RegisterClient",
+                                      g_variant_new ("(ss)",
+                                                     app_id,
+                                                     startup_id),
+                                      G_DBUS_CALL_FLAGS_NONE,
+                                      -1, /* timeout */
+                                      NULL, /* GCancellable */
+                                      &error);
+        if (! res) {
+                g_warning ("Failed to register client: %s", error->message);
+                g_error_free (error);
+                return FALSE;
+        }
+
+        if (! g_variant_is_of_type (res, G_VARIANT_TYPE ("(o)"))) {
+                g_warning ("RegisterClient returned unexpected type %s",
+                           g_variant_get_type_string (res));
+                return FALSE;
+        }
+
+        g_variant_get (res, "(&o)", &client_id);
+
+        client_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
+                                                      G_DBUS_PROXY_FLAGS_NONE,
+                                                      NULL, /* GDBusInterfaceInfo */
+                                                      SM_DBUS_NAME,
+                                                      client_id,
+                                                      SM_CLIENT_DBUS_INTERFACE,
+                                                      NULL, /* GCancellable */
+                                                      &error);
+        g_variant_unref (res);
+        if (client_proxy == NULL) {
+                g_message("Failed to get client proxy: %s", error->message);
+                g_error_free (error);
+                return FALSE;
+        }
+
+        g_signal_connect (client_proxy, "g-signal", G_CALLBACK (signal_cb), NULL);<--- You might need to cast the function pointer here
+
+        return TRUE;
+}
+
+int
+main (int argc, char **argv)
+{
+  gint ret;
+  PolkitAgentListener *listener;
+  GError *error;
+
+  gtk_init (&argc, &argv);
+
+  loop = NULL;
+  authority = NULL;
+  listener = NULL;
+  session = NULL;
+  ret = 1;
+
+  bindtextdomain (GETTEXT_PACKAGE, MATELOCALEDIR);
+#if HAVE_BIND_TEXTDOMAIN_CODESET
+  bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+#endif
+  textdomain (GETTEXT_PACKAGE);
+
+  loop = g_main_loop_new (NULL, FALSE);
+
+  error = NULL;
+  authority = polkit_authority_get_sync (NULL /* GCancellable* */, &error);
+  if (authority == NULL)
+    {
+      g_warning ("Error getting authority: %s", error->message);
+      g_error_free (error);
+      goto out;
+    }
+  g_signal_connect (authority,
+                    "changed",
+                    G_CALLBACK (on_authority_changed),
+                    NULL);
+
+  listener = polkit_mate_listener_new ();
+
+  error = NULL;
+  session = polkit_unix_session_new_for_process_sync (getpid (), NULL, &error);
+  if (error != NULL)
+    {
+      g_warning ("Unable to determine the session we are in: %s", error->message);
+      g_error_free (error);
+      goto out;
+    }
+
+  error = NULL;
+  if (!polkit_agent_listener_register (listener,
+				       POLKIT_AGENT_REGISTER_FLAGS_NONE,
+                                       session,
+                                       "/org/mate/PolicyKit1/AuthenticationAgent",
+				       NULL,
+                                       &error))
+    {
+      g_printerr ("Cannot register authentication agent: %s\n", error->message);
+      g_error_free (error);
+      goto out;
+    }
+
+  update_temporary_authorization_icon (authority);
+
+  register_client_to_gnome_session();
+
+  g_main_loop_run (loop);
+
+  ret = 0;
+
+ out:
+  if (authority != NULL)
+    g_object_unref (authority);
+  if (session != NULL)
+    g_object_unref (session);
+  if (listener != NULL)
+    g_object_unref (listener);
+  if (loop != NULL)
+    g_main_loop_unref (loop);
+
+  return ret;
+}
+
+ +
+ +
+ + diff --git a/2024-02-26-105642-9744-cppcheck@c2df8de7c7b1_v1.28.1/1.html b/2024-02-26-105642-9744-cppcheck@c2df8de7c7b1_v1.28.1/1.html new file mode 100644 index 0000000..bf8ec00 --- /dev/null +++ b/2024-02-26-105642-9744-cppcheck@c2df8de7c7b1_v1.28.1/1.html @@ -0,0 +1,335 @@ + + + + + + Cppcheck - HTML report - mate-polkit + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
/*
+ * Copyright (C) 2009 Red Hat, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ * Author: David Zeuthen <davidz@redhat.com>
+ */
+
+#ifndef __POLKIT_MATE_LISTENER_H
+#define __POLKIT_MATE_LISTENER_H
+
+#include <polkitagent/polkitagent.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define POLKIT_MATE_TYPE_LISTENER          (polkit_mate_listener_get_type())
+#define POLKIT_MATE_LISTENER(o)            (G_TYPE_CHECK_INSTANCE_CAST ((o), POLKIT_MATE_TYPE_LISTENER, PolkitMateListener))
+#define POLKIT_MATE_LISTENER_CLASS(k)      (G_TYPE_CHECK_CLASS_CAST((k), POLKIT_MATE_TYPE_LISTENER, PolkitMateListenerClass))
+#define POLKIT_MATE_LISTENER_GET_CLASS(o)  (G_TYPE_INSTANCE_GET_CLASS ((o), POLKIT_MATE_TYPE_LISTENER, PolkitMateListenerClass))
+#define POLKIT_MATE_IS_LISTENER(o)         (G_TYPE_CHECK_INSTANCE_TYPE ((o), POLKIT_MATE_TYPE_LISTENER))
+#define POLKIT_MATE_IS_LISTENER_CLASS(k)   (G_TYPE_CHECK_CLASS_TYPE ((k), POLKIT_MATE_TYPE_LISTENER))
+
+typedef struct _PolkitMateListener PolkitMateListener;
+typedef struct _PolkitMateListenerClass PolkitMateListenerClass;
+
+GType                 polkit_mate_listener_get_type   (void) G_GNUC_CONST;
+PolkitAgentListener  *polkit_mate_listener_new        (void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __POLKIT_MATE_LISTENER_H */
+
+ +
+ +
+ + diff --git a/2024-02-26-105642-9744-cppcheck@c2df8de7c7b1_v1.28.1/2.html b/2024-02-26-105642-9744-cppcheck@c2df8de7c7b1_v1.28.1/2.html new file mode 100644 index 0000000..bce6d3f --- /dev/null +++ b/2024-02-26-105642-9744-cppcheck@c2df8de7c7b1_v1.28.1/2.html @@ -0,0 +1,2639 @@ + + + + + + Cppcheck - HTML report - mate-polkit + + + + + +
+ + + +
+
   1
+   2
+   3
+   4
+   5
+   6
+   7
+   8
+   9
+  10
+  11
+  12
+  13
+  14
+  15
+  16
+  17
+  18
+  19
+  20
+  21
+  22
+  23
+  24
+  25
+  26
+  27
+  28
+  29
+  30
+  31
+  32
+  33
+  34
+  35
+  36
+  37
+  38
+  39
+  40
+  41
+  42
+  43
+  44
+  45
+  46
+  47
+  48
+  49
+  50
+  51
+  52
+  53
+  54
+  55
+  56
+  57
+  58
+  59
+  60
+  61
+  62
+  63
+  64
+  65
+  66
+  67
+  68
+  69
+  70
+  71
+  72
+  73
+  74
+  75
+  76
+  77
+  78
+  79
+  80
+  81
+  82
+  83
+  84
+  85
+  86
+  87
+  88
+  89
+  90
+  91
+  92
+  93
+  94
+  95
+  96
+  97
+  98
+  99
+ 100
+ 101
+ 102
+ 103
+ 104
+ 105
+ 106
+ 107
+ 108
+ 109
+ 110
+ 111
+ 112
+ 113
+ 114
+ 115
+ 116
+ 117
+ 118
+ 119
+ 120
+ 121
+ 122
+ 123
+ 124
+ 125
+ 126
+ 127
+ 128
+ 129
+ 130
+ 131
+ 132
+ 133
+ 134
+ 135
+ 136
+ 137
+ 138
+ 139
+ 140
+ 141
+ 142
+ 143
+ 144
+ 145
+ 146
+ 147
+ 148
+ 149
+ 150
+ 151
+ 152
+ 153
+ 154
+ 155
+ 156
+ 157
+ 158
+ 159
+ 160
+ 161
+ 162
+ 163
+ 164
+ 165
+ 166
+ 167
+ 168
+ 169
+ 170
+ 171
+ 172
+ 173
+ 174
+ 175
+ 176
+ 177
+ 178
+ 179
+ 180
+ 181
+ 182
+ 183
+ 184
+ 185
+ 186
+ 187
+ 188
+ 189
+ 190
+ 191
+ 192
+ 193
+ 194
+ 195
+ 196
+ 197
+ 198
+ 199
+ 200
+ 201
+ 202
+ 203
+ 204
+ 205
+ 206
+ 207
+ 208
+ 209
+ 210
+ 211
+ 212
+ 213
+ 214
+ 215
+ 216
+ 217
+ 218
+ 219
+ 220
+ 221
+ 222
+ 223
+ 224
+ 225
+ 226
+ 227
+ 228
+ 229
+ 230
+ 231
+ 232
+ 233
+ 234
+ 235
+ 236
+ 237
+ 238
+ 239
+ 240
+ 241
+ 242
+ 243
+ 244
+ 245
+ 246
+ 247
+ 248
+ 249
+ 250
+ 251
+ 252
+ 253
+ 254
+ 255
+ 256
+ 257
+ 258
+ 259
+ 260
+ 261
+ 262
+ 263
+ 264
+ 265
+ 266
+ 267
+ 268
+ 269
+ 270
+ 271
+ 272
+ 273
+ 274
+ 275
+ 276
+ 277
+ 278
+ 279
+ 280
+ 281
+ 282
+ 283
+ 284
+ 285
+ 286
+ 287
+ 288
+ 289
+ 290
+ 291
+ 292
+ 293
+ 294
+ 295
+ 296
+ 297
+ 298
+ 299
+ 300
+ 301
+ 302
+ 303
+ 304
+ 305
+ 306
+ 307
+ 308
+ 309
+ 310
+ 311
+ 312
+ 313
+ 314
+ 315
+ 316
+ 317
+ 318
+ 319
+ 320
+ 321
+ 322
+ 323
+ 324
+ 325
+ 326
+ 327
+ 328
+ 329
+ 330
+ 331
+ 332
+ 333
+ 334
+ 335
+ 336
+ 337
+ 338
+ 339
+ 340
+ 341
+ 342
+ 343
+ 344
+ 345
+ 346
+ 347
+ 348
+ 349
+ 350
+ 351
+ 352
+ 353
+ 354
+ 355
+ 356
+ 357
+ 358
+ 359
+ 360
+ 361
+ 362
+ 363
+ 364
+ 365
+ 366
+ 367
+ 368
+ 369
+ 370
+ 371
+ 372
+ 373
+ 374
+ 375
+ 376
+ 377
+ 378
+ 379
+ 380
+ 381
+ 382
+ 383
+ 384
+ 385
+ 386
+ 387
+ 388
+ 389
+ 390
+ 391
+ 392
+ 393
+ 394
+ 395
+ 396
+ 397
+ 398
+ 399
+ 400
+ 401
+ 402
+ 403
+ 404
+ 405
+ 406
+ 407
+ 408
+ 409
+ 410
+ 411
+ 412
+ 413
+ 414
+ 415
+ 416
+ 417
+ 418
+ 419
+ 420
+ 421
+ 422
+ 423
+ 424
+ 425
+ 426
+ 427
+ 428
+ 429
+ 430
+ 431
+ 432
+ 433
+ 434
+ 435
+ 436
+ 437
+ 438
+ 439
+ 440
+ 441
+ 442
+ 443
+ 444
+ 445
+ 446
+ 447
+ 448
+ 449
+ 450
+ 451
+ 452
+ 453
+ 454
+ 455
+ 456
+ 457
+ 458
+ 459
+ 460
+ 461
+ 462
+ 463
+ 464
+ 465
+ 466
+ 467
+ 468
+ 469
+ 470
+ 471
+ 472
+ 473
+ 474
+ 475
+ 476
+ 477
+ 478
+ 479
+ 480
+ 481
+ 482
+ 483
+ 484
+ 485
+ 486
+ 487
+ 488
+ 489
+ 490
+ 491
+ 492
+ 493
+ 494
+ 495
+ 496
+ 497
+ 498
+ 499
+ 500
+ 501
+ 502
+ 503
+ 504
+ 505
+ 506
+ 507
+ 508
+ 509
+ 510
+ 511
+ 512
+ 513
+ 514
+ 515
+ 516
+ 517
+ 518
+ 519
+ 520
+ 521
+ 522
+ 523
+ 524
+ 525
+ 526
+ 527
+ 528
+ 529
+ 530
+ 531
+ 532
+ 533
+ 534
+ 535
+ 536
+ 537
+ 538
+ 539
+ 540
+ 541
+ 542
+ 543
+ 544
+ 545
+ 546
+ 547
+ 548
+ 549
+ 550
+ 551
+ 552
+ 553
+ 554
+ 555
+ 556
+ 557
+ 558
+ 559
+ 560
+ 561
+ 562
+ 563
+ 564
+ 565
+ 566
+ 567
+ 568
+ 569
+ 570
+ 571
+ 572
+ 573
+ 574
+ 575
+ 576
+ 577
+ 578
+ 579
+ 580
+ 581
+ 582
+ 583
+ 584
+ 585
+ 586
+ 587
+ 588
+ 589
+ 590
+ 591
+ 592
+ 593
+ 594
+ 595
+ 596
+ 597
+ 598
+ 599
+ 600
+ 601
+ 602
+ 603
+ 604
+ 605
+ 606
+ 607
+ 608
+ 609
+ 610
+ 611
+ 612
+ 613
+ 614
+ 615
+ 616
+ 617
+ 618
+ 619
+ 620
+ 621
+ 622
+ 623
+ 624
+ 625
+ 626
+ 627
+ 628
+ 629
+ 630
+ 631
+ 632
+ 633
+ 634
+ 635
+ 636
+ 637
+ 638
+ 639
+ 640
+ 641
+ 642
+ 643
+ 644
+ 645
+ 646
+ 647
+ 648
+ 649
+ 650
+ 651
+ 652
+ 653
+ 654
+ 655
+ 656
+ 657
+ 658
+ 659
+ 660
+ 661
+ 662
+ 663
+ 664
+ 665
+ 666
+ 667
+ 668
+ 669
+ 670
+ 671
+ 672
+ 673
+ 674
+ 675
+ 676
+ 677
+ 678
+ 679
+ 680
+ 681
+ 682
+ 683
+ 684
+ 685
+ 686
+ 687
+ 688
+ 689
+ 690
+ 691
+ 692
+ 693
+ 694
+ 695
+ 696
+ 697
+ 698
+ 699
+ 700
+ 701
+ 702
+ 703
+ 704
+ 705
+ 706
+ 707
+ 708
+ 709
+ 710
+ 711
+ 712
+ 713
+ 714
+ 715
+ 716
+ 717
+ 718
+ 719
+ 720
+ 721
+ 722
+ 723
+ 724
+ 725
+ 726
+ 727
+ 728
+ 729
+ 730
+ 731
+ 732
+ 733
+ 734
+ 735
+ 736
+ 737
+ 738
+ 739
+ 740
+ 741
+ 742
+ 743
+ 744
+ 745
+ 746
+ 747
+ 748
+ 749
+ 750
+ 751
+ 752
+ 753
+ 754
+ 755
+ 756
+ 757
+ 758
+ 759
+ 760
+ 761
+ 762
+ 763
+ 764
+ 765
+ 766
+ 767
+ 768
+ 769
+ 770
+ 771
+ 772
+ 773
+ 774
+ 775
+ 776
+ 777
+ 778
+ 779
+ 780
+ 781
+ 782
+ 783
+ 784
+ 785
+ 786
+ 787
+ 788
+ 789
+ 790
+ 791
+ 792
+ 793
+ 794
+ 795
+ 796
+ 797
+ 798
+ 799
+ 800
+ 801
+ 802
+ 803
+ 804
+ 805
+ 806
+ 807
+ 808
+ 809
+ 810
+ 811
+ 812
+ 813
+ 814
+ 815
+ 816
+ 817
+ 818
+ 819
+ 820
+ 821
+ 822
+ 823
+ 824
+ 825
+ 826
+ 827
+ 828
+ 829
+ 830
+ 831
+ 832
+ 833
+ 834
+ 835
+ 836
+ 837
+ 838
+ 839
+ 840
+ 841
+ 842
+ 843
+ 844
+ 845
+ 846
+ 847
+ 848
+ 849
+ 850
+ 851
+ 852
+ 853
+ 854
+ 855
+ 856
+ 857
+ 858
+ 859
+ 860
+ 861
+ 862
+ 863
+ 864
+ 865
+ 866
+ 867
+ 868
+ 869
+ 870
+ 871
+ 872
+ 873
+ 874
+ 875
+ 876
+ 877
+ 878
+ 879
+ 880
+ 881
+ 882
+ 883
+ 884
+ 885
+ 886
+ 887
+ 888
+ 889
+ 890
+ 891
+ 892
+ 893
+ 894
+ 895
+ 896
+ 897
+ 898
+ 899
+ 900
+ 901
+ 902
+ 903
+ 904
+ 905
+ 906
+ 907
+ 908
+ 909
+ 910
+ 911
+ 912
+ 913
+ 914
+ 915
+ 916
+ 917
+ 918
+ 919
+ 920
+ 921
+ 922
+ 923
+ 924
+ 925
+ 926
+ 927
+ 928
+ 929
+ 930
+ 931
+ 932
+ 933
+ 934
+ 935
+ 936
+ 937
+ 938
+ 939
+ 940
+ 941
+ 942
+ 943
+ 944
+ 945
+ 946
+ 947
+ 948
+ 949
+ 950
+ 951
+ 952
+ 953
+ 954
+ 955
+ 956
+ 957
+ 958
+ 959
+ 960
+ 961
+ 962
+ 963
+ 964
+ 965
+ 966
+ 967
+ 968
+ 969
+ 970
+ 971
+ 972
+ 973
+ 974
+ 975
+ 976
+ 977
+ 978
+ 979
+ 980
+ 981
+ 982
+ 983
+ 984
+ 985
+ 986
+ 987
+ 988
+ 989
+ 990
+ 991
+ 992
+ 993
+ 994
+ 995
+ 996
+ 997
+ 998
+ 999
+1000
+1001
+1002
+1003
+1004
+1005
+1006
+1007
+1008
+1009
+1010
+1011
+1012
+1013
+1014
+1015
+1016
+1017
+1018
+1019
+1020
+1021
+1022
+1023
+1024
+1025
+1026
+1027
+1028
+1029
+1030
+1031
+1032
+1033
+1034
+1035
+1036
+1037
+1038
+1039
+1040
+1041
+1042
+1043
+1044
+1045
+1046
+1047
+1048
+1049
+1050
+1051
+1052
+1053
+1054
+1055
+1056
+1057
+1058
+1059
+1060
+1061
+1062
+1063
+1064
+1065
+1066
+1067
+1068
+1069
+1070
+1071
+1072
+1073
+1074
+1075
+1076
+1077
+1078
+1079
+1080
+1081
+1082
+1083
+1084
+1085
+1086
+1087
+1088
+1089
+1090
+1091
+1092
+1093
+1094
+1095
+1096
+1097
+1098
+1099
+1100
+1101
+1102
+1103
+1104
+1105
+1106
+1107
+1108
+1109
+1110
+1111
+1112
+1113
+1114
+1115
+1116
+1117
+1118
+1119
+1120
+1121
+1122
+1123
+1124
+1125
+1126
+1127
+1128
+1129
+1130
+1131
+1132
+1133
+1134
+1135
+1136
+1137
+1138
+1139
+1140
+1141
+1142
+1143
+1144
+1145
+1146
+1147
+1148
+1149
+1150
+1151
+1152
+1153
+1154
+1155
+1156
+1157
+1158
+1159
+1160
+1161
+1162
+1163
+1164
+1165
+1166
+1167
+1168
+1169
+1170
+1171
+1172
+1173
+1174
+1175
+1176
+1177
+1178
+1179
+1180
+1181
+1182
+1183
+1184
+1185
+1186
+1187
+1188
+1189
+1190
+1191
+1192
+1193
+1194
+1195
+1196
+1197
+1198
+1199
+1200
+1201
/*
+ * Copyright (C) 2009 Red Hat, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ * Author: David Zeuthen <davidz@redhat.com>
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"<--- Include file: "config.h" not found.
+#endif
+
+#define _GNU_SOURCE
+#include <unistd.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/types.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/stat.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <fcntl.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <stdio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <stdlib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <pwd.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <errno.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <glib/gi18n-lib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "polkitmateauthenticationdialog.h"
+
+#define RESPONSE_USER_SELECTED 1001
+
+struct _PolkitMateAuthenticationDialogPrivate
+{
+  GtkWidget *user_combobox;
+  GtkWidget *prompt_label;
+  GtkWidget *password_entry;
+  GtkWidget *auth_button;
+  GtkWidget *cancel_button;
+  GtkWidget *info_label;
+  GtkWidget *grid_password;
+
+  gchar *message;
+  gchar *action_id;
+  gchar *vendor;
+  gchar *vendor_url;
+  gchar *icon_name;
+  PolkitDetails *details;
+
+  gchar **users;
+  gchar *selected_user;
+
+  gboolean is_running;
+
+  GtkListStore *store;
+};
+
+G_DEFINE_TYPE_WITH_PRIVATE (PolkitMateAuthenticationDialog, polkit_mate_authentication_dialog, GTK_TYPE_DIALOG);
+
+enum {
+  PROP_0,
+  PROP_ACTION_ID,
+  PROP_VENDOR,
+  PROP_VENDOR_URL,
+  PROP_ICON_NAME,
+  PROP_MESSAGE,
+  PROP_DETAILS,
+  PROP_USERS,
+  PROP_SELECTED_USER,
+};
+
+enum {
+  PIXBUF_COL,
+  TEXT_COL,
+  USERNAME_COL,
+  N_COL
+};
+
+static void
+user_combobox_set_sensitive (GtkCellLayout   *cell_layout,
+                             GtkCellRenderer *cell,
+                             GtkTreeModel    *tree_model,
+                             GtkTreeIter     *iter,
+                             gpointer         user_data)
+{
+  GtkTreePath *path;
+  gint *indices;<--- Variable 'indices' can be declared as pointer to const
+  gboolean sensitive;
+
+  path = gtk_tree_model_get_path (tree_model, iter);
+  indices = gtk_tree_path_get_indices (path);
+  if (indices[0] == 0)
+    sensitive = FALSE;
+  else
+    sensitive = TRUE;
+  gtk_tree_path_free (path);
+
+  g_object_set (cell, "sensitive", sensitive, NULL);
+}
+
+static void
+user_combobox_changed (GtkComboBox *widget,
+                       gpointer     user_data)
+{
+  PolkitMateAuthenticationDialog *dialog = POLKIT_MATE_AUTHENTICATION_DIALOG (user_data);
+  GtkTreeIter iter;
+  gchar *user_name;
+
+  if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (widget), &iter))
+    {
+      gtk_tree_model_get (GTK_TREE_MODEL (dialog->priv->store), &iter, USERNAME_COL, &user_name, -1);
+
+      g_free (dialog->priv->selected_user);
+      dialog->priv->selected_user = user_name;
+
+      g_object_notify (G_OBJECT (dialog), "selected-user");
+
+      gtk_dialog_response (GTK_DIALOG (dialog), RESPONSE_USER_SELECTED);
+
+      /* make the password entry and Authenticate button sensitive again */
+      gtk_widget_set_sensitive (dialog->priv->prompt_label, TRUE);
+      gtk_widget_set_sensitive (dialog->priv->password_entry, TRUE);
+      gtk_widget_set_sensitive (dialog->priv->auth_button, TRUE);
+    }
+}
+
+#if HAVE_ACCOUNTSSERVICE
+static GdkPixbuf *
+get_user_icon (char *username)
+{
+  GError *error;
+  GDBusConnection *connection;
+  GVariant *find_user_result;
+  GVariant *get_icon_result;
+  GVariant *icon_result_variant;
+  const gchar *user_path;
+  const gchar *icon_filename;
+  GdkPixbuf *pixbuf = NULL;
+
+  error = NULL;
+  connection = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
+
+  if (connection == NULL)
+    {
+      g_warning ("Unable to connect to system bus: %s", error->message);
+      g_error_free (error);
+      return NULL;
+    }
+
+  find_user_result = g_dbus_connection_call_sync (connection,
+                                          "org.freedesktop.Accounts",
+                                          "/org/freedesktop/Accounts",
+                                          "org.freedesktop.Accounts",
+                                          "FindUserByName",
+                                          g_variant_new ("(s)",
+                                          username),
+                                          G_VARIANT_TYPE ("(o)"),
+                                          G_DBUS_CALL_FLAGS_NONE,
+                                          -1,
+                                          NULL,
+                                          &error);
+
+  if (find_user_result == NULL)
+    {
+      g_warning ("Accounts couldn't find user: %s", error->message);
+      g_error_free (error);
+      return NULL;
+    }
+
+  user_path = g_variant_get_string (g_variant_get_child_value (find_user_result, 0),
+                                    NULL);
+
+  get_icon_result = g_dbus_connection_call_sync (connection,
+                                                 "org.freedesktop.Accounts",
+                                                 user_path,
+                                                 "org.freedesktop.DBus.Properties",
+                                                 "Get",
+                                                 g_variant_new ("(ss)",
+                                                                "org.freedesktop.Accounts.User",
+                                                                "IconFile"),
+                                                 G_VARIANT_TYPE ("(v)"),
+                                                 G_DBUS_CALL_FLAGS_NONE,
+                                                 -1,
+                                                 NULL,
+                                                 &error);
+
+  g_variant_unref (find_user_result);
+
+  if (get_icon_result == NULL)
+    {
+      g_warning ("Accounts couldn't find user icon: %s", error->message);
+      g_error_free (error);
+      return NULL;
+    }
+
+  g_variant_get_child (get_icon_result, 0, "v", &icon_result_variant);
+  icon_filename = g_variant_get_string (icon_result_variant, NULL);
+
+  if (icon_filename == NULL)
+    {
+      g_warning ("Accounts didn't return a valid filename for user icon");
+    }
+  else
+    {
+      /* TODO: we probably shouldn't hard-code the size to 16x16 */
+      pixbuf = gdk_pixbuf_new_from_file_at_size (icon_filename,
+                                                 16,
+                                                 16,
+                                                 &error);
+      if (pixbuf == NULL)
+        {
+          g_warning ("Couldn't open user icon: %s", error->message);
+          g_error_free (error);
+        }
+    }
+
+  g_variant_unref (icon_result_variant);
+  g_variant_unref (get_icon_result);
+
+  return pixbuf;
+}
+#else
+static GdkPixbuf *
+get_user_icon (char *username)
+{
+  GdkPixbuf *pixbuf = NULL;
+  struct passwd *passwd;
+
+  passwd = getpwnam (username);
+  if (passwd->pw_dir != NULL)
+    {
+      gchar *path;
+      path = g_strdup_printf ("%s/.face", passwd->pw_dir);
+      /* TODO: we probably shouldn't hard-code the size to 16x16 */
+      pixbuf = gdk_pixbuf_new_from_file_at_scale (path, 16, 16, TRUE, NULL);
+      g_free (path);
+    }
+
+  return pixbuf;
+}
+#endif /* HAVE_ACCOUNTSSERVICE */
+
+static void
+create_user_combobox (PolkitMateAuthenticationDialog *dialog)
+{
+  int n, i, selected_index = 0;
+  GtkComboBox *combo;
+  GtkTreeIter iter;
+  GtkCellRenderer *renderer;
+
+  /* if we've already built the list of admin users once, then avoid
+   * doing it again.. (this is mainly used when the user entered the
+   * wrong password and the dialog is recycled)
+   */
+  if (dialog->priv->store != NULL)
+    return;
+
+  combo = GTK_COMBO_BOX (dialog->priv->user_combobox);
+  dialog->priv->store = gtk_list_store_new (3, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING);
+
+  gtk_list_store_append (dialog->priv->store, &iter);
+  gtk_list_store_set (dialog->priv->store, &iter,
+                      PIXBUF_COL, NULL,
+                      TEXT_COL, _("Select user..."),
+                      USERNAME_COL, NULL,
+                      -1);
+
+  /* For each user */
+  for (i = 0, n = 0; dialog->priv->users[n] != NULL; n++)
+  {
+      gchar *gecos;
+      gchar *real_name;
+      GdkPixbuf *pixbuf = NULL;
+      struct passwd *passwd;
+
+      /* we're single threaded so this is fine */
+      errno = 0;
+      passwd = getpwnam (dialog->priv->users[n]);
+      if (passwd == NULL)
+        {
+          g_warning ("Error doing getpwnam(\"%s\"): %s", dialog->priv->users[n], strerror (errno));
+          continue;
+        }
+
+      if (passwd->pw_gecos != NULL)
+        gecos = g_locale_to_utf8 (passwd->pw_gecos, -1, NULL, NULL, NULL);
+      else
+        gecos = NULL;
+
+      if (gecos != NULL && strlen (gecos) > 0)
+        {
+          gchar *first_comma;
+          first_comma = strchr (gecos, ',');
+          if (first_comma != NULL)
+            *first_comma = '\0';
+        }
+      if (gecos != NULL && strlen (gecos) > 0 && strcmp (gecos, dialog->priv->users[n]) != 0)
+        real_name = g_strdup_printf (_("%s (%s)"), gecos, dialog->priv->users[n]);
+       else
+         real_name = g_strdup (dialog->priv->users[n]);
+      g_free (gecos);
+
+      /* Load users face */
+      pixbuf = get_user_icon (dialog->priv->users[n]);
+
+      /* fall back to stock_person icon */
+      if (pixbuf == NULL)
+        {
+          pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
+                                             "stock_person",
+                                             GTK_ICON_SIZE_MENU,
+                                             0,
+                                             NULL);
+        }
+
+      gtk_list_store_append (dialog->priv->store, &iter);
+      gtk_list_store_set (dialog->priv->store, &iter,
+                          PIXBUF_COL, pixbuf,
+                          TEXT_COL, real_name,
+                          USERNAME_COL, dialog->priv->users[n],
+                          -1);
+
+      i++;
+      if (passwd->pw_uid == getuid ())
+        {
+          selected_index = i;
+          g_free (dialog->priv->selected_user);
+          dialog->priv->selected_user = g_strdup (dialog->priv->users[n]);
+        }
+
+      g_free (real_name);
+      g_object_unref (pixbuf);
+    }
+
+  gtk_combo_box_set_model (combo, GTK_TREE_MODEL (dialog->priv->store));
+
+  renderer = gtk_cell_renderer_pixbuf_new ();
+  gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), renderer, FALSE);
+  gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo),
+                                  renderer,
+                                  "pixbuf", PIXBUF_COL,
+                                  NULL);
+  gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (combo),
+                                      renderer,
+                                      user_combobox_set_sensitive,
+                                      NULL, NULL);
+
+  renderer = gtk_cell_renderer_text_new ();
+  gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), renderer, TRUE);
+  gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo),
+                                  renderer,
+                                  "text", TEXT_COL,
+                                  NULL);
+  gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (combo),
+                                      renderer,
+                                      user_combobox_set_sensitive,
+                                      NULL, NULL);
+
+  /* Select the default user */
+  gtk_combo_box_set_active (GTK_COMBO_BOX (combo), selected_index);
+
+  /* Listen when a new user is selected */
+  g_signal_connect (GTK_WIDGET (combo),
+                    "changed",
+                    G_CALLBACK (user_combobox_changed),
+                    dialog);
+}
+
+static GtkWidget *
+get_image (PolkitMateAuthenticationDialog *dialog)
+{
+  GdkPixbuf *pixbuf;
+  GdkPixbuf *copy_pixbuf;
+  GdkPixbuf *vendor_pixbuf;
+  GtkWidget *image;
+
+  pixbuf = NULL;
+  copy_pixbuf = NULL;
+  vendor_pixbuf = NULL;
+  image = NULL;
+
+  if (dialog->priv->icon_name == NULL || strlen (dialog->priv->icon_name) == 0)
+    {
+      image = gtk_image_new_from_icon_name ("dialog-password", GTK_ICON_SIZE_DIALOG);
+      goto out;
+    }
+
+  vendor_pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
+                                            dialog->priv->icon_name,
+                                            48,
+                                            0,
+                                            NULL);
+  if (vendor_pixbuf == NULL)
+    {
+      g_warning ("No icon for themed icon with name '%s'", dialog->priv->icon_name);
+      image = gtk_image_new_from_icon_name ("dialog-password", GTK_ICON_SIZE_DIALOG);
+      goto out;
+    }
+
+  pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
+                                     "dialog-password",
+                                     48,
+                                     0,
+                                     NULL);
+  if (pixbuf == NULL)
+    goto out;
+
+  /* need to copy the pixbuf since we're modifying it */
+  copy_pixbuf = gdk_pixbuf_copy (pixbuf);
+  if (copy_pixbuf == NULL)
+    goto out;
+
+  /* blend the vendor icon in the bottom right quarter */
+  gdk_pixbuf_composite (vendor_pixbuf,
+                        copy_pixbuf,
+                        24, 24, 24, 24,
+                        24, 24, 0.5, 0.5,
+                        GDK_INTERP_BILINEAR,
+                        255);
+
+  image = gtk_image_new_from_pixbuf (copy_pixbuf);
+
+out:
+  if (pixbuf != NULL)
+    g_object_unref (pixbuf);
+
+  if (copy_pixbuf != NULL)
+    g_object_unref (copy_pixbuf);
+
+  if (vendor_pixbuf != NULL)
+    g_object_unref (vendor_pixbuf);
+
+  return image;
+}
+
+static void
+polkit_mate_authentication_dialog_set_property (GObject      *object,
+                                                 guint         prop_id,
+                                                 const GValue *value,
+                                                 GParamSpec   *pspec)
+{
+  PolkitMateAuthenticationDialog *dialog = POLKIT_MATE_AUTHENTICATION_DIALOG (object);
+
+  switch (prop_id)
+    {
+    case PROP_DETAILS:
+      dialog->priv->details = g_value_dup_object (value);
+      break;
+
+    case PROP_ACTION_ID:
+      dialog->priv->action_id = g_value_dup_string (value);
+      break;
+
+    case PROP_VENDOR:
+      dialog->priv->vendor = g_value_dup_string (value);
+      break;
+
+    case PROP_VENDOR_URL:
+      dialog->priv->vendor_url = g_value_dup_string (value);
+      break;
+
+    case PROP_ICON_NAME:
+      dialog->priv->icon_name = g_value_dup_string (value);
+      break;
+
+    case PROP_MESSAGE:
+      dialog->priv->message = g_value_dup_string (value);
+      break;
+
+    case PROP_USERS:
+      dialog->priv->users = g_value_dup_boxed (value);
+      break;
+
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+    }
+}
+
+static void
+polkit_mate_authentication_dialog_get_property (GObject    *object,
+                                                 guint       prop_id,
+                                                 GValue     *value,
+                                                 GParamSpec *pspec)
+{
+  PolkitMateAuthenticationDialog *dialog = POLKIT_MATE_AUTHENTICATION_DIALOG (object);
+
+  switch (prop_id)
+    {
+    case PROP_MESSAGE:
+      g_value_set_string (value, dialog->priv->message);
+      break;
+
+    /* TODO: rest of the properties */
+
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+    }
+}
+
+static GtkWidget *
+add_row (GtkWidget *grid, int row, const char *label_text, GtkWidget *entry)
+{
+  GtkWidget *label;
+
+  label = gtk_label_new_with_mnemonic (label_text);
+  gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
+  gtk_label_set_xalign (GTK_LABEL (label), 1.0);
+  gtk_label_set_yalign (GTK_LABEL (label), 0.5);
+
+  gtk_widget_set_hexpand (label, FALSE);
+  gtk_grid_attach (GTK_GRID (grid), label,
+                   0, row, 1, 1);
+  gtk_widget_set_hexpand (entry, TRUE);
+  gtk_grid_attach (GTK_GRID (grid), entry,
+                   1, row, 1, 1);
+  gtk_label_set_mnemonic_widget (GTK_LABEL (label), entry);
+
+  return label;
+}
+
+static void
+action_id_activated (GtkLabel *url_label, gpointer user_data)
+{
+#if 0
+  GError *error;
+  DBusGConnection *bus;
+  DBusGProxy *manager_proxy;
+
+  error = NULL;
+  bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
+  if (bus == NULL)
+    {
+      g_warning ("Couldn't connect to session bus: %s", error->message);
+      g_error_free (error);
+      goto out;
+    }
+
+  manager_proxy = dbus_g_proxy_new_for_name (bus,
+                                             "org.mate.PolicyKit.AuthorizationManager",
+                                             "/",
+                                             "org.mate.PolicyKit.AuthorizationManager.SingleInstance");
+  if (manager_proxy == NULL)
+    {
+      g_warning ("Could not construct manager_proxy object; bailing out");
+      goto out;
+    }
+
+  if (!dbus_g_proxy_call (manager_proxy,
+                          "ShowAction",
+                          &error,
+                          G_TYPE_STRING, gtk_label_get_current_uri (GTK_LABEL (url_label)),
+                          G_TYPE_INVALID,
+                          G_TYPE_INVALID))
+    {
+      if (error != NULL)
+        {
+          g_warning ("Failed to call into manager: %s", error->message);
+          g_error_free (error);
+        }
+      else
+        {
+          g_warning ("Failed to call into manager");
+        }
+      goto out;
+    }
+
+out:
+        ;
+#endif
+}
+
+static void
+polkit_mate_authentication_dialog_init (PolkitMateAuthenticationDialog *dialog)
+{
+  dialog->priv = polkit_mate_authentication_dialog_get_instance_private (dialog);
+}
+
+static void
+polkit_mate_authentication_dialog_finalize (GObject *object)
+{
+  PolkitMateAuthenticationDialog *dialog;
+
+  dialog = POLKIT_MATE_AUTHENTICATION_DIALOG (object);
+
+  g_free (dialog->priv->message);
+  g_free (dialog->priv->action_id);
+  g_free (dialog->priv->vendor);
+  g_free (dialog->priv->vendor_url);
+  g_free (dialog->priv->icon_name);
+  if (dialog->priv->details != NULL)
+    g_object_unref (dialog->priv->details);
+
+  g_strfreev (dialog->priv->users);
+  g_free (dialog->priv->selected_user);
+
+  if (dialog->priv->store != NULL)
+    g_object_unref (dialog->priv->store);
+
+  if (G_OBJECT_CLASS (polkit_mate_authentication_dialog_parent_class)->finalize != NULL)
+    G_OBJECT_CLASS (polkit_mate_authentication_dialog_parent_class)->finalize (object);
+}
+
+static GtkWidget*
+polkit_mate_dialog_add_button (GtkDialog   *dialog,
+                               const gchar *button_text,
+                               const gchar *icon_name,
+                                     gint   response_id)
+{
+  GtkWidget *button;
+
+  button = gtk_button_new_with_mnemonic (button_text);
+  gtk_button_set_image (GTK_BUTTON (button), gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_BUTTON));
+
+  gtk_button_set_use_underline (GTK_BUTTON (button), TRUE);
+  gtk_style_context_add_class (gtk_widget_get_style_context (button), "text-button");
+  gtk_widget_set_can_default (button, TRUE);
+  gtk_widget_show (button);
+  gtk_dialog_add_action_widget (GTK_DIALOG (dialog), button, response_id);
+
+  return button;
+}
+
+static void
+polkit_mate_authentication_dialog_constructed (GObject *object)
+{
+  PolkitMateAuthenticationDialog *dialog;
+  GtkWidget *hbox;
+  GtkWidget *main_vbox;
+  GtkWidget *vbox;
+  GtkWidget *grid_password;
+  GtkWidget *details_expander;
+  GtkWidget *details_vbox;
+  GtkWidget *grid;
+  GtkWidget *label;
+  GtkWidget *image;
+  GtkWidget *content_area;
+  gboolean have_user_combobox;
+  gchar *s;
+  guint rows;
+
+  dialog = POLKIT_MATE_AUTHENTICATION_DIALOG (object);
+
+  if (G_OBJECT_CLASS (polkit_mate_authentication_dialog_parent_class)->constructed != NULL)
+    G_OBJECT_CLASS (polkit_mate_authentication_dialog_parent_class)->constructed (object);
+
+  have_user_combobox = FALSE;
+
+  dialog->priv->cancel_button = polkit_mate_dialog_add_button (GTK_DIALOG (dialog),
+                                                               _("_Cancel"),
+                                                               "process-stop",
+                                                               GTK_RESPONSE_CANCEL);
+
+  dialog->priv->auth_button = gtk_dialog_add_button (GTK_DIALOG (dialog),
+                                                     _("_Authenticate"),
+                                                     GTK_RESPONSE_OK);
+
+  gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
+
+  content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
+
+  gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
+  gtk_box_set_spacing (GTK_BOX (content_area), 2); /* 2 * 5 + 2 = 12 */
+  gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
+  gtk_window_set_icon_name (GTK_WINDOW (dialog), "dialog-password");
+
+  hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
+  gtk_container_set_border_width (GTK_CONTAINER (hbox), 5);
+  gtk_box_pack_start (GTK_BOX (content_area), hbox, TRUE, TRUE, 0);
+
+  image = get_image (dialog);
+  gtk_widget_set_halign (image, GTK_ALIGN_CENTER);
+  gtk_widget_set_valign (image, GTK_ALIGN_START);
+  gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0);
+
+  main_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 10);
+  gtk_box_pack_start (GTK_BOX (hbox), main_vbox, TRUE, TRUE, 0);
+
+  /* main message */
+  label = gtk_label_new (NULL);
+  s = g_strdup_printf ("<big><b>%s</b></big>", dialog->priv->message);
+  gtk_label_set_markup (GTK_LABEL (label), s);
+  g_free (s);
+
+  gtk_label_set_xalign (GTK_LABEL (label), 0.0);
+  gtk_label_set_yalign (GTK_LABEL (label), 0.5);
+  gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
+  gtk_label_set_max_width_chars (GTK_LABEL (label), 50);
+  gtk_box_pack_start (GTK_BOX (main_vbox), label, FALSE, FALSE, 0);
+
+  /* secondary message */
+  label = gtk_label_new (NULL);
+  if (g_strv_length (dialog->priv->users) > 1)
+    {
+          gtk_label_set_markup (GTK_LABEL (label),
+                                _("An application is attempting to perform an action that requires privileges. "
+                                  "Authentication as one of the users below is required to perform this action."));
+    }
+  else
+    {
+      if (strcmp (g_get_user_name (), dialog->priv->users[0]) == 0)
+        {
+          gtk_label_set_markup (GTK_LABEL (label),
+                                _("An application is attempting to perform an action that requires privileges. "
+                                  "Authentication is required to perform this action."));
+        }
+      else
+        {
+          gtk_label_set_markup (GTK_LABEL (label),
+                                _("An application is attempting to perform an action that requires privileges. "
+                                  "Authentication as the super user is required to perform this action."));
+        }
+    }
+
+  gtk_label_set_xalign (GTK_LABEL (label), 0.0);
+  gtk_label_set_yalign (GTK_LABEL (label), 0.5);
+  gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
+  gtk_label_set_max_width_chars (GTK_LABEL (label), 50);
+  gtk_box_pack_start (GTK_BOX (main_vbox), label, FALSE, FALSE, 0);
+
+  /* user combobox */
+  if (g_strv_length (dialog->priv->users) > 1)
+    {
+      dialog->priv->user_combobox = gtk_combo_box_new ();
+      gtk_box_pack_start (GTK_BOX (main_vbox), GTK_WIDGET (dialog->priv->user_combobox), FALSE, FALSE, 0);
+
+      create_user_combobox (dialog);
+
+      have_user_combobox = TRUE;
+    }
+  else
+    {
+      dialog->priv->selected_user = g_strdup (dialog->priv->users[0]);
+    }
+
+  /* password entry */
+  vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
+  gtk_box_pack_start (GTK_BOX (main_vbox), vbox, FALSE, FALSE, 0);
+
+  grid_password = gtk_grid_new ();
+  gtk_grid_set_column_spacing (GTK_GRID (grid_password), 12);
+  gtk_grid_set_row_spacing (GTK_GRID (grid_password), 6);
+  gtk_box_pack_start (GTK_BOX (vbox), grid_password, FALSE, FALSE, 0);
+  dialog->priv->password_entry = gtk_entry_new ();
+  gtk_entry_set_visibility (GTK_ENTRY (dialog->priv->password_entry), FALSE);
+  dialog->priv->prompt_label = add_row (grid_password, 0, _("_Password:"), dialog->priv->password_entry);
+
+  g_signal_connect_swapped (dialog->priv->password_entry, "activate",
+                            G_CALLBACK (gtk_window_activate_default),
+                            dialog);
+
+  dialog->priv->grid_password = grid_password;
+  /* initially never show the password entry stuff; we'll toggle it on/off so it's
+   * only shown when prompting for a password */
+  gtk_widget_set_no_show_all (dialog->priv->grid_password, TRUE);
+
+  /* A label for showing PAM_TEXT_INFO and PAM_TEXT_ERROR messages */
+  label = gtk_label_new (NULL);
+  gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
+  gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
+  dialog->priv->info_label = label;
+
+  /* Details */
+  details_expander = gtk_expander_new_with_mnemonic (_("<small><b>_Details</b></small>"));
+  gtk_expander_set_use_markup (GTK_EXPANDER (details_expander), TRUE);
+  gtk_box_pack_start (GTK_BOX (content_area), details_expander, FALSE, FALSE, 0);
+
+  details_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 10);
+  gtk_container_add (GTK_CONTAINER (details_expander), details_vbox);
+
+  grid = gtk_grid_new ();
+  gtk_widget_set_margin_start (grid, 20);
+  gtk_grid_set_column_spacing (GTK_GRID (grid), 12);
+  gtk_grid_set_row_spacing (GTK_GRID (grid), 6);
+  gtk_box_pack_start (GTK_BOX (details_vbox), grid, FALSE, FALSE, 0);
+
+  /* TODO: sort keys? */
+  rows = 0;
+  if (dialog->priv->details != NULL)
+    {
+      guint n;
+      gchar **keys;
+
+      keys = polkit_details_get_keys (dialog->priv->details);
+      for (n = 0; keys[n] != NULL; n++)
+        {
+          const gchar *key = keys[n];
+          const gchar *value;
+
+          value = polkit_details_lookup (dialog->priv->details, key);
+
+          label = gtk_label_new (NULL);
+          s = g_strdup_printf ("<small>%s</small>", value);
+          gtk_label_set_markup (GTK_LABEL (label), s);
+          g_free (s);
+
+          gtk_label_set_xalign (GTK_LABEL (label), 0.0);
+          gtk_label_set_yalign (GTK_LABEL (label), 1.0);
+
+          s = g_strdup_printf ("<small><b>%s:</b></small>", key);
+          add_row (grid, rows, s, label);
+          g_free (s);
+
+          rows++;
+        }
+      g_strfreev (keys);
+    }
+
+  /* --- */
+
+  label = gtk_label_new (NULL);
+  gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
+  s = g_strdup_printf ("<small><a href=\"%s\">%s</a></small>",
+                       dialog->priv->action_id,
+                       dialog->priv->action_id);
+  gtk_label_set_markup (GTK_LABEL (label), s);
+  g_free (s);
+
+  gtk_label_set_xalign (GTK_LABEL (label), 0.0);
+  gtk_label_set_yalign (GTK_LABEL (label), 1.0);
+
+  add_row (grid, rows++, _("<small><b>Action:</b></small>"), label);
+  g_signal_connect (label, "activate-link", G_CALLBACK (action_id_activated), NULL);
+
+  s = g_strdup_printf (_("Click to edit %s"), dialog->priv->action_id);
+  gtk_widget_set_tooltip_markup (label, s);
+  g_free (s);
+
+  /* --- */
+
+  label = gtk_label_new (NULL);
+  gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
+  s = g_strdup_printf ("<small><a href=\"%s\">%s</a></small>",
+                       dialog->priv->vendor_url,
+                       dialog->priv->vendor);
+  gtk_label_set_markup (GTK_LABEL (label), s);
+  g_free (s);
+
+  gtk_label_set_xalign (GTK_LABEL (label), 0.0);
+  gtk_label_set_yalign (GTK_LABEL (label), 1.0);
+
+  add_row (grid, rows++, _("<small><b>Vendor:</b></small>"), label);
+
+  s = g_strdup_printf (_("Click to open %s"), dialog->priv->vendor_url);
+  gtk_widget_set_tooltip_markup (label, s);
+  g_free (s);
+
+  /* Disable password entry and authenticate until have a user selected */
+  if (have_user_combobox && gtk_combo_box_get_active (GTK_COMBO_BOX (dialog->priv->user_combobox)) == 0)
+    {
+      gtk_widget_set_sensitive (dialog->priv->prompt_label, FALSE);
+      gtk_widget_set_sensitive (dialog->priv->password_entry, FALSE);
+      gtk_widget_set_sensitive (dialog->priv->auth_button, FALSE);
+    }
+
+  gtk_widget_realize (GTK_WIDGET (dialog));
+
+}
+
+static void
+polkit_mate_authentication_dialog_class_init (PolkitMateAuthenticationDialogClass *klass)
+{
+  GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+
+  gobject_class->finalize = polkit_mate_authentication_dialog_finalize;
+  gobject_class->get_property = polkit_mate_authentication_dialog_get_property;
+  gobject_class->set_property = polkit_mate_authentication_dialog_set_property;
+  gobject_class->constructed  = polkit_mate_authentication_dialog_constructed;
+
+  g_object_class_install_property (gobject_class,
+                                   PROP_DETAILS,
+                                   g_param_spec_object ("details",
+                                                        NULL,
+                                                        NULL,
+                                                        POLKIT_TYPE_DETAILS,
+                                                        G_PARAM_READWRITE |
+                                                        G_PARAM_CONSTRUCT_ONLY |
+                                                        G_PARAM_STATIC_NAME |
+                                                        G_PARAM_STATIC_NICK |
+                                                        G_PARAM_STATIC_BLURB));
+
+  g_object_class_install_property (gobject_class,
+                                   PROP_ACTION_ID,
+                                   g_param_spec_string ("action-id",
+                                                        NULL,
+                                                        NULL,
+                                                        NULL,
+                                                        G_PARAM_READWRITE |
+                                                        G_PARAM_CONSTRUCT_ONLY |
+                                                        G_PARAM_STATIC_NAME |
+                                                        G_PARAM_STATIC_NICK |
+                                                        G_PARAM_STATIC_BLURB));
+
+  g_object_class_install_property (gobject_class,
+                                   PROP_VENDOR,
+                                   g_param_spec_string ("vendor",
+                                                        NULL,
+                                                        NULL,
+                                                        NULL,
+                                                        G_PARAM_READWRITE |
+                                                        G_PARAM_CONSTRUCT_ONLY |
+                                                        G_PARAM_STATIC_NAME |
+                                                        G_PARAM_STATIC_NICK |
+                                                        G_PARAM_STATIC_BLURB));
+
+  g_object_class_install_property (gobject_class,
+                                   PROP_VENDOR_URL,
+                                   g_param_spec_string ("vendor-url",
+                                                        NULL,
+                                                        NULL,
+                                                        NULL,
+                                                        G_PARAM_READWRITE |
+                                                        G_PARAM_CONSTRUCT_ONLY |
+                                                        G_PARAM_STATIC_NAME |
+                                                        G_PARAM_STATIC_NICK |
+                                                        G_PARAM_STATIC_BLURB));
+
+  g_object_class_install_property (gobject_class,
+                                   PROP_ICON_NAME,
+                                   g_param_spec_string ("icon-name",
+                                                        NULL,
+                                                        NULL,
+                                                        NULL,
+                                                        G_PARAM_READWRITE |
+                                                        G_PARAM_CONSTRUCT_ONLY |
+                                                        G_PARAM_STATIC_NAME |
+                                                        G_PARAM_STATIC_NICK |
+                                                        G_PARAM_STATIC_BLURB));
+
+  g_object_class_install_property (gobject_class,
+                                   PROP_MESSAGE,
+                                   g_param_spec_string ("message",
+                                                        NULL,
+                                                        NULL,
+                                                        NULL,
+                                                        G_PARAM_READWRITE |
+                                                        G_PARAM_CONSTRUCT_ONLY |
+                                                        G_PARAM_STATIC_NAME |
+                                                        G_PARAM_STATIC_NICK |
+                                                        G_PARAM_STATIC_BLURB));
+
+  g_object_class_install_property (gobject_class,
+                                   PROP_USERS,
+                                   g_param_spec_boxed ("users",
+                                                       NULL,
+                                                       NULL,
+                                                       G_TYPE_STRV,
+                                                       G_PARAM_READWRITE |
+                                                       G_PARAM_CONSTRUCT_ONLY |
+                                                       G_PARAM_STATIC_NAME |
+                                                       G_PARAM_STATIC_NICK |
+                                                       G_PARAM_STATIC_BLURB));
+
+  g_object_class_install_property (gobject_class,
+                                   PROP_SELECTED_USER,
+                                   g_param_spec_string ("selected-user",
+                                                        NULL,
+                                                        NULL,
+                                                        NULL,
+                                                        G_PARAM_READABLE |
+                                                        G_PARAM_STATIC_NAME |
+                                                        G_PARAM_STATIC_NICK |
+                                                        G_PARAM_STATIC_BLURB));
+}
+
+/**
+ * polkit_mate_authentication_dialog_new:
+ *
+ * Yada yada yada...
+ *
+ * Returns: A new password dialog.
+ **/
+GtkWidget *
+polkit_mate_authentication_dialog_new (const gchar    *action_id,
+                                        const gchar    *vendor,
+                                        const gchar    *vendor_url,
+                                        const gchar    *icon_name,
+                                        const gchar    *message_markup,
+                                        PolkitDetails  *details,
+                                        gchar         **users)
+{
+  PolkitMateAuthenticationDialog *dialog;
+  GtkWindow *window;
+
+  dialog = g_object_new (POLKIT_MATE_TYPE_AUTHENTICATION_DIALOG,
+                         "action-id", action_id,
+                         "vendor", vendor,
+                         "vendor-url", vendor_url,
+                         "icon-name", icon_name,
+                         "message", message_markup,
+                         "details", details,
+                         "users", users,
+                         NULL);
+
+  window = GTK_WINDOW (dialog);
+
+  gtk_window_set_position (window, GTK_WIN_POS_CENTER);
+  gtk_window_set_modal (window, TRUE);
+  gtk_window_set_resizable (window, FALSE);
+  gtk_window_set_keep_above (window, TRUE);
+  gtk_window_set_title (window, _("Authenticate"));
+  g_signal_connect (dialog, "close", G_CALLBACK (gtk_widget_hide), NULL);
+
+  return GTK_WIDGET (dialog);
+}
+
+/**
+ * polkit_mate_authentication_dialog_indicate_error:
+ * @dialog: the auth dialog
+ *
+ * Call this function to indicate an authentication error; typically shakes the window
+ **/
+void
+polkit_mate_authentication_dialog_indicate_error (PolkitMateAuthenticationDialog *dialog)
+{
+  int x, y;
+  int n;
+  int diff;
+
+  /* TODO: detect compositing manager and do fancy stuff here */
+
+  gtk_window_get_position (GTK_WINDOW (dialog), &x, &y);
+
+  for (n = 0; n < 10; n++)
+    {
+      if (n % 2 == 0)
+        diff = -15;
+      else
+        diff = 15;
+
+      gtk_window_move (GTK_WINDOW (dialog), x + diff, y);
+
+      while (gtk_events_pending ())
+        {
+          gtk_main_iteration ();
+        }
+
+      g_usleep (10000);
+    }
+
+  gtk_window_move (GTK_WINDOW (dialog), x, y);
+}
+
+/**
+ * polkit_mate_authentication_dialog_run_until_user_is_selected:
+ * @dialog: A #PolkitMateAuthenticationDialog.
+ *
+ * Runs @dialog in a recursive main loop until a user have been selected.
+ *
+ * If there is only one element in the the users array (which is set upon construction) or
+ * an user has already been selected, this function returns immediately with the return
+ * value %TRUE.
+ *
+ * Returns: %TRUE if a user is selected (use polkit_mate_dialog_get_selected_user() to obtain the user) or
+ *          %FALSE if the dialog was cancelled.
+ **/
+gboolean
+polkit_mate_authentication_dialog_run_until_user_is_selected (PolkitMateAuthenticationDialog *dialog)
+{
+  gboolean ret;
+  gint response;
+
+  ret = FALSE;
+
+  if (dialog->priv->selected_user != NULL)
+    {
+      ret = TRUE;
+      goto out;
+    }
+
+  dialog->priv->is_running = TRUE;
+
+  response = gtk_dialog_run (GTK_DIALOG (dialog));
+
+  dialog->priv->is_running = FALSE;
+
+  if (response == RESPONSE_USER_SELECTED)
+    ret = TRUE;
+
+ out:
+  return ret;
+}
+
+/**
+ * polkit_mate_authentication_dialog_run_until_response_for_prompt:
+ * @dialog: A #PolkitMateAuthenticationDialog.
+ * @prompt: The prompt to present the user with.
+ * @echo_chars: Whether characters should be echoed in the password entry box.
+ * @was_cancelled: Set to %TRUE if the dialog was cancelled.
+ * @new_user_selected: Set to %TRUE if another user was selected.
+ *
+ * Runs @dialog in a recursive main loop until a response to @prompt have been obtained from the user.
+ *
+ * Returns: The response (free with g_free()) or %NULL if one of @was_cancelled or @new_user_selected
+ *          has been set to %TRUE.
+ **/
+gchar *
+polkit_mate_authentication_dialog_run_until_response_for_prompt (PolkitMateAuthenticationDialog *dialog,
+                                                                  const gchar           *prompt,
+                                                                  gboolean               echo_chars,
+                                                                  gboolean              *was_cancelled,
+                                                                  gboolean              *new_user_selected)
+{
+  gint response;
+  gchar *ret;
+
+  gtk_label_set_text_with_mnemonic (GTK_LABEL (dialog->priv->prompt_label), prompt);
+  gtk_entry_set_visibility (GTK_ENTRY (dialog->priv->password_entry), echo_chars);
+  gtk_entry_set_text (GTK_ENTRY (dialog->priv->password_entry), "");
+  gtk_widget_grab_focus (dialog->priv->password_entry);
+
+  ret = NULL;
+
+  if (was_cancelled != NULL)
+    *was_cancelled = FALSE;
+
+  if (new_user_selected != NULL)
+    *new_user_selected = FALSE;
+
+  dialog->priv->is_running = TRUE;
+
+  gtk_widget_set_no_show_all (dialog->priv->grid_password, FALSE);
+  gtk_widget_show_all (dialog->priv->grid_password);
+
+  response = gtk_dialog_run (GTK_DIALOG (dialog));
+
+  gtk_widget_hide (dialog->priv->grid_password);
+  gtk_widget_set_no_show_all (dialog->priv->grid_password, TRUE);
+
+  dialog->priv->is_running = FALSE;
+
+  if (response == GTK_RESPONSE_OK)
+    {
+      ret = g_strdup (gtk_entry_get_text (GTK_ENTRY (dialog->priv->password_entry)));
+    }
+  else if (response == RESPONSE_USER_SELECTED)
+    {
+      if (new_user_selected != NULL)
+        *new_user_selected = TRUE;
+    }
+  else
+    {
+      if (was_cancelled != NULL)
+        *was_cancelled = TRUE;
+    }
+
+  return ret;
+}
+
+/**
+ * polkit_mate_authentication_dialog_get_selected_user:
+ * @dialog: A #PolkitMateAuthenticationDialog.
+ *
+ * Gets the currently selected user.
+ *
+ * Returns: The currently selected user (free with g_free()) or %NULL if no user is currently selected.
+ **/
+gchar *
+polkit_mate_authentication_dialog_get_selected_user (PolkitMateAuthenticationDialog *dialog)
+{
+  return g_strdup (dialog->priv->selected_user);
+}
+
+void
+polkit_mate_authentication_dialog_set_info_message (PolkitMateAuthenticationDialog *dialog,
+                                                     const gchar                     *info_markup)
+{
+  gtk_label_set_markup (GTK_LABEL (dialog->priv->info_label), info_markup);
+}
+
+/**
+ * polkit_mate_authentication_dialog_cancel:
+ * @dialog: A #PolkitMateAuthenticationDialog.
+ *
+ * Cancels the dialog if it is currenlty running.
+ *
+ * Returns: %TRUE if the dialog was running.
+ **/
+gboolean
+polkit_mate_authentication_dialog_cancel (PolkitMateAuthenticationDialog *dialog)
+{
+  if (!dialog->priv->is_running)
+    return FALSE;
+
+  gtk_dialog_response (GTK_DIALOG (dialog), GTK_RESPONSE_CANCEL);
+
+  return TRUE;
+}
+
+ +
+ +
+ + diff --git a/2024-02-26-105642-9744-cppcheck@c2df8de7c7b1_v1.28.1/3.html b/2024-02-26-105642-9744-cppcheck@c2df8de7c7b1_v1.28.1/3.html new file mode 100644 index 0000000..6ad06dd --- /dev/null +++ b/2024-02-26-105642-9744-cppcheck@c2df8de7c7b1_v1.28.1/3.html @@ -0,0 +1,393 @@ + + + + + + Cppcheck - HTML report - mate-polkit + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
+78
/*
+ * Copyright (C) 2009 Red Hat, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ * Author: David Zeuthen <davidz@redhat.com>
+ */
+
+#ifndef __POLKIT_MATE_AUTHENTICATION_DIALOG_H
+#define __POLKIT_MATE_AUTHENTICATION_DIALOG_H
+
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <polkit/polkit.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define POLKIT_MATE_TYPE_AUTHENTICATION_DIALOG            (polkit_mate_authentication_dialog_get_type ())
+#define POLKIT_MATE_AUTHENTICATION_DIALOG(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), POLKIT_MATE_TYPE_AUTHENTICATION_DIALOG, PolkitMateAuthenticationDialog))
+#define POLKIT_MATE_AUTHENTICATION_DIALOG_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), POLKIT_MATE_TYPE_AUTHENTICATION_DIALOG, PolkitMateAuthenticationDialogClass))
+#define POLKIT_MATE_IS_AUTHENTICATION_DIALOG(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), POLKIT_MATE_TYPE_AUTHENTICATION_DIALOG))
+#define POLKIT_MATE_IS_AUTHENTICATION_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), POLKIT_MATE_TYPE_AUTHENTICATION_DIALOG))
+
+typedef struct _PolkitMateAuthenticationDialog        PolkitMateAuthenticationDialog;
+typedef struct _PolkitMateAuthenticationDialogClass   PolkitMateAuthenticationDialogClass;
+typedef struct _PolkitMateAuthenticationDialogPrivate PolkitMateAuthenticationDialogPrivate;
+
+struct _PolkitMateAuthenticationDialog
+{
+  GtkDialog parent_instance;
+  PolkitMateAuthenticationDialogPrivate *priv;
+};
+
+struct _PolkitMateAuthenticationDialogClass
+{
+  GtkDialogClass parent_class;
+};
+
+GType      polkit_mate_authentication_dialog_get_type                      (void);
+GtkWidget *polkit_mate_authentication_dialog_new                           (const gchar    *action_id,
+                                                                             const gchar    *vendor,
+                                                                             const gchar    *vendor_url,
+                                                                             const gchar    *icon_name,
+                                                                             const gchar    *message_markup,
+                                                                             PolkitDetails  *details,
+                                                                             gchar         **users);
+gchar     *polkit_mate_authentication_dialog_get_selected_user             (PolkitMateAuthenticationDialog *dialog);
+gboolean   polkit_mate_authentication_dialog_run_until_user_is_selected    (PolkitMateAuthenticationDialog *dialog);
+gchar     *polkit_mate_authentication_dialog_run_until_response_for_prompt (PolkitMateAuthenticationDialog *dialog,
+                                                                             const gchar                     *prompt,
+                                                                             gboolean                         echo_chars,
+                                                                             gboolean                        *was_cancelled,
+                                                                             gboolean                        *new_user_selected);
+gboolean   polkit_mate_authentication_dialog_cancel                        (PolkitMateAuthenticationDialog *dialog);
+void       polkit_mate_authentication_dialog_indicate_error                (PolkitMateAuthenticationDialog *dialog);
+void       polkit_mate_authentication_dialog_set_info_message              (PolkitMateAuthenticationDialog *dialog,
+                                                                             const gchar                     *info_markup);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __POLKIT_MATE_AUTHENTICATION_DIALOG_H */
+
+ +
+ +
+ + diff --git a/2024-02-26-105642-9744-cppcheck@c2df8de7c7b1_v1.28.1/4.html b/2024-02-26-105642-9744-cppcheck@c2df8de7c7b1_v1.28.1/4.html new file mode 100644 index 0000000..67c8d37 --- /dev/null +++ b/2024-02-26-105642-9744-cppcheck@c2df8de7c7b1_v1.28.1/4.html @@ -0,0 +1,1269 @@ + + + + + + Cppcheck - HTML report - mate-polkit + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
/*
+ * Copyright (C) 2009 Red Hat, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ * Author: David Zeuthen <davidz@redhat.com>
+ */
+
+#include "config.h"<--- Include file: "config.h" not found.
+
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/types.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <pwd.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gdk/gdkx.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <polkit/polkit.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <polkitagent/polkitagent.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "polkitmateauthenticator.h"
+#include "polkitmateauthenticationdialog.h"
+
+struct _PolkitMateAuthenticator
+{
+  GObject parent_instance;
+
+  PolkitAuthority *authority;
+  gchar *action_id;
+  gchar *message;
+  gchar *icon_name;
+  PolkitDetails *details;
+  gchar *cookie;
+  GList *identities;
+
+  PolkitActionDescription *action_desc;
+  gchar **users;
+
+  gboolean gained_authorization;
+  gboolean was_cancelled;
+  gboolean new_user_selected;
+  gchar *selected_user;
+
+  PolkitAgentSession *session;
+  GtkWidget *dialog;
+  GMainLoop *loop;
+};
+
+struct _PolkitMateAuthenticatorClass
+{
+  GObjectClass parent_class;
+
+};
+
+enum
+{
+  COMPLETED_SIGNAL,
+  LAST_SIGNAL,
+};
+
+static guint signals[LAST_SIGNAL] = {0};
+
+G_DEFINE_TYPE (PolkitMateAuthenticator, polkit_mate_authenticator, G_TYPE_OBJECT);
+
+static void
+polkit_mate_authenticator_init (PolkitMateAuthenticator *authenticator)
+{
+}
+
+static void
+polkit_mate_authenticator_finalize (GObject *object)
+{
+  PolkitMateAuthenticator *authenticator;
+
+  authenticator = POLKIT_MATE_AUTHENTICATOR (object);
+
+  if (authenticator->authority != NULL)
+    g_object_unref (authenticator->authority);
+  g_free (authenticator->action_id);
+  g_free (authenticator->message);
+  g_free (authenticator->icon_name);
+  if (authenticator->details != NULL)
+    g_object_unref (authenticator->details);
+  g_free (authenticator->cookie);
+  g_list_foreach (authenticator->identities, (GFunc) g_object_unref, NULL);
+  g_list_free (authenticator->identities);
+
+  if (authenticator->action_desc != NULL)
+    g_object_unref (authenticator->action_desc);
+  g_strfreev (authenticator->users);
+
+  g_free (authenticator->selected_user);
+  if (authenticator->session != NULL)
+    g_object_unref (authenticator->session);
+  if (authenticator->dialog != NULL)
+    gtk_widget_destroy (authenticator->dialog);
+  if (authenticator->loop != NULL)
+    g_main_loop_unref (authenticator->loop);
+
+  if (G_OBJECT_CLASS (polkit_mate_authenticator_parent_class)->finalize != NULL)
+    G_OBJECT_CLASS (polkit_mate_authenticator_parent_class)->finalize (object);
+}
+
+static void
+polkit_mate_authenticator_class_init (PolkitMateAuthenticatorClass *klass)
+{
+  GObjectClass *gobject_class;
+
+  gobject_class = G_OBJECT_CLASS (klass);
+
+  gobject_class->finalize = polkit_mate_authenticator_finalize;
+
+  /**
+   * PolkitMateAuthenticator::completed:
+   * @authenticator: A #PolkitMateAuthenticator.
+   * @gained_authorization: Whether the authorization was gained.
+   * @dismissed: Whether the dialog was dismissed.
+   *
+   * Emitted when the authentication is completed. The user is supposed to dispose of @authenticator
+   * upon receiving this signal.
+   **/
+  signals[COMPLETED_SIGNAL] = g_signal_new ("completed",
+                                            POLKIT_MATE_TYPE_AUTHENTICATOR,
+                                            G_SIGNAL_RUN_LAST,
+                                            0,                      /* class offset     */
+                                            NULL,                   /* accumulator      */
+                                            NULL,                   /* accumulator data */
+                                            g_cclosure_marshal_generic,
+                                            G_TYPE_NONE,
+                                            2,
+					    G_TYPE_BOOLEAN,
+                                            G_TYPE_BOOLEAN);
+}
+
+static PolkitActionDescription *
+get_desc_for_action (PolkitAuthority *authority,
+                     const gchar     *action_id)
+{
+  GList *action_descs;
+  GList *l;
+  PolkitActionDescription *result;
+
+  result = NULL;
+
+  action_descs = polkit_authority_enumerate_actions_sync (authority,
+                                                          NULL,
+                                                          NULL);
+  for (l = action_descs; l != NULL; l = l->next)
+    {
+      PolkitActionDescription *action_desc = POLKIT_ACTION_DESCRIPTION (l->data);
+
+      if (strcmp (polkit_action_description_get_action_id (action_desc), action_id) == 0)
+        {
+          result = g_object_ref (action_desc);
+          goto out;
+        }
+    }
+
+ out:
+
+  g_list_foreach (action_descs, (GFunc) g_object_unref, NULL);
+  g_list_free (action_descs);
+
+  return result;
+}
+
+static void
+on_dialog_deleted (GtkWidget *widget,
+                   GdkEvent  *event,
+                   gpointer   user_data)
+{
+  PolkitMateAuthenticator *authenticator = POLKIT_MATE_AUTHENTICATOR (user_data);
+
+  polkit_mate_authenticator_cancel (authenticator);
+}
+
+static void
+on_user_selected (GObject    *object,
+                  GParamSpec *pspec,
+                  gpointer    user_data)
+{
+  PolkitMateAuthenticator *authenticator = POLKIT_MATE_AUTHENTICATOR (user_data);
+
+  /* clear any previous messages */
+  polkit_mate_authentication_dialog_set_info_message (POLKIT_MATE_AUTHENTICATION_DIALOG (authenticator->dialog), "");
+
+  polkit_mate_authenticator_cancel (authenticator);
+  authenticator->new_user_selected = TRUE;
+}
+
+PolkitMateAuthenticator *
+polkit_mate_authenticator_new (const gchar     *action_id,
+                                const gchar     *message,
+                                const gchar     *icon_name,
+                                PolkitDetails   *details,
+                                const gchar     *cookie,
+                                GList           *identities)
+{
+  PolkitMateAuthenticator *authenticator;
+  GList *l;
+  guint n;
+  GError *error;
+
+  authenticator = POLKIT_MATE_AUTHENTICATOR (g_object_new (POLKIT_MATE_TYPE_AUTHENTICATOR, NULL));
+
+  error = NULL;
+  authenticator->authority = polkit_authority_get_sync (NULL /* GCancellable* */, &error);
+  if (authenticator->authority == NULL)
+    {
+      g_critical ("Error getting authority: %s", error->message);
+      g_error_free (error);
+      goto error;
+    }
+
+  authenticator->action_id = g_strdup (action_id);
+  authenticator->message = g_strdup (message);
+  authenticator->icon_name = g_strdup (icon_name);
+  if (details != NULL)
+    authenticator->details = g_object_ref (details);
+  authenticator->cookie = g_strdup (cookie);
+  authenticator->identities = g_list_copy (identities);
+  g_list_foreach (authenticator->identities, (GFunc) g_object_ref, NULL);
+
+  authenticator->action_desc = get_desc_for_action (authenticator->authority,
+                                                    authenticator->action_id);
+  if (authenticator->action_desc == NULL)
+    goto error;
+
+  authenticator->users = g_new0 (gchar *, g_list_length (authenticator->identities) + 1);
+  for (l = authenticator->identities, n = 0; l != NULL; l = l->next, n++)
+    {
+      PolkitUnixUser *user = POLKIT_UNIX_USER (l->data);
+      uid_t uid;
+      struct passwd *passwd;
+
+      uid = polkit_unix_user_get_uid (user);
+      passwd = getpwuid (uid);
+      authenticator->users[n] = g_strdup (passwd->pw_name);
+    }
+
+  authenticator->dialog = polkit_mate_authentication_dialog_new
+                            (authenticator->action_id,
+                             polkit_action_description_get_vendor_name (authenticator->action_desc),
+                             polkit_action_description_get_vendor_url (authenticator->action_desc),
+                             authenticator->icon_name,
+                             authenticator->message,
+                             authenticator->details,
+                             authenticator->users);
+  g_signal_connect (authenticator->dialog,
+                    "delete-event",
+                    G_CALLBACK (on_dialog_deleted),
+                    authenticator);
+  g_signal_connect (authenticator->dialog,
+                    "notify::selected-user",
+                    G_CALLBACK (on_user_selected),
+                    authenticator);
+
+  return authenticator;
+
+ error:
+  g_object_unref (authenticator);
+  return NULL;
+}
+
+static void
+session_request (PolkitAgentSession *session,
+                 const char         *request,
+                 gboolean            echo_on,
+                 gpointer            user_data)
+{
+  PolkitMateAuthenticator *authenticator = POLKIT_MATE_AUTHENTICATOR (user_data);
+  gchar *password;
+  gchar *modified_request;
+
+  password = NULL;
+
+  //g_debug ("in conversation_pam_prompt, request='%s', echo_on=%d", request, echo_on);
+
+  /* Fix up, and localize, password prompt if it's password auth */
+  if (g_ascii_strncasecmp (request, "password:", 9) == 0)
+    {
+      if (strcmp (g_get_user_name (), authenticator->selected_user) != 0)
+        {
+          modified_request = g_strdup_printf (_("_Password for %s:"), authenticator->selected_user);
+        }
+      else
+        {
+          modified_request = g_strdup (_("_Password:"));
+        }
+    }
+  else
+    {
+      modified_request = g_strdup (request);
+    }
+
+  gtk_widget_show_all (GTK_WIDGET (authenticator->dialog));
+  if (GDK_IS_X11_WINDOW (gtk_widget_get_window (GTK_WIDGET (authenticator->dialog))))
+    gtk_window_present_with_time (GTK_WINDOW (authenticator->dialog),
+                                  gdk_x11_get_server_time (gtk_widget_get_window (GTK_WIDGET (authenticator->dialog))));
+  else
+    gtk_window_present (GTK_WINDOW (authenticator->dialog));
+
+  password = polkit_mate_authentication_dialog_run_until_response_for_prompt (POLKIT_MATE_AUTHENTICATION_DIALOG (authenticator->dialog),
+                                                                               modified_request,
+                                                                               echo_on,
+                                                                               &authenticator->was_cancelled,
+                                                                               &authenticator->new_user_selected);
+
+  /* cancel auth unless user provided a password */
+  if (password == NULL)
+    {
+      polkit_mate_authenticator_cancel (authenticator);
+      goto out;
+    }
+  else
+    {
+      polkit_agent_session_response (authenticator->session, password);
+      g_free (password);
+    }
+
+out:
+  g_free (modified_request);
+}
+
+static void
+session_show_error (PolkitAgentSession *session,
+                    const gchar        *msg,
+                    gpointer            user_data)
+{
+  PolkitMateAuthenticator *authenticator = POLKIT_MATE_AUTHENTICATOR (user_data);
+  gchar *s;
+
+  s = g_strconcat ("<b>", msg, "</b>", NULL);
+  polkit_mate_authentication_dialog_set_info_message (POLKIT_MATE_AUTHENTICATION_DIALOG (authenticator->dialog), s);
+  g_free (s);
+}
+
+static void
+session_show_info (PolkitAgentSession *session,
+                   const gchar        *msg,
+                   gpointer            user_data)
+{
+  PolkitMateAuthenticator *authenticator = POLKIT_MATE_AUTHENTICATOR (user_data);
+  gchar *s;
+
+  s = g_strconcat ("<b>", msg, "</b>", NULL);
+  polkit_mate_authentication_dialog_set_info_message (POLKIT_MATE_AUTHENTICATION_DIALOG (authenticator->dialog), s);
+  g_free (s);
+
+  gtk_widget_show_all (GTK_WIDGET (authenticator->dialog));
+  gtk_window_present (GTK_WINDOW (authenticator->dialog));
+}
+
+static void
+session_completed (PolkitAgentSession *session,
+                   gboolean            gained_authorization,
+                   gpointer            user_data)
+{
+  PolkitMateAuthenticator *authenticator = POLKIT_MATE_AUTHENTICATOR (user_data);
+
+  authenticator->gained_authorization = gained_authorization;
+
+  //g_debug ("in conversation_done gained=%d", gained_authorization);
+
+  g_main_loop_quit (authenticator->loop);
+}
+
+static gboolean
+do_initiate (gpointer user_data)
+{
+  PolkitMateAuthenticator *authenticator = POLKIT_MATE_AUTHENTICATOR (user_data);
+  PolkitIdentity *identity;
+  gint num_tries;
+
+  gtk_widget_show_all (GTK_WIDGET (authenticator->dialog));
+  gtk_window_present (GTK_WINDOW (authenticator->dialog));
+  if (!polkit_mate_authentication_dialog_run_until_user_is_selected (POLKIT_MATE_AUTHENTICATION_DIALOG (authenticator->dialog)))
+    {
+      /* user cancelled the dialog */
+      /*g_debug ("User cancelled before selecting a user");*/
+      authenticator->was_cancelled = TRUE;
+      goto out;
+    }
+
+  authenticator->loop = g_main_loop_new (NULL, TRUE);
+
+  num_tries = 0;
+
+ try_again:
+
+  g_free (authenticator->selected_user);
+  authenticator->selected_user = polkit_mate_authentication_dialog_get_selected_user (POLKIT_MATE_AUTHENTICATION_DIALOG (authenticator->dialog));
+
+  /*g_debug ("Authenticating user %s", authenticator->selected_user);*/
+  identity = polkit_unix_user_new_for_name (authenticator->selected_user, NULL);
+
+  authenticator->session = polkit_agent_session_new (identity, authenticator->cookie);
+
+  g_object_unref (identity);
+
+  g_signal_connect (authenticator->session,
+                    "request",
+                    G_CALLBACK (session_request),
+                    authenticator);
+
+  g_signal_connect (authenticator->session,
+                    "show-info",
+                    G_CALLBACK (session_show_info),
+                    authenticator);
+
+  g_signal_connect (authenticator->session,
+                    "show-error",
+                    G_CALLBACK (session_show_error),
+                    authenticator);
+
+  g_signal_connect (authenticator->session,
+                    "completed",
+                    G_CALLBACK (session_completed),
+                    authenticator);
+
+  polkit_agent_session_initiate (authenticator->session);
+
+  g_main_loop_run (authenticator->loop);
+
+  /*g_debug ("gained_authorization=%d was_cancelled=%d new_user_selected=%d.",
+           authenticator->gained_authorization,
+           authenticator->was_cancelled,
+           authenticator->new_user_selected);*/
+
+  if (authenticator->new_user_selected)
+    {
+      /*g_debug ("New user selected");*/
+      authenticator->new_user_selected = FALSE;
+      g_object_unref (authenticator->session);
+      authenticator->session = NULL;
+      goto try_again;
+    }
+
+  num_tries++;
+
+  if (!authenticator->gained_authorization && !authenticator->was_cancelled)
+    {
+      if (authenticator->dialog != NULL)
+        {
+          gchar *s;
+
+          s = g_strconcat ("<b>", _("Your authentication attempt was unsuccessful. Please try again."), "</b>", NULL);
+          polkit_mate_authentication_dialog_set_info_message (
+                                  POLKIT_MATE_AUTHENTICATION_DIALOG (authenticator->dialog),
+                                  s);
+          g_free (s);
+          gtk_widget_queue_draw (authenticator->dialog);
+
+          /* shake the dialog to indicate error */
+          polkit_mate_authentication_dialog_indicate_error (POLKIT_MATE_AUTHENTICATION_DIALOG (authenticator->dialog));
+
+          if (num_tries < 3)
+            {
+              g_object_unref (authenticator->session);
+              authenticator->session = NULL;
+              goto try_again;
+            }
+        }
+    }
+
+ out:
+  g_signal_emit_by_name (authenticator,
+                         "completed",
+                         authenticator->gained_authorization,
+                         authenticator->was_cancelled);
+
+  g_object_unref (authenticator);
+
+  return FALSE;
+}
+
+void
+polkit_mate_authenticator_initiate (PolkitMateAuthenticator *authenticator)
+{
+  /* run from idle since we're going to block the main loop in the dialog (which has a recursive mainloop) */
+  g_idle_add (do_initiate, g_object_ref (authenticator));
+}
+
+void
+polkit_mate_authenticator_cancel (PolkitMateAuthenticator *authenticator)
+{
+  if (authenticator->dialog != NULL)
+    polkit_mate_authentication_dialog_cancel (POLKIT_MATE_AUTHENTICATION_DIALOG (authenticator->dialog));
+
+  authenticator->was_cancelled = TRUE;
+
+  if (authenticator->session != NULL)
+    {
+      polkit_agent_session_cancel (authenticator->session);
+    }
+}
+
+const gchar *
+polkit_mate_authenticator_get_cookie (PolkitMateAuthenticator *authenticator)<--- Parameter 'authenticator' can be declared as pointer to const
+{
+  return authenticator->cookie;
+}
+
+
+ +
+ +
+ + diff --git a/2024-02-26-105642-9744-cppcheck@c2df8de7c7b1_v1.28.1/5.html b/2024-02-26-105642-9744-cppcheck@c2df8de7c7b1_v1.28.1/5.html new file mode 100644 index 0000000..b1c66d2 --- /dev/null +++ b/2024-02-26-105642-9744-cppcheck@c2df8de7c7b1_v1.28.1/5.html @@ -0,0 +1,351 @@ + + + + + + Cppcheck - HTML report - mate-polkit + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
/*
+ * Copyright (C) 2009 Red Hat, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ * Author: David Zeuthen <davidz@redhat.com>
+ */
+
+#ifndef __POLKIT_MATE_AUTHENTICATOR_H
+#define __POLKIT_MATE_AUTHENTICATOR_H
+
+#include <glib-object.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define POLKIT_MATE_TYPE_AUTHENTICATOR          (polkit_mate_authenticator_get_type())
+#define POLKIT_MATE_AUTHENTICATOR(o)            (G_TYPE_CHECK_INSTANCE_CAST ((o), POLKIT_MATE_TYPE_AUTHENTICATOR, PolkitMateAuthenticator))
+#define POLKIT_MATE_AUTHENTICATOR_CLASS(k)      (G_TYPE_CHECK_CLASS_CAST((k), POLKIT_MATE_TYPE_AUTHENTICATOR, PolkitMateAuthenticatorClass))
+#define POLKIT_MATE_AUTHENTICATOR_GET_CLASS(o)  (G_TYPE_INSTANCE_GET_CLASS ((o), POLKIT_MATE_TYPE_AUTHENTICATOR, PolkitMateAuthenticatorClass))
+#define POLKIT_MATE_IS_AUTHENTICATOR(o)         (G_TYPE_CHECK_INSTANCE_TYPE ((o), POLKIT_MATE_TYPE_AUTHENTICATOR))
+#define POLKIT_MATE_IS_AUTHENTICATOR_CLASS(k)   (G_TYPE_CHECK_CLASS_TYPE ((k), POLKIT_MATE_TYPE_AUTHENTICATOR))
+
+typedef struct _PolkitMateAuthenticator PolkitMateAuthenticator;
+typedef struct _PolkitMateAuthenticatorClass PolkitMateAuthenticatorClass;
+
+GType                      polkit_mate_authenticator_get_type   (void) G_GNUC_CONST;
+PolkitMateAuthenticator  *polkit_mate_authenticator_new        (const gchar              *action_id,
+                                                                  const gchar              *message,
+                                                                  const gchar              *icon_name,
+                                                                  PolkitDetails            *details,
+                                                                  const gchar              *cookie,
+                                                                  GList                    *identities);
+void                       polkit_mate_authenticator_initiate   (PolkitMateAuthenticator *authenticator);
+void                       polkit_mate_authenticator_cancel     (PolkitMateAuthenticator *authenticator);
+const gchar               *polkit_mate_authenticator_get_cookie (PolkitMateAuthenticator *authenticator);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __POLKIT_MATE_AUTHENTICATOR_H */
+
+ +
+ +
+ + diff --git a/2024-02-26-105642-9744-cppcheck@c2df8de7c7b1_v1.28.1/6.html b/2024-02-26-105642-9744-cppcheck@c2df8de7c7b1_v1.28.1/6.html new file mode 100644 index 0000000..79a947d --- /dev/null +++ b/2024-02-26-105642-9744-cppcheck@c2df8de7c7b1_v1.28.1/6.html @@ -0,0 +1,761 @@ + + + + + + Cppcheck - HTML report - mate-polkit + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
/*
+ * Copyright (C) 2009 Red Hat, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ * Author: David Zeuthen <davidz@redhat.com>
+ */
+
+#include "config.h"<--- Include file: "config.h" not found.
+
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "polkitmatelistener.h"
+#include "polkitmateauthenticator.h"
+
+struct _PolkitMateListener
+{
+  PolkitAgentListener parent_instance;
+
+  /* we support multiple authenticators - they are simply queued up */
+  GList *authenticators;
+
+  PolkitMateAuthenticator *active_authenticator;
+};
+
+struct _PolkitMateListenerClass
+{
+  PolkitAgentListenerClass parent_class;
+};
+
+static void polkit_mate_listener_initiate_authentication (PolkitAgentListener  *listener,
+                                                           const gchar          *action_id,
+                                                           const gchar          *message,
+                                                           const gchar          *icon_name,
+                                                           PolkitDetails        *details,
+                                                           const gchar          *cookie,
+                                                           GList                *identities,
+                                                           GCancellable         *cancellable,
+                                                           GAsyncReadyCallback   callback,
+                                                           gpointer              user_data);
+
+static gboolean polkit_mate_listener_initiate_authentication_finish (PolkitAgentListener  *listener,
+                                                                      GAsyncResult         *res,
+                                                                      GError              **error);
+
+G_DEFINE_TYPE (PolkitMateListener, polkit_mate_listener, POLKIT_AGENT_TYPE_LISTENER);
+
+static void
+polkit_mate_listener_init (PolkitMateListener *listener)
+{
+}
+
+static void
+polkit_mate_listener_finalize (GObject *object)
+{
+  if (G_OBJECT_CLASS (polkit_mate_listener_parent_class)->finalize != NULL)
+    G_OBJECT_CLASS (polkit_mate_listener_parent_class)->finalize (object);
+}
+
+static void
+polkit_mate_listener_class_init (PolkitMateListenerClass *klass)
+{
+  GObjectClass *gobject_class;
+  PolkitAgentListenerClass *listener_class;
+
+  gobject_class = G_OBJECT_CLASS (klass);
+  listener_class = POLKIT_AGENT_LISTENER_CLASS (klass);
+
+  gobject_class->finalize = polkit_mate_listener_finalize;
+
+  listener_class->initiate_authentication          = polkit_mate_listener_initiate_authentication;
+  listener_class->initiate_authentication_finish   = polkit_mate_listener_initiate_authentication_finish;
+}
+
+PolkitAgentListener *
+polkit_mate_listener_new (void)
+{
+  return POLKIT_AGENT_LISTENER (g_object_new (POLKIT_MATE_TYPE_LISTENER, NULL));
+}
+
+typedef struct
+{
+  PolkitMateListener *listener;
+  PolkitMateAuthenticator *authenticator;
+
+  GTask        *task;
+  GCancellable *cancellable;
+
+  gulong cancel_id;
+} AuthData;
+
+static AuthData *
+auth_data_new (PolkitMateListener *listener,
+               PolkitMateAuthenticator *authenticator,
+               GTask *task,
+               GCancellable *cancellable)
+{
+  AuthData *data;
+
+  data = g_new0 (AuthData, 1);
+  data->listener = g_object_ref (listener);
+  data->authenticator = g_object_ref (authenticator);
+  data->task = g_object_ref (task);
+  data->cancellable = g_object_ref (cancellable);
+  return data;
+}
+
+static void
+auth_data_free (AuthData *data)
+{
+  g_object_unref (data->listener);
+  g_object_unref (data->authenticator);
+  g_object_unref (data->task);
+  if (data->cancellable != NULL && data->cancel_id > 0)
+    g_signal_handler_disconnect (data->cancellable, data->cancel_id);
+  g_object_unref (data->cancellable);
+  g_free (data);
+}
+
+static void
+maybe_initiate_next_authenticator (PolkitMateListener *listener)
+{
+  if (listener->active_authenticator == NULL && listener->authenticators != NULL)
+    {
+      polkit_mate_authenticator_initiate (POLKIT_MATE_AUTHENTICATOR (listener->authenticators->data));
+      listener->active_authenticator = listener->authenticators->data;
+    }
+}
+
+static void
+authenticator_completed (PolkitMateAuthenticator *authenticator,
+                         gboolean                 gained_authorization,
+                         gboolean                 dismissed,
+                         gpointer                 user_data)
+{
+  AuthData *data = user_data;
+
+  data->listener->authenticators = g_list_remove (data->listener->authenticators, authenticator);
+  if (authenticator == data->listener->active_authenticator)
+    data->listener->active_authenticator = NULL;
+
+  g_object_unref (authenticator);
+
+  if (dismissed)
+    {
+      g_task_return_new_error (data->task,
+                               POLKIT_ERROR,
+                               POLKIT_ERROR_CANCELLED,
+                               _("Authentication dialog was dismissed by the user"));
+    }
+
+  g_task_return_boolean (data->task, TRUE);
+  g_object_unref (data->task);
+
+  maybe_initiate_next_authenticator (data->listener);
+
+  auth_data_free (data);
+}
+
+static void
+cancelled_cb (GCancellable *cancellable,
+              gpointer user_data)
+{
+  AuthData *data = user_data;
+
+  polkit_mate_authenticator_cancel (data->authenticator);
+}
+
+static void
+polkit_mate_listener_initiate_authentication (PolkitAgentListener  *agent_listener,
+                                               const gchar          *action_id,
+                                               const gchar          *message,
+                                               const gchar          *icon_name,
+                                               PolkitDetails        *details,
+                                               const gchar          *cookie,
+                                               GList                *identities,
+                                               GCancellable         *cancellable,
+                                               GAsyncReadyCallback   callback,
+                                               gpointer              user_data)
+{
+  PolkitMateListener *listener = POLKIT_MATE_LISTENER (agent_listener);
+  GTask *task;
+  PolkitMateAuthenticator *authenticator;
+  AuthData *data;
+
+  task = g_task_new (G_OBJECT (listener),
+                     NULL,
+                     callback,
+                     user_data);
+  g_task_set_source_tag (task,
+                         polkit_mate_listener_initiate_authentication);
+
+  authenticator = polkit_mate_authenticator_new (action_id,
+                                                  message,
+                                                  icon_name,
+                                                  details,
+                                                  cookie,
+                                                  identities);
+  if (authenticator == NULL)
+    {
+      g_task_return_new_error (task,
+                               POLKIT_ERROR,
+                               POLKIT_ERROR_FAILED,
+                               "Error creating authentication object");
+      g_object_unref (task);
+      goto out;
+    }
+
+  data = auth_data_new (listener, authenticator, task, cancellable);
+
+  g_signal_connect (authenticator,
+                    "completed",
+                    G_CALLBACK (authenticator_completed),
+                    data);
+
+  if (cancellable != NULL)
+    {
+      data->cancel_id = g_signal_connect (cancellable,
+                                          "cancelled",
+                                          G_CALLBACK (cancelled_cb),
+                                          data);
+    }
+
+  listener->authenticators = g_list_append (listener->authenticators, authenticator);
+
+  maybe_initiate_next_authenticator (listener);
+
+ out:
+  ;
+}
+
+static gboolean
+polkit_mate_listener_initiate_authentication_finish (PolkitAgentListener  *listener,
+                                                      GAsyncResult         *res,
+                                                      GError              **error)
+{
+  GTask *task = G_TASK (res);
+
+  g_warn_if_fail (g_task_get_source_tag (task) == polkit_mate_listener_initiate_authentication);
+
+  if (g_task_propagate_pointer (task, error) == NULL) {
+    return FALSE;
+  }
+
+  return TRUE;
+}
+
+
+ +
+ +
+ + diff --git a/2024-02-26-105642-9744-cppcheck@c2df8de7c7b1_v1.28.1/index.html b/2024-02-26-105642-9744-cppcheck@c2df8de7c7b1_v1.28.1/index.html new file mode 100644 index 0000000..35f12cd --- /dev/null +++ b/2024-02-26-105642-9744-cppcheck@c2df8de7c7b1_v1.28.1/index.html @@ -0,0 +1,252 @@ + + + + + + Cppcheck - HTML report - mate-polkit + + + + + +
+ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
LineIdCWESeverityMessage
checkersReportinformationActive checkers: 106/592 (use --checkers-report=<filename> to see details)
src/main.c
23missingIncludeinformationInclude file: "config.h" not found.
26missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <gio/gio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
29missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
30missingIncludeSysteminformationInclude file: <polkitagent/polkitagent.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
33missingIncludeSysteminformationInclude file: <libayatana-appindicator/app-indicator.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
35missingIncludeSysteminformationInclude file: <libappindicator/app-indicator.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
226shadowVariable398styleLocal variable 'authority' shadows outer variable
316constParameterCallback398styleParameter 'signal_name' can be declared as pointer to const. However it seems that 'signal_cb' is a callback function, if 'signal_name' is declared with const you might also need to cast function pointer(s).
src/polkitmateauthenticationdialog.c
24missingIncludeinformationInclude file: "config.h" not found.
28missingIncludeSysteminformationInclude file: <unistd.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
29missingIncludeSysteminformationInclude file: <sys/types.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
30missingIncludeSysteminformationInclude file: <sys/stat.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
31missingIncludeSysteminformationInclude file: <fcntl.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
32missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
33missingIncludeSysteminformationInclude file: <stdio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
34missingIncludeSysteminformationInclude file: <stdlib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
35missingIncludeSysteminformationInclude file: <pwd.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
36missingIncludeSysteminformationInclude file: <errno.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
38missingIncludeSysteminformationInclude file: <glib/gi18n-lib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
39missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
99constVariablePointer398styleVariable 'indices' can be declared as pointer to const
src/polkitmateauthenticationdialog.h
26missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <polkit/polkit.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/polkitmateauthenticator.c
23missingIncludeinformationInclude file: "config.h" not found.
25missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <sys/types.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <pwd.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
29missingIncludeSysteminformationInclude file: <gdk/gdkx.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
31missingIncludeSysteminformationInclude file: <polkit/polkit.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
32missingIncludeSysteminformationInclude file: <polkitagent/polkitagent.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
512constParameterPointer398styleParameter 'authenticator' can be declared as pointer to const
src/polkitmateauthenticator.h
26missingIncludeSysteminformationInclude file: <glib-object.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/polkitmatelistener.c
23missingIncludeinformationInclude file: "config.h" not found.
25missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/polkitmatelistener.h
26missingIncludeSysteminformationInclude file: <polkitagent/polkitagent.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+ +
+ + diff --git a/2024-02-26-105642-9744-cppcheck@c2df8de7c7b1_v1.28.1/stats.html b/2024-02-26-105642-9744-cppcheck@c2df8de7c7b1_v1.28.1/stats.html new file mode 100644 index 0000000..5c5881a --- /dev/null +++ b/2024-02-26-105642-9744-cppcheck@c2df8de7c7b1_v1.28.1/stats.html @@ -0,0 +1,178 @@ + + + + + + Cppcheck - HTML report - mate-polkit + + + + + +
+ + + +
+

Top 10 files for style severity, total findings: 4
+   2  src/main.c
+   1  src/polkitmateauthenticator.c
+   1  src/polkitmateauthenticationdialog.c
+

+

Top 10 files for information severity, total findings: 35
+   12  src/polkitmateauthenticationdialog.c
+   8   src/polkitmateauthenticator.c
+   8   src/main.c
+   3   src/polkitmatelistener.c
+   2   src/polkitmateauthenticationdialog.h
+   1   src/polkitmatelistener.h
+   1   src/polkitmateauthenticator.h
+

+ +
+ +
+ + diff --git a/2024-02-26-105642-9744-cppcheck@c2df8de7c7b1_v1.28.1/style.css b/2024-02-26-105642-9744-cppcheck@c2df8de7c7b1_v1.28.1/style.css new file mode 100644 index 0000000..3897bfa --- /dev/null +++ b/2024-02-26-105642-9744-cppcheck@c2df8de7c7b1_v1.28.1/style.css @@ -0,0 +1,177 @@ + +body { + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif; + font-size: 13px; + line-height: 1.5; + height: 100%; + margin: 0; +} + +#wrapper { + position: fixed; + height: 100vh; + width: 100vw; + display: grid; + grid-template-rows: fit-content(8rem) auto fit-content(8rem); + grid-template-columns: fit-content(25%) 1fr; + grid-template-areas: + "header header" + "menu content" + "footer footer"; +} + +h1 { + margin: 0 0 8px -2px; + font-size: 175%; +} + +.header { + padding: 0 0 5px 15px; + grid-area: header; + border-bottom: thin solid #aaa; +} + +.footer { + grid-area: footer; + border-top: thin solid #aaa; + font-size: 85%; + +} + +.footer > p { + margin: 4px; +} + +#menu, +#menu_index { + grid-area: menu; + text-align: left; + overflow: auto; + padding: 0 23px 15px 15px; + border-right: thin solid #aaa; + min-width: 200px; +} + +#menu > a { + display: block; + margin-left: 10px; + font-size: 12px; +} + +#content, +#content_index { + grid-area: content; + padding: 0px 5px 15px 15px; + overflow: auto; +} + +label { + white-space: nowrap; +} + +label.checkBtn.disabled { + color: #606060; + background: #e0e0e0; + font-style: italic; +} + +label.checkBtn, input[type="text"] { + border: 1px solid grey; + border-radius: 4px; + box-shadow: 1px 1px inset; + padding: 1px 5px; +} + +label.checkBtn { + white-space: nowrap; + background: #ccddff; +} + +label.unchecked { + background: #eff8ff; + box-shadow: 1px 1px 1px; +} + +label.checkBtn:hover, label.unchecked:hover{ + box-shadow: 0 0 2px; +} + +label.disabled:hover { + box-shadow: 1px 1px inset; +} + +label.checkBtn > input { + display:none; +} + +.summaryTable { + width: 100%; +} + +table.summaryTable td { padding: 0 5px 0 5px; } + +.statHeader, .severityHeader { + font-weight: bold; +} + +.warning { + background-color: #ffffa7; +} + +.error { + background-color: #ffb7b7; +} + +.error2 { + background-color: #faa; + display: inline-block; + margin-left: 4px; +} + +.inconclusive { + background-color: #b6b6b4; +} + +.inconclusive2 { + background-color: #b6b6b4; + display: inline-block; + margin-left: 4px; +} + +.verbose { + display: inline-block; + vertical-align: top; + cursor: help; +} + +.verbose .content { + display: none; + position: absolute; + padding: 10px; + margin: 4px; + max-width: 40%; + white-space: pre-wrap; + border: 1px solid #000; + background-color: #ffffcc; + cursor: auto; +} + +.highlight .hll { + padding: 1px; +} + +.highlighttable { + background-color: #fff; + position: relative; + margin: -10px; +} + +.linenos { + border-right: thin solid #aaa; + color: #d3d3d3; + padding-right: 6px; +} + +.id-filtered, .severity-filtered, .file-filtered, .tool-filtered, .text-filtered { + visibility: collapse; +} diff --git a/2024-02-26-105807-9780-cppcheck@c2df8de7c7b1_master/0.html b/2024-02-26-105807-9780-cppcheck@c2df8de7c7b1_master/0.html new file mode 100644 index 0000000..95e5dbc --- /dev/null +++ b/2024-02-26-105807-9780-cppcheck@c2df8de7c7b1_master/0.html @@ -0,0 +1,1189 @@ + + + + + + Cppcheck - HTML report - mate-polkit + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
/*
+ * Copyright (C) 2009 Red Hat, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ * Author: David Zeuthen <davidz@redhat.com>
+ */
+
+#ifdef HAVE_CONFIG_H
+#  include "config.h"<--- Include file: "config.h" not found.
+#endif
+
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gio/gio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <polkitagent/polkitagent.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#if defined(HAVE_AYATANA_APPINDICATOR)
+# include <libayatana-appindicator/app-indicator.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#elif defined(HAVE_UBUNTU_APPINDICATOR)
+# include <libappindicator/app-indicator.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#endif
+
+#include "polkitmatelistener.h"
+
+/* session management support for auto-restart */
+#define SM_DBUS_NAME      "org.gnome.SessionManager"
+#define SM_DBUS_PATH      "/org/gnome/SessionManager"
+#define SM_DBUS_INTERFACE "org.gnome.SessionManager"
+#define SM_CLIENT_DBUS_INTERFACE "org.gnome.SessionManager.ClientPrivate"
+
+/* the Authority */
+static PolkitAuthority *authority = NULL;<--- Shadowed declaration
+
+/* the session we are servicing */
+static PolkitSubject *session = NULL;
+
+/* the current set of temporary authorizations */
+static GList *current_temporary_authorizations = NULL;
+
+#if defined(HAVE_AYATANA_APPINDICATOR) || defined(HAVE_UBUNTU_APPINDICATOR)
+static AppIndicator *app_indicator = NULL;
+#else
+static GtkStatusIcon *status_icon = NULL;
+#endif
+
+static GDBusProxy      *sm_proxy;
+static GDBusProxy      *client_proxy = NULL;
+
+static  GMainLoop *loop;
+
+static void
+revoke_tmp_authz_cb (GObject      *source_object,
+                     GAsyncResult *res,
+                     gpointer      user_data)
+{
+  GError *error;
+
+  error = NULL;
+  polkit_authority_revoke_temporary_authorizations_finish (POLKIT_AUTHORITY (source_object),
+                                                           res,
+                                                           &error);
+  if (error != NULL)
+    {
+      g_warning ("Error revoking temporary authorizations: %s", error->message);
+      g_error_free (error);
+    }
+}
+
+static void
+revoke_tmp_authz (void)
+{
+  polkit_authority_revoke_temporary_authorizations (authority,
+                                                    session,
+                                                    NULL,
+                                                    revoke_tmp_authz_cb,
+                                                    NULL);
+}
+
+#if defined(HAVE_AYATANA_APPINDICATOR) || defined(HAVE_UBUNTU_APPINDICATOR)
+static void
+on_menu_item_activate (GtkMenuItem *menu_item,
+                       gpointer     user_data)
+{
+  revoke_tmp_authz ();
+}
+#else
+static void
+on_status_icon_activate (GtkStatusIcon *status_icon,
+                         gpointer       user_data)
+{
+  revoke_tmp_authz ();
+}
+
+static void
+on_status_icon_popup_menu (GtkStatusIcon *status_icon,
+                           guint          button,
+                           guint          activate_time,
+                           gpointer       user_data)
+{
+  revoke_tmp_authz ();
+}
+#endif
+
+static void
+update_temporary_authorization_icon_real (void)
+{
+
+#if 0
+  GList *l;
+  g_debug ("have %d tmp authorizations", g_list_length (current_temporary_authorizations));
+  for (l = current_temporary_authorizations; l != NULL; l = l->next)
+    {
+      PolkitTemporaryAuthorization *authz = POLKIT_TEMPORARY_AUTHORIZATION (l->data);
+
+      g_debug ("have tmp authz for action %s (subject %s) with id %s (obtained %d, expires %d)",
+               polkit_temporary_authorization_get_action_id (authz),
+               polkit_subject_to_string (polkit_temporary_authorization_get_subject (authz)),
+               polkit_temporary_authorization_get_id (authz),
+               (gint) polkit_temporary_authorization_get_time_obtained (authz),
+               (gint) polkit_temporary_authorization_get_time_expires (authz));
+    }
+#endif
+
+  /* TODO:
+   *
+   * - we could do something fancy like displaying a window with the tmp authz
+   *   when the icon is clicked...
+   *
+   * - we could do some work using polkit_subject_exists() to ignore tmp authz
+   *   for subjects that no longer exists.. this is because temporary authorizations
+   *   are only valid for the subject that trigger the authentication dialog.
+   *
+   *   Maybe the authority could do this, would probably involve some polling, but
+   *   it seems cleaner to do this server side.
+   */
+
+  if (current_temporary_authorizations != NULL)
+    {
+      /* show icon */
+#if defined(HAVE_AYATANA_APPINDICATOR) || defined(HAVE_UBUNTU_APPINDICATOR)
+      if (app_indicator == NULL)
+        {
+          GtkWidget *item, *menu;
+
+          app_indicator = app_indicator_new ("mate-polkit",
+                                             "dialog-password",
+                                             APP_INDICATOR_CATEGORY_SYSTEM_SERVICES);
+
+          item = gtk_menu_item_new_with_label (_("Drop all elevated privileges"));
+          g_signal_connect (item,
+                            "activate",
+                            G_CALLBACK (on_menu_item_activate),
+                            NULL);
+          menu = gtk_menu_new ();
+          gtk_menu_shell_append (GTK_MENU_SHELL (menu), item);
+          gtk_widget_show_all (menu);
+
+          app_indicator_set_menu (app_indicator,
+                                  GTK_MENU (menu));
+          app_indicator_set_status (app_indicator,
+                                    APP_INDICATOR_STATUS_ACTIVE);
+        }
+      else
+        /*Reshow icon from existing appindicator */
+        app_indicator_set_status (app_indicator,
+				    APP_INDICATOR_STATUS_ACTIVE);
+
+#else
+      if (status_icon == NULL)
+        {
+          status_icon = gtk_status_icon_new_from_icon_name ("dialog-password");
+          gtk_status_icon_set_tooltip_text (status_icon,
+                                            _("Click the icon to drop all elevated privileges"));
+          g_signal_connect (status_icon,
+                            "activate",
+                            G_CALLBACK (on_status_icon_activate),
+                            NULL);
+          g_signal_connect (status_icon,
+                            "popup-menu",
+                            G_CALLBACK (on_status_icon_popup_menu),
+                            NULL);
+        }
+#endif
+    }
+  else
+    {
+      /* hide icon */
+#if defined(HAVE_AYATANA_APPINDICATOR) || defined(HAVE_UBUNTU_APPINDICATOR)
+      if (app_indicator != NULL)
+        {
+          /* keep the app_indicator, hide the icon or it won't come back*/
+          app_indicator_set_status (app_indicator,
+				    APP_INDICATOR_STATUS_PASSIVE);
+        }
+#else
+      if (status_icon != NULL)
+        {
+          gtk_status_icon_set_visible (status_icon, FALSE);
+          g_object_unref (status_icon);
+          status_icon = NULL;
+        }
+#endif
+    }
+}
+
+static void
+enumerate_temporary_authorizations_cb (GObject      *source_object,
+                                       GAsyncResult *res,
+                                       gpointer      user_data)
+{
+  PolkitAuthority *authority = POLKIT_AUTHORITY (source_object);<--- Shadow variable
+  GList *temporary_authorizations;
+  GError *error;
+
+  temporary_authorizations = NULL;
+
+  error = NULL;
+  temporary_authorizations = polkit_authority_enumerate_temporary_authorizations_finish (authority,
+                                                                                         res,
+                                                                                         &error);
+  if (error != NULL)
+    {
+      g_warning ("Error enumerating temporary authorizations: %s", error->message);
+      g_error_free (error);
+      goto out;
+    }
+
+  g_list_foreach (current_temporary_authorizations, (GFunc) g_object_unref, NULL);
+  g_list_free (current_temporary_authorizations);
+
+  current_temporary_authorizations = temporary_authorizations;
+
+  update_temporary_authorization_icon_real ();
+
+ out:
+  ;
+}
+
+static void
+update_temporary_authorization_icon (PolkitAuthority *authority)
+{
+  polkit_authority_enumerate_temporary_authorizations (authority,
+                                                       session,
+                                                       NULL,
+                                                       enumerate_temporary_authorizations_cb,
+                                                       NULL);
+}
+
+static void
+on_authority_changed (PolkitAuthority *authority,
+                      gpointer         user_data)
+{
+  update_temporary_authorization_icon (authority);
+}
+
+static void
+stop_cb (void)
+{
+        g_main_loop_quit (loop);
+}
+
+static gboolean
+end_session_response (gboolean is_okay, const gchar *reason)
+{
+        GVariant *res;
+        GError *error = NULL;
+
+        res = g_dbus_proxy_call_sync (client_proxy,
+                                      "EndSessionResponse",
+                                      g_variant_new ("(bs)",
+                                                     is_okay,
+                                                     reason),
+                                      G_DBUS_CALL_FLAGS_NONE,
+                                      -1, /* timeout */
+                                      NULL, /* GCancellable */
+                                      &error);
+        if (! res) {
+                g_warning ("Failed to call EndSessionResponse: %s", error->message);
+                g_error_free (error);
+                return FALSE;
+        }
+
+        g_variant_unref (res);
+        return TRUE;
+}
+
+static void
+query_end_session_cb (void)
+{
+        end_session_response (TRUE, "");
+}
+
+static void
+end_session_cb (void)
+{
+        end_session_response (TRUE, "");
+        g_main_loop_quit (loop);
+}
+
+static void
+signal_cb (GDBusProxy *proxy, gchar *sender_name, gchar *signal_name,<--- Parameter 'signal_name' can be declared as pointer to const
+           GVariant *parameters, gpointer user_data)
+{
+        if (strcmp (signal_name, "Stop") == 0) {
+                stop_cb ();
+        } else if (strcmp (signal_name, "QueryEndSession") == 0) {
+                query_end_session_cb ();
+        } else if (strcmp (signal_name, "EndSession") == 0) {
+                end_session_cb ();
+        }
+}
+
+static gboolean
+register_client_to_gnome_session (void)
+{
+        GError     *error = NULL;
+        GVariant   *res;
+        const char *startup_id;
+        const char *app_id;
+        char       *client_id;
+
+        startup_id = g_getenv ("DESKTOP_AUTOSTART_ID");
+        app_id = "polkit-mate-authentication-agent-1.desktop";
+
+        sm_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
+                                                  G_DBUS_PROXY_FLAGS_NONE,
+                                                  NULL, /* GDBusInterfaceInfo */
+                                                  SM_DBUS_NAME,
+                                                  SM_DBUS_PATH,
+                                                  SM_DBUS_INTERFACE,
+                                                  NULL, /* GCancellable */
+                                                  &error);
+        if (sm_proxy == NULL) {
+                g_message("Failed to get session manager: %s", error->message);
+                g_error_free (error);
+                return FALSE;
+        }
+
+        res = g_dbus_proxy_call_sync (sm_proxy,
+                                      "RegisterClient",
+                                      g_variant_new ("(ss)",
+                                                     app_id,
+                                                     startup_id),
+                                      G_DBUS_CALL_FLAGS_NONE,
+                                      -1, /* timeout */
+                                      NULL, /* GCancellable */
+                                      &error);
+        if (! res) {
+                g_warning ("Failed to register client: %s", error->message);
+                g_error_free (error);
+                return FALSE;
+        }
+
+        if (! g_variant_is_of_type (res, G_VARIANT_TYPE ("(o)"))) {
+                g_warning ("RegisterClient returned unexpected type %s",
+                           g_variant_get_type_string (res));
+                return FALSE;
+        }
+
+        g_variant_get (res, "(&o)", &client_id);
+
+        client_proxy = g_dbus_proxy_new_for_bus_sync (G_BUS_TYPE_SESSION,
+                                                      G_DBUS_PROXY_FLAGS_NONE,
+                                                      NULL, /* GDBusInterfaceInfo */
+                                                      SM_DBUS_NAME,
+                                                      client_id,
+                                                      SM_CLIENT_DBUS_INTERFACE,
+                                                      NULL, /* GCancellable */
+                                                      &error);
+        g_variant_unref (res);
+        if (client_proxy == NULL) {
+                g_message("Failed to get client proxy: %s", error->message);
+                g_error_free (error);
+                return FALSE;
+        }
+
+        g_signal_connect (client_proxy, "g-signal", G_CALLBACK (signal_cb), NULL);<--- You might need to cast the function pointer here
+
+        return TRUE;
+}
+
+int
+main (int argc, char **argv)
+{
+  gint ret;
+  PolkitAgentListener *listener;
+  GError *error;
+
+  gtk_init (&argc, &argv);
+
+  loop = NULL;
+  authority = NULL;
+  listener = NULL;
+  session = NULL;
+  ret = 1;
+
+  bindtextdomain (GETTEXT_PACKAGE, MATELOCALEDIR);
+#if HAVE_BIND_TEXTDOMAIN_CODESET
+  bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8");
+#endif
+  textdomain (GETTEXT_PACKAGE);
+
+  loop = g_main_loop_new (NULL, FALSE);
+
+  error = NULL;
+  authority = polkit_authority_get_sync (NULL /* GCancellable* */, &error);
+  if (authority == NULL)
+    {
+      g_warning ("Error getting authority: %s", error->message);
+      g_error_free (error);
+      goto out;
+    }
+  g_signal_connect (authority,
+                    "changed",
+                    G_CALLBACK (on_authority_changed),
+                    NULL);
+
+  listener = polkit_mate_listener_new ();
+
+  error = NULL;
+  session = polkit_unix_session_new_for_process_sync (getpid (), NULL, &error);
+  if (error != NULL)
+    {
+      g_warning ("Unable to determine the session we are in: %s", error->message);
+      g_error_free (error);
+      goto out;
+    }
+
+  error = NULL;
+  if (!polkit_agent_listener_register (listener,
+				       POLKIT_AGENT_REGISTER_FLAGS_NONE,
+                                       session,
+                                       "/org/mate/PolicyKit1/AuthenticationAgent",
+				       NULL,
+                                       &error))
+    {
+      g_printerr ("Cannot register authentication agent: %s\n", error->message);
+      g_error_free (error);
+      goto out;
+    }
+
+  update_temporary_authorization_icon (authority);
+
+  register_client_to_gnome_session();
+
+  g_main_loop_run (loop);
+
+  ret = 0;
+
+ out:
+  if (authority != NULL)
+    g_object_unref (authority);
+  if (session != NULL)
+    g_object_unref (session);
+  if (listener != NULL)
+    g_object_unref (listener);
+  if (loop != NULL)
+    g_main_loop_unref (loop);
+
+  return ret;
+}
+
+ +
+ +
+ + diff --git a/2024-02-26-105807-9780-cppcheck@c2df8de7c7b1_master/1.html b/2024-02-26-105807-9780-cppcheck@c2df8de7c7b1_master/1.html new file mode 100644 index 0000000..bf8ec00 --- /dev/null +++ b/2024-02-26-105807-9780-cppcheck@c2df8de7c7b1_master/1.html @@ -0,0 +1,335 @@ + + + + + + Cppcheck - HTML report - mate-polkit + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
/*
+ * Copyright (C) 2009 Red Hat, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ * Author: David Zeuthen <davidz@redhat.com>
+ */
+
+#ifndef __POLKIT_MATE_LISTENER_H
+#define __POLKIT_MATE_LISTENER_H
+
+#include <polkitagent/polkitagent.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define POLKIT_MATE_TYPE_LISTENER          (polkit_mate_listener_get_type())
+#define POLKIT_MATE_LISTENER(o)            (G_TYPE_CHECK_INSTANCE_CAST ((o), POLKIT_MATE_TYPE_LISTENER, PolkitMateListener))
+#define POLKIT_MATE_LISTENER_CLASS(k)      (G_TYPE_CHECK_CLASS_CAST((k), POLKIT_MATE_TYPE_LISTENER, PolkitMateListenerClass))
+#define POLKIT_MATE_LISTENER_GET_CLASS(o)  (G_TYPE_INSTANCE_GET_CLASS ((o), POLKIT_MATE_TYPE_LISTENER, PolkitMateListenerClass))
+#define POLKIT_MATE_IS_LISTENER(o)         (G_TYPE_CHECK_INSTANCE_TYPE ((o), POLKIT_MATE_TYPE_LISTENER))
+#define POLKIT_MATE_IS_LISTENER_CLASS(k)   (G_TYPE_CHECK_CLASS_TYPE ((k), POLKIT_MATE_TYPE_LISTENER))
+
+typedef struct _PolkitMateListener PolkitMateListener;
+typedef struct _PolkitMateListenerClass PolkitMateListenerClass;
+
+GType                 polkit_mate_listener_get_type   (void) G_GNUC_CONST;
+PolkitAgentListener  *polkit_mate_listener_new        (void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __POLKIT_MATE_LISTENER_H */
+
+ +
+ +
+ + diff --git a/2024-02-26-105807-9780-cppcheck@c2df8de7c7b1_master/2.html b/2024-02-26-105807-9780-cppcheck@c2df8de7c7b1_master/2.html new file mode 100644 index 0000000..bce6d3f --- /dev/null +++ b/2024-02-26-105807-9780-cppcheck@c2df8de7c7b1_master/2.html @@ -0,0 +1,2639 @@ + + + + + + Cppcheck - HTML report - mate-polkit + + + + + +
+ + + +
+
   1
+   2
+   3
+   4
+   5
+   6
+   7
+   8
+   9
+  10
+  11
+  12
+  13
+  14
+  15
+  16
+  17
+  18
+  19
+  20
+  21
+  22
+  23
+  24
+  25
+  26
+  27
+  28
+  29
+  30
+  31
+  32
+  33
+  34
+  35
+  36
+  37
+  38
+  39
+  40
+  41
+  42
+  43
+  44
+  45
+  46
+  47
+  48
+  49
+  50
+  51
+  52
+  53
+  54
+  55
+  56
+  57
+  58
+  59
+  60
+  61
+  62
+  63
+  64
+  65
+  66
+  67
+  68
+  69
+  70
+  71
+  72
+  73
+  74
+  75
+  76
+  77
+  78
+  79
+  80
+  81
+  82
+  83
+  84
+  85
+  86
+  87
+  88
+  89
+  90
+  91
+  92
+  93
+  94
+  95
+  96
+  97
+  98
+  99
+ 100
+ 101
+ 102
+ 103
+ 104
+ 105
+ 106
+ 107
+ 108
+ 109
+ 110
+ 111
+ 112
+ 113
+ 114
+ 115
+ 116
+ 117
+ 118
+ 119
+ 120
+ 121
+ 122
+ 123
+ 124
+ 125
+ 126
+ 127
+ 128
+ 129
+ 130
+ 131
+ 132
+ 133
+ 134
+ 135
+ 136
+ 137
+ 138
+ 139
+ 140
+ 141
+ 142
+ 143
+ 144
+ 145
+ 146
+ 147
+ 148
+ 149
+ 150
+ 151
+ 152
+ 153
+ 154
+ 155
+ 156
+ 157
+ 158
+ 159
+ 160
+ 161
+ 162
+ 163
+ 164
+ 165
+ 166
+ 167
+ 168
+ 169
+ 170
+ 171
+ 172
+ 173
+ 174
+ 175
+ 176
+ 177
+ 178
+ 179
+ 180
+ 181
+ 182
+ 183
+ 184
+ 185
+ 186
+ 187
+ 188
+ 189
+ 190
+ 191
+ 192
+ 193
+ 194
+ 195
+ 196
+ 197
+ 198
+ 199
+ 200
+ 201
+ 202
+ 203
+ 204
+ 205
+ 206
+ 207
+ 208
+ 209
+ 210
+ 211
+ 212
+ 213
+ 214
+ 215
+ 216
+ 217
+ 218
+ 219
+ 220
+ 221
+ 222
+ 223
+ 224
+ 225
+ 226
+ 227
+ 228
+ 229
+ 230
+ 231
+ 232
+ 233
+ 234
+ 235
+ 236
+ 237
+ 238
+ 239
+ 240
+ 241
+ 242
+ 243
+ 244
+ 245
+ 246
+ 247
+ 248
+ 249
+ 250
+ 251
+ 252
+ 253
+ 254
+ 255
+ 256
+ 257
+ 258
+ 259
+ 260
+ 261
+ 262
+ 263
+ 264
+ 265
+ 266
+ 267
+ 268
+ 269
+ 270
+ 271
+ 272
+ 273
+ 274
+ 275
+ 276
+ 277
+ 278
+ 279
+ 280
+ 281
+ 282
+ 283
+ 284
+ 285
+ 286
+ 287
+ 288
+ 289
+ 290
+ 291
+ 292
+ 293
+ 294
+ 295
+ 296
+ 297
+ 298
+ 299
+ 300
+ 301
+ 302
+ 303
+ 304
+ 305
+ 306
+ 307
+ 308
+ 309
+ 310
+ 311
+ 312
+ 313
+ 314
+ 315
+ 316
+ 317
+ 318
+ 319
+ 320
+ 321
+ 322
+ 323
+ 324
+ 325
+ 326
+ 327
+ 328
+ 329
+ 330
+ 331
+ 332
+ 333
+ 334
+ 335
+ 336
+ 337
+ 338
+ 339
+ 340
+ 341
+ 342
+ 343
+ 344
+ 345
+ 346
+ 347
+ 348
+ 349
+ 350
+ 351
+ 352
+ 353
+ 354
+ 355
+ 356
+ 357
+ 358
+ 359
+ 360
+ 361
+ 362
+ 363
+ 364
+ 365
+ 366
+ 367
+ 368
+ 369
+ 370
+ 371
+ 372
+ 373
+ 374
+ 375
+ 376
+ 377
+ 378
+ 379
+ 380
+ 381
+ 382
+ 383
+ 384
+ 385
+ 386
+ 387
+ 388
+ 389
+ 390
+ 391
+ 392
+ 393
+ 394
+ 395
+ 396
+ 397
+ 398
+ 399
+ 400
+ 401
+ 402
+ 403
+ 404
+ 405
+ 406
+ 407
+ 408
+ 409
+ 410
+ 411
+ 412
+ 413
+ 414
+ 415
+ 416
+ 417
+ 418
+ 419
+ 420
+ 421
+ 422
+ 423
+ 424
+ 425
+ 426
+ 427
+ 428
+ 429
+ 430
+ 431
+ 432
+ 433
+ 434
+ 435
+ 436
+ 437
+ 438
+ 439
+ 440
+ 441
+ 442
+ 443
+ 444
+ 445
+ 446
+ 447
+ 448
+ 449
+ 450
+ 451
+ 452
+ 453
+ 454
+ 455
+ 456
+ 457
+ 458
+ 459
+ 460
+ 461
+ 462
+ 463
+ 464
+ 465
+ 466
+ 467
+ 468
+ 469
+ 470
+ 471
+ 472
+ 473
+ 474
+ 475
+ 476
+ 477
+ 478
+ 479
+ 480
+ 481
+ 482
+ 483
+ 484
+ 485
+ 486
+ 487
+ 488
+ 489
+ 490
+ 491
+ 492
+ 493
+ 494
+ 495
+ 496
+ 497
+ 498
+ 499
+ 500
+ 501
+ 502
+ 503
+ 504
+ 505
+ 506
+ 507
+ 508
+ 509
+ 510
+ 511
+ 512
+ 513
+ 514
+ 515
+ 516
+ 517
+ 518
+ 519
+ 520
+ 521
+ 522
+ 523
+ 524
+ 525
+ 526
+ 527
+ 528
+ 529
+ 530
+ 531
+ 532
+ 533
+ 534
+ 535
+ 536
+ 537
+ 538
+ 539
+ 540
+ 541
+ 542
+ 543
+ 544
+ 545
+ 546
+ 547
+ 548
+ 549
+ 550
+ 551
+ 552
+ 553
+ 554
+ 555
+ 556
+ 557
+ 558
+ 559
+ 560
+ 561
+ 562
+ 563
+ 564
+ 565
+ 566
+ 567
+ 568
+ 569
+ 570
+ 571
+ 572
+ 573
+ 574
+ 575
+ 576
+ 577
+ 578
+ 579
+ 580
+ 581
+ 582
+ 583
+ 584
+ 585
+ 586
+ 587
+ 588
+ 589
+ 590
+ 591
+ 592
+ 593
+ 594
+ 595
+ 596
+ 597
+ 598
+ 599
+ 600
+ 601
+ 602
+ 603
+ 604
+ 605
+ 606
+ 607
+ 608
+ 609
+ 610
+ 611
+ 612
+ 613
+ 614
+ 615
+ 616
+ 617
+ 618
+ 619
+ 620
+ 621
+ 622
+ 623
+ 624
+ 625
+ 626
+ 627
+ 628
+ 629
+ 630
+ 631
+ 632
+ 633
+ 634
+ 635
+ 636
+ 637
+ 638
+ 639
+ 640
+ 641
+ 642
+ 643
+ 644
+ 645
+ 646
+ 647
+ 648
+ 649
+ 650
+ 651
+ 652
+ 653
+ 654
+ 655
+ 656
+ 657
+ 658
+ 659
+ 660
+ 661
+ 662
+ 663
+ 664
+ 665
+ 666
+ 667
+ 668
+ 669
+ 670
+ 671
+ 672
+ 673
+ 674
+ 675
+ 676
+ 677
+ 678
+ 679
+ 680
+ 681
+ 682
+ 683
+ 684
+ 685
+ 686
+ 687
+ 688
+ 689
+ 690
+ 691
+ 692
+ 693
+ 694
+ 695
+ 696
+ 697
+ 698
+ 699
+ 700
+ 701
+ 702
+ 703
+ 704
+ 705
+ 706
+ 707
+ 708
+ 709
+ 710
+ 711
+ 712
+ 713
+ 714
+ 715
+ 716
+ 717
+ 718
+ 719
+ 720
+ 721
+ 722
+ 723
+ 724
+ 725
+ 726
+ 727
+ 728
+ 729
+ 730
+ 731
+ 732
+ 733
+ 734
+ 735
+ 736
+ 737
+ 738
+ 739
+ 740
+ 741
+ 742
+ 743
+ 744
+ 745
+ 746
+ 747
+ 748
+ 749
+ 750
+ 751
+ 752
+ 753
+ 754
+ 755
+ 756
+ 757
+ 758
+ 759
+ 760
+ 761
+ 762
+ 763
+ 764
+ 765
+ 766
+ 767
+ 768
+ 769
+ 770
+ 771
+ 772
+ 773
+ 774
+ 775
+ 776
+ 777
+ 778
+ 779
+ 780
+ 781
+ 782
+ 783
+ 784
+ 785
+ 786
+ 787
+ 788
+ 789
+ 790
+ 791
+ 792
+ 793
+ 794
+ 795
+ 796
+ 797
+ 798
+ 799
+ 800
+ 801
+ 802
+ 803
+ 804
+ 805
+ 806
+ 807
+ 808
+ 809
+ 810
+ 811
+ 812
+ 813
+ 814
+ 815
+ 816
+ 817
+ 818
+ 819
+ 820
+ 821
+ 822
+ 823
+ 824
+ 825
+ 826
+ 827
+ 828
+ 829
+ 830
+ 831
+ 832
+ 833
+ 834
+ 835
+ 836
+ 837
+ 838
+ 839
+ 840
+ 841
+ 842
+ 843
+ 844
+ 845
+ 846
+ 847
+ 848
+ 849
+ 850
+ 851
+ 852
+ 853
+ 854
+ 855
+ 856
+ 857
+ 858
+ 859
+ 860
+ 861
+ 862
+ 863
+ 864
+ 865
+ 866
+ 867
+ 868
+ 869
+ 870
+ 871
+ 872
+ 873
+ 874
+ 875
+ 876
+ 877
+ 878
+ 879
+ 880
+ 881
+ 882
+ 883
+ 884
+ 885
+ 886
+ 887
+ 888
+ 889
+ 890
+ 891
+ 892
+ 893
+ 894
+ 895
+ 896
+ 897
+ 898
+ 899
+ 900
+ 901
+ 902
+ 903
+ 904
+ 905
+ 906
+ 907
+ 908
+ 909
+ 910
+ 911
+ 912
+ 913
+ 914
+ 915
+ 916
+ 917
+ 918
+ 919
+ 920
+ 921
+ 922
+ 923
+ 924
+ 925
+ 926
+ 927
+ 928
+ 929
+ 930
+ 931
+ 932
+ 933
+ 934
+ 935
+ 936
+ 937
+ 938
+ 939
+ 940
+ 941
+ 942
+ 943
+ 944
+ 945
+ 946
+ 947
+ 948
+ 949
+ 950
+ 951
+ 952
+ 953
+ 954
+ 955
+ 956
+ 957
+ 958
+ 959
+ 960
+ 961
+ 962
+ 963
+ 964
+ 965
+ 966
+ 967
+ 968
+ 969
+ 970
+ 971
+ 972
+ 973
+ 974
+ 975
+ 976
+ 977
+ 978
+ 979
+ 980
+ 981
+ 982
+ 983
+ 984
+ 985
+ 986
+ 987
+ 988
+ 989
+ 990
+ 991
+ 992
+ 993
+ 994
+ 995
+ 996
+ 997
+ 998
+ 999
+1000
+1001
+1002
+1003
+1004
+1005
+1006
+1007
+1008
+1009
+1010
+1011
+1012
+1013
+1014
+1015
+1016
+1017
+1018
+1019
+1020
+1021
+1022
+1023
+1024
+1025
+1026
+1027
+1028
+1029
+1030
+1031
+1032
+1033
+1034
+1035
+1036
+1037
+1038
+1039
+1040
+1041
+1042
+1043
+1044
+1045
+1046
+1047
+1048
+1049
+1050
+1051
+1052
+1053
+1054
+1055
+1056
+1057
+1058
+1059
+1060
+1061
+1062
+1063
+1064
+1065
+1066
+1067
+1068
+1069
+1070
+1071
+1072
+1073
+1074
+1075
+1076
+1077
+1078
+1079
+1080
+1081
+1082
+1083
+1084
+1085
+1086
+1087
+1088
+1089
+1090
+1091
+1092
+1093
+1094
+1095
+1096
+1097
+1098
+1099
+1100
+1101
+1102
+1103
+1104
+1105
+1106
+1107
+1108
+1109
+1110
+1111
+1112
+1113
+1114
+1115
+1116
+1117
+1118
+1119
+1120
+1121
+1122
+1123
+1124
+1125
+1126
+1127
+1128
+1129
+1130
+1131
+1132
+1133
+1134
+1135
+1136
+1137
+1138
+1139
+1140
+1141
+1142
+1143
+1144
+1145
+1146
+1147
+1148
+1149
+1150
+1151
+1152
+1153
+1154
+1155
+1156
+1157
+1158
+1159
+1160
+1161
+1162
+1163
+1164
+1165
+1166
+1167
+1168
+1169
+1170
+1171
+1172
+1173
+1174
+1175
+1176
+1177
+1178
+1179
+1180
+1181
+1182
+1183
+1184
+1185
+1186
+1187
+1188
+1189
+1190
+1191
+1192
+1193
+1194
+1195
+1196
+1197
+1198
+1199
+1200
+1201
/*
+ * Copyright (C) 2009 Red Hat, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ * Author: David Zeuthen <davidz@redhat.com>
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"<--- Include file: "config.h" not found.
+#endif
+
+#define _GNU_SOURCE
+#include <unistd.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/types.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/stat.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <fcntl.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <stdio.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <stdlib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <pwd.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <errno.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <glib/gi18n-lib.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "polkitmateauthenticationdialog.h"
+
+#define RESPONSE_USER_SELECTED 1001
+
+struct _PolkitMateAuthenticationDialogPrivate
+{
+  GtkWidget *user_combobox;
+  GtkWidget *prompt_label;
+  GtkWidget *password_entry;
+  GtkWidget *auth_button;
+  GtkWidget *cancel_button;
+  GtkWidget *info_label;
+  GtkWidget *grid_password;
+
+  gchar *message;
+  gchar *action_id;
+  gchar *vendor;
+  gchar *vendor_url;
+  gchar *icon_name;
+  PolkitDetails *details;
+
+  gchar **users;
+  gchar *selected_user;
+
+  gboolean is_running;
+
+  GtkListStore *store;
+};
+
+G_DEFINE_TYPE_WITH_PRIVATE (PolkitMateAuthenticationDialog, polkit_mate_authentication_dialog, GTK_TYPE_DIALOG);
+
+enum {
+  PROP_0,
+  PROP_ACTION_ID,
+  PROP_VENDOR,
+  PROP_VENDOR_URL,
+  PROP_ICON_NAME,
+  PROP_MESSAGE,
+  PROP_DETAILS,
+  PROP_USERS,
+  PROP_SELECTED_USER,
+};
+
+enum {
+  PIXBUF_COL,
+  TEXT_COL,
+  USERNAME_COL,
+  N_COL
+};
+
+static void
+user_combobox_set_sensitive (GtkCellLayout   *cell_layout,
+                             GtkCellRenderer *cell,
+                             GtkTreeModel    *tree_model,
+                             GtkTreeIter     *iter,
+                             gpointer         user_data)
+{
+  GtkTreePath *path;
+  gint *indices;<--- Variable 'indices' can be declared as pointer to const
+  gboolean sensitive;
+
+  path = gtk_tree_model_get_path (tree_model, iter);
+  indices = gtk_tree_path_get_indices (path);
+  if (indices[0] == 0)
+    sensitive = FALSE;
+  else
+    sensitive = TRUE;
+  gtk_tree_path_free (path);
+
+  g_object_set (cell, "sensitive", sensitive, NULL);
+}
+
+static void
+user_combobox_changed (GtkComboBox *widget,
+                       gpointer     user_data)
+{
+  PolkitMateAuthenticationDialog *dialog = POLKIT_MATE_AUTHENTICATION_DIALOG (user_data);
+  GtkTreeIter iter;
+  gchar *user_name;
+
+  if (gtk_combo_box_get_active_iter (GTK_COMBO_BOX (widget), &iter))
+    {
+      gtk_tree_model_get (GTK_TREE_MODEL (dialog->priv->store), &iter, USERNAME_COL, &user_name, -1);
+
+      g_free (dialog->priv->selected_user);
+      dialog->priv->selected_user = user_name;
+
+      g_object_notify (G_OBJECT (dialog), "selected-user");
+
+      gtk_dialog_response (GTK_DIALOG (dialog), RESPONSE_USER_SELECTED);
+
+      /* make the password entry and Authenticate button sensitive again */
+      gtk_widget_set_sensitive (dialog->priv->prompt_label, TRUE);
+      gtk_widget_set_sensitive (dialog->priv->password_entry, TRUE);
+      gtk_widget_set_sensitive (dialog->priv->auth_button, TRUE);
+    }
+}
+
+#if HAVE_ACCOUNTSSERVICE
+static GdkPixbuf *
+get_user_icon (char *username)
+{
+  GError *error;
+  GDBusConnection *connection;
+  GVariant *find_user_result;
+  GVariant *get_icon_result;
+  GVariant *icon_result_variant;
+  const gchar *user_path;
+  const gchar *icon_filename;
+  GdkPixbuf *pixbuf = NULL;
+
+  error = NULL;
+  connection = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
+
+  if (connection == NULL)
+    {
+      g_warning ("Unable to connect to system bus: %s", error->message);
+      g_error_free (error);
+      return NULL;
+    }
+
+  find_user_result = g_dbus_connection_call_sync (connection,
+                                          "org.freedesktop.Accounts",
+                                          "/org/freedesktop/Accounts",
+                                          "org.freedesktop.Accounts",
+                                          "FindUserByName",
+                                          g_variant_new ("(s)",
+                                          username),
+                                          G_VARIANT_TYPE ("(o)"),
+                                          G_DBUS_CALL_FLAGS_NONE,
+                                          -1,
+                                          NULL,
+                                          &error);
+
+  if (find_user_result == NULL)
+    {
+      g_warning ("Accounts couldn't find user: %s", error->message);
+      g_error_free (error);
+      return NULL;
+    }
+
+  user_path = g_variant_get_string (g_variant_get_child_value (find_user_result, 0),
+                                    NULL);
+
+  get_icon_result = g_dbus_connection_call_sync (connection,
+                                                 "org.freedesktop.Accounts",
+                                                 user_path,
+                                                 "org.freedesktop.DBus.Properties",
+                                                 "Get",
+                                                 g_variant_new ("(ss)",
+                                                                "org.freedesktop.Accounts.User",
+                                                                "IconFile"),
+                                                 G_VARIANT_TYPE ("(v)"),
+                                                 G_DBUS_CALL_FLAGS_NONE,
+                                                 -1,
+                                                 NULL,
+                                                 &error);
+
+  g_variant_unref (find_user_result);
+
+  if (get_icon_result == NULL)
+    {
+      g_warning ("Accounts couldn't find user icon: %s", error->message);
+      g_error_free (error);
+      return NULL;
+    }
+
+  g_variant_get_child (get_icon_result, 0, "v", &icon_result_variant);
+  icon_filename = g_variant_get_string (icon_result_variant, NULL);
+
+  if (icon_filename == NULL)
+    {
+      g_warning ("Accounts didn't return a valid filename for user icon");
+    }
+  else
+    {
+      /* TODO: we probably shouldn't hard-code the size to 16x16 */
+      pixbuf = gdk_pixbuf_new_from_file_at_size (icon_filename,
+                                                 16,
+                                                 16,
+                                                 &error);
+      if (pixbuf == NULL)
+        {
+          g_warning ("Couldn't open user icon: %s", error->message);
+          g_error_free (error);
+        }
+    }
+
+  g_variant_unref (icon_result_variant);
+  g_variant_unref (get_icon_result);
+
+  return pixbuf;
+}
+#else
+static GdkPixbuf *
+get_user_icon (char *username)
+{
+  GdkPixbuf *pixbuf = NULL;
+  struct passwd *passwd;
+
+  passwd = getpwnam (username);
+  if (passwd->pw_dir != NULL)
+    {
+      gchar *path;
+      path = g_strdup_printf ("%s/.face", passwd->pw_dir);
+      /* TODO: we probably shouldn't hard-code the size to 16x16 */
+      pixbuf = gdk_pixbuf_new_from_file_at_scale (path, 16, 16, TRUE, NULL);
+      g_free (path);
+    }
+
+  return pixbuf;
+}
+#endif /* HAVE_ACCOUNTSSERVICE */
+
+static void
+create_user_combobox (PolkitMateAuthenticationDialog *dialog)
+{
+  int n, i, selected_index = 0;
+  GtkComboBox *combo;
+  GtkTreeIter iter;
+  GtkCellRenderer *renderer;
+
+  /* if we've already built the list of admin users once, then avoid
+   * doing it again.. (this is mainly used when the user entered the
+   * wrong password and the dialog is recycled)
+   */
+  if (dialog->priv->store != NULL)
+    return;
+
+  combo = GTK_COMBO_BOX (dialog->priv->user_combobox);
+  dialog->priv->store = gtk_list_store_new (3, GDK_TYPE_PIXBUF, G_TYPE_STRING, G_TYPE_STRING);
+
+  gtk_list_store_append (dialog->priv->store, &iter);
+  gtk_list_store_set (dialog->priv->store, &iter,
+                      PIXBUF_COL, NULL,
+                      TEXT_COL, _("Select user..."),
+                      USERNAME_COL, NULL,
+                      -1);
+
+  /* For each user */
+  for (i = 0, n = 0; dialog->priv->users[n] != NULL; n++)
+  {
+      gchar *gecos;
+      gchar *real_name;
+      GdkPixbuf *pixbuf = NULL;
+      struct passwd *passwd;
+
+      /* we're single threaded so this is fine */
+      errno = 0;
+      passwd = getpwnam (dialog->priv->users[n]);
+      if (passwd == NULL)
+        {
+          g_warning ("Error doing getpwnam(\"%s\"): %s", dialog->priv->users[n], strerror (errno));
+          continue;
+        }
+
+      if (passwd->pw_gecos != NULL)
+        gecos = g_locale_to_utf8 (passwd->pw_gecos, -1, NULL, NULL, NULL);
+      else
+        gecos = NULL;
+
+      if (gecos != NULL && strlen (gecos) > 0)
+        {
+          gchar *first_comma;
+          first_comma = strchr (gecos, ',');
+          if (first_comma != NULL)
+            *first_comma = '\0';
+        }
+      if (gecos != NULL && strlen (gecos) > 0 && strcmp (gecos, dialog->priv->users[n]) != 0)
+        real_name = g_strdup_printf (_("%s (%s)"), gecos, dialog->priv->users[n]);
+       else
+         real_name = g_strdup (dialog->priv->users[n]);
+      g_free (gecos);
+
+      /* Load users face */
+      pixbuf = get_user_icon (dialog->priv->users[n]);
+
+      /* fall back to stock_person icon */
+      if (pixbuf == NULL)
+        {
+          pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
+                                             "stock_person",
+                                             GTK_ICON_SIZE_MENU,
+                                             0,
+                                             NULL);
+        }
+
+      gtk_list_store_append (dialog->priv->store, &iter);
+      gtk_list_store_set (dialog->priv->store, &iter,
+                          PIXBUF_COL, pixbuf,
+                          TEXT_COL, real_name,
+                          USERNAME_COL, dialog->priv->users[n],
+                          -1);
+
+      i++;
+      if (passwd->pw_uid == getuid ())
+        {
+          selected_index = i;
+          g_free (dialog->priv->selected_user);
+          dialog->priv->selected_user = g_strdup (dialog->priv->users[n]);
+        }
+
+      g_free (real_name);
+      g_object_unref (pixbuf);
+    }
+
+  gtk_combo_box_set_model (combo, GTK_TREE_MODEL (dialog->priv->store));
+
+  renderer = gtk_cell_renderer_pixbuf_new ();
+  gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), renderer, FALSE);
+  gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo),
+                                  renderer,
+                                  "pixbuf", PIXBUF_COL,
+                                  NULL);
+  gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (combo),
+                                      renderer,
+                                      user_combobox_set_sensitive,
+                                      NULL, NULL);
+
+  renderer = gtk_cell_renderer_text_new ();
+  gtk_cell_layout_pack_start (GTK_CELL_LAYOUT (combo), renderer, TRUE);
+  gtk_cell_layout_set_attributes (GTK_CELL_LAYOUT (combo),
+                                  renderer,
+                                  "text", TEXT_COL,
+                                  NULL);
+  gtk_cell_layout_set_cell_data_func (GTK_CELL_LAYOUT (combo),
+                                      renderer,
+                                      user_combobox_set_sensitive,
+                                      NULL, NULL);
+
+  /* Select the default user */
+  gtk_combo_box_set_active (GTK_COMBO_BOX (combo), selected_index);
+
+  /* Listen when a new user is selected */
+  g_signal_connect (GTK_WIDGET (combo),
+                    "changed",
+                    G_CALLBACK (user_combobox_changed),
+                    dialog);
+}
+
+static GtkWidget *
+get_image (PolkitMateAuthenticationDialog *dialog)
+{
+  GdkPixbuf *pixbuf;
+  GdkPixbuf *copy_pixbuf;
+  GdkPixbuf *vendor_pixbuf;
+  GtkWidget *image;
+
+  pixbuf = NULL;
+  copy_pixbuf = NULL;
+  vendor_pixbuf = NULL;
+  image = NULL;
+
+  if (dialog->priv->icon_name == NULL || strlen (dialog->priv->icon_name) == 0)
+    {
+      image = gtk_image_new_from_icon_name ("dialog-password", GTK_ICON_SIZE_DIALOG);
+      goto out;
+    }
+
+  vendor_pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
+                                            dialog->priv->icon_name,
+                                            48,
+                                            0,
+                                            NULL);
+  if (vendor_pixbuf == NULL)
+    {
+      g_warning ("No icon for themed icon with name '%s'", dialog->priv->icon_name);
+      image = gtk_image_new_from_icon_name ("dialog-password", GTK_ICON_SIZE_DIALOG);
+      goto out;
+    }
+
+  pixbuf = gtk_icon_theme_load_icon (gtk_icon_theme_get_default (),
+                                     "dialog-password",
+                                     48,
+                                     0,
+                                     NULL);
+  if (pixbuf == NULL)
+    goto out;
+
+  /* need to copy the pixbuf since we're modifying it */
+  copy_pixbuf = gdk_pixbuf_copy (pixbuf);
+  if (copy_pixbuf == NULL)
+    goto out;
+
+  /* blend the vendor icon in the bottom right quarter */
+  gdk_pixbuf_composite (vendor_pixbuf,
+                        copy_pixbuf,
+                        24, 24, 24, 24,
+                        24, 24, 0.5, 0.5,
+                        GDK_INTERP_BILINEAR,
+                        255);
+
+  image = gtk_image_new_from_pixbuf (copy_pixbuf);
+
+out:
+  if (pixbuf != NULL)
+    g_object_unref (pixbuf);
+
+  if (copy_pixbuf != NULL)
+    g_object_unref (copy_pixbuf);
+
+  if (vendor_pixbuf != NULL)
+    g_object_unref (vendor_pixbuf);
+
+  return image;
+}
+
+static void
+polkit_mate_authentication_dialog_set_property (GObject      *object,
+                                                 guint         prop_id,
+                                                 const GValue *value,
+                                                 GParamSpec   *pspec)
+{
+  PolkitMateAuthenticationDialog *dialog = POLKIT_MATE_AUTHENTICATION_DIALOG (object);
+
+  switch (prop_id)
+    {
+    case PROP_DETAILS:
+      dialog->priv->details = g_value_dup_object (value);
+      break;
+
+    case PROP_ACTION_ID:
+      dialog->priv->action_id = g_value_dup_string (value);
+      break;
+
+    case PROP_VENDOR:
+      dialog->priv->vendor = g_value_dup_string (value);
+      break;
+
+    case PROP_VENDOR_URL:
+      dialog->priv->vendor_url = g_value_dup_string (value);
+      break;
+
+    case PROP_ICON_NAME:
+      dialog->priv->icon_name = g_value_dup_string (value);
+      break;
+
+    case PROP_MESSAGE:
+      dialog->priv->message = g_value_dup_string (value);
+      break;
+
+    case PROP_USERS:
+      dialog->priv->users = g_value_dup_boxed (value);
+      break;
+
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+    }
+}
+
+static void
+polkit_mate_authentication_dialog_get_property (GObject    *object,
+                                                 guint       prop_id,
+                                                 GValue     *value,
+                                                 GParamSpec *pspec)
+{
+  PolkitMateAuthenticationDialog *dialog = POLKIT_MATE_AUTHENTICATION_DIALOG (object);
+
+  switch (prop_id)
+    {
+    case PROP_MESSAGE:
+      g_value_set_string (value, dialog->priv->message);
+      break;
+
+    /* TODO: rest of the properties */
+
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
+      break;
+    }
+}
+
+static GtkWidget *
+add_row (GtkWidget *grid, int row, const char *label_text, GtkWidget *entry)
+{
+  GtkWidget *label;
+
+  label = gtk_label_new_with_mnemonic (label_text);
+  gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
+  gtk_label_set_xalign (GTK_LABEL (label), 1.0);
+  gtk_label_set_yalign (GTK_LABEL (label), 0.5);
+
+  gtk_widget_set_hexpand (label, FALSE);
+  gtk_grid_attach (GTK_GRID (grid), label,
+                   0, row, 1, 1);
+  gtk_widget_set_hexpand (entry, TRUE);
+  gtk_grid_attach (GTK_GRID (grid), entry,
+                   1, row, 1, 1);
+  gtk_label_set_mnemonic_widget (GTK_LABEL (label), entry);
+
+  return label;
+}
+
+static void
+action_id_activated (GtkLabel *url_label, gpointer user_data)
+{
+#if 0
+  GError *error;
+  DBusGConnection *bus;
+  DBusGProxy *manager_proxy;
+
+  error = NULL;
+  bus = dbus_g_bus_get (DBUS_BUS_SESSION, &error);
+  if (bus == NULL)
+    {
+      g_warning ("Couldn't connect to session bus: %s", error->message);
+      g_error_free (error);
+      goto out;
+    }
+
+  manager_proxy = dbus_g_proxy_new_for_name (bus,
+                                             "org.mate.PolicyKit.AuthorizationManager",
+                                             "/",
+                                             "org.mate.PolicyKit.AuthorizationManager.SingleInstance");
+  if (manager_proxy == NULL)
+    {
+      g_warning ("Could not construct manager_proxy object; bailing out");
+      goto out;
+    }
+
+  if (!dbus_g_proxy_call (manager_proxy,
+                          "ShowAction",
+                          &error,
+                          G_TYPE_STRING, gtk_label_get_current_uri (GTK_LABEL (url_label)),
+                          G_TYPE_INVALID,
+                          G_TYPE_INVALID))
+    {
+      if (error != NULL)
+        {
+          g_warning ("Failed to call into manager: %s", error->message);
+          g_error_free (error);
+        }
+      else
+        {
+          g_warning ("Failed to call into manager");
+        }
+      goto out;
+    }
+
+out:
+        ;
+#endif
+}
+
+static void
+polkit_mate_authentication_dialog_init (PolkitMateAuthenticationDialog *dialog)
+{
+  dialog->priv = polkit_mate_authentication_dialog_get_instance_private (dialog);
+}
+
+static void
+polkit_mate_authentication_dialog_finalize (GObject *object)
+{
+  PolkitMateAuthenticationDialog *dialog;
+
+  dialog = POLKIT_MATE_AUTHENTICATION_DIALOG (object);
+
+  g_free (dialog->priv->message);
+  g_free (dialog->priv->action_id);
+  g_free (dialog->priv->vendor);
+  g_free (dialog->priv->vendor_url);
+  g_free (dialog->priv->icon_name);
+  if (dialog->priv->details != NULL)
+    g_object_unref (dialog->priv->details);
+
+  g_strfreev (dialog->priv->users);
+  g_free (dialog->priv->selected_user);
+
+  if (dialog->priv->store != NULL)
+    g_object_unref (dialog->priv->store);
+
+  if (G_OBJECT_CLASS (polkit_mate_authentication_dialog_parent_class)->finalize != NULL)
+    G_OBJECT_CLASS (polkit_mate_authentication_dialog_parent_class)->finalize (object);
+}
+
+static GtkWidget*
+polkit_mate_dialog_add_button (GtkDialog   *dialog,
+                               const gchar *button_text,
+                               const gchar *icon_name,
+                                     gint   response_id)
+{
+  GtkWidget *button;
+
+  button = gtk_button_new_with_mnemonic (button_text);
+  gtk_button_set_image (GTK_BUTTON (button), gtk_image_new_from_icon_name (icon_name, GTK_ICON_SIZE_BUTTON));
+
+  gtk_button_set_use_underline (GTK_BUTTON (button), TRUE);
+  gtk_style_context_add_class (gtk_widget_get_style_context (button), "text-button");
+  gtk_widget_set_can_default (button, TRUE);
+  gtk_widget_show (button);
+  gtk_dialog_add_action_widget (GTK_DIALOG (dialog), button, response_id);
+
+  return button;
+}
+
+static void
+polkit_mate_authentication_dialog_constructed (GObject *object)
+{
+  PolkitMateAuthenticationDialog *dialog;
+  GtkWidget *hbox;
+  GtkWidget *main_vbox;
+  GtkWidget *vbox;
+  GtkWidget *grid_password;
+  GtkWidget *details_expander;
+  GtkWidget *details_vbox;
+  GtkWidget *grid;
+  GtkWidget *label;
+  GtkWidget *image;
+  GtkWidget *content_area;
+  gboolean have_user_combobox;
+  gchar *s;
+  guint rows;
+
+  dialog = POLKIT_MATE_AUTHENTICATION_DIALOG (object);
+
+  if (G_OBJECT_CLASS (polkit_mate_authentication_dialog_parent_class)->constructed != NULL)
+    G_OBJECT_CLASS (polkit_mate_authentication_dialog_parent_class)->constructed (object);
+
+  have_user_combobox = FALSE;
+
+  dialog->priv->cancel_button = polkit_mate_dialog_add_button (GTK_DIALOG (dialog),
+                                                               _("_Cancel"),
+                                                               "process-stop",
+                                                               GTK_RESPONSE_CANCEL);
+
+  dialog->priv->auth_button = gtk_dialog_add_button (GTK_DIALOG (dialog),
+                                                     _("_Authenticate"),
+                                                     GTK_RESPONSE_OK);
+
+  gtk_dialog_set_default_response (GTK_DIALOG (dialog), GTK_RESPONSE_OK);
+
+  content_area = gtk_dialog_get_content_area (GTK_DIALOG (dialog));
+
+  gtk_container_set_border_width (GTK_CONTAINER (dialog), 5);
+  gtk_box_set_spacing (GTK_BOX (content_area), 2); /* 2 * 5 + 2 = 12 */
+  gtk_window_set_resizable (GTK_WINDOW (dialog), FALSE);
+  gtk_window_set_icon_name (GTK_WINDOW (dialog), "dialog-password");
+
+  hbox = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
+  gtk_container_set_border_width (GTK_CONTAINER (hbox), 5);
+  gtk_box_pack_start (GTK_BOX (content_area), hbox, TRUE, TRUE, 0);
+
+  image = get_image (dialog);
+  gtk_widget_set_halign (image, GTK_ALIGN_CENTER);
+  gtk_widget_set_valign (image, GTK_ALIGN_START);
+  gtk_box_pack_start (GTK_BOX (hbox), image, FALSE, FALSE, 0);
+
+  main_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 10);
+  gtk_box_pack_start (GTK_BOX (hbox), main_vbox, TRUE, TRUE, 0);
+
+  /* main message */
+  label = gtk_label_new (NULL);
+  s = g_strdup_printf ("<big><b>%s</b></big>", dialog->priv->message);
+  gtk_label_set_markup (GTK_LABEL (label), s);
+  g_free (s);
+
+  gtk_label_set_xalign (GTK_LABEL (label), 0.0);
+  gtk_label_set_yalign (GTK_LABEL (label), 0.5);
+  gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
+  gtk_label_set_max_width_chars (GTK_LABEL (label), 50);
+  gtk_box_pack_start (GTK_BOX (main_vbox), label, FALSE, FALSE, 0);
+
+  /* secondary message */
+  label = gtk_label_new (NULL);
+  if (g_strv_length (dialog->priv->users) > 1)
+    {
+          gtk_label_set_markup (GTK_LABEL (label),
+                                _("An application is attempting to perform an action that requires privileges. "
+                                  "Authentication as one of the users below is required to perform this action."));
+    }
+  else
+    {
+      if (strcmp (g_get_user_name (), dialog->priv->users[0]) == 0)
+        {
+          gtk_label_set_markup (GTK_LABEL (label),
+                                _("An application is attempting to perform an action that requires privileges. "
+                                  "Authentication is required to perform this action."));
+        }
+      else
+        {
+          gtk_label_set_markup (GTK_LABEL (label),
+                                _("An application is attempting to perform an action that requires privileges. "
+                                  "Authentication as the super user is required to perform this action."));
+        }
+    }
+
+  gtk_label_set_xalign (GTK_LABEL (label), 0.0);
+  gtk_label_set_yalign (GTK_LABEL (label), 0.5);
+  gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
+  gtk_label_set_max_width_chars (GTK_LABEL (label), 50);
+  gtk_box_pack_start (GTK_BOX (main_vbox), label, FALSE, FALSE, 0);
+
+  /* user combobox */
+  if (g_strv_length (dialog->priv->users) > 1)
+    {
+      dialog->priv->user_combobox = gtk_combo_box_new ();
+      gtk_box_pack_start (GTK_BOX (main_vbox), GTK_WIDGET (dialog->priv->user_combobox), FALSE, FALSE, 0);
+
+      create_user_combobox (dialog);
+
+      have_user_combobox = TRUE;
+    }
+  else
+    {
+      dialog->priv->selected_user = g_strdup (dialog->priv->users[0]);
+    }
+
+  /* password entry */
+  vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
+  gtk_box_pack_start (GTK_BOX (main_vbox), vbox, FALSE, FALSE, 0);
+
+  grid_password = gtk_grid_new ();
+  gtk_grid_set_column_spacing (GTK_GRID (grid_password), 12);
+  gtk_grid_set_row_spacing (GTK_GRID (grid_password), 6);
+  gtk_box_pack_start (GTK_BOX (vbox), grid_password, FALSE, FALSE, 0);
+  dialog->priv->password_entry = gtk_entry_new ();
+  gtk_entry_set_visibility (GTK_ENTRY (dialog->priv->password_entry), FALSE);
+  dialog->priv->prompt_label = add_row (grid_password, 0, _("_Password:"), dialog->priv->password_entry);
+
+  g_signal_connect_swapped (dialog->priv->password_entry, "activate",
+                            G_CALLBACK (gtk_window_activate_default),
+                            dialog);
+
+  dialog->priv->grid_password = grid_password;
+  /* initially never show the password entry stuff; we'll toggle it on/off so it's
+   * only shown when prompting for a password */
+  gtk_widget_set_no_show_all (dialog->priv->grid_password, TRUE);
+
+  /* A label for showing PAM_TEXT_INFO and PAM_TEXT_ERROR messages */
+  label = gtk_label_new (NULL);
+  gtk_label_set_line_wrap (GTK_LABEL (label), TRUE);
+  gtk_box_pack_start (GTK_BOX (vbox), label, FALSE, FALSE, 0);
+  dialog->priv->info_label = label;
+
+  /* Details */
+  details_expander = gtk_expander_new_with_mnemonic (_("<small><b>_Details</b></small>"));
+  gtk_expander_set_use_markup (GTK_EXPANDER (details_expander), TRUE);
+  gtk_box_pack_start (GTK_BOX (content_area), details_expander, FALSE, FALSE, 0);
+
+  details_vbox = gtk_box_new (GTK_ORIENTATION_VERTICAL, 10);
+  gtk_container_add (GTK_CONTAINER (details_expander), details_vbox);
+
+  grid = gtk_grid_new ();
+  gtk_widget_set_margin_start (grid, 20);
+  gtk_grid_set_column_spacing (GTK_GRID (grid), 12);
+  gtk_grid_set_row_spacing (GTK_GRID (grid), 6);
+  gtk_box_pack_start (GTK_BOX (details_vbox), grid, FALSE, FALSE, 0);
+
+  /* TODO: sort keys? */
+  rows = 0;
+  if (dialog->priv->details != NULL)
+    {
+      guint n;
+      gchar **keys;
+
+      keys = polkit_details_get_keys (dialog->priv->details);
+      for (n = 0; keys[n] != NULL; n++)
+        {
+          const gchar *key = keys[n];
+          const gchar *value;
+
+          value = polkit_details_lookup (dialog->priv->details, key);
+
+          label = gtk_label_new (NULL);
+          s = g_strdup_printf ("<small>%s</small>", value);
+          gtk_label_set_markup (GTK_LABEL (label), s);
+          g_free (s);
+
+          gtk_label_set_xalign (GTK_LABEL (label), 0.0);
+          gtk_label_set_yalign (GTK_LABEL (label), 1.0);
+
+          s = g_strdup_printf ("<small><b>%s:</b></small>", key);
+          add_row (grid, rows, s, label);
+          g_free (s);
+
+          rows++;
+        }
+      g_strfreev (keys);
+    }
+
+  /* --- */
+
+  label = gtk_label_new (NULL);
+  gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
+  s = g_strdup_printf ("<small><a href=\"%s\">%s</a></small>",
+                       dialog->priv->action_id,
+                       dialog->priv->action_id);
+  gtk_label_set_markup (GTK_LABEL (label), s);
+  g_free (s);
+
+  gtk_label_set_xalign (GTK_LABEL (label), 0.0);
+  gtk_label_set_yalign (GTK_LABEL (label), 1.0);
+
+  add_row (grid, rows++, _("<small><b>Action:</b></small>"), label);
+  g_signal_connect (label, "activate-link", G_CALLBACK (action_id_activated), NULL);
+
+  s = g_strdup_printf (_("Click to edit %s"), dialog->priv->action_id);
+  gtk_widget_set_tooltip_markup (label, s);
+  g_free (s);
+
+  /* --- */
+
+  label = gtk_label_new (NULL);
+  gtk_label_set_use_markup (GTK_LABEL (label), TRUE);
+  s = g_strdup_printf ("<small><a href=\"%s\">%s</a></small>",
+                       dialog->priv->vendor_url,
+                       dialog->priv->vendor);
+  gtk_label_set_markup (GTK_LABEL (label), s);
+  g_free (s);
+
+  gtk_label_set_xalign (GTK_LABEL (label), 0.0);
+  gtk_label_set_yalign (GTK_LABEL (label), 1.0);
+
+  add_row (grid, rows++, _("<small><b>Vendor:</b></small>"), label);
+
+  s = g_strdup_printf (_("Click to open %s"), dialog->priv->vendor_url);
+  gtk_widget_set_tooltip_markup (label, s);
+  g_free (s);
+
+  /* Disable password entry and authenticate until have a user selected */
+  if (have_user_combobox && gtk_combo_box_get_active (GTK_COMBO_BOX (dialog->priv->user_combobox)) == 0)
+    {
+      gtk_widget_set_sensitive (dialog->priv->prompt_label, FALSE);
+      gtk_widget_set_sensitive (dialog->priv->password_entry, FALSE);
+      gtk_widget_set_sensitive (dialog->priv->auth_button, FALSE);
+    }
+
+  gtk_widget_realize (GTK_WIDGET (dialog));
+
+}
+
+static void
+polkit_mate_authentication_dialog_class_init (PolkitMateAuthenticationDialogClass *klass)
+{
+  GObjectClass *gobject_class = G_OBJECT_CLASS (klass);
+
+  gobject_class->finalize = polkit_mate_authentication_dialog_finalize;
+  gobject_class->get_property = polkit_mate_authentication_dialog_get_property;
+  gobject_class->set_property = polkit_mate_authentication_dialog_set_property;
+  gobject_class->constructed  = polkit_mate_authentication_dialog_constructed;
+
+  g_object_class_install_property (gobject_class,
+                                   PROP_DETAILS,
+                                   g_param_spec_object ("details",
+                                                        NULL,
+                                                        NULL,
+                                                        POLKIT_TYPE_DETAILS,
+                                                        G_PARAM_READWRITE |
+                                                        G_PARAM_CONSTRUCT_ONLY |
+                                                        G_PARAM_STATIC_NAME |
+                                                        G_PARAM_STATIC_NICK |
+                                                        G_PARAM_STATIC_BLURB));
+
+  g_object_class_install_property (gobject_class,
+                                   PROP_ACTION_ID,
+                                   g_param_spec_string ("action-id",
+                                                        NULL,
+                                                        NULL,
+                                                        NULL,
+                                                        G_PARAM_READWRITE |
+                                                        G_PARAM_CONSTRUCT_ONLY |
+                                                        G_PARAM_STATIC_NAME |
+                                                        G_PARAM_STATIC_NICK |
+                                                        G_PARAM_STATIC_BLURB));
+
+  g_object_class_install_property (gobject_class,
+                                   PROP_VENDOR,
+                                   g_param_spec_string ("vendor",
+                                                        NULL,
+                                                        NULL,
+                                                        NULL,
+                                                        G_PARAM_READWRITE |
+                                                        G_PARAM_CONSTRUCT_ONLY |
+                                                        G_PARAM_STATIC_NAME |
+                                                        G_PARAM_STATIC_NICK |
+                                                        G_PARAM_STATIC_BLURB));
+
+  g_object_class_install_property (gobject_class,
+                                   PROP_VENDOR_URL,
+                                   g_param_spec_string ("vendor-url",
+                                                        NULL,
+                                                        NULL,
+                                                        NULL,
+                                                        G_PARAM_READWRITE |
+                                                        G_PARAM_CONSTRUCT_ONLY |
+                                                        G_PARAM_STATIC_NAME |
+                                                        G_PARAM_STATIC_NICK |
+                                                        G_PARAM_STATIC_BLURB));
+
+  g_object_class_install_property (gobject_class,
+                                   PROP_ICON_NAME,
+                                   g_param_spec_string ("icon-name",
+                                                        NULL,
+                                                        NULL,
+                                                        NULL,
+                                                        G_PARAM_READWRITE |
+                                                        G_PARAM_CONSTRUCT_ONLY |
+                                                        G_PARAM_STATIC_NAME |
+                                                        G_PARAM_STATIC_NICK |
+                                                        G_PARAM_STATIC_BLURB));
+
+  g_object_class_install_property (gobject_class,
+                                   PROP_MESSAGE,
+                                   g_param_spec_string ("message",
+                                                        NULL,
+                                                        NULL,
+                                                        NULL,
+                                                        G_PARAM_READWRITE |
+                                                        G_PARAM_CONSTRUCT_ONLY |
+                                                        G_PARAM_STATIC_NAME |
+                                                        G_PARAM_STATIC_NICK |
+                                                        G_PARAM_STATIC_BLURB));
+
+  g_object_class_install_property (gobject_class,
+                                   PROP_USERS,
+                                   g_param_spec_boxed ("users",
+                                                       NULL,
+                                                       NULL,
+                                                       G_TYPE_STRV,
+                                                       G_PARAM_READWRITE |
+                                                       G_PARAM_CONSTRUCT_ONLY |
+                                                       G_PARAM_STATIC_NAME |
+                                                       G_PARAM_STATIC_NICK |
+                                                       G_PARAM_STATIC_BLURB));
+
+  g_object_class_install_property (gobject_class,
+                                   PROP_SELECTED_USER,
+                                   g_param_spec_string ("selected-user",
+                                                        NULL,
+                                                        NULL,
+                                                        NULL,
+                                                        G_PARAM_READABLE |
+                                                        G_PARAM_STATIC_NAME |
+                                                        G_PARAM_STATIC_NICK |
+                                                        G_PARAM_STATIC_BLURB));
+}
+
+/**
+ * polkit_mate_authentication_dialog_new:
+ *
+ * Yada yada yada...
+ *
+ * Returns: A new password dialog.
+ **/
+GtkWidget *
+polkit_mate_authentication_dialog_new (const gchar    *action_id,
+                                        const gchar    *vendor,
+                                        const gchar    *vendor_url,
+                                        const gchar    *icon_name,
+                                        const gchar    *message_markup,
+                                        PolkitDetails  *details,
+                                        gchar         **users)
+{
+  PolkitMateAuthenticationDialog *dialog;
+  GtkWindow *window;
+
+  dialog = g_object_new (POLKIT_MATE_TYPE_AUTHENTICATION_DIALOG,
+                         "action-id", action_id,
+                         "vendor", vendor,
+                         "vendor-url", vendor_url,
+                         "icon-name", icon_name,
+                         "message", message_markup,
+                         "details", details,
+                         "users", users,
+                         NULL);
+
+  window = GTK_WINDOW (dialog);
+
+  gtk_window_set_position (window, GTK_WIN_POS_CENTER);
+  gtk_window_set_modal (window, TRUE);
+  gtk_window_set_resizable (window, FALSE);
+  gtk_window_set_keep_above (window, TRUE);
+  gtk_window_set_title (window, _("Authenticate"));
+  g_signal_connect (dialog, "close", G_CALLBACK (gtk_widget_hide), NULL);
+
+  return GTK_WIDGET (dialog);
+}
+
+/**
+ * polkit_mate_authentication_dialog_indicate_error:
+ * @dialog: the auth dialog
+ *
+ * Call this function to indicate an authentication error; typically shakes the window
+ **/
+void
+polkit_mate_authentication_dialog_indicate_error (PolkitMateAuthenticationDialog *dialog)
+{
+  int x, y;
+  int n;
+  int diff;
+
+  /* TODO: detect compositing manager and do fancy stuff here */
+
+  gtk_window_get_position (GTK_WINDOW (dialog), &x, &y);
+
+  for (n = 0; n < 10; n++)
+    {
+      if (n % 2 == 0)
+        diff = -15;
+      else
+        diff = 15;
+
+      gtk_window_move (GTK_WINDOW (dialog), x + diff, y);
+
+      while (gtk_events_pending ())
+        {
+          gtk_main_iteration ();
+        }
+
+      g_usleep (10000);
+    }
+
+  gtk_window_move (GTK_WINDOW (dialog), x, y);
+}
+
+/**
+ * polkit_mate_authentication_dialog_run_until_user_is_selected:
+ * @dialog: A #PolkitMateAuthenticationDialog.
+ *
+ * Runs @dialog in a recursive main loop until a user have been selected.
+ *
+ * If there is only one element in the the users array (which is set upon construction) or
+ * an user has already been selected, this function returns immediately with the return
+ * value %TRUE.
+ *
+ * Returns: %TRUE if a user is selected (use polkit_mate_dialog_get_selected_user() to obtain the user) or
+ *          %FALSE if the dialog was cancelled.
+ **/
+gboolean
+polkit_mate_authentication_dialog_run_until_user_is_selected (PolkitMateAuthenticationDialog *dialog)
+{
+  gboolean ret;
+  gint response;
+
+  ret = FALSE;
+
+  if (dialog->priv->selected_user != NULL)
+    {
+      ret = TRUE;
+      goto out;
+    }
+
+  dialog->priv->is_running = TRUE;
+
+  response = gtk_dialog_run (GTK_DIALOG (dialog));
+
+  dialog->priv->is_running = FALSE;
+
+  if (response == RESPONSE_USER_SELECTED)
+    ret = TRUE;
+
+ out:
+  return ret;
+}
+
+/**
+ * polkit_mate_authentication_dialog_run_until_response_for_prompt:
+ * @dialog: A #PolkitMateAuthenticationDialog.
+ * @prompt: The prompt to present the user with.
+ * @echo_chars: Whether characters should be echoed in the password entry box.
+ * @was_cancelled: Set to %TRUE if the dialog was cancelled.
+ * @new_user_selected: Set to %TRUE if another user was selected.
+ *
+ * Runs @dialog in a recursive main loop until a response to @prompt have been obtained from the user.
+ *
+ * Returns: The response (free with g_free()) or %NULL if one of @was_cancelled or @new_user_selected
+ *          has been set to %TRUE.
+ **/
+gchar *
+polkit_mate_authentication_dialog_run_until_response_for_prompt (PolkitMateAuthenticationDialog *dialog,
+                                                                  const gchar           *prompt,
+                                                                  gboolean               echo_chars,
+                                                                  gboolean              *was_cancelled,
+                                                                  gboolean              *new_user_selected)
+{
+  gint response;
+  gchar *ret;
+
+  gtk_label_set_text_with_mnemonic (GTK_LABEL (dialog->priv->prompt_label), prompt);
+  gtk_entry_set_visibility (GTK_ENTRY (dialog->priv->password_entry), echo_chars);
+  gtk_entry_set_text (GTK_ENTRY (dialog->priv->password_entry), "");
+  gtk_widget_grab_focus (dialog->priv->password_entry);
+
+  ret = NULL;
+
+  if (was_cancelled != NULL)
+    *was_cancelled = FALSE;
+
+  if (new_user_selected != NULL)
+    *new_user_selected = FALSE;
+
+  dialog->priv->is_running = TRUE;
+
+  gtk_widget_set_no_show_all (dialog->priv->grid_password, FALSE);
+  gtk_widget_show_all (dialog->priv->grid_password);
+
+  response = gtk_dialog_run (GTK_DIALOG (dialog));
+
+  gtk_widget_hide (dialog->priv->grid_password);
+  gtk_widget_set_no_show_all (dialog->priv->grid_password, TRUE);
+
+  dialog->priv->is_running = FALSE;
+
+  if (response == GTK_RESPONSE_OK)
+    {
+      ret = g_strdup (gtk_entry_get_text (GTK_ENTRY (dialog->priv->password_entry)));
+    }
+  else if (response == RESPONSE_USER_SELECTED)
+    {
+      if (new_user_selected != NULL)
+        *new_user_selected = TRUE;
+    }
+  else
+    {
+      if (was_cancelled != NULL)
+        *was_cancelled = TRUE;
+    }
+
+  return ret;
+}
+
+/**
+ * polkit_mate_authentication_dialog_get_selected_user:
+ * @dialog: A #PolkitMateAuthenticationDialog.
+ *
+ * Gets the currently selected user.
+ *
+ * Returns: The currently selected user (free with g_free()) or %NULL if no user is currently selected.
+ **/
+gchar *
+polkit_mate_authentication_dialog_get_selected_user (PolkitMateAuthenticationDialog *dialog)
+{
+  return g_strdup (dialog->priv->selected_user);
+}
+
+void
+polkit_mate_authentication_dialog_set_info_message (PolkitMateAuthenticationDialog *dialog,
+                                                     const gchar                     *info_markup)
+{
+  gtk_label_set_markup (GTK_LABEL (dialog->priv->info_label), info_markup);
+}
+
+/**
+ * polkit_mate_authentication_dialog_cancel:
+ * @dialog: A #PolkitMateAuthenticationDialog.
+ *
+ * Cancels the dialog if it is currenlty running.
+ *
+ * Returns: %TRUE if the dialog was running.
+ **/
+gboolean
+polkit_mate_authentication_dialog_cancel (PolkitMateAuthenticationDialog *dialog)
+{
+  if (!dialog->priv->is_running)
+    return FALSE;
+
+  gtk_dialog_response (GTK_DIALOG (dialog), GTK_RESPONSE_CANCEL);
+
+  return TRUE;
+}
+
+ +
+ +
+ + diff --git a/2024-02-26-105807-9780-cppcheck@c2df8de7c7b1_master/3.html b/2024-02-26-105807-9780-cppcheck@c2df8de7c7b1_master/3.html new file mode 100644 index 0000000..6ad06dd --- /dev/null +++ b/2024-02-26-105807-9780-cppcheck@c2df8de7c7b1_master/3.html @@ -0,0 +1,393 @@ + + + + + + Cppcheck - HTML report - mate-polkit + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
+58
+59
+60
+61
+62
+63
+64
+65
+66
+67
+68
+69
+70
+71
+72
+73
+74
+75
+76
+77
+78
/*
+ * Copyright (C) 2009 Red Hat, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ * Author: David Zeuthen <davidz@redhat.com>
+ */
+
+#ifndef __POLKIT_MATE_AUTHENTICATION_DIALOG_H
+#define __POLKIT_MATE_AUTHENTICATION_DIALOG_H
+
+#include <gtk/gtk.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <polkit/polkit.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define POLKIT_MATE_TYPE_AUTHENTICATION_DIALOG            (polkit_mate_authentication_dialog_get_type ())
+#define POLKIT_MATE_AUTHENTICATION_DIALOG(obj)            (G_TYPE_CHECK_INSTANCE_CAST ((obj), POLKIT_MATE_TYPE_AUTHENTICATION_DIALOG, PolkitMateAuthenticationDialog))
+#define POLKIT_MATE_AUTHENTICATION_DIALOG_CLASS(klass)    (G_TYPE_CHECK_CLASS_CAST ((klass), POLKIT_MATE_TYPE_AUTHENTICATION_DIALOG, PolkitMateAuthenticationDialogClass))
+#define POLKIT_MATE_IS_AUTHENTICATION_DIALOG(obj)         (G_TYPE_CHECK_INSTANCE_TYPE ((obj), POLKIT_MATE_TYPE_AUTHENTICATION_DIALOG))
+#define POLKIT_MATE_IS_AUTHENTICATION_DIALOG_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), POLKIT_MATE_TYPE_AUTHENTICATION_DIALOG))
+
+typedef struct _PolkitMateAuthenticationDialog        PolkitMateAuthenticationDialog;
+typedef struct _PolkitMateAuthenticationDialogClass   PolkitMateAuthenticationDialogClass;
+typedef struct _PolkitMateAuthenticationDialogPrivate PolkitMateAuthenticationDialogPrivate;
+
+struct _PolkitMateAuthenticationDialog
+{
+  GtkDialog parent_instance;
+  PolkitMateAuthenticationDialogPrivate *priv;
+};
+
+struct _PolkitMateAuthenticationDialogClass
+{
+  GtkDialogClass parent_class;
+};
+
+GType      polkit_mate_authentication_dialog_get_type                      (void);
+GtkWidget *polkit_mate_authentication_dialog_new                           (const gchar    *action_id,
+                                                                             const gchar    *vendor,
+                                                                             const gchar    *vendor_url,
+                                                                             const gchar    *icon_name,
+                                                                             const gchar    *message_markup,
+                                                                             PolkitDetails  *details,
+                                                                             gchar         **users);
+gchar     *polkit_mate_authentication_dialog_get_selected_user             (PolkitMateAuthenticationDialog *dialog);
+gboolean   polkit_mate_authentication_dialog_run_until_user_is_selected    (PolkitMateAuthenticationDialog *dialog);
+gchar     *polkit_mate_authentication_dialog_run_until_response_for_prompt (PolkitMateAuthenticationDialog *dialog,
+                                                                             const gchar                     *prompt,
+                                                                             gboolean                         echo_chars,
+                                                                             gboolean                        *was_cancelled,
+                                                                             gboolean                        *new_user_selected);
+gboolean   polkit_mate_authentication_dialog_cancel                        (PolkitMateAuthenticationDialog *dialog);
+void       polkit_mate_authentication_dialog_indicate_error                (PolkitMateAuthenticationDialog *dialog);
+void       polkit_mate_authentication_dialog_set_info_message              (PolkitMateAuthenticationDialog *dialog,
+                                                                             const gchar                     *info_markup);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __POLKIT_MATE_AUTHENTICATION_DIALOG_H */
+
+ +
+ +
+ + diff --git a/2024-02-26-105807-9780-cppcheck@c2df8de7c7b1_master/4.html b/2024-02-26-105807-9780-cppcheck@c2df8de7c7b1_master/4.html new file mode 100644 index 0000000..67c8d37 --- /dev/null +++ b/2024-02-26-105807-9780-cppcheck@c2df8de7c7b1_master/4.html @@ -0,0 +1,1269 @@ + + + + + + Cppcheck - HTML report - mate-polkit + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
+263
+264
+265
+266
+267
+268
+269
+270
+271
+272
+273
+274
+275
+276
+277
+278
+279
+280
+281
+282
+283
+284
+285
+286
+287
+288
+289
+290
+291
+292
+293
+294
+295
+296
+297
+298
+299
+300
+301
+302
+303
+304
+305
+306
+307
+308
+309
+310
+311
+312
+313
+314
+315
+316
+317
+318
+319
+320
+321
+322
+323
+324
+325
+326
+327
+328
+329
+330
+331
+332
+333
+334
+335
+336
+337
+338
+339
+340
+341
+342
+343
+344
+345
+346
+347
+348
+349
+350
+351
+352
+353
+354
+355
+356
+357
+358
+359
+360
+361
+362
+363
+364
+365
+366
+367
+368
+369
+370
+371
+372
+373
+374
+375
+376
+377
+378
+379
+380
+381
+382
+383
+384
+385
+386
+387
+388
+389
+390
+391
+392
+393
+394
+395
+396
+397
+398
+399
+400
+401
+402
+403
+404
+405
+406
+407
+408
+409
+410
+411
+412
+413
+414
+415
+416
+417
+418
+419
+420
+421
+422
+423
+424
+425
+426
+427
+428
+429
+430
+431
+432
+433
+434
+435
+436
+437
+438
+439
+440
+441
+442
+443
+444
+445
+446
+447
+448
+449
+450
+451
+452
+453
+454
+455
+456
+457
+458
+459
+460
+461
+462
+463
+464
+465
+466
+467
+468
+469
+470
+471
+472
+473
+474
+475
+476
+477
+478
+479
+480
+481
+482
+483
+484
+485
+486
+487
+488
+489
+490
+491
+492
+493
+494
+495
+496
+497
+498
+499
+500
+501
+502
+503
+504
+505
+506
+507
+508
+509
+510
+511
+512
+513
+514
+515
+516
/*
+ * Copyright (C) 2009 Red Hat, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ * Author: David Zeuthen <davidz@redhat.com>
+ */
+
+#include "config.h"<--- Include file: "config.h" not found.
+
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <sys/types.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <pwd.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <gdk/gdkx.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include <polkit/polkit.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <polkitagent/polkitagent.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "polkitmateauthenticator.h"
+#include "polkitmateauthenticationdialog.h"
+
+struct _PolkitMateAuthenticator
+{
+  GObject parent_instance;
+
+  PolkitAuthority *authority;
+  gchar *action_id;
+  gchar *message;
+  gchar *icon_name;
+  PolkitDetails *details;
+  gchar *cookie;
+  GList *identities;
+
+  PolkitActionDescription *action_desc;
+  gchar **users;
+
+  gboolean gained_authorization;
+  gboolean was_cancelled;
+  gboolean new_user_selected;
+  gchar *selected_user;
+
+  PolkitAgentSession *session;
+  GtkWidget *dialog;
+  GMainLoop *loop;
+};
+
+struct _PolkitMateAuthenticatorClass
+{
+  GObjectClass parent_class;
+
+};
+
+enum
+{
+  COMPLETED_SIGNAL,
+  LAST_SIGNAL,
+};
+
+static guint signals[LAST_SIGNAL] = {0};
+
+G_DEFINE_TYPE (PolkitMateAuthenticator, polkit_mate_authenticator, G_TYPE_OBJECT);
+
+static void
+polkit_mate_authenticator_init (PolkitMateAuthenticator *authenticator)
+{
+}
+
+static void
+polkit_mate_authenticator_finalize (GObject *object)
+{
+  PolkitMateAuthenticator *authenticator;
+
+  authenticator = POLKIT_MATE_AUTHENTICATOR (object);
+
+  if (authenticator->authority != NULL)
+    g_object_unref (authenticator->authority);
+  g_free (authenticator->action_id);
+  g_free (authenticator->message);
+  g_free (authenticator->icon_name);
+  if (authenticator->details != NULL)
+    g_object_unref (authenticator->details);
+  g_free (authenticator->cookie);
+  g_list_foreach (authenticator->identities, (GFunc) g_object_unref, NULL);
+  g_list_free (authenticator->identities);
+
+  if (authenticator->action_desc != NULL)
+    g_object_unref (authenticator->action_desc);
+  g_strfreev (authenticator->users);
+
+  g_free (authenticator->selected_user);
+  if (authenticator->session != NULL)
+    g_object_unref (authenticator->session);
+  if (authenticator->dialog != NULL)
+    gtk_widget_destroy (authenticator->dialog);
+  if (authenticator->loop != NULL)
+    g_main_loop_unref (authenticator->loop);
+
+  if (G_OBJECT_CLASS (polkit_mate_authenticator_parent_class)->finalize != NULL)
+    G_OBJECT_CLASS (polkit_mate_authenticator_parent_class)->finalize (object);
+}
+
+static void
+polkit_mate_authenticator_class_init (PolkitMateAuthenticatorClass *klass)
+{
+  GObjectClass *gobject_class;
+
+  gobject_class = G_OBJECT_CLASS (klass);
+
+  gobject_class->finalize = polkit_mate_authenticator_finalize;
+
+  /**
+   * PolkitMateAuthenticator::completed:
+   * @authenticator: A #PolkitMateAuthenticator.
+   * @gained_authorization: Whether the authorization was gained.
+   * @dismissed: Whether the dialog was dismissed.
+   *
+   * Emitted when the authentication is completed. The user is supposed to dispose of @authenticator
+   * upon receiving this signal.
+   **/
+  signals[COMPLETED_SIGNAL] = g_signal_new ("completed",
+                                            POLKIT_MATE_TYPE_AUTHENTICATOR,
+                                            G_SIGNAL_RUN_LAST,
+                                            0,                      /* class offset     */
+                                            NULL,                   /* accumulator      */
+                                            NULL,                   /* accumulator data */
+                                            g_cclosure_marshal_generic,
+                                            G_TYPE_NONE,
+                                            2,
+					    G_TYPE_BOOLEAN,
+                                            G_TYPE_BOOLEAN);
+}
+
+static PolkitActionDescription *
+get_desc_for_action (PolkitAuthority *authority,
+                     const gchar     *action_id)
+{
+  GList *action_descs;
+  GList *l;
+  PolkitActionDescription *result;
+
+  result = NULL;
+
+  action_descs = polkit_authority_enumerate_actions_sync (authority,
+                                                          NULL,
+                                                          NULL);
+  for (l = action_descs; l != NULL; l = l->next)
+    {
+      PolkitActionDescription *action_desc = POLKIT_ACTION_DESCRIPTION (l->data);
+
+      if (strcmp (polkit_action_description_get_action_id (action_desc), action_id) == 0)
+        {
+          result = g_object_ref (action_desc);
+          goto out;
+        }
+    }
+
+ out:
+
+  g_list_foreach (action_descs, (GFunc) g_object_unref, NULL);
+  g_list_free (action_descs);
+
+  return result;
+}
+
+static void
+on_dialog_deleted (GtkWidget *widget,
+                   GdkEvent  *event,
+                   gpointer   user_data)
+{
+  PolkitMateAuthenticator *authenticator = POLKIT_MATE_AUTHENTICATOR (user_data);
+
+  polkit_mate_authenticator_cancel (authenticator);
+}
+
+static void
+on_user_selected (GObject    *object,
+                  GParamSpec *pspec,
+                  gpointer    user_data)
+{
+  PolkitMateAuthenticator *authenticator = POLKIT_MATE_AUTHENTICATOR (user_data);
+
+  /* clear any previous messages */
+  polkit_mate_authentication_dialog_set_info_message (POLKIT_MATE_AUTHENTICATION_DIALOG (authenticator->dialog), "");
+
+  polkit_mate_authenticator_cancel (authenticator);
+  authenticator->new_user_selected = TRUE;
+}
+
+PolkitMateAuthenticator *
+polkit_mate_authenticator_new (const gchar     *action_id,
+                                const gchar     *message,
+                                const gchar     *icon_name,
+                                PolkitDetails   *details,
+                                const gchar     *cookie,
+                                GList           *identities)
+{
+  PolkitMateAuthenticator *authenticator;
+  GList *l;
+  guint n;
+  GError *error;
+
+  authenticator = POLKIT_MATE_AUTHENTICATOR (g_object_new (POLKIT_MATE_TYPE_AUTHENTICATOR, NULL));
+
+  error = NULL;
+  authenticator->authority = polkit_authority_get_sync (NULL /* GCancellable* */, &error);
+  if (authenticator->authority == NULL)
+    {
+      g_critical ("Error getting authority: %s", error->message);
+      g_error_free (error);
+      goto error;
+    }
+
+  authenticator->action_id = g_strdup (action_id);
+  authenticator->message = g_strdup (message);
+  authenticator->icon_name = g_strdup (icon_name);
+  if (details != NULL)
+    authenticator->details = g_object_ref (details);
+  authenticator->cookie = g_strdup (cookie);
+  authenticator->identities = g_list_copy (identities);
+  g_list_foreach (authenticator->identities, (GFunc) g_object_ref, NULL);
+
+  authenticator->action_desc = get_desc_for_action (authenticator->authority,
+                                                    authenticator->action_id);
+  if (authenticator->action_desc == NULL)
+    goto error;
+
+  authenticator->users = g_new0 (gchar *, g_list_length (authenticator->identities) + 1);
+  for (l = authenticator->identities, n = 0; l != NULL; l = l->next, n++)
+    {
+      PolkitUnixUser *user = POLKIT_UNIX_USER (l->data);
+      uid_t uid;
+      struct passwd *passwd;
+
+      uid = polkit_unix_user_get_uid (user);
+      passwd = getpwuid (uid);
+      authenticator->users[n] = g_strdup (passwd->pw_name);
+    }
+
+  authenticator->dialog = polkit_mate_authentication_dialog_new
+                            (authenticator->action_id,
+                             polkit_action_description_get_vendor_name (authenticator->action_desc),
+                             polkit_action_description_get_vendor_url (authenticator->action_desc),
+                             authenticator->icon_name,
+                             authenticator->message,
+                             authenticator->details,
+                             authenticator->users);
+  g_signal_connect (authenticator->dialog,
+                    "delete-event",
+                    G_CALLBACK (on_dialog_deleted),
+                    authenticator);
+  g_signal_connect (authenticator->dialog,
+                    "notify::selected-user",
+                    G_CALLBACK (on_user_selected),
+                    authenticator);
+
+  return authenticator;
+
+ error:
+  g_object_unref (authenticator);
+  return NULL;
+}
+
+static void
+session_request (PolkitAgentSession *session,
+                 const char         *request,
+                 gboolean            echo_on,
+                 gpointer            user_data)
+{
+  PolkitMateAuthenticator *authenticator = POLKIT_MATE_AUTHENTICATOR (user_data);
+  gchar *password;
+  gchar *modified_request;
+
+  password = NULL;
+
+  //g_debug ("in conversation_pam_prompt, request='%s', echo_on=%d", request, echo_on);
+
+  /* Fix up, and localize, password prompt if it's password auth */
+  if (g_ascii_strncasecmp (request, "password:", 9) == 0)
+    {
+      if (strcmp (g_get_user_name (), authenticator->selected_user) != 0)
+        {
+          modified_request = g_strdup_printf (_("_Password for %s:"), authenticator->selected_user);
+        }
+      else
+        {
+          modified_request = g_strdup (_("_Password:"));
+        }
+    }
+  else
+    {
+      modified_request = g_strdup (request);
+    }
+
+  gtk_widget_show_all (GTK_WIDGET (authenticator->dialog));
+  if (GDK_IS_X11_WINDOW (gtk_widget_get_window (GTK_WIDGET (authenticator->dialog))))
+    gtk_window_present_with_time (GTK_WINDOW (authenticator->dialog),
+                                  gdk_x11_get_server_time (gtk_widget_get_window (GTK_WIDGET (authenticator->dialog))));
+  else
+    gtk_window_present (GTK_WINDOW (authenticator->dialog));
+
+  password = polkit_mate_authentication_dialog_run_until_response_for_prompt (POLKIT_MATE_AUTHENTICATION_DIALOG (authenticator->dialog),
+                                                                               modified_request,
+                                                                               echo_on,
+                                                                               &authenticator->was_cancelled,
+                                                                               &authenticator->new_user_selected);
+
+  /* cancel auth unless user provided a password */
+  if (password == NULL)
+    {
+      polkit_mate_authenticator_cancel (authenticator);
+      goto out;
+    }
+  else
+    {
+      polkit_agent_session_response (authenticator->session, password);
+      g_free (password);
+    }
+
+out:
+  g_free (modified_request);
+}
+
+static void
+session_show_error (PolkitAgentSession *session,
+                    const gchar        *msg,
+                    gpointer            user_data)
+{
+  PolkitMateAuthenticator *authenticator = POLKIT_MATE_AUTHENTICATOR (user_data);
+  gchar *s;
+
+  s = g_strconcat ("<b>", msg, "</b>", NULL);
+  polkit_mate_authentication_dialog_set_info_message (POLKIT_MATE_AUTHENTICATION_DIALOG (authenticator->dialog), s);
+  g_free (s);
+}
+
+static void
+session_show_info (PolkitAgentSession *session,
+                   const gchar        *msg,
+                   gpointer            user_data)
+{
+  PolkitMateAuthenticator *authenticator = POLKIT_MATE_AUTHENTICATOR (user_data);
+  gchar *s;
+
+  s = g_strconcat ("<b>", msg, "</b>", NULL);
+  polkit_mate_authentication_dialog_set_info_message (POLKIT_MATE_AUTHENTICATION_DIALOG (authenticator->dialog), s);
+  g_free (s);
+
+  gtk_widget_show_all (GTK_WIDGET (authenticator->dialog));
+  gtk_window_present (GTK_WINDOW (authenticator->dialog));
+}
+
+static void
+session_completed (PolkitAgentSession *session,
+                   gboolean            gained_authorization,
+                   gpointer            user_data)
+{
+  PolkitMateAuthenticator *authenticator = POLKIT_MATE_AUTHENTICATOR (user_data);
+
+  authenticator->gained_authorization = gained_authorization;
+
+  //g_debug ("in conversation_done gained=%d", gained_authorization);
+
+  g_main_loop_quit (authenticator->loop);
+}
+
+static gboolean
+do_initiate (gpointer user_data)
+{
+  PolkitMateAuthenticator *authenticator = POLKIT_MATE_AUTHENTICATOR (user_data);
+  PolkitIdentity *identity;
+  gint num_tries;
+
+  gtk_widget_show_all (GTK_WIDGET (authenticator->dialog));
+  gtk_window_present (GTK_WINDOW (authenticator->dialog));
+  if (!polkit_mate_authentication_dialog_run_until_user_is_selected (POLKIT_MATE_AUTHENTICATION_DIALOG (authenticator->dialog)))
+    {
+      /* user cancelled the dialog */
+      /*g_debug ("User cancelled before selecting a user");*/
+      authenticator->was_cancelled = TRUE;
+      goto out;
+    }
+
+  authenticator->loop = g_main_loop_new (NULL, TRUE);
+
+  num_tries = 0;
+
+ try_again:
+
+  g_free (authenticator->selected_user);
+  authenticator->selected_user = polkit_mate_authentication_dialog_get_selected_user (POLKIT_MATE_AUTHENTICATION_DIALOG (authenticator->dialog));
+
+  /*g_debug ("Authenticating user %s", authenticator->selected_user);*/
+  identity = polkit_unix_user_new_for_name (authenticator->selected_user, NULL);
+
+  authenticator->session = polkit_agent_session_new (identity, authenticator->cookie);
+
+  g_object_unref (identity);
+
+  g_signal_connect (authenticator->session,
+                    "request",
+                    G_CALLBACK (session_request),
+                    authenticator);
+
+  g_signal_connect (authenticator->session,
+                    "show-info",
+                    G_CALLBACK (session_show_info),
+                    authenticator);
+
+  g_signal_connect (authenticator->session,
+                    "show-error",
+                    G_CALLBACK (session_show_error),
+                    authenticator);
+
+  g_signal_connect (authenticator->session,
+                    "completed",
+                    G_CALLBACK (session_completed),
+                    authenticator);
+
+  polkit_agent_session_initiate (authenticator->session);
+
+  g_main_loop_run (authenticator->loop);
+
+  /*g_debug ("gained_authorization=%d was_cancelled=%d new_user_selected=%d.",
+           authenticator->gained_authorization,
+           authenticator->was_cancelled,
+           authenticator->new_user_selected);*/
+
+  if (authenticator->new_user_selected)
+    {
+      /*g_debug ("New user selected");*/
+      authenticator->new_user_selected = FALSE;
+      g_object_unref (authenticator->session);
+      authenticator->session = NULL;
+      goto try_again;
+    }
+
+  num_tries++;
+
+  if (!authenticator->gained_authorization && !authenticator->was_cancelled)
+    {
+      if (authenticator->dialog != NULL)
+        {
+          gchar *s;
+
+          s = g_strconcat ("<b>", _("Your authentication attempt was unsuccessful. Please try again."), "</b>", NULL);
+          polkit_mate_authentication_dialog_set_info_message (
+                                  POLKIT_MATE_AUTHENTICATION_DIALOG (authenticator->dialog),
+                                  s);
+          g_free (s);
+          gtk_widget_queue_draw (authenticator->dialog);
+
+          /* shake the dialog to indicate error */
+          polkit_mate_authentication_dialog_indicate_error (POLKIT_MATE_AUTHENTICATION_DIALOG (authenticator->dialog));
+
+          if (num_tries < 3)
+            {
+              g_object_unref (authenticator->session);
+              authenticator->session = NULL;
+              goto try_again;
+            }
+        }
+    }
+
+ out:
+  g_signal_emit_by_name (authenticator,
+                         "completed",
+                         authenticator->gained_authorization,
+                         authenticator->was_cancelled);
+
+  g_object_unref (authenticator);
+
+  return FALSE;
+}
+
+void
+polkit_mate_authenticator_initiate (PolkitMateAuthenticator *authenticator)
+{
+  /* run from idle since we're going to block the main loop in the dialog (which has a recursive mainloop) */
+  g_idle_add (do_initiate, g_object_ref (authenticator));
+}
+
+void
+polkit_mate_authenticator_cancel (PolkitMateAuthenticator *authenticator)
+{
+  if (authenticator->dialog != NULL)
+    polkit_mate_authentication_dialog_cancel (POLKIT_MATE_AUTHENTICATION_DIALOG (authenticator->dialog));
+
+  authenticator->was_cancelled = TRUE;
+
+  if (authenticator->session != NULL)
+    {
+      polkit_agent_session_cancel (authenticator->session);
+    }
+}
+
+const gchar *
+polkit_mate_authenticator_get_cookie (PolkitMateAuthenticator *authenticator)<--- Parameter 'authenticator' can be declared as pointer to const
+{
+  return authenticator->cookie;
+}
+
+
+ +
+ +
+ + diff --git a/2024-02-26-105807-9780-cppcheck@c2df8de7c7b1_master/5.html b/2024-02-26-105807-9780-cppcheck@c2df8de7c7b1_master/5.html new file mode 100644 index 0000000..b1c66d2 --- /dev/null +++ b/2024-02-26-105807-9780-cppcheck@c2df8de7c7b1_master/5.html @@ -0,0 +1,351 @@ + + + + + + Cppcheck - HTML report - mate-polkit + + + + + +
+ + + +
+
 1
+ 2
+ 3
+ 4
+ 5
+ 6
+ 7
+ 8
+ 9
+10
+11
+12
+13
+14
+15
+16
+17
+18
+19
+20
+21
+22
+23
+24
+25
+26
+27
+28
+29
+30
+31
+32
+33
+34
+35
+36
+37
+38
+39
+40
+41
+42
+43
+44
+45
+46
+47
+48
+49
+50
+51
+52
+53
+54
+55
+56
+57
/*
+ * Copyright (C) 2009 Red Hat, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ * Author: David Zeuthen <davidz@redhat.com>
+ */
+
+#ifndef __POLKIT_MATE_AUTHENTICATOR_H
+#define __POLKIT_MATE_AUTHENTICATOR_H
+
+#include <glib-object.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define POLKIT_MATE_TYPE_AUTHENTICATOR          (polkit_mate_authenticator_get_type())
+#define POLKIT_MATE_AUTHENTICATOR(o)            (G_TYPE_CHECK_INSTANCE_CAST ((o), POLKIT_MATE_TYPE_AUTHENTICATOR, PolkitMateAuthenticator))
+#define POLKIT_MATE_AUTHENTICATOR_CLASS(k)      (G_TYPE_CHECK_CLASS_CAST((k), POLKIT_MATE_TYPE_AUTHENTICATOR, PolkitMateAuthenticatorClass))
+#define POLKIT_MATE_AUTHENTICATOR_GET_CLASS(o)  (G_TYPE_INSTANCE_GET_CLASS ((o), POLKIT_MATE_TYPE_AUTHENTICATOR, PolkitMateAuthenticatorClass))
+#define POLKIT_MATE_IS_AUTHENTICATOR(o)         (G_TYPE_CHECK_INSTANCE_TYPE ((o), POLKIT_MATE_TYPE_AUTHENTICATOR))
+#define POLKIT_MATE_IS_AUTHENTICATOR_CLASS(k)   (G_TYPE_CHECK_CLASS_TYPE ((k), POLKIT_MATE_TYPE_AUTHENTICATOR))
+
+typedef struct _PolkitMateAuthenticator PolkitMateAuthenticator;
+typedef struct _PolkitMateAuthenticatorClass PolkitMateAuthenticatorClass;
+
+GType                      polkit_mate_authenticator_get_type   (void) G_GNUC_CONST;
+PolkitMateAuthenticator  *polkit_mate_authenticator_new        (const gchar              *action_id,
+                                                                  const gchar              *message,
+                                                                  const gchar              *icon_name,
+                                                                  PolkitDetails            *details,
+                                                                  const gchar              *cookie,
+                                                                  GList                    *identities);
+void                       polkit_mate_authenticator_initiate   (PolkitMateAuthenticator *authenticator);
+void                       polkit_mate_authenticator_cancel     (PolkitMateAuthenticator *authenticator);
+const gchar               *polkit_mate_authenticator_get_cookie (PolkitMateAuthenticator *authenticator);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* __POLKIT_MATE_AUTHENTICATOR_H */
+
+ +
+ +
+ + diff --git a/2024-02-26-105807-9780-cppcheck@c2df8de7c7b1_master/6.html b/2024-02-26-105807-9780-cppcheck@c2df8de7c7b1_master/6.html new file mode 100644 index 0000000..79a947d --- /dev/null +++ b/2024-02-26-105807-9780-cppcheck@c2df8de7c7b1_master/6.html @@ -0,0 +1,761 @@ + + + + + + Cppcheck - HTML report - mate-polkit + + + + + +
+ + + +
+
  1
+  2
+  3
+  4
+  5
+  6
+  7
+  8
+  9
+ 10
+ 11
+ 12
+ 13
+ 14
+ 15
+ 16
+ 17
+ 18
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
+ 26
+ 27
+ 28
+ 29
+ 30
+ 31
+ 32
+ 33
+ 34
+ 35
+ 36
+ 37
+ 38
+ 39
+ 40
+ 41
+ 42
+ 43
+ 44
+ 45
+ 46
+ 47
+ 48
+ 49
+ 50
+ 51
+ 52
+ 53
+ 54
+ 55
+ 56
+ 57
+ 58
+ 59
+ 60
+ 61
+ 62
+ 63
+ 64
+ 65
+ 66
+ 67
+ 68
+ 69
+ 70
+ 71
+ 72
+ 73
+ 74
+ 75
+ 76
+ 77
+ 78
+ 79
+ 80
+ 81
+ 82
+ 83
+ 84
+ 85
+ 86
+ 87
+ 88
+ 89
+ 90
+ 91
+ 92
+ 93
+ 94
+ 95
+ 96
+ 97
+ 98
+ 99
+100
+101
+102
+103
+104
+105
+106
+107
+108
+109
+110
+111
+112
+113
+114
+115
+116
+117
+118
+119
+120
+121
+122
+123
+124
+125
+126
+127
+128
+129
+130
+131
+132
+133
+134
+135
+136
+137
+138
+139
+140
+141
+142
+143
+144
+145
+146
+147
+148
+149
+150
+151
+152
+153
+154
+155
+156
+157
+158
+159
+160
+161
+162
+163
+164
+165
+166
+167
+168
+169
+170
+171
+172
+173
+174
+175
+176
+177
+178
+179
+180
+181
+182
+183
+184
+185
+186
+187
+188
+189
+190
+191
+192
+193
+194
+195
+196
+197
+198
+199
+200
+201
+202
+203
+204
+205
+206
+207
+208
+209
+210
+211
+212
+213
+214
+215
+216
+217
+218
+219
+220
+221
+222
+223
+224
+225
+226
+227
+228
+229
+230
+231
+232
+233
+234
+235
+236
+237
+238
+239
+240
+241
+242
+243
+244
+245
+246
+247
+248
+249
+250
+251
+252
+253
+254
+255
+256
+257
+258
+259
+260
+261
+262
/*
+ * Copyright (C) 2009 Red Hat, Inc.
+ * Copyright (C) 2012-2021 MATE Developers
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General
+ * Public License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ * Author: David Zeuthen <davidz@redhat.com>
+ */
+
+#include "config.h"<--- Include file: "config.h" not found.
+
+#include <string.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+#include <glib/gi18n.h><--- Include file:  not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+#include "polkitmatelistener.h"
+#include "polkitmateauthenticator.h"
+
+struct _PolkitMateListener
+{
+  PolkitAgentListener parent_instance;
+
+  /* we support multiple authenticators - they are simply queued up */
+  GList *authenticators;
+
+  PolkitMateAuthenticator *active_authenticator;
+};
+
+struct _PolkitMateListenerClass
+{
+  PolkitAgentListenerClass parent_class;
+};
+
+static void polkit_mate_listener_initiate_authentication (PolkitAgentListener  *listener,
+                                                           const gchar          *action_id,
+                                                           const gchar          *message,
+                                                           const gchar          *icon_name,
+                                                           PolkitDetails        *details,
+                                                           const gchar          *cookie,
+                                                           GList                *identities,
+                                                           GCancellable         *cancellable,
+                                                           GAsyncReadyCallback   callback,
+                                                           gpointer              user_data);
+
+static gboolean polkit_mate_listener_initiate_authentication_finish (PolkitAgentListener  *listener,
+                                                                      GAsyncResult         *res,
+                                                                      GError              **error);
+
+G_DEFINE_TYPE (PolkitMateListener, polkit_mate_listener, POLKIT_AGENT_TYPE_LISTENER);
+
+static void
+polkit_mate_listener_init (PolkitMateListener *listener)
+{
+}
+
+static void
+polkit_mate_listener_finalize (GObject *object)
+{
+  if (G_OBJECT_CLASS (polkit_mate_listener_parent_class)->finalize != NULL)
+    G_OBJECT_CLASS (polkit_mate_listener_parent_class)->finalize (object);
+}
+
+static void
+polkit_mate_listener_class_init (PolkitMateListenerClass *klass)
+{
+  GObjectClass *gobject_class;
+  PolkitAgentListenerClass *listener_class;
+
+  gobject_class = G_OBJECT_CLASS (klass);
+  listener_class = POLKIT_AGENT_LISTENER_CLASS (klass);
+
+  gobject_class->finalize = polkit_mate_listener_finalize;
+
+  listener_class->initiate_authentication          = polkit_mate_listener_initiate_authentication;
+  listener_class->initiate_authentication_finish   = polkit_mate_listener_initiate_authentication_finish;
+}
+
+PolkitAgentListener *
+polkit_mate_listener_new (void)
+{
+  return POLKIT_AGENT_LISTENER (g_object_new (POLKIT_MATE_TYPE_LISTENER, NULL));
+}
+
+typedef struct
+{
+  PolkitMateListener *listener;
+  PolkitMateAuthenticator *authenticator;
+
+  GTask        *task;
+  GCancellable *cancellable;
+
+  gulong cancel_id;
+} AuthData;
+
+static AuthData *
+auth_data_new (PolkitMateListener *listener,
+               PolkitMateAuthenticator *authenticator,
+               GTask *task,
+               GCancellable *cancellable)
+{
+  AuthData *data;
+
+  data = g_new0 (AuthData, 1);
+  data->listener = g_object_ref (listener);
+  data->authenticator = g_object_ref (authenticator);
+  data->task = g_object_ref (task);
+  data->cancellable = g_object_ref (cancellable);
+  return data;
+}
+
+static void
+auth_data_free (AuthData *data)
+{
+  g_object_unref (data->listener);
+  g_object_unref (data->authenticator);
+  g_object_unref (data->task);
+  if (data->cancellable != NULL && data->cancel_id > 0)
+    g_signal_handler_disconnect (data->cancellable, data->cancel_id);
+  g_object_unref (data->cancellable);
+  g_free (data);
+}
+
+static void
+maybe_initiate_next_authenticator (PolkitMateListener *listener)
+{
+  if (listener->active_authenticator == NULL && listener->authenticators != NULL)
+    {
+      polkit_mate_authenticator_initiate (POLKIT_MATE_AUTHENTICATOR (listener->authenticators->data));
+      listener->active_authenticator = listener->authenticators->data;
+    }
+}
+
+static void
+authenticator_completed (PolkitMateAuthenticator *authenticator,
+                         gboolean                 gained_authorization,
+                         gboolean                 dismissed,
+                         gpointer                 user_data)
+{
+  AuthData *data = user_data;
+
+  data->listener->authenticators = g_list_remove (data->listener->authenticators, authenticator);
+  if (authenticator == data->listener->active_authenticator)
+    data->listener->active_authenticator = NULL;
+
+  g_object_unref (authenticator);
+
+  if (dismissed)
+    {
+      g_task_return_new_error (data->task,
+                               POLKIT_ERROR,
+                               POLKIT_ERROR_CANCELLED,
+                               _("Authentication dialog was dismissed by the user"));
+    }
+
+  g_task_return_boolean (data->task, TRUE);
+  g_object_unref (data->task);
+
+  maybe_initiate_next_authenticator (data->listener);
+
+  auth_data_free (data);
+}
+
+static void
+cancelled_cb (GCancellable *cancellable,
+              gpointer user_data)
+{
+  AuthData *data = user_data;
+
+  polkit_mate_authenticator_cancel (data->authenticator);
+}
+
+static void
+polkit_mate_listener_initiate_authentication (PolkitAgentListener  *agent_listener,
+                                               const gchar          *action_id,
+                                               const gchar          *message,
+                                               const gchar          *icon_name,
+                                               PolkitDetails        *details,
+                                               const gchar          *cookie,
+                                               GList                *identities,
+                                               GCancellable         *cancellable,
+                                               GAsyncReadyCallback   callback,
+                                               gpointer              user_data)
+{
+  PolkitMateListener *listener = POLKIT_MATE_LISTENER (agent_listener);
+  GTask *task;
+  PolkitMateAuthenticator *authenticator;
+  AuthData *data;
+
+  task = g_task_new (G_OBJECT (listener),
+                     NULL,
+                     callback,
+                     user_data);
+  g_task_set_source_tag (task,
+                         polkit_mate_listener_initiate_authentication);
+
+  authenticator = polkit_mate_authenticator_new (action_id,
+                                                  message,
+                                                  icon_name,
+                                                  details,
+                                                  cookie,
+                                                  identities);
+  if (authenticator == NULL)
+    {
+      g_task_return_new_error (task,
+                               POLKIT_ERROR,
+                               POLKIT_ERROR_FAILED,
+                               "Error creating authentication object");
+      g_object_unref (task);
+      goto out;
+    }
+
+  data = auth_data_new (listener, authenticator, task, cancellable);
+
+  g_signal_connect (authenticator,
+                    "completed",
+                    G_CALLBACK (authenticator_completed),
+                    data);
+
+  if (cancellable != NULL)
+    {
+      data->cancel_id = g_signal_connect (cancellable,
+                                          "cancelled",
+                                          G_CALLBACK (cancelled_cb),
+                                          data);
+    }
+
+  listener->authenticators = g_list_append (listener->authenticators, authenticator);
+
+  maybe_initiate_next_authenticator (listener);
+
+ out:
+  ;
+}
+
+static gboolean
+polkit_mate_listener_initiate_authentication_finish (PolkitAgentListener  *listener,
+                                                      GAsyncResult         *res,
+                                                      GError              **error)
+{
+  GTask *task = G_TASK (res);
+
+  g_warn_if_fail (g_task_get_source_tag (task) == polkit_mate_listener_initiate_authentication);
+
+  if (g_task_propagate_pointer (task, error) == NULL) {
+    return FALSE;
+  }
+
+  return TRUE;
+}
+
+
+ +
+ +
+ + diff --git a/2024-02-26-105807-9780-cppcheck@c2df8de7c7b1_master/index.html b/2024-02-26-105807-9780-cppcheck@c2df8de7c7b1_master/index.html new file mode 100644 index 0000000..35f12cd --- /dev/null +++ b/2024-02-26-105807-9780-cppcheck@c2df8de7c7b1_master/index.html @@ -0,0 +1,252 @@ + + + + + + Cppcheck - HTML report - mate-polkit + + + + + +
+ + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
LineIdCWESeverityMessage
checkersReportinformationActive checkers: 106/592 (use --checkers-report=<filename> to see details)
src/main.c
23missingIncludeinformationInclude file: "config.h" not found.
26missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <gio/gio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
29missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
30missingIncludeSysteminformationInclude file: <polkitagent/polkitagent.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
33missingIncludeSysteminformationInclude file: <libayatana-appindicator/app-indicator.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
35missingIncludeSysteminformationInclude file: <libappindicator/app-indicator.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
226shadowVariable398styleLocal variable 'authority' shadows outer variable
316constParameterCallback398styleParameter 'signal_name' can be declared as pointer to const. However it seems that 'signal_cb' is a callback function, if 'signal_name' is declared with const you might also need to cast function pointer(s).
src/polkitmateauthenticationdialog.c
24missingIncludeinformationInclude file: "config.h" not found.
28missingIncludeSysteminformationInclude file: <unistd.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
29missingIncludeSysteminformationInclude file: <sys/types.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
30missingIncludeSysteminformationInclude file: <sys/stat.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
31missingIncludeSysteminformationInclude file: <fcntl.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
32missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
33missingIncludeSysteminformationInclude file: <stdio.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
34missingIncludeSysteminformationInclude file: <stdlib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
35missingIncludeSysteminformationInclude file: <pwd.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
36missingIncludeSysteminformationInclude file: <errno.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
38missingIncludeSysteminformationInclude file: <glib/gi18n-lib.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
39missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
99constVariablePointer398styleVariable 'indices' can be declared as pointer to const
src/polkitmateauthenticationdialog.h
26missingIncludeSysteminformationInclude file: <gtk/gtk.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <polkit/polkit.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/polkitmateauthenticator.c
23missingIncludeinformationInclude file: "config.h" not found.
25missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <sys/types.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
27missingIncludeSysteminformationInclude file: <pwd.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
28missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
29missingIncludeSysteminformationInclude file: <gdk/gdkx.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
31missingIncludeSysteminformationInclude file: <polkit/polkit.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
32missingIncludeSysteminformationInclude file: <polkitagent/polkitagent.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
512constParameterPointer398styleParameter 'authenticator' can be declared as pointer to const
src/polkitmateauthenticator.h
26missingIncludeSysteminformationInclude file: <glib-object.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/polkitmatelistener.c
23missingIncludeinformationInclude file: "config.h" not found.
25missingIncludeSysteminformationInclude file: <string.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
26missingIncludeSysteminformationInclude file: <glib/gi18n.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
src/polkitmatelistener.h
26missingIncludeSysteminformationInclude file: <polkitagent/polkitagent.h> not found. Please note: Cppcheck does not need standard library headers to get proper results.
+
+ +
+ + diff --git a/2024-02-26-105807-9780-cppcheck@c2df8de7c7b1_master/stats.html b/2024-02-26-105807-9780-cppcheck@c2df8de7c7b1_master/stats.html new file mode 100644 index 0000000..5c5881a --- /dev/null +++ b/2024-02-26-105807-9780-cppcheck@c2df8de7c7b1_master/stats.html @@ -0,0 +1,178 @@ + + + + + + Cppcheck - HTML report - mate-polkit + + + + + +
+ + + +
+

Top 10 files for style severity, total findings: 4
+   2  src/main.c
+   1  src/polkitmateauthenticator.c
+   1  src/polkitmateauthenticationdialog.c
+

+

Top 10 files for information severity, total findings: 35
+   12  src/polkitmateauthenticationdialog.c
+   8   src/polkitmateauthenticator.c
+   8   src/main.c
+   3   src/polkitmatelistener.c
+   2   src/polkitmateauthenticationdialog.h
+   1   src/polkitmatelistener.h
+   1   src/polkitmateauthenticator.h
+

+ +
+ +
+ + diff --git a/2024-02-26-105807-9780-cppcheck@c2df8de7c7b1_master/style.css b/2024-02-26-105807-9780-cppcheck@c2df8de7c7b1_master/style.css new file mode 100644 index 0000000..3897bfa --- /dev/null +++ b/2024-02-26-105807-9780-cppcheck@c2df8de7c7b1_master/style.css @@ -0,0 +1,177 @@ + +body { + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif; + font-size: 13px; + line-height: 1.5; + height: 100%; + margin: 0; +} + +#wrapper { + position: fixed; + height: 100vh; + width: 100vw; + display: grid; + grid-template-rows: fit-content(8rem) auto fit-content(8rem); + grid-template-columns: fit-content(25%) 1fr; + grid-template-areas: + "header header" + "menu content" + "footer footer"; +} + +h1 { + margin: 0 0 8px -2px; + font-size: 175%; +} + +.header { + padding: 0 0 5px 15px; + grid-area: header; + border-bottom: thin solid #aaa; +} + +.footer { + grid-area: footer; + border-top: thin solid #aaa; + font-size: 85%; + +} + +.footer > p { + margin: 4px; +} + +#menu, +#menu_index { + grid-area: menu; + text-align: left; + overflow: auto; + padding: 0 23px 15px 15px; + border-right: thin solid #aaa; + min-width: 200px; +} + +#menu > a { + display: block; + margin-left: 10px; + font-size: 12px; +} + +#content, +#content_index { + grid-area: content; + padding: 0px 5px 15px 15px; + overflow: auto; +} + +label { + white-space: nowrap; +} + +label.checkBtn.disabled { + color: #606060; + background: #e0e0e0; + font-style: italic; +} + +label.checkBtn, input[type="text"] { + border: 1px solid grey; + border-radius: 4px; + box-shadow: 1px 1px inset; + padding: 1px 5px; +} + +label.checkBtn { + white-space: nowrap; + background: #ccddff; +} + +label.unchecked { + background: #eff8ff; + box-shadow: 1px 1px 1px; +} + +label.checkBtn:hover, label.unchecked:hover{ + box-shadow: 0 0 2px; +} + +label.disabled:hover { + box-shadow: 1px 1px inset; +} + +label.checkBtn > input { + display:none; +} + +.summaryTable { + width: 100%; +} + +table.summaryTable td { padding: 0 5px 0 5px; } + +.statHeader, .severityHeader { + font-weight: bold; +} + +.warning { + background-color: #ffffa7; +} + +.error { + background-color: #ffb7b7; +} + +.error2 { + background-color: #faa; + display: inline-block; + margin-left: 4px; +} + +.inconclusive { + background-color: #b6b6b4; +} + +.inconclusive2 { + background-color: #b6b6b4; + display: inline-block; + margin-left: 4px; +} + +.verbose { + display: inline-block; + vertical-align: top; + cursor: help; +} + +.verbose .content { + display: none; + position: absolute; + padding: 10px; + margin: 4px; + max-width: 40%; + white-space: pre-wrap; + border: 1px solid #000; + background-color: #ffffcc; + cursor: auto; +} + +.highlight .hll { + padding: 1px; +} + +.highlighttable { + background-color: #fff; + position: relative; + margin: -10px; +} + +.linenos { + border-right: thin solid #aaa; + color: #d3d3d3; + padding-right: 6px; +} + +.id-filtered, .severity-filtered, .file-filtered, .tool-filtered, .text-filtered { + visibility: collapse; +} diff --git a/CNAME b/CNAME new file mode 100644 index 0000000..49eef4f --- /dev/null +++ b/CNAME @@ -0,0 +1 @@ +mate-polkit.mate-desktop.dev diff --git a/index.html b/index.html new file mode 100644 index 0000000..e7a2170 --- /dev/null +++ b/index.html @@ -0,0 +1,46 @@ + + + + + mate-polkit Code Analyzer results + + +

+ mate-desktop/mate-polkit Static analyzer results +

+ GitHub + Build Status +
+Commit: c2df8de7c7b144189fc895639fc21261cf4c5d7d
+Compare: ad6d40200d0a...c2df8de7c7b1
+Branch: master
+Time: 2024-02-26 10:58:07+00:00
+Messages:
+
+release 1.28.1
+
+
+ + + -- cgit v1.2.1