version 1.7, 2022/03/22 01:51:36 |
version 1.9, 2022/03/25 21:12:46 |
|
|
|
|
%{ |
%{ |
#include <sys/queue.h> |
#include <sys/queue.h> |
#include <sys/stat.h> |
|
|
|
#include <stdio.h> |
#include <stdio.h> |
#include <stdarg.h> |
#include <stdarg.h> |
#include <unistd.h> |
|
#include <ctype.h> |
#include <ctype.h> |
|
|
#include "blind.h" |
#include "blind.h" |
|
#include "config.h" |
#include "log.h" |
#include "log.h" |
|
|
TAILQ_HEAD(files, file) files = TAILQ_HEAD_INITIALIZER(files); |
TAILQ_HEAD(files, file) files = TAILQ_HEAD_INITIALIZER(files); |
Line 48 int kw_cmp(const void *, const void *); |
|
Line 47 int kw_cmp(const void *, const void *); |
|
int yyparse(void); |
int yyparse(void); |
int yylex(void); |
int yylex(void); |
int yyerror(const char *, ...) |
int yyerror(const char *, ...) |
__attribute__((__format__ (printf, 1, 2))) |
__attribute__((__format__ (printf, 1, 2))) |
__attribute__((__nonnull__ (1))); |
__attribute__((__nonnull__ (1))); |
|
|
int config_load(struct blind *); |
int config_load(struct blind *); |
struct file *config_push(const char *); |
struct file *config_push(const char *); |
int config_pop(void); |
int config_pop(void); |
int config_perm(int, const char *); |
|
|
|
|
|
TAILQ_HEAD(symhead, sym) symhead = TAILQ_HEAD_INITIALIZER(symhead); |
TAILQ_HEAD(symhead, sym) symhead = TAILQ_HEAD_INITIALIZER(symhead); |
struct sym { |
struct sym { |
TAILQ_ENTRY(sym) entry; |
TAILQ_ENTRY(sym) entry; |
Line 518 config_pop(void) |
|
Line 515 config_pop(void) |
|
file = prv; |
file = prv; |
|
|
return (file ? 0 : EOF); |
return (file ? 0 : EOF); |
} |
|
|
|
int |
|
config_perm(int fd, const char *name) |
|
{ |
|
struct stat st; |
|
|
|
if (fstat(fd, &st)) { |
|
log_debug("cannot stat config file"); |
|
return (-1); |
|
} |
|
if (st.st_uid != 0 && st.st_uid != getuid()) { |
|
log_debug("not root or current user owned"); |
|
return (-1); |
|
} |
|
if (st.st_mode & (S_IWGRP | S_IXGRP | S_IRWXO)) { |
|
log_debug("insecure config file"); |
|
return (-1); |
|
} |
|
return (0); |
|
} |
} |