os/error.rs
1//! Error types for the OS layer.
2
3use engine::ObjectId;
4
5/// The error type for OS-layer operations.
6///
7/// Engine errors are carried transparently via [`OsError::Engine`].
8#[derive(Debug, thiserror::Error, PartialEq, Eq)]
9pub enum OsError {
10 /// An underlying Engine operation failed.
11 #[error(transparent)]
12 Engine(#[from] engine::Error),
13
14 /// A user with the same name or id already exists.
15 #[error("user `{0}` already exists")]
16 UserAlreadyExists(String),
17
18 /// A group with the same name or id already exists.
19 #[error("group `{0}` already exists")]
20 GroupAlreadyExists(String),
21
22 /// Authentication failed because the credentials do not match.
23 ///
24 /// The same error is returned for unknown users and wrong passwords, so
25 /// the existence of an account is not revealed.
26 #[error("authentication failed for `{0}`")]
27 AuthenticationFailed(String),
28
29 /// The account exists but is locked and cannot authenticate.
30 #[error("account `{0}` is locked")]
31 LockedAccount(String),
32
33 /// A user referenced by id does not exist.
34 #[error("no user with id {0}")]
35 UnknownUserId(u32),
36
37 /// A group referenced by id does not exist.
38 #[error("no group with id {0}")]
39 UnknownGroupId(u32),
40
41 /// A user referenced by name does not exist.
42 #[error("no user named `{0}`")]
43 UnknownUser(String),
44
45 /// A group referenced by name does not exist.
46 #[error("no group named `{0}`")]
47 UnknownGroup(String),
48
49 /// The object carries no Unix security attributes.
50 #[error("object {0} has no Unix attributes")]
51 MissingUnixAttrs(ObjectId),
52
53 /// The object carries malformed Unix security attributes.
54 #[error("object {0} has invalid Unix attributes: {1}")]
55 InvalidUnixAttrs(ObjectId, String),
56
57 /// A mode string could not be parsed as octal.
58 #[error("`{0}` is not a valid octal mode")]
59 InvalidMode(String),
60
61 /// The credentials cannot be elevated to the requested identity.
62 #[error("cannot elevate to uid {0}")]
63 InvalidElevation(u32),
64
65 /// A path argument was malformed or unsafe.
66 #[error("invalid path argument `{0}`")]
67 InvalidPathArgument(String),
68
69 /// A command invocation lacked a required positional argument.
70 #[error("{command}: missing argument {index}")]
71 MissingArgument {
72 /// The command that reported the error.
73 command: String,
74 /// The zero-based argument index.
75 index: usize,
76 },
77
78 /// A file could not be executed.
79 #[error("cannot execute `{0}`")]
80 CannotExecute(String),
81
82 /// The session is not authorized to execute the object.
83 #[error("execute permission denied for object {0}")]
84 ExecuteDenied(ObjectId),
85
86 /// A network interface referenced by name does not exist.
87 #[error("no network interface named `{0}`")]
88 UnknownInterface(String),
89
90 /// The account lacks the privileges the operation requires
91 /// (administrative rights on Windows).
92 #[error("Access is denied.")]
93 AccessDenied,
94}