|
| 1 | +// Copyright (c) 2018, Ben Boeckel |
| 2 | +// All rights reserved. |
| 3 | +// |
| 4 | +// Redistribution and use in source and binary forms, with or without modification, |
| 5 | +// are permitted provided that the following conditions are met: |
| 6 | +// |
| 7 | +// * Redistributions of source code must retain the above copyright notice, |
| 8 | +// this list of conditions and the following disclaimer. |
| 9 | +// * Redistributions in binary form must reproduce the above copyright notice, |
| 10 | +// this list of conditions and the following disclaimer in the documentation |
| 11 | +// and/or other materials provided with the distribution. |
| 12 | +// * Neither the name of this project nor the names of its contributors |
| 13 | +// may be used to endorse or promote products derived from this software |
| 14 | +// without specific prior written permission. |
| 15 | +// |
| 16 | +// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
| 17 | +// ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 18 | +// WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 19 | +// DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR |
| 20 | +// ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 21 | +// (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 22 | +// LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON |
| 23 | +// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 24 | +// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 25 | +// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 26 | + |
| 27 | +// Ignore rustfmt changes in here. The horizontal alignment is too useful to give up. |
| 28 | +#![cfg_attr(rustfmt, rustfmt_skip)] |
| 29 | + |
| 30 | +use crate::{KeyPermissions, KeyringSerial}; |
| 31 | + |
| 32 | +// TODO: change these to &CStr when const fns get unblocked. |
| 33 | +pub const KEY_TYPE_KEYRING: &str = "keyring"; |
| 34 | +pub const KEY_TYPE_USER: &str = "user"; |
| 35 | +pub const KEY_TYPE_LOGON: &str = "logon"; |
| 36 | +pub const KEY_TYPE_BIG_KEY: &str = "big_key"; |
| 37 | + |
| 38 | +pub const KEY_SPEC_THREAD_KEYRING: KeyringSerial = unsafe { KeyringSerial::new_unchecked(-1) }; |
| 39 | +pub const KEY_SPEC_PROCESS_KEYRING: KeyringSerial = unsafe { KeyringSerial::new_unchecked(-2) }; |
| 40 | +pub const KEY_SPEC_SESSION_KEYRING: KeyringSerial = unsafe { KeyringSerial::new_unchecked(-3) }; |
| 41 | +pub const KEY_SPEC_USER_KEYRING: KeyringSerial = unsafe { KeyringSerial::new_unchecked(-4) }; |
| 42 | +pub const KEY_SPEC_USER_SESSION_KEYRING: KeyringSerial = unsafe { KeyringSerial::new_unchecked(-5) }; |
| 43 | +pub const KEY_SPEC_GROUP_KEYRING: KeyringSerial = unsafe { KeyringSerial::new_unchecked(-6) }; |
| 44 | +pub const KEY_SPEC_REQKEY_AUTH_KEY: KeyringSerial = unsafe { KeyringSerial::new_unchecked(-7) }; |
| 45 | + |
| 46 | +pub const KEY_POS_VIEW: KeyPermissions = 0x0100_0000; /* possessor can view a key's attributes */ |
| 47 | +pub const KEY_POS_READ: KeyPermissions = 0x0200_0000; /* possessor can read key payload / view keyring */ |
| 48 | +pub const KEY_POS_WRITE: KeyPermissions = 0x0400_0000; /* possessor can update key payload / add link to keyring */ |
| 49 | +pub const KEY_POS_SEARCH: KeyPermissions = 0x0800_0000; /* possessor can find a key in search / search a keyring */ |
| 50 | +pub const KEY_POS_LINK: KeyPermissions = 0x1000_0000; /* possessor can create a link to a key/keyring */ |
| 51 | +pub const KEY_POS_SETATTR: KeyPermissions = 0x2000_0000; /* possessor can set key attributes */ |
| 52 | +pub const KEY_POS_ALL: KeyPermissions = 0x3f00_0000; |
| 53 | + |
| 54 | +pub const KEY_USR_VIEW: KeyPermissions = 0x0001_0000; /* user permissions... */ |
| 55 | +pub const KEY_USR_READ: KeyPermissions = 0x0002_0000; |
| 56 | +pub const KEY_USR_WRITE: KeyPermissions = 0x0004_0000; |
| 57 | +pub const KEY_USR_SEARCH: KeyPermissions = 0x0008_0000; |
| 58 | +pub const KEY_USR_LINK: KeyPermissions = 0x0010_0000; |
| 59 | +pub const KEY_USR_SETATTR: KeyPermissions = 0x0020_0000; |
| 60 | +pub const KEY_USR_ALL: KeyPermissions = 0x003f_0000; |
| 61 | + |
| 62 | +pub const KEY_GRP_VIEW: KeyPermissions = 0x0000_0100; /* group permissions... */ |
| 63 | +pub const KEY_GRP_READ: KeyPermissions = 0x0000_0200; |
| 64 | +pub const KEY_GRP_WRITE: KeyPermissions = 0x0000_0400; |
| 65 | +pub const KEY_GRP_SEARCH: KeyPermissions = 0x0000_0800; |
| 66 | +pub const KEY_GRP_LINK: KeyPermissions = 0x0000_1000; |
| 67 | +pub const KEY_GRP_SETATTR: KeyPermissions = 0x0000_2000; |
| 68 | +pub const KEY_GRP_ALL: KeyPermissions = 0x0000_3f00; |
| 69 | + |
| 70 | +pub const KEY_OTH_VIEW: KeyPermissions = 0x0000_0001; /* third party permissions... */ |
| 71 | +pub const KEY_OTH_READ: KeyPermissions = 0x0000_0002; |
| 72 | +pub const KEY_OTH_WRITE: KeyPermissions = 0x0000_0004; |
| 73 | +pub const KEY_OTH_SEARCH: KeyPermissions = 0x0000_0008; |
| 74 | +pub const KEY_OTH_LINK: KeyPermissions = 0x0000_0010; |
| 75 | +pub const KEY_OTH_SETATTR: KeyPermissions = 0x0000_0020; |
| 76 | +pub const KEY_OTH_ALL: KeyPermissions = 0x0000_003f; |
0 commit comments