Mercurial > hg
comparison mercurial/ui.py @ 3098:c27d1e1798a3
Back out trusted hgrc change for now
Backed out changeset 494521a3f1425
author | Matt Mackall <mpm@selenic.com> |
---|---|
date | Fri, 15 Sep 2006 16:00:16 -0500 |
parents | 494521a3f142 |
children | 09e8aecd8016 |
comparison
equal
deleted
inserted
replaced
3013:494521a3f142 | 3098:c27d1e1798a3 |
---|---|
17 self.overlay = {} | 17 self.overlay = {} |
18 if parentui is None: | 18 if parentui is None: |
19 # this is the parent of all ui children | 19 # this is the parent of all ui children |
20 self.parentui = None | 20 self.parentui = None |
21 self.readhooks = list(readhooks) | 21 self.readhooks = list(readhooks) |
22 self.trusted_users = {} | |
23 self.trusted_groups = {} | |
24 self.cdata = ConfigParser.SafeConfigParser() | 22 self.cdata = ConfigParser.SafeConfigParser() |
25 self.readconfig(util.rcpath()) | 23 self.readconfig(util.rcpath()) |
26 | 24 |
27 self.quiet = self.configbool("ui", "quiet") | 25 self.quiet = self.configbool("ui", "quiet") |
28 self.verbose = self.configbool("ui", "verbose") | 26 self.verbose = self.configbool("ui", "verbose") |
37 self.revlogopts = self.configrevlog() | 35 self.revlogopts = self.configrevlog() |
38 else: | 36 else: |
39 # parentui may point to an ui object which is already a child | 37 # parentui may point to an ui object which is already a child |
40 self.parentui = parentui.parentui or parentui | 38 self.parentui = parentui.parentui or parentui |
41 self.readhooks = list(parentui.readhooks or readhooks) | 39 self.readhooks = list(parentui.readhooks or readhooks) |
42 self.trusted_users = parentui.trusted_users.copy() | |
43 self.trusted_groups = parentui.trusted_groups.copy() | |
44 parent_cdata = self.parentui.cdata | 40 parent_cdata = self.parentui.cdata |
45 self.cdata = ConfigParser.SafeConfigParser(parent_cdata.defaults()) | 41 self.cdata = ConfigParser.SafeConfigParser(parent_cdata.defaults()) |
46 # make interpolation work | 42 # make interpolation work |
47 for section in parent_cdata.sections(): | 43 for section in parent_cdata.sections(): |
48 self.cdata.add_section(section) | 44 self.cdata.add_section(section) |
74 def readconfig(self, fn, root=None): | 70 def readconfig(self, fn, root=None): |
75 if isinstance(fn, basestring): | 71 if isinstance(fn, basestring): |
76 fn = [fn] | 72 fn = [fn] |
77 for f in fn: | 73 for f in fn: |
78 try: | 74 try: |
79 fp = open(f) | 75 self.cdata.read(f) |
80 except IOError: | |
81 continue | |
82 if ((self.trusted_users or self.trusted_groups) and | |
83 '*' not in self.trusted_users and | |
84 '*' not in self.trusted_groups): | |
85 st = util.fstat(fp) | |
86 user = util.username(st.st_uid) | |
87 group = util.groupname(st.st_gid) | |
88 if (user not in self.trusted_users and | |
89 group not in self.trusted_groups): | |
90 self.warn(_('not reading file %s from untrusted ' | |
91 'user %s, group %s\n') % (f, user, group)) | |
92 continue | |
93 try: | |
94 self.cdata.readfp(fp, f) | |
95 except ConfigParser.ParsingError, inst: | 76 except ConfigParser.ParsingError, inst: |
96 raise util.Abort(_("Failed to parse %s\n%s") % (f, inst)) | 77 raise util.Abort(_("Failed to parse %s\n%s") % (f, inst)) |
97 # translate paths relative to root (or home) into absolute paths | 78 # translate paths relative to root (or home) into absolute paths |
98 if root is None: | 79 if root is None: |
99 root = os.path.expanduser('~') | 80 root = os.path.expanduser('~') |
100 for name, path in self.configitems("paths"): | 81 for name, path in self.configitems("paths"): |
101 if path and "://" not in path and not os.path.isabs(path): | 82 if path and "://" not in path and not os.path.isabs(path): |
102 self.cdata.set("paths", name, os.path.join(root, path)) | 83 self.cdata.set("paths", name, os.path.join(root, path)) |
103 user = util.username() | |
104 if user is not None: | |
105 self.trusted_users[user] = 1 | |
106 for user in self.configlist('trusted', 'users'): | |
107 self.trusted_users[user] = 1 | |
108 for group in self.configlist('trusted', 'groups'): | |
109 self.trusted_groups[group] = 1 | |
110 for hook in self.readhooks: | 84 for hook in self.readhooks: |
111 hook(self) | 85 hook(self) |
112 | 86 |
113 def setconfig(self, section, name, val): | 87 def setconfig(self, section, name, val): |
114 self.overlay[(section, name)] = val | 88 self.overlay[(section, name)] = val |