netlib.narod.ru< Назад | Оглавление | Далее >

ipc/util.c

22325 /*
22326  * linux/ipc/util.c
22327  * Copyright (C) 1992 Krishna Balasubramanian
22328  *
22329  * Sep 1997 - Call suser() last after "normal" permission
22330  * checks so we get BSD style process accounting right.
22331  * Occurs in several places in the IPC code.  Chris
22332  * Evans, <chris@ferret.lmh.ox.ac.uk>
22333  */
22334 
22335 #include <linux/config.h>
22336 #include <linux/mm.h>
22337 #include <linux/shm.h>
22338 #include <linux/init.h>
22339 #include <linux/msg.h>
22340 
22341 #if defined(CONFIG_SYSVIPC)
22342 
22343 extern void sem_init(void), msg_init(void),
22344   shm_init(void);
22345 
22346 void __init ipc_init (void)
22347 {
22348   sem_init();
22349   msg_init();
22350   shm_init();
22351   return;
22352 }
22353 
22354 /* Check user, group, other permissions for access to ipc
22355  * resources. return 0 if allowed */
22356 int ipcperms (struct ipc_perm *ipcp, short flag)
22357 {
22358   /* flag will most probably be 0 or S_...UGO from
22359    * <linux/stat.h> */
22360   int requested_mode, granted_mode;
22361 
22362   requested_mode = (flag >> 6) | (flag >> 3) | flag;
22363   granted_mode = ipcp->mode;
22364   if (current->euid == ipcp->cuid ||
22365       current->euid == ipcp->uid)
22366     granted_mode >>= 6;
22367   else if (in_group_p(ipcp->cgid) ||
22368            in_group_p(ipcp->gid))
22369     granted_mode >>= 3;
22370   /* is there some bit set in requested_mode but not in
22371    * granted_mode? */
22372   if ((requested_mode & ~granted_mode & 0007) &&
22373       !capable(CAP_IPC_OWNER))
22374     return -1;
22375 
22376   return 0;
22377 }
22378 
22379 #else
22380 /* Dummy functions when SYSV IPC isn't configured */
22381 
22382 void sem_exit (void)
22383 {
22384     return;
22385 }
22386 
22387 int shm_swap (int prio, int gfp_mask)
22388 {
22389     return 0;
22390 }
22391 
22392 asmlinkage int sys_semget (key_t key, int nsems,
22393                            int semflg)
22394 {
22395   return -ENOSYS;
22396 }
22397 
22398 asmlinkage int sys_semop (int semid, struct sembuf *sops,
22399                           unsigned nsops)
22400 {
22401   return -ENOSYS;
22402 }
22403 
22404 asmlinkage int sys_semctl (int semid, int semnum,
22405                            int cmd, union semun arg)
22406 {
22407   return -ENOSYS;
22408 }
22409 
22410 asmlinkage int sys_msgget (key_t key, int msgflg)
22411 {
22412   return -ENOSYS;
22413 }
22414 
22415 asmlinkage int sys_msgsnd (int msqid,
22416   struct msgbuf *msgp, size_t msgsz, int msgflg)
22417 {
22418   return -ENOSYS;
22419 }
22420 
22421 asmlinkage int sys_msgrcv(int msqid, struct msgbuf *msgp,
22422                    size_t msgsz, long msgtyp, int msgflg)
22423 {
22424   return -ENOSYS;
22425 }
22426 
22427 asmlinkage int sys_msgctl (int msqid, int cmd,
22428                            struct msqid_ds *buf)
22429 {
22430   return -ENOSYS;
22431 }
22432 
22433 asmlinkage int sys_shmget (key_t key, int size, int flag)
22434 {
22435   return -ENOSYS;
22436 }
22437 
22438 asmlinkage int sys_shmat (int shmid, char *shmaddr,
22439                           int shmflg, ulong *addr)
22440 {
22441   return -ENOSYS;
22442 }
22443 
22444 asmlinkage int sys_shmdt (char *shmaddr)
22445 {
22446   return -ENOSYS;
22447 }
22448 
22449 asmlinkage int sys_shmctl (int shmid, int cmd,
22450                            struct shmid_ds *buf)
22451 {
22452   return -ENOSYS;
22453 }
22454 
22455 void shm_unuse(unsigned long entry, unsigned long page)
22456 {
22457 }
22458 
22459 #endif /* CONFIG_SYSVIPC */

netlib.narod.ru< Назад | Оглавление | Далее >

Сайт управляется системой uCoz