VDR 1.3.38 and "-u root"

Message ID 4DE7287515%linux@youmustbejoking.demon.co.uk
State New
Headers

Commit Message

Darren Salt Jan. 10, 2006, 6:31 p.m. UTC
  I demand that Oliver Friedrich may or may not have written...

[snip]
> And with 1.3.38 it is impossible to simply get the commandline help if
> no useraccount 'vdr' is present on the system and the user doesn't know
> the '-u' switch ...

The attached patch (or something similar) should help.
  

Comments

Oliver Friedrich Jan. 10, 2006, 8:30 p.m. UTC | #1
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Darren Salt schrieb:
> I demand that Oliver Friedrich may or may not have written...
> 
> [snip]
> 
>>And with 1.3.38 it is impossible to simply get the commandline help if
>>no useraccount 'vdr' is present on the system and the user doesn't know
>>the '-u' switch ...
> 
> 
> The attached patch (or something similar) should help.
> 

Hmm... this makes things much more complicated than it is needed ... :)

If Klaus implements the '-u' switch like he has explained earlier in
this thread your patch is not needed. No detection of special users is
needed, because it uses by default the current user.

Just my two cents ...
Oliver
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.5 (MingW32)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFDxBl0JL9YbV++5+wRAgwvAJwJ99I5juZAm6miP3CScQU4AQx/TACfbo2g
/rrHGyhMKmeOO070RMFZYv8=
=cZFr
-----END PGP SIGNATURE-----
  

Patch

diff -urNad vdr-1.3.38~/vdr.c vdr-1.3.38/vdr.c
--- vdr-1.3.38~/vdr.c	2006-01-09 15:08:26.000000000 +0000
+++ vdr-1.3.38/vdr.c	2006-01-09 15:08:26.780107092 +0000
@@ -35,6 +35,7 @@ 
 #include <sys/prctl.h>
 #include <termios.h>
 #include <unistd.h>
+#include <sys/types.h>
 #include "audio.h"
 #include "channels.h"
 #include "config.h"
@@ -151,6 +152,9 @@ 
   // Save terminal settings:
 
   struct termios savedTm;
+
+  bool isroot = !getuid ();// || !getgid () || !geteuid () || !getegid ();
+  
   bool HasStdin = (tcgetpgrp(STDIN_FILENO) == getpid() || getppid() != (pid_t)1) && tcgetattr(STDIN_FILENO, &savedTm) == 0;
 
   // Initiate locale:
@@ -226,6 +230,16 @@ 
     };
 
   int c;
+  if (isroot)
+  while ((c = getopt_long(argc, argv, "a:c:dD:E:g:hl:L:mp:P:r:s:t:u:v:Vw:", long_options, NULL)) != -1) {
+        switch (c) {
+          case 'h': DisplayHelp = true;
+                    break;
+          case 'V': DisplayVersion = true;
+                    break;
+          }
+        }
+  else
   while ((c = getopt_long(argc, argv, "a:c:dD:E:g:hl:L:mp:P:r:s:t:u:v:Vw:", long_options, NULL)) != -1) {
         switch (c) {
           case 'a': AudioCommand = optarg;
@@ -349,14 +363,17 @@ 
         return 2;
      if (!SetCapSysTime())
         return 2;
+     isroot = false;
      }
 
   // Help and version info:
 
   if (DisplayHelp || DisplayVersion) {
+    if (!isroot) {
      if (!PluginManager.HasPlugins())
         PluginManager.AddPlugin("*"); // adds all available plugins
      PluginManager.LoadPlugins();
+    }
      if (DisplayHelp) {
         printf("Usage: vdr [OPTIONS]\n\n"          // for easier orientation, this is column 80|
                "  -a CMD,   --audio=CMD    send Dolby Digital audio to stdin of command CMD\n"
@@ -415,7 +432,7 @@ 
         }
      if (DisplayVersion)
         printf("vdr (%s) - The Video Disk Recorder\n", VDRVERSION);
-     if (PluginManager.HasPlugins()) {
+     if (!isroot && PluginManager.HasPlugins()) {
         if (DisplayHelp)
            printf("Plugins: vdr -P\"name [OPTIONS]\"\n\n");
         for (int i = 0; ; i++) {