예제 #1
0
def main(argv):
    try:
        opts,args = getopt.getopt(sys.argv[1:], "", [])
    except getopt.GetoptError:
        sys.exit(2)
    #FIXME
    #check for 2 args here we assume the arguments are correct
    if len(args) != 2:
        dialog = gtk.MessageDialog(None,
                                   0,
                                   gtk.MESSAGE_ERROR,
                                   gtk.BUTTONS_CLOSE,
                                   _("Invalid arguments count."))
	dialog.set_title (_("Error"))
        dialog.format_secondary_text(_("Snapshot Now requires"
                                       " 2 arguments :\n- The path of the "
				       "directory to be snapshotted.\n"
                                       "- The zfs filesystem corresponding "
				       "to this directory."))
        dialog.run()
	sys.exit (2)
	
    rbacp = RBACprofile()
    # The user security attributes checked are the following:
    # 1. The "Primary Administrator" role
    # 4. The "ZFS Files System Management" profile.
    #
    # Valid combinations of the above are:
    # - 1 or 4
    # Note that an effective UID=0 will match any profile search so
    # no need to check it explicitly.
    if rbacp.has_profile("ZFS File System Management"):
	manager = SnapshotNowDialog(args[0],args[1])
        gtk.main()
    elif os.path.exists(argv) and os.path.exists("/usr/bin/gksu"):
        # Run via gksu, which will prompt for the root password
        newargs = ["gksu", argv]
        for arg in args:
            newargs.append(arg)
        os.execv("/usr/bin/gksu", newargs)
        # Shouldn't reach this point
        sys.exit(1)
    else:
        dialog = gtk.MessageDialog(None,
                                   0,
                                   gtk.MESSAGE_ERROR,
                                   gtk.BUTTONS_CLOSE,
                                   _("Insufficient Priviliges"))
	dialog.set_title (_("Error"))
        dialog.format_secondary_text(_("Snapshot Now requires "
                                       "administrative privileges to run. "
                                       "You have not been assigned the necessary"
                                       "administrative priviliges."
                                       "\n\nConsult your system administrator "))
        dialog.run()
        print argv + "is not a valid executable path"
        sys.exit(1)
예제 #2
0
def main(argv):
    try:
        opts,args = getopt.getopt(sys.argv[1:], "", [])
    except getopt.GetoptError:
        sys.exit(2)
    #FIXME
    #check for 2 args here we assume the arguments are correct
    if len(args) != 2:
        dialog = gtk.MessageDialog(None,
                                   0,
                                   gtk.MESSAGE_ERROR,
                                   gtk.BUTTONS_CLOSE,
                                   _("Invalid arguments count."))
	dialog.set_title (_("Error"))
        dialog.format_secondary_text(_("Snapshot Now requires"
                                       " 2 arguments :\n- The path of the "
				       "directory to be snapshotted.\n"
                                       "- The zfs filesystem corresponding "
				       "to this directory."))
        dialog.run()
	sys.exit (2)
	
    rbacp = RBACprofile()
    # The user security attributes checked are the following:
    # 1. The "Primary Administrator" role
    # 4. The "ZFS Files System Management" profile.
    #
    # Valid combinations of the above are:
    # - 1 or 4
    # Note that an effective UID=0 will match any profile search so
    # no need to check it explicitly.
    if rbacp.has_profile("ZFS File System Management"):
	manager = SnapshotNowDialog(args[0],args[1])
        gtk.main()
    elif os.path.exists(argv) and os.path.exists("/usr/bin/gksu"):
        # Run via gksu, which will prompt for the root password
        newargs = ["gksu", argv]
        for arg in args:
            newargs.append(arg)
        os.execv("/usr/bin/gksu", newargs)
        # Shouldn't reach this point
        sys.exit(1)
    else:
        dialog = gtk.MessageDialog(None,
                                   0,
                                   gtk.MESSAGE_ERROR,
                                   gtk.BUTTONS_CLOSE,
                                   _("Insufficient Priviliges"))
	dialog.set_title (_("Error"))
        dialog.format_secondary_text(_("Snapshot Now requires "
                                       "administrative privileges to run. "
                                       "You have not been assigned the necessary"
                                       "administrative priviliges."
                                       "\n\nConsult your system administrator "))
        dialog.run()
        print argv + "is not a valid executable path"
        sys.exit(1)
예제 #3
0
def main(argv):

    # Check SMF invocation environment
    if os.getenv("SMF_FMRI") == None or os.getenv("SMF_METHOD") != "start":
        sys.stderr.write("Command line invocation of %s unsupported.\n" \
                         % (sys.argv[0]))
        sys.stderr.write(
            "This command is intended for smf(5) invocation only.\n")
        sys.exit(smf.SMF_EXIT_ERR_NOSMF)

    # Daemonise the service.
    create_daemon()

    # The user security attributes checked are the following:
    # Note that UID == 0 will match any profile search so
    # no need to check it explicitly.
    syslog.openlog("time-sliderd", 0, syslog.LOG_DAEMON)
    rbacp = RBACprofile()
    if rbacp.has_profile("ZFS File System Management"):

        gobject.threads_init()

        # Tell dbus to use the gobject mainloop for async ops
        dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
        dbus.mainloop.glib.threads_init()
        # Register a bus name with the system dbus daemon
        systemBus = dbus.SystemBus()
        name = dbus.service.BusName("org.opensolaris.TimeSlider", systemBus)

        # Create and start the snapshot manger. Takes care of
        # auto snapshotting service and auto cleanup.
        snapshot = SnapshotManager(systemBus)
        snapshot.start()
        gobject.timeout_add(2000, monitor_threads, snapshot)

        mainloop = gobject.MainLoop()
        try:
            mainloop.run()
        except KeyboardInterrupt:
            mainloop.quit()
            sys.exit(smf.SMF_EXIT_OK)
    else:
        syslog.syslog(syslog.LOG_ERR,
               "%s has insufficient privileges to run time-sliderd!" \
               % rbacp.name)
        syslog.closelog()
        sys.exit(smf.SMF_EXIT_ERR_PERM)
    syslog.closelog()
    sys.exit(smf.SMF_EXIT_OK)
예제 #4
0
def main(argv):

    # Check SMF invocation environment
    if os.getenv("SMF_FMRI") == None or os.getenv("SMF_METHOD") != "start":
        sys.stderr.write("Command line invocation of %s unsupported.\n" \
                         % (sys.argv[0]))
        sys.stderr.write("This command is intended for smf(5) invocation only.\n")
        sys.exit(smf.SMF_EXIT_ERR_NOSMF)

    # Daemonise the service.
    create_daemon()

    # The user security attributes checked are the following:
    # Note that UID == 0 will match any profile search so
    # no need to check it explicitly.
    syslog.openlog("time-sliderd", 0, syslog.LOG_DAEMON)
    rbacp = RBACprofile()
    if rbacp.has_profile("ZFS File System Management"):

        gobject.threads_init()

        # Tell dbus to use the gobject mainloop for async ops
        dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
        dbus.mainloop.glib.threads_init()
        # Register a bus name with the system dbus daemon
        systemBus = dbus.SystemBus()
        name = dbus.service.BusName("org.opensolaris.TimeSlider", systemBus)

        # Create and start the snapshot manger. Takes care of
        # auto snapshotting service and auto cleanup.
        snapshot = SnapshotManager(systemBus)
        snapshot.start()
        gobject.timeout_add(2000, monitor_threads, snapshot)

        mainloop = gobject.MainLoop()
        try:
            mainloop.run()
        except KeyboardInterrupt:
            mainloop.quit()
            sys.exit(smf.SMF_EXIT_OK)
    else:
        syslog.syslog(syslog.LOG_ERR,
               "%s has insufficient privileges to run time-sliderd!" \
               % rbacp.name)
        syslog.closelog()    
        sys.exit(smf.SMF_EXIT_ERR_PERM)
    syslog.closelog()
    sys.exit(smf.SMF_EXIT_OK)
예제 #5
0
def main(argv):
    try:
        opts,args = getopt.getopt(sys.argv[1:], "", [])
    except getopt.GetoptError:
        sys.exit(2)
    rbacp = RBACprofile()
    if os.geteuid() == 0:
        if len(args) > 0:
            manager = DeleteSnapManager(args)
        else:
            manager = DeleteSnapManager()
        gtk.gdk.threads_enter()
        glib.idle_add(manager.initialise_view)
        gtk.main()
        gtk.gdk.threads_leave()
    elif os.path.exists(argv) and os.path.exists("/usr/bin/gksu"):
        # Run via gksu, which will prompt for the root password
        newargs = ["gksu", argv]
        for arg in args:
            newargs.append(arg)
        os.execv("/usr/bin/gksu", newargs);
        # Shouldn't reach this point
        sys.exit(1)
    else:
        dialog = gtk.MessageDialog(None,
                                   0,
                                   gtk.MESSAGE_ERROR,
                                   gtk.BUTTONS_CLOSE,
                                   _("Insufficient Priviliges"))
        dialog.format_secondary_text(_("Snapshot deletion requires "
                                       "administrative privileges to run. "
                                       "You have not been assigned the necessary"
                                       "administrative priviliges."
                                       "\n\nConsult your system administrator "))
        dialog.run()
        print argv + "is not a valid executable path"
        sys.exit(1)