Skip to content

Commit

Permalink
add possibility to disable auto restart in config file
Browse files Browse the repository at this point in the history
  • Loading branch information
zachmann committed Aug 26, 2024
1 parent b06f03e commit 95a7089
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 9 deletions.
1 change: 1 addition & 0 deletions src/defines/agent_values.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
#define CONFIG_KEY_STATSCOLLECT "stats_collect_local"
#define CONFIG_KEY_STATSCOLLECTSHARE "stats_collect_share"
#define CONFIG_KEY_STATSCOLLECTLOCATION "stats_collect_location"
#define CONFIG_KEY_RESTARTAFTERUPDATE "restart_after_update"
#define CONFIG_KEY_LEGACYAUDMODE "legacy_aud_mode"
#define CONFIG_KEY_PLAINADD "skip-check"

Expand Down
16 changes: 9 additions & 7 deletions src/oidc-agent/oidcp/oidcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
#include "oidc-agent/stats/statlogger.h"
#include "oidc-gen/promptAndSet/name.h"
#include "utils/agentLogger.h"
#include "utils/config/agent_config.h"
#include "utils/config/gen_config.h"
#include "utils/config/issuerConfig.h"
#include "utils/crypt/crypt.h"
Expand Down Expand Up @@ -288,15 +289,16 @@ int main(int argc, char** argv) {
}

set_prompt_mode(PROMPT_MODE_GUI);
int inotify_fd = -1;
#ifdef __linux__
set_restart_agent_args(argc, argv);
int inotify_fd = inotify_watch(AGENT_PATH);
if (inotify_fd < 0) {
agent_log(ERROR, "%s", oidc_serror());
exit(EXIT_FAILURE);
if (getAgentConfig()->restart_after_update) {
set_restart_agent_args(argc, argv);
inotify_fd = inotify_watch(AGENT_PATH);
if (inotify_fd < 0) {
agent_log(ERROR, "%s", oidc_serror());
exit(EXIT_FAILURE);
}
}
#else
int inotify_fd = -1;
#endif
handleClientComm(pipes, inotify_fd, &arguments, parent_alive_interval);
}
Expand Down
9 changes: 7 additions & 2 deletions src/utils/config/agent_config.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@ static agent_config_t* _getAgentConfig(const char* json) {
CONFIG_KEY_DEBUGLOGGING, IPC_KEY_LIFETIME, CONFIG_KEY_GROUP,
IPC_KEY_ALWAYSALLOWID, CONFIG_KEY_AUTOGEN,
CONFIG_KEY_AUTOGENSCOPEMODE, CONFIG_KEY_STATSCOLLECT,
CONFIG_KEY_STATSCOLLECTSHARE, CONFIG_KEY_STATSCOLLECTLOCATION);
CONFIG_KEY_STATSCOLLECTSHARE, CONFIG_KEY_STATSCOLLECTLOCATION,
CONFIG_KEY_RESTARTAFTERUPDATE);
if (getJSONValuesFromString(json, pairs, sizeof(pairs) / sizeof(*pairs)) <
0) {
SEC_FREE_KEY_VALUES();
Expand All @@ -43,7 +44,8 @@ static agent_config_t* _getAgentConfig(const char* json) {
KEY_VALUE_VARS(cert_path, bind_address, confirm, autoload, autoreauth,
customurischeme, webserver, debug, lifetime, group,
alwaysallowidtoken, autogen, autogenscopemode, stats_collect,
stats_collect_share, stats_collect_location);
stats_collect_share, stats_collect_location,
restart_after_update);
agent_config_t* c = secAlloc(sizeof(agent_config_t));
c->cert_path = oidc_strcopy(_cert_path);
c->bind_address = oidc_strcopy(_bind_address);
Expand All @@ -58,6 +60,9 @@ static agent_config_t* _getAgentConfig(const char* json) {
c->stats_collect = strToBit(_stats_collect);
c->stats_collect_share = strToBit(_stats_collect_share);
c->stats_collect_location = strToBit(_stats_collect_location);
c->restart_after_update = strValid(_restart_after_update)
? strToBit(_restart_after_update)
: 1; // default is on
if (strValid(_autogenscopemode)) {
if (strcaseequal(_autogenscopemode, CONFIG_VALUE_SCOPEMODE_EXACT)) {
c->autogenscopemode = AGENTCONFIG_AUTOGENSCOPEMODE_EXACT;
Expand Down
1 change: 1 addition & 0 deletions src/utils/config/agent_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ struct agent_config {
unsigned char stats_collect : 1;
unsigned char stats_collect_share : 1;
unsigned char stats_collect_location : 1;
unsigned char restart_after_update : 1;
time_t lifetime;
char* group;
};
Expand Down

0 comments on commit 95a7089

Please sign in to comment.