|
|
@ -102,21 +102,21 @@ class Log: |
|
|
|
syslog.syslog(priority, message) |
|
|
|
|
|
|
|
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__) |
|
|
|
sys.exit(1) |
|
|
|
|
|
|
|
import getopt |
|
|
|
|
|
|
|
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: |
|
|
|
usage() |
|
|
|
|
|
|
|
options = {'configFile' : '/etc/pamusb.conf', |
|
|
|
'daemon' : False, |
|
|
|
'path' : '/usr/bin/pamusb-check'} |
|
|
|
'check' : '/usr/bin/pamusb-check'} |
|
|
|
|
|
|
|
if len(args) != 0: |
|
|
|
usage() |
|
|
@ -128,13 +128,13 @@ for o, a in opts: |
|
|
|
options['configFile'] = a |
|
|
|
if o in ('-d', '--daemon'): |
|
|
|
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() |
|
|
|
|
|
|
|
username = pwd.getpwuid(os.getuid())[0] |
|
|
@ -182,7 +182,7 @@ def authChangeCallback(event): |
|
|
|
|
|
|
|
logger.info('Device "%s" has been inserted. ' \ |
|
|
|
'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'], |
|
|
|
username) |
|
|
|
logger.info('Executing "%s"' % cmdLine) |
|
|
|