Mercurial > p > roundup > code
comparison roundup/scripts/roundup_server.py @ 2543:6eda7612676d
allow ids in addition to names for -g and -u arguments;
fix vim modeline:
this form must be terminated with colon,
use softtabstop instead of tabstop
| author | Alexander Smishlajev <a1s@users.sourceforge.net> |
|---|---|
| date | Sun, 04 Jul 2004 12:52:06 +0000 |
| parents | 8822780fa519 |
| children | dd2b9f5a104c |
comparison
equal
deleted
inserted
replaced
| 2542:3dcdc5fef2e4 | 2543:6eda7612676d |
|---|---|
| 15 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. | 15 # SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. |
| 16 # | 16 # |
| 17 | 17 |
| 18 """Command-line script that runs a server over roundup.cgi.client. | 18 """Command-line script that runs a server over roundup.cgi.client. |
| 19 | 19 |
| 20 $Id: roundup_server.py,v 1.53 2004-07-02 08:52:00 a1s Exp $ | 20 $Id: roundup_server.py,v 1.54 2004-07-04 12:52:06 a1s Exp $ |
| 21 """ | 21 """ |
| 22 __docformat__ = 'restructuredtext' | 22 __docformat__ = 'restructuredtext' |
| 23 | 23 |
| 24 # python version check | 24 # python version check |
| 25 from roundup import version_check | 25 from roundup import version_check |
| 490 try: | 490 try: |
| 491 import grp | 491 import grp |
| 492 except ImportError: | 492 except ImportError: |
| 493 raise ValueError, _("Can't change groups - no grp module") | 493 raise ValueError, _("Can't change groups - no grp module") |
| 494 try: | 494 try: |
| 495 gid = grp.getgrnam(group)[2] | 495 try: |
| 496 gid = int(group) | |
| 497 except ValueError: | |
| 498 gid = grp.getgrnam(group)[2] | |
| 499 else: | |
| 500 grp.getgrgid(gid) | |
| 496 except KeyError: | 501 except KeyError: |
| 497 raise ValueError,_("Group %(group)s doesn't exist")%locals() | 502 raise ValueError,_("Group %(group)s doesn't exist")%locals() |
| 498 os.setgid(gid) | 503 os.setgid(gid) |
| 499 elif os.getuid(): | 504 elif os.getuid(): |
| 500 print _('WARNING: ignoring "-g" argument, not root') | 505 print _('WARNING: ignoring "-g" argument, not root') |
| 505 try: | 510 try: |
| 506 import pwd | 511 import pwd |
| 507 except ImportError: | 512 except ImportError: |
| 508 raise ValueError, _("Can't change users - no pwd module") | 513 raise ValueError, _("Can't change users - no pwd module") |
| 509 try: | 514 try: |
| 510 uid = pwd.getpwnam(user)[2] | 515 try: |
| 516 uid = int(user) | |
| 517 except ValueError: | |
| 518 uid = pwd.getpwnam(user)[2] | |
| 519 else: | |
| 520 pwd.getpwuid(uid) | |
| 511 except KeyError: | 521 except KeyError: |
| 512 raise ValueError, _("User %(user)s doesn't exist")%locals() | 522 raise ValueError, _("User %(user)s doesn't exist")%locals() |
| 513 os.setuid(uid) | 523 os.setuid(uid) |
| 514 elif os.getuid() and user is not None: | 524 elif os.getuid() and user is not None: |
| 515 print _('WARNING: ignoring "-u" argument, not root') | 525 print _('WARNING: ignoring "-u" argument, not root') |
| 567 print 'Keyboard Interrupt: exiting' | 577 print 'Keyboard Interrupt: exiting' |
| 568 | 578 |
| 569 if __name__ == '__main__': | 579 if __name__ == '__main__': |
| 570 run() | 580 run() |
| 571 | 581 |
| 572 # vim: set filetype=python ts=4 sw=4 et si | 582 # vim: set filetype=python sts=4 sw=4 et si : |
