#9396 Renaming user or group with --setattr does not check supported formats
Closed: fixed by frenaud. Opened by frenaud.

Issue

It is possible to rename a user / a group using multiple methods:

  • ipa user|stageuser|group-mod oldname --rename newname
  • ipa user|stageuser|group-mod oldname --setattr uid|cn=newname

When the first method is used, the CLI checks the format of the new name and refuses names containing only numbers for instance.
If the second method is used, no check is enforced and any value can be accepted.

The behavior should be consistent.

Steps to Reproduce

[root@server ~]# ipa group-mod testgroup --rename 1234
ipa: ERROR: invalid 'rename': may only include letters, numbers, _, -, . and $
[root@server ~]# ipa group-mod testgroup --setattr cn=1234
--------------------------
Modified group "testgroup"
--------------------------
  Group name: 1234
  GID: 205400104
[root@server ~]# 
[root@server ~]# ipa user-mod testuser --rename 123456
ipa: ERROR: invalid 'rename': may only include letters, numbers, _, -, . and $
[root@server ~]# ipa user-mod testuser --setattr uid=123456
------------------------
Modified user "testuser"
------------------------
  User login: 123456
  First name: test
  Last name: user
  Home directory: /home/testuser
  Login shell: /bin/sh
  Principal name: 123456@IPA.TEST
  Principal alias: 123456@IPA.TEST
  Email address: testuser@ipa.test
  UID: 205400107
  GID: 205400107
  Account disabled: False
  Password: False
  Member of groups: ipausers
  Kerberos keys available: False
[root@server ~]# 

Actual behavior

The command with --rename properly validates the new name but --setattr cn= or --setattr uid= do not.

Expected behavior

The 2 methods should have a consistent behavior and refuse the invalid new name.

Version/Release/Distribution

4.10.1


Metadata Update from @frenaud:
- Issue assigned to frenaud

Metadata Update from @frenaud:
- Custom field on_review adjusted to https://github.com/freeipa/freeipa/pull/6883

master:

  • 794b2c32f67aa8e69616171f3e8de99654698b7e User and groups: rename with --setattr must check format
  • ae6549ffae1ffe2bb6a1ba7dce0620ec0c20cabf xmlrpc tests: add test renaming user or group with setattr

ipa-4-9:

  • ba30addb05d47c36e2857c76ae2aff42d6f3fbb3 User and groups: rename with --setattr must check format
  • a5a4800cbe3e45907f39f78a3da3ded504712982 xmlrpc tests: add test renaming user or group with setattr

Metadata Update from @frenaud:
- Issue close_status updated to: fixed
- Issue status updated to: Closed (was: Open)

Metadata