|
@ -102,21 +102,21 @@ class Log: |
|
|
syslog.syslog(priority, message) |
|
|
syslog.syslog(priority, message) |
|
|
|
|
|
|
|
|
def usage(): |
|
|
def usage(): |
|
|
print 'Usage: %s [--config file] [--daemon] [--path pamusb-check\'s path]' % \ |
|
|
|
|
|
|
|
|
print 'Usage: %s [--help] [--config=path] [--daemon] [--check=path]' % \ |
|
|
os.path.basename(__file__) |
|
|
os.path.basename(__file__) |
|
|
sys.exit(1) |
|
|
sys.exit(1) |
|
|
|
|
|
|
|
|
import getopt |
|
|
import getopt |
|
|
|
|
|
|
|
|
try: |
|
|
try: |
|
|
opts, args = getopt.getopt(sys.argv[1:], "hc:dp:", |
|
|
|
|
|
["help", "config=", "daemon", "path="]) |
|
|
|
|
|
|
|
|
opts, args = getopt.getopt(sys.argv[1:], "hc:dc:", |
|
|
|
|
|
["help", "config=", "daemon", "check="]) |
|
|
except getopt.GetoptError: |
|
|
except getopt.GetoptError: |
|
|
usage() |
|
|
usage() |
|
|
|
|
|
|
|
|
options = {'configFile' : '/etc/pamusb.conf', |
|
|
options = {'configFile' : '/etc/pamusb.conf', |
|
|
'daemon' : False, |
|
|
'daemon' : False, |
|
|
'path' : '/usr/bin/pamusb-check'} |
|
|
|
|
|
|
|
|
'check' : '/usr/bin/pamusb-check'} |
|
|
|
|
|
|
|
|
if len(args) != 0: |
|
|
if len(args) != 0: |
|
|
usage() |
|
|
usage() |
|
@ -128,13 +128,13 @@ for o, a in opts: |
|
|
options['configFile'] = a |
|
|
options['configFile'] = a |
|
|
if o in ('-d', '--daemon'): |
|
|
if o in ('-d', '--daemon'): |
|
|
options['daemon'] = True |
|
|
options['daemon'] = True |
|
|
if o in ('-p', '--path'): |
|
|
|
|
|
options['path'] = a |
|
|
|
|
|
|
|
|
if o in ('-c', '--check'): |
|
|
|
|
|
options['check'] = a |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if not os.path.exists(options['path']): |
|
|
|
|
|
print '%s not found.' % options['path'] |
|
|
|
|
|
print "You might specify manually pamusb-check's location using --path." |
|
|
|
|
|
|
|
|
if not os.path.exists(options['check']): |
|
|
|
|
|
print '%s not found.' % options['check'] |
|
|
|
|
|
print "You might specify manually pamusb-check's location using --check." |
|
|
usage() |
|
|
usage() |
|
|
|
|
|
|
|
|
username = pwd.getpwuid(os.getuid())[0] |
|
|
username = pwd.getpwuid(os.getuid())[0] |
|
@ -182,7 +182,7 @@ def authChangeCallback(event): |
|
|
|
|
|
|
|
|
logger.info('Device "%s" has been inserted. ' \ |
|
|
logger.info('Device "%s" has been inserted. ' \ |
|
|
'Performing verification...' % deviceName) |
|
|
'Performing verification...' % deviceName) |
|
|
cmdLine = "%s -q -c %s -u %s -s pamusb-agent -a" % (options['path'], |
|
|
|
|
|
|
|
|
cmdLine = "%s -q -c %s -u %s -s pamusb-agent -a" % (options['check'], |
|
|
options['configFile'], |
|
|
options['configFile'], |
|
|
username) |
|
|
username) |
|
|
logger.info('Executing "%s"' % cmdLine) |
|
|
logger.info('Executing "%s"' % cmdLine) |
|
|