Lines Matching refs:self
116 def __init__(self): argument
117 self.xml = xml
118 self.notebook = xml.get_widget("notebook")
119 self.label_dict = {}
120 self.tooltip_dict = {}
122 self.label_dict[label] = label.get_text()
125 self.label_dict[label] = label.get_text()
128 self.label_dict[label] = label.get_text()
131 self.label_dict[label] = label.get_text()
134 self.label_dict[label] = label.get_text()
137 self.label_dict[label] = label.get_text()
140 self.label_dict[label] = label.get_text()
143 self.label_dict[label] = label.get_text()
146 self.label_dict[label] = label.get_text()
149 self.tooltip_dict[label] = label.get_tooltip_text()
152 self.tooltip_dict[label] = label.get_tooltip_text()
155 self.tooltip_dict[label] = label.get_tooltip_text()
158 self.tooltip_dict[label] = label.get_tooltip_text()
161 self.tooltip_dict[label] = label.get_tooltip_text()
164 self.tooltip_dict[label] = label.get_tooltip_text()
167 self.tooltip_dict[label] = label.get_tooltip_text()
170 self.tooltip_dict[label] = label.get_tooltip_text()
173 self.tooltip_dict[label] = label.get_tooltip_text()
176 self.tooltip_dict[label] = label.get_tooltip_text()
179 self.tooltip_dict[label] = label.get_tooltip_text()
182 self.tooltip_dict[label] = label.get_tooltip_text()
185 self.tooltip_dict[label] = label.get_tooltip_text()
188 self.tooltip_dict[label] = label.get_tooltip_text()
191 self.tooltip_dict[label] = label.get_tooltip_text()
194 self.tooltip_dict[label] = label.get_tooltip_text()
197 self.all_types = generate.get_all_types()
198 self.all_modules = get_all_modules()
199 self.all_roles = generate.get_all_roles()
200 self.all_users = generate.get_all_users()
202 self.all_types = []
203 self.all_modules = []
204 self.all_roles = []
205 self.all_users = []
206 self.error(str(e))
208 self.name = ""
209 xml.signal_connect("on_delete_clicked", self.delete)
210 xml.signal_connect("on_delete_boolean_clicked", self.delete_boolean)
211 xml.signal_connect("on_exec_select_clicked", self.exec_select)
212 xml.signal_connect("on_init_script_select_clicked", self.init_script_select)
213 xml.signal_connect("on_add_clicked", self.add)
214 xml.signal_connect("on_add_boolean_clicked", self.add_boolean)
215 xml.signal_connect("on_add_dir_clicked", self.add_dir)
216 xml.signal_connect("on_about_clicked", self.on_about_clicked)
217 xml.get_widget("cancel_button").connect("clicked", self.quit)
218 self.forward_button = xml.get_widget("forward_button")
219 self.forward_button.connect("clicked", self.forward)
220 self.back_button = xml.get_widget("back_button")
221 self.back_button.connect("clicked", self.back)
223 self.boolean_dialog = xml.get_widget("boolean_dialog")
224 self.boolean_name_entry = xml.get_widget("boolean_name_entry")
225 self.boolean_description_entry = xml.get_widget("boolean_description_entry")
227 self.pages = {}
229 …self.pages[i] = [self.SELECT_TYPE_PAGE, self.APP_PAGE, self.TRANSITION_PAGE, self.ROLE_PAGE, self.…
230 …self.pages[generate.RUSER] = [self.SELECT_TYPE_PAGE, self.APP_PAGE, self.ADMIN_PAGE, self.USER_TRA…
231 …self.pages[generate.LUSER] = [self.SELECT_TYPE_PAGE, self.APP_PAGE, self.TRANSITION_PAGE, self.IN_…
232 …self.pages[generate.SANDBOX] = [self.SELECT_TYPE_PAGE, self.APP_PAGE, self.IN_NET_PAGE, self.OUT_N…
233 …self.pages[generate.EUSER] = [self.SELECT_TYPE_PAGE, self.EXISTING_USER_PAGE, self.TRANSITION_PAGE…
236 …self.pages[i] = [self.SELECT_TYPE_PAGE, self.APP_PAGE, self.IN_NET_PAGE, self.OUT_NET_PAGE, self.C…
237 …self.pages[generate.USER] = [self.SELECT_TYPE_PAGE, self.APP_PAGE, self.USER_TRANSITION_PAGE, self…
239 self.current_page = 0
240 self.back_button.set_sensitive(0)
242 self.network_buttons = {}
244 self.in_tcp_all_checkbutton = xml.get_widget("in_tcp_all_checkbutton")
245 self.in_tcp_reserved_checkbutton = xml.get_widget("in_tcp_reserved_checkbutton")
246 self.in_tcp_unreserved_checkbutton = xml.get_widget("in_tcp_unreserved_checkbutton")
247 self.in_tcp_entry = self.xml.get_widget("in_tcp_entry")
248 …self.network_buttons[self.in_tcp_all_checkbutton] = [self.in_tcp_reserved_checkbutton, self.in_tcp…
250 self.out_tcp_all_checkbutton = xml.get_widget("out_tcp_all_checkbutton")
251 self.out_tcp_reserved_checkbutton = xml.get_widget("out_tcp_reserved_checkbutton")
252 self.out_tcp_unreserved_checkbutton = xml.get_widget("out_tcp_unreserved_checkbutton")
253 self.out_tcp_entry = self.xml.get_widget("out_tcp_entry")
255 self.network_buttons[self.out_tcp_all_checkbutton] = [self.out_tcp_entry]
257 self.in_udp_all_checkbutton = xml.get_widget("in_udp_all_checkbutton")
258 self.in_udp_reserved_checkbutton = xml.get_widget("in_udp_reserved_checkbutton")
259 self.in_udp_unreserved_checkbutton = xml.get_widget("in_udp_unreserved_checkbutton")
260 self.in_udp_entry = self.xml.get_widget("in_udp_entry")
262 …self.network_buttons[self.in_udp_all_checkbutton] = [self.in_udp_reserved_checkbutton, self.in_udp…
264 self.out_udp_all_checkbutton = xml.get_widget("out_udp_all_checkbutton")
265 self.out_udp_entry = self.xml.get_widget("out_udp_entry")
266 self.network_buttons[self.out_udp_all_checkbutton] = [self.out_udp_entry]
268 for b in self.network_buttons.keys():
269 b.connect("clicked", self.network_all_clicked)
271 self.boolean_treeview = self.xml.get_widget("boolean_treeview")
272 self.boolean_store = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_STRING)
273 self.boolean_treeview.set_model(self.boolean_store)
274 self.boolean_store.set_sort_column_id(0, gtk.SORT_ASCENDING)
276 self.boolean_treeview.append_column(col)
278 self.boolean_treeview.append_column(col)
280 self.role_treeview = self.xml.get_widget("role_treeview")
281 self.role_store = gtk.ListStore(gobject.TYPE_STRING)
282 self.role_treeview.set_model(self.role_store)
283 self.role_treeview.get_selection().set_mode(gtk.SELECTION_MULTIPLE)
284 self.role_store.set_sort_column_id(0, gtk.SORT_ASCENDING)
286 self.role_treeview.append_column(col)
288 self.existing_user_treeview = self.xml.get_widget("existing_user_treeview")
289 self.existing_user_store = gtk.ListStore(gobject.TYPE_STRING)
290 self.existing_user_treeview.set_model(self.existing_user_store)
291 self.existing_user_store.set_sort_column_id(0, gtk.SORT_ASCENDING)
293 self.existing_user_treeview.append_column(col)
295 for i in self.all_roles:
296 iter = self.role_store.append()
297 self.role_store.set_value(iter, 0, i[:-2])
299 self.in_tcp_reserved_checkbutton = xml.get_widget("in_tcp_reserved_checkbutton")
301 self.transition_treeview = self.xml.get_widget("transition_treeview")
302 self.transition_store = gtk.ListStore(gobject.TYPE_STRING)
303 self.transition_treeview.set_model(self.transition_store)
304 self.transition_treeview.get_selection().set_mode(gtk.SELECTION_MULTIPLE)
305 self.transition_store.set_sort_column_id(0, gtk.SORT_ASCENDING)
307 self.transition_treeview.append_column(col)
309 self.user_transition_treeview = self.xml.get_widget("user_transition_treeview")
310 self.user_transition_store = gtk.ListStore(gobject.TYPE_STRING)
311 self.user_transition_treeview.set_model(self.user_transition_store)
312 self.user_transition_treeview.get_selection().set_mode(gtk.SELECTION_MULTIPLE)
313 self.user_transition_store.set_sort_column_id(0, gtk.SORT_ASCENDING)
315 self.user_transition_treeview.append_column(col)
317 for i in self.all_users:
318 iter = self.user_transition_store.append()
319 self.user_transition_store.set_value(iter, 0, i[:-2])
320 iter = self.existing_user_store.append()
321 self.existing_user_store.set_value(iter, 0, i[:-2])
323 self.admin_treeview = self.xml.get_widget("admin_treeview")
324 self.admin_store = gtk.ListStore(gobject.TYPE_STRING)
325 self.admin_treeview.set_model(self.admin_store)
326 self.admin_treeview.get_selection().set_mode(gtk.SELECTION_MULTIPLE)
327 self.admin_store.set_sort_column_id(0, gtk.SORT_ASCENDING)
329 self.admin_treeview.append_column(col)
333 iter = self.transition_store.append()
334 self.transition_store.set_value(iter, 0, u)
337 iter = self.admin_store.append()
338 self.admin_store.set_value(iter, 0, a)
340 self.error(e.message)
342 def confine_application(self): argument
343 return self.get_type() in generate.APPLICATIONS
345 def forward(self, arg): argument
346 type = self.get_type()
347 if self.current_page == self.START_PAGE:
348 self.back_button.set_sensitive(1)
350 if self.pages[type][self.current_page] == self.SELECT_TYPE_PAGE:
351 if self.on_select_type_page_next():
354 if self.pages[type][self.current_page] == self.IN_NET_PAGE:
355 if self.on_in_net_page_next():
358 if self.pages[type][self.current_page] == self.OUT_NET_PAGE:
359 if self.on_out_net_page_next():
362 if self.pages[type][self.current_page] == self.APP_PAGE:
363 if self.on_name_page_next():
366 if self.pages[type][self.current_page] == self.EXISTING_USER_PAGE:
367 if self.on_existing_user_page_next():
370 if self.pages[type][self.current_page] == self.SELECT_DIR_PAGE:
371 outputdir = self.output_entry.get_text()
373 self.error(_("%s must be a directory") % outputdir)
376 if self.pages[type][self.current_page] == self.FINISH_PAGE:
377 self.generate_policy()
378 self.xml.get_widget("cancel_button").set_label(gtk.STOCK_CLOSE)
380 self.current_page = self.current_page + 1
381 self.notebook.set_current_page(self.pages[type][self.current_page])
382 if self.pages[type][self.current_page] == self.FINISH_PAGE:
383 self.forward_button.set_label(gtk.STOCK_APPLY)
385 def back(self, arg): argument
386 type = self.get_type()
387 if self.pages[type][self.current_page] == self.FINISH_PAGE:
388 self.forward_button.set_label(gtk.STOCK_GO_FORWARD)
390 self.current_page = self.current_page - 1
391 self.notebook.set_current_page(self.pages[type][self.current_page])
392 if self.pages[type][self.current_page] == self.START_PAGE:
393 self.back_button.set_sensitive(0)
395 def network_all_clicked(self, button): argument
397 for b in self.network_buttons[button]:
400 def verify(self, message, title=""): argument
411 def info(self, message): argument
420 def error(self, message): argument
429 def get_name(self): argument
430 if self.existing_user_radiobutton.get_active():
431 store, iter = self.existing_user_treeview.get_selection().get_selected()
436 return self.name_entry.get_text()
438 def get_type(self): argument
439 if self.sandbox_radiobutton.get_active():
441 if self.cgi_radiobutton.get_active():
443 if self.user_radiobutton.get_active():
445 if self.init_radiobutton.get_active():
447 if self.dbus_radiobutton.get_active():
449 if self.inetd_radiobutton.get_active():
451 if self.login_user_radiobutton.get_active():
453 if self.admin_user_radiobutton.get_active():
455 if self.xwindows_user_radiobutton.get_active():
457 if self.terminal_user_radiobutton.get_active():
459 if self.root_user_radiobutton.get_active():
461 if self.existing_user_radiobutton.get_active():
464 def generate_policy(self, *args): argument
465 outputdir = self.output_entry.get_text()
467 my_policy = generate.policy(self.get_name(), self.get_type())
469 iter = self.boolean_store.get_iter_first()
471 …my_policy.add_boolean(self.boolean_store.get_value(iter, 0), self.boolean_store.get_value(iter, 1))
472 iter = self.boolean_store.iter_next(iter)
474 if self.get_type() in generate.APPLICATIONS:
475 my_policy.set_program(self.exec_entry.get_text())
478 my_policy.set_use_syslog(self.syslog_checkbutton.get_active() == 1)
479 my_policy.set_use_tmp(self.tmp_checkbutton.get_active() == 1)
480 my_policy.set_use_uid(self.uid_checkbutton.get_active() == 1)
481 my_policy.set_use_pam(self.pam_checkbutton.get_active() == 1)
483 my_policy.set_use_dbus(self.dbus_checkbutton.get_active() == 1)
484 my_policy.set_use_audit(self.audit_checkbutton.get_active() == 1)
485 my_policy.set_use_terminal(self.terminal_checkbutton.get_active() == 1)
486 my_policy.set_use_mail(self.mail_checkbutton.get_active() == 1)
487 if self.get_type() is generate.DAEMON:
488 my_policy.set_init_script(self.init_script_entry.get_text())
489 if self.get_type() == generate.USER:
491 … self.user_transition_treeview.get_selection().selected_foreach(foreach, selected)
494 if self.get_type() == generate.RUSER:
496 self.admin_treeview.get_selection().selected_foreach(foreach, selected)
499 … self.user_transition_treeview.get_selection().selected_foreach(foreach, selected)
503 self.transition_treeview.get_selection().selected_foreach(foreach, selected)
507 self.role_treeview.get_selection().selected_foreach(foreach, selected)
510 …_tcp(self.in_tcp_all_checkbutton.get_active(), self.in_tcp_reserved_checkbutton.get_active(), self…
511 …_udp(self.in_udp_all_checkbutton.get_active(), self.in_udp_reserved_checkbutton.get_active(), self…
512 … my_policy.set_out_tcp(self.out_tcp_all_checkbutton.get_active(), self.out_tcp_entry.get_text())
513 … my_policy.set_out_udp(self.out_udp_all_checkbutton.get_active(), self.out_udp_entry.get_text())
515 iter = self.store.get_iter_first()
517 if self.store.get_value(iter, 1) == FILE:
518 my_policy.add_file(self.store.get_value(iter, 0))
520 my_policy.add_dir(self.store.get_value(iter, 0))
521 iter = self.store.iter_next(iter)
523 self.info(my_policy.generate(outputdir))
526 self.error(e.message)
528 def delete(self, args): argument
529 store, iter = self.view.get_selection().get_selected()
532 self.view.get_selection().select_path((0,))
534 def delete_boolean(self, args): argument
535 store, iter = self.boolean_treeview.get_selection().get_selected()
538 self.boolean_treeview.get_selection().select_path((0,))
540 def add_boolean(self, type): argument
541 self.boolean_name_entry.set_text("")
542 self.boolean_description_entry.set_text("")
543 rc = self.boolean_dialog.run()
544 self.boolean_dialog.hide()
547 iter = self.boolean_store.append()
548 self.boolean_store.set_value(iter, 0, self.boolean_name_entry.get_text())
549 self.boolean_store.set_value(iter, 1, self.boolean_description_entry.get_text())
551 def __add(self, type): argument
552 rc = self.file_dialog.run()
553 self.file_dialog.hide()
556 for i in self.file_dialog.get_filenames():
557 iter = self.store.append()
558 self.store.set_value(iter, 0, i)
559 self.store.set_value(iter, 1, type)
561 def exec_select(self, args): argument
562 self.file_dialog.set_select_multiple(0)
563 self.file_dialog.set_title(_("Select executable file to be confined."))
564 self.file_dialog.set_action(gtk.FILE_CHOOSER_ACTION_OPEN)
565 self.file_dialog.set_current_folder("/usr/sbin")
566 rc = self.file_dialog.run()
567 self.file_dialog.hide()
570 self.exec_entry.set_text(self.file_dialog.get_filename())
572 def init_script_select(self, args): argument
573 self.file_dialog.set_select_multiple(0)
574 self.file_dialog.set_title(_("Select init script file to be confined."))
575 self.file_dialog.set_action(gtk.FILE_CHOOSER_ACTION_OPEN)
576 self.file_dialog.set_current_folder("/etc/rc.d/init.d")
577 rc = self.file_dialog.run()
578 self.file_dialog.hide()
581 self.init_script_entry.set_text(self.file_dialog.get_filename())
583 def add(self, args): argument
584 self.file_dialog.set_title(_("Select file(s) that confined application creates or writes"))
585 self.file_dialog.set_current_folder("/")
586 self.file_dialog.set_action(gtk.FILE_CHOOSER_ACTION_OPEN)
587 self.file_dialog.set_select_multiple(1)
588 self.__add(FILE)
590 def add_dir(self, args): argument
591 …self.file_dialog.set_title(_("Select directory(s) that the confined application owns and writes in…
592 self.file_dialog.set_current_folder("/")
593 self.file_dialog.set_select_multiple(1)
594 self.file_dialog.set_action(gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER)
595 self.__add(DIR)
597 def on_about_clicked(self, args): argument
602 def quit(self, args): argument
605 def setupScreen(self): argument
607 self.mainWindow = self.xml.get_widget("main_window")
608 self.druid = self.xml.get_widget("druid")
609 self.type = 0
610 self.name_entry = self.xml.get_widget("name_entry")
611 self.name_entry.connect("insert_text", self.on_name_entry_changed)
612 self.name_entry.connect("focus_out_event", self.on_focus_out_event)
613 self.exec_entry = self.xml.get_widget("exec_entry")
614 self.exec_button = self.xml.get_widget("exec_button")
615 self.init_script_entry = self.xml.get_widget("init_script_entry")
616 self.init_script_button = self.xml.get_widget("init_script_button")
617 self.output_entry = self.xml.get_widget("output_entry")
618 self.output_entry.set_text(os.getcwd())
619 self.xml.get_widget("output_button").connect("clicked", self.output_button_clicked)
621 self.xwindows_user_radiobutton = self.xml.get_widget("xwindows_user_radiobutton")
622 self.terminal_user_radiobutton = self.xml.get_widget("terminal_user_radiobutton")
623 self.root_user_radiobutton = self.xml.get_widget("root_user_radiobutton")
624 self.login_user_radiobutton = self.xml.get_widget("login_user_radiobutton")
625 self.admin_user_radiobutton = self.xml.get_widget("admin_user_radiobutton")
626 self.existing_user_radiobutton = self.xml.get_widget("existing_user_radiobutton")
628 self.user_radiobutton = self.xml.get_widget("user_radiobutton")
629 self.init_radiobutton = self.xml.get_widget("init_radiobutton")
630 self.inetd_radiobutton = self.xml.get_widget("inetd_radiobutton")
631 self.dbus_radiobutton = self.xml.get_widget("dbus_radiobutton")
632 self.cgi_radiobutton = self.xml.get_widget("cgi_radiobutton")
633 self.sandbox_radiobutton = self.xml.get_widget("sandbox_radiobutton")
634 self.tmp_checkbutton = self.xml.get_widget("tmp_checkbutton")
635 self.uid_checkbutton = self.xml.get_widget("uid_checkbutton")
636 self.pam_checkbutton = self.xml.get_widget("pam_checkbutton")
637 self.dbus_checkbutton = self.xml.get_widget("dbus_checkbutton")
638 self.audit_checkbutton = self.xml.get_widget("audit_checkbutton")
639 self.terminal_checkbutton = self.xml.get_widget("terminal_checkbutton")
640 self.mail_checkbutton = self.xml.get_widget("mail_checkbutton")
641 self.syslog_checkbutton = self.xml.get_widget("syslog_checkbutton")
642 self.view = self.xml.get_widget("write_treeview")
643 self.file_dialog = self.xml.get_widget("filechooserdialog")
645 self.store = gtk.ListStore(gobject.TYPE_STRING, gobject.TYPE_INT)
646 self.view.set_model(self.store)
649 self.view.append_column(col)
650 self.view.get_selection().select_path((0,))
652 def output_button_clicked(self, *args): argument
653 self.file_dialog.set_title(_("Select directory to generate policy files in"))
654 self.file_dialog.set_action(gtk.FILE_CHOOSER_ACTION_SELECT_FOLDER)
655 self.file_dialog.set_select_multiple(0)
656 rc = self.file_dialog.run()
657 self.file_dialog.hide()
660 self.output_entry.set_text(self.file_dialog.get_filename())
662 def on_name_entry_changed(self, entry, text, size, position): argument
666 def on_focus_out_event(self, entry, third): argument
668 if self.name != name:
669 if name in self.all_types:
670 …if self.verify(_("Type %s_t already defined in current policy.\nDo you want to continue?") % name,…
673 if name in self.all_modules:
674 …if self.verify(_("Module %s.pp already loaded in current policy.\nDo you want to continue?") % nam…
679 if os.path.isfile(file) and self.init_script_entry.get_text() == "":
680 self.init_script_entry.set_text(file)
683 if os.path.isfile(file) and self.exec_entry.get_text() == "":
684 self.exec_entry.set_text(file)
686 self.name = name
689 def on_in_net_page_next(self, *args): argument
691 generate.verify_ports(self.in_tcp_entry.get_text())
692 generate.verify_ports(self.in_udp_entry.get_text())
694 self.error(e.message)
697 def on_out_net_page_next(self, *args): argument
699 generate.verify_ports(self.out_tcp_entry.get_text())
700 generate.verify_ports(self.out_udp_entry.get_text())
702 self.error(e.message)
705 def on_select_type_page_next(self, *args): argument
706 self.exec_entry.set_sensitive(self.confine_application())
707 self.exec_button.set_sensitive(self.confine_application())
708 self.init_script_entry.set_sensitive(self.init_radiobutton.get_active())
709 self.init_script_button.set_sensitive(self.init_radiobutton.get_active())
711 def on_existing_user_page_next(self, *args): argument
712 store, iter = self.view.get_selection().get_selected()
714 self.error(_("You must select a user"))
717 def on_name_page_next(self, *args): argument
718 name = self.name_entry.get_text()
720 … self.error(_("You must add a name made up of letters and numbers and containing no spaces."))
723 for i in self.label_dict:
724 text = '<b>%s</b>' % (self.label_dict[i] % ("'" + name + "'"))
727 for i in self.tooltip_dict:
728 text = self.tooltip_dict[i] % ("'" + name + "'")
731 if self.confine_application():
732 exe = self.exec_entry.get_text()
734 self.error(_("You must enter a executable"))
736 policy = generate.policy(name, self.get_type())
741 iter = self.store.append()
742 self.store.set_value(iter, 0, f)
743 self.store.set_value(iter, 1, FILE)
746 iter = self.store.append()
747 self.store.set_value(iter, 0, f)
748 self.store.set_value(iter, 1, DIR)
749 self.tmp_checkbutton.set_active(policy.use_tmp)
750 self.uid_checkbutton.set_active(policy.use_uid)
751 self.pam_checkbutton.set_active(policy.use_pam)
752 self.dbus_checkbutton.set_active(policy.use_dbus)
753 self.audit_checkbutton.set_active(policy.use_audit)
754 self.terminal_checkbutton.set_active(policy.use_terminal)
755 self.mail_checkbutton.set_active(policy.use_mail)
756 self.syslog_checkbutton.set_active(policy.use_syslog)
758 def stand_alone(self): argument
761 self.setupScreen()
762 self.mainWindow.connect("destroy", self.quit)
764 self.mainWindow.show_all()