Skip to content
This repository has been archived by the owner on Jul 19, 2024. It is now read-only.

Commit

Permalink
better escaping for the exec command
Browse files Browse the repository at this point in the history
  • Loading branch information
robby-d committed Jun 13, 2016
1 parent 02e3da0 commit 06dd649
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
## Versions ##
* v2.0.0 (2016-06-xx)
* v2.0.0 (2016-06-13)
* COMPATIBLE WITH: `counterparty-lib` 9.54.0 and `counterblock` 1.3.1
* Total revamp to use Docker and Docker Compose
* No upgrade path: Please rebuild your nodes using the instructions available at [here](http://counterparty.io/docs/federated_node/)
Expand Down
7 changes: 6 additions & 1 deletion fednode.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import sys
import os
import re
import argparse
import copy
import subprocess
Expand Down Expand Up @@ -204,7 +205,11 @@ def main():
elif args.command == 'ps':
run_compose_cmd(docker_config_path, "ps")
elif args.command == 'exec':
os.system("docker exec -i -t federatednode_{}_1 {}".format(args.service, ' '.join(args.cmd)))
if len(args.cmd) == 1 and re.match("['\"].*?['\"]", args.cmd[0]):
cmd = args.cmd
else:
cmd = '"{}"'.format(' '.join(args.cmd).replace('"', '\\"'))
os.system("docker exec -i -t federatednode_{}_1 bash -c {}".format(args.service, cmd))
elif args.command == 'shell':
exec_result = os.system("docker exec -i -t federatednode_{}_1 bash".format(args.service))
if exec_result != 0:
Expand Down

0 comments on commit 06dd649

Please sign in to comment.