def read_signed(self): if re.search(r"\.gz$", self.name): f = gzip.open(self.name) else: f = open(self.name) (signers, body) = gpg.verify_sig(f.read()) self.signers = signers self.requests = request.parse_requests(body)
def read(self): self._open() self.signers = [] body = self.fd.read() if string.strip(body) == "": # empty file, don't choke self.requests = [] return try: self.requests = request.parse_requests(body) except Exception, e: log.panic("error parsing %s: %s" % (self.name, e)) pass
log.error("can't fetch %s: %s" % (control_url + "/queue.gz", e)) sys.exit(1) sio = StringIO.StringIO() util.sendfile(f, sio) f.close() sio.seek(0) f = gzip.GzipFile(fileobj = sio) (signers, body) = gpg.verify_sig(f.read()) u = acl.user_by_email(signers) if u == None: log.alert("queue.gz not signed with signature of valid user: %s" % signers) sys.exit(1) if not u.can_do("sign_queue", "all"): log.alert("user %s is not allowed to sign my queue" % u.login) sys.exit(1) return request.parse_requests(body) def handle_reqs(builder, reqs): qpath = path.queue_file + "-" + builder if not os.access(qpath, os.F_OK): util.append_to(qpath, "<queue/>\n") q = B_Queue(qpath) q.lock(0) q.read() for r in reqs: if r.kind != 'group': raise Exception, 'handle_reqs: fatal: huh? %s' % r.kind need_it = 0 for b in r.batches: if builder in b.builders: need_it = 1
sys.exit(1) sio = StringIO.StringIO() util.sendfile(f, sio) f.close() sio.seek(0) f = gzip.GzipFile(fileobj=sio) (signers, body) = gpg.verify_sig(f.read()) u = acl.user_by_email(signers) if u == None: log.alert("queue.gz not signed with signature of valid user: %s" % signers) sys.exit(1) if not u.can_do("sign_queue", "all"): log.alert("user %s is not allowed to sign my queue" % u.login) sys.exit(1) return request.parse_requests(body) def handle_reqs(builder, reqs): qpath = path.queue_file + "-" + builder if not os.access(qpath, os.F_OK): util.append_to(qpath, "<queue/>\n") q = B_Queue(qpath) q.lock(0) q.read() for r in reqs: if r.kind != 'group': raise Exception, 'handle_reqs: fatal: huh? %s' % r.kind need_it = 0 for b in r.batches: if builder in b.builders: