diff options
author | Andrew Tridgell <tridge@samba.org> | 2004-05-04 06:07:52 +0000 |
---|---|---|
committer | Gerald (Jerry) Carter <jerry@samba.org> | 2007-10-10 12:51:44 -0500 |
commit | 21e6b1531b4e656af5962fdbeb671350f653fc26 (patch) | |
tree | da19a7700ea239f83782eb8f3ea5836945b145c3 /source4/rpc_server/wkssvc | |
parent | 73744d1ed6ba3b2d003eb029b9e9a0296ce895e6 (diff) | |
download | samba-21e6b1531b4e656af5962fdbeb671350f653fc26.tar.gz samba-21e6b1531b4e656af5962fdbeb671350f653fc26.tar.bz2 samba-21e6b1531b4e656af5962fdbeb671350f653fc26.zip |
r464: a big improvement to the API for writing server-side RPC
servers. Previously the server pipe code needed to return the RPC
level status (nearly always "OK") and separately set the function call
return using r->out.result. All the programmers writing servers
(metze, jelmer and me) were often getting this wrong, by doing things
like "return NT_STATUS_NO_MEMORY" which was really quite meaningless
as there is no code like that at the dcerpc level.
I have now modified pidl to generate the necessary boilerplate so that
just returning the status you want from the function will work. So for
a NTSTATUS function you return NT_STATUS_XXX and from a WERROR
function you return WERR_XXX. If you really want to generate a DCERPC
level fault rather than just a return value in your function then you
should use the DCESRV_FAULT() macro which will correctly generate a
fault for you.
As a side effect, this also adds automatic type checking of all of our
server side rpc functions, which was impossible with the old API. When
I changed the API I found and fixed quite a few functions with the
wrong type information, so this is definately useful.
I have also changed the server side template generation to generate a
DCERPC "operation range error" by default when you have not yet filled
in a server side function. This allows us to correctly implement
functions in any order in our rpc pipe servers and give the client the
right information about the fault.
(This used to be commit a4df5c7cf88891a78d82c8d6d7f058d8485e73f0)
Diffstat (limited to 'source4/rpc_server/wkssvc')
-rw-r--r-- | source4/rpc_server/wkssvc/dcesrv_wkssvc.c | 148 |
1 files changed, 70 insertions, 78 deletions
diff --git a/source4/rpc_server/wkssvc/dcesrv_wkssvc.c b/source4/rpc_server/wkssvc/dcesrv_wkssvc.c index 9a94c0c5da..973877d8f8 100644 --- a/source4/rpc_server/wkssvc/dcesrv_wkssvc.c +++ b/source4/rpc_server/wkssvc/dcesrv_wkssvc.c @@ -26,11 +26,10 @@ /* wkssvc_NetWkstaGetInfo */ -static NTSTATUS wkssvc_NetWkstaGetInfo(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, +static WERROR wkssvc_NetWkstaGetInfo(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct wkssvc_NetWkstaGetInfo *r) { struct dcesrv_context *dce_ctx = dce_call->conn->dce_ctx; - r->out.result = WERR_OK; /* NOTE: win2k3 ignores r->in.server_name completly so we do --metze */ @@ -61,343 +60,336 @@ static NTSTATUS wkssvc_NetWkstaGetInfo(struct dcesrv_call_state *dce_call, TALLO case 102: { r->out.info.info102 = NULL; - r->out.result = WERR_ACCESS_DENIED; - break; + return WERR_ACCESS_DENIED; } case 502: { r->out.info.info502 = NULL; - r->out.result = WERR_ACCESS_DENIED; - break; - } - default: { - r->out.result = WERR_UNKNOWN_LEVEL; - break; + return WERR_ACCESS_DENIED; } + default: + return WERR_UNKNOWN_LEVEL; } - return NT_STATUS_OK; + return WERR_OK; } /* wkssvc_NetWkstaSetInfo */ -static NTSTATUS wkssvc_NetWkstaSetInfo(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, +static WERROR wkssvc_NetWkstaSetInfo(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct wkssvc_NetWkstaSetInfo *r) { - return NT_STATUS_NOT_IMPLEMENTED; + return WERR_NOT_SUPPORTED; } /* WKSSVC_NETRWKSTAUSERENUM */ -static NTSTATUS WKSSVC_NETRWKSTAUSERENUM(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, +static WERROR WKSSVC_NETRWKSTAUSERENUM(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct WKSSVC_NETRWKSTAUSERENUM *r) { - return NT_STATUS_NOT_IMPLEMENTED; + return WERR_NOT_SUPPORTED; } /* WKSSVC_NETRWKSTAUSERGETINFO */ -static NTSTATUS WKSSVC_NETRWKSTAUSERGETINFO(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, +static WERROR WKSSVC_NETRWKSTAUSERGETINFO(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct WKSSVC_NETRWKSTAUSERGETINFO *r) { - return NT_STATUS_NOT_IMPLEMENTED; + return WERR_NOT_SUPPORTED; } /* WKSSVC_NETRWKSTAUSERSETINFO */ -static NTSTATUS WKSSVC_NETRWKSTAUSERSETINFO(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, +static WERROR WKSSVC_NETRWKSTAUSERSETINFO(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct WKSSVC_NETRWKSTAUSERSETINFO *r) { - return NT_STATUS_NOT_IMPLEMENTED; + return WERR_NOT_SUPPORTED; } /* wkssvc_NetWkstaTransportEnum */ -static NTSTATUS wkssvc_NetWkstaTransportEnum(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, +static WERROR wkssvc_NetWkstaTransportEnum(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct wkssvc_NetWkstaTransportEnum *r) { r->out.level = r->in.level; r->out.totalentries = 0; r->out.resume_handle = NULL; - r->out.result = WERR_OK; switch (r->in.level) { - case 0: { + case 0: r->out.ctr.ctr0 = talloc_p(mem_ctx, struct wkssvc_NetWkstaTransportCtr0); WERR_TALLOC_CHECK(r->out.ctr.ctr0); r->out.ctr.ctr0->count = 0; r->out.ctr.ctr0->array = NULL; - r->out.result = WERR_NOT_SUPPORTED; - break; - } + return WERR_NOT_SUPPORTED; + default: - r->out.result = WERR_UNKNOWN_LEVEL; - break; + return WERR_UNKNOWN_LEVEL; } - return NT_STATUS_OK; + return WERR_OK; } /* WKSSVC_NETRWKSTATRANSPORTADD */ -static NTSTATUS WKSSVC_NETRWKSTATRANSPORTADD(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, +static WERROR WKSSVC_NETRWKSTATRANSPORTADD(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct WKSSVC_NETRWKSTATRANSPORTADD *r) { - return NT_STATUS_NOT_IMPLEMENTED; + return WERR_NOT_SUPPORTED; } /* WKSSVC_NETRWKSTATRANSPORTDEL */ -static NTSTATUS WKSSVC_NETRWKSTATRANSPORTDEL(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, +static WERROR WKSSVC_NETRWKSTATRANSPORTDEL(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct WKSSVC_NETRWKSTATRANSPORTDEL *r) { - return NT_STATUS_NOT_IMPLEMENTED; + return WERR_NOT_SUPPORTED; } /* WKSSVC_NETRUSEADD */ -static NTSTATUS WKSSVC_NETRUSEADD(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, +static WERROR WKSSVC_NETRUSEADD(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct WKSSVC_NETRUSEADD *r) { - return NT_STATUS_NOT_IMPLEMENTED; + return WERR_NOT_SUPPORTED; } /* WKSSVC_NETRUSEGETINFO */ -static NTSTATUS WKSSVC_NETRUSEGETINFO(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, +static WERROR WKSSVC_NETRUSEGETINFO(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct WKSSVC_NETRUSEGETINFO *r) { - return NT_STATUS_NOT_IMPLEMENTED; + return WERR_NOT_SUPPORTED; } /* WKSSVC_NETRUSEDEL */ -static NTSTATUS WKSSVC_NETRUSEDEL(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, +static WERROR WKSSVC_NETRUSEDEL(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct WKSSVC_NETRUSEDEL *r) { - return NT_STATUS_NOT_IMPLEMENTED; + return WERR_NOT_SUPPORTED; } /* WKSSVC_NETRUSEENUM */ -static NTSTATUS WKSSVC_NETRUSEENUM(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, +static WERROR WKSSVC_NETRUSEENUM(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct WKSSVC_NETRUSEENUM *r) { - return NT_STATUS_NOT_IMPLEMENTED; + return WERR_NOT_SUPPORTED; } /* WKSSVC_NETRMESSAGEBUFFERSEND */ -static NTSTATUS WKSSVC_NETRMESSAGEBUFFERSEND(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, +static WERROR WKSSVC_NETRMESSAGEBUFFERSEND(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct WKSSVC_NETRMESSAGEBUFFERSEND *r) { - return NT_STATUS_NOT_IMPLEMENTED; + return WERR_NOT_SUPPORTED; } /* WKSSVC_NETRWORKSTATIONSTATISTICSGET */ -static NTSTATUS WKSSVC_NETRWORKSTATIONSTATISTICSGET(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, +static WERROR WKSSVC_NETRWORKSTATIONSTATISTICSGET(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct WKSSVC_NETRWORKSTATIONSTATISTICSGET *r) { - return NT_STATUS_NOT_IMPLEMENTED; + return WERR_NOT_SUPPORTED; } /* WKSSVC_NETRLOGONDOMAINNAMEADD */ -static NTSTATUS WKSSVC_NETRLOGONDOMAINNAMEADD(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, +static WERROR WKSSVC_NETRLOGONDOMAINNAMEADD(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct WKSSVC_NETRLOGONDOMAINNAMEADD *r) { - return NT_STATUS_NOT_IMPLEMENTED; + return WERR_NOT_SUPPORTED; } /* WKSSVC_NETRLOGONDOMAINNAMEDEL */ -static NTSTATUS WKSSVC_NETRLOGONDOMAINNAMEDEL(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, +static WERROR WKSSVC_NETRLOGONDOMAINNAMEDEL(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct WKSSVC_NETRLOGONDOMAINNAMEDEL *r) { - return NT_STATUS_NOT_IMPLEMENTED; + return WERR_NOT_SUPPORTED; } /* WKSSVC_NETRJOINDOMAIN */ -static NTSTATUS WKSSVC_NETRJOINDOMAIN(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, +static WERROR WKSSVC_NETRJOINDOMAIN(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct WKSSVC_NETRJOINDOMAIN *r) { - return NT_STATUS_NOT_IMPLEMENTED; + return WERR_NOT_SUPPORTED; } /* WKSSVC_NETRUNJOINDOMAIN */ -static NTSTATUS WKSSVC_NETRUNJOINDOMAIN(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, +static WERROR WKSSVC_NETRUNJOINDOMAIN(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct WKSSVC_NETRUNJOINDOMAIN *r) { - return NT_STATUS_NOT_IMPLEMENTED; + return WERR_NOT_SUPPORTED; } /* WKSSVC_NETRRENAMEMACHINEINDOMAIN */ -static NTSTATUS WKSSVC_NETRRENAMEMACHINEINDOMAIN(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, +static WERROR WKSSVC_NETRRENAMEMACHINEINDOMAIN(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct WKSSVC_NETRRENAMEMACHINEINDOMAIN *r) { - return NT_STATUS_NOT_IMPLEMENTED; + return WERR_NOT_SUPPORTED; } /* WKSSVC_NETRVALIDATENAME */ -static NTSTATUS WKSSVC_NETRVALIDATENAME(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, +static WERROR WKSSVC_NETRVALIDATENAME(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct WKSSVC_NETRVALIDATENAME *r) { - return NT_STATUS_NOT_IMPLEMENTED; + return WERR_NOT_SUPPORTED; } /* WKSSVC_NETRGETJOININFORMATION */ -static NTSTATUS WKSSVC_NETRGETJOININFORMATION(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, +static WERROR WKSSVC_NETRGETJOININFORMATION(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct WKSSVC_NETRGETJOININFORMATION *r) { - return NT_STATUS_NOT_IMPLEMENTED; + return WERR_NOT_SUPPORTED; } /* WKSSVC_NETRGETJOINABLEOUS */ -static NTSTATUS WKSSVC_NETRGETJOINABLEOUS(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, +static WERROR WKSSVC_NETRGETJOINABLEOUS(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct WKSSVC_NETRGETJOINABLEOUS *r) { - return NT_STATUS_NOT_IMPLEMENTED; + return WERR_NOT_SUPPORTED; } /* WKSSVC_NETRJOINDOMAIN2 */ -static NTSTATUS WKSSVC_NETRJOINDOMAIN2(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, +static WERROR WKSSVC_NETRJOINDOMAIN2(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct WKSSVC_NETRJOINDOMAIN2 *r) { - return NT_STATUS_NOT_IMPLEMENTED; + return WERR_NOT_SUPPORTED; } /* WKSSVC_NETRUNJOINDOMAIN2 */ -static NTSTATUS WKSSVC_NETRUNJOINDOMAIN2(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, +static WERROR WKSSVC_NETRUNJOINDOMAIN2(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct WKSSVC_NETRUNJOINDOMAIN2 *r) { - return NT_STATUS_NOT_IMPLEMENTED; + return WERR_NOT_SUPPORTED; } /* WKSSVC_NETRRENAMEMACHINEINDOMAIN2 */ -static NTSTATUS WKSSVC_NETRRENAMEMACHINEINDOMAIN2(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, +static WERROR WKSSVC_NETRRENAMEMACHINEINDOMAIN2(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct WKSSVC_NETRRENAMEMACHINEINDOMAIN2 *r) { - return NT_STATUS_NOT_IMPLEMENTED; + return WERR_NOT_SUPPORTED; } /* WKSSVC_NETRVALIDATENAME2 */ -static NTSTATUS WKSSVC_NETRVALIDATENAME2(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, +static WERROR WKSSVC_NETRVALIDATENAME2(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct WKSSVC_NETRVALIDATENAME2 *r) { - return NT_STATUS_NOT_IMPLEMENTED; + return WERR_NOT_SUPPORTED; } /* WKSSVC_NETRGETJOINABLEOUS2 */ -static NTSTATUS WKSSVC_NETRGETJOINABLEOUS2(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, +static WERROR WKSSVC_NETRGETJOINABLEOUS2(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct WKSSVC_NETRGETJOINABLEOUS2 *r) { - return NT_STATUS_NOT_IMPLEMENTED; + return WERR_NOT_SUPPORTED; } /* WKSSVC_NETRADDALTERNATECOMPUTERNAME */ -static NTSTATUS WKSSVC_NETRADDALTERNATECOMPUTERNAME(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, +static WERROR WKSSVC_NETRADDALTERNATECOMPUTERNAME(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct WKSSVC_NETRADDALTERNATECOMPUTERNAME *r) { - return NT_STATUS_NOT_IMPLEMENTED; + return WERR_NOT_SUPPORTED; } /* WKSSVC_NETRREMOVEALTERNATECOMPUTERNAME */ -static NTSTATUS WKSSVC_NETRREMOVEALTERNATECOMPUTERNAME(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, +static WERROR WKSSVC_NETRREMOVEALTERNATECOMPUTERNAME(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct WKSSVC_NETRREMOVEALTERNATECOMPUTERNAME *r) { - return NT_STATUS_NOT_IMPLEMENTED; + return WERR_NOT_SUPPORTED; } /* WKSSVC_NETRSETPRIMARYCOMPUTERNAME */ -static NTSTATUS WKSSVC_NETRSETPRIMARYCOMPUTERNAME(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, +static WERROR WKSSVC_NETRSETPRIMARYCOMPUTERNAME(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct WKSSVC_NETRSETPRIMARYCOMPUTERNAME *r) { - return NT_STATUS_NOT_IMPLEMENTED; + return WERR_NOT_SUPPORTED; } /* WKSSVC_NETRENUMERATECOMPUTERNAMES */ -static NTSTATUS WKSSVC_NETRENUMERATECOMPUTERNAMES(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, +static WERROR WKSSVC_NETRENUMERATECOMPUTERNAMES(struct dcesrv_call_state *dce_call, TALLOC_CTX *mem_ctx, struct WKSSVC_NETRENUMERATECOMPUTERNAMES *r) { - return NT_STATUS_NOT_IMPLEMENTED; + return WERR_NOT_SUPPORTED; } |