Skip to content

Commit bb13d1c

Browse files
committed
Parse gid from relative portion of on-premises SID
1 parent a9f4f14 commit bb13d1c

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/azure.rs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,20 @@ fn extract_group_info(group: &Value) -> GraphInfoResult<GroupInfo> {
121121
.as_str()
122122
.ok_or(GraphInfoRetrievalError::BadJSONResponse)?
123123
.to_string();
124-
// we punt the question of a GID
124+
let mut sid_parts : Vec<&str> = group["onPremisesSecurityIdentifier"]
125+
.as_str()
126+
.ok_or(GraphInfoRetrievalError::BadJSONResponse)?
127+
.split('-').collect();
128+
let group_id = sid_parts.pop().unwrap().parse::<u32>()?;
129+
// rid < 1000 should only be built-in groups
130+
if group_id < 1000 {
131+
return Err(GraphInfoRetrievalError::UnusableImmutableID);
132+
}
125133

126134
Ok(GroupInfo {
127135
groupname: group_name,
128136
object_id: object_id,
137+
group_id: group_id,
129138
})
130139
}
131140

src/lib.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ pub struct UserInfo {
6666
pub struct GroupInfo {
6767
groupname: String,
6868
object_id: String,
69+
group_id: u32
6970
}
7071

7172
/// The initgroups_dyn function populates a list of GIDs to which the named user belongs.
@@ -238,7 +239,7 @@ pub extern "C" fn _nss_aad_getgrnam_r(name: *const c_char,
238239
};
239240

240241
match fill_group_buf(result,
241-
config.group_ids[name],
242+
groupinfo.group_id as gid_t,
242243
buffer,
243244
buflen,
244245
name,

0 commit comments

Comments
 (0)