Lines Matching refs:self
112 def __init__(self): argument
113 self.xml = xml
114 self.notebook = xml.get_widget ("notebook")
115 self.label_dict = {}
116 self.tooltip_dict = {}
118 self.label_dict[label] = label.get_text()
121 self.label_dict[label] = label.get_text()
124 self.label_dict[label] = label.get_text()
127 self.label_dict[label] = label.get_text()
130 self.label_dict[label] = label.get_text()
133 self.label_dict[label] = label.get_text()
136 self.label_dict[label] = label.get_text()
139 self.label_dict[label] = label.get_text()
142 self.label_dict[label] = label.get_text()
145 self.tooltip_dict[label] = label.get_tooltip_text()
148 self.tooltip_dict[label] = label.get_tooltip_text()
151 self.tooltip_dict[label] = label.get_tooltip_text()
154 self.tooltip_dict[label] = label.get_tooltip_text()
157 self.tooltip_dict[label] = label.get_tooltip_text()
160 self.tooltip_dict[label] = label.get_tooltip_text()
163 self.tooltip_dict[label] = label.get_tooltip_text()
166 self.tooltip_dict[label] = label.get_tooltip_text()
169 self.tooltip_dict[label] = label.get_tooltip_text()
172 self.tooltip_dict[label] = label.get_tooltip_text()
175 self.tooltip_dict[label] = label.get_tooltip_text()
178 self.tooltip_dict[label] = label.get_tooltip_text()
181 self.tooltip_dict[label] = label.get_tooltip_text()
184 self.tooltip_dict[label] = label.get_tooltip_text()
187 self.tooltip_dict[label] = label.get_tooltip_text()
190 self.tooltip_dict[label] = label.get_tooltip_text()
193 self.all_types = generate.get_all_types()
194 self.all_modules = get_all_modules()
195 self.all_roles = generate.get_all_roles()
196 self.all_users = generate.get_all_users()
198 self.all_types = []
199 self.all_modules = []
200 self.all_roles = []
201 self.all_users = []
202 self.error(str(e))
204 self.name=""
205 xml.signal_connect("on_delete_clicked", self.delete)
206 xml.signal_connect("on_delete_boolean_clicked", self.delete_boolean)
207 xml.signal_connect("on_exec_select_clicked", self.exec_select)
208 xml.signal_connect("on_init_script_select_clicked", self.init_script_select)
209 xml.signal_connect("on_add_clicked", self.add)
210 xml.signal_connect("on_add_boolean_clicked", self.add_boolean)
211 xml.signal_connect("on_add_dir_clicked", self.add_dir)
212 xml.signal_connect("on_about_clicked", self.on_about_clicked)
213 xml.get_widget ("cancel_button").connect("clicked",self.quit)
214 self.forward_button = xml.get_widget ("forward_button")
215 self.forward_button.connect("clicked",self.forward)
216 self.back_button = xml.get_widget ("back_button")
217 self.back_button.connect("clicked",self.back)
219 self.boolean_dialog = xml.get_widget ("boolean_dialog")
220 self.boolean_name_entry = xml.get_widget ("boolean_name_entry")
221 self.boolean_description_entry = xml.get_widget ("boolean_description_entry")
223 self.pages={}
225 …self.pages[i] = [ self.SELECT_TYPE_PAGE, self.APP_PAGE, self.TRANSITION_PAGE, self.ROLE_PAGE, self…
226 …self.pages[generate.RUSER] = [ self.SELECT_TYPE_PAGE, self.APP_PAGE, self.ADMIN_PAGE, self.USER_T…
227 …self.pages[generate.LUSER] = [ self.SELECT_TYPE_PAGE, self.APP_PAGE, self.TRANSITION_PAGE, self.IN…
228 …self.pages[generate.SANDBOX] = [ self.SELECT_TYPE_PAGE, self.APP_PAGE, self.IN_NET_PAGE, self.OUT_…
229 …self.pages[generate.EUSER] = [ self.SELECT_TYPE_PAGE, self.EXISTING_USER_PAGE, self.TRANSITION_PAG…
232 …self.pages[i] = [ self.SELECT_TYPE_PAGE, self.APP_PAGE, self.IN_NET_PAGE, self.OUT_NET_PAGE, self.…
233 …self.pages[generate.USER] = [ self.SELECT_TYPE_PAGE, self.APP_PAGE, self.USER_TRANSITION_PAGE, sel…
235 self.current_page = 0
236 self.back_button.set_sensitive(0)
238 self.network_buttons = {}
240 self.in_tcp_all_checkbutton = xml.get_widget ("in_tcp_all_checkbutton")
241 self.in_tcp_reserved_checkbutton = xml.get_widget ("in_tcp_reserved_checkbutton")
242 self.in_tcp_unreserved_checkbutton = xml.get_widget ("in_tcp_unreserved_checkbutton")
243 self.in_tcp_entry = self.xml.get_widget("in_tcp_entry")
244 …self.network_buttons[self.in_tcp_all_checkbutton] = [ self.in_tcp_reserved_checkbutton, self.in_tc…
247 self.out_tcp_all_checkbutton = xml.get_widget ("out_tcp_all_checkbutton")
248 self.out_tcp_reserved_checkbutton = xml.get_widget ("out_tcp_reserved_checkbutton")
249 self.out_tcp_unreserved_checkbutton = xml.get_widget ("out_tcp_unreserved_checkbutton")
250 self.out_tcp_entry = self.xml.get_widget("out_tcp_entry")
252 self.network_buttons[self.out_tcp_all_checkbutton] = [ self.out_tcp_entry ]
254 self.in_udp_all_checkbutton = xml.get_widget ("in_udp_all_checkbutton")
255 self.in_udp_reserved_checkbutton = xml.get_widget ("in_udp_reserved_checkbutton")
256 self.in_udp_unreserved_checkbutton = xml.get_widget ("in_udp_unreserved_checkbutton")
257 self.in_udp_entry = self.xml.get_widget("in_udp_entry")
259 …self.network_buttons[self.in_udp_all_checkbutton] = [ self.in_udp_reserved_checkbutton, self.in_ud…
261 self.out_udp_all_checkbutton = xml.get_widget ("out_udp_all_checkbutton")
262 self.out_udp_entry = self.xml.get_widget("out_udp_entry")
263 self.network_buttons[self.out_udp_all_checkbutton] = [ self.out_udp_entry ]
265 for b in self.network_buttons.keys():
266 b.connect("clicked",self.network_all_clicked)
268 self.boolean_treeview = self.xml.get_widget("boolean_treeview")
269 self.boolean_store = gtk.ListStore(gobject.TYPE_STRING,gobject.TYPE_STRING)
270 self.boolean_treeview.set_model(self.boolean_store)
271 self.boolean_store.set_sort_column_id(0, gtk.SORT_ASCENDING)
273 self.boolean_treeview.append_column(col)
275 self.boolean_treeview.append_column(col)
277 self.role_treeview = self.xml.get_widget("role_treeview")
278 self.role_store = gtk.ListStore(gobject.TYPE_STRING)
279 self.role_treeview.set_model(self.role_store)
280 self.role_treeview.get_selection().set_mode(gtk.SELECTION_MULTIPLE)
281 self.role_store.set_sort_column_id(0, gtk.SORT_ASCENDING)
283 self.role_treeview.append_column(col)
285 self.existing_user_treeview = self.xml.get_widget("existing_user_treeview")
286 self.existing_user_store = gtk.ListStore(gobject.TYPE_STRING)
287 self.existing_user_treeview.set_model(self.existing_user_store)
288 self.existing_user_store.set_sort_column_id(0, gtk.SORT_ASCENDING)
290 self.existing_user_treeview.append_column(col)
292 for i in self.all_roles:
293 iter = self.role_store.append()
294 self.role_store.set_value(iter, 0, i[:-2])
296 self.in_tcp_reserved_checkbutton = xml.get_widget ("in_tcp_reserved_checkbutton")
298 self.transition_treeview = self.xml.get_widget("transition_treeview")
299 self.transition_store = gtk.ListStore(gobject.TYPE_STRING)
300 self.transition_treeview.set_model(self.transition_store)
301 self.transition_treeview.get_selection().set_mode(gtk.SELECTION_MULTIPLE)
302 self.transition_store.set_sort_column_id(0, gtk.SORT_ASCENDING)
304 self.transition_treeview.append_column(col)
306 self.user_transition_treeview = self.xml.get_widget("user_transition_treeview")
307 self.user_transition_store = gtk.ListStore(gobject.TYPE_STRING)
308 self.user_transition_treeview.set_model(self.user_transition_store)
309 self.user_transition_treeview.get_selection().set_mode(gtk.SELECTION_MULTIPLE)
310 self.user_transition_store.set_sort_column_id(0, gtk.SORT_ASCENDING)
312 self.user_transition_treeview.append_column(col)
314 for i in self.all_users:
315 iter = self.user_transition_store.append()
316 self.user_transition_store.set_value(iter, 0, i[:-2])
317 iter = self.existing_user_store.append()
318 self.existing_user_store.set_value(iter, 0, i[:-2])
320 self.admin_treeview = self.xml.get_widget("admin_treeview")
321 self.admin_store = gtk.ListStore(gobject.TYPE_STRING)
322 self.admin_treeview.set_model(self.admin_store)
323 self.admin_treeview.get_selection().set_mode(gtk.SELECTION_MULTIPLE)
324 self.admin_store.set_sort_column_id(0, gtk.SORT_ASCENDING)
326 self.admin_treeview.append_column(col)
330 iter = self.transition_store.append()
331 self.transition_store.set_value(iter, 0, u)
334 iter = self.admin_store.append()
335 self.admin_store.set_value(iter, 0, a)
337 self.error(e.message)
339 def confine_application(self): argument
340 return self.get_type() in generate.APPLICATIONS
342 def forward(self, arg): argument
343 type = self.get_type()
344 if self.current_page == self.START_PAGE:
345 self.back_button.set_sensitive(1)
347 if self.pages[type][self.current_page] == self.SELECT_TYPE_PAGE:
348 if self.on_select_type_page_next():
351 if self.pages[type][self.current_page] == self.IN_NET_PAGE:
352 if self.on_in_net_page_next():
355 if self.pages[type][self.current_page] == self.OUT_NET_PAGE:
356 if self.on_out_net_page_next():
359 if self.pages[type][self.current_page] == self.APP_PAGE:
360 if self.on_name_page_next():
363 if self.pages[type][self.current_page] == self.EXISTING_USER_PAGE:
364 if self.on_existing_user_page_next():
367 if self.pages[type][self.current_page] == self.SELECT_DIR_PAGE:
368 outputdir = self.output_entry.get_text()
370 self.error(_("%s must be a directory") % outputdir )
373 if self.pages[type][self.current_page] == self.FINISH_PAGE:
374 self.generate_policy()
375 self.xml.get_widget ("cancel_button").set_label(gtk.STOCK_CLOSE)
377 self.current_page = self.current_page + 1
378 self.notebook.set_current_page(self.pages[type][self.current_page])
379 if self.pages[type][self.current_page] == self.FINISH_PAGE:
380 self.forward_button.set_label(gtk.STOCK_APPLY)
382 def back(self,arg): argument
383 type = self.get_type()
384 if self.pages[type][self.current_page] == self.FINISH_PAGE:
385 self.forward_button.set_label(gtk.STOCK_GO_FORWARD)
387 self.current_page = self.current_page - 1
388 self.notebook.set_current_page(self.pages[type][self.current_page])
389 if self.pages[type][self.current_page] == self.START_PAGE:
390 self.back_button.set_sensitive(0)
392 def network_all_clicked(self, button): argument
394 for b in self.network_buttons[button]:
397 def verify(self, message, title="" ): argument
408 def info(self, message): argument
417 def error(self, message): argument
426 def get_name(self): argument
427 if self.existing_user_radiobutton.get_active():
428 store, iter = self.existing_user_treeview.get_selection().get_selected()
433 return self.name_entry.get_text()
435 def get_type(self): argument
436 if self.sandbox_radiobutton.get_active():
438 if self.cgi_radiobutton.get_active():
440 if self.user_radiobutton.get_active():
442 if self.init_radiobutton.get_active():
444 if self.dbus_radiobutton.get_active():
446 if self.inetd_radiobutton.get_active():
448 if self.login_user_radiobutton.get_active():
450 if self.admin_user_radiobutton.get_active():
452 if self.xwindows_user_radiobutton.get_active():
454 if self.terminal_user_radiobutton.get_active():
456 if self.root_user_radiobutton.get_active():
458 if self.existing_user_radiobutton.get_active():
461 def generate_policy(self, *args): argument
462 outputdir = self.output_entry.get_text()
464 my_policy=generate.policy(self.get_name(), self.get_type())
466 iter= self.boolean_store.get_iter_first()
468 …my_policy.add_boolean(self.boolean_store.get_value(iter, 0), self.boolean_store.get_value(iter, 1))
469 iter= self.boolean_store.iter_next(iter)
471 if self.get_type() in generate.APPLICATIONS:
472 my_policy.set_program(self.exec_entry.get_text())
475 my_policy.set_use_syslog(self.syslog_checkbutton.get_active() == 1)
476 my_policy.set_use_tmp(self.tmp_checkbutton.get_active() == 1)
477 my_policy.set_use_uid(self.uid_checkbutton.get_active() == 1)
478 my_policy.set_use_pam(self.pam_checkbutton.get_active() == 1)
480 my_policy.set_use_dbus(self.dbus_checkbutton.get_active() == 1)
481 my_policy.set_use_audit(self.audit_checkbutton.get_active() == 1)
482 my_policy.set_use_terminal(self.terminal_checkbutton.get_active() == 1)
483 my_policy.set_use_mail(self.mail_checkbutton.get_active() == 1)
484 if self.get_type() is generate.DAEMON:
485 my_policy.set_init_script(self.init_script_entry.get_text())
486 if self.get_type() == generate.USER:
488 … self.user_transition_treeview.get_selection().selected_foreach(foreach, selected)
491 if self.get_type() == generate.RUSER:
493 self.admin_treeview.get_selection().selected_foreach(foreach, selected)
496 … self.user_transition_treeview.get_selection().selected_foreach(foreach, selected)
500 self.transition_treeview.get_selection().selected_foreach(foreach, selected)
504 self.role_treeview.get_selection().selected_foreach(foreach, selected)
507 …_tcp(self.in_tcp_all_checkbutton.get_active(), self.in_tcp_reserved_checkbutton.get_active(), self…
508 …_udp(self.in_udp_all_checkbutton.get_active(), self.in_udp_reserved_checkbutton.get_active(), self…
509 … my_policy.set_out_tcp(self.out_tcp_all_checkbutton.get_active(), self.out_tcp_entry.get_text())
510 … my_policy.set_out_udp(self.out_udp_all_checkbutton.get_active(), self.out_udp_entry.get_text())
512 iter= self.store.get_iter_first()
514 if self.store.get_value(iter, 1) == FILE:
515 my_policy.add_file(self.store.get_value(iter, 0))
517 my_policy.add_dir(self.store.get_value(iter, 0))
518 iter= self.store.iter_next(iter)
520 self.info(my_policy.generate(outputdir))
523 self.error(e.message)
525 def delete(self, args): argument
526 store, iter = self.view.get_selection().get_selected()
529 self.view.get_selection().select_path ((0,))
531 def delete_boolean(self, args): argument
532 store, iter = self.boolean_treeview.get_selection().get_selected()
535 self.boolean_treeview.get_selection().select_path ((0,))
537 def add_boolean(self,type): argument
538 self.boolean_name_entry.set_text("")
539 self.boolean_description_entry.set_text("")
540 rc = self.boolean_dialog.run()
541 self.boolean_dialog.hide()
544 iter = self.boolean_store.append()
545 self.boolean_store.set_value(iter, 0, self.boolean_name_entry.get_text())
546 self.boolean_store.set_value(iter, 1, self.boolean_description_entry.get_text())
548 def __add(self,type): argument
549 rc = self.file_dialog.run()
550 self.file_dialog.hide()
553 for i in self.file_dialog.get_filenames():
554 iter = self.store.append()
555 self.store.set_value(iter, 0, i)
556 self.store.set_value(iter, 1, type)
558 def exec_select(self, args): argument
559 self.file_dialog.set_select_multiple(0)
560 self.file_dialog.set_title(_("Select executable file to be confined."))
561 self.file_dialog.set_action(gtk.FILE_CHOOSER_ACTION_OPEN)
562 self.file_dialog.set_current_folder("/usr/sbin")
563 rc = self.file_dialog.run()
564 self.file_dialog.hide()
567 self.exec_entry.set_text(self.file_dialog.get_filename())
569 def init_script_select(self, args): argument
570 self.file_dialog.set_select_multiple(0)
571 self.file_dialog.set_title(_("Select init script file to be confined."))
572 self.file_dialog.set_action(gtk.FILE_CHOOSER_ACTION_OPEN)
573 self.file_dialog.set_current_folder("/etc/rc.d/init.d")
574 rc = self.file_dialog.run()
575 self.file_dialog.hide()
578 self.init_script_entry.set_text(self.file_dialog.get_filename())
580 def add(self, args): argument
581 self.file_dialog.set_title(_("Select file(s) that confined application creates or writes"))
582 self.file_dialog.set_current_folder("/")
583 self.file_dialog.set_action(gtk.FILE_CHOOSER_ACTION_OPEN)
584 self.file_dialog.set_select_multiple(1)
585 self.__add(FILE)
587 def add_dir(self, args): argument
588 …self.file_dialog.set_title(_("Select directory(s) that the confined application owns and writes in…
589 self.file_dialog.set_current_folder("/")
590 self.file_dialog.set_select_multiple(1)
591 self.file_dialog.set_action(gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER)
592 self.__add(DIR)
594 def on_about_clicked(self, args): argument
599 def quit(self, args): argument
602 def setupScreen(self): argument
604 self.mainWindow = self.xml.get_widget("main_window")
605 self.druid = self.xml.get_widget("druid")
606 self.type = 0
607 self.name_entry = self.xml.get_widget("name_entry")
608 self.name_entry.connect("insert_text",self.on_name_entry_changed)
609 self.name_entry.connect("focus_out_event",self.on_focus_out_event)
610 self.exec_entry = self.xml.get_widget("exec_entry")
611 self.exec_button = self.xml.get_widget("exec_button")
612 self.init_script_entry = self.xml.get_widget("init_script_entry")
613 self.init_script_button = self.xml.get_widget("init_script_button")
614 self.output_entry = self.xml.get_widget("output_entry")
615 self.output_entry.set_text(os.getcwd())
616 self.xml.get_widget("output_button").connect("clicked",self.output_button_clicked)
618 self.xwindows_user_radiobutton = self.xml.get_widget("xwindows_user_radiobutton")
619 self.terminal_user_radiobutton = self.xml.get_widget("terminal_user_radiobutton")
620 self.root_user_radiobutton = self.xml.get_widget("root_user_radiobutton")
621 self.login_user_radiobutton = self.xml.get_widget("login_user_radiobutton")
622 self.admin_user_radiobutton = self.xml.get_widget("admin_user_radiobutton")
623 self.existing_user_radiobutton = self.xml.get_widget("existing_user_radiobutton")
625 self.user_radiobutton = self.xml.get_widget("user_radiobutton")
626 self.init_radiobutton = self.xml.get_widget("init_radiobutton")
627 self.inetd_radiobutton = self.xml.get_widget("inetd_radiobutton")
628 self.dbus_radiobutton = self.xml.get_widget("dbus_radiobutton")
629 self.cgi_radiobutton = self.xml.get_widget("cgi_radiobutton")
630 self.sandbox_radiobutton = self.xml.get_widget("sandbox_radiobutton")
631 self.tmp_checkbutton = self.xml.get_widget("tmp_checkbutton")
632 self.uid_checkbutton = self.xml.get_widget("uid_checkbutton")
633 self.pam_checkbutton = self.xml.get_widget("pam_checkbutton")
634 self.dbus_checkbutton = self.xml.get_widget("dbus_checkbutton")
635 self.audit_checkbutton = self.xml.get_widget("audit_checkbutton")
636 self.terminal_checkbutton = self.xml.get_widget("terminal_checkbutton")
637 self.mail_checkbutton = self.xml.get_widget("mail_checkbutton")
638 self.syslog_checkbutton = self.xml.get_widget("syslog_checkbutton")
639 self.view = self.xml.get_widget("write_treeview")
640 self.file_dialog = self.xml.get_widget("filechooserdialog")
642 self.store = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_INT)
643 self.view.set_model(self.store)
646 self.view.append_column(col)
647 self.view.get_selection().select_path ((0,))
649 def output_button_clicked(self, *args): argument
650 self.file_dialog.set_title(_("Select directory to generate policy files in"))
651 self.file_dialog.set_action(gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER)
652 self.file_dialog.set_select_multiple(0)
653 rc = self.file_dialog.run()
654 self.file_dialog.hide()
657 self.output_entry.set_text(self.file_dialog.get_filename())
659 def on_name_entry_changed(self, entry, text, size, position): argument
663 def on_focus_out_event(self, entry, third): argument
665 if self.name != name:
666 if name in self.all_types:
667 …if self.verify(_("Type %s_t already defined in current policy.\nDo you want to continue?") % name,…
670 if name in self.all_modules:
671 …if self.verify(_("Module %s.pp already loaded in current policy.\nDo you want to continue?") % nam…
676 if os.path.isfile(file) and self.init_script_entry.get_text() == "":
677 self.init_script_entry.set_text(file)
680 if os.path.isfile(file) and self.exec_entry.get_text() == "":
681 self.exec_entry.set_text(file)
683 self.name = name
686 def on_in_net_page_next(self, *args): argument
688 generate.verify_ports(self.in_tcp_entry.get_text())
689 generate.verify_ports(self.in_udp_entry.get_text())
691 self.error(e.message)
694 def on_out_net_page_next(self, *args): argument
696 generate.verify_ports(self.out_tcp_entry.get_text())
697 generate.verify_ports(self.out_udp_entry.get_text())
699 self.error(e.message)
702 def on_select_type_page_next(self, *args): argument
703 self.exec_entry.set_sensitive(self.confine_application())
704 self.exec_button.set_sensitive(self.confine_application())
705 self.init_script_entry.set_sensitive(self.init_radiobutton.get_active())
706 self.init_script_button.set_sensitive(self.init_radiobutton.get_active())
708 def on_existing_user_page_next(self, *args): argument
709 store, iter = self.view.get_selection().get_selected()
711 self.error(_("You must select a user"))
714 def on_name_page_next(self, *args): argument
715 name=self.name_entry.get_text()
717 … self.error(_("You must add a name made up of letters and numbers and containing no spaces."))
720 for i in self.label_dict:
721 text = '<b>%s</b>' % (self.label_dict[i] % ("'" + name + "'"))
724 for i in self.tooltip_dict:
725 text = self.tooltip_dict[i] % ("'" + name + "'")
728 if self.confine_application():
729 exe = self.exec_entry.get_text()
731 self.error(_("You must enter a executable"))
733 policy=generate.policy(name, self.get_type())
738 iter = self.store.append()
739 self.store.set_value(iter, 0, f)
740 self.store.set_value(iter, 1, FILE)
743 iter = self.store.append()
744 self.store.set_value(iter, 0, f)
745 self.store.set_value(iter, 1, DIR)
746 self.tmp_checkbutton.set_active(policy.use_tmp)
747 self.uid_checkbutton.set_active(policy.use_uid)
748 self.pam_checkbutton.set_active(policy.use_pam)
749 self.dbus_checkbutton.set_active(policy.use_dbus)
750 self.audit_checkbutton.set_active(policy.use_audit)
751 self.terminal_checkbutton.set_active(policy.use_terminal)
752 self.mail_checkbutton.set_active(policy.use_mail)
753 self.syslog_checkbutton.set_active(policy.use_syslog)
755 def stand_alone(self): argument
758 self.setupScreen()
759 self.mainWindow.connect("destroy", self.quit)
761 self.mainWindow.show_all()