def main(): args = parse_cmdline() setup_logging(args) log.debug1("Arguments: %s" % sys.argv) # Read the password from stdin user_pass = input(False) # Check for valid database and user names # We restrict this to having only letters, numbers # and underscores, for safety against SQL injection identifier = re.compile(r"^[^\d\W]\w*\Z") if not identifier.match(args.user): log.error("The user name was not a valid identifier.") sys.exit(1) # Connect to the local database via 'peer' conn = psycopg2.connect(database=args.database) conn.autocommit = True log.info1("Connected to local database '%s'" % args.database) cur = conn.cursor() # Construct the SQL statement sql_msg = ("ALTER ROLE %s WITH ENCRYPTED PASSWORD" % (args.user) + " %(pwd)s;") log.info1("Executing: %s" % sql_msg) log.debug10("Password: [%s]", user_pass) # Submit the request cur.execute(sql_msg, {'pwd': user_pass}) sys.exit(0)
def dbus_introspection_add_properties(obj, data, interface): doc = minidom.parseString(data) for node in doc.getElementsByTagName("interface"): if node.hasAttribute("name") and node.getAttribute("name") == interface: for key,value in obj.GetAll(interface).items(): prop = doc.createElement("property") prop.setAttribute("name", key) prop.setAttribute("type", dbus_signature(value)) prop.setAttribute("access", "read") node.appendChild(prop) log.debug10(doc.toxml()) return doc.toxml()
def dbus_introspection_add_properties(obj, data, interface): doc = minidom.parseString(data) for node in doc.getElementsByTagName("interface"): if node.hasAttribute("name") and node.getAttribute( "name") == interface: for key, value in obj.GetAll(interface).items(): prop = doc.createElement("property") prop.setAttribute("name", key) prop.setAttribute("type", dbus_signature(value)) prop.setAttribute("access", "read") node.appendChild(prop) log.debug10(doc.toxml()) return doc.toxml()