def add_group(core): result = False add_user_to_group = core.get_distro_ver_data('add_user_to_group', '') if add_user_to_group: usermod = os.path.join(utils.which("usermod"), "usermod") + " %s %s" % (add_user_to_group, prop.username) else: usermod = os.path.join(utils.which("usermod"), "usermod") + " %s %s" % ("-Glp", prop.username) su_sudo = utils.su_sudo() password_f = None if su_sudo is "su": name,version,is_su = utils.os_release() log.debug("name = %s version = %s is_su = %s" %(name,version,is_su)) if ( name == 'Fedora' and version >= '14' and is_su == True): #using su opening GUI apps fail in Fedora 14. #To run GUI apps as root, you need a root login shell (su -) in Fedora 14 su_sudo = 'su - -c "%s"' else: su_sudo = 'su -c "%s"' password_f = "get_password_ui" # password_f = utils.get_password cmd =su_sudo % usermod log.info("cmd = %s" %cmd) # sts, output = utils.run(cmd, True, password_f, -1,True,cmd) sts, output = utils.run(cmd, True, password_f, 1, True, "Please enter root/superuser password to add 'lp' group") if sts == 0: result = True return result
def add_group(core): result = False add_user_to_group = core.get_distro_ver_data('add_user_to_group', '') if add_user_to_group: usermod = os.path.join( utils.which("usermod"), "usermod") + " %s %s" % (add_user_to_group, prop.username) else: usermod = os.path.join(utils.which("usermod"), "usermod") + " %s %s" % ("-Glp", prop.username) su_sudo = utils.su_sudo() password_f = None if su_sudo is "su": name, version, is_su = utils.os_release() log.debug("name = %s version = %s is_su = %s" % (name, version, is_su)) if (name == 'Fedora' and version >= '14' and is_su == True): #using su opening GUI apps fail in Fedora 14. #To run GUI apps as root, you need a root login shell (su -) in Fedora 14 su_sudo = 'su - -c "%s"' else: su_sudo = 'su -c "%s"' password_f = "get_password_ui" # password_f = utils.get_password cmd = su_sudo % usermod log.info("cmd = %s" % cmd) # sts, output = utils.run(cmd, True, password_f, -1,True,cmd) sts, output = utils.run( cmd, True, password_f, 1, True, "Please enter root/superuser password to add 'lp' group") if sts == 0: result = True return result
if utils.to_bool(sys_conf.get('configure', 'policy-kit')): try: obj = PolicyKit() su_sudo = "%s" need_sudo = False log.debug("Using PolicyKit for authentication") except dbus.DBusException, ex: log.error("PolicyKit NOT installed when configured for use") if os.geteuid() == 0: su_sudo = "%s" need_sudo = False password_f = None if need_sudo: su_sudo = utils.su_sudo() if su_sudo is "su": name,version,is_su = utils.os_release() log.debug("name = %s version = %s is_su = %s" %(name,version,is_su)) if ( name == 'Fedora' and version >= '14' and is_su == True): #using su opening GUI apps fail in Fedora 14. #To run GUI apps as root, you need a root login shell (su -) in Fedora 14 su_sudo = 'su - -c "%s"' else: su_sudo = 'su -c "%s"' password_f = "get_password_ui" if su_sudo is None: log.error("Unable to find a suitable sudo command to run 'hp-plugin'") return (False, False) req = '--required'