From 2b5b3b9ec4e7ebdac56bab0ba69e8b1f318f2050 Mon Sep 17 00:00:00 2001 From: aiju Date: Wed, 11 May 2011 14:12:25 +0000 Subject: [PATCH 1/2] added simple xargs script --- rc/bin/xargs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100755 rc/bin/xargs diff --git a/rc/bin/xargs b/rc/bin/xargs new file mode 100755 index 000000000..0387f2712 --- /dev/null +++ b/rc/bin/xargs @@ -0,0 +1,21 @@ +#!/bin/rc +fn usage { + echo usage: $0 [-n num] program [arguments] + exit usage +} +rfork e +ifs=' +' +nargs=1 +while(~ $1 -*) { + switch($1) { + case -n + nargs=$2 + shift 2 + case * + echo bla + usage + } +} +while(x = `{read -n $nargs}) + $* $x From c2a41bb939c9c6518a941eb77f3ecba53c12010e Mon Sep 17 00:00:00 2001 From: aiju Date: Wed, 11 May 2011 14:22:50 +0000 Subject: [PATCH 2/2] added 403 handling to hgfactotum --- sys/lib/python/hgext/hgfactotum.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/sys/lib/python/hgext/hgfactotum.py b/sys/lib/python/hgext/hgfactotum.py index 654c7a7d3..cd8d0f44b 100644 --- a/sys/lib/python/hgext/hgfactotum.py +++ b/sys/lib/python/hgext/hgfactotum.py @@ -8,6 +8,8 @@ import base64 class factotumbasic(urllib2.BaseHandler): def __init__(self, passmgr=None): self.f = factotum.Factotum() + self.retried = 0 + self.auth = None def http_error_401(self, req, fp, code, msg, headers): host = urllib2.urlparse.urlparse(req.get_full_url())[1] authreq = headers.get('www-authenticate', None) @@ -16,13 +18,23 @@ class factotumbasic(urllib2.BaseHandler): if authreq[0].lower() != 'basic': return None chal = urllib2.parse_keqv_list(urllib2.parse_http_list(authreq[1])) realm = chal['realm'] + self.auth = (host, realm) + self.retried += 1 + if self.retried >= 3: + self.f.delkey(proto="pass", host=host, realm=realm, role="client") self.f.start(proto="pass", host=host, realm=realm, role="client") pw = self.f.read().replace(' ', ':', 1) val = 'Basic %s' % base64.b64encode(pw).strip() if req.headers.get('Authorization', None) == val: return None req.add_header('Authorization', val) - return self.parent.open(req) - + result = self.parent.open(req) + self.retried = 0 + return result + def http_error_403(self, req, fp, code, msg, headers): + if self.auth != None: + self.f.delkey(proto="pass", host=self.auth[0], realm=self.auth[1], role="client") + self.auth = None + class factotumdigest(urllib2.BaseHandler): auth_header = 'Authorization' handler_order = 490