Without calling umask() we create and use insecure temporary files that
can leave application and system data vulnerable to attack. Unlikely in
a module created for testing, but better fix it.
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Michael Adam <obnox@samba.org>
#include "config.h"
#include <sys/param.h>
+#include <sys/types.h>
+#include <sys/stat.h>
#include <pwd.h>
#include <stdlib.h>
struct pam_lib_items *pli)
{
int rv;
+ mode_t old_mask;
FILE *fp = NULL;
FILE *fp_tmp = NULL;
char buf[BUFSIZ];
}
/* We don't support concurrent runs.. */
+ old_mask = umask(0);
rv = mkstemp(template);
+ umask(old_mask);
if (rv <= 0) {
rv = PAM_BUF_ERR;
goto done;