Skip to content

Commit

Permalink
Fix parsing of custom share configuration (#60)
Browse files Browse the repository at this point in the history
The double-colon ":" char is considered a key/value separator in
Python's ConfigParser class default configuration. Some share manual
settings require ":" in the key string (e.g. Recycle Bin).

This commit configure the ConfigParser object to expect key/value lines
separated by "=" char only.
  • Loading branch information
DavidePrincipi authored Nov 19, 2024
1 parent 4a9f2c1 commit 947fac8
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions imageroot/actions/list-shares/50list_shares
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,12 @@ list_shares = {
"shares": []
}

ocfg = configparser.ConfigParser()
ocfg = configparser.ConfigParser(delimiters=("="))
with subprocess.Popen(podman_exec + ["net", "conf", "list"], stdout=subprocess.PIPE, text=True) as hconf:
ocfg.read_file(hconf.stdout, 'samba-registry-conf')
try:
ocfg.read_file(hconf.stdout, 'samba-registry-conf')
except Exception as ex:
print(agent.SD_ERR + "Share configuration parse error", ex, file=sys.stderr)

psharenames = subprocess.run(podman_exec + ["net", "conf", "listshares"], stdout=subprocess.PIPE, text=True)
for share_name in filter(None, psharenames.stdout.split("\n")):
Expand Down

0 comments on commit 947fac8

Please sign in to comment.