One Hat Cyber Team
Your IP :
216.73.216.115
Server IP :
194.44.31.54
Server :
Linux zen.imath.kiev.ua 4.18.0-553.77.1.el8_10.x86_64 #1 SMP Fri Oct 3 14:30:23 UTC 2025 x86_64
Server Software :
Apache/2.4.37 (Rocky Linux) OpenSSL/1.1.1k
PHP Version :
5.6.40
Buat File
|
Buat Folder
Eksekusi
Dir :
~
/
backup
/
oldserver
/
2
/
sbin
/
View File Name :
roled
#!/usr/bin/python -Es # -*- coding: utf-8 -*- # # Copyright (C) 2010-2014 Red Hat, Inc. # Authors: # Thomas Woerner <twoerner@redhat.com> # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. # # python fork magic derived from setroubleshoot # Copyright (C) 2006,2007,2008,2009 Red Hat, Inc. # Authors: # John Dennis <jdennis@redhat.com> # Dan Walsh <dwalsh@redhat.com> import os import sys import dbus import syslog import traceback import argparse from rolekit import config from rolekit.errors import * from rolekit.functions import roled_is_active from rolekit.logger import log, FileLog def parse_cmdline(): parser = argparse.ArgumentParser() parser.add_argument('--debug', nargs='?', const=1, default=0, type=int, choices=range(1, log.DEBUG_MAX+1), help="""Enable logging of debug messages. Additional argument in range 1..%s can be used to specify log level.""" % log.DEBUG_MAX, metavar="level") parser.add_argument('--debug-gc', help="""Turn on garbage collector leak information. The collector runs every 10 seconds and if there are leaks, it prints information about the leaks.""", action="store_true") parser.add_argument('--nofork', help="""Turn off daemon forking, run as a foreground process.""", action="store_true") parser.add_argument('--nopid', help="""Disable writing pid file and don't check for existing server process.""", action="store_true") parser.add_argument('--persistent', help="""Run persistently, no auto-termination.""", action="store_true") return parser.parse_args() def setup_logging(args): # Set up logging capabilities log_file = FileLog(config.ROLEKIT_LOGFILE, "a") log.setDateFormat("%Y-%m-%d %H:%M:%S") log.setFormat("%(date)s %(label)s%(message)s") log.setInfoLogging("*", log.syslog, [ log.FATAL, log.ERROR ]) log.addInfoLogging("*", log_file, [ log.FATAL, log.ERROR ]) log.setInfoLogging("*", log_file, [ log.WARNING ]) log.setDebugLogLevel(log.NO_INFO) log.setDebugLogLevel(log.NO_DEBUG) log.setDebugLogging("*", log_file) if args.debug: log.setInfoLogLevel(log.INFO_MAX) log.setDebugLogLevel(args.debug) log.addInfoLogging("*", log_file) log.addDebugLogging("*", log_file) if args.nofork: log.addInfoLogging("*", log.stdout) log.addDebugLogging("*", log.stdout) def startup(args): try: if not args.nofork: # do the UNIX double-fork magic, see Stevens' "Advanced # Programming in the UNIX Environment" for details (ISBN 0201563177) pid = os.fork() if pid > 0: # exit first parent sys.exit(0) # decouple from parent environment os.chdir("/") os.setsid() os.umask(os.umask(0o077) | 0o022) import resource # Resource usage information. maxfd = resource.getrlimit(resource.RLIMIT_NOFILE)[1] if (maxfd == resource.RLIM_INFINITY): maxfd = 1024 # Iterate through and close all file descriptors. for fd in range(0, maxfd): try: os.close(fd) except OSError: # ERROR, fd wasn't open to begin with (ignored) pass # Redirect the standard I/O file descriptors to /dev/null if (hasattr(os, "devnull")): REDIRECT_TO = os.devnull else: REDIRECT_TO = "/dev/null" os.open(REDIRECT_TO, os.O_RDWR) # standard input (0) os.dup2(0, 1) # standard output (1) os.dup2(0, 2) # standard error (2) if not args.nopid: # write the pid file pid_file = "/var/run/rolekit.pid" with open(pid_file, "w") as f: f.write(str(os.getpid())) # Start the server mainloop here from rolekit.server import server server.run_server(args.debug_gc, args.persistent) # Clean up on exit if not args.nopid: os.remove(pid_file) except OSError as e: log.fatal(_("Fork #1 failed: %d (%s)") % (e.errno, e.strerror)) log.error(traceback.format_exc()) if not args.nopid: os.remove(pid_file) sys.exit(1) except dbus.exceptions.DBusException as e: log.fatal(str(e)) log.error(traceback.format_exc()) if not args.nopid: os.remove(pid_file) sys.exit(1) except IOError as e: log.fatal(str(e)) log.error(traceback.format_exc()) if not args.nopid: os.remove(pid_file) sys.exit(1) def main(): # rolekit should only be run as the root user if os.getuid() != 0: print(_("You need to be root to run %s.") % sys.argv[0]) sys.exit(-1) # Process the command-line arguments args = parse_cmdline() setup_logging(args) # Don't attempt to run two copies of rolekit simultaneously if not args.nopid and roled_is_active(): log.fatal(_("Not starting roled, already running.")) sys.exit(1) startup(args) sys.exit(0) if __name__ == '__main__': main()