Skip to content

Commit

Permalink
utils/codesign: Ignore signtool's non-fatal non-zero exit code
Browse files Browse the repository at this point in the history
  • Loading branch information
derrod committed Jan 29, 2024
1 parent c896b89 commit f809320
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/utils/codesign.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::path::{Path, PathBuf};
use std::process::Command;

use anyhow::{anyhow, Context, Result};
use log::{debug, error, info};
use log::{debug, error, info, warn};
#[cfg(windows)]
use winreg::enums::{HKEY_LOCAL_MACHINE, KEY_READ, KEY_WOW64_32KEY};
#[cfg(windows)]
Expand All @@ -15,6 +15,8 @@ use winreg::RegKey;
use crate::models::config::CodesignOptions;

const MAX_FILES: usize = 20;
// std::process::Output's status is returned as an i32, but on Windows it's a u32
const IGNORE_STATUS: i32 = 0xc0000374u32 as i32;

#[cfg(windows)]
pub fn sign(files: Vec<PathBuf>, opts: &CodesignOptions) -> Result<()> {
Expand Down Expand Up @@ -58,6 +60,11 @@ pub fn sign(files: Vec<PathBuf>, opts: &CodesignOptions) -> Result<()> {
let output = Command::new(&signtool).args(chunk_args).output()?;

if !output.status.success() {
// Annoying error code that seems to only happen *after* successfully signing...
if output.status.code().unwrap() == IGNORE_STATUS {
warn!("signtool returned ignored non-success status: {}", output.status);
continue;
}
error!("signtool returned non-success status: {}", output.status);
std::io::stdout().write_all(&output.stdout)?;
std::io::stderr().write_all(&output.stderr)?;
Expand Down

0 comments on commit f809320

Please sign in to comment.