Mailing List archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[vdr] Patch: VDR syncing time with non-root user



Hi everyone,

On August 14th on the vdr-portal.de a patch by Balthasar popped up to enable VDR to sync the system time as non-root user.
http://www.vdrportal.de/board/thread.php?threadid=4377&sid=&hilight=&hilightuser=0

I thought I'd post it here as well since I think it'd solve a few problems for some users here on the list.

With kind permission of balthasar:

-----------------------------------------------------------------------

1. Install the patch
2. recompile vdr
3. create a shellscript with the content
   "/usr/bin/sudo /bin/date $1"
4. enter 
    visudo "vdr ALL=(ALL) NOPASSWD: /bin/date"
5. expand runvdr to "vdr -T /path/to/setTime.script"


diff -Nru vdr-1.2.2.org/eit.c vdr-1.2.2/eit.c
--- vdr-1.2.2.org/eit.c 2003-05-29 17:04:10.000000000 +0200
+++ vdr-1.2.2/eit.c     2003-08-07 02:25:18.000000000 +0200
@@ -38,6 +38,8 @@
 #include "libdtv/libdtv.h"
 #include "videodir.h"

+extern char *SetTime;
+
 // ---  cMJD ------------------------------------------------------------------

 class cMJD {
@@ -125,6 +127,9 @@
    struct tm *ptm;
    time_t loctim;

+   char *cmd;
+   char timestr[20];
+
    struct tm tm_r;
    ptm = localtime_r(&mjdtime, &tm_r);
    loctim = time(NULL);
@@ -133,8 +138,16 @@
    {
       isyslog("System Time = %s (%ld)\n", ctime(&loctim), loctim);
       isyslog("Local Time  = %s (%ld)\n", ctime(&mjdtime), mjdtime);
-      if (stime(&mjdtime) < 0)
-         esyslog("ERROR while setting system time: %m");
+      if ( SetTime ) {
+        strftime(timestr,20,"%m%d%H%M%Y.%S",ptm);
+        asprintf(&cmd,"%s %s %ld",SetTime,timestr,mjdtime);
+        dsyslog("Executing: %s",cmd);
+        SystemExec(cmd);
+        free(cmd);
+      } else {
+        if (stime(&mjdtime) < 0)
+          esyslog("ERROR while setting system time: %m");
+      }
       return true;
    }

diff -Nru vdr-1.2.2.org/vdr.c vdr-1.2.2/vdr.c
--- vdr-1.2.2.org/vdr.c 2003-08-02 16:01:32.000000000 +0200
+++ vdr-1.2.2/vdr.c     2003-08-07 02:30:05.000000000 +0200
@@ -61,6 +61,8 @@

 static int Interrupted = 0;

+char *SetTime=NULL;
+
 static void SignalHandler(int signum)
 {
   if (signum != SIGPIPE) {
@@ -123,6 +125,7 @@
       { "record",   required_argument, NULL, 'r' },
       { "shutdown", required_argument, NULL, 's' },
       { "terminal", required_argument, NULL, 't' },
+      { "timeset",  required_argument, NULL, 'T' },
       { "version",  no_argument,       NULL, 'V' },
       { "video",    required_argument, NULL, 'v' },
       { "watchdog", required_argument, NULL, 'w' },
@@ -130,7 +133,7 @@
     };

   int c;
-  while ((c = getopt_long(argc, argv, "a:c:dD:E:hl:L:mp:P:r:s:t:v:Vw:", long_options, NULL)) != -1) {
+  while ((c = getopt_long(argc, argv, "a:c:dD:E:hl:L:mp:P:r:s:t:T:v:Vw:", long_options, NULL)) != -1) {
         switch (c) {
           case 'a': AudioCommand = optarg;
                     break;
@@ -199,6 +202,8 @@
                     break;
           case 's': Shutdown = optarg;
                     break;
+          case 'T': SetTime = strdup(optarg);
+                    break;
           case 't': Terminal = optarg;
                     break;
           case 'V': DisplayVersion = true;

-----------------------------------------------------------------------

Have Fun!
If the path won't work for you (line breaks) you can download it at the above mentioned thread in the portal.

Credits go to balthasar of vdr-portal.de:
http://www.vdrportal.de/board/profile.php?userid=1436&sid=


Regards
Thomas


-- 
Info:
To unsubscribe send a mail to ecartis@linuxtv.org with "unsubscribe vdr" as subject.



Home | Main Index | Thread Index