AsciiDocLog: Use only line buffering

Instead of full buffering, which is the default for regular files on
Linux, use line buffering only.

There are two reasons for this:

* If Elbe crashes without closing the log, the most recent log messages
  will be missing if using full buffering.

* We can now monitor the log file for changes, e.g. with tail -f.

Signed-off-by: Stefan Gast <stefan.gast@linutronix.de>
db: Add get_project_data, is_build_in_progress, get_username

Needed for the ProjectManager introduced in the next commit.

Signed-off-by: Stefan Gast <stefan.gast@linutronix.de>
db.load_project: Add optional logpath parameter

The logpath is passed to the ElbeProject constructor, so when using the
database, we can also log to files (instead of just stdout).

Signed-off-by: Stefan Gast <stefan.gast@linutronix.de>
dbaction: Add missing return to ResetProjectAction

In case the user did not specify the builddir, return after printing the
error message.

Signed-off-by: Stefan Gast <stefan.gast@linutronix.de>
Write repomanager output to log object

All classes defined in repomanager.py are used while we are not in
chroot, so we can safely use log.do here. So the CDROM generation
phase is now logged to the log object instead of the console.

Signed-off-by: Stefan Gast <stefan.gast@linutronix.de>
db: Save owner for new projects

Default is still no owner, which means that these projects can only be
opened by administrators.

Signed-off-by: Stefan Gast <stefan.gast@linutronix.de>
db: Add an action to create new users

Signed-off-by: Stefan Gast <stefan.gast@linutronix.de>
db: Add get_owner_id to query for project owner

Signed-off-by: Stefan Gast <stefan.gast@linutronix.de>
db: Add list_projects_of

This methods lists all projects owned by the user with the given id.

Signed-off-by: Stefan Gast <stefan.gast@linutronix.de>
db: Add id to UserData

Signed-off-by: Stefan Gast <stefan.gast@linutronix.de>
db:add_user: Raise ElbeDBError on non-unique name

Just do the same as for non-unique project builddirs here to be more
consistent.

Signed-off-by: Stefan Gast <stefan.gast@linutronix.de>
db: Implement user deletion

Add a function del_user to ElbeDB. The function deletes the user from
the database and sets the owner of all projects of the deleted user to
None. The list of these projects is then returned and can be used for
further cleanup.

The corresponding elbe db command has also been implemented. It
optionally removes all projects that were owned by the user deleted.

Signed-off-by: Stefan Gast <stefan.gast@linutronix.de>
db: Add modify_user

Can be used to change user data and (optionally) the password.

Signed-off-by: Stefan Gast <stefan.gast@linutronix.de>
db: Add get_user_data to query user details

Signed-off-by: Stefan Gast <stefan.gast@linutronix.de>
Add AsyncBuilder class for background builds

This is a simple worker thread building ElbeProjects passed through
a queue. Used by the ProjectManager.

Signed-off-by: Stefan Gast <stefan.gast@linutronix.de>
Add a ProjectManager for open projects

The new ProjectManager class will be used to track open projects and to
map users to them. Each user can have one open project at a time,
which is the user's active project. The class only allows one user per
project at a time.

Currently supported operations:
    * creating new projects
    * opening existing projects
    * closing the active project of a user
    * deleting projects
    * getting a file list of the current project
    * setting the XML file of the current project
    * putting the current project into the build queue of the
      AsyncBuilder

Still need to implement project ownership and permission checks.

Signed-off-by: Stefan Gast <stefan.gast@linutronix.de>
ProjectManager: Write log files to builddir

Write log files to builddir/log.txt instead of stdout.

Signed-off-by: Stefan Gast <stefan.gast@linutronix.de>
ProjectManager: Add permission checks for open/del

Add permission checks for opening and deleting projects. Admins may open
and delete all projects, while regular users can only open and delete
their own projects.

Signed-off-by: Stefan Gast <stefan.gast@linutronix.de>
Merge remote-tracking branch 'origin/devel/stefan/fixes' into devel/manut
Merge remote-tracking branch 'origin/devel/stefan/projectmanager' into devel/manut