From 8bfcdd723d0840d49f6bfb5576e631215aabfc50 Mon Sep 17 00:00:00 2001 From: Andrew Tridgell Date: Wed, 30 May 2001 06:12:21 +0000 Subject: make swat recover from previously bad umask from xinetd (This used to be commit 045d7e1b167efc75bb3d411b3fcc35bba58c4ef7) --- source3/web/swat.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/source3/web/swat.c b/source3/web/swat.c index b25641909f1..71239d56813 100644 --- a/source3/web/swat.c +++ b/source3/web/swat.c @@ -344,8 +344,7 @@ static void write_config(FILE *f, BOOL show_defaults, char *(*dos_to_ext)(char * static int save_reload(int snum) { FILE *f; - - umask(022); + struct stat st; f = sys_fopen(servicesf,"w"); if (!f) { @@ -353,6 +352,12 @@ static int save_reload(int snum) return 0; } + /* just in case they have used the buggy xinetd to create the file */ + if (fstat(fileno(f), &st) == 0 && + (st.st_mode & S_IWOTH)) { + fchmod(fileno(f), S_IWUSR | S_IRUSR | S_IRGRP | S_IROTH); + } + write_config(f, False, _dos_to_unix); if (snum) lp_dump_one(f, False, snum, _dos_to_unix); @@ -986,6 +991,7 @@ static void printers_page(void) char *page; fault_setup(NULL); + umask(S_IWGRP | S_IWOTH); #if defined(HAVE_SET_AUTH_PARAMETERS) set_auth_parameters(argc, argv); -- cgit