def make_svn_auth(store, login, config, throw_on_error=True): """Create a Subversion password for a user. Generates a new random Subversion password, and assigns it to the user. The password is added to Apache's Subversion authentication file. """ # filename is, eg, /var/lib/ivle/svn/ivle.auth filename = config['paths']['svn']['auth_ivle'] if os.path.exists(filename): create = "" else: create = "c" user = User.get_by_login(store, login) if user.svn_pass is None: passwd = hashlib.md5(uuid.uuid4().bytes).hexdigest() user.svn_pass = unicode(passwd) res = subprocess.call(['htpasswd', '-%smb' % create, filename, login, user.svn_pass]) if res != 0 and throw_on_error: raise Exception("Unable to create ivle-auth for %s" % login) # Make sure the file is owned by the web server if create == "c": chown_to_webserver(filename) return user.svn_pass
def render(self, req): """Handler for the Server application which serves pages.""" # Get the username of the student whose work we are browsing, and the # path on the local machine where the file is stored. (login, jail, path) = studpath.url_to_jailpaths(req.config, self.path) owner = User.get_by_login(req.store, login) if not owner: # There is no user. raise NotFound() self.serve(req, owner, jail, path)
def worksheetexercise_to_exerciseattempts(worksheet_exercise, login): user = User.get_by_login(Store.of(worksheet_exercise), login) if user is None: return None return ExerciseAttempts(worksheet_exercise, user)
def _to_python(self, value, state): user = User.get_by_login(state.store, value) if user: return user else: raise formencode.Invalid('User does not exist', value, state)
def get_repository_owner(self, store, name): '''Resolve the user name into a user.''' return User.get_by_login(store, name)
def root_to_user(root, segment): if not segment.startswith("~"): return None return User.get_by_login(root.store, segment[1:])