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

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/smbsrv/libmlsvc/common/srvsvc_clnt.c
          +++ new/usr/src/lib/smbsrv/libmlsvc/common/srvsvc_clnt.c
↓ open down ↓ 26 lines elided ↑ open up ↑
  27   27  /*
  28   28   * Server Service (srvsvc) client side RPC library interface. The
  29   29   * srvsvc interface allows a client to query a server for information
  30   30   * on shares, sessions, connections and files on the server. Some
  31   31   * functions are available via anonymous IPC while others require
  32   32   * administrator privilege. Also, some functions return NT status
  33   33   * values while others return Win32 errors codes.
  34   34   */
  35   35  
  36   36  #include <sys/errno.h>
       37 +#include <sys/tzfile.h>
  37   38  #include <stdio.h>
  38   39  #include <time.h>
  39   40  #include <strings.h>
       41 +#include <unistd.h>
  40   42  
  41   43  #include <smbsrv/libsmb.h>
  42   44  #include <smbsrv/libmlsvc.h>
  43   45  #include <smbsrv/smbinfo.h>
  44   46  #include <smbsrv/ndl/srvsvc.ndl>
  45   47  
  46   48  /*
  47   49   * Information level for NetShareGetInfo.
  48   50   */
  49   51  DWORD srvsvc_info_level = 1;
↓ open down ↓ 352 lines elided ↑ open up ↑
 402  404          if ((svinfo->sv_type & SV_TYPE_NT) ||
 403  405              (svinfo->sv_type & SV_TYPE_SERVER_NT))
 404  406                  svinfo->sv_os = NATIVE_OS_WINNT;
 405  407          if (svinfo->sv_version_major > 4)
 406  408                  svinfo->sv_os = NATIVE_OS_WIN2000;
 407  409  
 408  410          srvsvc_close(&handle);
 409  411          return (0);
 410  412  }
 411  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 +
 412  456  /*
 413  457   * Synchronize the local system clock with the domain controller.
 414  458   */
 415  459  void
 416  460  srvsvc_timesync(void)
 417  461  {
 418  462          smb_domainex_t di;
 419  463          struct timeval tv;
 420  464          struct tm tm;
 421  465          time_t tsecs;
↓ open down ↓ 161 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX