68 _executable = _mountpoint = _service = None |
66 _executable = _mountpoint = _service = None |
69 |
67 |
70 configtable = {} |
68 configtable = {} |
71 configitem = registrar.configitem(configtable) |
69 configitem = registrar.configitem(configtable) |
72 |
70 |
73 configitem('factotum', 'executable', |
71 configitem( |
74 default='/bin/auth/factotum', |
72 'factotum', 'executable', default='/bin/auth/factotum', |
75 ) |
73 ) |
76 configitem('factotum', 'mountpoint', |
74 configitem( |
77 default='/mnt/factotum', |
75 'factotum', 'mountpoint', default='/mnt/factotum', |
78 ) |
76 ) |
79 configitem('factotum', 'service', |
77 configitem( |
80 default='hg', |
78 'factotum', 'service', default='hg', |
81 ) |
79 ) |
|
80 |
82 |
81 |
83 def auth_getkey(self, params): |
82 def auth_getkey(self, params): |
84 if not self.ui.interactive(): |
83 if not self.ui.interactive(): |
85 raise error.Abort(_('factotum not interactive')) |
84 raise error.Abort(_('factotum not interactive')) |
86 if 'user=' not in params: |
85 if 'user=' not in params: |
87 params = '%s user?' % params |
86 params = '%s user?' % params |
88 params = '%s !password?' % params |
87 params = '%s !password?' % params |
89 os.system(procutil.tonativestr("%s -g '%s'" % (_executable, params))) |
88 os.system(procutil.tonativestr("%s -g '%s'" % (_executable, params))) |
|
89 |
90 |
90 |
91 def auth_getuserpasswd(self, getkey, params): |
91 def auth_getuserpasswd(self, getkey, params): |
92 params = 'proto=pass %s' % params |
92 params = 'proto=pass %s' % params |
93 while True: |
93 while True: |
94 fd = os.open('%s/rpc' % _mountpoint, os.O_RDWR) |
94 fd = os.open('%s/rpc' % _mountpoint, os.O_RDWR) |
109 raise error.Abort(_('factotum not responding')) |
109 raise error.Abort(_('factotum not responding')) |
110 finally: |
110 finally: |
111 os.close(fd) |
111 os.close(fd) |
112 getkey(self, params) |
112 getkey(self, params) |
113 |
113 |
|
114 |
114 def monkeypatch_method(cls): |
115 def monkeypatch_method(cls): |
115 def decorator(func): |
116 def decorator(func): |
116 setattr(cls, func.__name__, func) |
117 setattr(cls, func.__name__, func) |
117 return func |
118 return func |
|
119 |
118 return decorator |
120 return decorator |
|
121 |
119 |
122 |
120 @monkeypatch_method(passwordmgr) |
123 @monkeypatch_method(passwordmgr) |
121 def find_user_password(self, realm, authuri): |
124 def find_user_password(self, realm, authuri): |
122 user, passwd = self.passwddb.find_user_password(realm, authuri) |
125 user, passwd = self.passwddb.find_user_password(realm, authuri) |
123 if user and passwd: |
126 if user and passwd: |
140 |
143 |
141 self.add_password(realm, authuri, user, passwd) |
144 self.add_password(realm, authuri, user, passwd) |
142 self._writedebug(user, passwd) |
145 self._writedebug(user, passwd) |
143 return (user, passwd) |
146 return (user, passwd) |
144 |
147 |
|
148 |
145 def uisetup(ui): |
149 def uisetup(ui): |
146 global _executable |
150 global _executable |
147 _executable = ui.config('factotum', 'executable') |
151 _executable = ui.config('factotum', 'executable') |
148 global _mountpoint |
152 global _mountpoint |
149 _mountpoint = ui.config('factotum', 'mountpoint') |
153 _mountpoint = ui.config('factotum', 'mountpoint') |