(file) Return to main.c CVS log (file) (dir) Up to [Pegasus] / pegasus / src / Executor

Diff for /pegasus/src/Executor/main.c between version 1.1.2.9 and 1.1.2.10

version 1.1.2.9, 2007/01/11 20:48:24 version 1.1.2.10, 2007/01/11 21:36:06
Line 49 
Line 49 
 #include "Policy.h" #include "Policy.h"
 #include "Macro.h" #include "Macro.h"
 #include "Assert.h" #include "Assert.h"
   #include "Options.h"
  
 /* /*
 **============================================================================== **==============================================================================
Line 300 
Line 301 
 /* /*
 **============================================================================== **==============================================================================
 ** **
 ** TestFlagOption()  
 **  
 **     Check whether argv contains the given option. Return 0 if so. Else  
 **     return -1. Remove the argument from the list if the *remove* argument  
 **     is non-zero.  
 **  
 **         if (TestFlagOption(&argc, &argv, "--help", 0) == 0)  
 **         {  
 **         }  
 **  
 **==============================================================================  
 */  
   
 int TestFlagOption(int* argc_, char*** argv_, const char* option, int remove)  
 {  
     int argc = *argc_;  
     char** argv = *argv_;  
     int i;  
   
     for (i = 0; i < argc; i++)  
     {  
         if (strcmp(argv[i], option) == 0)  
         {  
             if (remove)  
             {  
                 memmove(&argv[i], &argv[i + 1], (argc-i) * sizeof(char*));  
                 argc--;  
             }  
   
             *argc_ = argc;  
             *argv_ = argv;  
             return 0;  
         }  
     }  
   
     /* Not found */  
     return -1;  
 }  
   
 /*  
 **==============================================================================  
 **  
 ** main() ** main()
 ** **
 **============================================================================== **==============================================================================
 */ */
  
 void doit();  
   
 int main(int argc, char** argv) int main(int argc, char** argv)
 { {
     const char* cimservermainPath;     const char* cimservermainPath;
     int pair[2];     int pair[2];
     char username[EXECUTOR_BUFFER_SIZE];     char username[EXECUTOR_BUFFER_SIZE];
     int childPid;     int childPid;
     int perror;  
     const char* repositoryDir;     const char* repositoryDir;
       struct Options options;
   
       /* Get options. */
  
     /* Save as global so it can be used in error and log messages. */      GetOptions(&argc, &argv, &options);
   
       /* Save argc-argv as globals. */
  
     globals.argc = argc;     globals.argc = argc;
     globals.argv = argv;     globals.argv = argv;
Line 369 
Line 330 
  
     /* If shuting down, then run CIMSHUTDOWN client. */     /* If shuting down, then run CIMSHUTDOWN client. */
  
     if (TestFlagOption(&argc, &argv, "-s", 0) == 0)      if (options.shutdown)
         ExecShutdown();         ExecShutdown();
  
     /* Check for --dump-policy option. */      /* Process --policy and --macros options. */
  
     if (TestFlagOption(&argc, &argv, "--dump-policy", 0) == 0)      if (options.policy || options.macros)
     {     {
           if (options.policy)
         DumpPolicy(1);         DumpPolicy(1);
         putchar('\n');  
         exit(0);  
     }  
  
     /* Check for --dump-macros option. */          if (options.macros)
   
     if (TestFlagOption(&argc, &argv, "--dump-macros", 0) == 0)  
     {  
         DumpMacros();         DumpMacros();
         putchar('\n');  
         exit(0);         exit(0);
     }     }
  
Line 395 
Line 351 
     if ((cimservermainPath = FindMacro("cimservermainPath")) == NULL)     if ((cimservermainPath = FindMacro("cimservermainPath")) == NULL)
         Fatal(FL, "Failed to locate %s program", CIMSERVERMAIN);         Fatal(FL, "Failed to locate %s program", CIMSERVERMAIN);
  
     /* If CIMSERVERMAIN is already running, warn and exit now. */      /* If CIMSERVERMAIN is already running, warn and exit now, unless one of
        * the following options are given: -v, --version, -h, --help (these are
        * passed through to CIMSERVERMAIN).
        */
  
     if (TestCimServerProcess() == 0)      if (!options.version && !options.help && TestCimServerProcess() == 0)
     {     {
         fprintf(stderr,         fprintf(stderr,
             "%s: cimserver is already running (the PID found in the file "             "%s: cimserver is already running (the PID found in the file "
Line 430 
Line 389 
  
     GetLogLevel(argc, argv);     GetLogLevel(argc, argv);
  
     /* Extract --perror option (directs syslog output to stderr). */  
   
     perror = 0;  
   
     if (TestFlagOption(&argc, &argv, "--perror", 1) == 0)  
         perror = 1;  
   
     /* Open the log. */     /* Open the log. */
  
     OpenLog("cimexecutor", perror);      OpenLog("cimexecutor", options.perror);
  
     Log(LL_INFORMATION, "starting");     Log(LL_INFORMATION, "starting");
  
     /* Be sure this process is running as root (otherwise fail). */     /* Be sure this process is running as root (otherwise fail). */
  
     if (setuid(0) != 0 || setgid(0) != 0)     if (setuid(0) != 0 || setgid(0) != 0)
     {          Fatal(FL, "attempted to run program as non-root user");
         Log(LL_FATAL, "attempted to run program as non-root user");  
         fprintf(stderr,  
             "%s: this program must be run as root\n", globals.argv[0]);  
         exit(0);  
     }  
  
     /* Warn if authentication not enabled (strange use of executor if not). */      /* Warn if authentication not enabled (suspicious use of executor). */
  
     if (!globals.enableAuthentication)     if (!globals.enableAuthentication)
         Log(LL_WARNING, "authentication is NOT enabled");         Log(LL_WARNING, "authentication is NOT enabled");


Legend:
Removed from v.1.1.2.9  
changed lines
  Added in v.1.1.2.10

No CVS admin address has been configured
Powered by
ViewCVS 0.9.2