Skip to main content
Join the official 2019 Python Developers SurveyStart the survey!

List restartable programs or services using deleted libraries after upgrades

Project description

restartable

List running processes using files deleted by recent upgrades

Build Status

When upgrading packages, the package manager won't restart services or programs that depend on some updated library, for obvious reasons. This has security implications in the case of outdated libraries still in use.

OpenSUSE has a cool zypper ps command to check for programs and services using deleted files. It's also available in other distros as zypp-CheckAccessDeleted from the libzypp package. Those commands parse lsof output and check /proc/<pid>/cgroup to extract the service names.

Here's a Python version that checks /proc/<pid>/maps, extracting information from other files in /proc/<pid>.

No lsof dependency needed.

Excerpt from zypper manual:

After each upgrade or removal of packages, there may be running processes on the system which continue to use meanwhile deleted files. zypper ps lists all processes using deleted files, together with the corresponding files, and a service name hint, in case it’s a known service. This gives a hint which services may need to be restarted after an update. Usually programs which continue to use deleted shared libraries. The list contains the following information:

PID ID of the process
PPID ID of the parent process
UID ID of the user running the process
Login Login name of the user running the process
Command Command used to execute the process
Service Service name, if command is associated with a system service
Files The list of the deleted files

Installation

sudo pip3 install restartable

Usage

sudo restartable [OPTIONS]

List running processes using files deleted by recent upgrades

Options:
    -P, --proc PROC_DIRECTORY
	Specify /proc directory
    -s, --short
	Create a short table not showing the deleted files. Given twice,
	show only processes which are associated with a system service.
	Given three times, list the associated system service names only.
    -v, --verbose
        Show the complete command line

NOTES

  • Verified to work on Python 3.5+
  • You must run it as root to see the information you want.
  • The output is different from zypper ps to be easily parseable

BUGS / LIMITATIONS

  • The service names can only be extracted if started by Systemd

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for restartable, version 0.8.3
Filename, size File type Python version Upload date Hashes
Filename, size restartable-0.8.3-py3-none-any.whl (13.4 kB) File type Wheel Python version py3 Upload date Hashes View hashes
Filename, size restartable-0.8.3.tar.gz (12.3 kB) File type Source Python version None Upload date Hashes View hashes

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN SignalFx SignalFx Supporter DigiCert DigiCert EV certificate StatusPage StatusPage Status page