##// END OF EJS Templates
Back out trusted hgrc change for now...
Matt Mackall -
r3098:c27d1e17 default
parent child Browse files
Show More
@@ -50,8 +50,6 b' installed.'
50 particular repository. This file is not version-controlled, and
50 particular repository. This file is not version-controlled, and
51 will not get transferred during a "clone" operation. Options in
51 will not get transferred during a "clone" operation. Options in
52 this file override options in all other configuration files.
52 this file override options in all other configuration files.
53 On Unix, this file is only read if it belongs to a trusted user
54 or to a trusted group.
55
53
56 SYNTAX
54 SYNTAX
57 ------
55 ------
@@ -351,16 +349,6 b' server::'
351 6Mbps), uncompressed streaming is slower, because of the extra
349 6Mbps), uncompressed streaming is slower, because of the extra
352 data transfer overhead. Default is False.
350 data transfer overhead. Default is False.
353
351
354 trusted::
355 Mercurial will only read the .hg/hgrc file from a repository if
356 it belongs to a trusted user or to a trusted group. This section
357 specifies what users and groups are trusted. To trust everybody,
358 list a user or a group with name "*".
359 users;;
360 Comma-separated list of trusted users.
361 groups;;
362 Comma-separated list of trusted groups.
363
364 ui::
352 ui::
365 User interface controls.
353 User interface controls.
366 debug;;
354 debug;;
@@ -19,8 +19,6 b' class ui(object):'
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
@@ -39,8 +37,6 b' class ui(object):'
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
@@ -76,22 +72,7 b' class ui(object):'
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
@@ -100,13 +81,6 b' class ui(object):'
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
@@ -15,7 +15,7 b' platform-specific details from the core.'
15 from i18n import gettext as _
15 from i18n import gettext as _
16 from demandload import *
16 from demandload import *
17 demandload(globals(), "cStringIO errno getpass popen2 re shutil sys tempfile")
17 demandload(globals(), "cStringIO errno getpass popen2 re shutil sys tempfile")
18 demandload(globals(), "os threading time pwd grp")
18 demandload(globals(), "os threading time")
19
19
20 # used by parsedate
20 # used by parsedate
21 defaultdateformats = ('%Y-%m-%d %H:%M:%S', '%Y-%m-%d %H:%M',
21 defaultdateformats = ('%Y-%m-%d %H:%M:%S', '%Y-%m-%d %H:%M',
@@ -509,38 +509,6 b' def getuser():'
509 raise Abort(_('user name not available - set USERNAME '
509 raise Abort(_('user name not available - set USERNAME '
510 'environment variable'))
510 'environment variable'))
511
511
512 def username(uid=None):
513 """Return the name of the user with the given uid.
514
515 If uid is None, return the name of the current user."""
516 try:
517 # force an ImportError if there's no module pwd
518 getpwuid = pwd.getpwuid
519 if uid is None:
520 uid = os.getuid()
521 try:
522 return getpwuid(uid)[0]
523 except KeyError:
524 return str(uid)
525 except ImportError:
526 return None
527
528 def groupname(gid=None):
529 """Return the name of the group with the given gid.
530
531 If gid is None, return the name of the current group."""
532 try:
533 # force an ImportError if there's no module grp
534 getgrgid = grp.getgrgid
535 if gid is None:
536 gid = os.getgid()
537 try:
538 return getgrgid(gid)[0]
539 except KeyError:
540 return str(gid)
541 except ImportError:
542 return None
543
544 # Platform specific variants
512 # Platform specific variants
545 if os.name == 'nt':
513 if os.name == 'nt':
546 demandload(globals(), "msvcrt")
514 demandload(globals(), "msvcrt")
1 NO CONTENT: file was removed
NO CONTENT: file was removed
1 NO CONTENT: file was removed
NO CONTENT: file was removed
General Comments 0
You need to be logged in to leave comments. Login now