s3:smbd: Make sure we do not export "/" (root) as home dir
authorAndreas Schneider <asn@samba.org>
Thu, 22 Nov 2018 17:23:24 +0000 (18:23 +0100)
committerJeremy Allison <jra@samba.org>
Wed, 5 Dec 2018 00:38:14 +0000 (01:38 +0100)
If "/" (root) is returned as the home directory, prevent exporting it.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=13699

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Ralph Böhme <slow@samba.org>
source3/param/service.c
source3/smbd/password.c

index b21be6093d492f734777d4a91bbdec14ba5f1cd9..22f46f0889482f58a5130c6ca0d2668a699ae57b 100644 (file)
@@ -149,7 +149,11 @@ int find_service(TALLOC_CTX *ctx, const char *service_in, char **p_service_out)
                DEBUG(3,("checking for home directory %s gave %s\n",*p_service_out,
                        phome_dir?phome_dir:"(NULL)"));
 
-               iService = add_home_service(*p_service_out,*p_service_out /* 'username' */, phome_dir);
+               if (!strequal(phome_dir, "/")) {
+                       iService = add_home_service(*p_service_out,
+                                                   *p_service_out, /* username */
+                                                   phome_dir);
+               }
        }
 
        /* If we still don't have a service, attempt to add it as a printer. */
index f472bda2c70e03eddbafc22e8259198194bcdc0c..0576d2563ebaf3199acce8d5b2178f950f10156e 100644 (file)
@@ -129,6 +129,13 @@ int register_homes_share(const char *username)
                return -1;
        }
 
+       if (strequal(pwd->pw_dir, "/")) {
+               DBG_NOTICE("Invalid home directory defined for user '%s'\n",
+                          username);
+               TALLOC_FREE(pwd);
+               return -1;
+       }
+
        DEBUG(3, ("Adding homes service for user '%s' using home directory: "
                  "'%s'\n", username, pwd->pw_dir));