Ticket #174: run_email2trac.c-set_python_egg_cache_env.diff

File run_email2trac.c-set_python_egg_cache_env.diff, 1.4 KB (added by pepl@…, 12 years ago)
  • run_email2trac.c

    old new  
    5555  int status;
    5656
    5757  char   **trac_script_args;
     58  char   *python_egg_cache;
    5859  struct passwd *TRAC;
    5960  struct passwd *MTA;
    6061  struct stat script_attrs;
     
    7980      i++;
    8081      continue;
    8182    }
     83    else if ( (strcmp(argv[i],"--eggcache") == 0) ||
     84         (strcmp(argv[i],"-e") == 0) ) {
     85      i++;
     86      python_egg_cache = argv[i];
     87      continue;
     88    }
    8289   
    8390    trac_script_args[j] = argv[i];
    8491    j++;
    8592  }
    8693  trac_script_args[j] = NULL;
    8794
    88  
    8995  /* Check caller */
    90 
    91 
    9296  check_username(MTA_USER);
    9397  MTA = getpwnam(MTA_USER);
    9498
     
    102106    return -2;     /* 254 : Invalid caller */
    103107  }
    104108 
    105  
    106109  /* set UID/GID to Trac (or apache) user */
    107110  check_username(TRAC_USER);
    108111  if ( TRAC = getpwnam(TRAC_USER) ) {
     
    121124    return -4;    /* 252 : script not found */
    122125  }
    123126 
     127  /* Set PYTHON_EGG_CACHE env variable if we have been told to do so */
     128  if ( strlen(python_egg_cache) > 0 ) {
     129    setenv("PYTHON_EGG_CACHE",python_egg_cache ,1);
     130  }
     131
    124132  /* Execute script */
    125133  status = execv(trac_script, trac_script_args);
     134 
    126135  if ( DEBUG ) printf("Script %s execution failure (error=%d). Check permission and interpreter path.\n",trac_script,status);
    127136  return -1;     /* 255 : should never reach this point */
    128137