summaryrefslogtreecommitdiff
path: root/readconf.c
diff options
context:
space:
mode:
Diffstat (limited to 'readconf.c')
-rw-r--r--readconf.c23
1 files changed, 19 insertions, 4 deletions
diff --git a/readconf.c b/readconf.c
index ce0d1f753..096d1a71b 100644
--- a/readconf.c
+++ b/readconf.c
@@ -12,7 +12,7 @@
12 */ 12 */
13 13
14#include "includes.h" 14#include "includes.h"
15RCSID("$OpenBSD: readconf.c,v 1.128 2004/03/05 10:53:58 markus Exp $"); 15RCSID("$OpenBSD: readconf.c,v 1.129 2004/04/18 23:10:26 djm Exp $");
16 16
17#include "ssh.h" 17#include "ssh.h"
18#include "xmalloc.h" 18#include "xmalloc.h"
@@ -779,7 +779,8 @@ parse_int:
779 */ 779 */
780 780
781int 781int
782read_config_file(const char *filename, const char *host, Options *options) 782read_config_file(const char *filename, const char *host, Options *options,
783 int checkperm)
783{ 784{
784 FILE *f; 785 FILE *f;
785 char line[1024]; 786 char line[1024];
@@ -787,10 +788,24 @@ read_config_file(const char *filename, const char *host, Options *options)
787 int bad_options = 0; 788 int bad_options = 0;
788 789
789 /* Open the file. */ 790 /* Open the file. */
790 f = fopen(filename, "r"); 791 if ((f = fopen(filename, "r")) == NULL)
791 if (!f)
792 return 0; 792 return 0;
793 793
794 if (checkperm) {
795 struct stat sb;
796
797 if (fstat(fileno(f), &sb) == -1) {
798 fatal("fstat %s: %s", filename, strerror(errno));
799 fclose(f);
800 return (0);
801 }
802 if (((sb.st_uid != 0 && sb.st_uid != getuid()) ||
803 (sb.st_mode & 022) != 0)) {
804 fatal("Bad owner or permissions on %s", filename);
805 return 0;
806 }
807 }
808
794 debug("Reading configuration data %.200s", filename); 809 debug("Reading configuration data %.200s", filename);
795 810
796 /* 811 /*