Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions mig/shared/useradm.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.

Check warning on line 23 in mig/shared/useradm.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

line too long (81 > 80 characters)
#
# --- END_HEADER ---
#
Expand Down Expand Up @@ -130,7 +130,7 @@
return True
try:
os.remove(link_path)
except:

Check warning on line 133 in mig/shared/useradm.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

do not use bare 'except'
raise Exception('could not remove symlink: %s' % link_path)
return True

Expand Down Expand Up @@ -352,7 +352,7 @@
regex_patterns = ['distinguished_name']
else:
regex_patterns = []
(_, hits) = search_users(search_filter, configuration, db_path, force, verbose,

Check warning on line 355 in mig/shared/useradm.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

line too long (83 > 80 characters)
regex_match=regex_patterns)
peer_notes = []
if not hits:
Expand Down Expand Up @@ -588,16 +588,16 @@
reset_auth_type,
req_timestamp)
if valid_reset:
_logger.info("%r requested and authorized password reset"

Check warning on line 591 in mig/shared/useradm.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

line too long (81 > 80 characters)
% client_id)
if verbose:
print("User requested and authorized password reset")

Check warning on line 594 in mig/shared/useradm.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

line too long (81 > 80 characters)
authorized = True
else:
_logger.warning("%r requested password reset with bad token"

Check warning on line 597 in mig/shared/useradm.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

line too long (84 > 80 characters)
% client_id)
if verbose:
print("User requested password reset with bad token")

Check warning on line 600 in mig/shared/useradm.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

line too long (81 > 80 characters)

if authorized:
_logger.info("%r authorized password update" % client_id)
Expand Down Expand Up @@ -628,7 +628,7 @@
if verbose:
print("""Renewal request supplied a different
password and you didn't accept change anyway - nothing more to do""")
err = """Cannot renew account using a new password!

Check failure on line 631 in mig/shared/useradm.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

Assignment to variable "err" outside except: block [misc]
Please tell user to use the original password, request password reset or go
through renewal using Xgi-bin with proper authentication to authorize the
change."""
Expand All @@ -645,7 +645,7 @@
not isinstance(val, basestring) and \
isinstance(val, list):
val_list = updated_user.get(key, [])
val_list += [i for i in val if not i in val_list]

Check warning on line 648 in mig/shared/useradm.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

test for membership should be 'not in'
updated_user[key] = val_list
elif val:
updated_user[key] = val
Expand All @@ -666,7 +666,7 @@
short_id = user.get('short_id', '')
# For cert users short_id is the full DN so we should ignore then
if short_id and short_id != client_id and short_id.find(' ') == -1 and \
not short_id in openid_names:

Check warning on line 669 in mig/shared/useradm.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

test for membership should be 'not in'
openid_names.append(short_id)
add_names = []

Expand Down Expand Up @@ -741,7 +741,7 @@
return user


def create_user_in_fs(configuration, client_id, user, now, renew, force, verbose):

Check warning on line 744 in mig/shared/useradm.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

line too long (82 > 80 characters)
"""Handle all the parts of user creation or renewal relating to making
directories and writing default files.
"""
Expand Down Expand Up @@ -1154,7 +1154,7 @@
for (share_id, share_dict) in sharelinks.items():
# Update owner and use generic update helper to replace symlink
share_dict['owner'] = client_id
(mod_status, err) = update_share_link(share_dict, client_id,

Check failure on line 1157 in mig/shared/useradm.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

Assignment to variable "err" outside except: block [misc]
configuration, sharelinks)
if verbose:
if mod_status:
Expand Down Expand Up @@ -1425,14 +1425,14 @@
res_map = get_resource_map(configuration)
for (res_id, res) in res_map.items():
if client_id in res[OWNERS]:
(add_status, err) = resource_add_owners(configuration, res_id,

Check failure on line 1428 in mig/shared/useradm.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

Assignment to variable "err" outside except: block [misc]
[new_id])
if not add_status:
if verbose:
print('Could not add new %s owner of %s: %s'
% (new_id, res_id, err))
continue
(del_status, err) = resource_remove_owners(configuration, res_id,

Check failure on line 1435 in mig/shared/useradm.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

Assignment to variable "err" outside except: block [misc]
[client_id])
if not del_status:
if verbose:
Expand All @@ -1453,14 +1453,14 @@
for (vgrid_name, vgrid) in vgrid_map[VGRIDS].items():
if client_id in vgrid[OWNERS]:

(add_status, err) = vgrid_add_owners(configuration, vgrid_name,

Check failure on line 1456 in mig/shared/useradm.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

Assignment to variable "err" outside except: block [misc]
[new_id])
if not add_status:
if verbose:
print('Could not add new %s owner of %s: %s'
% (new_id, vgrid_name, err))
continue
(del_status, err) = vgrid_remove_owners(configuration, vgrid_name,

Check failure on line 1463 in mig/shared/useradm.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

Assignment to variable "err" outside except: block [misc]
[client_id])
if not del_status:
if verbose:
Expand All @@ -1472,14 +1472,14 @@
client_id,
new_id))
elif client_id in vgrid[MEMBERS]:
(add_status, err) = vgrid_add_members(configuration, vgrid_name,

Check failure on line 1475 in mig/shared/useradm.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

Assignment to variable "err" outside except: block [misc]
[new_id])
if not add_status:
if verbose:
print('Could not add new %s member of %s: %s'
% (new_id, vgrid_name, err))
continue
(del_status, err) = vgrid_remove_members(configuration, vgrid_name,

Check failure on line 1482 in mig/shared/useradm.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

Assignment to variable "err" outside except: block [misc]
[client_id])
if not del_status:
if verbose:
Expand All @@ -1496,7 +1496,7 @@
(re_status, re_list) = list_runtime_environments(configuration)
if re_status:
for re_name in re_list:
(re_status, err) = update_runtimeenv_owner(re_name, client_id,

Check failure on line 1499 in mig/shared/useradm.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

Assignment to variable "err" outside except: block [misc]
new_id, configuration)
if verbose:
if re_status:
Expand All @@ -1518,7 +1518,7 @@
for (share_id, share_dict) in sharelinks.items():
# Update owner and use generic update helper to replace symlink
share_dict['owner'] = new_id
(mod_status, err) = update_share_link(share_dict, new_id,

Check failure on line 1521 in mig/shared/useradm.py

View workflow job for this annotation

GitHub Actions / Style check python and annotate

Assignment to variable "err" outside except: block [misc]
configuration, sharelinks)
if verbose:
if mod_status:
Expand Down Expand Up @@ -2400,6 +2400,9 @@
else:
configuration = get_configuration_object()
_logger = configuration.logger
addresses = dict(zip(configuration.notify_protocols,
[[] for _ in configuration.notify_protocols]))
addresses['email'] = []
if db_path == keyword_auto:
db_path = default_db_path(configuration)
try:
Expand All @@ -2414,7 +2417,8 @@
if verbose:
print(err_msg)
_logger.error(err_msg)
return []
errors.append("notify %r preparation failed: %s" % (user_id, err_msg))
return (configuration, None, addresses, errors)

user_fields = {}
if user_id in user_db:
Expand All @@ -2439,9 +2443,6 @@
for field in get_fields:
user_fields[field] = user_dict.get(field, None)

addresses = dict(zip(configuration.notify_protocols,
[[] for _ in configuration.notify_protocols]))
addresses['email'] = []
for (proto, address_list) in targets.items():
if not proto in configuration.notify_protocols + ['email']:
errors.append('unsupported protocol: %s' % proto)
Expand Down