Browse Source

Agent: add process checks

master
Pekka Helenius 3 years ago
parent
commit
7c9dd7bf97
1 changed files with 18 additions and 0 deletions
  1. +18
    -0
      tools/pamusb-agent

+ 18
- 0
tools/pamusb-agent View File

@ -20,6 +20,7 @@ import sys
import pwd
import getopt
import signal
import fcntl
import re
import subprocess
import syslog
@ -33,6 +34,23 @@ from gi.repository import UDisks
import xml.etree.ElementTree as et
def processCheck():
global filelock
filelock=open(os.path.realpath(__file__),'r')
try:
fcntl.flock(filelock,fcntl.LOCK_EX|fcntl.LOCK_NB)
except:
print('Process is already running.')
sys.exit(1)
if os.getuid() != 0:
print('Process must be run as root.')
sys.exit(1)
processCheck()
class HotPlugDevice:
def __init__(self, serial):
self.__udi = None


Loading…
Cancel
Save