Test password removal via python proctitle
authorDavid Mulder <dmulder@suse.com>
Fri, 8 Nov 2019 20:06:53 +0000 (20:06 +0000)
committerStefan Metzmacher <metze@samba.org>
Thu, 26 Nov 2020 06:52:41 +0000 (06:52 +0000)
Signed-off-by: David Mulder <dmulder@suse.com>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
25 files changed:
.gitlab-ci.yml
bootstrap/config.py
bootstrap/generated-dists/centos7/bootstrap.sh
bootstrap/generated-dists/centos7/packages.yml
bootstrap/generated-dists/centos8/bootstrap.sh
bootstrap/generated-dists/centos8/packages.yml
bootstrap/generated-dists/debian10/bootstrap.sh
bootstrap/generated-dists/debian10/packages.yml
bootstrap/generated-dists/fedora32/bootstrap.sh
bootstrap/generated-dists/fedora32/packages.yml
bootstrap/generated-dists/fedora33/bootstrap.sh
bootstrap/generated-dists/fedora33/packages.yml
bootstrap/generated-dists/opensuse151/bootstrap.sh
bootstrap/generated-dists/opensuse151/packages.yml
bootstrap/generated-dists/opensuse152/bootstrap.sh
bootstrap/generated-dists/opensuse152/packages.yml
bootstrap/generated-dists/ubuntu1604/bootstrap.sh
bootstrap/generated-dists/ubuntu1604/packages.yml
bootstrap/generated-dists/ubuntu1804/bootstrap.sh
bootstrap/generated-dists/ubuntu1804/packages.yml
bootstrap/generated-dists/ubuntu2004/bootstrap.sh
bootstrap/generated-dists/ubuntu2004/packages.yml
bootstrap/sha1sum.txt
python/samba/tests/cred_opt.py [new file with mode: 0644]
selftest/tests.py

index d65f4d2b7691acdaec4146ab38933ff8a27a2212..accaced66a05f13787d341558973039898b69fe3 100644 (file)
@@ -32,7 +32,7 @@ variables:
   # Set this to the contents of bootstrap/sha1sum.txt
   # which is generated by bootstrap/template.py --render
   #
-  SAMBA_CI_CONTAINER_TAG: d4867986881a9601c4620baf9a3bf28f5d1d1343
+  SAMBA_CI_CONTAINER_TAG: 42ecbfbf716fa85ce251a955de72a92af26fc7b2
   #
   # We use the ubuntu1804 image as default as
   # it matches what we have on sn-devel-184.
index ecbc614f0568b6d75717876e73b58e3caf3b6b0d..982ebae1cd1af2f04505366747e49e9bb38e8563 100644 (file)
@@ -141,6 +141,7 @@ PKGS = [
     ('python3-dnspython', 'python3-dns'),
     ('python3-pexpect', ''),  # for wintest only
     ('python3-pyasn1', 'python3-pyasn1'), # for krb5 tests
+    ('python3-setproctitle', 'python3-setproctitle'),
 
     ('', 'libsemanage-python'),
     ('', 'policycoreutils-python'),
@@ -451,6 +452,7 @@ RPM_DISTS = {
             'libcephfs-devel': '',
             'gnutls-devel': 'compat-gnutls34-devel',
             'liburing-devel': '',   # not available
+            'python3-setproctitle': 'python36-setproctitle',
         }
     },
     'centos8': {
index 63746e248bca962cb834439a93dcd4d4c1ca751f..7a6659d8e9a6f928600873a11a649782fd3dab5d 100755 (executable)
@@ -91,6 +91,7 @@ yum install -y \
     python36-iso8601 \
     python36-markdown \
     python36-pyasn1 \
+    python36-setproctitle \
     quota-devel \
     readline-devel \
     redhat-lsb \
index 7fb9b81139769ed2bcbcee5bdbe645e31b7888b4..ef6bbf826704367ba85234a0c41fcb667f6e978d 100644 (file)
@@ -77,6 +77,7 @@ packages:
   - python36-iso8601
   - python36-markdown
   - python36-pyasn1
+  - python36-setproctitle
   - quota-devel
   - readline-devel
   - redhat-lsb
index 342188e7fe55ef97f6e0920a155e464e8a269bed..e5167a2b561c01ce5b3e76cc20f4cc39c8881c9b 100755 (executable)
@@ -98,6 +98,7 @@ yum install -y \
     python3-markdown \
     python3-policycoreutils \
     python3-pyasn1 \
+    python3-setproctitle \
     quota-devel \
     readline-devel \
     redhat-lsb \
index d82a80e69577fc4cb40fbb4aa1e9742834162ae0..4e45f1c15e17f2449dc22721ed0429d8e546b7e4 100644 (file)
@@ -80,6 +80,7 @@ packages:
   - python3-markdown
   - python3-policycoreutils
   - python3-pyasn1
+  - python3-setproctitle
   - quota-devel
   - readline-devel
   - redhat-lsb
index 94f85473811d66ee27735000b011026c2af0095c..0bf5f6b50d2f21531ad2d0d678d880d36db98e81 100755 (executable)
@@ -92,6 +92,7 @@ apt-get -y install \
     python3-matplotlib \
     python3-pexpect \
     python3-pyasn1 \
+    python3-setproctitle \
     rng-tools \
     rsync \
     sed \
index ff45afedf937ac64d6f7ee331cddf12ea33a7891..f302831ee9a5b3a91ec4b370160e700419f7af34 100644 (file)
@@ -81,6 +81,7 @@ packages:
   - python3-matplotlib
   - python3-pexpect
   - python3-pyasn1
+  - python3-setproctitle
   - rng-tools
   - rsync
   - sed
index 18fbfefedbc4a1416a1cb1e4503a56c68aa47e58..1a585d2f13398d7c019db44bf80298af2f5bac59 100755 (executable)
@@ -94,6 +94,7 @@ dnf install -y \
     python3-markdown \
     python3-policycoreutils \
     python3-pyasn1 \
+    python3-setproctitle \
     quota-devel \
     readline-devel \
     redhat-lsb \
index 6cb2ce3841fb566d04790180b8ca85bb968f57cc..ee3a0a6d2ff7e55a73fcec0c507c326324e26ec5 100644 (file)
@@ -83,6 +83,7 @@ packages:
   - python3-markdown
   - python3-policycoreutils
   - python3-pyasn1
+  - python3-setproctitle
   - quota-devel
   - readline-devel
   - redhat-lsb
index d7e77eab2553bc2a7a6ebabf267dae9923c7b647..fce2626eaeeda054a8b493fa7ac343a5962c232a 100755 (executable)
@@ -95,6 +95,7 @@ dnf install -y \
     python3-markdown \
     python3-policycoreutils \
     python3-pyasn1 \
+    python3-setproctitle \
     quota-devel \
     readline-devel \
     redhat-lsb \
index 98c362181d9f4ae90ac2967dd87a90863cfcfcba..9fb68c1c53995bf4a369b826ebd024f2c48ec91f 100644 (file)
@@ -84,6 +84,7 @@ packages:
   - python3-markdown
   - python3-policycoreutils
   - python3-pyasn1
+  - python3-setproctitle
   - quota-devel
   - readline-devel
   - redhat-lsb
index 33c8aeb402197b0ef47fe46835d745f4b8a45601..df136a64ae8ffecdceca3156f208e1dc88644be3 100755 (executable)
@@ -88,6 +88,7 @@ zypper --non-interactive install \
     python3-gpg \
     python3-iso8601 \
     python3-pyasn1 \
+    python3-setproctitle \
     readline-devel \
     rng-tools \
     rpcgen \
index 5e7b1a11d7a7220cb0f9e60f0df145cfa2e3c160..9f224e86c36858cbb7ffc5e26b3d005ade4eb62e 100644 (file)
@@ -76,6 +76,7 @@ packages:
   - python3-gpg
   - python3-iso8601
   - python3-pyasn1
+  - python3-setproctitle
   - readline-devel
   - rng-tools
   - rpcgen
index e2d23c7b2163e1c72ae51fc94445c04817c5ac48..ab9b2e523709c5eb7b9e8767044a48bcfda69ab9 100755 (executable)
@@ -90,6 +90,7 @@ zypper --non-interactive install \
     python3-gpg \
     python3-iso8601 \
     python3-pyasn1 \
+    python3-setproctitle \
     readline-devel \
     rng-tools \
     rpcgen \
index f68b06394a99af34a1198e4d5d82631abec22c0f..8a65ed8c688cf116a2202a9c0181350ee73bfe65 100644 (file)
@@ -78,6 +78,7 @@ packages:
   - python3-gpg
   - python3-iso8601
   - python3-pyasn1
+  - python3-setproctitle
   - readline-devel
   - rng-tools
   - rpcgen
index ab66f0884483d2d639c9078f8585c66e967ef8d1..acb9d4a427cdf3703d2ddc1e175156791aff75fc 100755 (executable)
@@ -91,6 +91,7 @@ apt-get -y install \
     python3-matplotlib \
     python3-pexpect \
     python3-pyasn1 \
+    python3-setproctitle \
     rng-tools \
     rsync \
     sed \
index d0a773558b4057e59088235a292bee711eb0cb47..33302f64a4b75ad45b0ecde14adda57ea9d6d1cf 100644 (file)
@@ -80,6 +80,7 @@ packages:
   - python3-matplotlib
   - python3-pexpect
   - python3-pyasn1
+  - python3-setproctitle
   - rng-tools
   - rsync
   - sed
index 013f289d88074d75fe4e9fc5a5e956229ed6cbf8..7f42512c2b8fa0d97496e4da8afeafafd8c91849 100755 (executable)
@@ -93,6 +93,7 @@ apt-get -y install \
     python3-matplotlib \
     python3-pexpect \
     python3-pyasn1 \
+    python3-setproctitle \
     rng-tools \
     rsync \
     sed \
index 2ba03c496afb7d62f13c5e841904d001e9074eaf..4711b7ce996668fd4f34ba9ae954462d2993708b 100644 (file)
@@ -82,6 +82,7 @@ packages:
   - python3-matplotlib
   - python3-pexpect
   - python3-pyasn1
+  - python3-setproctitle
   - rng-tools
   - rsync
   - sed
index 013f289d88074d75fe4e9fc5a5e956229ed6cbf8..7f42512c2b8fa0d97496e4da8afeafafd8c91849 100755 (executable)
@@ -93,6 +93,7 @@ apt-get -y install \
     python3-matplotlib \
     python3-pexpect \
     python3-pyasn1 \
+    python3-setproctitle \
     rng-tools \
     rsync \
     sed \
index 2ba03c496afb7d62f13c5e841904d001e9074eaf..4711b7ce996668fd4f34ba9ae954462d2993708b 100644 (file)
@@ -82,6 +82,7 @@ packages:
   - python3-matplotlib
   - python3-pexpect
   - python3-pyasn1
+  - python3-setproctitle
   - rng-tools
   - rsync
   - sed
index 816528d3b0e7b954d8fa8c6035c0edae35878e50..46493c16eb09165d99005ecc4ce79e245a4042f4 100644 (file)
@@ -1 +1 @@
-d4867986881a9601c4620baf9a3bf28f5d1d1343
+42ecbfbf716fa85ce251a955de72a92af26fc7b2
diff --git a/python/samba/tests/cred_opt.py b/python/samba/tests/cred_opt.py
new file mode 100644 (file)
index 0000000..91ca680
--- /dev/null
@@ -0,0 +1,50 @@
+# Unix SMB/CIFS implementation.
+# Copyright (C) David Mulder <dmulder@suse.com> 2019
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+
+"""Tests for cred option parsing.
+
+"""
+
+import optparse
+from samba.getopt import CredentialsOptions
+import samba.tests
+import setproctitle
+import sys
+
+password_opt = '--password=super_secret_password'
+clear_password_opt = '--password=xxx'
+
+class CredentialsOptionsTests(samba.tests.TestCase):
+
+    def setUp(self):
+        super(samba.tests.TestCase, self).setUp()
+        self.old_proctitle = setproctitle.getproctitle()
+        setproctitle.setproctitle('%s %s' % (self.old_proctitle, password_opt))
+        sys.argv.append(password_opt)
+
+    def test_clear_proctitle_password(self):
+        parser = optparse.OptionParser()
+        credopts = CredentialsOptions(parser)
+        parser.add_option_group(credopts)
+        (opts, args) = parser.parse_args()
+        self.assertNotIn(password_opt, setproctitle.getproctitle())
+        self.assertIn(clear_password_opt, setproctitle.getproctitle())
+
+    def tearDown(self):
+        super(samba.tests.TestCase, self).tearDown()
+        setproctitle.setproctitle(self.old_proctitle)
+        sys.argv.pop()
index 9772fe8f8f1acde6efe8e305664ef18b1ecfbb7d..381586eb868ccb54ddda06a4c22793c45fc1899f 100644 (file)
@@ -65,6 +65,7 @@ planpythontestsuite("none", "samba.tests.credentials")
 planpythontestsuite("none", "samba.tests.registry")
 planpythontestsuite("ad_dc_ntvfs:local", "samba.tests.auth")
 planpythontestsuite("none", "samba.tests.get_opt")
+planpythontestsuite("none", "samba.tests.cred_opt")
 planpythontestsuite("none", "samba.tests.security")
 planpythontestsuite("none", "samba.tests.dcerpc.misc")
 planpythontestsuite("none", "samba.tests.dcerpc.integer")