ntvfs: Fix Coverity ID 240791 Uninitialized scalar variable
[samba4-gss.git] / rust / sock / src / proto.rs
blob728637ac807864febbe204ad6afdb9923affed65
1 /*
2    Unix SMB/CIFS implementation.
4    Unix socket communication for the Himmelblau daemon
6    Copyright (C) David Mulder 2024
8    This program is free software; you can redistribute it and/or modify
9    it under the terms of the GNU General Public License as published by
10    the Free Software Foundation; either version 3 of the License, or
11    (at your option) any later version.
13    This program is distributed in the hope that it will be useful,
14    but WITHOUT ANY WARRANTY; without even the implied warranty of
15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16    GNU General Public License for more details.
18    You should have received a copy of the GNU General Public License
19    along with this program.  If not, see <http://www.gnu.org/licenses/>.
21 use libc::uid_t;
22 use libnss::group::Group as NssGroup;
23 use libnss::passwd::Passwd as NssPasswd;
24 use serde::{Deserialize, Serialize};
26 #[derive(Debug, Serialize, Deserialize)]
27 pub struct Passwd {
28     pub name: String,
29     pub passwd: String,
30     pub uid: u32,
31     pub gid: u32,
32     pub gecos: String,
33     pub dir: String,
34     pub shell: String,
37 impl From<Passwd> for NssPasswd {
38     fn from(val: Passwd) -> Self {
39         NssPasswd {
40             name: val.name,
41             passwd: val.passwd,
42             uid: val.uid,
43             gid: val.gid,
44             gecos: val.gecos,
45             dir: val.dir,
46             shell: val.shell,
47         }
48     }
51 #[derive(Debug, Serialize, Deserialize)]
52 pub struct Group {
53     pub name: String,
54     pub passwd: String,
55     pub gid: u32,
56     pub members: Vec<String>,
59 impl From<Group> for NssGroup {
60     fn from(val: Group) -> Self {
61         NssGroup {
62             name: val.name,
63             passwd: val.passwd,
64             gid: val.gid,
65             members: val.members,
66         }
67     }
70 #[derive(Serialize, Deserialize)]
71 pub enum PamAuthRequest {
72     Password { cred: String },
73     MFACode { cred: String },
74     MFAPoll { poll_attempt: u32 },
75     SetupPin { pin: String },
76     Pin { pin: String },
79 #[derive(Serialize, Deserialize)]
80 pub enum Request {
81     NssAccounts,
82     NssAccountByUid(uid_t),
83     NssAccountByName(String),
84     NssGroups,
85     NssGroupByGid(uid_t),
86     NssGroupByName(String),
87     PamAuthenticateInit(String),
88     PamAuthenticateStep(PamAuthRequest),
89     PamAccountAllowed(String),
90     PamAccountBeginSession(String),
93 #[derive(Debug, Serialize, Deserialize)]
94 pub enum PamAuthResponse {
95     Unknown,
96     Success,
97     Denied,
98     Password,
99     MFACode { msg: String },
100     MFAPoll { msg: String, polling_interval: u32 },
101     MFAPollWait,
102     SetupPin { msg: String },
103     Pin,
106 #[derive(Debug, Serialize, Deserialize)]
107 pub enum Response {
108     NssAccounts(Vec<Passwd>),
109     NssAccount(Option<Passwd>),
110     NssGroups(Vec<Group>),
111     NssGroup(Option<Group>),
112     PamStatus(Option<bool>),
113     PamAuthStepResponse(PamAuthResponse),
114     Success,
115     Error,