Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Database issues fresh install Ubuntu Server 16 #1434

Closed
syloktools opened this issue Aug 11, 2016 · 26 comments
Closed

Database issues fresh install Ubuntu Server 16 #1434

syloktools opened this issue Aug 11, 2016 · 26 comments
Labels
T: support Type: support. This issue is seeking support on a problem or question
Milestone

Comments

@syloktools
Copy link

syloktools commented Aug 11, 2016

debug_log.txt
error_log.txt

Fresh install and I am getting a database error. Newbie to all this.

Thanks.

image

If you would like to report a bug, please fill the template bellow

Work environment

Questions Answers
Type of issue Question
OS version (server) ubuntu
OS version (client) Win 7
@iglocska
Copy link
Member

Could you check your error.log file for what's causing the issue? It's located at /var/www/MISP/app/tmp/error.log .

@iglocska
Copy link
Member

My bad, completely missed it.

It looks like your database.php isn't correctly set up, could you have a look at whether you have it correctly set up? It's located at /var/www/MISP/app/Config/databse.php

@syloktools
Copy link
Author

root@ubuntu:/var/www/MISP/app/tmp/logs# sudo -u www-data vim /var/www/MISP/app/Config/database.php
*

  • CakePHP(tm) : Rapid Development Framework (http://cakephp.org)

  • Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)
    *

  • Licensed under The MIT License

  • Redistributions of files must retain the above copyright notice.
    *

  • @copyright Copyright 2005-2012, Cake Software Foundation, Inc. (http://cakefoundation.org)

  • @link http://cakephp.org CakePHP(tm) Project

  • @Package app.Config

  • @SInCE CakePHP(tm) v 0.2.9

  • @license MIT License (http://www.opensource.org/licenses/mit-license.php)
    /
    /
    *

  • In this file you set up your database connection details.
    *

  • @Package cake.config
    /
    /
    *

  • Database configuration class.

  • You can specify multiple configurations for production, development and testing.
    *

  • datasource => The name of a supported datasource; valid options are as follows:

  •          Database/Mysql          - MySQL 4 & 5,
    
  •          Database/Sqlite         - SQLite (PHP5 only),
    
  •          Database/Postgres       - PostgreSQL 7 and higher,
    
  •          Database/Sqlserver      - Microsoft SQL Server 2005 and higher
    
  • You can add custom database datasources (or override existing datasources) by adding the

  • appropriate file to app/Model/Datasource/Database. Datasources should be named 'MyDatasource.php',
    *
    *

  • persistent => true / false

  • Determines whether or not the database should use a persistent connection
    *

  • host =>

  • the host you connect to the database. To add a socket or port number, use 'port' => #
    *

  • prefix =>

  • Uses the given prefix for all the tables in this database. This setting can be overridden

  • on a per-table basis with the Model::$tablePrefix property.
    *

  • schema =>

  • For Postgres specifies which schema you would like to use the tables in. Postgres defaults to 'public'.
    *

  • encoding =>

  • For MySQL, Postgres specifies the character encoding to use when connecting to the

  • database. Uses database default not specified.
    *

  • unix_socket =>

  • For MySQL to connect via socket specify the unix_socket parameter instead of host and port
    */
    class DATABASE_CONFIG {

    public $Default = array(
            'datasource' => 'Database/Mysql',
            'persistent' => false,
            'host' => 'localhost',
            'login' => 'rnixon',
            'port' => 3306,
            'password' => '******',
            'database' => 'misp',
            'prefix' => '',
            //'encoding' => 'utf8',
    );
    

    }

@iglocska
Copy link
Member

It looks like you accidentally capitalised the name of the array, it should be $default. Could you change that and see if it works? Thanks!

@syloktools
Copy link
Author

Database error went away buy still the same:

2016-08-12 06:42:59 Notice: Notice (8): Undefined variable: debugMode in [/var/www/MISP/app/View/Layouts/default.ctp, line 92]
Trace:
include - APP/View/Layouts/default.ctp, line 92
View::_evaluate() - APP/Lib/cakephp/lib/Cake/View/View.php, line 971
View::_render() - APP/Lib/cakephp/lib/Cake/View/View.php, line 933
View::renderLayout() - APP/Lib/cakephp/lib/Cake/View/View.php, line 546
View::render() - APP/Lib/cakephp/lib/Cake/View/View.php, line 481
Controller::render() - APP/Lib/cakephp/lib/Cake/Controller/Controller.php, line 963
ExceptionRenderer::_outputMessage() - APP/Lib/cakephp/lib/Cake/Error/ExceptionRenderer.php, line 289
ExceptionRenderer::error500() - APP/Lib/cakephp/lib/Cake/Error/ExceptionRenderer.php, line 257
ExceptionRenderer::render() - APP/Lib/cakephp/lib/Cake/Error/ExceptionRenderer.php, line 187
ErrorHandler::handleException() - APP/Lib/cakephp/lib/Cake/Error/ErrorHandler.php, line 127
[main] - [internal], line ??

@syloktools
Copy link
Author

2016-08-12 06:42:59 Error: [ParseError] syntax error, unexpected 'o' (T_STRING), expecting function (T_FUNCTION)
Request URL: /
Stack Trace:
#0 /var/www/MISP/app/Lib/cakephp/lib/Cake/Model/ConnectionManager.php(83): ConnectionManager::_init()
#1 /var/www/MISP/app/Lib/cakephp/lib/Cake/Model/Model.php(3626): ConnectionManager::getDataSource('default')
#2 /var/www/MISP/app/Lib/cakephp/lib/Cake/Model/Model.php(1155): Model->setDataSource('default')
#3 /var/www/MISP/app/Lib/cakephp/lib/Cake/Model/Model.php(3653): Model->setSource('logs')
#4 /var/www/MISP/app/Lib/cakephp/lib/Cake/Model/Model.php(1387): Model->getDataSource()
#5 /var/www/MISP/app/Plugin/SysLogLogable/Model/Behavior/SysLogLogableBehavior.php(275): Model->schema()
#6 /var/www/MISP/app/Lib/cakephp/lib/Cake/Model/BehaviorCollection.php(145): SysLogLogableBehavior->setup(Object(User), Array)
#7 /var/www/MISP/app/Lib/cakephp/lib/Cake/Model/BehaviorCollection.php(66): BehaviorCollection->load('SysLogLogable.S...', Array)
#8 /var/www/MISP/app/Lib/cakephp/lib/Cake/Model/Model.php(774): BehaviorCollection->init('User', Array)
#9 /var/www/MISP/app/Model/AppModel.php(44): Model->__construct(NULL, 'default')
#10 [internal function]: AppModel->__construct(Array)
#11 /var/www/MISP/app/Lib/cakephp/lib/Cake/Utility/ClassRegistry.php(169): ReflectionClass->newInstance(Array)
#12 /var/www/MISP/app/Lib/cakephp/lib/Cake/Controller/Controller.php(741): ClassRegistry::init('User')
#13 /var/www/MISP/app/Controller/AppController.php(83): Controller->loadModel('User')
#14 /var/www/MISP/app/Controller/EventsController.php(43): AppController->beforeFilter()
#15 /var/www/MISP/app/Lib/cakephp/lib/Cake/Event/CakeEventManager.php(243): EventsController->beforeFilter(Object(CakeEvent))
#16 /var/www/MISP/app/Lib/cakephp/lib/Cake/Controller/Controller.php(677): CakeEventManager->dispatch(Object(CakeEvent))
#17 /var/www/MISP/app/Lib/cakephp/lib/Cake/Routing/Dispatcher.php(189): Controller->startupProcess()
#18 /var/www/MISP/app/Lib/cakephp/lib/Cake/Routing/Dispatcher.php(167): Dispatcher->_invoke(Object(EventsController), Object(CakeRequest))
#19 /var/www/MISP/app/webroot/index.php(92): Dispatcher->dispatch(Object(CakeRequest), Object(CakeResponse))
#20 {main}

@Rafiot
Copy link
Member

Rafiot commented Aug 12, 2016

To me, it seems your MISP repository is broken. What does git status says? Also, which version of PHP are you using?

@Rafiot Rafiot added this to the Support milestone Aug 12, 2016
@syloktools
Copy link
Author

HEAD detached at v2.4.50
Changes not staged for commit:
(use "git add ..." to update what will be committed)
(use "git checkout -- ..." to discard changes in working directory)
(commit or discard the untracked or modified content in submodules)

    modified:   ../../../PyMISP (modified content)
    modified:   ../../Lib/cakephp (modified content)
    modified:   ../../composer.json
    modified:   ../../files/taxonomies (modified content)
    modified:   ../../files/warninglists (modified content)

Untracked files:
(use "git add ..." to include in what will be committed)

    ../../../.gnupg/
    ../../Plugin/CakeResque/
    ../../cacert.pem

no changes added to commit (use "git add" and/or "git commit -a")

@iglocska
Copy link
Member

Could you check if you can connect to mysql using these settings?

public $Default = array(
'datasource' => 'Database/Mysql',
'persistent' => false,
'host' => 'localhost',
'login' => 'rnixon',
'port' => 3306,
'password' => '******',
'database' => 'misp',
'prefix' => '',
//'encoding' => 'utf8',
);

Something like this:

mysql -u rnixon -p misp;
and use the password from there to connect.

Does this work?

@syloktools
Copy link
Author

No it fails.

@syloktools
Copy link
Author

I change the DB user to root in database.php, an logged into mysql using root.

root@ubuntu:/var/www/MISP/app/tmp/logs# mysql -u root -p misp
Enter password:
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 38
Server version: 10.0.25-MariaDB-0ubuntu0.16.04.1 Ubuntu 16.04

Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [misp]>

@iglocska
Copy link
Member

OK so the issue is that the mariadb user you've provided MISP with didn't have access / wasn't set up properly. Could you retrace your steps using the install guide and see where it went wrong? Just make sure that you provide MISP with a user that has access to the misp database and that everything in there is imported from MYSQL.sql.

Let me know how it goes!

@syloktools
Copy link
Author

syloktools commented Aug 12, 2016

I was able to connect to the database. Now getting this error.

2016-08-12 11:36:19 Error: [ParseError] syntax error, unexpected end of file, expecting function (T_FUNCTION)
Request URL: /
Stack Trace:
#0 /var/www/MISP/app/Lib/cakephp/lib/Cake/Model/ConnectionManager.php(83): ConnectionManager::_init()
#1 /var/www/MISP/app/Lib/cakephp/lib/Cake/Model/Model.php(3626): ConnectionManager::getDataSource('default')
#2 /var/www/MISP/app/Lib/cakephp/lib/Cake/Model/Model.php(1155): Model->setDataSource('default')
#3 /var/www/MISP/app/Lib/cakephp/lib/Cake/Model/Model.php(3653): Model->setSource('logs')
#4 /var/www/MISP/app/Lib/cakephp/lib/Cake/Model/Model.php(1387): Model->getDataSource()
#5 /var/www/MISP/app/Plugin/SysLogLogable/Model/Behavior/SysLogLogableBehavior.php(275): Model->schema()
#6 /var/www/MISP/app/Lib/cakephp/lib/Cake/Model/BehaviorCollection.php(145): SysLogLogableBehavior->setup(Object(User), Array)
#7 /var/www/MISP/app/Lib/cakephp/lib/Cake/Model/BehaviorCollection.php(66): BehaviorCollection->load('SysLogLogable.S...', Array)
#8 /var/www/MISP/app/Lib/cakephp/lib/Cake/Model/Model.php(774): BehaviorCollection->init('User', Array)
#9 /var/www/MISP/app/Model/AppModel.php(44): Model->__construct(NULL, 'default')
#10 [internal function]: AppModel->__construct(Array)
#11 /var/www/MISP/app/Lib/cakephp/lib/Cake/Utility/ClassRegistry.php(169): ReflectionClass->newInstance(Array)
#12 /var/www/MISP/app/Lib/cakephp/lib/Cake/Controller/Controller.php(741): ClassRegistry::init('User')
#13 /var/www/MISP/app/Controller/AppController.php(83): Controller->loadModel('User')
#14 /var/www/MISP/app/Controller/EventsController.php(43): AppController->beforeFilter()
#15 /var/www/MISP/app/Lib/cakephp/lib/Cake/Event/CakeEventManager.php(243): EventsController->beforeFilter(Object(CakeEvent))
#16 /var/www/MISP/app/Lib/cakephp/lib/Cake/Controller/Controller.php(677): CakeEventManager->dispatch(Object(CakeEvent))
#17 /var/www/MISP/app/Lib/cakephp/lib/Cake/Routing/Dispatcher.php(189): Controller->startupProcess()
#18 /var/www/MISP/app/Lib/cakephp/lib/Cake/Routing/Dispatcher.php(167): Dispatcher->_invoke(Object(EventsController), Object(CakeRequest))
#19 /var/www/MISP/app/webroot/index.php(92): Dispatcher->dispatch(Object(CakeRequest), Object(CakeResponse))
#20 {main}

@syloktools
Copy link
Author

And this:

2016-08-12 11:35:17 Notice: Notice (8): Undefined variable: debugMode in [/var/www/MISP/app/View/Layouts/default.ctp, line 92]
Trace:
include - APP/View/Layouts/default.ctp, line 92
View::_evaluate() - APP/Lib/cakephp/lib/Cake/View/View.php, line 971
View::_render() - APP/Lib/cakephp/lib/Cake/View/View.php, line 933
View::renderLayout() - APP/Lib/cakephp/lib/Cake/View/View.php, line 546
View::render() - APP/Lib/cakephp/lib/Cake/View/View.php, line 481
Controller::render() - APP/Lib/cakephp/lib/Cake/Controller/Controller.php, line 963
ExceptionRenderer::_outputMessage() - APP/Lib/cakephp/lib/Cake/Error/ExceptionRenderer.php, line 289
ExceptionRenderer::error500() - APP/Lib/cakephp/lib/Cake/Error/ExceptionRenderer.php, line 257
ExceptionRenderer::render() - APP/Lib/cakephp/lib/Cake/Error/ExceptionRenderer.php, line 187
ErrorHandler::handleException() - APP/Lib/cakephp/lib/Cake/Error/ErrorHandler.php, line 127
[main] - [internal], line ??

@rotanid rotanid added the T: support Type: support. This issue is seeking support on a problem or question label Aug 13, 2016
@rotanid
Copy link
Member

rotanid commented Aug 13, 2016

your second error message is only a "Notice", so nothing to worry about.

the first one looks like one of the PHP files is messed up...

does "git status" in the MISP directory still not show anything else than what you already posted here?

maybe the Lib/cakephp got mixed up, please delete /var/www/MISP/app/Lib/cakephp/ completely and do a submodule update afterwards:

cd /var/www/MISP
git submodule update --init --force

@syloktools
Copy link
Author

Same.

Only error I see standing out in the logs is:
2016-08-15 05:47:40 Error: [ParseError] syntax error, unexpected end of file, expecting function (T_FUNCTION)

@FloatingGhost
Copy link
Member

Well, you've likely got a syntax error in a file, maybe a missing }?

Does the error give any more info? A filename?

@iglocska
Copy link
Member

Yeah that looks really weird. It sounds like one of the files is incomplete / corrupt? Never seen this happen before.

@iglocska
Copy link
Member

If you type "git status" in your MISP directory, do you see any files that are changed?

@syloktools
Copy link
Author

root@ubuntu:/var/www/MISP# git status
HEAD detached at v2.4.50
Changes not staged for commit:
(use "git add ..." to update what will be committed)
(use "git checkout -- ..." to discard changes in working directory)

    modified:   app/composer.json

Untracked files:
(use "git add ..." to include in what will be committed)

    .gnupg/
    app/Plugin/CakeResque/
    app/cacert.pem

no changes added to commit (use "git add" and/or "git commit -a")

@FloatingGhost
Copy link
Member

ok, nothing too bad there. Can you paste the full error? as in, everything?

@syloktools
Copy link
Author

2016-08-15 08:33:33 Error: [ParseError] syntax error, unexpected end of file, expecting function (T_FUNCTION)
Request URL: /
Stack Trace:
#0 /var/www/MISP/app/Lib/cakephp/lib/Cake/Model/ConnectionManager.php(83): ConnectionManager::_init()
#1 /var/www/MISP/app/Lib/cakephp/lib/Cake/Model/Model.php(3626): ConnectionManager::getDataSource('default')
#2 /var/www/MISP/app/Lib/cakephp/lib/Cake/Model/Model.php(1155): Model->setDataSource('default')
#3 /var/www/MISP/app/Lib/cakephp/lib/Cake/Model/Model.php(3653): Model->setSource('logs')
#4 /var/www/MISP/app/Lib/cakephp/lib/Cake/Model/Model.php(1387): Model->getDataSource()
#5 /var/www/MISP/app/Plugin/SysLogLogable/Model/Behavior/SysLogLogableBehavior.php(275): Model->schema()
#6 /var/www/MISP/app/Lib/cakephp/lib/Cake/Model/BehaviorCollection.php(145): SysLogLogableBehavior->setup(Object(User), Array)
#7 /var/www/MISP/app/Lib/cakephp/lib/Cake/Model/BehaviorCollection.php(66): BehaviorCollection->load('SysLogLogable.S...', Array)
#8 /var/www/MISP/app/Lib/cakephp/lib/Cake/Model/Model.php(774): BehaviorCollection->init('User', Array)
#9 /var/www/MISP/app/Model/AppModel.php(44): Model->__construct(NULL, 'default')
#10 [internal function]: AppModel->__construct(Array)
#11 /var/www/MISP/app/Lib/cakephp/lib/Cake/Utility/ClassRegistry.php(169): ReflectionClass->newInstance(Array)
#12 /var/www/MISP/app/Lib/cakephp/lib/Cake/Controller/Controller.php(741): ClassRegistry::init('User')
#13 /var/www/MISP/app/Controller/AppController.php(83): Controller->loadModel('User')
#14 /var/www/MISP/app/Controller/EventsController.php(43): AppController->beforeFilter()
#15 /var/www/MISP/app/Lib/cakephp/lib/Cake/Event/CakeEventManager.php(243): EventsController->beforeFilter(Object(CakeEvent))
#16 /var/www/MISP/app/Lib/cakephp/lib/Cake/Controller/Controller.php(677): CakeEventManager->dispatch(Object(CakeEvent))
#17 /var/www/MISP/app/Lib/cakephp/lib/Cake/Routing/Dispatcher.php(189): Controller->startupProcess()
#18 /var/www/MISP/app/Lib/cakephp/lib/Cake/Routing/Dispatcher.php(167): Dispatcher->_invoke(Object(EventsController), Object(CakeRequest))
#19 /var/www/MISP/app/webroot/index.php(92): Dispatcher->dispatch(Object(CakeRequest), Object(CakeResponse))
#20 {main}

@syloktools
Copy link
Author

Here is the debug log:

2016-08-15 08:35:10 Notice: Notice (8): Undefined variable: debugMode in [/var/www/MISP/app/View/Layouts/default.ctp, line 92]
Trace:
include - APP/View/Layouts/default.ctp, line 92
View::_evaluate() - APP/Lib/cakephp/lib/Cake/View/View.php, line 971
View::_render() - APP/Lib/cakephp/lib/Cake/View/View.php, line 933
View::renderLayout() - APP/Lib/cakephp/lib/Cake/View/View.php, line 546
View::render() - APP/Lib/cakephp/lib/Cake/View/View.php, line 481
Controller::render() - APP/Lib/cakephp/lib/Cake/Controller/Controller.php, line 963
ExceptionRenderer::_outputMessage() - APP/Lib/cakephp/lib/Cake/Error/ExceptionRenderer.php, line 289
ExceptionRenderer::error500() - APP/Lib/cakephp/lib/Cake/Error/ExceptionRenderer.php, line 257
ExceptionRenderer::render() - APP/Lib/cakephp/lib/Cake/Error/ExceptionRenderer.php, line 187
ErrorHandler::handleException() - APP/Lib/cakephp/lib/Cake/Error/ErrorHandler.php, line 127
[main] - [internal], line ??

@iglocska
Copy link
Member

I know this is asking a fair bit, but could you sanitise and send your bootstrap.php, config.php, core.php and database.php (all located in /var/www/MISP/app/Config) to the e-mail address in my profile? Make sure you remove any passphrases / urls etc, my suspicion is that one of the files is missing a bracket, semi-colon or something similar.

Thanks in advance!

@syloktools
Copy link
Author

Figured it out with a screen by screen comparison with the database.php file. I was missing a bracket at the very end. Must have delete it by fat fingers when write quiting.

@iglocska
Copy link
Member

Excellent news, glad that you've got it resolved! I'll close the issue for now, don't hesitate to open a new one if you run into anything else!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T: support Type: support. This issue is seeking support on a problem or question
Projects
None yet
Development

No branches or pull requests

5 participants