From e15bad3da1e6f3e99648f4700c7f535d8b264d86 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakobus=20Sch=C3=BCrz?= Date: Sun, 4 Aug 2019 02:52:44 +0200 Subject: [PATCH 1/8] only build principal with username out of user@host yield principals instead of print --- gitosis/principals.py | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/gitosis/principals.py b/gitosis/principals.py index d5a46c7..96aba88 100644 --- a/gitosis/principals.py +++ b/gitosis/principals.py @@ -22,7 +22,7 @@ def serve_principal(cfg, sshUser, principals): +'no-X11-forwarding,no-agent-forwarding,no-pty %(principals)s') for p in util.getAllowedSSHPrincipals(config=cfg).split() : - print TEMPLATE % dict(user=sshUser, principals=p) + yield print TEMPLATE % dict(user=sshUser.partition('@')[0], principals=p) class Main(app.App): def create_parser(self): @@ -44,12 +44,5 @@ class Main(app.App): if sshUser != "": log.info('Running serve_principal for user %s', sshUser) #log.debug('serve_principal: %s', serve_principal(cfg, sshUser, principals)) - serve_principal(cfg, sshUser, principals) + print serve_principal(cfg, sshUser, principals) log.info('Done.') -# -# if hook == 'post-update': -# log.info('Running hook %s', hook) -# post_update(cfg, git_dir) -# log.info('Done.') -# else: -# log.warning('Ignoring unknown hook: %r', hook) From 2c7b1c6e2241308a55a5e4ecd8daf5848b240b98 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakobus=20Sch=C3=BCrz?= Date: Sun, 4 Aug 2019 03:08:22 +0200 Subject: [PATCH 2/8] print removed --- gitosis/principals.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gitosis/principals.py b/gitosis/principals.py index 96aba88..248af7a 100644 --- a/gitosis/principals.py +++ b/gitosis/principals.py @@ -22,7 +22,7 @@ def serve_principal(cfg, sshUser, principals): +'no-X11-forwarding,no-agent-forwarding,no-pty %(principals)s') for p in util.getAllowedSSHPrincipals(config=cfg).split() : - yield print TEMPLATE % dict(user=sshUser.partition('@')[0], principals=p) + yield TEMPLATE % dict(user=sshUser.partition('@')[0], principals=p) class Main(app.App): def create_parser(self): From 8fbf51be7a14b66dc6081d1a315cf339fe021c71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakobus=20Sch=C3=BCrz?= Date: Sun, 4 Aug 2019 03:09:47 +0200 Subject: [PATCH 3/8] yield changed to print --- gitosis/principals.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gitosis/principals.py b/gitosis/principals.py index 248af7a..e4c9665 100644 --- a/gitosis/principals.py +++ b/gitosis/principals.py @@ -22,7 +22,7 @@ def serve_principal(cfg, sshUser, principals): +'no-X11-forwarding,no-agent-forwarding,no-pty %(principals)s') for p in util.getAllowedSSHPrincipals(config=cfg).split() : - yield TEMPLATE % dict(user=sshUser.partition('@')[0], principals=p) + print TEMPLATE % dict(user=sshUser.partition('@')[0], principals=p) class Main(app.App): def create_parser(self): @@ -44,5 +44,5 @@ class Main(app.App): if sshUser != "": log.info('Running serve_principal for user %s', sshUser) #log.debug('serve_principal: %s', serve_principal(cfg, sshUser, principals)) - print serve_principal(cfg, sshUser, principals) + serve_principal(cfg, sshUser, principals) log.info('Done.') From ea02faf354144a75c75970f83d233a5b05805f12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakobus=20Sch=C3=BCrz?= Date: Fri, 6 Sep 2019 00:38:07 +0200 Subject: [PATCH 4/8] fixed logging when GIT_DIR is none --- gitosis/run_hook.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/gitosis/run_hook.py b/gitosis/run_hook.py index 02fc055..1c66252 100644 --- a/gitosis/run_hook.py +++ b/gitosis/run_hook.py @@ -66,10 +66,12 @@ class Main(app.App): os.umask(0022) git_dir = os.environ.get('GIT_DIR') - log.debug("GIT_DIR", git_dir) if git_dir is None: log.error('Must have GIT_DIR set in enviroment') sys.exit(1) + else: + log.debug("GIT_DIR", git_dir) + if hook == 'post-update': log.info('Running hook %s', hook) From 2cb9ed308a49182e5bbc3466b771aa298da15735 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakobus=20Sch=C3=BCrz?= Date: Fri, 6 Sep 2019 00:44:26 +0200 Subject: [PATCH 5/8] remove debug-log --- gitosis/run_hook.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/gitosis/run_hook.py b/gitosis/run_hook.py index 1c66252..e535e6a 100644 --- a/gitosis/run_hook.py +++ b/gitosis/run_hook.py @@ -69,9 +69,6 @@ class Main(app.App): if git_dir is None: log.error('Must have GIT_DIR set in enviroment') sys.exit(1) - else: - log.debug("GIT_DIR", git_dir) - if hook == 'post-update': log.info('Running hook %s', hook) From 0fe0eef34d26e62a0d79b31c80d8e57705d751bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakobus=20Sch=C3=BCrz?= Date: Fri, 6 Sep 2019 00:52:33 +0200 Subject: [PATCH 6/8] debug added --- gitosis/ssh.py | 1 + 1 file changed, 1 insertion(+) diff --git a/gitosis/ssh.py b/gitosis/ssh.py index a315a5c..79c0456 100644 --- a/gitosis/ssh.py +++ b/gitosis/ssh.py @@ -62,6 +62,7 @@ def filterAuthorizedKeys(fp): def writeAuthorizedKeys(path, keydir): tmp = '%s.%d.tmp' % (path, os.getpid()) + log.debug("writeAuthorizedKeys") try: in_ = file(path) except IOError, e: From ebaf7a7f719dc82e1c96b91ab3ff734b8b2598e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakobus=20Sch=C3=BCrz?= Date: Fri, 6 Sep 2019 00:55:38 +0200 Subject: [PATCH 7/8] improve debug --- gitosis/ssh.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gitosis/ssh.py b/gitosis/ssh.py index 79c0456..252eb60 100644 --- a/gitosis/ssh.py +++ b/gitosis/ssh.py @@ -62,7 +62,7 @@ def filterAuthorizedKeys(fp): def writeAuthorizedKeys(path, keydir): tmp = '%s.%d.tmp' % (path, os.getpid()) - log.debug("writeAuthorizedKeys") + log.debug("writeAuthorizedKeys",tmp) try: in_ = file(path) except IOError, e: From 89921e7838b06216e0cb33f795e87b0bb1aeed2d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jakobus=20Sch=C3=BCrz?= Date: Fri, 6 Sep 2019 00:56:39 +0200 Subject: [PATCH 8/8] fix improved logging --- gitosis/ssh.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gitosis/ssh.py b/gitosis/ssh.py index 252eb60..6b95ceb 100644 --- a/gitosis/ssh.py +++ b/gitosis/ssh.py @@ -62,7 +62,7 @@ def filterAuthorizedKeys(fp): def writeAuthorizedKeys(path, keydir): tmp = '%s.%d.tmp' % (path, os.getpid()) - log.debug("writeAuthorizedKeys",tmp) + log.debug("writeAuthorizedKeys " + str(tmp) ) try: in_ = file(path) except IOError, e: