Revert "pwrap: Fix pso_copy to work with libpam.so.0.84.2"
authorAndreas Schneider <asn@samba.org>
Tue, 24 Mar 2020 06:05:28 +0000 (07:05 +0100)
committerAndreas Schneider <asn@samba.org>
Tue, 24 Mar 2020 07:38:02 +0000 (08:38 +0100)
This reverts commit 047e9fb616d21e202add9f16347cea2084444104.

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
src/pam_wrapper.c

index 3e5ebbe6c44fff2ba60d1062ab0d6a1730f801bf..357e09c4ea0efee38e0e89a3ce8d628fe52e7447 100644 (file)
@@ -937,14 +937,13 @@ static void pwrap_init(void)
 
 static int pso_copy(const char *src, const char *dst, const char *pdir, mode_t mode)
 {
-#define PSO_COPY_READ_SIZE 16
+#define PSO_COPY_READ_SIZE 9
        int srcfd = -1;
        int dstfd = -1;
        int rc = -1;
        ssize_t bread, bwritten;
        struct stat sb;
        char buf[PSO_COPY_READ_SIZE + 1];
-       size_t pso_copy_read_size = PSO_COPY_READ_SIZE;
        int cmp;
        size_t to_read;
        bool found_slash;
@@ -991,35 +990,13 @@ static int pso_copy(const char *src, const char *dst, const char *pdir, mode_t m
                to_read = 1;
                if (!found_slash && buf[0] == '/') {
                        found_slash = true;
-                       to_read = pso_copy_read_size;
+                       to_read = PSO_COPY_READ_SIZE;
                }
 
                if (found_slash && bread == PSO_COPY_READ_SIZE) {
-                       cmp = memcmp(buf, "usr/etc/pam.d/%s", 16);
+                       cmp = memcmp(buf, "etc/pam.d", 9);
                        if (cmp == 0) {
-                               char tmp[16] = {0};
-
-                               snprintf(tmp, sizeof(tmp), "%s/%%s", pdir + 1);
-
-                               memcpy(buf, tmp, 12);
-                               memset(&buf[12], '\0', 4);
-
-                               /*
-                                * If we found this string, we need to reduce
-                                * the read size to not miss, the next one.
-                                */
-                               pso_copy_read_size = 13;
-                       } else {
-                               cmp = memcmp(buf, "usr/etc/pam.d", 13);
-                               if (cmp == 0) {
-                                       memcpy(buf, pdir + 1, 9);
-                                       memset(&buf[9], '\0', 4);
-                               } else {
-                                       cmp = memcmp(buf, "etc/pam.d", 9);
-                                       if (cmp == 0) {
-                                               memcpy(buf, pdir + 1, 9);
-                                       }
-                               }
+                               memcpy(buf, pdir + 1, 9);
                        }
                        found_slash = false;
                }