Skip to content

Commit 899c1fa

Browse files
committed
Add support for -u to roundup-admin
Reimplement -u <login>[:<password>]. This opens the database as the login and applies expected permissions. It also creates history entries for the user. Note that the password is unused. The CLI has full access to the files so a password check is not useful. Left an edge case is when the login has a : in it. In this case it may not work as expected. So don't do that.
1 parent 36e9f7c commit 899c1fa

File tree

2 files changed

+19
-7
lines changed

2 files changed

+19
-7
lines changed

CHANGES.txt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,14 @@ Features:
2525
- issue2550919 - Anti-bot signup using 4 second delay. New config.ini
2626
param [web] registration_delay must be set to 0 if template
2727
user.register.html is not modified. See upgrading.txt for details.
28-
28+
- Reimplement -u <login>[:<password>]. This opens the database as the
29+
user and applies expected permissions. It also creates history
30+
entries for the user. Note that the password is unused, no mention
31+
of it is in the spec that I can find, so not sure what it was
32+
supposed to be used for as the CLI has full access to the files so a
33+
password check is not useful. An edge case is when the login has a :
34+
in it. In this case it may not work as expected. So don't do that.
35+
2936
Fixed:
3037

3138
- issue2550996 - Give better error message when running with -c

roundup/admin.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ def usage(self, message=''):
121121
122122
Options:
123123
-i instance home -- specify the issue tracker "home directory" to administer
124-
-u -- the user[:password] to use for commands
124+
-u -- the user[:password] to use for commands (default admin)
125125
-d -- print full designators not just class id numbers
126126
-c -- when outputting lists of data, comma-separate them.
127127
Same as '-S ","'.
@@ -1560,7 +1560,7 @@ def run_command(self, args):
15601560

15611561
# only open the database once!
15621562
if not self.db:
1563-
self.db = tracker.open('admin')
1563+
self.db = tracker.open(self.name)
15641564

15651565
self.db.tx_Source = 'cli'
15661566

@@ -1620,13 +1620,13 @@ def main(self):
16201620

16211621
# handle command-line args
16221622
self.tracker_home = os.environ.get('TRACKER_HOME', '')
1623-
# TODO: reinstate the user/password stuff (-u arg too)
1624-
name = password = ''
1623+
self.name = 'admin'
1624+
self.password = '' # unused
16251625
if 'ROUNDUP_LOGIN' in os.environ:
16261626
l = os.environ['ROUNDUP_LOGIN'].split(':')
1627-
name = l[0]
1627+
self.name = l[0]
16281628
if len(l) > 1:
1629-
password = l[1]
1629+
self.password = l[1]
16301630
self.separator = None
16311631
self.print_designator = 0
16321632
self.verbose = 0
@@ -1658,6 +1658,11 @@ def main(self):
16581658
self.separator = ' '
16591659
elif opt == '-d':
16601660
self.print_designator = 1
1661+
elif opt == '-u':
1662+
l = arg.split(':')
1663+
self.name = l[0]
1664+
if len(l) > 1:
1665+
self.password = l[1]
16611666

16621667
# if no command - go interactive
16631668
# wrap in a try/finally so we always close off the db

0 commit comments

Comments
 (0)