blob: 1ceb3d7d2ac6d6f6187c5eea8b5828ea0b211ac5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
#!/usr/bin/python
import config, store, os
standalone_py = os.path.join(os.path.dirname(__file__), 'standalone.py')
c = config.Config("/data/pypi/config.ini")
s = store.Store(c)
cursor = s.get_cursor()
cursor.execute("lock table sshkeys in exclusive mode") # to prevent simultaneous updates
cursor.execute("select u.name,s.key from users u, sshkeys s where u.name=s.name")
lines = []
for name, key in cursor.fetchall():
lines.append('command="%s -r %s",no-port-forwarding,no-X11-forwarding,no-agent-forwarding,no-pty %s\n' %
(standalone_py, name, key))
f = open(os.path.expanduser('~submit/.ssh/authorized_keys'), 'wb')
f.write(''.join(lines))
f.close()
s.rollback()
|