From 9c99863642d295e8b674c9c8b5eeda95bfc4d094 Mon Sep 17 00:00:00 2001 From: Luke Leighton Date: Wed, 20 May 1998 13:17:26 +0000 Subject: dce/rpc net time command from jean-francois. does not support timezones (This used to be commit 8e11d542eebe076d74ab264e22b87f7aed9bbe8f) --- source3/include/proto.h | 7 ++++ source3/include/rpc_srvsvc.h | 38 +++++++++++++++++- source3/rpc_parse/parse_srv.c | 87 +++++++++++++++++++++++++++++++++++++++++ source3/rpc_server/srv_srvsvc.c | 54 +++++++++++++++++++++++++ 4 files changed, 185 insertions(+), 1 deletion(-) diff --git a/source3/include/proto.h b/source3/include/proto.h index 760f889dd9..005911d1f6 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -828,6 +828,13 @@ void srv_io_q_net_srv_set_info(char *desc, SRV_Q_NET_SRV_SET_INFO *q_n, prs_str void make_srv_r_net_srv_set_info(SRV_R_NET_SRV_SET_INFO *srv, uint32 switch_value, SRV_INFO_CTR *ctr, uint32 status); void srv_io_r_net_srv_set_info(char *desc, SRV_R_NET_SRV_SET_INFO *r_n, prs_struct *ps, int depth); +void srv_io_q_net_remote_tod(char *desc, SRV_Q_NET_REMOTE_TOD *q_n, prs_struct *ps, int depth); +void srv_io_time_of_day_info(char *desc, TIME_OF_DAY_INFO *tod, prs_struct *ps, int depth); +void make_time_of_day_info(TIME_OF_DAY_INFO *tod, uint32 elapsedt, uint32 msecs, + uint32 hours, uint32 mins, uint32 secs, uint32 hunds, + uint32 zone, uint32 tintervals, uint32 day, + uint32 month, uint32 year, uint32 weekday); +void srv_io_r_net_remote_tod(char *desc, SRV_R_NET_REMOTE_TOD *r_n, prs_struct *ps, int depth); /*The following definitions come from lib/rpc/parse/parse_wks.c */ diff --git a/source3/include/rpc_srvsvc.h b/source3/include/rpc_srvsvc.h index 6ba137da2f..afcef4e168 100644 --- a/source3/include/rpc_srvsvc.h +++ b/source3/include/rpc_srvsvc.h @@ -32,7 +32,7 @@ #define SRV_NETSHAREENUM 0x0f #define SRV_NET_SRV_GET_INFO 0x15 #define SRV_NET_SRV_SET_INFO 0x16 - +#define SRV_NET_REMOTE_TOD 0x1c /* SESS_INFO_0 (pointers to level 0 session info strings) */ typedef struct ptr_sess_info0 @@ -535,6 +535,42 @@ typedef struct r_net_srv_set_info } SRV_R_NET_SRV_SET_INFO; +/* SRV_Q_NET_REMOTE_TOD */ +typedef struct q_net_remote_tod +{ + uint32 ptr_srv_name; + UNISTR2 uni_srv_name; /* "\\server" */ + +} SRV_Q_NET_REMOTE_TOD; + +/* TIME_OF_DAY_INFO */ +typedef struct time_of_day_info +{ + uint32 elapsedt; + uint32 msecs; + uint32 hours; + uint32 mins; + uint32 secs; + uint32 hunds; + uint32 zone; + uint32 tintervals; + uint32 day; + uint32 month; + uint32 year; + uint32 weekday; + +} TIME_OF_DAY_INFO; + +/* SRV_R_NET_REMOTE_TOD */ +typedef struct r_net_remote_tod +{ + uint32 ptr_srv_tod; /* pointer to TOD */ + TIME_OF_DAY_INFO *tod; + + uint32 status; /* return status */ + +} SRV_R_NET_REMOTE_TOD; + #endif /* _RPC_SRVSVC_H */ diff --git a/source3/rpc_parse/parse_srv.c b/source3/rpc_parse/parse_srv.c index 959a6096aa..592aece439 100644 --- a/source3/rpc_parse/parse_srv.c +++ b/source3/rpc_parse/parse_srv.c @@ -1525,4 +1525,91 @@ void srv_io_r_net_srv_set_info(char *desc, SRV_R_NET_SRV_SET_INFO *r_n, prs_str prs_uint32("status ", ps, depth, &(r_n->status )); } +/******************************************************************* + reads or writes a structure. + ********************************************************************/ +void srv_io_q_net_remote_tod(char *desc, SRV_Q_NET_REMOTE_TOD *q_n, prs_struct *ps, int depth) +{ + if (q_n == NULL) return; + + prs_debug(ps, depth, desc, "srv_io_q_net_remote_tod"); + depth++; + + prs_align(ps); + + prs_uint32("ptr_srv_name ", ps, depth, &(q_n->ptr_srv_name)); + smb_io_unistr2("", &(q_n->uni_srv_name), True, ps, depth); +} + +/******************************************************************* + reads or writes a TIME_OF_DAY_INFO structure. + ********************************************************************/ +void srv_io_time_of_day_info(char *desc, TIME_OF_DAY_INFO *tod, prs_struct *ps, int depth) +{ + if (tod == NULL) return; + + prs_debug(ps, depth, desc, "srv_io_time_of_day_info"); + depth++; + + prs_align(ps); + + prs_uint32("elapsedt ", ps, depth, &(tod->elapsedt )); + prs_uint32("msecs ", ps, depth, &(tod->msecs )); + prs_uint32("hours ", ps, depth, &(tod->hours )); + prs_uint32("mins ", ps, depth, &(tod->mins )); + prs_uint32("secs ", ps, depth, &(tod->secs )); + prs_uint32("hunds ", ps, depth, &(tod->hunds )); + prs_uint32("timezone ", ps, depth, &(tod->zone )); + prs_uint32("tintervals ", ps, depth, &(tod->tintervals)); + prs_uint32("day ", ps, depth, &(tod->day )); + prs_uint32("month ", ps, depth, &(tod->month )); + prs_uint32("year ", ps, depth, &(tod->year )); + prs_uint32("weekday ", ps, depth, &(tod->weekday )); +} + +/******************************************************************* + makes a TIME_OF_DAY_INFO structure. + ********************************************************************/ +void make_time_of_day_info(TIME_OF_DAY_INFO *tod, uint32 elapsedt, uint32 msecs, + uint32 hours, uint32 mins, uint32 secs, uint32 hunds, + uint32 zone, uint32 tintervals, uint32 day, + uint32 month, uint32 year, uint32 weekday) +{ + if (tod == NULL) return; + + DEBUG(5,("make_time_of_day_info\n")); + + tod->elapsedt = elapsedt; + tod->msecs = msecs; + tod->hours = hours; + tod->mins = mins; + tod->secs = secs; + tod->hunds = hunds; + tod->zone = zone; + tod->tintervals = tintervals; + tod->day = day; + tod->month = month; + tod->year = year; + tod->weekday = weekday; +} + + +/******************************************************************* + reads or writes a structure. + ********************************************************************/ +void srv_io_r_net_remote_tod(char *desc, SRV_R_NET_REMOTE_TOD *r_n, prs_struct *ps, int depth) +{ + if (r_n == NULL) return; + + prs_debug(ps, depth, desc, "srv_io_r_net_remote_tod"); + depth++; + + prs_align(ps); + + prs_uint32("ptr_srv_tod ", ps, depth, &(r_n->ptr_srv_tod)); + + srv_io_time_of_day_info("tod", r_n->tod, ps, depth); + + prs_uint32("status ", ps, depth, &(r_n->status)); +} diff --git a/source3/rpc_server/srv_srvsvc.c b/source3/rpc_server/srv_srvsvc.c index d06e2ac660..fedc7089e3 100644 --- a/source3/rpc_server/srv_srvsvc.c +++ b/source3/rpc_server/srv_srvsvc.c @@ -989,6 +989,59 @@ static void api_srv_net_share_enum( int uid, prs_struct *data, srv_reply_net_share_enum(&q_n, rdata); } +/******************************************************************* +time of day +********************************************************************/ +static void srv_reply_net_remote_tod(SRV_Q_NET_REMOTE_TOD *q_n, + prs_struct *rdata) +{ + SRV_R_NET_REMOTE_TOD r_n; + TIME_OF_DAY_INFO tod; + struct tm *t; + time_t unixdate = time(NULL); + + r_n.tod = &tod; + r_n.ptr_srv_tod = 0x1; + r_n.status = 0x0; + + DEBUG(5,("srv_reply_net_remote_tod: %d\n", __LINE__)); + + t = LocalTime(&unixdate); + + /* set up the */ + make_time_of_day_info(&tod, + unixdate, + 0, + t->tm_hour, + t->tm_min, + t->tm_sec, + 0, + TimeDiff(unixdate)/60, + 10000, + t->tm_mday, + t->tm_mon + 1, + 1900+t->tm_year, + t->tm_wday); + + /* store the response in the SMB stream */ + srv_io_r_net_remote_tod("", &r_n, rdata, 0); + + DEBUG(5,("srv_reply_net_remote_tod: %d\n", __LINE__)); +} +/******************************************************************* +********************************************************************/ +static void api_srv_net_remote_tod( int uid, prs_struct *data, + prs_struct *rdata ) +{ + SRV_Q_NET_REMOTE_TOD q_n; + + /* grab the net server get enum */ + srv_io_q_net_remote_tod("", &q_n, data, 0); + + /* construct reply. always indicate success */ + srv_reply_net_remote_tod(&q_n, rdata); +} + /******************************************************************* \PIPE\srvsvc commands @@ -1000,6 +1053,7 @@ struct api_struct api_srv_cmds[] = { "SRV_NETSHAREENUM" , SRV_NETSHAREENUM , api_srv_net_share_enum }, { "SRV_NETFILEENUM" , SRV_NETFILEENUM , api_srv_net_file_enum }, { "SRV_NET_SRV_GET_INFO", SRV_NET_SRV_GET_INFO, api_srv_net_srv_get_info }, + { "SRV_NET_REMOTE_TOD" , SRV_NET_REMOTE_TOD , api_srv_net_remote_tod }, { NULL , 0 , NULL } }; -- cgit