Skip to content

Commit

Permalink
Add docker passwords
Browse files Browse the repository at this point in the history
  • Loading branch information
alxchk committed May 23, 2017
1 parent 6e5063b commit c5e4fc6
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
2 changes: 2 additions & 0 deletions Linux/lazagne/config/manageModules.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from lazagne.softwares.sysadmin.env_variable import Env_variable
from lazagne.softwares.sysadmin.shadow import Shadow
from lazagne.softwares.sysadmin.aws import Aws
from lazagne.softwares.sysadmin.docker import Docker
# chats
from lazagne.softwares.chats.pidgin import Pidgin
from lazagne.softwares.chats.jitsi import Jitsi
Expand Down Expand Up @@ -54,6 +55,7 @@ def get_modules():
Pidgin(),
Shadow(),
Aws(),
Docker(),
SQLDeveloper(),
Squirrel(),
Wifi(),
Expand Down
45 changes: 45 additions & 0 deletions Linux/lazagne/softwares/sysadmin/docker.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
from lazagne.config.constant import *
from lazagne.config.write_output import print_debug
from lazagne.config.moduleInfo import ModuleInfo
from lazagne.config import homes

import json

import os

class Docker(ModuleInfo):
def __init__(self):
options = {'command': '-D', 'action': 'store_true', 'dest': 'docker', 'help': 'docker'}
suboptions = []
ModuleInfo.__init__(self, 'docker', 'sysadmin', options, suboptions)

def get_paths(self):
return homes.get(file=os.path.join('.docker', 'config.json'))

def get_creds(self, path):
try:
with open(path) as config:
config = json.load(config)
if not 'auths' in config:
return

for hub, auth in config['auths'].iteritems():
user, password = auth['auth'].decode('base64').split(':', 1)
yield hub, user, password


except:
return


def run(self, software_name=None):
all_passwords = []
for path in self.get_paths():
for hub, user, password in self.get_creds(path):
all_passwords.append({
'User': user,
'Password': password,
'Hub': hub,
})

return all_passwords

0 comments on commit c5e4fc6

Please sign in to comment.