Skip to content

Commit

Permalink
rest_client: complete fix in commit d90d70b
Browse files Browse the repository at this point in the history
Related to #2115

(cherry picked from commit 3110421)
  • Loading branch information
rvlad-patrascu committed Jun 21, 2020
1 parent a185ed9 commit 113734c
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 0 deletions.
2 changes: 2 additions & 0 deletions daemonize.c
Expand Up @@ -268,6 +268,8 @@ int daemonize(char* name, int * own_pgid)
/*parent process => exit */
exit(0);
}

is_pre_daemon = 0; /* attendant process at this point */
}

#ifdef __OS_linux
Expand Down
1 change: 1 addition & 0 deletions globals.h
Expand Up @@ -114,6 +114,7 @@ extern unsigned long pkg_mem_size;
extern int reply_to_via;

extern int is_main;
extern int is_pre_daemon;

extern int memlog; /*!< debugging level for printing memory debugs */
extern int memdump; /*!< debugging level for dumping memory status */
Expand Down
3 changes: 3 additions & 0 deletions main.c
Expand Up @@ -314,6 +314,9 @@ char **my_argv;

int is_main = 1; /* flag = is this the "main" process? */

/* flag = is this an initial, pre-daemon process ? */
int is_pre_daemon = 1;

char* pid_file = 0; /* filename as asked by user */
char* pgid_file = 0;

Expand Down
1 change: 1 addition & 0 deletions modules/rest_client/rest_client.c
Expand Up @@ -40,6 +40,7 @@
#include "rest_client.h"
#include "rest_methods.h"
#include "../../ssl_init_tweaks.h"
#include "../../pt.h"

/*
* Module parameters
Expand Down
49 changes: 49 additions & 0 deletions modules/rest_client/ssl_tweaks.c
@@ -0,0 +1,49 @@
/*
* Copyright (C) 2020 OpenSIPS Project
*
* This file is part of opensips, a free SIP server.
*
* opensips is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* opensips is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*
*/

#define _GNU_SOURCE

#include <openssl/ssl.h>
#include <dlfcn.h>

#include "../../sr_module.h"
#include "../../globals.h"

/* don't call the real openssl function (from libssh's destructor) when the
* pre-daemon processes exit */
void BN_clear_free(BIGNUM *a)
{
void (*real_BN_clear_free)(BIGNUM *a);
static int have_tls_mgm = -1;

if (have_tls_mgm == -1)
have_tls_mgm = module_loaded("tls_mgm");

if (have_tls_mgm && !no_daemon_mode && is_pre_daemon) {
return;
} else {
real_BN_clear_free = dlsym(RTLD_NEXT, "BN_clear_free");
if (!real_BN_clear_free)
return;

real_BN_clear_free(a);
}
}

0 comments on commit 113734c

Please sign in to comment.