This commit is contained in:
Jakobus Schürz 2019-08-01 22:41:53 +02:00
parent b88948bb2c
commit 0d631132e0

View file

@ -16,46 +16,15 @@ from gitosis import gitdaemon
from gitosis import app from gitosis import app
from gitosis import util from gitosis import util
def serve_principal(sshUser, principal):
print "Do nothing"
def post_update(cfg, git_dir): def serve_principal(sshUser, principals):
export = os.path.join(git_dir, 'gitosis-export') TEMPLATE=('command="gitosis-serve %(user)s",no-port-forwarding,'
try: +'no-X11-forwarding,no-agent-forwarding,no-pty %(principals)s')
shutil.rmtree(export)
except OSError, e: for (sshUser, principals) in keys:
if e.errno == errno.ENOENT: log.debug(TEMPLATE % dict(user=user))
pass yield TEMPLATE % dict(user=user, principals=principals)
else:
raise
repository.export(git_dir=git_dir, path=export)
os.rename(
os.path.join(export, 'gitosis.conf'),
os.path.join(export, '..', 'gitosis.conf'),
)
# re-read config to get up-to-date settings
cfg.read(os.path.join(export, '..', 'gitosis.conf'))
gitweb.set_descriptions(
config=cfg,
)
generated = util.getGeneratedFilesDir(config=cfg)
gitweb.generate_project_list(
config=cfg,
path=os.path.join(generated, 'projects.list'),
)
gitdaemon.set_export_ok(
config=cfg,
)
authorized_keys = util.getSSHAuthorizedKeysPath(config=cfg)
ssh.writeAuthorizedKeys(
path=authorized_keys,
keydir=os.path.join(export, 'keydir'),
)
principals = util.getSSHPrincipalsPath(config=cfg)
ssh_principals.writePrincipals(
path=principals,
principals=os.path.join(export, 'keydir/principals'),
)
class Main(app.App): class Main(app.App):
def create_parser(self): def create_parser(self):
@ -69,14 +38,10 @@ class Main(app.App):
try: try:
sshUser = args.pop(0) sshUser = args.pop(0)
principals = ' '.join(args) principals = ' '.join(args)
parser.error(principals)
except ValueError: except ValueError:
parser.error('Missing argument sshUsers and/or principals.') parser.error('Missing argument sshUsers and/or principals.')
log = logging.getLogger('gitosis.principals') log = logging.getLogger('gitosis.principals')
os.umask(0022)
git_dir = os.environ.get('GIT_DIR')
if sshUser != "": if sshUser != "":
log.info('Running serve_principal for user %s', sshUser) log.info('Running serve_principal for user %s', sshUser)