From 24f0892f8d7c242601f7a6211c3a95f966a11ecc Mon Sep 17 00:00:00 2001 From: Michiel Broek Date: Mon, 22 Apr 2002 20:49:03 +0000 Subject: [PATCH] mbfile check directory test is improved --- ChangeLog | 4 ++++ html/basic.html | 5 ++-- mbfido/mbfcheck.c | 60 +++++++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 64 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 0a6cf7df..46cd83b8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -4590,6 +4590,7 @@ v0.33.20 10-Feb-2002 Go into global configuration, exit and save, this will update the main configuration (add default macro path). Edit the message groups and file groups for new settings. + Run mbfile check to fix download directory permissions. general: Added structures for area maintenance with area lists. @@ -4727,6 +4728,9 @@ v0.33.20 10-Feb-2002 The mbfile index command now creates the html pages using the macro templates html.main and html.areas. The files.css file is no longer needed. + The check function now checks download directory permissions + and tries to correct errors. + Missing download directories are created mode 0775. mball: Will not crash anymore when it needs more then 10 minutes to diff --git a/html/basic.html b/html/basic.html index b023ad35..eadac0cd 100755 --- a/html/basic.html +++ b/html/basic.html @@ -12,7 +12,7 @@
-
Last update 09-Feb-2002
+
Last update 22-Apr-2002

 

MBSE BBS Basic Installation

@@ -39,8 +39,7 @@ layout looks like this:
/opt/mbse/english/txtfiles 0755 Default english ANSI files /opt/mbse/etc 0775 System configuration files /opt/mbse/fdb 0775 Files database -/opt/mbse/ftp/css 0755 Stylesheet for MBSE BBS pages. -/opt/mbse/ftp/pub 0755 Default FTP root for download areas. +/opt/mbse/ftp/pub 0775 Default FTP root for download areas. /opt/mbse/galego/macro 0755 N/A /opt/mbse/galego/menus 0755 Galego menu files /opt/mbse/galego/txtfiles 0755 Galego ANSI files diff --git a/mbfido/mbfcheck.c b/mbfido/mbfcheck.c index 9abe449f..af0f7b5b 100644 --- a/mbfido/mbfcheck.c +++ b/mbfido/mbfcheck.c @@ -63,7 +63,7 @@ extern int do_pack; /* Pack filebase */ void Check(void) { FILE *pAreas, *pFile; - int i, iAreas, iAreasNew = 0; + int i, iAreas, iAreasNew = 0, Fix; int iTotal = 0, iErrors = 0; char *sAreas, *fAreas, *newdir, *temp; DIR *dp; @@ -71,6 +71,8 @@ void Check(void) int Found, Update; char fn[PATH_MAX]; struct stat stb; + struct passwd *pw; + struct group *gr; sAreas = calloc(PATH_MAX, sizeof(char)); fAreas = calloc(PATH_MAX, sizeof(char)); @@ -114,7 +116,61 @@ void Check(void) if (access(area.Path, R_OK) == -1) { Syslog('!', "No dir: %s", area.Path); sprintf(newdir, "%s/foobar", area.Path); - mkdirs(newdir, 0755); + mkdirs(newdir, 0775); + } + + if (stat(area.Path, &stb) == 0) { + /* + * Very extended directory check + */ + Fix = FALSE; + if ((stb.st_mode & S_IRUSR) == 0) { + Fix = TRUE; + WriteError("No owner read access in %s, mode is %04o", area.Path, stb.st_mode & 0x1ff); + } + if ((stb.st_mode & S_IWUSR) == 0) { + Fix = TRUE; + WriteError("No owner write access in %s, mode is %04o", area.Path, stb.st_mode & 0x1ff); + } + if ((stb.st_mode & S_IRGRP) == 0) { + Fix = TRUE; + WriteError("No group read access in %s, mode is %04o", area.Path, stb.st_mode & 0x1ff); + } + if ((stb.st_mode & S_IWGRP) == 0) { + Fix = TRUE; + WriteError("No group write access in %s, mode is %04o", area.Path, stb.st_mode & 0x1ff); + } + if ((stb.st_mode & S_IROTH) == 0) { + Fix = TRUE; + WriteError("No others read access in %s, mode is %04o", area.Path, stb.st_mode & 0x1ff); + } + if (Fix) { + if (chmod(area.Path, 0775)) + WriteError("Could not set mode to 0775"); + else + Syslog('+', "Corrected directory mode to 0775"); + } + Fix = FALSE; + pw = getpwuid(stb.st_uid); + if (strcmp(pw->pw_name, (char *)"mbse")) { + WriteError("Directory %s not owned by user mbse", area.Path); + Fix = TRUE; + } + gr = getgrgid(stb.st_gid); + if (strcmp(gr->gr_name, (char *)"bbs")) { + WriteError("Directory %s not owned by group bbs", area.Path); + Fix = TRUE; + } + if (Fix) { + pw = getpwnam((char *)"mbse"); + gr = getgrnam((char *)"bbs"); + if (chown(area.Path, pw->pw_gid, gr->gr_gid)) + WriteError("Could not set owner to mbse.bbs"); + else + Syslog('+', "Corrected directory owner to mbse.bbs"); + } + } else { + WriteError("Can't stat %s", area.Path); } sprintf(fAreas, "%s/fdb/fdb%d.data", getenv("MBSE_ROOT"), i);