mirror of
https://github.com/Yubico/yubico-pam.git
synced 2025-02-01 01:52:17 +01:00
Merge branch 'pr-192'
This commit is contained in:
commit
fcfcba6c2f
32
pam_yubico.c
32
pam_yubico.c
@ -790,6 +790,9 @@ restpriv_out:
|
|||||||
static void
|
static void
|
||||||
parse_cfg (int flags, int argc, const char **argv, struct cfg *cfg)
|
parse_cfg (int flags, int argc, const char **argv, struct cfg *cfg)
|
||||||
{
|
{
|
||||||
|
struct stat st;
|
||||||
|
FILE *file = NULL;
|
||||||
|
int fd = -1;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
memset (cfg, 0, sizeof(struct cfg));
|
memset (cfg, 0, sizeof(struct cfg));
|
||||||
@ -879,24 +882,15 @@ parse_cfg (int flags, int argc, const char **argv, struct cfg *cfg)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
struct stat st;
|
fd = open(filename, O_WRONLY | O_APPEND | O_CLOEXEC | O_NOFOLLOW | O_NOCTTY);
|
||||||
int fd;
|
if (fd >= 0 && (fstat(fd, &st) == 0) && S_ISREG(st.st_mode))
|
||||||
FILE *file;
|
|
||||||
if(lstat(filename, &st) == 0)
|
|
||||||
{
|
{
|
||||||
if(S_ISREG(st.st_mode))
|
file = fdopen(fd, "a");
|
||||||
|
if(file != NULL)
|
||||||
{
|
{
|
||||||
fd = open(filename, O_WRONLY | O_CREAT | O_APPEND | O_CLOEXEC, S_IRUSR | S_IWUSR | S_IRGRP);
|
cfg->debug_file = file;
|
||||||
if (fd >= 0)
|
file = NULL;
|
||||||
{
|
fd = -1;
|
||||||
file = fdopen(fd, "a");
|
|
||||||
if (file)
|
|
||||||
{
|
|
||||||
cfg->debug_file = file;
|
|
||||||
} else {
|
|
||||||
close(fd);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -940,6 +934,12 @@ parse_cfg (int flags, int argc, const char **argv, struct cfg *cfg)
|
|||||||
DBG ("token_id_length=%u", cfg->token_id_length);
|
DBG ("token_id_length=%u", cfg->token_id_length);
|
||||||
DBG ("mode=%s", cfg->mode == CLIENT ? "client" : "chresp" );
|
DBG ("mode=%s", cfg->mode == CLIENT ? "client" : "chresp" );
|
||||||
DBG ("chalresp_path=%s", cfg->chalresp_path ? cfg->chalresp_path : "(null)");
|
DBG ("chalresp_path=%s", cfg->chalresp_path ? cfg->chalresp_path : "(null)");
|
||||||
|
|
||||||
|
if (fd != -1)
|
||||||
|
close(fd);
|
||||||
|
|
||||||
|
if (file != NULL)
|
||||||
|
fclose(file);
|
||||||
}
|
}
|
||||||
|
|
||||||
PAM_EXTERN int
|
PAM_EXTERN int
|
||||||
|
@ -250,7 +250,7 @@ do_add_hmac_chalresp(YK_KEY *yk, uint8_t slot, bool verbose, char *output_dir, u
|
|||||||
|
|
||||||
umask(077);
|
umask(077);
|
||||||
|
|
||||||
fd = open (fn, O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC, S_IRUSR | S_IWUSR);
|
fd = open (fn, O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC | O_NOFOLLOW | O_NOCTTY, S_IRUSR | S_IWUSR);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
fprintf (stderr, "Failed to open '%s' for writing: %s\n", fn, strerror (errno));
|
fprintf (stderr, "Failed to open '%s' for writing: %s\n", fn, strerror (errno));
|
||||||
goto out;
|
goto out;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user