Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Put database password in db_user_password.

  • Loading branch information...
commit a448212c7139caea8f1cbc77ae2c1063c9fa83e9 1 parent d17bbc8
@bvds authored
View
28 Documentation/server.html
@@ -39,6 +39,25 @@
A session ends when the student hits the submit button or the back
button on the browser. 
+<h2>Database access</h2>
+
+<p>Create the file <code>db_user_password</code> in the Andes root
+directory.&nbsp; This file should contain, on separate lines,
+the mysql user name, password, and (optionally) the database
+name.&nbsp;
+This file should be readable only by the user:
+<pre>
+chmod 600 db_user_password
+</pre>
+You can test this file by running, in lisp, the commands:
+<pre>
+(rhelp)
+(andes-database:read-login-file)
+</pre>
+The command <code>(start-help)</code> will access this file for any values
+that are not given explicitly.
+
+
<h2>Running the Help Server</h2>
For normal production use, the Help server will be run as a daemon.&nbsp;
@@ -46,12 +65,6 @@
and starts up a lisp process that and runs the contents
of the file <a href="../help-server/init.cl">
<code>help-server/init.cl</code></a>.&nbsp;
-You may need to edit the <code>start-help</code> command in
-<a href="../help-server/init.cl"><code>help-server/init.cl</code></a>
-in order to include your mysql password
-or any other customization that you need to run the server.&nbsp;
-The function <code>start-help</code> is documented in the source
-file <a href="../Help/sessions.cl"><code>Help/sessions.cl</code></a>.
<p>To install the help server, or reinstall it, enter the following
command in the Andes root directory (as superuser):
@@ -77,7 +90,8 @@
<h2>Software Updates</h2>
-To update the software, in the Andes root directory, enter:&nbsp; <code>make update</code>
+To update the software, in the Andes root directory, enter:&nbsp;
+<code>make update</code>
<p>If the help server is running, restart the server using:
<pre>
View
16 Help/database.cl
@@ -23,6 +23,7 @@
(defpackage :andes-database
(:use :cl :json :mysql-connect)
(:export :write-transaction :destroy :create :set-session
+ :read-login-file
:get-matching-sessions :first-session-p))
(in-package :andes-database)
@@ -59,7 +60,20 @@
(sb-thread:with-mutex (*db-lock*) ,@body)
(error "No common database defined, can't continue."))))
-(defun create (&key host db user password)
+(defun read-login-file (&optional path)
+ "Read the database login file; file contains user name, password & (optional) database name."
+ (with-open-file (f (or path (merge-pathnames "db_user_password"
+ cl-user::*andes-path*))
+ :if-does-not-exist nil)
+ (when f (values (read-line f) (read-line f) (read-line f nil)))))
+
+(defun create (&key user password db host)
+
+ (multiple-value-bind (u p d) (read-login-file)
+ (setf user (or user u "root"))
+ (setf password (or password p (error "No database password given.")))
+ (setf db (or db d "andes3")))
+
(unless *skip-db*
(setf *connection*
(connect :host host :user user :password password :database db))))
View
7 Help/sessions.cl
@@ -58,7 +58,10 @@
;; db the name of the database, default "andes"
;; user database user name, default "root"
;; password the database password
+ ;; See Documentation/server.html for setting default values for
+ ;; the database login.
"start a server with help system, optionally specifying the server port, the log file path, and database access."
+
;; global setup
;; tune garbage collection
@@ -81,9 +84,7 @@
(physics-algebra-rules-initialize) ;initialize grammar
;; Set up database
- (andes-database:create :host host :db (or db "andes3")
- :user (or user "root")
- :password (or password ""))
+ (andes-database:create :host host :db db :user user :password password)
;; start webserver
(webserver:start-json-rpc-service
View
6 INSTALL
@@ -96,8 +96,8 @@ make sbclrc # Install the sbcl initialization file ~/.sbclrc
# As superuser:
/sbin/chkconfig mysqld on
/sbin/service mysqld start
-# Then set the root password (you can choose your own) and restart:
- /usr/bin/mysqladmin -u root password 'sin(0)=0'
+# Then set the root password (choose your own) and restart:
+ /usr/bin/mysqladmin -u root password 'mysql-password'
/sbin/service mysqld restart
# (In OS X, go to http://dev.mysql.com, install mysql and MySQLStartupItem,
# add /usr/local/mysql/bin to PATH in ~/.profile,
@@ -140,7 +140,7 @@ make install-dojo
;; To test the Help Server type "sbcl" to start up lisp, then:
(rhelp)
-(start-help :password "my-db-pass") ;specify mysql password
+(start-help :password "my-db-pass") ;specify your mysql password
;; The help server is now running on port 8080.
;; You can test access to the help server by using telnet:
View
2  help-server/init.cl
@@ -8,7 +8,7 @@
(setf *swank-loaded* t))
;; Start help server.
-(start-help :password "my-db-pass")
+(start-help)
;; Start a Swank server
#+swank (when *swank-loaded*
Please sign in to comment.
Something went wrong with that request. Please try again.