[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
If you call `al_findfirst' without FA_RDONLY and run as root, files
owned by non-root won't be matched (which is strange because root can
write to everything). This was reported by "Ceniza" on #allegro.
Patch attached.
Index: ufile.c
===================================================================
RCS file: /cvsroot/alleg/allegro/src/unix/ufile.c,v
retrieving revision 1.1
diff -u -r1.1 ufile.c
--- ufile.c 17 Dec 2001 11:14:48 -0000 1.1
+++ ufile.c 27 Mar 2002 06:09:04 -0000
@@ -264,17 +264,20 @@
static int ff_get_attrib(AL_CONST char *name, struct stat *s)
{
int attrib = 0;
+ int euid = geteuid();
- if (s->st_uid == geteuid()) {
- if ((s->st_mode & S_IWUSR) == 0)
- attrib |= FA_RDONLY;
- }
- else if (s->st_gid == getegid()) {
- if ((s->st_mode & S_IWGRP) == 0)
- attrib |= FA_RDONLY;
- }
- else if ((s->st_mode & S_IWOTH) == 0) {
- attrib |= FA_RDONLY;
+ if (euid != 0) {
+ if (s->st_uid == euid) {
+ if ((s->st_mode & S_IWUSR) == 0)
+ attrib |= FA_RDONLY;
+ }
+ else if (s->st_gid == getegid()) {
+ if ((s->st_mode & S_IWGRP) == 0)
+ attrib |= FA_RDONLY;
+ }
+ else if ((s->st_mode & S_IWOTH) == 0) {
+ attrib |= FA_RDONLY;
+ }
}
if (S_ISDIR(s->st_mode))