diff --git a/README.md b/README.md index c8d8e5b..37bc1f9 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ sshch is released under DWTWL 2.55 license sshch compatible with pyhon2 and python3, no additional libraries are required ### Screenshot -![sshch](https://raw.githubusercontent.com/zlaxy/sshch/master/sshch_screenshot.png) +![sshch](https://gitlab.com/zlax/sshch/raw/master/sshch_screenshot.png) ### Installing **You can install a release version from pip:** ```bash diff --git a/setup.py b/setup.py index 5699f64..90bcaef 100644 --- a/setup.py +++ b/setup.py @@ -8,15 +8,15 @@ def main(): setup(name='sshch', author='zlaxy', author_email='zlaxyi@gmail.com', - url='https://github.com/zlaxy/sshch/', + url='https://gitlab.com/zlax/sshch', description='Ssh connection and aliases manager', long_description='SSH connection and aliases manager with curses and command line interface', long_description_content_type='text/x-rst', license='DWTWL 2.55', - version='1.0', + version='1.03', py_modules=['sshch'], scripts=['sshch/sshch'], - keywords='sshch ssh aliases manager', + keywords='sshch ssh aliases curses manager', python_requires='>=2.6, !=3.0.*, !=3.1.*, !=3.2.*, <4', # http://pypi.python.org/pypi?%3Aaction=list_classifiers diff --git a/sshch/sshch b/sshch/sshch index 08ac83a..c87b9f7 100755 --- a/sshch/sshch +++ b/sshch/sshch @@ -19,8 +19,8 @@ import time import curses from curses import textpad, panel -# https://github.com/zlaxy/sshch -version = "1.0" +# https://gitlab.com/zlax/sshch +version = "1.03" # path to conf file, default: ~/.config/sshch.conf conf_file = path.expanduser("~") + '/.config/sshch.conf' # expand groups by default @@ -64,12 +64,29 @@ def RemoveAliases(aliases): conf.write(open(conf_file, "w")) +def ConvertPassword(password): + password_string = "'" + for char in password: + if char == "'": + password_string += "'"+'"'+"'"+'"'+"'" + elif char == '"': + password_string += "''"+'"'+"''" + elif char == ';': + password_string += "'"+"\;"+"'" + elif char == "\\": + password_string += "'"+'"'+"\\"+"\\"+'"'+"'" + else: + password_string += char + password_string += "'" + return password_string + + def ConnectAlias(alias, command=False): exec_string = "" if conf.has_option(alias, "password"): password = base64.b32decode(base64.b16decode( base64.b64decode(conf.get(alias, "password")))) - exec_string = 'sshpass -p "' + password.decode('utf-8') + '" ' + exec_string = "sshpass -p " + ConvertPassword(password.decode('utf-8')) + " " if conf.has_option(alias, "exec_string"): exec_string = exec_string + conf.get(alias, "exec_string") if command: @@ -240,6 +257,7 @@ def GetTreeList(strings=True, expandlist=True): else: return resultalias; + def CMDFullList(option, opt, value, parser): for p in GetTreeList(): print (p) @@ -493,7 +511,8 @@ def CursesMain(): (height // 2) - 1, 4, "Enter new alias:", "", normal_text, highlight_text) add_alias = new_alias_textpad.edit(CursesTextpadConfirm) - add_alias = add_alias.split()[0].strip() + if not add_alias == "": + add_alias = add_alias.split()[0].strip() if not add_alias == "": add_result = AddNewAlias(add_alias) if add_result == True: @@ -526,7 +545,8 @@ def CursesMain(): (height // 2) - 1, 4, "Enter group name (without spaces):", "", normal_text, highlight_text) add_group = new_group_textpad.edit(CursesTextpadConfirm) - add_group = add_group.split()[0].strip() + if not add_group == "": + add_group = add_group.split()[0].strip() if not add_group == "": add_result = AddNewAlias(add_group) if add_result == True: