游俊德 wrote:
> Hello,
> 
> I have a question about source code of shm_open and sem_open functions.
> 
> int
> shm_open(const char *path, int flags, mode_t mode)
> {
> ........ (skipped) ....
> 
>         if (sb,st_uid != getuid()) {
>                 close(fd);
>                errno = EPERM;
>                 return -1;
>         }
> 
> ........ (skipped) ....
> }
> 
> I know the UID comparison is used to avoid share memory accessed by
> different user. Similar code also existed in sem_open function.
> 
> My question is, why it is getuid(), why not use geteuid()?
> I am not sure if it is bug or not, but I think it is more reasonable
> if it checked
> by effective user id,

geteuid may be better. though i would hope the difference doesn't matter.

Reply via email to