Mercurial > hg
comparison mercurial/ui.py @ 8133:57a2a0070d6b
ui: kill check_trusted
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Thu, 23 Apr 2009 15:40:10 -0500 |
parents | cece135ffcf0 |
children | e74e0c259bd3 |
comparison
equal
deleted
inserted
replaced
8132:cece135ffcf0 | 8133:57a2a0070d6b |
---|---|
42 self.trusted_groups = {} | 42 self.trusted_groups = {} |
43 # if ucdata is not None, its keys must be a superset of cdata's | 43 # if ucdata is not None, its keys must be a superset of cdata's |
44 self.cdata = util.configparser() | 44 self.cdata = util.configparser() |
45 self.ucdata = None | 45 self.ucdata = None |
46 # we always trust global config files | 46 # we always trust global config files |
47 self.check_trusted = False | 47 self.readconfig(util.rcpath(), assumetrusted=True) |
48 self.readconfig(util.rcpath()) | |
49 self.check_trusted = True | |
50 self.updateopts(verbose, debug, quiet, interactive) | 48 self.updateopts(verbose, debug, quiet, interactive) |
51 else: | 49 else: |
52 # parentui may point to an ui object which is already a child | 50 # parentui may point to an ui object which is already a child |
53 self.parentui = parentui.parentui or parentui | 51 self.parentui = parentui.parentui or parentui |
54 self.trusted_users = parentui.trusted_users.copy() | 52 self.trusted_users = parentui.trusted_users.copy() |
101 self.quiet = False | 99 self.quiet = False |
102 elif self.verbose and self.quiet: | 100 elif self.verbose and self.quiet: |
103 self.quiet = self.verbose = False | 101 self.quiet = self.verbose = False |
104 | 102 |
105 def _is_trusted(self, fp, f, warn=True): | 103 def _is_trusted(self, fp, f, warn=True): |
106 if not self.check_trusted: | |
107 return True | |
108 st = util.fstat(fp) | 104 st = util.fstat(fp) |
109 if util.isowner(fp, st): | 105 if util.isowner(fp, st): |
110 return True | 106 return True |
111 tusers = self.trusted_users | 107 tusers = self.trusted_users |
112 tgroups = self.trusted_groups | 108 tgroups = self.trusted_groups |
123 self.warn(_('Not trusting file %s from untrusted ' | 119 self.warn(_('Not trusting file %s from untrusted ' |
124 'user %s, group %s\n') % (f, user, group)) | 120 'user %s, group %s\n') % (f, user, group)) |
125 return False | 121 return False |
126 return True | 122 return True |
127 | 123 |
128 def readconfig(self, fn, root=None): | 124 def readconfig(self, fn, root=None, assumetrusted=False): |
129 if isinstance(fn, basestring): | 125 if isinstance(fn, basestring): |
130 fn = [fn] | 126 fn = [fn] |
131 for f in fn: | 127 for f in fn: |
132 try: | 128 try: |
133 fp = open(f) | 129 fp = open(f) |
134 except IOError: | 130 except IOError: |
135 continue | 131 continue |
136 cdata = self.cdata | 132 cdata = self.cdata |
137 trusted = self._is_trusted(fp, f) | 133 trusted = assumetrusted or self._is_trusted(fp, f) |
138 if not trusted: | 134 if not trusted: |
139 if self.ucdata is None: | 135 if self.ucdata is None: |
140 self.ucdata = dupconfig(self.cdata) | 136 self.ucdata = dupconfig(self.cdata) |
141 cdata = self.ucdata | 137 cdata = self.ucdata |
142 elif self.ucdata is not None: | 138 elif self.ucdata is not None: |