mirror of
https://github.com/samba-team/samba.git
synced 2024-12-23 17:34:34 +03:00
s4-srvsvc: merge srvsvc_NetRemoteTOD from s3 idl.
Guenther
This commit is contained in:
parent
f61ce2fe41
commit
9fd82703d1
@ -30,6 +30,7 @@ static NTSTATUS libnet_RemoteTOD_srvsvc(struct libnet_context *ctx, TALLOC_CTX *
|
||||
NTSTATUS status;
|
||||
struct libnet_RpcConnect c;
|
||||
struct srvsvc_NetRemoteTOD tod;
|
||||
struct srvsvc_NetRemoteTODInfo *info = NULL;
|
||||
struct tm tm;
|
||||
|
||||
/* prepare connect to the SRVSVC pipe of a timeserver */
|
||||
@ -48,6 +49,7 @@ static NTSTATUS libnet_RemoteTOD_srvsvc(struct libnet_context *ctx, TALLOC_CTX *
|
||||
|
||||
/* prepare srvsvc_NetrRemoteTOD */
|
||||
tod.in.server_unc = talloc_asprintf(mem_ctx, "\\%s", c.in.name);
|
||||
tod.out.info = &info;
|
||||
|
||||
/* 2. try srvsvc_NetRemoteTOD */
|
||||
status = dcerpc_srvsvc_NetRemoteTOD(c.out.dcerpc_pipe, mem_ctx, &tod);
|
||||
@ -68,18 +70,18 @@ static NTSTATUS libnet_RemoteTOD_srvsvc(struct libnet_context *ctx, TALLOC_CTX *
|
||||
}
|
||||
|
||||
/* need to set the out parameters */
|
||||
tm.tm_sec = (int)tod.out.info->secs;
|
||||
tm.tm_min = (int)tod.out.info->mins;
|
||||
tm.tm_hour = (int)tod.out.info->hours;
|
||||
tm.tm_mday = (int)tod.out.info->day;
|
||||
tm.tm_mon = (int)tod.out.info->month -1;
|
||||
tm.tm_year = (int)tod.out.info->year - 1900;
|
||||
tm.tm_sec = (int)info->secs;
|
||||
tm.tm_min = (int)info->mins;
|
||||
tm.tm_hour = (int)info->hours;
|
||||
tm.tm_mday = (int)info->day;
|
||||
tm.tm_mon = (int)info->month -1;
|
||||
tm.tm_year = (int)info->year - 1900;
|
||||
tm.tm_wday = -1;
|
||||
tm.tm_yday = -1;
|
||||
tm.tm_isdst = -1;
|
||||
|
||||
r->srvsvc.out.time = timegm(&tm);
|
||||
r->srvsvc.out.time_zone = tod.out.info->timezone * 60;
|
||||
r->srvsvc.out.time_zone = info->timezone * 60;
|
||||
|
||||
goto disconnect;
|
||||
|
||||
|
@ -1326,7 +1326,7 @@ import "security.idl", "svcctl.idl";
|
||||
/* Function: 0x1c */
|
||||
WERROR srvsvc_NetRemoteTOD(
|
||||
[in,unique] [string,charset(UTF16)] uint16 *server_unc,
|
||||
[out,unique] srvsvc_NetRemoteTODInfo *info
|
||||
[out,ref] srvsvc_NetRemoteTODInfo **info
|
||||
);
|
||||
|
||||
/**************************/
|
||||
|
@ -1688,31 +1688,34 @@ static WERROR dcesrv_srvsvc_NetRemoteTOD(struct dcesrv_call_state *dce_call, TAL
|
||||
struct timeval tval;
|
||||
time_t t;
|
||||
struct tm tm;
|
||||
struct srvsvc_NetRemoteTODInfo *info;
|
||||
|
||||
r->out.info = talloc(mem_ctx, struct srvsvc_NetRemoteTODInfo);
|
||||
W_ERROR_HAVE_NO_MEMORY(r->out.info);
|
||||
info = talloc(mem_ctx, struct srvsvc_NetRemoteTODInfo);
|
||||
W_ERROR_HAVE_NO_MEMORY(info);
|
||||
|
||||
GetTimeOfDay(&tval);
|
||||
t = tval.tv_sec;
|
||||
|
||||
gmtime_r(&t, &tm);
|
||||
|
||||
r->out.info->elapsed = t;
|
||||
info->elapsed = t;
|
||||
/* TODO: fake the uptime: just return the milliseconds till 0:00:00 today */
|
||||
r->out.info->msecs = (tm.tm_hour*60*60*1000)
|
||||
+ (tm.tm_min*60*1000)
|
||||
+ (tm.tm_sec*1000)
|
||||
+ (tval.tv_usec/1000);
|
||||
r->out.info->hours = tm.tm_hour;
|
||||
r->out.info->mins = tm.tm_min;
|
||||
r->out.info->secs = tm.tm_sec;
|
||||
r->out.info->hunds = tval.tv_usec/10000;
|
||||
r->out.info->timezone = get_time_zone(t)/60;
|
||||
r->out.info->tinterval = 310; /* just return the same as windows */
|
||||
r->out.info->day = tm.tm_mday;
|
||||
r->out.info->month = tm.tm_mon + 1;
|
||||
r->out.info->year = tm.tm_year + 1900;
|
||||
r->out.info->weekday = tm.tm_wday;
|
||||
info->msecs = (tm.tm_hour*60*60*1000)
|
||||
+ (tm.tm_min*60*1000)
|
||||
+ (tm.tm_sec*1000)
|
||||
+ (tval.tv_usec/1000);
|
||||
info->hours = tm.tm_hour;
|
||||
info->mins = tm.tm_min;
|
||||
info->secs = tm.tm_sec;
|
||||
info->hunds = tval.tv_usec/10000;
|
||||
info->timezone = get_time_zone(t)/60;
|
||||
info->tinterval = 310; /* just return the same as windows */
|
||||
info->day = tm.tm_mday;
|
||||
info->month = tm.tm_mon + 1;
|
||||
info->year = tm.tm_year + 1900;
|
||||
info->weekday = tm.tm_wday;
|
||||
|
||||
*r->out.info = info;
|
||||
|
||||
return WERR_OK;
|
||||
}
|
||||
|
@ -851,10 +851,11 @@ static bool test_NetRemoteTOD(struct torture_context *tctx,
|
||||
{
|
||||
NTSTATUS status;
|
||||
struct srvsvc_NetRemoteTOD r;
|
||||
struct srvsvc_NetRemoteTODInfo *info = NULL;
|
||||
|
||||
r.in.server_unc = talloc_asprintf(tctx,"\\\\%s",dcerpc_server_name(p));
|
||||
r.out.info = &info;
|
||||
|
||||
ZERO_STRUCT(r.out);
|
||||
torture_comment(tctx, "testing NetRemoteTOD\n");
|
||||
status = dcerpc_srvsvc_NetRemoteTOD(p, tctx, &r);
|
||||
torture_assert_ntstatus_ok(tctx, status, "NetRemoteTOD failed");
|
||||
|
Loading…
Reference in New Issue
Block a user