This file is indexed.

/usr/bin/xnetcardconfig.real is in xnetcardconfig 0.3.0-1.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  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
#!/usr/bin/ruby
#
# file: xnetcardconfig.real.in
#
# Copyright (c) 2004 os-cillation
# All rights reserved.
#
# Written by Benedikt Meurer <bm@os-cillation.de>.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2, or (at your option)
# any later version.
#
# This program 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 General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to :
#   Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
#   MA 02110-1301, USA.
#

require 'gtk3'

module Xfi
  class StockButton < Gtk::Button
    def initialize(text = nil, stock = nil)
      super()

      align = Gtk::Alignment.new(0.5, 0.5, 0, 0)
      align.show
      add align

      hbox = Gtk::HBox.new(false, 0)
      hbox.show
      align.add hbox

      @widget_image = Gtk::Image.new(stock, Gtk::IconSize::BUTTON)
      @widget_image.show
      hbox.pack_start(@widget_image, false, false, 2)

      @widget_label = Gtk::Label.new(text)
      @widget_label.show
      hbox.pack_start(@widget_label, false, false, 2)
    end

  private
    @widget_image
    @widget_label
  end

  class Wizard < Gtk::Window
    # Base class for pages
    class Page < Gtk::EventBox
      def initialize(title = nil)
        super()
        @title = title
        @can_next = @can_prev = TRUE
      end

      def title
        @title
      end

      def set_can_next(value)
        if @can_next != value; then
          @can_next = value
          @wizard.evaluate(self)
        end
      end
      def can_next
        @can_next
      end

      def set_can_prev(value)
        if @can_prev != value; then
          @can_prev = value
          @wizard.evaluate(self)
        end
      end
      def can_prev
        @can_prev
      end

      def wizard=(wizard)
        @wizard = wizard
      end
      def wizard
        @wizard
      end

      def activate
      end

    private
      @wizard
      @title
      @can_next
      @can_prev
    end

    def initialize
      super()

      set_border_width(10)

      @group = Gtk::SizeGroup.new(:both)
      @pages = Array.new

      box = Gtk::Box.new(:vertical, 10)
      box.show
      add box

      hbox = Gtk::Box.new(:horizontal, 10)
      hbox.show
      box.pack_start(hbox, true, true, 0)

      # the image on the left side
      vbox = Gtk::VBox.new(false, 0)
      vbox.show
      hbox.pack_start(vbox, false, false, 0)

      frame = Gtk::Frame.new
      frame.shadow_type = Gtk::SHADOW_IN
      frame.show
      vbox.pack_start(frame, false, false, 0)
      
      @image = Gtk::Image.new('/usr/share/apps/xnetcardconfig/logo.png')
      @image.show
      frame.add(@image)

      vbox = Gtk::VBox.new(false, 10)
      vbox.show
      hbox.pack_start(vbox, true, true, 0)

      @label_title = Gtk::Label.new
      @label_title.modify_font(Pango::FontDescription.new('Sans Bold'))
      @label_title.set_alignment(0.0, 0.5)
      @label_title.show
      vbox.pack_start(@label_title, false, false, 0)

      separator = Gtk::HSeparator.new
      separator.show
      vbox.pack_start(separator, false, false, 0)

      @box = Gtk::EventBox.new
      @box.set_border_width(12)
      @box.show
      vbox.pack_start(@box, true, true, 0)

      # now on with the button box
      separator = Gtk::HSeparator.new
      separator.show
      box.pack_start(separator, false, false, 0)

      buttonbox = Gtk::HButtonBox.new
      buttonbox.layout_style = Gtk::ButtonBox::END
      buttonbox.spacing = 10
      buttonbox.show
      box.pack_start(buttonbox, false, false, 0)

      @button_cancel = StockButton.new('Cancel', Gtk::Stock::CANCEL)
      @button_cancel.signal_connect('clicked') do destroy end
      @button_cancel.show
      buttonbox.pack_start(@button_cancel, false, false, 0)

      @button_prev = StockButton.new('Previous', Gtk::Stock::GO_BACK)
      @button_prev.sensitive = FALSE
      @button_prev.signal_connect('clicked') do back end
      @button_prev.show
      buttonbox.pack_start(@button_prev, false, false, 0)

      @button_next = StockButton.new('Next', Gtk::Stock::GO_FORWARD)
      @button_next.sensitive = FALSE
      @button_next.signal_connect('clicked') do forward end
      @button_next.show
      buttonbox.pack_start(@button_next, false, false, 0)

      @button_finish = StockButton.new('Done', Gtk::Stock::OK)
      @button_finish.signal_connect('clicked') do destroy end
      buttonbox.pack_start(@button_finish, false, false, 0)
    end

    def append(page)
      page.wizard = self
      @group.add_widget(page)
      @pages.push(page)
      activate((@current == nil) ? page : @current)
    end

    def evaluate(page)
      if page == @current; then
        @button_prev.sensitive = (@pages.first != page and page.can_prev)

        if @pages.last == page then
          @button_finish.sensitive = page.can_next
          @button_finish.show
          @button_next.hide
        else
          @button_finish.hide
          @button_next.show
          @button_next.sensitive = page.can_next
        end
      end
    end

  private
    def activate(page)
      @label_title.text = page.title

      @box.child != nil and @box.remove @box.child
      @box.add page

      @button_prev.sensitive = (@pages.first != page and page.can_prev)

      if @pages.last == page then
        @button_finish.sensitive = page.can_next
        @button_finish.show
        @button_next.hide
      else
        @button_finish.hide
        @button_next.show
        @button_next.sensitive = page.can_next
      end

      if @current != page then
        @current = page
        page.activate
        page.show
      end
    end

    def back
      if @pages.first != @current then
        activate(@pages[@pages.index(@current) - 1])
      end
    end

    def forward
      if @pages.last != @current then
        activate(@pages[@pages.index(@current) + 1])
      end
    end
  end
end


class NetworkInfo
  def initialize(interface)
    IO.popen("env LC_ALL=C LANG=C /sbin/ifconfig #{interface}") do |file|
      file.each_line do |line|
        line =~ /inet addr:([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/ and @address = $1
        line =~ /Mask:([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/ and @netmask = $1
      end
    end
    IO.popen('env LC_ALL=C LANG=C /bin/netstat -rn') do |file|
      file.each_line do |line|
        dest, gateway, others = line.split(' ')
        dest == '0.0.0.0' and @gateway = gateway
      end
    end
    @nameservers = Array.new
    File.open('/etc/resolv.conf', 'r') do |file|
      file.each_line do |line|
        if line =~ /^nameserver +([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+)/ then
          @nameservers.push $1
        end
      end
    end
  end

  def address
    @address
  end

  def netmask
    @netmask
  end

  def gateway
    @gateway
  end

  def nameservers
    @nameservers
  end

private
  @address
  @netmask
  @gateway
  @nameservers
end


class Global
  def Global.device=(device)
    @@device = device
  end
  def Global.device
    @@device
  end

  def Global.devices=(devices)
    @@devices = devices
  end
  def Global.devices
    @@devices
  end

  def Global.dhcp=(value)
    @@dhcp = value
  end
  def Global.dhcp?
    @@dhcp
  end

  def Global.address=(value)
    @@address = value
  end
  def Global.address
    @@address
  end

  def Global.netmask=(value)
    @@netmask = value
  end
  def Global.netmask
    @@netmask
  end

  def Global.gateway=(value)
    @@gateway = value
  end
  def Global.gateway
    @@gateway
  end

  def Global.nameserver=(value)
    @@nameserver = value
  end
  def Global.nameserver
    @@nameserver
  end

private
  @@device = 'eth0'
  @@devices = Array.new
  @@dhcp = TRUE
  @@address = nil
  @@netmask = nil
  @@gateway = nil
  @@nameserver = nil
end


module Pages
  class Intro < Xfi::Wizard::Page
    def initialize
      super('Configure your network')

      align = Gtk::Alignment.new(0, 0, 1.0, 1.0)
      align.show
      add align

      vbox = Gtk::VBox.new(false, 30)
      vbox.show
      align.add vbox

      label = Gtk::Label.new("This wizard will guide you through the\n" \
                             "steps required to setup your network.\n" \
                             "\n" \
                             "At first you must choose the network\n" \
                             "card you want to configure from the\n" \
                             "list below.\n")
      label.set_alignment(0.0, 0.5)
      label.show
      vbox.pack_start(label, false, false, 0)

      @store = Gtk::ListStore.new(Gdk::Pixbuf, String, String)

      
      icon = Gdk::Pixbuf.new('/usr/share/apps/xnetcardconfig/card.png')
      count = 0; Global.devices.each do |device|
        iter = @store.append
        iter[COLUMN_ICON] = icon
        iter[COLUMN_TEXT] = "Network Card #{count} (#{device})"
        iter[COLUMN_DEV]  = device
        count = count + 1
      end

      frame = Gtk::ScrolledWindow.new
      frame.shadow_type = Gtk::SHADOW_IN
      frame.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC)
      frame.show
      vbox.pack_start(frame, true, true, 0)

      @treeview = Gtk::TreeView.new(@store)
      @treeview.headers_visible = FALSE
      @treeview.selection.signal_connect('changed') do changed end
      @treeview.show
      frame.add @treeview

      column = Gtk::TreeViewColumn.new
      renderer = Gtk::CellRendererPixbuf.new
      column.pack_start(renderer, FALSE)
      column.set_attributes(renderer, :pixbuf => COLUMN_ICON)
      renderer = Gtk::CellRendererText.new
      column.pack_start(renderer, TRUE)
      column.set_attributes(renderer, :text => COLUMN_TEXT)
      @treeview.append_column(column)

      changed
    end

  private
    COLUMN_ICON = 0
    COLUMN_TEXT = 1
    COLUMN_DEV  = 2

    def changed
      iter = @treeview.selection.selected and Global.device = iter[COLUMN_DEV]
    end
  end

  class Type < Xfi::Wizard::Page
    def initialize
      super('Configure your network')

      align = Gtk::Alignment.new(0, 0, 1.0, 1.0)
      align.show
      add align

      vbox = Gtk::VBox.new(false, 30)
      vbox.show
      align.add vbox

      label = Gtk::Label.new("Do you want to use DHCP (Dynamic Host\n" \
                             "Configuration Protocol) to configure the\n" \
                             "network interface automatically or would\n" \
                             "you like to setup the interface manually?")
      label.set_alignment(0.0, 0.5)
      label.show
      vbox.pack_start(label, false, false, 0)

      box = Gtk::VBox.new(false, 10)
      box.show
      vbox.pack_start(box, false, false, 0)

      @button_dhcp = Gtk::RadioButton.new('Automatic configuration (DHCP)')
      @button_dhcp.signal_connect('toggled') do toggled end
      @button_dhcp.show
      box.pack_start(@button_dhcp, false, false, 0)

      @button_manual = Gtk::RadioButton.new(@button_dhcp,'Manual configuration')
      @button_manual.show
      box.pack_start(@button_manual, false, false, 0)

      frame = Gtk::ScrolledWindow.new
      frame.shadow_type = Gtk::SHADOW_IN
      frame.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC)
      frame.show
      vbox.pack_start(frame, true, true, 0)

      @textview = Gtk::TextView.new
      @textview.can_focus = FALSE
      @textview.wrap_mode = 3
      @textview.show
      frame.add @textview
      
      buffer = @textview.buffer
      buffer.tag_table.add(tag = Gtk::TextTag.new('b'))
      tag.weight = Pango::FontDescription::WEIGHT_BOLD

      # apply global setting
      if Global.dhcp?; then
        @button_dhcp.active = TRUE
      else
        @button_manual.active = TRUE
      end
      toggled
    end

  private
    def toggled
      if @button_dhcp.active?; then
        Global.dhcp = TRUE
        buffer = @textview.buffer
        buffer.delete(buffer.start_iter, buffer.end_iter)
        buffer.insert(buffer.end_iter, "Automatic configuration (DHCP)\n\n", 'b')
        buffer.insert(buffer.end_iter, "Choose this method if the network you " \
                                       "are connected to has a DHCP server " \
                                       "that is able to configure your computer.")
      else
        Global.dhcp = FALSE
        buffer = @textview.buffer
        buffer.delete(buffer.start_iter, buffer.end_iter)
        buffer.insert(buffer.end_iter, "Manual configuration\n\n", 'b')
        buffer.insert(buffer.end_iter, "You will have to enter all required " \
                                       "information to configure the network " \
                                       "interface. Choose this if unsure.")
      end
    end
  end

  class Execute < Xfi::Wizard::Page
    def initialize
      super('Configure your network')

      align = Gtk::Alignment.new(0, 0, 1, 1)
      align.show
      add align

      vbox = Gtk::VBox.new(false, 0)
      vbox.show
      align.add vbox

      @box_dhcp = create_dhcp
      vbox.pack_start(@box_dhcp, true, true, 0)

      @box_manual = create_manual
      @box_manual.show
      vbox.pack_start(@box_manual, true, true, 0)
    end

    def activate
      if Global.dhcp?; then
        @box_dhcp.show
        @box_manual.hide
        dhcp_perform
      else
        @box_dhcp.hide
        @box_manual.show
      end
    end

  private
    def dhcp_perform
      @label_dhcp.text = "Autoconfiguring #{Global.device}..."
      @label_dhcp_info.text = "The process of autoconfiguring a network\n" \
                              "interface can take some time, please stay\n" \
                              "patient.\n"
      @vbox_dhcp.show

      set_can_next(FALSE)
      set_can_prev(FALSE)

      timer = Gtk::timeout_add(100) do
        @progress_dhcp.pulse
      end

      thread = Thread.new do
        # cleanup first
        system("/sbin/pump -k -i \"#{Global.device}\"")
        rc = system("/sbin/pump -i \"#{Global.device}\"")
        Gtk::timeout_remove(timer)

        @vbox_dhcp.hide

        if not rc; then
          @label_dhcp_info.text = "The process of autoconfiguring the network\n" \
                                  "interface failed. Maybe check your cable\n" \
                                  "connection.\n" \
                                  "\n" \
                                  "You may want to go back now and try to\n" \
                                  "manually configure the network interface\n" \
                                  "instead.\n";
          set_can_prev(TRUE)
        else
          @label_dhcp_info.text = "The network interface was successfully\n" \
                                  "configured using DHCP. Click the button\n" \
                                  "labeled \"Next\" to complete the network\n" \
                                  "setup.\n"
          set_can_prev(TRUE)
          set_can_next(TRUE)
        end
      end
    end

    def create_dhcp
      box = Gtk::VBox.new(false, 30)
      box.show

      @vbox_dhcp = Gtk::VBox.new(false, 10)
      @vbox_dhcp.show
      box.pack_start(@vbox_dhcp, false, false, 0)

      @label_dhcp = Gtk::Label.new
      @label_dhcp.show
      @vbox_dhcp.pack_start(@label_dhcp, false, false, 0)

      frame = Gtk::EventBox.new
      frame.border_width = 12
      frame.show
      @vbox_dhcp.pack_start(frame, false, true, 0)

      @progress_dhcp = Gtk::ProgressBar.new
      @progress_dhcp.pulse_step = 0.10
      @progress_dhcp.show
      frame.add @progress_dhcp

      @label_dhcp_info = Gtk::Label.new
      @label_dhcp_info.show
      box.pack_start(@label_dhcp_info, false, false, 0)

      return box
    end

    def create_manual
      info = NetworkInfo.new(Global.device)

      box = Gtk::VBox.new(false, 30)
      box.show

      label = Gtk::Label.new("Please fill in the fields below:")
      label.set_alignment(0.0, 0.5)
      label.show
      box.pack_start(label, false, false, 0)

      table = Gtk::Table.new(4, 2)
      table.column_spacings = 6
      table.row_spacings = 6
      table.show
      box.pack_start(table, false, false, 0)

      label = Gtk::Label.new('Address:')
      label.set_alignment(1.0, 0.5)
      label.show
      table.attach(label, 0, 1, 0, 1, Gtk::FILL, Gtk::FILL)

      @entry_ip = Gtk::Entry.new
      @entry_ip.signal_connect('changed') do
        Global.address = @entry_ip.text
      end
      @entry_ip.text = info.address if info.address
      @entry_ip.show
      table.attach(@entry_ip, 1, 2, 0, 1, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL)

      label = Gtk::Label.new('Network mask:')
      label.set_alignment(1.0, 0.5)
      label.show
      table.attach(label, 0, 1, 1, 2, Gtk::FILL, Gtk::FILL)

      @entry_mask = Gtk::Entry.new
      @entry_mask.signal_connect('changed') do
        Global.netmask = @entry_mask.text
      end
      @entry_mask.text = info.netmask ? info.netmask : '255.255.255.0'
      @entry_mask.show
      table.attach(@entry_mask, 1, 2, 1, 2, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL)

      label = Gtk::Label.new('Gateway:')
      label.set_alignment(1.0, 0.5)
      label.show
      table.attach(label, 0, 1, 2, 3, Gtk::FILL, Gtk::FILL)

      @entry_gw = Gtk::Entry.new
      @entry_gw.signal_connect('changed') do
        Global.gateway = @entry_gw.text
      end
      @entry_gw.text = info.gateway if info.gateway
      @entry_gw.show
      table.attach(@entry_gw, 1, 2, 2, 3, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL)

      label = Gtk::Label.new('Nameserver:')
      label.set_alignment(1.0, 0.5)
      label.show
      table.attach(label, 0, 1, 3, 4, Gtk::FILL, Gtk::FILL)

      @entry_dns = Gtk::Entry.new
      @entry_dns.signal_connect('changed') do
        Global.nameserver = @entry_dns.text
      end
      @entry_dns.text = info.nameservers[0] if not info.nameservers.empty?
      @entry_dns.show
      table.attach(@entry_dns, 1, 2, 3, 4, Gtk::EXPAND | Gtk::FILL, Gtk::EXPAND | Gtk::FILL)

      return box
    end
  end


  class Finish < Xfi::Wizard::Page
    def initialize
      super('Configure your network')

      align = Gtk::Alignment.new(0, 0, 1, 1)
      align.show
      add align

      vbox = Gtk::VBox.new(false, 30)
      vbox.show
      align.add vbox

      label = Gtk::Label.new("Your network was configured successfully. The\n" \
                             "current network configuration is shown below.\n" \
                             "Click the button labeled \"Done\" to quit this\n" \
                             "wizard.")
      label.set_alignment(0.0, 0.5)
      label.show
      vbox.pack_start(label, false, false, 0)

      align = Gtk::Alignment.new(0.5, 0.5, 1, 1)
      align.show
      vbox.pack_start(align, false, false, 0)

      table = Gtk::Table.new(4, 2)
      table.column_spacings = 6
      table.row_spacings = 6
      table.show
      align.add table

      label = Gtk::Label.new('<b>Address:</b>')
      label.set_use_markup true
      label.set_alignment(1.0, 0.5)
      label.show
      table.attach(label, 0, 1, 0, 1, Gtk::FILL, Gtk::FILL)

      @label_address = Gtk::Label.new('127.0.0.1')
      @label_address.selectable = true
      @label_address.set_alignment(0.0, 0.5)
      @label_address.show
      table.attach(@label_address, 1, 2, 0, 1, Gtk::FILL, Gtk::FILL)

      label = Gtk::Label.new('<b>Network mask:</b>')
      label.set_use_markup true
      label.set_alignment(1.0, 0.5)
      label.show
      table.attach(label, 0, 1, 1, 2, Gtk::FILL, Gtk::FILL)

      @label_netmask = Gtk::Label.new('255.255.255.0')
      @label_netmask.selectable = true
      @label_netmask.set_alignment(0.0, 0.5)
      @label_netmask.show
      table.attach(@label_netmask, 1, 2, 1, 2, Gtk::FILL, Gtk::FILL)

      label = Gtk::Label.new('<b>Gateway:</b>')
      label.set_use_markup true
      label.set_alignment(1.0, 0.5)
      label.show
      table.attach(label, 0, 1, 2, 3, Gtk::FILL, Gtk::FILL)

      @label_gateway = Gtk::Label.new('255.255.255.255')
      @label_gateway.selectable = true
      @label_gateway.set_alignment(0.0, 0.5)
      @label_gateway.show
      table.attach(@label_gateway, 1, 2, 2, 3, Gtk::FILL, Gtk::FILL)

      label = Gtk::Label.new('<b>Nameserver(s):</b>')
      label.set_use_markup true
      label.set_alignment(1.0, 0.0)
      label.show
      table.attach(label, 0, 1, 3, 4, Gtk::FILL, Gtk::FILL)

      @label_dns = Gtk::Label.new("127.0.0.1")
      @label_dns.selectable = true
      @label_dns.set_alignment(0.0, 0.0)
      @label_dns.show
      table.attach(@label_dns, 1, 2, 3, 4, Gtk::FILL, Gtk::FILL)

      label = Gtk::Label.new("To run this wizard again, right click on the\n" \
                             "desktop with your mouse and choose the entry\n" \
                             "\"Configure network card\" from the \"System\"\n" \
                             "menu.")
      label.show
      vbox.pack_start(label, false, false, 0)
    end

    def activate
      if not Global.dhcp? then
        system("/sbin/pump -k -i \"#{Global.device}\"")
        system("/sbin/ifconfig \"#{Global.device}\" \"#{Global.address}\" " \
               "netmask \"#{Global.netmask}\" up")
        system("/sbin/route add default gw \"#{Global.gateway}\"")
        File.open('/etc/resolv.conf', 'w') do |file|
          file.puts("nameserver #{Global.nameserver}")
        end
      end

      # store config (Debian)
      if FileTest.writable? '/etc/network/interfaces'; then
        lines = Array.new
        File.open('/etc/network/interfaces', 'r') do |file|
          ignore_tabbed = false
          file.each_line do |line|
            if line =~ /#{Global.device}/; then
              ignore_tabbed = true
            elsif not (ignore_tabbed and line =~ /^\t/); then
              lines.push line.chomp
              ignore_tabbed = false
            end
          end
        end

        lines.push "auto #{Global.device}"
        if Global.dhcp?; then
          lines.push "iface #{Global.device} inet dhcp"
        else
          lines.push "iface #{Global.device} inet static"
          lines.push "\taddress #{Global.address}" if Global.address
          lines.push "\tnetmask #{Global.netmask}" if Global.netmask
          lines.push "\tgateway #{Global.gateway}" if Global.gateway
        end

        File.open('/etc/network/interfaces', 'w') do |file|
          lines.each do |line|
            file.puts line
          end
        end
      end

      info = NetworkInfo.new(Global.device)

      if info.address; then
        @label_address.text = info.address
      else
        @label_address.text = 'Unknown'
      end

      if info.netmask; then
        @label_netmask.text = info.netmask
      else
        @label_netmask.text = 'Unknown'
      end

      if info.gateway; then
        @label_gateway.text = info.gateway
      else
        @label_gateway.text = 'Unknown'
      end

      list = ''; info.nameservers.each do |ns|
        list != '' and list = list + "\n"
        list = list + ns
      end
      @label_dns.text = list
    end
  end
end


Gtk::init

# find network interfaces
File.open('/proc/net/dev', 'r') do |file|
  devices = Array.new
  file.each_line do |line|
    dev, other = line.strip.split(/\s*:\s*/)
    (dev =~ /^(eth|ath|wlan)[0-9]$/) and devices.push dev
  end
  Global.devices = devices
end

# check if any interfaces were found
if Global.devices.empty?; then
  dialog = Gtk::MessageDialog.new(nil, 0, \
                                  Gtk::MessageDialog::ERROR, \
                                  Gtk::MessageDialog::BUTTONS_CLOSE, \
                                  "No supported network cards were found.")
  dialog.run
  exit 0
end


wizard = Xfi::Wizard.new
wizard.title = 'Configure your network'
wizard.append(Pages::Intro.new)
wizard.append(Pages::Type.new)
wizard.append(Pages::Execute.new)
wizard.append(Pages::Finish.new)
wizard.signal_connect('destroy') do
  Gtk::main_quit
end
wizard.show

Gtk::main