Question: I have 2 question:

1. Consider the situation where Alice runs a owned Set-UID program
by Bob. The program wants to read the file contained in / etc / data, readable by
Alice, but by no one else. Can this program access the file?
2. Consider the situation where a process wants to access a file for reading;
the effective user ID of the process is 3000 and the real user ID is 4000. If the file is readable
for user ID 4000, but not for user ID 3000, this process can access the
file?

Answer: 
These are really the same question, and the answer in both cases is no, *unless* the program uses `setresuid` to change its effective UID to its real UID, or it uses `setfsuid` (Linux-specific) to change its filesystem UID to its real UID. But the program would have to be designed for this scenario; an ordinary program that never manipulates its UID/GID and just accesses files will fail the permission check.
Here is a concrete example of how to answer your part 1 question in code:

```
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>

static void flipuids(void) {
    uid_t r = getuid();
    uid_t e = geteuid();
    if (setreuid(e, r)) {
        perror("failed to flip");
        exit(1);
    }
}

int main(int argc, char *argv[]) {
    printf("euid=%d uid=%d\n", geteuid(), getuid());
    flipuids();
    printf("euid=%d uid=%d\n", geteuid(), getuid());
    FILE *file = fopen("/tmp/alices", "r");
    if (file == NULL) {
        perror("no reads");
        exit(1);
    }
    flipuids();
    printf("euid=%d uid=%d\n", geteuid(), getuid());
    fclose(file);
}

```

If you `chmod +s ./uidaccess` to make sure that the program has these permissions:

```
$ ls -l ./uidaccess
-rwsr-sr-x 1 bob bob 17008 Apr 18 09:34 uidaccess

```

Once the program is run by `alice`, it is an example of a process operating as described in your part 2 question.