Mercurial > crates > nonstick
comparison src/libpam/environ.rs @ 106:49d9e2b5c189
An irresponsible mix of implementing libpam-sys and other stuff.
| author | Paul Fisher <paul@pfish.zone> |
|---|---|
| date | Thu, 26 Jun 2025 22:41:28 -0400 |
| parents | 13b4d2a19674 |
| children | 80c07e5ab22f |
comparison
equal
deleted
inserted
replaced
| 105:13b4d2a19674 | 106:49d9e2b5c189 |
|---|---|
| 31 fn environ_set(&mut self, key: &OsStr, value: Option<&OsStr>) -> Result<Option<OsString>> { | 31 fn environ_set(&mut self, key: &OsStr, value: Option<&OsStr>) -> Result<Option<OsString>> { |
| 32 let old = self.environ_get(key); | 32 let old = self.environ_get(key); |
| 33 if old.is_none() && value.is_none() { | 33 if old.is_none() && value.is_none() { |
| 34 // pam_putenv returns an error if we try to remove a non-existent | 34 // pam_putenv returns an error if we try to remove a non-existent |
| 35 // environment variable, so just avoid that entirely. | 35 // environment variable, so just avoid that entirely. |
| 36 return Ok(None) | 36 return Ok(None); |
| 37 } | 37 } |
| 38 let total_len = key.len() + value.map(OsStr::len).unwrap_or_default() + 2; | 38 let total_len = key.len() + value.map(OsStr::len).unwrap_or_default() + 2; |
| 39 let mut result = Vec::with_capacity(total_len); | 39 let mut result = Vec::with_capacity(total_len); |
| 40 result.extend(key.as_bytes()); | 40 result.extend(key.as_bytes()); |
| 41 if let Some(value) = value { | 41 if let Some(value) = value { |
