Deprecated --allow-root and always drop privileges.

This commit is contained in:
Bastian Kleineidam 2011-02-18 15:32:21 +01:00
parent a493a3ded1
commit 97ef8ed204
8 changed files with 387 additions and 408 deletions

View file

@ -15,6 +15,7 @@ Changes:
- gui: Use Alt-key shortcuts for menu entries.
- checking: Improved thread locking and reduce calls to time.sleep().
- cmdline: Deprecated the --priority commandline option.
- cmdline: Deprecated the --allow-root commandline option.
Features:
- checking: Added support for Google Chrome bookmark files.

383
doc/de.po

File diff suppressed because it is too large Load diff

View file

@ -71,10 +71,6 @@ positive Nummer an.
\fB\-V\fP, \fB\-\-version\fP
Gebe die Version aus und beende das Programm.
.TP
\fB\-\-allow\-root\fP
Keine Entziehung der Priviligien, falls das Programm unter Unix als Benutzer
root läuft.
.TP
\fB\-\-stdin\fP
Lese Liste von URLs zum Prüfen von der Standardeingabe, getrennt durch
Leerzeichen.

View file

@ -70,9 +70,6 @@ of threads is 10. To disable threading specify a non-positive number.
\fB\-V\fP, \fB\-\-version\fP
Print version and exit.
.TP
\fB\-\-allow\-root\fP
Do not drop privileges when running as root user on Unix systems.
.TP
\fB\-\-stdin\fP
Read list of white-space separated URLs to check from stdin.
.

File diff suppressed because it is too large Load diff

View file

@ -140,3 +140,14 @@ def init_i18n ():
# initialize i18n, puts _() function into global namespace
init_i18n()
def drop_privileges ():
"""Make sure to drop root privileges on POSIX systems."""
if os.name != 'posix':
return
if os.geteuid() == 0:
log.warn(LOG_CHECK, _("Running as root user; "
"dropping privileges by changing user to nobody."))
import pwd
os.seteuid(pwd.getpwnam('nobody')[3])

View file

@ -206,17 +206,6 @@ def print_usage (msg):
sys.exit(1)
def ensure_notroot ():
"""Make sure LinkChecker is not run under root on POSIX systems."""
if os.name != 'posix':
return
if os.geteuid() == 0:
log.warn(LOG_CMDLINE, _("Running as root user; "
"dropping privileges by changing user to nobody."))
import pwd
os.seteuid(pwd.getpwnam('nobody')[3])
def viewprof ():
"""Print profiling data and exit."""
if not has_pstats:
@ -344,13 +333,15 @@ group.add_option("-t", "--threads", type="int", dest="threads",
help=_(
"""Generate no more than the given number of threads. Default number
of threads is 10. To disable threading specify a non-positive number."""))
# XXX deprecated
group.add_option("--priority", action="store_true", dest="priority",
help=_("""This option is deprecated and does nothing."""))
group.add_option("-V", "--version", action="store_true", dest="version",
help=_("""Print version and exit."""))
# XXX deprecated
group.add_option("--allow-root", action="store_true", dest="allowroot",
default=False, help=_(
"""Do not drop privileges when running as root user on Unix systems."""))
default=False,
help=_("""This option is deprecated and does nothing."""))
group.add_option("--stdin", action="store_true", dest="stdin",
help=_(
"""Read list of white-space separated URLs to check from stdin."""))
@ -587,9 +578,7 @@ try:
except linkcheck.LinkCheckerError, msg:
# config error
print_usage(str(msg))
# test if running with root privileges
if not options.allowroot:
ensure_notroot()
linkcheck.drop_privileges()
# test if running with -O
if options.debug and not __debug__:
log.warn(LOG_CMDLINE, _("Running with python -O disables debugging."))

View file

@ -21,7 +21,7 @@ Check HTML pages for broken links. This is the GUI client.
import sys
from PyQt4.QtGui import QApplication, QStyleFactory
from linkcheck.gui import LinkCheckerMain
from linkcheck import configuration
from linkcheck import configuration, drop_privileges
## Look and feel with stylesheets
# In Cleanlooks the progress bar text is outside the bar.
@ -44,6 +44,7 @@ def main (argv=None):
url = u""
window = LinkCheckerMain(url=url)
window.show()
drop_privileges()
sys.exit(app.exec_())