check access rights of purge/dump dirs (must be readable/writable)
authorMiloš Mulač <mulac@civ.zcu.cz>
Mon, 31 Jul 2006 14:21:30 +0000 (14:21 +0000)
committerMiloš Mulač <mulac@civ.zcu.cz>
Mon, 31 Jul 2006 14:21:30 +0000 (14:21 +0000)
org.glite.lb.server/src/bkserverd.c

index 85924b4..cf4b9cc 100644 (file)
@@ -1398,7 +1398,7 @@ static int parse_limits(char *opt, int *j_limit, int *e_limit, int *size_limit)
 static int check_mkdir(const char *dir)
 {
        struct stat     sbuf;
-       
+
        if ( stat(dir, &sbuf) )
        {
                if ( errno == ENOENT )
@@ -1417,13 +1417,22 @@ static int check_mkdir(const char *dir)
                        return 1;
                }
        }
-       else if (S_ISDIR(sbuf.st_mode)) return 0;
-       else {
+
+       if (!S_ISDIR(sbuf.st_mode))
+       {
                dprintf(("[%d] %s: not a directory\n", getpid(),dir));
                if (!debug) syslog(LOG_CRIT,"%s: not a directory",dir);
                return 1;
        }
 
+       if (access(dir, R_OK | W_OK))
+       {
+               dprintf(("[%d] %s: dircectory is not readable/writable\n", getpid(),dir));
+               if (!debug) syslog(LOG_CRIT,"%s: dircectory is not readable/writable",dir);
+               return 1;
+       }
+               
+
        return 0;
 }