shm.c (132943) | shm.c (147078) |
---|---|
1/* | 1/* |
2 * Copyright (c) 2000-2001, 2003 Sendmail, Inc. and its suppliers. | 2 * Copyright (c) 2000-2001, 2003, 2005 Sendmail, Inc. and its suppliers. |
3 * All rights reserved. 4 * 5 * By using this file, you agree to the terms and conditions set 6 * forth in the LICENSE file which can be found at the top level of 7 * the sendmail distribution. 8 */ 9 10#include <sm/gen.h> | 3 * All rights reserved. 4 * 5 * By using this file, you agree to the terms and conditions set 6 * forth in the LICENSE file which can be found at the top level of 7 * the sendmail distribution. 8 */ 9 10#include <sm/gen.h> |
11SM_RCSID("@(#)$Id: shm.c,v 1.16 2003/06/13 21:18:08 ca Exp $") | 11SM_RCSID("@(#)$Id: shm.c,v 1.18 2005/02/09 01:54:51 ca Exp $") |
12 13#if SM_CONF_SHM 14# include <stdlib.h> 15# include <unistd.h> 16# include <errno.h> 17# include <sm/shm.h> 18 19 --- 79 unchanged lines hidden (view full) --- 99 if (shm != SM_SHM_NULL && (r = shmdt(shm)) < 0) 100 return r; 101 if (owner && shmid >= 0 && (r = shmctl(shmid, IPC_RMID, NULL)) < 0) 102 return r; 103 return 0; 104} 105 106 | 12 13#if SM_CONF_SHM 14# include <stdlib.h> 15# include <unistd.h> 16# include <errno.h> 17# include <sm/shm.h> 18 19 --- 79 unchanged lines hidden (view full) --- 99 if (shm != SM_SHM_NULL && (r = shmdt(shm)) < 0) 100 return r; 101 if (owner && shmid >= 0 && (r = shmctl(shmid, IPC_RMID, NULL)) < 0) 102 return r; 103 return 0; 104} 105 106 |
107/* 108** SM_SHMSETOWNER -- set owner/group/mode of shared memory segment. 109** 110** Parameters: 111** shmid -- id. 112** uid -- uid to use 113** gid -- gid to use 114** mode -- mode to use 115** 116** Returns: 117** 0 on success. 118** < 0 on failure. 119*/ 120 121int 122sm_shmsetowner(shmid, uid, gid, mode) 123 int shmid; 124 uid_t uid; 125 gid_t gid; 126 mode_t mode; 127{ 128 int r; 129 struct shmid_ds shmid_ds; 130 131 memset(&shmid_ds, 0, sizeof(shmid_ds)); 132 if ((r = shmctl(shmid, IPC_STAT, &shmid_ds)) < 0) 133 return r; 134 shmid_ds.shm_perm.uid = uid; 135 shmid_ds.shm_perm.gid = gid; 136 shmid_ds.shm_perm.mode = mode; 137 if ((r = shmctl(shmid, IPC_SET, &shmid_ds)) < 0) 138 return r; 139 return 0; 140} |
|
107#endif /* SM_CONF_SHM */ | 141#endif /* SM_CONF_SHM */ |