File: 00-disable-dpkg-access.patch

package info (click to toggle)
lxsession 0.5.6-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,188 kB
  • sloc: ansic: 4,087; makefile: 523; sh: 238; xml: 114
file content (734 lines) | stat: -rw-r--r-- 23,886 bytes parent folder | download | duplicates (3)
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
Author: Andriy Grytsenko <andrej@rep.kiev.ua>
Description: Remove all dpkg related code from lxsession, it's forbidden by the Debian policy.

--- a/lxsession/app.vala
+++ b/lxsession/app.vala
@@ -1163,534 +1163,6 @@
     }
 }
 
-public class UpdatesManagerApp: SimpleAppObject
-{
-    string updatesmanager_command;
-
-    IconObject updates_icon;
-    MenuObject icon_menu;
-
-    IconObject language_icon;
-
-    IconObject reboot_icon;
-
-    string apt_update_path = "/var/lib/apt/periodic/update-success-stamp";
-    GLib.File apt_update_file ;
-    GLib.FileMonitor apt_update_monitor ;
-
-    string dpkg_update_path = "/var/lib/dpkg/status";
-    GLib.File dpkg_update_file ;
-    GLib.FileMonitor dpkg_update_monitor ;
-
-    string dpkg_run_path = "/var/lib/update-notifier/dpkg-run-stamp";
-    GLib.File dpkg_run_file ;
-    GLib.FileMonitor dpkg_run_monitor ;
-
-    string apt_lists_update_path = "/var/lib/apt/lists";
-    GLib.File apt_lists_update_file ;
-    GLib.FileMonitor apt_lists_update_monitor ;
-
-    string reboot_path = "/var/run/reboot-required";
-    GLib.File reboot_file ;
-    GLib.FileMonitor reboot_monitor ;
-
-    string dpkg_lock_file = "/var/lib/dpkg/lock";
-
-    int lock_check = 0;
-
-    public UpdatesManagerApp ()
-    {
-        init();
-    }
-
-    public override void read_settings()
-    {
-        updatesmanager_command = global_settings.get_item_string("Session", "updates_manager", "command");
-
-        switch (updatesmanager_command)
-        {
-            case null:
-                break;
-            case "":
-                break;
-            case " ":
-                break;
-            case "update-notifier-clone":
-                setup_apt_config();
-                setup_reboot_config();
-                run_check();
-                break;
-            default:
-                string[] create_command = updatesmanager_command.split_set(" ",0);
-                this.name = create_command[0];
-                this.command = create_command;
-                break;
-        }
-    }
-
-    public void test_inactivate()
-    {
-        updates_icon.inactivate();
-    }
-
-    public void test_activate()
-    {
-        updates_icon.activate();
-    }
-
-    public void run_check()
-    {
-        if (this.lock_check == 0)
-        {
-            if (check_lock_file(dpkg_lock_file) == true)
-            {
-                this.lock_check = 1;
-                int timeout = 60;
-                if (global_settings.get_item_string("Session", "updates_manager", "timeout") != null)
-                {
-                    timeout = int.parse(global_settings.get_item_string("Session", "updates_manager", "timeout"));
-                }
-                GLib.Timeout.add_seconds(timeout, on_apt_update_file_change);
-            }
-        }
-    }
-
-    public void reboot_launch()
-    {
-        var session = new SessionObject();
-        session.lxsession_restart();
-    }
-
-    public void run_check_reboot()
-    {
-        string notification_text ="";
-
-        if (this.reboot_file.query_exists ())
-        {
-            if (this.reboot_icon == null)
-            {
-                var reboot_icon_menu = new MenuObject() ;
-                string line = _("Reboot required");
-
-                try
-                {
-                    var dis = new DataInputStream (this.reboot_file.read ());
-                    line = dis.read_line ();
-                }
-                catch (GLib.Error e)
-                {
-                    message ("Error: %s\n", e.message);
-                }
-
-                if (line != null)
-                {
-                    notification_text = line;
-                }
-
-                var menu_item = new MenuItemObject();
-                menu_item.set_label(notification_text);
-                menu_item.activate.connect(() => {
-                    reboot_launch();
-                });
-                menu_item.show();
-                reboot_icon_menu.add(menu_item);
-
-                this.reboot_icon = new IconObject("RebootIcon", "system-reboot", notification_text, reboot_icon_menu);
-                this.reboot_icon.init();
-                this.reboot_icon.clear_actions ();
-                this.reboot_icon.add_action ("launch_reboot", _("Reboot"), () =>
-                {
-                    reboot_launch();
-                });
-                this.reboot_icon.activate();
-            }
-        }
-        else
-        {
-            if (this.reboot_icon != null)
-            {
-                this.reboot_icon.inactivate();
-            }
-        }
-    }
-
-    public void language_launch()
-    {
-        if (this.language_icon != null)
-        {
-            try
-            {
-                Process.spawn_command_line_async("gnome-language-selector");
-                this.language_icon.inactivate();
-            }
-            catch (SpawnError err)
-            {
-                warning (err.message);
-            }
-        }
-    }
-
-    public void check_language_support()
-    {
-        string command = "check-language-support";
-
-        string standard_output;
-        string standard_error;
-        int exit_status;
-
-        string launch_string = _("Launch language support");
-
-        try
-        {
-            Process.spawn_command_line_sync (command, out standard_output, out standard_error, out exit_status);
-
-            message ("Launching %s", command);
-            message ("Language state: %s", standard_error);
-            message ("Language exit status: %i", exit_status);
-            message ("Language output: %s", standard_output);
-
-        }
-        catch (SpawnError err)
-        {
-            warning (err.message);
-        }
-
-        if (standard_output != null)
-        {
-            if (standard_output.length >= 3)
-            {
-                if (this.language_icon == null)
-                {
-                    var language_icon_menu = new MenuObject() ;
-
-                    var menu_item = new MenuItemObject();
-                    menu_item.set_label(launch_string);
-                    menu_item.activate.connect(() => {
-                        language_launch();
-                    });
-                    menu_item.show();
-                    language_icon_menu.add(menu_item);
-
-                    this.language_icon = new IconObject("LanguageIcon", "preferences-desktop-locale", _("Language support missing"), language_icon_menu);
-                    this.language_icon.init();
-                    this.language_icon.clear_actions ();
-                    this.language_icon.add_action ("launch_language_support", launch_string, () =>
-                    {
-                        language_launch();
-                    });
-                    this.language_icon.activate();
-                }
-            }
-            else if (this.language_icon != null)
-                {
-                    this.language_icon.inactivate();
-                }
-        }
-        else if (this.language_icon != null)
-            {
-                this.language_icon.inactivate();
-            }
-    }
-
-    public void upgrade_launch (string upgrade_manager_command)
-    {
-        try
-        {
-            Process.spawn_command_line_async(upgrade_manager_command);
-        }
-        catch (SpawnError err)
-        {
-            warning (err.message);
-        }
-    }
-
-    public bool on_apt_update_file_change()
-    {
-        /* Launch something that check if updates are available */
-        /* For now, use lxsession-apt-check, which is apt-check from update-notifier */
-
-        string standard_output;
-        string standard_error;
-        int exit_status;
-
-        string notification_text = _("Updates available");
-
-        string launch_string = _("Launch Update Manager");
-        string upgrade_manager_command = "";
-
-        string[] updates_num;
-        int updates_urgent = 0;
-        int updates_normal = 0;
-        int updates_state = 0;
-        int number_updates = 0;
-
-        /* Lock the check process, to avoid launching the check many times when one is already running */
-        this.lock_check = 1;
-
-        if (this.icon_menu == null)
-        {
-            this.icon_menu = new MenuObject();
-
-            if (global_settings.get_item_string("Session", "upgrade_manager", "command") != null)
-            {
-                upgrade_manager_command = global_settings.get_item_string("Session", "upgrade_manager", "command");
-
-                var menu_item = new MenuItemObject();
-                menu_item.set_label(launch_string);
-                menu_item.activate.connect(() => {
-                    upgrade_launch (upgrade_manager_command);
-                });
-                menu_item.show();
-                icon_menu.add(menu_item);
-            }
-        }
-
-        string command = "/usr/bin/nice" + " " + "/usr/bin/ionice" + " " + "-c3" + " " + "/usr/lib/update-notifier/apt-check";
-
-        string error_string = "";
-
-        try
-        {
-            Process.spawn_command_line_sync (command, out standard_output, out standard_error, out exit_status);
-
-            message ("Launching %s", command);
-            message ("Update state: %s", standard_error);
-            message ("Update exit status: %i", exit_status);
-
-        }
-        catch (SpawnError err)
-        {
-            warning (err.message);
-        }
-
-        if (this.updates_icon == null)
-        {
-            this.updates_icon = new IconObject("UpdatesIcon", "software-update-available", notification_text, this.icon_menu);
-            this.updates_icon.init();
-            if (global_settings.get_item_string("Session", "upgrade_manager", "command") != null)
-            {
-                upgrade_manager_command = global_settings.get_item_string("Session", "upgrade_manager", "command");
-                this.updates_icon.clear_actions ();
-                this.updates_icon.add_action ("launch_upgrade_manager", launch_string, () =>
-                {
-                    upgrade_launch (upgrade_manager_command);
-                });
-            }
-            this.updates_icon.inactivate();
-        }
-        else
-        {
-            this.updates_icon.inactivate();
-        }
-
-        if (standard_error != "")
-        {
-            if (standard_error[0:1] == "E")
-            {
-                updates_urgent = 0;
-                updates_normal = 0;
-                updates_state = 1;
-                error_string =   _("An error occurred, please run Package Manager from the left-click menu or apt-get in a terminal to see what is wrong.");
-                if (standard_error.length > 3)
-                {
-                    notification_text = error_string + "\n" + _("The error message was: ") + standard_error;
-                }
-                else
-                {
-                    notification_text = error_string;
-                }
-            }
-            else
-                {
-                    updates_num = standard_error.split_set(";",2);
-                    message ("Number of upgrades: %s", updates_num[0]);
-                    message ("Number of security upgrades: %s", updates_num[1]);
-                    updates_num[2] = "0";
-
-                    updates_urgent = int.parse(updates_num[1]);
-                    updates_normal = int.parse(updates_num[0]);
-                    number_updates = updates_normal + updates_urgent;
-
-                    if (number_updates == 1)
-                    {
-                        notification_text = number_updates.to_string() + _(" Update available");
-                    }
-                    else if (number_updates > 1)
-                        {
-                            notification_text = number_updates.to_string() + (" ") + _("Updates available");
-                        }
-                }
-
-        }
-        else
-        {
-            updates_state = 1;
-        }
-
-
-        if (number_updates > 0)
-        {
-            message("Activate icon because of updates available");
-            this.updates_icon.set_notification_body(notification_text);
-            this.updates_icon.activate();
-        }
-
-        if (updates_urgent > 0)
-        {
-            message("Set urgent icon");
-            this.updates_icon.set_icon("software-update-urgent");
-            this.updates_icon.set_notification_body(notification_text);
-        }
-
-
-        if (updates_state > 0)
-        {
-            message("Problem in package state");
-            this.updates_icon.set_icon("software-update-urgent");
-            this.updates_icon.set_notification_body(notification_text);
-            this.updates_icon.clear_actions ();
-            this.updates_icon.add_action ("launch_upgrade_manager", launch_string, () =>
-            {
-                upgrade_launch ("synaptic-pkexec");
-            });
-            var new_menu = new MenuObject();
-            var new_menu_item = new MenuItemObject();
-            new_menu_item.set_label(launch_string);
-            new_menu_item.activate.connect(() => {
-                upgrade_launch ("synaptic-pkexec");
-            });
-            new_menu_item.show();
-            new_menu.add(new_menu_item);
-            this.updates_icon.set_menu(new_menu);
-            this.updates_icon.activate();
-        }
-
-        /* Check if language support is complete */
-        check_language_support();
-
-        /* Check if a reboot is requiered */
-        run_check_reboot();
-
-        /* Unlock the check */
-        this.lock_check = 0;
-
-        return false;
-    }
-
-    public void setup_apt_config ()
-    {
-        /* Note directories monitored by update-notifier :
-                "/var/lib/apt/lists/" ==> files of meta data of the repositories
-                "/var/lib/apt/lists/partial/"
-                "/var/cache/apt/archives/" ==> .deb in cache
-                "/var/cache/apt/archives/partial/"
-
-            Files monitored by update-notifier :
-              "/var/lib/dpkg/status" => big file of dpkg status
-              "/var/lib/update-notifier/dpkg-run-stamp" update-notifier stamp for dpkg ?
-              "/var/lib/apt/periodic/update-success-stamp" 
-        */
-
-        try
-        {
-            this.apt_update_file = File.new_for_path(this.apt_update_path);
-            this.apt_update_monitor = apt_update_file.monitor_file(GLib.FileMonitorFlags.NONE);
-            this.apt_update_monitor.changed.connect(run_check);
-            message ("Monitoring apt changes");
-        }
-        catch (GLib.Error err)
-        {
-            message (err.message);
-        }
-
-        try
-        {
-            this.dpkg_update_file = File.new_for_path(this.dpkg_update_path);
-            this.dpkg_update_monitor = dpkg_update_file.monitor_file(GLib.FileMonitorFlags.NONE);
-            this.dpkg_update_monitor.changed.connect(run_check);
-            message ("Monitoring dpkg changes");
-        }
-        catch (GLib.Error err)
-        {
-            message (err.message);
-        }
-
-        try
-        {
-            this.dpkg_run_file = File.new_for_path(this.dpkg_run_path);
-            this.dpkg_run_monitor = dpkg_run_file.monitor_file(GLib.FileMonitorFlags.NONE);
-            this.dpkg_run_monitor.changed.connect(run_check);
-            message ("Monitoring dpkg run changes");
-        }
-        catch (GLib.Error err)
-        {
-            message (err.message);
-        }
-
-        try
-        {
-            this.apt_lists_update_file = File.new_for_path(this.apt_lists_update_path);
-            this.apt_lists_update_monitor = apt_lists_update_file.monitor_directory(GLib.FileMonitorFlags.NONE);
-            this.apt_lists_update_monitor.changed.connect(run_check);
-            message ("Monitoring apt_lists changes");
-        }
-        catch (GLib.Error err)
-        {
-            message (err.message);
-        }
-    }
-
-    public void setup_reboot_config ()
-    {
-        try
-        {
-            this.reboot_file = File.new_for_path(this.reboot_path);
-            this.reboot_monitor = reboot_file.monitor_file(GLib.FileMonitorFlags.NONE);
-            this.reboot_monitor.changed.connect(run_check_reboot);
-            message ("Monitoring reboot changes");
-        }
-        catch (GLib.Error err)
-        {
-            message (err.message);
-        }
-    }
-
-    /* From https://mail.gnome.org/archives/vala-list/2010-October/msg00036.html */
-    public bool check_lock_file(string check_file)
-    {
-            
-            string lock_file_name = check_file;
-            int fd = Posix.open (lock_file_name, Posix.O_RDWR); 
-            if (fd == -1)
-            {
-              print ("There was an error opening the file '"  
-                + lock_file_name + " (Error number "  
-                + Posix.errno.to_string() + ")\n");
-              return true;
-            }
-                    
-            // Try to get a lock
-            Posix.Flock fl = Posix.Flock();
-            fl.l_type = Posix.F_WRLCK;
-            fl.l_whence = Posix.SEEK_SET;
-            fl.l_start = 100;
-            fl.l_len = 0;
-                    
-            int fcntl_return = Posix.fcntl (fd, Posix.F_SETLK, fl);
-            if (fcntl_return == -1) 
-                    return true;
-                    
-            // Release the lock again
-            fl.l_type = Posix.F_UNLCK;
-            fl.l_whence = Posix.SEEK_SET;
-            fl.l_start = 100;
-            fl.l_len = 0;
-            fcntl_return = Posix.fcntl (fd, Posix.F_SETLK, fl);
-
-            return false;
-    }
-
-}
 public class CrashManagerApp: SimpleAppObject
 {
     string crash_manager_command;
--- a/lxsession/dbus-lxde-session.vala
+++ b/lxsession/dbus-lxde-session.vala
@@ -425,21 +425,6 @@
                         KeyringActivate();
                         break;
 
-                    case "updates_manager":
-                        if (option == "check")
-                        {
-                            UpdatesCheck();
-                        }
-                        else if (option == "activate")
-                            {
-                                UpdatesAct();
-                            }
-                            else if (option == "inactivate")
-                                {
-                                    UpdatesInactivate();
-                                }
-                        break;
-
                     case "crash_manager":
                         if (option == "activate")
                         {
@@ -459,91 +444,6 @@
             }
         }
 
-        private void UpdatesActivate()
-        {
-            message("Reload updates_manager");
-            if (global_settings.get_item_string("Session", "updates_manager", "command") == null)
-            {
-                warning("Updates_manager not set");
-            }
-            else if (global_updates == null)
-            {
-                message("Updates_manager doesn't exist, creating it");
-                var updates = new UpdatesManagerApp();
-                global_updates = updates;
-                global_updates.launch();
-            }
-            else
-            {
-                message("Reload existing Updates_manager");
-                global_updates.reload();
-            }
-        }
-
-        private void UpdatesCheck()
-        {
-            message("Reload updates_manager");
-            if (global_settings.get_item_string("Session", "updates_manager", "command") == null)
-            {
-                warning("Updates_manager not set");
-            }
-            else if (global_updates == null)
-            {
-                message("Updates_manager doesn't exist, creating it");
-                var updates = new UpdatesManagerApp();
-                global_updates = updates;
-                global_updates.launch();
-                global_updates.run_check();
-            }
-            else
-            {
-                message("Check Updates");
-                global_updates.run_check();
-            }
-        }
-
-        private void UpdatesAct()
-        {
-            message("Reload updates_manager");
-            if (global_settings.get_item_string("Session", "updates_manager", "command") == null)
-            {
-                warning("Updates_manager not set");
-            }
-            else if (global_updates == null)
-            {
-                message("Updates_manager doesn't exist, creating it");
-                var updates = new UpdatesManagerApp();
-                global_updates = updates;
-                global_updates.test_activate();
-            }
-            else
-            {
-                message("Check Updates");
-                global_updates.test_activate();
-            }
-        }
-
-        private void UpdatesInactivate()
-        {
-            message("Reload updates_manager");
-            if (global_settings.get_item_string("Session", "updates_manager", "command") == null)
-            {
-                warning("Updates_manager not set");
-            }
-            else if (global_updates == null)
-            {
-                message("Updates_manager doesn't exist, creating it");
-                var updates = new UpdatesManagerApp();
-                global_updates = updates;
-                global_updates.test_inactivate();
-            }
-            else
-            {
-                message("Check Updates");
-                global_updates.test_inactivate();
-            }
-        }
-
         public void CrashManagerLaunch()
         {
             message("Launch crash manager");
@@ -1127,13 +1027,6 @@
             }
         }
 
-        /* Package manager running */
-        public async void PackageManagerRunning (out bool is_running)
-        {
-            message ("Check if package manager is running");
-            is_running = check_package_manager_running();
-        }
-
         /* Test interface */
         public void TestIconNotification()
         {
--- a/lxsession/main.vala
+++ b/lxsession/main.vala
@@ -54,7 +54,6 @@
     XrandrApp global_xrandr;
     KeyringApp global_keyring;
     A11yApp global_a11y;
-    UpdatesManagerApp global_updates;
     CrashManagerApp global_crash;
     GenericSimpleApp global_im1;
     GenericSimpleApp global_im2;
@@ -476,13 +475,6 @@
             global_proxy.launch();
         }
 
-        if (global_settings.get_item_string("Session", "updates_manager", "command") != null)
-        {
-            var updates = new UpdatesManagerApp();
-            global_updates = updates;
-            //global_updates.launch();
-        }
-
         if (global_settings.get_item_string("Session", "crash_manager", "command") != null)
         {
             var crash = new CrashManagerApp();
--- a/lxsession/utils.vala
+++ b/lxsession/utils.vala
@@ -139,37 +139,4 @@
     }
 }
 
-public bool check_package_manager_running ()
-{
-    GLib.File dpkg, apt_archives, apt_lists, unattended_upgrades;
-    bool return_value = false;
-
-    dpkg = File.new_for_path("/var/lib/dpkg/lock");
-    apt_archives = File.new_for_path("/var/cache/apt/archives/lock");
-    apt_lists = File.new_for_path("/var/lib/apt/lists/lock");
-    unattended_upgrades = File.new_for_path("/var/run/unattended-upgrades.lock");
-
-    if (dpkg.query_exists ())
-    {
-        return_value = true;
-    }
-
-    if (apt_archives.query_exists ())
-    {
-        return_value = true;
-    }
-
-    if (apt_lists.query_exists ())
-    {
-        return_value = true;
-    }
-
-    if (unattended_upgrades.query_exists ())
-    {
-        return_value = true;
-    }
-
-    return return_value;
-}
-
 }