Skip to content

Commit

Permalink
Updates config locations and making proxy default for Client
Browse files Browse the repository at this point in the history
Now we have all the configurations under
/usr/share/securedrop-client/ including the alembic.ini file.

The database file is now located at ~/securedrop_client/

Based on the PR review comments.
  • Loading branch information
kushaldas committed Oct 31, 2018
1 parent 9ee60c3 commit e2d3aca
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 23 deletions.
2 changes: 1 addition & 1 deletion files/alembic.ini
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ script_location = /usr/share/securedrop-client/alembic
# are written from script.py.mako
# output_encoding = utf-8

sqlalchemy.url = sqlite:////home/user/.securedrop_client/data/svs.sqlite
sqlalchemy.url = sqlite:////home/user/.securedrop_client/svs.sqlite


# Logging configuration
Expand Down
10 changes: 4 additions & 6 deletions files/securedrop-client
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
#!/bin/sh

mkdir -p ~/.securedrop_client/logs
mkdir -p ~/.securedrop_client/data
chmod 0700 ~/.securedrop_client/logs
chmod 0700 ~/.securedrop_client/data
mkdir -p ~/.securedrop_client
chmod 0700 ~/.securedrop_client
cd /opt/venvs/securedrop-client

# Now let us try to run alembic first
./bin/alembic -c /etc/securedrop-client/alembic.ini upgrade head
./bin/alembic -c /usr/share/securedrop-client/alembic.ini upgrade head

# Now execute the actual client
./bin/sd-client
./bin/sd-client
12 changes: 3 additions & 9 deletions run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,14 @@ while [ -n "$1" ]; do
done

SDC_HOME=${SDC_HOME:-$(mktemp -d)}
DB_HOME=$SDC_HOME/data
LOGS_HOME=$SDC_HOME/logs

export SDC_HOME DB_HOME LOGS_HOME
export SDC_HOME

mkdir -p $DB_HOME
mkdir -p $LOGS_HOME
chmod 0700 $SDC_HOME
chmod 0700 $DB_HOME
chmod 0700 $LOGS_HOME

echo "Running app with home directory: $SDC_HOME"

# create the database for local testing
./createdb.py $DB_HOME
./createdb.py $SDC_HOME

exec python -m securedrop_client --sdc-home "$SDC_HOME" $@
exec python -m securedrop_client --sdc-home "$SDC_HOME" --no-proxy $@
12 changes: 6 additions & 6 deletions securedrop_client/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def arg_parser() -> ArgumentParser:
help=('SecureDrop Client home directory for storing files and state. '
'(Default {})'.format(DEFAULT_SDC_HOME)))
parser.add_argument(
'--proxy', action='store_true',
'--no-proxy', action='store_true',
help='Use proxy AppVM name to connect to server.')
return parser

Expand Down Expand Up @@ -138,12 +138,12 @@ def start_app(args, qt_args) -> None:
app.setWindowIcon(load_icon(gui.icon))
app.setStyleSheet(load_css('sdclient.css'))

engine = make_engine(os.path.join(args.sdc_home, "data"))
engine = make_engine(args.sdc_home)
Session = sessionmaker(bind=engine)
session = Session()

client = Client("http://localhost:8081/", gui, session,
args.sdc_home, args.proxy)
args.sdc_home, not args.no_proxy)
client.setup()

configure_signal_handlers(app)
Expand All @@ -155,15 +155,15 @@ def start_app(args, qt_args) -> None:


def run() -> None:
config_file = "/etc/securedrop-client/client.ini"
config_file = "/usr/share/securedrop-client/client.ini"
args, qt_args = arg_parser().parse_known_args()
if args.sdc_home == expand_to_absolute(DEFAULT_SDC_HOME) and \
os.path.exists(config_file): # pragma: no cover
config = configparser.ConfigParser()
config.read(config_file)
args.sdc_home = config["client"]["homedir"]
sdc_home = config["client"]["use_securedrop_proxy"]
args.proxy = expand_to_absolute(sdc_home)
use_proxy = config["client"].getboolean("use_securedrop_proxy")
args.no_proxy = not use_proxy
# reinsert the program's name
qt_args.insert(0, 'securedrop-client')
start_app(args, qt_args)
2 changes: 1 addition & 1 deletion securedrop_client/logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class Client(QObject):
finish_api_call = pyqtSignal() # Acknowledges reciept of an API call.

def __init__(self, hostname, gui, session,
home: str, proxy: bool = False) -> None:
home: str, proxy: bool = True) -> None:
"""
The hostname, gui and session objects are used to coordinate with the
various other layers of the application: the location of the SecureDrop
Expand Down

0 comments on commit e2d3aca

Please sign in to comment.