Index: trunk/tools/subversion/user-management/homedirectorymanager.py |
— | — | @@ -133,12 +133,12 @@ |
134 | 134 | self.chmod(self.basedir + user + '/.ssh/authorized_keys', 0600) |
135 | 135 | for skeldir,skels in self.skelFiles.iteritems(): |
136 | 136 | for skel in skels: |
137 | | - shutil.copy(skeldir + skel, self.basedir + user + "/") |
| 137 | + self.copy(skeldir + skel, self.basedir + user + "/") |
138 | 138 | self.chmod(self.basedir + user + "/" + skel, 0600) |
139 | 139 | newGid = users[user]['gidNumber'] |
140 | 140 | newUid = users[user]['uidNumber'] |
141 | 141 | 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): |
143 | 143 | for name in files: |
144 | 144 | self.chown(os.path.join(root, name), newUid, newGid) |
145 | 145 | for name in dirs: |
— | — | @@ -174,7 +174,7 @@ |
175 | 175 | |
176 | 176 | # Write a list of keys to the user's authorized_keys file |
177 | 177 | 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") |
179 | 179 | |
180 | 180 | # Moved deleted users to SAVE |
181 | 181 | def moveUsers(self, users): |
— | — | @@ -263,19 +263,19 @@ |
264 | 264 | |
265 | 265 | def chown(self, path, user, group): |
266 | 266 | if not self.dryRun: |
267 | | - os.chown(self.basedir + userdir, -1, newGid) |
| 267 | + os.chown(path, user, group) |
268 | 268 | if self.dryRun or self.debugStatus: |
269 | 269 | self.log('chown %s %d %d' % (path, user, group)) |
270 | 270 | |
271 | | - def mkdir(self, path): |
| 271 | + def mkdir(self, path, mode): |
272 | 272 | if not self.dryRun: |
273 | | - os.mkdir(path) |
| 273 | + os.mkdir(path, mode) |
274 | 274 | if self.dryRun or self.debugStatus: |
275 | | - self.log('mkdir %s' % (path)) |
| 275 | + self.log('mkdir %s %o' % (path, mode)) |
276 | 276 | |
277 | 277 | def chmod(self, path, mode): |
278 | 278 | if not self.dryRun: |
279 | | - os.chmod(path) |
| 279 | + os.chmod(path, mode) |
280 | 280 | if self.dryRun or self.debugStatus: |
281 | 281 | self.log('chmod %s %o' % (path, mode)) |
282 | 282 | |
— | — | @@ -285,7 +285,7 @@ |
286 | 286 | f.write(contents) |
287 | 287 | f.close() |
288 | 288 | 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)) |
290 | 290 | |
291 | 291 | def rename(self, oldPath, newPath): |
292 | 292 | if not self.dryRun: |
— | — | @@ -293,6 +293,12 @@ |
294 | 294 | if self.dryRun or self.debugStatus: |
295 | 295 | self.log('rename %s %s' % (oldPath, newPath)) |
296 | 296 | |
| 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 | + |
297 | 303 | def main(): |
298 | 304 | homeDirectoryManager = HomeDirectoryManager() |
299 | 305 | homeDirectoryManager.run() |
Index: trunk/tools/subversion/user-management/add-ldap-user |
— | — | @@ -31,7 +31,7 @@ |
32 | 32 | if len(args) != 2: |
33 | 33 | parser.error("add-ldap-user expects exactly two arguments.") |
34 | 34 | |
35 | | - dryRun = parser.options.dryRun |
| 35 | + dryRun = options.dryRun |
36 | 36 | |
37 | 37 | ldapSupportLib.setBindInfoByOptions(options, parser) |
38 | 38 | |
— | — | @@ -130,7 +130,7 @@ |
131 | 131 | |
132 | 132 | userdict = {uid: {"uidNumber": int(uidNumber), "gidNumber": int(gidNumber), "sshPublicKey": keys}} |
133 | 133 | hdm = homedirectorymanager.HomeDirectoryManager() |
134 | | - hdm.dryRun = self.dryRun |
| 134 | + hdm.dryRun = dryRun |
135 | 135 | hdm.createHomeDir(userdict) |
136 | 136 | except ldap.UNWILLING_TO_PERFORM, msg: |
137 | 137 | sys.stderr.write("LDAP was unwilling to create the user. Error was: %s\n" % msg[0]["info"]) |