Page MenuHome

permission_patch4.txt

File Metadata

Author
Shaul Kedem (shul)
Created
Nov 13 2013, 1:06 PM

permission_patch4.txt

Index: source/blender/src/filesel.c
===================================================================
RCS file: /cvsroot/bf-blender/blender/source/blender/src/filesel.c,v
retrieving revision 1.61
diff -u -b -B -r1.61 filesel.c
--- source/blender/src/filesel.c 28 Jul 2005 03:20:21 -0000 1.61
+++ source/blender/src/filesel.c 29 Aug 2005 16:22:35 -0000
@@ -127,6 +127,10 @@
#define STARTSWITH(x, y) (strncmp(x, y, sizeof(x) - 1) == 0)
+/* Check the user have permissions for a specific file */
+#define ACCESS_OK(st_mode,uid) ((st_mode & (S_IRGRP | S_IROTH)) || ((st_mode & S_IRUSR) && (uid ==getuid())))
+
+
static int is_a_library(SpaceFile *sfile, char *dir, char *group);
static void do_library_append(SpaceFile *sfile);
static void library_to_filelist(SpaceFile *sfile);
@@ -648,8 +652,10 @@
BLI_getwdN(wdir);
sfile->totfile= BLI_getdir(sfile->dir, &(sfile->filelist));
+
chdir(wdir);
+
if(sfile->sort!=FILE_SORTALPHA) sort_filelist(sfile);
sfile->maxnamelen= 0;
@@ -948,8 +954,13 @@
glRects(x-14, y, x-8, y+7);
}
- if(S_ISDIR(files->type)) BIF_ThemeColor(TH_TEXT_HI);
- else BIF_ThemeColor(TH_TEXT);
+ if(S_ISDIR(files->type)) {
+ if(ACCESS_OK(files->s.st_mode,files->s.st_uid)) { /* check readability of dir or if the dir belong to current user*/
+ BIF_ThemeColor(TH_TEXT_HI);
+ } else { /* else paint in red*/
+ BIF_ThemeColor(TH_REDALERT);
+ }
+ } else BIF_ThemeColor(TH_TEXT);
s = files->string;
if(s) {
@@ -1863,6 +1874,7 @@
case LEFTMOUSE:
case MIDDLEMOUSE:
+
if(mval[0]>scrollrct.xmin && mval[0]<scrollrct.xmax && mval[1]>scrollrct.ymin && mval[1]<scrollrct.ymax) {
do_filescroll(sfile);
}
@@ -1874,12 +1886,16 @@
if(act>=0 && act<sfile->totfile) {
if(S_ISDIR(sfile->filelist[act].type)) {
+ if(ACCESS_OK(sfile->filelist[act].s.st_mode, sfile->filelist[act].s.st_uid)) { /* check readability of dir or if the dir belong to current user*/
strcat(sfile->dir, sfile->filelist[act].relname);
strcat(sfile->dir,"/");
checkdir(sfile->dir);
freefilelist(sfile);
sfile->ofs= 0;
do_draw= 1;
+ } else {
+ notice("Lack of permissions forbids you from entering this directory");
+ }
}
else {
if( strcmp(sfile->file, sfile->filelist[act].relname)) {

Event Timeline