From d38c12d85293dd93361dbb5597b4a8db8656bd1e Mon Sep 17 00:00:00 2001 From: maxliu2001 Date: Wed, 24 May 2023 18:53:17 +0000 Subject: [PATCH 1/3] first version of cli scanner tool --- .../wifibssid/result-format | 28 ++-- .../wifibssid/validate.py | 3 +- .../bssidscanner/Makefile | 1 + pscheduler-tool-bssidscanner/bssidscanner/run | 119 +---------------- .../bssidscanner/run-wrapped | 125 ++++++++++++++++++ .../bssidscanner/run.py | 0 6 files changed, 143 insertions(+), 133 deletions(-) create mode 100755 pscheduler-tool-bssidscanner/bssidscanner/run-wrapped delete mode 100644 pscheduler-tool-bssidscanner/bssidscanner/run.py diff --git a/pscheduler-test-wifibssid/wifibssid/result-format b/pscheduler-test-wifibssid/wifibssid/result-format index e304db657d..09b04a5346 100755 --- a/pscheduler-test-wifibssid/wifibssid/result-format +++ b/pscheduler-test-wifibssid/wifibssid/result-format @@ -46,13 +46,13 @@ if format == 'text/plain': print("") print(entry["ssid"] + ":") print(f' Signal: {entry["signal"]}') - print(f' Address: {entry["address"]}') - print(f' Frequency: {entry["frequency"]}') - print(f' Quality: {entry["quality"]}') - print(f' Bitrates: {entry["bitrates"]}') - print(f' Encrypted: {entry["encrypted"]}') - print(f' Channel: {entry["channel"]}') - print(f' Mode: {entry["mode"]}') + print(f' Address: {entry["bssid"]}') + print(f' Frequency: {entry["freq"]}') + # print(f' Quality: {entry["quality"]}') + # print(f' Bitrates: {entry["bitrates"]}') + # print(f' Encrypted: {entry["encrypted"]}') + # print(f' Channel: {entry["channel"]}') + print(f' Mode: {entry["flags"]}') print("") elif format == 'text/html': @@ -68,13 +68,13 @@ elif format == 'text/html': for entry in result['ssid_list']: print(f' SSID {entry["ssid"]}') print(f' Signal {entry["signal"]}') - print(f' Address {entry["address"]}') - print(f' Frequency {entry["frequency"]}') - print(f' Quality {entry["quality"]}') - print(f' Bitrates {entry["bitrates"]}') - print(f' Encrypted {entry["signal"]}') - print(f' Channel {entry["channel"]}') - print(f' Mode {entry["mode"]}') + print(f' Address {entry["bssid"]}') + print(f' Frequency {entry["freq"]}') + # print(f' Quality {entry["quality"]}') + # print(f' Bitrates {entry["bitrates"]}') + # print(f' Encrypted {entry["signal"]}') + # print(f' Channel {entry["channel"]}') + print(f' Mode {entry["flags"]}') print('') diff --git a/pscheduler-test-wifibssid/wifibssid/validate.py b/pscheduler-test-wifibssid/wifibssid/validate.py index c82f4c04f4..cf8df1214d 100644 --- a/pscheduler-test-wifibssid/wifibssid/validate.py +++ b/pscheduler-test-wifibssid/wifibssid/validate.py @@ -51,8 +51,7 @@ }, # If listed here, these parameters MUST be in the test spec. "required": [ - "interface", - "ssid", + "interface" ], # Treat other properties as acceptable. This should # ALWAYS be false. diff --git a/pscheduler-tool-bssidscanner/bssidscanner/Makefile b/pscheduler-tool-bssidscanner/bssidscanner/Makefile index 07ff198fe0..bd365aae01 100644 --- a/pscheduler-tool-bssidscanner/bssidscanner/Makefile +++ b/pscheduler-tool-bssidscanner/bssidscanner/Makefile @@ -11,6 +11,7 @@ FILES=\ merged-results \ participant-data \ run \ + run-wrapped install: $(FILES) ifndef DESTDIR diff --git a/pscheduler-tool-bssidscanner/bssidscanner/run b/pscheduler-tool-bssidscanner/bssidscanner/run index f1c8423f30..3b8deca601 100755 --- a/pscheduler-tool-bssidscanner/bssidscanner/run +++ b/pscheduler-tool-bssidscanner/bssidscanner/run @@ -1,119 +1,4 @@ -#!/usr/bin/env python3 +#!/bin/sh -e -# -# Development Order #5: -# -# This is the meat and bones of the tool, where the actual desired -# commands or operation will be run. The results are then recorded -# and added to the 'results' JSON data, which will then be sent -# back to the test. Both system and api are able to be used here. -# - -import datetime -import subprocess -import json -import sys -import time -import argparse -import time -from wifi import Cell #make sure that you have pip installed wifi - -import pscheduler - -# from stdin -input = pscheduler.json_load(exit_on_error=True) - -# Take input from test spec -try: - interface = input['test']['spec']['interface'] - ssid = input['test']['spec']['ssid'] -except KeyError: - pscheduler.fail('Missing data in input') - -# convert the comma separated ssids to a list -ssid = list(ssid.split(',')) - -duration = input['test']['spec'].get('duration', 'PT5S') -duration = pscheduler.timedelta_as_seconds( pscheduler.iso8601_as_timedelta(duration) ) -timeout_iso = input['test']['spec'].get('timeout', 'PT10S') -timeout = pscheduler.timedelta_as_seconds( pscheduler.iso8601_as_timedelta(timeout_iso) ) -start_time = datetime.datetime.now() -succeeded = False -error = '' -diags = '' - -# Run the actual task here: -def get_all_bssids(interface): - """ - Scan the given interface for all bssids - Return a list of all bssids - """ - start_time = time.time() - cells = Cell.all(interface) # Specify interface to scan on - wifi_list = [] - for cell in cells: - bssid = {} - bssid['ssid'] = cell.ssid - bssid['signal'] = cell.signal - bssid['address'] = cell.address - bssid['frequency'] = pscheduler.si_as_number(cell.frequency[:-2]) - quality_num,quality_denom = cell.quality.split('/') - bssid['quality'] = float(quality_num) / float(quality_denom) - bssid['bitrates'] = sorted(map(lambda v : pscheduler.si_as_number(v[:-3]), cell.bitrates)) - bssid['encrypted'] = cell.encrypted - bssid['channel'] = cell.channel - bssid['mode'] = cell.mode - wifi_list.append(bssid) - - end_time = time.time() - elapsed_time = end_time - start_time - log_msg = "Scan finished in " + str(elapsed_time) - return wifi_list, elapsed_time - -""" -Scan on the given interface -Output a list of all bssids in json format with the given ssid -""" -all_bssids, elapsed_time = get_all_bssids(interface) -ssid_list = [] - -# Check complete list for matching ssids -for bssid in all_bssids: - #if no ssids were given then append all the ssids - if not ssid: - ssid_list.append(bssid) - else: - #if ssid/ssids were given then only append those - if bssid['ssid'] in ssid: - ssid_list.append(bssid) - -succeeded = True - -# IMPORTANT NOTE: This code puts the process to sleep until the -# scheduled start time has arrived. It should be placed after all -# preparatory code has been executed and immediately before the tool -# is invoked (for plugins that run other programs) or any activity -# that does a measurement (for those that don't). - -try: - pscheduler.sleep_until(input['schedule']['start']) -except KeyError: - pscheduler.fail("Unable to find start time in input") - - -end_time = datetime.datetime.now() - -# Organize results into json data -results = { - 'succeeded': succeeded, - 'result': { - 'schema': 1, - 'time': pscheduler.timedelta_as_iso8601( end_time - start_time), - 'succeeded': succeeded, - 'ssid_list': ssid_list - }, - 'error': error, - 'diags': diags } - -pscheduler.succeed_json(results) +exec sudo "$(dirname $0)/run-wrapped" diff --git a/pscheduler-tool-bssidscanner/bssidscanner/run-wrapped b/pscheduler-tool-bssidscanner/bssidscanner/run-wrapped new file mode 100755 index 0000000000..c10b55ec60 --- /dev/null +++ b/pscheduler-tool-bssidscanner/bssidscanner/run-wrapped @@ -0,0 +1,125 @@ +#!/usr/bin/env python3 + +# +# Development Order #5: +# +# This is the meat and bones of the tool, where the actual desired +# commands or operation will be run. The results are then recorded +# and added to the 'results' JSON data, which will then be sent +# back to the test. Both system and api are able to be used here. +# + +import select +from os import getpid, makedirs, unlink, access, R_OK, system, listdir, path +import datetime +import pscheduler +# import subprocess +import time + +#temp file preserved between consecutive runs but not reboots +WPA_CONFIG_PATH = '/tmp/wpa_supplicant/wpa_supplicant.conf' +#initializes only when wpa_supplicant starts +WPA_CTRL_IFACE_BASE = '/var/run/wpa_supplicant' +ssid_set = set() + +# parse config +pscheduler_input = pscheduler.json_load(exit_on_error=True) +interface = pscheduler_input['test']['spec'].get('interface') +get_ssid = pscheduler_input['test']['spec'].get('ssid', None) +ssid_set = set(get_ssid.split(',')) if get_ssid else None +duration_iso = pscheduler_input['test']['spec'].get('duration', 'PT5S') +timeout_iso = pscheduler_input['test']['spec'].get('timeout', 'PT10S') +timeout = pscheduler.timedelta_as_seconds(pscheduler.iso8601_as_timedelta(timeout_iso)) +duration = pscheduler.timedelta_as_seconds(pscheduler.iso8601_as_timedelta(duration_iso)) +start_time = datetime.datetime.now() +error = '' +diags = '' +ssid_list = [] +dir_path = path.dirname(WPA_CONFIG_PATH) + +# check if interface already exists +if not access(f'{WPA_CTRL_IFACE_BASE}/{interface}', R_OK): + #create config file and start wpa_supplicant + if not path.exists(dir_path): + makedirs(dir_path) + with open(WPA_CONFIG_PATH, 'w') as f: + f.write('ctrl_interface='+WPA_CTRL_IFACE_BASE+'\r\n') + f.write('update_config=1\r\n') + f.write('p2p_disabled=1\r\n') + status, out, err = pscheduler.run_program(['wpa_supplicant','-Dnl80211','-B','-i',interface,'-c',WPA_CONFIG_PATH]) + if status: + pscheduler.succeed_json( { + 'succeeded': False, + 'diags': '', + 'error': 'failed to initialize interface', + 'result': None + } ) + +# run wpa_cli +start = datetime.datetime.now() +status, res, err = pscheduler.run_program(['wpa_cli', 'scan']) +if res.split('\n')[1] == 'OK': + status, res, err = pscheduler.run_program(['wpa_cli', 'scan_result']) +else: + pscheduler.succeed_json( { + 'succeeded': False, + 'diags': '', + 'error': 'wpa_cli scan failed', + 'result': None + } ) + + +result = res.split('\n') + +# account for automatic scanning interval of cli +while len(result) <= 3: + status, res, err = pscheduler.run_program(['wpa_cli', 'scan_result']) + result = res.split('\n') + time.sleep(0.3) + +for i in range(2, len(result)): + line = result[i].split('\t') + if len(line) == 1: + break + elif len(line) == 4: + bssid, freq, signal, flags = line + elif len(line) == 5: + bssid, freq, signal, flags, ssid = line + + if not ssid_set or ssid in ssid_set: + # retrieve prev ssid if ssid is empty + if ssid == '': + ssid = ssid_list[-1]['ssid'] + ssid_list.append({ + 'ssid': ssid, + 'bssid': bssid, + 'freq': int(freq), + 'signal': int(signal), + 'flags': flags + }) +end_time = datetime.datetime.now() + +# Check for empty result +if len(ssid_list) == 0: + pscheduler.succeed_json( { + 'succeeded': False, + 'diags': '', + 'error': 'scan completed but returned empty result', + 'result': None + } ) + +# Organize results into json data +results = { + 'succeeded': True, + 'result': { + 'schema': 1, + 'time': pscheduler.timedelta_as_iso8601(end_time - start_time), + 'succeeded': True, + 'ssid_list': ssid_list + }, + 'error': error, + 'diags': diags +} + + +pscheduler.succeed_json(results) diff --git a/pscheduler-tool-bssidscanner/bssidscanner/run.py b/pscheduler-tool-bssidscanner/bssidscanner/run.py deleted file mode 100644 index e69de29bb2..0000000000 From ea048332b96921eaa16be911daca427ebf5e4293 Mon Sep 17 00:00:00 2001 From: maxliu2001 Date: Fri, 16 Jun 2023 18:01:02 +0000 Subject: [PATCH 2/3] removed run wrapped and configured sudo roles for rpm and deb --- .../bssidscanner/Makefile | 1 - .../bssidscanner/duration | 2 +- pscheduler-tool-bssidscanner/bssidscanner/run | 126 +++++++++++++++- .../bssidscanner/run-wrapped | 125 ---------------- .../unibuild-packaging/deb/sudoers | 10 ++ .../rpm/pscheduler-tool-bssidscanner.spec | 17 +++ pscheduler-tool-umichwpa/umichwpa/run | 134 +++++++++++------- 7 files changed, 235 insertions(+), 180 deletions(-) delete mode 100755 pscheduler-tool-bssidscanner/bssidscanner/run-wrapped create mode 100644 pscheduler-tool-bssidscanner/bssidscanner/unibuild-packaging/deb/sudoers diff --git a/pscheduler-tool-bssidscanner/bssidscanner/Makefile b/pscheduler-tool-bssidscanner/bssidscanner/Makefile index bd365aae01..07ff198fe0 100644 --- a/pscheduler-tool-bssidscanner/bssidscanner/Makefile +++ b/pscheduler-tool-bssidscanner/bssidscanner/Makefile @@ -11,7 +11,6 @@ FILES=\ merged-results \ participant-data \ run \ - run-wrapped install: $(FILES) ifndef DESTDIR diff --git a/pscheduler-tool-bssidscanner/bssidscanner/duration b/pscheduler-tool-bssidscanner/bssidscanner/duration index 2612f43f1e..50595669fa 100644 --- a/pscheduler-tool-bssidscanner/bssidscanner/duration +++ b/pscheduler-tool-bssidscanner/bssidscanner/duration @@ -19,7 +19,7 @@ json = pscheduler.json_load(exit_on_error=True); timeout_iso = json.get("timeout", "PT10S") -timeout = pscheduler.iso8601_as_timedelta(timeout_iso)+datetime.timedelta(seconds=2) +timeout = pscheduler.iso8601_as_timedelta(timeout_iso)+datetime.timedelta(seconds=1) pscheduler.succeed_json({ "duration": pscheduler.timedelta_as_iso8601( timeout ) diff --git a/pscheduler-tool-bssidscanner/bssidscanner/run b/pscheduler-tool-bssidscanner/bssidscanner/run index 3b8deca601..4201790a38 100755 --- a/pscheduler-tool-bssidscanner/bssidscanner/run +++ b/pscheduler-tool-bssidscanner/bssidscanner/run @@ -1,4 +1,126 @@ -#!/bin/sh -e +#!/usr/bin/env python3 -exec sudo "$(dirname $0)/run-wrapped" +# +# Development Order #5: +# +# This is the meat and bones of the tool, where the actual desired +# commands or operation will be run. The results are then recorded +# and added to the 'results' JSON data, which will then be sent +# back to the test. Both system and api are able to be used here. +# +import select +from os import getpid, makedirs, unlink, access, R_OK, system, listdir, path +import datetime +import pscheduler +# import subprocess +import time + +#temp file preserved between consecutive runs but not reboots +WPA_CONFIG_PATH = '/tmp/wpa_supplicant.conf' +#initializes only when wpa_supplicant starts +WPA_CTRL_IFACE_BASE = '/var/run/wpa_supplicant' +ssid_set = set() + +# parse config +pscheduler_input = pscheduler.json_load(exit_on_error=True) +interface = pscheduler_input['test']['spec'].get('interface') +get_ssid = pscheduler_input['test']['spec'].get('ssid', None) +ssid_set = set(get_ssid.split(',')) if get_ssid else None +duration_iso = pscheduler_input['test']['spec'].get('duration', 'PT5S') +timeout_iso = pscheduler_input['test']['spec'].get('timeout', 'PT10S') +timeout = pscheduler.timedelta_as_seconds(pscheduler.iso8601_as_timedelta(timeout_iso)) +duration = pscheduler.timedelta_as_seconds(pscheduler.iso8601_as_timedelta(duration_iso)) +start_time = datetime.datetime.now() +error = '' +diags = '' +ssid_list = [] +dir_path = path.dirname(WPA_CONFIG_PATH) + +# check if interface already exists +status, res, err = pscheduler.run_program(['wpa_cli', 'status']) +if status: + # create config file and start wpa_supplicant + # if not path.exists(dir_path): + # makedirs(dir_path) + with open(WPA_CONFIG_PATH, 'w') as f: + f.write('ctrl_interface='+WPA_CTRL_IFACE_BASE+'\n') + f.write('update_config=1\n') + f.write('p2p_disabled=1\n') + status, out, err = pscheduler.run_program(['wpa_supplicant','-Dnl80211','-B','-i',interface,'-c',WPA_CONFIG_PATH]) + if status: + pscheduler.succeed_json( { + 'succeeded': False, + 'diags': out, + 'error': 'failed to initialize interface', + 'result': None + }) + +# run wpa_cli +start = datetime.datetime.now() +status, res, err = pscheduler.run_program(['wpa_cli', 'scan']) +if not status: + status, res, err = pscheduler.run_program(['wpa_cli', 'scan_result']) +else: + pscheduler.succeed_json( { + 'succeeded': False, + 'diags': res, + 'error': 'wpa_cli scan failed', + 'result': None + } ) + + +result = res.split('\n') + +# account for automatic scanning interval of cli +while len(result) <= 3: + status, res, err = pscheduler.run_program(['wpa_cli', 'scan_result']) + result = res.split('\n') + time.sleep(0.3) + +for i in range(2, len(result)): + line = result[i].split('\t') + if len(line) == 1: + break + elif len(line) == 4: + bssid, freq, signal, flags = line + elif len(line) == 5: + bssid, freq, signal, flags, ssid = line + + if not ssid_set or ssid in ssid_set: + # retrieve prev ssid if ssid is empty + if ssid == '': + ssid = ssid_list[-1]['ssid'] + ssid_list.append({ + 'ssid': ssid, + 'bssid': bssid, + 'freq': int(freq), + 'signal': int(signal), + 'flags': flags + }) +end_time = datetime.datetime.now() + +# Check for empty result +if len(ssid_list) == 0: + pscheduler.succeed_json( { + 'succeeded': False, + 'diags': '', + 'error': 'scan completed but returned empty result', + 'result': None + } ) + +# Organize results into json data +results = { + 'succeeded': True, + 'result': { + 'schema': 1, + 'time': pscheduler.timedelta_as_iso8601(end_time - start_time), + 'succeeded': True, + 'ssid_list': ssid_list + }, + 'error': error, + 'diags': diags +} + + +pscheduler.succeed_json(results) diff --git a/pscheduler-tool-bssidscanner/bssidscanner/run-wrapped b/pscheduler-tool-bssidscanner/bssidscanner/run-wrapped deleted file mode 100755 index c10b55ec60..0000000000 --- a/pscheduler-tool-bssidscanner/bssidscanner/run-wrapped +++ /dev/null @@ -1,125 +0,0 @@ -#!/usr/bin/env python3 - -# -# Development Order #5: -# -# This is the meat and bones of the tool, where the actual desired -# commands or operation will be run. The results are then recorded -# and added to the 'results' JSON data, which will then be sent -# back to the test. Both system and api are able to be used here. -# - -import select -from os import getpid, makedirs, unlink, access, R_OK, system, listdir, path -import datetime -import pscheduler -# import subprocess -import time - -#temp file preserved between consecutive runs but not reboots -WPA_CONFIG_PATH = '/tmp/wpa_supplicant/wpa_supplicant.conf' -#initializes only when wpa_supplicant starts -WPA_CTRL_IFACE_BASE = '/var/run/wpa_supplicant' -ssid_set = set() - -# parse config -pscheduler_input = pscheduler.json_load(exit_on_error=True) -interface = pscheduler_input['test']['spec'].get('interface') -get_ssid = pscheduler_input['test']['spec'].get('ssid', None) -ssid_set = set(get_ssid.split(',')) if get_ssid else None -duration_iso = pscheduler_input['test']['spec'].get('duration', 'PT5S') -timeout_iso = pscheduler_input['test']['spec'].get('timeout', 'PT10S') -timeout = pscheduler.timedelta_as_seconds(pscheduler.iso8601_as_timedelta(timeout_iso)) -duration = pscheduler.timedelta_as_seconds(pscheduler.iso8601_as_timedelta(duration_iso)) -start_time = datetime.datetime.now() -error = '' -diags = '' -ssid_list = [] -dir_path = path.dirname(WPA_CONFIG_PATH) - -# check if interface already exists -if not access(f'{WPA_CTRL_IFACE_BASE}/{interface}', R_OK): - #create config file and start wpa_supplicant - if not path.exists(dir_path): - makedirs(dir_path) - with open(WPA_CONFIG_PATH, 'w') as f: - f.write('ctrl_interface='+WPA_CTRL_IFACE_BASE+'\r\n') - f.write('update_config=1\r\n') - f.write('p2p_disabled=1\r\n') - status, out, err = pscheduler.run_program(['wpa_supplicant','-Dnl80211','-B','-i',interface,'-c',WPA_CONFIG_PATH]) - if status: - pscheduler.succeed_json( { - 'succeeded': False, - 'diags': '', - 'error': 'failed to initialize interface', - 'result': None - } ) - -# run wpa_cli -start = datetime.datetime.now() -status, res, err = pscheduler.run_program(['wpa_cli', 'scan']) -if res.split('\n')[1] == 'OK': - status, res, err = pscheduler.run_program(['wpa_cli', 'scan_result']) -else: - pscheduler.succeed_json( { - 'succeeded': False, - 'diags': '', - 'error': 'wpa_cli scan failed', - 'result': None - } ) - - -result = res.split('\n') - -# account for automatic scanning interval of cli -while len(result) <= 3: - status, res, err = pscheduler.run_program(['wpa_cli', 'scan_result']) - result = res.split('\n') - time.sleep(0.3) - -for i in range(2, len(result)): - line = result[i].split('\t') - if len(line) == 1: - break - elif len(line) == 4: - bssid, freq, signal, flags = line - elif len(line) == 5: - bssid, freq, signal, flags, ssid = line - - if not ssid_set or ssid in ssid_set: - # retrieve prev ssid if ssid is empty - if ssid == '': - ssid = ssid_list[-1]['ssid'] - ssid_list.append({ - 'ssid': ssid, - 'bssid': bssid, - 'freq': int(freq), - 'signal': int(signal), - 'flags': flags - }) -end_time = datetime.datetime.now() - -# Check for empty result -if len(ssid_list) == 0: - pscheduler.succeed_json( { - 'succeeded': False, - 'diags': '', - 'error': 'scan completed but returned empty result', - 'result': None - } ) - -# Organize results into json data -results = { - 'succeeded': True, - 'result': { - 'schema': 1, - 'time': pscheduler.timedelta_as_iso8601(end_time - start_time), - 'succeeded': True, - 'ssid_list': ssid_list - }, - 'error': error, - 'diags': diags -} - - -pscheduler.succeed_json(results) diff --git a/pscheduler-tool-bssidscanner/bssidscanner/unibuild-packaging/deb/sudoers b/pscheduler-tool-bssidscanner/bssidscanner/unibuild-packaging/deb/sudoers new file mode 100644 index 0000000000..af26e32eac --- /dev/null +++ b/pscheduler-tool-bssidscanner/bssidscanner/unibuild-packaging/deb/sudoers @@ -0,0 +1,10 @@ +# +# pscheduler-tool-bssidscanner +# +Cmnd_Alias PSCHEDULER_WPA_SUPPLICANT = /usr/sbin/wpa_supplicant +pscheduler ALL = (root) NOPASSWD: PSCHEDULER_WPA_SUPPLICANT +Defaults!PSCHEDULER_WPA_SUPPLICANT !requiretty + +Cmnd_Alias PSCHEDULER_WPA_CLI = /usr/sbin/wpa_cli +pscheduler ALL = (root) NOPASSWD: PSCHEDULER_WPA_CLI +Defaults!PSCHEDULER_WPA_CLI !requiretty diff --git a/pscheduler-tool-bssidscanner/bssidscanner/unibuild-packaging/rpm/pscheduler-tool-bssidscanner.spec b/pscheduler-tool-bssidscanner/bssidscanner/unibuild-packaging/rpm/pscheduler-tool-bssidscanner.spec index 87a066e035..fb92bacc0c 100644 --- a/pscheduler-tool-bssidscanner/bssidscanner/unibuild-packaging/rpm/pscheduler-tool-bssidscanner.spec +++ b/pscheduler-tool-bssidscanner/bssidscanner/unibuild-packaging/rpm/pscheduler-tool-bssidscanner.spec @@ -44,6 +44,23 @@ make \ DESTDIR=$RPM_BUILD_ROOT/%{dest} \ install +# Enable sudo for this tool +WPA_SUPP=$(command -v wpa_supplicant) +WPA_CLI=$(command -v wpa_cli) + +mkdir -p $RPM_BUILD_ROOT/%{_pscheduler_sudoersdir} +cat > $RPM_BUILD_ROOT/%{_pscheduler_sudoersdir}/%{name} < Date: Tue, 20 Jun 2023 17:39:49 +0000 Subject: [PATCH 3/3] minor style change --- pscheduler-tool-bssidscanner/bssidscanner/run | 9 +++------ .../rpm/pscheduler-tool-bssidscanner.spec | 1 + 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/pscheduler-tool-bssidscanner/bssidscanner/run b/pscheduler-tool-bssidscanner/bssidscanner/run index 4201790a38..619baaec44 100755 --- a/pscheduler-tool-bssidscanner/bssidscanner/run +++ b/pscheduler-tool-bssidscanner/bssidscanner/run @@ -41,20 +41,18 @@ dir_path = path.dirname(WPA_CONFIG_PATH) status, res, err = pscheduler.run_program(['wpa_cli', 'status']) if status: # create config file and start wpa_supplicant - # if not path.exists(dir_path): - # makedirs(dir_path) with open(WPA_CONFIG_PATH, 'w') as f: f.write('ctrl_interface='+WPA_CTRL_IFACE_BASE+'\n') f.write('update_config=1\n') f.write('p2p_disabled=1\n') - status, out, err = pscheduler.run_program(['wpa_supplicant','-Dnl80211','-B','-i',interface,'-c',WPA_CONFIG_PATH]) + status, out, err = pscheduler.run_program(['wpa_supplicant','-D','nl80211','-B','-i',interface,'-c',WPA_CONFIG_PATH]) if status: pscheduler.succeed_json( { 'succeeded': False, - 'diags': out, + 'diags': out + ' ' + str(status) + ' ' + err, 'error': 'failed to initialize interface', 'result': None - }) + }) # run wpa_cli start = datetime.datetime.now() @@ -69,7 +67,6 @@ else: 'result': None } ) - result = res.split('\n') # account for automatic scanning interval of cli diff --git a/pscheduler-tool-bssidscanner/bssidscanner/unibuild-packaging/rpm/pscheduler-tool-bssidscanner.spec b/pscheduler-tool-bssidscanner/bssidscanner/unibuild-packaging/rpm/pscheduler-tool-bssidscanner.spec index fb92bacc0c..ab4a4cba7b 100644 --- a/pscheduler-tool-bssidscanner/bssidscanner/unibuild-packaging/rpm/pscheduler-tool-bssidscanner.spec +++ b/pscheduler-tool-bssidscanner/bssidscanner/unibuild-packaging/rpm/pscheduler-tool-bssidscanner.spec @@ -50,6 +50,7 @@ WPA_CLI=$(command -v wpa_cli) mkdir -p $RPM_BUILD_ROOT/%{_pscheduler_sudoersdir} cat > $RPM_BUILD_ROOT/%{_pscheduler_sudoersdir}/%{name} <