r86025 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r86024‎ | r86025 | r86026 >
Date:05:49, 14 April 2011
Author:tstarling
Status:deferred
Tags:
Comment:
Assorted fixes that came up during server-side testing
Modified paths:
  • /trunk/tools/subversion/user-management/add-ldap-user (modified) (history)
  • /trunk/tools/subversion/user-management/homedirectorymanager.py (modified) (history)

Diff [purge]

Index: trunk/tools/subversion/user-management/homedirectorymanager.py
@@ -133,12 +133,12 @@
134134 self.chmod(self.basedir + user + '/.ssh/authorized_keys', 0600)
135135 for skeldir,skels in self.skelFiles.iteritems():
136136 for skel in skels:
137 - shutil.copy(skeldir + skel, self.basedir + user + "/")
 137+ self.copy(skeldir + skel, self.basedir + user + "/")
138138 self.chmod(self.basedir + user + "/" + skel, 0600)
139139 newGid = users[user]['gidNumber']
140140 newUid = users[user]['uidNumber']
141141 self.chown(self.basedir + user, newUid, newGid)
142 - for root, dirs, files in self.walk(self.basedir + user):
 142+ for root, dirs, files in os.walk(self.basedir + user):
143143 for name in files:
144144 self.chown(os.path.join(root, name), newUid, newGid)
145145 for name in dirs:
@@ -174,7 +174,7 @@
175175
176176 # Write a list of keys to the user's authorized_keys file
177177 def writeKeys(self, user, keys):
178 - self.writeFile(self.basedir + user + '/.ssh/authorized_keys', ''.join(keys))
 178+ self.writeFile(self.basedir + user + '/.ssh/authorized_keys', "\n".join(keys) + "\n")
179179
180180 # Moved deleted users to SAVE
181181 def moveUsers(self, users):
@@ -263,19 +263,19 @@
264264
265265 def chown(self, path, user, group):
266266 if not self.dryRun:
267 - os.chown(self.basedir + userdir, -1, newGid)
 267+ os.chown(path, user, group)
268268 if self.dryRun or self.debugStatus:
269269 self.log('chown %s %d %d' % (path, user, group))
270270
271 - def mkdir(self, path):
 271+ def mkdir(self, path, mode):
272272 if not self.dryRun:
273 - os.mkdir(path)
 273+ os.mkdir(path, mode)
274274 if self.dryRun or self.debugStatus:
275 - self.log('mkdir %s' % (path))
 275+ self.log('mkdir %s %o' % (path, mode))
276276
277277 def chmod(self, path, mode):
278278 if not self.dryRun:
279 - os.chmod(path)
 279+ os.chmod(path, mode)
280280 if self.dryRun or self.debugStatus:
281281 self.log('chmod %s %o' % (path, mode))
282282
@@ -285,7 +285,7 @@
286286 f.write(contents)
287287 f.close()
288288 if self.dryRun or self.debugStatus:
289 - self.log("\nwrite file %s:\n%s" % (path, contents))
 289+ self.log("write file %s:\n%s" % (path, contents))
290290
291291 def rename(self, oldPath, newPath):
292292 if not self.dryRun:
@@ -293,6 +293,12 @@
294294 if self.dryRun or self.debugStatus:
295295 self.log('rename %s %s' % (oldPath, newPath))
296296
 297+ def copy(self, srcPath, dstPath):
 298+ if not self.dryRun:
 299+ shutil.copy(srcPath, dstPath)
 300+ if self.dryRun or self.debugStatus:
 301+ self.log('copy %s %s' % (srcPath, dstPath))
 302+
297303 def main():
298304 homeDirectoryManager = HomeDirectoryManager()
299305 homeDirectoryManager.run()
Index: trunk/tools/subversion/user-management/add-ldap-user
@@ -31,7 +31,7 @@
3232 if len(args) != 2:
3333 parser.error("add-ldap-user expects exactly two arguments.")
3434
35 - dryRun = parser.options.dryRun
 35+ dryRun = options.dryRun
3636
3737 ldapSupportLib.setBindInfoByOptions(options, parser)
3838
@@ -130,7 +130,7 @@
131131
132132 userdict = {uid: {"uidNumber": int(uidNumber), "gidNumber": int(gidNumber), "sshPublicKey": keys}}
133133 hdm = homedirectorymanager.HomeDirectoryManager()
134 - hdm.dryRun = self.dryRun
 134+ hdm.dryRun = dryRun
135135 hdm.createHomeDir(userdict)
136136 except ldap.UNWILLING_TO_PERFORM, msg:
137137 sys.stderr.write("LDAP was unwilling to create the user. Error was: %s\n" % msg[0]["info"])

Status & tagging log