Skip to content

Commit

Permalink
Merge pull request #412 from himmelblau-idm/stable-0.9.x_backports
Browse files Browse the repository at this point in the history
Stable 0.9.x backports
  • Loading branch information
dmulder authored Mar 4, 2025
2 parents e0a9a01 + 0686cd8 commit 8c48655
Show file tree
Hide file tree
Showing 6 changed files with 58 additions and 41 deletions.
28 changes: 14 additions & 14 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ members = [
resolver = "2"

[workspace.package]
version = "0.9.0"
version = "0.9.1"
authors = [
"David Mulder <[email protected]>"
]
Expand Down
4 changes: 2 additions & 2 deletions man/man5/himmelblau.conf.5
Original file line number Diff line number Diff line change
Expand Up @@ -147,12 +147,12 @@ Determines whether password-only (single-factor) authentication is permitted whe
enable_sfa_fallback = true

.TP
.B cn_to_upn_mapping
.B cn_name_mapping
.RE
Allows users to enter the short form of their username (e.g., 'dave') instead of the full UPN.

.EXAMPLES
cn_to_upn_mapping = true
cn_name_mapping = true

.TP
.B local_groups
Expand Down
2 changes: 1 addition & 1 deletion src/cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,7 @@ async fn main() -> ExitCode {
};

if !really {
error!("Are you sure you want to proceed? If so use --really");
error!("Are you sure you want to proceed? This will revert the host to an unjoined state while NOT removing the host object from Entra Id. If so use --really");
return ExitCode::SUCCESS;
}

Expand Down
11 changes: 10 additions & 1 deletion src/common/src/resolver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ use hashbrown::HashSet;
use libc::uid_t;
use std::collections::BTreeSet;
use std::fmt::Display;
use std::fs;
use std::num::NonZeroUsize;
use std::ops::{Add, DerefMut, Sub};
use std::path::Path;
Expand All @@ -23,6 +24,7 @@ use lru::LruCache;
use tokio::sync::Mutex;
use uuid::Uuid;

use crate::constants::SERVER_CONFIG_PATH;
use crate::db::{Cache, CacheTxn, Db};
use crate::idprovider::interface::{
AuthCacheAction,
Expand Down Expand Up @@ -229,7 +231,14 @@ where
let mut nxcache_txn = self.nxcache.lock().await;
nxcache_txn.clear();
let mut dbtxn = self.db.write().await;
dbtxn.clear().and_then(|_| dbtxn.commit()).map_err(|_| ())
dbtxn.clear().and_then(|_| dbtxn.commit()).map_err(|_| ())?;

// Also delete the generated himmelblau.conf. This unjoins the host!
let path = Path::new(SERVER_CONFIG_PATH);
if path.exists() {
fs::remove_file(path).map_err(|_| ())?;
}
Ok(())
}

pub async fn invalidate(&self) -> Result<(), ()> {
Expand Down
52 changes: 30 additions & 22 deletions src/daemon/src/tasks_daemon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -431,32 +431,40 @@ async fn handle_tasks(stream: UnixStream, cfg: &HimmelblauConfig) {
}
Some(Ok(TaskRequest::LoadProfilePhoto(mut account_id, access_token))) => {
debug!("Received task -> LoadProfilePhoto({}, ...)", account_id);
let domain = split_username(&access_token).map(|(_, domain)| domain);
account_id = cfg.map_upn_to_name(&account_id);
// Set the profile picture
if let Some(domain) = domain {
match File::create(format!("/var/lib/AccountsService/icons/{}", account_id)) {
Ok(file) => {
let authority_host = cfg.get_authority_host(&domain);
let tenant_id = cfg.get_tenant_id(&domain);
let graph_url = cfg.get_graph_url(&domain);
if let Ok(graph) = Graph::new(
&cfg.get_odc_provider(&domain),
&domain,
Some(&authority_host),
tenant_id.as_deref(),
graph_url.as_deref(),
)
.await
{
if let Err(e) =
graph.fetch_user_profile_photo(&access_token, file).await
let icons_dir = "/var/lib/AccountsService/icons/";
if !Path::new(icons_dir).exists() {
info!("Profile photo directory '{}' doesn't exist.", icons_dir);
} else {
let domain = split_username(&access_token).map(|(_, domain)| domain);
account_id = cfg.map_upn_to_name(&account_id);
// Set the profile picture
if let Some(domain) = domain {
match File::create(format!("/var/lib/AccountsService/icons/{}", account_id))
{
Ok(file) => {
let authority_host = cfg.get_authority_host(&domain);
let tenant_id = cfg.get_tenant_id(&domain);
let graph_url = cfg.get_graph_url(&domain);
if let Ok(graph) = Graph::new(
&cfg.get_odc_provider(&domain),
&domain,
Some(&authority_host),
tenant_id.as_deref(),
graph_url.as_deref(),
)
.await
{
error!("Failed fetching user profile photo: {:?}", e);
if let Err(e) =
graph.fetch_user_profile_photo(&access_token, file).await
{
error!("Failed fetching user profile photo: {:?}", e);
}
}
}
Err(e) => {
error!("Failed creating file for user profile photo: {:?}", e)
}
}
Err(e) => error!("Failed creating file for user profile photo: {:?}", e),
}
}

Expand Down

0 comments on commit 8c48655

Please sign in to comment.