From fbd3a442acd523df4183888fa12f8ce7de11d429 Mon Sep 17 00:00:00 2001 From: Jarrod Johnson Date: Tue, 8 Feb 2022 17:38:01 -0500 Subject: [PATCH] Support numeric owner/group in syncfile list --- confluent_server/confluent/syncfiles.py | 29 ++++++++++++++++++++----- 1 file changed, 24 insertions(+), 5 deletions(-) diff --git a/confluent_server/confluent/syncfiles.py b/confluent_server/confluent/syncfiles.py index d9586f44..b5d6c277 100644 --- a/confluent_server/confluent/syncfiles.py +++ b/confluent_server/confluent/syncfiles.py @@ -128,15 +128,34 @@ class SyncList(object): try: uid = pwd.getpwnam(optval).pw_uid except KeyError: - uid = None - optval = {'name': optval, 'id': uid} + try: + uid = int(optval) + optval = None + except ValueError: + uid = None + if optval: + optval = {'name': optval} + else: + optval = {} + if uid is not None: + optval['id'] = uid elif optname == 'group': try: gid = grp.getgrnam(optval).gr_gid except KeyError: - gid = None - optval = {'name': optval, 'id': gid} - entopts[optname] = optval + try: + gid = int(optval) + optval = None + except ValueError: + gid = None + if optval: + optval = {'name': optval} + else: + optval = {} + if gid is not None: + optval['id'] = gid + if optval: + entopts[optname] = optval currmap[k] = v targ = v if v else k for f in targ.split():