コード例 #1
0
ファイル: makeuser.py プロジェクト: dcoles/ivle
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
コード例 #2
0
ファイル: __init__.py プロジェクト: dcoles/ivle
    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)
コード例 #3
0
ファイル: publishing.py プロジェクト: dcoles/ivle
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)
コード例 #4
0
ファイル: subject.py プロジェクト: dcoles/ivle
 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)
コード例 #5
0
ファイル: __init__.py プロジェクト: dcoles/ivle
 def get_repository_owner(self, store, name):
     '''Resolve the user name into a user.'''
     return User.get_by_login(store, name)
コード例 #6
0
ファイル: publishing.py プロジェクト: dcoles/ivle
def root_to_user(root, segment):
    if not segment.startswith("~"):
        return None
    return User.get_by_login(root.store, segment[1:])