Print this page
1575 untangle libmlrpc ... pre1:
 Move srvsvc_timecheck where it belongs


  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
  24  * Copyright 2015 Nexenta Systems, Inc.  All rights reserved.
  25  */
  26 
  27 /*
  28  * Server Service (srvsvc) client side RPC library interface. The
  29  * srvsvc interface allows a client to query a server for information
  30  * on shares, sessions, connections and files on the server. Some
  31  * functions are available via anonymous IPC while others require
  32  * administrator privilege. Also, some functions return NT status
  33  * values while others return Win32 errors codes.
  34  */
  35 
  36 #include <sys/errno.h>

  37 #include <stdio.h>
  38 #include <time.h>
  39 #include <strings.h>

  40 
  41 #include <smbsrv/libsmb.h>
  42 #include <smbsrv/libmlsvc.h>
  43 #include <smbsrv/smbinfo.h>
  44 #include <smbsrv/ndl/srvsvc.ndl>
  45 
  46 /*
  47  * Information level for NetShareGetInfo.
  48  */
  49 DWORD srvsvc_info_level = 1;
  50 
  51 /*
  52  * Bind to the the SRVSVC.
  53  *
  54  * If username argument is NULL, an anonymous connection will be established.
  55  * Otherwise, an authenticated connection will be established.
  56  */
  57 static int
  58 srvsvc_open(char *server, char *domain, char *username, mlsvc_handle_t *handle)
  59 {


 392         svinfo->sv_type = sv101->sv101_type;
 393         if (sv101->sv101_name)
 394                 svinfo->sv_name = strdup((char *)sv101->sv101_name);
 395         if (sv101->sv101_comment)
 396                 svinfo->sv_comment = strdup((char *)sv101->sv101_comment);
 397 
 398         if (svinfo->sv_type & SV_TYPE_WFW)
 399                 svinfo->sv_os = NATIVE_OS_WIN95;
 400         if (svinfo->sv_type & SV_TYPE_WINDOWS)
 401                 svinfo->sv_os = NATIVE_OS_WIN95;
 402         if ((svinfo->sv_type & SV_TYPE_NT) ||
 403             (svinfo->sv_type & SV_TYPE_SERVER_NT))
 404                 svinfo->sv_os = NATIVE_OS_WINNT;
 405         if (svinfo->sv_version_major > 4)
 406                 svinfo->sv_os = NATIVE_OS_WIN2000;
 407 
 408         srvsvc_close(&handle);
 409         return (0);
 410 }
 411 










































 412 /*
 413  * Synchronize the local system clock with the domain controller.
 414  */
 415 void
 416 srvsvc_timesync(void)
 417 {
 418         smb_domainex_t di;
 419         struct timeval tv;
 420         struct tm tm;
 421         time_t tsecs;
 422 
 423         if (!smb_domain_getinfo(&di))
 424                 return;
 425 
 426         if (srvsvc_net_remote_tod(di.d_dci.dc_name, di.d_primary.di_nbname,
 427             &tv, &tm) != 0)
 428                 return;
 429 
 430         if (settimeofday(&tv, 0))
 431                 smb_tracef("unable to set system time");




  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
  24  * Copyright 2015 Nexenta Systems, Inc.  All rights reserved.
  25  */
  26 
  27 /*
  28  * Server Service (srvsvc) client side RPC library interface. The
  29  * srvsvc interface allows a client to query a server for information
  30  * on shares, sessions, connections and files on the server. Some
  31  * functions are available via anonymous IPC while others require
  32  * administrator privilege. Also, some functions return NT status
  33  * values while others return Win32 errors codes.
  34  */
  35 
  36 #include <sys/errno.h>
  37 #include <sys/tzfile.h>
  38 #include <stdio.h>
  39 #include <time.h>
  40 #include <strings.h>
  41 #include <unistd.h>
  42 
  43 #include <smbsrv/libsmb.h>
  44 #include <smbsrv/libmlsvc.h>
  45 #include <smbsrv/smbinfo.h>
  46 #include <smbsrv/ndl/srvsvc.ndl>
  47 
  48 /*
  49  * Information level for NetShareGetInfo.
  50  */
  51 DWORD srvsvc_info_level = 1;
  52 
  53 /*
  54  * Bind to the the SRVSVC.
  55  *
  56  * If username argument is NULL, an anonymous connection will be established.
  57  * Otherwise, an authenticated connection will be established.
  58  */
  59 static int
  60 srvsvc_open(char *server, char *domain, char *username, mlsvc_handle_t *handle)
  61 {


 394         svinfo->sv_type = sv101->sv101_type;
 395         if (sv101->sv101_name)
 396                 svinfo->sv_name = strdup((char *)sv101->sv101_name);
 397         if (sv101->sv101_comment)
 398                 svinfo->sv_comment = strdup((char *)sv101->sv101_comment);
 399 
 400         if (svinfo->sv_type & SV_TYPE_WFW)
 401                 svinfo->sv_os = NATIVE_OS_WIN95;
 402         if (svinfo->sv_type & SV_TYPE_WINDOWS)
 403                 svinfo->sv_os = NATIVE_OS_WIN95;
 404         if ((svinfo->sv_type & SV_TYPE_NT) ||
 405             (svinfo->sv_type & SV_TYPE_SERVER_NT))
 406                 svinfo->sv_os = NATIVE_OS_WINNT;
 407         if (svinfo->sv_version_major > 4)
 408                 svinfo->sv_os = NATIVE_OS_WIN2000;
 409 
 410         srvsvc_close(&handle);
 411         return (0);
 412 }
 413 
 414 /*
 415  * Compare the time here with the remote time on the server
 416  * and report clock skew.
 417  */
 418 void
 419 srvsvc_timecheck(char *server, char *domain)
 420 {
 421         char                    hostname[MAXHOSTNAMELEN];
 422         struct timeval          dc_tv;
 423         struct tm               dc_tm;
 424         struct tm               *tm;
 425         time_t                  tnow;
 426         time_t                  tdiff;
 427         int                     priority;
 428 
 429         if (srvsvc_net_remote_tod(server, domain, &dc_tv, &dc_tm) < 0) {
 430                 syslog(LOG_DEBUG, "srvsvc_net_remote_tod failed");
 431                 return;
 432         }
 433 
 434         tnow = time(NULL);
 435 
 436         if (tnow > dc_tv.tv_sec)
 437                 tdiff = (tnow - dc_tv.tv_sec) / SECSPERMIN;
 438         else
 439                 tdiff = (dc_tv.tv_sec - tnow) / SECSPERMIN;
 440 
 441         if (tdiff != 0) {
 442                 (void) strlcpy(hostname, "localhost", MAXHOSTNAMELEN);
 443                 (void) gethostname(hostname, MAXHOSTNAMELEN);
 444 
 445                 priority = (tdiff > 2) ? LOG_NOTICE : LOG_DEBUG;
 446                 syslog(priority, "DC [%s] clock skew detected: %u minutes",
 447                     server, tdiff);
 448 
 449                 tm = gmtime(&dc_tv.tv_sec);
 450                 syslog(priority, "%-8s  UTC: %s", server, asctime(tm));
 451                 tm = gmtime(&tnow);
 452                 syslog(priority, "%-8s  UTC: %s", hostname, asctime(tm));
 453         }
 454 }
 455 
 456 /*
 457  * Synchronize the local system clock with the domain controller.
 458  */
 459 void
 460 srvsvc_timesync(void)
 461 {
 462         smb_domainex_t di;
 463         struct timeval tv;
 464         struct tm tm;
 465         time_t tsecs;
 466 
 467         if (!smb_domain_getinfo(&di))
 468                 return;
 469 
 470         if (srvsvc_net_remote_tod(di.d_dci.dc_name, di.d_primary.di_nbname,
 471             &tv, &tm) != 0)
 472                 return;
 473 
 474         if (settimeofday(&tv, 0))
 475                 smb_tracef("unable to set system time");