Changeset 745 for trunk/server/source3/utils/net_time.c
- Timestamp:
- Nov 27, 2012, 4:43:17 PM (13 years ago)
- Location:
- trunk/server
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/server
- Property svn:mergeinfo changed
/vendor/current merged: 581,587,591,594,597,600,615,618,740
- Property svn:mergeinfo changed
-
trunk/server/source3/utils/net_time.c
r672 r745 19 19 #include "includes.h" 20 20 #include "utils/net.h" 21 #include "libsmb/nmblib.h" 22 #include "libsmb/libsmb.h" 21 23 22 24 /* … … 104 106 } 105 107 106 /* try to set the system clock using /bin/date*/108 /* try to set the system clock */ 107 109 static int net_time_set(struct net_context *c, int argc, const char **argv) 108 110 { 109 time_t t = nettime(c, NULL); 110 char *cmd; 111 struct timeval tv; 111 112 int result; 112 113 113 if (t == 0) return -1; 114 tv.tv_sec = nettime(c, NULL); 115 tv.tv_usec=0; 116 117 if (tv.tv_sec == 0) return -1; 114 118 115 119 #ifdef __OS2__ 116 120 /* eCS (OS/2) native "net time set" routine */ 117 result = os2_setdatetime(t );121 result = os2_setdatetime(tv.tv_sec); 118 122 #else 119 /* yes, I know this is cheesy. Use "net time system" if you want to 120 roll your own. I'm putting this in as it works on a large number 121 of systems and the user has a choice in whether its used or not */ 122 if (asprintf(&cmd, "/bin/date %s", systime(t)) == -1) { 123 return -1; 124 } 125 result = system(cmd); 123 result = settimeofday(&tv,NULL); 126 124 #endif 125 127 126 if (result) 128 d_fprintf(stderr, _("%s failed. Error was (%s)\n"), 129 cmd, strerror(errno)); 130 free(cmd); 127 d_fprintf(stderr, _("setting system clock failed. Error was (%s)\n"), 128 strerror(errno)); 131 129 132 130 return result;
Note:
See TracChangeset
for help on using the changeset viewer.