X-Git-Url: https://git.decadent.org.uk/gitweb/?a=blobdiff_plain;f=dak%2Fadd_user.py;h=f087849c8bd507653af2c7af8c357bc1fc767bb8;hb=3950b9877f066f4946d5ac1eec121913f9594142;hp=28d312087fbcd712408027293d80e38dadb823fb;hpb=a286482465b9952a951ba8d4954a4ccfed4b3fef;p=dak.git diff --git a/dak/add_user.py b/dak/add_user.py index 28d31208..f087849c 100755 --- a/dak/add_user.py +++ b/dak/add_user.py @@ -22,8 +22,8 @@ import sys import apt_pkg from daklib import utils -from daklib.dbconn import DBConn, add_database_user, get_or_set_uid -from daklib.regexes import re_gpg_fingerprint, re_user_address, re_user_mails, re_user_name +from daklib.dbconn import DBConn, get_or_set_uid +from daklib.regexes import re_gpg_fingerprint_colon, re_user_address, re_user_mails, re_user_name ################################################################################ @@ -126,17 +126,11 @@ def main(): if not keyrings: keyrings = Cnf.ValueList("Dinstall::GPGKeyring") -# Ignore the PGP keyring for download of new keys. Ignore errors, if key is missing it will -# barf with the next commands. - cmd = "gpg --no-secmem-warning --no-default-keyring %s --recv-keys %s" \ - % (utils.gpg_keyring_args(keyrings), Cnf["Add-User::Options::Key"]) - (result, output) = commands.getstatusoutput(cmd) - cmd = "gpg --with-colons --no-secmem-warning --no-auto-check-trustdb --no-default-keyring %s --with-fingerprint --list-key %s" \ % (utils.gpg_keyring_args(keyrings), Cnf["Add-User::Options::Key"]) (result, output) = commands.getstatusoutput(cmd) - m = re_gpg_fingerprint.search(output) + m = re_gpg_fingerprint_colon.search(output) if not m: print output utils.fubar("0x%s: (1) No fingerprint found in gpg output but it returned 0?\n%s" \ @@ -167,7 +161,6 @@ def main(): continue emails.append(e.group(2)) - print "0x%s -> %s <%s> -> %s -> %s" % (Cnf["Add-User::Options::Key"], name, emails[0], uid, primary_key) prompt = "Add user %s with above data (y/N) ? " % (uid) @@ -176,39 +169,13 @@ def main(): if yn == "y": # Create an account for the user? summary = "" - if Cnf.FindB("Add-User::CreateAccount") or Cnf["Add-User::Options::Create"]: - password = GenPass() - pwcrypt = HashPass(password) - if Cnf.has_key("Add-User::GID"): - cmd = "sudo /usr/sbin/useradd -g users -m -p '%s' -c '%s' -G %s %s" \ - % (pwcrypt, name, Cnf["Add-User::GID"], uid) - else: - cmd = "sudo /usr/sbin/useradd -g users -m -p '%s' -c '%s' %s" \ - % (pwcrypt, name, uid) - (result, output) = commands.getstatusoutput(cmd) - if (result != 0): - utils.fubar("Invocation of '%s' failed:\n%s\n" % (cmd, output), result) - try: - summary+=createMail(uid, password, Cnf["Add-User::Options::Key"], Cnf["Dinstall::GPGKeyring"]) - except: - summary="" - utils.warn("Could not prepare password information for mail, not sending password.") # Now add user to the database. # Note that we provide a session, so we're responsible for committing uidobj = get_or_set_uid(uid, session=session) uid_id = uidobj.uid_id - add_database_user(uid) session.commit() - # The following two are kicked out in rhona, so we don't set them. kelly adds - # them as soon as she installs a package with unknown ones, so no problems to expect here. - # Just leave the comment in, to not think about "Why the hell aren't they added" in - # a year, if we ever touch uma again. - # maint_id = database.get_or_set_maintainer_id(name) - # session.execute("INSERT INTO fingerprint (fingerprint, uid) VALUES (:fingerprint, uid)", - # {'fingerprint': primary_key, 'uid': uid_id}) - # Lets add user to the email-whitelist file if its configured. if Cnf.has_key("Dinstall::MailWhiteList") and Cnf["Dinstall::MailWhiteList"] != "": f = utils.open_file(Cnf["Dinstall::MailWhiteList"], "a") @@ -228,7 +195,9 @@ def main(): Subst["__KEYID__"] = Cnf["Add-User::Options::Key"] Subst["__PRIMARY_KEY__"] = primary_key Subst["__FROM_ADDRESS__"] = Cnf["Dinstall::MyEmailAddress"] + Subst["__ADMIN_ADDRESS__"] = Cnf["Dinstall::MyAdminAddress"] Subst["__HOSTNAME__"] = Cnf["Dinstall::MyHost"] + Subst["__DISTRO__"] = Cnf["Dinstall::MyDistribution"] Subst["__SUMMARY__"] = summary new_add_message = utils.TemplateSubst(Subst,Cnf["Dir::Templates"]+"/add-user.added") utils.send_mail(new_add_message)