s4-server: move the creation of the IPC$ share into ntvfs
authorAndrew Tridgell <tridge@samba.org>
Wed, 10 Nov 2010 23:35:38 +0000 (10:35 +1100)
committerAndrew Tridgell <tridge@samba.org>
Thu, 11 Nov 2010 02:57:04 +0000 (02:57 +0000)
the IPC$ share is only used by the ntvfs backends, and doesn't need to
be created on every load of smb.conf. This fixes a problem with
testparm showing the ipc$ share when it isn't defined in smb.conf.

This also removes the admin$ share, which really shouldn't be on by
default. The admin$ share is used for remote software installation,
and normally exposes the c:\windows directory on a windows
server. That makes no sense on Samba. If for some reason a admin$
share is needed, then the admin can create one as usual. Exposing /tmp
via admin$ by default seems like a bad idea.

Pair-Programmed-With: Andrew Bartlett <abartlet@samba.org>

source4/ntvfs/ntvfs_base.c
source4/param/loadparm.c

index d8d73e95fe43c903a7448a0d91c4d1b702a4f92b..1b1a53361bedc8b9f69df7f39d1450ea59b0b860 100644 (file)
@@ -200,6 +200,30 @@ NTSTATUS ntvfs_init_connection(TALLOC_CTX *mem_ctx, struct share_config *scfg, e
        return NT_STATUS_OK;
 }
 
+/*
+  adds the IPC$ share, needed for RPC calls
+ */
+static NTSTATUS ntvfs_add_ipc_share(struct loadparm_context *lp_ctx)
+{
+       struct loadparm_service *ipc;
+
+       if (lpcfg_service(lp_ctx, "IPC$")) {
+               /* it has already been defined in smb.conf or elsewhere */
+               return NT_STATUS_OK;
+       }
+
+       ipc = lpcfg_add_service(lp_ctx, NULL, "IPC$");
+       NT_STATUS_HAVE_NO_MEMORY(ipc);
+
+       lpcfg_do_service_parameter(lp_ctx, ipc, "comment", "IPC Service");
+       lpcfg_do_service_parameter(lp_ctx, ipc, "path", "/dev/null");
+       lpcfg_do_service_parameter(lp_ctx, ipc, "ntvfs handler", "default");
+       lpcfg_do_service_parameter(lp_ctx, ipc, "browseable", "No");
+       lpcfg_do_service_parameter(lp_ctx, ipc, "fstype", "IPC");
+
+       return NT_STATUS_OK;
+}
+
 NTSTATUS ntvfs_init(struct loadparm_context *lp_ctx)
 {
        static bool initialized = false;
@@ -217,6 +241,8 @@ NTSTATUS ntvfs_init(struct loadparm_context *lp_ctx)
        run_init_functions(shared_init);
 
        talloc_free(shared_init);
+
+       ntvfs_add_ipc_share(lp_ctx);
        
        return NT_STATUS_OK;
 }
index 69dead77a3baefdef425f0ecf4d7df27c3f403c7..c85126ffaec16da89788a96b5ab108df035fa539 100644 (file)
@@ -1142,39 +1142,6 @@ bool lpcfg_add_home(struct loadparm_context *lp_ctx,
        return true;
 }
 
-/**
- * Add the IPC service.
- */
-
-static bool lpcfg_add_hidden(struct loadparm_context *lp_ctx, const char *name,
-                            const char *fstype)
-{
-       struct loadparm_service *service = lpcfg_add_service(lp_ctx, lp_ctx->sDefault, name);
-
-       if (service == NULL)
-               return false;
-
-       string_set(service, &service->szPath, tmpdir());
-
-       service->comment = talloc_asprintf(service, "%s Service (%s)",
-                               fstype, lp_ctx->globals->szServerString);
-       string_set(service, &service->fstype, fstype);
-       service->iMaxConnections = -1;
-       service->bAvailable = true;
-       service->bRead_only = true;
-       service->bPrint_ok = false;
-       service->bBrowseable = false;
-
-       if (strcasecmp(fstype, "IPC") == 0) {
-               lpcfg_do_service_parameter(lp_ctx, service, "ntvfs handler",
-                                       "default");
-       }
-
-       DEBUG(3, ("adding hidden service %s\n", name));
-
-       return true;
-}
-
 /**
  * Add a new printer service, with defaults coming from service iFrom.
  */
@@ -2501,9 +2468,6 @@ static bool lpcfg_update(struct loadparm_context *lp_ctx)
 {
        lpcfg_add_auto_services(lp_ctx, lpcfg_auto_services(lp_ctx));
 
-       lpcfg_add_hidden(lp_ctx, "IPC$", "IPC");
-       lpcfg_add_hidden(lp_ctx, "ADMIN$", "DISK");
-
        if (!lp_ctx->globals->szWINSservers && lp_ctx->globals->bWINSsupport) {
                lpcfg_do_global_parameter(lp_ctx, "wins server", "127.0.0.1");
        }