Comment 0 for bug 2002949

Revision history for this message
Renaud Miel (r-miel) wrote :

1) The release of Ubuntu I am using:
$ lsb_release -rd
Description: Ubuntu 22.04.1 LTS
Release: 22.04

2) The version of the package I am using
apt-cache policy python3-samba
$ apt-cache policy python3-samba
python3-samba:
  Installed: 2:4.15.9+dfsg-0ubuntu0.2
  Candidate: 2:4.15.9+dfsg-0ubuntu0.3
  Version table:
     2:4.15.9+dfsg-0ubuntu0.3 500
        500 http://jp.archive.ubuntu.com/ubuntu jammy-updates/main amd64 Packages
 *** 2:4.15.9+dfsg-0ubuntu0.2 500
        500 http://security.ubuntu.com/ubuntu jammy-security/main amd64 Packages
        100 /var/lib/dpkg/status
     2:4.15.5~dfsg-0ubuntu5 500
        500 http://jp.archive.ubuntu.com/ubuntu jammy/main amd64 Packages

3) What you expected to happen
I expected the old password to be updated with the provided new password

4) What happened instead
The old password was not updated and the error shown below occurred.

It looks like this is because in:

file: getopt.py,
function: _ensure_secure_proctitle(self, opt_str, secret_data, data_type="password")
line 201: pass_opt_re_str = "(.*[ ]+)(%s[= ]%s)([ ]*.*)" % (opt_str, secret_data)

the old password passed through argument secret_data is used as-is
to form a regular expression, instead of being properly escaped.

Suggested fix:
pass_opt_re_str = "(.*[ ]+)(%s[= ]%s)([ ]*.*)" % (re.escape(opt_str), re.escape(secret_data))

ERROR(): uncaught exception - missing ), unterminated subpattern at position 8
  File "/usr/bin/samba-tool", line 44, in
    retval = cmd._run("samba-tool", subcommand, *args)
  File "/usr/lib/python3/dist-packages/samba/netcmd/__init__.py", line 235, in _run
    return self.subcommands[subcommand]._run(
  File "/usr/lib/python3/dist-packages/samba/netcmd/__init__.py", line 235, in _run
    return self.subcommands[subcommand]._run(
  File "/usr/lib/python3/dist-packages/samba/netcmd/__init__.py", line 153, in _run
    opts, args = parser.parse_args(list(argv))
  File "/usr/lib/python3.10/optparse.py", line 1387, in parse_args
    stop = self._process_args(largs, rargs, values)
  File "/usr/lib/python3.10/optparse.py", line 1427, in _process_args
    self._process_long_opt(rargs, values)
  File "/usr/lib/python3.10/optparse.py", line 1501, in _process_long_opt
    option.process(opt, value, values, self)
  File "/usr/lib/python3.10/optparse.py", line 784, in process
    return self.take_action(
  File "/usr/lib/python3.10/optparse.py", line 805, in take_action
    self.callback(self, opt, value, parser, *args, **kwargs)
  File "/usr/lib/python3/dist-packages/samba/getopt.py", line 250, in _set_password
    self._ensure_secure_proctitle(opt_str, arg, "password")
  File "/usr/lib/python3/dist-packages/samba/getopt.py", line 202, in _ensure_secure_proctitle
    pass_opt_re = re.compile(pass_opt_re_str)
  File "/usr/lib/python3.10/re.py", line 251, in compile
    return _compile(pattern, flags)
  File "/usr/lib/python3.10/re.py", line 303, in _compile
    p = sre_compile.compile(pattern, flags)
  File "/usr/lib/python3.10/sre_compile.py", line 788, in compile
    p = sre_parse.parse(p, flags)
  File "/usr/lib/python3.10/sre_parse.py", line 955, in parse
    p = _parse_sub(source, state, flags & SRE_FLAG_VERBOSE, 0)
  File "/usr/lib/python3.10/sre_parse.py", line 444, in _parse_sub
    itemsappend(_parse(source, state, verbose, nested + 1,
  File "/usr/lib/python3.10/sre_parse.py", line 843, in _parse
    raise source.error("missing ), unterminated subpattern",