Use struct for server versions.
authorJelmer Vernooij <jelmer@samba.org>
Sat, 1 Nov 2008 14:50:52 +0000 (15:50 +0100)
committerJelmer Vernooij <jelmer@samba.org>
Sat, 1 Nov 2008 14:50:52 +0000 (15:50 +0100)
source4/ntptr/simple_ldb/ntptr_simple_ldb.c
source4/rpc_server/common/common.h
source4/rpc_server/common/server_info.c
source4/rpc_server/srvsvc/dcesrv_srvsvc.c
source4/rpc_server/wkssvc/dcesrv_wkssvc.c

index 1636aa91e78a7ff90662ac5ffd1fa450ccdf1046..e67dd01158d9cdf376fd5748d1cd0bc671e35257 100644 (file)
@@ -125,6 +125,7 @@ static WERROR sptr_OpenPrintServer(struct ntptr_context *ntptr, TALLOC_CTX *mem_
 static WERROR sptr_GetPrintServerData(struct ntptr_GenericHandle *server, TALLOC_CTX *mem_ctx,
                                      struct spoolss_GetPrinterData *r)
 {
+       struct dcerpc_server_info *server_info = lp_dcerpc_server_info(mem_ctx, server->ntptr->lp_ctx);
        if (strcmp("W3SvcInstalled", r->in.value_name) == 0) {
                r->out.type             = SPOOLSS_PRINTER_DATA_TYPE_UINT32;
                r->out.data.value       = 0;
@@ -170,9 +171,9 @@ static WERROR sptr_GetPrintServerData(struct ntptr_GenericHandle *server, TALLOC
                enum ndr_err_code ndr_err;
                struct spoolss_OSVersion os;
 
-               os.major                = dcesrv_common_get_version_major(mem_ctx, server->ntptr->lp_ctx);
-               os.minor                = dcesrv_common_get_version_minor(mem_ctx, server->ntptr->lp_ctx);
-               os.build                = dcesrv_common_get_version_build(mem_ctx, server->ntptr->lp_ctx);
+               os.major                = server_info->version_major;
+               os.minor                = server_info->version_minor;
+               os.build                = server_info->version_build;
                os.extra_string         = "";
 
                ndr_err = ndr_push_struct_blob(&blob, mem_ctx, lp_iconv_convenience(server->ntptr->lp_ctx), &os, (ndr_push_flags_fn_t)ndr_push_spoolss_OSVersion);
@@ -188,9 +189,9 @@ static WERROR sptr_GetPrintServerData(struct ntptr_GenericHandle *server, TALLOC
                enum ndr_err_code ndr_err;
                struct spoolss_OSVersionEx os_ex;
 
-               os_ex.major             = dcesrv_common_get_version_major(mem_ctx, server->ntptr->lp_ctx);
-               os_ex.minor             = dcesrv_common_get_version_minor(mem_ctx, server->ntptr->lp_ctx);
-               os_ex.build             = dcesrv_common_get_version_build(mem_ctx, server->ntptr->lp_ctx);
+               os_ex.major             = server_info->version_major;
+               os_ex.minor             = server_info->version_minor;
+               os_ex.build             = server_info->version_build;
                os_ex.extra_string              = "";
                os_ex.unknown2          = 0;
                os_ex.unknown3          = 0;
index af2d96cb3e3794ed0d90fee9896ace7ad602943a..aacd4603882f0dcbf5c80f8c434c903c0597b5c9 100644 (file)
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
+#ifndef _DCERPC_SERVER_COMMON_H_
+#define _DCERPC_SERVER_COMMON_H_
+
 struct share_config;
 struct dcesrv_context;
 enum srvsvc_ShareType dcesrv_common_get_share_type(TALLOC_CTX *mem_ctx, struct dcesrv_context *dce_ctx, struct share_config *scfg);
 enum srvsvc_PlatformId dcesrv_common_get_platform_id(TALLOC_CTX *mem_ctx, struct dcesrv_context *dce_ctx);
-const char *dcesrv_common_get_domain_name(TALLOC_CTX *mem_ctx, struct dcesrv_context *dce_ctx);
 const char *dcesrv_common_get_lan_root(TALLOC_CTX *mem_ctx, struct dcesrv_context *dce_ctx);
 const char *dcesrv_common_get_server_name(TALLOC_CTX *mem_ctx, struct dcesrv_context *dce_ctx, const char *server_unc);
-uint32_t dcesrv_common_get_version_major(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx);
-uint32_t dcesrv_common_get_version_minor(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx);
-uint32_t dcesrv_common_get_version_build(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx);
 uint32_t dcesrv_common_get_share_permissions(TALLOC_CTX *mem_ctx, struct dcesrv_context *dce_ctx, struct share_config *scfg);
 uint32_t dcesrv_common_get_share_current_users(TALLOC_CTX *mem_ctx, struct dcesrv_context *dce_ctx, struct share_config *scfg);
 const char *dcesrv_common_get_share_path(TALLOC_CTX *mem_ctx, struct dcesrv_context *dce_ctx, struct share_config *scfg);
 
 struct dcesrv_context;
+
+struct dcerpc_server_info { 
+       const char *domain_name;
+       uint32_t version_major;
+       uint32_t version_minor;
+       uint32_t version_build;
+};
+
+#endif /* _DCERPC_SERVER_COMMON_H_ */
index ab04b3af1f7496cc5c474bb8d5a5b0a2ef5703e2..59cdd642bbb18c00f2ba3f1fcec9afe62d5fbae7 100644 (file)
@@ -60,28 +60,6 @@ const char *dcesrv_common_get_server_name(TALLOC_CTX *mem_ctx, struct dcesrv_con
        return talloc_strdup(mem_ctx, p);
 }
 
-const char *dcesrv_common_get_domain_name(TALLOC_CTX *mem_ctx, struct dcesrv_context *dce_ctx)
-{
-       return talloc_strdup(mem_ctx, lp_workgroup(dce_ctx->lp_ctx));
-}
-
-/* This hardcoded value should go into a ldb database! */
-uint32_t dcesrv_common_get_version_major(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx)
-{
-       return lp_parm_int(lp_ctx, NULL, "server_info", "version_major", 5);
-}
-
-/* This hardcoded value should go into a ldb database! */
-uint32_t dcesrv_common_get_version_minor(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx)
-{
-       return lp_parm_int(lp_ctx, NULL, "server_info", "version_minor", 2);
-}
-
-/* This hardcoded value should go into a ldb database! */
-uint32_t dcesrv_common_get_version_build(TALLOC_CTX *mem_ctx, struct loadparm_context *lp_ctx)
-{
-       return lp_parm_int(lp_ctx, NULL, "server_info", "version_build", 3790);
-}
 
 /* This hardcoded value should go into a ldb database! */
 uint32_t dcesrv_common_get_server_type(TALLOC_CTX *mem_ctx, struct event_context *event_ctx, struct dcesrv_context *dce_ctx)
index b4e08896e5f2068568fecbf5ed4d8b343786f7bb..f33c49aa4e1eb3b713937414d5b042cb2b1d51d8 100644 (file)
@@ -1458,6 +1458,7 @@ static WERROR dcesrv_srvsvc_NetSrvGetInfo(struct dcesrv_call_state *dce_call, TA
                       struct srvsvc_NetSrvGetInfo *r)
 {
        struct dcesrv_context *dce_ctx = dce_call->conn->dce_ctx;
+       struct dcerpc_server_info *server_info = lp_dcerpc_server_info(mem_ctx, dce_ctx->lp_ctx);
 
        ZERO_STRUCTP(r->out.info);
 
@@ -1487,8 +1488,8 @@ static WERROR dcesrv_srvsvc_NetSrvGetInfo(struct dcesrv_call_state *dce_call, TA
                info101->server_name    = dcesrv_common_get_server_name(mem_ctx, dce_ctx, r->in.server_unc);
                W_ERROR_HAVE_NO_MEMORY(info101->server_name);
 
-               info101->version_major  = dcesrv_common_get_version_major(mem_ctx, dce_ctx->lp_ctx);
-               info101->version_minor  = dcesrv_common_get_version_minor(mem_ctx, dce_ctx->lp_ctx);
+               info101->version_major  = server_info->version_major;
+               info101->version_minor  = server_info->version_minor;
                info101->server_type    = dcesrv_common_get_server_type(mem_ctx, dce_call->event_ctx, dce_ctx);
                info101->comment        = talloc_strdup(mem_ctx, lp_serverstring(dce_ctx->lp_ctx));
                W_ERROR_HAVE_NO_MEMORY(info101->comment);
@@ -1507,8 +1508,8 @@ static WERROR dcesrv_srvsvc_NetSrvGetInfo(struct dcesrv_call_state *dce_call, TA
                info102->server_name    = dcesrv_common_get_server_name(mem_ctx, dce_ctx, r->in.server_unc);
                W_ERROR_HAVE_NO_MEMORY(info102->server_name);
 
-               info102->version_major  = dcesrv_common_get_version_major(mem_ctx, dce_ctx->lp_ctx);
-               info102->version_minor  = dcesrv_common_get_version_minor(mem_ctx, dce_ctx->lp_ctx);
+               info102->version_major  = server_info->version_major;
+               info102->version_minor  = server_info->version_minor;
                info102->server_type    = dcesrv_common_get_server_type(mem_ctx, dce_call->event_ctx, dce_ctx);
                info102->comment        = talloc_strdup(mem_ctx, lp_serverstring(dce_ctx->lp_ctx));
                W_ERROR_HAVE_NO_MEMORY(info102->comment);
index cbade288ca314bdea8231ae49a2885c5819add62..e23485aea9256bccfd28f1d4a29a975038749560 100644 (file)
@@ -23,6 +23,7 @@
 #include "rpc_server/dcerpc_server.h"
 #include "librpc/gen_ndr/ndr_wkssvc.h"
 #include "rpc_server/common/common.h"
+#include "param/param.h"
 
 /*
   wkssvc_NetWkstaGetInfo
@@ -31,6 +32,7 @@ static WERROR dcesrv_wkssvc_NetWkstaGetInfo(struct dcesrv_call_state *dce_call,
                       struct wkssvc_NetWkstaGetInfo *r)
 {
        struct dcesrv_context *dce_ctx = dce_call->conn->dce_ctx;
+       struct dcerpc_server_info *server_info = lp_dcerpc_server_info(mem_ctx, dce_ctx->lp_ctx);
 
        ZERO_STRUCT(r->out);
        r->out.info = talloc_zero(mem_ctx, union wkssvc_NetWkstaInfo);
@@ -49,10 +51,10 @@ static WERROR dcesrv_wkssvc_NetWkstaGetInfo(struct dcesrv_call_state *dce_call,
                info100->platform_id    = dcesrv_common_get_platform_id(mem_ctx, dce_ctx);
                info100->server_name    = dcesrv_common_get_server_name(mem_ctx, dce_ctx, NULL);
                W_ERROR_HAVE_NO_MEMORY(info100->server_name);
-               info100->domain_name    = dcesrv_common_get_domain_name(mem_ctx, dce_ctx);
+               info100->domain_name    = talloc_reference(mem_ctx, server_info->domain_name);
                W_ERROR_HAVE_NO_MEMORY(info100->domain_name);
-               info100->version_major  = dcesrv_common_get_version_major(mem_ctx, dce_ctx->lp_ctx);
-               info100->version_minor  = dcesrv_common_get_version_minor(mem_ctx, dce_ctx->lp_ctx);
+               info100->version_major  = server_info->version_major;
+               info100->version_minor  = server_info->version_minor;
 
                r->out.info->info100 = info100;
                return WERR_OK;
@@ -67,10 +69,10 @@ static WERROR dcesrv_wkssvc_NetWkstaGetInfo(struct dcesrv_call_state *dce_call,
                info101->platform_id    = dcesrv_common_get_platform_id(mem_ctx, dce_ctx);
                info101->server_name    = dcesrv_common_get_server_name(mem_ctx, dce_ctx, NULL);
                W_ERROR_HAVE_NO_MEMORY(info101->server_name);
-               info101->domain_name    = dcesrv_common_get_domain_name(mem_ctx, dce_ctx);
+               info101->domain_name    = talloc_reference(mem_ctx, server_info->domain_name);
                W_ERROR_HAVE_NO_MEMORY(info101->domain_name);
-               info101->version_major  = dcesrv_common_get_version_major(mem_ctx, dce_ctx->lp_ctx);
-               info101->version_minor  = dcesrv_common_get_version_minor(mem_ctx, dce_ctx->lp_ctx);
+               info101->version_major  = server_info->version_major;
+               info101->version_minor  = server_info->version_minor;
                info101->lan_root       = dcesrv_common_get_lan_root(mem_ctx, dce_ctx);
 
                r->out.info->info101 = info101;