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

Don't start server if session_config.json is syntactically incorrect #1151

Merged
merged 1 commit into from
Nov 24, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions libcodechecker/server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import stat
import socket
import ssl
import sys
import urllib

try:
Expand Down Expand Up @@ -748,6 +749,12 @@ def start_server(config_directory, package_data, port, db_conn_string,
.format(root_file))
root_sha = __make_root_file(root_file)

try:
manager = session_manager.SessionManager(root_sha, force_auth)
except IOError, ValueError:
LOG.error("The server's authentication config file is invalid!")
sys.exit(1)

http_server = CCSimpleHttpServer(server_addr,
RequestHandler,
config_directory,
Expand All @@ -757,9 +764,7 @@ def start_server(config_directory, package_data, port, db_conn_string,
suppress_handler,
context,
check_env,
session_manager.SessionManager(
root_sha, force_auth)
)
manager)

try:
instance_manager.register(os.getpid(),
Expand Down
8 changes: 7 additions & 1 deletion libcodechecker/session_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,12 @@ def load_session_cfg(session_cfg_file):
except IOError:
LOG.debug('Failed to open user authentication file: ' +
session_cfg_file)
raise
except ValueError as verr:
LOG.warning(verr)
LOG.warning('Not valid user authentication file: ' +
session_cfg_file)
raise

return scfg_dict

Expand Down Expand Up @@ -442,7 +444,11 @@ def __init__(self):
".codechecker.passwords.json")
LOG.debug(session_cfg_file)

scfg_dict = load_session_cfg(session_cfg_file)
try:
scfg_dict = load_session_cfg(session_cfg_file)
except (IOError, ValueError):
# On the client's side, continue execution with defaults.
scfg_dict = {}

if not scfg_dict.get("credentials"):
scfg_dict["credentials"] = {}
Expand Down