Commit 228baffe authored by Yann Garcia's avatar Yann Garcia
Browse files

Update config files

parent 4c66089e
Loading
Loading
Loading
Loading
+2 −2
Original line number Original line Diff line number Diff line
@@ -4,6 +4,6 @@ realm=vendors
login=guest
login=guest
password=password
password=password
https_port=8888
https_port=8888
cert_pem=/etc/its_bridge/certs/server.pem
cert_pem=/etc/its_bridge/certs/its_bridge.pem
cert_key=/etc/its_bridge/certs/server.key
cert_key=/etc/its_bridge/certs/its_bridge.key
conf_path=/etc/its_bridge
conf_path=/etc/its_bridge
+2 −1
Original line number Original line Diff line number Diff line
@@ -647,13 +647,14 @@ int32_t main(const int32_t p_argc, char* const p_argv[]) {
    fprintf(stderr, "Failed to parse configuration file: conf_path missing, exit.\n");
    fprintf(stderr, "Failed to parse configuration file: conf_path missing, exit.\n");
    goto error;
    goto error;
  }
  }
  printf("realm=%s, login=%s:%s, pem=%s, key=%s, conf_path=%s.\n", realm, login, password, cert_pem, cert_key, conf_path);


  /* Daemonize */
  /* Daemonize */
  if (daemonized) {
  if (daemonized) {
    daemonize();
    daemonize();
  }
  }


  printf("realm=%s, login=%s:%s, pem=%s, key=%s, conf_path=%s.\n", realm, login, password, cert_pem, cert_key, conf_path);

  /* Here is either the main process is not deamonized or th echild process if deamonized */
  /* Here is either the main process is not deamonized or th echild process if deamonized */
  set_pid_file(PID_FILE_NAME); /* Set PID file */
  set_pid_file(PID_FILE_NAME); /* Set PID file */
  set_lock_file(LOCK_FILE_NAME); /* Set lock file */
  set_lock_file(LOCK_FILE_NAME); /* Set lock file */
+13 −7
Original line number Original line Diff line number Diff line
@@ -349,11 +349,11 @@ void daemonize() {
  }
  }
  if (pid > 0) {
  if (pid > 0) {
    printf("daemonize: parent exists.\n");
    printf("daemonize: parent exists.\n");
    exit(0);
    exit(2);
  }
  }


  /* Child (daemon) continues */
  /* Child (daemon) continues */
  printf("daemonize: child started: %d.\n", pid);
  printf("daemonize: child started: %d.\n", getpid());
  if (setsid() < 0) { /* Obtain a new process group */
  if (setsid() < 0) { /* Obtain a new process group */
    fprintf(stderr, "daemonize: 'setsid' operation failure: %s.\n", strerror(errno));
    fprintf(stderr, "daemonize: 'setsid' operation failure: %s.\n", strerror(errno));
    exit(-1);
    exit(-1);
@@ -366,7 +366,7 @@ void daemonize() {
  i = open("/dev/null", O_RDWR); /* Redirection of standards outputs */
  i = open("/dev/null", O_RDWR); /* Redirection of standards outputs */
  dup(i); dup(i);
  dup(i); dup(i);


  umask(027); /* Set newly created file permissions */
  umask(0); /* Set newly created file permissions */


  /* Ignore part of signals */
  /* Ignore part of signals */
  signal(SIGCHLD,SIG_IGN);
  signal(SIGCHLD,SIG_IGN);
@@ -419,6 +419,8 @@ long get_file_size(const char *p_filename) {
    }
    }
    fclose(fp);
    fclose(fp);
    return size;
    return size;
  } else {
    fprintf(stderr, "get_file_size: Failed to open file: %s.\n", p_filename);
  }
  }


  return 0;
  return 0;
@@ -427,22 +429,26 @@ long get_file_size(const char *p_filename) {
char* load_file (const char *p_filename) {
char* load_file (const char *p_filename) {
  size_t size = get_file_size(p_filename);
  size_t size = get_file_size(p_filename);
  if (size == 0) {
  if (size == 0) {
    fprintf(stderr, "load_file: Wrong file size: %s.\n", p_filename);
    return NULL;
    return NULL;
  }
  }


  FILE* fp = fopen (p_filename, "rb");
  FILE* fp = fopen (p_filename, "rb");
  if (fp == NULL) {
  if (fp == NULL) {
    fprintf(stderr, "load_file: Failed to open file: %s.\n", strerror(errno));
    return NULL;
    return NULL;
  }
  }


  char* buffer = malloc(size + 1);
  char* buffer = malloc(size + 1);
  if (buffer == NULL) {
  if (buffer == NULL) {
    fprintf(stderr, "load_file: Failed to allocate memory: %s.\n", strerror(errno));
    fclose (fp);
    fclose (fp);
    return NULL;
    return NULL;
  }
  }
  buffer[size] = '\0';
  buffer[size] = '\0';


  if ((long)fread(buffer, 1, size, fp) != size) {
  if ((long)fread(buffer, 1, size, fp) != size) {
    fprintf(stderr, "load_file: Failed to read file: %s.\n", strerror(errno));
    free (buffer);
    free (buffer);
    buffer = NULL;
    buffer = NULL;
  }
  }