chiark / gitweb /
backend.py: Use configured delimiter for joining fields.
[chopwood] / cmd-remote.py
CommitLineData
a2916c06
MW
1### -*-python-*-
2###
3### Remote service commands
4###
5### (c) 2013 Mark Wooding
6###
7
8###----- Licensing notice ---------------------------------------------------
9###
10### This file is part of Chopwood: a password-changing service.
11###
12### Chopwood is free software; you can redistribute it and/or modify
13### it under the terms of the GNU Affero General Public License as
14### published by the Free Software Foundation; either version 3 of the
15### License, or (at your option) any later version.
16###
17### Chopwood is distributed in the hope that it will be useful,
18### but WITHOUT ANY WARRANTY; without even the implied warranty of
19### MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20### GNU Affero General Public License for more details.
21###
22### You should have received a copy of the GNU Affero General Public
23### License along with Chopwood; if not, see
24### <http://www.gnu.org/licenses/>.
25
26import cmdutil as CU
27import subcommand as SC
28import util as U
29
30@SC.subcommand(
74b87214 31 'set', ['remote'], 'Set password for remote service',
a2916c06
MW
32 params = [SC.Arg('service'), SC.Arg('user')])
33def cmd_set_svc(service, user):
71d74dcf 34 new = U.readline('new password')
a2916c06
MW
35 svc = CU.check_service(service)
36 svc.setpasswd(user, new)
37
38@SC.subcommand(
74b87214 39 'clear', ['remote'], 'Clear password for remote service',
a2916c06
MW
40 params = [SC.Arg('service'), SC.Arg('user')])
41def cmd_set_svc(service, user):
42 svc = CU.check_service(service)
43 svc.clearpasswd(user)
44
82d4f64b
MW
45@SC.subcommand(
46 'mkpwent', ['remote'], 'Create a new user record',
47 params = [SC.Arg('user'), SC.Arg('service')],
48 rparam = SC.Arg('fields'))
49def cmd_mkpwent_svc(user, service, fields):
50 passwd = U.readline('new password')
51 svc = CU.check_service(service)
52 svc.mkpwent(user, passwd, fields)
53
54@SC.subcommand(
55 'rmpwent', ['remote'], 'Remove an existing user record',
56 params = [SC.Arg('user'), SC.Arg('service')])
57def cmd_rmpwent_svc(user, service):
58 svc = CU.check_service(service)
59 svc.rmpwent(user)
60
a2916c06 61###----- That's all, folks --------------------------------------------------