Skip to content

Commit

Permalink
Merge pull request #173 from lukegb/syslogaint
Browse files Browse the repository at this point in the history
Avoid calling openlog when using GLOME as a library
  • Loading branch information
pkern authored Jan 25, 2024
2 parents 7b24c3d + eb2199c commit 951687a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 1 addition & 4 deletions login/login.c
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ void login_syslog(glome_login_config_t* config, pam_handle_t* pamh,
if (config->options & SYSLOG) {
va_list args;
va_start(args, format);
vsyslog(priority, format, args);
vsyslog(LOG_MAKEPRI(LOG_AUTH, priority), format, args);
va_end(args);
}
}
Expand Down Expand Up @@ -498,9 +498,6 @@ int login_run(glome_login_config_t* config, const char** error_tag) {
config->options, config->username, config->login_path,
config->auth_delay_sec);
}
if (config->options & SYSLOG) {
openlog("glome-login", LOG_PID | LOG_CONS, LOG_AUTH);
}

int r = login_authenticate(config, NULL, error_tag);
if (r != 0) {
Expand Down
6 changes: 6 additions & 0 deletions login/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
// limitations under the License.

#include <stdlib.h>
#include <syslog.h>
#include <unistd.h>

#include "config.h"
Expand Down Expand Up @@ -65,6 +66,11 @@ int main(int argc, char* argv[]) {
return EXITCODE_PANIC;
}

// Initialize syslog, if we're going to log.
if (config.options & SYSLOG) {
openlog(NULL, LOG_PID | LOG_CONS, LOG_AUTH);
}

const char* error_tag = NULL;
int rc = login_run(&config, &error_tag);
if (rc) {
Expand Down

0 comments on commit 951687a

Please sign in to comment.