mbfile check directory test is improved

This commit is contained in:
Michiel Broek 2002-04-22 20:49:03 +00:00
parent 92c739f160
commit 24f0892f8d
3 changed files with 64 additions and 5 deletions

View File

@ -4590,6 +4590,7 @@ v0.33.20 10-Feb-2002
Go into global configuration, exit and save, this will update Go into global configuration, exit and save, this will update
the main configuration (add default macro path). the main configuration (add default macro path).
Edit the message groups and file groups for new settings. Edit the message groups and file groups for new settings.
Run mbfile check to fix download directory permissions.
general: general:
Added structures for area maintenance with area lists. 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 The mbfile index command now creates the html pages using the
macro templates html.main and html.areas. The files.css file macro templates html.main and html.areas. The files.css file
is no longer needed. 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: mball:
Will not crash anymore when it needs more then 10 minutes to Will not crash anymore when it needs more then 10 minutes to

View File

@ -12,7 +12,7 @@
</HEAD> </HEAD>
<BODY> <BODY>
<BLOCKQUOTE> <BLOCKQUOTE>
<h5>Last update 09-Feb-2002</h5> <h5>Last update 22-Apr-2002</h5>
<P>&nbsp;<P> <P>&nbsp;<P>
<h1>MBSE BBS Basic Installation</h1> <h1>MBSE BBS Basic Installation</h1>
@ -39,8 +39,7 @@ layout looks like this:<br>
/opt/mbse/english/txtfiles 0755 Default english ANSI files /opt/mbse/english/txtfiles 0755 Default english ANSI files
/opt/mbse/etc 0775 System configuration files /opt/mbse/etc 0775 System configuration files
/opt/mbse/fdb 0775 Files database /opt/mbse/fdb 0775 Files database
/opt/mbse/ftp/css 0755 Stylesheet for MBSE BBS pages. /opt/mbse/ftp/pub 0775 Default FTP root for download areas.
/opt/mbse/ftp/pub 0755 Default FTP root for download areas.
/opt/mbse/galego/macro 0755 N/A /opt/mbse/galego/macro 0755 N/A
/opt/mbse/galego/menus 0755 Galego menu files /opt/mbse/galego/menus 0755 Galego menu files
/opt/mbse/galego/txtfiles 0755 Galego ANSI files /opt/mbse/galego/txtfiles 0755 Galego ANSI files

View File

@ -63,7 +63,7 @@ extern int do_pack; /* Pack filebase */
void Check(void) void Check(void)
{ {
FILE *pAreas, *pFile; FILE *pAreas, *pFile;
int i, iAreas, iAreasNew = 0; int i, iAreas, iAreasNew = 0, Fix;
int iTotal = 0, iErrors = 0; int iTotal = 0, iErrors = 0;
char *sAreas, *fAreas, *newdir, *temp; char *sAreas, *fAreas, *newdir, *temp;
DIR *dp; DIR *dp;
@ -71,6 +71,8 @@ void Check(void)
int Found, Update; int Found, Update;
char fn[PATH_MAX]; char fn[PATH_MAX];
struct stat stb; struct stat stb;
struct passwd *pw;
struct group *gr;
sAreas = calloc(PATH_MAX, sizeof(char)); sAreas = calloc(PATH_MAX, sizeof(char));
fAreas = 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) { if (access(area.Path, R_OK) == -1) {
Syslog('!', "No dir: %s", area.Path); Syslog('!', "No dir: %s", area.Path);
sprintf(newdir, "%s/foobar", 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); sprintf(fAreas, "%s/fdb/fdb%d.data", getenv("MBSE_ROOT"), i);